@solidjs/web 2.0.0-rc.4 → 2.0.0-rc.6
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 +163 -36
- package/dist/dev.js +161 -37
- package/dist/server.cjs +178 -37
- package/dist/server.js +177 -38
- package/dist/web.cjs +143 -36
- package/dist/web.js +141 -37
- 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 +497 -44
- package/frames/dist/server.js +497 -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 +164 -35
- package/server-functions/dist/client.js +161 -36
- package/server-functions/dist/server.cjs +899 -136
- package/server-functions/dist/server.dev.cjs +919 -136
- package/server-functions/dist/server.dev.js +915 -137
- package/server-functions/dist/server.js +895 -137
- package/types/client.d.ts +2 -1
- package/types/constants.d.ts +3 -1
- 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/jsx.d.ts +11 -16
- package/types/response.d.ts +11 -0
- package/types/serializer-decode.d.ts +14 -1
- package/types/serializer.d.ts +7 -0
- package/types/server-functions/client.d.ts +22 -2
- package/types/server-functions/flash.d.ts +9 -0
- package/types/server-functions/server.d.ts +131 -11
- package/types/server-functions/shared.d.ts +77 -14
- package/types/server-mock.d.ts +17 -2
- package/types/server.d.ts +16 -2
- package/types-cjs/client.d.cts +2 -1
- package/types-cjs/constants.d.cts +3 -1
- 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/jsx.d.cts +11 -16
- package/types-cjs/response.d.cts +11 -0
- 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 +22 -2
- package/types-cjs/server-functions/flash.d.cts +9 -0
- package/types-cjs/server-functions/server.d.cts +131 -11
- package/types-cjs/server-functions/shared.d.cts +77 -14
- package/types-cjs/server-mock.d.cts +17 -2
- package/types-cjs/server.d.cts +16 -2
package/types/client.d.ts
CHANGED
|
@@ -136,7 +136,7 @@ export declare function claimElement<T extends Element>(node: T): T;
|
|
|
136
136
|
export declare function setAttribute(node: Element, name: string, value: string): void;
|
|
137
137
|
export declare function setAttributeNS(node: Element, namespace: string, name: string, value: string): void;
|
|
138
138
|
export declare function className(node: Element, value: JSX.ClassValue, prev?: JSX.ClassValue): void;
|
|
139
|
-
export declare function addEvent(node: Element, name: string, handler: EventListener | EventListenerObject | (EventListenerObject & AddEventListenerOptions), delegate: boolean): void;
|
|
139
|
+
export declare function addEvent(node: Element, name: string, handler: EventListener | EventListenerObject | (EventListenerObject & AddEventListenerOptions), delegate: boolean): EventListener | EventListenerObject | void;
|
|
140
140
|
export declare function style(node: Element, value: {
|
|
141
141
|
[k: string]: string;
|
|
142
142
|
}, prev?: {
|
|
@@ -149,6 +149,7 @@ export declare function applyRef<T extends Element = Element>(r: ((element: NoIn
|
|
|
149
149
|
export declare function ref(fn: () => ((element: Element) => void) | ((element: Element) => void)[], element: Element): void;
|
|
150
150
|
/** Compiler-emitted primitive; not for hand-written code. @internal */
|
|
151
151
|
export declare function scope<T extends () => any>(fn: T): T;
|
|
152
|
+
export declare function getInsertionParent(): Node | undefined;
|
|
152
153
|
export declare function installHydrationRuntime(): void;
|
|
153
154
|
/**
|
|
154
155
|
* Compiler-emitted primitive; not for hand-written code.
|
package/types/constants.d.ts
CHANGED
|
@@ -15,4 +15,6 @@ declare const Namespaces: Record<string, string>;
|
|
|
15
15
|
declare const VoidElements: Set<string>;
|
|
16
16
|
declare const RawTextElements: Set<string>;
|
|
17
17
|
declare const DOMElements: Set<string>;
|
|
18
|
-
|
|
18
|
+
declare const COMPOSED_BODY_FRAMING: ReadonlySet<string>;
|
|
19
|
+
declare function isHttpNavigationTarget(target: string): boolean;
|
|
20
|
+
export { DOMWithState, ChildProperties, DelegatedEvents, SVGElements, MathMLElements, VoidElements, RawTextElements, Namespaces, DOMElements, $$SLOT, $$HOST, COMPOSED_BODY_FRAMING, isHttpNavigationTarget };
|
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/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
|
@@ -50,6 +50,8 @@ export declare const REVALIDATE_HEADER = "X-Revalidate";
|
|
|
50
50
|
export interface ResponseHelperInit extends ResponseInit {
|
|
51
51
|
revalidate?: string | string[];
|
|
52
52
|
}
|
|
53
|
+
/** @internal */
|
|
54
|
+
export declare const RESPONSE_HEADER_VALUE_LIMIT = 4096;
|
|
53
55
|
/**
|
|
54
56
|
* Response redirecting to `url` (default 302). `revalidate` names the
|
|
55
57
|
* cache keys the mutation invalidated.
|
|
@@ -60,6 +62,15 @@ export declare function redirect(url: string | Href, init?: number | ResponseHel
|
|
|
60
62
|
* them when omitted).
|
|
61
63
|
*/
|
|
62
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>;
|
|
63
74
|
/**
|
|
64
75
|
* A value paired with response metadata (status, headers, `revalidate`) —
|
|
65
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,4 +1,5 @@
|
|
|
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
5
|
export type { FlightDataConsumer, FlightDataContext, InvokeOptions, ServerFunction, ServerFunctionInvoker, ServerFunctionMetadata, SingleFlightPayload } from "./shared.js";
|
|
@@ -159,6 +160,25 @@ export declare function parseServerFunctionUrl(url: string): string | null;
|
|
|
159
160
|
export declare function configureServerFunctionsClient(config?: ServerFunctionsClientConfig): void;
|
|
160
161
|
export declare function createServerReference(id: string, name?: string, base?: string): ServerFunction;
|
|
161
162
|
export declare function GET<A extends readonly any[], R>(fn: (...args: A) => R): ServerFunction<A, Awaited<R>>;
|
|
162
|
-
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>>;
|
|
163
183
|
export declare function registerServerReference(): never;
|
|
164
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,8 +1,9 @@
|
|
|
1
|
-
export { ERROR_HEADER, FLASH_COOKIE, INSTANCE_HEADER, SERVER_FUNCTION_INVOKE, SINGLE_FLIGHT_HEADER, clearFlashCookie, decodeErrorHeaderValue, decodeResponse, decodeResponsePayload, encodeErrorHeaderValue, getServerFunctionMetadata, hasFlashCookie, invoke, isServerFunction, subscribeFlightData, withMeta } from "./shared.js";
|
|
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
|
+
import type { ServerFunction, ServerFunctionMetadata } from "./shared.js";
|
|
6
7
|
export type { FlightDataConsumer, FlightDataContext, InvokeOptions, ServerFunction, ServerFunctionInvoker, ServerFunctionMetadata, SingleFlightPayload } from "./shared.js";
|
|
7
8
|
export type { FlashSubmission } from "./flash.js";
|
|
8
9
|
/**
|
|
@@ -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
|
/**
|
|
@@ -225,9 +241,29 @@ export interface ServerFunctionsServerConfig {
|
|
|
225
241
|
/**
|
|
226
242
|
* Codec options (extra plugins etc.) for decoding arguments and encoding
|
|
227
243
|
* results — must match the client's. Stored in the shared layer, so
|
|
228
|
-
* `decodeResponse` sees them too.
|
|
244
|
+
* `decodeResponse` sees them too. When `serializeErrorStacks` is omitted,
|
|
245
|
+
* the server-function boundary defaults it from this module's compiled
|
|
246
|
+
* development variant.
|
|
229
247
|
*/
|
|
230
248
|
codec?: JSONCodecOptions;
|
|
249
|
+
/**
|
|
250
|
+
* Upper bound, in bytes, on a call's argument payload — the POST body,
|
|
251
|
+
* or the `?args=` query encoding. The payload is buffered and decoded
|
|
252
|
+
* before dispatch, so its cost is paid before application code can
|
|
253
|
+
* decline it; the bound is enforced up front and a request over it is
|
|
254
|
+
* refused with `413` before any decoding (#3115). Raise it for functions
|
|
255
|
+
* that accept large uploads, or set `Infinity` to remove the bound.
|
|
256
|
+
* @default 1_048_576 (1 MiB)
|
|
257
|
+
*/
|
|
258
|
+
bodySizeLimit?: number;
|
|
259
|
+
/**
|
|
260
|
+
* Upper bound on the number of arguments a call may carry. The decoded
|
|
261
|
+
* argument array is spread into the function call, so an unbounded list
|
|
262
|
+
* forces a range error out of any function regardless of what it does;
|
|
263
|
+
* past the bound the request is refused with `400` (#3115).
|
|
264
|
+
* @default 1000
|
|
265
|
+
*/
|
|
266
|
+
maxArguments?: number;
|
|
231
267
|
}
|
|
232
268
|
/**
|
|
233
269
|
* A registered server function: its build-stable id paired with the
|
|
@@ -347,6 +383,16 @@ export interface HandleServerFunctionOptions {
|
|
|
347
383
|
csrf?: boolean | ServerFunctionCSRFOptions;
|
|
348
384
|
/** Overrides the configured codec options for this handler. */
|
|
349
385
|
codec?: JSONCodecOptions;
|
|
386
|
+
/**
|
|
387
|
+
* Overrides the configured argument payload bound for this handler (see
|
|
388
|
+
* `ServerFunctionsServerConfig.bodySizeLimit`).
|
|
389
|
+
*/
|
|
390
|
+
bodySizeLimit?: number;
|
|
391
|
+
/**
|
|
392
|
+
* Overrides the configured argument count bound for this handler (see
|
|
393
|
+
* `ServerFunctionsServerConfig.maxArguments`).
|
|
394
|
+
*/
|
|
395
|
+
maxArguments?: number;
|
|
350
396
|
}
|
|
351
397
|
export interface ServerFunctionRequestCall {
|
|
352
398
|
type: "request";
|
|
@@ -366,6 +412,7 @@ export interface ServerFunctionResponseCall {
|
|
|
366
412
|
}
|
|
367
413
|
export type ServerFunctionCall = ServerFunctionRequestCall | ServerFunctionResponseCall;
|
|
368
414
|
export declare function configureServerFunctionsServer(config?: ServerFunctionsServerConfig): void;
|
|
415
|
+
export declare function registerFlightDataSource(source: string, hook: CollectFlightDataHook): () => void;
|
|
369
416
|
export declare function registerServerFunction<T extends any[], R>(id: string, callback: (...args: T) => R): (...args: T) => R;
|
|
370
417
|
export declare function getServerFunction<T extends any[], R>(id: string): (...args: T) => R;
|
|
371
418
|
export declare function registerServerReference<T extends any[], R>(id: string, fn: (...args: T) => R, name?: string): ServerFunctionReference<T, R>;
|
|
@@ -376,6 +423,8 @@ export declare function getServerFunctionInvocation(): ServerFunctionInvocation
|
|
|
376
423
|
export declare function getEventServerFunctionInvocation(event: RequestEvent | undefined): ServerFunctionInvocation | undefined;
|
|
377
424
|
export declare function foldSetCookies(headers: Headers, setCookies: readonly string[]): Headers;
|
|
378
425
|
export declare function createNoJSHandler(options?: NoJSHandlerOptions): (result: unknown, request: Request, args: unknown[], thrown?: boolean) => Response;
|
|
426
|
+
/** @internal */
|
|
427
|
+
export declare function guardFailures(value: any, state: any): any;
|
|
379
428
|
/**
|
|
380
429
|
* The response-side codec stream: `serializeStream` (shared.js) hardened
|
|
381
430
|
* with request-lifetime teardown. Server-only on purpose — the shared half
|
|
@@ -384,14 +433,16 @@ export declare function createNoJSHandler(options?: NoJSHandlerOptions): (result
|
|
|
384
433
|
* An abort of `signal` (the platform fires request.signal when the caller's
|
|
385
434
|
* fetch aborts or the tab goes away) or the consumer cancelling the
|
|
386
435
|
* ReadableStream (how platforms surface a dropped connection to the body)
|
|
387
|
-
* stops pending serialization and tears down
|
|
388
|
-
*
|
|
389
|
-
*
|
|
390
|
-
*
|
|
391
|
-
*
|
|
392
|
-
* the codec
|
|
436
|
+
* stops pending serialization and tears down EVERY async-iterable or
|
|
437
|
+
* ReadableStream source in the result graph, nested ones included (#3125) —
|
|
438
|
+
* each producer's `iterator.return()` / `reader.cancel()` runs, so
|
|
439
|
+
* generator `finally` blocks execute instead of the server pumping streams
|
|
440
|
+
* nobody is reading. The wiring rides guardFailures' walk: it already wraps
|
|
441
|
+
* every channel before the codec sees the value, so the demand gate and the
|
|
442
|
+
* teardown registry are threaded through its state (`{ items: rows() }` —
|
|
443
|
+
* a cursor beside a total — gets the same two guarantees as `return rows()`).
|
|
393
444
|
*/
|
|
394
|
-
export declare function serializeResponseStream(value: any, codecOptions: any, signal: any): ReadableStream<any>;
|
|
445
|
+
export declare function serializeResponseStream(value: any, codecOptions: any, signal: any, scope: any): ReadableStream<any>;
|
|
395
446
|
/** Message a sanitized (production) server error carries on the wire. */
|
|
396
447
|
export declare const GENERIC_SERVER_ERROR_MESSAGE = "Internal Server Error";
|
|
397
448
|
export declare function setServerFunctionsDev(dev: boolean): void;
|
|
@@ -399,4 +450,73 @@ export declare function sanitizeServerError(value: unknown): unknown;
|
|
|
399
450
|
export declare function observeServerFunctionCalls(observer: (call: ServerFunctionCall) => void): () => void;
|
|
400
451
|
export declare function serverFunctionUrl(id: string, boundArgs?: readonly unknown[]): string;
|
|
401
452
|
export declare function parseServerFunctionUrl(url: string): string | null;
|
|
453
|
+
/**
|
|
454
|
+
* Web-standard HTTP handler for server function calls: resolves the
|
|
455
|
+
* function id from the request, enforces the method allowlist (POST always
|
|
456
|
+
* dispatches; GET and HEAD dispatch only to functions that declared `GET`,
|
|
457
|
+
* with HEAD returning the equivalent GET's status and headers minus the
|
|
458
|
+
* body; every other method answers 405), decodes arguments, runs the
|
|
459
|
+
* function under a request-event scope, and encodes the result (forwarding
|
|
460
|
+
* redirect/revalidation metadata through headers). Mount it on the endpoint
|
|
461
|
+
* the client transport targets (default `/_server`); platform adapters (h3,
|
|
462
|
+
* express, ...) convert their request shape to a web `Request` around it.
|
|
463
|
+
*
|
|
464
|
+
* Requests are same-origin by default. The handler accepts browser requests
|
|
465
|
+
* proven by `Sec-Fetch-Site`, `Origin`, or `Referer`, and rejects requests
|
|
466
|
+
* without usable metadata unless explicitly configured otherwise. GET/HEAD
|
|
467
|
+
* requests to `GET`-declared functions skip this gate: they are reads by
|
|
468
|
+
* contract, cross-site response READING is already blocked by same-origin
|
|
469
|
+
* policy, and skipping it keeps the `Vary: Sec-Fetch-Site, Origin, Referer`
|
|
470
|
+
* it would impose off the responses shared caches are meant to store.
|
|
471
|
+
*
|
|
472
|
+
* Every response leaves with `Cache-Control: no-store` unless the function
|
|
473
|
+
* set its own cache policy (via `respond()` headers or a returned
|
|
474
|
+
* `Response`) — caching is opt-in on the wire, not just in prose.
|
|
475
|
+
*
|
|
476
|
+
* When the event carries a `response` head stub (`event.response`, see the
|
|
477
|
+
* server entry's `ResponseStub`), the handler folds it onto every outgoing
|
|
478
|
+
* response as the head freezes — its `Set-Cookie` values (cookies appended
|
|
479
|
+
* during the call) append cookie-by-cookie alongside the result's own,
|
|
480
|
+
* other stub headers fill gaps (the call's response metadata wins; the
|
|
481
|
+
* protocol-owned family — the error/format/single-flight tags, `Location`,
|
|
482
|
+
* `X-Revalidate` — never fills, and neither does `Content-Type`/`Content-
|
|
483
|
+
* Length` onto a bodiless response) — and marks the stub `committed`, so
|
|
484
|
+
* later cookie/header writes report instead of silently missing the wire.
|
|
485
|
+
*
|
|
486
|
+
* ## Thrown-error sanitization (security default)
|
|
487
|
+
*
|
|
488
|
+
* A thrown `Response`/envelope (`redirect`/`reload`/`respond`) is intentional
|
|
489
|
+
* control flow and is forwarded untouched. A *plain* thrown value (a bare
|
|
490
|
+
* `Error`, string, or object) is different: serialized verbatim it would ship
|
|
491
|
+
* its `message` and every own-property to the client — a driver/ORM error's
|
|
492
|
+
* failing query, connection string, or bound parameters included. So outside
|
|
493
|
+
* the dev build a plain thrown value is replaced with a generic `Error`
|
|
494
|
+
* before serialization; the client still receives *an* `Error` (the shape
|
|
495
|
+
* `submission.error` etc. expect), just with no leaked content. The dev
|
|
496
|
+
* build keeps full fidelity (message, stack, own-props) for DX and the dev
|
|
497
|
+
* toolbar inspector. Dev/prod is the BUILD VARIANT, not `NODE_ENV`:
|
|
498
|
+
* `@solidjs/web` publishes a dev copy of this entry behind the
|
|
499
|
+
* `development` export condition (what Vite dev resolves) and the default
|
|
500
|
+
* resolution sanitizes — as does importing the runtime source directly with
|
|
501
|
+
* no bundler signal (fail-safe).
|
|
502
|
+
*
|
|
503
|
+
* Escape hatch: brand the value with `markSafeError` (`Symbol.for(
|
|
504
|
+
* "solid.SafeError")`) to send its content intact in every environment.
|
|
505
|
+
* A `wrapInvocation`/`transformResult` override that maps errors expresses
|
|
506
|
+
* intent the same way — throw a `Response`/envelope, or brand the mapped
|
|
507
|
+
* error safe; an unbranded plain error it lets propagate is sanitized like
|
|
508
|
+
* any other, so a framework onError policy must brand its result to keep a
|
|
509
|
+
* custom client-facing message in production.
|
|
510
|
+
*
|
|
511
|
+
* @example
|
|
512
|
+
* ```ts
|
|
513
|
+
* import { handleServerFunctionRequest } from "@solidjs/web/server-functions";
|
|
514
|
+
* import "virtual:solid-server-function-manifest";
|
|
515
|
+
*
|
|
516
|
+
* // in the server's request handling:
|
|
517
|
+
* if (url.pathname.startsWith("/_server")) {
|
|
518
|
+
* return handleServerFunctionRequest(request);
|
|
519
|
+
* }
|
|
520
|
+
* ```
|
|
521
|
+
*/
|
|
402
522
|
export declare function handleServerFunctionRequest(request: Request, options?: HandleServerFunctionOptions): Promise<Response>;
|