@wardic/core 1.3.1 → 1.4.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/dist/Arc.d.ts +2 -2
- package/dist/Arc.js +1 -1
- package/dist/BaseValue.d.ts +11 -10
- package/dist/BaseValue.d.ts.map +1 -1
- package/dist/BaseValue.js +12 -15
- package/dist/BaseValue.js.map +1 -1
- package/dist/Batch.d.ts +12 -6
- package/dist/Batch.d.ts.map +1 -1
- package/dist/Batch.js +374 -30
- package/dist/Batch.js.map +1 -1
- package/dist/Clock.d.ts +16 -0
- package/dist/Clock.d.ts.map +1 -1
- package/dist/Clock.js +22 -8
- package/dist/Clock.js.map +1 -1
- package/dist/DefaultTransition.d.ts +3 -2
- package/dist/DefaultTransition.d.ts.map +1 -1
- package/dist/DefaultTransition.js +5 -3
- package/dist/DefaultTransition.js.map +1 -1
- package/dist/Drag.d.ts +24 -9
- package/dist/Drag.d.ts.map +1 -1
- package/dist/Drag.js +10 -10
- package/dist/Drag.js.map +1 -1
- package/dist/DragActivity.js +3 -3
- package/dist/DragRecognizer.d.ts +14 -8
- package/dist/DragRecognizer.d.ts.map +1 -1
- package/dist/DragRecognizer.js +93 -34
- package/dist/DragRecognizer.js.map +1 -1
- package/dist/Easing.d.ts +1 -1
- package/dist/Easing.js +1 -1
- package/dist/Frame.d.ts.map +1 -1
- package/dist/Frame.js +5 -3
- package/dist/Frame.js.map +1 -1
- package/dist/InputFeed.d.ts +11 -8
- package/dist/InputFeed.d.ts.map +1 -1
- package/dist/InputFeed.js +18 -37
- package/dist/InputFeed.js.map +1 -1
- package/dist/InputSource.d.ts +3 -3
- package/dist/InputSource.js +2 -2
- package/dist/Interpolator.d.ts +2 -2
- package/dist/Interpolator.js +2 -2
- package/dist/InterpolatorRegistry.d.ts +29 -15
- package/dist/InterpolatorRegistry.d.ts.map +1 -1
- package/dist/InterpolatorRegistry.js +17 -8
- package/dist/InterpolatorRegistry.js.map +1 -1
- package/dist/LiveValue.d.ts +16 -9
- package/dist/LiveValue.d.ts.map +1 -1
- package/dist/LiveValue.js +204 -27
- package/dist/LiveValue.js.map +1 -1
- package/dist/Machine.d.ts +21 -8
- package/dist/Machine.d.ts.map +1 -1
- package/dist/Machine.js +184 -60
- package/dist/Machine.js.map +1 -1
- package/dist/Playback.d.ts.map +1 -1
- package/dist/Playback.js +16 -9
- package/dist/Playback.js.map +1 -1
- package/dist/Projection.d.ts +9 -9
- package/dist/Projection.js +2 -2
- package/dist/Recognizer.d.ts +2 -2
- package/dist/Recognizer.d.ts.map +1 -1
- package/dist/Recognizer.js +15 -10
- package/dist/Recognizer.js.map +1 -1
- package/dist/ReducedMotion.d.ts +4 -4
- package/dist/ReducedMotion.js +6 -6
- package/dist/Renderer.d.ts +5 -5
- package/dist/Renderer.js +6 -6
- package/dist/Renderer.js.map +1 -1
- package/dist/Reorder.d.ts +1 -1
- package/dist/Reorder.d.ts.map +1 -1
- package/dist/Reorder.js +2 -1
- package/dist/Reorder.js.map +1 -1
- package/dist/ScrollSource.d.ts +1 -1
- package/dist/ScrollSource.d.ts.map +1 -1
- package/dist/Sequence.d.ts +1 -1
- package/dist/SharedSource.d.ts +3 -3
- package/dist/SharedSource.js +5 -5
- package/dist/SharedSource.js.map +1 -1
- package/dist/Spring.d.ts.map +1 -1
- package/dist/Spring.js +2 -1
- package/dist/Spring.js.map +1 -1
- package/dist/Values.d.ts +2 -2
- package/dist/Values.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/internal/carried.d.ts +13 -0
- package/dist/internal/carried.d.ts.map +1 -0
- package/dist/internal/carried.js +23 -0
- package/dist/internal/carried.js.map +1 -0
- package/dist/internal/firstSteps.d.ts +66 -0
- package/dist/internal/firstSteps.d.ts.map +1 -0
- package/dist/internal/firstSteps.js +107 -0
- package/dist/internal/firstSteps.js.map +1 -0
- package/dist/internal/frameLoop.d.ts +11 -3
- package/dist/internal/frameLoop.d.ts.map +1 -1
- package/dist/internal/frameLoop.js +190 -39
- package/dist/internal/frameLoop.js.map +1 -1
- package/dist/internal/guarded.d.ts +16 -0
- package/dist/internal/guarded.d.ts.map +1 -0
- package/dist/internal/guarded.js +68 -0
- package/dist/internal/guarded.js.map +1 -0
- package/dist/internal/lerpsNumbers.d.ts +11 -0
- package/dist/internal/lerpsNumbers.d.ts.map +1 -0
- package/dist/internal/lerpsNumbers.js +38 -0
- package/dist/internal/lerpsNumbers.js.map +1 -0
- package/dist/internal/options.d.ts +7 -7
- package/dist/internal/options.d.ts.map +1 -1
- package/dist/internal/options.js +10 -10
- package/dist/internal/options.js.map +1 -1
- package/dist/internal/stepper.d.ts +21 -4
- package/dist/internal/stepper.d.ts.map +1 -1
- package/dist/internal/stepper.js +21 -5
- package/dist/internal/stepper.js.map +1 -1
- package/dist/internal/tracing.d.ts +1 -1
- package/dist/internal/tracing.js +1 -1
- package/dist/unstable/AnimationControls.d.ts +45 -39
- package/dist/unstable/AnimationControls.d.ts.map +1 -1
- package/dist/unstable/AnimationControls.js +59 -35
- package/dist/unstable/AnimationControls.js.map +1 -1
- package/dist/unstable/AppearHandoff.d.ts +11 -5
- package/dist/unstable/AppearHandoff.d.ts.map +1 -1
- package/dist/unstable/AppearHandoff.js.map +1 -1
- package/dist/unstable/BatchCalls.d.ts +2 -2
- package/dist/unstable/BatchCalls.js +5 -5
- package/dist/unstable/Config.d.ts +21 -17
- package/dist/unstable/Config.d.ts.map +1 -1
- package/dist/unstable/Config.js.map +1 -1
- package/dist/unstable/FirstSteps.d.ts +25 -0
- package/dist/unstable/FirstSteps.d.ts.map +1 -0
- package/dist/unstable/FirstSteps.js +2 -0
- package/dist/unstable/FirstSteps.js.map +1 -0
- package/dist/unstable/FlushGate.d.ts +54 -50
- package/dist/unstable/FlushGate.d.ts.map +1 -1
- package/dist/unstable/FlushGate.js +201 -77
- package/dist/unstable/FlushGate.js.map +1 -1
- package/dist/unstable/FrameEffects.d.ts +6 -3
- package/dist/unstable/FrameEffects.d.ts.map +1 -1
- package/dist/unstable/FrameEffects.js +14 -3
- package/dist/unstable/FrameEffects.js.map +1 -1
- package/dist/unstable/FrameTime.d.ts +1 -1
- package/dist/unstable/FrameTime.js +1 -1
- package/dist/unstable/Imperative.d.ts +42 -13
- package/dist/unstable/Imperative.d.ts.map +1 -1
- package/dist/unstable/Imperative.js +279 -88
- package/dist/unstable/Imperative.js.map +1 -1
- package/dist/unstable/MeasuredPairs.d.ts +6 -2
- package/dist/unstable/MeasuredPairs.d.ts.map +1 -1
- package/dist/unstable/MeasuredPairs.js.map +1 -1
- package/dist/unstable/OwnValues.js +1 -1
- package/dist/unstable/PresenceRecord.d.ts +30 -26
- package/dist/unstable/PresenceRecord.d.ts.map +1 -1
- package/dist/unstable/PresenceRecord.js +8 -8
- package/dist/unstable/PresenceRecord.js.map +1 -1
- package/dist/unstable/Projector.d.ts +34 -0
- package/dist/unstable/Projector.d.ts.map +1 -0
- package/dist/unstable/Projector.js +9 -0
- package/dist/unstable/Projector.js.map +1 -0
- package/dist/unstable/Report.d.ts +8 -1
- package/dist/unstable/Report.d.ts.map +1 -1
- package/dist/unstable/Report.js +18 -2
- package/dist/unstable/Report.js.map +1 -1
- package/dist/unstable/RetargetLegs.d.ts +7 -1
- package/dist/unstable/RetargetLegs.d.ts.map +1 -1
- package/dist/unstable/RetargetLegs.js +24 -8
- package/dist/unstable/RetargetLegs.js.map +1 -1
- package/dist/unstable/Spine.d.ts +123 -68
- package/dist/unstable/Spine.d.ts.map +1 -1
- package/dist/unstable/Spine.js +319 -167
- package/dist/unstable/Spine.js.map +1 -1
- package/dist/unstable/Stops.d.ts +3 -3
- package/dist/unstable/Stops.js +4 -4
- package/dist/unstable/Subject.d.ts +2 -2
- package/dist/unstable/Subject.js +2 -2
- package/dist/unstable/Timelines.d.ts +11 -11
- package/dist/unstable/Timelines.d.ts.map +1 -1
- package/dist/unstable/Timelines.js +3 -3
- package/dist/unstable/VariantTarget.d.ts +32 -10
- package/dist/unstable/VariantTarget.d.ts.map +1 -1
- package/dist/unstable/VariantTarget.js +73 -20
- package/dist/unstable/VariantTarget.js.map +1 -1
- package/dist/unstable/VariantTree.d.ts +68 -34
- package/dist/unstable/VariantTree.d.ts.map +1 -1
- package/dist/unstable/VariantTree.js +83 -36
- package/dist/unstable/VariantTree.js.map +1 -1
- package/dist/unstable/WardicConfigValue.d.ts +13 -13
- package/dist/unstable/WardicConfigValue.d.ts.map +1 -1
- package/dist/unstable/WardicConfigValue.js +4 -4
- package/dist/unstable/WardicConfigValue.js.map +1 -1
- package/package.json +1 -1
- package/src/Arc.ts +3 -3
- package/src/BaseValue.ts +18 -21
- package/src/Batch.ts +391 -27
- package/src/Clock.ts +29 -8
- package/src/DefaultTransition.ts +5 -3
- package/src/Drag.ts +32 -14
- package/src/DragActivity.ts +3 -3
- package/src/DragRecognizer.ts +118 -41
- package/src/Easing.ts +1 -1
- package/src/Frame.ts +5 -3
- package/src/InputFeed.ts +39 -42
- package/src/InputSource.ts +5 -5
- package/src/Interpolator.ts +3 -3
- package/src/InterpolatorRegistry.ts +22 -13
- package/src/LiveValue.ts +186 -30
- package/src/Machine.ts +252 -81
- package/src/Playback.ts +15 -9
- package/src/Projection.ts +9 -9
- package/src/Recognizer.ts +16 -10
- package/src/ReducedMotion.ts +6 -6
- package/src/Renderer.ts +6 -6
- package/src/Reorder.ts +3 -2
- package/src/ScrollSource.ts +1 -1
- package/src/Sequence.ts +1 -1
- package/src/SharedSource.ts +5 -5
- package/src/Spring.ts +2 -1
- package/src/Values.ts +2 -2
- package/src/index.ts +1 -1
- package/src/internal/carried.ts +22 -0
- package/src/internal/firstSteps.ts +139 -0
- package/src/internal/frameLoop.ts +203 -41
- package/src/internal/guarded.ts +69 -0
- package/src/internal/lerpsNumbers.ts +53 -0
- package/src/internal/options.ts +10 -10
- package/src/internal/stepper.ts +33 -6
- package/src/internal/tracing.ts +1 -1
- package/src/unstable/AnimationControls.ts +88 -57
- package/src/unstable/AppearHandoff.ts +13 -6
- package/src/unstable/BatchCalls.ts +5 -5
- package/src/unstable/Config.ts +23 -17
- package/src/unstable/FirstSteps.ts +26 -0
- package/src/unstable/FlushGate.ts +250 -108
- package/src/unstable/FrameEffects.ts +17 -4
- package/src/unstable/FrameTime.ts +1 -1
- package/src/unstable/Imperative.ts +342 -101
- package/src/unstable/MeasuredPairs.ts +7 -1
- package/src/unstable/OwnValues.ts +1 -1
- package/src/unstable/PresenceRecord.ts +33 -29
- package/src/unstable/Projector.ts +45 -0
- package/src/unstable/Report.ts +20 -2
- package/src/unstable/RetargetLegs.ts +24 -9
- package/src/unstable/Spine.ts +399 -202
- package/src/unstable/Stops.ts +6 -6
- package/src/unstable/Subject.ts +2 -2
- package/src/unstable/Timelines.ts +12 -12
- package/src/unstable/VariantTarget.ts +102 -23
- package/src/unstable/VariantTree.ts +123 -42
- package/src/unstable/WardicConfigValue.ts +13 -13
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The rules of
|
|
3
|
-
* names
|
|
2
|
+
* The rules of a Subject's place in variant orchestration (ADR-0007, #50), on every binding: the
|
|
3
|
+
* names a Subject hands its children and inherits from its parent, the values it starts from, and
|
|
4
4
|
* what a server render builds. Each binding's variant node runs the orchestration over them, with its
|
|
5
5
|
* own reactivity.
|
|
6
6
|
*
|
|
7
7
|
* Motion's rule (CONTEXT.md, **Variant child**):
|
|
8
|
-
* -
|
|
8
|
+
* - A Subject that names its own variants, a name on any variant prop (`initial`, `animate`, the
|
|
9
9
|
* `while*` gestures, `exit`; #618), hands its children its `initial` and `animate` names, and an
|
|
10
10
|
* `initial={false}` with them (#134). Any other passes its parent's through, unless it sets
|
|
11
11
|
* `inherit={false}`, which passes none.
|
|
12
12
|
* - A **Variant child** (`variants`, no names of its own, `inherit` not `false`) inherits its
|
|
13
13
|
* ancestor's names and default transition, takes a stagger slot among the ancestor's variant
|
|
14
14
|
* children, and counts for the ancestor's `when`.
|
|
15
|
-
* -
|
|
16
|
-
* join: it owns their registry, their stagger and their `when`. Any other
|
|
15
|
+
* - A Subject with variants of its own (`variants`, or a name) is what its Variant children
|
|
16
|
+
* join: it owns their registry, their stagger and their `when`. Any other Subject passes its
|
|
17
17
|
* parent's context through, so a Variant child joins its nearest such ancestor; it renders no
|
|
18
18
|
* Provider unless it sets `inherit={false}` ({@link changesContext}).
|
|
19
19
|
*
|
|
@@ -22,13 +22,18 @@
|
|
|
22
22
|
* @module
|
|
23
23
|
*/
|
|
24
24
|
// Unstable: ADR-0071, decision 5. #672: solid's `variant-tree.ts`, moved for the spine to read an
|
|
25
|
-
//
|
|
25
|
+
// Subject's place in variant orchestration in core.
|
|
26
26
|
import * as Stagger from "../Stagger.ts"
|
|
27
27
|
import type * as Values from "../Values.ts"
|
|
28
|
+
import * as Report from "./Report.ts"
|
|
28
29
|
import * as Stops from "./Stops.ts"
|
|
30
|
+
import type * as WardicServices from "./WardicServices.ts"
|
|
29
31
|
import * as Arr from "effect/Array"
|
|
30
32
|
import * as Bool from "effect/Boolean"
|
|
33
|
+
import * as Cause from "effect/Cause"
|
|
34
|
+
import * as Effect from "effect/Effect"
|
|
31
35
|
import { constTrue, constUndefined, identity } from "effect/Function"
|
|
36
|
+
import type * as Option from "effect/Option"
|
|
32
37
|
import * as Predicate from "effect/Predicate"
|
|
33
38
|
import * as UndefinedOr from "effect/UndefinedOr"
|
|
34
39
|
import * as AnimationControls from "./AnimationControls.ts"
|
|
@@ -93,7 +98,7 @@ export interface WardicStaggerConfig {
|
|
|
93
98
|
* inherit).
|
|
94
99
|
* - `initial` — the parent's `initial` NAME, or `false`, read once (#50, #134).
|
|
95
100
|
*
|
|
96
|
-
* Every
|
|
101
|
+
* Every Ward's Subject provides one (#50): its own if it has variants of its own, else its
|
|
97
102
|
* parent's, passed through (`variant-node.ts`).
|
|
98
103
|
* - `transition` — the parent's transition, inherited as the DEFAULT for
|
|
99
104
|
* children that supply no local `transition`.
|
|
@@ -107,10 +112,10 @@ export type GestureLayer = "inView" | "focused" | "hovered" | "pressed" | "dragg
|
|
|
107
112
|
/** The gesture layers in Motion's priority, lowest first. */
|
|
108
113
|
export const GESTURE_LAYERS: ReadonlyArray<GestureLayer> = ["inView", "focused", "hovered", "pressed", "dragged"]
|
|
109
114
|
|
|
110
|
-
/** The variant names
|
|
115
|
+
/** The variant names a Subject hands its Variant children for its active gestures (#291): a name or a list each (#297). */
|
|
111
116
|
export type GestureNames = Readonly<Partial<Record<GestureLayer, Config.WardicVariantLabels | undefined>>>
|
|
112
117
|
|
|
113
|
-
/** No gesture on: what
|
|
118
|
+
/** No gesture on: what a Subject with none active hands down. */
|
|
114
119
|
export const NO_GESTURE_NAMES: GestureNames = {}
|
|
115
120
|
|
|
116
121
|
/** Two {@link GestureNames} the same: the same names for each gesture, a list name by name (#297). */
|
|
@@ -124,7 +129,7 @@ export type GestureStates = Readonly<Record<GestureLayer, boolean>>
|
|
|
124
129
|
export const NO_GESTURE_STATES: GestureStates = { inView: false, focused: false, hovered: false, pressed: false, dragged: false }
|
|
125
130
|
|
|
126
131
|
/**
|
|
127
|
-
* What
|
|
132
|
+
* What a Subject hands its Variant children for its gestures (#291, Motion's `setActive` and variant
|
|
128
133
|
* context): whether each is on (its own, or its own provider's), and each one's label (its own
|
|
129
134
|
* `while*`, if a name, else the one it took). A Variant child's gesture is on while its provider's is.
|
|
130
135
|
*/
|
|
@@ -133,7 +138,7 @@ export interface GestureHandDown {
|
|
|
133
138
|
readonly names: GestureNames
|
|
134
139
|
}
|
|
135
140
|
|
|
136
|
-
/** Nothing on, no labels: what
|
|
141
|
+
/** Nothing on, no labels: what a Subject hands down with no provider and no gesture. */
|
|
137
142
|
export const NO_HAND_DOWN: GestureHandDown = { on: NO_GESTURE_STATES, names: NO_GESTURE_NAMES }
|
|
138
143
|
|
|
139
144
|
/** Two hand-downs the same: each gesture on alike, with the same label. */
|
|
@@ -142,7 +147,7 @@ export const sameHandDown = (a: GestureHandDown, b: GestureHandDown): boolean =>
|
|
|
142
147
|
|
|
143
148
|
/** What a context hands down, nothing without a context or its gestures. */
|
|
144
149
|
export const handDownFrom = (context: WardicVariantContextValue | undefined): GestureHandDown => {
|
|
145
|
-
// Per Retarget, per
|
|
150
|
+
// Per Retarget, per Subject: guards, nothing made (most Subjects have no provider).
|
|
146
151
|
if (Predicate.isUndefined(context)) return NO_HAND_DOWN
|
|
147
152
|
const gestures = context.gestures
|
|
148
153
|
if (Predicate.isUndefined(gestures)) return NO_HAND_DOWN
|
|
@@ -173,7 +178,7 @@ const labelOf = (own: object | Config.WardicVariantLabels | undefined, inherited
|
|
|
173
178
|
return inherited
|
|
174
179
|
}
|
|
175
180
|
|
|
176
|
-
/** What
|
|
181
|
+
/** What a Subject hands down (#291), from its config, its own states, and what it takes. */
|
|
177
182
|
export const handDownOf = (config: GestureConfig, own: GestureStates, above: GestureHandDown): GestureHandDown => ({
|
|
178
183
|
on: gesturesOn(own, above.on),
|
|
179
184
|
names: {
|
|
@@ -313,7 +318,7 @@ export interface WardicVariantContextValue {
|
|
|
313
318
|
readonly staggerFor?: (name: string | undefined) => WardicStaggerConfig
|
|
314
319
|
/**
|
|
315
320
|
* For a list: whether a Variant child's keys of `name` may start, that name's own
|
|
316
|
-
* `beforeChildren`: true unless it has one and this
|
|
321
|
+
* `beforeChildren`: true unless it has one and this Subject's keys of that name haven't settled
|
|
317
322
|
* since its list last changed. Optional: left out, always.
|
|
318
323
|
*/
|
|
319
324
|
readonly mayStartFor?: (name: string) => boolean
|
|
@@ -341,7 +346,7 @@ export interface WardicVariantContextValue {
|
|
|
341
346
|
readonly appearGroup?: unknown
|
|
342
347
|
}
|
|
343
348
|
|
|
344
|
-
/** The part of
|
|
349
|
+
/** The part of a Subject's config its place in variant orchestration reads. */
|
|
345
350
|
export interface VariantConfig extends GestureConfig {
|
|
346
351
|
readonly initial?: object | Config.WardicVariantLabels | false | undefined
|
|
347
352
|
readonly animate?: object | Config.WardicVariantLabels | undefined
|
|
@@ -358,7 +363,7 @@ export interface VariantConfig extends GestureConfig {
|
|
|
358
363
|
readonly controlled?: boolean | undefined
|
|
359
364
|
}
|
|
360
365
|
|
|
361
|
-
/** An `initial`
|
|
366
|
+
/** An `initial` a Subject hands its children: a variant name or list (#297), `false` (#134), or `undefined` for a values map or nothing. */
|
|
362
367
|
export const initialNameOf = (entry: object | Config.WardicVariantLabels | false | undefined): Config.WardicVariantLabels | false | undefined =>
|
|
363
368
|
Bool.match(entry === false, { onTrue: () => false as const, onFalse: () => nameOf(entry as object | Config.WardicVariantLabels | undefined) })
|
|
364
369
|
|
|
@@ -385,21 +390,21 @@ export const namesOwnVariants = (config: VariantConfig): boolean =>
|
|
|
385
390
|
VariantTarget.isLabels(config.whileDrag) ||
|
|
386
391
|
VariantTarget.isLabels(config.exit)
|
|
387
392
|
|
|
388
|
-
/** Whether
|
|
393
|
+
/** Whether a Subject has variants of its own, so Variant children join it (Motion's `isVariantNode`). */
|
|
389
394
|
export const hasOwnVariants = (config: VariantConfig): boolean =>
|
|
390
395
|
Predicate.isNotUndefined(config.variants) || namesOwnVariants(config)
|
|
391
396
|
|
|
392
397
|
/**
|
|
393
|
-
* Whether
|
|
394
|
-
* Provider (#50): it has variants of its own, or it sets `inherit={false}`. Any other
|
|
398
|
+
* Whether a Subject changes what its children read, so it renders its variant context's
|
|
399
|
+
* Provider (#50): it has variants of its own, or it sets `inherit={false}`. Any other Subject hands
|
|
395
400
|
* its children its parent's context as it is, so it renders none. Decided once, at setup, from the
|
|
396
401
|
* same props on a server and on the client, so the nesting never changes after mount.
|
|
397
402
|
*/
|
|
398
403
|
export const changesContext = (config: VariantConfig): boolean => hasOwnVariants(config) || config.inherit === false
|
|
399
404
|
|
|
400
405
|
/**
|
|
401
|
-
* The **Controls change** in effect for
|
|
402
|
-
* it inherits from is in, else none. Per mount, for every
|
|
406
|
+
* The **Controls change** in effect for a Subject (#433): its own controls', else the one the context
|
|
407
|
+
* it inherits from is in, else none. Per mount, for every Subject (#460): guards, nothing built.
|
|
403
408
|
*/
|
|
404
409
|
export const controlsChangeOf = (
|
|
405
410
|
controls: Reactivity.Accessor<AnimationControls.ControlsChange | undefined> | undefined,
|
|
@@ -412,22 +417,22 @@ export const controlsChangeOf = (
|
|
|
412
417
|
return change
|
|
413
418
|
}
|
|
414
419
|
|
|
415
|
-
/** Whether
|
|
420
|
+
/** Whether a Subject is a **Variant child** (CONTEXT.md). */
|
|
416
421
|
export const isVariantChild = (config: VariantConfig): boolean =>
|
|
417
422
|
Predicate.isNotUndefined(config.variants) && !namesOwnVariants(config) && config.inherit !== false
|
|
418
423
|
|
|
419
|
-
/** The context
|
|
424
|
+
/** The context a Subject inherits names and its default transition from: its parent's, for a Variant child. */
|
|
420
425
|
export const inheritedContext = (
|
|
421
426
|
config: VariantConfig,
|
|
422
427
|
parent: WardicVariantContextValue | undefined,
|
|
423
428
|
): WardicVariantContextValue | undefined => {
|
|
424
|
-
// Per
|
|
429
|
+
// Per Subject at mount (#540): statements.
|
|
425
430
|
if (isVariantChild(config)) return parent
|
|
426
431
|
return undefined
|
|
427
432
|
}
|
|
428
433
|
|
|
429
434
|
/**
|
|
430
|
-
* The `initial`
|
|
435
|
+
* The `initial` a Subject's Starting style resolves: its own, else the `initial` name (or `false`) of
|
|
431
436
|
* the context it inherits from (#50, #134). Read once, as every `initial` is.
|
|
432
437
|
*/
|
|
433
438
|
export const initialOf = (
|
|
@@ -439,7 +444,7 @@ export const initialOf = (
|
|
|
439
444
|
onUndefined: () => UndefinedOr.match(inherited, { onUndefined: constUndefined, onDefined: (context) => context.initial }),
|
|
440
445
|
})
|
|
441
446
|
|
|
442
|
-
/** The `animate`
|
|
447
|
+
/** The `animate` a Subject starts at with `initial={false}`: its own, else the name its context hands down (#134). Read once, untracked. */
|
|
443
448
|
const animateOf = (
|
|
444
449
|
config: VariantConfig,
|
|
445
450
|
inherited: WardicVariantContextValue | undefined,
|
|
@@ -451,7 +456,7 @@ const animateOf = (
|
|
|
451
456
|
})
|
|
452
457
|
|
|
453
458
|
/**
|
|
454
|
-
* Whether
|
|
459
|
+
* Whether a Subject starts at its `animate`, with nothing animating at mount (#134, Motion's
|
|
455
460
|
* `isInitialAnimationBlocked`): its `initial` (own or inherited) is `false`, or it renders with an
|
|
456
461
|
* `<AnimatePresence initial={false}>`'s first render (`presenceBlocks`).
|
|
457
462
|
*/
|
|
@@ -462,7 +467,7 @@ export const startsAtAnimate = (
|
|
|
462
467
|
): boolean => presenceBlocks || initialOf(config, inherited) === false
|
|
463
468
|
|
|
464
469
|
/**
|
|
465
|
-
* Whether
|
|
470
|
+
* Whether a Subject's mount tells nothing (#448, Motion's `animation-state.ts`): it
|
|
466
471
|
* {@link startsAtAnimate}, or its `initial` (own, else inherited) is the same name, list or values map
|
|
467
472
|
* as its `animate` (own, else inherited). Its first Retarget, landing with nothing to animate, is told
|
|
468
473
|
* to no one. Read once, untracked.
|
|
@@ -480,8 +485,14 @@ export const startsQuiet = (
|
|
|
480
485
|
return VariantTarget.sameLabels(initial as Config.WardicVariantLabels, animateOf(config, inherited, untrack) as Config.WardicVariantLabels)
|
|
481
486
|
}
|
|
482
487
|
|
|
488
|
+
/** What a Subject starts from, and the first of its variants whose resolver threw (#979). */
|
|
489
|
+
export interface Starting {
|
|
490
|
+
readonly values: Values.Values
|
|
491
|
+
readonly failure: Option.Option<VariantTarget.VariantFailure>
|
|
492
|
+
}
|
|
493
|
+
|
|
483
494
|
/**
|
|
484
|
-
* The values
|
|
495
|
+
* The values a Subject starts from, its Starting style's input (ADR-0003): its `initial` (own, else
|
|
485
496
|
* inherited, #50), or, when it {@link startsAtAnimate}, its `animate` (own, else inherited), as
|
|
486
497
|
* Motion's `initial={false}` (#134). Read once: an inherited name is read through `untrack`.
|
|
487
498
|
*/
|
|
@@ -490,11 +501,37 @@ export const startingValuesOf = (
|
|
|
490
501
|
inherited: WardicVariantContextValue | undefined,
|
|
491
502
|
presenceBlocks: boolean,
|
|
492
503
|
untrack: Reactivity.Reactivity["untrack"],
|
|
504
|
+
): Values.Values => startingValuesFrom(config, inherited, presenceBlocks, untrack, VariantTarget.startingVariantsOf(config.variants, config.custom).variants)
|
|
505
|
+
|
|
506
|
+
/**
|
|
507
|
+
* {@link startingValuesOf}, with what a resolver among the Subject's variants threw: its entry gives no
|
|
508
|
+
* values, and the Subject starts at the rest (#979).
|
|
509
|
+
*/
|
|
510
|
+
export const startingOf = (
|
|
511
|
+
config: VariantConfig,
|
|
512
|
+
inherited: WardicVariantContextValue | undefined,
|
|
513
|
+
presenceBlocks: boolean,
|
|
514
|
+
untrack: Reactivity.Reactivity["untrack"],
|
|
515
|
+
): Starting => {
|
|
516
|
+
const variants = VariantTarget.startingVariantsOf(config.variants, config.custom)
|
|
517
|
+
return { values: startingValuesFrom(config, inherited, presenceBlocks, untrack, variants.variants), failure: variants.failure }
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
/**
|
|
521
|
+
* {@link startingValuesOf} from its variants already resolved to values (`VariantTarget.startingVariantsOf`):
|
|
522
|
+
* what a Subject's start reads, which reads their failure too.
|
|
523
|
+
*/
|
|
524
|
+
export const startingValuesFrom = (
|
|
525
|
+
config: VariantConfig,
|
|
526
|
+
inherited: WardicVariantContextValue | undefined,
|
|
527
|
+
presenceBlocks: boolean,
|
|
528
|
+
untrack: Reactivity.Reactivity["untrack"],
|
|
529
|
+
variants: object | undefined,
|
|
493
530
|
): Values.Values => {
|
|
494
531
|
const atAnimate = startsAtAnimate(config, inherited, presenceBlocks)
|
|
495
532
|
const animate = animateOf(config, inherited, untrack)
|
|
496
533
|
const initial = initialOf(config, inherited)
|
|
497
|
-
// Per
|
|
534
|
+
// Per Subject at mount (#540): statements. Starting at `animate` resolves as `initial={false}`,
|
|
498
535
|
// and its first target is `animate`.
|
|
499
536
|
let from = initial
|
|
500
537
|
let first = initial
|
|
@@ -502,11 +539,11 @@ export const startingValuesOf = (
|
|
|
502
539
|
from = false
|
|
503
540
|
first = animate
|
|
504
541
|
}
|
|
542
|
+
// Dynamic variants resolved first (#277): `@wardic/dom`'s Starting style reads values maps only.
|
|
505
543
|
const values = Stops.resolveInitial({
|
|
506
544
|
initial: from,
|
|
507
545
|
animate,
|
|
508
|
-
|
|
509
|
-
variants: VariantTarget.startingVariantsOf(config.variants, config.custom) as Readonly<Record<string, object | undefined>> | undefined,
|
|
546
|
+
variants: variants as Readonly<Record<string, object | undefined>> | undefined,
|
|
510
547
|
})
|
|
511
548
|
// The first target's Transition end (#428, Motion's `makeLatestValues`): set at once, so a server
|
|
512
549
|
// renders it, and a hydration finds it.
|
|
@@ -517,7 +554,7 @@ export const startingValuesOf = (
|
|
|
517
554
|
}
|
|
518
555
|
|
|
519
556
|
/**
|
|
520
|
-
* A name
|
|
557
|
+
* A name a Subject hands its children (Motion's `getCurrentTreeVariants`): `own` if it names its own
|
|
521
558
|
* variants, else `fromParent` unless it sets `inherit={false}`.
|
|
522
559
|
*/
|
|
523
560
|
export const handedDown = <A extends Config.WardicVariantLabels | false>(config: VariantConfig, own: () => A | undefined, fromParent: () => A | undefined): A | undefined =>
|
|
@@ -526,11 +563,11 @@ export const handedDown = <A extends Config.WardicVariantLabels | false>(config:
|
|
|
526
563
|
onFalse: () => Bool.match(config.inherit === false, { onTrue: constUndefined, onFalse: fromParent }),
|
|
527
564
|
})
|
|
528
565
|
|
|
529
|
-
/**
|
|
566
|
+
/** A Subject's own transition, else the one it inherits. */
|
|
530
567
|
export const ownOrInherited = (own: Config.WardicTransition | undefined, inherited: WardicVariantContextValue | undefined): Config.WardicTransition | undefined =>
|
|
531
568
|
UndefinedOr.match(own, { onUndefined: () => UndefinedOr.map(inherited, (context) => context.transition()), onDefined: identity })
|
|
532
569
|
|
|
533
|
-
/** The stagger config
|
|
570
|
+
/** The stagger config a Subject's `transition` gives its Variant children. */
|
|
534
571
|
export const staggerOf = (transition: Config.WardicTransition | undefined): WardicStaggerConfig =>
|
|
535
572
|
UndefinedOr.match(transition, { onUndefined: () => staggerWith({}), onDefined: staggerWith })
|
|
536
573
|
|
|
@@ -554,18 +591,62 @@ export const directed = (index: number, total: number, direction: 1 | -1): numbe
|
|
|
554
591
|
return index
|
|
555
592
|
}
|
|
556
593
|
|
|
594
|
+
/**
|
|
595
|
+
* Where a stagger reports a `delayChildren` function that throws: the runtime it's reported on, and whether
|
|
596
|
+
* it's failing, so a run of throws is reported once. A Variant child's is its Subject's, for its life, its
|
|
597
|
+
* run ended by its next clean call. A presence's exit and a server's Appear timing make one for the event,
|
|
598
|
+
* `event`, whose first throw is reported whatever its other calls do.
|
|
599
|
+
*/
|
|
600
|
+
export interface DelayFailures {
|
|
601
|
+
delayFailing: boolean
|
|
602
|
+
readonly runtime: Pick<WardicServices.Runner<never>, "runFork">
|
|
603
|
+
readonly event?: true
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
/** The runtime a server render reports on: Effect's default, as a server holds no app reporters. */
|
|
607
|
+
export const ON_SERVER: Pick<WardicServices.Runner<never>, "runFork"> = { runFork: (effect) => Effect.runFork(effect) }
|
|
608
|
+
|
|
609
|
+
/** One exit's or one render's {@link DelayFailures}, reported on `runtime` at its first throw. */
|
|
610
|
+
export const eventDelayFailuresOf = (runtime: Pick<WardicServices.Runner<never>, "runFork">): DelayFailures => ({ delayFailing: false, runtime, event: true })
|
|
611
|
+
|
|
557
612
|
/**
|
|
558
613
|
* A child's delay in a stagger (ADR-0007): its `delayChildren` plus its place from the origin, turned
|
|
559
614
|
* by its `staggerDirection`. A function `delayChildren` (#436, Motion's `calcChildStagger`) decides it
|
|
560
|
-
* whole, from the child's index and the count
|
|
561
|
-
*
|
|
615
|
+
* whole, from the child's index and the count; one that throws gives the child no delay, reported on
|
|
616
|
+
* `failures` (on Effect's default runtime with none) at the first throw of a run of them. Every stagger,
|
|
617
|
+
* a Variant child's, a presence's exit's and a server's Appear timing, is placed by it.
|
|
562
618
|
*/
|
|
563
|
-
export const childDelayOf = (s: WardicStaggerConfig, index: number, total: number): number => {
|
|
564
|
-
if (Predicate.isFunction(s.delayChildren)) return s.delayChildren
|
|
619
|
+
export const childDelayOf = (s: WardicStaggerConfig, index: number, total: number, failures: DelayFailures | undefined): number => {
|
|
620
|
+
if (Predicate.isFunction(s.delayChildren)) return calledDelayOf(s.delayChildren, index, total, failures)
|
|
565
621
|
return s.delayChildren + Stagger.make(s.amount, { from: s.from })(directed(index, total, s.direction), total)
|
|
566
622
|
}
|
|
567
623
|
|
|
568
|
-
|
|
624
|
+
// #979 (ADR-0074, row 43, found by group H's probe): a `delayChildren` function is the app's, called at each
|
|
625
|
+
// child's Retarget, exit and Appear timing with no try. A throw halted Solid 2, came out of Solid 1's
|
|
626
|
+
// setter, and skipped Foldkit's later watches at a patch.
|
|
627
|
+
const DELAY_FAILED = "wardic.stagger: a delayChildren function failed"
|
|
628
|
+
|
|
629
|
+
/** `delayChildren` called for a child, a throw its child's: no delay, reported once a run on `failures`. */
|
|
630
|
+
// A child's run is its Subject's, whatever name it's staggered under: a parent's own transition staggers
|
|
631
|
+
// every name with one function, so a run kept by name would report it again for each. (The review's: a
|
|
632
|
+
// child staggered under two names at once, one function throwing and one not, is reported at each change.)
|
|
633
|
+
const calledDelayOf = (delayChildren: Config.WardicStagger, index: number, total: number, failures: DelayFailures | undefined): number => {
|
|
634
|
+
try {
|
|
635
|
+
const delay = delayChildren(index, total)
|
|
636
|
+
if (Predicate.isNotUndefined(failures) && failures.delayFailing && failures.event !== true) failures.delayFailing = false
|
|
637
|
+
return delay
|
|
638
|
+
} catch (defect) {
|
|
639
|
+
if (Predicate.isUndefined(failures)) {
|
|
640
|
+
Report.failureOn(undefined, DELAY_FAILED, Cause.die(defect), { index })
|
|
641
|
+
return 0
|
|
642
|
+
}
|
|
643
|
+
if (!failures.delayFailing) failures.runtime.runFork(Report.failure(DELAY_FAILED, Cause.die(defect)).pipe(Effect.annotateLogs({ index })))
|
|
644
|
+
failures.delayFailing = true
|
|
645
|
+
return 0
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
/** A name's orchestration (#297): its stagger config, and its own `when`, from its own transition, else the Subject's. */
|
|
569
650
|
export interface NameConfig {
|
|
570
651
|
readonly stagger: WardicStaggerConfig
|
|
571
652
|
readonly when: "beforeChildren" | "afterChildren" | undefined
|
|
@@ -593,7 +674,7 @@ export const staggerWith = ({ staggerChildren = 0, delayChildren = 0, from = "fi
|
|
|
593
674
|
export const sameStagger = (a: WardicStaggerConfig, b: WardicStaggerConfig): boolean =>
|
|
594
675
|
a.amount === b.amount && a.delayChildren === b.delayChildren && a.from === b.from && a.direction === b.direction
|
|
595
676
|
|
|
596
|
-
/** What
|
|
677
|
+
/** What a Subject provides when it has no variants of its own: its parent's context, unless `inherit={false}`. */
|
|
597
678
|
export const passedThrough = (
|
|
598
679
|
config: VariantConfig,
|
|
599
680
|
parent: WardicVariantContextValue | undefined,
|
|
@@ -607,7 +688,7 @@ export const INERT_REGISTRATION: WardicChildRegistration = Object.freeze({
|
|
|
607
688
|
dispose: () => {},
|
|
608
689
|
})
|
|
609
690
|
|
|
610
|
-
/**
|
|
691
|
+
/** A Subject's place in variant orchestration during a server render (ADR-0021). */
|
|
611
692
|
export interface ServerVariantNode {
|
|
612
693
|
/** What its children read: the same context the client builds, with inert orchestration. */
|
|
613
694
|
readonly provided: WardicVariantContextValue | undefined
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* What a `WardicConfig` gives the
|
|
2
|
+
* What a `WardicConfig` gives the Wards' Subjects below it (#434, Motion's `MotionConfig`), on
|
|
3
3
|
* every binding: its **Config transition**, its reduced motion and whether its
|
|
4
4
|
* animations are skipped (#468).
|
|
5
5
|
*
|
|
6
|
-
* - **The Config transition is
|
|
7
|
-
* `{ ...config, ...props }`: whatever reads the
|
|
6
|
+
* - **The Config transition is a Subject's own when it gives none,** as Motion's
|
|
7
|
+
* `{ ...config, ...props }`: whatever reads the Subject's `transition` reads it, a Variant child's in
|
|
8
8
|
* place of its parent's (Q3).
|
|
9
|
-
* - **Its reduced motion** (ADR-0029) is the
|
|
10
|
-
* reads its `MotionConfig`'s per
|
|
11
|
-
* - **`skipAnimations`** (#468) makes every animation of the
|
|
9
|
+
* - **Its reduced motion** (ADR-0029) is the Subject's, over the `WardicProvider`'s (Q2), as Motion
|
|
10
|
+
* reads its `MotionConfig`'s per Subject.
|
|
11
|
+
* - **`skipAnimations`** (#468) makes every animation of the Subjects below a **Skipped animation**,
|
|
12
12
|
* Motion's `MotionConfig` `skipAnimations`, whatever their reduced motion.
|
|
13
13
|
* - **`isValidProp`** (#443) keeps the props it says aren't valid from being passed on, Motion's
|
|
14
14
|
* `MotionConfig` `isValidProp`.
|
|
@@ -33,7 +33,7 @@ import * as VariantTarget from "./VariantTarget.ts"
|
|
|
33
33
|
|
|
34
34
|
/** What a `WardicConfig` gives below it (#434): one value per config, read where a binding reads it. */
|
|
35
35
|
export interface WardicConfigValue {
|
|
36
|
-
/** Its **Config transition**: read when
|
|
36
|
+
/** Its **Config transition**: read when a Subject's transition is, so a change starts nothing by itself. */
|
|
37
37
|
readonly transition: () => Config.WardicTransition | undefined
|
|
38
38
|
/**
|
|
39
39
|
* Its reduced motion (ADR-0029): its own, else an enclosing config's, else `undefined` for the
|
|
@@ -46,8 +46,8 @@ export interface WardicConfigValue {
|
|
|
46
46
|
*/
|
|
47
47
|
readonly skipAnimations: () => boolean | undefined
|
|
48
48
|
/**
|
|
49
|
-
* Which of
|
|
50
|
-
* own, else an enclosing config's, else `undefined`, every one. Read as each
|
|
49
|
+
* Which of a Ward's own props it passes on (#443, Motion's `MotionConfig` `isValidProp`): its
|
|
50
|
+
* own, else an enclosing config's, else `undefined`, every one. Read as each Subject is made.
|
|
51
51
|
*/
|
|
52
52
|
readonly isValidProp: () => ((key: string) => boolean) | undefined
|
|
53
53
|
/**
|
|
@@ -59,7 +59,7 @@ export interface WardicConfigValue {
|
|
|
59
59
|
|
|
60
60
|
/**
|
|
61
61
|
* A `WardicConfig`'s transition (#434): its own, laid over its parent's with `inherit: true` (as a
|
|
62
|
-
* variant's own is over the
|
|
62
|
+
* variant's own is over the Subject's), else its parent's when it gives none.
|
|
63
63
|
*/
|
|
64
64
|
export const configTransitionOf = (own: Config.WardicVariantTransition | undefined, parent: WardicConfigValue | undefined): Config.WardicTransition | undefined =>
|
|
65
65
|
VariantTarget.transitionOfTarget(own, parentTransitionOf(parent))
|
|
@@ -120,14 +120,14 @@ export const pointMapOptionOf = (read: () => Config.WardicTransformPoint | undef
|
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
-
/** The nearest config's `isValidProp` (#443), as
|
|
123
|
+
/** The nearest config's `isValidProp` (#443), as a Subject is made: `undefined` for none. */
|
|
124
124
|
export const isValidPropOf = (config: WardicConfigValue | undefined): ((key: string) => boolean) | undefined => {
|
|
125
125
|
if (Predicate.isUndefined(config)) return undefined
|
|
126
126
|
return config.isValidProp()
|
|
127
127
|
}
|
|
128
128
|
|
|
129
129
|
/**
|
|
130
|
-
* Whether
|
|
130
|
+
* Whether a Subject's animations are skipped (#468), read when each starts: its nearest config's
|
|
131
131
|
* `skipAnimations`. With no config above, never, and nothing made.
|
|
132
132
|
*/
|
|
133
133
|
export const skipAnimationsOf = (config: WardicConfigValue | undefined): (() => boolean) => {
|
|
@@ -135,7 +135,7 @@ export const skipAnimationsOf = (config: WardicConfigValue | undefined): (() =>
|
|
|
135
135
|
return () => config.skipAnimations() === true
|
|
136
136
|
}
|
|
137
137
|
|
|
138
|
-
/** The reduced motion
|
|
138
|
+
/** The reduced motion a Subject's nearest config sets (#434), now: `undefined` for none, the provider's. */
|
|
139
139
|
export const settingOf = (config: WardicConfigValue | undefined): ReducedMotion.Config | undefined => {
|
|
140
140
|
if (Predicate.isUndefined(config)) return undefined
|
|
141
141
|
return config.reducedMotion()
|