@solidjs/web 2.0.0-beta.1 → 2.0.0-beta.11
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 +251 -106
- package/dist/dev.js +239 -102
- package/dist/server.cjs +391 -109
- package/dist/server.js +384 -105
- package/dist/web.cjs +237 -97
- package/dist/web.js +225 -93
- package/package.json +100 -33
- package/storage/package.json +8 -3
- package/storage/types/src/index.d.ts +147 -21
- package/storage/types/src/jsx.d.ts +29 -0
- package/storage/types/src/server-mock.d.ts +89 -0
- package/storage/types-cjs/index.d.cts +2 -0
- package/storage/types-cjs/package.json +3 -0
- package/storage/types-cjs/src/client.d.cts +1 -0
- package/storage/types-cjs/src/index.d.cts +171 -0
- package/storage/types-cjs/src/jsx.d.cts +29 -0
- package/storage/types-cjs/src/server-mock.d.cts +161 -0
- package/storage/types-cjs/storage/src/index.d.cts +2 -0
- package/types/client.d.ts +31 -15
- package/types/core.d.ts +3 -3
- package/types/index.d.ts +147 -21
- package/types/jsx-properties.d.ts +92 -0
- package/types/jsx.d.ts +4321 -1
- package/types/server-mock.d.ts +89 -0
- package/types/server.d.ts +36 -18
- package/types-cjs/client.d.cts +104 -0
- package/types-cjs/core.d.cts +3 -0
- package/types-cjs/index.d.cts +171 -0
- package/types-cjs/jsx-properties.d.cts +92 -0
- package/types-cjs/jsx.d.cts +4321 -0
- package/types-cjs/package.json +3 -0
- package/types-cjs/server-mock.d.cts +161 -0
- package/types-cjs/server.d.cts +174 -0
|
@@ -0,0 +1,161 @@
|
|
|
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
|
+
*/
|
|
16
|
+
export declare function renderToString<T>(fn: () => T, options?: {
|
|
17
|
+
nonce?: string;
|
|
18
|
+
renderId?: string;
|
|
19
|
+
noScripts?: boolean;
|
|
20
|
+
plugins?: any[];
|
|
21
|
+
manifest?: Record<string, {
|
|
22
|
+
file: string;
|
|
23
|
+
css?: string[];
|
|
24
|
+
isEntry?: boolean;
|
|
25
|
+
isDynamicEntry?: boolean;
|
|
26
|
+
imports?: string[];
|
|
27
|
+
}>;
|
|
28
|
+
onError?: (err: any) => void;
|
|
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
|
+
*/
|
|
45
|
+
export declare function renderToStringAsync<T>(fn: () => T, options?: {
|
|
46
|
+
timeoutMs?: number;
|
|
47
|
+
nonce?: string;
|
|
48
|
+
renderId?: string;
|
|
49
|
+
noScripts?: boolean;
|
|
50
|
+
plugins?: any[];
|
|
51
|
+
manifest?: Record<string, {
|
|
52
|
+
file: string;
|
|
53
|
+
css?: string[];
|
|
54
|
+
isEntry?: boolean;
|
|
55
|
+
isDynamicEntry?: boolean;
|
|
56
|
+
imports?: string[];
|
|
57
|
+
}>;
|
|
58
|
+
onError?: (err: any) => void;
|
|
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
|
+
*/
|
|
79
|
+
export declare function renderToStream<T>(fn: () => T, options?: {
|
|
80
|
+
nonce?: string;
|
|
81
|
+
renderId?: string;
|
|
82
|
+
noScripts?: boolean;
|
|
83
|
+
plugins?: any[];
|
|
84
|
+
manifest?: Record<string, {
|
|
85
|
+
file: string;
|
|
86
|
+
css?: string[];
|
|
87
|
+
isEntry?: boolean;
|
|
88
|
+
isDynamicEntry?: boolean;
|
|
89
|
+
imports?: string[];
|
|
90
|
+
}>;
|
|
91
|
+
onCompleteShell?: (info: {
|
|
92
|
+
write: (v: string) => void;
|
|
93
|
+
}) => void;
|
|
94
|
+
onCompleteAll?: (info: {
|
|
95
|
+
write: (v: string) => void;
|
|
96
|
+
}) => void;
|
|
97
|
+
onError?: (err: any) => void;
|
|
98
|
+
}): {
|
|
99
|
+
then: (fn: (html: string) => void) => void;
|
|
100
|
+
pipe: (writable: {
|
|
101
|
+
write: (v: string) => void;
|
|
102
|
+
end: () => void;
|
|
103
|
+
}) => void;
|
|
104
|
+
pipeTo: (writable: WritableStream) => Promise<void>;
|
|
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
|
+
*/
|
|
111
|
+
export declare function ssr(template: string[] | string, ...nodes: any[]): {
|
|
112
|
+
t: string;
|
|
113
|
+
};
|
|
114
|
+
/**
|
|
115
|
+
* Compiler primitive — emitted by JSX-DOM-Expressions for SSR element
|
|
116
|
+
* output. Not meant for hand-written code.
|
|
117
|
+
* @internal
|
|
118
|
+
*/
|
|
119
|
+
export declare function ssrElement(name: string, props: any, children: any, needsId: boolean): {
|
|
120
|
+
t: string;
|
|
121
|
+
};
|
|
122
|
+
/**
|
|
123
|
+
* Compiler primitive — serializes a classList object for SSR output. Not
|
|
124
|
+
* meant for hand-written code.
|
|
125
|
+
* @internal
|
|
126
|
+
*/
|
|
127
|
+
export declare function ssrClassList(value: {
|
|
128
|
+
[k: string]: boolean;
|
|
129
|
+
}): string;
|
|
130
|
+
/**
|
|
131
|
+
* Compiler primitive — serializes a style object for SSR output. Not meant
|
|
132
|
+
* for hand-written code.
|
|
133
|
+
* @internal
|
|
134
|
+
*/
|
|
135
|
+
export declare function ssrStyle(value: {
|
|
136
|
+
[k: string]: string;
|
|
137
|
+
}): string;
|
|
138
|
+
/**
|
|
139
|
+
* Compiler primitive — serializes a boolean attribute for SSR output. Not
|
|
140
|
+
* meant for hand-written code.
|
|
141
|
+
* @internal
|
|
142
|
+
*/
|
|
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
|
+
*/
|
|
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
|
+
*/
|
|
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
|
+
*/
|
|
161
|
+
export declare function escape(html: string): string;
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { JSX } from "./jsx.cjs";
|
|
2
|
+
export const ChildProperties: Set<string>;
|
|
3
|
+
export const DelegatedEvents: Set<string>;
|
|
4
|
+
export const DOMElements: Set<string>;
|
|
5
|
+
export const SVGElements: Set<string>;
|
|
6
|
+
export const MathMLElements: Set<string>;
|
|
7
|
+
export const VoidElements: Set<string>;
|
|
8
|
+
export const RawTextElements: Set<string>;
|
|
9
|
+
export const Namespaces: Record<string, string>;
|
|
10
|
+
|
|
11
|
+
type MountableElement = Element | Document | ShadowRoot | DocumentFragment | Node;
|
|
12
|
+
|
|
13
|
+
export function renderToString<T>(
|
|
14
|
+
fn: () => T,
|
|
15
|
+
options?: {
|
|
16
|
+
nonce?: string;
|
|
17
|
+
renderId?: string;
|
|
18
|
+
noScripts?: boolean;
|
|
19
|
+
plugins?: any[];
|
|
20
|
+
manifest?: Record<
|
|
21
|
+
string,
|
|
22
|
+
{ file: string; css?: string[]; isEntry?: boolean; imports?: string[] }
|
|
23
|
+
> & { _base?: string };
|
|
24
|
+
onError?: (err: any) => void;
|
|
25
|
+
}
|
|
26
|
+
): string;
|
|
27
|
+
/** @deprecated use renderToStream which also returns a promise */
|
|
28
|
+
export function renderToStringAsync<T>(
|
|
29
|
+
fn: () => T,
|
|
30
|
+
options?: {
|
|
31
|
+
timeoutMs?: number;
|
|
32
|
+
nonce?: string;
|
|
33
|
+
renderId?: string;
|
|
34
|
+
noScripts?: boolean;
|
|
35
|
+
plugins?: any[];
|
|
36
|
+
manifest?: Record<
|
|
37
|
+
string,
|
|
38
|
+
{ file: string; css?: string[]; isEntry?: boolean; imports?: string[] }
|
|
39
|
+
> & { _base?: string };
|
|
40
|
+
onError?: (err: any) => void;
|
|
41
|
+
}
|
|
42
|
+
): Promise<string>;
|
|
43
|
+
export function renderToStream<T>(
|
|
44
|
+
fn: () => T,
|
|
45
|
+
options?: {
|
|
46
|
+
nonce?: string;
|
|
47
|
+
renderId?: string;
|
|
48
|
+
noScripts?: boolean;
|
|
49
|
+
plugins?: any[];
|
|
50
|
+
manifest?: Record<
|
|
51
|
+
string,
|
|
52
|
+
{ file: string; css?: string[]; isEntry?: boolean; imports?: string[] }
|
|
53
|
+
> & { _base?: string };
|
|
54
|
+
onCompleteShell?: (info: { write: (v: string) => void }) => void;
|
|
55
|
+
onCompleteAll?: (info: { write: (v: string) => void }) => void;
|
|
56
|
+
onError?: (err: any) => void;
|
|
57
|
+
}
|
|
58
|
+
): {
|
|
59
|
+
then: (fn: (html: string) => void) => void;
|
|
60
|
+
pipe: (writable: { write: (v: string) => void; end: () => void }) => void;
|
|
61
|
+
pipeTo: (writable: WritableStream) => Promise<void>;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export function HydrationScript(props: { nonce?: string; eventNames?: string[] }): JSX.Element;
|
|
65
|
+
export function ssr(template: string[] | string, ...nodes: any[]): { t: string };
|
|
66
|
+
export function ssrElement(
|
|
67
|
+
name: string,
|
|
68
|
+
props: any,
|
|
69
|
+
children: any,
|
|
70
|
+
needsId: boolean
|
|
71
|
+
): { t: string };
|
|
72
|
+
export function ssrClassName(value: string | { [k: string]: boolean } | Array<any>): string;
|
|
73
|
+
export function ssrStyle(value: string | { [k: string]: string }): string;
|
|
74
|
+
export function ssrStyleProperty(name: string, value: any): string;
|
|
75
|
+
export function ssrAttribute(key: string, value: any): string;
|
|
76
|
+
export function ssrGroup<T extends () => any[]>(fn: T, n: number): T;
|
|
77
|
+
export function ssrHydrationKey(): string;
|
|
78
|
+
export function resolveSSRNode(node: any, result?: any, top?: boolean): any;
|
|
79
|
+
export function escape(s: any, attr?: boolean): any;
|
|
80
|
+
export function applyRef(
|
|
81
|
+
r: ((element: any) => void) | ((element: any) => void)[],
|
|
82
|
+
element: any
|
|
83
|
+
): void;
|
|
84
|
+
export function useAssets(fn: () => JSX.Element): void;
|
|
85
|
+
export function getAssets(): string;
|
|
86
|
+
export function getHydrationKey(): string | undefined;
|
|
87
|
+
export function effect<T>(fn: (prev?: T) => T, effect: (value: T, prev?: T) => void): void;
|
|
88
|
+
export function memo<T>(fn: () => T, equal: boolean): () => T;
|
|
89
|
+
export function createComponent<T>(Comp: (props: T) => JSX.Element, props: T): JSX.Element;
|
|
90
|
+
export function mergeProps(...sources: unknown[]): unknown;
|
|
91
|
+
export function getOwner(): unknown;
|
|
92
|
+
export function generateHydrationScript(options?: {
|
|
93
|
+
nonce?: string;
|
|
94
|
+
eventNames?: string[];
|
|
95
|
+
}): string;
|
|
96
|
+
export declare const RequestContext: unique symbol;
|
|
97
|
+
export interface RequestEvent {
|
|
98
|
+
request: Request;
|
|
99
|
+
locals: Record<string | number | symbol, any>;
|
|
100
|
+
}
|
|
101
|
+
export function getRequestEvent(): RequestEvent | undefined;
|
|
102
|
+
|
|
103
|
+
export function Assets(props: { children?: JSX.Element }): JSX.Element;
|
|
104
|
+
export function untrack<T>(fn: () => T): T;
|
|
105
|
+
|
|
106
|
+
// client-only APIs
|
|
107
|
+
|
|
108
|
+
/** @deprecated not supported on the server side */
|
|
109
|
+
export function style(
|
|
110
|
+
node: Element,
|
|
111
|
+
value: { [k: string]: string },
|
|
112
|
+
prev?: { [k: string]: string }
|
|
113
|
+
): void;
|
|
114
|
+
|
|
115
|
+
/** @deprecated not supported on the server side */
|
|
116
|
+
export function insert<T>(
|
|
117
|
+
parent: MountableElement,
|
|
118
|
+
accessor: (() => T) | T,
|
|
119
|
+
marker?: Node | null,
|
|
120
|
+
init?: JSX.Element
|
|
121
|
+
): JSX.Element;
|
|
122
|
+
|
|
123
|
+
/** @deprecated not supported on the server side */
|
|
124
|
+
export function spread<T>(node: Element, accessor: T, skipChildren?: Boolean): void;
|
|
125
|
+
|
|
126
|
+
/** @deprecated not supported on the server side */
|
|
127
|
+
export function delegateEvents(eventNames: string[], d?: Document): void;
|
|
128
|
+
/** @deprecated not supported on the server side */
|
|
129
|
+
export function dynamicProperty(props: unknown, key: string): unknown;
|
|
130
|
+
/** @deprecated not supported on the server side */
|
|
131
|
+
export function setAttribute(node: Element, name: string, value: string): void;
|
|
132
|
+
/** @deprecated not supported on the server side */
|
|
133
|
+
export function setAttributeNS(node: Element, namespace: string, name: string, value: string): void;
|
|
134
|
+
|
|
135
|
+
/** @deprecated not supported on the server side */
|
|
136
|
+
export function addEventListener(
|
|
137
|
+
node: Element,
|
|
138
|
+
name: string,
|
|
139
|
+
handler: () => void,
|
|
140
|
+
delegate: boolean
|
|
141
|
+
): void;
|
|
142
|
+
|
|
143
|
+
/** @deprecated not supported on the server side */
|
|
144
|
+
export function render(code: () => JSX.Element, element: MountableElement): () => void;
|
|
145
|
+
/**
|
|
146
|
+
* @deprecated not supported on the server side
|
|
147
|
+
* @param flag
|
|
148
|
+
* - `undefined` — clone the template as-is (uses `cloneNode`).
|
|
149
|
+
* - `1` — use `document.importNode` instead of `cloneNode`.
|
|
150
|
+
* - `2` — the template html is wrapped; the outer tag is stripped at clone time.
|
|
151
|
+
*/
|
|
152
|
+
export function template(html: string, flag?: 1 | 2): () => Element;
|
|
153
|
+
/** @deprecated not supported on the server side */
|
|
154
|
+
export function setProperty(node: Element, name: string, value: any): void;
|
|
155
|
+
/** @deprecated not supported on the server side */
|
|
156
|
+
export function className(node: Element, value: string): void;
|
|
157
|
+
/** @deprecated not supported on the server side */
|
|
158
|
+
export function assign(node: Element, props: any, skipChildren?: Boolean): void;
|
|
159
|
+
|
|
160
|
+
/** @deprecated not supported on the server side */
|
|
161
|
+
export function hydrate(
|
|
162
|
+
fn: () => JSX.Element,
|
|
163
|
+
node: MountableElement,
|
|
164
|
+
options?: { renderId?: string; owner?: unknown }
|
|
165
|
+
): () => void;
|
|
166
|
+
|
|
167
|
+
/** @deprecated not supported on the server side */
|
|
168
|
+
export function getNextElement(template?: () => Element): Element;
|
|
169
|
+
/** @deprecated not supported on the server side */
|
|
170
|
+
export function getNextMatch(start: Node, elementName: string): Element;
|
|
171
|
+
/** @deprecated not supported on the server side */
|
|
172
|
+
export function getNextMarker(start: Node): [Node, Array<Node>];
|
|
173
|
+
/** @deprecated not supported on the server side */
|
|
174
|
+
export function runHydrationEvents(): void;
|