@solidjs/web 2.0.0-beta.2 → 2.0.0-beta.20
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 +783 -223
- package/dist/dev.js +757 -217
- package/dist/server.cjs +742 -186
- package/dist/server.js +714 -183
- package/dist/web.cjs +772 -196
- package/dist/web.js +746 -190
- package/package.json +193 -38
- package/serialization/dist/serialization.cjs +83 -0
- package/serialization/dist/serialization.js +75 -0
- package/serialization/package.json +20 -0
- package/serialization/types/index.d.ts +139 -0
- package/serialization/types-cjs/index.d.cts +139 -0
- package/serialization/types-cjs/package.json +3 -0
- package/server-functions/dist/client.cjs +370 -0
- package/server-functions/dist/client.js +363 -0
- package/server-functions/dist/server.cjs +542 -0
- package/server-functions/dist/server.js +531 -0
- package/server-functions/package.json +30 -0
- package/storage/package.json +8 -3
- package/storage/types/index.d.ts +26 -0
- package/storage/types-cjs/index.d.cts +28 -0
- package/storage/types-cjs/package.json +3 -0
- package/types/client.d.ts +64 -21
- package/types/core.d.ts +3 -3
- package/types/index.d.ts +156 -24
- package/types/jsx-properties.d.ts +93 -0
- package/types/jsx.d.ts +4135 -1
- package/types/response.d.ts +93 -0
- package/types/serializer.d.ts +139 -0
- package/types/server-functions/client.d.ts +63 -0
- package/types/server-functions/server.d.ts +188 -0
- package/types/server-functions/shared.d.ts +171 -0
- package/types/server-mock.d.ts +89 -0
- package/types/server.d.ts +123 -28
- package/types-cjs/client.d.cts +131 -0
- package/types-cjs/core.d.cts +3 -0
- package/types-cjs/index.d.cts +178 -0
- package/types-cjs/jsx-properties.d.cts +93 -0
- package/types-cjs/jsx.d.cts +4135 -0
- package/types-cjs/package.json +3 -0
- package/types-cjs/response.d.cts +93 -0
- package/types-cjs/serializer.d.cts +139 -0
- package/types-cjs/server-functions/client.d.cts +63 -0
- package/types-cjs/server-functions/server.d.cts +188 -0
- package/types-cjs/server-functions/shared.d.cts +171 -0
- package/types-cjs/server-mock.d.cts +161 -0
- package/types-cjs/server.d.cts +251 -0
- package/storage/types/src/client.d.ts +0 -1
- package/storage/types/src/index.d.ts +0 -46
- package/storage/types/src/server-mock.d.ts +0 -72
- package/storage/types/storage/src/index.d.ts +0 -2
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,59 @@ export declare function renderToStream<T>(fn: () => T, options?: {
|
|
|
54
103
|
}) => void;
|
|
55
104
|
pipeTo: (writable: WritableStream) => Promise<void>;
|
|
56
105
|
};
|
|
106
|
+
/**
|
|
107
|
+
* Compiler primitive — emitted by JSX-DOM-Expressions for tagged-template
|
|
108
|
+
* SSR output. Not meant for hand-written code.
|
|
109
|
+
* @internal
|
|
110
|
+
*/
|
|
57
111
|
export declare function ssr(template: string[] | string, ...nodes: any[]): {
|
|
58
112
|
t: string;
|
|
59
113
|
};
|
|
114
|
+
/**
|
|
115
|
+
* Compiler primitive — emitted by JSX-DOM-Expressions for SSR element
|
|
116
|
+
* output. Not meant for hand-written code.
|
|
117
|
+
* @internal
|
|
118
|
+
*/
|
|
60
119
|
export declare function ssrElement(name: string, props: any, children: any, needsId: boolean): {
|
|
61
120
|
t: string;
|
|
62
121
|
};
|
|
122
|
+
/**
|
|
123
|
+
* Compiler primitive — serializes a classList object for SSR output. Not
|
|
124
|
+
* meant for hand-written code.
|
|
125
|
+
* @internal
|
|
126
|
+
*/
|
|
63
127
|
export declare function ssrClassList(value: {
|
|
64
128
|
[k: string]: boolean;
|
|
65
129
|
}): string;
|
|
130
|
+
/**
|
|
131
|
+
* Compiler primitive — serializes a style object for SSR output. Not meant
|
|
132
|
+
* for hand-written code.
|
|
133
|
+
* @internal
|
|
134
|
+
*/
|
|
66
135
|
export declare function ssrStyle(value: {
|
|
67
136
|
[k: string]: string;
|
|
68
137
|
}): string;
|
|
138
|
+
/**
|
|
139
|
+
* Compiler primitive — serializes a boolean attribute for SSR output. Not
|
|
140
|
+
* meant for hand-written code.
|
|
141
|
+
* @internal
|
|
142
|
+
*/
|
|
69
143
|
export declare function ssrAttribute(key: string, value: boolean): string;
|
|
144
|
+
/**
|
|
145
|
+
* Compiler primitive — generates the hydration-key attribute for SSR
|
|
146
|
+
* output. Not meant for hand-written code.
|
|
147
|
+
* @internal
|
|
148
|
+
*/
|
|
70
149
|
export declare function ssrHydrationKey(): string;
|
|
150
|
+
/**
|
|
151
|
+
* Compiler primitive — collapses an SSR-shaped node into its HTML string.
|
|
152
|
+
* Not meant for hand-written code.
|
|
153
|
+
* @internal
|
|
154
|
+
*/
|
|
71
155
|
export declare function resolveSSRNode(node: any): string;
|
|
156
|
+
/**
|
|
157
|
+
* Escapes a string for safe inclusion in HTML output. Used by the SSR
|
|
158
|
+
* runtime; not generally part of user code.
|
|
159
|
+
* @internal
|
|
160
|
+
*/
|
|
72
161
|
export declare function escape(html: string): string;
|
package/types/server.d.ts
CHANGED
|
@@ -1,21 +1,70 @@
|
|
|
1
1
|
import { JSX } from "./jsx.js";
|
|
2
|
-
|
|
2
|
+
import { SerializerPlugin } from "./serializer.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
|
|
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
63
|
nonce?: string;
|
|
15
64
|
renderId?: string;
|
|
16
65
|
noScripts?: boolean;
|
|
17
|
-
plugins?:
|
|
18
|
-
manifest?:
|
|
66
|
+
plugins?: SerializerPlugin[];
|
|
67
|
+
manifest?: AssetManifest | AssetResolver | AssetResolverFn;
|
|
19
68
|
onError?: (err: any) => void;
|
|
20
69
|
}
|
|
21
70
|
): string;
|
|
@@ -27,8 +76,8 @@ export function renderToStringAsync<T>(
|
|
|
27
76
|
nonce?: string;
|
|
28
77
|
renderId?: string;
|
|
29
78
|
noScripts?: boolean;
|
|
30
|
-
plugins?:
|
|
31
|
-
manifest?:
|
|
79
|
+
plugins?: SerializerPlugin[];
|
|
80
|
+
manifest?: AssetManifest | AssetResolver | AssetResolverFn;
|
|
32
81
|
onError?: (err: any) => void;
|
|
33
82
|
}
|
|
34
83
|
): Promise<string>;
|
|
@@ -38,8 +87,8 @@ export function renderToStream<T>(
|
|
|
38
87
|
nonce?: string;
|
|
39
88
|
renderId?: string;
|
|
40
89
|
noScripts?: boolean;
|
|
41
|
-
plugins?:
|
|
42
|
-
manifest?:
|
|
90
|
+
plugins?: SerializerPlugin[];
|
|
91
|
+
manifest?: AssetManifest | AssetResolver | AssetResolverFn;
|
|
43
92
|
onCompleteShell?: (info: { write: (v: string) => void }) => void;
|
|
44
93
|
onCompleteAll?: (info: { write: (v: string) => void }) => void;
|
|
45
94
|
onError?: (err: any) => void;
|
|
@@ -62,25 +111,50 @@ export function ssrClassName(value: string | { [k: string]: boolean } | Array<an
|
|
|
62
111
|
export function ssrStyle(value: string | { [k: string]: string }): string;
|
|
63
112
|
export function ssrStyleProperty(name: string, value: any): string;
|
|
64
113
|
export function ssrAttribute(key: string, value: any): string;
|
|
114
|
+
export function ssrGroup<T extends () => any[]>(fn: T, n: number): T;
|
|
115
|
+
export function scope<T>(fn: () => T): () => unknown;
|
|
65
116
|
export function ssrHydrationKey(): string;
|
|
66
117
|
export function resolveSSRNode(node: any, result?: any, top?: boolean): any;
|
|
67
118
|
export function escape(s: any, attr?: boolean): any;
|
|
68
|
-
export function applyRef(
|
|
119
|
+
export function applyRef(
|
|
120
|
+
r: ((element: any) => void) | ((element: any) => void)[],
|
|
121
|
+
element: any
|
|
122
|
+
): void;
|
|
69
123
|
export function useAssets(fn: () => JSX.Element): void;
|
|
70
124
|
export function getAssets(): string;
|
|
71
125
|
export function getHydrationKey(): string | undefined;
|
|
72
|
-
export function effect<T>(fn: (prev?: T) => T, effect: (value: T, prev?: T) => void
|
|
126
|
+
export function effect<T>(fn: (prev?: T) => T, effect: (value: T, prev?: T) => void): void;
|
|
73
127
|
export function memo<T>(fn: () => T, equal: boolean): () => T;
|
|
74
128
|
export function createComponent<T>(Comp: (props: T) => JSX.Element, props: T): JSX.Element;
|
|
75
129
|
export function mergeProps(...sources: unknown[]): unknown;
|
|
76
130
|
export function getOwner(): unknown;
|
|
77
|
-
export function
|
|
78
|
-
|
|
131
|
+
export function generateHydrationScript(options?: {
|
|
132
|
+
nonce?: string;
|
|
133
|
+
eventNames?: string[];
|
|
134
|
+
}): string;
|
|
135
|
+
/**
|
|
136
|
+
* Registered symbol (`Symbol.for("solid.RequestContext")`) naming the
|
|
137
|
+
* global slot where `provideRequestEvent` parks the AsyncLocalStorage that
|
|
138
|
+
* scopes request events. Integration plumbing — application code reads the
|
|
139
|
+
* event through `getRequestEvent()` instead.
|
|
140
|
+
* @internal
|
|
141
|
+
*/
|
|
79
142
|
export declare const RequestContext: unique symbol;
|
|
143
|
+
/**
|
|
144
|
+
* The per-request context available on the server: the incoming `Request`
|
|
145
|
+
* and a `locals` bag integrations and middleware can hang state on.
|
|
146
|
+
* Frameworks typically extend this shape with richer fields.
|
|
147
|
+
*/
|
|
80
148
|
export interface RequestEvent {
|
|
81
149
|
request: Request;
|
|
82
150
|
locals: Record<string | number | symbol, any>;
|
|
83
151
|
}
|
|
152
|
+
/**
|
|
153
|
+
* The current request event, when called on the server inside a request
|
|
154
|
+
* scope (established by `provideRequestEvent` from `@solidjs/web/storage`
|
|
155
|
+
* or by the framework). Undefined on the client and outside a request.
|
|
156
|
+
* Read it above `await` boundaries in partially-polyfilled environments.
|
|
157
|
+
*/
|
|
84
158
|
export function getRequestEvent(): RequestEvent | undefined;
|
|
85
159
|
|
|
86
160
|
export function Assets(props: { children?: JSX.Element }): JSX.Element;
|
|
@@ -104,15 +178,26 @@ export function insert<T>(
|
|
|
104
178
|
): JSX.Element;
|
|
105
179
|
|
|
106
180
|
/** @deprecated not supported on the server side */
|
|
107
|
-
export function spread<T>(
|
|
108
|
-
node: Element,
|
|
109
|
-
accessor: T,
|
|
110
|
-
isSVG?: Boolean,
|
|
111
|
-
skipChildren?: Boolean
|
|
112
|
-
): void;
|
|
181
|
+
export function spread<T>(node: Element, accessor: T, skipChildren?: Boolean): void;
|
|
113
182
|
|
|
114
183
|
/** @deprecated not supported on the server side */
|
|
115
|
-
export function delegateEvents(eventNames: string[]
|
|
184
|
+
export function delegateEvents(eventNames: string[]): void;
|
|
185
|
+
/** @deprecated not supported on the server side */
|
|
186
|
+
export function registerDelegatedRoot(root: MountableElement): void;
|
|
187
|
+
/** @deprecated not supported on the server side */
|
|
188
|
+
export function unregisterDelegatedRoot(root: MountableElement): void;
|
|
189
|
+
/** @deprecated not supported on the server side */
|
|
190
|
+
export function registerDelegatedContainer(
|
|
191
|
+
container: MountableElement,
|
|
192
|
+
owner?: MountableElement
|
|
193
|
+
): void;
|
|
194
|
+
/** @deprecated not supported on the server side */
|
|
195
|
+
export function unregisterDelegatedContainer(
|
|
196
|
+
container: MountableElement,
|
|
197
|
+
owner?: MountableElement
|
|
198
|
+
): void;
|
|
199
|
+
/** @deprecated not supported on the server side */
|
|
200
|
+
export function getDelegatedRoot(node: MountableElement): MountableElement | undefined;
|
|
116
201
|
/** @deprecated not supported on the server side */
|
|
117
202
|
export function dynamicProperty(props: unknown, key: string): unknown;
|
|
118
203
|
/** @deprecated not supported on the server side */
|
|
@@ -121,23 +206,24 @@ export function setAttribute(node: Element, name: string, value: string): void;
|
|
|
121
206
|
export function setAttributeNS(node: Element, namespace: string, name: string, value: string): void;
|
|
122
207
|
|
|
123
208
|
/** @deprecated not supported on the server side */
|
|
124
|
-
export function
|
|
125
|
-
node: Element,
|
|
126
|
-
name: string,
|
|
127
|
-
handler: () => void,
|
|
128
|
-
delegate: boolean
|
|
129
|
-
): void;
|
|
209
|
+
export function addEvent(node: Element, name: string, handler: () => void, delegate: boolean): void;
|
|
130
210
|
|
|
131
211
|
/** @deprecated not supported on the server side */
|
|
132
212
|
export function render(code: () => JSX.Element, element: MountableElement): () => void;
|
|
133
|
-
/**
|
|
134
|
-
|
|
213
|
+
/**
|
|
214
|
+
* @deprecated not supported on the server side
|
|
215
|
+
* @param flag
|
|
216
|
+
* - `undefined` — clone the template as-is (uses `cloneNode`).
|
|
217
|
+
* - `1` — use `document.importNode` instead of `cloneNode`.
|
|
218
|
+
* - `2` — the template html is wrapped; the outer tag is stripped at clone time.
|
|
219
|
+
*/
|
|
220
|
+
export function template(html: string, flag?: 1 | 2): () => Element;
|
|
135
221
|
/** @deprecated not supported on the server side */
|
|
136
222
|
export function setProperty(node: Element, name: string, value: any): void;
|
|
137
223
|
/** @deprecated not supported on the server side */
|
|
138
224
|
export function className(node: Element, value: string): void;
|
|
139
225
|
/** @deprecated not supported on the server side */
|
|
140
|
-
export function assign(node: Element, props: any,
|
|
226
|
+
export function assign(node: Element, props: any, skipChildren?: Boolean): void;
|
|
141
227
|
|
|
142
228
|
/** @deprecated not supported on the server side */
|
|
143
229
|
export function hydrate(
|
|
@@ -154,3 +240,12 @@ export function getNextMatch(start: Node, elementName: string): Element;
|
|
|
154
240
|
export function getNextMarker(start: Node): [Node, Array<Node>];
|
|
155
241
|
/** @deprecated not supported on the server side */
|
|
156
242
|
export function runHydrationEvents(): void;
|
|
243
|
+
/** @deprecated not supported on the server side */
|
|
244
|
+
export function ref(
|
|
245
|
+
fn: () => ((element: Element) => void) | ((element: Element) => void)[],
|
|
246
|
+
element: Element
|
|
247
|
+
): void;
|
|
248
|
+
/** @deprecated not supported on the server side */
|
|
249
|
+
export function setStyleProperty(node: Element, name: string, value: any): void;
|
|
250
|
+
/** @deprecated not supported on the server side — register assets through the render context instead */
|
|
251
|
+
export function acquireAsset(descriptor: unknown): () => void;
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { JSX } from "./jsx.cjs";
|
|
2
|
+
export const DOMWithState: Record<string, Record<string, 1 | 2>>;
|
|
3
|
+
export const ChildProperties: Set<string>;
|
|
4
|
+
export const DelegatedEvents: Set<string>;
|
|
5
|
+
export const DOMElements: Set<string>;
|
|
6
|
+
export const SVGElements: Set<string>;
|
|
7
|
+
export const MathMLElements: Set<string>;
|
|
8
|
+
export const VoidElements: Set<string>;
|
|
9
|
+
export const RawTextElements: Set<string>;
|
|
10
|
+
export const Namespaces: Record<string, string>;
|
|
11
|
+
|
|
12
|
+
type MountableElement = Element | Document | ShadowRoot | DocumentFragment | Node;
|
|
13
|
+
export function render(
|
|
14
|
+
code: () => JSX.Element,
|
|
15
|
+
element: MountableElement,
|
|
16
|
+
init?: JSX.Element,
|
|
17
|
+
options?: { owner?: unknown }
|
|
18
|
+
): () => void;
|
|
19
|
+
/**
|
|
20
|
+
* @param flag
|
|
21
|
+
* - `undefined` — clone the template as-is (uses `cloneNode`).
|
|
22
|
+
* - `1` — use `document.importNode` instead of `cloneNode`.
|
|
23
|
+
* - `2` — the template html is wrapped; the outer tag is stripped at clone time.
|
|
24
|
+
*/
|
|
25
|
+
export function template(html: string, flag?: 1 | 2): () => Element;
|
|
26
|
+
export function scope<T extends () => any>(fn: T): T;
|
|
27
|
+
export function effect<T>(fn: (prev?: T) => T, effect: (value: T, prev?: T) => void): void;
|
|
28
|
+
export function memo<T>(fn: () => T, equal: boolean): () => T;
|
|
29
|
+
export function untrack<T>(fn: () => T): T;
|
|
30
|
+
export function insert<T>(
|
|
31
|
+
parent: MountableElement,
|
|
32
|
+
accessor: (() => T) | T,
|
|
33
|
+
marker?: Node | null,
|
|
34
|
+
init?: JSX.Element,
|
|
35
|
+
options?: {
|
|
36
|
+
/**
|
|
37
|
+
* Live accessor for the slot's logical host in the source tree (portals).
|
|
38
|
+
* Each top-level node the slot manages is tagged with a `_$host` getter
|
|
39
|
+
* backed by this accessor so delegated events retarget correctly.
|
|
40
|
+
*/
|
|
41
|
+
host?: () => Node | null;
|
|
42
|
+
/** Defer the insert effect to the queue instead of running it inline. */
|
|
43
|
+
schedule?: boolean;
|
|
44
|
+
}
|
|
45
|
+
): JSX.Element;
|
|
46
|
+
export function createComponent<T>(Comp: (props: T) => JSX.Element, props: T): JSX.Element;
|
|
47
|
+
export function delegateEvents(eventNames: string[]): void;
|
|
48
|
+
export function registerDelegatedRoot(root: MountableElement): void;
|
|
49
|
+
export function unregisterDelegatedRoot(root: MountableElement): void;
|
|
50
|
+
export function registerDelegatedContainer(
|
|
51
|
+
container: MountableElement,
|
|
52
|
+
owner?: MountableElement
|
|
53
|
+
): void;
|
|
54
|
+
export function unregisterDelegatedContainer(
|
|
55
|
+
container: MountableElement,
|
|
56
|
+
owner?: MountableElement
|
|
57
|
+
): void;
|
|
58
|
+
export function getDelegatedRoot(node: MountableElement): MountableElement | undefined;
|
|
59
|
+
export function spread<T>(node: Element, accessor: T, skipChildren?: Boolean): void;
|
|
60
|
+
export function assign(
|
|
61
|
+
node: Element,
|
|
62
|
+
props: any,
|
|
63
|
+
skipChildren?: Boolean,
|
|
64
|
+
prevProps?: any,
|
|
65
|
+
skipRef?: Boolean
|
|
66
|
+
): void;
|
|
67
|
+
export function setAttribute(node: Element, name: string, value: string): void;
|
|
68
|
+
export function setAttributeNS(node: Element, namespace: string, name: string, value: string): void;
|
|
69
|
+
export function className(node: Element, value: JSX.ClassValue, prev?: JSX.ClassValue): void;
|
|
70
|
+
export function setProperty(node: Element, name: string, value: any): void;
|
|
71
|
+
export function setStyleProperty(node: Element, name: string, value: any): void;
|
|
72
|
+
export function addEvent(
|
|
73
|
+
node: Element,
|
|
74
|
+
name: string,
|
|
75
|
+
handler: EventListener | EventListenerObject | (EventListenerObject & AddEventListenerOptions),
|
|
76
|
+
delegate: boolean
|
|
77
|
+
): void;
|
|
78
|
+
export function style(
|
|
79
|
+
node: Element,
|
|
80
|
+
value: { [k: string]: string },
|
|
81
|
+
prev?: { [k: string]: string }
|
|
82
|
+
): void;
|
|
83
|
+
export function getOwner(): unknown;
|
|
84
|
+
export function mergeProps(...sources: unknown[]): unknown;
|
|
85
|
+
export function dynamicProperty(props: unknown, key: string): unknown;
|
|
86
|
+
export function applyRef(
|
|
87
|
+
r: ((element: Element) => void) | ((element: Element) => void)[],
|
|
88
|
+
element: Element
|
|
89
|
+
): void;
|
|
90
|
+
export function ref(
|
|
91
|
+
fn: () => ((element: Element) => void) | ((element: Element) => void)[],
|
|
92
|
+
element: Element
|
|
93
|
+
): void;
|
|
94
|
+
|
|
95
|
+
export function hydrate(
|
|
96
|
+
fn: () => JSX.Element,
|
|
97
|
+
node: MountableElement,
|
|
98
|
+
options?: { renderId?: string; owner?: unknown }
|
|
99
|
+
): () => void;
|
|
100
|
+
export function getHydrationKey(): string | undefined;
|
|
101
|
+
export function getNextElement(template?: () => Element): Element;
|
|
102
|
+
export function getNextMatch(start: Node, elementName: string): Element;
|
|
103
|
+
export function getNextMarker(start: Node): [Node, Array<Node>];
|
|
104
|
+
export function useAssets(fn: () => JSX.Element): void;
|
|
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;
|
|
119
|
+
export function HydrationScript(props?: { nonce?: string; eventNames?: string[] }): JSX.Element;
|
|
120
|
+
export function generateHydrationScript(options?: {
|
|
121
|
+
nonce?: string;
|
|
122
|
+
eventNames?: string[];
|
|
123
|
+
}): string;
|
|
124
|
+
export function Assets(props: { children?: JSX.Element }): JSX.Element;
|
|
125
|
+
export interface RequestEvent {
|
|
126
|
+
request: Request;
|
|
127
|
+
locals: Record<string | number | symbol, any>;
|
|
128
|
+
}
|
|
129
|
+
export declare const RequestContext: unique symbol;
|
|
130
|
+
export function getRequestEvent(): RequestEvent | undefined;
|
|
131
|
+
export function runHydrationEvents(): void;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { getOwner, runWithOwner, createComponent, createRoot as root, sharedConfig, untrack, merge as mergeProps, flatten, ssrHandleError, ssrScope } from "solid-js";
|
|
2
|
+
export declare const effect: (fn: any, effectFn: any, options: any) => void;
|
|
3
|
+
export declare const memo: (fn: any) => import("solid-js").SourceAccessor<any>;
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import { hydrate as hydrateCore } from "./client.cjs";
|
|
2
|
+
import { Component } from "solid-js";
|
|
3
|
+
import type { JSX } from "./jsx.cjs";
|
|
4
|
+
export * from "./client.cjs";
|
|
5
|
+
export * from "./server-mock.cjs";
|
|
6
|
+
export * from "./response.cjs";
|
|
7
|
+
export type { JSX } from "./jsx.cjs";
|
|
8
|
+
export { For, Show, Switch, Match, Errored, Loading, Repeat, Reveal, NoHydration, Hydration } from "solid-js";
|
|
9
|
+
import { merge } from "solid-js";
|
|
10
|
+
/**
|
|
11
|
+
* Compiler-emitted prop-spread helper. The JSX transform (in
|
|
12
|
+
* `dom-expressions`) emits `mergeProps(...)` calls when compiling prop
|
|
13
|
+
* spreads on components — it is *not* a user-facing API. Application code
|
|
14
|
+
* should import `merge` from `solid-js` directly.
|
|
15
|
+
*
|
|
16
|
+
* @internal
|
|
17
|
+
*/
|
|
18
|
+
export declare const mergeProps: typeof merge;
|
|
19
|
+
/**
|
|
20
|
+
* Build-time constant indicating whether code is running on the server. This
|
|
21
|
+
* client entry sets it to `false`; the matching server entry (`@solidjs/web`
|
|
22
|
+
* resolved through the `solid` server export condition) sets it to `true`.
|
|
23
|
+
*
|
|
24
|
+
* Bundlers can dead-code-eliminate branches gated on `isServer`, so guarding
|
|
25
|
+
* browser-only code with `if (!isServer) {…}` keeps it out of the SSR bundle
|
|
26
|
+
* entirely.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```ts
|
|
30
|
+
* import { isServer } from "@solidjs/web";
|
|
31
|
+
*
|
|
32
|
+
* if (!isServer) {
|
|
33
|
+
* // Browser-only: tree-shaken out of the SSR bundle.
|
|
34
|
+
* window.addEventListener("resize", onResize);
|
|
35
|
+
* }
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export declare const isServer: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Build-time constant indicating whether code is running in a dev build.
|
|
41
|
+
* Replaced statically (`_SOLID_DEV_`) by the bundler integration, so guards
|
|
42
|
+
* like `if (isDev) {…}` are stripped from production builds.
|
|
43
|
+
*
|
|
44
|
+
* Use this to gate dev-only diagnostics, warnings, or expensive invariants
|
|
45
|
+
* that should never ship to production.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```ts
|
|
49
|
+
* import { isDev } from "@solidjs/web";
|
|
50
|
+
*
|
|
51
|
+
* if (isDev) {
|
|
52
|
+
* console.warn("debug-only path");
|
|
53
|
+
* }
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
export declare const isDev: boolean;
|
|
57
|
+
type MountableElement = Element | Document | ShadowRoot | DocumentFragment | Node;
|
|
58
|
+
export type IntrinsicElement = Extract<keyof JSX.IntrinsicElements, string>;
|
|
59
|
+
export type ValidComponent = IntrinsicElement | Component<any> | (string & {});
|
|
60
|
+
export type ComponentProps<T extends ValidComponent> = T extends Component<infer P> ? P : T extends keyof JSX.IntrinsicElements ? JSX.IntrinsicElements[T] : Record<string, unknown>;
|
|
61
|
+
export type DynamicProps<T extends ValidComponent, P = ComponentProps<T>> = {
|
|
62
|
+
[K in keyof P]: P[K];
|
|
63
|
+
} & {
|
|
64
|
+
component: T | null | undefined | false;
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Renders a component tree into a DOM element. Returns a dispose function
|
|
68
|
+
* that tears the tree down and cleans up reactive scopes when called.
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```tsx
|
|
72
|
+
* import { render } from "@solidjs/web";
|
|
73
|
+
*
|
|
74
|
+
* const dispose = render(() => <App />, document.getElementById("root")!);
|
|
75
|
+
*
|
|
76
|
+
* // Later, to unmount:
|
|
77
|
+
* dispose();
|
|
78
|
+
* ```
|
|
79
|
+
*
|
|
80
|
+
* @remarks
|
|
81
|
+
* The top-level insert is queued via `insertOptions: { schedule: true }` so
|
|
82
|
+
* its initial DOM attach goes through the effect queue rather than executing
|
|
83
|
+
* inline. This lets the mount participate in transitions: if an uncaught
|
|
84
|
+
* async read surfaces during the initial render (no `Loading` ancestor
|
|
85
|
+
* absorbs it), the mount is held by the transition and attaches atomically
|
|
86
|
+
* once all pending settles. On the no-async happy path the tail `flush()`
|
|
87
|
+
* drains the queued callback so the attach is synchronous by the time
|
|
88
|
+
* `render()` returns. The dev enforcement window scopes
|
|
89
|
+
* `ASYNC_OUTSIDE_LOADING_BOUNDARY` to the initial mount only.
|
|
90
|
+
*/
|
|
91
|
+
export declare function render(code: () => JSX.Element, element: MountableElement, init?: unknown, options?: {
|
|
92
|
+
renderId?: string;
|
|
93
|
+
}): () => void;
|
|
94
|
+
/**
|
|
95
|
+
* Resumes a server-rendered tree on the client, attaching event listeners
|
|
96
|
+
* and reactive bindings without reconstructing the DOM. Returns a `dispose`
|
|
97
|
+
* function that tears down reactive scopes (DOM nodes are left in place).
|
|
98
|
+
*
|
|
99
|
+
* Use this when the page HTML was produced by `renderToString`,
|
|
100
|
+
* `renderToStringAsync`, or `renderToStream`. For client-only apps, use
|
|
101
|
+
* `render` instead.
|
|
102
|
+
*
|
|
103
|
+
* Pass `options.renderId` to hydrate one of multiple roots emitted by a
|
|
104
|
+
* server render that used the same id.
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* ```tsx
|
|
108
|
+
* import { hydrate } from "@solidjs/web";
|
|
109
|
+
*
|
|
110
|
+
* hydrate(() => <App />, document.getElementById("root")!);
|
|
111
|
+
* ```
|
|
112
|
+
*/
|
|
113
|
+
export declare const hydrate: typeof hydrateCore;
|
|
114
|
+
/**
|
|
115
|
+
* Renders its children into a different part of the DOM (modal roots,
|
|
116
|
+
* tooltips, layers that need to escape an `overflow: hidden` ancestor).
|
|
117
|
+
*
|
|
118
|
+
* If `mount` is omitted, the portal attaches to `document.body`. The portal
|
|
119
|
+
* still participates in the parent's reactive scope and disposes when the
|
|
120
|
+
* parent does.
|
|
121
|
+
*
|
|
122
|
+
* Portals are client-only islands: the server renders nothing for them, and
|
|
123
|
+
* under hydration the children render fresh once hydration settles. Async
|
|
124
|
+
* read inside a portal therefore starts on the client — data that should be
|
|
125
|
+
* fetched on the server belongs above the portal (hoist the read, not the
|
|
126
|
+
* render), and async UI inside one wants its own `<Loading>` boundary.
|
|
127
|
+
*
|
|
128
|
+
* @example
|
|
129
|
+
* ```tsx
|
|
130
|
+
* <Portal mount={document.getElementById("modal-root")!}>
|
|
131
|
+
* <Dialog />
|
|
132
|
+
* </Portal>
|
|
133
|
+
* ```
|
|
134
|
+
*
|
|
135
|
+
* @description https://docs.solidjs.com/reference/components/portal
|
|
136
|
+
*/
|
|
137
|
+
export declare function Portal(props: {
|
|
138
|
+
mount?: Element;
|
|
139
|
+
children: JSX.Element;
|
|
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
|
+
export declare function dynamic<T extends ValidComponent>(source: () => T | Promise<T> | null | undefined | false): Component<ComponentProps<T>>;
|
|
163
|
+
/**
|
|
164
|
+
* Renders an arbitrary custom or native component and forwards the other
|
|
165
|
+
* props. JSX form of `dynamic()` — same primitive, picked at the JSX site.
|
|
166
|
+
*
|
|
167
|
+
* @example
|
|
168
|
+
* ```tsx
|
|
169
|
+
* <Dynamic
|
|
170
|
+
* component={multiline() ? RichTextEditor : "input"}
|
|
171
|
+
* value={value()}
|
|
172
|
+
* onInput={onInput}
|
|
173
|
+
* />
|
|
174
|
+
* ```
|
|
175
|
+
*
|
|
176
|
+
* @description https://docs.solidjs.com/reference/components/dynamic
|
|
177
|
+
*/
|
|
178
|
+
export declare function Dynamic<T extends ValidComponent>(props: DynamicProps<T>): JSX.Element;
|