@solidjs/web 2.0.0-rc.14 → 2.0.0-rc.16
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 +475 -591
- package/dist/server.js +459 -489
- package/dist/server.observe.js +459 -498
- package/dist/web.dev.js +206 -220
- package/dist/web.js +196 -208
- package/dist/web.observe.js +206 -213
- package/frames/dist/client.dev.js +664 -643
- package/frames/dist/client.js +593 -582
- package/frames/dist/client.observe.js +624 -589
- package/frames/dist/regions.js +43 -2
- package/frames/dist/server.dev.js +578 -450
- package/frames/dist/server.js +578 -397
- package/frames/dist/server.observe.js +578 -397
- package/frames/dist/trace.js +4 -1
- package/frames/dist/wire.js +371 -6
- package/package.json +13 -13
- package/serialization/dist/decode.js +11 -9
- package/serialization/dist/serialization.js +11 -9
- package/serialization/types/serializer-decode.d.ts +2 -2
- package/server-functions/dist/client.dev.js +5 -2
- package/server-functions/dist/client.js +3 -2
- package/server-functions/dist/client.observe.js +5 -2
- package/server-functions/dist/rich-args.js +33 -1
- package/server-functions/dist/server.dev.js +218 -35
- package/server-functions/dist/server.js +218 -35
- package/server-functions/dist/server.observe.js +218 -35
- package/skills/server-components/SKILL.md +74 -185
- package/types/client.d.ts +112 -10
- package/types/constants.d.ts +2 -1
- 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 +1 -53
- package/types/frames/wire-tier.d.ts +54 -1
- package/types/head.d.ts +1 -0
- package/types/index.d.ts +57 -50
- package/types/index.server.d.ts +3 -27
- package/types/jsx.d.ts +14 -17
- package/types/observe.d.ts +14 -7
- package/types/render.d.ts +3 -1
- package/types/response.d.ts +31 -8
- package/types/serializer-decode.d.ts +2 -2
- package/types/server-functions/argument-codec.d.ts +21 -0
- package/types/server-functions/client.d.ts +18 -5
- package/types/server-functions/server.d.ts +6 -2
- package/types/server-functions/shared.d.ts +19 -0
- package/types/server-mock.d.ts +9 -2
- package/types/server-observe.d.ts +3 -2
- package/types/server.d.ts +124 -67
- 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/head.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export declare function classifyHeadTag(desc: any): {
|
|
|
14
14
|
};
|
|
15
15
|
export declare function qualifierValue(name: any, value: any): any;
|
|
16
16
|
export declare function asciiLowerCase(value: any): any;
|
|
17
|
+
export declare function headBodyText(tag: any, props: any, text: any): any;
|
|
17
18
|
export declare function resourceIdentity(tag: any, props: any): string;
|
|
18
19
|
export declare function replaceableIdentity(tag: any, props: any, key: any, unique: any): any;
|
|
19
20
|
export declare function resolveHead(groups: any): Map<any, any>;
|
package/types/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Component } from "solid-js";
|
|
1
|
+
import { Component, type DynamicOptions } from "solid-js";
|
|
2
2
|
import type { JSX } from "./jsx.js";
|
|
3
3
|
export * from "./client.js";
|
|
4
4
|
export * from "./server-mock.js";
|
|
@@ -73,27 +73,67 @@ 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;
|
|
80
80
|
children: JSX.Element;
|
|
81
81
|
}): JSX.Element;
|
|
82
|
-
export
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
82
|
+
export type { DynamicOptions } from "solid-js";
|
|
83
|
+
export { dynamicComponent } from "solid-js";
|
|
84
|
+
/**
|
|
85
|
+
* Returns a stable `Component` whose identity is driven by a reactive (and
|
|
86
|
+
* optionally async) `source`. The returned component can be used anywhere a
|
|
87
|
+
* normal component is used; children and props flow through JSX as usual.
|
|
88
|
+
*
|
|
89
|
+
* `source` may return a component, a native tag name (`'input'`, `'textarea'`,
|
|
90
|
+
* etc.), `undefined`, or a `Promise` of any of the above. A pending promise
|
|
91
|
+
* propagates as `NotReadyError` through the surrounding reactive scope, so
|
|
92
|
+
* async swaps compose with `<Loading>` boundaries the same way as `lazy`.
|
|
93
|
+
*
|
|
94
|
+
* During SSR a pending source streams in behind its boundary by default. Pass
|
|
95
|
+
* `{ deferStream: true }` to hold the document's first flush until it settles
|
|
96
|
+
* (the same option `createMemo` takes); the client ignores it.
|
|
97
|
+
*
|
|
98
|
+
* For a tag-name source the element's namespace is inferred from the tag. A
|
|
99
|
+
* tag that exists in both HTML and SVG (`a`, `script`, `style`, `title`) is
|
|
100
|
+
* created as HTML unless the instance passes `xmlns` — the same attribute
|
|
101
|
+
* compiled JSX uses for the same purpose. `is` (customized built-ins) and
|
|
102
|
+
* `xmlns` are read once at creation and then applied as ordinary attributes.
|
|
103
|
+
*
|
|
104
|
+
* `{ static: true }` says the source cannot change: it is called once,
|
|
105
|
+
* untracked, when `dynamic()` is called, and each instance renders the result
|
|
106
|
+
* with no computation of its own — a tag name goes straight to the compiled
|
|
107
|
+
* element path (create or claim, spread), a component is called directly. No
|
|
108
|
+
* owner is created on either side, so hydration keys stay aligned with the
|
|
109
|
+
* compiled output. Use it for a constant (`dynamic(() => "li", { static: true })`
|
|
110
|
+
* in a runtime `styled()`), or per instance from the shape of a prop:
|
|
111
|
+
* `isStatic(props, "as")` is true when the caller wrote `as="button"`
|
|
112
|
+
* (a data property) and false when they wrote `as={cond() ? …}` (a getter),
|
|
113
|
+
* so a polymorphic component keeps a reactive public `as` and still pays
|
|
114
|
+
* nothing for the literal case. A static source may not return a promise.
|
|
115
|
+
*
|
|
116
|
+
* @example
|
|
117
|
+
* ```tsx
|
|
118
|
+
* // `source` can return either a custom Component or a native tag
|
|
119
|
+
* // name — they're interchangeable, and the returned reference is a
|
|
120
|
+
* // stable Component you can use anywhere a normal one would go.
|
|
121
|
+
* const Field = dynamic(() => multiline() ? RichTextEditor : "input");
|
|
122
|
+
* return <Field value={value()} onInput={onInput} />;
|
|
123
|
+
*
|
|
124
|
+
* // An ambiguous tag inside an SVG tree: say which namespace you mean.
|
|
125
|
+
* const Link = dynamic(() => "a");
|
|
126
|
+
* <svg><Link xmlns="http://www.w3.org/2000/svg" href="/x">…</Link></svg>
|
|
127
|
+
*
|
|
128
|
+
* // A polymorphic component: no memo when `as` arrived as a literal.
|
|
129
|
+
* function Polymorphic(props) {
|
|
130
|
+
* const Tag = dynamic(() => props.as, { static: isStatic(props, "as") });
|
|
131
|
+
* return <Tag {...omit(props, "as")} />;
|
|
132
|
+
* }
|
|
133
|
+
* ```
|
|
134
|
+
*
|
|
135
|
+
* @description https://v2.solidjs.com/reference/solid-web/components/dynamic
|
|
136
|
+
*/
|
|
97
137
|
/**
|
|
98
138
|
* A component from a reactive source. The source may answer with the
|
|
99
139
|
* component itself, a promise of it, or an async iterable of it — a `live`
|
|
@@ -115,39 +155,6 @@ export interface DynamicOptions {
|
|
|
115
155
|
* component mount — should use `dynamicComponent`, which never does.
|
|
116
156
|
*/
|
|
117
157
|
export declare function dynamic<T extends ValidComponent>(source: () => T | Promise<T> | AsyncIterable<T> | null | undefined | false, options?: DynamicOptions): Component<ComponentProps<T>>;
|
|
118
|
-
/**
|
|
119
|
-
* `dynamic` for a source that only ever answers with a component — never a
|
|
120
|
-
* tag name. Same contract, same semantics, same hydration shape (the two
|
|
121
|
-
* share one implementation): a reactive, optionally async source; a stable
|
|
122
|
-
* `Component` back; `{ static: true }` and `{ deferStream: true }` as on
|
|
123
|
-
* `dynamic`. The source's type excludes strings, so a tag name is a compile
|
|
124
|
-
* error here — use `dynamic` for one.
|
|
125
|
-
*
|
|
126
|
-
* Cost model, which is the reason this exists: `dynamic` must be able to
|
|
127
|
-
* render a tag, so one `dynamic` anywhere on a page retains the element
|
|
128
|
-
* runtime — `createElement`, `spread` and the prop-collection helpers, the
|
|
129
|
-
* SVG/MathML tables — for everyone, whether or not any source ever answers
|
|
130
|
-
* with a string (a bundler cannot know what a source will resolve to).
|
|
131
|
-
* `dynamicComponent` has no tag arm and never references that runtime, so a
|
|
132
|
-
* page whose only dynamic mounts are components pays nothing for it.
|
|
133
|
-
*
|
|
134
|
-
* This is the documented way to mount a server component: a server
|
|
135
|
-
* function's answer is a component reference, and the frames transport
|
|
136
|
-
* resolves every call for the same function to the same mount identity, so
|
|
137
|
-
* a refetch or an argument change is delivered into the mounted instance
|
|
138
|
-
* rather than remounting it (see `dynamic` for the full account).
|
|
139
|
-
*
|
|
140
|
-
* @example
|
|
141
|
-
* ```tsx
|
|
142
|
-
* const Story = dynamicComponent(() => getStory(props.storyId));
|
|
143
|
-
* return <Story comment={p => <Comment cid={p.cid}>{p.children}</Comment>} />;
|
|
144
|
-
*
|
|
145
|
-
* // A client component chosen by (sync) data — the same thing `dynamic`
|
|
146
|
-
* // does, without retaining the element runtime for the page.
|
|
147
|
-
* const Page = dynamicComponent(() => (page().editable ? Editor : Viewer));
|
|
148
|
-
* ```
|
|
149
|
-
*/
|
|
150
|
-
export declare function dynamicComponent<C extends Component<any>>(source: () => C | Promise<C> | AsyncIterable<C> | null | undefined | false, options?: DynamicOptions): Component<ComponentProps<C>>;
|
|
151
158
|
/**
|
|
152
159
|
* @deprecated Use `dynamic()`. `<Dynamic>` is the same primitive, but its
|
|
153
160
|
* shape puts the tag in the same bag as the element's props: every instance
|
package/types/index.server.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Component } from "solid-js";
|
|
1
|
+
import { type Component, type DynamicOptions } from "solid-js";
|
|
2
2
|
import type { JSX } from "./jsx.js";
|
|
3
3
|
export * from "./server.js";
|
|
4
4
|
export * from "./response.js";
|
|
@@ -25,33 +25,9 @@ export declare const isDev: boolean;
|
|
|
25
25
|
export type IntrinsicElement = Extract<keyof JSX.IntrinsicElements, string>;
|
|
26
26
|
export type ValidComponent = IntrinsicElement | Component<any> | (string & {});
|
|
27
27
|
export type ComponentProps<T extends ValidComponent> = T extends Component<infer P> ? P : T extends keyof JSX.IntrinsicElements ? JSX.IntrinsicElements[T] : Record<string, unknown>;
|
|
28
|
-
export
|
|
29
|
-
|
|
30
|
-
* SSR only: hold the document's first flush until the source settles, so
|
|
31
|
-
* the resolved component renders into the shell instead of streaming in
|
|
32
|
-
* behind its boundary's fallback. Same meaning as `createMemo`'s
|
|
33
|
-
* `deferStream`. Default `false` — a `dynamic()` source is data of unknown
|
|
34
|
-
* cost and streams by default (a code-split `lazy()` always holds the shell
|
|
35
|
-
* for its module load, since its code is a prerequisite to the render).
|
|
36
|
-
*/
|
|
37
|
-
deferStream?: boolean;
|
|
38
|
-
/**
|
|
39
|
-
* The source cannot change: call it once, untracked, now, and render the
|
|
40
|
-
* result with no computation per instance (see the client `dynamic`). The
|
|
41
|
-
* source must resolve synchronously.
|
|
42
|
-
*/
|
|
43
|
-
static?: boolean;
|
|
44
|
-
}
|
|
28
|
+
export type { DynamicOptions } from "solid-js";
|
|
29
|
+
export { dynamicComponent } from "solid-js";
|
|
45
30
|
export declare function dynamic<T extends ValidComponent>(source: () => T | Promise<T> | null | undefined | false, options?: DynamicOptions): Component<ComponentProps<T>>;
|
|
46
|
-
/**
|
|
47
|
-
* The server twin of the client's `dynamicComponent`: `dynamic` for a source
|
|
48
|
-
* that only ever answers with a component, never a tag name. Same owner
|
|
49
|
-
* shape as `dynamic` on both sides (the factory / value / render memos), so
|
|
50
|
-
* hydration ids agree with the client whichever of the two mounts the same
|
|
51
|
-
* value. The client entry's JSDoc carries the cost model; here the tag arm
|
|
52
|
-
* is simply absent.
|
|
53
|
-
*/
|
|
54
|
-
export declare function dynamicComponent<C extends Component<any>>(source: () => C | Promise<C> | null | undefined | false, options?: DynamicOptions): Component<ComponentProps<C>>;
|
|
55
31
|
/** @deprecated Props of the deprecated `<Dynamic>`; see `dynamic()`. */
|
|
56
32
|
export type DynamicProps<T extends ValidComponent, P = ComponentProps<T>> = {
|
|
57
33
|
[K in keyof P]: P[K];
|
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;
|
|
@@ -1139,20 +1145,11 @@ export namespace JSX {
|
|
|
1139
1145
|
target?: "_self" | "_blank" | "_parent" | "_top" | (string & {}) | RemoveAttribute;
|
|
1140
1146
|
type?: string | RemoveAttribute;
|
|
1141
1147
|
|
|
1142
|
-
// Client-side navigation contract.
|
|
1143
|
-
//
|
|
1144
|
-
//
|
|
1145
|
-
// so plain `<a>` elements participate without per-router augmentation.
|
|
1148
|
+
// Client-side navigation contract. `link` is inert markup on its own —
|
|
1149
|
+
// a routing integration that delegates anchor clicks (e.g. @solidjs/router)
|
|
1150
|
+
// reads it off the element at event time.
|
|
1146
1151
|
/** Marks the anchor as a client-navigation link when the integration requires explicit opt-in. */
|
|
1147
1152
|
link?: BooleanAttribute | RemoveAttribute;
|
|
1148
|
-
/** Serialized (JSON) history state pushed alongside the navigation. */
|
|
1149
|
-
state?: string | RemoveAttribute;
|
|
1150
|
-
/** Suppress scroll restoration/reset after the navigation. */
|
|
1151
|
-
noscroll?: BooleanAttribute | RemoveAttribute;
|
|
1152
|
-
/** Replace the current history entry instead of pushing a new one. */
|
|
1153
|
-
replace?: BooleanAttribute | RemoveAttribute;
|
|
1154
|
-
/** Route preload intent; `"false"` disables the integration's default eager preload. */
|
|
1155
|
-
preload?: boolean | "false" | RemoveAttribute;
|
|
1156
1153
|
|
|
1157
1154
|
/** @experimental */
|
|
1158
1155
|
attributionsrc?: string | RemoveAttribute;
|
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
|
@@ -4,8 +4,14 @@
|
|
|
4
4
|
* payloads); the HTTP handler forwards `response`'s headers and
|
|
5
5
|
* (non-redirect) status and encodes `value` as the body through the codec,
|
|
6
6
|
* while client-only integrations read `value` directly — no reparse.
|
|
7
|
+
*
|
|
8
|
+
* The envelope IS a `Response` — the given response's body, status and
|
|
9
|
+
* headers — so a consumer that knows nothing of Solid (a filesystem
|
|
10
|
+
* router's API dispatch, any fetch-style handler) answers with it as-is.
|
|
11
|
+
* `response` is the envelope itself, or `undefined` when constructed
|
|
12
|
+
* without one.
|
|
7
13
|
*/
|
|
8
|
-
export interface ResponseEnvelope<T = unknown> {
|
|
14
|
+
export interface ResponseEnvelope<T = unknown> extends Response {
|
|
9
15
|
response: Response | undefined;
|
|
10
16
|
value: T;
|
|
11
17
|
}
|
|
@@ -60,9 +66,9 @@ export interface ResponseHelperInit extends ResponseInit {
|
|
|
60
66
|
* The cache keys the mutation invalidated, sent as the `X-Revalidate`
|
|
61
67
|
* header for the client's integrations to apply. Three declarations, three
|
|
62
68
|
* scopes: omitted sends no header — the host's default (Solid Router
|
|
63
|
-
* revalidates everything after
|
|
64
|
-
* convention reloads only what it owns); an empty
|
|
65
|
-
* 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,
|
|
66
72
|
* whatever the host's default. How named keys are matched (prefixes,
|
|
67
73
|
* namespaces) is each integration's business.
|
|
68
74
|
*/
|
|
@@ -73,13 +79,24 @@ export declare const RESPONSE_HEADER_VALUE_LIMIT = 4096;
|
|
|
73
79
|
/**
|
|
74
80
|
* Response redirecting to `url` (default 302). `revalidate` names the
|
|
75
81
|
* cache keys the mutation invalidated.
|
|
82
|
+
*
|
|
83
|
+
* Typed so it never shows up in the type of the function returning it: a
|
|
84
|
+
* redirect is control flow for the integration to act on, not a value.
|
|
85
|
+
* `T` defaults to `never`, which vanishes from the inferred return type's
|
|
86
|
+
* union; where the context expects a type (an annotated return, a
|
|
87
|
+
* `Response`-typed request handler) `T` takes it. A literal `never` return
|
|
88
|
+
* would also mark code after a bare call unreachable; a type parameter
|
|
89
|
+
* does not. At runtime it is a real `Response`.
|
|
76
90
|
*/
|
|
77
|
-
export declare function redirect(url: string | Href, init?: number | ResponseHelperInit):
|
|
91
|
+
export declare function redirect<T = never>(url: string | Href, init?: number | ResponseHelperInit): T;
|
|
78
92
|
/**
|
|
79
93
|
* Empty response requesting revalidation of the named cache keys (all of
|
|
80
94
|
* them when omitted).
|
|
95
|
+
*
|
|
96
|
+
* Typed as `redirect` is, for the same reason: it never shows up in the
|
|
97
|
+
* type of the function returning it. At runtime it is a real `Response`.
|
|
81
98
|
*/
|
|
82
|
-
export declare function reload(init?: ResponseHelperInit):
|
|
99
|
+
export declare function reload<T = never>(init?: ResponseHelperInit): T;
|
|
83
100
|
/**
|
|
84
101
|
* Statuses HTTP forbids a body on — the `Response` constructor enforces it
|
|
85
102
|
* by throwing on ANY body, `JSON.stringify(undefined)`'s `"undefined"`
|
|
@@ -94,6 +111,12 @@ export declare const NULL_BODY_STATUSES: ReadonlySet<number>;
|
|
|
94
111
|
* for the things a naked return can't express. Progressive enhancement
|
|
95
112
|
* stays invisible: the carried response holds a plain JSON body so
|
|
96
113
|
* consumers without the client runtime (no-JS form posts, direct HTTP)
|
|
97
|
-
* 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.
|
|
116
|
+
*
|
|
117
|
+
* Typed as `value`'s type: every caller of the function returning it —
|
|
118
|
+
* over HTTP or in-process — receives the value, never the envelope. At
|
|
119
|
+
* runtime it is a `ResponseEnvelope`, a real `Response` that integrations
|
|
120
|
+
* recognize with `isResponseEnvelope()`.
|
|
98
121
|
*/
|
|
99
|
-
export declare function respond<T>(value: T, init?: ResponseHelperInit):
|
|
122
|
+
export declare function respond<T>(value: T, init?: ResponseHelperInit): T;
|
|
@@ -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,21 @@
|
|
|
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
|
+
/** The configured codec options with encode-side refusals ahead of every plugin. */
|
|
21
|
+
export declare function argumentEncodeCodec(codec: 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
|
|
@@ -98,6 +103,10 @@ export interface ServerFunctionsClientConfig {
|
|
|
98
103
|
* }
|
|
99
104
|
* });
|
|
100
105
|
* ```
|
|
106
|
+
*
|
|
107
|
+
* Return synchronously when you can: hydration adopts a server-rendered
|
|
108
|
+
* read only if its request is sent in the same tick, so an async hook
|
|
109
|
+
* makes every hydrated read fetch again from the browser.
|
|
101
110
|
*/
|
|
102
111
|
prepareRequest?: PrepareRequestHook;
|
|
103
112
|
/**
|
|
@@ -120,7 +129,10 @@ export interface ServerFunctionsClientConfig {
|
|
|
120
129
|
* declared shape and per-call options as dispatched (a `GET`-declared
|
|
121
130
|
* read stays a GET; a caller-supplied `signal` still owns the wire) —
|
|
122
131
|
* for a handler re-asking on its own account (a frames boundary's
|
|
123
|
-
* `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`).
|
|
124
136
|
*/
|
|
125
137
|
handle(response: Response, ctx: {
|
|
126
138
|
id: string;
|
|
@@ -128,6 +140,7 @@ export interface ServerFunctionsClientConfig {
|
|
|
128
140
|
args: unknown[];
|
|
129
141
|
context: unknown;
|
|
130
142
|
retry(): Promise<unknown>;
|
|
143
|
+
startedAt?: number;
|
|
131
144
|
}): unknown;
|
|
132
145
|
/**
|
|
133
146
|
* Answer a call before any request is made (t = 0 local answers — see
|
|
@@ -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
|
*/
|
|
@@ -433,7 +437,7 @@ export interface HandleServerFunctionOptions {
|
|
|
433
437
|
* This request's server error hook, ahead of `configureServerErrors`' (see
|
|
434
438
|
* `ServerErrorHook` in `@solidjs/web`): the function's throw
|
|
435
439
|
* (`handling: "thrown"`) and a failure escaping through its result graph
|
|
436
|
-
* (`"channel"`), once per error, before the wire policy applies. Entry-only
|
|
440
|
+
* (`"channel"`), once per error per request, before the wire policy applies. Entry-only
|
|
437
441
|
* like `wrapInvocation`: a direct call the body makes during a render
|
|
438
442
|
* reports through the ambient hook.
|
|
439
443
|
*/
|
|
@@ -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
|
}
|
package/types/server-mock.d.ts
CHANGED
|
@@ -271,7 +271,7 @@ export declare function getExpectedRedirectStatus(response: ResponseStub): numbe
|
|
|
271
271
|
*/
|
|
272
272
|
export declare function createSSRResponse(result: string, event: RequestEvent | undefined, options?: {
|
|
273
273
|
responseInit?: ResponseInit;
|
|
274
|
-
nonce?:
|
|
274
|
+
nonce?: CSPNonce;
|
|
275
275
|
transformChunk?: (chunk: string) => string;
|
|
276
276
|
}): Response;
|
|
277
277
|
export declare function createSSRResponse(result: {
|
|
@@ -281,7 +281,7 @@ export declare function createSSRResponse(result: {
|
|
|
281
281
|
}): void;
|
|
282
282
|
}, event: RequestEvent | undefined, options?: {
|
|
283
283
|
responseInit?: ResponseInit;
|
|
284
|
-
nonce?:
|
|
284
|
+
nonce?: CSPNonce;
|
|
285
285
|
transformChunk?: (chunk: string) => string;
|
|
286
286
|
}): Promise<Response>;
|
|
287
287
|
/**
|
|
@@ -325,6 +325,13 @@ export declare function ssrElement(name: string, props: any | any[] | (() => any
|
|
|
325
325
|
* @internal
|
|
326
326
|
*/
|
|
327
327
|
export declare function ssrElementAttribute(key: string, value: any): string;
|
|
328
|
+
/**
|
|
329
|
+
* Compiler primitive — the hole after a candidate anchor's attributes in SSR
|
|
330
|
+
* output, the render's link handler's markup (see the server entry's
|
|
331
|
+
* `setLinkClaim`). Not meant for hand-written code.
|
|
332
|
+
* @internal
|
|
333
|
+
*/
|
|
334
|
+
export declare function ssrLinkClaim(attrs: Readonly<Record<string, unknown>>): string;
|
|
328
335
|
/**
|
|
329
336
|
* Compiler primitive — serializes a class value (string, object map, or
|
|
330
337
|
* array) for SSR output. Not meant for hand-written code.
|
|
@@ -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;
|