@solidjs/web 2.0.0-rc.13 → 2.0.0-rc.14
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/server.dev.js +200 -73
- package/dist/server.js +182 -59
- package/dist/server.observe.js +183 -60
- package/dist/web.dev.js +70 -35
- package/dist/web.js +43 -31
- package/dist/web.observe.js +43 -33
- package/frames/dist/assets.js +92 -0
- package/frames/dist/bind.dev.js +326 -0
- package/frames/dist/bind.js +295 -0
- package/frames/dist/client.dev.js +605 -1086
- package/frames/dist/client.js +572 -1066
- package/frames/dist/client.observe.js +571 -1066
- package/frames/dist/regions.js +130 -0
- package/frames/dist/server.dev.js +339 -177
- package/frames/dist/server.js +335 -173
- package/frames/dist/server.observe.js +335 -173
- package/frames/dist/trace.js +42 -0
- package/frames/dist/wire.js +133 -0
- package/package.json +28 -2
- package/performance-tracks/dist/performance-tracks.dev.js +2 -1
- package/performance-tracks/dist/performance-tracks.observe.js +2 -1
- package/performance-tracks/types/index.d.ts +8 -6
- package/serialization/dist/decode.js +37 -8
- package/serialization/dist/serialization.js +39 -10
- package/serialization/types/serializer-decode.d.ts +24 -2
- package/server-functions/dist/client.dev.js +99 -61
- package/server-functions/dist/client.js +99 -61
- package/server-functions/dist/client.observe.js +99 -61
- package/server-functions/dist/server.dev.js +87 -50
- package/server-functions/dist/server.js +87 -50
- package/server-functions/dist/server.observe.js +87 -50
- package/skills/server-components/SKILL.md +65 -43
- package/types/client.d.ts +20 -0
- package/types/constants.d.ts +2 -1
- package/types/diagnostics.d.ts +8 -0
- package/types/frames/assets-tier.d.ts +78 -0
- package/types/frames/bind-tier.d.ts +60 -0
- package/types/frames/client.d.ts +37 -3
- package/types/frames/frame-client.d.ts +249 -78
- package/types/frames/frame-container-plugin.d.ts +2 -2
- package/types/frames/frame-sink.d.ts +33 -0
- package/types/frames/frame-transport.d.ts +66 -18
- package/types/frames/regions-tier.d.ts +45 -0
- package/types/frames/serializer-decode.d.ts +24 -2
- package/types/frames/server.d.ts +32 -8
- package/types/frames/trace-tier.d.ts +2 -0
- package/types/frames/wire-tier.d.ts +116 -0
- package/types/index.d.ts +38 -0
- package/types/index.server.d.ts +9 -0
- package/types/jsx.d.ts +1 -1
- package/types/observe.d.ts +4 -2
- package/types/serializer-decode.d.ts +24 -2
- package/types/server-functions/client.d.ts +26 -0
- package/types/server-functions/registry.d.ts +4 -1
- package/types/server-functions/shared.d.ts +12 -8
- package/types/server-mock.d.ts +13 -1
- package/types/server.d.ts +34 -8
|
@@ -14,12 +14,12 @@ this file is the operative subset.
|
|
|
14
14
|
|
|
15
15
|
- Exists because of **server data** (a todo row, a nav link, a search
|
|
16
16
|
form the server renders)? It is **server markup**. Client behavior or a
|
|
17
|
-
client-driven value on it is
|
|
17
|
+
client-driven value on it is a **binding slot** — bind, never wrap.
|
|
18
18
|
Do not wrap a server-rendered element in a client component to give it a
|
|
19
19
|
handler or a class.
|
|
20
20
|
- Exists because of **client state alone** (an optimistic add, a modal, a
|
|
21
21
|
drag ghost, an editor open over a field)? It is a **client component**
|
|
22
|
-
placed through a **
|
|
22
|
+
placed through a **template slot**.
|
|
23
23
|
|
|
24
24
|
When the client confirms an optimistic entity and the server renders it, the
|
|
25
25
|
row _becomes_ server markup; `$key` on the element reconciles the two.
|
|
@@ -27,19 +27,19 @@ row _becomes_ server markup; `$key` on the element reconciles the two.
|
|
|
27
27
|
## The two kinds of slot
|
|
28
28
|
|
|
29
29
|
```tsx
|
|
30
|
-
import type {
|
|
30
|
+
import type { BindingSlot, Slot } from "@solidjs/web/frames";
|
|
31
31
|
|
|
32
32
|
interface TodosProps {
|
|
33
|
-
pending: Slot; //
|
|
34
|
-
row:
|
|
35
|
-
filters:
|
|
33
|
+
pending: Slot; // template: the client returns JSX
|
|
34
|
+
row: BindingSlot<{ id: string; completed: boolean }, RowBehavior>; // bindings: the client returns an object
|
|
35
|
+
filters: BindingSlot<{}, FilterBehavior>; // no args: called bare
|
|
36
36
|
}
|
|
37
37
|
```
|
|
38
38
|
|
|
39
|
-
A **
|
|
39
|
+
A **template slot** is placed as an element: `<props.pending />`. The client
|
|
40
40
|
owns those nodes.
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
A **binding slot** is _called_ once per data context and its properties
|
|
43
43
|
are _bound_ at positions of the server's own template:
|
|
44
44
|
|
|
45
45
|
```tsx
|
|
@@ -72,12 +72,17 @@ export async function todoList() {
|
|
|
72
72
|
The client passes the fill — a function of the args that returns the object:
|
|
73
73
|
|
|
74
74
|
```tsx
|
|
75
|
-
<Todos row={rowFor} filters={() => ({ all
|
|
75
|
+
<Todos row={rowFor} filters={() => ({ get all() { return filter() === "all"; }, … })} pending={() => <For each={adds}>{…}</For>} />
|
|
76
76
|
```
|
|
77
77
|
|
|
78
|
-
|
|
78
|
+
The fill must return a plain object. An array, a DOM node, a function or
|
|
79
|
+
an async value is a type error on both sides (`BindingSlot`'s return is
|
|
80
|
+
`SlotOutput<J>`, a branded `SlotError` naming the reason) and a
|
|
81
|
+
`fill-shape` finding at runtime.
|
|
79
82
|
|
|
80
|
-
|
|
83
|
+
## The one rule for binding slots
|
|
84
|
+
|
|
85
|
+
> **A slot property is a JSX attribute value or a text child, whole, and nothing else.**
|
|
81
86
|
|
|
82
87
|
Legal positions: an attribute (`hidden={row.removed}`, `checked={row.done}`,
|
|
83
88
|
`title={row.error}`), a class name inside object form
|
|
@@ -86,8 +91,12 @@ Legal positions: an attribute (`hidden={row.removed}`, `checked={row.done}`,
|
|
|
86
91
|
an event (`onInput={row.onToggle}`), a ref (`ref={row.ref}`) — on an element
|
|
87
92
|
with a spread too (`<button {...rest} onClick={row.go} />` — the last
|
|
88
93
|
source that has the key wins, `undefined` included, as the client's
|
|
89
|
-
spread reads it)
|
|
90
|
-
|
|
94
|
+
spread reads it) — and a text child (`<strong>{list.remaining}</strong> items
|
|
95
|
+
left`): a string or number renders, nullish and booleans render empty, and
|
|
96
|
+
the client owns the text between a `<!--_s:t=…-->` marker pair. Never the
|
|
97
|
+
content of `<textarea>`, `<title>`, `<style>` or `<script>`, where the
|
|
98
|
+
markers would be literal text — bind `value=` or a style property there.
|
|
99
|
+
Not a `prop:*` property, not inside another slot call's args (nested in
|
|
91
100
|
plain objects and arrays included). Reserved keys the fill must not use:
|
|
92
101
|
keys beginning with `$` or a digit, `length`, `slice`, `t`/`h`/`p`, `then`,
|
|
93
102
|
`constructor`/`toString`/`valueOf`/`toJSON`; anything else (`filter`, `map`
|
|
@@ -97,25 +106,34 @@ The server **does not have the value** — on the stream face a property read
|
|
|
97
106
|
is a stand-in with no value, on the document face only the initial one — so
|
|
98
107
|
nothing can be computed from it on the server. Every one of these is wrong:
|
|
99
108
|
|
|
100
|
-
| Wrong | Why | Write instead
|
|
101
|
-
| ---------------------------------------------------------------------- | ------------------------------------------------------------------------------------- |
|
|
102
|
-
| ``class={`todo ${row.done}`}`` | stringified: not the whole value | `class={{ todo: true, completed: row.done }}` or return `rowClass` from the fill
|
|
103
|
-
| `row.count > 3 ? "a" : "b"` | comparison on a stand-in | decide in the fill; return the decided value
|
|
104
|
-
| `if (row.error) …`, `row.error && <button/>`, `<Show when={row.done}>` | truthiness: a stand-in is an object and **always truthy** — the branch always renders | presence → `hidden={…}` or a class; a node that exists because of client state → a
|
|
105
|
-
| `<strong>{row.
|
|
106
|
-
|
|
|
107
|
-
|
|
|
108
|
-
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
109
|
+
| Wrong | Why | Write instead |
|
|
110
|
+
| ---------------------------------------------------------------------- | ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------ |
|
|
111
|
+
| ``class={`todo ${row.done}`}`` | stringified: not the whole value | `class={{ todo: true, completed: row.done }}` or return `rowClass` from the fill |
|
|
112
|
+
| `row.count > 3 ? "a" : "b"` | comparison on a stand-in | decide in the fill; return the decided value |
|
|
113
|
+
| `if (row.error) …`, `row.error && <button/>`, `<Show when={row.done}>` | truthiness: a stand-in is an object and **always truthy** — the branch always renders | presence → `hidden={…}` or a class; a node that exists because of client state → a template slot |
|
|
114
|
+
| `<strong>{row.label}</strong>` where the fill returns JSX for `label` | a text position renders a string or number | a template slot for markup |
|
|
115
|
+
| `<textarea>{row.draft}</textarea>` | raw-text content: the markers land in the text | `value={row.draft}` |
|
|
116
|
+
| `format(row.title)` (a server helper) | the helper receives a stand-in | do the formatting in the fill |
|
|
117
|
+
| `<li {...row}>` | spread: the template must show what the client owns | name each position |
|
|
118
|
+
| `onClick={() => …}` on a server element | a server function can never run in the browser | bind a slot property or a form `action` |
|
|
119
|
+
| `onKeyDown={[row.key, 1]}` | a tuple: a marker names keys, never data | return `onKeyDown: [handler, data]` from the fill; bind `onKeyDown={row.onKeyDown}` |
|
|
120
|
+
|
|
121
|
+
Every case except truthiness and raw-text content is a dev finding
|
|
122
|
+
(`BINDING_SLOT_POSITION`) and renders **nothing on either face**, so it
|
|
123
|
+
shows on the first render. Truthiness has no runtime hook: if a retry button
|
|
124
|
+
appears on every row, this is why. Raw-text content has none either; in
|
|
125
|
+
`<textarea>` and `<title>` the markers show as text.
|
|
114
126
|
|
|
115
127
|
## Writing the fill
|
|
116
128
|
|
|
117
|
-
- **
|
|
118
|
-
|
|
129
|
+
- **The fill runs once per occurrence, as a component body does.** It runs
|
|
130
|
+
untracked, under the occurrence's owner, with live args. State it
|
|
131
|
+
creates (a signal, a memo, an `onCleanup`) lives as long as the
|
|
132
|
+
occurrence. A top-level read is read once, and `STRICT_READ_UNTRACKED`
|
|
133
|
+
names it.
|
|
134
|
+
- **Values as getters, handlers as plain closures.** A getter is the
|
|
135
|
+
reactive form, as on a component's props object; a plain value never
|
|
136
|
+
updates:
|
|
119
137
|
|
|
120
138
|
```tsx
|
|
121
139
|
const rowFor = (p: { id: string; completed: boolean }): RowBehavior => ({
|
|
@@ -133,11 +151,11 @@ is why.
|
|
|
133
151
|
});
|
|
134
152
|
```
|
|
135
153
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
154
|
+
Each getter is read where its position binds, so a change moves the
|
|
155
|
+
positions that read it. The same object serves a client
|
|
156
|
+
`<TodoRow row={rowFor(todo)} />`, whose body reads it the same way. A
|
|
157
|
+
plain value is right only for what never changes (a constant handler,
|
|
158
|
+
a fixed class).
|
|
141
159
|
|
|
142
160
|
- **Name it like a props interface**, because it is one (a shared component
|
|
143
161
|
takes it as a prop). Handlers are `on` + intent — `onToggle`, `onRemove`,
|
|
@@ -147,9 +165,10 @@ is why.
|
|
|
147
165
|
runtime reads nothing into the prefix — the position decides what a
|
|
148
166
|
property is — but a reader can tell a handler from a value without
|
|
149
167
|
opening the type.
|
|
150
|
-
-
|
|
151
|
-
|
|
152
|
-
fires once per element.
|
|
168
|
+
- Handlers and refs are read once, when an element binds, and bind as in
|
|
169
|
+
client JSX: delegated events delegate, a `[handler, data]` tuple returned
|
|
170
|
+
from the fill binds as a tuple, a ref fires once per element. A handler
|
|
171
|
+
behind a getter is read once, as `onClick={cond() ? a : b}` is.
|
|
153
172
|
- **`$key` is optional.** A call repeated within a render (a component
|
|
154
173
|
prop re-evaluates it per position) is one occurrence either way. Add
|
|
155
174
|
`$key: t.id` when the fill holds its own state (an edit draft, a signal
|
|
@@ -162,7 +181,7 @@ is why.
|
|
|
162
181
|
## Shared components
|
|
163
182
|
|
|
164
183
|
One component can render on both sides: on the server its `row` prop is
|
|
165
|
-
the
|
|
184
|
+
the binding slot's return, on the client it is the fill's result. It
|
|
166
185
|
cannot tell and need not. Put `$key={props.id}` on the element it renders
|
|
167
186
|
(morph identity) — the slot call's own `$key` is a different key for a
|
|
168
187
|
different job. Do not read `document`/`window` during render; that is the
|
|
@@ -181,26 +200,29 @@ cannot be marked — the `inline` finding below.
|
|
|
181
200
|
|
|
182
201
|
## Diagnostics
|
|
183
202
|
|
|
184
|
-
`
|
|
203
|
+
`BINDING_SLOT_POSITION` (`data.reason`):
|
|
185
204
|
|
|
186
205
|
| reason | severity | what happened | fix |
|
|
187
206
|
| -------------- | -------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
188
207
|
| `spread` | error (throws) | a slot's return was spread onto an element | name each position |
|
|
189
208
|
| `stringified` | warn | template literal / concatenation | whole value at one position |
|
|
190
209
|
| `coerced` | warn | comparison, arithmetic, `==` | decide in the fill |
|
|
191
|
-
| `text` | warn | placed as a text child | markup slot |
|
|
192
210
|
| `inline` | warn | reached `class`/`style` inside template quotes | compile with `serverComponents: true` |
|
|
193
211
|
| `markup` | warn | the fill returned JSX but the template read a property | return an object, or place the slot |
|
|
194
212
|
| `server-local` | warn | a server function at `on*`/`ref` | bind a slot property |
|
|
213
|
+
| `tuple` | warn | an array at an `on*` position | return the tuple from the fill |
|
|
195
214
|
| `reserved-key` | warn | the fill used a reserved key | rename it |
|
|
196
215
|
| `arg` | warn | a slot property passed in another slot call's argument (nested in plain objects/arrays; `data.path`) | pass the server's own value, or read it in the fill from client state |
|
|
197
216
|
| `prop` | warn | a slot property at a `prop:*` key of a spread | bind the attribute form, or set the property in the fill's ref |
|
|
198
|
-
| `fill-shape` | warn (client) | the fill returned a non-object (`null`, array, DOM node, primitive), or the prop read as data is not a function
|
|
217
|
+
| `fill-shape` | warn (client) | the fill returned a non-object (`null`, array, DOM node, async value, primitive), or the prop read as data is not a function | return a plain object from a function prop |
|
|
218
|
+
| `text-shape` | warn (client) | a text position received a non-primitive (object, array, DOM node, function, async value — `data.key`, `data.shape`) | return a string or number; markup goes in a template slot |
|
|
199
219
|
| `orphan` | warn (client) | markers for an occurrence that can never bind: `data.why` `"fill"` — no fill for the prop; `"record"` — a called occurrence with no args record | `fill`: pass the prop / match the name on both sides. `record`: not the fill — rebuild client and server together (stale prebundle, cached asset), else report it |
|
|
200
220
|
|
|
201
|
-
Every reason but `fill-shape` and `orphan` comes from the server render.
|
|
221
|
+
Every reason but `fill-shape`, `text-shape` and `orphan` comes from the server render.
|
|
202
222
|
`orphan` is the one failure this model cannot otherwise show you: the
|
|
203
223
|
element is inert — a handler that never fires, a class that never updates —
|
|
204
224
|
with no error.
|
|
205
225
|
|
|
206
|
-
`STRICT_READ_UNTRACKED`
|
|
226
|
+
`STRICT_READ_UNTRACKED` naming a fill ("the \`row\` binding-slot fill",
|
|
227
|
+
"the \`comment\` template-slot fill"): a top-level read in its body; use
|
|
228
|
+
getters (above).
|
package/types/client.d.ts
CHANGED
|
@@ -159,6 +159,26 @@ export declare function registerDelegatedRoot(root: MountableElement): void;
|
|
|
159
159
|
export declare function unregisterDelegatedRoot(root: MountableElement): void;
|
|
160
160
|
export declare function registerDelegatedContainer(container: MountableElement, owner?: MountableElement): void;
|
|
161
161
|
export declare function unregisterDelegatedContainer(container: MountableElement, owner?: MountableElement): void;
|
|
162
|
+
/**
|
|
163
|
+
* Runs `fn` as a handler of the DOM event `e`, inside the interaction frame
|
|
164
|
+
* the runtime opens for `e` — the one its own listeners for `e` run in. A
|
|
165
|
+
* listener the runtime did not attach (a router's `document` click handler,
|
|
166
|
+
* analytics, drag-and-drop) wraps its body in this, so its work joins the
|
|
167
|
+
* same interaction record as the component handlers for the same event
|
|
168
|
+
* instead of running outside one. In production builds this is `fn()`.
|
|
169
|
+
*
|
|
170
|
+
* Use it for listeners that respond to the user (`click`, `submit`,
|
|
171
|
+
* `keydown`), not for passive ones (`mousemove`, `focusin` preloads), which
|
|
172
|
+
* would each record an interaction.
|
|
173
|
+
*
|
|
174
|
+
* @example
|
|
175
|
+
* ```ts
|
|
176
|
+
* document.addEventListener("click", e =>
|
|
177
|
+
* dispatchAsInteraction(e, () => handleAnchorClick(e))
|
|
178
|
+
* );
|
|
179
|
+
* ```
|
|
180
|
+
*/
|
|
181
|
+
export declare function dispatchAsInteraction<T>(e: Event, fn: () => T): T;
|
|
162
182
|
export declare function getDelegatedRoot(node: MountableElement): MountableElement | undefined;
|
|
163
183
|
export declare function setProperty(node: Element, name: string, value: any): void;
|
|
164
184
|
export declare function registerElementClaim(handler: (element: Element) => void): () => void;
|
package/types/constants.d.ts
CHANGED
|
@@ -17,4 +17,5 @@ declare const RawTextElements: Set<string>;
|
|
|
17
17
|
declare const DOMElements: Set<string>;
|
|
18
18
|
declare const COMPOSED_BODY_FRAMING: ReadonlySet<string>;
|
|
19
19
|
declare function isHttpNavigationTarget(target: string): boolean;
|
|
20
|
-
|
|
20
|
+
declare function isEventName(name: string): boolean;
|
|
21
|
+
export { DOMWithState, ChildProperties, DelegatedEvents, SVGElements, MathMLElements, VoidElements, RawTextElements, Namespaces, DOMElements, $$SLOT, $$HOST, COMPOSED_BODY_FRAMING, isHttpNavigationTarget, isEventName };
|
package/types/diagnostics.d.ts
CHANGED
|
@@ -52,5 +52,13 @@ export declare function unscopedHoleAllocatedIds(before: string, after: string,
|
|
|
52
52
|
hole?: number;
|
|
53
53
|
registered?: string;
|
|
54
54
|
}, subject?: unknown): void;
|
|
55
|
+
/**
|
|
56
|
+
* Dev CHECK: a function reached an attribute whose name starts with `on` but
|
|
57
|
+
* is not an event handler — a lowercase `onclick`, or a 1.x `on:click`. Only
|
|
58
|
+
* `on` + an uppercase letter (`onClick`) binds an event in 2.0; anything else
|
|
59
|
+
* is a plain attribute, so the function is stringified into the attribute's
|
|
60
|
+
* text. Reported once per attribute name so a row template reports once.
|
|
61
|
+
*/
|
|
62
|
+
export declare function lowercaseEventAttribute(name: string, node: Element): void;
|
|
55
63
|
/** `Name: message` for an Error, `String(value)` otherwise. */
|
|
56
64
|
export declare function errorText(error: unknown): string;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@solidjs/web/frames/assets` — the frames client's ASSETS tier (frames
|
|
3
|
+
* savings pass §3 row C5): what a segment's `seg:<k>:assets` record does to
|
|
4
|
+
* the document head, loaded on demand through the tier mechanism
|
|
5
|
+
* (`prepareTier("assets")`, frame-client.ts).
|
|
6
|
+
*
|
|
7
|
+
* What rides in this chunk, and so leaves the eager frames client: the
|
|
8
|
+
* import-free mirror of the client asset registry's head conventions
|
|
9
|
+
* (`ensureStylesheet` / `ensurePreload` / `ensureModulePreload` /
|
|
10
|
+
* `applyInlineStyles`, `findHeadElement`'s attribute-compared lookup and
|
|
11
|
+
* head.ts's `qualifierValue`), the per-frame flush a pending stylesheet
|
|
12
|
+
* wakes, and the assets pass over a record (modules, typed preloads, inline
|
|
13
|
+
* styles). The eager client keeps the record itself (`chunkToRecords`'
|
|
14
|
+
* `assets` case, the host's `seg::assets` accumulate), the pass's walk over
|
|
15
|
+
* the store, and the reveal's READINESS TERM: a segment whose assets record
|
|
16
|
+
* carries stylesheets or inline styles while this tier is not resident is
|
|
17
|
+
* not ready — the server's `<Loading>` fallback stays on screen; the reveal
|
|
18
|
+
* happens at max(tier load, stylesheet load) (frames savings pass §1,
|
|
19
|
+
* "assets": no FOUC, no blank). Once the tier is resident only stylesheets
|
|
20
|
+
* gate: inline styles apply at the record's arrival (the walk runs ahead of
|
|
21
|
+
* the segments in the same flush), modules and preloads likewise, and a
|
|
22
|
+
* segment with none of these never waits on the tier.
|
|
23
|
+
*
|
|
24
|
+
* The module's exports ARE its dispatch: `prepareTier` stamps the load with
|
|
25
|
+
* the module once it has resolved (`tierLoads.assets.r`), and the eager
|
|
26
|
+
* client calls `gate` from `#segmentReady` and `apply` from `#flush`'s
|
|
27
|
+
* assets walk off that stamp. No `install()`: the tier registers nothing
|
|
28
|
+
* and imports nothing of the client — it needs no shared instance, only
|
|
29
|
+
* the frame handed to `gate` (its `apply` is the flush a settled sheet
|
|
30
|
+
* triggers).
|
|
31
|
+
*
|
|
32
|
+
* The server announces this tier wherever it emits an assets chunk
|
|
33
|
+
* (`sink.needs("assets")` — the shell's pre-flush assets, a style-gated
|
|
34
|
+
* fragment's, a late module / preload; frame-sink.ts): `X-Frame-Tiers` /
|
|
35
|
+
* `chunk.tiers` on a stream, `_$HY.r["sc:tiers"]` + a `modulepreload` on a
|
|
36
|
+
* document — so the load is a warm start; an un-announced record starts it
|
|
37
|
+
* from the readiness check or the walk and the segment waits (the same DOM,
|
|
38
|
+
* later).
|
|
39
|
+
* @experimental
|
|
40
|
+
*/
|
|
41
|
+
import type { Frame } from "./frame-client.js";
|
|
42
|
+
/** A stylesheet entry as the sink writes it: a url, or `{ href, attrs }`. */
|
|
43
|
+
export type StylesheetEntry = string | {
|
|
44
|
+
href: string;
|
|
45
|
+
attrs?: Record<string, string>;
|
|
46
|
+
};
|
|
47
|
+
/** A typed preload entry (`<link rel="preload">`): request-qualifying attributes, optional href. */
|
|
48
|
+
export interface PreloadEntry {
|
|
49
|
+
href?: string;
|
|
50
|
+
attrs: Record<string, string>;
|
|
51
|
+
}
|
|
52
|
+
/** An inline style entry (`<style data-asset>`). */
|
|
53
|
+
export interface InlineStyleEntry {
|
|
54
|
+
id: string;
|
|
55
|
+
content?: string;
|
|
56
|
+
attrs?: Record<string, string>;
|
|
57
|
+
}
|
|
58
|
+
/** The head-affecting members of a `seg:<k>:assets` record. */
|
|
59
|
+
export interface AssetsRecord {
|
|
60
|
+
modules?: string[];
|
|
61
|
+
styles?: StylesheetEntry[];
|
|
62
|
+
inlineStyles?: InlineStyleEntry[];
|
|
63
|
+
preloads?: PreloadEntry[];
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* The stylesheet gate for one segment (`#segmentReady`'s style term, once
|
|
67
|
+
* the tier is resident): ensure every named sheet is in the head — pending
|
|
68
|
+
* links are inserted now, even while another prerequisite is missing, so
|
|
69
|
+
* the load overlaps the rest of the stream — and report whether all have
|
|
70
|
+
* settled. `frame` is re-flushed when a pending one settles.
|
|
71
|
+
*/
|
|
72
|
+
export declare function gate(entries: StylesheetEntry[], frame: Frame): boolean;
|
|
73
|
+
/**
|
|
74
|
+
* The assets pass for one record (`#flush`'s walk, once per record identity
|
|
75
|
+
* per mount): module preloads, typed preloads, inline styles. Stylesheets
|
|
76
|
+
* are the gate's (`gate`) — never applied here.
|
|
77
|
+
*/
|
|
78
|
+
export declare function apply(record: AssetsRecord): void;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Register a text start marker's position on its parent element's consumer
|
|
3
|
+
* entry for the occurrence — the one its attribute markers opened, if any,
|
|
4
|
+
* so an element is one consumer however its positions are spelled. The slot
|
|
5
|
+
* sync's walk dispatches here (frame-client.ts `collectSlots`).
|
|
6
|
+
*/
|
|
7
|
+
export declare function text(start: Comment, elements: Map<string, any>): void;
|
|
8
|
+
/**
|
|
9
|
+
* An element's positions join each occurrence's consumer list, in document
|
|
10
|
+
* order. The slot sync's walk dispatches here for every server element with
|
|
11
|
+
* attributes (frame-client.ts `collectSlots`).
|
|
12
|
+
*/
|
|
13
|
+
export declare function positions(el: Element, elements: Map<string, any>): void;
|
|
14
|
+
/**
|
|
15
|
+
* The consumer set the slot sync found for a MOUNTED data occurrence — at
|
|
16
|
+
* the mount (the set the fill was handed) and on every re-sync. A changed
|
|
17
|
+
* set (a morph replaced one of its elements, a response added or dropped a
|
|
18
|
+
* bound position) rebinds in place through the mount's rebinder: the fill's
|
|
19
|
+
* computation stays, the binding gets the new set.
|
|
20
|
+
*/
|
|
21
|
+
export declare function sync(frame: object, occurrence: string, consumers: any[]): void;
|
|
22
|
+
/** The mount's rebind callback (`ctx.onRebind`), registered during the
|
|
23
|
+
* invocation — before `sync` records the mount's set. */
|
|
24
|
+
export declare function rebinder(frame: object, occurrence: string, fn: (consumers: any[]) => void): void;
|
|
25
|
+
/** The occurrence is gone (unmounted, or re-invoked: the new invocation
|
|
26
|
+
* registers its own rebinder). */
|
|
27
|
+
export declare function unmount(frame: object, occurrence: string): void;
|
|
28
|
+
/** The positions of an incoming element a client fill writes (see
|
|
29
|
+
* `owned`). */
|
|
30
|
+
interface Owned {
|
|
31
|
+
attrs: Set<string>;
|
|
32
|
+
class: string[] | null;
|
|
33
|
+
style: string[] | null;
|
|
34
|
+
}
|
|
35
|
+
export declare function owned(el: Element): Owned | null;
|
|
36
|
+
/**
|
|
37
|
+
* Apply the server's value for `name` (null: absent) to an element with
|
|
38
|
+
* binding-slot positions: a client-owned attribute is left alone; owned
|
|
39
|
+
* `class`/`style` NAMES are re-imposed over the server's string. Returns
|
|
40
|
+
* whether the attribute changed, or undefined when the position is not
|
|
41
|
+
* owned and the caller writes it. (The eager wrapper answers `undefined`
|
|
42
|
+
* itself for a null `owned`; the arms call here with one.)
|
|
43
|
+
*/
|
|
44
|
+
export declare function apply(oldEl: Element, name: string, value: string, owned: Owned): boolean | undefined;
|
|
45
|
+
/**
|
|
46
|
+
* Bind a binding-slot occurrence (principles §9.2.3). The fill runs ONCE,
|
|
47
|
+
* untracked, under the occurrence's owner — a component body: a top-level
|
|
48
|
+
* read is a one-time read (dev names it through `untrack`'s label), and state
|
|
49
|
+
* created in the body lives as long as the occurrence. Its object's value
|
|
50
|
+
* positions are written by one render effect over every consuming element,
|
|
51
|
+
* diffed per position by `assign`, so a getter's change re-reads the
|
|
52
|
+
* occurrence and touches only what moved. Handlers and refs are read once
|
|
53
|
+
* when an element binds and handed to `assign`, which binds them as client
|
|
54
|
+
* JSX does (delegation, tuples). A consumer change (`ctx.onRebind`: the morph
|
|
55
|
+
* replaced an element, a response bound a new position) rebinds without
|
|
56
|
+
* re-running the fill. The client entry's `slotsFor` dispatches here under
|
|
57
|
+
* the occurrence's owner (client.ts).
|
|
58
|
+
*/
|
|
59
|
+
export declare function bind(fill: (args: any) => any, args: any, ctx: any, label: string | undefined): void;
|
|
60
|
+
export {};
|
package/types/frames/client.d.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
+
import { type TierModule } from "./frame-client.js";
|
|
1
2
|
export { createFrame, createFrameHost, createFrameElement, FRAME_APPLIED_EVENT } from "./frame-client.js";
|
|
2
|
-
export {
|
|
3
|
-
|
|
3
|
+
export type { TierModule } from "./frame-client.js";
|
|
4
|
+
/** @internal */
|
|
5
|
+
export { isAsyncValue } from "./frame-client.js";
|
|
6
|
+
export { FRAME_STREAM_HEADER, applyFrameResponse, isFrameStreamResponse, createServerComponentHandler } from "./frame-transport.js";
|
|
7
|
+
export type { Slot, BindingSlot, SlotOutput, SlotError } from "./server.js";
|
|
4
8
|
/**
|
|
5
9
|
* Client-condition twin of the server face's `asyncArg` (DR-2 value tier):
|
|
6
10
|
* the identity that types an async value crossing the slot border as its
|
|
@@ -16,6 +20,24 @@ export declare function asyncArg<T>(value: PromiseLike<T> | AsyncIterable<T>): T
|
|
|
16
20
|
* @experimental
|
|
17
21
|
*/
|
|
18
22
|
export declare function getFrameHost(): any;
|
|
23
|
+
/**
|
|
24
|
+
* Options for `installServerComponents`.
|
|
25
|
+
* @experimental
|
|
26
|
+
*/
|
|
27
|
+
export interface InstallOptions {
|
|
28
|
+
/**
|
|
29
|
+
* Frames-client tiers by name → loader. A tier's module's exports are its
|
|
30
|
+
* appliers (the runtime dispatches to them once resident) and its
|
|
31
|
+
* optional `install()` is called once the import resolves; every live
|
|
32
|
+
* frame is then flushed so what the tier makes applicable applies (a held
|
|
33
|
+
* occurrence mounts, a style-gated segment requests its sheets). A name
|
|
34
|
+
* with no loader is resident (eager); `trace` (`@solidjs/web/frames/trace`),
|
|
35
|
+
* `regions` (`@solidjs/web/frames/regions`) and `assets`
|
|
36
|
+
* (`@solidjs/web/frames/assets`) have built-in loaders that an entry here
|
|
37
|
+
* replaces. See `installServerComponents`.
|
|
38
|
+
*/
|
|
39
|
+
tiers?: Record<string, () => Promise<TierModule>>;
|
|
40
|
+
}
|
|
19
41
|
/**
|
|
20
42
|
* Installs the server-component transport policy on the server-function
|
|
21
43
|
* client — the identity split (DR-1): CONTENT is keyed by the call's
|
|
@@ -31,6 +53,18 @@ export declare function getFrameHost(): any;
|
|
|
31
53
|
* Call once in the client entry (an explicit call — the package is
|
|
32
54
|
* `sideEffects: false`, so a bare import would be tree-shaken away);
|
|
33
55
|
* call again to rebind to a custom host.
|
|
56
|
+
*
|
|
57
|
+
* `options.tiers` maps a frames-client tier's name to its loader (`() =>
|
|
58
|
+
* import(...)`, the module whose exports are the tier's appliers, with an
|
|
59
|
+
* optional `install()`): the client resolves tier chunks itself, so the
|
|
60
|
+
* server announces NAMES only (`_$HY.r["sc:tiers"]`, `X-Frame-Tiers`) and
|
|
61
|
+
* the loads start here from the document's record — the `modulepreload`
|
|
62
|
+
* the document may also carry made the fetch warm. The built-in table
|
|
63
|
+
* carries `trace` (the container tier's client half,
|
|
64
|
+
* `@solidjs/web/frames/trace`), `regions` (nested server-content regions,
|
|
65
|
+
* `@solidjs/web/frames/regions`) and `assets` (the head mirror and the
|
|
66
|
+
* stylesheet gate, `@solidjs/web/frames/assets`); a loader given here for
|
|
67
|
+
* a name replaces the built-in one (tests gate a tier's load this way).
|
|
34
68
|
* @experimental
|
|
35
69
|
*/
|
|
36
|
-
export declare function installServerComponents(host?: any): void;
|
|
70
|
+
export declare function installServerComponents(host?: any, options?: InstallOptions): void;
|