@mkbabb/keyframes.js 4.3.0 → 4.4.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.
@@ -2,6 +2,7 @@ import { AnimationRangeValue } from '@mkbabb/value.js';
2
2
  import { AnimationTimelineValue } from '@mkbabb/value.js';
3
3
  import { ColorSpace } from '@mkbabb/value.js';
4
4
  import { CSSTimelineOptions } from '@mkbabb/value.js';
5
+ import { CustomFunctionDescriptor } from '@mkbabb/value.js';
5
6
  import { extractAnimationOptions } from '@mkbabb/value.js';
6
7
  import { HueInterpolationMethod } from '@mkbabb/value.js';
7
8
  import { InterpolatedVar } from '@mkbabb/value.js';
@@ -101,10 +102,10 @@ export declare interface AdoptRunningOptions extends IngestOptions {
101
102
  * // MotionPath spec → fromMotionPath (F.W12 §S2)
102
103
  * animate(box, { path: "path('M 0 0 Q 100 -100 200 0')", rotate: "auto" }, { duration: 2000 });
103
104
  */
104
- declare function animate<V extends Vars = any>(target: HTMLElement | HTMLElement[], input: AnimateInput<V>, options?: AnimateOptions): CSSKeyframesAnimation<V>;
105
+ declare function animate<V extends Vars = any>(target: HTMLElement | HTMLElement[], input: AnimateInput<V>, options?: AnimateOptions): CSSKeyframesAnimation<V> | AnimationGroup<V> | Sequence<V>;
105
106
 
106
107
  /**
107
- * The declarative input to {@link animate} — one of the four `from*` shapes:
108
+ * The declarative input to {@link animate} — one of the six dispatch shapes:
108
109
  *
109
110
  * • `string` — a CSS `@keyframes` (or bare keyframe-block) source.
110
111
  * • `KeyframeMap` — `{ "0%": {...}, "100%": {...} }` or the `Map` form.
@@ -112,8 +113,12 @@ declare function animate<V extends Vars = any>(target: HTMLElement | HTMLElement
112
113
  * pair, or more stops), distributed evenly 0→100%.
113
114
  * • `MotionPathInput` — `{ path, from?, to?, rotate? }` — an `offset-distance`
114
115
  * sweep over an author `offset-path` (F.W12 §S2).
116
+ * • `AnimationGroup` — the SPATIAL per-frame blender (L.W8 §S3) — routed to
117
+ * its own `.play()`, NOT wrapped in a new animation.
118
+ * • `Sequence` — the TEMPORAL master-playhead orchestrator (L.W8 §S3)
119
+ * — routed to its own `.play()`.
115
120
  */
116
- export declare type AnimateInput<V extends Vars> = string | KeyframeMap<V> | V[] | MotionPathInput;
121
+ export declare type AnimateInput<V extends Vars> = string | KeyframeMap<V> | V[] | MotionPathInput | AnimationGroup<V> | Sequence<V>;
117
122
 
118
123
  /**
119
124
  * Options accepted by {@link animate}. The animation-options surface, plus an
@@ -131,1096 +136,760 @@ export declare interface AnimateOptions extends Partial<InputAnimationOptions> {
131
136
  autoPlay?: boolean;
132
137
  }
133
138
 
134
- declare class Animation_2<V extends Vars = any> {
135
- id: number;
136
- name: string | undefined;
137
- superKey: string | undefined;
138
- targets: HTMLElement[];
139
- options: AnimationOptions;
139
+ /**
140
+ * The value.js-bearing engine surface, resolved through `loadAnimationEngine()`.
141
+ *
142
+ * Spelled as an explicit interface (rather than `typeof import("./engine")`)
143
+ * because the dts roll-up — API Extractor — cannot resolve a `typeof import()`
144
+ * type node that points at an internal module. The shape stays in lockstep
145
+ * with `./engine`'s runtime exports.
146
+ */
147
+ export declare interface AnimationEngine {
140
148
  /**
141
- * The frame-compilation half — template frames → sampled `frames[]`.
142
- * `Animation` composes one and delegates `addFrame`/`parse` + the frame
143
- * accessors (`templateFrames`/`parsedVars`/`frames`/`frameId`) to it.
144
- * Assigned in the constructor once `options` exists (the compiler holds a
145
- * live reference to that options object).
146
- *
147
- * READ-ONLY surface (G.W19): the backing `_compiler` is written ONLY by the
148
- * constructor and {@link adoptCompiled}. An external `animation.compiler = …`
149
- * write was the one cross-boundary reach-in vector that could desync the
150
- * live-options reference (`this.options !== this.compiler.options`); making
151
- * `compiler` a get-only accessor makes that reach-in a COMPILE error, not a
152
- * convention. Adopt a compiled state via `adoptCompiled(source)`.
149
+ * The core engine constructor (PKG-3, L.W8 §S4) — renamed from `Animation`
150
+ * to clear the `globalThis.Animation` d.ts collision. `Animation` below is
151
+ * the @deprecated backward-compat alias (same runtime constructor).
153
152
  */
154
- private _compiler;
155
- get compiler(): FrameCompiler<V>;
153
+ KeyframesAnimation: typeof KeyframesAnimation;
154
+ /** @deprecated Use {@link KeyframesAnimation}. Backward-compat alias (PKG-3). */
155
+ Animation: typeof KeyframesAnimation;
156
+ CSSKeyframesAnimation: typeof CSSKeyframesAnimation;
157
+ AnimationGroup: typeof AnimationGroup;
158
+ getAnimationId: (animation: KeyframesAnimation | string) => string;
159
+ getTimingFunction: (timingFunction: TimingFunction | TimingFunctionNames | string | undefined) => TimingFunction | undefined;
160
+ resolveKeyframes: (input: string | Stylesheet) => ResolvedKeyframes;
161
+ /** The single-call front door — dispatch + auto-target + auto-play. */
162
+ animate: typeof animate;
163
+ /** CSS-native MotionPath (F.W12) — offset-distance over an author offset-path. */
164
+ MotionPath: typeof MotionPath;
165
+ fromMotionPath: typeof fromMotionPath;
166
+ /** CSS-native DrawSVG (G.W13) — stroke-dashoffset sweep over the path length. */
167
+ DrawSVG: typeof DrawSVG;
168
+ fromDrawSVG: typeof fromDrawSVG;
156
169
  /**
157
- * THE rAF owner for this animation — the standalone rAF play loop and
158
- * the WAAPI shadow tick both ride it, so `stop()` halts either
159
- * uniformly and no raw rAF handle leaks onto the instance.
170
+ * MorphSVG (O.W6, the DM-3 7-tranche chronic terminal) — SVG path-shape
171
+ * morphing over value.js's `PathGeometry`. Samples two `d` strings at
172
+ * `samples` uniform arc-length steps, pairs the points, and interpolates the
173
+ * `(x, y)` pairs across `t`; `MorphSVG.sampleD(t)` reads the morphed `d`.
160
174
  */
161
- readonly playback: RAFPlayback;
175
+ MorphSVG: typeof MorphSVG;
176
+ fromMorphSVG: typeof fromMorphSVG;
162
177
  /**
163
- * The live WAAPI compositor animations during a `_playWAAPI` delegation
164
- * (one per target), populated by `playWAAPI` and cleared on teardown.
165
- * The lifecycle methods (`stop`/`reset`) cancel these so a stopped
166
- * compositor animation never keeps painting and the awaited play
167
- * promise never hangs. Empty on the rAF path.
178
+ * The preset library (`fadeIn`, `bounce`, `shake`, …) — heavy (each returns
179
+ * a `CSSKeyframesAnimation`), so it rides the dynamic boundary as a namespace
180
+ * instead of the light static barrel: `const { presets } = await
181
+ * loadAnimationEngine(); presets.fadeIn({ duration: 500 })` (F.W11).
168
182
  */
169
- _waAnimations: globalThis.Animation[];
170
- startTime: number | undefined;
171
- pausedTime: number;
172
- t: number;
173
- iteration: number;
183
+ presets: typeof AnimationPresets;
184
+ DIRECTIONS: readonly AnimationOptions["direction"][];
185
+ FILL_MODES: readonly AnimationOptions["fillMode"][];
186
+ defaultOptions: AnimationOptions;
187
+ defaultLayerConfig: AnimationLayerConfig;
174
188
  /**
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.
189
+ * K.W8 INGEST (FLAGGED ADDITIVE) — the round-trip pointed FORWARD at the
190
+ * live web. `fromStyleSheets`/`fromLiveAnimations`/`resolveLiveKeyframes`
191
+ * walk the CSSOM into kf `CSSKeyframesAnimation` objects (per-sheet CORS
192
+ * `try/catch` → a `CORS_SKIP` diagnostic, never a silent drop); `adoptRunning`
193
+ * takes over a RUNNING CSS animation mid-flight via `getAnimations()`
194
+ * currentTime handoff (the continuity seed, NOT seed-at-zero). HEAVY (the
195
+ * ingest needs the value.js parser) — reached only here, never the LIGHT
196
+ * barrel. Named `adoptRunning` to disambiguate from `engine.adoptCompiled`.
181
197
  */
182
- diagnostics: Diagnostic[];
198
+ fromStyleSheets: typeof fromStyleSheets;
199
+ fromLiveAnimations: typeof fromLiveAnimations;
200
+ resolveLiveKeyframes: typeof resolveLiveKeyframes;
201
+ adoptRunning: typeof adoptRunning;
183
202
  /**
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).
203
+ * K.W9 SCROLL-AS-CSS (FLAGGED ADDITIVE) — the scroll-grammar round-trip
204
+ * (`parseScrollCSS` / `serializeScrollOptions` / `roundTripScrollCSS`,
205
+ * consuming value.js 0.13.0's typed `CSSTimelineOptions` extractor +
206
+ * inverse serializer), the `ScrollScene` JS driver (`createScrollScene`),
207
+ * the conservative-correct backend dispatch (`dispatchScrollBackend`), and
208
+ * the `position:sticky` pin synthesis (`pinCSS`). HEAVY (static value.js
209
+ * edge) — reached only here, never the LIGHT barrel.
192
210
  */
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;
211
+ ScrollScene: typeof ScrollScene;
212
+ createScrollScene: typeof createScrollScene;
213
+ parseScrollCSS: typeof parseScrollCSS;
214
+ parseScrollTimeline: typeof parseScrollTimeline;
215
+ parseScrollRange: typeof parseScrollRange;
216
+ serializeScrollOptions: typeof serializeScrollOptions;
217
+ roundTripScrollCSS: typeof roundTripScrollCSS;
218
+ dispatchScrollBackend: typeof dispatchScrollBackend;
219
+ resolveRange: typeof resolveRange;
220
+ pinCSS: typeof pinCSS;
221
+ /**
222
+ * K.W10 COMPILE (FLAGGED ADDITIVE) — the round-trip's BACKWARD half:
223
+ * `compileToCSS(group | sequence | childList)` → a ZERO-RUNTIME CSS artifact
224
+ * (`@keyframes` + `animation-*` longhands + `animation-composition` layering
225
+ * + `linear()` springs + materialized stagger delays + perceptual `oklab()`
226
+ * densify) PLUS the CC-3 ineligibility report (the four named refusals —
227
+ * `weighted` blend / custom renderers / perceptual oklab beyond densify /
228
+ * computed-unit drift). The compiler is the parser run BACKWARD over the SAME
229
+ * data model (`format.ts` is `keyframes.ts` run backward); a human pastes the
230
+ * result and ships with ZERO kf bytes on the page. HEAVY (value.js-bearing) —
231
+ * reached only here, never the LIGHT barrel.
232
+ */
233
+ compileToCSS: typeof compileToCSS;
234
+ /**
235
+ * L.W6 AGENT-AUTHORING VERB (FLAGGED ADDITIVE) — the round-trip's FORWARD
236
+ * half: the VALIDATION layer over the compile surface, the first question an
237
+ * LLM agent asks before it suggests kf ("will this `@keyframes` block ship
238
+ * faithfully?"). `validate(css, opts?)` is a READ-ONLY projection over three
239
+ * already-typed channels (the adapter `diagnostics`, the compile
240
+ * `{ eligible, refusals }`, the WAAPI `eligibility`) onto ONE agent-shaped
241
+ * `ValidateResult` envelope an LLM branches on WITHOUT scraping a message;
242
+ * `explain(css, opts?)` formats the SAME verdict deterministic human/LLM-
243
+ * readable. NO new engine code — a pure JOIN over the channels L.W1/L.W2 made
244
+ * honest. HEAVY (validate.ts imports the engine + compile + waapi) — reached
245
+ * only here, never the LIGHT barrel.
246
+ */
247
+ validate: typeof validate;
248
+ explain: typeof explain;
249
+ /**
250
+ * L.W8 S1 ED-3 DOGFOOD INVERSION (FLAGGED ADDITIVE) — the heavy
251
+ * serialization/painting/scheduler helpers over a parsed `Animation`.
252
+ * `CSSKeyframesToString`/`CSSKeyframesToStrings` re-serialize the parsed
253
+ * keyframes back to CSS (the FORWARD half of `fromString`, value.js-bearing);
254
+ * `formatCSSKeyframeString` trims one keyframe body for display;
255
+ * `transformTargetsStyle` paints a `Vars` snapshot onto DOM targets (the
256
+ * same painter the run loop drives); `yieldToMain` is the engine's ONE
257
+ * INP-relief yield ladder. HEAVY (they ride the engine chunk) — reached only
258
+ * here, never the LIGHT barrel.
259
+ */
260
+ CSSKeyframesToString: typeof CSSKeyframesToString;
261
+ CSSKeyframesToStrings: typeof CSSKeyframesToStrings;
262
+ formatCSSKeyframeString: typeof formatCSSKeyframeString;
263
+ transformTargetsStyle: typeof transformTargetsStyle;
264
+ yieldToMain: typeof yieldToMain;
265
+ }
266
+
267
+ export declare interface AnimationFrame<V extends Vars> {
268
+ id: number;
269
+ start: ValueUnit;
270
+ ixs: {
271
+ start: number;
272
+ stop: number;
273
+ };
274
+ time: {
275
+ start: number;
276
+ stop: number;
277
+ };
278
+ flatVars: V;
279
+ vars: V;
280
+ interpVars: {
281
+ [arg: string]: Array<InterpolatedVar<V>>;
282
+ };
283
+ /**
284
+ * Pre-flattened array of all interpolation variables across all properties.
285
+ * Built once during parse() to avoid Object.values().flat() allocation
286
+ * on every interpFrames() call in the hot path.
287
+ */
288
+ allInterpVars: Array<InterpolatedVar<V>>;
289
+ transform: TransformFunction<V>;
290
+ timingFunction: Easing;
291
+ /**
292
+ * The compiled per-segment `animation-composition` operator (K.W7). A
293
+ * segment runs from a START stop to a STOP stop; the operator is the STOP
294
+ * stop's declared composition (CSS attaches `animation-composition` to the
295
+ * keyframe being composited TOWARD). `replace` (or omission) is the legacy
296
+ * behaviour — the apply writes the lerped value verbatim. `add` accumulates
297
+ * the lerped numeric leaf onto the captured underlying base (un-clamped,
298
+ * element-wise — the same leaf `group.ts`'s `add` layer runs); `accumulate`
299
+ * is repeat-aware (iteration N stacks onto N−1's end). A non-numeric leaf
300
+ * (color, `<custom-ident>`) `replace`-falls-back AND emits a
301
+ * `COMPOSITION_FALLBACK` diagnostic — never a silent wrong pixel.
302
+ */
303
+ composition?: CompositeOperator;
304
+ }
305
+
306
+ export declare class AnimationGroup<V extends Vars> {
307
+ animations: AnimationGroupObject<V>;
308
+ /**
309
+ * The group's composite transform. Defaults to a real no-op at the FIELD
310
+ * (I.W0 S3) — NOT a lying definite-assignment assertion: a childless or
311
+ * pre-`parse()` group composites nothing via a harmless no-op instead of
312
+ * throwing `this.transform is not a function`. The constructor overrides it
313
+ * with the first child's transform when one exists.
314
+ */
315
+ transform: TransformFunction<V>;
316
+ superKey: string | undefined;
317
+ paused: boolean;
202
318
  started: boolean;
203
319
  done: boolean;
204
- reversed: boolean;
205
- paused: boolean;
206
320
  /**
207
- * True when an `AnimationGroup` is driving this animation's
208
- * `advanceTo()` and `interpFrames()` from its own rAF loop. Set by
209
- * the group at construction; standalone `.play()` / `.draw()`
210
- * throw when this is true rather than racing the group.
321
+ * When true, `play()` honors `prefers-reduced-motion: reduce` by snapping
322
+ * every child to its final frame in a single composite instead of running
323
+ * the rAF draw loop. SSR-safe off-DOM. Default false.
211
324
  */
212
- managed: boolean;
325
+ respectReducedMotion: boolean;
213
326
  /**
214
- * If the most recent `play()` was rejected by WAAPI eligibility
215
- * but `useWAAPI: true` was requested, this records the reason.
216
- * Queryable by debug builds — no console output is produced.
327
+ * Children-per-slice before `advanceTo()` yields to the main thread. Groups
328
+ * at or under this size tick in one slice (fast path); larger groups tick in
329
+ * batches with a `scheduler.yield()` between them (INP relief).
217
330
  */
218
- waapiIneligibleReason: string | undefined;
219
- unflatten: boolean;
220
- private resolvePromise;
331
+ static readonly YIELD_BATCH = 32;
332
+ singleTarget: boolean;
333
+ lastTickTime: number;
334
+ /** THE rAF owner for the group's draw loop. */
335
+ readonly playback: RAFPlayback;
336
+ resolvePromise: ((value: void | PromiseLike<void>) => void) | null;
221
337
  private _playingPromise;
338
+ /** Pre-bound frame callback — allocated once to avoid a per-loop closure. */
339
+ private _boundFrame;
340
+ /** Cached entries sorted by layer zIndex (see `getEntries`). */
341
+ private _entries;
342
+ private _entriesDirty;
222
343
  /**
223
- * Pre-bound frame callback — allocated once to avoid creating a new
224
- * closure on every playback loop start.
344
+ * Long-lived composite buffer, cleared in place at the top of
345
+ * `transformFramesGrouped` (the zero-alloc idiom `interpFrames`'s `out` buffer
346
+ * uses) — no fresh object allocated per frame.
225
347
  */
226
- private _boundFrame;
348
+ private _grouped;
227
349
  /**
228
- * The ONE output buffer for the standalone play loop's `interpFrames`
229
- * calls — reused every frame so steady-state playback allocates no
230
- * per-frame result object (the primitive-level analogue of the group's
231
- * hoisted `_grouped` buffer, gated by `proof:standalone-zero-alloc`).
232
- * The play path (`_frame`) never returns this object to a consumer, so
233
- * reuse is safe; `at()` (a query whose result the caller keeps) still
234
- * allocates a fresh object.
350
+ * The compile-stable union of every child's contributed (whitelist-filtered)
351
+ * keys — what `_grouped` is null-filled to each frame so the composite clears
352
+ * WITHOUT `delete` (F.W4 S2: the delete-loop trapped `_grouped` in V8
353
+ * dictionary mode). Recomputed only on a structural change; the fold lives in
354
+ * `group-layer-springs`.
235
355
  */
236
- private _interpOut;
356
+ private _groupedKeys;
357
+ private _groupedKeysDirty;
237
358
  /**
238
- * The compile-stable union of every frame's `flatVars` keys — the maximal
239
- * key-set any `interpFrames` call can write. Fixed at `parse` (the keys
240
- * never change across frames; a color-space renormalize re-derives the same
241
- * carriers under the same keys). It is what `clearBuffer` null-fills to keep
242
- * a reused buffer stale-free WITHOUT `delete` (F.W4 S1 — the V8 dictionary-
243
- * mode trap the delete-loop fell into). Exposed (read-only) as `flatKeys`
244
- * so the `AnimationGroup` can size its own composite buffer the same way.
359
+ * P.W2 — the SoA composite layout for the `add`/`weighted` blend arms (the
360
+ * validated 3.7× — `scripts/group-soa-decision.json`, bit-identical
361
+ * `maxErr=0`). One {@link SoALayerPlan} per `add`/`weighted` entry: the FLAT
362
+ * list of pure-numeric `(carrier, incoming)` `ValueUnit<number>` pairs that
363
+ * blend would touch, hoisted out of the per-frame `for..in` + `Array.isArray`
364
+ * + per-element `isNumericUnit` dispatch into a contiguous {@link Float64Array}
365
+ * fold. Rebuilt ONLY on a structural change (alongside `_groupedKeys`), NEVER
366
+ * per frame. The `replace` default arm is dispatch-free and carries NO plan;
367
+ * the non-numeric (color/computed/string/mixed) tail keeps the boxed
368
+ * per-element path. The probe (`carrier-probe`) proved `interpFrames` MUTATES
369
+ * each leaf `ValueUnit.value` IN PLACE, so the carrier + incoming refs are
370
+ * STABLE across frames — the plan is valid until the entry set / a layer
371
+ * whitelist / a blend mode changes (every such mutation routes through
372
+ * `invalidateEntries`).
373
+ */
374
+ private _soaPlans;
375
+ /**
376
+ * The long-lived SoA fold scratch — the contiguous numeric accumulate buffer
377
+ * the `add`/`weighted` fold seeds, folds, and writes back through. Sized to
378
+ * the WIDEST single-layer numeric pair count once per structural change
379
+ * (reused across layers AND frames — zero per-frame alloc, the F.W4 zero-alloc
380
+ * discipline). `null` until the first plan with numeric pairs is built.
381
+ */
382
+ private _compositeBuf;
383
+ /**
384
+ * K.W11 PHYS-C — true iff ANY layer currently carries a `weightSpring`. The
385
+ * fast-path guard: when false (the universal case) `advanceTo` skips the
386
+ * per-frame spring scan entirely, so the constant-weight blend hot path takes
387
+ * ZERO new work. Set true by `transitionLayer`; recomputed false once every
388
+ * driving spring has settled.
245
389
  */
246
- private _stableKeys;
390
+ private _hasLayerSprings;
391
+ constructor(...inputs: (KeyframesAnimation<V> | AnimationGroupInput<V>)[]);
247
392
  /**
248
- * The consumer's EXPLICIT constructor options (NOT merged with defaults) —
249
- * retained so `fromString` can layer a parsed style-rule `animation`
250
- * shorthand UNDER them (constructor-explicit wins over parsed-from-CSS, F.W8).
393
+ * The animation entries sorted by layer zIndex, dirty-flag cached — rebuilt
394
+ * only when the animations object or a layer config is mutated. All hot-path
395
+ * iteration uses this instead of `Object.values()`.
251
396
  */
252
- protected _ctorOptions: Partial<InputAnimationOptions>;
253
- /** The compile-stable union of this animation's interpolated keys. */
254
- get flatKeys(): readonly string[];
397
+ private getEntries;
398
+ /** Mark entries cache stale. Called at all mutation boundaries. */
399
+ private invalidateEntries;
400
+ setSuperKey(superKey: string): this;
401
+ setTargets(...targets: HTMLElement[]): this;
402
+ onStart(): this;
403
+ onEnd(): this;
255
404
  /**
256
- * The instance's ONE default DOM-style renderer, allocated once.
257
- * "Did the consumer supply a custom transform?" is a reference
258
- * comparison against this single value ({@link usesDefaultRenderer}) —
259
- * typed and bind-proof, unlike a Symbol tag on a closure, which
260
- * `Function.prototype.bind` silently drops.
405
+ * Composite all animation values into a single grouped transform (per-frame
406
+ * for single-target groups). Applies layer blending (replace / add /
407
+ * weighted) in zIndex order, then calls the group transform with the merged
408
+ * values. Each child's values refresh in place (`interpFrames` clears and
409
+ * rewrites the long-lived buffer), so no stale keys leak and no fresh object
410
+ * is allocated per entry per frame.
261
411
  */
262
- protected readonly _defaultTransform: TransformFunction<V>;
263
- /** True when `fn` is this instance's default DOM-style renderer. */
264
- usesDefaultRenderer(fn: TransformFunction<V> | undefined): boolean;
265
- private dispatchAnimationEvent;
266
- constructor(options?: Partial<InputAnimationOptions>, targets?: HTMLElement[] | HTMLElement | undefined, name?: string | undefined, superKey?: string | undefined);
267
- get templateFrames(): TemplateAnimationFrame<V>[];
268
- set templateFrames(value: TemplateAnimationFrame<V>[]);
269
- get parsedVars(): ParsedVarMap[];
270
- get frames(): AnimationFrame<V>[];
271
- get frameId(): number;
272
- /** Append a template frame (delegated to the compiler). Chainable. */
273
- addFrame<K extends V>(start: number | string | ValueUnit<number>, vars: Partial<K>, transform?: TransformFunction<K>, timingFunction?: InputAnimationOptions["timingFunction"], composition?: CompositeOperator): Animation_2<K>;
274
- /** Compile the template frames into the sampled `frames[]`. Chainable. */
275
- parse(): this;
412
+ transformFramesGrouped(t: number): Record<string, unknown>;
276
413
  /**
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.
414
+ * The boxed `add`/`weighted` blend arm — the per-element AoS path that the
415
+ * SoA fold (`soaBlendLayer`) supplants for the pure-numeric majority. Kept as
416
+ * THE blend implementation for two roles: (1) the plan-build frame (every key,
417
+ * `only === undefined`) — it establishes the carriers `buildSoAPlans` then
418
+ * captures; (2) the per-frame residual (the plan's `boxedKeys` — non-numeric /
419
+ * mixed / first-touch leaves the fold cannot cover, typically empty). Both
420
+ * arms guard on `Array.isArray(existing) && Array.isArray(incoming)` and loop
421
+ * `Math.min(existing.length, incoming.length)` elements with a per-element
422
+ * `isNumericUnit` guard — the byte-exact G.W17 leaf contract (proof:blend),
423
+ * un-clamped `add` (`+=`), spring-weighted `lerp`. A non-array carrier (or a
424
+ * skipped key) falls through to `groupedValues[key] = incoming`.
425
+ */
426
+ private boxedBlendArm;
427
+ /**
428
+ * P.W2 — the SoA fold for ONE `add`/`weighted` layer (the validated 3.7×,
429
+ * `scripts/group-soa-decision.json`: weighted 3.66×, add 3.69×, bit-identical
430
+ * `maxErr=0`). Replaces the boxed `for..in` + `Array.isArray` + per-element
431
+ * `isNumericUnit` dispatch with a contiguous {@link Float64Array} fold over the
432
+ * plan's precomputed numeric `(carrier, incoming)` pairs: seed `_compositeBuf`
433
+ * from each carrier, apply the op against the incoming, write back. The carrier
434
+ * units are the SAME `ValueUnit`s a lower layer parked in `_grouped` (the refs
435
+ * are frame-stable — `interpFrames` mutates `.value` in place), so writing the
436
+ * folded result back to `carrier.value` mutates the live composite exactly as
437
+ * the boxed arm did. The `add` accumulate is naturally UN-CLAMPED; the
438
+ * `weighted` lerp reads ONE per-layer `w` (the K.W11 PHYS-C spring weight).
439
+ */
440
+ private soaBlendLayer;
441
+ /**
442
+ * P.W2 — build the SoA fold layout for every `add`/`weighted` layer (rebuilt
443
+ * ONLY on a structural change, gated by the `_groupedKeys` dirty seam). A
444
+ * NON-destructive carrier-resolution walk in zIndex order mirrors the boxed
445
+ * blend's carrier semantics EXACTLY: `replace` (and the non-array first-touch
446
+ * fall-through) parks a key's leaf as its carrier; `add`/`weighted` over an
447
+ * array carrier blend the numeric elements in place. For each `add`/`weighted`
448
+ * layer, the pure-numeric `(carrier, incoming)` element pairs (carrier IS an
449
+ * array, both elements numeric) are extracted into the flat `carriers`/
450
+ * `incomings` arrays the fold loops; every other key it touches (non-array
451
+ * carrier, or ANY non-numeric / mixed element) is recorded in `boxedKeys` for
452
+ * the boxed residual. `_compositeBuf` is grown to the widest layer's numeric
453
+ * width ONCE (reused across layers and frames — zero per-frame alloc). The
454
+ * walk mutates NOTHING (it reads `.value` only to classify, never writes), so
455
+ * the building frame's already-computed composite is untouched.
456
+ */
457
+ private buildSoAPlans;
458
+ /**
459
+ * Render the current composition as a static frame at each child's current
460
+ * `t`. Single-target groups go through the blended transform; multi-target
461
+ * groups apply each child's interpolated vars to its own targets. The public
462
+ * entry point for state mutated outside the rAF loop (scrubbing, state
463
+ * restore, pause snapshots) that needs the visual to update immediately.
283
464
  */
284
- private computeHasComposition;
465
+ render(): void;
285
466
  /**
286
- * Adopt another animation's ALREADY-COMPILED state as ONE atomic motion
287
- * (G.W19) — the first-class verb for the "single-compile, then transplant"
288
- * pattern (E.W8 S0): a throwaway animation is built + compiled ONCE off the
289
- * new keyframes, and the live animation adopts that compiled state without a
290
- * second compile.
291
- *
292
- * The transplant moves the `{ compiler, options, unflatten }` triad together
293
- * and re-binds the live-options reference BY CONSTRUCTION — `this.options` is
294
- * read OFF the adopted compiler, so `this.options === this.compiler.options`
295
- * holds without relying on the caller's assignment order. This is the
296
- * invariant the demo formerly held by a comment + three ordered field writes;
297
- * here it is the method's contract, enforced by `proof:adopt-compiled`. A
298
- * `compiler` adopted WITHOUT re-binding `options` would leave the setters
299
- * mutating one object while the compiler reads another — the exact desync
300
- * the `6e29236` live-options lock guards against.
301
- *
302
- * Recomputes `_stableKeys` so `flatKeys` (the buffer-sizing contract)
303
- * reflects the adopted compiled frames, not the pre-adopt key-set. Chainable.
304
- *
305
- * @param source an animation whose `compiler` is already compiled.
467
+ * Set a child animation's current time without touching its siblings.
468
+ * Updates `pausedTime` so the child resumes correctly from the scrub
469
+ * position. Chainable; call `render()` afterwards to reflect it visually.
306
470
  */
307
- adoptCompiled(source: Animation_2<V>): this;
471
+ setChildTime(nameOrAnim: string | KeyframesAnimation<V>, t: number): this;
308
472
  /**
309
- * Recompute `_stableKeys` — the union of every compiled frame's `flatVars`
310
- * keys — after a (re)compile. The maximal key-set the `clearBuffer`
311
- * null-fill resets, so a reused interpolation buffer stays in V8
312
- * fast-properties mode without ever calling `delete` (F.W4 S1).
473
+ * Advance all child animations to absolute clock `t`. SYNC on the steady
474
+ * path (J.W6 S1): children that all step synchronously advance the group
475
+ * with no per-frame `Promise.all`/microtask hop; a thenable only on a
476
+ * genuinely-async child or the over-`YIELD_BATCH` yield path.
313
477
  */
314
- private computeStableKeys;
478
+ advanceTo(t: number): this | Promise<this>;
479
+ /** The post-advance tail — `onEnd` once the render marked done. */
480
+ private _endAdvance;
315
481
  /**
316
- * Option setters — the fail-explicit contract.
317
- *
318
- * Genuine omission (`undefined`/`null`) means "use the default" and is
319
- * always accepted; present-but-malformed input THROWS a typed
320
- * `AnimationOptionError` naming the option and the offending value.
321
- * This is the same posture the layer API chose ("silent no-ops were
322
- * hiding consumer bugs") applied to the whole options surface — no
323
- * silent fallback, no silently-preserved previous value.
482
+ * One frame of the group's draw loop (driven by `RAFPlayback.loop`): ticks
483
+ * all children, then renders (single-target: grouped blending; multi-target:
484
+ * per-child). Returns whether the loop should continue.
324
485
  */
325
- setTimingFunction(timingFunction: InputAnimationOptions["timingFunction"]): this;
326
- setIterationCount(iterationCount: InputAnimationOptions["iterationCount"]): this;
327
- setDuration(duration: InputAnimationOptions["duration"]): this;
328
- setDelay(delay: InputAnimationOptions["delay"]): this;
329
- setDirection(direction: InputAnimationOptions["direction"]): this;
330
- setFillMode(fillMode: InputAnimationOptions["fillMode"]): this;
331
- setUseWAAPI(useWAAPI: InputAnimationOptions["useWAAPI"]): this;
332
- setRespectReducedMotion(respectReducedMotion: InputAnimationOptions["respectReducedMotion"]): this;
333
- setColorSpace(colorSpace: InputAnimationOptions["colorSpace"]): this;
334
- setHueMethod(hueMethod: InputAnimationOptions["hueMethod"]): this;
335
- setOptions(options: Partial<InputAnimationOptions>): this;
336
- reverse(): this;
337
- fillForwards(): void;
338
- fillBackwards(): void;
486
+ private _frame;
487
+ /** The post-advance render half of `_frame` — composite, or settle. */
488
+ private _renderFrame;
489
+ private _resolvePlay;
339
490
  /**
340
- * Where the playhead rests after a completed play — derived ONCE from
341
- * `fillMode` (forwards/both → final; none/backwards → initial). This is
342
- * the explicit rest-position contract: completion paints the rest frame
343
- * per this derivation, and the reduced-motion snap is "rest = final,
344
- * paint it, settle" — the same path a `fillMode: forwards` completion
345
- * takes, not a separate code path.
491
+ * The completion front-door (G.W13) — `await group.finished` resolves once
492
+ * the in-flight composite play settles. Exposes the ONE held
493
+ * `_playingPromise` `play()` constructs (the re-entrant guard returns it;
494
+ * the `finally`-clear nulls it on settle) — NOT a second completion
495
+ * lifecycle. A settled (or never-played) group resolves immediately.
346
496
  */
347
- get restPosition(): "initial" | "final";
348
- /** Paint the rest frame per the fill contract. */
349
- paintRest(): void;
497
+ get finished(): Promise<void>;
350
498
  /**
351
- * Stateless progress query. Maps [0,1] from first keyframe to last,
352
- * regardless of playback direction. `apply=true` invokes transform callbacks.
499
+ * Start the animation group. Resolves when all children complete (or on
500
+ * explicit stop/reset). Re-entrant: a `play()` while one is in flight
501
+ * returns the same promise rather than leaking a second draw loop. Under
502
+ * `respectReducedMotion` + an active query, snaps every child to its final
503
+ * frame in a single composite (no rAF loop), then settles as a completed
504
+ * play would.
353
505
  */
354
- at(progress: number, apply?: boolean): Record<string, ValueUnit[]>;
506
+ play(): Promise<void>;
355
507
  /**
356
- * Interpolate all active frames at time `t`. This is the hot path —
357
- * called once per rAF frame during playback.
358
- *
359
- * Uses binary search (O(log N)) to find the first matching frame,
360
- * then scans neighbors to collect all overlapping frames at `t`
361
- * (multiple properties may share the same time range).
362
- *
363
- * @param t - Current animation time in milliseconds
364
- * @param transformFrames - If true, applies each frame's transform function to targets
365
- * @param out - Optional output object to write results into. When
366
- * provided, its keys are cleared first so no stale keys from a
367
- * previous call leak through. Pass this per-animation to achieve
368
- * zero-allocation steady-state playback.
369
- * @returns Merged flat vars from all active frames
508
+ * `prefers-reduced-motion` snap: rest = final, paint it, settle — the SAME
509
+ * terminal path a completed play takes, motion elided. Every child advances
510
+ * to its final frame, one composite paints, `settle()` readies the group for
511
+ * replay (final frame stays on the target(s), matching `Animation`'s snap).
370
512
  */
371
- interpFrames(t: number, transformFrames?: boolean, out?: Record<string, ValueUnit[]>): Record<string, ValueUnit[]>;
513
+ private _playReducedMotion;
372
514
  /**
373
- * Clear a reused interpolation buffer to a stale-free state WITHOUT
374
- * `delete` — the V8-correct stable-key null-fill (F.W4 S1). The key-set is
375
- * compile-stable (`_stableKeys` is the union of every frame's `flatVars`
376
- * keys, fixed at `parse`), so null-filling it keeps the buffer in
377
- * fast-properties mode AND zero-alloc. Inactive keys read back `undefined`;
378
- * every consumer of a reused buffer (the group blend, the unused play-loop
379
- * `_interpOut`) skips them — only the standalone return path (which never
380
- * reuses a buffer) must be `undefined`-free, and it takes the alias / fresh
381
- * merge above.
515
+ * Pause the group — idempotent. Pausing an already-paused (or
516
+ * not-yet-started) group is a no-op, NOT a resume (use {@link toggle} for
517
+ * the explicit flip). Cancels the rAF loop immediately and renders a
518
+ * final-frame snapshot so the visual matches the exact pause moment.
382
519
  */
383
- private clearBuffer;
520
+ pause(): this;
384
521
  /**
385
- * Interpolate ONE active frame at time `t` in place (lerp + optional
386
- * transform). Lifted off the `interpFrames` hot loop so playback allocates
387
- * no per-frame closure. A zero-width frame (`start === stop`, a degenerate
388
- * keyframe pair) snaps to the endpoint instead of dividing by zero in
389
- * `scale` (E-RT-5). The merge into the result buffer is done by the caller
390
- * (F.W4 S3 — so the single-frame path can alias `flatVars` with no copy).
522
+ * Resume the group — idempotent. Unpauses every child DIRECTLY (not via
523
+ * `child.resume()`, which would start each child's own rAF loop — the
524
+ * group's draw loop owns the ticking) and re-registers that loop.
391
525
  */
392
- private processFrame;
526
+ resume(): this;
527
+ /** The explicit flip: pauses if playing, resumes if paused. */
528
+ toggle(): this;
393
529
  /**
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.
530
+ * Pure state teardown — never paints. Releases every child
531
+ * (`managed = false`, `child.settle()`) and clears the group's playback
532
+ * flags. Completion and the reduced-motion snap both end here, leaving the
533
+ * rest frame on the target(s).
414
534
  */
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;
437
- /** SYNC unless `delay > 0` — then a thenable resolving after the sleep. */
438
- onStart(): Promise<void> | undefined;
439
- onEnd(): void;
535
+ settle(): this;
440
536
  /**
441
- * Advance the playhead to absolute clock `t` (a rAF timestamp, NOT a
442
- * delta). Lazily runs `onStart` on the first call, reconciles the
443
- * pause/resume clock, and ends the iteration once `t` reaches the
444
- * duration. This is the DRIVER-layer advance — the one meaning of the
445
- * absolute-clock step, distinct from the `tickDt(dt)` stepper surface
446
- * the rest of the engine canonicalized to.
447
- *
448
- * SYNC on the steady path (J.W6 S1 — the F.W5 held half, landed): every
449
- * post-start frame returns a plain number (no per-frame promise+microtask
450
- * hop); a thenable ONLY when the FIRST tick awaits the genuinely-async
451
- * delay sleep. Ordering locked by proof:event-ordering.
537
+ * Explicit rewind: paint every started child back to its INITIAL frame, then
538
+ * settle — the user-facing "return to start". Completion does NOT come here
539
+ * (it settles where the fill contract rested the pixels).
452
540
  */
453
- advanceTo(t: number): number | Promise<number>;
454
- /** The post-start advance body — pause clock, local time, iteration end. */
455
- private _advance;
541
+ reset(): this;
456
542
  /**
457
- * One frame of the standalone rAF play path, driven by the shared
458
- * `RAFPlayback.loop`. Returns whether the loop should continue.
543
+ * Halt the draw loop, rewind to the initial frame (the transport-stop
544
+ * semantic the demo's controls expect), and resolve any pending `play()`.
459
545
  */
460
- private _frame;
461
- /** The post-advance render half of `_frame` — paint, or settle on done. */
462
- private _renderFrame;
463
- private _resolvePlay;
464
- /** Internal rAF-based play loop — loop ownership rides `this.playback`. */
465
- private _playRAF;
546
+ stop(): this;
547
+ playing(): boolean;
548
+ forcePause(): void;
549
+ forcePlay(): void;
466
550
  /**
467
- * Play via the Web Animations API. WAAPI handles visuals on the
468
- * compositor thread; a shadow loop in `playWAAPI` (riding
469
- * `this.playback`) drives `advanceTo()` so events, iteration count,
470
- * pause/resume, and other lifecycle state stay coherent with the
471
- * rAF path.
472
- *
473
- * No silent fallback — eligibility is decided once in `play()`
474
- * before this is invoked, and runtime errors propagate.
551
+ * Set layer config for an animation by name or reference. Chainable; throws
552
+ * on an unregistered key (silent no-ops were hiding consumer bugs).
475
553
  */
476
- private _playWAAPI;
554
+ setLayerConfig(nameOrAnim: string | KeyframesAnimation<V>, config: Partial<AnimationLayerConfig>): this;
555
+ /** Convenience toggle for enabling/disabling a layer. Chainable. */
556
+ setLayerEnabled(nameOrAnim: string | KeyframesAnimation<V>, enabled: boolean): this;
557
+ /** Read the layer config for an animation by name or reference. */
558
+ getLayerConfig(nameOrAnim: string | KeyframesAnimation<V>): AnimationLayerConfig | undefined;
559
+ /**
560
+ * Spring a layer's blend `weight` from its CURRENT value to `weight` (K.W11
561
+ * PHYS-C — the spring-driven crossfade). Seeds a `SpringProgress` (via
562
+ * `seedLayerSpring`), parks it on `layer.weightSpring`, and forces
563
+ * `blendMode` to `weighted`. A re-target mid-flight RE-SEATS the in-flight
564
+ * spring from its live `(value, velocity)` (`set target`) — no kink. Full
565
+ * trajectory documentation in `./group-layer-springs`. Chainable.
566
+ */
567
+ transitionLayer(nameOrAnim: string | KeyframesAnimation<V>, target: {
568
+ weight: number;
569
+ spring?: LayerTransitionSpring;
570
+ }): this;
477
571
  /**
478
- * Cancel the live WAAPI compositor animations (if any). Cancelling
479
- * rejects each `wa.finished`, which `playWAAPI` catches as a halt — so
480
- * this both stops the compositor paint AND unblocks the awaited play
481
- * promise. No-op on the rAF path.
572
+ * Physically crossfade between two layers (K.W11 PHYS-C): spring layer `a`
573
+ * down to weight `0` and layer `b` up to weight `1`, each over its own
574
+ * `SpringProgress`. Two `transitionLayer` calls — the flagship demo moment, a
575
+ * crossfade that overshoots and settles. Chainable.
482
576
  */
483
- private _cancelWAAPI;
577
+ crossfade(a: string | KeyframesAnimation<V>, b: string | KeyframesAnimation<V>, options?: {
578
+ spring?: LayerTransitionSpring;
579
+ }): this;
484
580
  /**
485
- * `prefers-reduced-motion` snap: rest = final, paint it, settle — the
486
- * SAME terminal path a `fillMode: forwards` completion takes, with the
487
- * motion elided. The lifecycle stays observable (`animationstart` →
488
- * final paint → `animationend`) so consumers' event wiring is identical
489
- * to a completed normal play.
581
+ * Advance every spring-driven layer weight by the frame delta `dt` ms (K.W11
582
+ * PHYS-C). Called from `advanceTo` ONLY when `_hasLayerSprings` is true, so
583
+ * the constant-weight path pays nothing. On settle the converged value
584
+ * commits to the constant `layer.weight` and the spring is CLEARED — the
585
+ * `weighted` leaf's `?? layer.weight` read then serves the constant.
490
586
  */
491
- private _playReducedMotion;
587
+ private advanceLayerSprings;
588
+ }
589
+
590
+ export declare interface AnimationGroupEntry<V extends Vars> {
591
+ animation: KeyframesAnimation<V>;
592
+ values: Record<string, unknown>;
593
+ layer: AnimationLayerConfig;
594
+ }
595
+
596
+ /** Input type for AnimationGroup constructor — bare Animation or Animation with layer config. */
597
+ declare type AnimationGroupInput<V extends Vars> = KeyframesAnimation<V> | {
598
+ animation: KeyframesAnimation<V>;
599
+ layer?: Partial<AnimationLayerConfig>;
600
+ };
601
+
602
+ declare interface AnimationGroupObject<V extends Vars> {
603
+ [key: string]: AnimationGroupEntry<V>;
604
+ }
605
+
606
+ export declare interface AnimationLayerConfig {
607
+ /** Higher wins. Default: 0 */
608
+ zIndex: number;
609
+ /** 0–1 for 'weighted' blend mode. Default: 1 */
610
+ weight: number;
492
611
  /**
493
- * Mid-flight reduced-motion snap (D-LIB-3). A running rAF loop detected a
494
- * live flip to `reduce`; converge to the rest frame and resolve the
495
- * in-flight `play()` exactly as a forwards completion would. Distinct from
496
- * `_playReducedMotion` (the up-front gate) only in that `animationstart`
497
- * already fired — so here we paint final, mark done, end, settle, and
498
- * release the awaiter. The WAAPI lane snaps via the same path: the up-front
499
- * gate already routes reduced-motion away from WAAPI, and a live flip on a
500
- * WAAPI animation cancels the compositor handles before settling.
612
+ * Optional spring (or any {@link WeightStepper}) DRIVING this layer's
613
+ * blend `weight` (K.W11 PHYS-C — the spring-driven crossfade). When
614
+ * present the `weighted` blend leaf reads `weightSpring.value` in place of
615
+ * the constant `weight` (one nullish read; the per-frame lerp untouched),
616
+ * so a layer transition follows a PHYSICAL trajectory that can overshoot
617
+ * and settle — the flagship demo moment only kf's weighted-blend substrate
618
+ * can hold. Constructed + advanced by `AnimationGroup.transitionLayer` /
619
+ * `crossfade`; cleared on settle, when the read falls back to the
620
+ * now-updated constant `weight`. Absent on a static-weight layer (the
621
+ * read is `?? layer.weight`), so the constant path is byte-unchanged.
501
622
  */
502
- private _snapToReducedMotion;
623
+ weightSpring?: WeightStepper;
503
624
  /**
504
- * The completion front-door (G.W13) — `await anim.finished` resolves once
505
- * the in-flight play settles. It exposes the ONE held `_playingPromise`
506
- * `play()` already constructs (the re-entrant guard returns it; the
507
- * `finally`-clear nulls it on settle) — NOT a second completion lifecycle.
508
- * Two reads mid-play return the SAME promise. A settled (or never-played)
509
- * animation reads `null` and resolves immediately: "not running" = "nothing
510
- * to await" — the honest semantics for a getter that reports current
511
- * settledness, not a pre-armed future run.
625
+ * Default: 'replace'. Defaulting on a genuinely-omitted blend mode is
626
+ * the sanctioned contract (the fail-explicit seam throws only on
627
+ * malformed PRESENT input, never on omission) — an unspecified layer
628
+ * blends by replacement, the least-surprising composite.
512
629
  */
513
- get finished(): Promise<void>;
514
- play(): Promise<void>;
630
+ blendMode: BlendMode;
631
+ /** Layer toggle. Default: true */
632
+ enabled: boolean;
633
+ /** Optional property whitelist — only these properties will be output from this layer */
634
+ properties?: Set<string>;
635
+ }
636
+
637
+ /** Thrown when an animation option receives malformed (non-undefined) input. */
638
+ export declare class AnimationOptionError extends Error {
639
+ readonly option: string;
640
+ readonly value: unknown;
515
641
  /**
516
- * Pause playback — idempotent. Pausing an already-paused (or
517
- * not-yet-started) animation is a no-op, never a resume: a method named
518
- * `pause` pauses. Use {@link resume} for the explicit resume.
642
+ * Stable structured reason for programmatic consumers — branch on this,
643
+ * never on the human message. Carried only by the two named rows
644
+ * ({@link AnimationOptionErrorCode}); undefined otherwise.
519
645
  */
520
- pause(): this;
521
- resume(): this;
522
- /** The explicit flip: pauses if playing, resumes if paused. */
523
- toggle(): this;
524
- /**
525
- * Halt playback where it stands: cancel the loop AND the WAAPI
526
- * compositor animations, settle state, and resolve any pending `play()`
527
- * promise. Never paints — `reset()` is the explicit rewind.
528
- */
529
- stop(): void;
530
- playing(): boolean;
531
- /** Returns the effective time accounting for direction reversal. */
532
- get effectiveT(): number;
533
- /**
534
- * Pure state teardown — flags, clocks, iteration. NEVER paints. This is
535
- * the terminal half of the rest-position contract: completion paints
536
- * the rest frame (via `onEnd` → `paintRest`) and then settles; the
537
- * reduced-motion snap paints final and then settles. Settling is
538
- * orthogonal to where the pixels rest.
539
- */
540
- settle(): this;
541
- /**
542
- * Explicit rewind: paint the INITIAL frame, then settle. This is the
543
- * user-facing "return to start" — rest position `initial`, painted
544
- * deliberately — distinct from `settle()`, which tears down state and
545
- * leaves the pixels where they rest.
546
- */
547
- reset(): this;
548
- setTargets(...targets: HTMLElement[]): this;
549
- group(...animations: Animation_2<V>[]): AnimationGroup<V>;
646
+ readonly code?: AnimationOptionErrorCode;
647
+ constructor(option: string, value: unknown, reason: string, code?: AnimationOptionErrorCode);
550
648
  }
551
- export { Animation_2 as Animation }
552
649
 
553
650
  /**
554
- * The value.js-bearing engine surface, resolved through `loadAnimationEngine()`.
651
+ * Typed option-validation errors — the fail-explicit seam.
555
652
  *
556
- * Spelled as an explicit interface (rather than `typeof import("./engine")`)
557
- * because the dts roll-up — API Extractor — cannot resolve a `typeof import()`
558
- * type node that points at an internal module. The shape stays in lockstep
559
- * with `./engine`'s runtime exports.
653
+ * The engine's option setters and the light engines' easing inputs THROW on
654
+ * malformed input rather than silently defaulting or no-oping — the posture
655
+ * the layer API already chose ("silent no-ops were hiding consumer bugs",
656
+ * `group.ts` setLayerConfig). Defaulting happens only for genuine
657
+ * `undefined`: an omitted option means "use the default"; a
658
+ * present-but-malformed option is a consumer bug and surfaces as one of
659
+ * these.
660
+ *
661
+ * Value.js-free: light modules import these without touching the boundary.
560
662
  */
561
- export declare interface AnimationEngine {
562
- Animation: typeof Animation_2;
563
- CSSKeyframesAnimation: typeof CSSKeyframesAnimation;
564
- AnimationGroup: typeof AnimationGroup;
565
- getAnimationId: (animation: Animation_2 | string) => string;
566
- getTimingFunction: (timingFunction: TimingFunction | TimingFunctionNames | string | undefined) => TimingFunction | undefined;
567
- resolveKeyframes: (input: string | Stylesheet) => ResolvedKeyframes;
568
- /** The single-call front door — dispatch + auto-target + auto-play. */
569
- animate: typeof animate;
570
- /** CSS-native MotionPath (F.W12) — offset-distance over an author offset-path. */
571
- MotionPath: typeof MotionPath;
572
- fromMotionPath: typeof fromMotionPath;
573
- /** CSS-native DrawSVG (G.W13) — stroke-dashoffset sweep over the path length. */
574
- DrawSVG: typeof DrawSVG;
575
- fromDrawSVG: typeof fromDrawSVG;
663
+ /**
664
+ * The stable, machine-branchable reasons a typed option error can carry
665
+ * (J.W1 S8, K3-internal). EXACTLY the two engine-internal rows the
666
+ * ingestion lane folds into J.W1 — a structured `code` ON the typed throw,
667
+ * NOT a diagnostics channel (the full `Diagnostic[]` surface stays a K.W0
668
+ * seed item):
669
+ *
670
+ * - `EMPTY_PARSE` — a blank/whitespace-only keyframe selector reached the
671
+ * compile seam (the H-A2 "......" class, named).
672
+ * - `UNKNOWN_TIMING_FN` — a present-but-unresolvable timing function (not a
673
+ * callable, a registry name, or a cubic-bezier()/steps() literal).
674
+ * - `NAMED_SELECTOR_NO_TIMELINE` — a scroll-range named selector
675
+ * (`entry`/`exit`/`cover`/`contain`) was accepted at ingest (L.W1 S4), but a
676
+ * numeric `%` position was genuinely demanded with NO `ScrollTimeline`/
677
+ * `ManualTimeline` present to map the phase. A named selector is only
678
+ * meaningful in a scroll context; resolving it to a number outside one is a
679
+ * consumer bug, so the deferred resolve refuses with this code rather than
680
+ * inventing a position. (The bare-ingest floor — accept + preserve, no
681
+ * resolution demanded — never throws.)
682
+ */
683
+ declare type AnimationOptionErrorCode = "EMPTY_PARSE" | "UNKNOWN_TIMING_FN" | "NAMED_SELECTOR_NO_TIMELINE";
684
+
685
+ export declare type AnimationOptions = {
686
+ duration: number;
687
+ delay: number;
688
+ iterationCount: number;
689
+ direction: (typeof DIRECTIONS)[number];
690
+ fillMode: (typeof FILL_MODES)[number];
691
+ timingFunction: Easing;
692
+ useWAAPI: boolean;
576
693
  /**
577
- * The preset library (`fadeIn`, `bounce`, `shake`, …) — heavy (each returns
578
- * a `CSSKeyframesAnimation`), so it rides the dynamic boundary as a namespace
579
- * instead of the light static barrel: `const { presets } = await
580
- * loadAnimationEngine(); presets.fadeIn({ duration: 500 })` (F.W11).
694
+ * When true, honor `prefers-reduced-motion: reduce` by snapping the
695
+ * `Animation`/`AnimationGroup` `play()` path to the final frame in a
696
+ * single paint instead of running the rAF/WAAPI loop. SSR-safe no-op
697
+ * off-DOM. Default false (consumers opt in).
581
698
  */
582
- presets: typeof AnimationPresets;
583
- DIRECTIONS: readonly AnimationOptions["direction"][];
584
- FILL_MODES: readonly AnimationOptions["fillMode"][];
585
- defaultOptions: AnimationOptions;
586
- defaultLayerConfig: AnimationLayerConfig;
699
+ respectReducedMotion: boolean;
700
+ colorSpace: ColorSpace;
701
+ hueMethod?: HueInterpolationMethod;
587
702
  /**
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;
703
+ * The LAYER-level `animation-composition` operator (L.W1 S5, Band A) — the
704
+ * round-trip field for an authored `animation-composition: add` that arrived
705
+ * through a sibling `.class { animation: … }` shorthand/longhand ingest.
706
+ * Distinct from the per-KEYFRAME {@link TemplateAnimationFrame.composition}
707
+ * (the per-stop operator); this is the whole-animation composite the engine
708
+ * carries off `extractAnimationOptions`'s `composition` field. Omission means
709
+ * `replace` (the CSS default — the serializer omits it). value.js 0.13.0's
710
+ * `CSSAnimationOptions.composition` surfaces it; `fromString` reads it here.
711
+ */
712
+ composite?: CompositeOperator;
713
+ /**
714
+ * `animation-iteration-composite` (CSS Animations L2). BOOKED, not
715
+ * implemented: the L2 draft marks this property experimental — there is no
716
+ * stable value.js parse for it and no honoring path in the engine. The field
717
+ * is a typed `never` placeholder (a named tripwire): a future
718
+ * silently-WRONG implementation that tries to assign anything to it reddens
719
+ * the type check, forcing the implementation to land alongside a real
720
+ * `proof:iteration-composite-baseline` gate rather than sliding in unproven.
721
+ */
722
+ iterationComposite?: never;
723
+ };
724
+
725
+ declare namespace AnimationPresets {
726
+ export {
727
+ fadeIn,
728
+ fadeOut,
729
+ pulse,
730
+ shake,
731
+ bounce,
732
+ flipPreset,
733
+ rotateIn,
734
+ slideIn,
735
+ heartbeat,
736
+ glow,
737
+ typewriter,
738
+ rainbowText,
739
+ warpLeft,
740
+ warpRight,
741
+ blurIn,
742
+ blurOut,
743
+ blurInOut,
744
+ progressBar,
745
+ skeletonLoading,
746
+ textFocusBlur,
747
+ gradientBackground,
748
+ rotateScale,
749
+ typingCursor,
750
+ accordionExpand,
751
+ notificationBounce,
752
+ spinner,
753
+ parallaxScroll,
754
+ slideInLeftKeyframes,
755
+ slideInLeft,
756
+ slideOutLeft,
757
+ slideInRightKeyframes,
758
+ slideInRight,
759
+ slideOutRight,
760
+ hover,
761
+ jumpUp,
762
+ jumpDown,
763
+ springScaleIn,
764
+ springSlideIn,
765
+ springPop,
766
+ springWobble,
767
+ enterPresets,
768
+ exitPresets,
769
+ attentionPresets,
770
+ loopPresets,
771
+ presetTaxonomy
772
+ }
773
+ }
774
+
775
+ export { AnimationRangeValue }
776
+
777
+ export { AnimationTimelineValue }
778
+
779
+ /** Attention animations — a one-shot nudge to draw the eye. */
780
+ declare const attentionPresets: {
781
+ readonly pulse: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
782
+ readonly shake: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
783
+ readonly bounce: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
784
+ readonly flip: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
785
+ readonly notificationBounce: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
786
+ readonly springPop: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
787
+ readonly springWobble: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
788
+ };
789
+
790
+ export declare type BlendMode = "replace" | "add" | "weighted";
791
+
792
+ declare const blurIn: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
793
+
794
+ declare const blurInOut: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
795
+
796
+ declare const blurOut: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
797
+
798
+ declare const bounce: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
799
+
800
+ /** The compile result — the artifact + the CC-3 ineligibility report. */
801
+ export declare interface CompiledCSS {
601
802
  /**
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.
803
+ * The zero-runtime CSS artifact — `@keyframes` blocks + `.class { animation }`
804
+ * rules. Empty string when EVERY child refused (then `refusals` carries the
805
+ * whole story).
609
806
  */
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;
807
+ css: string;
620
808
  /**
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.
809
+ * True iff EVERY walked child compiled faithfully. False when one or more
810
+ * refused — `refusals` names each, and the JS playback is the only faithful
811
+ * path for those.
631
812
  */
632
- compileToCSS: typeof compileToCSS;
813
+ eligible: boolean;
814
+ /** The CC-3 refusals — one per child that could not compile faithfully. */
815
+ refusals: CompileRefusal[];
633
816
  }
634
817
 
635
- export declare interface AnimationFrame<V extends Vars> {
636
- id: number;
637
- start: ValueUnit;
638
- ixs: {
639
- start: number;
640
- stop: number;
641
- };
642
- time: {
643
- start: number;
644
- stop: number;
645
- };
646
- flatVars: V;
647
- vars: V;
648
- interpVars: {
649
- [arg: string]: Array<InterpolatedVar<V>>;
650
- };
818
+ /** The input shapes `compileToCSS` accepts. */
819
+ export declare type CompileInput<V extends Vars = any> = AnimationGroup<V> | Sequence<V> | ReadonlyArray<KeyframesAnimation<V> | {
820
+ animation: KeyframesAnimation<V>;
821
+ }>;
822
+
823
+ /** Options for {@link compileToCSS}. */
824
+ export declare interface CompileOptions {
651
825
  /**
652
- * Pre-flattened array of all interpolation variables across all properties.
653
- * Built once during parse() to avoid Object.values().flat() allocation
654
- * on every interpFrames() call in the hot path.
826
+ * Per-child stagger delays (ms), index-aligned with the walked children —
827
+ * the materialized output of `stagger.delays(total)`. CC-1 emits these as
828
+ * literal per-child `animation-delay`, expressing an eased origin-aware
829
+ * curve `sibling-index()` cannot (the universal literal-delay form;
830
+ * `@supports (sibling-index)` is CC-6 BOOK, not the default).
655
831
  */
656
- allInterpVars: Array<InterpolatedVar<V>>;
657
- transform: TransformFunction<V>;
658
- timingFunction: Easing;
832
+ staggerDelays?: readonly number[];
659
833
  /**
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;
672
- }
673
-
674
- export declare class AnimationGroup<V extends Vars> {
675
- animations: AnimationGroupObject<V>;
676
- /**
677
- * The group's composite transform. Defaults to a real no-op at the FIELD
678
- * (I.W0 S3) — NOT a lying definite-assignment assertion. A childless or
679
- * pre-`parse()` group (e.g. the empty HOME backdrop) composites nothing,
680
- * so `transformFramesGrouped` calls a harmless no-op instead of throwing
681
- * `this.transform is not a function` (B1/E1). The constructor overrides
682
- * this with the first child's transform when one exists.
683
- */
684
- transform: TransformFunction<V>;
685
- superKey: string | undefined;
686
- paused: boolean;
687
- started: boolean;
688
- done: boolean;
689
- /**
690
- * When true, `play()` honors `prefers-reduced-motion: reduce` by snapping
691
- * every child to its final frame in a single composite instead of running
692
- * the rAF draw loop. SSR-safe no-op off-DOM. Default false.
693
- */
694
- respectReducedMotion: boolean;
695
- /**
696
- * Children-per-slice before `advanceTo()` yields to the main thread. Groups at
697
- * or under this size tick in one slice (fast path); larger groups tick in
698
- * batches with a `scheduler.yield()` between them so a big per-frame
699
- * composite doesn't run as one long task (INP relief).
700
- */
701
- static readonly YIELD_BATCH = 32;
702
- singleTarget: boolean;
703
- lastTickTime: number;
704
- /** THE rAF owner for the group's draw loop. */
705
- readonly playback: RAFPlayback;
706
- resolvePromise: ((value: void | PromiseLike<void>) => void) | null;
707
- private _playingPromise;
708
- /**
709
- * Pre-bound frame callback — allocated once in constructor to avoid
710
- * creating a new closure on every playback loop start.
711
- */
712
- private _boundFrame;
713
- /**
714
- * Cached entries array, sorted by layer zIndex. Rebuilt on demand
715
- * via dirty flag to avoid Object.values() allocation on every frame.
716
- */
717
- private _entries;
718
- private _entriesDirty;
719
- /**
720
- * Long-lived composite buffer, cleared in place at the top of
721
- * `transformFramesGrouped` (the same zero-alloc idiom `interpFrames`'s
722
- * `out` buffer already uses). With it the compositor honours the class's
723
- * own zero-alloc discipline — no fresh `groupedValues` object, and no
724
- * per-layer `filteredValues` object, allocated per frame.
725
- */
726
- private _grouped;
727
- /**
728
- * The compile-stable union of every child's contributed (whitelist-filtered)
729
- * keys — what `_grouped` is null-filled to each frame so the composite is
730
- * cleared WITHOUT `delete` (F.W4 S2: the delete-loop trapped `_grouped` in
731
- * V8 dictionary mode). Recomputed only when the entry set / a layer
732
- * whitelist changes (via `invalidateEntries`); stable across frames.
733
- */
734
- private _groupedKeys;
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;
745
- constructor(...inputs: (Animation_2<V> | AnimationGroupInput<V>)[]);
746
- /**
747
- * Returns the animation entries sorted by layer zIndex.
748
- * Uses dirty-flag caching — only rebuilds when the animations object
749
- * or layer configs are mutated. All hot-path iteration (tick, draw,
750
- * transformFramesGrouped) uses this instead of Object.values().
751
- */
752
- private getEntries;
753
- /** Mark entries cache stale. Called at all mutation boundaries. */
754
- private invalidateEntries;
755
- /**
756
- * Recompute `_groupedKeys` — the union of each child's contributed keys
757
- * (whitelist-filtered when the layer carries one). The maximal key-set the
758
- * `transformFramesGrouped` null-fill clears, so the composite buffer stays
759
- * in V8 fast-properties mode without `delete` (F.W4 S2). Children are parsed
760
- * (their `flatKeys` populated) before the first composite — the group only
761
- * blends during play, after child setup — and any later structural change
762
- * re-dirties through `invalidateEntries`.
763
- */
764
- private computeGroupedKeys;
765
- setSuperKey(superKey: string): this;
766
- setTargets(...targets: HTMLElement[]): this;
767
- onStart(): this;
768
- onEnd(): this;
769
- /**
770
- * Composite all animation values into a single grouped transform.
771
- * Called per-frame for single-target groups. Applies layer blending
772
- * (replace / add / weighted) in zIndex order, then calls the group
773
- * transform function with the merged values.
774
- *
775
- * Refreshes every child's values at its current `t` in place —
776
- * `interpFrames(t, false, entry.values)` clears and rewrites the
777
- * long-lived buffer, so no stale keys leak across frames and no
778
- * fresh object is allocated per entry per frame.
779
- */
780
- transformFramesGrouped(t: number): Record<string, unknown>;
781
- /**
782
- * Render the current composition as a static frame using each
783
- * child's current `t`. Single-target groups go through the
784
- * blended transform; multi-target groups apply each child's
785
- * interpolated vars directly to its own targets.
786
- *
787
- * This is the public entry point for scenarios that mutate a
788
- * child's state outside the rAF loop (scrubbing, state restore,
789
- * pause snapshots) and need the visual to update immediately.
790
- */
791
- render(): void;
792
- /**
793
- * Set a child animation's current time without touching its
794
- * siblings. Updates `pausedTime` so the child resumes correctly
795
- * from the scrub position. Chainable. Call `render()` afterwards
796
- * to reflect the change visually.
797
- */
798
- setChildTime(nameOrAnim: string | Animation_2<V>, t: number): this;
799
- /**
800
- * Advance all child animations to absolute clock `t`. SYNC on the steady
801
- * path (J.W6 S1): children that all step synchronously advance the group
802
- * with no per-frame `Promise.all`/microtask hop; a thenable only on a
803
- * genuinely-async child or the over-`YIELD_BATCH` yield path.
804
- */
805
- advanceTo(t: number): this | Promise<this>;
806
- /** Batched advance — yield to the main thread between batches. */
807
- private _advanceBatched;
808
- /** The post-advance tail — `onEnd` once the render marked done. */
809
- private _endAdvance;
810
- /** Advance one slice — `undefined` iff every child stepped sync. */
811
- private _advanceSlice;
812
- /**
813
- * One frame of the group's draw loop, driven by the shared
814
- * `RAFPlayback.loop`. Ticks all children, then renders
815
- * (single-target: grouped blending; multi-target: per-child).
816
- * Returns whether the loop should continue.
817
- */
818
- private _frame;
819
- /** The post-advance render half of `_frame` — composite, or settle. */
820
- private _renderFrame;
821
- private _resolvePlay;
822
- /**
823
- * Start the animation group. Returns a promise that resolves
824
- * when all child animations complete (or on explicit stop/reset).
825
- * Re-entrant: a `play()` while one is in flight returns the same
826
- * promise rather than leaking a second draw loop.
827
- *
828
- * Under `respectReducedMotion` + an active `prefers-reduced-motion`
829
- * query, snaps every child to its final frame in a single composite —
830
- * no rAF draw loop — then settles exactly as a completed play would.
831
- */
832
- /**
833
- * The completion front-door (G.W13) — `await group.finished` resolves once
834
- * the in-flight composite play settles. Exposes the ONE held
835
- * `_playingPromise` `play()` constructs (the re-entrant guard returns it;
836
- * the `finally`-clear nulls it on settle) — NOT a second completion
837
- * lifecycle. A settled (or never-played) group resolves immediately.
838
- */
839
- get finished(): Promise<void>;
840
- play(): Promise<void>;
841
- /**
842
- * `prefers-reduced-motion` snap for the group: rest = final, paint it,
843
- * settle — the SAME terminal path a completed play takes, with the
844
- * motion elided. Every child advances to its final frame, one composite
845
- * paints, and `settle()` (pure teardown, never a repaint) readies the
846
- * group for replay. The final frame stays on the target(s), matching
847
- * `Animation._playReducedMotion`.
848
- */
849
- private _playReducedMotion;
850
- /**
851
- * Pause the group — idempotent. Pausing an already-paused (or
852
- * not-yet-started) group is a no-op, NOT a resume. Mirrors
853
- * `Animation.pause`: a method named `pause` pauses, never secretly
854
- * resumes. Use {@link toggle} for the explicit flip, {@link resume}
855
- * for the explicit resume.
856
- *
857
- * Cancels the rAF loop immediately (don't wait for the frame callback to
858
- * self-terminate) and renders a final-frame snapshot so the visual
859
- * matches the exact pause moment.
860
- */
861
- pause(): this;
862
- /**
863
- * Resume the group — idempotent. Resuming a running (or not-yet-started)
864
- * group is a no-op. Unpauses every child DIRECTLY (not via
865
- * `child.resume()`, which would start each child's own rAF loop) — the
866
- * group's draw loop owns the ticking — and re-registers that loop.
867
- */
868
- resume(): this;
869
- /** The explicit flip: pauses if playing, resumes if paused. */
870
- toggle(): this;
871
- /**
872
- * Pure state teardown — never paints. The group analogue of
873
- * `Animation.settle()`: releases every child (`managed = false`,
874
- * `child.settle()`) and clears the group's own playback flags.
875
- * Completion and the reduced-motion snap both end here, leaving the
876
- * rest frame (per each child's fill contract) on the target(s).
877
- */
878
- settle(): this;
879
- /**
880
- * Explicit rewind: paint every started child back to its INITIAL
881
- * frame, then settle. This is the user-facing "return to start" —
882
- * rest position `initial` painted deliberately, not a completion side
883
- * effect. (Completion does NOT come here; it settles where the fill
884
- * contract rested the pixels.)
885
- */
886
- reset(): this;
887
- /**
888
- * Halt the draw loop, rewind to the initial frame (the transport-stop
889
- * semantic the demo's controls expect), and resolve any pending
890
- * `play()` promise.
891
- */
892
- stop(): this;
893
- playing(): boolean;
894
- forcePause(): void;
895
- forcePlay(): void;
896
- /**
897
- * Set layer config for an animation by name or reference.
898
- * Chainable. Throws when the key doesn't match a registered
899
- * animation — silent no-ops were hiding consumer bugs.
900
- */
901
- setLayerConfig(nameOrAnim: string | Animation_2<V>, config: Partial<AnimationLayerConfig>): this;
902
- /** Convenience toggle for enabling/disabling a layer. Chainable. */
903
- setLayerEnabled(nameOrAnim: string | Animation_2<V>, enabled: boolean): this;
904
- /** Read the layer config for an animation. */
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.
834
+ * CC-2 — the oklab densify stop count (the N intermediate `oklab()` stops
835
+ * baked per color segment, INCLUSIVE of endpoints). Default
836
+ * {@link DEFAULT_DENSIFY_STOPS}. Raise it for a longer color arc; the ΔE
837
+ * proof decides ship-vs-refuse.
943
838
  */
944
- crossfade(a: string | Animation_2<V>, b: string | Animation_2<V>, options?: {
945
- spring?: LayerTransitionSpring;
946
- }): this;
839
+ densifyStops?: number;
947
840
  /**
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.
841
+ * CC-2 — the ΔE-ε ship-vs-refuse threshold (the perceptual-distance band the
842
+ * densified `oklab()` stops must hold against kf's JS lerp). Default
843
+ * {@link DEFAULT_DELTA_E_EPSILON}. A track whose densify exceeds this REFUSES
844
+ * with the perceptual-oklab reason (a drifting densify is worse than an
845
+ * honest refusal).
956
846
  */
957
- private advanceLayerSprings;
958
- }
959
-
960
- export declare interface AnimationGroupEntry<V extends Vars> {
961
- animation: Animation_2<V>;
962
- values: Record<string, unknown>;
963
- layer: AnimationLayerConfig;
847
+ deltaEEpsilon?: number;
848
+ /** Prettier print-width for the emitted artifact. Omit for the default. */
849
+ printWidth?: number;
964
850
  }
965
851
 
966
- /** Input type for AnimationGroup constructor — bare Animation or Animation with layer config. */
967
- declare type AnimationGroupInput<V extends Vars> = Animation_2<V> | {
968
- animation: Animation_2<V>;
969
- layer?: Partial<AnimationLayerConfig>;
970
- };
971
-
972
- declare interface AnimationGroupObject<V extends Vars> {
973
- [key: string]: AnimationGroupEntry<V>;
852
+ /** A single refusal — the child name + a typed reason + a human message. */
853
+ export declare interface CompileRefusal {
854
+ /** The compiled child's class/animation name. */
855
+ name: string;
856
+ reason: CompileRefusalReason;
857
+ /** The verbatim message the demo's ineligibility UI shows (CC-4). */
858
+ message: string;
974
859
  }
975
860
 
976
- export declare interface AnimationLayerConfig {
977
- /** Higher wins. Default: 0 */
978
- zIndex: number;
979
- /** 0–1 for 'weighted' blend mode. Default: 1 */
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;
994
- /**
995
- * Default: 'replace'. Defaulting on a genuinely-omitted blend mode is
996
- * the sanctioned contract (the fail-explicit seam throws only on
997
- * malformed PRESENT input, never on omission) — an unspecified layer
998
- * blends by replacement, the least-surprising composite.
999
- */
1000
- blendMode: BlendMode;
1001
- /** Layer toggle. Default: true */
1002
- enabled: boolean;
1003
- /** Optional property whitelist — only these properties will be output from this layer */
1004
- properties?: Set<string>;
1005
- }
861
+ /**
862
+ * The reason a child could not compile faithfully. Generalizes
863
+ * `waapiIneligibleReason` to the CSS-compile domain — the trust surface. Each
864
+ * names the kf axis that exceeds pure CSS (the refusal is marketing for the
865
+ * moat). A refused child's JS playback is the only faithful path.
866
+ */
867
+ export declare type CompileRefusalReason = "weighted-blend" | "custom-renderer" | "perceptual-oklab" | "computed-unit-drift";
1006
868
 
1007
- /** Thrown when an animation option receives malformed (non-undefined) input. */
1008
- export declare class AnimationOptionError extends Error {
1009
- readonly option: string;
1010
- readonly value: unknown;
1011
- /**
1012
- * Stable structured reason for programmatic consumers — branch on this,
1013
- * never on the human message. Carried only by the two named rows
1014
- * ({@link AnimationOptionErrorCode}); undefined otherwise.
1015
- */
1016
- readonly code?: AnimationOptionErrorCode;
1017
- constructor(option: string, value: unknown, reason: string, code?: AnimationOptionErrorCode);
869
+ /**
870
+ * The COMPILER surface (L.W7 S3 `loadCompiler()`) — the engine core PLUS the
871
+ * round-trip's BACKWARD half, `compileToCSS`. A consumer compiling an
872
+ * orchestration graph to zero-runtime CSS pays for `engine` + `compile`, not
873
+ * the ingest / motion / draw / preset weight.
874
+ */
875
+ export declare interface CompilerSurface extends EngineCore {
876
+ compileToCSS: typeof compileToCSS;
1018
877
  }
1019
878
 
1020
879
  /**
1021
- * Typed option-validation errors — the fail-explicit seam.
1022
- *
1023
- * The engine's option setters and the light engines' easing inputs THROW on
1024
- * malformed input rather than silently defaulting or no-oping — the posture
1025
- * the layer API already chose ("silent no-ops were hiding consumer bugs",
1026
- * `group.ts` setLayerConfig). Defaulting happens only for genuine
1027
- * `undefined`: an omitted option means "use the default"; a
1028
- * present-but-malformed option is a consumer bug and surfaces as one of
1029
- * these.
880
+ * THE compiler (CC-1/CC-2/CC-3) — compile an orchestration graph to zero-runtime
881
+ * CSS. Walks the input (`AnimationGroup` / `Sequence` / child list), emits one
882
+ * `@keyframes` + one `animation` shorthand per child (the `replace`/`add`
883
+ * layering as `animation-composition`, springs as `linear()`, stagger delays
884
+ * materialized, computed units verbatim, color tracks densified into perceptual
885
+ * `oklab()` stops under the ΔE-ε proof), and REFUSES with a NAMED reason what
886
+ * cannot compile faithfully (CC-3 — the replay-equality invariant's honest
887
+ * refusal). The result is async because `formatCSS` (Prettier) is.
1030
888
  *
1031
- * Value.js-free: light modules import these without touching the boundary.
889
+ * @returns `{ css, eligible, refusals }` — the artifact + the trust surface.
1032
890
  */
1033
- /**
1034
- * The stable, machine-branchable reasons a typed option error can carry
1035
- * (J.W1 S8, K3-internal). EXACTLY the two engine-internal rows the
1036
- * ingestion lane folds into J.W1 — a structured `code` ON the typed throw,
1037
- * NOT a diagnostics channel (the full `Diagnostic[]` surface stays a K.W0
1038
- * seed item):
1039
- *
1040
- * - `EMPTY_PARSE` — a blank/whitespace-only keyframe selector reached the
1041
- * compile seam (the H-A2 "......" class, named).
1042
- * - `UNKNOWN_TIMING_FN` — a present-but-unresolvable timing function (not a
1043
- * callable, a registry name, or a cubic-bezier()/steps() literal).
1044
- */
1045
- declare type AnimationOptionErrorCode = "EMPTY_PARSE" | "UNKNOWN_TIMING_FN";
1046
-
1047
- export declare type AnimationOptions = {
1048
- duration: number;
1049
- delay: number;
1050
- iterationCount: number;
1051
- direction: (typeof DIRECTIONS)[number];
1052
- fillMode: (typeof FILL_MODES)[number];
1053
- timingFunction: Easing;
1054
- useWAAPI: boolean;
1055
- /**
1056
- * When true, honor `prefers-reduced-motion: reduce` by snapping the
1057
- * `Animation`/`AnimationGroup` `play()` path to the final frame in a
1058
- * single paint instead of running the rAF/WAAPI loop. SSR-safe no-op
1059
- * off-DOM. Default false (consumers opt in).
1060
- */
1061
- respectReducedMotion: boolean;
1062
- colorSpace: ColorSpace;
1063
- hueMethod?: HueInterpolationMethod;
1064
- };
1065
-
1066
- declare namespace AnimationPresets {
1067
- export {
1068
- fadeIn,
1069
- fadeOut,
1070
- pulse,
1071
- shake,
1072
- bounce,
1073
- flip_2 as flip,
1074
- rotateIn,
1075
- slideIn,
1076
- heartbeat,
1077
- glow,
1078
- typewriter,
1079
- rainbowText,
1080
- warpLeft,
1081
- warpRight,
1082
- blurIn,
1083
- blurOut,
1084
- blurInOut,
1085
- progressBar,
1086
- skeletonLoading,
1087
- textFocusBlur,
1088
- gradientBackground,
1089
- rotateScale,
1090
- typingCursor,
1091
- accordionExpand,
1092
- notificationBounce,
1093
- spinner,
1094
- parallaxScroll,
1095
- slideInLeftKeyframes,
1096
- slideInLeft,
1097
- slideOutLeft,
1098
- slideInRightKeyframes,
1099
- slideInRight,
1100
- slideOutRight,
1101
- hover,
1102
- jumpUp,
1103
- jumpDown,
1104
- springScaleIn,
1105
- springSlideIn,
1106
- springPop,
1107
- springWobble,
1108
- enterPresets,
1109
- exitPresets,
1110
- attentionPresets,
1111
- loopPresets,
1112
- presetTaxonomy
1113
- }
1114
- }
1115
-
1116
- export { AnimationRangeValue }
1117
-
1118
- export { AnimationTimelineValue }
1119
-
1120
- /** Attention animations — a one-shot nudge to draw the eye. */
1121
- declare const attentionPresets: {
1122
- readonly pulse: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
1123
- readonly shake: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
1124
- readonly bounce: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
1125
- readonly flip: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
1126
- readonly notificationBounce: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
1127
- readonly springPop: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
1128
- readonly springWobble: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
1129
- };
1130
-
1131
- export declare type BlendMode = "replace" | "add" | "weighted";
1132
-
1133
- declare const blurIn: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
1134
-
1135
- declare const blurInOut: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
1136
-
1137
- declare const blurOut: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
1138
-
1139
- declare const bounce: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
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
-
891
+ declare function compileToCSS<V extends Vars>(input: CompileInput<V>, opts?: CompileOptions): Promise<CompiledCSS>;
892
+
1224
893
  /**
1225
894
  * The CSS `animation-composition` operator (K.W7). Distinct from
1226
895
  * {@link BlendMode} (the GROUP's per-LAYER blend tier — `replace`/`add`/
@@ -1267,7 +936,7 @@ export declare function createNativeTimeline(spec: NativeTimelineSpec): Animatio
1267
936
  */
1268
937
  declare function createScrollScene(spec?: ScrollSceneOptions | CSSTimelineOptions): ScrollScene;
1269
938
 
1270
- export declare class CSSKeyframesAnimation<V extends Vars> extends Animation_2<V> {
939
+ export declare class CSSKeyframesAnimation<V extends Vars> extends KeyframesAnimation<V> {
1271
940
  constructor(options?: Partial<InputAnimationOptions>, ...targets: HTMLElement[]);
1272
941
  /**
1273
942
  * One transform-resolution seam for the three `from*` entry points:
@@ -1287,23 +956,35 @@ export declare class CSSKeyframesAnimation<V extends Vars> extends Animation_2<V
1287
956
  * flag) without re-parsing the source CSS.
1288
957
  */
1289
958
  propertyRegistry: Map<string, PropertyDescriptor_2>;
1290
- fromString(keyframes: string, transform?: TransformFunction<V>): this;
1291
959
  /**
1292
- * Register every parsed `@property` descriptor with the UA via
1293
- * `CSS.registerProperty` (D-LIB-1) — one guarded pass at the end of
1294
- * `fromString`. Feature-detected (`CSS.registerProperty` may be absent:
1295
- * SSR, jsdom, older engines) so it no-ops to today's behaviour where
1296
- * unsupported. A duplicate-name re-registration throws a benign
1297
- * `InvalidModificationError` (the global registry is process-wide and
1298
- * idempotent for a given name) — swallowed per-descriptor so one already-
1299
- * registered name never aborts the rest of the pass.
1300
- *
1301
- * Baseline 2024-07-09 (newly available — feature-detect mandatory).
960
+ * Parsed scroll-grammar (`animation-timeline` / `animation-range` /
961
+ * `timeline-scope` / `animation-trigger`) recovered from a sibling style rule
962
+ * by `fromString` (L.W2 S1 — CC-6) via `recoverScrollOptions` (the
963
+ * CSS-metadata-recovery seam); `undefined` when the input carried no scroll
964
+ * grammar (the canonical time-clock animation). A read-only metadata field —
965
+ * no hot-path impact, analogous to {@link propertyRegistry}. The compiler
966
+ * (`compileToCSS`) reads it to EMIT the scroll longhands back out, closing the
967
+ * round-trip's EMIT half.
1302
968
  */
1303
- private registerProperties;
969
+ scrollOptions?: CSSTimelineOptions;
970
+ fromString(keyframes: string, transform?: TransformFunction<V>): this;
1304
971
  transform(vars: V): void;
1305
972
  }
1306
973
 
974
+ declare function CSSKeyframesToString<V extends Vars>(animation: KeyframesAnimation<V>, name?: string, printWidth?: number | undefined): Promise<string>;
975
+
976
+ /**
977
+ * Per-stop card serializer for the editor pane — ONE formatted keyframe
978
+ * string per DECLARED template stop, index-aligned with
979
+ * `animation.templateFrames` (the pairing the card list renders by).
980
+ * Unified onto the declared-template authority (J.W1 S1): each card is
981
+ * {@link declaredKeyframeBody} — the AUTHORED values. The former path mapped
982
+ * `animation.frames` (the interp PAIRS — N−1 segments for N stops, so the
983
+ * last card simply did not exist) and read `frame.flatVars` (DOM-resolved,
984
+ * interp-mutated) — both defects die with the unification.
985
+ */
986
+ declare const CSSKeyframesToStrings: <V extends Vars>(animation: KeyframesAnimation<V>) => Promise<string[]>;
987
+
1307
988
  export { CSSTimelineOptions }
1308
989
 
1309
990
  /**
@@ -1406,7 +1087,7 @@ declare interface Diagnostic extends Partial<ParseDiagnostic> {
1406
1087
  * WAAPI-reason rows are AUTHORED here but POPULATED by K.W8 (which owns the
1407
1088
  * CSSOM walk that produces them).
1408
1089
  */
1409
- declare type DiagnosticCode = "EMPTY_PARSE" | "UNKNOWN_TIMING_FN" | "COMPOSITION_FALLBACK" | "PARSE_ERROR" | "CORS_SKIP" | "WAAPI_INELIGIBLE";
1090
+ declare type DiagnosticCode = "EMPTY_PARSE" | "UNKNOWN_TIMING_FN" | "COMPOSITION_FALLBACK" | "PARSE_ERROR" | "CORS_SKIP" | "WAAPI_INELIGIBLE" | "ADOPT_REFUSE";
1410
1091
 
1411
1092
  declare const DIRECTIONS: readonly ["normal", "reverse", "alternate", "alternate-reverse"];
1412
1093
 
@@ -1436,6 +1117,69 @@ declare function dispatchScrollBackend<V extends Vars>(request: ScrollDispatchRe
1436
1117
  */
1437
1118
  export declare function drag(element: HTMLElement, options?: DragOptions): Draggable;
1438
1119
 
1120
+ /**
1121
+ * Construct a 2-D drag — two one-axis {@link Draggable}s (one per axis), a
1122
+ * shared subscriber that emits `(x, y, vx, vy)` whenever either axis updates,
1123
+ * and a unified `dispose()`. KISS: the 1-D engine stays 1-D; this is additive
1124
+ * sugar that wires the composition the caller would otherwise hand-roll.
1125
+ *
1126
+ * `options.x` / `options.y` are independent {@link DragOptions} — `bounds`,
1127
+ * `rubberBand`, and `snap` pass through PER AXIS (e.g. bound `x` to the
1128
+ * viewport width and `y` to its height separately). The `axis` field of each
1129
+ * is FORCED (`x` → `"x"`, `y` → `"y"`); any author `axis` is ignored.
1130
+ */
1131
+ export declare function drag2D(element: HTMLElement, options?: {
1132
+ x?: DragOptions;
1133
+ y?: DragOptions;
1134
+ }): Drag2DHandle;
1135
+
1136
+ /**
1137
+ * The 2-D drag sugar — two one-axis {@link Draggable}s composed behind a
1138
+ * single `(x, y, vx, vy)` surface. Split out of `drag.ts` (the 1-D engine)
1139
+ * as additive sugar: the engine stays one-dimensional (KISS); this module is
1140
+ * the front door that spares every 2-D consumer the two-`Draggable`
1141
+ * boilerplate. LIGHT — it imports only `Draggable` + `DragOptions` from
1142
+ * `./drag`, so it carries zero static `@mkbabb/value.js` edge.
1143
+ *
1144
+ * Re-exported THROUGH `drag.ts` so the barrel `export { drag, Draggable,
1145
+ * drag2D } from "./drag"` keeps resolving unchanged.
1146
+ */
1147
+ /**
1148
+ * The composite handle a {@link drag2D} returns — two one-axis `Draggable`s
1149
+ * wired behind a single `(x, y, vx, vy)` subscriber and a unified dispose.
1150
+ * Sugar only: the 1-D engine stays 1-D (KISS); this is the front door that
1151
+ * spares every 2-D consumer the two-Draggable boilerplate.
1152
+ */
1153
+ export declare interface Drag2DHandle {
1154
+ /** The x-axis `Draggable` (tracks `clientX`). */
1155
+ readonly x: Draggable;
1156
+ /** The y-axis `Draggable` (tracks `clientY`). */
1157
+ readonly y: Draggable;
1158
+ /**
1159
+ * Current `(x, y)` position. While an axis is dragging this is the live
1160
+ * pointer-pinned target; otherwise the spring's settled / in-flight value.
1161
+ */
1162
+ readonly value: {
1163
+ x: number;
1164
+ y: number;
1165
+ };
1166
+ /** Current `(vx, vy)` velocity (units/s). */
1167
+ readonly velocity: {
1168
+ x: number;
1169
+ y: number;
1170
+ };
1171
+ /** True when BOTH axes have settled. */
1172
+ readonly settled: boolean;
1173
+ /**
1174
+ * Subscribe to `(x, y, vx, vy)` emissions — fires whenever EITHER axis
1175
+ * updates (live drag follow + post-release fling). Returns an unsubscribe
1176
+ * handle.
1177
+ */
1178
+ subscribe(fn: (x: number, y: number, vx: number, vy: number) => void): () => void;
1179
+ /** Remove all listeners and dispose both `Draggable`s. */
1180
+ dispose(): void;
1181
+ }
1182
+
1439
1183
  /**
1440
1184
  * The single scalar axis a {@link Draggable} tracks. A 2-D drag composes
1441
1185
  * two `Draggable`s (one per axis) — the engine stays one-dimensional, the
@@ -1462,6 +1206,12 @@ export declare class Draggable {
1462
1206
  private readonly axis;
1463
1207
  private readonly transform;
1464
1208
  private readonly velocityWindow;
1209
+ /** Hard `[min, max]` value-domain constraint, or `undefined` (free). */
1210
+ private readonly bounds;
1211
+ /** Rubber-band resistance over `bounds` (only consulted when bounds set). */
1212
+ private readonly rubberBand;
1213
+ /** Snap targets in the value domain, or `undefined` (no snap). */
1214
+ private readonly snap;
1465
1215
  private element;
1466
1216
  private capturedPointerId;
1467
1217
  /** Rolling pointer samples for release-velocity estimation. */
@@ -1510,7 +1260,18 @@ export declare class Draggable {
1510
1260
  private coordOf;
1511
1261
  private handleDown;
1512
1262
  private handleMove;
1263
+ /**
1264
+ * Map a raw value-domain coordinate through {@link bounds} +
1265
+ * {@link rubberBand}. With no bounds the coordinate passes through. Below
1266
+ * `min`: `min + (value − min)·rubberBand`. Above `max`: `max +
1267
+ * (value − max)·rubberBand`. In range: the coordinate unchanged. At
1268
+ * `rubberBand = 0` the value is hard-clamped to the limit; at `1` the band
1269
+ * is fully transparent (pass-through).
1270
+ */
1271
+ private applyBounds;
1513
1272
  private handleUp;
1273
+ /** The snap target nearest `value` (ties → the first encountered). */
1274
+ private nearestSnap;
1514
1275
  /**
1515
1276
  * End the current gesture: release capture + remove the per-gesture
1516
1277
  * listeners. Idempotent — safe when no gesture is active.
@@ -1557,6 +1318,33 @@ export declare interface DragOptions {
1557
1318
  * 100ms.
1558
1319
  */
1559
1320
  velocityWindow?: number;
1321
+ /**
1322
+ * Hard constraint on the value domain `[min, max]`. The drag cannot pull
1323
+ * the spring target beyond these limits (a clamp in value domain, BEFORE
1324
+ * the rubber-band factor). When omitted the drag is unconstrained — the
1325
+ * mapped coordinate goes straight to the spring target as before.
1326
+ */
1327
+ bounds?: {
1328
+ min: number;
1329
+ max: number;
1330
+ };
1331
+ /**
1332
+ * Rubber-band resistance factor in `[0, 1]`. When the mapped pointer
1333
+ * coordinate exceeds {@link bounds}, the spring target is set to the
1334
+ * boundary + (excess × `rubberBand`) — the pointer coordinate decays
1335
+ * toward the limit rather than being hard-clamped. Default `0.4` (the
1336
+ * Motion / iOS spring-overscroll feel); `0` is a hard clamp, `1` is
1337
+ * pass-through (unconstrained). Has no effect when `bounds` is omitted.
1338
+ */
1339
+ rubberBand?: number;
1340
+ /**
1341
+ * Snap targets in the value domain. On release, the spring's projected
1342
+ * resting point (via {@link decayRest}) selects the nearest target; the
1343
+ * spring is reseated toward that target rather than decelerating freely.
1344
+ * {@link bounds} (if set) apply AFTER snap selection — a snap target
1345
+ * outside bounds is clamped to the bound. Omitted / empty = no snap.
1346
+ */
1347
+ snap?: number[];
1560
1348
  }
1561
1349
 
1562
1350
  /**
@@ -1681,6 +1469,31 @@ export declare interface ElementMorphOptions {
1681
1469
  transformOrigin?: string;
1682
1470
  }
1683
1471
 
1472
+ /**
1473
+ * The engine CORE surface — `Animation` / `CSSKeyframesAnimation` /
1474
+ * `AnimationGroup` + the timing/keyframe helpers + the option constants. This
1475
+ * is `./engine`'s own runtime exports: parse + interpolate WITHOUT the
1476
+ * ingest / compile / motion-path / draw-svg / animate / preset front doors. The
1477
+ * granular `loadEngine()` (L.W7 S3) resolves exactly this — a consumer that
1478
+ * needs only `new CSSKeyframesAnimation(opts).fromString(css)` pays for the
1479
+ * `engine` chunk alone, not the eight-chunk full surface.
1480
+ */
1481
+ export declare interface EngineCore {
1482
+ /** The core engine constructor (PKG-3, L.W8 §S4 — renamed from `Animation`). */
1483
+ KeyframesAnimation: typeof KeyframesAnimation;
1484
+ /** @deprecated Use {@link KeyframesAnimation}. Backward-compat alias (PKG-3). */
1485
+ Animation: typeof KeyframesAnimation;
1486
+ CSSKeyframesAnimation: typeof CSSKeyframesAnimation;
1487
+ AnimationGroup: typeof AnimationGroup;
1488
+ getAnimationId: (animation: KeyframesAnimation | string) => string;
1489
+ getTimingFunction: (timingFunction: TimingFunction | TimingFunctionNames | string | undefined) => TimingFunction | undefined;
1490
+ resolveKeyframes: (input: string | Stylesheet) => ResolvedKeyframes;
1491
+ DIRECTIONS: readonly AnimationOptions["direction"][];
1492
+ FILL_MODES: readonly AnimationOptions["fillMode"][];
1493
+ defaultOptions: AnimationOptions;
1494
+ defaultLayerConfig: AnimationLayerConfig;
1495
+ }
1496
+
1684
1497
  /** Entrance animations — bring an element INTO view. */
1685
1498
  declare const enterPresets: {
1686
1499
  readonly fadeIn: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
@@ -1705,6 +1518,28 @@ declare const exitPresets: {
1705
1518
  readonly jumpDown: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
1706
1519
  };
1707
1520
 
1521
+ /**
1522
+ * `explain(css, opts?)` — the human/LLM-readable companion. Calls
1523
+ * {@link validate} and formats the result as a concise, DETERMINISTIC string
1524
+ * (field order fixed, no locale-sensitive formatting) so a doctest can assert it
1525
+ * byte-for-byte. The shape the demo's ineligibility panel produces, as a
1526
+ * first-class library API. An LLM agent can present it verbatim or parse it for a
1527
+ * fix suggestion.
1528
+ *
1529
+ * Format (one block; the `–` bullets enumerate the refusals / WAAPI reason /
1530
+ * diagnostics, each on its own line):
1531
+ *
1532
+ * @keyframes color-drift:
1533
+ * parseable: yes
1534
+ * compile-eligible: no
1535
+ * – perceptual-oklab: color-drift cannot compile: …
1536
+ * waapi-eligible: no
1537
+ * – color interpolation requires perceptual lerp
1538
+ * diagnostics:
1539
+ * – COMPOSITION_FALLBACK: …
1540
+ */
1541
+ declare function explain(css: string, opts?: ValidateOptions): Promise<string>;
1542
+
1708
1543
  declare const fadeIn: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
1709
1544
 
1710
1545
  declare const fadeOut: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
@@ -1722,8 +1557,6 @@ declare const FILL_MODES: readonly ["none", "forwards", "backwards", "both"];
1722
1557
  */
1723
1558
  export declare function flip(element: HTMLElement, mutate: () => void, options?: FlipOptions): Promise<void>;
1724
1559
 
1725
- declare const flip_2: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
1726
-
1727
1560
  export declare interface FlipOptions {
1728
1561
  /** Playback duration in milliseconds. Defaults to `300`. */
1729
1562
  duration?: number;
@@ -1736,6 +1569,22 @@ export declare interface FlipOptions {
1736
1569
  transformOrigin?: string;
1737
1570
  }
1738
1571
 
1572
+ /**
1573
+ * The card-flip attention preset.
1574
+ *
1575
+ * ── PKG-3 RENAME (L.W8 §S4 · audit W126). Formerly the preset `flip`. Renamed
1576
+ * `flip` → `flipPreset` because the rolled-up `dist/keyframes.d.ts` placed this
1577
+ * preset (reachable as `presets.flip`) and the LIGHT top-level `flip` export
1578
+ * (the FLIP-layout helper in `flip.ts`) under the same name `flip`, so API
1579
+ * Extractor renamed this one with a numeric suffix and re-exported it under the
1580
+ * `flip` name inside the `AnimationPresets` namespace — a numeric-suffixed alias
1581
+ * `proof:pkg3-clean` greps for. Naming the preset `flipPreset` (distinct from the
1582
+ * light `flip`) clears the collision. BREAKING (5.0.0): the access path is now
1583
+ * `presets.flipPreset`; the nested taxonomy key `attentionPresets.flip` is
1584
+ * unchanged (a property name, not a top-level declaration — no collision).
1585
+ */
1586
+ declare const flipPreset: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
1587
+
1739
1588
  /**
1740
1589
  * Shared-element FLIP: animate element `a` onto the rect of element `b`
1741
1590
  * (Motion's `layoutId` / GSAP Flip shared-element style). Unlike `flip`, `a`
@@ -1752,251 +1601,752 @@ export declare interface FlipOptions {
1752
1601
  */
1753
1602
  export declare function flipShared(a: HTMLElement, b: HTMLElement, options?: FlipOptions): Promise<void>;
1754
1603
 
1604
+ declare function formatCSSKeyframeString(keyframe: string): string;
1605
+
1755
1606
  declare class FrameCompiler<V extends Vars = any> {
1756
1607
  private readonly _options;
1757
1608
  templateFrames: TemplateAnimationFrame<V>[];
1758
1609
  parsedVars: ParsedVarMap[];
1759
1610
  frames: AnimationFrame<V>[];
1760
1611
  /**
1761
- * Next TEMPLATE frame id — a monotonic handle assigned in `addFrame`
1762
- * (stable across re-parse, since `parse` does not re-add templates).
1763
- * Compiled-frame ids are content-derived from `(startIx, stopIx)`
1764
- * (see `createFrame`), NOT this counter, so `parse()` is idempotent.
1612
+ * Next TEMPLATE frame id — a monotonic handle assigned in `addFrame`
1613
+ * (stable across re-parse, since `parse` does not re-add templates).
1614
+ * Compiled-frame ids are content-derived from `(startIx, stopIx)`
1615
+ * (see `createFrame`), NOT this counter, so `parse()` is idempotent.
1616
+ */
1617
+ frameId: number;
1618
+ /**
1619
+ * The compile inputs live on the owning `Animation`'s `options` object.
1620
+ * The compiler holds a REFERENCE to it (the setters mutate it in place,
1621
+ * never replace it), so the NEXT compile always reads the current
1622
+ * `duration`/`easing`/`colorSpace` without re-linking. For values baked
1623
+ * into already-compiled frames, the setter triggers a targeted re-derive:
1624
+ * `setDuration` rescales `frame.time` in place; `setColorSpace`/
1625
+ * `setHueMethod` call {@link renormalizeColors} (the color resolution is
1626
+ * the only baked state that depends on them). No setter silently no-ops a
1627
+ * change to compiled state.
1628
+ */
1629
+ constructor(_options: AnimationOptions);
1630
+ /**
1631
+ * The live options object the compiler reads (a REFERENCE to the owning
1632
+ * `Animation`'s `options` — the setters mutate it in place). Read-only:
1633
+ * the compiler never replaces it. Exposed so `Animation.adoptCompiled`
1634
+ * can re-bind `Animation.options` to the adopted compiler's options object
1635
+ * BY CONSTRUCTION (`this.options === this.compiler.options`, the live-options
1636
+ * invariant — G.W19 / the `6e29236` lock), without poking a private field.
1637
+ */
1638
+ get options(): AnimationOptions;
1639
+ addFrame<K extends V>(start: number | string | ValueUnit<number>, vars: Partial<K>, transform?: TransformFunction<K>, timingFunction?: InputAnimationOptions["timingFunction"], composition?: CompositeOperator): void;
1640
+ createFrame(startIx: number, endIx: number): AnimationFrame<V>;
1641
+ /**
1642
+ * Build an index mapping each variable name to the frame indices where
1643
+ * it appears. Used by reconcileVars() for O(1) "next occurrence" lookups
1644
+ * instead of O(N) findIndex scans per variable.
1645
+ */
1646
+ private buildVarIndex;
1647
+ /**
1648
+ * Reconcile interpolation variables across non-adjacent keyframes.
1649
+ * For each variable at frame `ix`, find the next frame that also
1650
+ * defines that variable and create an interpolation segment between them.
1651
+ *
1652
+ * Uses a pre-built variable index (from buildVarIndex) to avoid
1653
+ * O(frames²) findIndex scans.
1654
+ */
1655
+ reconcileVars(ix: number, varIndex: Map<string, number[]>): void;
1656
+ /**
1657
+ * Compile `templateFrames` into the sampled `frames[]`. `targets` is the
1658
+ * one DOM input — each parsed var is bound to it so computed-unit
1659
+ * resolution can read the live box. Pure otherwise.
1660
+ */
1661
+ parse(targets: HTMLElement[]): void;
1662
+ /**
1663
+ * Derive a frame's `flatVars`/`vars`/`allInterpVars` from its
1664
+ * `interpVars` — the pre-flattened forms the hot path
1665
+ * (`interpFrames`) iterates without re-walking. Called once per frame
1666
+ * at the tail of `parse`, and again by `renormalizeColors` after a
1667
+ * color-space change re-derives the interp carriers in place.
1668
+ */
1669
+ private finalizeFrameVars;
1670
+ /**
1671
+ * Re-derive the color-resolved interpolation carriers in place after a
1672
+ * `colorSpace`/`hueMethod` change on already-compiled frames. Only the
1673
+ * per-`InterpolatedVar` color resolution depends on the color space —
1674
+ * the flatten/sort/reconcile structure does not — so this re-runs
1675
+ * `createInterpVarValue` over the existing `frames`/`parsedVars` and
1676
+ * rebuilds the hot-path arrays, with NO re-flatten and NO re-sort. The
1677
+ * new carriers derive from the already-target-bound `parsedVars`, the
1678
+ * same provenance `parse` gives them, so DOM binding is preserved.
1679
+ *
1680
+ * The owning `Animation`'s `setColorSpace`/`setHueMethod` call this when
1681
+ * frames already exist; before `parse`, the option is simply read by the
1682
+ * next compile.
1683
+ */
1684
+ renormalizeColors(): void;
1685
+ }
1686
+
1687
+ /**
1688
+ * Build a CSS-native SVG line-drawing animation: read the target's path length
1689
+ * ONCE, set `stroke-dasharray` to that length (one solid full-length dash), and
1690
+ * sweep `stroke-dashoffset` from → to (default `0% → 100%` ⇒ offset `L → 0`,
1691
+ * the line draws in). Returns the constructed {@link CSSKeyframesAnimation} as
1692
+ * the control handle (the `animate()` contract — `.play()` / `.pause()` /
1693
+ * `.stop()` / `.finished`), consistent with the `from*` factory family.
1694
+ *
1695
+ * The returned animation passes the EXISTING WAAPI eligibility gate
1696
+ * (`isWAAPIEligible`) for an SVG DOM target with a uniform CSS-twin easing, and
1697
+ * delegates compositor-thread via `playWAAPI` — no new eligibility predicate.
1698
+ *
1699
+ * The line length `L` is read a SINGLE time at construction (the
1700
+ * `motion-path.ts` "browser owns the geometry" pattern). A path mutated mid-draw
1701
+ * is a re-construct, not a per-frame re-measure — a per-frame `getTotalLength`
1702
+ * would be a layout round-trip the Mandate's measure-first forbids.
1703
+ *
1704
+ * @param target an SVG geometry element exposing `getTotalLength()`.
1705
+ * @param options `{ from?, to?, ...animationOptions }`.
1706
+ *
1707
+ * @example
1708
+ * // Draw a path stroke in over 2s:
1709
+ * fromDrawSVG(pathEl, { duration: 2000 });
1710
+ */
1711
+ declare function fromDrawSVG<V extends Record<string, any> = any>(target: SVGDrawTarget, options?: DrawSVGOptions): CSSKeyframesAnimation<V>;
1712
+
1713
+ /**
1714
+ * K1 — `fromLiveAnimations`: adopt every RUNNING CSS animation on the document
1715
+ * (or a single element) by reconstructing each from its source `@keyframes`
1716
+ * RULE (via the CSSOM walk — NOT from `getAnimations().getKeyframes()`, the
1717
+ * computed form that has lost `var()`/`cqw`/oklab). The `getAnimations()` read
1718
+ * provides the SET of live animation names; the reconstruction provides the
1719
+ * authored keyframes. The result maps each live animation name → its
1720
+ * reconstructed kf object (the recovered, axis-preserving source).
1721
+ *
1722
+ * Distinct from {@link fromStyleSheets} (which walks EVERY declared `@keyframes`
1723
+ * rule, running or not): `fromLiveAnimations` narrows to the names currently
1724
+ * RUNNING on the page — the animations a user actually sees in motion.
1725
+ */
1726
+ declare const fromLiveAnimations: <V extends Vars = any>(target?: Document | Element, options?: IngestOptions) => IngestResult<V>;
1727
+
1728
+ /**
1729
+ * Build an SVG path-shape morph: sample two `d` strings at `samples` uniform
1730
+ * arc-length steps each, pair the point sets, and interpolate the `(x, y)`
1731
+ * pairs from the `from`-polyline (`0%`) to the `to`-polyline (`100%`). Returns
1732
+ * the constructed {@link CSSKeyframesAnimation} as the control handle (the
1733
+ * `animate()` contract — `.play()` / `.pause()` / `.stop()` / `.finished`),
1734
+ * consistent with the `from*` factory family.
1735
+ *
1736
+ * value.js's `PathGeometry` owns the geometry (the `d`-parse + arc-length
1737
+ * table, built ONCE per path at construction); the engine's native numeric
1738
+ * `lerp` traverses the per-point coordinate keys. The morphed `d` at any `t` is
1739
+ * reassembled from the interpolated points — read it via the `MorphSVG` class's
1740
+ * {@link MorphSVG.sampleD}.
1741
+ *
1742
+ * Refuses a degenerate input: a zero-length `from` or `to` path throws a typed
1743
+ * {@link AnimationOptionError} rather than faking a silent zero-frame / identity
1744
+ * morph (the honest-or-refuse law — a morph between a zero-length path and
1745
+ * anything is a malformed input, not a morph).
1746
+ *
1747
+ * @param from the source SVG path `d` string.
1748
+ * @param to the target SVG path `d` string (differing geometry).
1749
+ * @param options `{ samples?, target?, autoPlay?, ...animationOptions }`.
1750
+ *
1751
+ * @example
1752
+ * // Morph a triangle into a square over 1s:
1753
+ * const m = fromMorphSVG(
1754
+ * "M 0 0 L 100 0 L 50 100 Z",
1755
+ * "M 0 0 L 100 0 L 100 100 L 0 100 Z",
1756
+ * { duration: 1000 },
1757
+ * );
1758
+ */
1759
+ declare function fromMorphSVG<V extends Record<string, any> = any>(from: string, to: string, options?: MorphSVGOptions): CSSKeyframesAnimation<V>;
1760
+
1761
+ /**
1762
+ * Build a CSS-native path-motion animation: set the author `offset-path` (and
1763
+ * optional `offset-rotate`) on the target(s), and sweep `offset-distance` from
1764
+ * → to. Returns the constructed {@link CSSKeyframesAnimation} as the control
1765
+ * handle (the `animate()` contract — `.play()` / `.pause()` / `.stop()` / the
1766
+ * awaitable play promise), consistent with the `from*` factory family.
1767
+ *
1768
+ * The returned animation passes the EXISTING WAAPI eligibility gate
1769
+ * (`isWAAPIEligible`) for a DOM target with a uniform CSS-twin easing, and
1770
+ * delegates compositor-thread via `playWAAPI` — no new eligibility predicate.
1771
+ *
1772
+ * @param target one or more DOM elements (or a single element) to move.
1773
+ * @param options `{ path, from?, to?, rotate?, ...animationOptions }`.
1774
+ *
1775
+ * @example
1776
+ * // Move a box along a quadratic path, facing along it, over 2s:
1777
+ * fromMotionPath(box, {
1778
+ * path: "path('M 0 0 Q 100 -100 200 0')",
1779
+ * rotate: "auto",
1780
+ * duration: 2000,
1781
+ * });
1782
+ */
1783
+ declare function fromMotionPath<V extends Record<string, any> = any>(target: HTMLElement | HTMLElement[], options: MotionPathOptions): CSSKeyframesAnimation<V>;
1784
+
1785
+ /**
1786
+ * K1 — `fromStyleSheets`: the consumer-facing front door over
1787
+ * {@link resolveLiveKeyframes}. Walk the document's (or the given list's)
1788
+ * stylesheets and return every reconstructed `@keyframes` animation. The honest
1789
+ * `CORS_SKIP`/`PARSE_ERROR` rows ride the returned {@link IngestResult}.
1790
+ *
1791
+ * @example
1792
+ * const { CSSKeyframesAnimation, fromStyleSheets } = await loadAnimationEngine();
1793
+ * const { animations, diagnostics } = fromStyleSheets();
1794
+ * const pulse = animations.get("pulse")?.animation;
1795
+ * pulse?.setTargets(el).play(); // re-drive the page's OWN animation
1796
+ * for (const d of diagnostics) console.warn(d.code, d.message); // honest skips
1797
+ */
1798
+ declare const fromStyleSheets: <V extends Vars = any>(source?: Document | ShadowRoot | CSSStyleSheet[] | CSSStyleSheet, options?: IngestOptions) => IngestResult<V>;
1799
+
1800
+ declare const glow: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
1801
+
1802
+ declare const gradientBackground: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
1803
+
1804
+ declare const heartbeat: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
1805
+
1806
+ declare const hover: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
1807
+
1808
+ /**
1809
+ * One ingested animation + the diagnostics its reconstruction produced. The
1810
+ * `name` is the `@keyframes` identifier (the CSSOM `CSSKeyframesRule.name`); the
1811
+ * `animation` is the reconstructed `CSSKeyframesAnimation`, already carrying any
1812
+ * sibling-style-rule `animation-*` options. `diagnostics` carries the honesty
1813
+ * rows for THIS rule (a malformed body → `PARSE_ERROR`, etc.); the walk-level
1814
+ * rows (`CORS_SKIP`) ride {@link IngestResult.diagnostics}.
1815
+ */
1816
+ export declare interface IngestedAnimation<V extends Vars = any> {
1817
+ /** The `@keyframes` identifier (CSSOM `CSSKeyframesRule.name`). */
1818
+ name: string;
1819
+ /** The reconstructed kf animation — replay-equal to the source CSS. */
1820
+ animation: CSSKeyframesAnimation<V>;
1821
+ /** Per-rule reconstruction diagnostics (empty on a clean ingest). */
1822
+ diagnostics: Diagnostic[];
1823
+ }
1824
+
1825
+ /** Options shared by the ingest entry points. */
1826
+ export declare interface IngestOptions {
1827
+ /**
1828
+ * Restrict the ingest to a single `@keyframes` name. When set, only the
1829
+ * matching rule is reconstructed (the rest are skipped without a
1830
+ * diagnostic — a name filter is an intentional narrowing, not a failure).
1831
+ */
1832
+ animationName?: string;
1833
+ /**
1834
+ * Animation options applied as the BASE for each reconstructed animation,
1835
+ * BELOW any sibling-style-rule `animation-*` declarations the source CSS
1836
+ * carries (the source's declared options win — the round-trip preserves the
1837
+ * AUTHORED timing). Empty by default.
1838
+ */
1839
+ options?: Partial<InputAnimationOptions>;
1840
+ }
1841
+
1842
+ /**
1843
+ * The result of a CSSOM walk: every `@keyframes` rule reconstructed into a kf
1844
+ * animation, plus the WALK-LEVEL diagnostics (the `CORS_SKIP` rows a
1845
+ * cross-origin sheet produces — the honesty surface S3). A consumer reads
1846
+ * `animations` for the recovered objects and `diagnostics` for the citable
1847
+ * reasons the walk could not complete a step faithfully — NEVER a silent drop.
1848
+ */
1849
+ export declare interface IngestResult<V extends Vars = any> {
1850
+ /** Every `@keyframes` rule reconstructed, keyed by its CSS name. */
1851
+ animations: Map<string, IngestedAnimation<V>>;
1852
+ /**
1853
+ * Walk-level diagnostics — the `CORS_SKIP` rows (a cross-origin sheet whose
1854
+ * `cssRules` throws `SecurityError`) and any other reason the walk could not
1855
+ * read a sheet. A typed {@link Diagnostic}[] on the same stable-`code` idiom
1856
+ * as `resolveKeyframes`; empty when every sheet was same-origin + parsed.
1857
+ */
1858
+ diagnostics: Diagnostic[];
1859
+ }
1860
+
1861
+ /**
1862
+ * The INGEST surface (L.W7 S3 `loadIngest()`) — the engine core PLUS the
1863
+ * forward-pointed live-web walk (`fromStyleSheets` / `fromLiveAnimations` /
1864
+ * `resolveLiveKeyframes` / `adoptRunning`) and the scroll-grammar round-trip
1865
+ * (`ScrollScene` + `parseScrollCSS` / `serializeScrollOptions` / …). A
1866
+ * consumer ingesting CSSOM / adopting a running animation / driving a scroll
1867
+ * scene pays for `engine` + `ingest` + `scroll-scene`, not the compile /
1868
+ * motion / draw / preset weight.
1869
+ */
1870
+ export declare interface IngestSurface extends EngineCore {
1871
+ fromStyleSheets: typeof fromStyleSheets;
1872
+ fromLiveAnimations: typeof fromLiveAnimations;
1873
+ resolveLiveKeyframes: typeof resolveLiveKeyframes;
1874
+ adoptRunning: typeof adoptRunning;
1875
+ ScrollScene: typeof ScrollScene;
1876
+ createScrollScene: typeof createScrollScene;
1877
+ parseScrollCSS: typeof parseScrollCSS;
1878
+ parseScrollTimeline: typeof parseScrollTimeline;
1879
+ parseScrollRange: typeof parseScrollRange;
1880
+ serializeScrollOptions: typeof serializeScrollOptions;
1881
+ roundTripScrollCSS: typeof roundTripScrollCSS;
1882
+ dispatchScrollBackend: typeof dispatchScrollBackend;
1883
+ resolveRange: typeof resolveRange;
1884
+ pinCSS: typeof pinCSS;
1885
+ }
1886
+
1887
+ export declare type InputAnimationOptions = Partial<{
1888
+ duration: number | string;
1889
+ delay: number | string;
1890
+ iterationCount: number | string | "infinite" | undefined;
1891
+ direction: (typeof DIRECTIONS)[number];
1892
+ fillMode: (typeof FILL_MODES)[number];
1893
+ timingFunction: TimingFunction | Easing | TimingFunctionNames | string | undefined;
1894
+ /** When true (default), eligible animations may use the Web Animations API for compositor-thread execution. Set to false to force rAF. */
1895
+ useWAAPI: boolean;
1896
+ /** When true, snap `play()` to the final frame under `prefers-reduced-motion: reduce`. Default false. */
1897
+ respectReducedMotion: boolean;
1898
+ colorSpace?: ColorSpace;
1899
+ hueMethod?: HueInterpolationMethod;
1900
+ /** The LAYER-level `animation-composition` operator (L.W1 S5). Omission ⇒ `replace`. */
1901
+ composite?: CompositeOperator;
1902
+ }>;
1903
+
1904
+ export { InterpolatedVar }
1905
+
1906
+ declare const jumpDown: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
1907
+
1908
+ declare const jumpUp: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
1909
+
1910
+ /** A keyframe map: percent/keyword stops → partial var frames. */
1911
+ export declare type KeyframeMap<V extends Vars> = Map<string, Partial<V>> | Record<string, Partial<V>>;
1912
+
1913
+ /**
1914
+ * The core animation engine — keyframes, timing, interpolation, playback.
1915
+ *
1916
+ * ── PKG-3 RENAME (L.W8 §S4 · audit W126). Formerly `Animation`; renamed to
1917
+ * `KeyframesAnimation` because the old name collided with the ambient
1918
+ * `globalThis.Animation` (WAAPI), leaking a numeric-suffixed collision alias
1919
+ * into the d.ts roll-up (packaging-k.md:118-127). The old `Animation` name
1920
+ * survives as a backward-compat RE-EXPORT alias (value + type) below — see the
1921
+ * `@deprecated` `Animation` export for the full rationale. Gated by
1922
+ * `proof:pkg3-clean`. The runtime constructor is `KeyframesAnimation`.
1923
+ */
1924
+ declare class KeyframesAnimation<V extends Vars = any> {
1925
+ id: number;
1926
+ name: string | undefined;
1927
+ superKey: string | undefined;
1928
+ targets: HTMLElement[];
1929
+ options: AnimationOptions;
1930
+ /**
1931
+ * The frame-compilation half — template frames → sampled `frames[]`.
1932
+ * `Animation` composes one and delegates `addFrame`/`parse` + the frame
1933
+ * accessors (`templateFrames`/`parsedVars`/`frames`/`frameId`) to it.
1934
+ * Assigned in the constructor once `options` exists (the compiler holds a
1935
+ * live reference to that options object).
1936
+ *
1937
+ * READ-ONLY surface (G.W19): the backing `_compiler` is written ONLY by the
1938
+ * constructor and {@link adoptCompiled}. An external `animation.compiler = …`
1939
+ * write was the one cross-boundary reach-in vector that could desync the
1940
+ * live-options reference (`this.options !== this.compiler.options`); making
1941
+ * `compiler` a get-only accessor makes that reach-in a COMPILE error, not a
1942
+ * convention. Adopt a compiled state via `adoptCompiled(source)`.
1943
+ */
1944
+ private _compiler;
1945
+ get compiler(): FrameCompiler<V>;
1946
+ /**
1947
+ * THE rAF owner for this animation — the standalone rAF play loop and
1948
+ * the WAAPI shadow tick both ride it, so `stop()` halts either
1949
+ * uniformly and no raw rAF handle leaks onto the instance.
1950
+ */
1951
+ readonly playback: RAFPlayback;
1952
+ /**
1953
+ * The live WAAPI compositor animations during a `_playWAAPI` delegation
1954
+ * (one per target), populated by `playWAAPI` and cleared on teardown.
1955
+ * The lifecycle methods (`stop`/`reset`) cancel these so a stopped
1956
+ * compositor animation never keeps painting and the awaited play
1957
+ * promise never hangs. Empty on the rAF path.
1958
+ */
1959
+ _waAnimations: globalThis.Animation[];
1960
+ startTime: number | undefined;
1961
+ pausedTime: number;
1962
+ t: number;
1963
+ iteration: number;
1964
+ /**
1965
+ * Structured parse/honoring diagnostics (K.W7 S4) — surfaced from the
1966
+ * adapter's `resolveKeyframes` ({@link CSSKeyframesAnimation.fromString})
1967
+ * and joined by the engine's own composition-fallback rows. A FLAT additive
1968
+ * array of stable-coded {@link Diagnostic} rows; empty on a clean parse with
1969
+ * no fallback. Every SILENT fallback site is mirrored here — the honesty
1970
+ * surface (`proof:diagnostics-channel`). Queryable; no console output.
1971
+ */
1972
+ diagnostics: Diagnostic[];
1973
+ /**
1974
+ * The captured UNDERLYING base value for each composited leaf (K.W7 S1),
1975
+ * keyed by the flat property key — the per-element numeric base the
1976
+ * `add`/`accumulate` operator accumulates ONTO (snapshotted the first time a
1977
+ * composited leaf is applied). Empty for a pure-`replace` animation (the
1978
+ * zero-overhead path). The capture/accumulate logic lives in
1979
+ * `./engine-composition` ({@link applyComposition}/`captureUnderlyingBase`).
1980
+ */
1981
+ private _compositionBase;
1982
+ /** Properties whose non-numeric composite already emitted its
1983
+ * `COMPOSITION_FALLBACK` row — so a long playback emits the honesty row
1984
+ * ONCE per property, not once per frame (S3/S4). */
1985
+ private _compositionFallbackSeen;
1986
+ /** True once `fromString`/`addFrame` saw a non-`replace` operator — the hot
1987
+ * path skips ALL composition work when this is false (the predictable
1988
+ * per-animation-constant branch the §gate's clause (f) measures free). */
1989
+ private _hasComposition;
1990
+ started: boolean;
1991
+ done: boolean;
1992
+ reversed: boolean;
1993
+ paused: boolean;
1994
+ /**
1995
+ * True when an `AnimationGroup` is driving this animation's
1996
+ * `advanceTo()` and `interpFrames()` from its own rAF loop. Set by
1997
+ * the group at construction; standalone `.play()` / `.draw()`
1998
+ * throw when this is true rather than racing the group.
1999
+ */
2000
+ managed: boolean;
2001
+ /**
2002
+ * If the most recent `play()` was rejected by WAAPI eligibility
2003
+ * but `useWAAPI: true` was requested, this records the reason.
2004
+ * Queryable by debug builds — no console output is produced.
2005
+ */
2006
+ waapiIneligibleReason: string | undefined;
2007
+ unflatten: boolean;
2008
+ private resolvePromise;
2009
+ private _playingPromise;
2010
+ /**
2011
+ * Pre-bound frame callback — allocated once to avoid creating a new
2012
+ * closure on every playback loop start.
2013
+ */
2014
+ private _boundFrame;
2015
+ /**
2016
+ * The ONE output buffer for the standalone play loop's `interpFrames`
2017
+ * calls — reused every frame so steady-state playback allocates no
2018
+ * per-frame result object (the primitive-level analogue of the group's
2019
+ * hoisted `_grouped` buffer, gated by `proof:standalone-zero-alloc`).
2020
+ * The play path (`_frame`) never returns this object to a consumer, so
2021
+ * reuse is safe; `at()` (a query whose result the caller keeps) still
2022
+ * allocates a fresh object.
2023
+ */
2024
+ private _interpOut;
2025
+ /**
2026
+ * The compile-stable union of every frame's `flatVars` keys — the maximal
2027
+ * key-set any `interpFrames` call can write. Fixed at `parse` (the keys
2028
+ * never change across frames; a color-space renormalize re-derives the same
2029
+ * carriers under the same keys). It is what `clearBuffer` null-fills to keep
2030
+ * a reused buffer stale-free WITHOUT `delete` (F.W4 S1 — the V8 dictionary-
2031
+ * mode trap the delete-loop fell into). Exposed (read-only) as `flatKeys`
2032
+ * so the `AnimationGroup` can size its own composite buffer the same way.
2033
+ */
2034
+ private _stableKeys;
2035
+ /**
2036
+ * The consumer's EXPLICIT constructor options (NOT merged with defaults) —
2037
+ * retained so `fromString` can layer a parsed style-rule `animation`
2038
+ * shorthand UNDER them (constructor-explicit wins over parsed-from-CSS, F.W8).
2039
+ */
2040
+ protected _ctorOptions: Partial<InputAnimationOptions>;
2041
+ /** The compile-stable union of this animation's interpolated keys. */
2042
+ get flatKeys(): readonly string[];
2043
+ /**
2044
+ * The instance's ONE default DOM-style renderer, allocated once.
2045
+ * "Did the consumer supply a custom transform?" is a reference
2046
+ * comparison against this single value ({@link usesDefaultRenderer}) —
2047
+ * typed and bind-proof, unlike a Symbol tag on a closure, which
2048
+ * `Function.prototype.bind` silently drops.
2049
+ */
2050
+ protected readonly _defaultTransform: TransformFunction<V>;
2051
+ /** True when `fn` is this instance's default DOM-style renderer. */
2052
+ usesDefaultRenderer(fn: TransformFunction<V> | undefined): boolean;
2053
+ private dispatchAnimationEvent;
2054
+ constructor(options?: Partial<InputAnimationOptions>, targets?: HTMLElement[] | HTMLElement | undefined, name?: string | undefined, superKey?: string | undefined);
2055
+ get templateFrames(): TemplateAnimationFrame<V>[];
2056
+ set templateFrames(value: TemplateAnimationFrame<V>[]);
2057
+ get parsedVars(): ParsedVarMap[];
2058
+ get frames(): AnimationFrame<V>[];
2059
+ get frameId(): number;
2060
+ /** Append a template frame (delegated to the compiler). Chainable. */
2061
+ addFrame<K extends V>(start: number | string | ValueUnit<number>, vars: Partial<K>, transform?: TransformFunction<K>, timingFunction?: InputAnimationOptions["timingFunction"], composition?: CompositeOperator): KeyframesAnimation<K>;
2062
+ /** Compile the template frames into the sampled `frames[]`. Chainable. */
2063
+ parse(): this;
2064
+ /**
2065
+ * Set `_hasComposition` (K.W7 S1) — true iff ANY compiled frame carries a
2066
+ * non-`replace` `animation-composition` operator (the hot-path branch reads
2067
+ * this ONE per-animation constant; a pure-`replace` animation never pays for
2068
+ * the composition work) — and reset the per-run base/fallback caches so a
2069
+ * re-parse re-snapshots the underlying base. See `./engine-composition`.
2070
+ */
2071
+ private computeHasComposition;
2072
+ /**
2073
+ * Adopt another animation's ALREADY-COMPILED state as ONE atomic motion
2074
+ * (G.W19) — the first-class verb for the "single-compile, then transplant"
2075
+ * pattern (E.W8 S0): a throwaway animation is built + compiled ONCE off the
2076
+ * new keyframes, and the live animation adopts that compiled state without a
2077
+ * second compile.
2078
+ *
2079
+ * The transplant moves the `{ compiler, options, unflatten }` triad together
2080
+ * and re-binds the live-options reference BY CONSTRUCTION — `this.options` is
2081
+ * read OFF the adopted compiler, so `this.options === this.compiler.options`
2082
+ * holds without relying on the caller's assignment order. This is the
2083
+ * invariant the demo formerly held by a comment + three ordered field writes;
2084
+ * here it is the method's contract, enforced by `proof:adopt-compiled`. A
2085
+ * `compiler` adopted WITHOUT re-binding `options` would leave the setters
2086
+ * mutating one object while the compiler reads another — the exact desync
2087
+ * the `6e29236` live-options lock guards against.
2088
+ *
2089
+ * Recomputes `_stableKeys` so `flatKeys` (the buffer-sizing contract)
2090
+ * reflects the adopted compiled frames, not the pre-adopt key-set. Chainable.
2091
+ *
2092
+ * @param source an animation whose `compiler` is already compiled.
2093
+ */
2094
+ adoptCompiled(source: KeyframesAnimation<V>): this;
2095
+ /**
2096
+ * Recompute `_stableKeys` — the union of every compiled frame's `flatVars`
2097
+ * keys — after a (re)compile. The maximal key-set the `clearBuffer`
2098
+ * null-fill resets, so a reused interpolation buffer stays in V8
2099
+ * fast-properties mode without ever calling `delete` (F.W4 S1).
2100
+ */
2101
+ private computeStableKeys;
2102
+ /**
2103
+ * Option setters — the fail-explicit contract.
2104
+ *
2105
+ * Genuine omission (`undefined`/`null`) means "use the default" and is
2106
+ * always accepted; present-but-malformed input THROWS a typed
2107
+ * `AnimationOptionError` naming the option and the offending value.
2108
+ * This is the same posture the layer API chose ("silent no-ops were
2109
+ * hiding consumer bugs") applied to the whole options surface — no
2110
+ * silent fallback, no silently-preserved previous value.
2111
+ */
2112
+ setTimingFunction(timingFunction: InputAnimationOptions["timingFunction"]): this;
2113
+ setIterationCount(iterationCount: InputAnimationOptions["iterationCount"]): this;
2114
+ setDuration(duration: InputAnimationOptions["duration"]): this;
2115
+ setDelay(delay: InputAnimationOptions["delay"]): this;
2116
+ setDirection(direction: InputAnimationOptions["direction"]): this;
2117
+ setFillMode(fillMode: InputAnimationOptions["fillMode"]): this;
2118
+ setUseWAAPI(useWAAPI: InputAnimationOptions["useWAAPI"]): this;
2119
+ setRespectReducedMotion(respectReducedMotion: InputAnimationOptions["respectReducedMotion"]): this;
2120
+ setColorSpace(colorSpace: InputAnimationOptions["colorSpace"]): this;
2121
+ setHueMethod(hueMethod: InputAnimationOptions["hueMethod"]): this;
2122
+ /**
2123
+ * Set the LAYER-level `animation-composition` operator (L.W1 S5, Band A).
2124
+ * Genuine omission (`undefined`) leaves the field unset — the serializer
2125
+ * treats it as the CSS default `replace` and omits the longhand. A present
2126
+ * value is stored verbatim (`replace` | `add` | `accumulate`), so a sibling
2127
+ * `.class { animation-composition: add }` ingested by `fromString`
2128
+ * round-trips on re-serialize.
2129
+ */
2130
+ setComposite(composite: InputAnimationOptions["composite"]): this;
2131
+ setOptions(options: Partial<InputAnimationOptions>): this;
2132
+ reverse(): this;
2133
+ fillForwards(): void;
2134
+ fillBackwards(): void;
2135
+ /**
2136
+ * Where the playhead rests after a completed play — derived ONCE from
2137
+ * `fillMode` (forwards/both → final; none/backwards → initial). This is
2138
+ * the explicit rest-position contract: completion paints the rest frame
2139
+ * per this derivation, and the reduced-motion snap is "rest = final,
2140
+ * paint it, settle" — the same path a `fillMode: forwards` completion
2141
+ * takes, not a separate code path.
2142
+ */
2143
+ get restPosition(): "initial" | "final";
2144
+ /** Paint the rest frame per the fill contract. */
2145
+ paintRest(): void;
2146
+ /**
2147
+ * Stateless progress query. Maps [0,1] from first keyframe to last,
2148
+ * regardless of playback direction. `apply=true` invokes transform callbacks.
2149
+ */
2150
+ at(progress: number, apply?: boolean): Record<string, ValueUnit[]>;
2151
+ /**
2152
+ * Interpolate all active frames at time `t`. This is the hot path —
2153
+ * called once per rAF frame during playback.
2154
+ *
2155
+ * Uses binary search (O(log N)) to find the first matching frame,
2156
+ * then scans neighbors to collect all overlapping frames at `t`
2157
+ * (multiple properties may share the same time range).
2158
+ *
2159
+ * @param t - Current animation time in milliseconds
2160
+ * @param transformFrames - If true, applies each frame's transform function to targets
2161
+ * @param out - Optional output object to write results into. When
2162
+ * provided, its keys are cleared first so no stale keys from a
2163
+ * previous call leak through. Pass this per-animation to achieve
2164
+ * zero-allocation steady-state playback.
2165
+ * @returns Merged flat vars from all active frames
2166
+ */
2167
+ interpFrames(t: number, transformFrames?: boolean, out?: Record<string, ValueUnit[]>): Record<string, ValueUnit[]>;
2168
+ /**
2169
+ * Clear a reused interpolation buffer to a stale-free state WITHOUT
2170
+ * `delete` — the V8-correct stable-key null-fill (F.W4 S1). The key-set is
2171
+ * compile-stable (`_stableKeys` is the union of every frame's `flatVars`
2172
+ * keys, fixed at `parse`), so null-filling it keeps the buffer in
2173
+ * fast-properties mode AND zero-alloc. Inactive keys read back `undefined`;
2174
+ * every consumer of a reused buffer (the group blend, the unused play-loop
2175
+ * `_interpOut`) skips them — only the standalone return path (which never
2176
+ * reuses a buffer) must be `undefined`-free, and it takes the alias / fresh
2177
+ * merge above.
1765
2178
  */
1766
- frameId: number;
2179
+ private clearBuffer;
1767
2180
  /**
1768
- * The compile inputs live on the owning `Animation`'s `options` object.
1769
- * The compiler holds a REFERENCE to it (the setters mutate it in place,
1770
- * never replace it), so the NEXT compile always reads the current
1771
- * `duration`/`easing`/`colorSpace` without re-linking. For values baked
1772
- * into already-compiled frames, the setter triggers a targeted re-derive:
1773
- * `setDuration` rescales `frame.time` in place; `setColorSpace`/
1774
- * `setHueMethod` call {@link renormalizeColors} (the color resolution is
1775
- * the only baked state that depends on them). No setter silently no-ops a
1776
- * change to compiled state.
2181
+ * Interpolate ONE active frame at time `t` in place (lerp + optional
2182
+ * transform). Lifted off the `interpFrames` hot loop so playback allocates
2183
+ * no per-frame closure. A zero-width frame (`start === stop`, a degenerate
2184
+ * keyframe pair) snaps to the endpoint instead of dividing by zero in
2185
+ * `scale` (E-RT-5). The merge into the result buffer is done by the caller
2186
+ * (F.W4 S3 — so the single-frame path can alias `flatVars` with no copy).
1777
2187
  */
1778
- constructor(_options: AnimationOptions);
2188
+ private processFrame;
1779
2189
  /**
1780
- * The live options object the compiler reads (a REFERENCE to the owning
1781
- * `Animation`'s `options` — the setters mutate it in place). Read-only:
1782
- * the compiler never replaces it. Exposed so `Animation.adoptCompiled`
1783
- * can re-bind `Animation.options` to the adopted compiler's options object
1784
- * BY CONSTRUCTION (`this.options === this.compiler.options`, the live-options
1785
- * invariant — G.W19 / the `6e29236` lock), without poking a private field.
2190
+ * Composite ONE frame's lerped numeric leaves onto the captured underlying
2191
+ * base per its `animation-composition` operator (K.W7 S1) — the thin engine
2192
+ * seam threading the live per-run state into the pure `./engine-composition`
2193
+ * honoring (where the un-clamped add, repeat-aware accumulate, captured base,
2194
+ * and non-numeric `replace`-fallback + `COMPOSITION_FALLBACK` row live).
1786
2195
  */
1787
- get options(): AnimationOptions;
1788
- addFrame<K extends V>(start: number | string | ValueUnit<number>, vars: Partial<K>, transform?: TransformFunction<K>, timingFunction?: InputAnimationOptions["timingFunction"], composition?: CompositeOperator): void;
1789
- createFrame(startIx: number, endIx: number): AnimationFrame<V>;
2196
+ private applyComposition;
2197
+ /** SYNC unless `delay > 0` — then a thenable resolving after the sleep. */
2198
+ onStart(): Promise<void> | undefined;
2199
+ onEnd(): void;
1790
2200
  /**
1791
- * Build an index mapping each variable name to the frame indices where
1792
- * it appears. Used by reconcileVars() for O(1) "next occurrence" lookups
1793
- * instead of O(N) findIndex scans per variable.
2201
+ * Advance the playhead to absolute clock `t` (a rAF timestamp, NOT a
2202
+ * delta). Lazily runs `onStart` on the first call, reconciles the
2203
+ * pause/resume clock, and ends the iteration once `t` reaches the
2204
+ * duration. This is the DRIVER-layer advance — the one meaning of the
2205
+ * absolute-clock step, distinct from the `tickDt(dt)` stepper surface
2206
+ * the rest of the engine canonicalized to.
2207
+ *
2208
+ * SYNC on the steady path (J.W6 S1 — the F.W5 held half, landed): every
2209
+ * post-start frame returns a plain number (no per-frame promise+microtask
2210
+ * hop); a thenable ONLY when the FIRST tick awaits the genuinely-async
2211
+ * delay sleep. Ordering locked by proof:event-ordering.
1794
2212
  */
1795
- private buildVarIndex;
2213
+ advanceTo(t: number): number | Promise<number>;
2214
+ /** The post-start advance body — pause clock, local time, iteration end. */
2215
+ private _advance;
1796
2216
  /**
1797
- * Reconcile interpolation variables across non-adjacent keyframes.
1798
- * For each variable at frame `ix`, find the next frame that also
1799
- * defines that variable and create an interpolation segment between them.
2217
+ * One frame of the standalone rAF play path, driven by the shared
2218
+ * `RAFPlayback.loop`. Returns whether the loop should continue.
2219
+ */
2220
+ private _frame;
2221
+ /** The post-advance render half of `_frame` — paint, or settle on done. */
2222
+ private _renderFrame;
2223
+ private _resolvePlay;
2224
+ /** Internal rAF-based play loop — loop ownership rides `this.playback`. */
2225
+ private _playRAF;
2226
+ /**
2227
+ * Play via the Web Animations API. WAAPI handles visuals on the
2228
+ * compositor thread; a shadow loop in `playWAAPI` (riding
2229
+ * `this.playback`) drives `advanceTo()` so events, iteration count,
2230
+ * pause/resume, and other lifecycle state stay coherent with the
2231
+ * rAF path.
1800
2232
  *
1801
- * Uses a pre-built variable index (from buildVarIndex) to avoid
1802
- * O(frames²) findIndex scans.
2233
+ * No silent fallback — eligibility is decided once in `play()`
2234
+ * before this is invoked, and runtime errors propagate.
1803
2235
  */
1804
- reconcileVars(ix: number, varIndex: Map<string, number[]>): void;
2236
+ private _playWAAPI;
1805
2237
  /**
1806
- * Compile `templateFrames` into the sampled `frames[]`. `targets` is the
1807
- * one DOM input — each parsed var is bound to it so computed-unit
1808
- * resolution can read the live box. Pure otherwise.
2238
+ * Cancel the live WAAPI compositor animations (if any). Cancelling
2239
+ * rejects each `wa.finished`, which `playWAAPI` catches as a halt — so
2240
+ * this both stops the compositor paint AND unblocks the awaited play
2241
+ * promise. No-op on the rAF path.
1809
2242
  */
1810
- parse(targets: HTMLElement[]): void;
2243
+ private _cancelWAAPI;
1811
2244
  /**
1812
- * Derive a frame's `flatVars`/`vars`/`allInterpVars` from its
1813
- * `interpVars` — the pre-flattened forms the hot path
1814
- * (`interpFrames`) iterates without re-walking. Called once per frame
1815
- * at the tail of `parse`, and again by `renormalizeColors` after a
1816
- * color-space change re-derives the interp carriers in place.
2245
+ * `prefers-reduced-motion` snap: rest = final, paint it, settle — the
2246
+ * SAME terminal path a `fillMode: forwards` completion takes, with the
2247
+ * motion elided. The lifecycle stays observable (`animationstart` →
2248
+ * final paint → `animationend`) so consumers' event wiring is identical
2249
+ * to a completed normal play.
1817
2250
  */
1818
- private finalizeFrameVars;
2251
+ private _playReducedMotion;
1819
2252
  /**
1820
- * Re-derive the color-resolved interpolation carriers in place after a
1821
- * `colorSpace`/`hueMethod` change on already-compiled frames. Only the
1822
- * per-`InterpolatedVar` color resolution depends on the color space —
1823
- * the flatten/sort/reconcile structure does not — so this re-runs
1824
- * `createInterpVarValue` over the existing `frames`/`parsedVars` and
1825
- * rebuilds the hot-path arrays, with NO re-flatten and NO re-sort. The
1826
- * new carriers derive from the already-target-bound `parsedVars`, the
1827
- * same provenance `parse` gives them, so DOM binding is preserved.
1828
- *
1829
- * The owning `Animation`'s `setColorSpace`/`setHueMethod` call this when
1830
- * frames already exist; before `parse`, the option is simply read by the
1831
- * next compile.
2253
+ * Mid-flight reduced-motion snap (D-LIB-3). A running rAF loop detected a
2254
+ * live flip to `reduce`; converge to the rest frame and resolve the
2255
+ * in-flight `play()` exactly as a forwards completion would. Distinct from
2256
+ * `_playReducedMotion` (the up-front gate) only in that `animationstart`
2257
+ * already fired — so here we paint final, mark done, end, settle, and
2258
+ * release the awaiter. The WAAPI lane snaps via the same path: the up-front
2259
+ * gate already routes reduced-motion away from WAAPI, and a live flip on a
2260
+ * WAAPI animation cancels the compositor handles before settling.
1832
2261
  */
1833
- renormalizeColors(): void;
1834
- }
1835
-
1836
- /**
1837
- * Build a CSS-native SVG line-drawing animation: read the target's path length
1838
- * ONCE, set `stroke-dasharray` to that length (one solid full-length dash), and
1839
- * sweep `stroke-dashoffset` from → to (default `0% → 100%` ⇒ offset `L → 0`,
1840
- * the line draws in). Returns the constructed {@link CSSKeyframesAnimation} as
1841
- * the control handle (the `animate()` contract — `.play()` / `.pause()` /
1842
- * `.stop()` / `.finished`), consistent with the `from*` factory family.
1843
- *
1844
- * The returned animation passes the EXISTING WAAPI eligibility gate
1845
- * (`isWAAPIEligible`) for an SVG DOM target with a uniform CSS-twin easing, and
1846
- * delegates compositor-thread via `playWAAPI` — no new eligibility predicate.
1847
- *
1848
- * The line length `L` is read a SINGLE time at construction (the
1849
- * `motion-path.ts` "browser owns the geometry" pattern). A path mutated mid-draw
1850
- * is a re-construct, not a per-frame re-measure — a per-frame `getTotalLength`
1851
- * would be a layout round-trip the Mandate's measure-first forbids.
1852
- *
1853
- * @param target an SVG geometry element exposing `getTotalLength()`.
1854
- * @param options `{ from?, to?, ...animationOptions }`.
1855
- *
1856
- * @example
1857
- * // Draw a path stroke in over 2s:
1858
- * fromDrawSVG(pathEl, { duration: 2000 });
1859
- */
1860
- declare function fromDrawSVG<V extends Record<string, any> = any>(target: SVGDrawTarget, options?: DrawSVGOptions): CSSKeyframesAnimation<V>;
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
-
1877
- /**
1878
- * Build a CSS-native path-motion animation: set the author `offset-path` (and
1879
- * optional `offset-rotate`) on the target(s), and sweep `offset-distance` from
1880
- * → to. Returns the constructed {@link CSSKeyframesAnimation} as the control
1881
- * handle (the `animate()` contract — `.play()` / `.pause()` / `.stop()` / the
1882
- * awaitable play promise), consistent with the `from*` factory family.
1883
- *
1884
- * The returned animation passes the EXISTING WAAPI eligibility gate
1885
- * (`isWAAPIEligible`) for a DOM target with a uniform CSS-twin easing, and
1886
- * delegates compositor-thread via `playWAAPI` — no new eligibility predicate.
1887
- *
1888
- * @param target one or more DOM elements (or a single element) to move.
1889
- * @param options `{ path, from?, to?, rotate?, ...animationOptions }`.
1890
- *
1891
- * @example
1892
- * // Move a box along a quadratic path, facing along it, over 2s:
1893
- * fromMotionPath(box, {
1894
- * path: "path('M 0 0 Q 100 -100 200 0')",
1895
- * rotate: "auto",
1896
- * duration: 2000,
1897
- * });
1898
- */
1899
- declare function fromMotionPath<V extends Record<string, any> = any>(target: HTMLElement | HTMLElement[], options: MotionPathOptions): CSSKeyframesAnimation<V>;
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
-
1916
- declare const glow: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
1917
-
1918
- declare const gradientBackground: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
1919
-
1920
- declare const heartbeat: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
1921
-
1922
- declare const hover: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
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 {
2262
+ private _snapToReducedMotion;
2263
+ /**
2264
+ * The completion front-door (G.W13) — `await anim.finished` resolves once
2265
+ * the in-flight play settles. It exposes the ONE held `_playingPromise`
2266
+ * `play()` already constructs (the re-entrant guard returns it; the
2267
+ * `finally`-clear nulls it on settle) — NOT a second completion lifecycle.
2268
+ * Two reads mid-play return the SAME promise. A settled (or never-played)
2269
+ * animation reads `null` and resolves immediately: "not running" = "nothing
2270
+ * to await" — the honest semantics for a getter that reports current
2271
+ * settledness, not a pre-armed future run.
2272
+ */
2273
+ get finished(): Promise<void>;
2274
+ play(): Promise<void>;
1943
2275
  /**
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).
2276
+ * Pause playback — idempotent. Pausing an already-paused (or
2277
+ * not-yet-started) animation is a no-op, never a resume: a method named
2278
+ * `pause` pauses. Use {@link resume} for the explicit resume.
1947
2279
  */
1948
- animationName?: string;
2280
+ pause(): this;
2281
+ resume(): this;
2282
+ /** The explicit flip: pauses if playing, resumes if paused. */
2283
+ toggle(): this;
1949
2284
  /**
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.
2285
+ * Halt playback where it stands: cancel the loop AND the WAAPI
2286
+ * compositor animations, settle state, and resolve any pending `play()`
2287
+ * promise. Never paints — `reset()` is the explicit rewind.
1954
2288
  */
1955
- options?: Partial<InputAnimationOptions>;
2289
+ stop(): void;
2290
+ playing(): boolean;
2291
+ /** Returns the effective time accounting for direction reversal. */
2292
+ get effectiveT(): number;
2293
+ /**
2294
+ * Pure state teardown — flags, clocks, iteration. NEVER paints. This is
2295
+ * the terminal half of the rest-position contract: completion paints
2296
+ * the rest frame (via `onEnd` → `paintRest`) and then settles; the
2297
+ * reduced-motion snap paints final and then settles. Settling is
2298
+ * orthogonal to where the pixels rest.
2299
+ */
2300
+ settle(): this;
2301
+ /**
2302
+ * Explicit rewind: paint the INITIAL frame, then settle. This is the
2303
+ * user-facing "return to start" — rest position `initial`, painted
2304
+ * deliberately — distinct from `settle()`, which tears down state and
2305
+ * leaves the pixels where they rest.
2306
+ */
2307
+ reset(): this;
2308
+ setTargets(...targets: HTMLElement[]): this;
2309
+ group(...animations: KeyframesAnimation<V>[]): AnimationGroup<V>;
1956
2310
  }
2311
+ export { KeyframesAnimation as Animation }
2312
+ export { KeyframesAnimation }
1957
2313
 
1958
2314
  /**
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.
2315
+ * The JS scroll-progress sampler.
2316
+ *
2317
+ * ── PKG-3 RENAME (L.W8 §S4 · audit W126). Formerly `ScrollTimeline`. Renamed
2318
+ * `ScrollTimeline` → `KeyframesScrollTimeline` because the rolled-up d.ts
2319
+ * declaration `ScrollTimeline` collided with the ambient `globalThis.ScrollTimeline`
2320
+ * (the Houdini native scroll timeline): API Extractor renamed the colliding
2321
+ * source class and re-exported it under a numeric-suffixed alias that leaked
2322
+ * into IDE hover text. Naming the class `KeyframesScrollTimeline` (no ambient
2323
+ * collision) clears the rename; gated by `proof:pkg3-clean`. The old
2324
+ * `ScrollTimeline` name survives as a backward-compat RE-EXPORT alias (value +
2325
+ * type) — see the `@deprecated` `ScrollTimeline` export below; because the
2326
+ * canonical name no longer collides, API Extractor emits the alias cleanly
2327
+ * (`KeyframesScrollTimeline` exported under the `ScrollTimeline` name, no
2328
+ * numeric suffix).
1964
2329
  */
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[];
2330
+ declare class KeyframesScrollTimeline extends Timeline {
2331
+ private threshold;
2332
+ private getScrollY;
2333
+ private getViewportHeight;
2334
+ constructor(options?: KeyframesScrollTimelineOptions);
2335
+ protected sample(): number;
1975
2336
  }
2337
+ export { KeyframesScrollTimeline }
2338
+ export { KeyframesScrollTimeline as ScrollTimeline }
1976
2339
 
1977
- export declare type InputAnimationOptions = Partial<{
1978
- duration: number | string;
1979
- delay: number | string;
1980
- iterationCount: number | string | "infinite" | undefined;
1981
- direction: (typeof DIRECTIONS)[number];
1982
- fillMode: (typeof FILL_MODES)[number];
1983
- timingFunction: TimingFunction | Easing | TimingFunctionNames | string | undefined;
1984
- /** When true (default), eligible animations may use the Web Animations API for compositor-thread execution. Set to false to force rAF. */
1985
- useWAAPI: boolean;
1986
- /** When true, snap `play()` to the final frame under `prefers-reduced-motion: reduce`. Default false. */
1987
- respectReducedMotion: boolean;
1988
- colorSpace?: ColorSpace;
1989
- hueMethod?: HueInterpolationMethod;
1990
- }>;
1991
-
1992
- export { InterpolatedVar }
1993
-
1994
- declare const jumpDown: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
1995
-
1996
- declare const jumpUp: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
1997
-
1998
- /** A keyframe map: percent/keyword stops → partial var frames. */
1999
- export declare type KeyframeMap<V extends Vars> = Map<string, Partial<V>> | Record<string, Partial<V>>;
2340
+ declare interface KeyframesScrollTimelineOptions extends TimelineOptions {
2341
+ /** Viewport fraction for full progress. Default 0.35. */
2342
+ threshold?: number | undefined;
2343
+ /** Custom scroll position supplier. Default: window.scrollY. */
2344
+ getScrollY?: (() => number) | undefined;
2345
+ /** Custom viewport height supplier. Default: window.innerHeight. */
2346
+ getViewportHeight?: (() => number) | undefined;
2347
+ }
2348
+ export { KeyframesScrollTimelineOptions }
2349
+ export { KeyframesScrollTimelineOptions as ScrollTimelineOptions }
2000
2350
 
2001
2351
  /**
2002
2352
  * Options for `AnimationGroup.transitionLayer` / `crossfade` (K.W11 PHYS-C).
@@ -2007,26 +2357,14 @@ export declare type KeyframeMap<V extends Vars> = Map<string, Partial<V>> | Reco
2007
2357
  */
2008
2358
  declare type LayerTransitionSpring = Partial<Omit<SpringProgressOptions, "initial" | "initialVelocity">>;
2009
2359
 
2010
- /**
2011
- * Load the heavy CSS-keyframe parsing engine — `Animation`,
2012
- * `CSSKeyframesAnimation`, `AnimationGroup`, `getTimingFunction`,
2013
- * `resolveKeyframes`, and the animation-options constants (`DIRECTIONS`,
2014
- * `FILL_MODES`, `defaultOptions`, `defaultLayerConfig`).
2015
- *
2016
- * This is the dynamic boundary: the `import("./engine")` pulls value.js into
2017
- * the consumer's graph only when first awaited, so a light-only consumer
2018
- * (spring / smooth / numeric / morph / timeline) never loads it.
2019
- *
2020
- * ```ts
2021
- * const { CSSKeyframesAnimation } = await loadAnimationEngine();
2022
- * const anim = new CSSKeyframesAnimation(opts).fromString(css);
2023
- * ```
2024
- *
2025
- * The browser caches the dynamic module after the first load, so repeat
2026
- * calls resolve from the module cache without a second fetch.
2027
- */
2028
2360
  export declare const loadAnimationEngine: () => Promise<AnimationEngine>;
2029
2361
 
2362
+ export declare const loadCompiler: () => Promise<CompilerSurface>;
2363
+
2364
+ export declare const loadEngine: () => Promise<EngineCore>;
2365
+
2366
+ export declare const loadIngest: () => Promise<IngestSurface>;
2367
+
2030
2368
  /** Looping animations — run continuously (`iterationCount: Infinity`). */
2031
2369
  declare const loopPresets: {
2032
2370
  readonly heartbeat: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
@@ -2048,6 +2386,12 @@ export declare class ManualTimeline extends Timeline {
2048
2386
  protected sample(): number;
2049
2387
  }
2050
2388
 
2389
+ /** A sampled point on a path polyline. */
2390
+ export declare interface MorphPoint {
2391
+ x: number;
2392
+ y: number;
2393
+ }
2394
+
2051
2395
  export declare interface MorphRect {
2052
2396
  x: number;
2053
2397
  y: number;
@@ -2055,6 +2399,66 @@ export declare interface MorphRect {
2055
2399
  height: number;
2056
2400
  }
2057
2401
 
2402
+ /**
2403
+ * `MorphSVG` — the class form of {@link fromMorphSVG}, for callers who prefer a
2404
+ * named primitive alongside `CSSKeyframesAnimation` / `MotionPath` / `DrawSVG`.
2405
+ * Construction is the factory: `new MorphSVG(from, to).animation` is the control
2406
+ * handle. The factory is the canonical entry; this is a thin ergonomic wrapper
2407
+ * that ALSO exposes {@link sampleD} — the morphed `d` string at a normalized
2408
+ * `t`, reassembled from the interpolated point coordinates.
2409
+ */
2410
+ declare class MorphSVG<V extends Record<string, any> = any> {
2411
+ /** The underlying coordinate-interpolating animation — the control handle. */
2412
+ readonly animation: CSSKeyframesAnimation<V>;
2413
+ /** The uniform-sample count (point pairs = samples + 1). */
2414
+ readonly samples: number;
2415
+ constructor(from: string, to: string, options?: MorphSVGOptions);
2416
+ /**
2417
+ * The morphed SVG path `d` string at a normalized `t` in `[0, 1]`, built
2418
+ * from the engine's interpolated point coordinates (`0` → the `from`
2419
+ * polyline, `1` → the `to` polyline, `0.5` → the point-wise midpoint). The
2420
+ * value a consumer renders (`<path d>` / a `d:` custom property), distinct
2421
+ * from BOTH endpoint polylines at any interior `t`.
2422
+ */
2423
+ sampleD(t: number): string;
2424
+ /** Start (or re-enter) the morph play loop. */
2425
+ play(): Promise<void>;
2426
+ /** Pause the play loop, retaining the playhead. */
2427
+ pause(): this;
2428
+ /** Halt and rewind the play loop. */
2429
+ stop(): this;
2430
+ /** Resolve once the morph completes — the {@link Animation.finished} front-door. */
2431
+ get finished(): Promise<void>;
2432
+ }
2433
+
2434
+ export declare interface MorphSVGOptions extends Partial<InputAnimationOptions> {
2435
+ /**
2436
+ * The number of uniform arc-length steps each path is sampled at. The
2437
+ * morph emits `samples + 1` point-pairs (the endpoints inclusive), and the
2438
+ * MATCHED count between the `0%` and `100%` frames is what makes the
2439
+ * polyline channel interpolable. Default `64` — the keystone-validated
2440
+ * resolution. Must be an integer `>= 2` (a 1-sample "morph" is just the two
2441
+ * endpoints with no body); a smaller / non-integer value throws.
2442
+ */
2443
+ samples?: number;
2444
+ /**
2445
+ * Optional target the morph drives. When given, the morph writes the
2446
+ * interpolated polyline `d` (`MorphSVG.sampleD`) onto the target's
2447
+ * `--morph-d` CSS custom property each frame so an author can render it
2448
+ * (e.g. `<path d="" style="d: var(--morph-d)">` or a JS reader). Default
2449
+ * target-less: the returned handle IS the control surface, exactly like
2450
+ * `fromDrawSVG`'s target-less form — `MorphSVG.sampleD(t)` reads the
2451
+ * morphed `d` directly without a DOM write.
2452
+ */
2453
+ target?: HTMLElement | SVGElement;
2454
+ /**
2455
+ * Auto-start the play loop after construction + targeting. Default true.
2456
+ * `false` returns a constructed, NOT-yet-playing handle so the caller can
2457
+ * drive the returned animation (`.play()` / `.pause()` / `.stop()`).
2458
+ */
2459
+ autoPlay?: boolean;
2460
+ }
2461
+
2058
2462
  declare interface MorphValues {
2059
2463
  [key: string]: number;
2060
2464
  translateX: number;
@@ -2238,6 +2642,98 @@ export declare type NumericFrameCallback<T extends Record<string, number>> = (va
2238
2642
  */
2239
2643
  export declare type OffsetPath = string;
2240
2644
 
2645
+ /**
2646
+ * A periodic phase clock: a linear phase ramp ∈ [0, 1) advanced by
2647
+ * `frequency × dt` per {@link tick}, plus a pure {@link sample} that maps a raw
2648
+ * time to its waveform value WITHOUT touching the running phase.
2649
+ *
2650
+ * LIGHT (value.js-free) — plain trig/floor math, no CSS parsing, no rAF
2651
+ * ownership. The caller drives the loop (mirrors `SmoothProgress` /
2652
+ * `SpringProgress`): feed `dt` (seconds) from a `RAFPlayback` loop or a
2653
+ * `ScrollTimeline`, read {@link phase} (or {@link value}) per frame.
2654
+ */
2655
+ export declare class Oscillator {
2656
+ private readonly frequency;
2657
+ private readonly waveform;
2658
+ /** The current phase ∈ [0, 1) — a linear ramp modulo 1 driven by {@link tick}. */
2659
+ phase: number;
2660
+ constructor(opts: OscillatorConfig);
2661
+ /**
2662
+ * Advance the phase by `frequency × dt` and wrap into [0, 1). Returns the
2663
+ * new phase. `dt` is in the caller's units (seconds for a `RAFPlayback`
2664
+ * frame, a normalized scroll delta for a `ScrollTimeline`); the consumer
2665
+ * owns the clock, so a negative `dt` runs the phase backward (and wraps
2666
+ * correctly, never going negative). No rAF — a pure stepper.
2667
+ */
2668
+ tick(dt: number): number;
2669
+ /**
2670
+ * The waveform value of the CURRENT running phase ∈ [-1, 1]. A pure read
2671
+ * over {@link phase} — does not advance the clock. Pair with {@link tick}:
2672
+ * `osc.tick(dt); const v = osc.value;`.
2673
+ */
2674
+ get value(): number;
2675
+ /**
2676
+ * Pure stateless sample: `t → waveform(t × frequency)`. Independent of the
2677
+ * running {@link phase} — it never reads or mutates it, so a consumer can
2678
+ * sample an absolute clock (`osc.sample(elapsedSeconds)`) without disturbing
2679
+ * a concurrently-`tick`ed phase. `t` is in the same units as `dt`.
2680
+ */
2681
+ sample(t: number): number;
2682
+ /** Reset the running phase (default 0). Does not change frequency/waveform. */
2683
+ reset(phase?: number): void;
2684
+ }
2685
+
2686
+ /**
2687
+ * Construction options for {@link Oscillator}.
2688
+ *
2689
+ * Named `OscillatorConfig` (NOT `OscillatorOptions`, the `…Options` convention
2690
+ * of the sibling steppers) deliberately: the Web Audio API declares a GLOBAL
2691
+ * `interface OscillatorOptions` (`lib.dom.d.ts`), so an `OscillatorOptions`
2692
+ * source type collides with `globalThis.OscillatorOptions` in the API-Extractor
2693
+ * d.ts roll-up — it renames to `OscillatorOptions_2`, which leaks into every IDE
2694
+ * hover (the PKG-3 defect `proof:published-surface` clause (h) gates, the same
2695
+ * `globalThis.Animation`/`ScrollTimeline` collision L.W8 S4 renamed away). The
2696
+ * non-colliding `OscillatorConfig` keeps the surface clean.
2697
+ */
2698
+ export declare interface OscillatorConfig {
2699
+ /**
2700
+ * Cycles per unit of `dt` — the phase advances `frequency × dt` per
2701
+ * {@link Oscillator.tick}. With `dt` in seconds a `frequency` of `1` is one
2702
+ * full cycle per second (1 Hz). Required; no implicit default rate.
2703
+ */
2704
+ frequency: number;
2705
+ /**
2706
+ * The periodic shape `phase ∈ [0, 1) → value ∈ [-1, 1]` that
2707
+ * {@link Oscillator.sample} (and a consumer reading {@link Oscillator.phase}
2708
+ * through {@link waveformValue}) applies. Default `"sine"`.
2709
+ */
2710
+ waveform?: OscillatorWaveform;
2711
+ }
2712
+
2713
+ /**
2714
+ * Oscillator — a LIGHT periodic phase clock (L.W9 S5 · W128 KF-OSCILLATOR).
2715
+ *
2716
+ * A frequency-driven phase ramp ∈ [0, 1) with a pure waveform shaper over it.
2717
+ * The boundary law places "playback/phase = kf", so the primitive belongs here
2718
+ * beside `SmoothProgress` / `SpringProgress` / `RAFPlayback`: it is a periodic
2719
+ * phase clock, NOT a CSS value parser, so it carries ZERO static edge to
2720
+ * `@mkbabb/value.js` (proof:boundary gates it as a value.js-free LIGHT entry).
2721
+ *
2722
+ * The consume signal is glass-ui BB's `W-EASING-PRIMITIVE` wave — its speedtest
2723
+ * idle-breath and the demo's `KF-OSCILLATOR` scene read the phase to drive a
2724
+ * looping motion. glass-ui co-schedules; kf owns the phase math
2725
+ * (`docs/tranches/L/waves/L.W9.md §S5`).
2726
+ *
2727
+ * NO rAF ownership — the caller drives the loop. `tick(dt)` advances the phase
2728
+ * by `frequency × dt` (with `dt` in SECONDS from the caller's `RAFPlayback`
2729
+ * loop or `ScrollTimeline`), mirroring the `SmoothProgress` / `SpringProgress`
2730
+ * stepper discipline (a pure step, the consumer owns the clock). `sample(t)` is
2731
+ * a stateless pure mapping `t → waveform(t × frequency)` — it never touches the
2732
+ * running phase, so the two surfaces are independent on the one primitive.
2733
+ */
2734
+ /** The four canonical periodic waveforms the phase clock shapes a phase into. */
2735
+ export declare type OscillatorWaveform = "sine" | "triangle" | "square" | "sawtooth";
2736
+
2241
2737
  declare const parallaxScroll: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
2242
2738
 
2243
2739
  declare type ParsedVarMap = Record<string, ValueArray>;
@@ -2570,6 +3066,17 @@ export declare interface ResolvedKeyframes {
2570
3066
  composition: Map<string, string>;
2571
3067
  /** `@property --foo { ... }` registry */
2572
3068
  properties: Map<string, PropertyDescriptor_2>;
3069
+ /**
3070
+ * `@function --foo(...) { ... }` descriptor registry (P.W13 — the emerging-CSS
3071
+ * resolve seam). Collected via value.js `extractFunctions` exactly as
3072
+ * `properties` is collected via `extractProperties`. Threaded into the
3073
+ * {@link resolveValues} pass's {@link ResolveContext} so the dashed-function
3074
+ * `@function` CALL-inlining lands greenable the moment value.js-P publishes
3075
+ * the call-parse arm; the descriptor is captured NOW (a read-only registry —
3076
+ * the inlining that CONSUMES it is the value.js-P-gated seam in
3077
+ * `resolve-values.ts`).
3078
+ */
3079
+ functions: Map<string, CustomFunctionDescriptor>;
2573
3080
  /**
2574
3081
  * Animation options recovered from a top-level style rule's
2575
3082
  * `animation` shorthand or longhand declarations (if any). Empty
@@ -2587,6 +3094,15 @@ export declare interface ResolvedKeyframes {
2587
3094
  * K.W8 populates the ingest rows (`CORS_SKIP`, `WAAPI_INELIGIBLE`) it owns.
2588
3095
  */
2589
3096
  diagnostics: Diagnostic[];
3097
+ /**
3098
+ * The parsed CSS `Stylesheet` AST the resolve walked (L.W2 S1). Surfaced so a
3099
+ * caller can recover scroll-grammar (`animation-timeline`/`animation-range`)
3100
+ * from the SAME parse via `extractTimelineOptions(resolved.stylesheet)` —
3101
+ * `CSSKeyframesAnimation.fromString` threads it onto `scrollOptions` so the
3102
+ * compiler's EMIT half (CC-6) can serialize the scroll longhands back out. A
3103
+ * read-only metadata field; the keyframe/option resolution is unchanged.
3104
+ */
3105
+ stylesheet: Stylesheet;
2590
3106
  }
2591
3107
 
2592
3108
  /**
@@ -2631,7 +3147,7 @@ export declare function resolveEasing(name: string): Promise<Easing>;
2631
3147
  * normalises a STRING of CSS, `resolveLiveKeyframes` normalises the LIVE CSSOM —
2632
3148
  * the parser pointed forward at the web the page already ships.
2633
3149
  */
2634
- declare const resolveLiveKeyframes: <V extends Vars = any>(source?: Document | CSSStyleSheet[] | CSSStyleSheet, options?: IngestOptions) => IngestResult<V>;
3150
+ declare const resolveLiveKeyframes: <V extends Vars = any>(source?: Document | ShadowRoot | CSSStyleSheet[] | CSSStyleSheet, options?: IngestOptions) => IngestResult<V>;
2635
3151
 
2636
3152
  /**
2637
3153
  * Resolve a parsed `AnimationRangeValue` (or `undefined` → the whole [0,1]
@@ -2675,7 +3191,7 @@ export declare type ScrollDispatch = {
2675
3191
  */
2676
3192
  export declare interface ScrollDispatchRequest<V extends Vars> {
2677
3193
  /** The animation to drive over the scroll clock. */
2678
- animation?: Animation_2<V> | undefined;
3194
+ animation?: KeyframesAnimation<V> | undefined;
2679
3195
  /** The native timeline spec (`scroll`/`view`) for the eligible fast lane. */
2680
3196
  nativeSpec?: NativeTimelineSpec | undefined;
2681
3197
  /** True if scrub smoothing was requested (forces JS — native has no smoother). */
@@ -2795,25 +3311,6 @@ export declare interface ScrollSceneOptions {
2795
3311
  /** A `.on(event, cb)` subscriber. Receives the local progress at the crossing. */
2796
3312
  export declare type ScrollSceneSubscriber = (progress: number) => void;
2797
3313
 
2798
- declare class ScrollTimeline_2 extends Timeline {
2799
- private threshold;
2800
- private getScrollY;
2801
- private getViewportHeight;
2802
- constructor(options?: ScrollTimelineOptions_2);
2803
- protected sample(): number;
2804
- }
2805
- export { ScrollTimeline_2 as ScrollTimeline }
2806
-
2807
- declare interface ScrollTimelineOptions_2 extends TimelineOptions {
2808
- /** Viewport fraction for full progress. Default 0.35. */
2809
- threshold?: number | undefined;
2810
- /** Custom scroll position supplier. Default: window.scrollY. */
2811
- getScrollY?: (() => number) | undefined;
2812
- /** Custom viewport height supplier. Default: window.innerHeight. */
2813
- getViewportHeight?: (() => number) | undefined;
2814
- }
2815
- export { ScrollTimelineOptions_2 as ScrollTimelineOptions }
2816
-
2817
3314
  /**
2818
3315
  * The master-playhead orchestrator. Positions child animations along one clock
2819
3316
  * and drives them via `Animation.advanceTo`. See the module docstring for the
@@ -2824,6 +3321,13 @@ export declare class Sequence<V extends Vars = any> {
2824
3321
  readonly entries: SequenceEntry<V>[];
2825
3322
  /** Named positions on the master clock, registered via {@link label}. */
2826
3323
  private readonly labels;
3324
+ /**
3325
+ * The transport-events bus — the per-event subscriber registry + the
3326
+ * crossing detector (segment-lifecycle + label straddle). `on(...)` forwards
3327
+ * to `_events.subscribe`, and `_fireCrossings` to `_events.fire`. See
3328
+ * `./sequence-events` for the channel + detector body.
3329
+ */
3330
+ private readonly _events;
2827
3331
  /**
2828
3332
  * The running insertion cursor (ms) — the end of the last-inserted
2829
3333
  * segment. Relative `"+="`/`"-="` positions and auto-append (`at` omitted)
@@ -2887,13 +3391,32 @@ export declare class Sequence<V extends Vars = any> {
2887
3391
  get rate(): number;
2888
3392
  /** Register a named position on the master clock. Chainable. */
2889
3393
  label(name: string, at?: SequencePosition): this;
3394
+ /**
3395
+ * Subscribe to a segment-lifecycle or label crossing. Returns an
3396
+ * unsubscribe handle — the `ScrollScene.on` idiom (`scroll-scene.ts:506-514`).
3397
+ *
3398
+ * - `"segment:enter"` fires when the playhead enters a segment's
3399
+ * `[at, at + duration)` span (forward across `at`, or backward across the
3400
+ * span end); the callback receives that segment's `animation` reference
3401
+ * and the master-clock position at the crossing.
3402
+ * - `"segment:leave"` fires on the complementary crossing OUT of the span.
3403
+ * - `"label"` fires when the playhead straddles a registered label position
3404
+ * in EITHER direction; the callback receives `(name, masterClock)`.
3405
+ *
3406
+ * Crossings fire on EVERY paint — `seek` (scrub) and the rAF play loop,
3407
+ * forward, reverse, and yoyo. The callback's `masterClock` lets the consumer
3408
+ * infer direction; there is no `once` idiom — unsubscribe in the callback
3409
+ * (via the returned handle) for one-shot behaviour.
3410
+ */
3411
+ on(event: "segment:enter" | "segment:leave", cb: SequenceSegmentSubscriber): () => void;
3412
+ on(event: "label", cb: SequenceLabelSubscriber): () => void;
2890
3413
  /**
2891
3414
  * Append a child animation at `at` (absolute ms, a label, a `"+="`/`"-="`
2892
3415
  * relative token, or — omitted — the running cursor, i.e. after the
2893
3416
  * previous segment). Advances the insertion cursor to this segment's end.
2894
3417
  * Chainable.
2895
3418
  */
2896
- add(animation: Animation_2<V>, at?: SequencePosition): this;
3419
+ add(animation: KeyframesAnimation<V>, at?: SequencePosition): this;
2897
3420
  /**
2898
3421
  * Resolve a {@link SequencePosition} to an absolute ms offset.
2899
3422
  *
@@ -2925,6 +3448,17 @@ export declare class Sequence<V extends Vars = any> {
2925
3448
  * forward-monotone re-anchor window to break (F.W9 §S3 MEASURE-FIRST).
2926
3449
  */
2927
3450
  private _applyAt;
3451
+ /**
3452
+ * Detect and fire segment-lifecycle + label crossings between the previous
3453
+ * painted phase and `phase` — the ONE detector both `seek` (scrub) and
3454
+ * `_frame` (the rAF play loop) drive, so play fires the identical crossings a
3455
+ * scrub would. The detector + the per-event subscriber state live on the
3456
+ * `_events` bus (`./sequence-events`); this thin wrapper threads the segments
3457
+ * and labels the bus reads. The bus updates its own `_prevPhase` on EVERY
3458
+ * call (even the early-exit) so a subscriber registered mid-transport
3459
+ * straddles from the true prior playhead.
3460
+ */
3461
+ private _fireCrossings;
2928
3462
  /**
2929
3463
  * Fold a raw, repeat-extended master clock down to an effective phase in
2930
3464
  * `[0, duration]` per the `repeat`/`yoyo` transport. With `repeat(1)` +
@@ -3038,13 +3572,39 @@ export declare class Sequence<V extends Vars = any> {
3038
3572
  yoyo(on?: boolean): this;
3039
3573
  }
3040
3574
 
3041
- /** A resolved sequence segment: a child animation anchored at an absolute ms offset. */
3575
+ /**
3576
+ * A resolved sequence segment: a child animation anchored at an absolute ms
3577
+ * offset. The shape {@link SequenceEventBus.fire} reads to test segment
3578
+ * membership.
3579
+ */
3042
3580
  export declare interface SequenceEntry<V extends Vars> {
3043
- animation: Animation_2<V>;
3581
+ animation: KeyframesAnimation<V>;
3044
3582
  /** Absolute offset (ms) of this segment's local t=0 on the master clock. */
3045
3583
  at: number;
3046
3584
  }
3047
3585
 
3586
+ /**
3587
+ * The transport-crossing events a `Sequence` fires via {@link Sequence.on} —
3588
+ * the segment-lifecycle pair plus the named-label crossing.
3589
+ *
3590
+ * - `"segment:enter"` — the playhead crossed INTO a segment's
3591
+ * `[at, at + duration)` span (forward across `at`, or backward across the
3592
+ * span's end).
3593
+ * - `"segment:leave"` — the complementary crossing OUT of that span.
3594
+ * - `"label"` — the playhead straddled a position registered via
3595
+ * {@link Sequence.label}, in EITHER direction.
3596
+ *
3597
+ * Mirror of `ScrollSceneEvent` (`scroll-scene.ts:190`) — a typed, per-event
3598
+ * subscribe channel.
3599
+ */
3600
+ export declare type SequenceEvent = "segment:enter" | "segment:leave" | "label";
3601
+
3602
+ /**
3603
+ * A `label` subscriber. Receives the crossed label's `name` and the
3604
+ * master-clock position (ms) at the crossing.
3605
+ */
3606
+ export declare type SequenceLabelSubscriber = (name: string, masterClock: number) => void;
3607
+
3048
3608
  export declare interface SequenceOptions {
3049
3609
  /**
3050
3610
  * When true, `play()` honors `prefers-reduced-motion: reduce` by snapping
@@ -3066,6 +3626,17 @@ export declare interface SequenceOptions {
3066
3626
  */
3067
3627
  export declare type SequencePosition = number | `+=${number}` | `-=${number}` | string;
3068
3628
 
3629
+ /**
3630
+ * A `segment:enter` / `segment:leave` subscriber. Receives the crossing
3631
+ * segment's own `animation` reference and the master-clock position (ms) at the
3632
+ * crossing. The clock lets the consumer infer direction (a backward crossing
3633
+ * arrives with a smaller `masterClock` than the prior call).
3634
+ */
3635
+ export declare type SequenceSegmentSubscriber = (animation: KeyframesAnimation<any>, masterClock: number) => void;
3636
+
3637
+ /** The union over the two subscriber shapes (the {@link Sequence.on} fallthrough). */
3638
+ export declare type SequenceSubscriber = SequenceSegmentSubscriber | SequenceLabelSubscriber;
3639
+
3069
3640
  /**
3070
3641
  * SO-1 SERIALIZE — round-trip a typed `CSSTimelineOptions` BACK to its CSS
3071
3642
  * longhand declarations (`{ "animation-timeline"?, "animation-range"?,
@@ -3328,6 +3899,12 @@ export declare class SpringProgress {
3328
3899
  private omegaD;
3329
3900
  private subscribers;
3330
3901
  private disposed;
3902
+ private vecOrigin;
3903
+ private vecOriginVel;
3904
+ private vecTarget;
3905
+ private vecCurrent;
3906
+ private vecVelocity;
3907
+ private vecElapsed;
3331
3908
  private _playback;
3332
3909
  private _onFrame;
3333
3910
  constructor(options?: Partial<SpringProgressOptions>);
@@ -3390,6 +3967,51 @@ export declare class SpringProgress {
3390
3967
  snap(): void;
3391
3968
  /** Reset position + velocity to a specified value (default 0). */
3392
3969
  reset(value?: number, velocity?: number): void;
3970
+ /**
3971
+ * Re-seat a MULTI-CHANNEL spring vector onto `targets` (one lane per
3972
+ * element), under this spring's `(response, dampingFraction)`. The lanes
3973
+ * ring identically to a scalar `SpringProgress` of the same config — the
3974
+ * solver is the SAME closed form (`evaluateAt`) shared across channels — but
3975
+ * step in ONE `tickVector(dt)` call into one `Float64Array` per tick, the
3976
+ * dispatch/alloc amortization the W122 probe measured at 2.97–3.78× over K
3977
+ * independent scalar instances (ADOPT @ K=8, `proof:spring-vector`).
3978
+ *
3979
+ * First call ARMS the lanes (lazily — a scalar-only spring never allocates
3980
+ * the vector buffers, so the scalar hot path is unchanged). Subsequent calls
3981
+ * re-seat each lane's origin from the lane's CURRENT `(x, v)`, so a mid-flight
3982
+ * target change is continuous per channel — the vector analogue of the scalar
3983
+ * `set target` re-seat. The lane count is fixed by the FIRST `setTargets`
3984
+ * length; a later call with a different length throws (the buffers are
3985
+ * stable references the consumer reads via {@link values}).
3986
+ *
3987
+ * `initialVelocity` (the scalar seed) does NOT carry into the lanes — a fresh
3988
+ * vector starts each lane at rest unless re-seated from prior motion. The
3989
+ * scalar `currentValue` / `target` are untouched; the two modes are
3990
+ * independent surfaces on one solver.
3991
+ */
3992
+ setTargets(targets: Float64Array): void;
3993
+ /**
3994
+ * The shared output lane buffer — the K channels' current values, written
3995
+ * in place by {@link tickVector}. A STABLE reference (never re-allocated
3996
+ * after the first {@link setTargets}); read it after each tick. Returns an
3997
+ * empty `Float64Array` before the first `setTargets` arms the lanes.
3998
+ */
3999
+ get values(): Float64Array;
4000
+ /**
4001
+ * The shared output velocity lane buffer — the K channels' current
4002
+ * velocities, written in place by {@link tickVector}. A STABLE reference;
4003
+ * empty before the first {@link setTargets}.
4004
+ */
4005
+ get velocities(): Float64Array;
4006
+ /**
4007
+ * Advance EVERY lane by `dt` MILLISECONDS — one call, K channels, one buffer
4008
+ * write. The analytic per-channel step is the same closed form `evaluateAt`
4009
+ * uses (the shared `omega`/`zeta`/`omegaD`), with the transcendentals
4010
+ * (`exp`/`cos`/`sin`) hoisted once per tick and reused across lanes — the
4011
+ * amortization the W122 probe measured. No-op (returns the same buffer)
4012
+ * before the first {@link setTargets}, when disposed, or for `dt <= 0`.
4013
+ */
4014
+ tickVector(dt: number): Float64Array;
3393
4015
  /**
3394
4016
  * Subscribe to per-tick updates. Returns an unsubscribe handle.
3395
4017
  * Called with `(value, velocity)` on every `tick`/`snap`/`reset`/
@@ -3719,6 +4341,15 @@ export declare const toEasing: (input: TimingFunction | Easing) => Easing;
3719
4341
 
3720
4342
  export declare type TransformFunction<V extends Vars> = (v: V, t: number) => void;
3721
4343
 
4344
+ /**
4345
+ * Default DOM-style renderer used by `Animation.transform` when no
4346
+ * user-supplied transform is provided. "Is this the default renderer?"
4347
+ * is decided by reference comparison against the Animation instance's
4348
+ * one `_defaultTransform` (`usesDefaultRenderer`) — typed and
4349
+ * bind-proof, not a Symbol tag a wrapper would silently drop.
4350
+ */
4351
+ declare function transformTargetsStyle<V extends Vars>(vars: V, targets: HTMLElement[], flat?: boolean): void;
4352
+
3722
4353
  declare const typewriter: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
3723
4354
 
3724
4355
  declare const typingCursor: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
@@ -3729,6 +4360,81 @@ export declare class UnknownEasingError extends Error {
3729
4360
  constructor(easingName: string);
3730
4361
  }
3731
4362
 
4363
+ /**
4364
+ * `validate(css, opts?)` — the READ-ONLY projection over the three typed channels
4365
+ * onto one {@link ValidateResult} envelope. Async because `compileToCSS` is (its
4366
+ * Prettier pass).
4367
+ *
4368
+ * The pipeline:
4369
+ * 1. `parseCSSStylesheet(css)` → the AST; `parseable` is true when value.js
4370
+ * surfaced at least one recognized item and the resolve raised no
4371
+ * `PARSE_ERROR` (the spec-faithful reality — a dropped `!important` decl is
4372
+ * not a parse failure).
4373
+ * 2. `CSSKeyframesAnimation.fromString(css)` → the parsed animation +
4374
+ * `anim.diagnostics` (the adapter's silent-fallback channel).
4375
+ * 3. `compileToCSS([anim], opts.compile)` → `{ eligible, refusals }`.
4376
+ * 4. `isWAAPIEligible(anim)` → the compositor-thread verdict.
4377
+ */
4378
+ declare function validate(css: string, opts?: ValidateOptions): Promise<ValidateResult>;
4379
+
4380
+ /**
4381
+ * Options for {@link validate} / {@link explain}. A thin pass-through to the
4382
+ * underlying channels — NOT a new option surface. `compile` forwards verbatim to
4383
+ * `compileToCSS` (the ΔE-ε / densify-stop knobs the refusal arm reads).
4384
+ */
4385
+ export declare interface ValidateOptions {
4386
+ /**
4387
+ * Forwarded verbatim to `compileToCSS` — the CC-2 densify-stop count + the
4388
+ * ΔE-ε ship-vs-refuse threshold the perceptual-oklab refusal arm reads. Omit
4389
+ * for the compiler defaults.
4390
+ */
4391
+ compile?: CompileOptions;
4392
+ }
4393
+
4394
+ /**
4395
+ * The flat, agent-shaped envelope `validate` returns — the JOIN over the three
4396
+ * typed channels. An LLM agent branches on these fields WITHOUT scraping a
4397
+ * message string. Every constituent type (`CompileRefusal`, `Diagnostic`,
4398
+ * `WAAPIEligibility`) is already exported from the barrel — the ONLY new type is
4399
+ * this envelope.
4400
+ */
4401
+ export declare interface ValidateResult {
4402
+ /**
4403
+ * True iff value.js parsed the CSS without a `PARSE_ERROR` diagnostic — the
4404
+ * block surfaced at least one recognized stylesheet item (a `@keyframes` /
4405
+ * `@property` / style rule). A spec-invalid keyframe `!important` declaration
4406
+ * is SILENTLY dropped at the AST by value.js (the L.W1 S1 reality) — that drop
4407
+ * is NOT a parse failure, so a block carrying it stays `parseable:true`.
4408
+ */
4409
+ parseable: boolean;
4410
+ /**
4411
+ * True iff `compileToCSS` produced an artifact for every child — the compile
4412
+ * surface's own `eligible` flag. False when any child refused (see
4413
+ * {@link refusals}). Separate from {@link waapi}: a block can be compile-
4414
+ * eligible (the CSS round-trips faithfully) yet WAAPI-ineligible (color
4415
+ * interpolation, computed units) and vice versa.
4416
+ */
4417
+ eligible: boolean;
4418
+ /**
4419
+ * The CC-3 refusals — one per child that could not compile faithfully (the
4420
+ * `{ name, reason, message }` trust surface). Empty on a clean compile.
4421
+ */
4422
+ refusals: CompileRefusal[];
4423
+ /**
4424
+ * All parse/honoring diagnostics from `resolveKeyframes` — every SILENT
4425
+ * fallback the adapter used to swallow, now a citable row with a stable
4426
+ * {@link Diagnostic.code}. Empty on a clean parse.
4427
+ */
4428
+ diagnostics: Diagnostic[];
4429
+ /**
4430
+ * The WAAPI eligibility verdict — `{ eligible: true }` or
4431
+ * `{ eligible: false; reason: string }`. Separate from {@link eligible}: the
4432
+ * compositor-thread delegation has its own, narrower bar (no color interp, no
4433
+ * computed units, a uniform CSS-twinned easing).
4434
+ */
4435
+ waapi: WAAPIEligibility;
4436
+ }
4437
+
3732
4438
  export declare type Vars<T = any> = {
3733
4439
  [arg: string]: number | string | T;
3734
4440
  };
@@ -3755,10 +4461,63 @@ export declare interface VelocityProbe {
3755
4461
  };
3756
4462
  }
3757
4463
 
4464
+ declare type WAAPIEligibility = {
4465
+ eligible: true;
4466
+ } | {
4467
+ eligible: false;
4468
+ reason: string;
4469
+ };
4470
+
4471
+ /**
4472
+ * Fire-and-forget idle-warmer for the heavy engine (L.W7 S1, W121).
4473
+ *
4474
+ * Pre-flights `loadAnimationEngine()`'s dynamic import so the first
4475
+ * `.animate()` / `new CSSKeyframesAnimation()` call on a cold page resolves
4476
+ * against an already-in-flight (or already-resolved) Promise instead of paying
4477
+ * network + parse + compile latency inline. Call it during idle —
4478
+ * `requestIdleCallback`, `visibilitychange`, or `mouseenter` on the app shell:
4479
+ *
4480
+ * ```ts
4481
+ * requestIdleCallback(() => warmEngine());
4482
+ * ```
4483
+ *
4484
+ * Idempotent and value.js-free by construction: it shares the SAME
4485
+ * module-scope `_enginePromise` with `loadAnimationEngine()`, so a
4486
+ * `loadAnimationEngine()` after `warmEngine()` returns the same in-flight
4487
+ * Promise — no double import. It fires a DYNAMIC import only; it names no
4488
+ * static value.js specifier, so `proof:boundary` stays green.
4489
+ *
4490
+ * L.W7 S4 (MEASURE-FIRST — the `scheduler.postTask` adoption is DEFERRED, not
4491
+ * shipped). `scheduler.postTask("background", …)` would be the idiomatic home
4492
+ * for an idle warm, but the `proof:scheduler-posttask` probe only SKIPS in
4493
+ * jsdom (the API is absent there) — it has NOT positively MEASURED that the
4494
+ * `"background"` call does not degrade INP on a real engine. Per the wave's own
4495
+ * measure-first law (and inv ε — no claim without an observed oracle), warmEngine
4496
+ * stays on the PROVEN bare `void loadAnimationEngine()` path. The probe + gate are
4497
+ * ARMED: when a real-browser run (Playwright with `scheduler.postTask`) measures
4498
+ * the background dispatch safe, warmEngine adopts `postTask("background")` then —
4499
+ * a gated future change, not an unmeasured ship today.
4500
+ */
4501
+ export declare const warmEngine: () => void;
4502
+
3758
4503
  declare const warpLeft: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
3759
4504
 
3760
4505
  declare const warpRight: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
3761
4506
 
4507
+ /**
4508
+ * Map a phase ∈ ℝ to its waveform value ∈ [-1, 1]. Pure — the phase is reduced
4509
+ * to its fractional cycle position internally, so a phase outside [0, 1) (e.g. a
4510
+ * raw `t × frequency` from {@link Oscillator.sample}) shapes the same as its
4511
+ * wrapped equivalent. Exported as a value.js-free leaf a consumer can apply to
4512
+ * its own phase without constructing an `Oscillator`.
4513
+ *
4514
+ * - `sine` — `sin(2π·p)`, smooth.
4515
+ * - `triangle` — linear up then down, peaks at `p = 0.25` / `0.75`.
4516
+ * - `square` — `+1` for the first half-cycle, `-1` for the second.
4517
+ * - `sawtooth` — linear ramp `-1 → +1` across the cycle.
4518
+ */
4519
+ export declare function waveformValue(phase: number, waveform: OscillatorWaveform): number;
4520
+
3762
4521
  /**
3763
4522
  * The minimal stepper surface a spring-driven blend weight reads (K.W11
3764
4523
  * PHYS-C). A `SpringProgress` satisfies it structurally (`value` getter +
@@ -3777,4 +4536,18 @@ export declare interface WeightStepper {
3777
4536
  readonly settled: boolean;
3778
4537
  }
3779
4538
 
4539
+ /**
4540
+ * `yieldToMain()` — break a long main-thread task so the browser can service
4541
+ * input/render between slices (INP relief). Used by `AnimationGroup.advanceTo()`
4542
+ * to keep a large group's per-frame composite from monopolizing the main
4543
+ * thread as one long task.
4544
+ *
4545
+ * Baseline-Newly: prefers the native `scheduler.yield()` (continuation runs
4546
+ * at the FRONT of the task queue, so yielding stays cheap); falls back to a
4547
+ * `MessageChannel` macrotask, then `setTimeout(0)` — a ≤20 LOC progressive
4548
+ * fallback per the Baseline browser policy. SSR-safe: resolves immediately
4549
+ * off-DOM (no event loop to yield to that matters for a headless render).
4550
+ */
4551
+ declare function yieldToMain(): Promise<void>;
4552
+
3780
4553
  export { }