@mkbabb/keyframes.js 4.2.0 → 4.3.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.
@@ -1,8 +1,14 @@
1
+ import { AnimationRangeValue } from '@mkbabb/value.js';
2
+ import { AnimationTimelineValue } from '@mkbabb/value.js';
1
3
  import { ColorSpace } from '@mkbabb/value.js';
4
+ import { CSSTimelineOptions } from '@mkbabb/value.js';
2
5
  import { extractAnimationOptions } from '@mkbabb/value.js';
3
6
  import { HueInterpolationMethod } from '@mkbabb/value.js';
4
7
  import { InterpolatedVar } from '@mkbabb/value.js';
8
+ import { ParseDiagnostic } from '@mkbabb/value.js';
5
9
  import { PropertyDescriptor as PropertyDescriptor_2 } from '@mkbabb/value.js';
10
+ import { RangeBoundary } from '@mkbabb/value.js';
11
+ import { RangePhase } from '@mkbabb/value.js';
6
12
  import { Stylesheet } from '@mkbabb/value.js';
7
13
  import { timingFunctions } from '@mkbabb/value.js';
8
14
  import { ValueArray } from '@mkbabb/value.js';
@@ -10,6 +16,69 @@ import { ValueUnit } from '@mkbabb/value.js';
10
16
 
11
17
  declare const accordionExpand: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
12
18
 
19
+ /**
20
+ * The outcome of an {@link adoptRunning} takeover. `animation` is the kf object
21
+ * now driving the element (seeded at the captured playhead, already playing);
22
+ * `currentTime` is the playhead (ms) the takeover seeded from; `diagnostics`
23
+ * carries any honest refusal (no running animation by that name → a row, never
24
+ * a silent no-op).
25
+ */
26
+ export declare interface AdoptResult<V extends Vars = any> {
27
+ /** The kf animation now driving the element (null on a refused adopt). */
28
+ animation: CSSKeyframesAnimation<V> | null;
29
+ /** The captured native `currentTime` (ms) the kf playhead seeded from. */
30
+ currentTime: number;
31
+ /** Honest refusal rows (e.g. no running animation by that name). */
32
+ diagnostics: Diagnostic[];
33
+ }
34
+
35
+ /**
36
+ * K2 — `adoptRunning`: the mid-flight TEMPORAL takeover. Given a live element
37
+ * with a running CSS animation, seamlessly hand control to the kf engine:
38
+ *
39
+ * 1. `el.getAnimations()` → find the running `CSSAnimation` matching
40
+ * `{ animationName }`; read its `currentTime` + `playState`.
41
+ * 2. Reconstruct the kf `CSSKeyframesAnimation` from the CSSOM `@keyframes`
42
+ * RULE (via {@link resolveLiveKeyframes} — the AUTHORED form, preserving
43
+ * `var()`/`cqw`/oklab), NOT from `getAnimations().getKeyframes()` (which has
44
+ * px-resolved `var()`/`cqw` and RGB-baked oklab — the very axes kf preserves).
45
+ * 3. Seed the kf animation at the captured `currentTime` (the continuity seed
46
+ * — NOT seed-at-zero, which flashes the element to its 0% state).
47
+ * 4. Commit the current frame inline (the commit-on-ADOPT), then `cancel()`
48
+ * the native animation, so there is no leaked-precedence flash (the inverse
49
+ * of `playWAAPI`'s commit-on-finish discipline — `waapi.ts`).
50
+ * 5. Hand control to the kf engine (the kf animation plays from `currentTime`).
51
+ *
52
+ * NAMED `adoptRunning` to disambiguate from `engine.ts`'s `adoptCompiled`
53
+ * (compiled-state internal adopt — untouched; HARDENING-5 HAZARD-1).
54
+ *
55
+ * @example
56
+ * const { adoptRunning } = await loadAnimationEngine();
57
+ * // el is mid-flight on `.spin { animation: spin 2s linear infinite }`
58
+ * const { animation } = await adoptRunning(el, { animationName: "spin" });
59
+ * // the kf object now drives `el` from the exact playhead — no visible seam.
60
+ * animation?.pause(); // ...now scrub / spring-ify / re-color it.
61
+ */
62
+ declare const adoptRunning: <V extends Vars = any>(el: Element, options: AdoptRunningOptions) => Promise<AdoptResult<V>>;
63
+
64
+ /** Options for {@link adoptRunning}. */
65
+ export declare interface AdoptRunningOptions extends IngestOptions {
66
+ /**
67
+ * The running CSS animation's name to adopt. REQUIRED — an element may host
68
+ * several CSS animations, and the takeover must name exactly one (the
69
+ * `@keyframes` rule to reconstruct + the `getAnimations()` entry to read the
70
+ * playhead from).
71
+ */
72
+ animationName: string;
73
+ /**
74
+ * Commit the native animation's current computed frame inline before
75
+ * cancelling it (the commit-on-ADOPT, the inverse of `playWAAPI`'s
76
+ * commit-on-finish), so there is no flash between the native paint and the
77
+ * kf paint. Default true; set false only when the caller commits itself.
78
+ */
79
+ commit?: boolean;
80
+ }
81
+
13
82
  /**
14
83
  * Construct, target, and play an animation in one call. Returns the
15
84
  * `CSSKeyframesAnimation` as the control handle — `await animate(...)` is NOT
@@ -102,6 +171,34 @@ declare class Animation_2<V extends Vars = any> {
102
171
  pausedTime: number;
103
172
  t: number;
104
173
  iteration: number;
174
+ /**
175
+ * Structured parse/honoring diagnostics (K.W7 S4) — surfaced from the
176
+ * adapter's `resolveKeyframes` ({@link CSSKeyframesAnimation.fromString})
177
+ * and joined by the engine's own composition-fallback rows. A FLAT additive
178
+ * array of stable-coded {@link Diagnostic} rows; empty on a clean parse with
179
+ * no fallback. Every SILENT fallback site is mirrored here — the honesty
180
+ * surface (`proof:diagnostics-channel`). Queryable; no console output.
181
+ */
182
+ diagnostics: Diagnostic[];
183
+ /**
184
+ * The captured UNDERLYING base value for each composited leaf (K.W7 S1) —
185
+ * keyed by the flat property key, holding the per-element numeric base the
186
+ * `add`/`accumulate` operator accumulates ONTO. CSS `animation-composition:
187
+ * add` composites the animation's effect on top of the element's underlying
188
+ * value (its value WITHOUT this animation); we snapshot it the first time a
189
+ * composited leaf is applied (before the engine overwrites the inline
190
+ * style), then accumulate onto it each frame. Empty for a pure-`replace`
191
+ * animation (the legacy zero-overhead path — the Map is never touched).
192
+ */
193
+ private _compositionBase;
194
+ /** Properties whose non-numeric composite already emitted its
195
+ * `COMPOSITION_FALLBACK` row — so a long playback emits the honesty row
196
+ * ONCE per property, not once per frame (S3/S4). */
197
+ private _compositionFallbackSeen;
198
+ /** True once `fromString`/`addFrame` saw a non-`replace` operator — the hot
199
+ * path skips ALL composition work when this is false (the predictable
200
+ * per-animation-constant branch the §gate's clause (f) measures free). */
201
+ private _hasComposition;
105
202
  started: boolean;
106
203
  done: boolean;
107
204
  reversed: boolean;
@@ -173,9 +270,18 @@ declare class Animation_2<V extends Vars = any> {
173
270
  get frames(): AnimationFrame<V>[];
174
271
  get frameId(): number;
175
272
  /** Append a template frame (delegated to the compiler). Chainable. */
176
- addFrame<K extends V>(start: number | string | ValueUnit<number>, vars: Partial<K>, transform?: TransformFunction<K>, timingFunction?: InputAnimationOptions["timingFunction"]): Animation_2<K>;
273
+ addFrame<K extends V>(start: number | string | ValueUnit<number>, vars: Partial<K>, transform?: TransformFunction<K>, timingFunction?: InputAnimationOptions["timingFunction"], composition?: CompositeOperator): Animation_2<K>;
177
274
  /** Compile the template frames into the sampled `frames[]`. Chainable. */
178
275
  parse(): this;
276
+ /**
277
+ * Set `_hasComposition` (K.W7 S1) — true iff ANY compiled frame carries a
278
+ * non-`replace` `animation-composition` operator. The honoring hot-path
279
+ * branch (`processFrame` → `applyComposition`) reads this ONE per-animation
280
+ * constant; a pure-`replace` animation never pays for the composition work.
281
+ * Also resets the per-run base/fallback caches so a re-parse (new keyframes)
282
+ * re-snapshots the underlying base.
283
+ */
284
+ private computeHasComposition;
179
285
  /**
180
286
  * Adopt another animation's ALREADY-COMPILED state as ONE atomic motion
181
287
  * (G.W19) — the first-class verb for the "single-compile, then transplant"
@@ -284,6 +390,50 @@ declare class Animation_2<V extends Vars = any> {
284
390
  * (F.W4 S3 — so the single-frame path can alias `flatVars` with no copy).
285
391
  */
286
392
  private processFrame;
393
+ /**
394
+ * Composite ONE frame's lerped numeric leaves onto the captured underlying
395
+ * base, per the frame's `animation-composition` operator (K.W7 S1). The
396
+ * leaf is a `ValueUnit[]` (a one-element array for a scalar, an N-element
397
+ * array for a multi-component leaf — a transform list); the lerp already
398
+ * wrote `unit.value`, so the composite is `unit.value += base` IN PLACE
399
+ * (un-clamped — CSS does not clamp at composition; the same `group.ts` `add`
400
+ * leaf contract). The underlying base is snapshotted the first time the leaf
401
+ * is composited (from the target's pre-animation value), keyed by the flat
402
+ * property name. The `replace` operator is filtered out by the caller.
403
+ *
404
+ * - `add` — `value = base + lerp`
405
+ * - `accumulate` — repeat-aware: `value = base + iteration·(endΔ) + lerp`,
406
+ * so iteration N stacks onto N−1's net effect (the one new
407
+ * semantic; reads the engine's own `iteration` counter).
408
+ *
409
+ * A NON-NUMERIC leaf (color, `<custom-ident>`, discrete) has no faithful
410
+ * numeric add: it `replace`-falls-back (the leaf keeps its lerped value) AND
411
+ * emits a `COMPOSITION_FALLBACK` row naming the property — never a silent
412
+ * wrong pixel (the honest-refusal clause). The row is emitted ONCE per
413
+ * property (a `Set` guard) so a long playback does not flood the channel.
414
+ */
415
+ private applyComposition;
416
+ /**
417
+ * Snapshot the underlying base for a composited leaf (K.W7 S1) — the
418
+ * element's value WITHOUT this animation, the value `add`/`accumulate`
419
+ * composites onto. Reads the target's pre-animation INLINE style for the
420
+ * leaf's CSS property and parses each component to a number; an absent /
421
+ * non-numeric inline value is the CSS initial-ish `0` (additive identity),
422
+ * so a fresh element with no underlying declaration composites as a pure
423
+ * `add` onto `0` (the lerped value passes through unchanged — faithful: no
424
+ * underlying value means nothing to add to). Bounded to `count` elements.
425
+ */
426
+ private captureUnderlyingBase;
427
+ /**
428
+ * The segment END value for a leaf element (K.W7 — the `accumulate`
429
+ * repeat-aware stack). The compiled `InterpolatedVar` carries `start`/`stop`
430
+ * ValueUnits; the end of the segment is `stop.value`. Returns the captured
431
+ * base when the stop is not a plain number (the accumulate degrades to a
432
+ * no-stack `add`, never a NaN).
433
+ */
434
+ private endValueFor;
435
+ /** Emit a `COMPOSITION_FALLBACK` diagnostic ONCE per property (S3/S4). */
436
+ private emitCompositionFallback;
287
437
  /** SYNC unless `delay > 0` — then a thenable resolving after the sleep. */
288
438
  onStart(): Promise<void> | undefined;
289
439
  onEnd(): void;
@@ -434,6 +584,52 @@ export declare interface AnimationEngine {
434
584
  FILL_MODES: readonly AnimationOptions["fillMode"][];
435
585
  defaultOptions: AnimationOptions;
436
586
  defaultLayerConfig: AnimationLayerConfig;
587
+ /**
588
+ * K.W8 INGEST (FLAGGED ADDITIVE) — the round-trip pointed FORWARD at the
589
+ * live web. `fromStyleSheets`/`fromLiveAnimations`/`resolveLiveKeyframes`
590
+ * walk the CSSOM into kf `CSSKeyframesAnimation` objects (per-sheet CORS
591
+ * `try/catch` → a `CORS_SKIP` diagnostic, never a silent drop); `adoptRunning`
592
+ * takes over a RUNNING CSS animation mid-flight via `getAnimations()`
593
+ * currentTime handoff (the continuity seed, NOT seed-at-zero). HEAVY (the
594
+ * ingest needs the value.js parser) — reached only here, never the LIGHT
595
+ * barrel. Named `adoptRunning` to disambiguate from `engine.adoptCompiled`.
596
+ */
597
+ fromStyleSheets: typeof fromStyleSheets;
598
+ fromLiveAnimations: typeof fromLiveAnimations;
599
+ resolveLiveKeyframes: typeof resolveLiveKeyframes;
600
+ adoptRunning: typeof adoptRunning;
601
+ /**
602
+ * K.W9 SCROLL-AS-CSS (FLAGGED ADDITIVE) — the scroll-grammar round-trip
603
+ * (`parseScrollCSS` / `serializeScrollOptions` / `roundTripScrollCSS`,
604
+ * consuming value.js 0.13.0's typed `CSSTimelineOptions` extractor +
605
+ * inverse serializer), the `ScrollScene` JS driver (`createScrollScene`),
606
+ * the conservative-correct backend dispatch (`dispatchScrollBackend`), and
607
+ * the `position:sticky` pin synthesis (`pinCSS`). HEAVY (static value.js
608
+ * edge) — reached only here, never the LIGHT barrel.
609
+ */
610
+ ScrollScene: typeof ScrollScene;
611
+ createScrollScene: typeof createScrollScene;
612
+ parseScrollCSS: typeof parseScrollCSS;
613
+ parseScrollTimeline: typeof parseScrollTimeline;
614
+ parseScrollRange: typeof parseScrollRange;
615
+ serializeScrollOptions: typeof serializeScrollOptions;
616
+ roundTripScrollCSS: typeof roundTripScrollCSS;
617
+ dispatchScrollBackend: typeof dispatchScrollBackend;
618
+ resolveRange: typeof resolveRange;
619
+ pinCSS: typeof pinCSS;
620
+ /**
621
+ * K.W10 COMPILE (FLAGGED ADDITIVE) — the round-trip's BACKWARD half:
622
+ * `compileToCSS(group | sequence | childList)` → a ZERO-RUNTIME CSS artifact
623
+ * (`@keyframes` + `animation-*` longhands + `animation-composition` layering
624
+ * + `linear()` springs + materialized stagger delays + perceptual `oklab()`
625
+ * densify) PLUS the CC-3 ineligibility report (the four named refusals —
626
+ * `weighted` blend / custom renderers / perceptual oklab beyond densify /
627
+ * computed-unit drift). The compiler is the parser run BACKWARD over the SAME
628
+ * data model (`format.ts` is `keyframes.ts` run backward); a human pastes the
629
+ * result and ships with ZERO kf bytes on the page. HEAVY (value.js-bearing) —
630
+ * reached only here, never the LIGHT barrel.
631
+ */
632
+ compileToCSS: typeof compileToCSS;
437
633
  }
438
634
 
439
635
  export declare interface AnimationFrame<V extends Vars> {
@@ -460,6 +656,19 @@ export declare interface AnimationFrame<V extends Vars> {
460
656
  allInterpVars: Array<InterpolatedVar<V>>;
461
657
  transform: TransformFunction<V>;
462
658
  timingFunction: Easing;
659
+ /**
660
+ * The compiled per-segment `animation-composition` operator (K.W7). A
661
+ * segment runs from a START stop to a STOP stop; the operator is the STOP
662
+ * stop's declared composition (CSS attaches `animation-composition` to the
663
+ * keyframe being composited TOWARD). `replace` (or omission) is the legacy
664
+ * behaviour — the apply writes the lerped value verbatim. `add` accumulates
665
+ * the lerped numeric leaf onto the captured underlying base (un-clamped,
666
+ * element-wise — the same leaf `group.ts`'s `add` layer runs); `accumulate`
667
+ * is repeat-aware (iteration N stacks onto N−1's end). A non-numeric leaf
668
+ * (color, `<custom-ident>`) `replace`-falls-back AND emits a
669
+ * `COMPOSITION_FALLBACK` diagnostic — never a silent wrong pixel.
670
+ */
671
+ composition?: CompositeOperator;
463
672
  }
464
673
 
465
674
  export declare class AnimationGroup<V extends Vars> {
@@ -524,6 +733,15 @@ export declare class AnimationGroup<V extends Vars> {
524
733
  */
525
734
  private _groupedKeys;
526
735
  private _groupedKeysDirty;
736
+ /**
737
+ * K.W11 PHYS-C — true iff ANY layer currently carries a `weightSpring`. A
738
+ * pure fast-path guard: when false (the universal case — no crossfade in
739
+ * flight) `advanceTo` skips the per-frame spring scan entirely, so the
740
+ * constant-weight blend hot path takes ZERO new work. Set true by
741
+ * `transitionLayer`; recomputed false by `advanceLayerSprings` once every
742
+ * driving spring has settled and been cleared.
743
+ */
744
+ private _hasLayerSprings;
527
745
  constructor(...inputs: (Animation_2<V> | AnimationGroupInput<V>)[]);
528
746
  /**
529
747
  * Returns the animation entries sorted by layer zIndex.
@@ -685,6 +903,58 @@ export declare class AnimationGroup<V extends Vars> {
685
903
  setLayerEnabled(nameOrAnim: string | Animation_2<V>, enabled: boolean): this;
686
904
  /** Read the layer config for an animation. */
687
905
  getLayerConfig(nameOrAnim: string | Animation_2<V>): AnimationLayerConfig | undefined;
906
+ /**
907
+ * Resolve a name/reference to its registered entry, throwing the same
908
+ * fail-explicit "no animation registered" error the other layer methods
909
+ * raise. The shared lookup the transition API + `setLayerConfig` use.
910
+ */
911
+ private requireEntry;
912
+ /**
913
+ * Spring a layer's blend `weight` from its CURRENT value to `weight`
914
+ * (K.W11 PHYS-C — the spring-driven crossfade). Constructs a
915
+ * `SpringProgress` seeded at the layer's current weight, targeting the new
916
+ * weight, and parks it on `layer.weightSpring`; the group's managed loop
917
+ * advances it per frame (`advanceLayerSprings`) and the `weighted` blend
918
+ * leaf reads its value in place of the constant. With an UNDER-damped
919
+ * spring the weight momentarily blends PAST the target (the canonical iOS
920
+ * "snap into place" for a whole animation layer) before settling — a
921
+ * PHYSICAL trajectory, NOT a hard cut.
922
+ *
923
+ * Re-targeting mid-flight (a second `transitionLayer` before the spring
924
+ * settles) RE-SEATS the existing spring from its live `(value, velocity)`
925
+ * (the shipped `set target` → `reseatTarget`), so the weight does not kink —
926
+ * it inherits the in-flight velocity. On settle the spring clears and the
927
+ * leaf falls back to the now-updated constant `weight`.
928
+ *
929
+ * Forces the layer's `blendMode` to `weighted` (the only weight-parametric
930
+ * mode); `add`/`replace` are not weight-driven and the spec leaves them
931
+ * untouched. Chainable.
932
+ */
933
+ transitionLayer(nameOrAnim: string | Animation_2<V>, target: {
934
+ weight: number;
935
+ spring?: LayerTransitionSpring;
936
+ }): this;
937
+ /**
938
+ * Physically crossfade between two layers (K.W11 PHYS-C): spring layer `a`
939
+ * down to weight `0` and layer `b` up to weight `1`, each over its own
940
+ * `SpringProgress` (the same `spring` shape). Two `transitionLayer` calls —
941
+ * the flagship demo moment: a crossfade that overshoots and settles, only
942
+ * possible on kf's weighted-blend substrate. Chainable.
943
+ */
944
+ crossfade(a: string | Animation_2<V>, b: string | Animation_2<V>, options?: {
945
+ spring?: LayerTransitionSpring;
946
+ }): this;
947
+ /**
948
+ * Advance every spring-driven layer weight by the frame delta `dt` ms
949
+ * (K.W11 PHYS-C). Called from `advanceTo` ONLY when `_hasLayerSprings` is
950
+ * true, so the constant-weight blend path pays nothing. On a spring's
951
+ * settle the live `weightSpring.value` has converged to its target, so the
952
+ * driven `layer.weight` is committed to that target and the spring CLEARED —
953
+ * the `weighted` leaf's `?? layer.weight` read then serves the constant,
954
+ * byte-identical to a never-sprung layer. Recomputes `_hasLayerSprings`
955
+ * false once the last spring clears.
956
+ */
957
+ private advanceLayerSprings;
688
958
  }
689
959
 
690
960
  export declare interface AnimationGroupEntry<V extends Vars> {
@@ -708,6 +978,19 @@ export declare interface AnimationLayerConfig {
708
978
  zIndex: number;
709
979
  /** 0–1 for 'weighted' blend mode. Default: 1 */
710
980
  weight: number;
981
+ /**
982
+ * Optional spring (or any {@link WeightStepper}) DRIVING this layer's
983
+ * blend `weight` (K.W11 PHYS-C — the spring-driven crossfade). When
984
+ * present the `weighted` blend leaf reads `weightSpring.value` in place of
985
+ * the constant `weight` (one nullish read; the per-frame lerp untouched),
986
+ * so a layer transition follows a PHYSICAL trajectory that can overshoot
987
+ * and settle — the flagship demo moment only kf's weighted-blend substrate
988
+ * can hold. Constructed + advanced by `AnimationGroup.transitionLayer` /
989
+ * `crossfade`; cleared on settle, when the read falls back to the
990
+ * now-updated constant `weight`. Absent on a static-weight layer (the
991
+ * read is `?? layer.weight`), so the constant path is byte-unchanged.
992
+ */
993
+ weightSpring?: WeightStepper;
711
994
  /**
712
995
  * Default: 'replace'. Defaulting on a genuinely-omitted blend mode is
713
996
  * the sanctioned contract (the fail-explicit seam throws only on
@@ -830,6 +1113,10 @@ declare namespace AnimationPresets {
830
1113
  }
831
1114
  }
832
1115
 
1116
+ export { AnimationRangeValue }
1117
+
1118
+ export { AnimationTimelineValue }
1119
+
833
1120
  /** Attention animations — a one-shot nudge to draw the eye. */
834
1121
  declare const attentionPresets: {
835
1122
  readonly pulse: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
@@ -851,6 +1138,101 @@ declare const blurOut: (options?: InputAnimationOptions) => CSSKeyframesAnimatio
851
1138
 
852
1139
  declare const bounce: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
853
1140
 
1141
+ /** The compile result — the artifact + the CC-3 ineligibility report. */
1142
+ export declare interface CompiledCSS {
1143
+ /**
1144
+ * The zero-runtime CSS artifact — `@keyframes` blocks + `.class { animation }`
1145
+ * rules. Empty string when EVERY child refused (then `refusals` carries the
1146
+ * whole story).
1147
+ */
1148
+ css: string;
1149
+ /**
1150
+ * True iff EVERY walked child compiled faithfully. False when one or more
1151
+ * refused — `refusals` names each, and the JS playback is the only faithful
1152
+ * path for those.
1153
+ */
1154
+ eligible: boolean;
1155
+ /** The CC-3 refusals — one per child that could not compile faithfully. */
1156
+ refusals: CompileRefusal[];
1157
+ }
1158
+
1159
+ /** The input shapes `compileToCSS` accepts. */
1160
+ export declare type CompileInput<V extends Vars = any> = AnimationGroup<V> | Sequence<V> | ReadonlyArray<Animation_2<V> | {
1161
+ animation: Animation_2<V>;
1162
+ }>;
1163
+
1164
+ /** Options for {@link compileToCSS}. */
1165
+ export declare interface CompileOptions {
1166
+ /**
1167
+ * Per-child stagger delays (ms), index-aligned with the walked children —
1168
+ * the materialized output of `stagger.delays(total)`. CC-1 emits these as
1169
+ * literal per-child `animation-delay`, expressing an eased origin-aware
1170
+ * curve `sibling-index()` cannot (the universal literal-delay form;
1171
+ * `@supports (sibling-index)` is CC-6 BOOK, not the default).
1172
+ */
1173
+ staggerDelays?: readonly number[];
1174
+ /**
1175
+ * CC-2 — the oklab densify stop count (the N intermediate `oklab()` stops
1176
+ * baked per color segment, INCLUSIVE of endpoints). Default
1177
+ * {@link DEFAULT_DENSIFY_STOPS}. Raise it for a longer color arc; the ΔE
1178
+ * proof decides ship-vs-refuse.
1179
+ */
1180
+ densifyStops?: number;
1181
+ /**
1182
+ * CC-2 — the ΔE-ε ship-vs-refuse threshold (the perceptual-distance band the
1183
+ * densified `oklab()` stops must hold against kf's JS lerp). Default
1184
+ * {@link DEFAULT_DELTA_E_EPSILON}. A track whose densify exceeds this REFUSES
1185
+ * with the perceptual-oklab reason (a drifting densify is worse than an
1186
+ * honest refusal).
1187
+ */
1188
+ deltaEEpsilon?: number;
1189
+ /** Prettier print-width for the emitted artifact. Omit for the default. */
1190
+ printWidth?: number;
1191
+ }
1192
+
1193
+ /** A single refusal — the child name + a typed reason + a human message. */
1194
+ export declare interface CompileRefusal {
1195
+ /** The compiled child's class/animation name. */
1196
+ name: string;
1197
+ reason: CompileRefusalReason;
1198
+ /** The verbatim message the demo's ineligibility UI shows (CC-4). */
1199
+ message: string;
1200
+ }
1201
+
1202
+ /**
1203
+ * The reason a child could not compile faithfully. Generalizes
1204
+ * `waapiIneligibleReason` to the CSS-compile domain — the trust surface. Each
1205
+ * names the kf axis that exceeds pure CSS (the refusal is marketing for the
1206
+ * moat). A refused child's JS playback is the only faithful path.
1207
+ */
1208
+ export declare type CompileRefusalReason = "weighted-blend" | "custom-renderer" | "perceptual-oklab" | "computed-unit-drift";
1209
+
1210
+ /**
1211
+ * THE compiler (CC-1/CC-2/CC-3) — compile an orchestration graph to zero-runtime
1212
+ * CSS. Walks the input (`AnimationGroup` / `Sequence` / child list), emits one
1213
+ * `@keyframes` + one `animation` shorthand per child (the `replace`/`add`
1214
+ * layering as `animation-composition`, springs as `linear()`, stagger delays
1215
+ * materialized, computed units verbatim, color tracks densified into perceptual
1216
+ * `oklab()` stops under the ΔE-ε proof), and REFUSES with a NAMED reason what
1217
+ * cannot compile faithfully (CC-3 — the replay-equality invariant's honest
1218
+ * refusal). The result is async because `formatCSS` (Prettier) is.
1219
+ *
1220
+ * @returns `{ css, eligible, refusals }` — the artifact + the trust surface.
1221
+ */
1222
+ declare function compileToCSS<V extends Vars>(input: CompileInput<V>, opts?: CompileOptions): Promise<CompiledCSS>;
1223
+
1224
+ /**
1225
+ * The CSS `animation-composition` operator (K.W7). Distinct from
1226
+ * {@link BlendMode} (the GROUP's per-LAYER blend tier — `replace`/`add`/
1227
+ * `weighted`): this is the per-KEYFRAME composite operator the author declares
1228
+ * on a single animation, matching the CSS grammar exactly (`weighted` is not a
1229
+ * CSS composite; `accumulate` is the repeat-aware one CSS adds). The engine
1230
+ * routes `add`/`accumulate` onto the SAME un-clamped numeric leaf the group's
1231
+ * `add` layer runs (`group.ts`), so the two tiers share one accumulation
1232
+ * semantic without sharing a type.
1233
+ */
1234
+ declare type CompositeOperator = "replace" | "add" | "accumulate";
1235
+
854
1236
  /**
855
1237
  * Feature-detect (`"ScrollTimeline" in window` / `"ViewTimeline" in window`)
856
1238
  * and construct a NATIVE `AnimationTimeline` for the additive WAAPI scroll
@@ -870,6 +1252,21 @@ declare const bounce: (options?: InputAnimationOptions) => CSSKeyframesAnimation
870
1252
  */
871
1253
  export declare function createNativeTimeline(spec: NativeTimelineSpec): AnimationTimeline | null;
872
1254
 
1255
+ /**
1256
+ * Construct a `ScrollScene` from a parsed `CSSTimelineOptions` (the SO-1 parse
1257
+ * output) OR a direct `ScrollSceneOptions` spec. The CSS-fed construction is the
1258
+ * round-trip's driving half (parse → drive); the spec-fed construction is
1259
+ * value.js-INDEPENDENT (it needs no grammar — only the physics primitives).
1260
+ *
1261
+ * @example
1262
+ * // CSS-fed (value.js-gated parse → JS driver):
1263
+ * const opts = parseScrollCSS(stylesheet);
1264
+ * const scene = createScrollScene({ range: opts.range, scrub: 0.2 });
1265
+ * // spec-fed (value.js-independent):
1266
+ * const scene = createScrollScene({ range: { start: { offset: "0%" }, end: { offset: "100%" } } });
1267
+ */
1268
+ declare function createScrollScene(spec?: ScrollSceneOptions | CSSTimelineOptions): ScrollScene;
1269
+
873
1270
  export declare class CSSKeyframesAnimation<V extends Vars> extends Animation_2<V> {
874
1271
  constructor(options?: Partial<InputAnimationOptions>, ...targets: HTMLElement[]);
875
1272
  /**
@@ -907,6 +1304,8 @@ export declare class CSSKeyframesAnimation<V extends Vars> extends Animation_2<V
907
1304
  transform(vars: V): void;
908
1305
  }
909
1306
 
1307
+ export { CSSTimelineOptions }
1308
+
910
1309
  /**
911
1310
  * The closed-form frictional glide. Given a release `velocity` `v0`, an
912
1311
  * `initial` position `x0`, and a `friction` `k`, returns a pure sampler
@@ -974,8 +1373,60 @@ export declare interface DecaySample {
974
1373
  velocity: number;
975
1374
  }
976
1375
 
1376
+ /**
1377
+ * A structured parse/honoring diagnostic (K.W7 S4). Extends the value.js
1378
+ * `ParseDiagnostic` producer (the CONSUMED shape — `message`/`offset`/`line`/
1379
+ * `column`/`expected`/`input`) with a stable kf-side {@link DiagnosticCode} and
1380
+ * an optional `property` (the leaf a `COMPOSITION_FALLBACK` names). The
1381
+ * value.js half (`message`/`offset`/…) is `Partial` because the engine-internal
1382
+ * rows (EMPTY_PARSE, COMPOSITION_FALLBACK) are NOT byte-offset parse failures —
1383
+ * they carry a `message` + `code` only; a row sourced from the value.js
1384
+ * `OnParseError` producer carries the full positional record. NOT a kf-local
1385
+ * re-author of the producer: it CONSUMES `ParseDiagnostic`'s field shape and
1386
+ * widens it with the stable code (inv-16 published-only consumption holds).
1387
+ */
1388
+ declare interface Diagnostic extends Partial<ParseDiagnostic> {
1389
+ /** A stable, branch-on-able code — never scrape `message`. */
1390
+ code: DiagnosticCode;
1391
+ /** The human-readable summary (always present; the producer's or kf's). */
1392
+ message: string;
1393
+ /** The CSS property a `COMPOSITION_FALLBACK` refuses to composite. */
1394
+ property?: string;
1395
+ }
1396
+
1397
+ /**
1398
+ * The stable diagnostic `code`s the kf-side sink emits (K.W7 S4). A FLAT,
1399
+ * additive enum — NOT a logging framework — so a programmatic consumer branches
1400
+ * on the reason without scraping a message string (the J.W1 typed-throw idiom
1401
+ * lifted onto the structured field). The engine-internal rows
1402
+ * (`EMPTY_PARSE`/`UNKNOWN_TIMING_FN`) were J.W1-landed as typed throws; W7 lifts
1403
+ * them onto this field. `COMPOSITION_FALLBACK` is the K.W7 honesty row (the
1404
+ * non-numeric composite leaf's refusal). `PARSE_ERROR` carries the value.js
1405
+ * `OnParseError` producer's structured diagnostic verbatim. The CORS-skip /
1406
+ * WAAPI-reason rows are AUTHORED here but POPULATED by K.W8 (which owns the
1407
+ * CSSOM walk that produces them).
1408
+ */
1409
+ declare type DiagnosticCode = "EMPTY_PARSE" | "UNKNOWN_TIMING_FN" | "COMPOSITION_FALLBACK" | "PARSE_ERROR" | "CORS_SKIP" | "WAAPI_INELIGIBLE";
1410
+
977
1411
  declare const DIRECTIONS: readonly ["normal", "reverse", "alternate", "alternate-reverse"];
978
1412
 
1413
+ /**
1414
+ * SO-1/SO-2 the DISPATCH (conservative-correct, with a queryable reason). The
1415
+ * WAAPI-eligibility seam pointed at the scroll clock:
1416
+ *
1417
+ * DOM target + WAAPI-eligible + native ScrollTimeline present + NO scrub/snap/
1418
+ * velocity → NATIVE (zero main-thread)
1419
+ * scrub OR snap OR velocity requested → JS (native has no smoother/snap)
1420
+ * non-DOM target / no animation → JS (the universal driver)
1421
+ * WAAPI-ineligible (computed unit / color / custom curve) → JS (the ineligible set)
1422
+ * native ScrollTimeline ABSENT (Firefox, jsdom, SSR) → JS (createNativeTimeline → null)
1423
+ *
1424
+ * The JS path NEVER deletes the native lane and the native path NEVER swallows
1425
+ * an ineligible animation — the reason string is the honesty surface (the
1426
+ * `waapiIneligibleReason` idiom). This ADDS a tier; it deletes no driver.
1427
+ */
1428
+ declare function dispatchScrollBackend<V extends Vars>(request: ScrollDispatchRequest<V>): ScrollDispatch;
1429
+
979
1430
  /**
980
1431
  * Functional sugar over {@link Draggable}: construct, `attach(element)`,
981
1432
  * and return the instance — the one-call front door for the common case.
@@ -1334,7 +1785,7 @@ declare class FrameCompiler<V extends Vars = any> {
1334
1785
  * invariant — G.W19 / the `6e29236` lock), without poking a private field.
1335
1786
  */
1336
1787
  get options(): AnimationOptions;
1337
- addFrame<K extends V>(start: number | string | ValueUnit<number>, vars: Partial<K>, transform?: TransformFunction<K>, timingFunction?: InputAnimationOptions["timingFunction"]): void;
1788
+ addFrame<K extends V>(start: number | string | ValueUnit<number>, vars: Partial<K>, transform?: TransformFunction<K>, timingFunction?: InputAnimationOptions["timingFunction"], composition?: CompositeOperator): void;
1338
1789
  createFrame(startIx: number, endIx: number): AnimationFrame<V>;
1339
1790
  /**
1340
1791
  * Build an index mapping each variable name to the frame indices where
@@ -1408,6 +1859,21 @@ declare class FrameCompiler<V extends Vars = any> {
1408
1859
  */
1409
1860
  declare function fromDrawSVG<V extends Record<string, any> = any>(target: SVGDrawTarget, options?: DrawSVGOptions): CSSKeyframesAnimation<V>;
1410
1861
 
1862
+ /**
1863
+ * K1 — `fromLiveAnimations`: adopt every RUNNING CSS animation on the document
1864
+ * (or a single element) by reconstructing each from its source `@keyframes`
1865
+ * RULE (via the CSSOM walk — NOT from `getAnimations().getKeyframes()`, the
1866
+ * computed form that has lost `var()`/`cqw`/oklab). The `getAnimations()` read
1867
+ * provides the SET of live animation names; the reconstruction provides the
1868
+ * authored keyframes. The result maps each live animation name → its
1869
+ * reconstructed kf object (the recovered, axis-preserving source).
1870
+ *
1871
+ * Distinct from {@link fromStyleSheets} (which walks EVERY declared `@keyframes`
1872
+ * rule, running or not): `fromLiveAnimations` narrows to the names currently
1873
+ * RUNNING on the page — the animations a user actually sees in motion.
1874
+ */
1875
+ declare const fromLiveAnimations: <V extends Vars = any>(target?: Document | Element, options?: IngestOptions) => IngestResult<V>;
1876
+
1411
1877
  /**
1412
1878
  * Build a CSS-native path-motion animation: set the author `offset-path` (and
1413
1879
  * optional `offset-rotate`) on the target(s), and sweep `offset-distance` from
@@ -1432,6 +1898,21 @@ declare function fromDrawSVG<V extends Record<string, any> = any>(target: SVGDra
1432
1898
  */
1433
1899
  declare function fromMotionPath<V extends Record<string, any> = any>(target: HTMLElement | HTMLElement[], options: MotionPathOptions): CSSKeyframesAnimation<V>;
1434
1900
 
1901
+ /**
1902
+ * K1 — `fromStyleSheets`: the consumer-facing front door over
1903
+ * {@link resolveLiveKeyframes}. Walk the document's (or the given list's)
1904
+ * stylesheets and return every reconstructed `@keyframes` animation. The honest
1905
+ * `CORS_SKIP`/`PARSE_ERROR` rows ride the returned {@link IngestResult}.
1906
+ *
1907
+ * @example
1908
+ * const { CSSKeyframesAnimation, fromStyleSheets } = await loadAnimationEngine();
1909
+ * const { animations, diagnostics } = fromStyleSheets();
1910
+ * const pulse = animations.get("pulse")?.animation;
1911
+ * pulse?.setTargets(el).play(); // re-drive the page's OWN animation
1912
+ * for (const d of diagnostics) console.warn(d.code, d.message); // honest skips
1913
+ */
1914
+ declare const fromStyleSheets: <V extends Vars = any>(source?: Document | CSSStyleSheet[] | CSSStyleSheet, options?: IngestOptions) => IngestResult<V>;
1915
+
1435
1916
  declare const glow: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
1436
1917
 
1437
1918
  declare const gradientBackground: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
@@ -1440,6 +1921,59 @@ declare const heartbeat: (options?: InputAnimationOptions) => CSSKeyframesAnimat
1440
1921
 
1441
1922
  declare const hover: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
1442
1923
 
1924
+ /**
1925
+ * One ingested animation + the diagnostics its reconstruction produced. The
1926
+ * `name` is the `@keyframes` identifier (the CSSOM `CSSKeyframesRule.name`); the
1927
+ * `animation` is the reconstructed `CSSKeyframesAnimation`, already carrying any
1928
+ * sibling-style-rule `animation-*` options. `diagnostics` carries the honesty
1929
+ * rows for THIS rule (a malformed body → `PARSE_ERROR`, etc.); the walk-level
1930
+ * rows (`CORS_SKIP`) ride {@link IngestResult.diagnostics}.
1931
+ */
1932
+ export declare interface IngestedAnimation<V extends Vars = any> {
1933
+ /** The `@keyframes` identifier (CSSOM `CSSKeyframesRule.name`). */
1934
+ name: string;
1935
+ /** The reconstructed kf animation — replay-equal to the source CSS. */
1936
+ animation: CSSKeyframesAnimation<V>;
1937
+ /** Per-rule reconstruction diagnostics (empty on a clean ingest). */
1938
+ diagnostics: Diagnostic[];
1939
+ }
1940
+
1941
+ /** Options shared by the ingest entry points. */
1942
+ export declare interface IngestOptions {
1943
+ /**
1944
+ * Restrict the ingest to a single `@keyframes` name. When set, only the
1945
+ * matching rule is reconstructed (the rest are skipped without a
1946
+ * diagnostic — a name filter is an intentional narrowing, not a failure).
1947
+ */
1948
+ animationName?: string;
1949
+ /**
1950
+ * Animation options applied as the BASE for each reconstructed animation,
1951
+ * BELOW any sibling-style-rule `animation-*` declarations the source CSS
1952
+ * carries (the source's declared options win — the round-trip preserves the
1953
+ * AUTHORED timing). Empty by default.
1954
+ */
1955
+ options?: Partial<InputAnimationOptions>;
1956
+ }
1957
+
1958
+ /**
1959
+ * The result of a CSSOM walk: every `@keyframes` rule reconstructed into a kf
1960
+ * animation, plus the WALK-LEVEL diagnostics (the `CORS_SKIP` rows a
1961
+ * cross-origin sheet produces — the honesty surface S3). A consumer reads
1962
+ * `animations` for the recovered objects and `diagnostics` for the citable
1963
+ * reasons the walk could not complete a step faithfully — NEVER a silent drop.
1964
+ */
1965
+ export declare interface IngestResult<V extends Vars = any> {
1966
+ /** Every `@keyframes` rule reconstructed, keyed by its CSS name. */
1967
+ animations: Map<string, IngestedAnimation<V>>;
1968
+ /**
1969
+ * Walk-level diagnostics — the `CORS_SKIP` rows (a cross-origin sheet whose
1970
+ * `cssRules` throws `SecurityError`) and any other reason the walk could not
1971
+ * read a sheet. A typed {@link Diagnostic}[] on the same stable-`code` idiom
1972
+ * as `resolveKeyframes`; empty when every sheet was same-origin + parsed.
1973
+ */
1974
+ diagnostics: Diagnostic[];
1975
+ }
1976
+
1443
1977
  export declare type InputAnimationOptions = Partial<{
1444
1978
  duration: number | string;
1445
1979
  delay: number | string;
@@ -1464,6 +1998,15 @@ declare const jumpUp: (options?: InputAnimationOptions) => CSSKeyframesAnimation
1464
1998
  /** A keyframe map: percent/keyword stops → partial var frames. */
1465
1999
  export declare type KeyframeMap<V extends Vars> = Map<string, Partial<V>> | Record<string, Partial<V>>;
1466
2000
 
2001
+ /**
2002
+ * Options for `AnimationGroup.transitionLayer` / `crossfade` (K.W11 PHYS-C).
2003
+ * The `spring` half is the {@link SpringProgressOptions} subset that shapes the
2004
+ * weight trajectory (`response`/`dampingFraction`/`bounce`-via-config); the
2005
+ * spring is ALWAYS seeded at the layer's CURRENT weight and targets the new
2006
+ * weight, so `initial`/`initialVelocity` are managed internally and excluded.
2007
+ */
2008
+ declare type LayerTransitionSpring = Partial<Omit<SpringProgressOptions, "initial" | "initialVelocity">>;
2009
+
1467
2010
  /**
1468
2011
  * Load the heavy CSS-keyframe parsing engine — `Animation`,
1469
2012
  * `CSSKeyframesAnimation`, `AnimationGroup`, `getTimingFunction`,
@@ -1575,6 +2118,14 @@ export declare interface MotionPathOptions extends Partial<InputAnimationOptions
1575
2118
  autoPlay?: boolean;
1576
2119
  }
1577
2120
 
2121
+ declare type NativeScrollAttachment = {
2122
+ attached: true;
2123
+ animations: globalThis.Animation[];
2124
+ } | {
2125
+ attached: false;
2126
+ reason: string;
2127
+ };
2128
+
1578
2129
  /**
1579
2130
  * Spec for the ADDITIVE native scroll-driven bridge (D-LIB-2 / F-5).
1580
2131
  *
@@ -1691,6 +2242,57 @@ declare const parallaxScroll: (options?: InputAnimationOptions) => CSSKeyframesA
1691
2242
 
1692
2243
  declare type ParsedVarMap = Record<string, ValueArray>;
1693
2244
 
2245
+ /**
2246
+ * SO-1 PARSE — extract the full scroll-grammar (`animation-timeline` /
2247
+ * `animation-range` / `timeline-scope` / `animation-trigger`) from a scroll-
2248
+ * driven stylesheet (string OR a pre-parsed `Stylesheet`) into a typed
2249
+ * `CSSTimelineOptions`. Consumes value.js 0.13.0's `extractTimelineOptions` over
2250
+ * the parsed stylesheet — the acyclic-spine consume edge (the grammar lives in
2251
+ * value.js, where the `animation-*` parsing already lives; kf re-derives no
2252
+ * parallel name table).
2253
+ *
2254
+ * @example
2255
+ * parseScrollCSS(`.card {
2256
+ * animation: reveal linear both;
2257
+ * animation-timeline: view();
2258
+ * animation-range: entry 0% cover 40%;
2259
+ * }`)
2260
+ * // → { timeline: { kind: "view" },
2261
+ * // range: { start: { phase: "entry", offset: "0%" },
2262
+ * // end: { phase: "cover", offset: "40%" } } }
2263
+ */
2264
+ declare function parseScrollCSS(input: string | Stylesheet): CSSTimelineOptions;
2265
+
2266
+ /**
2267
+ * Parse an `animation-range` shorthand (`entry 0% cover 40%`) to its typed
2268
+ * `{ start, end? }` form — a pass-through to value.js's `parseAnimationRange`.
2269
+ */
2270
+ declare function parseScrollRange(input: string): AnimationRangeValue;
2271
+
2272
+ /**
2273
+ * Parse a single `animation-timeline` value (`scroll(root block)`, `view()`,
2274
+ * `--named`, `auto`, `none`) to its typed form — a thin pass-through to
2275
+ * value.js's `parseAnimationTimeline` (kf consumes the VALUE grammar; it never
2276
+ * re-derives a local parser). Emits the value VERBATIM; resolves no defaults.
2277
+ */
2278
+ declare function parseScrollTimeline(input: string): AnimationTimelineValue;
2279
+
2280
+ /**
2281
+ * SO-3 the `position:sticky` pin SYNTHESIS — EMIT the pin CSS (kf authors the
2282
+ * platform's pin; the browser pins on the compositor). The pin uses
2283
+ * `position:sticky`, NEVER `transform:translateY` (SO-4 KILLED — cross-thread
2284
+ * jitter). Returns a declaration block string the consumer applies to the
2285
+ * pinned element. `top` defaults to `0` (pin to the scrollport top).
2286
+ *
2287
+ * @example
2288
+ * pinCSS() // → "position: sticky; top: 0px;"
2289
+ * pinCSS({ top: 24 }) // → "position: sticky; top: 24px;"
2290
+ */
2291
+ declare function pinCSS(opts?: {
2292
+ top?: number;
2293
+ bottom?: number;
2294
+ }): string;
2295
+
1694
2296
  /**
1695
2297
  * The full preset taxonomy, grouped by intent. Each leaf is one of the
1696
2298
  * existing exported factory functions — the taxonomy is a discovery index over
@@ -1739,6 +2341,15 @@ declare const presetTaxonomy: {
1739
2341
  };
1740
2342
  };
1741
2343
 
2344
+ /**
2345
+ * Measure the instantaneous velocity (units/SECOND) of a position stream from
2346
+ * a two-sample {@link VelocityProbe} (K.W11 PHYS-B2). The forward difference
2347
+ * `(curr − prev) / dt` with `dt` in seconds. A zero / negative `dt` (two
2348
+ * samples at the same frame, or out-of-order) yields `0` — no division blow-up,
2349
+ * a stationary read.
2350
+ */
2351
+ export declare function probeVelocity(probe: VelocityProbe): number;
2352
+
1742
2353
  declare const progressBar: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
1743
2354
 
1744
2355
  declare const pulse: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
@@ -1863,6 +2474,81 @@ export declare interface RAFPlaybackOptions {
1863
2474
 
1864
2475
  declare const rainbowText: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
1865
2476
 
2477
+ export { RangeBoundary }
2478
+
2479
+ export { RangePhase }
2480
+
2481
+ /**
2482
+ * The reduced-motion policy a surface honors (K.W11 PHYS-E). The ONE gate
2483
+ * takes a SCALE, not just a boolean — WCAG 2.3.3-aligned ("shorten the
2484
+ * travel, keep the meaning"):
2485
+ *
2486
+ * - `false` / `undefined` — do not honor reduced motion (the conservative
2487
+ * default; the animation runs at full amplitude regardless of the OS query).
2488
+ * - `true` — the classic binary snap: under an active `prefers-reduced-motion:
2489
+ * reduce` the surface jumps to its terminal state (amplitude scale `0`).
2490
+ * - a `number` ∈ [0, 1] — the INTENSITY: under an active query the surface
2491
+ * scales its motion AMPLITUDE to this fraction (`0.3` → 30 % of the
2492
+ * displacement-from-rest) while preserving the trajectory shape, settle
2493
+ * time, and the opacity/color track. `1` ≈ full motion, `0` ≡ the binary
2494
+ * snap. The scale comes from the CONSUMER's policy (a settings slider, a
2495
+ * per-animation field) — the OS exposes only a binary signal; kf provides
2496
+ * the MECHANISM, the app provides the policy.
2497
+ */
2498
+ export declare type ReducedMotionPolicy = boolean | number | undefined;
2499
+
2500
+ /**
2501
+ * Resolve a {@link ReducedMotionPolicy} to the AMPLITUDE SCALE ∈ [0, 1] a
2502
+ * stepper multiplies its displacement-from-rest by (K.W11 PHYS-E).
2503
+ *
2504
+ * - When reduced motion is NOT honored / NOT active → `1` (full amplitude).
2505
+ * - `respect === true` under an active query → `0` (the binary snap — zero
2506
+ * displacement, the classic behavior).
2507
+ * - `respect` a number under an active query → that number, clamped to
2508
+ * [0, 1] (the intensity).
2509
+ *
2510
+ * Off-DOM / no active query → always `1`, so SSR and a user without the
2511
+ * preference set are byte-unchanged. The analytic spring scales `(originValue
2512
+ * − targetValue)` by this factor at `evaluateAt`, so amplitude scaling is
2513
+ * EXACT and free — the envelope (curve shape + settle time) is preserved by
2514
+ * construction; only the peak displacement shrinks.
2515
+ */
2516
+ export declare function reducedMotionScale(respect: ReducedMotionPolicy): number;
2517
+
2518
+ /**
2519
+ * Velocity-continuous interruption of a parsed-CSS (or any positional)
2520
+ * animation, re-served as a spring (K.W11 PHYS-B2 — the only-kf seam).
2521
+ *
2522
+ * At interruption the engine path carries a POSITION (`effectiveT` → the
2523
+ * interpolated value) but NO velocity — a keyframe stream has no analytic
2524
+ * derivative. This finite-differences the interp stream over the last frame
2525
+ * (the {@link VelocityProbe}: the two most recent `(value, time)` samples), then
2526
+ * seeds a fresh {@link SpringProgress} at the CURRENT position
2527
+ * (`probe.curr.value`) with that MEASURED velocity, targeting `newTarget`. The
2528
+ * first post-interruption frames therefore continue the prior direction and
2529
+ * speed within ε — no visible kink — instead of restarting from rest.
2530
+ *
2531
+ * The spring's `linear()` twin (`springTimingFunction` / `springLinearStops`)
2532
+ * is the SAME kf-internal emitter the compiler consumes, so the reseated
2533
+ * transition is round-trippable: the velocity-continuous interruption composes
2534
+ * INTO the round-trip rather than forfeiting it.
2535
+ *
2536
+ * Pure construction — no DOM, no rAF until the returned spring is `.play()`ed
2537
+ * or `tickDt`-driven. value.js-free (LIGHT): it composes only `SpringProgress`
2538
+ * and the leaf finite difference.
2539
+ *
2540
+ * @param probe The two most recent `(value, time-ms)` samples of the
2541
+ * interrupted stream (`prev` then `curr`, the interruption
2542
+ * position).
2543
+ * @param newTarget The value the spring transitions toward.
2544
+ * @param options Spring config (`response` / `dampingFraction` / thresholds /
2545
+ * `respectReducedMotion`); `initial` and `initialVelocity` are
2546
+ * IGNORED — they are seeded from the probe.
2547
+ * @returns A `SpringProgress` seeded at `(probe.curr.value, measured velocity)`,
2548
+ * targeting `newTarget`.
2549
+ */
2550
+ export declare function reseatToSpring(probe: VelocityProbe, newTarget: number, options?: Partial<Omit<SpringProgressOptions, "initial" | "initialVelocity">>): SpringProgress;
2551
+
1866
2552
  /**
1867
2553
  * Result of normalising a CSS keyframes input down to the shape the
1868
2554
  * `CSSKeyframesAnimation.fromString` flow expects: a `Map<percent →
@@ -1890,6 +2576,27 @@ export declare interface ResolvedKeyframes {
1890
2576
  * when the input has no matching style rule.
1891
2577
  */
1892
2578
  options: ReturnType<typeof extractAnimationOptions>;
2579
+ /**
2580
+ * Structured parse/honoring diagnostics (K.W7 S4) — every SILENT fallback
2581
+ * the resolve path used to swallow, now a citable row. CONSUMES the value.js
2582
+ * 0.12.0 `ParseDiagnostic`/`OnParseError` producer (N2 row 10): a failed
2583
+ * parse surfaced through `OnParseError` lands here as a `PARSE_ERROR` row,
2584
+ * and the kf-side fallbacks (`EMPTY_PARSE`, and the engine's
2585
+ * `COMPOSITION_FALLBACK`) join it. A FLAT additive array with stable
2586
+ * {@link DiagnosticCode}s, NOT a logging framework. Empty on a clean parse.
2587
+ * K.W8 populates the ingest rows (`CORS_SKIP`, `WAAPI_INELIGIBLE`) it owns.
2588
+ */
2589
+ diagnostics: Diagnostic[];
2590
+ }
2591
+
2592
+ /**
2593
+ * The resolved [start,end] scroll-extent fractions for a parsed
2594
+ * `animation-range`. The driver maps a raw scroll position `p ∈ [0,1]` over the
2595
+ * scene's extent into local progress `(p − start)/(end − start)`, clamped.
2596
+ */
2597
+ export declare interface ResolvedRange {
2598
+ start: number;
2599
+ end: number;
1893
2600
  }
1894
2601
 
1895
2602
  /**
@@ -1912,10 +2619,182 @@ export declare interface ResolvedKeyframes {
1912
2619
  */
1913
2620
  export declare function resolveEasing(name: string): Promise<Easing>;
1914
2621
 
2622
+ /**
2623
+ * K1 — `resolveLiveKeyframes`: the lowest-level CSSOM walk. Accepts a
2624
+ * `Document`, an explicit `CSSStyleSheet[]`, or a single `CSSStyleSheet`, and
2625
+ * reconstructs every `@keyframes` rule it can read. The per-sheet `try/catch` is
2626
+ * the honesty surface (S3): a cross-origin sheet whose `cssRules` getter throws
2627
+ * `SecurityError` becomes a `CORS_SKIP` diagnostic row — never an uncaught throw
2628
+ * and never a silent drop ("ingestion's honest failure mode IS a diagnostic").
2629
+ *
2630
+ * The named sibling of `resolveKeyframes` (`adapter.ts`): where `resolveKeyframes`
2631
+ * normalises a STRING of CSS, `resolveLiveKeyframes` normalises the LIVE CSSOM —
2632
+ * the parser pointed forward at the web the page already ships.
2633
+ */
2634
+ declare const resolveLiveKeyframes: <V extends Vars = any>(source?: Document | CSSStyleSheet[] | CSSStyleSheet, options?: IngestOptions) => IngestResult<V>;
2635
+
2636
+ /**
2637
+ * Resolve a parsed `AnimationRangeValue` (or `undefined` → the whole [0,1]
2638
+ * timeline) into [start,end] extent fractions. The driver-side fill of the
2639
+ * division-of-labour law: value.js emits the phases/offsets verbatim, kf turns
2640
+ * them into the TIME mapping.
2641
+ */
2642
+ declare function resolveRange(range: AnimationRangeValue | undefined): ResolvedRange;
2643
+
1915
2644
  declare const rotateIn: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
1916
2645
 
1917
2646
  declare const rotateScale: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
1918
2647
 
2648
+ /**
2649
+ * The full SO-1 round-trip in one call: `parse → serialize`. Returns the typed
2650
+ * options AND the re-serialized longhand declarations, so a consumer (or the
2651
+ * `proof:scroll-roundtrip` gate) can assert the replay-equality invariant
2652
+ * (`serialize(parse(s))` canonical-form-equal to `s`).
2653
+ */
2654
+ declare function roundTripScrollCSS(input: string | Stylesheet): {
2655
+ options: CSSTimelineOptions;
2656
+ declarations: ReturnType<typeof serializeScrollOptions>;
2657
+ };
2658
+
2659
+ /** Which backend a `ScrollScene` dispatched to, and why the JS path was chosen. */
2660
+ export declare type ScrollBackend = "native" | "js";
2661
+
2662
+ /** The dispatch verdict — which backend, and (for JS) the human-readable reason. */
2663
+ export declare type ScrollDispatch = {
2664
+ backend: "native";
2665
+ attachment: NativeScrollAttachment;
2666
+ } | {
2667
+ backend: "js";
2668
+ reason: string;
2669
+ };
2670
+
2671
+ /**
2672
+ * The dispatch request — what the caller wants over the parsed scene. The matrix
2673
+ * reads these + the target shape to choose native vs JS (the conservative-correct
2674
+ * backend choice with a queryable reason).
2675
+ */
2676
+ export declare interface ScrollDispatchRequest<V extends Vars> {
2677
+ /** The animation to drive over the scroll clock. */
2678
+ animation?: Animation_2<V> | undefined;
2679
+ /** The native timeline spec (`scroll`/`view`) for the eligible fast lane. */
2680
+ nativeSpec?: NativeTimelineSpec | undefined;
2681
+ /** True if scrub smoothing was requested (forces JS — native has no smoother). */
2682
+ scrub?: boolean | undefined;
2683
+ /** True if snap was requested (forces JS — native has no physics snap). */
2684
+ snap?: boolean | undefined;
2685
+ /** True if scroll velocity / non-DOM driving was requested (forces JS). */
2686
+ velocity?: boolean | undefined;
2687
+ }
2688
+
2689
+ /**
2690
+ * The kf `ScrollScene` JS DRIVER (SO-2). Drives an engine's progress from a raw
2691
+ * scroll position through the parsed `animation-range`, composing the SHIPPED
2692
+ * primitives:
2693
+ *
2694
+ * scrub → `SmoothProgress` damping (the smoothing the native lane lacks)
2695
+ * snap → `decayRest` (project the idle rest point) + `SpringProgress` settle
2696
+ * (the PHYS-D snapDecay primitive — composes shipped physics, invents none)
2697
+ * enter/leave → the threshold detector DERIVED from the parsed range
2698
+ *
2699
+ * The caller drives the loop (`scrollProgress(p)` per scroll event); the scene
2700
+ * owns no rAF. `progress` is the smoother-damped local progress the engine reads.
2701
+ *
2702
+ * The driver owns TIME (the live offset resolution); value.js owns VALUES (the
2703
+ * parsed phases/offsets). The native lane is NOT deleted — this is the universal
2704
+ * fallback the dispatch falls back to.
2705
+ */
2706
+ export declare class ScrollScene {
2707
+ private readonly resolvedRange;
2708
+ private readonly snapPoints;
2709
+ private readonly snapSpring;
2710
+ private readonly scrubSeconds;
2711
+ private readonly smoother;
2712
+ private rawScroll;
2713
+ private localProgress;
2714
+ private wasInside;
2715
+ private readonly subscribers;
2716
+ constructor(options?: ScrollSceneOptions);
2717
+ /** The resolved [start,end] scroll-extent fractions for this scene. */
2718
+ get range(): ResolvedRange;
2719
+ /**
2720
+ * Drive the scene from a raw scroll position `p ∈ [0,1]` over the scene's
2721
+ * scroll extent (the caller resolves the live scroller; kf maps it to the
2722
+ * range). Maps `p` to local progress `(p − start)/(end − start)` clamped,
2723
+ * routes it through the scrub smoother (if any), and fires enter/leave at
2724
+ * the range boundaries. Returns the (possibly un-smoothed) local progress.
2725
+ *
2726
+ * The smoother converges over subsequent `.tick(dt)` calls; the immediate
2727
+ * return is the smoother's current value (so the first call seeds the
2728
+ * target). Consumers driving their own rAF call `.tick(dt)` per frame.
2729
+ */
2730
+ scrollProgress(p: number): number;
2731
+ /**
2732
+ * Advance the scrub smoother by `dt` ms (frame-rate independent). A no-op
2733
+ * when no scrub was requested (the progress tracks scroll 1:1). Returns the
2734
+ * current smoothed local progress — the engine-write input the driver tracks.
2735
+ */
2736
+ tick(dt: number): number;
2737
+ /** The current local progress (smoother-damped if scrub was requested). */
2738
+ get progress(): number;
2739
+ /** True if no scrub smoother, or the smoother has settled. */
2740
+ get settled(): boolean;
2741
+ /**
2742
+ * SO-2 `.snap()` — PHYS-D snapDecay. On scroll-idle, project the rest point
2743
+ * the current scroll momentum would coast to (`decayRest`), pick the nearest
2744
+ * configured snap point, and settle to it via `SpringProgress`. Returns the
2745
+ * chosen snap target (local progress), or `null` when no snap points are
2746
+ * configured.
2747
+ *
2748
+ * Composes the SHIPPED `decayRest` (the closed-form projected rest) +
2749
+ * `SpringProgress` (the settle) — it invents no physics (the PHYS-A coupled
2750
+ * form is KILLED). `velocity` is the release scroll velocity (units/s); `0`
2751
+ * snaps from the rest position directly.
2752
+ */
2753
+ snapTo(velocity?: number): number | null;
2754
+ /**
2755
+ * Advance the snap settle by `dt` ms. Returns the spring's current local
2756
+ * progress (and writes it to `progress`), or the unchanged progress when no
2757
+ * snap is active. Drive this per frame after `snapTo()` until `settled`.
2758
+ */
2759
+ tickSnap(dt: number): number;
2760
+ /** Subscribe to an enter/leave threshold crossing. Returns an unsubscribe fn. */
2761
+ on(event: ScrollSceneEvent, cb: ScrollSceneSubscriber): () => void;
2762
+ private fire;
2763
+ }
2764
+
2765
+ /** The set of enter/leave threshold events the range-derived detector fires. */
2766
+ export declare type ScrollSceneEvent = "enter" | "leave";
2767
+
2768
+ export declare interface ScrollSceneOptions {
2769
+ /**
2770
+ * The parsed `CSSTimelineOptions` (from {@link parseScrollCSS}) OR a direct
2771
+ * spec. The `range` drives the [0,1] mapping; the `timeline` informs the
2772
+ * native-vs-JS dispatch (a named/`auto` timeline that the platform can run
2773
+ * natively).
2774
+ */
2775
+ range?: AnimationRangeValue | undefined;
2776
+ timeline?: AnimationTimelineValue | undefined;
2777
+ /**
2778
+ * Scrub smoothing seconds (the damping the native `animation-range` lane
2779
+ * LACKS — a STRICT capability of the JS driver). `0`/omitted ⇒ no smoothing
2780
+ * (the scrub tracks scroll 1:1). A positive value enables `SmoothProgress`
2781
+ * damping. Requesting scrub forces the JS backend (native has no smoother).
2782
+ */
2783
+ scrub?: number | undefined;
2784
+ /**
2785
+ * Snap points (local progress in [0,1]) the scene settles to on scroll-idle
2786
+ * via `decayRest` + `SpringProgress`. Requesting snap forces the JS backend.
2787
+ */
2788
+ snap?: SnapPoints | undefined;
2789
+ /** Spring config for the snap settle (the PHYS-D snapDecay primitive). */
2790
+ snapSpring?: Partial<SpringProgressOptions> | undefined;
2791
+ /** Extra SmoothProgress config for the scrub smoother. */
2792
+ smoothing?: Partial<SmoothProgressOptions> | undefined;
2793
+ }
2794
+
2795
+ /** A `.on(event, cb)` subscriber. Receives the local progress at the crossing. */
2796
+ export declare type ScrollSceneSubscriber = (progress: number) => void;
2797
+
1919
2798
  declare class ScrollTimeline_2 extends Timeline {
1920
2799
  private threshold;
1921
2800
  private getScrollY;
@@ -2187,6 +3066,26 @@ export declare interface SequenceOptions {
2187
3066
  */
2188
3067
  export declare type SequencePosition = number | `+=${number}` | `-=${number}` | string;
2189
3068
 
3069
+ /**
3070
+ * SO-1 SERIALIZE — round-trip a typed `CSSTimelineOptions` BACK to its CSS
3071
+ * longhand declarations (`{ "animation-timeline"?, "animation-range"?,
3072
+ * "timeline-scope"?, "animation-trigger"? }`). The parser run BACKWARD over the
3073
+ * SAME data model — value.js's `serializeTimelineOptions` (the inverse mirror of
3074
+ * its extractor), NOT a re-derived lossy emitter. Emits only present fields (no
3075
+ * default padding); the keys mirror the CSS longhand names.
3076
+ *
3077
+ * THE REPLAY-EQUALITY ORACLE: `serializeScrollOptions(parseScrollCSS(s))` is
3078
+ * canonical-form-equal to `s`'s scroll declarations — a faithful round-trip, OR
3079
+ * a REFUSAL (a parse that drops a phase reds the gate), never a silent
3080
+ * approximation. See {@link roundTripScrollCSS}.
3081
+ */
3082
+ declare function serializeScrollOptions(opts: CSSTimelineOptions): {
3083
+ "animation-timeline"?: string;
3084
+ "animation-range"?: string;
3085
+ "timeline-scope"?: string;
3086
+ "animation-trigger"?: string;
3087
+ };
3088
+
2190
3089
  declare const shake: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
2191
3090
 
2192
3091
  declare const skeletonLoading: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
@@ -2292,6 +3191,9 @@ export declare interface SmoothProgressOptions {
2292
3191
  respectReducedMotion: boolean;
2293
3192
  }
2294
3193
 
3194
+ /** A `.snap()` snap point — a local progress in [0,1] the scene settles to. */
3195
+ export declare type SnapPoints = readonly number[];
3196
+
2295
3197
  declare const spinner: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
2296
3198
 
2297
3199
  /**
@@ -2408,6 +3310,19 @@ export declare class SpringProgress {
2408
3310
  /** Cached `(x, v)` at the most recent target re-seat. */
2409
3311
  private originValue;
2410
3312
  private originVelocity;
3313
+ /**
3314
+ * Amplitude scale ∈ [0, 1] resolved from `respectReducedMotion` at each
3315
+ * target re-seat (K.W11 PHYS-E). `1` is full motion (the default / no
3316
+ * active query); a numeric policy under an active `prefers-reduced-motion`
3317
+ * query yields the intensity. `evaluateAt` solves toward a SCALED target
3318
+ * `origin + s·(target − origin)`, so the spring still starts at the origin
3319
+ * but travels only `s ×` the full distance — the peak overshoot scales while
3320
+ * the envelope (curve + settle time) is preserved by construction. Re-resolved
3321
+ * per re-seat (not per frame) so a live OS toggle is honored at the next
3322
+ * target change, and the per-frame `evaluateAt` stays a field read — zero
3323
+ * extra `matchMedia` cost in the hot path.
3324
+ */
3325
+ private amplitudeScale;
2411
3326
  private omega;
2412
3327
  private zeta;
2413
3328
  private omegaD;
@@ -2539,11 +3454,24 @@ export declare interface SpringProgressOptions {
2539
3454
  /** Velocity settle threshold (units/s). Default 1e-3. */
2540
3455
  velocitySettleThreshold: number;
2541
3456
  /**
2542
- * When true, honor `prefers-reduced-motion: reduce` by snapping to
2543
- * target immediately rather than springing. SSR-safe (no-op on
2544
- * non-browser environments). Default false.
3457
+ * Honor `prefers-reduced-motion: reduce` (K.W11 PHYS-E — the
3458
+ * intensity-scaled, WCAG 2.3.3-aligned gate):
3459
+ *
3460
+ * - `false` (default) — ignore the preference; the spring runs at full
3461
+ * amplitude.
3462
+ * - `true` — the classic binary snap: under an active query the spring
3463
+ * jumps to target at zero velocity (amplitude scale `0`). SSR-safe.
3464
+ * - a `number` ∈ [0, 1] — the AMPLITUDE INTENSITY: under an active query
3465
+ * the spring keeps its trajectory SHAPE (curve + settle time) but scales
3466
+ * its displacement-from-rest (`originValue − targetValue`) to this
3467
+ * fraction. At `0.3` the peak overshoot is 30 % of the full-intensity
3468
+ * peak; the envelope is preserved by construction (the analytic form
3469
+ * makes the scaling exact and free). `1` ≈ full motion, `0` ≡ the snap.
3470
+ *
3471
+ * The scale is the CONSUMER's policy (a settings slider, a per-animation
3472
+ * field) — the OS exposes only a binary signal; kf provides the mechanism.
2545
3473
  */
2546
- respectReducedMotion: boolean;
3474
+ respectReducedMotion: ReducedMotionPolicy;
2547
3475
  }
2548
3476
 
2549
3477
  /**
@@ -2688,6 +3616,16 @@ export declare interface TemplateAnimationFrame<V extends Vars> {
2688
3616
  vars: V;
2689
3617
  transform?: TransformFunction<V>;
2690
3618
  timingFunction?: Easing;
3619
+ /**
3620
+ * The author-declared `animation-composition` operator for this stop
3621
+ * (`replace` | `add` | `accumulate`), captured by the adapter and threaded
3622
+ * here so the engine HONORS it (K.W7 — the fidelity floor). Genuine
3623
+ * omission means `replace` (the default composite). value.js lifts it onto
3624
+ * `rule.composition`; `resolveKeyframes` captures it on
3625
+ * `ResolvedKeyframes.composition`; `fromString` reads that Map into this
3626
+ * field. The compiled {@link AnimationFrame.composition} inherits it.
3627
+ */
3628
+ composition?: CompositeOperator;
2691
3629
  }
2692
3630
 
2693
3631
  declare const textFocusBlur: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
@@ -2795,8 +3733,48 @@ export declare type Vars<T = any> = {
2795
3733
  [arg: string]: number | string | T;
2796
3734
  };
2797
3735
 
3736
+ /**
3737
+ * A two-sample window over a position stream — the last two `(value, time)`
3738
+ * the engine emitted before an interruption (K.W11 PHYS-B2). `time` is in
3739
+ * MILLISECONDS (the engine's `effectiveT` clock); `value` is the interpolated
3740
+ * scalar of the animated property at that time. The finite difference
3741
+ * `(curr.value − prev.value) / ((curr.time − prev.time) / 1000)` is the
3742
+ * measured velocity in units/SECOND — the one place a numerical derivative is
3743
+ * correct, because a keyframe stream carries NO analytic velocity.
3744
+ */
3745
+ export declare interface VelocityProbe {
3746
+ /** The earlier sample `(value, time-ms)`. */
3747
+ prev: {
3748
+ value: number;
3749
+ time: number;
3750
+ };
3751
+ /** The later sample `(value, time-ms)` — the interruption position. */
3752
+ curr: {
3753
+ value: number;
3754
+ time: number;
3755
+ };
3756
+ }
3757
+
2798
3758
  declare const warpLeft: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
2799
3759
 
2800
3760
  declare const warpRight: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
2801
3761
 
3762
+ /**
3763
+ * The minimal stepper surface a spring-driven blend weight reads (K.W11
3764
+ * PHYS-C). A `SpringProgress` satisfies it structurally (`value` getter +
3765
+ * `tickDt` + `settled`); typing it as this narrow shape — NOT importing
3766
+ * `SpringProgress` — keeps `constants.ts` from gaining a class edge and lets
3767
+ * a consumer drive a layer's weight with ANY analytic stepper (a decay glide,
3768
+ * a custom `Tickable`). The read is one nullish access in the `weighted` blend
3769
+ * leaf; the group's managed loop advances it per frame via `tickDt`.
3770
+ */
3771
+ export declare interface WeightStepper {
3772
+ /** The stepper's current scalar — read in place of the constant `weight`. */
3773
+ readonly value: number;
3774
+ /** Advance the stepper by `dt` milliseconds (the group's managed tick). */
3775
+ tickDt(dt: number): number;
3776
+ /** True once the stepper has converged — the group clears it then. */
3777
+ readonly settled: boolean;
3778
+ }
3779
+
2802
3780
  export { }