@solidjs/web 2.0.0-rc.3 → 2.0.0-rc.5
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/dist/dev.cjs +398 -17
- package/dist/dev.js +396 -19
- package/dist/server.cjs +166 -38
- package/dist/server.js +165 -39
- package/dist/web.cjs +369 -17
- package/dist/web.js +367 -19
- package/frames/dist/client.cjs +41 -8
- package/frames/dist/client.dev.cjs +41 -8
- package/frames/dist/client.dev.js +41 -8
- package/frames/dist/client.js +41 -8
- package/frames/dist/server.cjs +432 -44
- package/frames/dist/server.js +432 -44
- package/package.json +2 -2
- package/serialization/dist/decode.cjs +4 -2
- package/serialization/dist/decode.js +4 -2
- package/serialization/dist/serialization.cjs +12 -8
- package/serialization/dist/serialization.js +12 -8
- package/serialization/types/index.d.ts +7 -0
- package/serialization/types/serializer-decode.d.ts +14 -1
- package/serialization/types/serializer.d.ts +7 -0
- package/serialization/types-cjs/index.d.cts +7 -0
- package/serialization/types-cjs/serializer-decode.d.cts +14 -1
- package/serialization/types-cjs/serializer.d.cts +7 -0
- package/server-functions/dist/client.cjs +271 -47
- package/server-functions/dist/client.js +264 -47
- package/server-functions/dist/server.cjs +872 -131
- package/server-functions/dist/server.dev.cjs +892 -131
- package/server-functions/dist/server.dev.js +884 -131
- package/server-functions/dist/server.js +864 -131
- package/types/client.d.ts +4 -2
- package/types/cookies.d.ts +6 -14
- package/types/frames/frame-client.d.ts +4 -0
- package/types/frames/serializer-decode.d.ts +14 -1
- package/types/frames/serializer.d.ts +7 -0
- package/types/index.d.ts +1 -0
- package/types/jsx.d.ts +11 -16
- package/types/patch-driver.d.ts +3 -0
- package/types/response.d.ts +20 -1
- package/types/serializer-decode.d.ts +14 -1
- package/types/serializer.d.ts +7 -0
- package/types/server-functions/client.d.ts +58 -7
- package/types/server-functions/flash.d.ts +9 -0
- package/types/server-functions/registry.d.ts +38 -1
- package/types/server-functions/server.d.ts +66 -14
- package/types/server-functions/shared.d.ts +122 -16
- package/types/server-mock.d.ts +17 -2
- package/types/server.d.ts +16 -2
- package/types-cjs/client.d.cts +4 -2
- package/types-cjs/cookies.d.cts +6 -14
- package/types-cjs/frames/frame-client.d.cts +4 -0
- package/types-cjs/frames/serializer-decode.d.cts +14 -1
- package/types-cjs/frames/serializer.d.cts +7 -0
- package/types-cjs/index.d.cts +1 -0
- package/types-cjs/jsx.d.cts +11 -16
- package/types-cjs/patch-driver.d.cts +3 -0
- package/types-cjs/response.d.cts +20 -1
- package/types-cjs/serializer-decode.d.cts +14 -1
- package/types-cjs/serializer.d.cts +7 -0
- package/types-cjs/server-functions/client.d.cts +58 -7
- package/types-cjs/server-functions/flash.d.cts +9 -0
- package/types-cjs/server-functions/registry.d.cts +38 -1
- package/types-cjs/server-functions/server.d.cts +66 -14
- package/types-cjs/server-functions/shared.d.cts +122 -16
- package/types-cjs/server-mock.d.cts +17 -2
- package/types-cjs/server.d.cts +16 -2
package/types/client.d.ts
CHANGED
|
@@ -79,6 +79,8 @@ export interface RequestEvent {
|
|
|
79
79
|
export type { CookieOptions } from "./cookies.js";
|
|
80
80
|
export type { ServerFunction, ServerFunctionMetadata, ServerFunctionRPC } from "./server-functions/shared.js";
|
|
81
81
|
export declare const waitAsset: (promise: Promise<unknown>) => void;
|
|
82
|
+
export declare let listDriver: ((parent: Node, listFn: any, marker?: Node, lateClassic?: () => void) => boolean) | undefined;
|
|
83
|
+
export declare function installListDriver(driver: typeof listDriver): void;
|
|
82
84
|
export { DOMWithState, ChildProperties, DOMElements, SVGElements, MathMLElements, VoidElements, RawTextElements, Namespaces, DelegatedEvents } from "./constants.js";
|
|
83
85
|
/** Client stub — hydration bootstrap is a server-only emit. */
|
|
84
86
|
export declare function generateHydrationScript(_options?: {
|
|
@@ -145,10 +147,10 @@ export declare function spread<T>(node: Element, accessor: T, skipChildren?: Boo
|
|
|
145
147
|
export declare function dynamicProperty(props: unknown, key: string): unknown;
|
|
146
148
|
export declare function applyRef<T extends Element = Element>(r: ((element: NoInfer<T>) => void) | ((element: NoInfer<T>) => void)[], element: T): void;
|
|
147
149
|
export declare function ref(fn: () => ((element: Element) => void) | ((element: Element) => void)[], element: Element): void;
|
|
148
|
-
|
|
150
|
+
/** Compiler-emitted primitive; not for hand-written code. @internal */
|
|
149
151
|
export declare function scope<T extends () => any>(fn: T): T;
|
|
150
152
|
export declare function installHydrationRuntime(): void;
|
|
151
|
-
|
|
153
|
+
/**
|
|
152
154
|
* Compiler-emitted primitive; not for hand-written code.
|
|
153
155
|
* @internal
|
|
154
156
|
*/
|
package/types/cookies.d.ts
CHANGED
|
@@ -13,6 +13,12 @@ export interface CookieOptions {
|
|
|
13
13
|
secure?: boolean;
|
|
14
14
|
/** Cookie `SameSite` attribute, any case. */
|
|
15
15
|
sameSite?: "lax" | "strict" | "none" | "Lax" | "Strict" | "None";
|
|
16
|
+
/**
|
|
17
|
+
* Emit the `Partitioned` attribute (CHIPS): a third-party cookie keyed to
|
|
18
|
+
* the top-level site it was set under — the only third-party cookie that
|
|
19
|
+
* keeps working as browsers finish removing the rest. Requires `secure`.
|
|
20
|
+
*/
|
|
21
|
+
partitioned?: boolean;
|
|
16
22
|
}
|
|
17
23
|
/**
|
|
18
24
|
* Parses a `Cookie` request header into a name → value map. Names and
|
|
@@ -25,20 +31,6 @@ export interface CookieOptions {
|
|
|
25
31
|
* `parseCookieHeader(event.request.headers.get("cookie"))`.
|
|
26
32
|
*/
|
|
27
33
|
export declare function parseCookieHeader(header: string | null | undefined): Record<string, string>;
|
|
28
|
-
/**
|
|
29
|
-
* Serializes a cookie to a `Set-Cookie` header value. The name and value
|
|
30
|
-
* are `encodeURIComponent`-encoded (the parser decodes symmetrically);
|
|
31
|
-
* `path` defaults to `/` — the only defaulted attribute — and every other
|
|
32
|
-
* attribute is emitted exactly when the caller asked for it: `domain`,
|
|
33
|
-
* `maxAge` (seconds, truncated to an integer), `expires` (a `Date`),
|
|
34
|
-
* `httpOnly`, `secure`, `sameSite` (`"lax" | "strict" | "none"`, any
|
|
35
|
-
* case).
|
|
36
|
-
*
|
|
37
|
-
* The write half of the platform gap — the blessed response-cookie write
|
|
38
|
-
* is `event.response.headers.append("set-cookie", serializeCookie(name,
|
|
39
|
-
* value, options))`, which every head materialization path carries to the
|
|
40
|
-
* wire entry-by-entry.
|
|
41
|
-
*/
|
|
42
34
|
export declare function serializeCookie(name: string, value: string, options?: CookieOptions): string;
|
|
43
35
|
export declare const FLASH_COOKIE = "flash";
|
|
44
36
|
/** Whether a Cookie header carries a flash cookie (readable or not). */
|
|
@@ -105,6 +105,18 @@ export interface JSONCodecOptions {
|
|
|
105
105
|
disabledFeatures?: number;
|
|
106
106
|
/** Maximum parse/deserialize depth. Defaults to 64. Must match on both peers. */
|
|
107
107
|
depthLimit?: number;
|
|
108
|
+
/**
|
|
109
|
+
* Whether serialized `Error`s carry their `.stack` — server file paths,
|
|
110
|
+
* internal function names, the shape of the deployment — to the peer.
|
|
111
|
+
* Defaults to `NODE_ENV === "development"`, but that signal describes the
|
|
112
|
+
* PROCESS, not the artifact: a production build running with
|
|
113
|
+
* `NODE_ENV=development` (a base image, a stray dotenv) ships stacks to
|
|
114
|
+
* the wire — including for errors marked safe with `markSafeError`, whose
|
|
115
|
+
* stacks traverse application code (#3152). Set `false` to pin production
|
|
116
|
+
* disclosure regardless of the ambient variable. Encode-side only; the
|
|
117
|
+
* decode side is always permissive, so it need not match peers.
|
|
118
|
+
*/
|
|
119
|
+
serializeErrorStacks?: boolean;
|
|
108
120
|
}
|
|
109
121
|
/**
|
|
110
122
|
* A resident, response-scoped decode table over the keyed JSON codec: apply
|
|
@@ -142,10 +154,11 @@ export declare const DEFAULT_WEB_PLUGINS: any; /**
|
|
|
142
154
|
* Integration-facing; may change (see the entry banner).
|
|
143
155
|
*/
|
|
144
156
|
export declare function resolveSerializerPlugins(customPlugins?: SerializerPlugin[]): SerializerPlugin[];
|
|
145
|
-
export declare function resolveCodecOptions({ plugins, disabledFeatures, depthLimit }?: JSONCodecOptions): {
|
|
157
|
+
export declare function resolveCodecOptions({ plugins, disabledFeatures, depthLimit, serializeErrorStacks }?: JSONCodecOptions): {
|
|
146
158
|
plugins: SerializerPlugin<any, any>[];
|
|
147
159
|
disabledFeatures: any;
|
|
148
160
|
depthLimit: number;
|
|
161
|
+
serializeErrorStacks: boolean;
|
|
149
162
|
}; /**
|
|
150
163
|
* Creates the decoding counterpart of `serializeJSON`. Cross-references
|
|
151
164
|
* between chunks resolve through state shared across calls, so all chunks
|
|
@@ -19,6 +19,13 @@ export interface WebSerializerOptions {
|
|
|
19
19
|
* any override — serialized stacks leak server paths to the client.
|
|
20
20
|
*/
|
|
21
21
|
disabledFeatures?: number;
|
|
22
|
+
/**
|
|
23
|
+
* Whether serialized `Error`s carry their `.stack`. Defaults to
|
|
24
|
+
* `NODE_ENV === "development"`; set `false` to pin production disclosure
|
|
25
|
+
* to the deployment rather than the ambient variable (#3152 — see
|
|
26
|
+
* `JSONCodecOptions.serializeErrorStacks`).
|
|
27
|
+
*/
|
|
28
|
+
serializeErrorStacks?: boolean;
|
|
22
29
|
/** Extra plugins, composed ahead of `DEFAULT_WEB_PLUGINS`. */
|
|
23
30
|
plugins?: SerializerPlugin[];
|
|
24
31
|
/** Receives each emitted script chunk. */
|
package/types/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Component } from "solid-js";
|
|
2
2
|
import type { JSX } from "./jsx.js";
|
|
3
3
|
export * from "./client.js";
|
|
4
|
+
export { patchDriver, rowProof, driveList } from "./patch-driver.js";
|
|
4
5
|
export * from "./server-mock.js";
|
|
5
6
|
export * from "./response.js";
|
|
6
7
|
export type { JSX } from "./jsx.js";
|
package/types/jsx.d.ts
CHANGED
|
@@ -1080,6 +1080,7 @@ export namespace JSX {
|
|
|
1080
1080
|
type HTMLFormEncType = "application/x-www-form-urlencoded" | "multipart/form-data" | "text/plain";
|
|
1081
1081
|
type HTMLFormMethod = "post" | "get" | "dialog";
|
|
1082
1082
|
type HTMLCrossorigin = "anonymous" | "use-credentials" | EnumeratedAcceptsEmpty;
|
|
1083
|
+
type HTMLFetchPriority = "high" | "low" | "auto";
|
|
1083
1084
|
type HTMLReferrerPolicy =
|
|
1084
1085
|
| "no-referrer"
|
|
1085
1086
|
| "no-referrer-when-downgrade"
|
|
@@ -1105,19 +1106,8 @@ export namespace JSX {
|
|
|
1105
1106
|
| "allow-top-navigation"
|
|
1106
1107
|
| "allow-top-navigation-by-user-activation"
|
|
1107
1108
|
| "allow-top-navigation-to-custom-protocols";
|
|
1108
|
-
type
|
|
1109
|
-
|
|
1110
|
-
| "document"
|
|
1111
|
-
| "embed"
|
|
1112
|
-
| "fetch"
|
|
1113
|
-
| "font"
|
|
1114
|
-
| "image"
|
|
1115
|
-
| "object"
|
|
1116
|
-
| "script"
|
|
1117
|
-
| "style"
|
|
1118
|
-
| "track"
|
|
1119
|
-
| "video"
|
|
1120
|
-
| "worker";
|
|
1109
|
+
type HTMLPreloadAs = "fetch" | "font" | "image" | "script" | "style" | "track";
|
|
1110
|
+
type HTMLLinkAs = HTMLPreloadAs | "audio" | "document" | "embed" | "object" | "video" | "worker";
|
|
1121
1111
|
|
|
1122
1112
|
interface AnchorHTMLAttributes<T> extends HTMLAttributes<T> {
|
|
1123
1113
|
download?: string | EnumeratedAcceptsEmpty | RemoveAttribute;
|
|
@@ -1367,7 +1357,7 @@ export namespace JSX {
|
|
|
1367
1357
|
browsingtopics?: string | RemoveAttribute;
|
|
1368
1358
|
crossorigin?: HTMLCrossorigin | RemoveAttribute;
|
|
1369
1359
|
decoding?: "sync" | "async" | "auto" | RemoveAttribute;
|
|
1370
|
-
fetchpriority?:
|
|
1360
|
+
fetchpriority?: HTMLFetchPriority | RemoveAttribute;
|
|
1371
1361
|
height?: number | string | RemoveAttribute;
|
|
1372
1362
|
ismap?: BooleanAttribute | RemoveAttribute;
|
|
1373
1363
|
loading?: "eager" | "lazy" | RemoveAttribute;
|
|
@@ -1522,7 +1512,7 @@ export namespace JSX {
|
|
|
1522
1512
|
color?: string | RemoveAttribute;
|
|
1523
1513
|
crossorigin?: HTMLCrossorigin | RemoveAttribute;
|
|
1524
1514
|
disabled?: BooleanAttribute | RemoveAttribute;
|
|
1525
|
-
fetchpriority?:
|
|
1515
|
+
fetchpriority?: HTMLFetchPriority | RemoveAttribute;
|
|
1526
1516
|
href?: string | RemoveAttribute;
|
|
1527
1517
|
hreflang?: string | RemoveAttribute;
|
|
1528
1518
|
imagesizes?: string | RemoveAttribute;
|
|
@@ -1713,7 +1703,7 @@ export namespace JSX {
|
|
|
1713
1703
|
blocking?: "render" | RemoveAttribute;
|
|
1714
1704
|
crossorigin?: HTMLCrossorigin | RemoveAttribute;
|
|
1715
1705
|
defer?: BooleanAttribute | RemoveAttribute;
|
|
1716
|
-
fetchpriority?:
|
|
1706
|
+
fetchpriority?: HTMLFetchPriority | RemoveAttribute;
|
|
1717
1707
|
for?: string | RemoveAttribute;
|
|
1718
1708
|
integrity?: string | RemoveAttribute;
|
|
1719
1709
|
nomodule?: BooleanAttribute | RemoveAttribute;
|
|
@@ -3500,6 +3490,11 @@ export namespace JSX {
|
|
|
3500
3490
|
* @url https://developer.mozilla.org/en-US/docs/Web/API/HTMLSelectElement
|
|
3501
3491
|
*/
|
|
3502
3492
|
select: SelectHTMLAttributes<HTMLSelectElement> & Properties<HTMLSelectElement>;
|
|
3493
|
+
/**
|
|
3494
|
+
* @url https://developer.mozilla.org/en-US/docs/Web/HTML/Element/selectedcontent
|
|
3495
|
+
* @url https://developer.mozilla.org/en-US/docs/Web/API/HTMLSelectedContentElement
|
|
3496
|
+
*/
|
|
3497
|
+
selectedcontent: HTMLAttributes<HTMLElement> & Properties<HTMLElement>;
|
|
3503
3498
|
/**
|
|
3504
3499
|
* @url https://developer.mozilla.org/en-US/docs/Web/HTML/Element/slot
|
|
3505
3500
|
* @url https://developer.mozilla.org/en-US/docs/Web/API/HTMLSlotElement
|
package/types/response.d.ts
CHANGED
|
@@ -16,7 +16,15 @@ export declare const ResponseEnvelope: {
|
|
|
16
16
|
export declare function isResponseEnvelope(value: unknown): value is ResponseEnvelope;
|
|
17
17
|
export declare const HREF: unique symbol;
|
|
18
18
|
export interface Href {
|
|
19
|
-
|
|
19
|
+
/**
|
|
20
|
+
* The brand doubles as a channel: when the slot holds a string it is the
|
|
21
|
+
* value's *logical* path — the routable pathname before an integration's
|
|
22
|
+
* display rendering (eg. a hash router's `#` prefix). `redirect()` prefers
|
|
23
|
+
* it over coercion so Location headers carry routable paths; `toString()`
|
|
24
|
+
* remains the display href for the DOM. `true` brands a value whose
|
|
25
|
+
* string form is already logical.
|
|
26
|
+
*/
|
|
27
|
+
[HREF]: true | string;
|
|
20
28
|
toString(): string;
|
|
21
29
|
}
|
|
22
30
|
/** Whether `value` is an `Href`-branded URL-bearing value. */
|
|
@@ -42,6 +50,8 @@ export declare const REVALIDATE_HEADER = "X-Revalidate";
|
|
|
42
50
|
export interface ResponseHelperInit extends ResponseInit {
|
|
43
51
|
revalidate?: string | string[];
|
|
44
52
|
}
|
|
53
|
+
/** @internal */
|
|
54
|
+
export declare const RESPONSE_HEADER_VALUE_LIMIT = 4096;
|
|
45
55
|
/**
|
|
46
56
|
* Response redirecting to `url` (default 302). `revalidate` names the
|
|
47
57
|
* cache keys the mutation invalidated.
|
|
@@ -52,6 +62,15 @@ export declare function redirect(url: string | Href, init?: number | ResponseHel
|
|
|
52
62
|
* them when omitted).
|
|
53
63
|
*/
|
|
54
64
|
export declare function reload(init?: ResponseHelperInit): Response;
|
|
65
|
+
/**
|
|
66
|
+
* Statuses HTTP forbids a body on — the `Response` constructor enforces it
|
|
67
|
+
* by throwing on ANY body, `JSON.stringify(undefined)`'s `"undefined"`
|
|
68
|
+
* included. Shared with the server-function encoder, which answers void
|
|
69
|
+
* results on these statuses with a real null-body response and reports
|
|
70
|
+
* value-carrying ones as authoring errors (#3095).
|
|
71
|
+
* @internal
|
|
72
|
+
*/
|
|
73
|
+
export declare const NULL_BODY_STATUSES: ReadonlySet<number>;
|
|
55
74
|
/**
|
|
56
75
|
* A value paired with response metadata (status, headers, `revalidate`) —
|
|
57
76
|
* for the things a naked return can't express. Progressive enhancement
|
|
@@ -105,6 +105,18 @@ export interface JSONCodecOptions {
|
|
|
105
105
|
disabledFeatures?: number;
|
|
106
106
|
/** Maximum parse/deserialize depth. Defaults to 64. Must match on both peers. */
|
|
107
107
|
depthLimit?: number;
|
|
108
|
+
/**
|
|
109
|
+
* Whether serialized `Error`s carry their `.stack` — server file paths,
|
|
110
|
+
* internal function names, the shape of the deployment — to the peer.
|
|
111
|
+
* Defaults to `NODE_ENV === "development"`, but that signal describes the
|
|
112
|
+
* PROCESS, not the artifact: a production build running with
|
|
113
|
+
* `NODE_ENV=development` (a base image, a stray dotenv) ships stacks to
|
|
114
|
+
* the wire — including for errors marked safe with `markSafeError`, whose
|
|
115
|
+
* stacks traverse application code (#3152). Set `false` to pin production
|
|
116
|
+
* disclosure regardless of the ambient variable. Encode-side only; the
|
|
117
|
+
* decode side is always permissive, so it need not match peers.
|
|
118
|
+
*/
|
|
119
|
+
serializeErrorStacks?: boolean;
|
|
108
120
|
}
|
|
109
121
|
/**
|
|
110
122
|
* A resident, response-scoped decode table over the keyed JSON codec: apply
|
|
@@ -142,10 +154,11 @@ export declare const DEFAULT_WEB_PLUGINS: any; /**
|
|
|
142
154
|
* Integration-facing; may change (see the entry banner).
|
|
143
155
|
*/
|
|
144
156
|
export declare function resolveSerializerPlugins(customPlugins?: SerializerPlugin[]): SerializerPlugin[];
|
|
145
|
-
export declare function resolveCodecOptions({ plugins, disabledFeatures, depthLimit }?: JSONCodecOptions): {
|
|
157
|
+
export declare function resolveCodecOptions({ plugins, disabledFeatures, depthLimit, serializeErrorStacks }?: JSONCodecOptions): {
|
|
146
158
|
plugins: SerializerPlugin<any, any>[];
|
|
147
159
|
disabledFeatures: any;
|
|
148
160
|
depthLimit: number;
|
|
161
|
+
serializeErrorStacks: boolean;
|
|
149
162
|
}; /**
|
|
150
163
|
* Creates the decoding counterpart of `serializeJSON`. Cross-references
|
|
151
164
|
* between chunks resolve through state shared across calls, so all chunks
|
package/types/serializer.d.ts
CHANGED
|
@@ -19,6 +19,13 @@ export interface WebSerializerOptions {
|
|
|
19
19
|
* any override — serialized stacks leak server paths to the client.
|
|
20
20
|
*/
|
|
21
21
|
disabledFeatures?: number;
|
|
22
|
+
/**
|
|
23
|
+
* Whether serialized `Error`s carry their `.stack`. Defaults to
|
|
24
|
+
* `NODE_ENV === "development"`; set `false` to pin production disclosure
|
|
25
|
+
* to the deployment rather than the ambient variable (#3152 — see
|
|
26
|
+
* `JSONCodecOptions.serializeErrorStacks`).
|
|
27
|
+
*/
|
|
28
|
+
serializeErrorStacks?: boolean;
|
|
22
29
|
/** Extra plugins, composed ahead of `DEFAULT_WEB_PLUGINS`. */
|
|
23
30
|
plugins?: SerializerPlugin[];
|
|
24
31
|
/** Receives each emitted script chunk. */
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import type { ServerFunction, ServerFunctionMetadata } from "./shared.js";
|
|
2
|
+
export { ChunkReader, ERROR_HEADER, FLASH_COOKIE, INSTANCE_HEADER, REDIRECT_HEADER, SERVER_FUNCTION_INVOKE, SINGLE_FLIGHT_HEADER, UNKNOWN_HEADER, clearFlashCookie, createChunk, decodeErrorHeaderValue, decodeRedirectHeaderValue, decodeResponse, decodeResponsePayload, deserializeStream, encodeErrorHeaderValue, frameAddress, getFlightDataConsumer, getFlightDataSourceIds, getServerFunctionMetadata, getServerFunctionsCodec, hasFlashCookie, invoke, isServerFunction, serializeString, subscribeFlightData, withMeta } from "./shared.js";
|
|
2
3
|
export { REVALIDATE_HEADER } from "../response.js";
|
|
3
4
|
import { JSONCodecOptions } from "../serializer-decode.js";
|
|
4
|
-
export type { FlightDataConsumer, FlightDataContext, ServerFunction, ServerFunctionMetadata, SingleFlightPayload } from "./shared.js";
|
|
5
|
+
export type { FlightDataConsumer, FlightDataContext, InvokeOptions, ServerFunction, ServerFunctionInvoker, ServerFunctionMetadata, SingleFlightPayload } from "./shared.js";
|
|
5
6
|
/** The context `prepareRequest` receives alongside the outgoing RequestInit. */
|
|
6
7
|
export interface PrepareRequestContext {
|
|
7
8
|
/** The build-stable id of the function being called. */
|
|
@@ -25,10 +26,11 @@ export type PrepareRequestHook = (init: RequestInit, context: PrepareRequestCont
|
|
|
25
26
|
/** Options for `configureServerFunctionsClient`. */
|
|
26
27
|
export interface ServerFunctionsClientConfig {
|
|
27
28
|
/**
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
29
|
+
* Mount path the server's HTTP handler answers on. Must match the server
|
|
30
|
+
* configuration — the id travels as the segment after it, and SSR'd
|
|
31
|
+
* reference `url`s (e.g. form actions) and client fetches both derive
|
|
32
|
+
* from it. Prefix it when the app serves from a base path
|
|
33
|
+
* (e.g. `` `${BASE_URL}_server` ``).
|
|
32
34
|
* @default "/_server"
|
|
33
35
|
*/
|
|
34
36
|
endpoint?: string;
|
|
@@ -38,6 +40,34 @@ export interface ServerFunctionsClientConfig {
|
|
|
38
40
|
* `decodeResponse` sees them too.
|
|
39
41
|
*/
|
|
40
42
|
codec?: JSONCodecOptions;
|
|
43
|
+
/**
|
|
44
|
+
* Sends every server-function request — retries, telemetry, a test
|
|
45
|
+
* double, or an app's own route. Always called as `(address, init)`, the
|
|
46
|
+
* address relative to the document as the global one receives it, so
|
|
47
|
+
* `parseServerFunctionUrl` reads the id back out for telemetry. `null`
|
|
48
|
+
* restores the global.
|
|
49
|
+
*
|
|
50
|
+
* ```ts
|
|
51
|
+
* configureServerFunctionsClient({
|
|
52
|
+
* fetch: (address, init) => fetch(rewrite(address), init)
|
|
53
|
+
* });
|
|
54
|
+
* ```
|
|
55
|
+
*
|
|
56
|
+
* Forward `init` — the call's `signal` rides on it, and dropping it voids
|
|
57
|
+
* both the caller's abort and the teardown a live source's `break`
|
|
58
|
+
* performs. Keep the call same-origin, since a cross-origin send is
|
|
59
|
+
* stamped `Sec-Fetch-Site: cross-site` and the handler's origin gate
|
|
60
|
+
* refuses it, and hand back what the peer answered, unread.
|
|
61
|
+
*
|
|
62
|
+
* A retrying wrapper may re-send a request that got NO response; it must
|
|
63
|
+
* never replay one whose response ended. A response that dies mid-body may
|
|
64
|
+
* have executed (mutations are not idempotent), and reconnecting a live
|
|
65
|
+
* source is the runtime's job — a replay would race it.
|
|
66
|
+
*
|
|
67
|
+
* The wrapper replaces delivery for the requests the runtime chooses to
|
|
68
|
+
* send; the call-to-request mapping itself is not contractual.
|
|
69
|
+
*/
|
|
70
|
+
fetch?: ((address: string, init: RequestInit) => Response | Promise<Response>) | null;
|
|
41
71
|
/**
|
|
42
72
|
* Runs before every server-function fetch. Return (or mutate and return)
|
|
43
73
|
* the RequestInit the transport will use; `context.meta` is the
|
|
@@ -125,9 +155,30 @@ export interface ServerFunctionInvocation {
|
|
|
125
155
|
id: string;
|
|
126
156
|
}
|
|
127
157
|
export declare function observeServerFunctionCalls(observer: (call: ServerFunctionCall) => void): () => void;
|
|
158
|
+
export declare function serverFunctionUrl(id: string, boundArgs?: readonly unknown[]): string;
|
|
159
|
+
export declare function parseServerFunctionUrl(url: string): string | null;
|
|
128
160
|
export declare function configureServerFunctionsClient(config?: ServerFunctionsClientConfig): void;
|
|
129
161
|
export declare function createServerReference(id: string, name?: string, base?: string): ServerFunction;
|
|
130
162
|
export declare function GET<A extends readonly any[], R>(fn: (...args: A) => R): ServerFunction<A, Awaited<R>>;
|
|
131
|
-
export
|
|
163
|
+
export interface LiveServerFunction<A extends readonly any[] = any[], R = any> {
|
|
164
|
+
(...args: A): LiveSource<R>;
|
|
165
|
+
/** The build-stable function id (stable across the client and server builds). */
|
|
166
|
+
readonly id: string;
|
|
167
|
+
/** URL invoking this function directly over HTTP. */
|
|
168
|
+
readonly url: string;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Declares a value-shaped live source: a server function returning an async
|
|
172
|
+
* iterable whose yields are successive VALUES of one logical query, with the
|
|
173
|
+
* contract that the source re-yields current state on every invocation.
|
|
174
|
+
* Calls to the returned reference produce an iterable that survives the
|
|
175
|
+
* connection — post-connect deaths re-invoke with exponential backoff
|
|
176
|
+
* (reset per healthy value, woken early by connectivity returning),
|
|
177
|
+
* first-connect failures reject like a normal call, and `break` aborts the
|
|
178
|
+
* in-flight request. Live calls are reads and never opt into single-flight
|
|
179
|
+
* enveloping. Wire state, if wanted, rides the returned iterable's
|
|
180
|
+
* `onstatus` hook. Compose with `GET` inside-out: `live(GET(fn))`.
|
|
181
|
+
*/
|
|
182
|
+
export declare function live<A extends readonly any[], R>(fn: (...args: A) => R): LiveServerFunction<A, Awaited<R>>;
|
|
132
183
|
export declare function registerServerReference(): never;
|
|
133
184
|
export declare function getServerFunctionInvocation(): ServerFunctionInvocation | undefined;
|
|
@@ -13,6 +13,15 @@ export interface FlashSubmission {
|
|
|
13
13
|
result?: any;
|
|
14
14
|
/** The thrown value, when the call threw. */
|
|
15
15
|
error?: any;
|
|
16
|
+
/**
|
|
17
|
+
* Set when the outcome was too large for the cookie's 4 KB ceiling and
|
|
18
|
+
* was degraded to fit (#3137): the input echo is dropped, and `result` /
|
|
19
|
+
* `error` may carry a bounded prefix — or the bare outcome flag `true` —
|
|
20
|
+
* rather than the full value. The submission still says what happened
|
|
21
|
+
* and where; integrations should render it as "succeeded (result too
|
|
22
|
+
* large to display)" rather than replaying the value.
|
|
23
|
+
*/
|
|
24
|
+
truncated?: boolean;
|
|
16
25
|
}
|
|
17
26
|
export declare function encodeFlashCookie(url: string, result: any, input: any[], thrown?: boolean): string;
|
|
18
27
|
export declare function decodeFlashCookie(cookieHeader: string | null): FlashSubmission | undefined;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export type { ServerFunction, ServerFunctionMetadata, ServerFunctionRPC } from "./shared.js";
|
|
1
|
+
export type { InvokeOptions, ServerFunction, ServerFunctionInvoker, ServerFunctionMetadata, ServerFunctionRPC } from "./shared.js";
|
|
2
|
+
import type { InvokeOptions } from "./shared.js";
|
|
2
3
|
export declare const SERVER_FUNCTION_METADATA: unique symbol;
|
|
3
4
|
/**
|
|
4
5
|
* Reads a server function reference's declaration metadata (e.g.
|
|
@@ -45,6 +46,42 @@ export declare function isServerFunction(fn: any): boolean;
|
|
|
45
46
|
* ```
|
|
46
47
|
*/
|
|
47
48
|
export declare function withMeta(fn: any, meta: any): any;
|
|
49
|
+
export declare const SERVER_FUNCTION_INVOKE: unique symbol;
|
|
50
|
+
/**
|
|
51
|
+
* Applies a server function once with per-call, invocation-scoped options —
|
|
52
|
+
* `Function.prototype.call` for server functions, the options bag in the
|
|
53
|
+
* `thisArg` slot (declaration wrappers like `GET` and `withMeta` are `bind`:
|
|
54
|
+
* they return a new reference with context baked in; `invoke` applies one
|
|
55
|
+
* call and leaves no residue on the reference).
|
|
56
|
+
*
|
|
57
|
+
* ```ts
|
|
58
|
+
* import { invoke } from "@solidjs/web/server-functions";
|
|
59
|
+
*
|
|
60
|
+
* const user = await invoke(getUser, { signal: controller.signal }, id);
|
|
61
|
+
* ```
|
|
62
|
+
*
|
|
63
|
+
* Options are strictly invocation-scoped — things that vary between calls
|
|
64
|
+
* of the SAME function and cannot be declared or configured: `signal`
|
|
65
|
+
* (the call's lifecycle; aborting rejects the call and cancels the
|
|
66
|
+
* request), `keepalive` (calls made while the page unloads), `priority`
|
|
67
|
+
* (fetch priority hint). Anything with a longer lifetime is refused with a
|
|
68
|
+
* pointer to its home: session-dynamic transport policy → `prepareRequest`;
|
|
69
|
+
* declaration-static shape → `GET`/`withMeta`; call policy (retries,
|
|
70
|
+
* dedupe, deadlines) → the data layer that owns the call, wired through
|
|
71
|
+
* `signal`.
|
|
72
|
+
*
|
|
73
|
+
* Dispatches through the reference's invocation channel
|
|
74
|
+
* (`SERVER_FUNCTION_INVOKE`). Core's declaration wrappers forward it —
|
|
75
|
+
* `GET` invokes over its query encoding, `live` ends its iteration on
|
|
76
|
+
* abort. Wrappers that share calls (caches, channels) may adapt or decline
|
|
77
|
+
* it; a data layer needs neither — it holds the reference below such
|
|
78
|
+
* wrappers and invokes it directly with its own signal. On the server the
|
|
79
|
+
* call runs in-process: `signal`
|
|
80
|
+
* rejects the caller (the work, like a server behind HTTP, runs on unless
|
|
81
|
+
* the function observes a signal itself) and the transport hints are
|
|
82
|
+
* no-ops, since they describe a wire that does not exist.
|
|
83
|
+
*/
|
|
84
|
+
export declare function invoke<A extends readonly any[], R>(fn: (...args: A) => R, options: InvokeOptions, ...args: A): R;
|
|
48
85
|
export declare const LIVE_SOURCE: unique symbol;
|
|
49
86
|
/**
|
|
50
87
|
* Fills the RPC seam. Called by the transport halves (client fetch RPC,
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
export { ERROR_HEADER, FLASH_COOKIE,
|
|
1
|
+
export { ERROR_HEADER, FLASH_COOKIE, INSTANCE_HEADER, REDIRECT_HEADER, SERVER_FUNCTION_INVOKE, SINGLE_FLIGHT_HEADER, UNKNOWN_HEADER, clearFlashCookie, decodeErrorHeaderValue, decodeRedirectHeaderValue, decodeResponse, decodeResponsePayload, encodeErrorHeaderValue, getServerFunctionMetadata, hasFlashCookie, invoke, isServerFunction, subscribeFlightData, withMeta } from "./shared.js";
|
|
2
2
|
export { decodeFlashCookie, encodeFlashCookie } from "./flash.js";
|
|
3
3
|
import { ResponseEnvelope } from "../response.js";
|
|
4
4
|
import { JSONCodecOptions } from "../serializer-decode.js";
|
|
5
5
|
import { RequestEvent } from "../server.js";
|
|
6
|
-
|
|
6
|
+
import type { ServerFunction, ServerFunctionMetadata } from "./shared.js";
|
|
7
|
+
export type { FlightDataConsumer, FlightDataContext, InvokeOptions, ServerFunction, ServerFunctionInvoker, ServerFunctionMetadata, SingleFlightPayload } from "./shared.js";
|
|
7
8
|
export type { FlashSubmission } from "./flash.js";
|
|
8
9
|
/**
|
|
9
10
|
* The request event a server function call runs under: the base
|
|
@@ -130,6 +131,18 @@ export interface ServerFunctionCSRFOptions {
|
|
|
130
131
|
* @default false
|
|
131
132
|
*/
|
|
132
133
|
allowRequestsWithoutOriginCheck?: boolean;
|
|
134
|
+
/**
|
|
135
|
+
* Applies the origin gate to GET-declared reads as well. By default the
|
|
136
|
+
* gate is skipped for declared reads: same-origin policy already keeps a
|
|
137
|
+
* cross-site caller from READING the response, and the gate's `Vary`
|
|
138
|
+
* fragments (or, on CDNs that ignore Vary, poisons) the shared-cache
|
|
139
|
+
* entries the `GET` helper exists to enable (#3071). The premise that
|
|
140
|
+
* skip rests on is `GET()`'s safety contract — declared reads are safe
|
|
141
|
+
* to EXECUTE from any origin (#3114). A deployment that does not rely
|
|
142
|
+
* on shared caches can enable this to gate its reads too.
|
|
143
|
+
* @default false
|
|
144
|
+
*/
|
|
145
|
+
protectDeclaredReads?: boolean;
|
|
133
146
|
}
|
|
134
147
|
/** Options for `configureServerFunctionsServer`. */
|
|
135
148
|
export interface ServerFunctionsServerConfig {
|
|
@@ -150,10 +163,13 @@ export interface ServerFunctionsServerConfig {
|
|
|
150
163
|
*/
|
|
151
164
|
wrapInvocation?: WrapInvocationHook;
|
|
152
165
|
/**
|
|
153
|
-
* The single-flight hook: produces the data payload folded into
|
|
166
|
+
* The unnamed single-flight hook: produces the data payload folded into
|
|
154
167
|
* responses of calls that opted in (see `CollectFlightDataHook`).
|
|
155
168
|
* Registered once by the integration that owns data production (a
|
|
156
|
-
* router); per-handler `collectFlightData` options override it.
|
|
169
|
+
* router); per-handler `collectFlightData` options override it. Other
|
|
170
|
+
* integrations contribute additively through
|
|
171
|
+
* `registerFlightDataSource(id, hook)` instead of competing for this
|
|
172
|
+
* slot.
|
|
157
173
|
*/
|
|
158
174
|
collectFlightData?: CollectFlightDataHook;
|
|
159
175
|
/**
|
|
@@ -208,10 +224,11 @@ export interface ServerFunctionsServerConfig {
|
|
|
208
224
|
*/
|
|
209
225
|
handleNoJS?: ((result: unknown, request: Request, args: unknown[], thrown?: boolean) => Response | Promise<Response>) | null;
|
|
210
226
|
/**
|
|
211
|
-
*
|
|
212
|
-
*
|
|
213
|
-
*
|
|
214
|
-
*
|
|
227
|
+
* Mount path the HTTP handler answers on. Must match the client
|
|
228
|
+
* configuration — the id travels as the segment after it, a request whose
|
|
229
|
+
* path does not start with it is not a call, and SSR'd reference `url`s
|
|
230
|
+
* (e.g. form actions) derive from it. Prefix it when the app serves from
|
|
231
|
+
* a base path (e.g. `` `${BASE_URL}_server` ``).
|
|
215
232
|
* @default "/_server"
|
|
216
233
|
*/
|
|
217
234
|
endpoint?: string;
|
|
@@ -227,6 +244,24 @@ export interface ServerFunctionsServerConfig {
|
|
|
227
244
|
* `decodeResponse` sees them too.
|
|
228
245
|
*/
|
|
229
246
|
codec?: JSONCodecOptions;
|
|
247
|
+
/**
|
|
248
|
+
* Upper bound, in bytes, on a call's argument payload — the POST body,
|
|
249
|
+
* or the `?args=` query encoding. The payload is buffered and decoded
|
|
250
|
+
* before dispatch, so its cost is paid before application code can
|
|
251
|
+
* decline it; the bound is enforced up front and a request over it is
|
|
252
|
+
* refused with `413` before any decoding (#3115). Raise it for functions
|
|
253
|
+
* that accept large uploads, or set `Infinity` to remove the bound.
|
|
254
|
+
* @default 1_048_576 (1 MiB)
|
|
255
|
+
*/
|
|
256
|
+
bodySizeLimit?: number;
|
|
257
|
+
/**
|
|
258
|
+
* Upper bound on the number of arguments a call may carry. The decoded
|
|
259
|
+
* argument array is spread into the function call, so an unbounded list
|
|
260
|
+
* forces a range error out of any function regardless of what it does;
|
|
261
|
+
* past the bound the request is refused with `400` (#3115).
|
|
262
|
+
* @default 1000
|
|
263
|
+
*/
|
|
264
|
+
maxArguments?: number;
|
|
230
265
|
}
|
|
231
266
|
/**
|
|
232
267
|
* A registered server function: its build-stable id paired with the
|
|
@@ -346,6 +381,16 @@ export interface HandleServerFunctionOptions {
|
|
|
346
381
|
csrf?: boolean | ServerFunctionCSRFOptions;
|
|
347
382
|
/** Overrides the configured codec options for this handler. */
|
|
348
383
|
codec?: JSONCodecOptions;
|
|
384
|
+
/**
|
|
385
|
+
* Overrides the configured argument payload bound for this handler (see
|
|
386
|
+
* `ServerFunctionsServerConfig.bodySizeLimit`).
|
|
387
|
+
*/
|
|
388
|
+
bodySizeLimit?: number;
|
|
389
|
+
/**
|
|
390
|
+
* Overrides the configured argument count bound for this handler (see
|
|
391
|
+
* `ServerFunctionsServerConfig.maxArguments`).
|
|
392
|
+
*/
|
|
393
|
+
maxArguments?: number;
|
|
349
394
|
}
|
|
350
395
|
export interface ServerFunctionRequestCall {
|
|
351
396
|
type: "request";
|
|
@@ -365,6 +410,7 @@ export interface ServerFunctionResponseCall {
|
|
|
365
410
|
}
|
|
366
411
|
export type ServerFunctionCall = ServerFunctionRequestCall | ServerFunctionResponseCall;
|
|
367
412
|
export declare function configureServerFunctionsServer(config?: ServerFunctionsServerConfig): void;
|
|
413
|
+
export declare function registerFlightDataSource(source: string, hook: CollectFlightDataHook): () => void;
|
|
368
414
|
export declare function registerServerFunction<T extends any[], R>(id: string, callback: (...args: T) => R): (...args: T) => R;
|
|
369
415
|
export declare function getServerFunction<T extends any[], R>(id: string): (...args: T) => R;
|
|
370
416
|
export declare function registerServerReference<T extends any[], R>(id: string, fn: (...args: T) => R, name?: string): ServerFunctionReference<T, R>;
|
|
@@ -375,6 +421,8 @@ export declare function getServerFunctionInvocation(): ServerFunctionInvocation
|
|
|
375
421
|
export declare function getEventServerFunctionInvocation(event: RequestEvent | undefined): ServerFunctionInvocation | undefined;
|
|
376
422
|
export declare function foldSetCookies(headers: Headers, setCookies: readonly string[]): Headers;
|
|
377
423
|
export declare function createNoJSHandler(options?: NoJSHandlerOptions): (result: unknown, request: Request, args: unknown[], thrown?: boolean) => Response;
|
|
424
|
+
/** @internal */
|
|
425
|
+
export declare function guardFailures(value: any, state: any): any;
|
|
378
426
|
/**
|
|
379
427
|
* The response-side codec stream: `serializeStream` (shared.js) hardened
|
|
380
428
|
* with request-lifetime teardown. Server-only on purpose — the shared half
|
|
@@ -383,12 +431,14 @@ export declare function createNoJSHandler(options?: NoJSHandlerOptions): (result
|
|
|
383
431
|
* An abort of `signal` (the platform fires request.signal when the caller's
|
|
384
432
|
* fetch aborts or the tab goes away) or the consumer cancelling the
|
|
385
433
|
* ReadableStream (how platforms surface a dropped connection to the body)
|
|
386
|
-
* stops pending serialization and tears down
|
|
387
|
-
*
|
|
388
|
-
*
|
|
389
|
-
*
|
|
390
|
-
*
|
|
391
|
-
* the codec
|
|
434
|
+
* stops pending serialization and tears down EVERY async-iterable or
|
|
435
|
+
* ReadableStream source in the result graph, nested ones included (#3125) —
|
|
436
|
+
* each producer's `iterator.return()` / `reader.cancel()` runs, so
|
|
437
|
+
* generator `finally` blocks execute instead of the server pumping streams
|
|
438
|
+
* nobody is reading. The wiring rides guardFailures' walk: it already wraps
|
|
439
|
+
* every channel before the codec sees the value, so the demand gate and the
|
|
440
|
+
* teardown registry are threaded through its state (`{ items: rows() }` —
|
|
441
|
+
* a cursor beside a total — gets the same two guarantees as `return rows()`).
|
|
392
442
|
*/
|
|
393
443
|
export declare function serializeResponseStream(value: any, codecOptions: any, signal: any): ReadableStream<any>;
|
|
394
444
|
/** Message a sanitized (production) server error carries on the wire. */
|
|
@@ -396,4 +446,6 @@ export declare const GENERIC_SERVER_ERROR_MESSAGE = "Internal Server Error";
|
|
|
396
446
|
export declare function setServerFunctionsDev(dev: boolean): void;
|
|
397
447
|
export declare function sanitizeServerError(value: unknown): unknown;
|
|
398
448
|
export declare function observeServerFunctionCalls(observer: (call: ServerFunctionCall) => void): () => void;
|
|
449
|
+
export declare function serverFunctionUrl(id: string, boundArgs?: readonly unknown[]): string;
|
|
450
|
+
export declare function parseServerFunctionUrl(url: string): string | null;
|
|
399
451
|
export declare function handleServerFunctionRequest(request: Request, options?: HandleServerFunctionOptions): Promise<Response>;
|