@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
package/src/internal/stepper.ts
CHANGED
|
@@ -42,8 +42,32 @@ export const durationOf = (duration: number): number => {
|
|
|
42
42
|
|
|
43
43
|
// --- Tween -------------------------------------------------------------------
|
|
44
44
|
|
|
45
|
+
/** A tween run's time, rewritten in place each tick (#895): a field, which V8 rewrites where it is. */
|
|
45
46
|
export interface TweenState {
|
|
46
|
-
|
|
47
|
+
elapsed: number
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** A run's own Frame, rewritten in place each tick (#895): a blend's and the keyframes step's, a tween's as a {@link TweenFrame}. */
|
|
51
|
+
export interface WritableFrame<A> {
|
|
52
|
+
value: A
|
|
53
|
+
done: boolean
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* A tween's own Frame, rewritten in place each tick: a class of its own, so no Frame whose `value` is a
|
|
58
|
+
* record shares its hidden class, and V8 keeps its `value` a number field it rewrites where it is. Its
|
|
59
|
+
* fields are assigned in the constructor, not declared with values: a field declared that way starts as
|
|
60
|
+
* `undefined`, and V8 would keep it able to hold anything, boxing each number stored in it.
|
|
61
|
+
*/
|
|
62
|
+
// #1031 (ADR-0030, *Amendment (#1031)*): as a `{ value, done }` literal it shared `blendedBy`'s Frame's hidden
|
|
63
|
+
// class, whose `value` is a record, so each frame's number was boxed into it, 16 B a Subject.
|
|
64
|
+
export class TweenFrame implements WritableFrame<number> {
|
|
65
|
+
declare value: number
|
|
66
|
+
declare done: boolean
|
|
67
|
+
constructor(value: number) {
|
|
68
|
+
this.value = value
|
|
69
|
+
this.done = false
|
|
70
|
+
}
|
|
47
71
|
}
|
|
48
72
|
|
|
49
73
|
/** A tween's options with every default filled in. */
|
|
@@ -102,19 +126,21 @@ export const resolveTween: (options: TweenOptions) => ResolvedTween = /*#__PURE_
|
|
|
102
126
|
|
|
103
127
|
export const initTween = (): TweenState => ({ elapsed: 0 })
|
|
104
128
|
|
|
105
|
-
/** One frame of a resolved tween. */
|
|
129
|
+
/** One frame of a resolved tween, into its run's `state` and `frame`: nothing made (#895). */
|
|
106
130
|
export const stepTween = (
|
|
107
131
|
state: TweenState,
|
|
132
|
+
frame: WritableFrame<number>,
|
|
108
133
|
dt: number,
|
|
109
134
|
from: number,
|
|
110
135
|
to: number,
|
|
111
136
|
tween: ResolvedTween,
|
|
112
|
-
):
|
|
137
|
+
): void => {
|
|
113
138
|
const elapsed = state.elapsed + dt
|
|
139
|
+
state.elapsed = elapsed
|
|
114
140
|
const active = Math.max(0, elapsed - tween.delay)
|
|
115
141
|
const t = Scalar.clamp(active / tween.duration, 0, 1)
|
|
116
|
-
|
|
117
|
-
|
|
142
|
+
frame.value = Scalar.lerp(from, to, tween.ease(t))
|
|
143
|
+
frame.done = elapsed >= tween.delay + tween.duration
|
|
118
144
|
}
|
|
119
145
|
|
|
120
146
|
// --- A run of repeats, and keyframes (#226) ----------------------------------
|
|
@@ -160,13 +186,14 @@ export interface Pass {
|
|
|
160
186
|
}
|
|
161
187
|
|
|
162
188
|
/**
|
|
163
|
-
* Where a run is `t` seconds in, by Motion's `JSAnimation` iteration math
|
|
189
|
+
* Where a run is `t` seconds in, by Motion's `JSAnimation` iteration math: every
|
|
164
190
|
* pass and every gap is a stretch of one time, so a pass starts the moment the one before it ends,
|
|
165
191
|
* wherever that falls in a tick (#226). A gap holds where its pass ended. Every other pass is
|
|
166
192
|
* turned by its `repeatType`, and `flip` (`reverse`) reads every pass's stops from last to first,
|
|
167
193
|
* Motion's mirrored generator (#429). Written into `pass`; whether the run has ended. Per frame
|
|
168
194
|
* (ADR-0025): arithmetic and statement `if`s.
|
|
169
195
|
*/
|
|
196
|
+
// `motion-dom` 13.3.0's `JSAnimation`.
|
|
170
197
|
export const passAt = (t: number, run: ResolvedRun, flip: boolean, pass: Pass): boolean => {
|
|
171
198
|
const cycle = run.cycle
|
|
172
199
|
const total = run.total
|
package/src/internal/tracing.ts
CHANGED
|
@@ -97,7 +97,7 @@ export const tracedScoped = <A, E, R>(
|
|
|
97
97
|
/**
|
|
98
98
|
* `self` under the span `name` when the fiber running it is traced and the app gives spans; as it is
|
|
99
99
|
* otherwise. Decided once, when the stream is run, and the pull handed on is `self`'s own: a
|
|
100
|
-
* `Stream.unwrap` here suspended every pull, per
|
|
100
|
+
* `Stream.unwrap` here suspended every pull, per stream per frame for a Stream consumer (+4–6% on
|
|
101
101
|
* Bun's `ticksOnly`). `Shape.tracedStream` hands `self` back untraced, which is how it's told.
|
|
102
102
|
*/
|
|
103
103
|
export const tracedStream = <A, E, R>(self: Stream.Stream<A, E, R>, name: string, options: Spans.Options = {}): Stream.Stream<A, E, R> => {
|
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* **Animation controls** (#433's PR 3, CONTEXT.md; Motion's `useAnimationControls`), on every binding:
|
|
3
|
-
* one object made outside any component and given as `animate={controls}` to any number of
|
|
4
|
-
*
|
|
3
|
+
* one object made outside any component and given as `animate={controls}` to any number of Wards'
|
|
4
|
+
* Subjects, which follow its calls.
|
|
5
5
|
*
|
|
6
|
-
* - **`start(definition, transitionOverride)`** sets each
|
|
6
|
+
* - **`start(definition, transitionOverride)`** sets each Subject's `animate` entry (a **Controls
|
|
7
7
|
* change**), so it Retargets, staggers its Variant children and lands as a change of the prop would.
|
|
8
|
-
* It resolves once each
|
|
9
|
-
* - The override is the transition of that change: it beats the definition's own on the
|
|
8
|
+
* It resolves once each Subject and the Variant children it hands its names to have landed.
|
|
9
|
+
* - The override is the transition of that change: it beats the definition's own on the Subject and
|
|
10
10
|
* on each Variant child, and it is their orchestration (stagger, `when`), as Motion's
|
|
11
11
|
* `transitionOverride` is.
|
|
12
12
|
* - Their next Retarget, a gesture's, runs on their own transitions again.
|
|
13
|
-
* - **`set(definition)`** is an **Instant change**: the
|
|
13
|
+
* - **`set(definition)`** is an **Instant change**: the Subjects and their Variant children
|
|
14
14
|
* snap there, as Motion's `setValues` sets them.
|
|
15
|
-
* - **`stop()`** ends each
|
|
15
|
+
* - **`stop()`** ends each Ward's running legs where they are.
|
|
16
16
|
*
|
|
17
|
-
* A function definition is called once per
|
|
18
|
-
* Motion's `controls.start((i) => …)
|
|
17
|
+
* A function definition is called once per Subject, with its `custom`, values and velocities, as
|
|
18
|
+
* Motion's `controls.start((i) => …)`, every Subject's before any is set: one that throws for a Subject
|
|
19
|
+
* refuses the call, taking nothing. A Subject hears the controls from its mount to its unmount.
|
|
19
20
|
*
|
|
20
21
|
* Unstable, for Wardic's own packages: public, with no semver promise.
|
|
21
22
|
*
|
|
@@ -39,32 +40,34 @@ declare const queueMicrotask: (callback: () => void) => void
|
|
|
39
40
|
export type { WardicAnimationControls, WardicControlsDefinition } from "./Config.ts"
|
|
40
41
|
|
|
41
42
|
/**
|
|
42
|
-
* A **Controls change** (#433): what one `start` or `set` set one
|
|
43
|
-
* transition it runs on, and the landings it waits for. The
|
|
43
|
+
* A **Controls change** (#433): what one `start` or `set` set one Subject's `animate` entry to, the
|
|
44
|
+
* transition it runs on, and the landings it waits for. The Subject and each Variant child it reaches
|
|
44
45
|
* join it at the Retarget it makes them run, and leave at that one's landing (or the next's).
|
|
45
46
|
*/
|
|
46
47
|
export interface ControlsChange {
|
|
47
48
|
/** Its place among every change: a trigger key part, so a change is a trigger even to the same name. */
|
|
48
49
|
readonly serial: number
|
|
49
|
-
/** The
|
|
50
|
+
/** The Subject's `animate` entry: a target or a name, a resolver already called. */
|
|
50
51
|
readonly definition: Config.WardicVariant | Config.WardicVariantLabels
|
|
51
|
-
/** The transition of the change (start's override, set's instant one), or none: the
|
|
52
|
+
/** The transition of the change (start's override, set's instant one), or none: the Subject's own. */
|
|
52
53
|
readonly override: Config.WardicTransition | undefined
|
|
53
|
-
/**
|
|
54
|
+
/** Subjects in it that haven't landed. */
|
|
54
55
|
pending: number
|
|
55
|
-
/** Whether every
|
|
56
|
+
/** Whether every Subject it reaches has had its chance to join: its binding's flush has run. */
|
|
56
57
|
armed: boolean
|
|
57
58
|
/** Told once it has landed. */
|
|
58
59
|
readonly landed: () => void
|
|
59
60
|
}
|
|
60
61
|
|
|
61
|
-
/** What a controlled
|
|
62
|
+
/** What a controlled Subject does at a change, as its binding wires it: its entry worked out, then set, and the change's landing promised. */
|
|
62
63
|
export interface Controlled {
|
|
63
|
-
|
|
64
|
+
/** Its entry for `definition`: a function definition called with its `custom`, values and velocities; anything else as it is. */
|
|
65
|
+
readonly entryOf: (definition: Config.WardicControlsDefinition) => Config.WardicVariant | Config.WardicVariantLabels
|
|
66
|
+
readonly change: (entry: Config.WardicVariant | Config.WardicVariantLabels, override: Config.WardicTransition | undefined) => Promise<void>
|
|
64
67
|
readonly stop: () => void
|
|
65
68
|
}
|
|
66
69
|
|
|
67
|
-
/** The
|
|
70
|
+
/** The Subjects each controls reach, by the controls. */
|
|
68
71
|
// Module state (#460, Q7): each controls object's subscribers, held weakly by it.
|
|
69
72
|
const subscribers = new WeakMap<Config.WardicAnimationControls, Set<Controlled>>()
|
|
70
73
|
|
|
@@ -72,28 +75,43 @@ const subscribers = new WeakMap<Config.WardicAnimationControls, Set<Controlled>>
|
|
|
72
75
|
export const INSTANT: Config.WardicTransition = { type: "tween", duration: 0 }
|
|
73
76
|
|
|
74
77
|
/**
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
|
|
78
|
+
* Each Subject's entry for `definition`, worked out before any is set: a function definition that throws
|
|
79
|
+
* for one refuses the call, taking nothing, as an `animate()` call refuses one.
|
|
80
|
+
*/
|
|
81
|
+
// #979 (ADR-0074, row 35): `start` and `set` set each Subject's entry as they called its function, so one
|
|
82
|
+
// that threw for a later Subject left the earlier ones changed and the rest unreached, as #986's row 20.
|
|
83
|
+
const entriesOf = (reachedNow: ReadonlyArray<Controlled>, definition: Config.WardicControlsDefinition): ReadonlyArray<Config.WardicVariant | Config.WardicVariantLabels> =>
|
|
84
|
+
Arr.map(reachedNow, (controlled) => controlled.entryOf(definition))
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Makes animation controls, which animate Subjects from code by their variants or targets: a binding
|
|
88
|
+
* gives them to each Subject as its `animate`, then `start`, `set` or `stop` them. Needs no owner.
|
|
89
|
+
* Motion's `useAnimationControls`.
|
|
78
90
|
*
|
|
79
91
|
* @example
|
|
80
92
|
* const controls = createAnimationControls()
|
|
81
|
-
*
|
|
93
|
+
* // A binding gives `controls` to each Subject as its `animate`.
|
|
82
94
|
* await controls.start("visible")
|
|
83
|
-
* @see https://wardic.dev/reference/solid/animation/create-animation-controls
|
|
84
95
|
*/
|
|
85
|
-
// #433's PR 3: each `start` or `set` is a Controls change of each
|
|
96
|
+
// #433's PR 3: each `start` or `set` is a Controls change of each Subject's `animate` entry. Solid's
|
|
97
|
+
// export declares its own doc, with its markup (#1053).
|
|
86
98
|
export const createAnimationControls = (): Config.WardicAnimationControls => {
|
|
87
99
|
const reached = new Set<Controlled>()
|
|
88
100
|
const controls: Config.WardicAnimationControls = {
|
|
89
101
|
[Config.CONTROLS]: true,
|
|
90
|
-
start: (definition, transitionOverride) =>
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
102
|
+
start: (definition, transitionOverride) => {
|
|
103
|
+
const reachedNow = Arr.fromIterable(reached)
|
|
104
|
+
const entries = entriesOf(reachedNow, definition)
|
|
105
|
+
return Promise.all(Arr.zipWith(reachedNow, entries, (controlled, entry) => controlled.change(entry, transitionOverride))).then(() => undefined)
|
|
106
|
+
},
|
|
107
|
+
set: (definition) => {
|
|
108
|
+
const reachedNow = Arr.fromIterable(reached)
|
|
109
|
+
const entries = entriesOf(reachedNow, definition)
|
|
110
|
+
Arr.forEach(Arr.zip(reachedNow, entries), ([controlled, entry]) => {
|
|
111
|
+
void controlled.change(entry, INSTANT)
|
|
112
|
+
})
|
|
113
|
+
},
|
|
114
|
+
stop: () => reached.forEach((controlled) => controlled.stop()),
|
|
97
115
|
}
|
|
98
116
|
subscribers.set(controls, reached)
|
|
99
117
|
return controls
|
|
@@ -102,17 +120,17 @@ export const createAnimationControls = (): Config.WardicAnimationControls => {
|
|
|
102
120
|
/** Whether `u` is **Animation controls** (Motion's `isAnimationControls`). */
|
|
103
121
|
export const isAnimationControls = (u: unknown): u is Config.WardicAnimationControls => Predicate.hasProperty(u, Config.CONTROLS)
|
|
104
122
|
|
|
105
|
-
/**
|
|
123
|
+
/** A Subject's `animate` as **Animation controls**, when it is them: what a binding reads once at its mount (#798); `undefined` for a target or a name. */
|
|
106
124
|
export const controlsOf = (animate: unknown): Config.WardicAnimationControls | undefined =>
|
|
107
125
|
Bool.match(isAnimationControls(animate), { onTrue: () => animate as Config.WardicAnimationControls, onFalse: constUndefined })
|
|
108
126
|
|
|
109
|
-
/** Reach `
|
|
110
|
-
export const subscribe = (controls: Config.WardicAnimationControls,
|
|
127
|
+
/** Reach `controlled` from `controls`, until the returned function: its mount to its unmount. */
|
|
128
|
+
export const subscribe = (controls: Config.WardicAnimationControls, controlled: Controlled): (() => void) => {
|
|
111
129
|
const reached = subscribers.get(controls)
|
|
112
130
|
if (Predicate.isUndefined(reached)) return () => undefined
|
|
113
|
-
reached.add(
|
|
131
|
+
reached.add(controlled)
|
|
114
132
|
return () => {
|
|
115
|
-
reached.delete(
|
|
133
|
+
reached.delete(controlled)
|
|
116
134
|
}
|
|
117
135
|
}
|
|
118
136
|
|
|
@@ -121,49 +139,61 @@ export const subscribe = (controls: Config.WardicAnimationControls, element: Con
|
|
|
121
139
|
let serials = 0
|
|
122
140
|
|
|
123
141
|
/**
|
|
124
|
-
* A
|
|
125
|
-
*
|
|
126
|
-
* lands once every element it reaches has joined, at the end of the binding's flush (`armed`), and
|
|
127
|
-
* left. One that reaches no element lands then.
|
|
142
|
+
* A Subject's entry for `definition`: a resolver called with its `custom`, values and velocities (once,
|
|
143
|
+
* as Motion's), anything else as it is.
|
|
128
144
|
*/
|
|
129
|
-
|
|
145
|
+
// #433; #979 (row 35): worked out for every Subject before any is set.
|
|
146
|
+
export const entryOf = (
|
|
130
147
|
definition: Config.WardicControlsDefinition,
|
|
131
|
-
override: Config.WardicTransition | undefined,
|
|
132
148
|
custom: unknown,
|
|
133
149
|
values: Readonly<Record<string, number | string>>,
|
|
134
150
|
velocities: Readonly<Record<string, number>>,
|
|
151
|
+
): Config.WardicVariant | Config.WardicVariantLabels =>
|
|
152
|
+
Bool.match(Predicate.isFunction(definition), {
|
|
153
|
+
onTrue: () => (definition as Config.WardicVariantResolver)(custom, { ...values }, { ...velocities }),
|
|
154
|
+
onFalse: () => definition as Config.WardicVariant | Config.WardicVariantLabels,
|
|
155
|
+
})
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* A change of one Subject: its entry, on `override`, and its landing, promised. It lands once every
|
|
159
|
+
* Subject it reaches has joined, at the end of the binding's flush (`armed`), and left. One that reaches
|
|
160
|
+
* no Subject lands then.
|
|
161
|
+
*/
|
|
162
|
+
// #433.
|
|
163
|
+
export const changeOf = (
|
|
164
|
+
entry: Config.WardicVariant | Config.WardicVariantLabels,
|
|
165
|
+
override: Config.WardicTransition | undefined,
|
|
135
166
|
): { readonly change: ControlsChange; readonly landing: Promise<void> } => {
|
|
167
|
+
// The landing's resolver, set as the promise is made: its executor runs at once, so it's set before it's read,
|
|
168
|
+
// never missing, and needs no Option. `Promise.withResolvers` would say so; it's ES2024, and core builds against
|
|
169
|
+
// ES2022 (#1053, Q18).
|
|
136
170
|
let resolve!: () => void
|
|
137
171
|
const landing = new Promise<void>((done) => {
|
|
138
172
|
resolve = done
|
|
139
173
|
})
|
|
140
|
-
const entry = Bool.match(Predicate.isFunction(definition), {
|
|
141
|
-
onTrue: () => (definition as Config.WardicVariantResolver)(custom, { ...values }, { ...velocities }),
|
|
142
|
-
onFalse: () => definition as Config.WardicVariant | Config.WardicVariantLabels,
|
|
143
|
-
})
|
|
144
174
|
const change: ControlsChange = { serial: ++serials, definition: entry, override, pending: 0, armed: false, landed: resolve }
|
|
145
175
|
return { change, landing }
|
|
146
176
|
}
|
|
147
177
|
|
|
148
|
-
/**
|
|
178
|
+
/** A Subject joins `change`: it runs a Retarget for it. */
|
|
149
179
|
export const join = (change: ControlsChange): void => {
|
|
150
180
|
change.pending++
|
|
151
181
|
}
|
|
152
182
|
|
|
153
|
-
/**
|
|
183
|
+
/** A Subject in `change` landed, or left it (a later change, its unmount): it lands once none is left and it's armed. */
|
|
154
184
|
export const leave = (change: ControlsChange): void => {
|
|
155
185
|
change.pending--
|
|
156
186
|
if (change.armed && change.pending <= 0) change.landed()
|
|
157
187
|
}
|
|
158
188
|
|
|
159
|
-
/** `change` armed, its binding's flush having run: it lands now if no
|
|
189
|
+
/** `change` armed, its binding's flush having run: it lands now if no Subject joined, or all have left. */
|
|
160
190
|
export const arm = (change: ControlsChange): void => {
|
|
161
191
|
change.armed = true
|
|
162
192
|
if (change.pending <= 0) change.landed()
|
|
163
193
|
}
|
|
164
194
|
|
|
165
195
|
/**
|
|
166
|
-
*
|
|
196
|
+
* A Subject's config with **Animation controls** for its `animate` (#433), as everything but its
|
|
167
197
|
* controls reads it: `change`'s entry (none before the first), and marked controlled, so it names its
|
|
168
198
|
* own variants whatever the entry is (Motion's `isControllingVariants`).
|
|
169
199
|
*/
|
|
@@ -174,14 +204,14 @@ export const controlledConfigOf = <C extends Pick<Config.SpineConfig, "animate">
|
|
|
174
204
|
export const uncontrolledOf = <C extends Pick<Config.SpineConfig, "animate">>(config: C): C =>
|
|
175
205
|
Bool.match(isAnimationControls(config.animate), { onTrue: () => controlledConfigOf(config, undefined), onFalse: () => config })
|
|
176
206
|
|
|
177
|
-
/** What a controlled
|
|
207
|
+
/** What a controlled Subject reads at a change: its `custom`, and its values and velocities now (its Snapshot). */
|
|
178
208
|
export interface ControlledState {
|
|
179
209
|
readonly custom: () => unknown
|
|
180
210
|
/** Its Snapshot: its values, and its velocities now (#663), a spring leg's being on its Frame. */
|
|
181
211
|
readonly snapshot: ControlledSnapshot
|
|
182
212
|
}
|
|
183
213
|
|
|
184
|
-
/** What Animation controls read of
|
|
214
|
+
/** What Animation controls read of a Ward's Snapshot: its values, and its velocities now (#663). */
|
|
185
215
|
// #672: the controls name what they read, so they import nothing of the spine, whose Snapshot meets it.
|
|
186
216
|
export interface ControlledSnapshot {
|
|
187
217
|
readonly values: Values.Values
|
|
@@ -189,13 +219,14 @@ export interface ControlledSnapshot {
|
|
|
189
219
|
}
|
|
190
220
|
|
|
191
221
|
/**
|
|
192
|
-
* A mounted
|
|
222
|
+
* A mounted Subject as its controls reach it (#433): a change sets its entry through `setChange`, its
|
|
193
223
|
* binding's signal, and arms once the binding's flush has run (a microtask after, Solid 2's included),
|
|
194
|
-
* every
|
|
224
|
+
* every Subject it reaches joined by then; `stop` ends its legs.
|
|
195
225
|
*/
|
|
196
|
-
export const
|
|
197
|
-
|
|
198
|
-
|
|
226
|
+
export const controlledSubject = (setChange: (change: ControlsChange) => void, state: ControlledState, stop: () => void): Controlled => ({
|
|
227
|
+
entryOf: (definition) => entryOf(definition, state.custom(), state.snapshot.values, state.snapshot.velocitiesNow(state.snapshot)),
|
|
228
|
+
change: (entry, override) => {
|
|
229
|
+
const made = changeOf(entry, override)
|
|
199
230
|
setChange(made.change)
|
|
200
231
|
queueMicrotask(() => arm(made.change))
|
|
201
232
|
return made.landing
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* A Subject's mount animation as both sides describe it, and its **Handoff** as the spine reads it
|
|
3
3
|
* (#48, ADR-0044): how far in its first legs start, from where its Appear animation has got. Its
|
|
4
4
|
* binding samples a server's and finds a client's.
|
|
5
5
|
*
|
|
@@ -16,15 +16,15 @@ import * as UndefinedOr from "effect/UndefinedOr"
|
|
|
16
16
|
import type * as Config from "./Config.ts"
|
|
17
17
|
import * as RetargetLegs from "./RetargetLegs.ts"
|
|
18
18
|
|
|
19
|
-
/**
|
|
19
|
+
/** A Subject's mount animation, described the same on the server and the client. */
|
|
20
20
|
export interface MountAnimation {
|
|
21
|
-
/** The
|
|
21
|
+
/** The Subject's tag, by which its Environment routes some keys; `undefined` for a Subject whose tag isn't known. */
|
|
22
22
|
readonly tag: string | undefined
|
|
23
23
|
/** Each animated key's start. */
|
|
24
24
|
readonly from: Values.Values
|
|
25
25
|
/** Each animated key's target. */
|
|
26
26
|
readonly to: Values.Values
|
|
27
|
-
/** The
|
|
27
|
+
/** The Subject's own transition: its stagger isn't in it (ADR-0007). */
|
|
28
28
|
readonly transition: Config.WardicTransition | undefined
|
|
29
29
|
/** Whether reduced motion is on for it (ADR-0029). */
|
|
30
30
|
readonly reduced: boolean
|
|
@@ -37,11 +37,18 @@ export interface MountAnimation {
|
|
|
37
37
|
readonly stops?: RetargetLegs.StopsByKey | undefined
|
|
38
38
|
/**
|
|
39
39
|
* Whether it's a **Skipped animation** (#468): every key lands on its first frame, so its Appear
|
|
40
|
-
* animation takes 0 s, holding its end from first
|
|
40
|
+
* animation takes 0 s, holding its end from the first frame drawn. Part of its key; left out when it isn't.
|
|
41
41
|
*/
|
|
42
42
|
readonly skipped?: boolean | undefined
|
|
43
43
|
/** Its **Transform template** (#443): its stops drawn through it, as the client draws them. Left out with none. */
|
|
44
44
|
readonly template?: Config.SpineConfig["transformTemplate"]
|
|
45
|
+
/**
|
|
46
|
+
* Each key already at its target, which it leaves where it is, at its value, as the client writes it
|
|
47
|
+
* beside the moving keys: its Environment may draw some of them together with those in each stop.
|
|
48
|
+
* Part of its key when it draws any; none, or an empty one, holds nothing.
|
|
49
|
+
*/
|
|
50
|
+
// #1004 (ADR-0044, *Amendment (#1004)*).
|
|
51
|
+
readonly held?: Values.Values | undefined
|
|
45
52
|
}
|
|
46
53
|
|
|
47
54
|
/** Whether a transition repeats for ever: a tween's `repeat: Infinity`, a tween as it runs (ADR-0051). */
|
|
@@ -63,7 +70,7 @@ const heldInAppear = (transition: Config.WardicTransition | undefined): number =
|
|
|
63
70
|
/** A mount animation's `skipped` (#468): left out when it isn't, so its key is as before. */
|
|
64
71
|
export const skippedField = (skipped: boolean): { readonly skipped?: true } => Bool.match(skipped, { onTrue: () => ({ skipped: true }) as const, onFalse: () => ({}) })
|
|
65
72
|
|
|
66
|
-
/**
|
|
73
|
+
/** A Subject's Appear animation, found at mount: the spine starts its first legs as far in as it has got. */
|
|
67
74
|
export interface Handoff {
|
|
68
75
|
/** How far its animation has run, in seconds (its delay included). */
|
|
69
76
|
readonly elapsed: () => number
|
|
@@ -93,7 +93,7 @@ const snapAfter = (delay: number): Batch.Transition => {
|
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
/**
|
|
96
|
-
* A Default transition held by a key's own `delay`, as a
|
|
96
|
+
* A Default transition held by a key's own `delay`, as a Ward's Subject's is when its transition gives
|
|
97
97
|
* only a delay (ADR-0051): one object for each transition and delay, so the members on it share it.
|
|
98
98
|
*/
|
|
99
99
|
// Module state (#460, Q7): a cache held weakly by the object it's for, so it goes with it.
|
|
@@ -115,8 +115,8 @@ export const delayedBy = (transition: Batch.Transition, delay: number): Batch.Tr
|
|
|
115
115
|
|
|
116
116
|
/**
|
|
117
117
|
* A transition without a `stagger()` delay, which a change gives each member by its place: one object
|
|
118
|
-
* each. A `delay` in seconds stays, held by the keys the transition's own fields reach, as a
|
|
119
|
-
*
|
|
118
|
+
* each. A `delay` in seconds stays, held by the keys the transition's own fields reach, as a Ward's
|
|
119
|
+
* Subject's top-level delay is.
|
|
120
120
|
*/
|
|
121
121
|
// Module state (#460, Q7): a cache held weakly by the object it's for, so it goes with it.
|
|
122
122
|
const UNSTAGGERED = new WeakMap<object, Config.WardicTransition>()
|
|
@@ -152,7 +152,7 @@ export interface KeyPlan {
|
|
|
152
152
|
}
|
|
153
153
|
|
|
154
154
|
/**
|
|
155
|
-
* Each key's plan for a change, by its index, as a
|
|
155
|
+
* Each key's plan for a change, by its index, as a Ward's Subject's keys run (#301): its entry, else
|
|
156
156
|
* `default`, else the transition's own fields; reduced motion's Snap for a positional key that doesn't
|
|
157
157
|
* opt out; its Default transition, held by its own `delay`, for a key whose transition isn't defined.
|
|
158
158
|
*/
|
|
@@ -390,7 +390,7 @@ export const isMember: Predicate.Refinement<unknown, Imperative.BatchMember> = /
|
|
|
390
390
|
/**
|
|
391
391
|
* A compiled sequence's parts (Q40): each Batch's members as one part, in the order they first appear,
|
|
392
392
|
* with their animations; every other subject as it is. `restOf` gives what of a member's animation its
|
|
393
|
-
* Subject takes itself (
|
|
393
|
+
* Subject takes itself (`@wardic/dom`'s member's own keys the Batch doesn't draw), when it takes any.
|
|
394
394
|
*/
|
|
395
395
|
export const sequencePartsOf = <X, S>(
|
|
396
396
|
compiled: ReadonlyArray<readonly [X | Imperative.BatchMember, Sequence.Animation]>,
|
package/src/unstable/Config.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The config types a binding's
|
|
2
|
+
* The config types a binding's Subjects and the spine share, each built on {@link ValueKeys}: the keys
|
|
3
3
|
* an Environment animates and the values each takes. Empty here, `ValueKeys` is filled by the
|
|
4
4
|
* Environment's binding types (`@wardic/dom/unstable/WardConfig` fills it), so each type keeps its
|
|
5
5
|
* name and its shape whatever fills it.
|
|
@@ -52,7 +52,7 @@ export type WardicStagger = (index: number, total: number) => number
|
|
|
52
52
|
|
|
53
53
|
/**
|
|
54
54
|
* A path for `x` and `y` to travel along together: from where they start to where they end, the point
|
|
55
|
-
* at each progress, 0 to 1, with a turn (`rotate`, in degrees) for one that turns the
|
|
55
|
+
* at each progress, 0 to 1, with a turn (`rotate`, in degrees) for one that turns the Subject. `arc()`
|
|
56
56
|
* makes one; any function of this shape is one, a curve of your own.
|
|
57
57
|
*/
|
|
58
58
|
// A Path (#438).
|
|
@@ -144,14 +144,14 @@ export interface WardicSkipAnimations {
|
|
|
144
144
|
* An axis the target leaves out ends where it rests (#574): where a Path in flight was taking it, so
|
|
145
145
|
* one caught mid-air curves back to its line, else where it is.
|
|
146
146
|
* A layout animation reads it where Motion's does, on its layout transition: the `layout` entry when
|
|
147
|
-
* there is one, else the
|
|
147
|
+
* there is one, else the Subject's transition. On any other value's entry it isn't read.
|
|
148
148
|
*/
|
|
149
149
|
export interface WardicTransitionPath {
|
|
150
150
|
readonly path?: WardicPath
|
|
151
151
|
}
|
|
152
152
|
|
|
153
153
|
/**
|
|
154
|
-
* How
|
|
154
|
+
* How a Subject gets to its target: a spring, a tween, or an inertia, with a value's own transition
|
|
155
155
|
* under its name. With no `type`, a spring field (`stiffness`, `damping`, `mass`, `velocity`,
|
|
156
156
|
* `restDelta`, `restSpeed`, `bounce`, `visualDuration`) makes it a spring, and anything else a tween, so
|
|
157
157
|
* `{ duration: 0.5 }` is a 0.5 s tween. A spring's missing fields are Motion's 100 / 10 / 1, or set by
|
|
@@ -167,7 +167,7 @@ export interface WardicTransitionPath {
|
|
|
167
167
|
export type WardicTransition = WardicTransitionWith<WardicTransitionEntries>
|
|
168
168
|
|
|
169
169
|
/**
|
|
170
|
-
* A transition with the entries `E` (#301): {@link WardicTransition}'s two arms. A
|
|
170
|
+
* A transition with the entries `E` (#301): {@link WardicTransition}'s two arms. A Ward's Subject's
|
|
171
171
|
* config checks each transition in it against the entries its keys allow (`WardChecked`).
|
|
172
172
|
*/
|
|
173
173
|
export type WardicTransitionWith<E> =
|
|
@@ -198,7 +198,7 @@ export type WardicValueKey = Exclude<keyof ValueKeys & string, "transition">
|
|
|
198
198
|
|
|
199
199
|
/**
|
|
200
200
|
* A transition's per-value entries: a value's own transition under its name, `default` for every value
|
|
201
|
-
* without one, and `layout` for the
|
|
201
|
+
* without one, and `layout` for the Subject's layout animations. A value runs on its entry, else
|
|
202
202
|
* `default`, else the transition's own fields. Motion's `TransitionWithValueOverrides`.
|
|
203
203
|
*/
|
|
204
204
|
// #301; `layout`, ADR-0009 *Amendment (#171)*: a layout animation on `layout`, else `default`, else the
|
|
@@ -227,7 +227,7 @@ export type WardicTransitionFor<K extends string> = WardicTransitionWith<WardicV
|
|
|
227
227
|
|
|
228
228
|
/**
|
|
229
229
|
* A variant's own transition, or a target's: it runs the animation that variant starts, in place of
|
|
230
|
-
* the
|
|
230
|
+
* the Subject's `transition`, unless `inherit: true` lays it over the Subject's, its own fields winning.
|
|
231
231
|
* Motion's.
|
|
232
232
|
*/
|
|
233
233
|
// #277, ADR-0048.
|
|
@@ -236,7 +236,7 @@ export type WardicVariantTransition = WardicTransition & WardicInherit
|
|
|
236
236
|
/**
|
|
237
237
|
* A target's **Transition end** (Motion's `transitionEnd`): values set at once, with no
|
|
238
238
|
* animation, once the keys the target animates have landed. Its keys are the target's, so they return to their base when it's no longer active;
|
|
239
|
-
* a target interrupted before it lands never sets them; the target
|
|
239
|
+
* a target interrupted before it lands never sets them; the target a Subject renders first sets its
|
|
240
240
|
* own at once, on a server too.
|
|
241
241
|
*/
|
|
242
242
|
export type WardicTransitionEnd = Omit<ValueKeys, "transition">
|
|
@@ -255,15 +255,20 @@ export type WardicVariant =
|
|
|
255
255
|
* Variant names (Motion's `VariantLabels`): one name, or a list of them. A list merges its
|
|
256
256
|
* names' values in order, a later name's winning a key both set. Each key animates on the own
|
|
257
257
|
* transition of the last name that sets it, and each name orchestrates the keys it sets in the
|
|
258
|
-
*
|
|
258
|
+
* Subject's Variant children. An empty list is no name.
|
|
259
259
|
*/
|
|
260
260
|
export type WardicVariantLabels = string | ReadonlyArray<string>
|
|
261
261
|
|
|
262
262
|
/**
|
|
263
263
|
* A dynamic variant (Motion's `TargetResolver`): called each time the variant is
|
|
264
|
-
* resolved with the
|
|
264
|
+
* resolved with the Subject's `custom` (or, for an exit, its `<AnimatePresence custom>`), its values
|
|
265
265
|
* now and their velocities, and returns its target, or another variant's name.
|
|
266
|
+
*
|
|
267
|
+
* One that throws is reported, and only its Subject is affected: it keeps its last target until the
|
|
268
|
+
* variant resolves, leaves without that exit, or starts without that variant's values.
|
|
266
269
|
*/
|
|
270
|
+
// #979 (group F; ADR-0074, ADR-0007's Amendment): core's one call site catches it, and the failure
|
|
271
|
+
// travels as the target's value, so no binding's update sees the throw.
|
|
267
272
|
export type WardicVariantResolver = (
|
|
268
273
|
// Motion's `custom` is `any`: a resolver declares its own (`(direction: number) => …`).
|
|
269
274
|
custom: any,
|
|
@@ -274,28 +279,29 @@ export type WardicVariantResolver = (
|
|
|
274
279
|
/** Named targets, each a target or a {@link WardicVariantResolver}. */
|
|
275
280
|
export type WardicVariants = Readonly<Record<string, WardicVariant | WardicVariantResolver>>
|
|
276
281
|
|
|
277
|
-
/** What controls start or set
|
|
282
|
+
/** What controls start or set a Subject to: a target, a variant name or a list of them, or a function of each Subject's `custom`. Motion's `AnimationDefinition`. */
|
|
278
283
|
export type WardicControlsDefinition = WardicVariant | WardicVariantLabels | WardicVariantResolver
|
|
279
284
|
|
|
280
285
|
/** The mark that tells controls from a target. */
|
|
281
286
|
export const CONTROLS: unique symbol = Symbol("wardic.animationControls")
|
|
282
287
|
|
|
283
288
|
/**
|
|
284
|
-
* `createAnimationControls()`'s controls: give them as `animate={controls}`, and every
|
|
289
|
+
* `createAnimationControls()`'s controls: give them as `animate={controls}`, and every Subject given
|
|
285
290
|
* them follows `start`, `set` and `stop`. Motion's `LegacyAnimationControls`.
|
|
286
291
|
*/
|
|
287
292
|
// #433.
|
|
288
293
|
export interface WardicAnimationControls {
|
|
289
294
|
readonly [CONTROLS]: true
|
|
290
295
|
/**
|
|
291
|
-
* Animates every
|
|
296
|
+
* Animates every Subject given these controls to `definition`, as a change of its `animate` would,
|
|
292
297
|
* its variant children following. `transitionOverride`, when given, is the transition of this change,
|
|
293
|
-
* over the definition's own, and its stagger. Resolves once each
|
|
298
|
+
* over the definition's own, and its stagger. Resolves once each Subject and its children have landed.
|
|
299
|
+
* A function definition that throws for one Subject refuses the call, throwing, with no Subject changed.
|
|
294
300
|
*/
|
|
295
301
|
readonly start: (definition: WardicControlsDefinition, transitionOverride?: WardicTransition) => Promise<void>
|
|
296
|
-
/** Sets every
|
|
302
|
+
/** Sets every Subject given these controls, and its variant children, at `definition` at once; refused, with none set, as `start` is. */
|
|
297
303
|
readonly set: (definition: WardicControlsDefinition) => void
|
|
298
|
-
/** Ends every
|
|
304
|
+
/** Ends every Subject's running animation where it is. */
|
|
299
305
|
readonly stop: () => void
|
|
300
306
|
}
|
|
301
307
|
|
|
@@ -312,7 +318,7 @@ export type WardicAnimationDefinition = WardicVariantLabels | ValueKeys
|
|
|
312
318
|
export type WardicTransformPoint = (point: { readonly x: number; readonly y: number }) => { readonly x: number; readonly y: number }
|
|
313
319
|
|
|
314
320
|
/**
|
|
315
|
-
* What the spine reads of
|
|
321
|
+
* What the spine reads of a Ward's config: its start, its targets, variants and transitions, each
|
|
316
322
|
* gesture's target, its layout, and the callbacks it tells. Every binding's config extends it, with
|
|
317
323
|
* its Environment's own props beside.
|
|
318
324
|
*/
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The late-frame rule's reader of the Frame loop's ticks, for a run that keeps the rule for each thing it
|
|
3
|
+
* moves, each begun at its own time: a long task delays a frame, whose dt then holds the task's time, and a
|
|
4
|
+
* thing begun in that task, or in the late frame after its tick, takes none of it. The loop carries its
|
|
5
|
+
* `Reader`: what one made now owes, and the dt of each of its steps while it owes one. A loop that carries
|
|
6
|
+
* none (a test's own) is read with `owingNothing`, under which nothing owes.
|
|
7
|
+
*
|
|
8
|
+
* Unstable, for Wardic's own packages: public, with no semver promise.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* import * as FirstSteps from "@wardic/core/unstable/FirstSteps"
|
|
12
|
+
* import * as Option from "effect/Option"
|
|
13
|
+
*
|
|
14
|
+
* const ticks = Option.getOrElse(FirstSteps.readerOf(loop), () => FirstSteps.owingNothing)
|
|
15
|
+
* // A thing made now: what it owes.
|
|
16
|
+
* let owed = ticks.madeOwing()
|
|
17
|
+
* // A step of it at the tick's `dt`, while it owes: its own dt, and what it owes after.
|
|
18
|
+
* const own = ticks.owingDt(owed, dt)
|
|
19
|
+
* owed = ticks.owedAfter(owed)
|
|
20
|
+
*
|
|
21
|
+
* @module
|
|
22
|
+
*/
|
|
23
|
+
// Unstable: ADR-0071, decision 5. #1028 (ADR-0027 *Amendment (#1028)*): core's `internal/firstSteps.ts`,
|
|
24
|
+
// for the projection's coordinator, whose nodes keep #1026's rule each as a Batch's members do.
|
|
25
|
+
export type { Reader } from "../internal/firstSteps.ts"
|
|
26
|
+
export { owingNothing, readerOf } from "../internal/firstSteps.ts"
|