@solidjs/web 2.0.0-rc.0 → 2.0.0-rc.10

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.
Files changed (108) hide show
  1. package/README.md +1 -1
  2. package/dist/server.dev.js +4472 -0
  3. package/dist/server.js +1363 -224
  4. package/dist/{server.cjs → server.observe.js} +1563 -424
  5. package/dist/{dev.cjs → web.dev.js} +708 -365
  6. package/dist/web.js +460 -144
  7. package/dist/{dev.js → web.observe.js} +511 -213
  8. package/frames/dist/client.dev.js +464 -72
  9. package/frames/dist/client.js +364 -71
  10. package/frames/dist/{client.dev.cjs → client.observe.js} +487 -134
  11. package/frames/dist/server.dev.js +1713 -0
  12. package/frames/dist/server.js +553 -2495
  13. package/frames/dist/server.observe.js +1713 -0
  14. package/frames/package.json +2 -25
  15. package/package.json +214 -254
  16. package/performance-tracks/dist/performance-tracks.dev.js +678 -0
  17. package/performance-tracks/dist/performance-tracks.js +6 -0
  18. package/performance-tracks/dist/performance-tracks.observe.js +666 -0
  19. package/performance-tracks/package.json +7 -0
  20. package/performance-tracks/types/index.d.ts +67 -0
  21. package/serialization/decode/package.json +2 -15
  22. package/serialization/dist/decode.js +101 -12
  23. package/serialization/dist/serialization.js +112 -20
  24. package/serialization/package.json +2 -15
  25. package/serialization/types/index.d.ts +76 -157
  26. package/serialization/types/serializer-decode.d.ts +149 -112
  27. package/serialization/types/serializer.d.ts +101 -0
  28. package/server-functions/dist/client.dev.js +1364 -0
  29. package/server-functions/dist/client.js +745 -85
  30. package/server-functions/dist/client.observe.js +1343 -0
  31. package/server-functions/dist/server.dev.js +2203 -175
  32. package/server-functions/dist/server.js +2111 -176
  33. package/server-functions/dist/server.observe.js +3043 -0
  34. package/server-functions/package.json +2 -35
  35. package/server-functions/rich-args/package.json +2 -15
  36. package/storage/package.json +2 -15
  37. package/types/client.d.ts +193 -288
  38. package/types/constants.d.ts +20 -0
  39. package/types/cookies.d.ts +32 -84
  40. package/types/diagnostics.d.ts +56 -0
  41. package/types/frames/client.d.ts +1 -1
  42. package/types/frames/frame-client.d.ts +323 -259
  43. package/types/frames/frame-container-plugin.d.ts +72 -0
  44. package/types/frames/frame-sink.d.ts +101 -158
  45. package/types/frames/frame-transport.d.ts +192 -190
  46. package/types/frames/serializer-decode.d.ts +219 -0
  47. package/types/frames/serializer.d.ts +76 -157
  48. package/types/frames/server.d.ts +1 -1
  49. package/types/head.d.ts +19 -0
  50. package/types/index.d.ts +62 -76
  51. package/types/index.server.d.ts +174 -0
  52. package/types/jsx.d.ts +33 -26
  53. package/types/observe.d.ts +358 -0
  54. package/types/reconcile.d.ts +1 -0
  55. package/types/render.d.ts +9 -0
  56. package/types/response.d.ts +75 -150
  57. package/types/serializer-decode.d.ts +149 -112
  58. package/types/serializer.d.ts +76 -157
  59. package/types/server-functions/client.d.ts +202 -174
  60. package/types/server-functions/flash.d.ts +28 -30
  61. package/types/server-functions/registry.d.ts +102 -0
  62. package/types/server-functions/rich-args.d.ts +1 -10
  63. package/types/server-functions/server.d.ts +518 -454
  64. package/types/server-functions/shared.d.ts +366 -425
  65. package/types/server-mock.d.ts +110 -13
  66. package/types/server-observe.d.ts +77 -0
  67. package/types/server.d.ts +425 -425
  68. package/types/trace.d.ts +127 -0
  69. package/LICENSE +0 -21
  70. package/dist/web.cjs +0 -2007
  71. package/frames/dist/client.cjs +0 -1916
  72. package/frames/dist/server.cjs +0 -3667
  73. package/serialization/dist/decode.cjs +0 -110
  74. package/serialization/dist/serialization.cjs +0 -232
  75. package/serialization/types-cjs/index.d.cts +0 -182
  76. package/serialization/types-cjs/package.json +0 -3
  77. package/serialization/types-cjs/serializer-decode.d.cts +0 -182
  78. package/server-functions/dist/client.cjs +0 -646
  79. package/server-functions/dist/rich-args.cjs +0 -11
  80. package/server-functions/dist/server.cjs +0 -1077
  81. package/server-functions/dist/server.dev.cjs +0 -1077
  82. package/storage/dist/storage.cjs +0 -12
  83. package/storage/types-cjs/index.d.cts +0 -28
  84. package/storage/types-cjs/package.json +0 -3
  85. package/types/core.d.ts +0 -6
  86. package/types-cjs/client.d.cts +0 -337
  87. package/types-cjs/cookies.d.cts +0 -93
  88. package/types-cjs/core.d.cts +0 -6
  89. package/types-cjs/frames/client.d.cts +0 -36
  90. package/types-cjs/frames/frame-client.d.cts +0 -338
  91. package/types-cjs/frames/frame-sink.d.cts +0 -194
  92. package/types-cjs/frames/frame-transport.d.cts +0 -222
  93. package/types-cjs/frames/serializer.d.cts +0 -182
  94. package/types-cjs/frames/server.d.cts +0 -52
  95. package/types-cjs/index.d.cts +0 -230
  96. package/types-cjs/jsx-properties.d.cts +0 -93
  97. package/types-cjs/jsx.d.cts +0 -4150
  98. package/types-cjs/package.json +0 -3
  99. package/types-cjs/response.d.cts +0 -174
  100. package/types-cjs/serializer-decode.d.cts +0 -182
  101. package/types-cjs/serializer.d.cts +0 -182
  102. package/types-cjs/server-functions/client.d.cts +0 -201
  103. package/types-cjs/server-functions/flash.d.cts +0 -38
  104. package/types-cjs/server-functions/rich-args.d.cts +0 -10
  105. package/types-cjs/server-functions/server.d.cts +0 -588
  106. package/types-cjs/server-functions/shared.d.cts +0 -523
  107. package/types-cjs/server-mock.d.cts +0 -277
  108. package/types-cjs/server.d.cts +0 -523
@@ -1,10 +1,77 @@
1
1
  import type { RequestEvent, RequestEventLocals, ResponseStub } from "./client.js";
2
- /** Static asset manifest produced by a build (e.g. parsed Vite manifest.json). */
2
+ import type { JSX } from "./jsx.js";
3
+ import type { ServerErrorSite } from "solid-js";
4
+ /**
5
+ * Where a server-side failure was met, as the server error hook hears it —
6
+ * the client's view of the server entry's type (see `configureServerErrors`
7
+ * there). `kind: "render"`: `fallback`/`client`/`failed`; `kind:
8
+ * "server-function"`: `thrown`/`channel`.
9
+ */
10
+ export interface ServerErrorContext extends Omit<ServerErrorSite, "event"> {
11
+ event?: RequestEvent;
12
+ }
13
+ /** The server error hook (see the server entry's `configureServerErrors`). Its return is the wire value; nothing for the default. */
14
+ export type ServerErrorHook = (error: unknown, context: ServerErrorContext) => unknown | void;
15
+ export interface ServerErrorsConfig {
16
+ onError?: ServerErrorHook;
17
+ }
18
+ /**
19
+ * Registers the ambient server error hook. Server-only; on the client this
20
+ * is a no-op so isomorphic setup code can call it unguarded.
21
+ */
22
+ export declare function configureServerErrors(_config: ServerErrorsConfig): void;
23
+ type PreloadLinkAttributes = {
24
+ type?: string;
25
+ crossorigin?: JSX.HTMLCrossorigin;
26
+ integrity?: string;
27
+ referrerpolicy?: JSX.HTMLReferrerPolicy;
28
+ fetchpriority?: JSX.HTMLFetchPriority;
29
+ media?: string;
30
+ };
31
+ /**
32
+ * An explicit `<link rel="preload">` emitted by the SSR asset pipeline.
33
+ *
34
+ * `as` is the HTML Standard's set of preload destinations exactly — anything
35
+ * else translates to null and the browser does nothing with the link.
36
+ *
37
+ * `imagesrcset` candidates must already be resolved by the integration: they
38
+ * are carried verbatim (a relative candidate resolves against the DOCUMENT
39
+ * URL, not the manifest base). Pair it with `imagesizes` whenever a candidate
40
+ * uses a width descriptor, which the spec requires — without it the source
41
+ * size falls back to `100vw` and the preload can miss the image the `<img>`
42
+ * selects. Omitting `href` is the spec's own recommendation for the source-set
43
+ * form: it would only serve browsers without `imagesrcset` support, and there
44
+ * it would likely preload the wrong candidate.
45
+ */
46
+ export type PreloadLink = PreloadLinkAttributes & ({
47
+ href: string;
48
+ as: Exclude<JSX.HTMLPreloadAs, "image">;
49
+ imagesrcset?: never;
50
+ imagesizes?: never;
51
+ } | {
52
+ href: string;
53
+ as: "image";
54
+ imagesrcset?: string;
55
+ imagesizes?: string;
56
+ } | {
57
+ href?: never;
58
+ as: "image";
59
+ imagesrcset: string;
60
+ imagesizes?: string;
61
+ });
62
+ /**
63
+ * Static asset graph consumed by the SSR pipeline. This is Solid's own
64
+ * contract — a parsed Vite client manifest satisfies it structurally
65
+ * (unknown fields pass through untyped), but any bundler integration can
66
+ * produce it. Only these fields are ever read: `preloads` is Solid's
67
+ * extension slot for explicit typed links the integration selects.
68
+ */
3
69
  export type AssetManifest = Record<string, {
4
70
  file: string;
5
71
  css?: string[];
6
72
  isEntry?: boolean;
7
73
  imports?: string[];
74
+ preloads?: PreloadLink[];
8
75
  }> & {
9
76
  _base?: string;
10
77
  };
@@ -17,6 +84,7 @@ export type InlineStyleAsset = {
17
84
  export type ResolvedAssets = {
18
85
  js: string[];
19
86
  css: (string | InlineStyleAsset)[];
87
+ preloads?: PreloadLink[];
20
88
  };
21
89
  /**
22
90
  * Resolver form of the manifest option — the primitive a dev server
@@ -24,8 +92,9 @@ export type ResolvedAssets = {
24
92
  * normalized into a sync resolver internally). `resolve` may return a
25
93
  * promise (async resolvers require streaming rendering); CSS entries may be
26
94
  * 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 }`.
95
+ * descriptors (emitted as `<style>` tags), and `preloads` carries explicit
96
+ * preload links selected by the integration. A bare `resolve`-shaped
97
+ * function is accepted as shorthand for `{ resolve }`.
29
98
  */
30
99
  export type AssetResolver = {
31
100
  resolve(key: string): ResolvedAssets | null | undefined | Promise<ResolvedAssets | null | undefined>;
@@ -39,6 +108,15 @@ export type AssetResolver = {
39
108
  };
40
109
  /** Bare-function shorthand for `AssetResolver` (no sync fast path). */
41
110
  export type AssetResolverFn = (key: string) => ResolvedAssets | null | undefined | Promise<ResolvedAssets | null | undefined>;
111
+ /**
112
+ * CSP nonce for the tags a server render emits. A string applies to both
113
+ * nonce-aware destinations; a `{ script, style }` pair routes each tag to
114
+ * its destination's nonce, with `false` leaving that destination un-nonced.
115
+ */
116
+ export type CSPNonce = string | {
117
+ script: string | false;
118
+ style: string | false;
119
+ };
42
120
  /**
43
121
  * Renders a component tree synchronously to an HTML string. Async reads inside
44
122
  * `<Loading>` boundaries emit their `fallback` content; for full-graph
@@ -55,12 +133,13 @@ export type AssetResolverFn = (key: string) => ResolvedAssets | null | undefined
55
133
  * ```
56
134
  */
57
135
  export declare function renderToString<T>(fn: () => T, options?: {
58
- nonce?: string;
136
+ nonce?: CSPNonce;
59
137
  renderId?: string;
60
138
  noScripts?: boolean;
61
139
  plugins?: any[];
62
140
  manifest?: AssetManifest | AssetResolver | AssetResolverFn;
63
- onError?: (err: any) => void;
141
+ /** This render's server error hook, ahead of `configureServerErrors`' (see the server entry). */
142
+ onError?: ServerErrorHook;
64
143
  /**
65
144
  * Embedded-render contract for hosts that own the document. When the
66
145
  * render output contains no `</head>`, everything head-bound (resolved
@@ -100,7 +179,7 @@ export declare function renderToString<T>(fn: () => T, options?: {
100
179
  * ```
101
180
  */
102
181
  export declare function renderToStream<T>(fn: () => T, options?: {
103
- nonce?: string;
182
+ nonce?: CSPNonce;
104
183
  renderId?: string;
105
184
  noScripts?: boolean;
106
185
  plugins?: any[];
@@ -111,7 +190,8 @@ export declare function renderToStream<T>(fn: () => T, options?: {
111
190
  onCompleteAll?: (info: {
112
191
  write: (v: string) => void;
113
192
  }) => void;
114
- onError?: (err: any) => void;
193
+ /** This render's server error hook, ahead of `configureServerErrors`' (see the server entry). */
194
+ onError?: ServerErrorHook;
115
195
  /**
116
196
  * Embedded-render contract for hosts that own the document. When the
117
197
  * shell contains no `</head>`, everything head-bound at first flush
@@ -123,6 +203,14 @@ export declare function renderToStream<T>(fn: () => T, options?: {
123
203
  * the shell has a `</head>` (splicing is automatic then).
124
204
  */
125
205
  onHead?: (head: string) => void;
206
+ /**
207
+ * The request's lifecycle. Aborting tears the render down exactly as a
208
+ * client disconnect does (`SSR_STREAM_ABANDONED`, `data.reason:
209
+ * "signal"`); the one teardown handle for a host whose transport cannot
210
+ * report a dead consumer through the sink or the readable view — pass
211
+ * `request.signal`.
212
+ */
213
+ signal?: AbortSignal;
126
214
  }): {
127
215
  /**
128
216
  * Awaiting the stream resolves with the complete HTML once every boundary
@@ -171,8 +259,9 @@ export declare function getExpectedRedirectStatus(response: ResponseStub): numbe
171
259
  * shell flush, a pre-flush `Location` becomes a real redirect
172
260
  * (`getExpectedRedirectStatus`), and a post-flush one appends the
173
261
  * nonce-aware `<script>window.location=...</script>` fallback. String
174
- * results return a `Response` synchronously; stream results resolve at
175
- * shell flush. Server-only.
262
+ * results return a `Response` synchronously (an awaited `renderToStream`
263
+ * result arrives already committed — its head froze at completion); stream
264
+ * results resolve at shell flush. Server-only.
176
265
  */
177
266
  export declare function createSSRResponse(result: string, event: RequestEvent | undefined, options?: {
178
267
  responseInit?: ResponseInit;
@@ -208,7 +297,7 @@ export declare function commitEventResponse(response: Response, event?: RequestE
208
297
  */
209
298
  export declare function composeMiddleware(middlewares: FetchMiddleware[]): (request: Request, next: (request?: Request) => Response | Promise<Response>) => Promise<Response>;
210
299
  /**
211
- * Compiler primitive — emitted by JSX-DOM-Expressions for tagged-template
300
+ * Compiler primitive — emitted by Solid's JSX compiler for tagged-template
212
301
  * SSR output. Not meant for hand-written code.
213
302
  * @internal
214
303
  */
@@ -216,13 +305,20 @@ export declare function ssr(template: string[] | string, ...nodes: any[]): {
216
305
  t: string;
217
306
  };
218
307
  /**
219
- * Compiler primitive — emitted by JSX-DOM-Expressions for SSR element
308
+ * Compiler primitive — emitted by Solid's JSX compiler for SSR element
220
309
  * output. Not meant for hand-written code.
221
310
  * @internal
222
311
  */
223
- export declare function ssrElement(name: string, props: any, children: any, needsId: boolean): {
312
+ export declare function ssrElement(name: string, props: any | any[] | (() => any | any[]), children: any, needsId: boolean, skip?: (key: string) => boolean, attrs?: string | (() => string)): {
224
313
  t: string;
225
314
  };
315
+ /**
316
+ * Compiler primitive — serializes one attribute of a spread element as
317
+ * `ssrElement` would, for a dynamic attribute after the element's last
318
+ * spread. Not meant for hand-written code.
319
+ * @internal
320
+ */
321
+ export declare function ssrElementAttribute(key: string, value: any): string;
226
322
  /**
227
323
  * Compiler primitive — serializes a class value (string, object map, or
228
324
  * array) for SSR output. Not meant for hand-written code.
@@ -268,10 +364,11 @@ export declare function ssrHydrationKey(): string;
268
364
  * Not meant for hand-written code.
269
365
  * @internal
270
366
  */
271
- export declare function resolveSSRNode(node: any, result?: any, top?: boolean): any;
367
+ export declare function resolveSSRNode(node: any, result?: any, top?: boolean, nested?: boolean): any;
272
368
  /**
273
369
  * Escapes a string for safe inclusion in HTML output. Used by the SSR
274
370
  * runtime; not generally part of user code.
275
371
  * @internal
276
372
  */
277
373
  export declare function escape(s: any, attr?: boolean): any;
374
+ export {};
@@ -0,0 +1,77 @@
1
+ import { type FrameProducedEvent, type RenderEvent } from "./observe.js";
2
+ import { type TraceRecord } from "./trace.js";
3
+ import type { RequestEvent } from "./server.js";
4
+ /**
5
+ * The one gate for a server record and the `Server-Timing` metric projected
6
+ * from it (`TimedWork` in trace.ts): whether the runtime builds the record
7
+ * of `type` — `"invocation"` (→ `solid-invocation`), `"render"` (→
8
+ * `solid-shell`), `"boundary"` (→ `solid-boundary`, gated in the reactive
9
+ * library's boundary with this same rule). Dev builds always: dev is the
10
+ * panel's home, and the boundary already measures for its dev checks.
11
+ * Observe builds while a listener is on the type (`observed`), so an app
12
+ * with no observer sees no wire change; the record is then delivered AND
13
+ * the metric written from it — one clock, one object. `false` in prod,
14
+ * where `records()` is `undefined`.
15
+ */
16
+ export declare function timesServerWork(type: "invocation" | "render" | "boundary"): boolean;
17
+ /** What the renderer holds while a render is being recorded. */
18
+ export interface RenderObservation {
19
+ /**
20
+ * The shell is complete — for a stream, handed to the sink; for a string,
21
+ * the document assembled: stamps `shellMs`, the `solid-shell` metric's
22
+ * duration. Once; a later call is ignored.
23
+ */
24
+ shell(): void;
25
+ /** A `<Loading>` boundary the shell waited on settled: counts it (`boundaries`). */
26
+ boundary(): void;
27
+ /** The render ended; delivers the record. Once. */
28
+ settle(outcome: RenderEvent["outcome"]): void;
29
+ }
30
+ /**
31
+ * Opens the `"render"` record for a render of `mode` — on the request's
32
+ * trace record, where the head commit reads it (`TraceRecord.render`) —
33
+ * when `timesServerWork("render")`; `undefined` otherwise, and the renderer
34
+ * then does nothing extra, not even read the clock. The record is built as
35
+ * the render proceeds and delivered at `settle`, to a listener if there is
36
+ * one; `event` is the request the render serves, the record's live half.
37
+ */
38
+ export declare function observeRender(trace: TraceRecord, mode: RenderEvent["mode"], event: RequestEvent | undefined): RenderObservation | undefined;
39
+ /** What the runtime passes an observation from either dispatch leg. */
40
+ export interface InvocationContext {
41
+ id: string;
42
+ direct: boolean;
43
+ event: RequestEvent;
44
+ request?: Request;
45
+ args: unknown[];
46
+ }
47
+ /** What the frame producer hands an observation: the stream's identity. */
48
+ export interface FrameObservation {
49
+ /** Counts the chunk — call for every chunk written after `start`. */
50
+ chunk(chunk: {
51
+ type: string;
52
+ id: string;
53
+ }): void;
54
+ /** Delivers the record. `error` is the value thrown on the synchronous failure path. */
55
+ settle(outcome: FrameProducedEvent["outcome"], error?: unknown): void;
56
+ }
57
+ /**
58
+ * Opens the observation of one frame stream, at its `start`; the producer
59
+ * feeds it every chunk and settles it at `complete`. `undefined` with no
60
+ * listener or outside observe builds — the producer then does nothing
61
+ * extra, not even read the clock.
62
+ */
63
+ export declare function observeFrame(frame: {
64
+ id: string;
65
+ version: number;
66
+ }): FrameObservation | undefined;
67
+ /**
68
+ * Runs `execute` — the wrapped server-function execution — and reports it
69
+ * as an `"invocation"` record once it settles: synchronously for a sync
70
+ * return or throw, at resolution/rejection for a promise. Returns
71
+ * `execute`'s value (a promise is re-wrapped, still a native Promise);
72
+ * throws what it throws. Timed while `timesServerWork("invocation")` — the
73
+ * duration also rides the response's `Server-Timing` — and, with no
74
+ * listener in an observe build or outside observe builds altogether, it is
75
+ * `execute()` and nothing else.
76
+ */
77
+ export declare function observeInvocation<T>(context: InvocationContext, execute: () => T): T;