@solidjs/web 2.0.0-rc.15 → 2.0.0-rc.17
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/README.md +1 -1
- package/dist/server.dev.js +361 -483
- package/dist/server.js +346 -391
- package/dist/server.observe.js +346 -391
- package/dist/web.dev.js +110 -55
- package/dist/web.js +51 -50
- package/dist/web.observe.js +61 -55
- package/frames/dist/client.dev.js +610 -621
- package/frames/dist/client.js +540 -566
- package/frames/dist/client.observe.js +571 -573
- package/frames/dist/regions.js +43 -2
- package/frames/dist/server.dev.js +793 -424
- package/frames/dist/server.js +792 -371
- package/frames/dist/server.observe.js +792 -371
- package/frames/dist/wire.js +371 -6
- package/package.json +11 -11
- package/serialization/dist/decode.js +9 -7
- package/serialization/dist/serialization.js +9 -7
- package/serialization/types/serializer-decode.d.ts +2 -2
- package/server-functions/dist/client.dev.js +13 -22
- package/server-functions/dist/client.js +11 -22
- package/server-functions/dist/client.observe.js +13 -22
- package/server-functions/dist/rich-args.js +84 -1
- package/server-functions/dist/server.dev.js +194 -20
- package/server-functions/dist/server.js +194 -20
- package/server-functions/dist/server.observe.js +194 -20
- package/skills/server-components/SKILL.md +74 -185
- package/types/client.d.ts +27 -5
- package/types/diagnostics.d.ts +16 -0
- package/types/frames/assets-tier.d.ts +2 -2
- package/types/frames/client.d.ts +8 -3
- package/types/frames/frame-client.d.ts +121 -157
- package/types/frames/frame-morph.d.ts +28 -0
- package/types/frames/frame-sink.d.ts +13 -9
- package/types/frames/frame-transport.d.ts +30 -1
- package/types/frames/regions-tier.d.ts +15 -0
- package/types/frames/serializer-decode.d.ts +2 -2
- package/types/frames/server.d.ts +0 -52
- package/types/frames/wire-tier.d.ts +54 -1
- package/types/index.d.ts +2 -2
- package/types/jsx.d.ts +11 -5
- package/types/observe.d.ts +14 -7
- package/types/render.d.ts +3 -1
- package/types/response.d.ts +5 -4
- package/types/serializer-decode.d.ts +2 -2
- package/types/server-functions/argument-codec.d.ts +30 -0
- package/types/server-functions/client.d.ts +27 -9
- package/types/server-functions/server.d.ts +23 -2
- package/types/server-functions/shared.d.ts +19 -0
- package/types/server-functions/uploads.d.ts +50 -0
- package/types/server-observe.d.ts +3 -2
- package/types/server.d.ts +58 -77
- package/frames/dist/bind.dev.js +0 -326
- package/frames/dist/bind.js +0 -295
- package/types/frames/bind-tier.d.ts +0 -60
|
@@ -1,4 +1,22 @@
|
|
|
1
1
|
import type { FrameHost, FrameHostOptions } from "./frame-client.js";
|
|
2
|
+
/**
|
|
3
|
+
* A frame's mount as the live appliers reach it (the frame's `#live`):
|
|
4
|
+
* `e` its element, `t` its live-target cache, `c` its claim, `k` its slot
|
|
5
|
+
* index builder, `s` what each hole's range shows, `x` the give-up for a row-op record (mark it spent,
|
|
6
|
+
* cancel the connection so the resume re-sends the hole whole); `w`, in
|
|
7
|
+
* dev builds only, the diagnostic for a hole whose closing comment is gone
|
|
8
|
+
* (this chunk is built once for every condition, so the gate is the eager
|
|
9
|
+
* client's).
|
|
10
|
+
*/
|
|
11
|
+
interface LiveMount {
|
|
12
|
+
e: Element;
|
|
13
|
+
t: Map<string, Node>;
|
|
14
|
+
c: unknown;
|
|
15
|
+
k(found: Map<string, any>): void;
|
|
16
|
+
s(): Record<string, string>;
|
|
17
|
+
x(key: string, record: unknown): void;
|
|
18
|
+
w?: false | ((marker: string, open: Node) => void);
|
|
19
|
+
}
|
|
2
20
|
/**
|
|
3
21
|
* The host the handler hands over: the frame host, carrying the lazily
|
|
4
22
|
* loaded deserializer's load (`prepareData`) the transport awaits before a
|
|
@@ -113,4 +131,39 @@ export declare function cancel(host: object, address: string): void;
|
|
|
113
131
|
* @internal
|
|
114
132
|
*/
|
|
115
133
|
export declare function connect(response: Response, wire: WireSlot, address: string, binding: unknown, host: Host, bump: (address: string) => number, begin: (address: string, version: number) => void): unknown;
|
|
116
|
-
|
|
134
|
+
/**
|
|
135
|
+
* Morph a live hole's marked range (`<!--lh:N-->…<!--lh:/N-->`, marker =
|
|
136
|
+
* `lh:N`) to its re-emitted html — the client half of the Stage 3 hole
|
|
137
|
+
* ledger. The same range-anchored reconcile as the root morph, so
|
|
138
|
+
* interior element identity (focus, media, third-party widget state)
|
|
139
|
+
* survives value ticks. A hole's content may hold slot ranges: the morph
|
|
140
|
+
* then resolves them against the frame's displaced-range index (`index`,
|
|
141
|
+
* one per flush pass: `r` the slot ranges by occurrence, `g` the subtrees
|
|
142
|
+
* the morphs inserted whole), as the root's does, so an occurrence the new
|
|
143
|
+
* content still has keeps its range — interior and mounted state —
|
|
144
|
+
* wherever it moved; the sync after the pass mounts the new ones and
|
|
145
|
+
* unmounts the ones gone. Returns whether the markers were found and the
|
|
146
|
+
* morph ran.
|
|
147
|
+
* @internal
|
|
148
|
+
*/
|
|
149
|
+
export declare function hole(f: LiveMount, marker: string, record: any, index: {
|
|
150
|
+
r?: Map<string, any>;
|
|
151
|
+
g?: Node[];
|
|
152
|
+
}): boolean;
|
|
153
|
+
/**
|
|
154
|
+
* Apply a live attr-hole re-emission: find the element addressed
|
|
155
|
+
* `data-lha="addr"` in the frame's range, parse the rebuilt attribute
|
|
156
|
+
* text through a scratch element (native entity decoding), and patch the
|
|
157
|
+
* element to match it the way the root morph matches server output
|
|
158
|
+
* (`morphAttributes`): set what's present, remove what is not — the text
|
|
159
|
+
* is the tag's WHOLE attribute area, so a name absent from it has
|
|
160
|
+
* vanished on the server, whether or not the emission names it in
|
|
161
|
+
* `removed` (a resume's re-emission cannot: the server holds the client's
|
|
162
|
+
* previous text only as a digest). The address itself and a
|
|
163
|
+
* `<details>`/`<dialog>` `open` are the morph's exceptions here too.
|
|
164
|
+
* Returns false when the element isn't in the DOM yet (pending; later
|
|
165
|
+
* flushes retry).
|
|
166
|
+
* @internal
|
|
167
|
+
*/
|
|
168
|
+
export declare function attrs(f: LiveMount, addr: string, record: any): boolean;
|
|
169
|
+
export { graft, morph } from "./frame-morph.js";
|
package/types/index.d.ts
CHANGED
|
@@ -73,7 +73,7 @@ export type DynamicProps<T extends ValidComponent, P = ComponentProps<T>> = {
|
|
|
73
73
|
* </Portal>
|
|
74
74
|
* ```
|
|
75
75
|
*
|
|
76
|
-
* @description https://
|
|
76
|
+
* @description https://v2.solidjs.com/reference/solid-web/components/portal
|
|
77
77
|
*/
|
|
78
78
|
export declare function Portal(props: {
|
|
79
79
|
mount?: Element;
|
|
@@ -132,7 +132,7 @@ export { dynamicComponent } from "solid-js";
|
|
|
132
132
|
* }
|
|
133
133
|
* ```
|
|
134
134
|
*
|
|
135
|
-
* @description https://
|
|
135
|
+
* @description https://v2.solidjs.com/reference/solid-web/components/dynamic
|
|
136
136
|
*/
|
|
137
137
|
/**
|
|
138
138
|
* A component from a reactive source. The source may answer with the
|
package/types/jsx.d.ts
CHANGED
|
@@ -253,11 +253,10 @@ export namespace JSX {
|
|
|
253
253
|
/**
|
|
254
254
|
* Entity identity for server markup: the frame morph matches keyed
|
|
255
255
|
* elements across responses by it, so client state attached to the
|
|
256
|
-
* element (
|
|
257
|
-
*
|
|
258
|
-
*
|
|
259
|
-
*
|
|
260
|
-
* one occurrence per render with or without it).
|
|
256
|
+
* element (focus, selection) follows the entity through reorders and
|
|
257
|
+
* refetches. SSR compiles it to the `_key` attribute; a DOM compile strips
|
|
258
|
+
* it. On a component, `$key` is slot occurrence identity across
|
|
259
|
+
* responses (optional; without it identity is positional).
|
|
261
260
|
*/
|
|
262
261
|
$key?: string | number | undefined;
|
|
263
262
|
}
|
|
@@ -896,6 +895,13 @@ export namespace JSX {
|
|
|
896
895
|
extends CustomAttributes<T>, PropAttributes, EventHandlersElement<T>, AriaAttributes {
|
|
897
896
|
// [key: ClassKeys]: boolean;
|
|
898
897
|
|
|
898
|
+
/**
|
|
899
|
+
* `data-*` attributes. JSX already accepts hyphenated names; this types
|
|
900
|
+
* them in props objects too (`ComponentProps<"div">`, a spread's source).
|
|
901
|
+
* `true` writes `""`; `false` and `undefined` remove the attribute.
|
|
902
|
+
*/
|
|
903
|
+
[key: `data-${string}`]: string | number | boolean | undefined;
|
|
904
|
+
|
|
899
905
|
// properties
|
|
900
906
|
innerHTML?: string;
|
|
901
907
|
textContent?: string | number;
|
package/types/observe.d.ts
CHANGED
|
@@ -472,11 +472,17 @@ declare module "solid-js" {
|
|
|
472
472
|
export declare function settledPromise(value: unknown): Promise<unknown> | undefined;
|
|
473
473
|
export declare function isDeferredBody(value: unknown): boolean;
|
|
474
474
|
/**
|
|
475
|
-
* The census one
|
|
476
|
-
*
|
|
477
|
-
*
|
|
475
|
+
* The census of one wire message (frame-sink.ts), kept by either half so
|
|
476
|
+
* both add up to the same numbers: a message counts once, and each record
|
|
477
|
+
* by what it writes — the root's content (`""`) a shell (or, addressed to
|
|
478
|
+
* a nested region, a region), `seg:<k>` content a fragment, `slot:<k>` a
|
|
479
|
+
* slot, any `:error` record an error. The end of the response (`:complete`,
|
|
480
|
+
* `:bound`) is not counted: a message writing only that is none.
|
|
478
481
|
*/
|
|
479
|
-
export declare function
|
|
482
|
+
export declare function frameRecordCensus(event: FrameEventBase, message: {
|
|
483
|
+
type?: string;
|
|
484
|
+
r?: Record<string, any>;
|
|
485
|
+
}, own: boolean): void;
|
|
480
486
|
/** What the client runtime hands a call observation as the call proceeds. */
|
|
481
487
|
export interface CallObservation {
|
|
482
488
|
/**
|
|
@@ -502,13 +508,14 @@ export declare function observeCall(id: string, method: "GET" | "POST", args: un
|
|
|
502
508
|
/** What the client's stream reader hands a frame observation. */
|
|
503
509
|
export interface FrameApplyObservation {
|
|
504
510
|
/**
|
|
505
|
-
* Every
|
|
506
|
-
* `wireId` is the id the
|
|
511
|
+
* Every message read, after the consumer's remapping (`as`, `version`) —
|
|
512
|
+
* `wireId` is the id the message carried before it.
|
|
507
513
|
*/
|
|
508
514
|
chunk(chunk: {
|
|
509
|
-
type
|
|
515
|
+
type?: string;
|
|
510
516
|
id: string;
|
|
511
517
|
version: number;
|
|
518
|
+
r?: Record<string, unknown>;
|
|
512
519
|
}, wireId: string): void;
|
|
513
520
|
/**
|
|
514
521
|
* The apply ended — cleanly, or with the failure it threw (a read that
|
package/types/render.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
export declare let spreadName: string | undefined;
|
|
2
|
-
export declare
|
|
2
|
+
export declare let spreadLoc: string | undefined;
|
|
3
|
+
export declare function setSpreadName(name: string | undefined, loc?: string): void;
|
|
3
4
|
/** Dev: remember the element the running binding effect writes (first one wins). */
|
|
4
5
|
export declare function tagElement(node: Node): void;
|
|
5
6
|
export declare function effect<T>(fn: (prev?: T) => T, effectFn: (value: T, prev?: T) => void | (() => void), options?: {
|
|
6
7
|
scope?: boolean;
|
|
7
8
|
name?: string;
|
|
9
|
+
loc?: string;
|
|
8
10
|
}): void;
|
|
9
11
|
export declare function memo<T>(fn: () => T): () => T;
|
package/types/response.d.ts
CHANGED
|
@@ -66,9 +66,9 @@ export interface ResponseHelperInit extends ResponseInit {
|
|
|
66
66
|
* The cache keys the mutation invalidated, sent as the `X-Revalidate`
|
|
67
67
|
* header for the client's integrations to apply. Three declarations, three
|
|
68
68
|
* scopes: omitted sends no header — the host's default (Solid Router
|
|
69
|
-
* revalidates everything after
|
|
70
|
-
* convention reloads only what it owns); an empty
|
|
71
|
-
* header — nothing, explicitly; `REVALIDATE_ALL` (`"*"`) — every entry,
|
|
69
|
+
* revalidates everything after any mutation, form action or direct call;
|
|
70
|
+
* a router without that convention reloads only what it owns); an empty
|
|
71
|
+
* list (or `""`) sends an empty header — nothing, explicitly; `REVALIDATE_ALL` (`"*"`) — every entry,
|
|
72
72
|
* whatever the host's default. How named keys are matched (prefixes,
|
|
73
73
|
* namespaces) is each integration's business.
|
|
74
74
|
*/
|
|
@@ -111,7 +111,8 @@ export declare const NULL_BODY_STATUSES: ReadonlySet<number>;
|
|
|
111
111
|
* for the things a naked return can't express. Progressive enhancement
|
|
112
112
|
* stays invisible: the carried response holds a plain JSON body so
|
|
113
113
|
* consumers without the client runtime (no-JS form posts, direct HTTP)
|
|
114
|
-
* get real JSON, while integrations read `value` — no reparse.
|
|
114
|
+
* get real JSON, while integrations read `value` — no reparse. The body is
|
|
115
|
+
* encoded when read, so `value` may be anything a plain return may.
|
|
115
116
|
*
|
|
116
117
|
* Typed as `value`'s type: every caller of the function returning it —
|
|
117
118
|
* over HTTP or in-process — receives the value, never the envelope. At
|
|
@@ -223,8 +223,8 @@ export declare const DEFAULT_WEB_PLUGINS: readonly ({
|
|
|
223
223
|
* Integration-facing; may change (see the entry banner).
|
|
224
224
|
*/
|
|
225
225
|
export declare function resolveSerializerPlugins(customPlugins?: SerializerPlugin[]): SerializerPlugin[];
|
|
226
|
-
export declare function resolveCodecOptions(
|
|
227
|
-
plugins:
|
|
226
|
+
export declare function resolveCodecOptions(options?: JSONCodecOptions): {
|
|
227
|
+
plugins: any;
|
|
228
228
|
disabledFeatures: number;
|
|
229
229
|
depthLimit: number;
|
|
230
230
|
serializeErrorStacks: boolean;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/** The refusal: thrown by the encoder, and answered as a 400 by dispatch. */
|
|
2
|
+
export declare function refusedArgumentError(name?: string): TypeError;
|
|
3
|
+
/** The refusal behind `error`, if any: the codec reports a plugin's throw as the `cause` of its own error. */
|
|
4
|
+
export declare function refusedArgument(error: any): any;
|
|
5
|
+
/**
|
|
6
|
+
* The codec options server-function arguments decode with: `codec` with its
|
|
7
|
+
* complete plugin list resolved and the refused types filtered out.
|
|
8
|
+
* `defaults` is the codec's default plugin set (from the lazily loaded
|
|
9
|
+
* decode module).
|
|
10
|
+
*/
|
|
11
|
+
export declare function argumentDecodeCodec(codec: any, defaults: any): any;
|
|
12
|
+
/**
|
|
13
|
+
* Whether a framed argument payload names a refused type. Read only on a
|
|
14
|
+
* decode that already failed: a payload naming one can never decode (its
|
|
15
|
+
* tag has no plugin), so this tells the refusal apart from every other
|
|
16
|
+
* malformed payload. A plugin node spells its tag as `"c":"<tag>"`; inside a
|
|
17
|
+
* JSON string the quotes would be escaped, so payload data cannot spell it.
|
|
18
|
+
*/
|
|
19
|
+
export declare function namesRefusedType(payload: any): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* The configured codec options with encode-side refusals ahead of every
|
|
22
|
+
* plugin. `extra` holds plugins for one call (the upload serializer), which
|
|
23
|
+
* go first.
|
|
24
|
+
*/
|
|
25
|
+
export declare function argumentEncodeCodec(codec: any, extra?: any[]): any;
|
|
26
|
+
/**
|
|
27
|
+
* Decode options from `argumentDecodeCodec` with plugins for one request
|
|
28
|
+
* (the upload deserializer) ahead of the resolved list.
|
|
29
|
+
*/
|
|
30
|
+
export declare function withArgumentPlugins(argumentCodec: any, extra: any): any;
|
|
@@ -23,6 +23,8 @@ export interface PrepareRequestContext {
|
|
|
23
23
|
* a chain — compose by wrapping functions in userland.
|
|
24
24
|
*/
|
|
25
25
|
export type PrepareRequestHook = (init: RequestInit, context: PrepareRequestContext) => RequestInit | Promise<RequestInit>;
|
|
26
|
+
/** How the transport sends a request: `fetch`'s shape, as the runtime calls it. */
|
|
27
|
+
export type ServerFunctionsSend = (address: string, init: RequestInit) => Response | Promise<Response>;
|
|
26
28
|
/** Options for `configureServerFunctionsClient`. */
|
|
27
29
|
export interface ServerFunctionsClientConfig {
|
|
28
30
|
/**
|
|
@@ -50,14 +52,17 @@ export interface ServerFunctionsClientConfig {
|
|
|
50
52
|
/**
|
|
51
53
|
* Codec options (extra plugins etc.) for encoding arguments and decoding
|
|
52
54
|
* results — must match the server's. Stored in the shared layer, so
|
|
53
|
-
* `decodeResponse` sees them too.
|
|
55
|
+
* `decodeResponse` sees them too. Arguments never carry `Response` or
|
|
56
|
+
* `Request` values, whatever plugins are configured: the server refuses
|
|
57
|
+
* them, and the rich-args encoder rejects the call before sending.
|
|
54
58
|
*/
|
|
55
59
|
codec?: JSONCodecOptions;
|
|
56
60
|
/**
|
|
57
61
|
* Sends every server-function request — retries, telemetry, a test
|
|
58
|
-
* double, or an app's own route.
|
|
62
|
+
* double, or an app's own route. Called as `(address, init)`, the
|
|
59
63
|
* address relative to the document as the global one receives it, so
|
|
60
|
-
* `parseServerFunctionActionUrl` reads the id back out for telemetry
|
|
64
|
+
* `parseServerFunctionActionUrl` reads the id back out for telemetry (a
|
|
65
|
+
* trailing third argument is the transport's own; ignore it). `null`
|
|
61
66
|
* restores the global.
|
|
62
67
|
*
|
|
63
68
|
* ```ts
|
|
@@ -81,7 +86,7 @@ export interface ServerFunctionsClientConfig {
|
|
|
81
86
|
* The wrapper replaces delivery for the requests the runtime chooses to
|
|
82
87
|
* send; the call-to-request mapping itself is not contractual.
|
|
83
88
|
*/
|
|
84
|
-
fetch?:
|
|
89
|
+
fetch?: ServerFunctionsSend | null;
|
|
85
90
|
/**
|
|
86
91
|
* Runs before every server-function fetch. Return (or mutate and return)
|
|
87
92
|
* the RequestInit the transport will use; `context.meta` is the
|
|
@@ -124,7 +129,10 @@ export interface ServerFunctionsClientConfig {
|
|
|
124
129
|
* declared shape and per-call options as dispatched (a `GET`-declared
|
|
125
130
|
* read stays a GET; a caller-supplied `signal` still owns the wire) —
|
|
126
131
|
* for a handler re-asking on its own account (a frames boundary's
|
|
127
|
-
* `reset`, frames-rulings 3.3).
|
|
132
|
+
* `reset`, frames-rulings 3.3). Observe tier only: `ctx.startedAt` is
|
|
133
|
+
* when the request was sent (`performance.now()`), so a handler can
|
|
134
|
+
* stamp what it hands out with the request's start
|
|
135
|
+
* (`OBSERVE.attribution.markFlight`).
|
|
128
136
|
*/
|
|
129
137
|
handle(response: Response, ctx: {
|
|
130
138
|
id: string;
|
|
@@ -132,6 +140,7 @@ export interface ServerFunctionsClientConfig {
|
|
|
132
140
|
args: unknown[];
|
|
133
141
|
context: unknown;
|
|
134
142
|
retry(): Promise<unknown>;
|
|
143
|
+
startedAt?: number;
|
|
135
144
|
}): unknown;
|
|
136
145
|
/**
|
|
137
146
|
* Answer a call before any request is made (t = 0 local answers — see
|
|
@@ -170,9 +179,11 @@ export interface ServerFunctionsClientConfig {
|
|
|
170
179
|
* Encoder for argument lists JSON can't carry faithfully. JSON-safe args
|
|
171
180
|
* always go as plain JSON (no codec in the bundle); anything else throws
|
|
172
181
|
* unless this is set. Installed by `enableRichArguments()` from the
|
|
173
|
-
* rich-args entry — set directly only for custom wire encodings.
|
|
182
|
+
* rich-args entry — set directly only for custom wire encodings. A
|
|
183
|
+
* `FormData` answer is sent as an upload: the codec output in its `args`
|
|
184
|
+
* field and each file in a `file<index>` part.
|
|
174
185
|
*/
|
|
175
|
-
serializeArgs?(args: unknown[]): string | Promise<string>;
|
|
186
|
+
serializeArgs?(args: unknown[]): string | FormData | Promise<string | FormData>;
|
|
176
187
|
}
|
|
177
188
|
/** Wire-state transitions a live call's iterable can report. */
|
|
178
189
|
export type LiveSourceStatus = "connected" | "reconnecting" | "closed";
|
|
@@ -218,7 +229,7 @@ export interface ServerFunctionInvocation {
|
|
|
218
229
|
* <link rel="preload" as="fetch" crossorigin href={serverFunctionUrl(getUser, id)} />
|
|
219
230
|
* ```
|
|
220
231
|
*
|
|
221
|
-
* A `live(
|
|
232
|
+
* A `live(fn)` reference's call connects at the live address, so that
|
|
222
233
|
* is the url returned for one (`<endpoint>/live/<id>[?args=...]`): a
|
|
223
234
|
* standing event stream of the answer — fetch it by hand (`curl -N`) to
|
|
224
235
|
* watch it; do not preload or prefetch it, which would open a stream
|
|
@@ -242,6 +253,12 @@ export interface LiveServerFunction<A extends readonly any[] = any[], R = any> {
|
|
|
242
253
|
/** URL invoking this function directly over HTTP. */
|
|
243
254
|
readonly url: string;
|
|
244
255
|
}
|
|
256
|
+
/**
|
|
257
|
+
* Declares a live server function whose answer is the same for every
|
|
258
|
+
* viewer: on the client exactly `live(fn)` — the sharing is the server's.
|
|
259
|
+
* @experimental
|
|
260
|
+
*/
|
|
261
|
+
export declare function broadcast<A extends readonly any[], R>(fn: (...args: A) => R): LiveServerFunction<A, Awaited<R>>;
|
|
245
262
|
/**
|
|
246
263
|
* Declares a value-shaped live source: a server function returning an async
|
|
247
264
|
* iterable whose yields are successive VALUES of one logical query, with the
|
|
@@ -252,7 +269,8 @@ export interface LiveServerFunction<A extends readonly any[] = any[], R = any> {
|
|
|
252
269
|
* first-connect failures reject like a normal call, and `break` aborts the
|
|
253
270
|
* in-flight request. Live calls are reads and never opt into single-flight
|
|
254
271
|
* enveloping. Wire state, if wanted, rides the returned iterable's
|
|
255
|
-
* `onstatus` hook.
|
|
272
|
+
* `onstatus` hook. Implies `GET` (a live source is a read); an explicit
|
|
273
|
+
* `live(GET(fn))` is equivalent.
|
|
256
274
|
*/
|
|
257
275
|
export declare function live<A extends readonly any[], R>(fn: (...args: A) => R): LiveServerFunction<A, Awaited<R>>;
|
|
258
276
|
export declare function registerServerReference(): never;
|
|
@@ -280,7 +280,11 @@ export interface ServerFunctionsServerConfig {
|
|
|
280
280
|
/**
|
|
281
281
|
* Codec options (extra plugins etc.) for decoding arguments and encoding
|
|
282
282
|
* results — must match the client's. Stored in the shared layer, so
|
|
283
|
-
* `decodeResponse` sees them too.
|
|
283
|
+
* `decodeResponse` sees them too. One asymmetry is fixed: arguments are
|
|
284
|
+
* client input and never decode `Response` or `Request` values, whatever
|
|
285
|
+
* plugins are configured — a call carrying one is refused with `400`.
|
|
286
|
+
* Results keep the full set. Every plugin added here is a type a client
|
|
287
|
+
* can make the server construct. When `serializeErrorStacks` is omitted,
|
|
284
288
|
* the server-function boundary defaults it from this module's compiled
|
|
285
289
|
* development variant.
|
|
286
290
|
*/
|
|
@@ -390,6 +394,14 @@ export interface ServerFunctionInvocation {
|
|
|
390
394
|
* `false` for the data and bare addresses, and for in-process calls.
|
|
391
395
|
*/
|
|
392
396
|
live: boolean;
|
|
397
|
+
/** A live call to a `broadcast` declaration: its answer is shared. */
|
|
398
|
+
broadcast?: boolean;
|
|
399
|
+
/**
|
|
400
|
+
* For a broadcast call, the arguments as they arrived on the wire: callers
|
|
401
|
+
* whose encodings are equal share one render. Absent when the encoding
|
|
402
|
+
* wasn't kept (an unbuffered body), and then the call is not shared.
|
|
403
|
+
*/
|
|
404
|
+
shareKey?: string;
|
|
393
405
|
}
|
|
394
406
|
/**
|
|
395
407
|
* Hooks layering framework policy onto `handleServerFunctionRequest`.
|
|
@@ -433,7 +445,7 @@ export interface HandleServerFunctionOptions {
|
|
|
433
445
|
* This request's server error hook, ahead of `configureServerErrors`' (see
|
|
434
446
|
* `ServerErrorHook` in `@solidjs/web`): the function's throw
|
|
435
447
|
* (`handling: "thrown"`) and a failure escaping through its result graph
|
|
436
|
-
* (`"channel"`), once per error, before the wire policy applies. Entry-only
|
|
448
|
+
* (`"channel"`), once per error per request, before the wire policy applies. Entry-only
|
|
437
449
|
* like `wrapInvocation`: a direct call the body makes during a render
|
|
438
450
|
* reports through the ambient hook.
|
|
439
451
|
*/
|
|
@@ -515,6 +527,15 @@ export declare function registerServerReference<T extends any[], R>(id: string,
|
|
|
515
527
|
export declare function createServerReference<T extends any[], R>(reference: ServerFunctionReference<T, R>): (...args: T) => R;
|
|
516
528
|
export declare function GET<A extends readonly any[], R>(fn: (...args: A) => R): ServerFunction<A, Awaited<R>>;
|
|
517
529
|
export declare function live<A extends readonly any[], R>(fn: (...args: A) => R): ServerFunction<A, LiveSource<Awaited<R>>>;
|
|
530
|
+
/**
|
|
531
|
+
* Declares a live server function whose answer is the same for every
|
|
532
|
+
* viewer: implies `live` and `GET`, and at the live address every caller
|
|
533
|
+
* with the same arguments shares ONE render (frames server half). The
|
|
534
|
+
* outer body still runs per call — a gate (auth, redirects) — but what it
|
|
535
|
+
* returns is the shared answer's to render.
|
|
536
|
+
* @experimental
|
|
537
|
+
*/
|
|
538
|
+
export declare function broadcast<A extends readonly any[], R>(fn: (...args: A) => R): ServerFunction<A, LiveSource<Awaited<R>>>;
|
|
518
539
|
export declare function getServerFunctionInvocation(): ServerFunctionInvocation | undefined;
|
|
519
540
|
export declare function getEventServerFunctionInvocation(event: RequestEvent | undefined): ServerFunctionInvocation | undefined;
|
|
520
541
|
export declare function foldSetCookies(headers: Headers, setCookies: readonly string[]): Headers;
|
|
@@ -111,6 +111,25 @@ export interface ServerFunctionMetadata {
|
|
|
111
111
|
* `withMeta` write wins.
|
|
112
112
|
*/
|
|
113
113
|
readonly name?: string;
|
|
114
|
+
/**
|
|
115
|
+
* This function's own send, client side: the transport calls it instead
|
|
116
|
+
* of the configured `fetch` for every request the function makes, with
|
|
117
|
+
* the configured send (the app's `fetch`, or the global) as `next`. For
|
|
118
|
+
* an integration that answers a declared function's calls itself — a
|
|
119
|
+
* prerendered build's static artifacts, a cache — while the app's
|
|
120
|
+
* transport `fetch` stays the app's: pass on what you don't answer
|
|
121
|
+
* through `next`. The contract is `fetch`'s (see
|
|
122
|
+
* `ServerFunctionsClientConfig.fetch`); hydration adopts a
|
|
123
|
+
* server-rendered read only if the send reaches the global `fetch` in the
|
|
124
|
+
* same tick.
|
|
125
|
+
*
|
|
126
|
+
* ```ts
|
|
127
|
+
* withMeta(getPosts, {
|
|
128
|
+
* fetch: (address, init, next) => cached(address) ?? next(address, init)
|
|
129
|
+
* });
|
|
130
|
+
* ```
|
|
131
|
+
*/
|
|
132
|
+
readonly fetch?: (address: string, init: RequestInit, next: (address: string, init: RequestInit) => Response | Promise<Response>) => Response | Promise<Response>;
|
|
114
133
|
/** User-declared transport metadata attached with `withMeta`. */
|
|
115
134
|
readonly [key: string]: unknown;
|
|
116
135
|
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export declare const UPLOAD_ARGS_PART = "args";
|
|
2
|
+
export declare const UPLOAD_FILE_PART = "file";
|
|
3
|
+
/**
|
|
4
|
+
* True for a file or a blob. One from another frame is an instance of that
|
|
5
|
+
* frame's `Blob`, so its shape tells instead.
|
|
6
|
+
*/
|
|
7
|
+
declare function isBlob(value: any): boolean;
|
|
8
|
+
/**
|
|
9
|
+
* The client half. Each file or blob in the arguments serializes as its
|
|
10
|
+
* index in `files`. A file that appears twice is pushed once, so it arrives
|
|
11
|
+
* as one value.
|
|
12
|
+
*/
|
|
13
|
+
export declare function createUploadSerializer(files: any): {
|
|
14
|
+
tag: string;
|
|
15
|
+
test: typeof isBlob;
|
|
16
|
+
parse: {
|
|
17
|
+
sync: (value: any, ctx: any) => {
|
|
18
|
+
i: any;
|
|
19
|
+
};
|
|
20
|
+
async: (value: any, ctx: any) => Promise<{
|
|
21
|
+
i: any;
|
|
22
|
+
}>;
|
|
23
|
+
stream: (value: any, ctx: any) => {
|
|
24
|
+
i: any;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
serialize: (node: any, ctx: any) => any;
|
|
28
|
+
deserialize: () => never;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* The server half, made for one request. Each index turns back into its
|
|
32
|
+
* part of `form`. A bad index or a missing part fails the decode.
|
|
33
|
+
*/
|
|
34
|
+
export declare function createUploadDeserializer(form: any): {
|
|
35
|
+
tag: string;
|
|
36
|
+
test: () => boolean;
|
|
37
|
+
parse: {
|
|
38
|
+
sync: () => never;
|
|
39
|
+
async: () => never;
|
|
40
|
+
stream: () => never;
|
|
41
|
+
};
|
|
42
|
+
serialize: () => never;
|
|
43
|
+
deserialize: (node: any, ctx: any) => any;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* The request body for a call with files. `FormData` only takes blobs of its
|
|
47
|
+
* own frame, so a blob from another frame is copied first.
|
|
48
|
+
*/
|
|
49
|
+
export declare function createUploadBody(serialized: any, files: any): Promise<FormData>;
|
|
50
|
+
export {};
|
|
@@ -55,9 +55,10 @@ export interface InvocationContext {
|
|
|
55
55
|
/** What the frame producer hands an observation: the stream's identity. */
|
|
56
56
|
export interface FrameObservation {
|
|
57
57
|
/** Counts the chunk — call for every chunk written after `start`. */
|
|
58
|
-
chunk(
|
|
59
|
-
type
|
|
58
|
+
chunk(message: {
|
|
59
|
+
type?: string;
|
|
60
60
|
id: string;
|
|
61
|
+
r?: Record<string, any>;
|
|
61
62
|
}): void;
|
|
62
63
|
/** Delivers the record. `error` is the value thrown on the synchronous failure path. */
|
|
63
64
|
settle(outcome: FrameProducedEvent["outcome"], error?: unknown): void;
|