@solidjs/web 2.0.0-rc.2 → 2.0.0-rc.4
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 +433 -72
- package/dist/dev.js +426 -71
- package/dist/server.cjs +39 -21
- package/dist/server.js +40 -23
- package/dist/web.cjs +421 -70
- package/dist/web.js +414 -69
- package/frames/dist/client.cjs +8 -8
- package/frames/dist/client.dev.cjs +8 -8
- package/frames/dist/client.dev.js +8 -8
- package/frames/dist/client.js +8 -8
- package/frames/dist/server.cjs +28 -18
- package/frames/dist/server.js +29 -19
- package/package.json +20 -22
- package/serialization/dist/decode.cjs +3 -3
- package/serialization/dist/decode.js +3 -3
- package/serialization/dist/serialization.cjs +7 -11
- package/serialization/dist/serialization.js +7 -6
- package/serialization/types/index.d.ts +69 -157
- package/serialization/types/serializer-decode.d.ts +89 -112
- package/serialization/types/serializer.d.ts +94 -0
- package/serialization/types-cjs/index.d.cts +69 -157
- package/serialization/types-cjs/serializer-decode.d.cts +89 -112
- package/serialization/types-cjs/serializer.d.cts +94 -0
- package/server-functions/dist/client.cjs +126 -19
- package/server-functions/dist/client.js +123 -19
- package/server-functions/dist/server.cjs +156 -28
- package/server-functions/dist/server.dev.cjs +156 -28
- package/server-functions/dist/server.dev.js +153 -28
- package/server-functions/dist/server.js +153 -28
- package/types/client.d.ts +152 -290
- package/types/constants.d.ts +18 -0
- package/types/cookies.d.ts +31 -75
- package/types/frames/frame-client.d.ts +287 -277
- package/types/frames/frame-container-plugin.d.ts +71 -0
- package/types/frames/frame-sink.d.ts +58 -160
- package/types/frames/frame-transport.d.ts +161 -194
- package/types/frames/serializer-decode.d.ts +159 -0
- package/types/frames/serializer.d.ts +69 -157
- package/types/head.d.ts +16 -0
- package/types/index.d.ts +1 -65
- package/types/index.server.d.ts +125 -0
- package/types/jsx.d.ts +5 -13
- package/types/patch-driver.d.ts +3 -0
- package/types/reconcile.d.ts +1 -0
- package/types/render.d.ts +4 -0
- package/types/response.d.ts +48 -152
- package/types/serializer-decode.d.ts +89 -112
- package/types/serializer.d.ts +69 -157
- package/types/server-functions/client.d.ts +124 -222
- package/types/server-functions/flash.d.ts +10 -30
- package/types/server-functions/registry.d.ts +100 -0
- package/types/server-functions/rich-args.d.ts +1 -10
- package/types/server-functions/server.d.ts +295 -574
- package/types/server-functions/shared.d.ts +155 -458
- package/types/server-mock.d.ts +2 -2
- package/types/server.d.ts +242 -434
- package/types-cjs/client.d.cts +152 -290
- package/types-cjs/constants.d.cts +18 -0
- package/types-cjs/cookies.d.cts +31 -75
- package/types-cjs/frames/frame-client.d.cts +287 -277
- package/types-cjs/frames/frame-container-plugin.d.cts +71 -0
- package/types-cjs/frames/frame-sink.d.cts +58 -160
- package/types-cjs/frames/frame-transport.d.cts +161 -194
- package/types-cjs/frames/serializer-decode.d.cts +159 -0
- package/types-cjs/frames/serializer.d.cts +69 -157
- package/types-cjs/head.d.cts +16 -0
- package/types-cjs/index.d.cts +1 -65
- package/types-cjs/index.server.d.cts +125 -0
- package/types-cjs/jsx.d.cts +5 -13
- package/types-cjs/patch-driver.d.cts +3 -0
- package/types-cjs/reconcile.d.cts +1 -0
- package/types-cjs/render.d.cts +4 -0
- package/types-cjs/response.d.cts +48 -152
- package/types-cjs/serializer-decode.d.cts +89 -112
- package/types-cjs/serializer.d.cts +69 -157
- package/types-cjs/server-functions/client.d.cts +124 -222
- package/types-cjs/server-functions/flash.d.cts +10 -30
- package/types-cjs/server-functions/registry.d.cts +100 -0
- package/types-cjs/server-functions/rich-args.d.cts +1 -10
- package/types-cjs/server-functions/server.d.cts +295 -574
- package/types-cjs/server-functions/shared.d.cts +155 -458
- package/types-cjs/server-mock.d.cts +2 -2
- package/types-cjs/server.d.cts +242 -434
- package/LICENSE +0 -21
- package/types/core.d.ts +0 -9
- package/types-cjs/core.d.cts +0 -9
|
@@ -5,34 +5,14 @@
|
|
|
5
5
|
* returned one fills `result` — mirroring the split a scripted call sees.
|
|
6
6
|
*/
|
|
7
7
|
export interface FlashSubmission {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
8
|
+
/** The arguments the call was made with (files are dropped). */
|
|
9
|
+
input: any[];
|
|
10
|
+
/** The call's url: pathname + search of the server function request. */
|
|
11
|
+
url: string;
|
|
12
|
+
/** The returned value, when the call returned. */
|
|
13
|
+
result?: any;
|
|
14
|
+
/** The thrown value, when the call threw. */
|
|
15
|
+
error?: any;
|
|
16
16
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
* Encodes the outcome of a no-JS call as a `Set-Cookie` value, for the
|
|
20
|
-
* handler to send with its redirect. `url` identifies which submission the
|
|
21
|
-
* outcome belongs to; pass `thrown` when the call threw rather than
|
|
22
|
-
* returned.
|
|
23
|
-
*
|
|
24
|
-
* The payload is JSON inside the cookie: `FormData` and `URLSearchParams`
|
|
25
|
-
* arguments are captured as entry pairs and revived on decode, and `File`
|
|
26
|
-
* entries are dropped (they cannot ride a cookie). Keep in mind the 4 KB
|
|
27
|
-
* cookie budget — outcomes larger than that will not survive the round
|
|
28
|
-
* trip.
|
|
29
|
-
*/
|
|
30
|
-
export function encodeFlashCookie(url: string, result: any, input: any[], thrown?: boolean): string;
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Decodes the flash cookie out of a request's `Cookie` header, for the
|
|
34
|
-
* render that follows the redirect. Returns undefined when the cookie is
|
|
35
|
-
* absent or unreadable — a malformed cookie never takes down the render,
|
|
36
|
-
* and `clearFlashCookie` should be appended regardless.
|
|
37
|
-
*/
|
|
38
|
-
export function decodeFlashCookie(cookieHeader: string | null): FlashSubmission | undefined;
|
|
17
|
+
export declare function encodeFlashCookie(url: string, result: any, input: any[], thrown?: boolean): string;
|
|
18
|
+
export declare function decodeFlashCookie(cookieHeader: string | null): FlashSubmission | undefined;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
export type { InvokeOptions, ServerFunction, ServerFunctionInvoker, ServerFunctionMetadata, ServerFunctionRPC } from "./shared.js";
|
|
2
|
+
import type { InvokeOptions } from "./shared.js";
|
|
3
|
+
export declare const SERVER_FUNCTION_METADATA: unique symbol;
|
|
4
|
+
/**
|
|
5
|
+
* Reads a server function reference's declaration metadata (e.g.
|
|
6
|
+
* `method: "GET"` for `GET(fn)` references). Returns undefined when `fn`
|
|
7
|
+
* is not a server function reference; plain references carry an empty
|
|
8
|
+
* metadata object.
|
|
9
|
+
*/
|
|
10
|
+
export declare function getServerFunctionMetadata(fn: any): any;
|
|
11
|
+
/**
|
|
12
|
+
* Whether `fn` is a server function reference (a client proxy or a
|
|
13
|
+
* server-side registered callable). Detection is by the registered-symbol
|
|
14
|
+
* metadata brand, so it holds across duplicated module instances.
|
|
15
|
+
*/
|
|
16
|
+
export declare function isServerFunction(fn: any): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Attaches user-declared transport metadata to a server function reference
|
|
19
|
+
* (client proxy or server-registered callable) and returns the reference.
|
|
20
|
+
* Writes ride the same channel `GET` uses: later writes shallow-merge over
|
|
21
|
+
* earlier ones, and `getServerFunctionMetadata(fn)` reads the merged bag —
|
|
22
|
+
* so `withMeta` composes with `GET` in either order.
|
|
23
|
+
*
|
|
24
|
+
* The pattern is declare-on-function, react-in-hook: metadata declared
|
|
25
|
+
* here is what `prepareRequest` receives as `context.meta`, letting
|
|
26
|
+
* session-dynamic transport policy key on declarations instead of
|
|
27
|
+
* comparing function ids:
|
|
28
|
+
*
|
|
29
|
+
* ```ts
|
|
30
|
+
* export const chargeCard = withMeta(async (amount: number) => {
|
|
31
|
+
* "use server";
|
|
32
|
+
* // ...
|
|
33
|
+
* }, { requiresAuth: true });
|
|
34
|
+
*
|
|
35
|
+
* configureServerFunctionsClient({
|
|
36
|
+
* prepareRequest(init, { meta }) {
|
|
37
|
+
* if (meta?.requiresAuth) {
|
|
38
|
+
* return {
|
|
39
|
+
* ...init,
|
|
40
|
+
* headers: { ...init.headers, Authorization: `Bearer ${session.token()}` }
|
|
41
|
+
* };
|
|
42
|
+
* }
|
|
43
|
+
* return init;
|
|
44
|
+
* }
|
|
45
|
+
* });
|
|
46
|
+
* ```
|
|
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;
|
|
85
|
+
export declare const LIVE_SOURCE: unique symbol;
|
|
86
|
+
/**
|
|
87
|
+
* Fills the RPC seam. Called by the transport halves (client fetch RPC,
|
|
88
|
+
* server in-process dispatch) when the first server function reference is
|
|
89
|
+
* created; first write wins — both halves register equivalent surfaces, and
|
|
90
|
+
* a per-build half never coexists with the other build's.
|
|
91
|
+
* @internal
|
|
92
|
+
*/
|
|
93
|
+
export declare function provideServerFunctionRPC(rpc: any): void;
|
|
94
|
+
/**
|
|
95
|
+
* The registered RPC surface, or undefined when no server function exists
|
|
96
|
+
* in this build's graph. Integration plumbing (routers): gate every use of
|
|
97
|
+
* the transport/codec behind this read instead of importing it.
|
|
98
|
+
* @internal
|
|
99
|
+
*/
|
|
100
|
+
export declare function getServerFunctionRPC(): any;
|
|
@@ -1,10 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* Opt-in codec encoding for server-function ARGUMENTS. By default the client
|
|
3
|
-
* sends argument lists as plain JSON (no serializer in the bundle) and
|
|
4
|
-
* throws on values JSON can't carry faithfully. Call once at startup to
|
|
5
|
-
* send Dates, Maps, Sets, typed arrays, cyclic structures, etc. through the
|
|
6
|
-
* codec — at the cost of the serializer's write half (~5 KB gz on top of
|
|
7
|
-
* the decode half responses already need). The handler accepts both
|
|
8
|
-
* encodings unconditionally.
|
|
9
|
-
*/
|
|
10
|
-
export function enableRichArguments(): void;
|
|
1
|
+
export declare function enableRichArguments(): void;
|