@wardic/core 1.2.0 → 1.3.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 (76) hide show
  1. package/dist/BaseValue.d.ts.map +1 -1
  2. package/dist/BaseValue.js +2 -0
  3. package/dist/BaseValue.js.map +1 -1
  4. package/dist/Batch.d.ts +6 -0
  5. package/dist/Batch.d.ts.map +1 -1
  6. package/dist/Batch.js +40 -10
  7. package/dist/Batch.js.map +1 -1
  8. package/dist/DefaultTransition.d.ts +21 -12
  9. package/dist/DefaultTransition.d.ts.map +1 -1
  10. package/dist/DefaultTransition.js +43 -2
  11. package/dist/DefaultTransition.js.map +1 -1
  12. package/dist/FrameLoop.d.ts +5 -1
  13. package/dist/FrameLoop.d.ts.map +1 -1
  14. package/dist/FrameLoop.js.map +1 -1
  15. package/dist/Machine.d.ts +3 -0
  16. package/dist/Machine.d.ts.map +1 -1
  17. package/dist/Machine.js +4 -3
  18. package/dist/Machine.js.map +1 -1
  19. package/dist/Spring.d.ts +7 -0
  20. package/dist/Spring.d.ts.map +1 -1
  21. package/dist/Spring.js +16 -0
  22. package/dist/Spring.js.map +1 -1
  23. package/dist/UnitScale.d.ts +39 -0
  24. package/dist/UnitScale.d.ts.map +1 -0
  25. package/dist/UnitScale.js +45 -0
  26. package/dist/UnitScale.js.map +1 -0
  27. package/dist/index.d.ts +1 -0
  28. package/dist/index.d.ts.map +1 -1
  29. package/dist/index.js +1 -0
  30. package/dist/index.js.map +1 -1
  31. package/dist/internal/frameLoop.js +5 -5
  32. package/dist/internal/frameLoop.js.map +1 -1
  33. package/dist/unstable/BatchCalls.d.ts +150 -0
  34. package/dist/unstable/BatchCalls.d.ts.map +1 -0
  35. package/dist/unstable/BatchCalls.js +319 -0
  36. package/dist/unstable/BatchCalls.js.map +1 -0
  37. package/dist/unstable/Config.d.ts +11 -0
  38. package/dist/unstable/Config.d.ts.map +1 -1
  39. package/dist/unstable/Config.js.map +1 -1
  40. package/dist/unstable/FrameEffects.d.ts +59 -0
  41. package/dist/unstable/FrameEffects.d.ts.map +1 -0
  42. package/dist/unstable/FrameEffects.js +142 -0
  43. package/dist/unstable/FrameEffects.js.map +1 -0
  44. package/dist/unstable/FrameTime.d.ts +1 -4
  45. package/dist/unstable/FrameTime.d.ts.map +1 -1
  46. package/dist/unstable/FrameTime.js +1 -4
  47. package/dist/unstable/FrameTime.js.map +1 -1
  48. package/dist/unstable/Imperative.d.ts +292 -0
  49. package/dist/unstable/Imperative.d.ts.map +1 -0
  50. package/dist/unstable/Imperative.js +922 -0
  51. package/dist/unstable/Imperative.js.map +1 -0
  52. package/dist/unstable/RetargetLegs.d.ts +2 -1
  53. package/dist/unstable/RetargetLegs.d.ts.map +1 -1
  54. package/dist/unstable/RetargetLegs.js +23 -15
  55. package/dist/unstable/RetargetLegs.js.map +1 -1
  56. package/dist/unstable/Spine.d.ts +17 -14
  57. package/dist/unstable/Spine.d.ts.map +1 -1
  58. package/dist/unstable/Spine.js +33 -16
  59. package/dist/unstable/Spine.js.map +1 -1
  60. package/package.json +1 -1
  61. package/src/BaseValue.ts +2 -0
  62. package/src/Batch.ts +62 -9
  63. package/src/DefaultTransition.ts +53 -2
  64. package/src/FrameLoop.ts +6 -2
  65. package/src/Machine.ts +7 -3
  66. package/src/Spring.ts +16 -0
  67. package/src/UnitScale.ts +56 -0
  68. package/src/index.ts +1 -0
  69. package/src/internal/frameLoop.ts +5 -5
  70. package/src/unstable/BatchCalls.ts +419 -0
  71. package/src/unstable/Config.ts +17 -0
  72. package/src/unstable/FrameEffects.ts +172 -0
  73. package/src/unstable/FrameTime.ts +1 -5
  74. package/src/unstable/Imperative.ts +1232 -0
  75. package/src/unstable/RetargetLegs.ts +20 -11
  76. package/src/unstable/Spine.ts +48 -21
@@ -15,12 +15,9 @@ import * as Effect from "effect/Effect";
15
15
  import * as Predicate from "effect/Predicate";
16
16
  /**
17
17
  * How long a key's velocity holds once nothing has moved it, in ms (Motion's `MAX_VELOCITY_DELTA`):
18
- * past it, the key is at rest. A velocity worked out from two frames further apart takes this as their
19
- * time apart.
18
+ * past it, the key is at rest. A velocity worked out over a longer step takes this as the step's time.
20
19
  */
21
20
  export const MAX_VELOCITY_DELTA = 30;
22
- /** A frame at 60 Hz, in ms: the time a leg's first frame is read over, from where it started (Motion's first-frame delta). */
23
- export const NOMINAL_FRAME = 1000 / 60;
24
21
  /**
25
22
  * The time now, in ms: the same for the rest of this synchronous block (core's `Clock.syncNow`).
26
23
  * Per frame: a check, and a read once a tick. A Snapshot's time until its spine gives it its
@@ -1 +1 @@
1
- {"version":3,"file":"FrameTime.js","sourceRoot":"","sources":["../../src/unstable/FrameTime.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,iGAAiG;AACjG,sGAAsG;AACtG,OAAO,KAAK,KAAK,MAAM,aAAa,CAAA;AACpC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,SAAS,MAAM,kBAAkB,CAAA;AAG7C;;;;GAIG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,EAAE,CAAA;AAEpC,8HAA8H;AAC9H,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,GAAG,EAAE,CAAA;AAKtC;;;;GAIG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAiB,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC,CAAA;AAE5E,+CAA+C;AAC/C,6EAA6E;AAC7E,MAAM,SAAS,GAAG,IAAI,OAAO,EAAsE,CAAA;AAEnG;;;GAGG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,OAA6D,EAAkB,EAAE;IAC1G,MAAM,IAAI,GAAG,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;IACnC,IAAI,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAA;IAC/C,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,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A;IAC5B,OAAO,IAAI,CAAA;AACb,CAAC,CAAA"}
@@ -0,0 +1,292 @@
1
+ /**
2
+ * **Imperative animation** (#433, CONTEXT.md; Motion's `animate`), for every Environment: an
3
+ * **Animation scope**'s `animate`, the Subjects it animates, and the **Playback controls** it returns.
4
+ * An Environment says what its Subjects are and how a plain one starts ({@link Subjects}), and what
5
+ * its Batches are ({@link Batches}); each binding's `createAnimate()` builds on it.
6
+ *
7
+ * - **A Wardic element** animates through its own spine, registered here while it's mounted: the
8
+ * call takes the keys it animates, which stay where it leaves them until the element's own target
9
+ * for them changes (Motion's latest-wins).
10
+ * - **A plain Subject** animates through a spine of its own (#433's Q4), with no config, presence or
11
+ * layout node: it starts from the Subject's Own value (ADR-0022) and keeps its values for the next
12
+ * call, velocity included. It's in the gate only while it animates, so the gate keeps nothing of a
13
+ * Subject it isn't animating.
14
+ * - **The controls** are Motion's (`AnimationPlaybackControls`): awaitable, with `stop`, `cancel`,
15
+ * `complete`, `pause`, `play`, `speed`, `time` and `duration`, every Subject's legs run through one
16
+ * `Playback.Playhead`. Its `finished` resolves at a landing or `complete()`, never at a `stop()` or a
17
+ * `cancel()`, as Motion's.
18
+ * - **A sequence** (#433's PR 2, Motion's) is compiled by core's `Sequence` to each Subject's
19
+ * Keyframes over the whole sequence, run on the same controls: each Subject animates as a call
20
+ * does, and a function Segment's value, from 0, is told to its callback each frame.
21
+ *
22
+ * Unstable, for Wardic's own packages: public, with no semver promise.
23
+ *
24
+ * @module
25
+ */
26
+ import type * as DefaultTransition from "../DefaultTransition.ts";
27
+ import * as Playback from "../Playback.ts";
28
+ import * as ReducedMotion from "../ReducedMotion.ts";
29
+ import * as Sequence from "../Sequence.ts";
30
+ import type * as Config from "./Config.ts";
31
+ import type * as FlushGate from "./FlushGate.ts";
32
+ import type * as MeasuredPairs from "./MeasuredPairs.ts";
33
+ import type * as OwnValues from "./OwnValues.ts";
34
+ import * as Spine from "./Spine.ts";
35
+ import type * as VariableValues from "./VariableValues.ts";
36
+ import type * as WardicServices from "./WardicServices.ts";
37
+ /** What an Imperative animation animates a Wardic element through: what its spine hands over (`host`). */
38
+ type Animatable = Pick<Spine.ElementSpine, "host">;
39
+ /**
40
+ * Register a mounted Wardic element's spine for the Imperative animations of its Subject (#433): until
41
+ * the returned function, which its unmount calls.
42
+ */
43
+ export declare const registerAnimatable: (subject: object, spine: Animatable) => (() => void);
44
+ /** What a scope animates plain Subjects with: its provider's. */
45
+ export interface AnimateEnv {
46
+ readonly runtime: WardicServices.Runner<WardicServices.WardicServices>;
47
+ readonly gate: FlushGate.Shape;
48
+ readonly reducedMotion: () => boolean;
49
+ /**
50
+ * Whether its animations are skipped (#468): its scope's nearest `WardicConfig`'s, read as each
51
+ * starts, and handed to each Subject's animation in its transition, as Motion's `useAnimate` does.
52
+ */
53
+ readonly skipAnimations: () => boolean;
54
+ readonly positionalKeys: ReducedMotion.PositionalKeys["Service"];
55
+ readonly defaultTransition: DefaultTransition.DefaultTransition["Service"];
56
+ /** Its Environment's reads of its Subjects' own values (#672). */
57
+ readonly ownValues: OwnValues.Shape;
58
+ /** Its Environment's Measured pairs (#430, #672). */
59
+ readonly measuredPairs: MeasuredPairs.Shape;
60
+ /** Its Environment's Variable values (#55, #672). */
61
+ readonly variableValues: VariableValues.Shape;
62
+ }
63
+ /**
64
+ * An Environment's Subjects, for `animate`: what its first argument names, and where a plain one
65
+ * starts. The DOM's are elements, selectors looked up in the scope and lists of them; a scene's, its
66
+ * objects.
67
+ */
68
+ export interface Subjects<S extends object> {
69
+ /** The Subjects `given` names, inside `scope` (a binding's scope, or `undefined`): none when it names none. */
70
+ readonly resolve: (given: unknown, scope: unknown) => ReadonlyArray<S>;
71
+ /** A plain Subject's Base-value links (ADR-0022): its Own values, and the DOM's Starting style. */
72
+ readonly startLinksOf: (subject: S) => Spine.StartLinks;
73
+ }
74
+ /** What `animate` asks of a Batch's binding (#665): its tracks, and its Segments in a sequence. */
75
+ export interface BatchCalls {
76
+ /** An `animate` call's track over its members, or the members `members` names, driven by `head`. */
77
+ track(call: BatchCall): Spine.ImperativeTrack;
78
+ /** The members a Batch or a member's handle names: `undefined` for every member, none once a handle's member has left. */
79
+ namedOf(entry: BatchEntry): ReadonlyArray<number> | undefined;
80
+ /** A sequence's Segment of the Batch, or of the members `named` names: its members' entries, in member order, and its values for core. */
81
+ segmentOf(named: ReadonlyArray<number> | undefined, target: Readonly<Record<string, unknown>>): {
82
+ readonly subjects: ReadonlyArray<BatchMember>;
83
+ readonly values: Readonly<Record<string, Sequence.Value>>;
84
+ };
85
+ /** A sequence's track over its members, each through its own Batch keys' stops, driven by `head`. */
86
+ sequenceTrack(call: BatchSequenceCall): Spine.ImperativeTrack;
87
+ }
88
+ /** What `animate` knows of a Batch or a member's handle: its binding, and a handle's member by its index. */
89
+ export interface BatchEntry {
90
+ readonly binding: BatchCalls;
91
+ readonly member: number | undefined;
92
+ }
93
+ /** A member's entry: a member's handle's, or a member's Subject's. */
94
+ export interface BatchMember extends BatchEntry {
95
+ readonly member: number;
96
+ }
97
+ /** An `animate` call of a Batch: its targets, its transition, its scope's settings, its Playhead and landing. */
98
+ export interface BatchCall {
99
+ readonly target: Readonly<Record<string, unknown>>;
100
+ readonly transition: Config.WardicTransition | undefined;
101
+ readonly reducedMotion: boolean;
102
+ readonly skipAnimations: boolean;
103
+ readonly head: Playback.Playhead;
104
+ readonly settled: () => void;
105
+ /** It ended with a key a later change took, never landing (#951). */
106
+ readonly taken: () => void;
107
+ /** The members it moves, in order: every member when left out. */
108
+ readonly members: ReadonlyArray<number> | undefined;
109
+ }
110
+ /** A sequence's part for a Batch: its members, in order, each one's compiled animation, its scope's settings, its Playhead and landing. */
111
+ export interface BatchSequenceCall {
112
+ readonly members: ReadonlyArray<number>;
113
+ readonly animations: ReadonlyArray<Sequence.Animation>;
114
+ readonly reducedMotion: boolean;
115
+ readonly skipAnimations: boolean;
116
+ readonly head: Playback.Playhead;
117
+ readonly settled: () => void;
118
+ /** It ended with a key a later change took, never landing (#951). */
119
+ readonly taken: () => void;
120
+ }
121
+ /** An `animate` call's parts for Subjects that are Batch members' (#665): each Batch's members, and each Subject's own keys. */
122
+ export interface CallParts<S extends object> {
123
+ readonly members: ReadonlyArray<{
124
+ readonly binding: BatchCalls;
125
+ readonly members: ReadonlyArray<number>;
126
+ readonly target: Readonly<Record<string, unknown>>;
127
+ }>;
128
+ readonly subjects: ReadonlyArray<{
129
+ readonly subject: S;
130
+ readonly index: number;
131
+ readonly target: object;
132
+ }>;
133
+ }
134
+ /** A compiled sequence's part for one Batch: its members, in the order they first appear, and each one's animation. */
135
+ export interface SequencePart {
136
+ readonly binding: BatchCalls;
137
+ readonly members: ReadonlyArray<number>;
138
+ readonly animations: ReadonlyArray<Sequence.Animation>;
139
+ }
140
+ /** An Environment's Batches, for `animate`: its handles, and the Subjects that are its members'. */
141
+ export interface Batches<S extends object> {
142
+ /** The Batch or member handle `given` is: `undefined` for anything else. */
143
+ entryOf(given: unknown): BatchEntry | undefined;
144
+ /** Whether any of `subjects` is a Batch member's: when none is, a call keeps the plain path. */
145
+ hasMembers(subjects: ReadonlyArray<S>): boolean;
146
+ /** A call's parts, when some of `subjects` are members': each Batch's members as one part, with its keys. */
147
+ callPartsOf(subjects: ReadonlyArray<S>, target: object): CallParts<S>;
148
+ /** A Segment's subjects: each member's as its member's entry, each Batch checking the Segment's values once. */
149
+ segmentSubjectsOf(subjects: ReadonlyArray<S>, target: Readonly<Record<string, unknown>>): ReadonlyArray<S | BatchMember>;
150
+ /** A compiled sequence's parts: each Batch's members as one part, the other keys of a member's its Subject's. */
151
+ sequencePartsOf<X>(compiled: ReadonlyArray<readonly [X | BatchMember, Sequence.Animation]>): {
152
+ readonly batches: ReadonlyArray<SequencePart>;
153
+ readonly others: ReadonlyArray<readonly [X | S, Sequence.Animation]>;
154
+ };
155
+ }
156
+ /** An Environment with no Batches. */
157
+ export declare const noBatches: Batches<object>;
158
+ /** What `animate` works with: its Environment's Subjects and Batches. */
159
+ export interface Ports<S extends object> {
160
+ readonly subjects: Subjects<S>;
161
+ readonly batches: Batches<S>;
162
+ }
163
+ /** The transition `T` without its `delay`, each arm: `animate`'s and a Segment's take their own. */
164
+ type WithoutDelayOf<T> = T extends unknown ? {
165
+ readonly [K in keyof T as Exclude<K, "delay">]: T[K];
166
+ } : never;
167
+ /** A transition without its `delay`, each arm. */
168
+ type WithoutDelay = WithoutDelayOf<Config.WardicTransition>;
169
+ /** `animate`'s options over the transition `T`: its `delay` each Subject's, and `onComplete`. */
170
+ type AnimateOptionsOver<T> = WithoutDelayOf<T> & EachDelay & {
171
+ readonly onComplete?: (() => void) | undefined;
172
+ };
173
+ /** A `delay` that may be each Subject's (Motion's `delay(i, n)`; `stagger()` is #436). */
174
+ interface EachDelay {
175
+ readonly delay?: number | ((index: number, count: number) => number) | undefined;
176
+ }
177
+ /**
178
+ * `animate`'s options: a transition, laid field by field over the target's own, its `delay` a number,
179
+ * or a function of each Subject's index and their count, such as `stagger(0.05)`; and `onComplete`,
180
+ * called as it lands, each Subject's `transitionEnd` already set. Motion's, though Motion's `animate`
181
+ * runs on the options alone.
182
+ */
183
+ export type WardicAnimateOptions = AnimateOptionsOver<Config.WardicTransition>;
184
+ /**
185
+ * {@link WardicAnimateOptions} for a Subject whose keys are `K`: its transition's entries are under
186
+ * `K`'s names, as {@link Config.WardicTransitionFor}'s, `default` for the rest.
187
+ */
188
+ export type WardicAnimateOptionsFor<K extends string> = AnimateOptionsOver<Config.WardicTransitionFor<Exclude<K, "onComplete">>>;
189
+ /** Where an animation is: `"idle"`, `"running"`, `"paused"` or `"finished"`. Motion's `AnimationPlayState`. */
190
+ export type WardicPlayState = "idle" | "running" | "paused" | "finished";
191
+ /**
192
+ * What `animate` returns: an animation's controls, and a promise of its landing, so it can be awaited.
193
+ * Motion's `AnimationPlaybackControls`.
194
+ */
195
+ export interface WardicPlaybackControls extends PromiseLike<void> {
196
+ /** Seconds played, a delay included. Set, it seeks: each key starts again there, holding while paused. */
197
+ time: number;
198
+ /** How fast it plays: 1 as given, 2 twice as fast, 0 held, below 0 backwards. */
199
+ speed: number;
200
+ /** How long it runs, in seconds: its longest Subject's longest key, a spring's to rest. */
201
+ readonly duration: number;
202
+ /**
203
+ * Where it is: `"running"`, `"paused"`, `"finished"` once it lands, and `"idle"` after `stop()` or
204
+ * `cancel()`, or once a later animation has taken one of its keys and the rest have landed.
205
+ */
206
+ readonly state: WardicPlayState;
207
+ /**
208
+ * Resolves when it lands, or at `complete()`; never at `stop()` or `cancel()`, nor once a later
209
+ * animation takes one of its keys, as Motion's.
210
+ */
211
+ readonly finished: Promise<void>;
212
+ /** Play it on: from where it's paused, or again from its start once it's finished or cancelled. Not after `stop()`. */
213
+ readonly play: () => void;
214
+ /** Hold it where it is. */
215
+ readonly pause: () => void;
216
+ /** End it where it is, for good: its keys stay there. */
217
+ readonly stop: () => void;
218
+ /** End it, and put its keys back where it started them. */
219
+ readonly cancel: () => void;
220
+ /** Go to its end at once, and finish. */
221
+ readonly complete: () => void;
222
+ }
223
+ /** What a scope hears of its animations: each one's start and its end, however it ended. */
224
+ export interface AnimationWatch {
225
+ readonly started: (controls: WardicPlaybackControls) => void;
226
+ /** It's no longer in flight: `landed` when it finished. */
227
+ readonly ended: (controls: WardicPlaybackControls, landed: boolean) => void;
228
+ }
229
+ /** An animation of no Subject: finished at once (a server's, or a subject that matched none). */
230
+ export declare const finishedControls: () => WardicPlaybackControls;
231
+ /**
232
+ * Where a Segment starts in a sequence: seconds in, `1.5`; after or before the end of the Segment
233
+ * before, `"+0.5"` or `"-0.5"`; at its start, `"<"`, or around it, `"<+0.5"` or `"<-0.5"`; or a label's
234
+ * name. Motion's `SequenceTime`.
235
+ */
236
+ export type WardicSequenceTime = number | "<" | `+${number}` | `-${number}` | `<+${number}` | `<-${number}` | (string & {});
237
+ /** A label in a sequence: a name for where the Segment before ends, or `{ name, at }` for a time of its own. Motion's. */
238
+ export type WardicSequenceLabel = string | {
239
+ readonly name: string;
240
+ readonly at: WardicSequenceTime;
241
+ };
242
+ /**
243
+ * A Segment's options: a transition, with a value's own entries laid over it; its `delay`, a number or
244
+ * a function of each Subject's index and count, such as `stagger(0.05)`; and `at`, where it starts. A
245
+ * spring through two stops or fewer plays as an easing over its time to rest. Motion's.
246
+ */
247
+ export type WardicSegmentOptions = WithoutDelay & EachDelay & {
248
+ readonly at?: WardicSequenceTime | undefined;
249
+ };
250
+ /** A Segment's values: each a value or a list of keyframes, as a target's. */
251
+ export type WardicSegmentTarget = Omit<Config.WardicTargetValues, "transition">;
252
+ /**
253
+ * A function Segment, `[callback, value?, options?]`: its callback is given a value each frame, from 0
254
+ * to 1 unless it gives its own stops, for what isn't a Subject's own value. Motion's, in place of its
255
+ * motion value Segments.
256
+ */
257
+ export type WardicFunctionSegment = readonly [callback: (value: number) => void] | readonly [callback: (value: number) => void, options: WardicSegmentOptions] | readonly [callback: (value: number) => void, value: number | Config.WardicKeyframes<number>, options: WardicSegmentOptions] | readonly [callback: (value: string) => void, value: string | Config.WardicKeyframes<string>, options: WardicSegmentOptions];
258
+ /**
259
+ * A sequence's options: `duration`, the whole sequence scaled to it; `delay`; `repeat`, `repeatType`
260
+ * and `repeatDelay`; `defaultTransition`, each Segment's when it gives none (a 0.3 s `easeOut` tween
261
+ * otherwise); and `onComplete`, called as it lands. Motion's `SequenceOptions`.
262
+ */
263
+ export interface WardicSequenceOptions {
264
+ readonly duration?: number | undefined;
265
+ readonly delay?: number | undefined;
266
+ readonly repeat?: number | undefined;
267
+ readonly repeatType?: "loop" | "reverse" | "mirror" | undefined;
268
+ readonly repeatDelay?: number | undefined;
269
+ readonly defaultTransition?: Config.WardicTransition | undefined;
270
+ readonly onComplete?: (() => void) | undefined;
271
+ }
272
+ /**
273
+ * An **Animation scope**'s `animate` (#433), over an Environment's {@link Ports}: `animate(subject,
274
+ * target, options?)`, a Batch's `animate(batch, target, options?)` and `animate(sequence, options?)`,
275
+ * each returning its Playback controls. `scope()` is handed to the Environment's {@link Subjects.resolve}
276
+ * (the DOM's selectors are looked up inside it); each animation is told to `watch` as it starts and
277
+ * ends. Every Subject's legs start in the call, on the loop by the end of its task. An Environment
278
+ * types its own overloads over it.
279
+ */
280
+ export declare const make: <S extends object>(env: AnimateEnv, ports: Ports<S>, scope: () => unknown, watch: AnimationWatch) => (first: unknown, second?: unknown, third?: WardicAnimateOptions) => WardicPlaybackControls;
281
+ /** Whether `given` is a sequence rather than a subject (#433, Motion's `isSequence`): a list with a Segment, itself a list, in it; a list of Subjects has none. A binding whose `animate` is its own tells the forms apart by it (#798). */
282
+ export declare const isSequence: (given: unknown) => given is ReadonlyArray<unknown>;
283
+ /**
284
+ * Whether a Segment animates anything under `scope` (#798): a function Segment does, and a Batch's; a
285
+ * Segment of Subjects when its subject names one; a label (a string, or `{ name, at }`) never. What a
286
+ * binding asks of a sequence before it plays it, since one that animates nothing lands at once.
287
+ */
288
+ export declare const segmentAnimates: <S extends object>(ports: Ports<S>, segment: unknown, scope: unknown) => boolean;
289
+ /** `watch`, with `also` told each start and end after it, when given: a scope's own watch beside its owner's (#433), a binding's beside a scope's (#798). */
290
+ export declare const alsoTold: (watch: AnimationWatch, also: AnimationWatch | undefined) => AnimationWatch;
291
+ export {};
292
+ //# sourceMappingURL=Imperative.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Imperative.d.ts","sourceRoot":"","sources":["../../src/unstable/Imperative.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAKH,OAAO,KAAK,KAAK,iBAAiB,MAAM,yBAAyB,CAAA;AAIjE,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAA;AAC1C,OAAO,KAAK,aAAa,MAAM,qBAAqB,CAAA;AACpD,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAA;AAE1C,OAAO,KAAK,KAAK,MAAM,MAAM,aAAa,CAAA;AAC1C,OAAO,KAAK,KAAK,SAAS,MAAM,gBAAgB,CAAA;AAChD,OAAO,KAAK,KAAK,aAAa,MAAM,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