@wardic/core 1.3.2 → 1.5.0-next.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 +15 -5
- package/dist/Batch.d.ts.map +1 -1
- package/dist/Batch.js +218 -20
- package/dist/Batch.js.map +1 -1
- package/dist/Clock.d.ts +7 -7
- package/dist/Clock.d.ts.map +1 -1
- package/dist/Clock.js +17 -16
- 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 +8 -6
- package/dist/DragRecognizer.d.ts.map +1 -1
- package/dist/DragRecognizer.js +51 -16
- 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 +1 -1
- package/dist/InputFeed.js +2 -2
- package/dist/InputSource.d.ts +9 -3
- package/dist/InputSource.d.ts.map +1 -1
- package/dist/InputSource.js +2 -2
- package/dist/InputSource.js.map +1 -1
- 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 +7 -6
- package/dist/LiveValue.d.ts.map +1 -1
- package/dist/LiveValue.js +45 -14
- package/dist/LiveValue.js.map +1 -1
- package/dist/Machine.d.ts +7 -4
- package/dist/Machine.d.ts.map +1 -1
- package/dist/Machine.js +146 -45
- package/dist/Machine.js.map +1 -1
- package/dist/Playback.d.ts.map +1 -1
- package/dist/Playback.js +6 -1
- package/dist/Playback.js.map +1 -1
- package/dist/Projection.d.ts +8 -19
- package/dist/Projection.d.ts.map +1 -1
- package/dist/Projection.js +3 -19
- package/dist/Projection.js.map +1 -1
- package/dist/Recognizer.d.ts +1 -1
- package/dist/Recognizer.d.ts.map +1 -1
- package/dist/Recognizer.js +22 -7
- 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 +12 -2
- package/dist/Reorder.d.ts.map +1 -1
- package/dist/Reorder.js +65 -37
- 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 +1 -1
- package/dist/internal/frameLoop.d.ts.map +1 -1
- package/dist/internal/frameLoop.js +102 -81
- package/dist/internal/frameLoop.js.map +1 -1
- 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/projectionRest.d.ts +22 -0
- package/dist/internal/projectionRest.d.ts.map +1 -0
- package/dist/internal/projectionRest.js +20 -0
- package/dist/internal/projectionRest.js.map +1 -0
- package/dist/internal/stepper.d.ts +13 -2
- package/dist/internal/stepper.d.ts.map +1 -1
- package/dist/internal/stepper.js +16 -1
- 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 +37 -38
- package/dist/unstable/AnimationControls.d.ts.map +1 -1
- package/dist/unstable/AnimationControls.js +39 -36
- package/dist/unstable/AnimationControls.js.map +1 -1
- package/dist/unstable/AppearHandoff.d.ts +5 -5
- package/dist/unstable/AppearHandoff.d.ts.map +1 -1
- package/dist/unstable/BatchCalls.d.ts +2 -2
- package/dist/unstable/BatchCalls.js +5 -5
- package/dist/unstable/Config.d.ts +19 -19
- package/dist/unstable/Config.d.ts.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 +53 -51
- package/dist/unstable/FlushGate.d.ts.map +1 -1
- package/dist/unstable/FlushGate.js +56 -49
- package/dist/unstable/FlushGate.js.map +1 -1
- package/dist/unstable/FrameEffects.d.ts +2 -2
- package/dist/unstable/FrameEffects.js +2 -2
- package/dist/unstable/FrameTime.d.ts +1 -1
- package/dist/unstable/FrameTime.js +1 -1
- package/dist/unstable/Imperative.d.ts +29 -9
- package/dist/unstable/Imperative.d.ts.map +1 -1
- package/dist/unstable/Imperative.js +79 -47
- package/dist/unstable/Imperative.js.map +1 -1
- package/dist/unstable/OwnValues.js +1 -1
- package/dist/unstable/PresenceRecord.d.ts +31 -27
- 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 +1 -1
- package/dist/unstable/Report.js +1 -1
- package/dist/unstable/RetargetLegs.d.ts +1 -1
- package/dist/unstable/RetargetLegs.d.ts.map +1 -1
- package/dist/unstable/RetargetLegs.js +9 -8
- package/dist/unstable/RetargetLegs.js.map +1 -1
- package/dist/unstable/Spine.d.ts +81 -72
- package/dist/unstable/Spine.d.ts.map +1 -1
- package/dist/unstable/Spine.js +171 -164
- 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 +7 -7
- package/dist/unstable/VariantTarget.d.ts.map +1 -1
- package/dist/unstable/VariantTarget.js +11 -11
- package/dist/unstable/VariantTarget.js.map +1 -1
- package/dist/unstable/VariantTree.d.ts +43 -36
- package/dist/unstable/VariantTree.d.ts.map +1 -1
- package/dist/unstable/VariantTree.js +34 -34
- 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 +236 -22
- package/src/Clock.ts +18 -17
- package/src/DefaultTransition.ts +5 -3
- package/src/Drag.ts +32 -14
- package/src/DragActivity.ts +3 -3
- package/src/DragRecognizer.ts +65 -23
- package/src/Easing.ts +1 -1
- package/src/Frame.ts +5 -3
- package/src/InputFeed.ts +2 -2
- package/src/InputSource.ts +12 -5
- package/src/Interpolator.ts +3 -3
- package/src/InterpolatorRegistry.ts +22 -13
- package/src/LiveValue.ts +47 -17
- package/src/Machine.ts +199 -61
- package/src/Playback.ts +5 -1
- package/src/Projection.ts +10 -28
- package/src/Recognizer.ts +24 -8
- package/src/ReducedMotion.ts +6 -6
- package/src/Renderer.ts +6 -6
- package/src/Reorder.ts +84 -38
- 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 +103 -87
- package/src/internal/lerpsNumbers.ts +53 -0
- package/src/internal/options.ts +10 -10
- package/src/internal/projectionRest.ts +31 -0
- package/src/internal/stepper.ts +20 -2
- package/src/internal/tracing.ts +1 -1
- package/src/unstable/AnimationControls.ts +59 -56
- package/src/unstable/AppearHandoff.ts +6 -6
- package/src/unstable/BatchCalls.ts +5 -5
- package/src/unstable/Config.ts +19 -19
- package/src/unstable/FirstSteps.ts +26 -0
- package/src/unstable/FlushGate.ts +92 -82
- package/src/unstable/FrameEffects.ts +2 -2
- package/src/unstable/FrameTime.ts +1 -1
- package/src/unstable/Imperative.ts +126 -56
- package/src/unstable/OwnValues.ts +1 -1
- package/src/unstable/PresenceRecord.ts +34 -30
- package/src/unstable/Projector.ts +45 -0
- package/src/unstable/Report.ts +1 -1
- package/src/unstable/RetargetLegs.ts +10 -9
- package/src/unstable/Spine.ts +210 -201
- 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 +13 -13
- package/src/unstable/VariantTree.ts +50 -43
- package/src/unstable/WardicConfigValue.ts +13 -13
|
@@ -1,22 +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) => …)`, every
|
|
19
|
-
* refuses the call, taking nothing.
|
|
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.
|
|
20
20
|
*
|
|
21
21
|
* Unstable, for Wardic's own packages: public, with no semver promise.
|
|
22
22
|
*
|
|
@@ -40,26 +40,26 @@ declare const queueMicrotask: (callback: () => void) => void
|
|
|
40
40
|
export type { WardicAnimationControls, WardicControlsDefinition } from "./Config.ts"
|
|
41
41
|
|
|
42
42
|
/**
|
|
43
|
-
* A **Controls change** (#433): what one `start` or `set` set one
|
|
44
|
-
* 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
|
|
45
45
|
* join it at the Retarget it makes them run, and leave at that one's landing (or the next's).
|
|
46
46
|
*/
|
|
47
47
|
export interface ControlsChange {
|
|
48
48
|
/** Its place among every change: a trigger key part, so a change is a trigger even to the same name. */
|
|
49
49
|
readonly serial: number
|
|
50
|
-
/** The
|
|
50
|
+
/** The Subject's `animate` entry: a target or a name, a resolver already called. */
|
|
51
51
|
readonly definition: Config.WardicVariant | Config.WardicVariantLabels
|
|
52
|
-
/** 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. */
|
|
53
53
|
readonly override: Config.WardicTransition | undefined
|
|
54
|
-
/**
|
|
54
|
+
/** Subjects in it that haven't landed. */
|
|
55
55
|
pending: number
|
|
56
|
-
/** Whether every
|
|
56
|
+
/** Whether every Subject it reaches has had its chance to join: its binding's flush has run. */
|
|
57
57
|
armed: boolean
|
|
58
58
|
/** Told once it has landed. */
|
|
59
59
|
readonly landed: () => void
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
/** 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. */
|
|
63
63
|
export interface Controlled {
|
|
64
64
|
/** Its entry for `definition`: a function definition called with its `custom`, values and velocities; anything else as it is. */
|
|
65
65
|
readonly entryOf: (definition: Config.WardicControlsDefinition) => Config.WardicVariant | Config.WardicVariantLabels
|
|
@@ -67,7 +67,7 @@ export interface Controlled {
|
|
|
67
67
|
readonly stop: () => void
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
/** The
|
|
70
|
+
/** The Subjects each controls reach, by the controls. */
|
|
71
71
|
// Module state (#460, Q7): each controls object's subscribers, held weakly by it.
|
|
72
72
|
const subscribers = new WeakMap<Config.WardicAnimationControls, Set<Controlled>>()
|
|
73
73
|
|
|
@@ -75,43 +75,43 @@ const subscribers = new WeakMap<Config.WardicAnimationControls, Set<Controlled>>
|
|
|
75
75
|
export const INSTANT: Config.WardicTransition = { type: "tween", duration: 0 }
|
|
76
76
|
|
|
77
77
|
/**
|
|
78
|
-
* Each
|
|
78
|
+
* Each Subject's entry for `definition`, worked out before any is set: a function definition that throws
|
|
79
79
|
* for one refuses the call, taking nothing, as an `animate()` call refuses one.
|
|
80
80
|
*/
|
|
81
|
-
// #979 (ADR-0074, row 35): `start` and `set` set each
|
|
82
|
-
// that threw for a later
|
|
83
|
-
const entriesOf = (
|
|
84
|
-
Arr.map(
|
|
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
85
|
|
|
86
86
|
/**
|
|
87
|
-
* Makes animation controls, which animate
|
|
88
|
-
* to each
|
|
89
|
-
*
|
|
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`.
|
|
90
90
|
*
|
|
91
91
|
* @example
|
|
92
92
|
* const controls = createAnimationControls()
|
|
93
|
-
*
|
|
93
|
+
* // A binding gives `controls` to each Subject as its `animate`.
|
|
94
94
|
* await controls.start("visible")
|
|
95
|
-
* @see https://wardic.dev/reference/solid/animation/create-animation-controls
|
|
96
95
|
*/
|
|
97
|
-
// #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).
|
|
98
98
|
export const createAnimationControls = (): Config.WardicAnimationControls => {
|
|
99
99
|
const reached = new Set<Controlled>()
|
|
100
100
|
const controls: Config.WardicAnimationControls = {
|
|
101
101
|
[Config.CONTROLS]: true,
|
|
102
102
|
start: (definition, transitionOverride) => {
|
|
103
|
-
const
|
|
104
|
-
const entries = entriesOf(
|
|
105
|
-
return Promise.all(Arr.zipWith(
|
|
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
106
|
},
|
|
107
107
|
set: (definition) => {
|
|
108
|
-
const
|
|
109
|
-
const entries = entriesOf(
|
|
110
|
-
Arr.forEach(Arr.zip(
|
|
111
|
-
void
|
|
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
112
|
})
|
|
113
113
|
},
|
|
114
|
-
stop: () => reached.forEach((
|
|
114
|
+
stop: () => reached.forEach((controlled) => controlled.stop()),
|
|
115
115
|
}
|
|
116
116
|
subscribers.set(controls, reached)
|
|
117
117
|
return controls
|
|
@@ -120,17 +120,17 @@ export const createAnimationControls = (): Config.WardicAnimationControls => {
|
|
|
120
120
|
/** Whether `u` is **Animation controls** (Motion's `isAnimationControls`). */
|
|
121
121
|
export const isAnimationControls = (u: unknown): u is Config.WardicAnimationControls => Predicate.hasProperty(u, Config.CONTROLS)
|
|
122
122
|
|
|
123
|
-
/**
|
|
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. */
|
|
124
124
|
export const controlsOf = (animate: unknown): Config.WardicAnimationControls | undefined =>
|
|
125
125
|
Bool.match(isAnimationControls(animate), { onTrue: () => animate as Config.WardicAnimationControls, onFalse: constUndefined })
|
|
126
126
|
|
|
127
|
-
/** Reach `
|
|
128
|
-
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) => {
|
|
129
129
|
const reached = subscribers.get(controls)
|
|
130
130
|
if (Predicate.isUndefined(reached)) return () => undefined
|
|
131
|
-
reached.add(
|
|
131
|
+
reached.add(controlled)
|
|
132
132
|
return () => {
|
|
133
|
-
reached.delete(
|
|
133
|
+
reached.delete(controlled)
|
|
134
134
|
}
|
|
135
135
|
}
|
|
136
136
|
|
|
@@ -139,10 +139,10 @@ export const subscribe = (controls: Config.WardicAnimationControls, element: Con
|
|
|
139
139
|
let serials = 0
|
|
140
140
|
|
|
141
141
|
/**
|
|
142
|
-
*
|
|
142
|
+
* A Subject's entry for `definition`: a resolver called with its `custom`, values and velocities (once,
|
|
143
143
|
* as Motion's), anything else as it is.
|
|
144
144
|
*/
|
|
145
|
-
// #433; #979 (row 35): worked out for every
|
|
145
|
+
// #433; #979 (row 35): worked out for every Subject before any is set.
|
|
146
146
|
export const entryOf = (
|
|
147
147
|
definition: Config.WardicControlsDefinition,
|
|
148
148
|
custom: unknown,
|
|
@@ -155,15 +155,18 @@ export const entryOf = (
|
|
|
155
155
|
})
|
|
156
156
|
|
|
157
157
|
/**
|
|
158
|
-
* A change of one
|
|
159
|
-
*
|
|
160
|
-
* no
|
|
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
161
|
*/
|
|
162
162
|
// #433.
|
|
163
163
|
export const changeOf = (
|
|
164
164
|
entry: Config.WardicVariant | Config.WardicVariantLabels,
|
|
165
165
|
override: Config.WardicTransition | undefined,
|
|
166
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).
|
|
167
170
|
let resolve!: () => void
|
|
168
171
|
const landing = new Promise<void>((done) => {
|
|
169
172
|
resolve = done
|
|
@@ -172,25 +175,25 @@ export const changeOf = (
|
|
|
172
175
|
return { change, landing }
|
|
173
176
|
}
|
|
174
177
|
|
|
175
|
-
/**
|
|
178
|
+
/** A Subject joins `change`: it runs a Retarget for it. */
|
|
176
179
|
export const join = (change: ControlsChange): void => {
|
|
177
180
|
change.pending++
|
|
178
181
|
}
|
|
179
182
|
|
|
180
|
-
/**
|
|
183
|
+
/** A Subject in `change` landed, or left it (a later change, its unmount): it lands once none is left and it's armed. */
|
|
181
184
|
export const leave = (change: ControlsChange): void => {
|
|
182
185
|
change.pending--
|
|
183
186
|
if (change.armed && change.pending <= 0) change.landed()
|
|
184
187
|
}
|
|
185
188
|
|
|
186
|
-
/** `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. */
|
|
187
190
|
export const arm = (change: ControlsChange): void => {
|
|
188
191
|
change.armed = true
|
|
189
192
|
if (change.pending <= 0) change.landed()
|
|
190
193
|
}
|
|
191
194
|
|
|
192
195
|
/**
|
|
193
|
-
*
|
|
196
|
+
* A Subject's config with **Animation controls** for its `animate` (#433), as everything but its
|
|
194
197
|
* controls reads it: `change`'s entry (none before the first), and marked controlled, so it names its
|
|
195
198
|
* own variants whatever the entry is (Motion's `isControllingVariants`).
|
|
196
199
|
*/
|
|
@@ -201,14 +204,14 @@ export const controlledConfigOf = <C extends Pick<Config.SpineConfig, "animate">
|
|
|
201
204
|
export const uncontrolledOf = <C extends Pick<Config.SpineConfig, "animate">>(config: C): C =>
|
|
202
205
|
Bool.match(isAnimationControls(config.animate), { onTrue: () => controlledConfigOf(config, undefined), onFalse: () => config })
|
|
203
206
|
|
|
204
|
-
/** What a controlled
|
|
207
|
+
/** What a controlled Subject reads at a change: its `custom`, and its values and velocities now (its Snapshot). */
|
|
205
208
|
export interface ControlledState {
|
|
206
209
|
readonly custom: () => unknown
|
|
207
210
|
/** Its Snapshot: its values, and its velocities now (#663), a spring leg's being on its Frame. */
|
|
208
211
|
readonly snapshot: ControlledSnapshot
|
|
209
212
|
}
|
|
210
213
|
|
|
211
|
-
/** What Animation controls read of
|
|
214
|
+
/** What Animation controls read of a Ward's Snapshot: its values, and its velocities now (#663). */
|
|
212
215
|
// #672: the controls name what they read, so they import nothing of the spine, whose Snapshot meets it.
|
|
213
216
|
export interface ControlledSnapshot {
|
|
214
217
|
readonly values: Values.Values
|
|
@@ -216,11 +219,11 @@ export interface ControlledSnapshot {
|
|
|
216
219
|
}
|
|
217
220
|
|
|
218
221
|
/**
|
|
219
|
-
* A mounted
|
|
222
|
+
* A mounted Subject as its controls reach it (#433): a change sets its entry through `setChange`, its
|
|
220
223
|
* binding's signal, and arms once the binding's flush has run (a microtask after, Solid 2's included),
|
|
221
|
-
* every
|
|
224
|
+
* every Subject it reaches joined by then; `stop` ends its legs.
|
|
222
225
|
*/
|
|
223
|
-
export const
|
|
226
|
+
export const controlledSubject = (setChange: (change: ControlsChange) => void, state: ControlledState, stop: () => void): Controlled => ({
|
|
224
227
|
entryOf: (definition) => entryOf(definition, state.custom(), state.snapshot.values, state.snapshot.velocitiesNow(state.snapshot)),
|
|
225
228
|
change: (entry, override) => {
|
|
226
229
|
const made = changeOf(entry, override)
|
|
@@ -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,7 +37,7 @@ 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. */
|
|
@@ -70,7 +70,7 @@ const heldInAppear = (transition: Config.WardicTransition | undefined): number =
|
|
|
70
70
|
/** A mount animation's `skipped` (#468): left out when it isn't, so its key is as before. */
|
|
71
71
|
export const skippedField = (skipped: boolean): { readonly skipped?: true } => Bool.match(skipped, { onTrue: () => ({ skipped: true }) as const, onFalse: () => ({}) })
|
|
72
72
|
|
|
73
|
-
/**
|
|
73
|
+
/** A Subject's Appear animation, found at mount: the spine starts its first legs as far in as it has got. */
|
|
74
74
|
export interface Handoff {
|
|
75
75
|
/** How far its animation has run, in seconds (its delay included). */
|
|
76
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,16 +255,16 @@ 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
266
|
*
|
|
267
|
-
* One that throws is reported, and only its
|
|
267
|
+
* One that throws is reported, and only its Subject is affected: it keeps its last target until the
|
|
268
268
|
* variant resolves, leaves without that exit, or starts without that variant's values.
|
|
269
269
|
*/
|
|
270
270
|
// #979 (group F; ADR-0074, ADR-0007's Amendment): core's one call site catches it, and the failure
|
|
@@ -279,29 +279,29 @@ export type WardicVariantResolver = (
|
|
|
279
279
|
/** Named targets, each a target or a {@link WardicVariantResolver}. */
|
|
280
280
|
export type WardicVariants = Readonly<Record<string, WardicVariant | WardicVariantResolver>>
|
|
281
281
|
|
|
282
|
-
/** 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`. */
|
|
283
283
|
export type WardicControlsDefinition = WardicVariant | WardicVariantLabels | WardicVariantResolver
|
|
284
284
|
|
|
285
285
|
/** The mark that tells controls from a target. */
|
|
286
286
|
export const CONTROLS: unique symbol = Symbol("wardic.animationControls")
|
|
287
287
|
|
|
288
288
|
/**
|
|
289
|
-
* `createAnimationControls()`'s controls: give them as `animate={controls}`, and every
|
|
289
|
+
* `createAnimationControls()`'s controls: give them as `animate={controls}`, and every Subject given
|
|
290
290
|
* them follows `start`, `set` and `stop`. Motion's `LegacyAnimationControls`.
|
|
291
291
|
*/
|
|
292
292
|
// #433.
|
|
293
293
|
export interface WardicAnimationControls {
|
|
294
294
|
readonly [CONTROLS]: true
|
|
295
295
|
/**
|
|
296
|
-
* Animates every
|
|
296
|
+
* Animates every Subject given these controls to `definition`, as a change of its `animate` would,
|
|
297
297
|
* its variant children following. `transitionOverride`, when given, is the transition of this change,
|
|
298
|
-
* over the definition's own, and its stagger. Resolves once each
|
|
299
|
-
* A function definition that throws for one
|
|
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.
|
|
300
300
|
*/
|
|
301
301
|
readonly start: (definition: WardicControlsDefinition, transitionOverride?: WardicTransition) => Promise<void>
|
|
302
|
-
/** Sets every
|
|
302
|
+
/** Sets every Subject given these controls, and its variant children, at `definition` at once; refused, with none set, as `start` is. */
|
|
303
303
|
readonly set: (definition: WardicControlsDefinition) => void
|
|
304
|
-
/** Ends every
|
|
304
|
+
/** Ends every Subject's running animation where it is. */
|
|
305
305
|
readonly stop: () => void
|
|
306
306
|
}
|
|
307
307
|
|
|
@@ -318,7 +318,7 @@ export type WardicAnimationDefinition = WardicVariantLabels | ValueKeys
|
|
|
318
318
|
export type WardicTransformPoint = (point: { readonly x: number; readonly y: number }) => { readonly x: number; readonly y: number }
|
|
319
319
|
|
|
320
320
|
/**
|
|
321
|
-
* What the spine reads of
|
|
321
|
+
* What the spine reads of a Ward's config: its start, its targets, variants and transitions, each
|
|
322
322
|
* gesture's target, its layout, and the callbacks it tells. Every binding's config extends it, with
|
|
323
323
|
* its Environment's own props beside.
|
|
324
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"
|