@mkbabb/keyframes.js 4.0.0 → 4.2.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/README.md +397 -65
- package/dist/{animate-DjKYCuyH.js → animate-WjeAtXAe.js} +2 -2
- package/dist/{animations-CK1FLX_G.js → animations-WlZvjmDT.js} +2 -2
- package/dist/draw-svg-Dm9f0vTl.js +41 -0
- package/dist/{engine-BZeJ58xD.js → engine-Gk4Q7ltr.js} +204 -152
- package/dist/keyframes.d.ts +237 -28
- package/dist/keyframes.js +14 -8
- package/dist/{motion-path-723lMAlR.js → motion-path-DQ73oD2j.js} +1 -1
- package/dist/{springTimingFunction-BgkJPP-_.js → springTimingFunction-DMb11kBe.js} +1 -1
- package/dist/{timeline-5rnU0j6r.js → timeline-CPT7qUV1.js} +12 -11
- package/package.json +229 -131
package/dist/keyframes.d.ts
CHANGED
|
@@ -74,8 +74,16 @@ declare class Animation_2<V extends Vars = any> {
|
|
|
74
74
|
* accessors (`templateFrames`/`parsedVars`/`frames`/`frameId`) to it.
|
|
75
75
|
* Assigned in the constructor once `options` exists (the compiler holds a
|
|
76
76
|
* live reference to that options object).
|
|
77
|
+
*
|
|
78
|
+
* READ-ONLY surface (G.W19): the backing `_compiler` is written ONLY by the
|
|
79
|
+
* constructor and {@link adoptCompiled}. An external `animation.compiler = …`
|
|
80
|
+
* write was the one cross-boundary reach-in vector that could desync the
|
|
81
|
+
* live-options reference (`this.options !== this.compiler.options`); making
|
|
82
|
+
* `compiler` a get-only accessor makes that reach-in a COMPILE error, not a
|
|
83
|
+
* convention. Adopt a compiled state via `adoptCompiled(source)`.
|
|
77
84
|
*/
|
|
78
|
-
|
|
85
|
+
private _compiler;
|
|
86
|
+
get compiler(): FrameCompiler<V>;
|
|
79
87
|
/**
|
|
80
88
|
* THE rAF owner for this animation — the standalone rAF play loop and
|
|
81
89
|
* the WAAPI shadow tick both ride it, so `stop()` halts either
|
|
@@ -168,6 +176,29 @@ declare class Animation_2<V extends Vars = any> {
|
|
|
168
176
|
addFrame<K extends V>(start: number | string | ValueUnit<number>, vars: Partial<K>, transform?: TransformFunction<K>, timingFunction?: InputAnimationOptions["timingFunction"]): Animation_2<K>;
|
|
169
177
|
/** Compile the template frames into the sampled `frames[]`. Chainable. */
|
|
170
178
|
parse(): this;
|
|
179
|
+
/**
|
|
180
|
+
* Adopt another animation's ALREADY-COMPILED state as ONE atomic motion
|
|
181
|
+
* (G.W19) — the first-class verb for the "single-compile, then transplant"
|
|
182
|
+
* pattern (E.W8 S0): a throwaway animation is built + compiled ONCE off the
|
|
183
|
+
* new keyframes, and the live animation adopts that compiled state without a
|
|
184
|
+
* second compile.
|
|
185
|
+
*
|
|
186
|
+
* The transplant moves the `{ compiler, options, unflatten }` triad together
|
|
187
|
+
* and re-binds the live-options reference BY CONSTRUCTION — `this.options` is
|
|
188
|
+
* read OFF the adopted compiler, so `this.options === this.compiler.options`
|
|
189
|
+
* holds without relying on the caller's assignment order. This is the
|
|
190
|
+
* invariant the demo formerly held by a comment + three ordered field writes;
|
|
191
|
+
* here it is the method's contract, enforced by `proof:adopt-compiled`. A
|
|
192
|
+
* `compiler` adopted WITHOUT re-binding `options` would leave the setters
|
|
193
|
+
* mutating one object while the compiler reads another — the exact desync
|
|
194
|
+
* the `6e29236` live-options lock guards against.
|
|
195
|
+
*
|
|
196
|
+
* Recomputes `_stableKeys` so `flatKeys` (the buffer-sizing contract)
|
|
197
|
+
* reflects the adopted compiled frames, not the pre-adopt key-set. Chainable.
|
|
198
|
+
*
|
|
199
|
+
* @param source an animation whose `compiler` is already compiled.
|
|
200
|
+
*/
|
|
201
|
+
adoptCompiled(source: Animation_2<V>): this;
|
|
171
202
|
/**
|
|
172
203
|
* Recompute `_stableKeys` — the union of every compiled frame's `flatVars`
|
|
173
204
|
* keys — after a (re)compile. The maximal key-set the `clearBuffer`
|
|
@@ -253,8 +284,9 @@ declare class Animation_2<V extends Vars = any> {
|
|
|
253
284
|
* (F.W4 S3 — so the single-frame path can alias `flatVars` with no copy).
|
|
254
285
|
*/
|
|
255
286
|
private processFrame;
|
|
256
|
-
|
|
257
|
-
|
|
287
|
+
/** SYNC unless `delay > 0` — then a thenable resolving after the sleep. */
|
|
288
|
+
onStart(): Promise<void> | undefined;
|
|
289
|
+
onEnd(): void;
|
|
258
290
|
/**
|
|
259
291
|
* Advance the playhead to absolute clock `t` (a rAF timestamp, NOT a
|
|
260
292
|
* delta). Lazily runs `onStart` on the first call, reconciles the
|
|
@@ -262,13 +294,22 @@ declare class Animation_2<V extends Vars = any> {
|
|
|
262
294
|
* duration. This is the DRIVER-layer advance — the one meaning of the
|
|
263
295
|
* absolute-clock step, distinct from the `tickDt(dt)` stepper surface
|
|
264
296
|
* the rest of the engine canonicalized to.
|
|
297
|
+
*
|
|
298
|
+
* SYNC on the steady path (J.W6 S1 — the F.W5 held half, landed): every
|
|
299
|
+
* post-start frame returns a plain number (no per-frame promise+microtask
|
|
300
|
+
* hop); a thenable ONLY when the FIRST tick awaits the genuinely-async
|
|
301
|
+
* delay sleep. Ordering locked by proof:event-ordering.
|
|
265
302
|
*/
|
|
266
|
-
advanceTo(t: number): Promise<number>;
|
|
303
|
+
advanceTo(t: number): number | Promise<number>;
|
|
304
|
+
/** The post-start advance body — pause clock, local time, iteration end. */
|
|
305
|
+
private _advance;
|
|
267
306
|
/**
|
|
268
307
|
* One frame of the standalone rAF play path, driven by the shared
|
|
269
308
|
* `RAFPlayback.loop`. Returns whether the loop should continue.
|
|
270
309
|
*/
|
|
271
310
|
private _frame;
|
|
311
|
+
/** The post-advance render half of `_frame` — paint, or settle on done. */
|
|
312
|
+
private _renderFrame;
|
|
272
313
|
private _resolvePlay;
|
|
273
314
|
/** Internal rAF-based play loop — loop ownership rides `this.playback`. */
|
|
274
315
|
private _playRAF;
|
|
@@ -309,6 +350,17 @@ declare class Animation_2<V extends Vars = any> {
|
|
|
309
350
|
* WAAPI animation cancels the compositor handles before settling.
|
|
310
351
|
*/
|
|
311
352
|
private _snapToReducedMotion;
|
|
353
|
+
/**
|
|
354
|
+
* The completion front-door (G.W13) — `await anim.finished` resolves once
|
|
355
|
+
* the in-flight play settles. It exposes the ONE held `_playingPromise`
|
|
356
|
+
* `play()` already constructs (the re-entrant guard returns it; the
|
|
357
|
+
* `finally`-clear nulls it on settle) — NOT a second completion lifecycle.
|
|
358
|
+
* Two reads mid-play return the SAME promise. A settled (or never-played)
|
|
359
|
+
* animation reads `null` and resolves immediately: "not running" = "nothing
|
|
360
|
+
* to await" — the honest semantics for a getter that reports current
|
|
361
|
+
* settledness, not a pre-armed future run.
|
|
362
|
+
*/
|
|
363
|
+
get finished(): Promise<void>;
|
|
312
364
|
play(): Promise<void>;
|
|
313
365
|
/**
|
|
314
366
|
* Pause playback — idempotent. Pausing an already-paused (or
|
|
@@ -368,6 +420,9 @@ export declare interface AnimationEngine {
|
|
|
368
420
|
/** CSS-native MotionPath (F.W12) — offset-distance over an author offset-path. */
|
|
369
421
|
MotionPath: typeof MotionPath;
|
|
370
422
|
fromMotionPath: typeof fromMotionPath;
|
|
423
|
+
/** CSS-native DrawSVG (G.W13) — stroke-dashoffset sweep over the path length. */
|
|
424
|
+
DrawSVG: typeof DrawSVG;
|
|
425
|
+
fromDrawSVG: typeof fromDrawSVG;
|
|
371
426
|
/**
|
|
372
427
|
* The preset library (`fadeIn`, `bounce`, `shake`, …) — heavy (each returns
|
|
373
428
|
* a `CSSKeyframesAnimation`), so it rides the dynamic boundary as a namespace
|
|
@@ -409,6 +464,14 @@ export declare interface AnimationFrame<V extends Vars> {
|
|
|
409
464
|
|
|
410
465
|
export declare class AnimationGroup<V extends Vars> {
|
|
411
466
|
animations: AnimationGroupObject<V>;
|
|
467
|
+
/**
|
|
468
|
+
* The group's composite transform. Defaults to a real no-op at the FIELD
|
|
469
|
+
* (I.W0 S3) — NOT a lying definite-assignment assertion. A childless or
|
|
470
|
+
* pre-`parse()` group (e.g. the empty HOME backdrop) composites nothing,
|
|
471
|
+
* so `transformFramesGrouped` calls a harmless no-op instead of throwing
|
|
472
|
+
* `this.transform is not a function` (B1/E1). The constructor overrides
|
|
473
|
+
* this with the first child's transform when one exists.
|
|
474
|
+
*/
|
|
412
475
|
transform: TransformFunction<V>;
|
|
413
476
|
superKey: string | undefined;
|
|
414
477
|
paused: boolean;
|
|
@@ -516,12 +579,17 @@ export declare class AnimationGroup<V extends Vars> {
|
|
|
516
579
|
*/
|
|
517
580
|
setChildTime(nameOrAnim: string | Animation_2<V>, t: number): this;
|
|
518
581
|
/**
|
|
519
|
-
* Advance all child animations to absolute clock `t`.
|
|
520
|
-
*
|
|
521
|
-
*
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
582
|
+
* Advance all child animations to absolute clock `t`. SYNC on the steady
|
|
583
|
+
* path (J.W6 S1): children that all step synchronously advance the group
|
|
584
|
+
* with no per-frame `Promise.all`/microtask hop; a thenable only on a
|
|
585
|
+
* genuinely-async child or the over-`YIELD_BATCH` yield path.
|
|
586
|
+
*/
|
|
587
|
+
advanceTo(t: number): this | Promise<this>;
|
|
588
|
+
/** Batched advance — yield to the main thread between batches. */
|
|
589
|
+
private _advanceBatched;
|
|
590
|
+
/** The post-advance tail — `onEnd` once the render marked done. */
|
|
591
|
+
private _endAdvance;
|
|
592
|
+
/** Advance one slice — `undefined` iff every child stepped sync. */
|
|
525
593
|
private _advanceSlice;
|
|
526
594
|
/**
|
|
527
595
|
* One frame of the group's draw loop, driven by the shared
|
|
@@ -530,6 +598,8 @@ export declare class AnimationGroup<V extends Vars> {
|
|
|
530
598
|
* Returns whether the loop should continue.
|
|
531
599
|
*/
|
|
532
600
|
private _frame;
|
|
601
|
+
/** The post-advance render half of `_frame` — composite, or settle. */
|
|
602
|
+
private _renderFrame;
|
|
533
603
|
private _resolvePlay;
|
|
534
604
|
/**
|
|
535
605
|
* Start the animation group. Returns a promise that resolves
|
|
@@ -541,6 +611,14 @@ export declare class AnimationGroup<V extends Vars> {
|
|
|
541
611
|
* query, snaps every child to its final frame in a single composite —
|
|
542
612
|
* no rAF draw loop — then settles exactly as a completed play would.
|
|
543
613
|
*/
|
|
614
|
+
/**
|
|
615
|
+
* The completion front-door (G.W13) — `await group.finished` resolves once
|
|
616
|
+
* the in-flight composite play settles. Exposes the ONE held
|
|
617
|
+
* `_playingPromise` `play()` constructs (the re-entrant guard returns it;
|
|
618
|
+
* the `finally`-clear nulls it on settle) — NOT a second completion
|
|
619
|
+
* lifecycle. A settled (or never-played) group resolves immediately.
|
|
620
|
+
*/
|
|
621
|
+
get finished(): Promise<void>;
|
|
544
622
|
play(): Promise<void>;
|
|
545
623
|
/**
|
|
546
624
|
* `prefers-reduced-motion` snap for the group: rest = final, paint it,
|
|
@@ -643,6 +721,19 @@ export declare interface AnimationLayerConfig {
|
|
|
643
721
|
properties?: Set<string>;
|
|
644
722
|
}
|
|
645
723
|
|
|
724
|
+
/** Thrown when an animation option receives malformed (non-undefined) input. */
|
|
725
|
+
export declare class AnimationOptionError extends Error {
|
|
726
|
+
readonly option: string;
|
|
727
|
+
readonly value: unknown;
|
|
728
|
+
/**
|
|
729
|
+
* Stable structured reason for programmatic consumers — branch on this,
|
|
730
|
+
* never on the human message. Carried only by the two named rows
|
|
731
|
+
* ({@link AnimationOptionErrorCode}); undefined otherwise.
|
|
732
|
+
*/
|
|
733
|
+
readonly code?: AnimationOptionErrorCode;
|
|
734
|
+
constructor(option: string, value: unknown, reason: string, code?: AnimationOptionErrorCode);
|
|
735
|
+
}
|
|
736
|
+
|
|
646
737
|
/**
|
|
647
738
|
* Typed option-validation errors — the fail-explicit seam.
|
|
648
739
|
*
|
|
@@ -656,12 +747,19 @@ export declare interface AnimationLayerConfig {
|
|
|
656
747
|
*
|
|
657
748
|
* Value.js-free: light modules import these without touching the boundary.
|
|
658
749
|
*/
|
|
659
|
-
/**
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
750
|
+
/**
|
|
751
|
+
* The stable, machine-branchable reasons a typed option error can carry
|
|
752
|
+
* (J.W1 S8, K3-internal). EXACTLY the two engine-internal rows the
|
|
753
|
+
* ingestion lane folds into J.W1 — a structured `code` ON the typed throw,
|
|
754
|
+
* NOT a diagnostics channel (the full `Diagnostic[]` surface stays a K.W0
|
|
755
|
+
* seed item):
|
|
756
|
+
*
|
|
757
|
+
* - `EMPTY_PARSE` — a blank/whitespace-only keyframe selector reached the
|
|
758
|
+
* compile seam (the H-A2 "......" class, named).
|
|
759
|
+
* - `UNKNOWN_TIMING_FN` — a present-but-unresolvable timing function (not a
|
|
760
|
+
* callable, a registry name, or a cubic-bezier()/steps() literal).
|
|
761
|
+
*/
|
|
762
|
+
declare type AnimationOptionErrorCode = "EMPTY_PARSE" | "UNKNOWN_TIMING_FN";
|
|
665
763
|
|
|
666
764
|
export declare type AnimationOptions = {
|
|
667
765
|
duration: number;
|
|
@@ -1030,6 +1128,45 @@ export declare interface DragOptions {
|
|
|
1030
1128
|
/** A drag emission: the spring's current position + velocity. */
|
|
1031
1129
|
export declare type DragSubscriber = (value: number, velocity: number) => void;
|
|
1032
1130
|
|
|
1131
|
+
/**
|
|
1132
|
+
* `DrawSVG` — the class form of {@link fromDrawSVG}, for callers who prefer a
|
|
1133
|
+
* named primitive alongside `CSSKeyframesAnimation` / `MotionPath`. Construction
|
|
1134
|
+
* is the factory: `new DrawSVG(target).animation` is the control handle. The
|
|
1135
|
+
* factory is the canonical entry; this is a thin ergonomic wrapper.
|
|
1136
|
+
*/
|
|
1137
|
+
declare class DrawSVG<V extends Record<string, any> = any> {
|
|
1138
|
+
/** The underlying stroke-dashoffset animation — the control handle. */
|
|
1139
|
+
readonly animation: CSSKeyframesAnimation<V>;
|
|
1140
|
+
constructor(target: SVGDrawTarget, options?: DrawSVGOptions);
|
|
1141
|
+
/** Start (or re-enter) the line-drawing play loop. */
|
|
1142
|
+
play(): Promise<void>;
|
|
1143
|
+
/** Pause the play loop, retaining the playhead. */
|
|
1144
|
+
pause(): this;
|
|
1145
|
+
/** Halt and rewind the play loop. */
|
|
1146
|
+
stop(): this;
|
|
1147
|
+
/** Resolve once the draw completes — the {@link Animation.finished} front-door. */
|
|
1148
|
+
get finished(): Promise<void>;
|
|
1149
|
+
}
|
|
1150
|
+
|
|
1151
|
+
export declare interface DrawSVGOptions extends Partial<InputAnimationOptions> {
|
|
1152
|
+
/**
|
|
1153
|
+
* Start of the draw sweep — a percent STRING (`"0%"` → `"100%"`) or a 0..1
|
|
1154
|
+
* NUMBER fraction (`0` → `1`), the two unambiguous forms. Default `"0%"` —
|
|
1155
|
+
* the stroke starts undrawn (full `stroke-dashoffset`) and draws IN; `"100%"`
|
|
1156
|
+
* → `"0%"` (or `1` → `0`) erases it. A number outside `[0, 1]` throws (a
|
|
1157
|
+
* percent must be a string — no silent `50`-means-5000% footgun).
|
|
1158
|
+
*/
|
|
1159
|
+
from?: string | number;
|
|
1160
|
+
/** End of the draw sweep — same `"100%"`/`1` two-form contract. Default `"100%"`. */
|
|
1161
|
+
to?: string | number;
|
|
1162
|
+
/**
|
|
1163
|
+
* Auto-start the play loop after construction + targeting. Default true.
|
|
1164
|
+
* `false` returns a constructed, targeted, NOT-yet-playing handle so the
|
|
1165
|
+
* caller can drive the returned animation (`.play()` / `.pause()` / `.stop()`).
|
|
1166
|
+
*/
|
|
1167
|
+
autoPlay?: boolean;
|
|
1168
|
+
}
|
|
1169
|
+
|
|
1033
1170
|
/**
|
|
1034
1171
|
* The typed easing value — a callable curve plus, when one exists, the CSS
|
|
1035
1172
|
* easing string that reproduces it (e.g. a spring's `linear()` stops).
|
|
@@ -1165,7 +1302,7 @@ export declare interface FlipOptions {
|
|
|
1165
1302
|
export declare function flipShared(a: HTMLElement, b: HTMLElement, options?: FlipOptions): Promise<void>;
|
|
1166
1303
|
|
|
1167
1304
|
declare class FrameCompiler<V extends Vars = any> {
|
|
1168
|
-
private
|
|
1305
|
+
private readonly _options;
|
|
1169
1306
|
templateFrames: TemplateAnimationFrame<V>[];
|
|
1170
1307
|
parsedVars: ParsedVarMap[];
|
|
1171
1308
|
frames: AnimationFrame<V>[];
|
|
@@ -1187,8 +1324,16 @@ declare class FrameCompiler<V extends Vars = any> {
|
|
|
1187
1324
|
* the only baked state that depends on them). No setter silently no-ops a
|
|
1188
1325
|
* change to compiled state.
|
|
1189
1326
|
*/
|
|
1190
|
-
constructor(
|
|
1191
|
-
|
|
1327
|
+
constructor(_options: AnimationOptions);
|
|
1328
|
+
/**
|
|
1329
|
+
* The live options object the compiler reads (a REFERENCE to the owning
|
|
1330
|
+
* `Animation`'s `options` — the setters mutate it in place). Read-only:
|
|
1331
|
+
* the compiler never replaces it. Exposed so `Animation.adoptCompiled`
|
|
1332
|
+
* can re-bind `Animation.options` to the adopted compiler's options object
|
|
1333
|
+
* BY CONSTRUCTION (`this.options === this.compiler.options`, the live-options
|
|
1334
|
+
* invariant — G.W19 / the `6e29236` lock), without poking a private field.
|
|
1335
|
+
*/
|
|
1336
|
+
get options(): AnimationOptions;
|
|
1192
1337
|
addFrame<K extends V>(start: number | string | ValueUnit<number>, vars: Partial<K>, transform?: TransformFunction<K>, timingFunction?: InputAnimationOptions["timingFunction"]): void;
|
|
1193
1338
|
createFrame(startIx: number, endIx: number): AnimationFrame<V>;
|
|
1194
1339
|
/**
|
|
@@ -1237,6 +1382,32 @@ declare class FrameCompiler<V extends Vars = any> {
|
|
|
1237
1382
|
renormalizeColors(): void;
|
|
1238
1383
|
}
|
|
1239
1384
|
|
|
1385
|
+
/**
|
|
1386
|
+
* Build a CSS-native SVG line-drawing animation: read the target's path length
|
|
1387
|
+
* ONCE, set `stroke-dasharray` to that length (one solid full-length dash), and
|
|
1388
|
+
* sweep `stroke-dashoffset` from → to (default `0% → 100%` ⇒ offset `L → 0`,
|
|
1389
|
+
* the line draws in). Returns the constructed {@link CSSKeyframesAnimation} as
|
|
1390
|
+
* the control handle (the `animate()` contract — `.play()` / `.pause()` /
|
|
1391
|
+
* `.stop()` / `.finished`), consistent with the `from*` factory family.
|
|
1392
|
+
*
|
|
1393
|
+
* The returned animation passes the EXISTING WAAPI eligibility gate
|
|
1394
|
+
* (`isWAAPIEligible`) for an SVG DOM target with a uniform CSS-twin easing, and
|
|
1395
|
+
* delegates compositor-thread via `playWAAPI` — no new eligibility predicate.
|
|
1396
|
+
*
|
|
1397
|
+
* The line length `L` is read a SINGLE time at construction (the
|
|
1398
|
+
* `motion-path.ts` "browser owns the geometry" pattern). A path mutated mid-draw
|
|
1399
|
+
* is a re-construct, not a per-frame re-measure — a per-frame `getTotalLength`
|
|
1400
|
+
* would be a layout round-trip the Mandate's measure-first forbids.
|
|
1401
|
+
*
|
|
1402
|
+
* @param target an SVG geometry element exposing `getTotalLength()`.
|
|
1403
|
+
* @param options `{ from?, to?, ...animationOptions }`.
|
|
1404
|
+
*
|
|
1405
|
+
* @example
|
|
1406
|
+
* // Draw a path stroke in over 2s:
|
|
1407
|
+
* fromDrawSVG(pathEl, { duration: 2000 });
|
|
1408
|
+
*/
|
|
1409
|
+
declare function fromDrawSVG<V extends Record<string, any> = any>(target: SVGDrawTarget, options?: DrawSVGOptions): CSSKeyframesAnimation<V>;
|
|
1410
|
+
|
|
1240
1411
|
/**
|
|
1241
1412
|
* Build a CSS-native path-motion animation: set the author `offset-path` (and
|
|
1242
1413
|
* optional `offset-rotate`) on the target(s), and sweep `offset-distance` from
|
|
@@ -1497,7 +1668,7 @@ export declare interface NumericAnimationOptions {
|
|
|
1497
1668
|
* When true, honor `prefers-reduced-motion: reduce` by snapping to the
|
|
1498
1669
|
* final keyframe values immediately rather than interpolating over
|
|
1499
1670
|
* `duration`. The play promise resolves on the next microtask. Default
|
|
1500
|
-
* false (
|
|
1671
|
+
* false (conservative default — opt in to the reduced-motion snap).
|
|
1501
1672
|
*
|
|
1502
1673
|
* The check uses `matchMedia` if available; on SSR / Node the option
|
|
1503
1674
|
* is a no-op (animations proceed normally).
|
|
@@ -1582,10 +1753,12 @@ declare const pulse: (options?: InputAnimationOptions) => CSSKeyframesAnimation<
|
|
|
1582
1753
|
* - {@link drive} — settle-based dt loop over a {@link Tickable}
|
|
1583
1754
|
* (`SmoothProgress`, `SpringProgress`): steps until the stepper settles,
|
|
1584
1755
|
* auto-stopping; idempotent so target re-seats can re-arm it.
|
|
1585
|
-
* - {@link loop} — self-rescheduling frame loop over
|
|
1756
|
+
* - {@link loop} — self-rescheduling frame loop over a maybe-async callback
|
|
1586
1757
|
* (`Animation`, `AnimationGroup`, the WAAPI shadow tick): the callback
|
|
1587
|
-
* returns `true` to continue;
|
|
1588
|
-
*
|
|
1758
|
+
* returns `true` to continue; a thenable result defers rescheduling until
|
|
1759
|
+
* it resolves, so a slow async frame never double-schedules, while a
|
|
1760
|
+
* sync frame (the steady `Animation`/group `_frame`, J.W6 S1) reschedules
|
|
1761
|
+
* inline on the sync fast-path.
|
|
1589
1762
|
*
|
|
1590
1763
|
* Because all three ride one core, none can diverge — the generation guard
|
|
1591
1764
|
* that makes `loop` safe against a `stop()` + restart mid-frame protects
|
|
@@ -1595,6 +1768,21 @@ declare const pulse: (options?: InputAnimationOptions) => CSSKeyframesAnimation<
|
|
|
1595
1768
|
* `SpringProgress` `_startLoop`/`_stopLoop` byte-siblings, the
|
|
1596
1769
|
* `AnimationGroup` draw loop, `Animation._playRAF`, and the WAAPI shadow
|
|
1597
1770
|
* loop — all delegate here. No other module owns a rAF handle.
|
|
1771
|
+
*
|
|
1772
|
+
* BIND-PROOF BY CONSTRUCTION (I.W1 S1). The public control surface —
|
|
1773
|
+
* `play`/`drive`/`loop`/`stop` — is declared as ARROW CLASS-FIELDS, not
|
|
1774
|
+
* prototype methods, so each captures `this` at construction. A consumer can
|
|
1775
|
+
* `const { stop } = playback`, pass `playback.stop` straight as a callback, or
|
|
1776
|
+
* call `playback.stop()` as a member — ALL THREE are safe, forever, because the
|
|
1777
|
+
* receiver can never be dropped. This closes the entire unbound-method crash
|
|
1778
|
+
* class at the engine seam (the `this._gen++` throw a free-standing `stop()`
|
|
1779
|
+
* used to raise inside a Vue reactive flush — `rootcause-rc-dfa-gen.md`):
|
|
1780
|
+
* binding correctness lives ONCE here, never re-asserted per call site. The
|
|
1781
|
+
* arrow fields move these four methods onto the INSTANCE rather than the
|
|
1782
|
+
* prototype — a per-instance allocation accepted because `RAFPlayback`
|
|
1783
|
+
* instances are FEW and long-lived (one per scene/animation). The private
|
|
1784
|
+
* `_run`/`_cleanup` stay prototype methods: they are only ever reached as
|
|
1785
|
+
* `this._run(…)` internally, never extracted as values, so they need no bind.
|
|
1598
1786
|
*/
|
|
1599
1787
|
export declare class RAFPlayback {
|
|
1600
1788
|
private _rafId;
|
|
@@ -1635,14 +1823,14 @@ export declare class RAFPlayback {
|
|
|
1635
1823
|
* `onTick(1)` fires once, no rAF loop is spawned, and the promise
|
|
1636
1824
|
* resolves on the next microtask.
|
|
1637
1825
|
*/
|
|
1638
|
-
play(duration: number, onTick: (progress: number) => void, options?: RAFPlaybackOptions)
|
|
1826
|
+
play: (duration: number, onTick: (progress: number) => void, options?: RAFPlaybackOptions) => Promise<void>;
|
|
1639
1827
|
/**
|
|
1640
1828
|
* Drive a {@link Tickable}'s dt-stepper once per frame until it
|
|
1641
1829
|
* settles, invoking `onFrame` after each step. Idempotent — a call
|
|
1642
1830
|
* while the loop is already running is a no-op, so consumers re-arm
|
|
1643
1831
|
* freely on every target re-seat. The loop auto-stops on settle.
|
|
1644
1832
|
*/
|
|
1645
|
-
drive(tickable: Tickable, onFrame?: () => void)
|
|
1833
|
+
drive: (tickable: Tickable, onFrame?: () => void) => void;
|
|
1646
1834
|
/**
|
|
1647
1835
|
* Self-rescheduling frame loop over an async callback. `cb(now)`
|
|
1648
1836
|
* returns `true` to continue; the next frame is scheduled only after
|
|
@@ -1650,9 +1838,9 @@ export declare class RAFPlayback {
|
|
|
1650
1838
|
* between frames halts the loop — the in-flight callback finishes,
|
|
1651
1839
|
* no further frame is scheduled.
|
|
1652
1840
|
*/
|
|
1653
|
-
loop(cb: (now: number) => boolean | Promise<boolean>)
|
|
1841
|
+
loop: (cb: (now: number) => boolean | Promise<boolean>) => void;
|
|
1654
1842
|
/** Cancel a running playback. A pending play promise resolves immediately. */
|
|
1655
|
-
stop()
|
|
1843
|
+
stop: () => void;
|
|
1656
1844
|
private _cleanup;
|
|
1657
1845
|
}
|
|
1658
1846
|
|
|
@@ -1886,6 +2074,15 @@ export declare class Sequence<V extends Vars = any> {
|
|
|
1886
2074
|
* Under `respectReducedMotion` + an active query, snaps to the rest frame
|
|
1887
2075
|
* in one paint (a terminal `seek(duration)`), no draw loop.
|
|
1888
2076
|
*/
|
|
2077
|
+
/**
|
|
2078
|
+
* The completion front-door (G.W13) — `await sequence.finished` resolves
|
|
2079
|
+
* once the in-flight transport settles. Exposes the ONE held
|
|
2080
|
+
* `_playingPromise` `play()` constructs (the re-entrant guard returns it;
|
|
2081
|
+
* the `finally`-clear nulls it on settle) — NOT a second completion
|
|
2082
|
+
* lifecycle. A settled (or never-played, or reduced-motion-snapped)
|
|
2083
|
+
* sequence resolves immediately.
|
|
2084
|
+
*/
|
|
2085
|
+
get finished(): Promise<void>;
|
|
1889
2086
|
play(): Promise<void>;
|
|
1890
2087
|
private _frame;
|
|
1891
2088
|
/**
|
|
@@ -2086,7 +2283,8 @@ export declare interface SmoothProgressOptions {
|
|
|
2086
2283
|
* When true, honor `prefers-reduced-motion: reduce` by snapping to
|
|
2087
2284
|
* target immediately rather than damping. `setTarget` short-circuits
|
|
2088
2285
|
* the smooth-toward path; `play()` invokes `onFrame` once with the
|
|
2089
|
-
* target value. Default false (
|
|
2286
|
+
* target value. Default false (conservative default — opt in to the
|
|
2287
|
+
* reduced-motion snap).
|
|
2090
2288
|
*
|
|
2091
2289
|
* The check uses `matchMedia` if available; on SSR / Node the option
|
|
2092
2290
|
* is a no-op (animations proceed normally).
|
|
@@ -2473,6 +2671,17 @@ export declare interface StaggerOptions {
|
|
|
2473
2671
|
*/
|
|
2474
2672
|
export declare type StaggerOrigin = "first" | "last" | "center" | "edges" | number;
|
|
2475
2673
|
|
|
2674
|
+
/**
|
|
2675
|
+
* The minimal geometry contract DrawSVG needs: any SVG element that exposes
|
|
2676
|
+
* `getTotalLength()` (`SVGGeometryElement` — `<path>`, `<line>`, `<circle>`,
|
|
2677
|
+
* `<ellipse>`, `<rect>`, `<polygon>`, `<polyline>`). Narrower than `SVGElement`
|
|
2678
|
+
* so a non-geometry SVG node is a type error at the call site, not a runtime
|
|
2679
|
+
* surprise.
|
|
2680
|
+
*/
|
|
2681
|
+
export declare type SVGDrawTarget = SVGElement & {
|
|
2682
|
+
getTotalLength(): number;
|
|
2683
|
+
};
|
|
2684
|
+
|
|
2476
2685
|
export declare interface TemplateAnimationFrame<V extends Vars> {
|
|
2477
2686
|
id: number;
|
|
2478
2687
|
start: ValueUnit;
|
package/dist/keyframes.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as e, c as t, d as n, g as r, h as i, i as a, l as o, m as s, n as c, o as l, p as u, r as d, t as f, u as p } from "./timeline-
|
|
2
|
-
import { n as m, r as h, t as g } from "./springTimingFunction-
|
|
1
|
+
import { a as e, c as t, d as n, g as r, h as i, i as a, l as o, m as s, n as c, o as l, p as u, r as d, t as f, u as p } from "./timeline-CPT7qUV1.js";
|
|
2
|
+
import { n as m, r as h, t as g } from "./springTimingFunction-DMb11kBe.js";
|
|
3
3
|
//#region src/animation/numeric.ts
|
|
4
4
|
var _ = class {
|
|
5
5
|
keyframes;
|
|
@@ -372,6 +372,9 @@ var I = class {
|
|
|
372
372
|
for (let { animation: t } of this.entries) t.setTargets(...e);
|
|
373
373
|
return this;
|
|
374
374
|
}
|
|
375
|
+
get finished() {
|
|
376
|
+
return this._playingPromise ?? Promise.resolve();
|
|
377
|
+
}
|
|
375
378
|
play() {
|
|
376
379
|
if (this._playingPromise) return this._playingPromise;
|
|
377
380
|
if (this.respectReducedMotion && L()) return this.seek(this.duration), Promise.resolve();
|
|
@@ -441,17 +444,20 @@ var I = class {
|
|
|
441
444
|
return this._yoyoOn = e, this;
|
|
442
445
|
}
|
|
443
446
|
}, L = () => typeof matchMedia == "function" && matchMedia("(prefers-reduced-motion: reduce)").matches, R = async () => {
|
|
444
|
-
let [e, t, n, r] = await Promise.all([
|
|
445
|
-
import("./engine-
|
|
446
|
-
import("./animate-
|
|
447
|
-
import("./motion-path-
|
|
448
|
-
import("./
|
|
447
|
+
let [e, t, n, r, i] = await Promise.all([
|
|
448
|
+
import("./engine-Gk4Q7ltr.js"),
|
|
449
|
+
import("./animate-WjeAtXAe.js"),
|
|
450
|
+
import("./motion-path-DQ73oD2j.js"),
|
|
451
|
+
import("./draw-svg-Dm9f0vTl.js"),
|
|
452
|
+
import("./animations-WlZvjmDT.js")
|
|
449
453
|
]);
|
|
450
454
|
return Object.assign({
|
|
451
455
|
animate: t.animate,
|
|
452
456
|
MotionPath: n.MotionPath,
|
|
453
457
|
fromMotionPath: n.fromMotionPath,
|
|
454
|
-
|
|
458
|
+
DrawSVG: r.DrawSVG,
|
|
459
|
+
fromDrawSVG: r.fromDrawSVG,
|
|
460
|
+
presets: i
|
|
455
461
|
}, e);
|
|
456
462
|
};
|
|
457
463
|
//#endregion
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as e, o as t, s as n } from "./timeline-
|
|
1
|
+
import { c as e, o as t, s as n } from "./timeline-CPT7qUV1.js";
|
|
2
2
|
//#region src/animation/spring.ts
|
|
3
3
|
function r(t) {
|
|
4
4
|
let { visualDuration: n, duration: r, bounce: a = 0, ...o } = t, s = n ?? r ?? i.response, c = 1 - e(a, -1, 1);
|
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
var e = (e) => typeof e == "string" ? JSON.stringify(e) : typeof e == "function" ? `[function ${e.name || "anonymous"}]` : String(e), t = class extends Error {
|
|
3
3
|
option;
|
|
4
4
|
value;
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
code;
|
|
6
|
+
constructor(t, n, r, i) {
|
|
7
|
+
super(`Invalid value for animation option "${t}": ${e(n)} — ${r}`), this.name = "AnimationOptionError", this.option = t, this.value = n, i !== void 0 && (this.code = i);
|
|
7
8
|
}
|
|
8
9
|
}, n = class extends Error {
|
|
9
10
|
easingName;
|
|
@@ -25,7 +26,7 @@ var i = (e) => typeof e == "function" ? { fn: e } : e, a = /^(linear|ease|ease-i
|
|
|
25
26
|
async function c(e) {
|
|
26
27
|
let t;
|
|
27
28
|
try {
|
|
28
|
-
t = await import("./engine-
|
|
29
|
+
t = await import("./engine-Gk4Q7ltr.js");
|
|
29
30
|
} catch (t) {
|
|
30
31
|
throw Error(`keyframes: the engine chunk failed to load while resolving easing "${e}" — the easing registry is unreachable.`, { cause: t });
|
|
31
32
|
}
|
|
@@ -107,7 +108,7 @@ var S = class {
|
|
|
107
108
|
};
|
|
108
109
|
this._rafId = m(r);
|
|
109
110
|
}
|
|
110
|
-
play(e, t, n) {
|
|
111
|
+
play = (e, t, n) => {
|
|
111
112
|
if (e <= 0) throw Error("RAFPlayback.play() requires a duration > 0.");
|
|
112
113
|
return this.stop(), x(n?.respectReducedMotion, () => (t(1), Promise.resolve()), () => new Promise((n) => {
|
|
113
114
|
this._resolve = n, this._startTime = void 0, this._run((n) => {
|
|
@@ -116,19 +117,19 @@ var S = class {
|
|
|
116
117
|
return t(r), r < 1;
|
|
117
118
|
});
|
|
118
119
|
}));
|
|
119
|
-
}
|
|
120
|
-
drive(e, t) {
|
|
120
|
+
};
|
|
121
|
+
drive = (e, t) => {
|
|
121
122
|
this._rafId === null && (this._lastFrameT = 0, this._run((n) => {
|
|
122
123
|
let r = this._lastFrameT ? n - this._lastFrameT : 16.667;
|
|
123
124
|
return this._lastFrameT = n, e.tickDt(r), t?.(), !e.settled;
|
|
124
125
|
}));
|
|
125
|
-
}
|
|
126
|
-
loop(e) {
|
|
126
|
+
};
|
|
127
|
+
loop = (e) => {
|
|
127
128
|
this.stop(), this._run(e);
|
|
128
|
-
}
|
|
129
|
-
stop() {
|
|
129
|
+
};
|
|
130
|
+
stop = () => {
|
|
130
131
|
this._gen++, this._rafId !== null && h(this._rafId), this._cleanup();
|
|
131
|
-
}
|
|
132
|
+
};
|
|
132
133
|
_cleanup() {
|
|
133
134
|
this._rafId = null, this._startTime = void 0, this._lastFrameT = 0;
|
|
134
135
|
let e = this._resolve;
|