@solidjs/web 2.0.0-beta.7 → 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.
@@ -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;
@@ -4,6 +4,8 @@ export const DelegatedEvents: Set<string>;
4
4
  export const DOMElements: Set<string>;
5
5
  export const SVGElements: Set<string>;
6
6
  export const MathMLElements: Set<string>;
7
+ export const VoidElements: Set<string>;
8
+ export const RawTextElements: Set<string>;
7
9
  export const Namespaces: Record<string, string>;
8
10
 
9
11
  type MountableElement = Element | Document | ShadowRoot | DocumentFragment | Node;
@@ -15,7 +17,10 @@ export function renderToString<T>(
15
17
  renderId?: string;
16
18
  noScripts?: boolean;
17
19
  plugins?: any[];
18
- manifest?: Record<string, { file: string; css?: string[]; isEntry?: boolean; imports?: string[] }> & { _base?: string };
20
+ manifest?: Record<
21
+ string,
22
+ { file: string; css?: string[]; isEntry?: boolean; imports?: string[] }
23
+ > & { _base?: string };
19
24
  onError?: (err: any) => void;
20
25
  }
21
26
  ): string;
@@ -28,7 +33,10 @@ export function renderToStringAsync<T>(
28
33
  renderId?: string;
29
34
  noScripts?: boolean;
30
35
  plugins?: any[];
31
- manifest?: Record<string, { file: string; css?: string[]; isEntry?: boolean; imports?: string[] }> & { _base?: string };
36
+ manifest?: Record<
37
+ string,
38
+ { file: string; css?: string[]; isEntry?: boolean; imports?: string[] }
39
+ > & { _base?: string };
32
40
  onError?: (err: any) => void;
33
41
  }
34
42
  ): Promise<string>;
@@ -39,7 +47,10 @@ export function renderToStream<T>(
39
47
  renderId?: string;
40
48
  noScripts?: boolean;
41
49
  plugins?: any[];
42
- manifest?: Record<string, { file: string; css?: string[]; isEntry?: boolean; imports?: string[] }> & { _base?: string };
50
+ manifest?: Record<
51
+ string,
52
+ { file: string; css?: string[]; isEntry?: boolean; imports?: string[] }
53
+ > & { _base?: string };
43
54
  onCompleteShell?: (info: { write: (v: string) => void }) => void;
44
55
  onCompleteAll?: (info: { write: (v: string) => void }) => void;
45
56
  onError?: (err: any) => void;
@@ -65,7 +76,10 @@ export function ssrAttribute(key: string, value: any): string;
65
76
  export function ssrHydrationKey(): string;
66
77
  export function resolveSSRNode(node: any, result?: any, top?: boolean): any;
67
78
  export function escape(s: any, attr?: boolean): any;
68
- export function applyRef(r: ((element: any) => void) | ((element: any) => void)[], element: any): void;
79
+ export function applyRef(
80
+ r: ((element: any) => void) | ((element: any) => void)[],
81
+ element: any
82
+ ): void;
69
83
  export function useAssets(fn: () => JSX.Element): void;
70
84
  export function getAssets(): string;
71
85
  export function getHydrationKey(): string | undefined;
@@ -75,7 +89,10 @@ export function createComponent<T>(Comp: (props: T) => JSX.Element, props: T): J
75
89
  export function mergeProps(...sources: unknown[]): unknown;
76
90
  export function getOwner(): unknown;
77
91
  export function ssrRunInScope(fn: () => void, owner: unknown): void;
78
- export function generateHydrationScript(options?: { nonce?: string; eventNames?: string[] }): string;
92
+ export function generateHydrationScript(options?: {
93
+ nonce?: string;
94
+ eventNames?: string[];
95
+ }): string;
79
96
  export declare const RequestContext: unique symbol;
80
97
  export interface RequestEvent {
81
98
  request: Request;
@@ -104,11 +121,7 @@ export function insert<T>(
104
121
  ): JSX.Element;
105
122
 
106
123
  /** @deprecated not supported on the server side */
107
- export function spread<T>(
108
- node: Element,
109
- accessor: T,
110
- skipChildren?: Boolean
111
- ): void;
124
+ export function spread<T>(node: Element, accessor: T, skipChildren?: Boolean): void;
112
125
 
113
126
  /** @deprecated not supported on the server side */
114
127
  export function delegateEvents(eventNames: string[], d?: Document): void;