@solidjs/web 2.0.0-beta.16 → 2.0.0-beta.18

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.
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "commonjs"
3
+ }
package/types/client.d.ts CHANGED
@@ -103,6 +103,19 @@ export function getNextMatch(start: Node, elementName: string): Element;
103
103
  export function getNextMarker(start: Node): [Node, Array<Node>];
104
104
  export function useAssets(fn: () => JSX.Element): void;
105
105
  export function getAssets(): string;
106
+ export type AssetDescriptor =
107
+ | { type: "style"; href: string; attrs?: Record<string, string> }
108
+ | { type: "inline-style"; id: string; content?: string; attrs?: Record<string, string> }
109
+ | { type: "module"; href: string }
110
+ | ExclusiveAssetDescriptor<any>;
111
+ export interface ExclusiveAssetDescriptor<T> {
112
+ policy: "exclusive";
113
+ key: string;
114
+ value: T;
115
+ get(): T;
116
+ set(value: T): void;
117
+ }
118
+ export function acquireAsset(descriptor: AssetDescriptor): () => void;
106
119
  export function HydrationScript(props?: { nonce?: string; eventNames?: string[] }): JSX.Element;
107
120
  export function generateHydrationScript(options?: {
108
121
  nonce?: string;
package/types/index.d.ts CHANGED
@@ -118,6 +118,12 @@ export declare const hydrate: typeof hydrateCore;
118
118
  * still participates in the parent's reactive scope and disposes when the
119
119
  * parent does.
120
120
  *
121
+ * Portals are client-only islands: the server renders nothing for them, and
122
+ * under hydration the children render fresh once hydration settles. Async
123
+ * read inside a portal therefore starts on the client — data that should be
124
+ * fetched on the server belongs above the portal (hoist the read, not the
125
+ * render), and async UI inside one wants its own `<Loading>` boundary.
126
+ *
121
127
  * @example
122
128
  * ```tsx
123
129
  * <Portal mount={document.getElementById("modal-root")!}>
@@ -127,7 +133,7 @@ export declare const hydrate: typeof hydrateCore;
127
133
  *
128
134
  * @description https://docs.solidjs.com/reference/components/portal
129
135
  */
130
- export declare function Portal<T extends boolean = false, S extends boolean = false>(props: {
136
+ export declare function Portal(props: {
131
137
  mount?: Element;
132
138
  children: JSX.Element;
133
139
  }): JSX.Element;
@@ -0,0 +1,97 @@
1
+ import { Plugin, Serializer, SerovalNode } from "seroval";
2
+
3
+ export type { SerovalNode };
4
+
5
+ /** A Seroval plugin usable with the web serializers. */
6
+ export type SerializerPlugin = Plugin<any, any>;
7
+
8
+ /**
9
+ * Baseline plugin set for serializing web-platform values (AbortSignal,
10
+ * Event, FormData, Headers, ReadableStream, Request, Response, URL, ...).
11
+ */
12
+ export const DEFAULT_WEB_PLUGINS: readonly SerializerPlugin[];
13
+
14
+ /**
15
+ * Composes custom plugins with `DEFAULT_WEB_PLUGINS`. Custom plugins come
16
+ * first so they can shadow a default for values both would match. Returns a
17
+ * fresh array; the defaults are never mutated.
18
+ */
19
+ export function resolveSerializerPlugins(customPlugins?: SerializerPlugin[]): SerializerPlugin[];
20
+
21
+ export interface WebSerializerOptions {
22
+ /** Name of the global object the emitted scripts write resolved values into. */
23
+ globalIdentifier: string;
24
+ scopeId?: string;
25
+ /**
26
+ * Seroval feature bitflags to exclude from output. Defaults to disabling
27
+ * post-ES2017 features (AggregateError, BigInt typed arrays).
28
+ */
29
+ disabledFeatures?: number;
30
+ /** Extra plugins, composed ahead of `DEFAULT_WEB_PLUGINS`. */
31
+ plugins?: SerializerPlugin[];
32
+ onData: (result: string) => void;
33
+ onError?: (error: unknown) => void;
34
+ onDone?: () => void;
35
+ }
36
+
37
+ /**
38
+ * Creates a streaming Seroval serializer preconfigured with the web plugin
39
+ * set and the default feature policy.
40
+ */
41
+ export function createSerializer(options: WebSerializerOptions): Serializer;
42
+
43
+ export type HydrationSerializerOptions = Omit<
44
+ WebSerializerOptions,
45
+ "globalIdentifier" | "disabledFeatures"
46
+ >;
47
+
48
+ /**
49
+ * Serializer for SSR hydration output. Pins the hydration global (`_$HY.r`)
50
+ * and feature policy — only the wiring options (callbacks, scope, extra
51
+ * plugins) are configurable.
52
+ */
53
+ export function createHydrationSerializer(options: HydrationSerializerOptions): Serializer;
54
+
55
+ /** Returns the cross-reference bootstrap script for a render scope. */
56
+ export function getLocalHeaderScript(id?: string): string;
57
+
58
+ // ---- JSON codec (server function transports) ----
59
+
60
+ export interface JSONCodecOptions {
61
+ /** Extra plugins, composed ahead of `DEFAULT_WEB_PLUGINS`. Must match on both peers. */
62
+ plugins?: SerializerPlugin[];
63
+ /**
64
+ * Seroval feature bitflags to exclude. Defaults to disabling `RegExp`
65
+ * (payloads may come from an untrusted peer). Must match on both peers.
66
+ */
67
+ disabledFeatures?: number;
68
+ /** Maximum parse/deserialize depth. Defaults to 64. Must match on both peers. */
69
+ depthLimit?: number;
70
+ }
71
+
72
+ export interface JSONSerializeOptions extends JSONCodecOptions {
73
+ /**
74
+ * Receives each serialized node; `initial` is true for the first chunk
75
+ * (the source value itself). Async values produce additional chunks as
76
+ * they resolve.
77
+ */
78
+ onParse: (node: SerovalNode, initial: boolean) => void;
79
+ onError?: (error: unknown) => void;
80
+ /** Fires once all async values have settled. */
81
+ onDone?: () => void;
82
+ }
83
+
84
+ /**
85
+ * Serializes `value` as SerovalNode chunks delivered through `onParse`.
86
+ * Wire framing of the nodes is the transport's concern. Returns a cancel
87
+ * function that aborts pending async serialization.
88
+ */
89
+ export function serializeJSON(value: unknown, options: JSONSerializeOptions): () => void;
90
+
91
+ /**
92
+ * Creates the decoding counterpart of `serializeJSON`. Cross-references
93
+ * between chunks resolve through state shared across calls, so all chunks
94
+ * from one stream must go through the same deserializer instance. The first
95
+ * chunk's return value is the decoded source value.
96
+ */
97
+ export function createJSONDeserializer(options?: JSONCodecOptions): <T>(node: SerovalNode) => T;
package/types/server.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { JSX } from "./jsx.js";
2
+ import { SerializerPlugin } from "./serializer.js";
2
3
  export const DOMWithState: Record<string, Record<string, 1 | 2>>;
3
4
  export const ChildProperties: Set<string>;
4
5
  export const DelegatedEvents: Set<string>;
@@ -11,17 +12,59 @@ export const Namespaces: Record<string, string>;
11
12
 
12
13
  type MountableElement = Element | Document | ShadowRoot | DocumentFragment | Node;
13
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
+
14
60
  export function renderToString<T>(
15
61
  fn: () => T,
16
62
  options?: {
17
63
  nonce?: string;
18
64
  renderId?: string;
19
65
  noScripts?: boolean;
20
- plugins?: any[];
21
- manifest?: Record<
22
- string,
23
- { file: string; css?: string[]; isEntry?: boolean; imports?: string[] }
24
- > & { _base?: string };
66
+ plugins?: SerializerPlugin[];
67
+ manifest?: AssetManifest | AssetResolver | AssetResolverFn;
25
68
  onError?: (err: any) => void;
26
69
  }
27
70
  ): string;
@@ -33,11 +76,8 @@ export function renderToStringAsync<T>(
33
76
  nonce?: string;
34
77
  renderId?: string;
35
78
  noScripts?: boolean;
36
- plugins?: any[];
37
- manifest?: Record<
38
- string,
39
- { file: string; css?: string[]; isEntry?: boolean; imports?: string[] }
40
- > & { _base?: string };
79
+ plugins?: SerializerPlugin[];
80
+ manifest?: AssetManifest | AssetResolver | AssetResolverFn;
41
81
  onError?: (err: any) => void;
42
82
  }
43
83
  ): Promise<string>;
@@ -47,11 +87,8 @@ export function renderToStream<T>(
47
87
  nonce?: string;
48
88
  renderId?: string;
49
89
  noScripts?: boolean;
50
- plugins?: any[];
51
- manifest?: Record<
52
- string,
53
- { file: string; css?: string[]; isEntry?: boolean; imports?: string[] }
54
- > & { _base?: string };
90
+ plugins?: SerializerPlugin[];
91
+ manifest?: AssetManifest | AssetResolver | AssetResolverFn;
55
92
  onCompleteShell?: (info: { write: (v: string) => void }) => void;
56
93
  onCompleteAll?: (info: { write: (v: string) => void }) => void;
57
94
  onError?: (err: any) => void;
@@ -192,3 +229,5 @@ export function ref(
192
229
  ): void;
193
230
  /** @deprecated not supported on the server side */
194
231
  export function setStyleProperty(node: Element, name: string, value: any): void;
232
+ /** @deprecated not supported on the server side — register assets through the render context instead */
233
+ export function acquireAsset(descriptor: unknown): () => void;
@@ -103,6 +103,19 @@ export function getNextMatch(start: Node, elementName: string): Element;
103
103
  export function getNextMarker(start: Node): [Node, Array<Node>];
104
104
  export function useAssets(fn: () => JSX.Element): void;
105
105
  export function getAssets(): string;
106
+ export type AssetDescriptor =
107
+ | { type: "style"; href: string; attrs?: Record<string, string> }
108
+ | { type: "inline-style"; id: string; content?: string; attrs?: Record<string, string> }
109
+ | { type: "module"; href: string }
110
+ | ExclusiveAssetDescriptor<any>;
111
+ export interface ExclusiveAssetDescriptor<T> {
112
+ policy: "exclusive";
113
+ key: string;
114
+ value: T;
115
+ get(): T;
116
+ set(value: T): void;
117
+ }
118
+ export function acquireAsset(descriptor: AssetDescriptor): () => void;
106
119
  export function HydrationScript(props?: { nonce?: string; eventNames?: string[] }): JSX.Element;
107
120
  export function generateHydrationScript(options?: {
108
121
  nonce?: string;
@@ -118,6 +118,12 @@ export declare const hydrate: typeof hydrateCore;
118
118
  * still participates in the parent's reactive scope and disposes when the
119
119
  * parent does.
120
120
  *
121
+ * Portals are client-only islands: the server renders nothing for them, and
122
+ * under hydration the children render fresh once hydration settles. Async
123
+ * read inside a portal therefore starts on the client — data that should be
124
+ * fetched on the server belongs above the portal (hoist the read, not the
125
+ * render), and async UI inside one wants its own `<Loading>` boundary.
126
+ *
121
127
  * @example
122
128
  * ```tsx
123
129
  * <Portal mount={document.getElementById("modal-root")!}>
@@ -127,7 +133,7 @@ export declare const hydrate: typeof hydrateCore;
127
133
  *
128
134
  * @description https://docs.solidjs.com/reference/components/portal
129
135
  */
130
- export declare function Portal<T extends boolean = false, S extends boolean = false>(props: {
136
+ export declare function Portal(props: {
131
137
  mount?: Element;
132
138
  children: JSX.Element;
133
139
  }): JSX.Element;
@@ -0,0 +1,97 @@
1
+ import { Plugin, Serializer, SerovalNode } from "seroval";
2
+
3
+ export type { SerovalNode };
4
+
5
+ /** A Seroval plugin usable with the web serializers. */
6
+ export type SerializerPlugin = Plugin<any, any>;
7
+
8
+ /**
9
+ * Baseline plugin set for serializing web-platform values (AbortSignal,
10
+ * Event, FormData, Headers, ReadableStream, Request, Response, URL, ...).
11
+ */
12
+ export const DEFAULT_WEB_PLUGINS: readonly SerializerPlugin[];
13
+
14
+ /**
15
+ * Composes custom plugins with `DEFAULT_WEB_PLUGINS`. Custom plugins come
16
+ * first so they can shadow a default for values both would match. Returns a
17
+ * fresh array; the defaults are never mutated.
18
+ */
19
+ export function resolveSerializerPlugins(customPlugins?: SerializerPlugin[]): SerializerPlugin[];
20
+
21
+ export interface WebSerializerOptions {
22
+ /** Name of the global object the emitted scripts write resolved values into. */
23
+ globalIdentifier: string;
24
+ scopeId?: string;
25
+ /**
26
+ * Seroval feature bitflags to exclude from output. Defaults to disabling
27
+ * post-ES2017 features (AggregateError, BigInt typed arrays).
28
+ */
29
+ disabledFeatures?: number;
30
+ /** Extra plugins, composed ahead of `DEFAULT_WEB_PLUGINS`. */
31
+ plugins?: SerializerPlugin[];
32
+ onData: (result: string) => void;
33
+ onError?: (error: unknown) => void;
34
+ onDone?: () => void;
35
+ }
36
+
37
+ /**
38
+ * Creates a streaming Seroval serializer preconfigured with the web plugin
39
+ * set and the default feature policy.
40
+ */
41
+ export function createSerializer(options: WebSerializerOptions): Serializer;
42
+
43
+ export type HydrationSerializerOptions = Omit<
44
+ WebSerializerOptions,
45
+ "globalIdentifier" | "disabledFeatures"
46
+ >;
47
+
48
+ /**
49
+ * Serializer for SSR hydration output. Pins the hydration global (`_$HY.r`)
50
+ * and feature policy — only the wiring options (callbacks, scope, extra
51
+ * plugins) are configurable.
52
+ */
53
+ export function createHydrationSerializer(options: HydrationSerializerOptions): Serializer;
54
+
55
+ /** Returns the cross-reference bootstrap script for a render scope. */
56
+ export function getLocalHeaderScript(id?: string): string;
57
+
58
+ // ---- JSON codec (server function transports) ----
59
+
60
+ export interface JSONCodecOptions {
61
+ /** Extra plugins, composed ahead of `DEFAULT_WEB_PLUGINS`. Must match on both peers. */
62
+ plugins?: SerializerPlugin[];
63
+ /**
64
+ * Seroval feature bitflags to exclude. Defaults to disabling `RegExp`
65
+ * (payloads may come from an untrusted peer). Must match on both peers.
66
+ */
67
+ disabledFeatures?: number;
68
+ /** Maximum parse/deserialize depth. Defaults to 64. Must match on both peers. */
69
+ depthLimit?: number;
70
+ }
71
+
72
+ export interface JSONSerializeOptions extends JSONCodecOptions {
73
+ /**
74
+ * Receives each serialized node; `initial` is true for the first chunk
75
+ * (the source value itself). Async values produce additional chunks as
76
+ * they resolve.
77
+ */
78
+ onParse: (node: SerovalNode, initial: boolean) => void;
79
+ onError?: (error: unknown) => void;
80
+ /** Fires once all async values have settled. */
81
+ onDone?: () => void;
82
+ }
83
+
84
+ /**
85
+ * Serializes `value` as SerovalNode chunks delivered through `onParse`.
86
+ * Wire framing of the nodes is the transport's concern. Returns a cancel
87
+ * function that aborts pending async serialization.
88
+ */
89
+ export function serializeJSON(value: unknown, options: JSONSerializeOptions): () => void;
90
+
91
+ /**
92
+ * Creates the decoding counterpart of `serializeJSON`. Cross-references
93
+ * between chunks resolve through state shared across calls, so all chunks
94
+ * from one stream must go through the same deserializer instance. The first
95
+ * chunk's return value is the decoded source value.
96
+ */
97
+ export function createJSONDeserializer(options?: JSONCodecOptions): <T>(node: SerovalNode) => T;
@@ -1,4 +1,5 @@
1
1
  import { JSX } from "./jsx.cjs";
2
+ import { SerializerPlugin } from "./serializer.cjs";
2
3
  export const DOMWithState: Record<string, Record<string, 1 | 2>>;
3
4
  export const ChildProperties: Set<string>;
4
5
  export const DelegatedEvents: Set<string>;
@@ -11,17 +12,59 @@ export const Namespaces: Record<string, string>;
11
12
 
12
13
  type MountableElement = Element | Document | ShadowRoot | DocumentFragment | Node;
13
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
+
14
60
  export function renderToString<T>(
15
61
  fn: () => T,
16
62
  options?: {
17
63
  nonce?: string;
18
64
  renderId?: string;
19
65
  noScripts?: boolean;
20
- plugins?: any[];
21
- manifest?: Record<
22
- string,
23
- { file: string; css?: string[]; isEntry?: boolean; imports?: string[] }
24
- > & { _base?: string };
66
+ plugins?: SerializerPlugin[];
67
+ manifest?: AssetManifest | AssetResolver | AssetResolverFn;
25
68
  onError?: (err: any) => void;
26
69
  }
27
70
  ): string;
@@ -33,11 +76,8 @@ export function renderToStringAsync<T>(
33
76
  nonce?: string;
34
77
  renderId?: string;
35
78
  noScripts?: boolean;
36
- plugins?: any[];
37
- manifest?: Record<
38
- string,
39
- { file: string; css?: string[]; isEntry?: boolean; imports?: string[] }
40
- > & { _base?: string };
79
+ plugins?: SerializerPlugin[];
80
+ manifest?: AssetManifest | AssetResolver | AssetResolverFn;
41
81
  onError?: (err: any) => void;
42
82
  }
43
83
  ): Promise<string>;
@@ -47,11 +87,8 @@ export function renderToStream<T>(
47
87
  nonce?: string;
48
88
  renderId?: string;
49
89
  noScripts?: boolean;
50
- plugins?: any[];
51
- manifest?: Record<
52
- string,
53
- { file: string; css?: string[]; isEntry?: boolean; imports?: string[] }
54
- > & { _base?: string };
90
+ plugins?: SerializerPlugin[];
91
+ manifest?: AssetManifest | AssetResolver | AssetResolverFn;
55
92
  onCompleteShell?: (info: { write: (v: string) => void }) => void;
56
93
  onCompleteAll?: (info: { write: (v: string) => void }) => void;
57
94
  onError?: (err: any) => void;
@@ -192,3 +229,5 @@ export function ref(
192
229
  ): void;
193
230
  /** @deprecated not supported on the server side */
194
231
  export function setStyleProperty(node: Element, name: string, value: any): void;
232
+ /** @deprecated not supported on the server side — register assets through the render context instead */
233
+ export function acquireAsset(descriptor: unknown): () => void;
@@ -1 +0,0 @@
1
- export * from "@dom-expressions/runtime/src/client.js";
@@ -1,171 +0,0 @@
1
- import { hydrate as hydrateCore } from "./client.js";
2
- import { Component } from "solid-js";
3
- import type { JSX } from "./jsx.js";
4
- export * from "./client.js";
5
- export * from "./server-mock.js";
6
- export type { JSX } from "./jsx.js";
7
- export { For, Show, Switch, Match, Errored, Loading, Repeat, Reveal, NoHydration, Hydration } from "solid-js";
8
- import { merge } from "solid-js";
9
- /**
10
- * Compiler-emitted prop-spread helper. The JSX transform (in
11
- * `dom-expressions`) emits `mergeProps(...)` calls when compiling prop
12
- * spreads on components — it is *not* a user-facing API. Application code
13
- * should import `merge` from `solid-js` directly.
14
- *
15
- * @internal
16
- */
17
- export declare const mergeProps: typeof merge;
18
- /**
19
- * Build-time constant indicating whether code is running on the server. This
20
- * client entry sets it to `false`; the matching server entry (`@solidjs/web`
21
- * resolved through the `solid` server export condition) sets it to `true`.
22
- *
23
- * Bundlers can dead-code-eliminate branches gated on `isServer`, so guarding
24
- * browser-only code with `if (!isServer) {…}` keeps it out of the SSR bundle
25
- * entirely.
26
- *
27
- * @example
28
- * ```ts
29
- * import { isServer } from "@solidjs/web";
30
- *
31
- * if (!isServer) {
32
- * // Browser-only: tree-shaken out of the SSR bundle.
33
- * window.addEventListener("resize", onResize);
34
- * }
35
- * ```
36
- */
37
- export declare const isServer: boolean;
38
- /**
39
- * Build-time constant indicating whether code is running in a dev build.
40
- * Replaced statically (`_SOLID_DEV_`) by the bundler integration, so guards
41
- * like `if (isDev) {…}` are stripped from production builds.
42
- *
43
- * Use this to gate dev-only diagnostics, warnings, or expensive invariants
44
- * that should never ship to production.
45
- *
46
- * @example
47
- * ```ts
48
- * import { isDev } from "@solidjs/web";
49
- *
50
- * if (isDev) {
51
- * console.warn("debug-only path");
52
- * }
53
- * ```
54
- */
55
- export declare const isDev: boolean;
56
- type MountableElement = Element | Document | ShadowRoot | DocumentFragment | Node;
57
- export type IntrinsicElement = Extract<keyof JSX.IntrinsicElements, string>;
58
- export type ValidComponent = IntrinsicElement | Component<any> | (string & {});
59
- export type ComponentProps<T extends ValidComponent> = T extends Component<infer P> ? P : T extends keyof JSX.IntrinsicElements ? JSX.IntrinsicElements[T] : Record<string, unknown>;
60
- export type DynamicProps<T extends ValidComponent, P = ComponentProps<T>> = {
61
- [K in keyof P]: P[K];
62
- } & {
63
- component: T | null | undefined | false;
64
- };
65
- /**
66
- * Renders a component tree into a DOM element. Returns a dispose function
67
- * that tears the tree down and cleans up reactive scopes when called.
68
- *
69
- * @example
70
- * ```tsx
71
- * import { render } from "@solidjs/web";
72
- *
73
- * const dispose = render(() => <App />, document.getElementById("root")!);
74
- *
75
- * // Later, to unmount:
76
- * dispose();
77
- * ```
78
- *
79
- * @remarks
80
- * The top-level insert is queued via `insertOptions: { schedule: true }` so
81
- * its initial DOM attach goes through the effect queue rather than executing
82
- * inline. This lets the mount participate in transitions: if an uncaught
83
- * async read surfaces during the initial render (no `Loading` ancestor
84
- * absorbs it), the mount is held by the transition and attaches atomically
85
- * once all pending settles. On the no-async happy path the tail `flush()`
86
- * drains the queued callback so the attach is synchronous by the time
87
- * `render()` returns. The dev enforcement window scopes
88
- * `ASYNC_OUTSIDE_LOADING_BOUNDARY` to the initial mount only.
89
- */
90
- export declare function render(code: () => JSX.Element, element: MountableElement, init?: unknown, options?: {
91
- renderId?: string;
92
- }): () => void;
93
- /**
94
- * Resumes a server-rendered tree on the client, attaching event listeners
95
- * and reactive bindings without reconstructing the DOM. Returns a `dispose`
96
- * function that tears down reactive scopes (DOM nodes are left in place).
97
- *
98
- * Use this when the page HTML was produced by `renderToString`,
99
- * `renderToStringAsync`, or `renderToStream`. For client-only apps, use
100
- * `render` instead.
101
- *
102
- * Pass `options.renderId` to hydrate one of multiple roots emitted by a
103
- * server render that used the same id.
104
- *
105
- * @example
106
- * ```tsx
107
- * import { hydrate } from "@solidjs/web";
108
- *
109
- * hydrate(() => <App />, document.getElementById("root")!);
110
- * ```
111
- */
112
- export declare const hydrate: typeof hydrateCore;
113
- /**
114
- * Renders its children into a different part of the DOM (modal roots,
115
- * tooltips, layers that need to escape an `overflow: hidden` ancestor).
116
- *
117
- * If `mount` is omitted, the portal attaches to `document.body`. The portal
118
- * still participates in the parent's reactive scope and disposes when the
119
- * parent does.
120
- *
121
- * @example
122
- * ```tsx
123
- * <Portal mount={document.getElementById("modal-root")!}>
124
- * <Dialog />
125
- * </Portal>
126
- * ```
127
- *
128
- * @description https://docs.solidjs.com/reference/components/portal
129
- */
130
- export declare function Portal<T extends boolean = false, S extends boolean = false>(props: {
131
- mount?: Element;
132
- children: JSX.Element;
133
- }): JSX.Element;
134
- /**
135
- * Returns a stable `Component` whose identity is driven by a reactive (and
136
- * optionally async) `source`. The returned component can be used anywhere a
137
- * normal component is used; children and props flow through JSX as usual.
138
- *
139
- * `source` may return a component, a native tag name (`'input'`, `'textarea'`,
140
- * etc.), `undefined`, or a `Promise` of any of the above. A pending promise
141
- * propagates as `NotReadyError` through the surrounding reactive scope, so
142
- * async swaps compose with `<Loading>` boundaries the same way as `lazy`.
143
- *
144
- * @example
145
- * ```tsx
146
- * // `source` can return either a custom Component or a native tag
147
- * // name — they're interchangeable, and the returned reference is a
148
- * // stable Component you can use anywhere a normal one would go.
149
- * const Field = dynamic(() => multiline() ? RichTextEditor : "input");
150
- * return <Field value={value()} onInput={onInput} />;
151
- * ```
152
- *
153
- * @description https://docs.solidjs.com/reference/components/dynamic
154
- */
155
- export declare function dynamic<T extends ValidComponent>(source: () => T | Promise<T> | null | undefined | false): Component<ComponentProps<T>>;
156
- /**
157
- * Renders an arbitrary custom or native component and forwards the other
158
- * props. JSX form of `dynamic()` — same primitive, picked at the JSX site.
159
- *
160
- * @example
161
- * ```tsx
162
- * <Dynamic
163
- * component={multiline() ? RichTextEditor : "input"}
164
- * value={value()}
165
- * onInput={onInput}
166
- * />
167
- * ```
168
- *
169
- * @description https://docs.solidjs.com/reference/components/dynamic
170
- */
171
- export declare function Dynamic<T extends ValidComponent>(props: DynamicProps<T>): JSX.Element;