@solidjs/web 2.0.0-beta.8 → 2.0.0-beta.9
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/README.md +27 -4
- package/dist/dev.cjs +61 -55
- package/dist/dev.js +61 -57
- package/dist/server.cjs +24 -21
- package/dist/server.js +23 -22
- package/dist/web.cjs +56 -47
- package/dist/web.js +56 -49
- package/package.json +6 -7
- package/storage/types/src/index.d.ts +69 -20
- package/storage/types/src/server-mock.d.ts +57 -0
- package/storage/types-cjs/src/index.d.cts +69 -20
- package/storage/types-cjs/src/server-mock.d.cts +57 -0
- package/types/client.d.ts +2 -0
- package/types/core.d.ts +1 -1
- package/types/index.d.ts +69 -20
- package/types/server-mock.d.ts +57 -0
- package/types/server.d.ts +2 -0
- package/types-cjs/client.d.cts +2 -0
- package/types-cjs/core.d.cts +1 -1
- package/types-cjs/index.d.cts +69 -20
- package/types-cjs/server-mock.d.cts +57 -0
- package/types-cjs/server.d.cts +2 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { hydrate as hydrateCore } from "./client.js";
|
|
2
|
-
import { JSX, ComponentProps, ValidComponent } from "solid-js";
|
|
2
|
+
import { JSX, Component, ComponentProps, ValidComponent } from "solid-js";
|
|
3
3
|
export * from "./client.js";
|
|
4
4
|
export * from "./server-mock.js";
|
|
5
5
|
export { For, Show, Switch, Match, Errored, Loading, Repeat, Reveal, NoHydration, Hydration, merge as mergeProps } from "solid-js";
|
|
@@ -9,27 +9,70 @@ type MountableElement = Element | Document | ShadowRoot | DocumentFragment | Nod
|
|
|
9
9
|
export type DynamicProps<T extends ValidComponent, P = ComponentProps<T>> = {
|
|
10
10
|
[K in keyof P]: P[K];
|
|
11
11
|
} & {
|
|
12
|
-
component: T | undefined;
|
|
12
|
+
component: T | null | undefined | false;
|
|
13
13
|
};
|
|
14
14
|
/**
|
|
15
|
-
* Renders a component tree into a DOM element
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
15
|
+
* Renders a component tree into a DOM element. Returns a dispose function
|
|
16
|
+
* that tears the tree down and cleans up reactive scopes when called.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```tsx
|
|
20
|
+
* import { render } from "@solidjs/web";
|
|
21
|
+
*
|
|
22
|
+
* const dispose = render(() => <App />, document.getElementById("root")!);
|
|
23
|
+
*
|
|
24
|
+
* // Later, to unmount:
|
|
25
|
+
* dispose();
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* @remarks
|
|
29
|
+
* The top-level insert is queued via `insertOptions: { schedule: true }` so
|
|
30
|
+
* its initial DOM attach goes through the effect queue rather than executing
|
|
31
|
+
* inline. This lets the mount participate in transitions: if an uncaught
|
|
32
|
+
* async read surfaces during the initial render (no `Loading` ancestor
|
|
33
|
+
* absorbs it), the mount is held by the transition and attaches atomically
|
|
34
|
+
* once all pending settles. On the no-async happy path the tail `flush()`
|
|
35
|
+
* drains the queued callback so the attach is synchronous by the time
|
|
36
|
+
* `render()` returns. The dev enforcement window scopes
|
|
37
|
+
* `ASYNC_OUTSIDE_LOADING_BOUNDARY` to the initial mount only.
|
|
24
38
|
*/
|
|
25
39
|
export declare function render(code: () => JSX.Element, element: MountableElement, init?: unknown, options?: {
|
|
26
40
|
renderId?: string;
|
|
27
41
|
}): () => void;
|
|
42
|
+
/**
|
|
43
|
+
* Resumes a server-rendered tree on the client, attaching event listeners
|
|
44
|
+
* and reactive bindings without reconstructing the DOM. Returns a `dispose`
|
|
45
|
+
* function that tears down reactive scopes (DOM nodes are left in place).
|
|
46
|
+
*
|
|
47
|
+
* Use this when the page HTML was produced by `renderToString`,
|
|
48
|
+
* `renderToStringAsync`, or `renderToStream`. For client-only apps, use
|
|
49
|
+
* `render` instead.
|
|
50
|
+
*
|
|
51
|
+
* Pass `options.renderId` to hydrate one of multiple roots emitted by a
|
|
52
|
+
* server render that used the same id.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```tsx
|
|
56
|
+
* import { hydrate } from "@solidjs/web";
|
|
57
|
+
*
|
|
58
|
+
* hydrate(() => <App />, document.getElementById("root")!);
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
28
61
|
export declare const hydrate: typeof hydrateCore;
|
|
29
62
|
/**
|
|
30
|
-
* Renders
|
|
63
|
+
* Renders its children into a different part of the DOM (modal roots,
|
|
64
|
+
* tooltips, layers that need to escape an `overflow: hidden` ancestor).
|
|
31
65
|
*
|
|
32
|
-
*
|
|
66
|
+
* If `mount` is omitted, the portal attaches to `document.body`. The portal
|
|
67
|
+
* still participates in the parent's reactive scope and disposes when the
|
|
68
|
+
* parent does.
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```tsx
|
|
72
|
+
* <Portal mount={document.getElementById("modal-root")!}>
|
|
73
|
+
* <Dialog />
|
|
74
|
+
* </Portal>
|
|
75
|
+
* ```
|
|
33
76
|
*
|
|
34
77
|
* @description https://docs.solidjs.com/reference/components/portal
|
|
35
78
|
*/
|
|
@@ -38,18 +81,24 @@ export declare function Portal<T extends boolean = false, S extends boolean = fa
|
|
|
38
81
|
children: JSX.Element;
|
|
39
82
|
}): Text;
|
|
40
83
|
/**
|
|
41
|
-
*
|
|
84
|
+
* Returns a stable `Component` whose identity is driven by a reactive (and
|
|
85
|
+
* optionally async) `source`. The returned component can be used anywhere a
|
|
86
|
+
* normal component is used; children and props flow through JSX as usual.
|
|
87
|
+
*
|
|
88
|
+
* `source` may return a component, a native tag name (`'input'`, `'textarea'`,
|
|
89
|
+
* etc.), `undefined`, or a `Promise` of any of the above. A pending promise
|
|
90
|
+
* propagates as `NotReadyError` through the surrounding reactive scope, so
|
|
91
|
+
* async swaps compose with `Loading`/Suspense boundaries the same way as
|
|
92
|
+
* `lazy`.
|
|
42
93
|
*
|
|
43
|
-
* This is a lower level version of the `Dynamic` component, useful for
|
|
44
|
-
* performance optimizations in libraries. Do not use this unless you know
|
|
45
|
-
* what you are doing.
|
|
46
94
|
* ```typescript
|
|
47
|
-
* const
|
|
48
|
-
*
|
|
95
|
+
* const User = dynamic(() => getUserComp(props.id));
|
|
96
|
+
* return <User>client content</User>;
|
|
49
97
|
* ```
|
|
98
|
+
*
|
|
50
99
|
* @description https://docs.solidjs.com/reference/components/dynamic
|
|
51
100
|
*/
|
|
52
|
-
export declare function
|
|
101
|
+
export declare function dynamic<T extends ValidComponent>(source: () => T | Promise<T> | null | undefined | false): Component<ComponentProps<T>>;
|
|
53
102
|
/**
|
|
54
103
|
* Renders an arbitrary custom or native component and passes the other props
|
|
55
104
|
* ```typescript
|
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Renders a component tree synchronously to an HTML string. Async reads inside
|
|
3
|
+
* `<Loading>` boundaries emit their `fallback` content; for full-graph
|
|
4
|
+
* resolution use `renderToStringAsync` instead.
|
|
5
|
+
*
|
|
6
|
+
* Pair the returned HTML with `hydrate()` on the client.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```tsx
|
|
10
|
+
* import { renderToString } from "@solidjs/web";
|
|
11
|
+
*
|
|
12
|
+
* const html = renderToString(() => <App />);
|
|
13
|
+
* res.send(`<!doctype html><html><body><div id="root">${html}</div></body></html>`);
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
1
16
|
export declare function renderToString<T>(fn: () => T, options?: {
|
|
2
17
|
nonce?: string;
|
|
3
18
|
renderId?: string;
|
|
@@ -12,6 +27,21 @@ export declare function renderToString<T>(fn: () => T, options?: {
|
|
|
12
27
|
}>;
|
|
13
28
|
onError?: (err: any) => void;
|
|
14
29
|
}): string;
|
|
30
|
+
/**
|
|
31
|
+
* Renders a component tree to an HTML string and awaits all async reads in the
|
|
32
|
+
* subtree before resolving. The returned HTML reflects the fully-settled state
|
|
33
|
+
* — no `<Loading>` fallbacks appear in the output.
|
|
34
|
+
*
|
|
35
|
+
* Use this when you want a complete page in one round-trip. For incremental
|
|
36
|
+
* streaming with progressive boundary resolution, use `renderToStream`.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```tsx
|
|
40
|
+
* import { renderToStringAsync } from "@solidjs/web";
|
|
41
|
+
*
|
|
42
|
+
* const html = await renderToStringAsync(() => <App />);
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
15
45
|
export declare function renderToStringAsync<T>(fn: () => T, options?: {
|
|
16
46
|
timeoutMs?: number;
|
|
17
47
|
nonce?: string;
|
|
@@ -27,6 +57,25 @@ export declare function renderToStringAsync<T>(fn: () => T, options?: {
|
|
|
27
57
|
}>;
|
|
28
58
|
onError?: (err: any) => void;
|
|
29
59
|
}): Promise<string>;
|
|
60
|
+
/**
|
|
61
|
+
* Streams an HTML response, flushing the synchronous shell first and then
|
|
62
|
+
* progressively emitting async-resolved fragments as their `<Loading>`
|
|
63
|
+
* boundaries settle. Good for time-to-first-byte sensitive pages.
|
|
64
|
+
*
|
|
65
|
+
* Returns an object with `pipe`/`pipeTo` for piping to a Node `Writable` or
|
|
66
|
+
* a Web `WritableStream`, plus a `then` for awaiting full completion.
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```tsx
|
|
70
|
+
* import { renderToStream } from "@solidjs/web";
|
|
71
|
+
*
|
|
72
|
+
* // Node:
|
|
73
|
+
* renderToStream(() => <App />).pipe(res);
|
|
74
|
+
*
|
|
75
|
+
* // Web (Workers / Deno):
|
|
76
|
+
* await renderToStream(() => <App />).pipeTo(stream.writable);
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
30
79
|
export declare function renderToStream<T>(fn: () => T, options?: {
|
|
31
80
|
nonce?: string;
|
|
32
81
|
renderId?: string;
|
|
@@ -54,19 +103,27 @@ export declare function renderToStream<T>(fn: () => T, options?: {
|
|
|
54
103
|
}) => void;
|
|
55
104
|
pipeTo: (writable: WritableStream) => Promise<void>;
|
|
56
105
|
};
|
|
106
|
+
/** Compiler primitive — emitted by JSX-DOM-Expressions for tagged-template SSR output. Not meant for hand-written code. */
|
|
57
107
|
export declare function ssr(template: string[] | string, ...nodes: any[]): {
|
|
58
108
|
t: string;
|
|
59
109
|
};
|
|
110
|
+
/** Compiler primitive — emitted by JSX-DOM-Expressions for SSR element output. Not meant for hand-written code. */
|
|
60
111
|
export declare function ssrElement(name: string, props: any, children: any, needsId: boolean): {
|
|
61
112
|
t: string;
|
|
62
113
|
};
|
|
114
|
+
/** Compiler primitive — serializes a classList object for SSR output. Not meant for hand-written code. */
|
|
63
115
|
export declare function ssrClassList(value: {
|
|
64
116
|
[k: string]: boolean;
|
|
65
117
|
}): string;
|
|
118
|
+
/** Compiler primitive — serializes a style object for SSR output. Not meant for hand-written code. */
|
|
66
119
|
export declare function ssrStyle(value: {
|
|
67
120
|
[k: string]: string;
|
|
68
121
|
}): string;
|
|
122
|
+
/** Compiler primitive — serializes a boolean attribute for SSR output. Not meant for hand-written code. */
|
|
69
123
|
export declare function ssrAttribute(key: string, value: boolean): string;
|
|
124
|
+
/** Compiler primitive — generates the hydration-key attribute for SSR output. Not meant for hand-written code. */
|
|
70
125
|
export declare function ssrHydrationKey(): string;
|
|
126
|
+
/** Compiler primitive — collapses an SSR-shaped node into its HTML string. Not meant for hand-written code. */
|
|
71
127
|
export declare function resolveSSRNode(node: any): string;
|
|
128
|
+
/** Escapes a string for safe inclusion in HTML output. Useful when constructing SSR fragments by hand. */
|
|
72
129
|
export declare function escape(html: string): string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { hydrate as hydrateCore } from "./client.cjs";
|
|
2
|
-
import { JSX, ComponentProps, ValidComponent } from "solid-js";
|
|
2
|
+
import { JSX, Component, ComponentProps, ValidComponent } from "solid-js";
|
|
3
3
|
export * from "./client.cjs";
|
|
4
4
|
export * from "./server-mock.cjs";
|
|
5
5
|
export { For, Show, Switch, Match, Errored, Loading, Repeat, Reveal, NoHydration, Hydration, merge as mergeProps } from "solid-js";
|
|
@@ -9,27 +9,70 @@ type MountableElement = Element | Document | ShadowRoot | DocumentFragment | Nod
|
|
|
9
9
|
export type DynamicProps<T extends ValidComponent, P = ComponentProps<T>> = {
|
|
10
10
|
[K in keyof P]: P[K];
|
|
11
11
|
} & {
|
|
12
|
-
component: T | undefined;
|
|
12
|
+
component: T | null | undefined | false;
|
|
13
13
|
};
|
|
14
14
|
/**
|
|
15
|
-
* Renders a component tree into a DOM element
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
15
|
+
* Renders a component tree into a DOM element. Returns a dispose function
|
|
16
|
+
* that tears the tree down and cleans up reactive scopes when called.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```tsx
|
|
20
|
+
* import { render } from "@solidjs/web";
|
|
21
|
+
*
|
|
22
|
+
* const dispose = render(() => <App />, document.getElementById("root")!);
|
|
23
|
+
*
|
|
24
|
+
* // Later, to unmount:
|
|
25
|
+
* dispose();
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* @remarks
|
|
29
|
+
* The top-level insert is queued via `insertOptions: { schedule: true }` so
|
|
30
|
+
* its initial DOM attach goes through the effect queue rather than executing
|
|
31
|
+
* inline. This lets the mount participate in transitions: if an uncaught
|
|
32
|
+
* async read surfaces during the initial render (no `Loading` ancestor
|
|
33
|
+
* absorbs it), the mount is held by the transition and attaches atomically
|
|
34
|
+
* once all pending settles. On the no-async happy path the tail `flush()`
|
|
35
|
+
* drains the queued callback so the attach is synchronous by the time
|
|
36
|
+
* `render()` returns. The dev enforcement window scopes
|
|
37
|
+
* `ASYNC_OUTSIDE_LOADING_BOUNDARY` to the initial mount only.
|
|
24
38
|
*/
|
|
25
39
|
export declare function render(code: () => JSX.Element, element: MountableElement, init?: unknown, options?: {
|
|
26
40
|
renderId?: string;
|
|
27
41
|
}): () => void;
|
|
42
|
+
/**
|
|
43
|
+
* Resumes a server-rendered tree on the client, attaching event listeners
|
|
44
|
+
* and reactive bindings without reconstructing the DOM. Returns a `dispose`
|
|
45
|
+
* function that tears down reactive scopes (DOM nodes are left in place).
|
|
46
|
+
*
|
|
47
|
+
* Use this when the page HTML was produced by `renderToString`,
|
|
48
|
+
* `renderToStringAsync`, or `renderToStream`. For client-only apps, use
|
|
49
|
+
* `render` instead.
|
|
50
|
+
*
|
|
51
|
+
* Pass `options.renderId` to hydrate one of multiple roots emitted by a
|
|
52
|
+
* server render that used the same id.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```tsx
|
|
56
|
+
* import { hydrate } from "@solidjs/web";
|
|
57
|
+
*
|
|
58
|
+
* hydrate(() => <App />, document.getElementById("root")!);
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
28
61
|
export declare const hydrate: typeof hydrateCore;
|
|
29
62
|
/**
|
|
30
|
-
* Renders
|
|
63
|
+
* Renders its children into a different part of the DOM (modal roots,
|
|
64
|
+
* tooltips, layers that need to escape an `overflow: hidden` ancestor).
|
|
31
65
|
*
|
|
32
|
-
*
|
|
66
|
+
* If `mount` is omitted, the portal attaches to `document.body`. The portal
|
|
67
|
+
* still participates in the parent's reactive scope and disposes when the
|
|
68
|
+
* parent does.
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```tsx
|
|
72
|
+
* <Portal mount={document.getElementById("modal-root")!}>
|
|
73
|
+
* <Dialog />
|
|
74
|
+
* </Portal>
|
|
75
|
+
* ```
|
|
33
76
|
*
|
|
34
77
|
* @description https://docs.solidjs.com/reference/components/portal
|
|
35
78
|
*/
|
|
@@ -38,18 +81,24 @@ export declare function Portal<T extends boolean = false, S extends boolean = fa
|
|
|
38
81
|
children: JSX.Element;
|
|
39
82
|
}): Text;
|
|
40
83
|
/**
|
|
41
|
-
*
|
|
84
|
+
* Returns a stable `Component` whose identity is driven by a reactive (and
|
|
85
|
+
* optionally async) `source`. The returned component can be used anywhere a
|
|
86
|
+
* normal component is used; children and props flow through JSX as usual.
|
|
87
|
+
*
|
|
88
|
+
* `source` may return a component, a native tag name (`'input'`, `'textarea'`,
|
|
89
|
+
* etc.), `undefined`, or a `Promise` of any of the above. A pending promise
|
|
90
|
+
* propagates as `NotReadyError` through the surrounding reactive scope, so
|
|
91
|
+
* async swaps compose with `Loading`/Suspense boundaries the same way as
|
|
92
|
+
* `lazy`.
|
|
42
93
|
*
|
|
43
|
-
* This is a lower level version of the `Dynamic` component, useful for
|
|
44
|
-
* performance optimizations in libraries. Do not use this unless you know
|
|
45
|
-
* what you are doing.
|
|
46
94
|
* ```typescript
|
|
47
|
-
* const
|
|
48
|
-
*
|
|
95
|
+
* const User = dynamic(() => getUserComp(props.id));
|
|
96
|
+
* return <User>client content</User>;
|
|
49
97
|
* ```
|
|
98
|
+
*
|
|
50
99
|
* @description https://docs.solidjs.com/reference/components/dynamic
|
|
51
100
|
*/
|
|
52
|
-
export declare function
|
|
101
|
+
export declare function dynamic<T extends ValidComponent>(source: () => T | Promise<T> | null | undefined | false): Component<ComponentProps<T>>;
|
|
53
102
|
/**
|
|
54
103
|
* Renders an arbitrary custom or native component and passes the other props
|
|
55
104
|
* ```typescript
|
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Renders a component tree synchronously to an HTML string. Async reads inside
|
|
3
|
+
* `<Loading>` boundaries emit their `fallback` content; for full-graph
|
|
4
|
+
* resolution use `renderToStringAsync` instead.
|
|
5
|
+
*
|
|
6
|
+
* Pair the returned HTML with `hydrate()` on the client.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```tsx
|
|
10
|
+
* import { renderToString } from "@solidjs/web";
|
|
11
|
+
*
|
|
12
|
+
* const html = renderToString(() => <App />);
|
|
13
|
+
* res.send(`<!doctype html><html><body><div id="root">${html}</div></body></html>`);
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
1
16
|
export declare function renderToString<T>(fn: () => T, options?: {
|
|
2
17
|
nonce?: string;
|
|
3
18
|
renderId?: string;
|
|
@@ -12,6 +27,21 @@ export declare function renderToString<T>(fn: () => T, options?: {
|
|
|
12
27
|
}>;
|
|
13
28
|
onError?: (err: any) => void;
|
|
14
29
|
}): string;
|
|
30
|
+
/**
|
|
31
|
+
* Renders a component tree to an HTML string and awaits all async reads in the
|
|
32
|
+
* subtree before resolving. The returned HTML reflects the fully-settled state
|
|
33
|
+
* — no `<Loading>` fallbacks appear in the output.
|
|
34
|
+
*
|
|
35
|
+
* Use this when you want a complete page in one round-trip. For incremental
|
|
36
|
+
* streaming with progressive boundary resolution, use `renderToStream`.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```tsx
|
|
40
|
+
* import { renderToStringAsync } from "@solidjs/web";
|
|
41
|
+
*
|
|
42
|
+
* const html = await renderToStringAsync(() => <App />);
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
15
45
|
export declare function renderToStringAsync<T>(fn: () => T, options?: {
|
|
16
46
|
timeoutMs?: number;
|
|
17
47
|
nonce?: string;
|
|
@@ -27,6 +57,25 @@ export declare function renderToStringAsync<T>(fn: () => T, options?: {
|
|
|
27
57
|
}>;
|
|
28
58
|
onError?: (err: any) => void;
|
|
29
59
|
}): Promise<string>;
|
|
60
|
+
/**
|
|
61
|
+
* Streams an HTML response, flushing the synchronous shell first and then
|
|
62
|
+
* progressively emitting async-resolved fragments as their `<Loading>`
|
|
63
|
+
* boundaries settle. Good for time-to-first-byte sensitive pages.
|
|
64
|
+
*
|
|
65
|
+
* Returns an object with `pipe`/`pipeTo` for piping to a Node `Writable` or
|
|
66
|
+
* a Web `WritableStream`, plus a `then` for awaiting full completion.
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```tsx
|
|
70
|
+
* import { renderToStream } from "@solidjs/web";
|
|
71
|
+
*
|
|
72
|
+
* // Node:
|
|
73
|
+
* renderToStream(() => <App />).pipe(res);
|
|
74
|
+
*
|
|
75
|
+
* // Web (Workers / Deno):
|
|
76
|
+
* await renderToStream(() => <App />).pipeTo(stream.writable);
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
30
79
|
export declare function renderToStream<T>(fn: () => T, options?: {
|
|
31
80
|
nonce?: string;
|
|
32
81
|
renderId?: string;
|
|
@@ -54,19 +103,27 @@ export declare function renderToStream<T>(fn: () => T, options?: {
|
|
|
54
103
|
}) => void;
|
|
55
104
|
pipeTo: (writable: WritableStream) => Promise<void>;
|
|
56
105
|
};
|
|
106
|
+
/** Compiler primitive — emitted by JSX-DOM-Expressions for tagged-template SSR output. Not meant for hand-written code. */
|
|
57
107
|
export declare function ssr(template: string[] | string, ...nodes: any[]): {
|
|
58
108
|
t: string;
|
|
59
109
|
};
|
|
110
|
+
/** Compiler primitive — emitted by JSX-DOM-Expressions for SSR element output. Not meant for hand-written code. */
|
|
60
111
|
export declare function ssrElement(name: string, props: any, children: any, needsId: boolean): {
|
|
61
112
|
t: string;
|
|
62
113
|
};
|
|
114
|
+
/** Compiler primitive — serializes a classList object for SSR output. Not meant for hand-written code. */
|
|
63
115
|
export declare function ssrClassList(value: {
|
|
64
116
|
[k: string]: boolean;
|
|
65
117
|
}): string;
|
|
118
|
+
/** Compiler primitive — serializes a style object for SSR output. Not meant for hand-written code. */
|
|
66
119
|
export declare function ssrStyle(value: {
|
|
67
120
|
[k: string]: string;
|
|
68
121
|
}): string;
|
|
122
|
+
/** Compiler primitive — serializes a boolean attribute for SSR output. Not meant for hand-written code. */
|
|
69
123
|
export declare function ssrAttribute(key: string, value: boolean): string;
|
|
124
|
+
/** Compiler primitive — generates the hydration-key attribute for SSR output. Not meant for hand-written code. */
|
|
70
125
|
export declare function ssrHydrationKey(): string;
|
|
126
|
+
/** Compiler primitive — collapses an SSR-shaped node into its HTML string. Not meant for hand-written code. */
|
|
71
127
|
export declare function resolveSSRNode(node: any): string;
|
|
128
|
+
/** Escapes a string for safe inclusion in HTML output. Useful when constructing SSR fragments by hand. */
|
|
72
129
|
export declare function escape(html: string): string;
|
package/types/client.d.ts
CHANGED
|
@@ -5,6 +5,8 @@ export const DelegatedEvents: Set<string>;
|
|
|
5
5
|
export const DOMElements: Set<string>;
|
|
6
6
|
export const SVGElements: Set<string>;
|
|
7
7
|
export const MathMLElements: Set<string>;
|
|
8
|
+
export const VoidElements: Set<string>;
|
|
9
|
+
export const RawTextElements: Set<string>;
|
|
8
10
|
export const Namespaces: Record<string, string>;
|
|
9
11
|
|
|
10
12
|
type MountableElement = Element | Document | ShadowRoot | DocumentFragment | Node;
|
package/types/core.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { getOwner, runWithOwner, createComponent, createRoot as root, sharedConfig, untrack, merge as mergeProps, flatten, ssrHandleError, ssrRunInScope } from "solid-js";
|
|
2
2
|
export declare const effect: (fn: any, effectFn: any, options: any) => void;
|
|
3
|
-
export declare const memo: (fn: any
|
|
3
|
+
export declare const memo: (fn: any) => import("solid-js").Accessor<any>;
|
package/types/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { hydrate as hydrateCore } from "./client.js";
|
|
2
|
-
import { JSX, ComponentProps, ValidComponent } from "solid-js";
|
|
2
|
+
import { JSX, Component, ComponentProps, ValidComponent } from "solid-js";
|
|
3
3
|
export * from "./client.js";
|
|
4
4
|
export * from "./server-mock.js";
|
|
5
5
|
export { For, Show, Switch, Match, Errored, Loading, Repeat, Reveal, NoHydration, Hydration, merge as mergeProps } from "solid-js";
|
|
@@ -9,27 +9,70 @@ type MountableElement = Element | Document | ShadowRoot | DocumentFragment | Nod
|
|
|
9
9
|
export type DynamicProps<T extends ValidComponent, P = ComponentProps<T>> = {
|
|
10
10
|
[K in keyof P]: P[K];
|
|
11
11
|
} & {
|
|
12
|
-
component: T | undefined;
|
|
12
|
+
component: T | null | undefined | false;
|
|
13
13
|
};
|
|
14
14
|
/**
|
|
15
|
-
* Renders a component tree into a DOM element
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
15
|
+
* Renders a component tree into a DOM element. Returns a dispose function
|
|
16
|
+
* that tears the tree down and cleans up reactive scopes when called.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```tsx
|
|
20
|
+
* import { render } from "@solidjs/web";
|
|
21
|
+
*
|
|
22
|
+
* const dispose = render(() => <App />, document.getElementById("root")!);
|
|
23
|
+
*
|
|
24
|
+
* // Later, to unmount:
|
|
25
|
+
* dispose();
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* @remarks
|
|
29
|
+
* The top-level insert is queued via `insertOptions: { schedule: true }` so
|
|
30
|
+
* its initial DOM attach goes through the effect queue rather than executing
|
|
31
|
+
* inline. This lets the mount participate in transitions: if an uncaught
|
|
32
|
+
* async read surfaces during the initial render (no `Loading` ancestor
|
|
33
|
+
* absorbs it), the mount is held by the transition and attaches atomically
|
|
34
|
+
* once all pending settles. On the no-async happy path the tail `flush()`
|
|
35
|
+
* drains the queued callback so the attach is synchronous by the time
|
|
36
|
+
* `render()` returns. The dev enforcement window scopes
|
|
37
|
+
* `ASYNC_OUTSIDE_LOADING_BOUNDARY` to the initial mount only.
|
|
24
38
|
*/
|
|
25
39
|
export declare function render(code: () => JSX.Element, element: MountableElement, init?: unknown, options?: {
|
|
26
40
|
renderId?: string;
|
|
27
41
|
}): () => void;
|
|
42
|
+
/**
|
|
43
|
+
* Resumes a server-rendered tree on the client, attaching event listeners
|
|
44
|
+
* and reactive bindings without reconstructing the DOM. Returns a `dispose`
|
|
45
|
+
* function that tears down reactive scopes (DOM nodes are left in place).
|
|
46
|
+
*
|
|
47
|
+
* Use this when the page HTML was produced by `renderToString`,
|
|
48
|
+
* `renderToStringAsync`, or `renderToStream`. For client-only apps, use
|
|
49
|
+
* `render` instead.
|
|
50
|
+
*
|
|
51
|
+
* Pass `options.renderId` to hydrate one of multiple roots emitted by a
|
|
52
|
+
* server render that used the same id.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```tsx
|
|
56
|
+
* import { hydrate } from "@solidjs/web";
|
|
57
|
+
*
|
|
58
|
+
* hydrate(() => <App />, document.getElementById("root")!);
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
28
61
|
export declare const hydrate: typeof hydrateCore;
|
|
29
62
|
/**
|
|
30
|
-
* Renders
|
|
63
|
+
* Renders its children into a different part of the DOM (modal roots,
|
|
64
|
+
* tooltips, layers that need to escape an `overflow: hidden` ancestor).
|
|
31
65
|
*
|
|
32
|
-
*
|
|
66
|
+
* If `mount` is omitted, the portal attaches to `document.body`. The portal
|
|
67
|
+
* still participates in the parent's reactive scope and disposes when the
|
|
68
|
+
* parent does.
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```tsx
|
|
72
|
+
* <Portal mount={document.getElementById("modal-root")!}>
|
|
73
|
+
* <Dialog />
|
|
74
|
+
* </Portal>
|
|
75
|
+
* ```
|
|
33
76
|
*
|
|
34
77
|
* @description https://docs.solidjs.com/reference/components/portal
|
|
35
78
|
*/
|
|
@@ -38,18 +81,24 @@ export declare function Portal<T extends boolean = false, S extends boolean = fa
|
|
|
38
81
|
children: JSX.Element;
|
|
39
82
|
}): Text;
|
|
40
83
|
/**
|
|
41
|
-
*
|
|
84
|
+
* Returns a stable `Component` whose identity is driven by a reactive (and
|
|
85
|
+
* optionally async) `source`. The returned component can be used anywhere a
|
|
86
|
+
* normal component is used; children and props flow through JSX as usual.
|
|
87
|
+
*
|
|
88
|
+
* `source` may return a component, a native tag name (`'input'`, `'textarea'`,
|
|
89
|
+
* etc.), `undefined`, or a `Promise` of any of the above. A pending promise
|
|
90
|
+
* propagates as `NotReadyError` through the surrounding reactive scope, so
|
|
91
|
+
* async swaps compose with `Loading`/Suspense boundaries the same way as
|
|
92
|
+
* `lazy`.
|
|
42
93
|
*
|
|
43
|
-
* This is a lower level version of the `Dynamic` component, useful for
|
|
44
|
-
* performance optimizations in libraries. Do not use this unless you know
|
|
45
|
-
* what you are doing.
|
|
46
94
|
* ```typescript
|
|
47
|
-
* const
|
|
48
|
-
*
|
|
95
|
+
* const User = dynamic(() => getUserComp(props.id));
|
|
96
|
+
* return <User>client content</User>;
|
|
49
97
|
* ```
|
|
98
|
+
*
|
|
50
99
|
* @description https://docs.solidjs.com/reference/components/dynamic
|
|
51
100
|
*/
|
|
52
|
-
export declare function
|
|
101
|
+
export declare function dynamic<T extends ValidComponent>(source: () => T | Promise<T> | null | undefined | false): Component<ComponentProps<T>>;
|
|
53
102
|
/**
|
|
54
103
|
* Renders an arbitrary custom or native component and passes the other props
|
|
55
104
|
* ```typescript
|
package/types/server-mock.d.ts
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Renders a component tree synchronously to an HTML string. Async reads inside
|
|
3
|
+
* `<Loading>` boundaries emit their `fallback` content; for full-graph
|
|
4
|
+
* resolution use `renderToStringAsync` instead.
|
|
5
|
+
*
|
|
6
|
+
* Pair the returned HTML with `hydrate()` on the client.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```tsx
|
|
10
|
+
* import { renderToString } from "@solidjs/web";
|
|
11
|
+
*
|
|
12
|
+
* const html = renderToString(() => <App />);
|
|
13
|
+
* res.send(`<!doctype html><html><body><div id="root">${html}</div></body></html>`);
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
1
16
|
export declare function renderToString<T>(fn: () => T, options?: {
|
|
2
17
|
nonce?: string;
|
|
3
18
|
renderId?: string;
|
|
@@ -12,6 +27,21 @@ export declare function renderToString<T>(fn: () => T, options?: {
|
|
|
12
27
|
}>;
|
|
13
28
|
onError?: (err: any) => void;
|
|
14
29
|
}): string;
|
|
30
|
+
/**
|
|
31
|
+
* Renders a component tree to an HTML string and awaits all async reads in the
|
|
32
|
+
* subtree before resolving. The returned HTML reflects the fully-settled state
|
|
33
|
+
* — no `<Loading>` fallbacks appear in the output.
|
|
34
|
+
*
|
|
35
|
+
* Use this when you want a complete page in one round-trip. For incremental
|
|
36
|
+
* streaming with progressive boundary resolution, use `renderToStream`.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```tsx
|
|
40
|
+
* import { renderToStringAsync } from "@solidjs/web";
|
|
41
|
+
*
|
|
42
|
+
* const html = await renderToStringAsync(() => <App />);
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
15
45
|
export declare function renderToStringAsync<T>(fn: () => T, options?: {
|
|
16
46
|
timeoutMs?: number;
|
|
17
47
|
nonce?: string;
|
|
@@ -27,6 +57,25 @@ export declare function renderToStringAsync<T>(fn: () => T, options?: {
|
|
|
27
57
|
}>;
|
|
28
58
|
onError?: (err: any) => void;
|
|
29
59
|
}): Promise<string>;
|
|
60
|
+
/**
|
|
61
|
+
* Streams an HTML response, flushing the synchronous shell first and then
|
|
62
|
+
* progressively emitting async-resolved fragments as their `<Loading>`
|
|
63
|
+
* boundaries settle. Good for time-to-first-byte sensitive pages.
|
|
64
|
+
*
|
|
65
|
+
* Returns an object with `pipe`/`pipeTo` for piping to a Node `Writable` or
|
|
66
|
+
* a Web `WritableStream`, plus a `then` for awaiting full completion.
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```tsx
|
|
70
|
+
* import { renderToStream } from "@solidjs/web";
|
|
71
|
+
*
|
|
72
|
+
* // Node:
|
|
73
|
+
* renderToStream(() => <App />).pipe(res);
|
|
74
|
+
*
|
|
75
|
+
* // Web (Workers / Deno):
|
|
76
|
+
* await renderToStream(() => <App />).pipeTo(stream.writable);
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
30
79
|
export declare function renderToStream<T>(fn: () => T, options?: {
|
|
31
80
|
nonce?: string;
|
|
32
81
|
renderId?: string;
|
|
@@ -54,19 +103,27 @@ export declare function renderToStream<T>(fn: () => T, options?: {
|
|
|
54
103
|
}) => void;
|
|
55
104
|
pipeTo: (writable: WritableStream) => Promise<void>;
|
|
56
105
|
};
|
|
106
|
+
/** Compiler primitive — emitted by JSX-DOM-Expressions for tagged-template SSR output. Not meant for hand-written code. */
|
|
57
107
|
export declare function ssr(template: string[] | string, ...nodes: any[]): {
|
|
58
108
|
t: string;
|
|
59
109
|
};
|
|
110
|
+
/** Compiler primitive — emitted by JSX-DOM-Expressions for SSR element output. Not meant for hand-written code. */
|
|
60
111
|
export declare function ssrElement(name: string, props: any, children: any, needsId: boolean): {
|
|
61
112
|
t: string;
|
|
62
113
|
};
|
|
114
|
+
/** Compiler primitive — serializes a classList object for SSR output. Not meant for hand-written code. */
|
|
63
115
|
export declare function ssrClassList(value: {
|
|
64
116
|
[k: string]: boolean;
|
|
65
117
|
}): string;
|
|
118
|
+
/** Compiler primitive — serializes a style object for SSR output. Not meant for hand-written code. */
|
|
66
119
|
export declare function ssrStyle(value: {
|
|
67
120
|
[k: string]: string;
|
|
68
121
|
}): string;
|
|
122
|
+
/** Compiler primitive — serializes a boolean attribute for SSR output. Not meant for hand-written code. */
|
|
69
123
|
export declare function ssrAttribute(key: string, value: boolean): string;
|
|
124
|
+
/** Compiler primitive — generates the hydration-key attribute for SSR output. Not meant for hand-written code. */
|
|
70
125
|
export declare function ssrHydrationKey(): string;
|
|
126
|
+
/** Compiler primitive — collapses an SSR-shaped node into its HTML string. Not meant for hand-written code. */
|
|
71
127
|
export declare function resolveSSRNode(node: any): string;
|
|
128
|
+
/** Escapes a string for safe inclusion in HTML output. Useful when constructing SSR fragments by hand. */
|
|
72
129
|
export declare function escape(html: string): string;
|