sygnal 6.5.0 → 7.0.0
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/CHANGELOG.md +156 -0
- package/README.md +2 -0
- package/dist/astro/index.cjs.js +423 -27
- package/dist/astro/index.cjs.js.map +1 -1
- package/dist/astro/index.mjs +423 -27
- package/dist/astro/index.mjs.map +1 -1
- package/dist/astro/server.cjs.js.map +1 -1
- package/dist/astro/server.mjs.map +1 -1
- package/dist/devtools.cjs.js +141 -3
- package/dist/devtools.cjs.js.map +1 -1
- package/dist/devtools.esm.js +141 -4
- package/dist/devtools.esm.js.map +1 -1
- package/dist/diagnostics.cjs.js +169 -14
- package/dist/diagnostics.cjs.js.map +1 -1
- package/dist/diagnostics.esm.js +168 -15
- package/dist/diagnostics.esm.js.map +1 -1
- package/dist/guide/accessibility.md +2 -0
- package/dist/guide/ai-chat.md +6 -6
- package/dist/guide/behaviors.md +1 -1
- package/dist/guide/element-commands.md +4 -2
- package/dist/guide/forms-reference.md +89 -3
- package/dist/guide/forms.md +8 -8
- package/dist/guide/http.md +77 -7
- package/dist/guide/migrating-to-7.md +314 -0
- package/dist/guide/recipes/ai-summarize.md +2 -1
- package/dist/guide/recipes/i18n.md +1 -1
- package/dist/guide/ui/tabs.md +5 -4
- package/dist/guide/ui/tooltip.md +24 -0
- package/dist/index.cjs.js +781 -320
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +319 -43
- package/dist/index.esm.js +781 -320
- package/dist/index.esm.js.map +1 -1
- package/dist/sygnal.min.js +1 -1
- package/dist/sygnal.min.js.map +1 -1
- package/dist/ui.cjs.js +96 -11
- package/dist/ui.cjs.js.map +1 -1
- package/dist/ui.esm.js +96 -12
- package/dist/ui.esm.js.map +1 -1
- package/dist/vike/config/package.json +1 -1
- package/dist/vike/onRenderClient.cjs.js +63 -43
- package/dist/vike/onRenderClient.cjs.js.map +1 -1
- package/dist/vike/onRenderClient.mjs +63 -43
- package/dist/vike/onRenderClient.mjs.map +1 -1
- package/dist/vike/onRenderHtml.cjs.js +21 -25
- package/dist/vike/onRenderHtml.cjs.js.map +1 -1
- package/dist/vike/onRenderHtml.mjs +21 -25
- package/dist/vike/onRenderHtml.mjs.map +1 -1
- package/dist/vite/plugin.cjs.js +410 -27
- package/dist/vite/plugin.cjs.js.map +1 -1
- package/dist/vite/plugin.mjs +410 -27
- package/dist/vite/plugin.mjs.map +1 -1
- package/llms.txt +17 -16
- package/package.json +1 -1
- package/src/astro/index.d.ts +8 -0
- package/src/astro/index.ts +18 -0
- package/src/core/actions.ts +28 -21
- package/src/core/define.ts +2 -0
- package/src/core/hooks.ts +8 -2
- package/src/core/hosts/collection.ts +4 -3
- package/src/core/instance.ts +60 -16
- package/src/core/runtime.ts +5 -1
- package/src/core/view.ts +2 -0
- package/src/cycle/dom/utils.ts +4 -2
- package/src/devtools.d.ts +13 -0
- package/src/devtools.ts +3 -0
- package/src/extra/ai/chat/behavior.ts +3 -3
- package/src/extra/ai/commandBar.ts +3 -3
- package/src/extra/ai/compose/behavior.ts +3 -3
- package/src/extra/ai/transports/shared.ts +8 -2
- package/src/extra/behaviors.ts +21 -0
- package/src/extra/devGraph.ts +111 -0
- package/src/extra/devMcp.ts +1 -1
- package/src/extra/devtools.ts +18 -0
- package/src/extra/diagnostics/checks/fetch.ts +21 -1
- package/src/extra/diagnostics/checks/forms.ts +4 -3
- package/src/extra/diagnostics/checks/index.ts +2 -1
- package/src/extra/diagnostics/checks/inspect.ts +68 -6
- package/src/extra/diagnostics/checks/next.ts +3 -0
- package/src/extra/diagnostics/checks/public.d.ts +133 -12
- package/src/extra/diagnostics/checks/timingAudit.ts +47 -0
- package/src/extra/diagnostics/codes.ts +19 -0
- package/src/extra/fetchDriver.ts +112 -7
- package/src/extra/fetchEventSource.ts +113 -0
- package/src/extra/form.ts +68 -26
- package/src/extra/formHelpers.ts +3 -1
- package/src/extra/lens.ts +3 -2
- package/src/extra/queryCache.ts +4 -3
- package/src/extra/socketDriver.ts +10 -4
- package/src/extra/testing.ts +68 -11
- package/src/index.d.ts +199 -30
- package/src/index.ts +1 -0
- package/src/shared.ts +3 -0
- package/src/ui/dialog.ts +3 -2
- package/src/ui/tooltips.ts +92 -0
- package/src/ui.d.ts +35 -0
- package/src/ui.ts +1 -0
- package/src/vike/onRenderClient.ts +44 -46
- package/src/vike/onRenderHtml.ts +5 -26
- package/src/vike/shell.ts +33 -0
- package/src/vite/graph.ts +255 -0
- package/src/vite/mcp.ts +3 -3
- package/src/vite/plugin.d.ts +19 -0
- package/src/vite/plugin.ts +144 -25
package/dist/index.d.ts
CHANGED
|
@@ -2041,9 +2041,23 @@ type DiagnosticSeverity$1 = 'error' | 'warn' | 'info'
|
|
|
2041
2041
|
|
|
2042
2042
|
/** How an action is dispatched. */
|
|
2043
2043
|
/** 'agent' (static, PLAN-6 K-1): only the component's `agent` declaration dispatches it */
|
|
2044
|
-
|
|
2044
|
+
/**
|
|
2045
|
+
* 'behavior' (static, PLAN-10 A-8): a `uses` entry's action nothing else triggers that the behavior
|
|
2046
|
+
* may dispatch itself where the checker can't list it (a package behavior, an open model, ...)
|
|
2047
|
+
*/
|
|
2048
|
+
type InspectActionTrigger = 'intent' | 'next' | 'reply' | 'builtin' | 'agent' | 'behavior' | 'unknown'
|
|
2045
2049
|
|
|
2046
|
-
|
|
2050
|
+
/**
|
|
2051
|
+
* PLAN-10 A-4 (static only): a source position, 1-based. `file` (relative to the working
|
|
2052
|
+
* directory) only when it isn't the component's file.
|
|
2053
|
+
*/
|
|
2054
|
+
interface InspectLocation {
|
|
2055
|
+
line: number
|
|
2056
|
+
column: number
|
|
2057
|
+
file?: string
|
|
2058
|
+
}
|
|
2059
|
+
|
|
2060
|
+
interface InspectAction extends Partial<InspectLocation> {
|
|
2047
2061
|
name: string
|
|
2048
2062
|
/**
|
|
2049
2063
|
* 'intent': returned by the component's intent. 'builtin': BOOTSTRAP,
|
|
@@ -2057,18 +2071,56 @@ interface InspectAction {
|
|
|
2057
2071
|
trigger: InspectActionTrigger
|
|
2058
2072
|
/** sinks of the model entry (STATE, EVENTS, EFFECT, PARENT, custom drivers); [] without a model entry */
|
|
2059
2073
|
sinks: string[]
|
|
2074
|
+
/** the `uses` key of the behavior that owns it ('pager' for 'pager.NEXT') */
|
|
2075
|
+
behavior?: string
|
|
2076
|
+
/** static, PLAN-10 A-4: the model entry (line/column on the action: the intent property, else this) */
|
|
2077
|
+
modelAt?: InspectLocation
|
|
2078
|
+
/**
|
|
2079
|
+
* static, PLAN-10 A-7 (actions with a STATE sink only): the top-level state keys the STATE
|
|
2080
|
+
* reducer(s) may write (a behavior's: its slice); [] when it never changes state; null when unknown
|
|
2081
|
+
*/
|
|
2082
|
+
writes?: string[] | null
|
|
2083
|
+
/** static, PLAN-10 A-7: a STATE reducer may return undefined (removes a Collection item) */
|
|
2084
|
+
removes?: true
|
|
2060
2085
|
}
|
|
2061
2086
|
|
|
2062
|
-
interface InspectChild {
|
|
2087
|
+
interface InspectChild extends Partial<InspectLocation> {
|
|
2063
2088
|
name: string
|
|
2064
|
-
|
|
2089
|
+
/**
|
|
2090
|
+
* 'layout' (static, PLAN-10 A-9): Vike's shell, a +Wrapper / +Layout rendering the next +Layout in
|
|
2091
|
+
* or a +Page it applies to (Wrapper(s) > Layout(s) > Page); no location (no JSX site)
|
|
2092
|
+
*/
|
|
2093
|
+
via: 'tag' | 'collection' | 'switchable' | 'slot' | 'layout'
|
|
2065
2094
|
/** Collection: the `from` state field, when known */
|
|
2066
2095
|
from?: string | null
|
|
2067
2096
|
/** runtime: number of live instances behind this entry (e.g. Collection items) */
|
|
2068
2097
|
count?: number
|
|
2098
|
+
/** runtime, PLAN-10 D522: the ids of those instances */
|
|
2099
|
+
ids?: string[]
|
|
2100
|
+
/**
|
|
2101
|
+
* static, PLAN-10 A-3: the id of the component it renders (resolved through the import); null when
|
|
2102
|
+
* it isn't in the graph (a package, a widget, a file not scanned, a dynamic value)
|
|
2103
|
+
*/
|
|
2104
|
+
id?: string | null
|
|
2105
|
+
/** static, PLAN-10 A-1: a literal `state` lens (`<Greeting state="host" />`) */
|
|
2106
|
+
state?: string
|
|
2107
|
+
/** static, PLAN-10 A-2: the package the tag is imported from ('sygnal/ui') */
|
|
2108
|
+
external?: string
|
|
2109
|
+
/** static, PLAN-10 A-2: a widget tag (defineWidget, fromZag, fromReact, the sygnal/ui Zag parts) */
|
|
2110
|
+
widget?: true
|
|
2111
|
+
}
|
|
2112
|
+
|
|
2113
|
+
/** PLAN-10 A-5 (static): a CHILD.select(Child) call in an intent */
|
|
2114
|
+
interface InspectChildSelect extends InspectLocation {
|
|
2115
|
+
/** the selected component's name as written */
|
|
2116
|
+
child: string | null
|
|
2117
|
+
/** its id; null when it isn't in the graph */
|
|
2118
|
+
id: string | null
|
|
2119
|
+
/** the intent actions whose stream contains the call (the receivers of the child's PARENT sink) */
|
|
2120
|
+
actions: string[]
|
|
2069
2121
|
}
|
|
2070
2122
|
|
|
2071
|
-
interface InspectSelector {
|
|
2123
|
+
interface InspectSelector extends Partial<InspectLocation> {
|
|
2072
2124
|
/** CSS selector passed to DOM.select() (chained selects joined with a space) */
|
|
2073
2125
|
selector: string
|
|
2074
2126
|
/** event types listened to; null when unknown (runtime, real DOM) */
|
|
@@ -2084,10 +2136,12 @@ interface InspectSelector {
|
|
|
2084
2136
|
isolationHit: string | null
|
|
2085
2137
|
/** PLAN-4 CT-1: the control this selector is (its key), when it is `[data-control="<Key>"]` */
|
|
2086
2138
|
control?: string
|
|
2139
|
+
/** the `uses` key of the behavior that listens to it */
|
|
2140
|
+
behavior?: string
|
|
2087
2141
|
}
|
|
2088
2142
|
|
|
2089
2143
|
/** PLAN-4 CT-1: a control (controls()) a component renders */
|
|
2090
|
-
interface InspectControl {
|
|
2144
|
+
interface InspectControl extends Partial<InspectLocation> {
|
|
2091
2145
|
/** the control's key (rendered as data-control="<name>") */
|
|
2092
2146
|
name: string
|
|
2093
2147
|
/** the intrinsic tag of a tag spec; null for a spec object */
|
|
@@ -2102,10 +2156,14 @@ interface InspectDiagnostic {
|
|
|
2102
2156
|
code: string
|
|
2103
2157
|
severity: DiagnosticSeverity$1
|
|
2104
2158
|
component?: string
|
|
2159
|
+
/** static, PLAN-10 A-3: the id of the component it is attached to */
|
|
2160
|
+
componentId?: string
|
|
2105
2161
|
message: string
|
|
2106
2162
|
fix?: string
|
|
2107
2163
|
docsUrl?: string
|
|
2108
2164
|
data?: any
|
|
2165
|
+
/** runtime only: when it was reported (ms since the epoch; each is reported once per process) */
|
|
2166
|
+
timestamp?: number
|
|
2109
2167
|
/** static only */
|
|
2110
2168
|
file?: string
|
|
2111
2169
|
line?: number
|
|
@@ -2160,6 +2218,12 @@ interface InspectComponent {
|
|
|
2160
2218
|
name: string
|
|
2161
2219
|
/** runtime: instance number (as a string); static: 'file:line' of the definition */
|
|
2162
2220
|
id: string
|
|
2221
|
+
/**
|
|
2222
|
+
* static, PLAN-10 D521: 'file#name', stable when lines move (hosts key selection and positions by it);
|
|
2223
|
+
* a second component of the same name in one file gets 'file#name#2', and so on. Runtime (PLAN-10 P-2,
|
|
2224
|
+
* D544): the same key when sygnal/vite's dev server stamped the component function, else absent
|
|
2225
|
+
*/
|
|
2226
|
+
key?: string
|
|
2163
2227
|
/** runtime: the parent instance's id; static: null (see the parents' `children`) */
|
|
2164
2228
|
parentId: string | null
|
|
2165
2229
|
/** static only: source file, relative to the working directory */
|
|
@@ -2169,6 +2233,32 @@ interface InspectComponent {
|
|
|
2169
2233
|
* component renders it, else how it is first rendered
|
|
2170
2234
|
*/
|
|
2171
2235
|
kind: 'root' | 'child' | 'collection-item' | 'switchable'
|
|
2236
|
+
/** PLAN-10 A-1 / D522: rendered as a component (or started as an entry) but has no statics */
|
|
2237
|
+
viewOnly?: true
|
|
2238
|
+
/**
|
|
2239
|
+
* static, PLAN-10 A-6: started by run(), defineElement() or a Vike +Page / +Layout / +Wrapper; 'unknown' on the
|
|
2240
|
+
* other roots when an entry call's component can't be resolved (picked at run time).
|
|
2241
|
+
* runtime (D522): true on an app's root instance
|
|
2242
|
+
*/
|
|
2243
|
+
entry?: true | 'unknown'
|
|
2244
|
+
/**
|
|
2245
|
+
* static, Vike only (PLAN-10 A-9): on a +Page's component its route ('/orders/@id': from the
|
|
2246
|
+
* filesystem, or the literal string a +route file / the config's `route` sets); null for a Route
|
|
2247
|
+
* Function or a route the checker can't read (with `routeDynamic`) and for _error/+Page. On a
|
|
2248
|
+
* +Layout's / +Wrapper's: the URL prefix of the directory it applies to
|
|
2249
|
+
*/
|
|
2250
|
+
route?: string | null
|
|
2251
|
+
/**
|
|
2252
|
+
* static, Vike only (PLAN-10 A-9): every route of a component several +Page files export (`route` is
|
|
2253
|
+
* the first, in path order; null for a dynamic one or the error page); omitted otherwise
|
|
2254
|
+
*/
|
|
2255
|
+
routes?: (string | null)[]
|
|
2256
|
+
/** static, Vike only (PLAN-10 A-9): the route is a Route Function or can't be read (route: null) */
|
|
2257
|
+
routeDynamic?: true
|
|
2258
|
+
/** runtime, PLAN-10 D522: the app (run()) it belongs to: its root's index among the live roots, oldest first */
|
|
2259
|
+
app?: number
|
|
2260
|
+
/** runtime, PLAN-10 D522: false on a hidden Switchable page and below it; omitted when shown */
|
|
2261
|
+
shown?: false
|
|
2172
2262
|
actions: InspectAction[]
|
|
2173
2263
|
/** state keys (runtime: current state; static: initialState) */
|
|
2174
2264
|
stateKeys: string[]
|
|
@@ -2176,14 +2266,27 @@ interface InspectComponent {
|
|
|
2176
2266
|
calculated: string[]
|
|
2177
2267
|
/** context fields this component provides (Component.context) */
|
|
2178
2268
|
contextProvides: string[]
|
|
2179
|
-
/** context fields its view reads (static
|
|
2269
|
+
/** context fields its view reads (static: the view source; runtime, D530: what its latest render read) */
|
|
2180
2270
|
contextConsumes?: string[] | null
|
|
2271
|
+
/**
|
|
2272
|
+
* static, PLAN-10 A-7: top-level state keys the view (and its child lenses, calculated and
|
|
2273
|
+
* context functions) reads literally; omitted when none
|
|
2274
|
+
*/
|
|
2275
|
+
stateReads?: string[]
|
|
2276
|
+
/** static, PLAN-10 A-7: stateReads may be incomplete (the state used whole somewhere) */
|
|
2277
|
+
stateReadsPartial?: true
|
|
2181
2278
|
/** EVENTS types this component emits */
|
|
2182
2279
|
eventsEmitted: string[]
|
|
2183
2280
|
/** EVENTS types this component selects ('*' = EVENTS.select() without a type) */
|
|
2184
2281
|
eventsSelected: string[]
|
|
2185
2282
|
children: InspectChild[]
|
|
2186
2283
|
selectors: InspectSelector[]
|
|
2284
|
+
/** static, PLAN-10 A-4: where the `context` static's entries are */
|
|
2285
|
+
contextEntries?: Array<InspectLocation & { name: string }>
|
|
2286
|
+
/** static, PLAN-10 A-4: the EVENTS emit and select sites of its intent and model */
|
|
2287
|
+
eventSites?: Array<InspectLocation & { type: string; role: 'emit' | 'select' }>
|
|
2288
|
+
/** static, PLAN-10 A-5: CHILD.select(Child) in its intent */
|
|
2289
|
+
childSelects?: InspectChildSelect[]
|
|
2187
2290
|
/** PLAN-4 CT-1: the controls it renders (runtime: seen in its renders); omitted when none */
|
|
2188
2291
|
controls?: InspectControl[]
|
|
2189
2292
|
/** static only, PLAN-4 GS-2 (G-224): the element commands (ELEMENT sink) its model sends; omitted when none */
|
|
@@ -2198,7 +2301,7 @@ interface InspectComponent {
|
|
|
2198
2301
|
}
|
|
2199
2302
|
|
|
2200
2303
|
/** PLAN-4 GS-2: an element command a model entry sends (static inspect, sygnal-check --graph) */
|
|
2201
|
-
interface InspectCommand {
|
|
2304
|
+
interface InspectCommand extends Partial<InspectLocation> {
|
|
2202
2305
|
/** the model entry that sends it */
|
|
2203
2306
|
action: string
|
|
2204
2307
|
/** the command's method (its first key) */
|
|
@@ -2220,13 +2323,15 @@ interface InspectAgent {
|
|
|
2220
2323
|
description: string | null
|
|
2221
2324
|
/** the declaration has a read projection */
|
|
2222
2325
|
read: boolean
|
|
2223
|
-
actions: Array<{ name: string; consequential: boolean; input: boolean }
|
|
2326
|
+
actions: Array<{ name: string; consequential: boolean; input: boolean } & Partial<InspectLocation>>
|
|
2327
|
+
/** the read-only `agent.queries` tools; omitted when none */
|
|
2328
|
+
queries?: Array<{ name: string; input: boolean } & Partial<InspectLocation>>
|
|
2224
2329
|
/** spreads: what is listed may be incomplete */
|
|
2225
2330
|
partial?: true
|
|
2226
2331
|
}
|
|
2227
2332
|
|
|
2228
2333
|
/** PLAN-4 GS-7: a literal timer spec of a `timers` static (static inspect, sygnal-check --graph) */
|
|
2229
|
-
interface InspectTimer {
|
|
2334
|
+
interface InspectTimer extends Partial<InspectLocation> {
|
|
2230
2335
|
name: string
|
|
2231
2336
|
every?: number | null
|
|
2232
2337
|
after?: number | null
|
|
@@ -2261,8 +2366,12 @@ interface InspectGraph {
|
|
|
2261
2366
|
/** which implementation produced the graph */
|
|
2262
2367
|
source?: 'runtime' | 'static'
|
|
2263
2368
|
components: InspectComponent[]
|
|
2264
|
-
/**
|
|
2265
|
-
|
|
2369
|
+
/**
|
|
2370
|
+
* EVENTS bus: type -> names of the components that emit / select it (each name once); emitterIds /
|
|
2371
|
+
* selectorIds (PLAN-10 A-3, D522, D528): the id of every such component (static) or instance
|
|
2372
|
+
* (runtime), not parallel to the names
|
|
2373
|
+
*/
|
|
2374
|
+
events: Record<string, { emitters: string[]; selectors: string[]; emitterIds?: string[]; selectorIds?: string[] }>
|
|
2266
2375
|
/** diagnostics not tied to a listed component */
|
|
2267
2376
|
diagnostics: InspectDiagnostic[]
|
|
2268
2377
|
/** runtime, PLAN-3 5-3: makeFetchDriver cache entries, by sink name (empty when no cache) */
|
|
@@ -2392,9 +2501,12 @@ type ComponentProps<STATE, PROPS, CONTEXT> = (
|
|
|
2392
2501
|
*/
|
|
2393
2502
|
type UidFunction = (name?: string) => string
|
|
2394
2503
|
|
|
2395
|
-
/**
|
|
2504
|
+
/**
|
|
2505
|
+
* The first argument of a component's view: its props plus `state`, `context`, `children`, `slots` and `uid`.
|
|
2506
|
+
* PLAN-11 Q-1: PROPS = `any` is read as "any other props" (`any & X` would make `state` `any` too).
|
|
2507
|
+
*/
|
|
2396
2508
|
type ViewProps<STATE = any, PROPS = {}, CONTEXT = {}> =
|
|
2397
|
-
PROPS & { state: STATE; context: CONTEXT; children?: JSX.Element | JSX.Element[]; slots?: Record<string, JSX.Element[]>; uid: UidFunction }
|
|
2509
|
+
(0 extends (1 & PROPS) ? { [prop: string]: any } : PROPS) & { state: STATE; context: CONTEXT; children?: JSX.Element | JSX.Element[]; slots?: Record<string, JSX.Element[]>; uid: UidFunction }
|
|
2398
2510
|
|
|
2399
2511
|
/**
|
|
2400
2512
|
* The `state` prop a parent passes to a sub-component in JSX: the name of a field of the
|
|
@@ -2429,13 +2541,19 @@ type NextFunction<ACTIONS = any> = ACTIONS extends object
|
|
|
2429
2541
|
) => void
|
|
2430
2542
|
: (action: string, data?: any, delay?: number) => void
|
|
2431
2543
|
|
|
2432
|
-
|
|
2544
|
+
|
|
2545
|
+
/**
|
|
2546
|
+
* A reducer's 4th argument. 7.0: STATE runs first; every other sink gets the committed state as
|
|
2547
|
+
* `state` (and as its 1st argument), with the state from before the action as `previousState`
|
|
2548
|
+
* (in a STATE reducer both are the old state)
|
|
2549
|
+
*/
|
|
2550
|
+
type ReducerExtras<PROPS, CONTEXT, STATE = any> = PROPS & { state: STATE; previousState: STATE; context: CONTEXT; children?: JSX.Element | JSX.Element[]; slots?: Record<string, JSX.Element[]>; uid: UidFunction }
|
|
2433
2551
|
|
|
2434
2552
|
type Reducer<STATE, PROPS, ACTIONS = any, DATA = any, RETURN = any, CONTEXT = {}> = (
|
|
2435
2553
|
state: STATE,
|
|
2436
2554
|
args: DATA,
|
|
2437
2555
|
next: NextFunction<ACTIONS>,
|
|
2438
|
-
props: ReducerExtras<PROPS, CONTEXT>
|
|
2556
|
+
props: ReducerExtras<PROPS, CONTEXT, STATE>
|
|
2439
2557
|
) => RETURN | ABORT | undefined
|
|
2440
2558
|
|
|
2441
2559
|
type ExactShape<EXPECTED, ACTUAL extends EXPECTED> = ACTUAL &
|
|
@@ -2571,7 +2689,7 @@ type AnySinkConstant =
|
|
|
2571
2689
|
* `props.signal` aborts on DISPOSE (undefined where AbortController is missing).
|
|
2572
2690
|
*/
|
|
2573
2691
|
type EffectReducer<STATE, PROPS, ACTIONS, DATA, CALCULATED, CONTEXT = {}> =
|
|
2574
|
-
| ((state: STATE & CALCULATED, args: DATA, next: NextFunction<ACTIONS>, props: ReducerExtras<PROPS, CONTEXT> & { signal?: AbortSignal }) => void)
|
|
2692
|
+
| ((state: STATE & CALCULATED, args: DATA, next: NextFunction<ACTIONS>, props: ReducerExtras<PROPS, CONTEXT, STATE & CALCULATED> & { signal?: AbortSignal }) => void)
|
|
2575
2693
|
|
|
2576
2694
|
type DefaultSinks<STATE, PROPS, ACTIONS, DATA, CALCULATED, SINK_RETURNS extends NonStateSinkReturns = {}, CONTEXT = {}> = {
|
|
2577
2695
|
STATE?: SinkValue<STATE, PROPS, ACTIONS, DATA, STATE, CALCULATED, CONTEXT>;
|
|
@@ -3241,10 +3359,11 @@ declare function pager(options?: PagerOptions): Behavior<PagerState, PagerAction
|
|
|
3241
3359
|
type FieldErrors = Record<string, string>
|
|
3242
3360
|
|
|
3243
3361
|
/** One field of a `form` slice: `state.form.fields.email`, `state.form.fields['addresses.7.city']`. */
|
|
3244
|
-
interface FormField {
|
|
3362
|
+
interface FormField<T = any> {
|
|
3245
3363
|
/** The field name, for `name={f.name}` (the path in `values`; rows of an array by id) */
|
|
3246
3364
|
name: string;
|
|
3247
|
-
value:
|
|
3365
|
+
/** The field's value: typed for a top-level field of a typed form (`fields.email.value: string`) */
|
|
3366
|
+
value: T;
|
|
3248
3367
|
/** What to show: a server or check error at once, a schema error once the field is touched (per `show`) or after a submit; '' when none */
|
|
3249
3368
|
error: string;
|
|
3250
3369
|
/** `!!error`, for `aria-invalid={f.email.invalid}` */
|
|
@@ -3281,12 +3400,36 @@ interface FormState<V = any> {
|
|
|
3281
3400
|
validating: boolean;
|
|
3282
3401
|
/** The schema has answered at least once since the start (or the last `form.RESET`) */
|
|
3283
3402
|
validated: boolean;
|
|
3403
|
+
/**
|
|
3404
|
+
* PLAN-11 (6.7): the submit request's last progress step, when it is sent with
|
|
3405
|
+
* `progress: 'form.PROGRESS'`; null otherwise and after `form.DONE` / `form.ERRORS` / `form.RESET`
|
|
3406
|
+
*/
|
|
3407
|
+
progress: { phase: 'upload' | 'download'; loaded: number; total: number | null; fraction: number | null } | null;
|
|
3408
|
+
/**
|
|
3409
|
+
* PLAN-11 (6.7): how many times the form started over (`form.RESET`, `resetOnShow`). A file
|
|
3410
|
+
* input can't be cleared through state: key it with this, `key={'avatar' + state.form.resets}`
|
|
3411
|
+
*/
|
|
3412
|
+
resets: number;
|
|
3284
3413
|
}
|
|
3285
3414
|
|
|
3415
|
+
type FormIsAny<T> = 0 extends (1 & T) ? true : false
|
|
3416
|
+
|
|
3417
|
+
/**
|
|
3418
|
+
* A form's `fields` (PLAN-11 F-1): the top-level fields of `values` by name, typed
|
|
3419
|
+
* (`fields.email.value: string`), and nested paths ('addresses.7.city', 'addresses.7') with any
|
|
3420
|
+
* value. A top-level name that isn't in `values` is a type error (a typo). Untyped values (any):
|
|
3421
|
+
* `Record<string, FormField>`.
|
|
3422
|
+
*/
|
|
3423
|
+
type FormFields<V = any> = FormIsAny<V> extends true
|
|
3424
|
+
? Record<string, FormField>
|
|
3425
|
+
: V extends object
|
|
3426
|
+
? { [K in keyof V & string]-?: FormField<V[K]> } & { [path: `${string}.${string}`]: FormField }
|
|
3427
|
+
: Record<string, FormField>
|
|
3428
|
+
|
|
3286
3429
|
/** A `form` slice's calculated fields. */
|
|
3287
|
-
interface FormCalculated {
|
|
3430
|
+
interface FormCalculated<V = any> {
|
|
3288
3431
|
/** Every field of `values` by name (leaves, arrays, and array rows' fields by row id) */
|
|
3289
|
-
fields:
|
|
3432
|
+
fields: FormFields<V>;
|
|
3290
3433
|
/** No schema error and no failed check, as of the schema's last answer (false until its first; an async re-validation keeps the previous value) */
|
|
3291
3434
|
valid: boolean;
|
|
3292
3435
|
dirty: boolean;
|
|
@@ -3302,15 +3445,38 @@ interface FormFieldCheck {
|
|
|
3302
3445
|
error?: (body: any) => string | false | null | undefined;
|
|
3303
3446
|
}
|
|
3304
3447
|
|
|
3305
|
-
|
|
3448
|
+
/** Types only: the key of `FormOptions`' phantom output type (not exported, never set) */
|
|
3449
|
+
declare const formOutput: unique symbol
|
|
3450
|
+
|
|
3451
|
+
/** PLAN-11: the `request` option of form(): a request without reply actions (the form names them), or a function of the submit data and the host state */
|
|
3452
|
+
type FormRequestObject = Exclude<FetchRequest, string> & { url: string; ok?: never; error?: never }
|
|
3453
|
+
type FormRequest<OUT = any> =
|
|
3454
|
+
| FormRequestObject
|
|
3455
|
+
| ((data: OUT, state: any) => FormRequestObject | typeof ABORT | null | undefined | false)
|
|
3456
|
+
|
|
3457
|
+
interface FormOptions<V = any, OUT = any> {
|
|
3458
|
+
/** Phantom, types only: the schema's output (`FormOutput<typeof uses.form>`); never set */
|
|
3459
|
+
readonly [formOutput]?: OUT;
|
|
3306
3460
|
/**
|
|
3307
3461
|
* The start values; field names are paths in it (rows of an array of objects need an `id`, SYG236).
|
|
3308
3462
|
* Or a function of the host component's state, for start values that come from state (a default
|
|
3309
3463
|
* from the settings): called when the form starts, and each time it starts over (`resetOnShow`)
|
|
3310
3464
|
*/
|
|
3311
3465
|
values: V | ((state: any) => V);
|
|
3312
|
-
/**
|
|
3313
|
-
|
|
3466
|
+
/**
|
|
3467
|
+
* The host action a valid submit dispatches with the schema's output (SYG234 when it has no model entry). With an `http` sink in its entry the submit is pending until `form.DONE` / `form.ERRORS`; otherwise it is done at once.
|
|
3468
|
+
* Optional with `request` (then dispatched too, for state; its entry should send no request)
|
|
3469
|
+
*/
|
|
3470
|
+
submit?: string;
|
|
3471
|
+
/**
|
|
3472
|
+
* PLAN-11 (6.7): the form sends a valid submit itself on the `http` sink: a request, or a
|
|
3473
|
+
* function of the schema's output and the host's state (`(data, state) => ({ url: '/api/items/' + state.id, method: 'PUT' })`;
|
|
3474
|
+
* `ABORT` / falsy sends nothing and leaves the submit pending). The form adds the body
|
|
3475
|
+
* (`multipart: data` when a top-level value is a File or files, else `json: data`, unless the
|
|
3476
|
+
* request sets `json`, `multipart` or `body`), `progress: 'form.PROGRESS'` (unless set) and its own
|
|
3477
|
+
* `ok: 'form.DONE'`, `error: 'form.ERRORS'`
|
|
3478
|
+
*/
|
|
3479
|
+
request?: FormRequest<OUT>;
|
|
3314
3480
|
/** Async checks by field name: run on blur and before a submit, which waits for them */
|
|
3315
3481
|
check?: Record<string, FormFieldCheck>;
|
|
3316
3482
|
/** When a schema error shows: after the field's blur (default), on input, or only after a submit */
|
|
@@ -3340,9 +3506,19 @@ interface FormOptions<V = any> {
|
|
|
3340
3506
|
tool?: FormToolHandle;
|
|
3341
3507
|
}
|
|
3342
3508
|
|
|
3343
|
-
|
|
3344
|
-
|
|
3345
|
-
|
|
3509
|
+
/**
|
|
3510
|
+
* What `form.ERRORS` takes (the runtime's `replyErrors`): an error reply (a driver's
|
|
3511
|
+
* `{ error, status?, body?, request }` or `{ status, body }`, the body `{ errors }` or the map
|
|
3512
|
+
* itself), a map `{ name: message | messages }`, or a list of issues `[{ path, message }]`
|
|
3513
|
+
*/
|
|
3514
|
+
type FormServerErrors =
|
|
3515
|
+
| Record<string, string | ReadonlyArray<string>>
|
|
3516
|
+
| ReadonlyArray<{ message: string; path?: ReadonlyArray<any> }>
|
|
3517
|
+
| { status?: number; body?: any; error?: any; request?: any }
|
|
3518
|
+
|
|
3519
|
+
interface FormActions<V = any> {
|
|
3520
|
+
/** A field changed (the form element's input events): `{ name, value }`; a checkbox gives `checked` as `value` and its own value as `item` (on an array field: added or removed); a file input its File (`multiple`: File[]; none: null) */
|
|
3521
|
+
CHANGE: { name: string; value: any; item?: any; file?: boolean };
|
|
3346
3522
|
/**
|
|
3347
3523
|
* Several fields at once, by field name (`{ values: { name: 'Dana', 'addresses.7.city': 'Hilo' } }`),
|
|
3348
3524
|
* as if typed: one validation, `touched` as for CHANGE, their server errors and check results
|
|
@@ -3351,20 +3527,49 @@ interface FormActions {
|
|
|
3351
3527
|
SET: { values: Record<string, any> };
|
|
3352
3528
|
/** A field lost focus (focusout): its name */
|
|
3353
3529
|
BLUR: string;
|
|
3354
|
-
/** The form element's submit (default prevented) */
|
|
3355
|
-
SUBMIT:
|
|
3530
|
+
/** The form element's submit (default prevented); its data is ignored (a host may dispatch it from a button) */
|
|
3531
|
+
SUBMIT: unknown;
|
|
3356
3532
|
/** Adds a row to an array field (with the next id): `{ field: 'addresses', value: { street: '' } }` */
|
|
3357
3533
|
ADD: { field: string; value?: Record<string, any> };
|
|
3358
3534
|
/** Removes a row by id: `{ field: 'addresses', id }` */
|
|
3359
3535
|
REMOVE: { field: string; id: any };
|
|
3360
|
-
/** Server errors: an error reply (`{ status, body: { errors } }`)
|
|
3361
|
-
ERRORS:
|
|
3362
|
-
/** The submit was saved: `initial` becomes `values
|
|
3363
|
-
DONE:
|
|
3364
|
-
/**
|
|
3365
|
-
|
|
3536
|
+
/** Server errors: an error reply (`{ status, body: { errors } }`), a map `{ name: message }` or a list of issues; focuses the first */
|
|
3537
|
+
ERRORS: FormServerErrors;
|
|
3538
|
+
/** The submit was saved: `initial` becomes `values`. Its data (the reply) is ignored */
|
|
3539
|
+
DONE: unknown;
|
|
3540
|
+
/** PLAN-11: a progress step of the submit request (`progress: 'form.PROGRESS'` on it): kept as `progress` while submitting */
|
|
3541
|
+
PROGRESS: FetchProgress;
|
|
3542
|
+
/** Back to `initial`, or to the values given (whole values, not merged; anything but a plain object, such as a click event, means `initial`) */
|
|
3543
|
+
RESET: V | null | undefined;
|
|
3366
3544
|
}
|
|
3367
3545
|
|
|
3546
|
+
/**
|
|
3547
|
+
* The schema's input type (Standard Schema `~standard.types.input`; zod, valibot and arktype declare
|
|
3548
|
+
* it); `any` for a schema that doesn't declare `types`
|
|
3549
|
+
*/
|
|
3550
|
+
type SchemaInput<S> = S extends { readonly '~standard': { readonly types?: infer T } }
|
|
3551
|
+
? [NonNullable<T>] extends [{ readonly input: infer I }] ? I : any
|
|
3552
|
+
: any
|
|
3553
|
+
|
|
3554
|
+
type FormSchemaOutput<S> = S extends { readonly '~standard': { readonly types?: infer T } }
|
|
3555
|
+
? [NonNullable<T>] extends [{ readonly output: infer O }] ? O : any
|
|
3556
|
+
: any
|
|
3557
|
+
|
|
3558
|
+
/** The values type of `form(schema, { values })`: the schema's input when it declares one, else what `values` gives */
|
|
3559
|
+
type FormValuesOf<V, S> = FormIsAny<SchemaInput<S>> extends true ? V : SchemaInput<S>
|
|
3560
|
+
|
|
3561
|
+
/** What `form()` returns: a behavior whose types carry the values (V) and the schema's output (OUT, the submit payload) */
|
|
3562
|
+
type FormBehavior<V = any, OUT = any> = Behavior<FormState<V>, FormActions<V>, FormCalculated<V>, FormOptions<V, OUT>>
|
|
3563
|
+
|
|
3564
|
+
/**
|
|
3565
|
+
* The data the host's submit action gets (the schema's output) from a `form()` use:
|
|
3566
|
+
* `SIGN_UP: { HTTP: (state, data: FormOutput<typeof uses.form>) => ... }`. Or from the schema:
|
|
3567
|
+
* `SchemaOutput<typeof signupSchema>`. `any` for a schema that doesn't declare `types`.
|
|
3568
|
+
*/
|
|
3569
|
+
type FormOutput<F> = F extends Behavior<any, any, any, infer OPTIONS>
|
|
3570
|
+
? OPTIONS extends { readonly [formOutput]?: infer O } ? (unknown extends O ? any : O) : any
|
|
3571
|
+
: any
|
|
3572
|
+
|
|
3368
3573
|
/**
|
|
3369
3574
|
* A form with validation (PLAN-5 F-1), any Standard Schema validator (zod, valibot, arktype, a
|
|
3370
3575
|
* hand-written object):
|
|
@@ -3379,7 +3584,11 @@ interface FormActions {
|
|
|
3379
3584
|
* that sends nothing (STATE, PARENT, EVENTS) is done at once. Throws SYG231 when
|
|
3380
3585
|
* `schema` isn't a Standard Schema.
|
|
3381
3586
|
*/
|
|
3382
|
-
declare function form<V = any
|
|
3587
|
+
declare function form<V = any, S extends StandardSchemaLike = StandardSchemaLike>(
|
|
3588
|
+
schema: S,
|
|
3589
|
+
options: FormOptions<V, FormSchemaOutput<S>> & { values: FormIsAny<SchemaInput<S>> extends true ? unknown : SchemaInput<S> | ((state: any) => SchemaInput<S>) }
|
|
3590
|
+
& ({ submit: string } | { request: FormRequest<FormSchemaOutput<S>> })
|
|
3591
|
+
): FormBehavior<FormValuesOf<V, S>, FormSchemaOutput<S>>
|
|
3383
3592
|
|
|
3384
3593
|
/** A Standard Schema's result for `values`: errors by field name, and the output when there are none. A Promise for an async schema. */
|
|
3385
3594
|
declare function checkForm(schema: StandardSchemaLike, values: any): { errors: FieldErrors; value: any } | Promise<{ errors: FieldErrors; value: any }>
|
|
@@ -4614,6 +4823,9 @@ type FetchInit = {
|
|
|
4614
4823
|
* descendants'): two instances, or Collection items, using the same category never see or
|
|
4615
4824
|
* cancel each other's requests. The root component sees every reply.
|
|
4616
4825
|
*/
|
|
4826
|
+
/** PLAN-11: one value of a request's `multipart` body */
|
|
4827
|
+
type MultipartValue = Blob | string | number | boolean | null | undefined | Record<string, any>
|
|
4828
|
+
|
|
4617
4829
|
type FetchRequest = string | {
|
|
4618
4830
|
/** Request URL (prefixed with the driver's `baseUrl`) */
|
|
4619
4831
|
url: string;
|
|
@@ -4639,8 +4851,24 @@ type FetchRequest = string | {
|
|
|
4639
4851
|
query?: Record<string, string | number | boolean | null | undefined | Array<string | number | boolean | null | undefined>>;
|
|
4640
4852
|
/** Sent as JSON.stringify(json), with `Content-Type: application/json` unless set */
|
|
4641
4853
|
json?: any;
|
|
4854
|
+
/**
|
|
4855
|
+
* PLAN-11 (6.7): a multipart/form-data body, written as data: `{ file: state.file, title: state.title }`.
|
|
4856
|
+
* A File or Blob is a file part, an array repeats the name (`files: [a, b]`), null/undefined are
|
|
4857
|
+
* skipped, an object is sent as JSON text, anything else as a string. The browser sets the
|
|
4858
|
+
* content-type (with its boundary); a `content-type` header is dropped. POST by default
|
|
4859
|
+
*/
|
|
4860
|
+
multipart?: Record<string, MultipartValue | ReadonlyArray<MultipartValue>>;
|
|
4642
4861
|
/** Raw body (string, FormData, Blob, ...) */
|
|
4643
4862
|
body?: any;
|
|
4863
|
+
/**
|
|
4864
|
+
* PLAN-11 (6.7): report upload and download progress. An action name: each step arrives as that
|
|
4865
|
+
* action of the sending instance (`UPLOADING: (state, { phase, fraction }) => ...`); `true`: on
|
|
4866
|
+
* `HTTP.progress(category?)`. Data: FetchProgress. The request then goes over XMLHttpRequest
|
|
4867
|
+
* (the only way to see upload progress in every browser); fetch-only `init` options
|
|
4868
|
+
* (`keepalive`, `priority`, `cache`, `redirect`, `integrity`, `mode`, `referrerPolicy`) don't
|
|
4869
|
+
* apply (SYG636). Not for resources or `batch`. Without XMLHttpRequest (Node): no steps
|
|
4870
|
+
*/
|
|
4871
|
+
progress?: string | true;
|
|
4644
4872
|
/**
|
|
4645
4873
|
* Latest only: sending this request aborts this component's requests still in flight in the
|
|
4646
4874
|
* same category; their responses and errors are never delivered. Default: the driver's `latest`
|
|
@@ -4755,10 +4983,15 @@ type FetchRetry = SocketReconnect & {
|
|
|
4755
4983
|
count?: number;
|
|
4756
4984
|
}
|
|
4757
4985
|
|
|
4758
|
-
/**
|
|
4759
|
-
|
|
4986
|
+
/**
|
|
4987
|
+
* Any Standard Schema (https://standardschema.dev): an object with `~standard.validate`. `IN` / `OUT`
|
|
4988
|
+
* are its declared `~standard.types` (input / output; zod, valibot, arktype declare them), read by
|
|
4989
|
+
* `form()`, `SchemaInput` and `SchemaOutput`; a schema without `types` is `StandardSchemaLike<any>`.
|
|
4990
|
+
*/
|
|
4991
|
+
type StandardSchemaLike<IN = any, OUT = IN> = {
|
|
4760
4992
|
readonly '~standard': {
|
|
4761
4993
|
validate: (value: unknown) => {value?: any; issues?: ReadonlyArray<{message: string; path?: ReadonlyArray<any>}>} | Promise<{value?: any; issues?: ReadonlyArray<{message: string; path?: ReadonlyArray<any>}>}>;
|
|
4994
|
+
readonly types?: { readonly input: IN; readonly output: OUT } | undefined;
|
|
4762
4995
|
[key: string]: any;
|
|
4763
4996
|
};
|
|
4764
4997
|
}
|
|
@@ -4885,11 +5118,30 @@ type FetchError<REQUEST = any> = {
|
|
|
4885
5118
|
body?: any;
|
|
4886
5119
|
}
|
|
4887
5120
|
|
|
5121
|
+
/**
|
|
5122
|
+
* PLAN-11 (6.7): one progress step of a request sent with `progress`. Steps come at most every
|
|
5123
|
+
* 50 ms per phase, always including the first and the last (`fraction: 1`). A request with a
|
|
5124
|
+
* body reports 'upload' then 'download'; a GET only 'download'. A retry starts again at 0.
|
|
5125
|
+
*/
|
|
5126
|
+
type FetchProgress<REQUEST = any> = {
|
|
5127
|
+
phase: 'upload' | 'download';
|
|
5128
|
+
/** Bytes sent ('upload') or received ('download') so far */
|
|
5129
|
+
loaded: number;
|
|
5130
|
+
/** Total bytes, or null when unknown (a download without Content-Length) */
|
|
5131
|
+
total: number | null;
|
|
5132
|
+
/** loaded / total (0..1), or null when the total is unknown */
|
|
5133
|
+
fraction: number | null;
|
|
5134
|
+
category: string | undefined;
|
|
5135
|
+
request: REQUEST;
|
|
5136
|
+
}
|
|
5137
|
+
|
|
4888
5138
|
type FetchSource<VALUE = any> = {
|
|
4889
5139
|
/** 2xx responses: all of them, one category, or those a predicate accepts */
|
|
4890
5140
|
select: (category?: string | ((response: FetchResponse<VALUE>) => boolean)) => Stream<FetchResponse<VALUE>>
|
|
4891
5141
|
/** Failures. Filters like select(). While nothing listens, failures are console.error'd */
|
|
4892
5142
|
errors: (category?: string | ((failure: FetchError) => boolean)) => Stream<FetchError>
|
|
5143
|
+
/** PLAN-11: progress steps of requests sent with `progress: true`. Filters like select() */
|
|
5144
|
+
progress: (category?: string | ((step: FetchProgress) => boolean)) => Stream<FetchProgress>
|
|
4893
5145
|
}
|
|
4894
5146
|
|
|
4895
5147
|
type FetchDriverOptions = {
|
|
@@ -4908,8 +5160,10 @@ type FetchDriverOptions = {
|
|
|
4908
5160
|
timeoutMs?: number;
|
|
4909
5161
|
/** Default `parse` for every request. Default 'auto' */
|
|
4910
5162
|
parse?: 'auto' | 'json' | 'text' | 'response' | ((response: Response) => any);
|
|
4911
|
-
/** The fetch implementation. Default: `globalThis.fetch`, read at each request (so test stubs apply) */
|
|
5163
|
+
/** The fetch implementation. Default: `globalThis.fetch`, read at each request (so test stubs apply). Not used for `progress` requests */
|
|
4912
5164
|
fetch?: (input: string, init?: any) => Promise<any>;
|
|
5165
|
+
/** PLAN-11: the XMLHttpRequest class for `progress` requests. Default: the global one, read at each request */
|
|
5166
|
+
XMLHttpRequest?: any;
|
|
4913
5167
|
/**
|
|
4914
5168
|
* PLAN-3 D88: the query cache, off by default: `cache: queryCache({ staleTime })`. On:
|
|
4915
5169
|
* resources' GET/HEAD replies are cached (stale-while-revalidate: cached data shows at once,
|
|
@@ -4992,6 +5246,12 @@ type SseConnection = SocketActions & {
|
|
|
4992
5246
|
/** URL (after `baseUrl`) */
|
|
4993
5247
|
sse: string;
|
|
4994
5248
|
withCredentials?: boolean;
|
|
5249
|
+
/**
|
|
5250
|
+
* PLAN-11 (6.7): request headers, e.g. `{ authorization: 'Bearer ' + state.token }`. The native
|
|
5251
|
+
* EventSource can't send headers, so a connection with them is read with `fetch` (same events,
|
|
5252
|
+
* reconnects with `Last-Event-ID`). A changed header (a new token in state) reconnects
|
|
5253
|
+
*/
|
|
5254
|
+
headers?: Record<string, string>;
|
|
4995
5255
|
/** Named events → actions: `{ 'price-update': 'PRICE' }` (data JSON-parsed when it parses) */
|
|
4996
5256
|
events?: Record<string, string>;
|
|
4997
5257
|
}
|
|
@@ -5044,8 +5304,10 @@ type SocketDriverOptions = {
|
|
|
5044
5304
|
queueLimit?: number;
|
|
5045
5305
|
/** The WebSocket class. Default: `globalThis.WebSocket`, read at connect time (so test stubs apply) */
|
|
5046
5306
|
WebSocket?: any;
|
|
5047
|
-
/** The EventSource class. Default: `globalThis.EventSource`, read at connect time */
|
|
5307
|
+
/** The EventSource class. Default: `globalThis.EventSource`, read at connect time (an `sse` connection with `headers`: a fetch-based one, unless this is given) */
|
|
5048
5308
|
EventSource?: any;
|
|
5309
|
+
/** PLAN-11: the fetch for `sse` connections with `headers`. Default: `globalThis.fetch` */
|
|
5310
|
+
fetch?: (input: string, init?: any) => Promise<any>;
|
|
5049
5311
|
}
|
|
5050
5312
|
|
|
5051
5313
|
/**
|
|
@@ -5469,6 +5731,12 @@ type FakeCacheEntry = {
|
|
|
5469
5731
|
}
|
|
5470
5732
|
|
|
5471
5733
|
interface RenderOptions {
|
|
5734
|
+
/**
|
|
5735
|
+
* 7.0 timing audit (SYG257, info): report each output sink that reads a top-level state field
|
|
5736
|
+
* its action's STATE changed (it gets the new value since 7.0; 6.x gave it the old one). For
|
|
5737
|
+
* migrating 6.x code; default off (configureTimingAudit() from 'sygnal/diagnostics' sets it for all)
|
|
5738
|
+
*/
|
|
5739
|
+
timingAudit?: boolean;
|
|
5472
5740
|
/** Override initial state (defaults to component's .initialState) */
|
|
5473
5741
|
initialState?: any;
|
|
5474
5742
|
/**
|
|
@@ -5794,6 +6062,14 @@ interface RenderResult<STATE = any> {
|
|
|
5794
6062
|
* throws (the driver would only log it, SYG678).
|
|
5795
6063
|
*/
|
|
5796
6064
|
fail: (sinkName: string, error: any, target?: string | FakeReplyOptions | Record<string, any> | ((request: any) => boolean)) => Promise<void>;
|
|
6065
|
+
/**
|
|
6066
|
+
* PLAN-11 (6.7): one progress step of a pending request sent with `progress` (chosen as in
|
|
6067
|
+
* respond; `'UPLOADING'` matches its progress action too): `t.progress('HTTP', { loaded: 50, total: 100 }, 'UPLOADING')`.
|
|
6068
|
+
* The component gets FetchProgress (`fraction: 0.5`) as that action, or on `HTTP.progress()`
|
|
6069
|
+
* for `progress: true`. `phase` defaults to 'upload' for a request with a body, else
|
|
6070
|
+
* 'download'. The request stays pending until respond()/fail(). Resolves once reduced and rendered.
|
|
6071
|
+
*/
|
|
6072
|
+
progress: (sinkName: string, step: { loaded: number; total?: number; phase?: 'upload' | 'download' }, target?: string | FakeReplyOptions | Record<string, any> | ((request: any) => boolean)) => Promise<void>;
|
|
5797
6073
|
/**
|
|
5798
6074
|
* PLAN-6 L-4: stream into a pending request of the LLM fake (the sink named by `llmSink`,
|
|
5799
6075
|
* default 'LLM': the real makeChatDriver over an in-memory transport). Chunks: strings (text),
|
|
@@ -5925,13 +6201,13 @@ interface RenderResult<STATE = any> {
|
|
|
5925
6201
|
* `await t.next(pred)` / `waitForState` / `settle()` / `ready()` it shows the state the wait resolved with.
|
|
5926
6202
|
*/
|
|
5927
6203
|
query: {
|
|
5928
|
-
(selector: string):
|
|
6204
|
+
<E extends Element = Element>(selector: string): E | null;
|
|
5929
6205
|
/** A control's element (`t.query(Draft)` is an HTMLInputElement for an 'input' control), or null */
|
|
5930
6206
|
<CONTROL extends AnyControl>(control: CONTROL): ControlElementOf<CONTROL> | null;
|
|
5931
6207
|
};
|
|
5932
6208
|
/** Every element matching a selector (or a control) in the rendered tree (Portals included), as query() */
|
|
5933
6209
|
queryAll: {
|
|
5934
|
-
(selector: string):
|
|
6210
|
+
<E extends Element = Element>(selector: string): E[];
|
|
5935
6211
|
<CONTROL extends AnyControl>(control: CONTROL): Array<ControlElementOf<CONTROL>>;
|
|
5936
6212
|
};
|
|
5937
6213
|
/**
|
|
@@ -6098,4 +6374,4 @@ declare global {
|
|
|
6098
6374
|
*/
|
|
6099
6375
|
declare function byId<T = any, S = any>(field: string, id: unknown, idKey?: string): { get(state: S): T | undefined; set(state: S, value: T): S }
|
|
6100
6376
|
|
|
6101
|
-
export { ABORT, type ActionCause, type ActionsOf, type ActiveTimer, type AgentAction, type AgentConfirm, type AgentConfirmInfo, type AgentDeclaration, type AgentIssue, type AgentQuery, type AgentQueryResult, type AgentResult, type AgentSchema, type AgentTool, type AgentToolSet, type AgentToolsOptions, type AguiOptions, type AnswerPick, type AnswerPicks, type AnthropicMessagesOptions, type AnyComponentModule, type AnyControl, type AppErrorHook, type AppErrorInfo, type AppErrorPhase, type ArrayKeysOf, type ArrayPathsOf, type AsyncDriverError, type AsyncDriverFromFunction, type AsyncRequest, type Behavior, type BehaviorDefinition, type BehaviorFactory, type BehaviorHandler, type BehaviorModelEntry, type BehaviorProps, type BehaviorSources, type BehaviorState, type BehaviorTarget, type BrowserCommand, type BrowserFake, type BrowserFakeOptions, type BrowserIntersection, type BrowserPosition, type BrowserResize, type BrowserSource, type BrowserSources, type BrowserSpec, type Catalog, type CatalogContainer, type CatalogContainerDecl, type CatalogDecl, type CatalogOption, type CatalogParam, type CatalogParamValue, type CatalogParamsOf, type CatalogPart, type CatalogPartDecl, type CatalogRecord, type CatalogTree, type CatalogTreeNode, type ChatAbort, type ChatActions, type ChatAskOptions, type ChatCall, type ChatCard, type ChatCardStatus, type ChatClientTool, type ChatCompletionsOptions, type ChatDelta, type ChatDone, type ChatDriverOptions, type ChatError, type ChatEvent, type ChatOk, type ChatOptions, type ChatOutputOf, type ChatOutputSchema, type ChatRequest, type ChatSource, type ChatState, type ChatStatus, type ChatTool, type ChatToolCall, type ChatToolPart, type ChatTransport, type ChatUsage, type ChromePromptOptions, type ChromePromptStatus, type ChromePromptTransport, type ClassesType, Collection, type CollectionFrom, type CollectionProps, type Command, type CommandBarActions, type CommandBarOptions, type CommandBarResult, type CommandBarState, type CommandBarStatus, type CommandBarUnsure, type CommandSource, type Component, type ComposeActions, type ComposeAnswer, type ComposeBackend, type ComposeNames, type ComposeOptions, type ComposeRenderOptions, type ComposeRenderable, type ComposeState, type ComposeStatus, type ComposeTree, Composed, type ComposedProps, type Connections, type ContainerView, type Control, type ControlCommonProps, type ControlDOMSource, type ControlElementOf, type ControlEvent, type ControlH, type ControlPropsOf, type ControlSpec, type ControlSpecObject, type ControlsOf, type ConvertedSchema, type CycleDOMEvent, type CycleDriver, type DOMDriverOptions, type DOMEventShorthand, type DOMEventShorthands, type DOMSource, type DefaultDrivers, type DefineComponentOptions, type DevToolsActionCause, type DevToolsCopyAsTestOptions, type DevToolsSessionRecording, type Diagnostic, type DiagnosticCode, type DiagnosticSeverity, type DiagnosticsMode, type DiagnosticsOptions, type DragDriverCategory, type DragDriverRegistration, type DragDriverSource, type DragSource, type DragStartPayload, type DriverFactories, type DriverFromAsyncOptions, type DriverSpec, type DriverSpecs, type DropPayload, type ElementCommand, type ElementCommandRegistry, type ElementCommands, type ElementProps, type ElementTarget, type EmittedEvent, type EnrichedEventStream, type Event$1 as Event, type EventName, type EventPayload, type EventPayloadFunction, type EventSink, type EventsFnOptions, type EventsSource, type ExactShape, type ExplainedAction, type ExposeWebMcpOptions, type FakeCacheEntry, type FakeChatChunk, type FakeConnection, type FakeConnectionTarget, type FakeReplyOptions, type FetchCacheOptions, type FetchDriverOptions, type FetchError, type FetchFailure, type FetchInit, type FetchInvalidate, type FetchRequest, type FetchResponse, type FetchRetry, type FetchSource, type FieldErrors, type Filter, type FixDrivers, type FormActions, type FormCalculated, type FormData, type FormField, type FormFieldCheck, type FormOptions, type FormSource, type FormState, type FormTool, type FormToolHandle, type FormToolResult, type FromAISDKOptions, type HeadValue, type HotModuleAPI, type HttpTransportOptions, type InspectAction, type InspectActionTrigger, type InspectChild, type InspectCommand, type InspectComponent, type InspectDiagnostic, type InspectFix, type InspectGraph, type InspectRecentAction, type InspectRelatedLocation, type InspectSelector, type InspectTextEdit, type InspectTimer, type InstallPrompt, type IntentSources, type IntrinsicControlProps, type JsonSchemaObject, type Layout, type LayoutNode, type LazyComponent, type LazyOptions, type Lens, type Lense, MainDOMSource, type McpAppDisplayMode, type McpAppDriverOptions, type McpAppError, type McpAppRequest, type McpAppSource, type McpContentBlock, type McpDownloadItem, type McpHostContext, type McpHostInfo, type McpLogLevel, type McpResourceContents, type McpSamplingRequest, type McpToolResult, type MockConfig, MockedDOMSource, type NonStateSinkReturns, type OpenResponsesEvent, type OpenResponsesOptions, type PagerActions, type PagerCalculated, type PagerOptions, type PagerState, type ParamNames, type ParentPayloadOf, type Persist, type PersistOptions, type PersistOptionsFor, type PersistStorage, type PersistedEntry, Portal, type PortalProps, type ProcessFormOptions, type QueryCache, type QueryCacheSnapshot, type QueryCacheSnapshotEntry, type Ref, type Ref$, type RegisteredEvent, type RenderOptions, type RenderResult, type RenderToStringOptions, type RenderableComponent, type ReplyRequest, type Resource, type ResourceRequest, type RootComponent, type Route, type RouteName, type RouteParamsArg, type RouteQuery, type Router, type RouterBlocked, type RouterCommand, type RouterOptions, type RouterSource, type RunOptions, type SchemaOutput, type ScrollToAlign, type SelectedDOMSource, type SelectionActions, type SelectionCalculated, type SelectionOptions, type SelectionState, type ServiceWorkerCommand, type ServiceWorkerOptions, type ServiceWorkerSource, type SimulatedEventInit, Slot, type SlotProps, type SocketActions, type SocketClose, type SocketConnection, type SocketDriverOptions, type SocketError, type SocketEvent, type SocketOpen, type SocketReconnect, type SocketRequest, type SocketSource, type SortFunction, type SortObject, type SortSpec, type SortableActions, type SortableDropped, type SortableOptions, type SortableState, type SseConnection, type StandardSchemaLike, type StateProp, type StrictDialect, type StrictSchemas, Suspense, type SuspenseProps, Switchable, type SwitchableProps, type SygnalApp, type SygnalBodyDOMSource, type SygnalDOMSource, type SygnalDevTools, type SygnalDocumentDOMSource, type SygnalEvents, type SygnalSinks, type TestAction, type Thunk, type ThunkData, type TimerAfter, type TimerFrame, type TimerSpec, type TimerTick, type Timers, Transition, type TransitionProps, type UIMessageStreamOptions, type UidFunction, type UndoBehaviorOptions, type UndoHistory, type UndoOptions, type UsesActions, type UsesState, type ViewProps, VirtualCollection, type VirtualCollectionProps, type WebMcpHandle, type Widget, type WidgetDefinition, type WidgetDispatch, type WidgetElementOf, type WidgetEmit, type WidgetHandle, type WidgetHostProps, type WithinTarget, abort, agentTools, agui, answers, anthropicMessages, askCard, byId, chat, chatCompletions, checkForm, choice, chromePrompt, classes, clearDiagnostics, clipboardSource, commandBar, compose, composeWith, controls, createCommand, createInstallPrompt, createRef, createRef$, decide, defineBehavior, defineCatalog, defineComponent, defineWidget, driverFromAsync, emit, enableHMR, encodeOpenResponses, event, exactState, experimentalExposeWebMcp, fieldName, fieldNames, focusInvalid, focusWithin, form, formErrors, formTool, fromAISDK, fromTree, geolocationSource, getDevTools, getDiagnostics, getField, hasField, intersectionSource, isSelected, jsonSchema, lazy, makeBrowserDriver, makeBrowserDriverWith, makeChatDriver, makeDOMDriver, makeDragDriver, makeFetchDriver, makeHeadDriver, makeMcpAppDriver, makeRouter, makeRouterDriver, makeServiceWorkerDriver, makeSocketDriver, makeTimerDriver, makeViewTransitionDOMDriver, mediaSource, messageText, mockDOMSource, noul, onDiagnostic, onlineSource, onlineStatus$, openResponses, openToolCalls, outputJsonSchema, pager, parseInput, persist, portal, processDrag, processForm, queryCache, removeNode, renderComponent, renderHead, renderToString, replyErrors, resizeSource, run, score, selection, set, setField, sortable, storageSource, strictSchemas, thunk, toJsonSchema, toTree, toggle, uiMessageStream, undo, undoable, visibilitySource, withToolResults, xs };
|
|
6377
|
+
export { ABORT, type ActionCause, type ActionsOf, type ActiveTimer, type AgentAction, type AgentConfirm, type AgentConfirmInfo, type AgentDeclaration, type AgentIssue, type AgentQuery, type AgentQueryResult, type AgentResult, type AgentSchema, type AgentTool, type AgentToolSet, type AgentToolsOptions, type AguiOptions, type AnswerPick, type AnswerPicks, type AnthropicMessagesOptions, type AnyComponentModule, type AnyControl, type AppErrorHook, type AppErrorInfo, type AppErrorPhase, type ArrayKeysOf, type ArrayPathsOf, type AsyncDriverError, type AsyncDriverFromFunction, type AsyncRequest, type Behavior, type BehaviorDefinition, type BehaviorFactory, type BehaviorHandler, type BehaviorModelEntry, type BehaviorProps, type BehaviorSources, type BehaviorState, type BehaviorTarget, type BrowserCommand, type BrowserFake, type BrowserFakeOptions, type BrowserIntersection, type BrowserPosition, type BrowserResize, type BrowserSource, type BrowserSources, type BrowserSpec, type Catalog, type CatalogContainer, type CatalogContainerDecl, type CatalogDecl, type CatalogOption, type CatalogParam, type CatalogParamValue, type CatalogParamsOf, type CatalogPart, type CatalogPartDecl, type CatalogRecord, type CatalogTree, type CatalogTreeNode, type ChatAbort, type ChatActions, type ChatAskOptions, type ChatCall, type ChatCard, type ChatCardStatus, type ChatClientTool, type ChatCompletionsOptions, type ChatDelta, type ChatDone, type ChatDriverOptions, type ChatError, type ChatEvent, type ChatOk, type ChatOptions, type ChatOutputOf, type ChatOutputSchema, type ChatRequest, type ChatSource, type ChatState, type ChatStatus, type ChatTool, type ChatToolCall, type ChatToolPart, type ChatTransport, type ChatUsage, type ChromePromptOptions, type ChromePromptStatus, type ChromePromptTransport, type ClassesType, Collection, type CollectionFrom, type CollectionProps, type Command, type CommandBarActions, type CommandBarOptions, type CommandBarResult, type CommandBarState, type CommandBarStatus, type CommandBarUnsure, type CommandSource, type Component, type ComposeActions, type ComposeAnswer, type ComposeBackend, type ComposeNames, type ComposeOptions, type ComposeRenderOptions, type ComposeRenderable, type ComposeState, type ComposeStatus, type ComposeTree, Composed, type ComposedProps, type Connections, type ContainerView, type Control, type ControlCommonProps, type ControlDOMSource, type ControlElementOf, type ControlEvent, type ControlH, type ControlPropsOf, type ControlSpec, type ControlSpecObject, type ControlsOf, type ConvertedSchema, type CycleDOMEvent, type CycleDriver, type DOMDriverOptions, type DOMEventShorthand, type DOMEventShorthands, type DOMSource, type DefaultDrivers, type DefineComponentOptions, type DevToolsActionCause, type DevToolsCopyAsTestOptions, type DevToolsSessionRecording, type Diagnostic, type DiagnosticCode, type DiagnosticSeverity, type DiagnosticsMode, type DiagnosticsOptions, type DragDriverCategory, type DragDriverRegistration, type DragDriverSource, type DragSource, type DragStartPayload, type DriverFactories, type DriverFromAsyncOptions, type DriverSpec, type DriverSpecs, type DropPayload, type ElementCommand, type ElementCommandRegistry, type ElementCommands, type ElementProps, type ElementTarget, type EmittedEvent, type EnrichedEventStream, type Event$1 as Event, type EventName, type EventPayload, type EventPayloadFunction, type EventSink, type EventsFnOptions, type EventsSource, type ExactShape, type ExplainedAction, type ExposeWebMcpOptions, type FakeCacheEntry, type FakeChatChunk, type FakeConnection, type FakeConnectionTarget, type FakeReplyOptions, type FetchCacheOptions, type FetchDriverOptions, type FetchError, type FetchFailure, type FetchInit, type FetchInvalidate, type FetchProgress, type FetchRequest, type FetchResponse, type FetchRetry, type FetchSource, type FieldErrors, type Filter, type FixDrivers, type FormActions, type FormBehavior, type FormCalculated, type FormData, type FormField, type FormFieldCheck, type FormFields, type FormOptions, type FormOutput, type FormRequest, type FormServerErrors, type FormSource, type FormState, type FormTool, type FormToolHandle, type FormToolResult, type FromAISDKOptions, type HeadValue, type HotModuleAPI, type HttpTransportOptions, type InspectAction, type InspectActionTrigger, type InspectChild, type InspectChildSelect, type InspectCommand, type InspectComponent, type InspectDiagnostic, type InspectFix, type InspectGraph, type InspectLocation, type InspectRecentAction, type InspectRelatedLocation, type InspectSelector, type InspectTextEdit, type InspectTimer, type InstallPrompt, type IntentSources, type IntrinsicControlProps, type JsonSchemaObject, type Layout, type LayoutNode, type LazyComponent, type LazyOptions, type Lens, type Lense, MainDOMSource, type McpAppDisplayMode, type McpAppDriverOptions, type McpAppError, type McpAppRequest, type McpAppSource, type McpContentBlock, type McpDownloadItem, type McpHostContext, type McpHostInfo, type McpLogLevel, type McpResourceContents, type McpSamplingRequest, type McpToolResult, type MockConfig, MockedDOMSource, type MultipartValue, type NonStateSinkReturns, type OpenResponsesEvent, type OpenResponsesOptions, type PagerActions, type PagerCalculated, type PagerOptions, type PagerState, type ParamNames, type ParentPayloadOf, type Persist, type PersistOptions, type PersistOptionsFor, type PersistStorage, type PersistedEntry, Portal, type PortalProps, type ProcessFormOptions, type QueryCache, type QueryCacheSnapshot, type QueryCacheSnapshotEntry, type Ref, type Ref$, type RegisteredEvent, type RenderOptions, type RenderResult, type RenderToStringOptions, type RenderableComponent, type ReplyRequest, type Resource, type ResourceRequest, type RootComponent, type Route, type RouteName, type RouteParamsArg, type RouteQuery, type Router, type RouterBlocked, type RouterCommand, type RouterOptions, type RouterSource, type RunOptions, type SchemaInput, type SchemaOutput, type ScrollToAlign, type SelectedDOMSource, type SelectionActions, type SelectionCalculated, type SelectionOptions, type SelectionState, type ServiceWorkerCommand, type ServiceWorkerOptions, type ServiceWorkerSource, type SimulatedEventInit, Slot, type SlotProps, type SocketActions, type SocketClose, type SocketConnection, type SocketDriverOptions, type SocketError, type SocketEvent, type SocketOpen, type SocketReconnect, type SocketRequest, type SocketSource, type SortFunction, type SortObject, type SortSpec, type SortableActions, type SortableDropped, type SortableOptions, type SortableState, type SseConnection, type StandardSchemaLike, type StateProp, type StrictDialect, type StrictSchemas, Suspense, type SuspenseProps, Switchable, type SwitchableProps, type SygnalApp, type SygnalBodyDOMSource, type SygnalDOMSource, type SygnalDevTools, type SygnalDocumentDOMSource, type SygnalEvents, type SygnalSinks, type TestAction, type Thunk, type ThunkData, type TimerAfter, type TimerFrame, type TimerSpec, type TimerTick, type Timers, Transition, type TransitionProps, type UIMessageStreamOptions, type UidFunction, type UndoBehaviorOptions, type UndoHistory, type UndoOptions, type UsesActions, type UsesState, type ViewProps, VirtualCollection, type VirtualCollectionProps, type WebMcpHandle, type Widget, type WidgetDefinition, type WidgetDispatch, type WidgetElementOf, type WidgetEmit, type WidgetHandle, type WidgetHostProps, type WithinTarget, abort, agentTools, agui, answers, anthropicMessages, askCard, byId, chat, chatCompletions, checkForm, choice, chromePrompt, classes, clearDiagnostics, clipboardSource, commandBar, compose, composeWith, controls, createCommand, createInstallPrompt, createRef, createRef$, decide, defineBehavior, defineCatalog, defineComponent, defineWidget, driverFromAsync, emit, enableHMR, encodeOpenResponses, event, exactState, experimentalExposeWebMcp, fieldName, fieldNames, focusInvalid, focusWithin, form, formErrors, formTool, fromAISDK, fromTree, geolocationSource, getDevTools, getDiagnostics, getField, hasField, intersectionSource, isSelected, jsonSchema, lazy, makeBrowserDriver, makeBrowserDriverWith, makeChatDriver, makeDOMDriver, makeDragDriver, makeFetchDriver, makeHeadDriver, makeMcpAppDriver, makeRouter, makeRouterDriver, makeServiceWorkerDriver, makeSocketDriver, makeTimerDriver, makeViewTransitionDOMDriver, mediaSource, messageText, mockDOMSource, noul, onDiagnostic, onlineSource, onlineStatus$, openResponses, openToolCalls, outputJsonSchema, pager, parseInput, persist, portal, processDrag, processForm, queryCache, removeNode, renderComponent, renderHead, renderToString, replyErrors, resizeSource, run, score, selection, set, setField, sortable, storageSource, strictSchemas, thunk, toJsonSchema, toTree, toggle, uiMessageStream, undo, undoable, visibilitySource, withToolResults, xs };
|