@solidjs/web 2.0.0-rc.5 → 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 +113 -31
- package/dist/dev.js +113 -32
- package/dist/server.cjs +17 -3
- package/dist/server.js +17 -3
- package/dist/web.cjs +113 -31
- package/dist/web.js +113 -32
- package/frames/dist/server.cjs +87 -22
- package/frames/dist/server.js +87 -22
- package/package.json +2 -2
- package/server-functions/dist/client.cjs +14 -2
- package/server-functions/dist/client.js +14 -2
- package/server-functions/dist/server.cjs +219 -69
- package/server-functions/dist/server.dev.cjs +219 -69
- package/server-functions/dist/server.dev.js +219 -69
- package/server-functions/dist/server.js +219 -69
- package/types/client.d.ts +2 -1
- package/types/constants.d.ts +3 -1
- package/types/server-functions/server.d.ts +73 -2
- package/types-cjs/client.d.cts +2 -1
- package/types-cjs/constants.d.cts +3 -1
- package/types-cjs/server-functions/server.d.cts +73 -2
|
@@ -241,7 +241,9 @@ export interface ServerFunctionsServerConfig {
|
|
|
241
241
|
/**
|
|
242
242
|
* Codec options (extra plugins etc.) for decoding arguments and encoding
|
|
243
243
|
* results — must match the client's. Stored in the shared layer, so
|
|
244
|
-
* `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.
|
|
245
247
|
*/
|
|
246
248
|
codec?: JSONCodecOptions;
|
|
247
249
|
/**
|
|
@@ -440,7 +442,7 @@ export declare function guardFailures(value: any, state: any): any;
|
|
|
440
442
|
* teardown registry are threaded through its state (`{ items: rows() }` —
|
|
441
443
|
* a cursor beside a total — gets the same two guarantees as `return rows()`).
|
|
442
444
|
*/
|
|
443
|
-
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>;
|
|
444
446
|
/** Message a sanitized (production) server error carries on the wire. */
|
|
445
447
|
export declare const GENERIC_SERVER_ERROR_MESSAGE = "Internal Server Error";
|
|
446
448
|
export declare function setServerFunctionsDev(dev: boolean): void;
|
|
@@ -448,4 +450,73 @@ export declare function sanitizeServerError(value: unknown): unknown;
|
|
|
448
450
|
export declare function observeServerFunctionCalls(observer: (call: ServerFunctionCall) => void): () => void;
|
|
449
451
|
export declare function serverFunctionUrl(id: string, boundArgs?: readonly unknown[]): string;
|
|
450
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
|
+
*/
|
|
451
522
|
export declare function handleServerFunctionRequest(request: Request, options?: HandleServerFunctionOptions): Promise<Response>;
|
package/types-cjs/client.d.cts
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.
|
|
@@ -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 };
|
|
@@ -241,7 +241,9 @@ export interface ServerFunctionsServerConfig {
|
|
|
241
241
|
/**
|
|
242
242
|
* Codec options (extra plugins etc.) for decoding arguments and encoding
|
|
243
243
|
* results — must match the client's. Stored in the shared layer, so
|
|
244
|
-
* `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.
|
|
245
247
|
*/
|
|
246
248
|
codec?: JSONCodecOptions;
|
|
247
249
|
/**
|
|
@@ -440,7 +442,7 @@ export declare function guardFailures(value: any, state: any): any;
|
|
|
440
442
|
* teardown registry are threaded through its state (`{ items: rows() }` —
|
|
441
443
|
* a cursor beside a total — gets the same two guarantees as `return rows()`).
|
|
442
444
|
*/
|
|
443
|
-
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>;
|
|
444
446
|
/** Message a sanitized (production) server error carries on the wire. */
|
|
445
447
|
export declare const GENERIC_SERVER_ERROR_MESSAGE = "Internal Server Error";
|
|
446
448
|
export declare function setServerFunctionsDev(dev: boolean): void;
|
|
@@ -448,4 +450,73 @@ export declare function sanitizeServerError(value: unknown): unknown;
|
|
|
448
450
|
export declare function observeServerFunctionCalls(observer: (call: ServerFunctionCall) => void): () => void;
|
|
449
451
|
export declare function serverFunctionUrl(id: string, boundArgs?: readonly unknown[]): string;
|
|
450
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
|
+
*/
|
|
451
522
|
export declare function handleServerFunctionRequest(request: Request, options?: HandleServerFunctionOptions): Promise<Response>;
|