@wardic/core 1.0.1 → 1.1.1

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.
Files changed (147) hide show
  1. package/dist/Batch.d.ts +4 -2
  2. package/dist/Batch.d.ts.map +1 -1
  3. package/dist/Batch.js +80 -13
  4. package/dist/Batch.js.map +1 -1
  5. package/dist/DefaultTransition.d.ts.map +1 -1
  6. package/dist/DefaultTransition.js +1 -1
  7. package/dist/DefaultTransition.js.map +1 -1
  8. package/dist/LiveValue.d.ts +61 -0
  9. package/dist/LiveValue.d.ts.map +1 -1
  10. package/dist/LiveValue.js +79 -5
  11. package/dist/LiveValue.js.map +1 -1
  12. package/dist/Machine.d.ts +10 -1
  13. package/dist/Machine.d.ts.map +1 -1
  14. package/dist/Machine.js +18 -1
  15. package/dist/Machine.js.map +1 -1
  16. package/dist/Renderer.js +2 -2
  17. package/dist/Renderer.js.map +1 -1
  18. package/dist/Spans.d.ts +41 -0
  19. package/dist/Spans.d.ts.map +1 -0
  20. package/dist/Spans.js +39 -0
  21. package/dist/Spans.js.map +1 -0
  22. package/dist/index.d.ts +1 -0
  23. package/dist/index.d.ts.map +1 -1
  24. package/dist/index.js +1 -0
  25. package/dist/index.js.map +1 -1
  26. package/dist/internal/frameLoop.d.ts +1 -1
  27. package/dist/internal/frameLoop.d.ts.map +1 -1
  28. package/dist/internal/frameLoop.js +42 -19
  29. package/dist/internal/frameLoop.js.map +1 -1
  30. package/dist/internal/options.d.ts.map +1 -1
  31. package/dist/internal/options.js +2 -2
  32. package/dist/internal/options.js.map +1 -1
  33. package/dist/internal/tracing.d.ts +34 -14
  34. package/dist/internal/tracing.d.ts.map +1 -1
  35. package/dist/internal/tracing.js +56 -24
  36. package/dist/internal/tracing.js.map +1 -1
  37. package/dist/unstable/AnimationControls.d.ts +110 -0
  38. package/dist/unstable/AnimationControls.d.ts.map +1 -0
  39. package/dist/unstable/AnimationControls.js +107 -0
  40. package/dist/unstable/AnimationControls.js.map +1 -0
  41. package/dist/unstable/AppearHandoff.d.ts +53 -0
  42. package/dist/unstable/AppearHandoff.d.ts.map +1 -0
  43. package/dist/unstable/AppearHandoff.js +23 -0
  44. package/dist/unstable/AppearHandoff.js.map +1 -0
  45. package/dist/unstable/Config.d.ts +285 -0
  46. package/dist/unstable/Config.d.ts.map +1 -0
  47. package/dist/unstable/Config.js +3 -0
  48. package/dist/unstable/Config.js.map +1 -0
  49. package/dist/unstable/FlushGate.d.ts +222 -0
  50. package/dist/unstable/FlushGate.d.ts.map +1 -0
  51. package/dist/unstable/FlushGate.js +567 -0
  52. package/dist/unstable/FlushGate.js.map +1 -0
  53. package/dist/unstable/FrameTime.d.ts +21 -0
  54. package/dist/unstable/FrameTime.d.ts.map +1 -0
  55. package/dist/unstable/FrameTime.js +45 -0
  56. package/dist/unstable/FrameTime.js.map +1 -0
  57. package/dist/unstable/MeasuredPairs.d.ts +51 -0
  58. package/dist/unstable/MeasuredPairs.d.ts.map +1 -0
  59. package/dist/unstable/MeasuredPairs.js +20 -0
  60. package/dist/unstable/MeasuredPairs.js.map +1 -0
  61. package/dist/unstable/OwnValues.d.ts +29 -0
  62. package/dist/unstable/OwnValues.d.ts.map +1 -0
  63. package/dist/unstable/OwnValues.js +22 -0
  64. package/dist/unstable/OwnValues.js.map +1 -0
  65. package/dist/unstable/PresenceRecord.d.ts +176 -0
  66. package/dist/unstable/PresenceRecord.d.ts.map +1 -0
  67. package/dist/unstable/PresenceRecord.js +26 -0
  68. package/dist/unstable/PresenceRecord.js.map +1 -0
  69. package/dist/unstable/Reactivity.d.ts +29 -0
  70. package/dist/unstable/Reactivity.d.ts.map +1 -0
  71. package/dist/unstable/Reactivity.js +15 -0
  72. package/dist/unstable/Reactivity.js.map +1 -0
  73. package/dist/unstable/Report.d.ts +30 -0
  74. package/dist/unstable/Report.d.ts.map +1 -0
  75. package/dist/unstable/Report.js +66 -0
  76. package/dist/unstable/Report.js.map +1 -0
  77. package/dist/unstable/RetargetLegs.d.ts +189 -0
  78. package/dist/unstable/RetargetLegs.d.ts.map +1 -0
  79. package/dist/unstable/RetargetLegs.js +834 -0
  80. package/dist/unstable/RetargetLegs.js.map +1 -0
  81. package/dist/unstable/Spine.d.ts +696 -0
  82. package/dist/unstable/Spine.d.ts.map +1 -0
  83. package/dist/unstable/Spine.js +2617 -0
  84. package/dist/unstable/Spine.js.map +1 -0
  85. package/dist/unstable/Stops.d.ts +82 -0
  86. package/dist/unstable/Stops.d.ts.map +1 -0
  87. package/dist/unstable/Stops.js +149 -0
  88. package/dist/unstable/Stops.js.map +1 -0
  89. package/dist/unstable/Subject.d.ts +11 -0
  90. package/dist/unstable/Subject.d.ts.map +1 -0
  91. package/dist/unstable/Subject.js +12 -0
  92. package/dist/unstable/Subject.js.map +1 -0
  93. package/dist/unstable/Timelines.d.ts +51 -0
  94. package/dist/unstable/Timelines.d.ts.map +1 -0
  95. package/dist/unstable/Timelines.js +10 -0
  96. package/dist/unstable/Timelines.js.map +1 -0
  97. package/dist/unstable/VariableValues.d.ts +27 -0
  98. package/dist/unstable/VariableValues.d.ts.map +1 -0
  99. package/dist/unstable/VariableValues.js +19 -0
  100. package/dist/unstable/VariableValues.js.map +1 -0
  101. package/dist/unstable/VariantTarget.d.ts +106 -0
  102. package/dist/unstable/VariantTarget.d.ts.map +1 -0
  103. package/dist/unstable/VariantTarget.js +185 -0
  104. package/dist/unstable/VariantTarget.js.map +1 -0
  105. package/dist/unstable/VariantTree.d.ts +351 -0
  106. package/dist/unstable/VariantTree.d.ts.map +1 -0
  107. package/dist/unstable/VariantTree.js +362 -0
  108. package/dist/unstable/VariantTree.js.map +1 -0
  109. package/dist/unstable/WardicConfigValue.d.ts +89 -0
  110. package/dist/unstable/WardicConfigValue.d.ts.map +1 -0
  111. package/dist/unstable/WardicConfigValue.js +106 -0
  112. package/dist/unstable/WardicConfigValue.js.map +1 -0
  113. package/dist/unstable/WardicServices.d.ts +46 -0
  114. package/dist/unstable/WardicServices.d.ts.map +1 -0
  115. package/dist/unstable/WardicServices.js +72 -0
  116. package/dist/unstable/WardicServices.js.map +1 -0
  117. package/package.json +1 -1
  118. package/src/Batch.ts +68 -12
  119. package/src/DefaultTransition.ts +1 -1
  120. package/src/LiveValue.ts +129 -5
  121. package/src/Machine.ts +22 -1
  122. package/src/Renderer.ts +2 -2
  123. package/src/Spans.ts +50 -0
  124. package/src/index.ts +1 -0
  125. package/src/internal/frameLoop.ts +44 -20
  126. package/src/internal/options.ts +2 -2
  127. package/src/internal/tracing.ts +82 -28
  128. package/src/unstable/AnimationControls.ts +199 -0
  129. package/src/unstable/AppearHandoff.ts +81 -0
  130. package/src/unstable/Config.ts +326 -0
  131. package/src/unstable/FlushGate.ts +730 -0
  132. package/src/unstable/FrameTime.ts +52 -0
  133. package/src/unstable/MeasuredPairs.ts +56 -0
  134. package/src/unstable/OwnValues.ts +32 -0
  135. package/src/unstable/PresenceRecord.ts +201 -0
  136. package/src/unstable/Reactivity.ts +35 -0
  137. package/src/unstable/Report.ts +75 -0
  138. package/src/unstable/RetargetLegs.ts +1062 -0
  139. package/src/unstable/Spine.ts +3275 -0
  140. package/src/unstable/Stops.ts +221 -0
  141. package/src/unstable/Subject.ts +13 -0
  142. package/src/unstable/Timelines.ts +58 -0
  143. package/src/unstable/VariableValues.ts +27 -0
  144. package/src/unstable/VariantTarget.ts +246 -0
  145. package/src/unstable/VariantTree.ts +643 -0
  146. package/src/unstable/WardicConfigValue.ts +154 -0
  147. package/src/unstable/WardicServices.ts +125 -0
@@ -0,0 +1,326 @@
1
+ /**
2
+ * The config types a binding's elements and the spine share, each built on {@link ValueKeys}: the keys
3
+ * an Environment animates and the values each takes. Empty here, `ValueKeys` is filled by the
4
+ * Environment's binding types (`@wardic/dom/unstable/WardConfig` fills it), so each type keeps its
5
+ * name and its shape whatever fills it.
6
+ *
7
+ * Unstable, for Wardic's own packages: public, with no semver promise.
8
+ *
9
+ * @module
10
+ */
11
+ // Unstable: ADR-0071, decision 5. #672 (the build grill's Q24 A, Q25): solid's `config.ts`'s types
12
+ // that the spine and its neighbours read, moved so core names no Environment's keys (#609). With
13
+ // `@wardic/dom` in a program, each is exactly what it was; core's own build sees an empty map, and its
14
+ // code reads keys by name at run time, as it did. Only one Environment's types may fill it: a scene's
15
+ // keys come through `@wardic/three`'s own `animate` types (ADR-0069, decision 4). The controls'
16
+ // interface and its mark (#433) came from `animation-controls.ts` by way of `config.ts`.
17
+ import type * as Arc from "../Arc.ts"
18
+ import type * as Machine from "../Machine.ts"
19
+ import type * as Stagger from "../Stagger.ts"
20
+
21
+ /**
22
+ * The keys an Environment animates, each with the values it takes: empty in core. An Environment's
23
+ * binding types fill it by declaration merging.
24
+ *
25
+ * @example
26
+ * declare module "@wardic/core/unstable/Config" {
27
+ * interface ValueKeys extends MyValues {}
28
+ * }
29
+ */
30
+ export interface ValueKeys {}
31
+
32
+ /**
33
+ * A **Keyframes** value (Motion's): the stops a key passes through in order, as
34
+ * `animate={{ scale: [1, 1.2, 1] }}`. A first `null` is where the key is now; a later one repeats the
35
+ * stop before it. An explicit first stop is jumped to as its animation starts. More than two stops run
36
+ * on a tween (Motion's 0.8 s one with no transition defined; `times` places them, `ease` may be one per
37
+ * Interval, between two stops): a spring takes two.
38
+ */
39
+ export type WardicKeyframes<V> = ReadonlyArray<V | null>
40
+
41
+ /**
42
+ * A target's values: each of {@link ValueKeys}' keys with a value or its {@link WardicKeyframes}. Every
43
+ * target takes them; a start reads one at its first stop, and a Transition end takes one value per key.
44
+ */
45
+ export type WardicTargetValues = {
46
+ readonly [K in keyof ValueKeys]?: K extends "transition" ? ValueKeys[K] : ValueKeys[K] | WardicKeyframes<Exclude<ValueKeys[K], undefined>>
47
+ }
48
+
49
+ /** A stagger: a child's delay in seconds, from its index and the count. `stagger()` makes one. Motion's `DynamicOption<number>`. */
50
+ // #436.
51
+ export type WardicStagger = (index: number, total: number) => number
52
+
53
+ /**
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 element. `arc()`
56
+ * makes one; any function of this shape is one, a curve of your own.
57
+ */
58
+ // A Path (#438).
59
+ export type WardicPath = Arc.Path
60
+
61
+ /**
62
+ * How a parent's variant children are timed against it and each other: `when`, `delayChildren`,
63
+ * `staggerChildren`, `staggerDirection` and `from`. Read on the parent's transition, for the variant
64
+ * change it hands its children.
65
+ */
66
+ // ADR-0007: they take effect on the parent that hands its names down; a child inherits them as its
67
+ // default transition but reads orchestration off the parent's context, not its own transition.
68
+ export interface WardicOrchestration {
69
+ /** Seconds between one child's start and the next's. */
70
+ readonly staggerChildren?: number
71
+ /**
72
+ * Fixed delay added to every child before its staggered offset; or, as Motion's, a function of a
73
+ * child's index and the count, `stagger()`'s, which decides each child's whole delay:
74
+ * `staggerChildren`, `staggerDirection` and `from` aren't read beside it.
75
+ */
76
+ // #436.
77
+ readonly delayChildren?: number | WardicStagger
78
+ /** `-1` reverses the stagger order, the last child first. Default `1`. */
79
+ readonly staggerDirection?: 1 | -1
80
+ /** The child the stagger grows from: `"first"` (the default), `"last"`, `"center"` or an index. */
81
+ readonly from?: Stagger.Origin
82
+ /**
83
+ * Orders the parent and its children: `"beforeChildren"` animates the parent, then the children once
84
+ * it lands; `"afterChildren"` the children, then the parent once they've all landed. Left out, they
85
+ * animate together.
86
+ */
87
+ readonly when?: "beforeChildren" | "afterChildren"
88
+ }
89
+
90
+ /**
91
+ * A transition's reduced-motion opt-out, on both arms. An animation honours the
92
+ * provider's `reducedMotion` by default: under it, its positional keys snap and a layout
93
+ * animation lands at once.
94
+ */
95
+ export interface WardicReducedMotion {
96
+ /** `false` animates the transition's keys whatever the provider's `reducedMotion` says. Default `true`. */
97
+ readonly respectReducedMotion?: boolean
98
+ }
99
+
100
+ /**
101
+ * A transition of `type: "inertia"`: each number glides from where it is at its velocity, its own or
102
+ * `velocity`, and comes to rest `power × velocity` on, through `modifyTarget`, springing back to `min`
103
+ * or `max` past one. Its target isn't read, so with no velocity it stays where it is. A value that
104
+ * isn't a number, a colour or a length with units, runs on its default transition instead.
105
+ * `timeConstant` is in milliseconds, as Motion's. Motion's `inertia`.
106
+ */
107
+ // #435.
108
+ export interface WardicInertia {
109
+ readonly type: "inertia"
110
+ /** The velocity every key glides from, per second: each key's own when left out. */
111
+ readonly velocity?: number
112
+ /** How far a glide carries, as a multiple of its velocity. Default 0.8. */
113
+ readonly power?: number
114
+ /** The glide's time constant, in milliseconds. Default 325. */
115
+ readonly timeConstant?: number
116
+ /** The bounce back from an edge: its stiffness and damping. Defaults 500 and 10. */
117
+ readonly bounceStiffness?: number
118
+ readonly bounceDamping?: number
119
+ /** At rest within this of where it's going. Default 0.5. */
120
+ readonly restDelta?: number
121
+ /** A bounce at rest below this speed, per second. Default 2. */
122
+ readonly restSpeed?: number
123
+ /** Moves where a glide rests, called with where it would: snapping it to a grid, say. */
124
+ readonly modifyTarget?: (ideal: number) => number
125
+ /** The edges: past one, the glide springs back to it. */
126
+ readonly min?: number
127
+ readonly max?: number
128
+ /** Seconds each key holds where it is before it glides. */
129
+ readonly delay?: number
130
+ }
131
+
132
+ /**
133
+ * A transition's **Skipped animation** (Motion's `skipAnimations`), on both arms: `true` lands its
134
+ * keys at their ends on the next frame, with no delay, as a `WardicConfig`'s `skipAnimations` does.
135
+ * `false` doesn't undo a config's.
136
+ */
137
+ export interface WardicSkipAnimations {
138
+ readonly skipAnimations?: boolean
139
+ }
140
+
141
+ /**
142
+ * A transition's **Path** (#438, Motion's `path`): `x` and `y` travel along it together, rather than
143
+ * each on its own, on `x`'s transition, from rest. `arc()` makes one; any {@link WardicPath} is one.
144
+ * An axis the target leaves out ends where it rests (#574): where a Path in flight was taking it, so
145
+ * one caught mid-air curves back to its line, else where it is.
146
+ * A layout animation reads it where Motion's does, on its layout transition: the `layout` entry when
147
+ * there is one, else the element's transition. On any other value's entry it isn't read.
148
+ */
149
+ export interface WardicTransitionPath {
150
+ readonly path?: WardicPath
151
+ }
152
+
153
+ /**
154
+ * How an element gets to its target: a spring, a tween, or an inertia, with a value's own transition
155
+ * under its name. With no `type`, a spring field (`stiffness`, `damping`, `mass`, `velocity`,
156
+ * `restDelta`, `restSpeed`, `bounce`, `visualDuration`) makes it a spring, and anything else a tween, so
157
+ * `{ duration: 0.5 }` is a 0.5 s tween. A spring's missing fields are Motion's 100 / 10 / 1, or set by
158
+ * time, a `duration` or `visualDuration` with a `bounce`; a tween's easing is `easeOut`. With neither,
159
+ * each value runs on its default. It also takes `delay`, a tween's repeats, a `path`, its variant
160
+ * children's orchestration, `respectReducedMotion` and `skipAnimations`.
161
+ */
162
+ // ADR-0051: a transition with only orchestration, `delay` or the opt-out leaves each key on its
163
+ // Environment's Default transition. A spring set by time (#359) is solved to its physics. A "tween"
164
+ // routes every key through `animateValues`, Keyframes through `keyframesValues` with `times` and an
165
+ // `ease` per Interval (#429). `from` is the stagger's origin on both arms: a spring's own `from` was
166
+ // never a transition's, and the two clashed (#243). A value's own transition: #301.
167
+ export type WardicTransition = WardicTransitionWith<WardicTransitionEntries>
168
+
169
+ /**
170
+ * A transition with the entries `E` (#301): {@link WardicTransition}'s two arms. A Wardic element's
171
+ * config checks each transition in it against the entries its keys allow (`WardChecked`).
172
+ */
173
+ export type WardicTransitionWith<E> =
174
+ | ({ readonly type?: "spring" } & Omit<Machine.SpringOptions, "from"> & WardicOrchestration & WardicReducedMotion & WardicSkipAnimations & WardicTransitionPath & E)
175
+ | ({ readonly type?: "tween" } & Machine.KeyframesOptions & WardicOrchestration & WardicReducedMotion & WardicSkipAnimations & WardicTransitionPath & E)
176
+ | (WardicInertia & WardicOrchestration & WardicReducedMotion & WardicSkipAnimations & WardicTransitionPath & E)
177
+
178
+ /**
179
+ * One value's own transition, under its name in a `transition`: a spring, a tween or an inertia, without
180
+ * the orchestration, which is the whole transition's. With `inherit: true` it's laid over the
181
+ * transition's own fields, its own winning; without, it stands alone, taking only the transition's
182
+ * `respectReducedMotion` and `skipAnimations`. Motion's `ValueTransition`.
183
+ */
184
+ // #301.
185
+ export type WardicValueTransition =
186
+ | ({ readonly type?: "spring" } & Omit<Machine.SpringOptions, "from"> & WardicReducedMotion & WardicSkipAnimations & WardicTransitionPath & WardicInherit)
187
+ | ({ readonly type?: "tween" } & Machine.KeyframesOptions & WardicReducedMotion & WardicSkipAnimations & WardicTransitionPath & WardicInherit)
188
+ | (WardicInertia & WardicReducedMotion & WardicSkipAnimations & WardicTransitionPath & WardicInherit)
189
+
190
+ /** `inherit: true` lays a transition over the one it would replace, its own fields winning, as Motion's. */
191
+ // #277, #301.
192
+ export interface WardicInherit {
193
+ readonly inherit?: boolean
194
+ }
195
+
196
+ /** The name of a value a transition can have an entry for: any of {@link ValueKeys}' keys. */
197
+ export type WardicValueKey = Exclude<keyof ValueKeys & string, "transition">
198
+
199
+ /**
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 element's layout animations. A value runs on its entry, else
202
+ * `default`, else the transition's own fields. Motion's `TransitionWithValueOverrides`.
203
+ */
204
+ // #301; `layout`, ADR-0009 *Amendment (#171)*: a layout animation on `layout`, else `default`, else the
205
+ // own fields, else Motion's 0.45 s tween.
206
+ export type WardicTransitionEntries = WardicValueEntries<WardicValueKey> & { readonly layout?: WardicValueTransition }
207
+
208
+ /** Entries for the values `K`, and `default` for the rest (#301). */
209
+ export type WardicValueEntries<K extends string> = { readonly default?: WardicValueTransition } & { readonly [P in K]?: WardicValueTransition }
210
+
211
+ /**
212
+ * A variant's own transition, or a target's: it runs the animation that variant starts, in place of
213
+ * the element's `transition`, unless `inherit: true` lays it over the element's, its own fields winning.
214
+ * Motion's.
215
+ */
216
+ // #277, ADR-0048.
217
+ export type WardicVariantTransition = WardicTransition & WardicInherit
218
+
219
+ /**
220
+ * A target's **Transition end** (Motion's `transitionEnd`): values set at once, with no
221
+ * 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;
222
+ * a target interrupted before it lands never sets them; the target an element renders first sets its
223
+ * own at once, on a server too.
224
+ */
225
+ export type WardicTransitionEnd = Omit<ValueKeys, "transition">
226
+
227
+ /**
228
+ * A target, as a variant, `animate` or `exit` gives it (Motion's `TargetAndTransition`): its
229
+ * values, each a value or its Keyframes ({@link WardicTargetValues}), optionally the transition
230
+ * the animation to it runs on, as an object, and its Transition end ({@link WardicTransitionEnd}).
231
+ * A plain map of {@link ValueKeys}' values fits too, its own `transition` key a value as any other.
232
+ */
233
+ export type WardicVariant =
234
+ | (WardicTargetValues & { readonly transitionEnd?: WardicTransitionEnd })
235
+ | (Omit<WardicTargetValues, "transition"> & { readonly transition?: WardicVariantTransition; readonly transitionEnd?: WardicTransitionEnd })
236
+
237
+ /**
238
+ * Variant names (Motion's `VariantLabels`): one name, or a list of them. A list merges its
239
+ * names' values in order, a later name's winning a key both set. Each key animates on the own
240
+ * transition of the last name that sets it, and each name orchestrates the keys it sets in the
241
+ * element's Variant children. An empty list is no name.
242
+ */
243
+ export type WardicVariantLabels = string | ReadonlyArray<string>
244
+
245
+ /**
246
+ * A dynamic variant (Motion's `TargetResolver`): called each time the variant is
247
+ * resolved with the element's `custom` (or, for an exit, its `<AnimatePresence custom>`), its values
248
+ * now and their velocities, and returns its target, or another variant's name.
249
+ */
250
+ export type WardicVariantResolver = (
251
+ // Motion's `custom` is `any`: a resolver declares its own (`(direction: number) => …`).
252
+ custom: any,
253
+ current: Readonly<Record<string, number | string>>,
254
+ velocity: Readonly<Record<string, number>>,
255
+ ) => WardicVariant | string
256
+
257
+ /** Named targets, each a target or a {@link WardicVariantResolver}. */
258
+ export type WardicVariants = Readonly<Record<string, WardicVariant | WardicVariantResolver>>
259
+
260
+ /** What controls start or set an element to: a target, a variant name or a list of them, or a function of each element's `custom`. Motion's `AnimationDefinition`. */
261
+ export type WardicControlsDefinition = WardicVariant | WardicVariantLabels | WardicVariantResolver
262
+
263
+ /** The mark that tells controls from a target. */
264
+ export const CONTROLS: unique symbol = Symbol("wardic.animationControls")
265
+
266
+ /**
267
+ * `createAnimationControls()`'s controls: give them as `animate={controls}`, and every element given
268
+ * them follows `start`, `set` and `stop`. Motion's `LegacyAnimationControls`.
269
+ */
270
+ // #433.
271
+ export interface WardicAnimationControls {
272
+ readonly [CONTROLS]: true
273
+ /**
274
+ * Animates every element given these controls to `definition`, as a change of its `animate` would,
275
+ * its variant children following. `transitionOverride`, when given, is the transition of this change,
276
+ * over the definition's own, and its stagger. Resolves once each element and its children have landed.
277
+ */
278
+ readonly start: (definition: WardicControlsDefinition, transitionOverride?: WardicTransition) => Promise<void>
279
+ /** Sets every element given these controls, and its variant children, at `definition` at once. */
280
+ readonly set: (definition: WardicControlsDefinition) => void
281
+ /** Ends every element's running animation where it is. */
282
+ readonly stop: () => void
283
+ }
284
+
285
+ /**
286
+ * Motion's `definition` of an animation: a variant name, or its target values. A list of names
287
+ * on Solid 2's landing, where `animate` gave one; Solid 1's callbacks are told each name.
288
+ */
289
+ export type WardicAnimationDefinition = WardicVariantLabels | ValueKeys
290
+
291
+ /**
292
+ * A point mapping (Motion's `TransformPoint`): handed a point in the Environment's coordinates, it
293
+ * gives the one a drag or a pan uses.
294
+ */
295
+ export type WardicTransformPoint = (point: { readonly x: number; readonly y: number }) => { readonly x: number; readonly y: number }
296
+
297
+ /**
298
+ * What the spine reads of an element's config: its start, its targets, variants and transitions, each
299
+ * gesture's target, its layout, and the callbacks it tells. Every binding's config extends it, with
300
+ * its Environment's own props beside.
301
+ */
302
+ // #672 (the build grill's Q15): the spine and the Controls change read these, so core names what they
303
+ // read, and dom's `WardConfig` extends it.
304
+ export interface SpineConfig {
305
+ readonly initial?: WardicVariant | WardicVariantLabels | false
306
+ readonly animate?: WardicVariant | WardicVariantLabels | WardicAnimationControls
307
+ readonly exit?: WardicVariant | WardicVariantLabels
308
+ readonly variants?: WardicVariants
309
+ readonly transition?: WardicTransition
310
+ readonly inherit?: boolean
311
+ // Motion's `custom` is `any`: a resolver declares its own.
312
+ readonly custom?: any
313
+ readonly key?: string | number
314
+ readonly whileHover?: WardicVariant | WardicVariantLabels
315
+ readonly whileTap?: WardicVariant | WardicVariantLabels
316
+ readonly whileFocus?: WardicVariant | WardicVariantLabels
317
+ readonly whileInView?: WardicVariant | WardicVariantLabels
318
+ readonly whileDrag?: WardicVariant | WardicVariantLabels
319
+ readonly layout?: boolean | "position" | "size" | "preserve-aspect" | "x" | "y"
320
+ readonly layoutId?: string
321
+ readonly appear?: boolean
322
+ readonly transformTemplate?: (values: Readonly<Record<string, string | number>>, generated: string) => string
323
+ readonly onUpdate?: (latest: Readonly<Record<string, number | string>>) => void
324
+ readonly onAnimationStart?: (definition: WardicAnimationDefinition) => void
325
+ readonly onAnimationComplete?: (definition: WardicAnimationDefinition) => void
326
+ }