@solidjs/web 2.0.0-experimental.8 → 2.0.0-rc.0
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 +22 -4
- package/dist/dev.cjs +1585 -225
- package/dist/dev.js +1510 -201
- package/dist/server.cjs +2642 -264
- package/dist/server.js +2542 -217
- package/dist/web.cjs +1523 -218
- package/dist/web.js +1448 -194
- package/frames/dist/client.cjs +1916 -0
- package/frames/dist/client.dev.cjs +1933 -0
- package/frames/dist/client.dev.js +1921 -0
- package/frames/dist/client.js +1904 -0
- package/frames/dist/server.cjs +3667 -0
- package/frames/dist/server.js +3654 -0
- package/frames/package.json +30 -0
- package/package.json +349 -37
- package/serialization/decode/package.json +20 -0
- package/serialization/dist/decode.cjs +110 -0
- package/serialization/dist/decode.js +104 -0
- package/serialization/dist/serialization.cjs +232 -0
- package/serialization/dist/serialization.js +215 -0
- package/serialization/package.json +20 -0
- package/serialization/types/index.d.ts +182 -0
- package/serialization/types/serializer-decode.d.ts +182 -0
- package/serialization/types-cjs/index.d.cts +182 -0
- package/serialization/types-cjs/package.json +3 -0
- package/serialization/types-cjs/serializer-decode.d.cts +182 -0
- package/server-functions/dist/client.cjs +646 -0
- package/server-functions/dist/client.js +617 -0
- package/server-functions/dist/rich-args.cjs +11 -0
- package/server-functions/dist/rich-args.js +9 -0
- package/server-functions/dist/server.cjs +1077 -0
- package/server-functions/dist/server.dev.cjs +1077 -0
- package/server-functions/dist/server.dev.js +1045 -0
- package/server-functions/dist/server.js +1045 -0
- package/server-functions/package.json +40 -0
- package/server-functions/rich-args/package.json +20 -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 +290 -27
- package/types/cookies.d.ts +93 -0
- package/types/core.d.ts +6 -2
- package/types/frames/client.d.ts +36 -0
- package/types/frames/frame-client.d.ts +338 -0
- package/types/frames/frame-sink.d.ts +194 -0
- package/types/frames/frame-transport.d.ts +222 -0
- package/types/frames/serializer.d.ts +182 -0
- package/types/frames/server.d.ts +52 -0
- package/types/index.d.ts +209 -24
- package/types/jsx-properties.d.ts +93 -0
- package/types/jsx.d.ts +4150 -1
- package/types/response.d.ts +174 -0
- package/types/serializer-decode.d.ts +182 -0
- package/types/serializer.d.ts +182 -0
- package/types/server-functions/client.d.ts +201 -0
- package/types/server-functions/flash.d.ts +38 -0
- package/types/server-functions/rich-args.d.ts +10 -0
- package/types/server-functions/server.d.ts +588 -0
- package/types/server-functions/shared.d.ts +523 -0
- package/types/server-mock.d.ts +249 -12
- package/types/server.d.ts +424 -51
- package/types-cjs/client.d.cts +337 -0
- package/types-cjs/cookies.d.cts +93 -0
- package/types-cjs/core.d.cts +6 -0
- package/types-cjs/frames/client.d.cts +36 -0
- package/types-cjs/frames/frame-client.d.cts +338 -0
- package/types-cjs/frames/frame-sink.d.cts +194 -0
- package/types-cjs/frames/frame-transport.d.cts +222 -0
- package/types-cjs/frames/serializer.d.cts +182 -0
- package/types-cjs/frames/server.d.cts +52 -0
- package/types-cjs/index.d.cts +230 -0
- package/types-cjs/jsx-properties.d.cts +93 -0
- package/types-cjs/jsx.d.cts +4150 -0
- package/types-cjs/package.json +3 -0
- package/types-cjs/response.d.cts +174 -0
- package/types-cjs/serializer-decode.d.cts +182 -0
- package/types-cjs/serializer.d.cts +182 -0
- package/types-cjs/server-functions/client.d.cts +201 -0
- package/types-cjs/server-functions/flash.d.cts +38 -0
- package/types-cjs/server-functions/rich-args.d.cts +10 -0
- package/types-cjs/server-functions/server.d.cts +588 -0
- package/types-cjs/server-functions/shared.d.cts +523 -0
- package/types-cjs/server-mock.d.cts +277 -0
- package/types-cjs/server.d.cts +523 -0
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
import type { RequestEvent, RequestEventLocals, ResponseStub } from "./client.cjs";
|
|
2
|
+
/** Static asset manifest produced by a build (e.g. parsed Vite manifest.json). */
|
|
3
|
+
export type AssetManifest = Record<string, {
|
|
4
|
+
file: string;
|
|
5
|
+
css?: string[];
|
|
6
|
+
isEntry?: boolean;
|
|
7
|
+
imports?: string[];
|
|
8
|
+
}> & {
|
|
9
|
+
_base?: string;
|
|
10
|
+
};
|
|
11
|
+
/** Inline style content, e.g. dev CSS collected from a bundler's module graph. */
|
|
12
|
+
export type InlineStyleAsset = {
|
|
13
|
+
id: string;
|
|
14
|
+
content: string;
|
|
15
|
+
attrs?: Record<string, string>;
|
|
16
|
+
};
|
|
17
|
+
export type ResolvedAssets = {
|
|
18
|
+
js: string[];
|
|
19
|
+
css: (string | InlineStyleAsset)[];
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Resolver form of the manifest option — the primitive a dev server
|
|
23
|
+
* implements against its live module graph (a static manifest object is
|
|
24
|
+
* normalized into a sync resolver internally). `resolve` may return a
|
|
25
|
+
* promise (async resolvers require streaming rendering); CSS entries may be
|
|
26
|
+
* URL strings (emitted as load-gated `<link>` tags) or inline-style
|
|
27
|
+
* descriptors (emitted as `<style>` tags). A bare `resolve`-shaped function
|
|
28
|
+
* is accepted as shorthand for `{ resolve }`.
|
|
29
|
+
*/
|
|
30
|
+
export type AssetResolver = {
|
|
31
|
+
resolve(key: string): ResolvedAssets | null | undefined | Promise<ResolvedAssets | null | undefined>;
|
|
32
|
+
/**
|
|
33
|
+
* Synchronous fast path answering with whatever is knowable without async
|
|
34
|
+
* work (typically js URLs, omitting css). Sync consumers — e.g. a lazy
|
|
35
|
+
* component's `moduleUrl` getter used by islands — use this when `resolve`
|
|
36
|
+
* would return a promise, so adapters should provide it whenever possible.
|
|
37
|
+
*/
|
|
38
|
+
resolveSync?(key: string): ResolvedAssets | null | undefined;
|
|
39
|
+
};
|
|
40
|
+
/** Bare-function shorthand for `AssetResolver` (no sync fast path). */
|
|
41
|
+
export type AssetResolverFn = (key: string) => ResolvedAssets | null | undefined | Promise<ResolvedAssets | null | undefined>;
|
|
42
|
+
/**
|
|
43
|
+
* Renders a component tree synchronously to an HTML string. Async reads inside
|
|
44
|
+
* `<Loading>` boundaries emit their `fallback` content; for full-graph
|
|
45
|
+
* resolution await `renderToStream` instead.
|
|
46
|
+
*
|
|
47
|
+
* Pair the returned HTML with `hydrate()` on the client.
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```tsx
|
|
51
|
+
* import { renderToString } from "@solidjs/web";
|
|
52
|
+
*
|
|
53
|
+
* const html = renderToString(() => <App />);
|
|
54
|
+
* res.send(`<!doctype html><html><body><div id="root">${html}</div></body></html>`);
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
export declare function renderToString<T>(fn: () => T, options?: {
|
|
58
|
+
nonce?: string;
|
|
59
|
+
renderId?: string;
|
|
60
|
+
noScripts?: boolean;
|
|
61
|
+
plugins?: any[];
|
|
62
|
+
manifest?: AssetManifest | AssetResolver | AssetResolverFn;
|
|
63
|
+
onError?: (err: any) => void;
|
|
64
|
+
/**
|
|
65
|
+
* Embedded-render contract for hosts that own the document. When the
|
|
66
|
+
* render output contains no `</head>`, everything head-bound (resolved
|
|
67
|
+
* `useHead` winners, eager resources, tracked asset links, inline
|
|
68
|
+
* styles) is delivered here as one HTML string — prelude (charset/base)
|
|
69
|
+
* first — for the host to splice into its own `<head>` template, instead
|
|
70
|
+
* of being dropped. Called synchronously before `renderToString`
|
|
71
|
+
* returns; not called when the output has a `</head>` (splicing is
|
|
72
|
+
* automatic then).
|
|
73
|
+
*/
|
|
74
|
+
onHead?: (head: string) => void;
|
|
75
|
+
}): string;
|
|
76
|
+
/**
|
|
77
|
+
* Streams an HTML response, flushing the synchronous shell first and then
|
|
78
|
+
* progressively emitting async-resolved fragments as their `<Loading>`
|
|
79
|
+
* boundaries settle. Good for time-to-first-byte sensitive pages.
|
|
80
|
+
*
|
|
81
|
+
* Returns an object with `pipe`/`pipeTo` for piping to a Node `Writable` or
|
|
82
|
+
* a Web `WritableStream`, a lazy `readable` byte-stream view for
|
|
83
|
+
* `new Response(stream.readable)`, plus a thenable for awaiting full
|
|
84
|
+
* completion — `await renderToStream(...)` resolves with the settled HTML
|
|
85
|
+
* (the fully-resolved-string form of the render). `pipe`, `pipeTo`, and
|
|
86
|
+
* `readable` each consume the render — use exactly one of the three.
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* ```tsx
|
|
90
|
+
* import { renderToStream } from "@solidjs/web";
|
|
91
|
+
*
|
|
92
|
+
* // Node:
|
|
93
|
+
* renderToStream(() => <App />).pipe(res);
|
|
94
|
+
*
|
|
95
|
+
* // Web (Workers / Deno):
|
|
96
|
+
* return new Response(renderToStream(() => <App />).readable);
|
|
97
|
+
*
|
|
98
|
+
* // Fully settled string:
|
|
99
|
+
* const html = await renderToStream(() => <App />);
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
export declare function renderToStream<T>(fn: () => T, options?: {
|
|
103
|
+
nonce?: string;
|
|
104
|
+
renderId?: string;
|
|
105
|
+
noScripts?: boolean;
|
|
106
|
+
plugins?: any[];
|
|
107
|
+
manifest?: AssetManifest | AssetResolver | AssetResolverFn;
|
|
108
|
+
onCompleteShell?: (info: {
|
|
109
|
+
write: (v: string) => void;
|
|
110
|
+
}) => void;
|
|
111
|
+
onCompleteAll?: (info: {
|
|
112
|
+
write: (v: string) => void;
|
|
113
|
+
}) => void;
|
|
114
|
+
onError?: (err: any) => void;
|
|
115
|
+
/**
|
|
116
|
+
* Embedded-render contract for hosts that own the document. When the
|
|
117
|
+
* shell contains no `</head>`, everything head-bound at first flush
|
|
118
|
+
* (resolved `useHead` winners, eager resources, tracked asset links,
|
|
119
|
+
* inline styles) is delivered here as one HTML string — prelude first —
|
|
120
|
+
* before the shell chunk is emitted, so the host can write its own
|
|
121
|
+
* `<head>` ahead of piping the stream. Post-shell head updates flow
|
|
122
|
+
* through the stream itself and apply in the browser. Not called when
|
|
123
|
+
* the shell has a `</head>` (splicing is automatic then).
|
|
124
|
+
*/
|
|
125
|
+
onHead?: (head: string) => void;
|
|
126
|
+
}): {
|
|
127
|
+
/**
|
|
128
|
+
* Awaiting the stream resolves with the complete HTML once every boundary
|
|
129
|
+
* settles — the fully-settled-string form of the render. Render errors
|
|
130
|
+
* route through `onError` and the promise resolves with whatever HTML the
|
|
131
|
+
* render produced; it never rejects.
|
|
132
|
+
*/
|
|
133
|
+
then<TResult1 = string, TResult2 = never>(onfulfilled?: ((html: string) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
|
|
134
|
+
pipe: (writable: {
|
|
135
|
+
write: (v: string) => void;
|
|
136
|
+
end: () => void;
|
|
137
|
+
}) => void;
|
|
138
|
+
pipeTo: (writable: WritableStream) => Promise<void>;
|
|
139
|
+
readonly readable: ReadableStream<Uint8Array>;
|
|
140
|
+
};
|
|
141
|
+
/**
|
|
142
|
+
* Fetch-style middleware: receives the `Request` and a `next` continuation
|
|
143
|
+
* (pass a `Request` to substitute it downstream) and returns the `Response`.
|
|
144
|
+
* Composed with `composeMiddleware`; runs inside the request-event scope, so
|
|
145
|
+
* `getRequestEvent()` works exactly as in application code.
|
|
146
|
+
*/
|
|
147
|
+
export type FetchMiddleware = (request: Request, next: (request?: Request) => Promise<Response>) => Response | Promise<Response>;
|
|
148
|
+
/**
|
|
149
|
+
* Creates a fresh, uncommitted {@link ResponseStub}. Server-only.
|
|
150
|
+
*/
|
|
151
|
+
export declare function createResponseStub(): ResponseStub;
|
|
152
|
+
/**
|
|
153
|
+
* Builds the canonical request event — a web-standard `Request`, a `locals`
|
|
154
|
+
* bag, and a stub-backed `response` head — for `provideRequestEvent`.
|
|
155
|
+
* Server-only: on the client the request event belongs to the server that
|
|
156
|
+
* rendered the page.
|
|
157
|
+
*/
|
|
158
|
+
export declare function createRequestEvent<T extends object = {}>(request: Request, init?: T): {
|
|
159
|
+
request: Request;
|
|
160
|
+
locals: RequestEventLocals;
|
|
161
|
+
response: ResponseStub;
|
|
162
|
+
} & T;
|
|
163
|
+
/**
|
|
164
|
+
* The HTTP status a redirect should use: the stub's own status when it is a
|
|
165
|
+
* redirect status (301/302/303/307/308), 302 otherwise. Server-only.
|
|
166
|
+
*/
|
|
167
|
+
export declare function getExpectedRedirectStatus(response: ResponseStub): number;
|
|
168
|
+
/**
|
|
169
|
+
* Derives the outgoing `Response` for an SSR render result, running the
|
|
170
|
+
* response-head lifecycle against `event.response`: the stub commits at
|
|
171
|
+
* shell flush, a pre-flush `Location` becomes a real redirect
|
|
172
|
+
* (`getExpectedRedirectStatus`), and a post-flush one appends the
|
|
173
|
+
* nonce-aware `<script>window.location=...</script>` fallback. String
|
|
174
|
+
* results return a `Response` synchronously; stream results resolve at
|
|
175
|
+
* shell flush. Server-only.
|
|
176
|
+
*/
|
|
177
|
+
export declare function createSSRResponse(result: string, event: RequestEvent | undefined, options?: {
|
|
178
|
+
responseInit?: ResponseInit;
|
|
179
|
+
nonce?: string;
|
|
180
|
+
transformChunk?: (chunk: string) => string;
|
|
181
|
+
}): Response;
|
|
182
|
+
export declare function createSSRResponse(result: {
|
|
183
|
+
pipe(writable: {
|
|
184
|
+
write: (v: string) => void;
|
|
185
|
+
end: () => void;
|
|
186
|
+
}): void;
|
|
187
|
+
}, event: RequestEvent | undefined, options?: {
|
|
188
|
+
responseInit?: ResponseInit;
|
|
189
|
+
nonce?: string;
|
|
190
|
+
transformChunk?: (chunk: string) => string;
|
|
191
|
+
}): Promise<Response>;
|
|
192
|
+
/**
|
|
193
|
+
* Handler-lifecycle plumbing — the exit for a `Response` that did not go
|
|
194
|
+
* through `createSSRResponse` (a middleware early return, an API result):
|
|
195
|
+
* folds the request event's response stub onto it (cookies append
|
|
196
|
+
* entry-by-entry, other headers gap-fill, status never) and commits the
|
|
197
|
+
* stub. Already-committed stubs pass the response through untouched, so
|
|
198
|
+
* handlers apply it unconditionally after their middleware chain unwinds.
|
|
199
|
+
* `event` defaults to the ambient `getRequestEvent()`. Application
|
|
200
|
+
* middleware never calls this. Server-only.
|
|
201
|
+
*/
|
|
202
|
+
export declare function commitEventResponse(response: Response, event?: RequestEvent): Response;
|
|
203
|
+
/**
|
|
204
|
+
* Composes fetch-style middleware — `(request, next) => Response` — into a
|
|
205
|
+
* single function of the same shape. Nothing reaches the wire until the
|
|
206
|
+
* outermost middleware returns, so headers on the returned `Response` stay
|
|
207
|
+
* mutable through the whole unwind, streamed bodies included. Server-only.
|
|
208
|
+
*/
|
|
209
|
+
export declare function composeMiddleware(middlewares: FetchMiddleware[]): (request: Request, next: (request?: Request) => Response | Promise<Response>) => Promise<Response>;
|
|
210
|
+
/**
|
|
211
|
+
* Compiler primitive — emitted by JSX-DOM-Expressions for tagged-template
|
|
212
|
+
* SSR output. Not meant for hand-written code.
|
|
213
|
+
* @internal
|
|
214
|
+
*/
|
|
215
|
+
export declare function ssr(template: string[] | string, ...nodes: any[]): {
|
|
216
|
+
t: string;
|
|
217
|
+
};
|
|
218
|
+
/**
|
|
219
|
+
* Compiler primitive — emitted by JSX-DOM-Expressions for SSR element
|
|
220
|
+
* output. Not meant for hand-written code.
|
|
221
|
+
* @internal
|
|
222
|
+
*/
|
|
223
|
+
export declare function ssrElement(name: string, props: any, children: any, needsId: boolean): {
|
|
224
|
+
t: string;
|
|
225
|
+
};
|
|
226
|
+
/**
|
|
227
|
+
* Compiler primitive — serializes a class value (string, object map, or
|
|
228
|
+
* array) for SSR output. Not meant for hand-written code.
|
|
229
|
+
* @internal
|
|
230
|
+
*/
|
|
231
|
+
export declare function ssrClassName(value: string | {
|
|
232
|
+
[k: string]: boolean;
|
|
233
|
+
} | Array<any>): string;
|
|
234
|
+
/**
|
|
235
|
+
* Compiler primitive — serializes a style value for SSR output. Not meant
|
|
236
|
+
* for hand-written code.
|
|
237
|
+
* @internal
|
|
238
|
+
*/
|
|
239
|
+
export declare function ssrStyle(value: string | {
|
|
240
|
+
[k: string]: string;
|
|
241
|
+
}): string;
|
|
242
|
+
/**
|
|
243
|
+
* Compiler primitive — serializes one style property for SSR output. Not
|
|
244
|
+
* meant for hand-written code.
|
|
245
|
+
* @internal
|
|
246
|
+
*/
|
|
247
|
+
export declare function ssrStyleProperty(name: string, value: any): string;
|
|
248
|
+
/**
|
|
249
|
+
* Compiler primitive — serializes an attribute for SSR output. Not meant
|
|
250
|
+
* for hand-written code.
|
|
251
|
+
* @internal
|
|
252
|
+
*/
|
|
253
|
+
export declare function ssrAttribute(key: string, value: any): string;
|
|
254
|
+
/**
|
|
255
|
+
* Compiler primitive — wraps a template-group closure for SSR output. Not
|
|
256
|
+
* meant for hand-written code.
|
|
257
|
+
* @internal
|
|
258
|
+
*/
|
|
259
|
+
export declare function ssrGroup<T extends () => any[]>(fn: T, n: number): T;
|
|
260
|
+
/**
|
|
261
|
+
* Compiler primitive — generates the hydration-key attribute for SSR
|
|
262
|
+
* output. Not meant for hand-written code.
|
|
263
|
+
* @internal
|
|
264
|
+
*/
|
|
265
|
+
export declare function ssrHydrationKey(): string;
|
|
266
|
+
/**
|
|
267
|
+
* Compiler primitive — collapses an SSR-shaped node into its HTML string.
|
|
268
|
+
* Not meant for hand-written code.
|
|
269
|
+
* @internal
|
|
270
|
+
*/
|
|
271
|
+
export declare function resolveSSRNode(node: any, result?: any, top?: boolean): any;
|
|
272
|
+
/**
|
|
273
|
+
* Escapes a string for safe inclusion in HTML output. Used by the SSR
|
|
274
|
+
* runtime; not generally part of user code.
|
|
275
|
+
* @internal
|
|
276
|
+
*/
|
|
277
|
+
export declare function escape(s: any, attr?: boolean): any;
|