@mkbabb/keyframes.js 4.3.0 → 5.0.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,1872 +136,2226 @@ 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. The legacy `Animation`
151
+ * backward-compat alias was DROPPED in 5.0.0 (Q.WE1 — NO-LEGACY).
153
152
  */
154
- private _compiler;
155
- get compiler(): FrameCompiler<V>;
153
+ KeyframesAnimation: typeof KeyframesAnimation;
154
+ CSSKeyframesAnimation: typeof CSSKeyframesAnimation;
155
+ AnimationGroup: typeof AnimationGroup;
156
+ getAnimationId: (animation: KeyframesAnimation | string) => string;
157
+ getTimingFunction: (timingFunction: TimingFunction | TimingFunctionNames | string | undefined) => TimingFunction | undefined;
158
+ resolveKeyframes: (input: string | Stylesheet) => ResolvedKeyframes;
159
+ /** The single-call front door — dispatch + auto-target + auto-play. */
160
+ animate: typeof animate;
161
+ /** CSS-native MotionPath (F.W12) — offset-distance over an author offset-path. */
162
+ MotionPath: typeof MotionPath;
163
+ fromMotionPath: typeof fromMotionPath;
164
+ /** CSS-native DrawSVG (G.W13) — stroke-dashoffset sweep over the path length. */
165
+ DrawSVG: typeof DrawSVG;
166
+ fromDrawSVG: typeof fromDrawSVG;
156
167
  /**
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.
168
+ * MorphSVG (O.W6, the DM-3 7-tranche chronic terminal) — SVG path-shape
169
+ * morphing over value.js's `PathGeometry`. Samples two `d` strings at
170
+ * `samples` uniform arc-length steps, pairs the points, and interpolates the
171
+ * `(x, y)` pairs across `t`; `MorphSVG.sampleD(t)` reads the morphed `d`.
160
172
  */
161
- readonly playback: RAFPlayback;
173
+ MorphSVG: typeof MorphSVG;
174
+ fromMorphSVG: typeof fromMorphSVG;
162
175
  /**
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.
176
+ * The preset library (`fadeIn`, `bounce`, `shake`, …) — heavy (each returns
177
+ * a `CSSKeyframesAnimation`), so it rides the dynamic boundary as a namespace
178
+ * instead of the light static barrel: `const { presets } = await
179
+ * loadAnimationEngine(); presets.fadeIn({ duration: 500 })` (F.W11).
168
180
  */
169
- _waAnimations: globalThis.Animation[];
170
- startTime: number | undefined;
171
- pausedTime: number;
172
- t: number;
173
- iteration: number;
181
+ presets: typeof AnimationPresets;
182
+ DIRECTIONS: readonly AnimationOptions["direction"][];
183
+ FILL_MODES: readonly AnimationOptions["fillMode"][];
184
+ defaultOptions: AnimationOptions;
185
+ defaultLayerConfig: AnimationLayerConfig;
174
186
  /**
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.
187
+ * K.W8 INGEST (FLAGGED ADDITIVE) — the round-trip pointed FORWARD at the
188
+ * live web. `fromStyleSheets`/`fromLiveAnimations`/`resolveLiveKeyframes`
189
+ * walk the CSSOM into kf `CSSKeyframesAnimation` objects (per-sheet CORS
190
+ * `try/catch` → a `CORS_SKIP` diagnostic, never a silent drop); `adoptRunning`
191
+ * takes over a RUNNING CSS animation mid-flight via `getAnimations()`
192
+ * currentTime handoff (the continuity seed, NOT seed-at-zero). HEAVY (the
193
+ * ingest needs the value.js parser) — reached only here, never the LIGHT
194
+ * barrel. Named `adoptRunning` to disambiguate from `engine.adoptCompiled`.
181
195
  */
182
- diagnostics: Diagnostic[];
196
+ fromStyleSheets: typeof fromStyleSheets;
197
+ fromLiveAnimations: typeof fromLiveAnimations;
198
+ resolveLiveKeyframes: typeof resolveLiveKeyframes;
199
+ adoptRunning: typeof adoptRunning;
183
200
  /**
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).
201
+ * K.W9 SCROLL-AS-CSS (FLAGGED ADDITIVE) — the scroll-grammar round-trip
202
+ * (`parseScrollCSS` / `serializeScrollOptions` / `roundTripScrollCSS`,
203
+ * consuming value.js 0.13.0's typed `CSSTimelineOptions` extractor +
204
+ * inverse serializer), the `ScrollScene` JS driver (`createScrollScene`),
205
+ * the conservative-correct backend dispatch (`dispatchScrollBackend`), and
206
+ * the `position:sticky` pin synthesis (`pinCSS`). HEAVY (static value.js
207
+ * edge) — reached only here, never the LIGHT barrel.
192
208
  */
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;
209
+ ScrollScene: typeof ScrollScene;
210
+ createScrollScene: typeof createScrollScene;
211
+ parseScrollCSS: typeof parseScrollCSS;
212
+ parseScrollTimeline: typeof parseScrollTimeline;
213
+ parseScrollRange: typeof parseScrollRange;
214
+ serializeScrollOptions: typeof serializeScrollOptions;
215
+ roundTripScrollCSS: typeof roundTripScrollCSS;
216
+ dispatchScrollBackend: typeof dispatchScrollBackend;
217
+ resolveRange: typeof resolveRange;
218
+ pinCSS: typeof pinCSS;
219
+ /**
220
+ * K.W10 COMPILE (FLAGGED ADDITIVE) — the round-trip's BACKWARD half:
221
+ * `compileToCSS(group | sequence | childList)` → a ZERO-RUNTIME CSS artifact
222
+ * (`@keyframes` + `animation-*` longhands + `animation-composition` layering
223
+ * + `linear()` springs + materialized stagger delays + perceptual `oklab()`
224
+ * densify) PLUS the CC-3 ineligibility report (the four named refusals —
225
+ * `weighted` blend / custom renderers / perceptual oklab beyond densify /
226
+ * computed-unit drift). The compiler is the parser run BACKWARD over the SAME
227
+ * data model (`format.ts` is `keyframes.ts` run backward); a human pastes the
228
+ * result and ships with ZERO kf bytes on the page. HEAVY (value.js-bearing) —
229
+ * reached only here, never the LIGHT barrel.
230
+ */
231
+ compileToCSS: typeof compileToCSS;
232
+ /**
233
+ * L.W6 AGENT-AUTHORING VERB (FLAGGED ADDITIVE) — the round-trip's FORWARD
234
+ * half: the VALIDATION layer over the compile surface, the first question an
235
+ * LLM agent asks before it suggests kf ("will this `@keyframes` block ship
236
+ * faithfully?"). `validate(css, opts?)` is a READ-ONLY projection over three
237
+ * already-typed channels (the adapter `diagnostics`, the compile
238
+ * `{ eligible, refusals }`, the WAAPI `eligibility`) onto ONE agent-shaped
239
+ * `ValidateResult` envelope an LLM branches on WITHOUT scraping a message;
240
+ * `explain(css, opts?)` formats the SAME verdict deterministic human/LLM-
241
+ * readable. NO new engine code — a pure JOIN over the channels L.W1/L.W2 made
242
+ * honest. HEAVY (validate.ts imports the engine + compile + waapi) — reached
243
+ * only here, never the LIGHT barrel.
244
+ */
245
+ validate: typeof validate;
246
+ explain: typeof explain;
247
+ /**
248
+ * L.W8 S1 ED-3 DOGFOOD INVERSION (FLAGGED ADDITIVE) — the heavy
249
+ * serialization/painting/scheduler helpers over a parsed `Animation`.
250
+ * `CSSKeyframesToString`/`CSSKeyframesToStrings` re-serialize the parsed
251
+ * keyframes back to CSS (the FORWARD half of `fromString`, value.js-bearing);
252
+ * `formatCSSKeyframeString` trims one keyframe body for display;
253
+ * `transformTargetsStyle` paints a `Vars` snapshot onto DOM targets (the
254
+ * same painter the run loop drives); `yieldToMain` is the engine's ONE
255
+ * INP-relief yield ladder. HEAVY (they ride the engine chunk) — reached only
256
+ * here, never the LIGHT barrel.
257
+ */
258
+ CSSKeyframesToString: typeof CSSKeyframesToString;
259
+ CSSKeyframesToStrings: typeof CSSKeyframesToStrings;
260
+ formatCSSKeyframeString: typeof formatCSSKeyframeString;
261
+ transformTargetsStyle: typeof transformTargetsStyle;
262
+ yieldToMain: typeof yieldToMain;
263
+ }
264
+
265
+ export declare interface AnimationFrame<V extends Vars> {
266
+ id: number;
267
+ start: ValueUnit;
268
+ ixs: {
269
+ start: number;
270
+ stop: number;
271
+ };
272
+ time: {
273
+ start: number;
274
+ stop: number;
275
+ };
276
+ flatVars: V;
277
+ vars: V;
278
+ interpVars: {
279
+ [arg: string]: Array<InterpolatedVar<V>>;
280
+ };
281
+ /**
282
+ * Pre-flattened array of all interpolation variables across all properties.
283
+ * Built once during parse() to avoid Object.values().flat() allocation
284
+ * on every interpFrames() call in the hot path.
285
+ */
286
+ allInterpVars: Array<InterpolatedVar<V>>;
287
+ /**
288
+ * Q.WB3 S2 — the precomputed numeric SoA fold layout (built ONCE at `parse`
289
+ * over the stable `allInterpVars` set). `processFrame` folds the numeric subset
290
+ * through ONE `lerpArray` over the packed `Float64Array` buffers and strides
291
+ * the result back into the numeric leaves' `.value` slots; the boxed residual
292
+ * (color/computed/mixed) keeps the per-element `lerpValue`. Absent (undefined)
293
+ * for a frame with no numeric ivs, or before `parse` runs — `processFrame`
294
+ * falls back to the all-boxed walk. Bit-identical to the boxed path.
295
+ */
296
+ _numericPlan?: NumericFoldPlan<V>;
297
+ transform: TransformFunction<V>;
298
+ timingFunction: Easing;
299
+ /**
300
+ * The compiled per-segment `animation-composition` operator (K.W7). A
301
+ * segment runs from a START stop to a STOP stop; the operator is the STOP
302
+ * stop's declared composition (CSS attaches `animation-composition` to the
303
+ * keyframe being composited TOWARD). `replace` (or omission) is the legacy
304
+ * behaviour — the apply writes the lerped value verbatim. `add` accumulates
305
+ * the lerped numeric leaf onto the captured underlying base (un-clamped,
306
+ * element-wise — the same leaf `group.ts`'s `add` layer runs); `accumulate`
307
+ * is repeat-aware (iteration N stacks onto N−1's end). A non-numeric leaf
308
+ * (color, `<custom-ident>`) `replace`-falls-back AND emits a
309
+ * `COMPOSITION_FALLBACK` diagnostic — never a silent wrong pixel.
310
+ */
311
+ composition?: CompositeOperator;
312
+ }
313
+
314
+ export declare class AnimationGroup<V extends Vars> {
315
+ animations: AnimationGroupObject<V>;
316
+ /**
317
+ * The group's composite transform. Defaults to a real no-op at the FIELD
318
+ * (I.W0 S3) — NOT a lying definite-assignment assertion: a childless or
319
+ * pre-`parse()` group composites nothing via a harmless no-op instead of
320
+ * throwing `this.transform is not a function`. The constructor overrides it
321
+ * with the first child's transform when one exists.
322
+ */
323
+ transform: TransformFunction<V>;
324
+ superKey: string | undefined;
325
+ paused: boolean;
202
326
  started: boolean;
203
327
  done: boolean;
204
- reversed: boolean;
205
- paused: boolean;
206
328
  /**
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.
329
+ * When true, `play()` honors `prefers-reduced-motion: reduce` by snapping
330
+ * every child to its final frame in a single composite instead of running
331
+ * the rAF draw loop. SSR-safe off-DOM. Default false.
211
332
  */
212
- managed: boolean;
333
+ respectReducedMotion: boolean;
213
334
  /**
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.
335
+ * Children-per-slice before `advanceTo()` yields to the main thread. Groups
336
+ * at or under this size tick in one slice (fast path); larger groups tick in
337
+ * batches with a `scheduler.yield()` between them (INP relief).
217
338
  */
218
- waapiIneligibleReason: string | undefined;
219
- unflatten: boolean;
220
- private resolvePromise;
339
+ static readonly YIELD_BATCH = 32;
340
+ singleTarget: boolean;
341
+ lastTickTime: number;
342
+ /** THE rAF owner for the group's draw loop. */
343
+ readonly playback: RAFPlayback;
344
+ resolvePromise: ((value: void | PromiseLike<void>) => void) | null;
221
345
  private _playingPromise;
346
+ /** Pre-bound frame callback — allocated once to avoid a per-loop closure. */
347
+ private _boundFrame;
348
+ /** Cached entries sorted by layer zIndex (see `getEntries`). */
349
+ private _entries;
350
+ private _entriesDirty;
222
351
  /**
223
- * Pre-bound frame callback — allocated once to avoid creating a new
224
- * closure on every playback loop start.
352
+ * Long-lived composite buffer, cleared in place at the top of
353
+ * `transformFramesGrouped` (the zero-alloc idiom `interpFrames`'s `out` buffer
354
+ * uses) — no fresh object allocated per frame.
225
355
  */
226
- private _boundFrame;
356
+ private _grouped;
227
357
  /**
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.
358
+ * The compile-stable union of every child's contributed (whitelist-filtered)
359
+ * keys — what `_grouped` is null-filled to each frame so the composite clears
360
+ * WITHOUT `delete` (F.W4 S2: the delete-loop trapped `_grouped` in V8
361
+ * dictionary mode). Recomputed only on a structural change; the fold lives in
362
+ * `group-layer-springs`.
235
363
  */
236
- private _interpOut;
364
+ private _groupedKeys;
365
+ private _groupedKeysDirty;
237
366
  /**
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.
367
+ * P.W2 — the SoA composite layout for the `add`/`weighted` blend arms (the
368
+ * validated 3.7× — `scripts/soa-composite-decision.json`, bit-identical
369
+ * `maxErr=0`). One {@link SoALayerPlan} per `add`/`weighted` entry: the FLAT
370
+ * list of pure-numeric `(carrier, incoming)` `ValueUnit<number>` pairs that
371
+ * blend would touch, hoisted out of the per-frame `for..in` + `Array.isArray`
372
+ * + per-element `isNumericUnit` dispatch into a contiguous {@link Float64Array}
373
+ * fold. Built by {@link buildSoAPlans} (INTERNAL, `./group-soa`). Rebuilt ONLY
374
+ * on a structural change (alongside `_groupedKeys`), NEVER per frame. The
375
+ * `replace` default arm is dispatch-free and carries NO plan; the non-numeric
376
+ * (color/computed/string/mixed) tail keeps the boxed per-element path. The
377
+ * probe (`carrier-probe`) proved `interpFrames` MUTATES each leaf
378
+ * `ValueUnit.value` IN PLACE, so the carrier + incoming refs are STABLE across
379
+ * frames — the plan is valid until the entry set / a layer whitelist / a blend
380
+ * mode changes (every such mutation routes through `invalidateEntries`).
381
+ */
382
+ private _soaPlans;
383
+ /**
384
+ * The long-lived SoA fold scratch — the contiguous numeric accumulate buffer
385
+ * the `add`/`weighted` fold seeds, folds, and writes back through. Sized to
386
+ * the WIDEST single-layer numeric pair count once per structural change
387
+ * (reused across layers AND frames — zero per-frame alloc, the F.W4 zero-alloc
388
+ * discipline). `null` until the first plan with numeric pairs is built.
389
+ */
390
+ private _compositeBuf;
391
+ /**
392
+ * K.W11 PHYS-C — true iff ANY layer currently carries a `weightSpring`. The
393
+ * fast-path guard: when false (the universal case) `advanceTo` skips the
394
+ * per-frame spring scan entirely, so the constant-weight blend hot path takes
395
+ * ZERO new work. Set true by `transitionLayer`; recomputed false once every
396
+ * driving spring has settled.
245
397
  */
246
- private _stableKeys;
398
+ private _hasLayerSprings;
399
+ constructor(...inputs: (KeyframesAnimation<V> | AnimationGroupInput<V>)[]);
247
400
  /**
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).
401
+ * The animation entries sorted by layer zIndex, dirty-flag cached — rebuilt
402
+ * only when the animations object or a layer config is mutated. All hot-path
403
+ * iteration uses this instead of `Object.values()`.
251
404
  */
252
- protected _ctorOptions: Partial<InputAnimationOptions>;
253
- /** The compile-stable union of this animation's interpolated keys. */
254
- get flatKeys(): readonly string[];
405
+ private getEntries;
406
+ /** Mark entries cache stale. Called at all mutation boundaries. */
407
+ private invalidateEntries;
408
+ setSuperKey(superKey: string): this;
409
+ setTargets(...targets: HTMLElement[]): this;
410
+ onStart(): this;
411
+ onEnd(): this;
255
412
  /**
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.
413
+ * Composite all animation values into a single grouped transform (per-frame
414
+ * for single-target groups). Applies layer blending (replace / add /
415
+ * weighted) in zIndex order, then calls the group transform with the merged
416
+ * values. Each child's values refresh in place (`interpFrames` clears and
417
+ * rewrites the long-lived buffer), so no stale keys leak and no fresh object
418
+ * is allocated per entry per frame.
261
419
  */
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;
420
+ transformFramesGrouped(t: number): Record<string, unknown>;
276
421
  /**
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.
422
+ * The boxed `add`/`weighted` blend arm — the per-element AoS path that the
423
+ * SoA fold (`soaBlendLayer`) supplants for the pure-numeric majority. Kept as
424
+ * THE blend implementation for two roles: (1) the plan-build frame (every key,
425
+ * `only === undefined`) — it establishes the carriers `buildSoAPlans` then
426
+ * captures; (2) the per-frame residual (the plan's `boxedKeys` — non-numeric /
427
+ * mixed / first-touch leaves the fold cannot cover, typically empty). Both
428
+ * arms guard on `Array.isArray(existing) && Array.isArray(incoming)` and loop
429
+ * `Math.min(existing.length, incoming.length)` elements with a per-element
430
+ * `isNumericUnit` guard — the byte-exact G.W17 leaf contract (proof:blend),
431
+ * un-clamped `add` (`+=`), spring-weighted `lerp`. A non-array carrier (or a
432
+ * skipped key) falls through to `groupedValues[key] = incoming`.
433
+ */
434
+ private boxedBlendArm;
435
+ /**
436
+ * P.W2 — the SoA fold for ONE `add`/`weighted` layer (the validated 3.7×,
437
+ * `scripts/soa-composite-decision.json`, bit-identical `maxErr=0`). A thin
438
+ * delegating wrapper over {@link groupSoABlendLayer} (the fold body lives in
439
+ * `./group-soa`, Q.WF2): the wrapper forwards the group's `_compositeBuf`
440
+ * scratch + the plan. The instance METHOD is kept (not inlined at the call
441
+ * site) so `proof:soa-composite`'s `soa-path-taken` clause can monkey-patch
442
+ * `group.soaBlendLayer` on the instance to count fold invocations.
443
+ */
444
+ private soaBlendLayer;
445
+ /**
446
+ * Render the current composition as a static frame at each child's current
447
+ * `t`. Single-target groups go through the blended transform; multi-target
448
+ * groups apply each child's interpolated vars to its own targets. The public
449
+ * entry point for state mutated outside the rAF loop (scrubbing, state
450
+ * restore, pause snapshots) that needs the visual to update immediately.
283
451
  */
284
- private computeHasComposition;
285
- /**
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.
306
- */
307
- adoptCompiled(source: Animation_2<V>): this;
308
- /**
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).
313
- */
314
- private computeStableKeys;
452
+ render(): void;
315
453
  /**
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.
454
+ * Set a child animation's current time without touching its siblings.
455
+ * Updates `pausedTime` so the child resumes correctly from the scrub
456
+ * position. Chainable; call `render()` afterwards to reflect it visually.
324
457
  */
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;
458
+ setChildTime(nameOrAnim: string | KeyframesAnimation<V>, t: number): this;
339
459
  /**
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.
460
+ * Advance all child animations to absolute clock `t`. SYNC on the steady
461
+ * path (J.W6 S1): children that all step synchronously advance the group
462
+ * with no per-frame `Promise.all`/microtask hop; a thenable only on a
463
+ * genuinely-async child or the over-`YIELD_BATCH` yield path.
346
464
  */
347
- get restPosition(): "initial" | "final";
348
- /** Paint the rest frame per the fill contract. */
349
- paintRest(): void;
465
+ advanceTo(t: number): this | Promise<this>;
466
+ /** The post-advance tail — `onEnd` once the render marked done. */
467
+ private _endAdvance;
350
468
  /**
351
- * Stateless progress query. Maps [0,1] from first keyframe to last,
352
- * regardless of playback direction. `apply=true` invokes transform callbacks.
469
+ * One frame of the group's draw loop (driven by `RAFPlayback.loop`): ticks
470
+ * all children, then renders (single-target: grouped blending; multi-target:
471
+ * per-child). Returns whether the loop should continue.
353
472
  */
354
- at(progress: number, apply?: boolean): Record<string, ValueUnit[]>;
473
+ private _frame;
474
+ /** The post-advance render half of `_frame` — composite, or settle. */
475
+ private _renderFrame;
476
+ private _resolvePlay;
355
477
  /**
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
478
+ * The completion front-door (G.W13) — `await group.finished` resolves once
479
+ * the in-flight composite play settles. Exposes the ONE held
480
+ * `_playingPromise` `play()` constructs (the re-entrant guard returns it;
481
+ * the `finally`-clear nulls it on settle) — NOT a second completion
482
+ * lifecycle. A settled (or never-played) group resolves immediately.
370
483
  */
371
- interpFrames(t: number, transformFrames?: boolean, out?: Record<string, ValueUnit[]>): Record<string, ValueUnit[]>;
484
+ get finished(): Promise<void>;
372
485
  /**
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.
486
+ * Start the animation group. Resolves when all children complete (or on
487
+ * explicit stop/reset). Re-entrant: a `play()` while one is in flight
488
+ * returns the same promise rather than leaking a second draw loop. Under
489
+ * `respectReducedMotion` + an active query, snaps every child to its final
490
+ * frame in a single composite (no rAF loop), then settles as a completed
491
+ * play would.
382
492
  */
383
- private clearBuffer;
493
+ play(): Promise<void>;
384
494
  /**
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).
495
+ * `prefers-reduced-motion` snap: rest = final, paint it, settle — the SAME
496
+ * terminal path a completed play takes, motion elided. Every child advances
497
+ * to its final frame, one composite paints, `settle()` readies the group for
498
+ * replay (final frame stays on the target(s), matching `Animation`'s snap).
391
499
  */
392
- private processFrame;
500
+ private _playReducedMotion;
393
501
  /**
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.
502
+ * Pause the group — idempotent. Pausing an already-paused (or
503
+ * not-yet-started) group is a no-op, NOT a resume (use {@link toggle} for
504
+ * the explicit flip). Cancels the rAF loop immediately and renders a
505
+ * final-frame snapshot so the visual matches the exact pause moment.
414
506
  */
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;
507
+ pause(): this;
440
508
  /**
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.
509
+ * Resume the group — idempotent. Unpauses every child DIRECTLY (not via
510
+ * `child.resume()`, which would start each child's own rAF loop — the
511
+ * group's draw loop owns the ticking) and re-registers that loop.
452
512
  */
453
- advanceTo(t: number): number | Promise<number>;
454
- /** The post-start advance body — pause clock, local time, iteration end. */
455
- private _advance;
513
+ resume(): this;
514
+ /** The explicit flip: pauses if playing, resumes if paused. */
515
+ toggle(): this;
456
516
  /**
457
- * One frame of the standalone rAF play path, driven by the shared
458
- * `RAFPlayback.loop`. Returns whether the loop should continue.
517
+ * Pure state teardown — never paints. Releases every child
518
+ * (`managed = false`, `child.settle()`) and clears the group's playback
519
+ * flags. Completion and the reduced-motion snap both end here, leaving the
520
+ * rest frame on the target(s).
459
521
  */
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;
466
- /**
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.
475
- */
476
- private _playWAAPI;
522
+ settle(): this;
477
523
  /**
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.
524
+ * Explicit rewind: paint every started child back to its INITIAL frame, then
525
+ * settle — the user-facing "return to start". Completion does NOT come here
526
+ * (it settles where the fill contract rested the pixels).
482
527
  */
483
- private _cancelWAAPI;
528
+ reset(): this;
484
529
  /**
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.
530
+ * Halt the draw loop, rewind to the initial frame (the transport-stop
531
+ * semantic the demo's controls expect), and resolve any pending `play()`.
490
532
  */
491
- private _playReducedMotion;
533
+ stop(): this;
534
+ playing(): boolean;
535
+ forcePause(): void;
536
+ forcePlay(): void;
492
537
  /**
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.
538
+ * Set layer config for an animation by name or reference. Chainable; throws
539
+ * on an unregistered key (silent no-ops were hiding consumer bugs).
501
540
  */
502
- private _snapToReducedMotion;
541
+ setLayerConfig(nameOrAnim: string | KeyframesAnimation<V>, config: Partial<AnimationLayerConfig>): this;
542
+ /** Convenience toggle for enabling/disabling a layer. Chainable. */
543
+ setLayerEnabled(nameOrAnim: string | KeyframesAnimation<V>, enabled: boolean): this;
544
+ /** Read the layer config for an animation by name or reference. */
545
+ getLayerConfig(nameOrAnim: string | KeyframesAnimation<V>): AnimationLayerConfig | undefined;
546
+ /**
547
+ * Spring a layer's blend `weight` from its CURRENT value to `weight` (K.W11
548
+ * PHYS-C — the spring-driven crossfade). Seeds a `SpringProgress` (via
549
+ * `seedLayerSpring`), parks it on `layer.weightSpring`, and forces
550
+ * `blendMode` to `weighted`. A re-target mid-flight RE-SEATS the in-flight
551
+ * spring from its live `(value, velocity)` (`set target`) — no kink. Full
552
+ * trajectory documentation in `./group-layer-springs`. Chainable.
553
+ */
554
+ transitionLayer(nameOrAnim: string | KeyframesAnimation<V>, target: {
555
+ weight: number;
556
+ spring?: LayerTransitionSpring;
557
+ }): this;
503
558
  /**
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.
559
+ * Physically crossfade between two layers (K.W11 PHYS-C): spring layer `a`
560
+ * down to weight `0` and layer `b` up to weight `1`, each over its own
561
+ * `SpringProgress`. Two `transitionLayer` calls — the flagship demo moment, a
562
+ * crossfade that overshoots and settles. Chainable.
512
563
  */
513
- get finished(): Promise<void>;
514
- play(): Promise<void>;
564
+ crossfade(a: string | KeyframesAnimation<V>, b: string | KeyframesAnimation<V>, options?: {
565
+ spring?: LayerTransitionSpring;
566
+ }): this;
515
567
  /**
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.
568
+ * Advance every spring-driven layer weight by the frame delta `dt` ms (K.W11
569
+ * PHYS-C). Called from `advanceTo` ONLY when `_hasLayerSprings` is true, so
570
+ * the constant-weight path pays nothing. On settle the converged value
571
+ * commits to the constant `layer.weight` and the spring is CLEARED — the
572
+ * `weighted` leaf's `?? layer.weight` read then serves the constant.
519
573
  */
520
- pause(): this;
521
- resume(): this;
522
- /** The explicit flip: pauses if playing, resumes if paused. */
523
- toggle(): this;
574
+ private advanceLayerSprings;
575
+ }
576
+
577
+ export declare interface AnimationGroupEntry<V extends Vars> {
578
+ animation: KeyframesAnimation<V>;
579
+ values: Record<string, unknown>;
580
+ layer: AnimationLayerConfig;
581
+ }
582
+
583
+ /** Input type for AnimationGroup constructor — bare Animation or Animation with layer config. */
584
+ declare type AnimationGroupInput<V extends Vars> = KeyframesAnimation<V> | {
585
+ animation: KeyframesAnimation<V>;
586
+ layer?: Partial<AnimationLayerConfig>;
587
+ };
588
+
589
+ declare interface AnimationGroupObject<V extends Vars> {
590
+ [key: string]: AnimationGroupEntry<V>;
591
+ }
592
+
593
+ export declare interface AnimationLayerConfig {
594
+ /** Higher wins. Default: 0 */
595
+ zIndex: number;
596
+ /** 0–1 for 'weighted' blend mode. Default: 1 */
597
+ weight: number;
524
598
  /**
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.
599
+ * Optional spring (or any {@link WeightStepper}) DRIVING this layer's
600
+ * blend `weight` (K.W11 PHYS-C — the spring-driven crossfade). When
601
+ * present the `weighted` blend leaf reads `weightSpring.value` in place of
602
+ * the constant `weight` (one nullish read; the per-frame lerp untouched),
603
+ * so a layer transition follows a PHYSICAL trajectory that can overshoot
604
+ * and settle — the flagship demo moment only kf's weighted-blend substrate
605
+ * can hold. Constructed + advanced by `AnimationGroup.transitionLayer` /
606
+ * `crossfade`; cleared on settle, when the read falls back to the
607
+ * now-updated constant `weight`. Absent on a static-weight layer (the
608
+ * read is `?? layer.weight`), so the constant path is byte-unchanged.
528
609
  */
529
- stop(): void;
530
- playing(): boolean;
531
- /** Returns the effective time accounting for direction reversal. */
532
- get effectiveT(): number;
610
+ weightSpring?: WeightStepper;
533
611
  /**
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.
612
+ * Default: 'replace'. Defaulting on a genuinely-omitted blend mode is
613
+ * the sanctioned contract (the fail-explicit seam throws only on
614
+ * malformed PRESENT input, never on omission) — an unspecified layer
615
+ * blends by replacement, the least-surprising composite.
539
616
  */
540
- settle(): this;
617
+ blendMode: BlendMode;
618
+ /** Layer toggle. Default: true */
619
+ enabled: boolean;
620
+ /** Optional property whitelist — only these properties will be output from this layer */
621
+ properties?: Set<string>;
622
+ }
623
+
624
+ /** Thrown when an animation option receives malformed (non-undefined) input. */
625
+ export declare class AnimationOptionError extends Error {
626
+ readonly option: string;
627
+ readonly value: unknown;
541
628
  /**
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.
629
+ * Stable structured reason for programmatic consumers — branch on this,
630
+ * never on the human message. Carried only by the two named rows
631
+ * ({@link AnimationOptionErrorCode}); undefined otherwise.
546
632
  */
547
- reset(): this;
548
- setTargets(...targets: HTMLElement[]): this;
549
- group(...animations: Animation_2<V>[]): AnimationGroup<V>;
633
+ readonly code?: AnimationOptionErrorCode;
634
+ constructor(option: string, value: unknown, reason: string, code?: AnimationOptionErrorCode);
550
635
  }
551
- export { Animation_2 as Animation }
552
636
 
553
637
  /**
554
- * The value.js-bearing engine surface, resolved through `loadAnimationEngine()`.
638
+ * Typed option-validation errors — the fail-explicit seam.
555
639
  *
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.
640
+ * The engine's option setters and the light engines' easing inputs THROW on
641
+ * malformed input rather than silently defaulting or no-oping — the posture
642
+ * the layer API already chose ("silent no-ops were hiding consumer bugs",
643
+ * `group.ts` setLayerConfig). Defaulting happens only for genuine
644
+ * `undefined`: an omitted option means "use the default"; a
645
+ * present-but-malformed option is a consumer bug and surfaces as one of
646
+ * these.
647
+ *
648
+ * Value.js-free: light modules import these without touching the boundary.
560
649
  */
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;
576
- /**
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).
581
- */
582
- presets: typeof AnimationPresets;
583
- DIRECTIONS: readonly AnimationOptions["direction"][];
584
- FILL_MODES: readonly AnimationOptions["fillMode"][];
585
- defaultOptions: AnimationOptions;
586
- defaultLayerConfig: AnimationLayerConfig;
587
- /**
588
- * K.W8 INGEST (FLAGGED ADDITIVE) — the round-trip pointed FORWARD at the
589
- * live web. `fromStyleSheets`/`fromLiveAnimations`/`resolveLiveKeyframes`
590
- * walk the CSSOM into kf `CSSKeyframesAnimation` objects (per-sheet CORS
591
- * `try/catch` → a `CORS_SKIP` diagnostic, never a silent drop); `adoptRunning`
592
- * takes over a RUNNING CSS animation mid-flight via `getAnimations()`
593
- * currentTime handoff (the continuity seed, NOT seed-at-zero). HEAVY (the
594
- * ingest needs the value.js parser) — reached only here, never the LIGHT
595
- * barrel. Named `adoptRunning` to disambiguate from `engine.adoptCompiled`.
596
- */
597
- fromStyleSheets: typeof fromStyleSheets;
598
- fromLiveAnimations: typeof fromLiveAnimations;
599
- resolveLiveKeyframes: typeof resolveLiveKeyframes;
600
- adoptRunning: typeof adoptRunning;
650
+ /**
651
+ * The stable, machine-branchable reasons a typed option error can carry
652
+ * (J.W1 S8, K3-internal). EXACTLY the two engine-internal rows the
653
+ * ingestion lane folds into J.W1 — a structured `code` ON the typed throw,
654
+ * NOT a diagnostics channel (the full `Diagnostic[]` surface stays a K.W0
655
+ * seed item):
656
+ *
657
+ * - `EMPTY_PARSE` — a blank/whitespace-only keyframe selector reached the
658
+ * compile seam (the H-A2 "......" class, named).
659
+ * - `UNKNOWN_TIMING_FN` — a present-but-unresolvable timing function (not a
660
+ * callable, a registry name, or a cubic-bezier()/steps() literal).
661
+ * - `NAMED_SELECTOR_NO_TIMELINE` — a scroll-range named selector
662
+ * (`entry`/`exit`/`cover`/`contain`) was accepted at ingest (L.W1 S4), but a
663
+ * numeric `%` position was genuinely demanded with NO `ScrollTimeline`/
664
+ * `ManualTimeline` present to map the phase. A named selector is only
665
+ * meaningful in a scroll context; resolving it to a number outside one is a
666
+ * consumer bug, so the deferred resolve refuses with this code rather than
667
+ * inventing a position. (The bare-ingest floor — accept + preserve, no
668
+ * resolution demanded — never throws.)
669
+ */
670
+ declare type AnimationOptionErrorCode = "EMPTY_PARSE" | "UNKNOWN_TIMING_FN" | "NAMED_SELECTOR_NO_TIMELINE";
671
+
672
+ export declare type AnimationOptions = {
673
+ duration: number;
674
+ delay: number;
675
+ iterationCount: number;
676
+ direction: (typeof DIRECTIONS)[number];
677
+ fillMode: (typeof FILL_MODES)[number];
678
+ timingFunction: Easing;
679
+ useWAAPI: boolean;
601
680
  /**
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.
681
+ * When true, honor `prefers-reduced-motion: reduce` by snapping the
682
+ * `Animation`/`AnimationGroup` `play()` path to the final frame in a
683
+ * single paint instead of running the rAF/WAAPI loop. SSR-safe no-op
684
+ * off-DOM. Default false (consumers opt in).
609
685
  */
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;
686
+ respectReducedMotion: boolean;
687
+ colorSpace: ColorSpace;
688
+ hueMethod?: HueInterpolationMethod;
620
689
  /**
621
- * K.W10 COMPILE (FLAGGED ADDITIVE) — the round-trip's BACKWARD half:
622
- * `compileToCSS(group | sequence | childList)` → a ZERO-RUNTIME CSS artifact
623
- * (`@keyframes` + `animation-*` longhands + `animation-composition` layering
624
- * + `linear()` springs + materialized stagger delays + perceptual `oklab()`
625
- * densify) PLUS the CC-3 ineligibility report (the four named refusals —
626
- * `weighted` blend / custom renderers / perceptual oklab beyond densify /
627
- * computed-unit drift). The compiler is the parser run BACKWARD over the SAME
628
- * data model (`format.ts` is `keyframes.ts` run backward); a human pastes the
629
- * result and ships with ZERO kf bytes on the page. HEAVY (value.js-bearing) —
630
- * reached only here, never the LIGHT barrel.
631
- */
632
- compileToCSS: typeof compileToCSS;
690
+ * The LAYER-level `animation-composition` operator (L.W1 S5, Band A) — the
691
+ * round-trip field for an authored `animation-composition: add` that arrived
692
+ * through a sibling `.class { animation: … }` shorthand/longhand ingest.
693
+ * Distinct from the per-KEYFRAME {@link TemplateAnimationFrame.composition}
694
+ * (the per-stop operator); this is the whole-animation composite the engine
695
+ * carries off `extractAnimationOptions`'s `composition` field. Omission means
696
+ * `replace` (the CSS default — the serializer omits it). value.js 0.13.0's
697
+ * `CSSAnimationOptions.composition` surfaces it; `fromString` reads it here.
698
+ */
699
+ composite?: CompositeOperator;
700
+ /**
701
+ * `animation-iteration-composite` (CSS Animations L2). BOOKED, not
702
+ * implemented: the L2 draft marks this property experimental — there is no
703
+ * stable value.js parse for it and no honoring path in the engine. The field
704
+ * is a typed `never` placeholder (a named tripwire): a future
705
+ * silently-WRONG implementation that tries to assign anything to it reddens
706
+ * the type check, forcing the implementation to land alongside a real
707
+ * `proof:iteration-composite-baseline` gate rather than sliding in unproven.
708
+ */
709
+ iterationComposite?: never;
710
+ };
711
+
712
+ declare namespace AnimationPresets {
713
+ export {
714
+ fadeIn,
715
+ fadeOut,
716
+ pulse,
717
+ shake,
718
+ bounce,
719
+ flipPreset,
720
+ rotateIn,
721
+ slideIn,
722
+ heartbeat,
723
+ glow,
724
+ typewriter,
725
+ rainbowText,
726
+ warpLeft,
727
+ warpRight,
728
+ blurIn,
729
+ blurOut,
730
+ blurInOut,
731
+ progressBar,
732
+ skeletonLoading,
733
+ textFocusBlur,
734
+ gradientBackground,
735
+ rotateScale,
736
+ typingCursor,
737
+ accordionExpand,
738
+ notificationBounce,
739
+ spinner,
740
+ parallaxScroll,
741
+ slideInLeftKeyframes,
742
+ slideInLeft,
743
+ slideOutLeft,
744
+ slideInRightKeyframes,
745
+ slideInRight,
746
+ slideOutRight,
747
+ hover,
748
+ jumpUp,
749
+ jumpDown,
750
+ springScaleIn,
751
+ springSlideIn,
752
+ springPop,
753
+ springWobble,
754
+ enterPresets,
755
+ exitPresets,
756
+ attentionPresets,
757
+ loopPresets,
758
+ presetTaxonomy
759
+ }
633
760
  }
634
761
 
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
- };
762
+ export { AnimationRangeValue }
763
+
764
+ export { AnimationTimelineValue }
765
+
766
+ /** Attention animations — a one-shot nudge to draw the eye. */
767
+ declare const attentionPresets: {
768
+ readonly pulse: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
769
+ readonly shake: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
770
+ readonly bounce: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
771
+ readonly flip: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
772
+ readonly notificationBounce: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
773
+ readonly springPop: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
774
+ readonly springWobble: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
775
+ };
776
+
777
+ export declare type BlendMode = "replace" | "add" | "weighted";
778
+
779
+ declare const blurIn: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
780
+
781
+ declare const blurInOut: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
782
+
783
+ declare const blurOut: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
784
+
785
+ declare const bounce: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
786
+
787
+ /** The compile result — the artifact + the CC-3 ineligibility report. */
788
+ export declare interface CompiledCSS {
651
789
  /**
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.
790
+ * The zero-runtime CSS artifact — `@keyframes` blocks + `.class { animation }`
791
+ * rules. Empty string when EVERY child refused (then `refusals` carries the
792
+ * whole story).
655
793
  */
656
- allInterpVars: Array<InterpolatedVar<V>>;
657
- transform: TransformFunction<V>;
658
- timingFunction: Easing;
794
+ css: string;
659
795
  /**
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.
796
+ * True iff EVERY walked child compiled faithfully. False when one or more
797
+ * refused — `refusals` names each, and the JS playback is the only faithful
798
+ * path for those.
670
799
  */
671
- composition?: CompositeOperator;
800
+ eligible: boolean;
801
+ /** The CC-3 refusals — one per child that could not compile faithfully. */
802
+ refusals: CompileRefusal[];
672
803
  }
673
804
 
674
- export declare class AnimationGroup<V extends Vars> {
675
- animations: AnimationGroupObject<V>;
805
+ /** The input shapes `compileToCSS` accepts. */
806
+ export declare type CompileInput<V extends Vars = any> = AnimationGroup<V> | Sequence<V> | ReadonlyArray<KeyframesAnimation<V> | {
807
+ animation: KeyframesAnimation<V>;
808
+ }>;
809
+
810
+ /** Options for {@link compileToCSS}. */
811
+ export declare interface CompileOptions {
676
812
  /**
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.
813
+ * Per-child stagger delays (ms), index-aligned with the walked children —
814
+ * the materialized output of `stagger.delays(total)`. CC-1 emits these as
815
+ * literal per-child `animation-delay`, expressing an eased origin-aware
816
+ * curve `sibling-index()` cannot (the universal literal-delay form;
817
+ * `@supports (sibling-index)` is CC-6 BOOK, not the default).
683
818
  */
684
- transform: TransformFunction<V>;
685
- superKey: string | undefined;
686
- paused: boolean;
687
- started: boolean;
688
- done: boolean;
819
+ staggerDelays?: readonly number[];
689
820
  /**
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.
821
+ * CC-2 — the oklab densify stop count (the N intermediate `oklab()` stops
822
+ * baked per color segment, INCLUSIVE of endpoints). Default
823
+ * {@link DEFAULT_DENSIFY_STOPS}. Raise it for a longer color arc; the ΔE
824
+ * proof decides ship-vs-refuse.
693
825
  */
694
- respectReducedMotion: boolean;
826
+ densifyStops?: number;
695
827
  /**
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.
828
+ * CC-2 — the ΔE-ε ship-vs-refuse threshold (the perceptual-distance band the
829
+ * densified `oklab()` stops must hold against kf's JS lerp). Default
830
+ * {@link DEFAULT_DELTA_E_EPSILON}. A track whose densify exceeds this REFUSES
831
+ * with the perceptual-oklab reason (a drifting densify is worse than an
832
+ * honest refusal).
838
833
  */
839
- get finished(): Promise<void>;
840
- play(): Promise<void>;
834
+ deltaEEpsilon?: number;
835
+ /** Prettier print-width for the emitted artifact. Omit for the default. */
836
+ printWidth?: number;
837
+ }
838
+
839
+ /** A single refusal — the child name + a typed reason + a human message. */
840
+ export declare interface CompileRefusal {
841
+ /** The compiled child's class/animation name. */
842
+ name: string;
843
+ reason: CompileRefusalReason;
844
+ /** The verbatim message the demo's ineligibility UI shows (CC-4). */
845
+ message: string;
846
+ }
847
+
848
+ /**
849
+ * The reason a child could not compile faithfully. Generalizes
850
+ * `waapiIneligibleReason` to the CSS-compile domain — the trust surface. Each
851
+ * names the kf axis that exceeds pure CSS (the refusal is marketing for the
852
+ * moat). A refused child's JS playback is the only faithful path.
853
+ */
854
+ export declare type CompileRefusalReason = "weighted-blend" | "custom-renderer" | "perceptual-oklab" | "computed-unit-drift";
855
+
856
+ /**
857
+ * The COMPILER surface (L.W7 S3 `loadCompiler()`) — the engine core PLUS the
858
+ * round-trip's BACKWARD half, `compileToCSS`. A consumer compiling an
859
+ * orchestration graph to zero-runtime CSS pays for `engine` + `compile`, not
860
+ * the ingest / motion / draw / preset weight.
861
+ */
862
+ export declare interface CompilerSurface extends EngineCore {
863
+ compileToCSS: typeof compileToCSS;
864
+ }
865
+
866
+ /**
867
+ * THE compiler (CC-1/CC-2/CC-3) — compile an orchestration graph to zero-runtime
868
+ * CSS. Walks the input (`AnimationGroup` / `Sequence` / child list), emits one
869
+ * `@keyframes` + one `animation` shorthand per child (the `replace`/`add`
870
+ * layering as `animation-composition`, springs as `linear()`, stagger delays
871
+ * materialized, computed units verbatim, color tracks densified into perceptual
872
+ * `oklab()` stops under the ΔE-ε proof), and REFUSES with a NAMED reason what
873
+ * cannot compile faithfully (CC-3 — the replay-equality invariant's honest
874
+ * refusal). The result is async because `formatCSS` (Prettier) is.
875
+ *
876
+ * @returns `{ css, eligible, refusals }` — the artifact + the trust surface.
877
+ */
878
+ declare function compileToCSS<V extends Vars>(input: CompileInput<V>, opts?: CompileOptions): Promise<CompiledCSS>;
879
+
880
+ /**
881
+ * The CSS `animation-composition` operator (K.W7). Distinct from
882
+ * {@link BlendMode} (the GROUP's per-LAYER blend tier — `replace`/`add`/
883
+ * `weighted`): this is the per-KEYFRAME composite operator the author declares
884
+ * on a single animation, matching the CSS grammar exactly (`weighted` is not a
885
+ * CSS composite; `accumulate` is the repeat-aware one CSS adds). The engine
886
+ * routes `add`/`accumulate` onto the SAME un-clamped numeric leaf the group's
887
+ * `add` layer runs (`group.ts`), so the two tiers share one accumulation
888
+ * semantic without sharing a type.
889
+ */
890
+ declare type CompositeOperator = "replace" | "add" | "accumulate";
891
+
892
+ /**
893
+ * Feature-detect (`"ScrollTimeline" in window` / `"ViewTimeline" in window`)
894
+ * and construct a NATIVE `AnimationTimeline` for the additive WAAPI scroll
895
+ * bridge (D-LIB-2 / F-5). Returns `null` where the platform lacks the API
896
+ * (Firefox today, SSR, jsdom) — the caller then keeps the JS {@link Timeline}
897
+ * sampler, which is the proven fallback AND the only general driver over
898
+ * non-DOM targets.
899
+ *
900
+ * CRITICAL — the ARCH-kill HOLDS: this does NOT replace the JS sampler. Native
901
+ * scroll-driven is Chromium-only / not-Baseline, and the JS `Timeline` is a
902
+ * strictly more general caller-polled sampler (it also applies `SmoothProgress`
903
+ * smoothing + boundary snap the native `animation-range` path has none of). The
904
+ * bridge is a pure additive fast lane where supported + eligible. No polyfill.
905
+ *
906
+ * Light: a runtime `in`-detect over the `window` globals — zero static
907
+ * value.js / engine edge, so importing this keeps `timeline.ts` light.
908
+ */
909
+ export declare function createNativeTimeline(spec: NativeTimelineSpec): AnimationTimeline | null;
910
+
911
+ /**
912
+ * Construct a `ScrollScene` from a parsed `CSSTimelineOptions` (the SO-1 parse
913
+ * output) OR a direct `ScrollSceneOptions` spec. The CSS-fed construction is the
914
+ * round-trip's driving half (parse → drive); the spec-fed construction is
915
+ * value.js-INDEPENDENT (it needs no grammar — only the physics primitives).
916
+ *
917
+ * @example
918
+ * // CSS-fed (value.js-gated parse → JS driver):
919
+ * const opts = parseScrollCSS(stylesheet);
920
+ * const scene = createScrollScene({ range: opts.range, scrub: 0.2 });
921
+ * // spec-fed (value.js-independent):
922
+ * const scene = createScrollScene({ range: { start: { offset: "0%" }, end: { offset: "100%" } } });
923
+ */
924
+ declare function createScrollScene(spec?: ScrollSceneOptions | CSSTimelineOptions): ScrollScene;
925
+
926
+ export declare class CSSKeyframesAnimation<V extends Vars> extends KeyframesAnimation<V> {
841
927
  /**
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`.
928
+ * Q.WD1-bind S2 (DM-22) — the timeline a scroll-range named selector resolves
929
+ * its phase against. Stored by {@link bindTimeline} for the no-timeline guard's
930
+ * check; `undefined` until a timeline is bound. A scroll-context operation
931
+ * specific to CSS keyframes with named selectors (the base `Animation` class is
932
+ * value.js-/scroll-agnostic), so the field + method live here.
848
933
  */
849
- private _playReducedMotion;
934
+ private _boundTimeline?;
935
+ constructor(options?: Partial<InputAnimationOptions>, ...targets: HTMLElement[]);
850
936
  /**
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.
937
+ * Q.WD1-bind S2 (DM-22) — the attach-time deferred-resolution seam. A
938
+ * scroll-range named keyframe selector (`entry`/`exit`/`cover`/`contain`)
939
+ * ingests OPAQUELY (the L.W1 S4 floor) and is RESOLVABLE only under a timeline;
940
+ * `bindTimeline` is where that resolution happens. It walks `templateFrames`,
941
+ * resolves each named-selector start to a numeric `%` `ValueUnit` via
942
+ * {@link namedSelectorToFraction}, CLEARS the `NAMED_SELECTOR_SUPERTYPE` tag (so
943
+ * the resolved frame is indistinguishable from an author-written `%` at the sort
944
+ * step — no NaN), and re-compiles. The play-time guard
945
+ * (`assertNoUnresolvedNamedSelector`) then finds zero unresolved frames and
946
+ * passes silently — so this MUST land before the guard fires (the gate-enforced
947
+ * sub-wave ordering: the guard over-throws on a bound animation if the resolver
948
+ * is absent).
856
949
  *
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.
950
+ * Idempotent + safe to call before `fromString`: with no named frames the walk
951
+ * is a no-op; calling it after a NaN-producing `parse()` purges the NaN frames.
891
952
  */
892
- stop(): this;
893
- playing(): boolean;
894
- forcePause(): void;
895
- forcePlay(): void;
953
+ bindTimeline(timeline: Timeline): this;
896
954
  /**
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.
955
+ * One transform-resolution seam for the three `from*` entry points:
956
+ * a supplied transform is the consumer's renderer (vars arrive
957
+ * unflattened); genuine omission resolves to the instance's ONE
958
+ * default DOM-style renderer, which keeps WAAPI eligibility a
959
+ * reference comparison (`usesDefaultRenderer`).
932
960
  */
933
- transitionLayer(nameOrAnim: string | Animation_2<V>, target: {
934
- weight: number;
935
- spring?: LayerTransitionSpring;
936
- }): this;
961
+ private resolveTransform;
962
+ fromVars(vars: V[], transform?: TransformFunction<V>): this;
963
+ fromKeyframes(keyframes: Map<string, Partial<V>> | Record<string, Partial<V>>, transform?: TransformFunction<V>): this;
937
964
  /**
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.
965
+ * Property registry from `@property` declarations parsed by
966
+ * `fromString`. Empty when the input had no `@property` rules.
967
+ * Consumers can read this to recover the type metadata for
968
+ * custom properties (syntax string, initial value, inheritance
969
+ * flag) without re-parsing the source CSS.
943
970
  */
944
- crossfade(a: string | Animation_2<V>, b: string | Animation_2<V>, options?: {
945
- spring?: LayerTransitionSpring;
946
- }): this;
971
+ propertyRegistry: Map<string, PropertyDescriptor_2>;
947
972
  /**
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.
973
+ * Parsed scroll-grammar (`animation-timeline` / `animation-range` /
974
+ * `timeline-scope` / `animation-trigger`) recovered from a sibling style rule
975
+ * by `fromString` (L.W2 S1 — CC-6) via `recoverScrollOptions` (the
976
+ * CSS-metadata-recovery seam); `undefined` when the input carried no scroll
977
+ * grammar (the canonical time-clock animation). A read-only metadata field —
978
+ * no hot-path impact, analogous to {@link propertyRegistry}. The compiler
979
+ * (`compileToCSS`) reads it to EMIT the scroll longhands back out, closing the
980
+ * round-trip's EMIT half.
956
981
  */
957
- private advanceLayerSprings;
982
+ scrollOptions?: CSSTimelineOptions;
983
+ fromString(keyframes: string, transform?: TransformFunction<V>): this;
984
+ transform(vars: V): void;
958
985
  }
959
986
 
960
- export declare interface AnimationGroupEntry<V extends Vars> {
961
- animation: Animation_2<V>;
962
- values: Record<string, unknown>;
963
- layer: AnimationLayerConfig;
964
- }
987
+ declare function CSSKeyframesToString<V extends Vars>(animation: KeyframesAnimation<V>, name?: string, printWidth?: number | undefined): Promise<string>;
965
988
 
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
- };
989
+ /**
990
+ * Per-stop card serializer for the editor pane — ONE formatted keyframe
991
+ * string per DECLARED template stop, index-aligned with
992
+ * `animation.templateFrames` (the pairing the card list renders by).
993
+ * Unified onto the declared-template authority (J.W1 S1): each card is
994
+ * {@link declaredKeyframeBody} — the AUTHORED values. The former path mapped
995
+ * `animation.frames` (the interp PAIRS — N−1 segments for N stops, so the
996
+ * last card simply did not exist) and read `frame.flatVars` (DOM-resolved,
997
+ * interp-mutated) — both defects die with the unification.
998
+ */
999
+ declare const CSSKeyframesToStrings: <V extends Vars>(animation: KeyframesAnimation<V>) => Promise<string[]>;
971
1000
 
972
- declare interface AnimationGroupObject<V extends Vars> {
973
- [key: string]: AnimationGroupEntry<V>;
974
- }
975
-
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
- }
1006
-
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);
1018
- }
1001
+ export { CSSTimelineOptions }
1019
1002
 
1020
1003
  /**
1021
- * Typed option-validation errors — the fail-explicit seam.
1004
+ * The closed-form frictional glide. Given a release `velocity` `v0`, an
1005
+ * `initial` position `x0`, and a `friction` `k`, returns a pure sampler
1006
+ * `(t) => { value, velocity }` evaluating
1022
1007
  *
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.
1008
+ * x(t) = x0 + (v0 / k)·(1 − e^(−k·t))
1009
+ * v(t) = v0·e^(−k·t)
1030
1010
  *
1031
- * Value.js-free: light modules import these without touching the boundary.
1011
+ * at any elapsed time `t` in SECONDS — the spring's native clock. `t ≤ 0`
1012
+ * yields the seed state `(x0, v0)`. Allocation-free per call (one closure
1013
+ * captured once); the returned function does no further allocation.
1014
+ *
1015
+ * @throws if `friction <= 0` — a non-positive coefficient has no finite
1016
+ * resting point and is a programmer error, surfaced explicitly.
1032
1017
  */
1018
+ export declare function decay(options: DecayOptions): (t: number) => DecaySample;
1019
+
1033
1020
  /**
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):
1021
+ * Frictional decay (inertial glide) — the one-line closed-form sibling of
1022
+ * the spring solver, for the fling/flick case where there is no target to
1023
+ * settle to, only an initial velocity bleeding off under friction.
1039
1024
  *
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).
1025
+ * The model is a first-order velocity-proportional drag, `v'(t) = −k·v(t)`,
1026
+ * whose closed-form position is
1027
+ *
1028
+ * x(t) = x0 + (v0 / k)·(1 − e^(−k·t))
1029
+ *
1030
+ * with velocity `v(t) = v0·e^(−k·t)`. As `t → ∞` the glide asymptotes to a
1031
+ * finite resting point `x0 + v0/k` (the projected endpoint a release would
1032
+ * coast to). Larger `k` → more friction → shorter glide.
1033
+ *
1034
+ * LIGHT module: zero static `@mkbabb/value.js` edge. Pure math — no rAF, no
1035
+ * DOM, no allocation in the hot path. A richer canonical closed form is the
1036
+ * value.js hand-off VJ-1; `decay` ships keyframes-local today and collapses
1037
+ * to a thin caller once value.js publishes the canonical surface.
1044
1038
  */
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;
1039
+ /** Inputs to the {@link decay} frictional-glide closed form. */
1040
+ export declare interface DecayOptions {
1041
+ /** Starting position. Default 0. */
1042
+ initial?: number;
1043
+ /** Release velocity (units/s) — the flick speed handed off at release. */
1044
+ velocity: number;
1055
1045
  /**
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).
1046
+ * Friction coefficient (1/s). Strictly positive — larger means more
1047
+ * drag and a shorter glide. Default 5.
1060
1048
  */
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
- }
1049
+ friction?: number;
1114
1050
  }
1115
1051
 
1116
- export { AnimationRangeValue }
1052
+ /**
1053
+ * The asymptotic resting point of a glide — the position a release of
1054
+ * `velocity` from `initial` under `friction` coasts to as `t → ∞`
1055
+ * (`x0 + v0/k`). The projected endpoint, useful for snap-to-target /
1056
+ * paginated-fling decisions without running the loop.
1057
+ *
1058
+ * @throws if `friction <= 0` (see {@link decay}).
1059
+ */
1060
+ export declare function decayRest(options: DecayOptions): number;
1117
1061
 
1118
- export { AnimationTimelineValue }
1062
+ /** A sampled point on a decay glide: position + velocity at time `t`. */
1063
+ export declare interface DecaySample {
1064
+ /** Position `x(t) = x0 + v0/k·(1 − e^(−k·t))`. */
1065
+ value: number;
1066
+ /** Velocity `v(t) = v0·e^(−k·t)`. */
1067
+ velocity: number;
1068
+ }
1119
1069
 
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
- };
1070
+ /**
1071
+ * A structured parse/honoring diagnostic (K.W7 S4). Extends the value.js
1072
+ * `ParseDiagnostic` producer (the CONSUMED shape — `message`/`offset`/`line`/
1073
+ * `column`/`expected`/`input`) with a stable kf-side {@link DiagnosticCode} and
1074
+ * an optional `property` (the leaf a `COMPOSITION_FALLBACK` names). The
1075
+ * value.js half (`message`/`offset`/…) is `Partial` because the engine-internal
1076
+ * rows (EMPTY_PARSE, COMPOSITION_FALLBACK) are NOT byte-offset parse failures —
1077
+ * they carry a `message` + `code` only; a row sourced from the value.js
1078
+ * `OnParseError` producer carries the full positional record. NOT a kf-local
1079
+ * re-author of the producer: it CONSUMES `ParseDiagnostic`'s field shape and
1080
+ * widens it with the stable code (inv-16 published-only consumption holds).
1081
+ */
1082
+ declare interface Diagnostic extends Partial<ParseDiagnostic> {
1083
+ /** A stable, branch-on-able code — never scrape `message`. */
1084
+ code: DiagnosticCode;
1085
+ /** The human-readable summary (always present; the producer's or kf's). */
1086
+ message: string;
1087
+ /** The CSS property a `COMPOSITION_FALLBACK` refuses to composite. */
1088
+ property?: string;
1089
+ }
1130
1090
 
1131
- export declare type BlendMode = "replace" | "add" | "weighted";
1091
+ /**
1092
+ * The stable diagnostic `code`s the kf-side sink emits (K.W7 S4). A FLAT,
1093
+ * additive enum — NOT a logging framework — so a programmatic consumer branches
1094
+ * on the reason without scraping a message string (the J.W1 typed-throw idiom
1095
+ * lifted onto the structured field). The engine-internal rows
1096
+ * (`EMPTY_PARSE`/`UNKNOWN_TIMING_FN`) were J.W1-landed as typed throws; W7 lifts
1097
+ * them onto this field. `COMPOSITION_FALLBACK` is the K.W7 honesty row (the
1098
+ * non-numeric composite leaf's refusal). `PARSE_ERROR` carries the value.js
1099
+ * `OnParseError` producer's structured diagnostic verbatim. The CORS-skip /
1100
+ * WAAPI-reason rows are AUTHORED here but POPULATED by K.W8 (which owns the
1101
+ * CSSOM walk that produces them).
1102
+ */
1103
+ declare type DiagnosticCode = "EMPTY_PARSE" | "UNKNOWN_TIMING_FN" | "COMPOSITION_FALLBACK" | "PARSE_ERROR" | "CORS_SKIP" | "WAAPI_INELIGIBLE" | "ADOPT_REFUSE";
1132
1104
 
1133
- declare const blurIn: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
1105
+ declare const DIRECTIONS: readonly ["normal", "reverse", "alternate", "alternate-reverse"];
1134
1106
 
1135
- declare const blurInOut: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
1107
+ /**
1108
+ * SO-1/SO-2 the DISPATCH (conservative-correct, with a queryable reason). The
1109
+ * WAAPI-eligibility seam pointed at the scroll clock:
1110
+ *
1111
+ * DOM target + WAAPI-eligible + native ScrollTimeline present + NO scrub/snap/
1112
+ * velocity → NATIVE (zero main-thread)
1113
+ * scrub OR snap OR velocity requested → JS (native has no smoother/snap)
1114
+ * non-DOM target / no animation → JS (the universal driver)
1115
+ * WAAPI-ineligible (computed unit / color / custom curve) → JS (the ineligible set)
1116
+ * native ScrollTimeline ABSENT (Firefox, jsdom, SSR) → JS (createNativeTimeline → null)
1117
+ *
1118
+ * The JS path NEVER deletes the native lane and the native path NEVER swallows
1119
+ * an ineligible animation — the reason string is the honesty surface (the
1120
+ * `waapiIneligibleReason` idiom). This ADDS a tier; it deletes no driver.
1121
+ */
1122
+ declare function dispatchScrollBackend<V extends Vars>(request: ScrollDispatchRequest<V>): ScrollDispatch;
1136
1123
 
1137
- declare const blurOut: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
1124
+ /**
1125
+ * Functional sugar over {@link Draggable}: construct, `attach(element)`,
1126
+ * and return the instance — the one-call front door for the common case.
1127
+ * The returned `Draggable` exposes `.spring` (for `.play()` / fling-loop
1128
+ * ownership), `.subscribe()`, `.value`/`.velocity`/`.settled`, and
1129
+ * `.detach()`/`.dispose()`.
1130
+ */
1131
+ export declare function drag(element: HTMLElement, options?: DragOptions): Draggable;
1138
1132
 
1139
- declare const bounce: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
1133
+ /**
1134
+ * Construct a 2-D drag — two one-axis {@link Draggable}s (one per axis), a
1135
+ * shared subscriber that emits `(x, y, vx, vy)` whenever either axis updates,
1136
+ * and a unified `dispose()`. KISS: the 1-D engine stays 1-D; this is additive
1137
+ * sugar that wires the composition the caller would otherwise hand-roll.
1138
+ *
1139
+ * `options.x` / `options.y` are independent {@link DragOptions} — `bounds`,
1140
+ * `rubberBand`, and `snap` pass through PER AXIS (e.g. bound `x` to the
1141
+ * viewport width and `y` to its height separately). The `axis` field of each
1142
+ * is FORCED (`x` → `"x"`, `y` → `"y"`); any author `axis` is ignored.
1143
+ */
1144
+ export declare function drag2D(element: HTMLElement, options?: {
1145
+ x?: DragOptions;
1146
+ y?: DragOptions;
1147
+ }): Drag2DHandle;
1140
1148
 
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
+ * The 2-D drag sugar — two one-axis {@link Draggable}s composed behind a
1151
+ * single `(x, y, vx, vy)` surface. Split out of `drag.ts` (the 1-D engine)
1152
+ * as additive sugar: the engine stays one-dimensional (KISS); this module is
1153
+ * the front door that spares every 2-D consumer the two-`Draggable`
1154
+ * boilerplate. LIGHT — it imports only `Draggable` + `DragOptions` from
1155
+ * `./drag`, so it carries zero static `@mkbabb/value.js` edge.
1156
+ *
1157
+ * Re-exported THROUGH `drag.ts` so the barrel `export { drag, Draggable,
1158
+ * drag2D } from "./drag"` keeps resolving unchanged.
1159
+ */
1160
+ /**
1161
+ * The composite handle a {@link drag2D} returns — two one-axis `Draggable`s
1162
+ * wired behind a single `(x, y, vx, vy)` subscriber and a unified dispose.
1163
+ * Sugar only: the 1-D engine stays 1-D (KISS); this is the front door that
1164
+ * spares every 2-D consumer the two-Draggable boilerplate.
1165
+ */
1166
+ export declare interface Drag2DHandle {
1167
+ /** The x-axis `Draggable` (tracks `clientX`). */
1168
+ readonly x: Draggable;
1169
+ /** The y-axis `Draggable` (tracks `clientY`). */
1170
+ readonly y: Draggable;
1171
+ /**
1172
+ * Current `(x, y)` position. While an axis is dragging this is the live
1173
+ * pointer-pinned target; otherwise the spring's settled / in-flight value.
1174
+ */
1175
+ readonly value: {
1176
+ x: number;
1177
+ y: number;
1178
+ };
1179
+ /** Current `(vx, vy)` velocity (units/s). */
1180
+ readonly velocity: {
1181
+ x: number;
1182
+ y: number;
1183
+ };
1184
+ /** True when BOTH axes have settled. */
1185
+ readonly settled: boolean;
1149
1186
  /**
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.
1187
+ * Subscribe to `(x, y, vx, vy)` emissions — fires whenever EITHER axis
1188
+ * updates (live drag follow + post-release fling). Returns an unsubscribe
1189
+ * handle.
1153
1190
  */
1154
- eligible: boolean;
1155
- /** The CC-3 refusals — one per child that could not compile faithfully. */
1156
- refusals: CompileRefusal[];
1191
+ subscribe(fn: (x: number, y: number, vx: number, vy: number) => void): () => void;
1192
+ /** Remove all listeners and dispose both `Draggable`s. */
1193
+ dispose(): void;
1157
1194
  }
1158
1195
 
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 {
1196
+ /**
1197
+ * The single scalar axis a {@link Draggable} tracks. A 2-D drag composes
1198
+ * two `Draggable`s (one per axis) — the engine stays one-dimensional, the
1199
+ * caller owns the composition (KISS).
1200
+ */
1201
+ export declare type DragAxis = "x" | "y";
1202
+
1203
+ /**
1204
+ * A one-axis draggable: pointer-capture follow + release-velocity fling
1205
+ * over a `SpringProgress`. The hard physics (a continuous analytic
1206
+ * trajectory seeded from the release velocity) is the spring's; this class
1207
+ * is the pointer-event plumbing that feeds it.
1208
+ *
1209
+ * Lifecycle: `attach(element)` binds `pointerdown`; a down captures the
1210
+ * pointer and binds `pointermove`/`pointerup` for the gesture's duration;
1211
+ * `up` re-seats the spring from `(value, releaseVelocity)` and lets it
1212
+ * fling. `detach()` removes every listener and releases capture. The
1213
+ * underlying spring is reachable via `.spring` for `.play()` /
1214
+ * `.subscribe()` / fling-loop ownership.
1215
+ */
1216
+ export declare class Draggable {
1217
+ /** The spring the drag follows + flings — the physics core. */
1218
+ readonly spring: SpringProgress;
1219
+ private readonly axis;
1220
+ private readonly transform;
1221
+ private readonly velocityWindow;
1222
+ /** Hard `[min, max]` value-domain constraint, or `undefined` (free). */
1223
+ private readonly bounds;
1224
+ /** Rubber-band resistance over `bounds` (only consulted when bounds set). */
1225
+ private readonly rubberBand;
1226
+ /** Snap targets in the value domain, or `undefined` (no snap). */
1227
+ private readonly snap;
1228
+ private element;
1229
+ private capturedPointerId;
1230
+ /** Rolling pointer samples for release-velocity estimation. */
1231
+ private samples;
1232
+ private subscribers;
1233
+ private springUnsub;
1234
+ private readonly onPointerDown;
1235
+ private readonly onPointerMove;
1236
+ private readonly onPointerUp;
1237
+ constructor(options?: DragOptions);
1238
+ /** True while a pointer gesture is in progress (down, not yet up). */
1239
+ get dragging(): boolean;
1240
+ /** Current spring position. */
1241
+ get value(): number;
1242
+ /** Current spring velocity (units/s). */
1243
+ get velocity(): number;
1244
+ /** True once the post-release fling has settled. */
1245
+ get settled(): boolean;
1166
1246
  /**
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).
1247
+ * Bind the drag to `element`. Adds the `pointerdown` listener; the
1248
+ * per-gesture `pointermove`/`pointerup` listeners are added on down and
1249
+ * removed on up. Idempotent re-attach detaches the previous element
1250
+ * first. Returns a detach handle (calling it is equivalent to
1251
+ * {@link detach}).
1172
1252
  */
1173
- staggerDelays?: readonly number[];
1253
+ attach(element: HTMLElement): () => void;
1174
1254
  /**
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.
1255
+ * Remove every listener, release any active pointer capture, and end an
1256
+ * in-flight gesture. Leaves the spring's current state intact (a fling
1257
+ * already in progress continues unless the caller stops it).
1179
1258
  */
1180
- densifyStops?: number;
1259
+ detach(): void;
1181
1260
  /**
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).
1261
+ * Subscribe to `(value, velocity)` emissions — both the live drag-
1262
+ * follow and the post-release fling. Returns an unsubscribe handle.
1263
+ * Lazily bridges to the spring's own subscription so the spring stays
1264
+ * the single source of truth.
1187
1265
  */
1188
- deltaEEpsilon?: number;
1189
- /** Prettier print-width for the emitted artifact. Omit for the default. */
1190
- printWidth?: number;
1266
+ subscribe(fn: DragSubscriber): () => void;
1267
+ private emit;
1268
+ /**
1269
+ * Tear down: detach listeners + dispose the spring. After `dispose()`
1270
+ * the draggable is inert.
1271
+ */
1272
+ dispose(): void;
1273
+ private coordOf;
1274
+ private handleDown;
1275
+ private handleMove;
1276
+ /**
1277
+ * Map a raw value-domain coordinate through {@link bounds} +
1278
+ * {@link rubberBand}. With no bounds the coordinate passes through. Below
1279
+ * `min`: `min + (value − min)·rubberBand`. Above `max`: `max +
1280
+ * (value − max)·rubberBand`. In range: the coordinate unchanged. At
1281
+ * `rubberBand = 0` the value is hard-clamped to the limit; at `1` the band
1282
+ * is fully transparent (pass-through).
1283
+ */
1284
+ private applyBounds;
1285
+ private handleUp;
1286
+ /** The snap target nearest `value` (ties → the first encountered). */
1287
+ private nearestSnap;
1288
+ /**
1289
+ * End the current gesture: release capture + remove the per-gesture
1290
+ * listeners. Idempotent — safe when no gesture is active.
1291
+ */
1292
+ private endGesture;
1293
+ private pushSample;
1294
+ /**
1295
+ * Release velocity = average pointer velocity over the sample window,
1296
+ * in units PER SECOND (the spring's clock). Estimated as `Δvalue / Δt`
1297
+ * across the oldest and newest retained samples — robust to a single
1298
+ * jittery last frame, unlike a two-point last-pair difference. Returns
1299
+ * 0 when there is insufficient motion (a tap, or a held release).
1300
+ */
1301
+ private estimateVelocity;
1191
1302
  }
1192
1303
 
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;
1304
+ export declare interface DragOptions {
1305
+ /**
1306
+ * Which pointer axis drives the spring target — `clientX` (`"x"`) or
1307
+ * `clientY` (`"y"`). Default `"x"`.
1308
+ */
1309
+ axis?: DragAxis;
1310
+ /**
1311
+ * Map a raw pointer coordinate (px, in client space) to the spring's
1312
+ * value domain. Default identity (track pointer pixels directly). Use
1313
+ * e.g. `(px) => px - originPx` to track an offset, or a scale factor
1314
+ * for a normalized [0, 1] domain.
1315
+ */
1316
+ transform?: (clientCoord: number) => number;
1317
+ /**
1318
+ * The spring the drag drives. Supplies the physics — the fling on
1319
+ * release re-seats THIS spring from `(currentValue, releaseVelocity)`.
1320
+ * Defaults to a fresh `SpringProgress` with the engine defaults.
1321
+ */
1322
+ spring?: SpringProgress;
1323
+ /**
1324
+ * Options for the default spring (ignored when `spring` is supplied).
1325
+ */
1326
+ springOptions?: Partial<SpringProgressOptions>;
1327
+ /**
1328
+ * Velocity-sampling window in milliseconds. The release velocity is the
1329
+ * average pointer velocity over the last `velocityWindow` ms of moves —
1330
+ * a short window tracks flicks, a longer one smooths jitter. Default
1331
+ * 100ms.
1332
+ */
1333
+ velocityWindow?: number;
1334
+ /**
1335
+ * Hard constraint on the value domain `[min, max]`. The drag cannot pull
1336
+ * the spring target beyond these limits (a clamp in value domain, BEFORE
1337
+ * the rubber-band factor). When omitted the drag is unconstrained — the
1338
+ * mapped coordinate goes straight to the spring target as before.
1339
+ */
1340
+ bounds?: {
1341
+ min: number;
1342
+ max: number;
1343
+ };
1344
+ /**
1345
+ * Rubber-band resistance factor in `[0, 1]`. When the mapped pointer
1346
+ * coordinate exceeds {@link bounds}, the spring target is set to the
1347
+ * boundary + (excess × `rubberBand`) — the pointer coordinate decays
1348
+ * toward the limit rather than being hard-clamped. Default `0.4` (the
1349
+ * Motion / iOS spring-overscroll feel); `0` is a hard clamp, `1` is
1350
+ * pass-through (unconstrained). Has no effect when `bounds` is omitted.
1351
+ */
1352
+ rubberBand?: number;
1353
+ /**
1354
+ * Snap targets in the value domain. On release, the spring's projected
1355
+ * resting point (via {@link decayRest}) selects the nearest target; the
1356
+ * spring is reseated toward that target rather than decelerating freely.
1357
+ * {@link bounds} (if set) apply AFTER snap selection — a snap target
1358
+ * outside bounds is clamped to the bound. Omitted / empty = no snap.
1359
+ */
1360
+ snap?: number[];
1200
1361
  }
1201
1362
 
1202
1363
  /**
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.
1364
+ * Drag / fling adapter — the INPUT layer over the already-SOTA spring
1365
+ * velocity core. It captures the pointer, tracks the drag as a live
1366
+ * `SpringProgress` target on every `pointermove`, samples the pointer
1367
+ * velocity over a short window, and on release hands that velocity to the
1368
+ * spring's re-seat (`SpringProgress` re-seats the closed-form solution from
1369
+ * `(x, v)` so the fling trajectory is continuous with the gesture).
1219
1370
  *
1220
- * @returns `{ css, eligible, refusals }` — the artifact + the trust surface.
1371
+ * LIGHT module: zero static `@mkbabb/value.js` edge. The physics is
1372
+ * keyframes-local (the spring solver); this file is pure input plumbing.
1373
+ *
1374
+ * Framework-free by design — plain `addEventListener` + Pointer Capture
1375
+ * with explicit teardown. This is library code, not a Vue demo: a consumer
1376
+ * wires the returned `value`/`velocity`/`settled` reads (or `subscribe`)
1377
+ * into their own render layer. SSR-safe: construction does not touch the
1378
+ * DOM until `attach()`.
1221
1379
  */
1222
- declare function compileToCSS<V extends Vars>(input: CompileInput<V>, opts?: CompileOptions): Promise<CompiledCSS>;
1380
+ /** A drag emission: the spring's current position + velocity. */
1381
+ export declare type DragSubscriber = (value: number, velocity: number) => void;
1223
1382
 
1224
1383
  /**
1225
- * The CSS `animation-composition` operator (K.W7). Distinct from
1226
- * {@link BlendMode} (the GROUP's per-LAYER blend tier — `replace`/`add`/
1227
- * `weighted`): this is the per-KEYFRAME composite operator the author declares
1228
- * on a single animation, matching the CSS grammar exactly (`weighted` is not a
1229
- * CSS composite; `accumulate` is the repeat-aware one CSS adds). The engine
1230
- * routes `add`/`accumulate` onto the SAME un-clamped numeric leaf the group's
1231
- * `add` layer runs (`group.ts`), so the two tiers share one accumulation
1232
- * semantic without sharing a type.
1384
+ * `DrawSVG` — the class form of {@link fromDrawSVG}, for callers who prefer a
1385
+ * named primitive alongside `CSSKeyframesAnimation` / `MotionPath`. Construction
1386
+ * is the factory: `new DrawSVG(target).animation` is the control handle. The
1387
+ * factory is the canonical entry; this is a thin ergonomic wrapper.
1233
1388
  */
1234
- declare type CompositeOperator = "replace" | "add" | "accumulate";
1389
+ declare class DrawSVG<V extends Record<string, any> = any> {
1390
+ /** The underlying stroke-dashoffset animation — the control handle. */
1391
+ readonly animation: CSSKeyframesAnimation<V>;
1392
+ constructor(target: SVGDrawTarget, options?: DrawSVGOptions);
1393
+ /** Start (or re-enter) the line-drawing play loop. */
1394
+ play(): Promise<void>;
1395
+ /** Pause the play loop, retaining the playhead. */
1396
+ pause(): this;
1397
+ /** Halt and rewind the play loop. */
1398
+ stop(): this;
1399
+ /** Resolve once the draw completes — the {@link Animation.finished} front-door. */
1400
+ get finished(): Promise<void>;
1401
+ }
1402
+
1403
+ export declare interface DrawSVGOptions extends Partial<InputAnimationOptions> {
1404
+ /**
1405
+ * Start of the draw sweep — a percent STRING (`"0%"` → `"100%"`) or a 0..1
1406
+ * NUMBER fraction (`0` → `1`), the two unambiguous forms. Default `"0%"` —
1407
+ * the stroke starts undrawn (full `stroke-dashoffset`) and draws IN; `"100%"`
1408
+ * → `"0%"` (or `1` → `0`) erases it. A number outside `[0, 1]` throws (a
1409
+ * percent must be a string — no silent `50`-means-5000% footgun).
1410
+ */
1411
+ from?: string | number;
1412
+ /** End of the draw sweep — same `"100%"`/`1` two-form contract. Default `"100%"`. */
1413
+ to?: string | number;
1414
+ /**
1415
+ * Auto-start the play loop after construction + targeting. Default true.
1416
+ * `false` returns a constructed, targeted, NOT-yet-playing handle so the
1417
+ * caller can drive the returned animation (`.play()` / `.pause()` / `.stop()`).
1418
+ */
1419
+ autoPlay?: boolean;
1420
+ }
1235
1421
 
1236
1422
  /**
1237
- * Feature-detect (`"ScrollTimeline" in window` / `"ViewTimeline" in window`)
1238
- * and construct a NATIVE `AnimationTimeline` for the additive WAAPI scroll
1239
- * bridge (D-LIB-2 / F-5). Returns `null` where the platform lacks the API
1240
- * (Firefox today, SSR, jsdom) — the caller then keeps the JS {@link Timeline}
1241
- * sampler, which is the proven fallback AND the only general driver over
1242
- * non-DOM targets.
1243
- *
1244
- * CRITICAL — the ARCH-kill HOLDS: this does NOT replace the JS sampler. Native
1245
- * scroll-driven is Chromium-only / not-Baseline, and the JS `Timeline` is a
1246
- * strictly more general caller-polled sampler (it also applies `SmoothProgress`
1247
- * smoothing + boundary snap the native `animation-range` path has none of). The
1248
- * bridge is a pure additive fast lane where supported + eligible. No polyfill.
1423
+ * The typed easing value — a callable curve plus, when one exists, the CSS
1424
+ * easing string that reproduces it (e.g. a spring's `linear()` stops).
1249
1425
  *
1250
- * Light: a runtime `in`-detect over the `window` globals — zero static
1251
- * value.js / engine edge, so importing this keeps `timeline.ts` light.
1426
+ * Replaces the former Symbol-on-a-closure side channel: the "this closure
1427
+ * has a CSS twin" fact now flows through the type system, so wrapping or
1428
+ * binding the callable can no longer silently drop it. `waapi.ts` reads
1429
+ * `.css` to run the true curve on the compositor; everything else reads
1430
+ * `.fn`.
1252
1431
  */
1253
- export declare function createNativeTimeline(spec: NativeTimelineSpec): AnimationTimeline | null;
1432
+ export declare interface Easing {
1433
+ /** The callable curve — the hot-path interpolation function. */
1434
+ fn: TimingFunction;
1435
+ /** CSS easing string that faithfully reproduces `fn`, when one exists. */
1436
+ css?: string;
1437
+ }
1254
1438
 
1255
1439
  /**
1256
- * Construct a `ScrollScene` from a parsed `CSSTimelineOptions` (the SO-1 parse
1257
- * output) OR a direct `ScrollSceneOptions` spec. The CSS-fed construction is the
1258
- * round-trip's driving half (parse → drive); the spec-fed construction is
1259
- * value.js-INDEPENDENT (it needs no grammar — only the physics primitives).
1440
+ * Interpolate position and scale between two elements or rects.
1260
1441
  *
1261
- * @example
1262
- * // CSS-fed (value.js-gated parse → JS driver):
1263
- * const opts = parseScrollCSS(stylesheet);
1264
- * const scene = createScrollScene({ range: opts.range, scrub: 0.2 });
1265
- * // spec-fed (value.js-independent):
1266
- * const scene = createScrollScene({ range: { start: { offset: "0%" }, end: { offset: "100%" } } });
1442
+ * Two usage modes:
1443
+ * - **Stateless**: call `.at(progress)` or `.toCSSTransform(progress)`
1444
+ * - **Managed**: call `.play(element)` to animate an element from source
1445
+ * to destination over the configured duration
1267
1446
  */
1268
- declare function createScrollScene(spec?: ScrollSceneOptions | CSSTimelineOptions): ScrollScene;
1269
-
1270
- export declare class CSSKeyframesAnimation<V extends Vars> extends Animation_2<V> {
1271
- constructor(options?: Partial<InputAnimationOptions>, ...targets: HTMLElement[]);
1272
- /**
1273
- * One transform-resolution seam for the three `from*` entry points:
1274
- * a supplied transform is the consumer's renderer (vars arrive
1275
- * unflattened); genuine omission resolves to the instance's ONE
1276
- * default DOM-style renderer, which keeps WAAPI eligibility a
1277
- * reference comparison (`usesDefaultRenderer`).
1278
- */
1279
- private resolveTransform;
1280
- fromVars(vars: V[], transform?: TransformFunction<V>): this;
1281
- fromKeyframes(keyframes: Map<string, Partial<V>> | Record<string, Partial<V>>, transform?: TransformFunction<V>): this;
1282
- /**
1283
- * Property registry from `@property` declarations parsed by
1284
- * `fromString`. Empty when the input had no `@property` rules.
1285
- * Consumers can read this to recover the type metadata for
1286
- * custom properties (syntax string, initial value, inheritance
1287
- * flag) without re-parsing the source CSS.
1288
- */
1289
- propertyRegistry: Map<string, PropertyDescriptor_2>;
1290
- fromString(keyframes: string, transform?: TransformFunction<V>): this;
1447
+ export declare class ElementMorph {
1448
+ private animation;
1449
+ private transformOrigin;
1450
+ private timingFunction;
1451
+ private duration;
1452
+ constructor(from: HTMLElement | MorphRect, to: HTMLElement | MorphRect, options?: ElementMorphOptions);
1453
+ /** Re-measure source and destination, rebuilding the internal animation. */
1454
+ measure(from: HTMLElement | MorphRect, to: HTMLElement | MorphRect): this;
1455
+ /** Get raw transform values at the given progress [0, 1]. */
1456
+ at(progress: number): MorphValues;
1457
+ /** Get a CSS transform string at the given progress [0, 1]. */
1458
+ toCSSTransform(progress: number): string;
1459
+ /** Apply the morph transform to an element at the given progress [0, 1]. */
1460
+ apply(element: HTMLElement, progress: number): void;
1291
1461
  /**
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.
1462
+ * Animate an element from source to destination over the configured duration.
1300
1463
  *
1301
- * Baseline 2024-07-09 (newly available — feature-detect mandatory).
1464
+ * @param element — the element to apply transforms to
1465
+ * @param duration — override the duration set in constructor options (ms)
1302
1466
  */
1303
- private registerProperties;
1304
- transform(vars: V): void;
1467
+ play(element: HTMLElement, duration?: number): Promise<void>;
1468
+ /** Cancel a running `.play()` animation. */
1469
+ stop(): void;
1305
1470
  }
1306
1471
 
1307
- export { CSSTimelineOptions }
1472
+ export declare interface ElementMorphOptions {
1473
+ /**
1474
+ * Easing as a callable `TimingFunction` or a typed `Easing` —
1475
+ * synchronous and value.js-free (`ElementMorph` composes
1476
+ * `NumericAnimation`, which enforces the same contract). Resolve a
1477
+ * string name first via `await resolveEasing(name)`.
1478
+ */
1479
+ timingFunction?: TimingFunction | Easing;
1480
+ /** Playback duration in milliseconds. Required for `.play()`. */
1481
+ duration?: number;
1482
+ transformOrigin?: string;
1483
+ }
1308
1484
 
1309
1485
  /**
1310
- * The closed-form frictional glide. Given a release `velocity` `v0`, an
1311
- * `initial` position `x0`, and a `friction` `k`, returns a pure sampler
1312
- * `(t) => { value, velocity }` evaluating
1313
- *
1314
- * x(t) = x0 + (v0 / k)·(1 − e^(−k·t))
1315
- * v(t) = v0·e^(−k·t)
1316
- *
1317
- * at any elapsed time `t` in SECONDS — the spring's native clock. `t ≤ 0`
1318
- * yields the seed state `(x0, v0)`. Allocation-free per call (one closure
1319
- * captured once); the returned function does no further allocation.
1320
- *
1321
- * @throws if `friction <= 0` — a non-positive coefficient has no finite
1322
- * resting point and is a programmer error, surfaced explicitly.
1486
+ * The engine CORE surface — `Animation` / `CSSKeyframesAnimation` /
1487
+ * `AnimationGroup` + the timing/keyframe helpers + the option constants. This
1488
+ * is `./engine`'s own runtime exports: parse + interpolate WITHOUT the
1489
+ * ingest / compile / motion-path / draw-svg / animate / preset front doors. The
1490
+ * granular `loadEngine()` (L.W7 S3) resolves exactly this — a consumer that
1491
+ * needs only `new CSSKeyframesAnimation(opts).fromString(css)` pays for the
1492
+ * `engine` chunk alone, not the eight-chunk full surface.
1323
1493
  */
1324
- export declare function decay(options: DecayOptions): (t: number) => DecaySample;
1494
+ export declare interface EngineCore {
1495
+ /** The core engine constructor (PKG-3, L.W8 §S4 — renamed from `Animation`). */
1496
+ KeyframesAnimation: typeof KeyframesAnimation;
1497
+ CSSKeyframesAnimation: typeof CSSKeyframesAnimation;
1498
+ AnimationGroup: typeof AnimationGroup;
1499
+ getAnimationId: (animation: KeyframesAnimation | string) => string;
1500
+ getTimingFunction: (timingFunction: TimingFunction | TimingFunctionNames | string | undefined) => TimingFunction | undefined;
1501
+ resolveKeyframes: (input: string | Stylesheet) => ResolvedKeyframes;
1502
+ DIRECTIONS: readonly AnimationOptions["direction"][];
1503
+ FILL_MODES: readonly AnimationOptions["fillMode"][];
1504
+ defaultOptions: AnimationOptions;
1505
+ defaultLayerConfig: AnimationLayerConfig;
1506
+ }
1507
+
1508
+ /** Entrance animations — bring an element INTO view. */
1509
+ declare const enterPresets: {
1510
+ readonly fadeIn: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
1511
+ readonly slideIn: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
1512
+ readonly slideInLeft: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
1513
+ readonly slideInRight: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
1514
+ readonly rotateIn: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
1515
+ readonly blurIn: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
1516
+ readonly springScaleIn: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
1517
+ readonly springSlideIn: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
1518
+ readonly jumpUp: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
1519
+ };
1520
+
1521
+ /** Exit animations — take an element OUT of view. */
1522
+ declare const exitPresets: {
1523
+ readonly fadeOut: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
1524
+ readonly slideOutLeft: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
1525
+ readonly slideOutRight: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
1526
+ readonly blurOut: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
1527
+ readonly warpLeft: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
1528
+ readonly warpRight: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
1529
+ readonly jumpDown: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
1530
+ };
1325
1531
 
1326
1532
  /**
1327
- * Frictional decay (inertial glide) — the one-line closed-form sibling of
1328
- * the spring solver, for the fling/flick case where there is no target to
1329
- * settle to, only an initial velocity bleeding off under friction.
1533
+ * `explain(css, opts?)` — the human/LLM-readable companion. Calls
1534
+ * {@link validate} and formats the result as a concise, DETERMINISTIC string
1535
+ * (field order fixed, no locale-sensitive formatting) so a doctest can assert it
1536
+ * byte-for-byte. The shape the demo's ineligibility panel produces, as a
1537
+ * first-class library API. An LLM agent can present it verbatim or parse it for a
1538
+ * fix suggestion.
1330
1539
  *
1331
- * The model is a first-order velocity-proportional drag, `v'(t) = −k·v(t)`,
1332
- * whose closed-form position is
1333
- *
1334
- * x(t) = x0 + (v0 / k)·(1 − e^(−k·t))
1335
- *
1336
- * with velocity `v(t) = v0·e^(−k·t)`. As `t → ∞` the glide asymptotes to a
1337
- * finite resting point `x0 + v0/k` (the projected endpoint a release would
1338
- * coast to). Larger `k` → more friction → shorter glide.
1540
+ * Format (one block; the `–` bullets enumerate the refusals / WAAPI reason /
1541
+ * diagnostics, each on its own line):
1339
1542
  *
1340
- * LIGHT module: zero static `@mkbabb/value.js` edge. Pure math — no rAF, no
1341
- * DOM, no allocation in the hot path. A richer canonical closed form is the
1342
- * value.js hand-off VJ-1; `decay` ships keyframes-local today and collapses
1343
- * to a thin caller once value.js publishes the canonical surface.
1543
+ * @keyframes color-drift:
1544
+ * parseable: yes
1545
+ * compile-eligible: no
1546
+ * – perceptual-oklab: color-drift cannot compile: …
1547
+ * waapi-eligible: no
1548
+ * – color interpolation requires perceptual lerp
1549
+ * diagnostics:
1550
+ * – COMPOSITION_FALLBACK: …
1344
1551
  */
1345
- /** Inputs to the {@link decay} frictional-glide closed form. */
1346
- export declare interface DecayOptions {
1347
- /** Starting position. Default 0. */
1348
- initial?: number;
1349
- /** Release velocity (units/s) — the flick speed handed off at release. */
1350
- velocity: number;
1351
- /**
1352
- * Friction coefficient (1/s). Strictly positive — larger means more
1353
- * drag and a shorter glide. Default 5.
1354
- */
1355
- friction?: number;
1356
- }
1552
+ declare function explain(css: string, opts?: ValidateOptions): Promise<string>;
1357
1553
 
1358
- /**
1359
- * The asymptotic resting point of a glide — the position a release of
1360
- * `velocity` from `initial` under `friction` coasts to as `t → ∞`
1361
- * (`x0 + v0/k`). The projected endpoint, useful for snap-to-target /
1362
- * paginated-fling decisions without running the loop.
1363
- *
1364
- * @throws if `friction <= 0` (see {@link decay}).
1365
- */
1366
- export declare function decayRest(options: DecayOptions): number;
1554
+ declare const fadeIn: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
1367
1555
 
1368
- /** A sampled point on a decay glide: position + velocity at time `t`. */
1369
- export declare interface DecaySample {
1370
- /** Position `x(t) = x0 + v0/k·(1 − e^(−k·t))`. */
1371
- value: number;
1372
- /** Velocity `v(t) = v0·e^(−k·t)`. */
1373
- velocity: number;
1374
- }
1556
+ declare const fadeOut: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
1375
1557
 
1376
- /**
1377
- * A structured parse/honoring diagnostic (K.W7 S4). Extends the value.js
1378
- * `ParseDiagnostic` producer (the CONSUMED shape — `message`/`offset`/`line`/
1379
- * `column`/`expected`/`input`) with a stable kf-side {@link DiagnosticCode} and
1380
- * an optional `property` (the leaf a `COMPOSITION_FALLBACK` names). The
1381
- * value.js half (`message`/`offset`/…) is `Partial` because the engine-internal
1382
- * rows (EMPTY_PARSE, COMPOSITION_FALLBACK) are NOT byte-offset parse failures —
1383
- * they carry a `message` + `code` only; a row sourced from the value.js
1384
- * `OnParseError` producer carries the full positional record. NOT a kf-local
1385
- * re-author of the producer: it CONSUMES `ParseDiagnostic`'s field shape and
1386
- * widens it with the stable code (inv-16 published-only consumption holds).
1387
- */
1388
- declare interface Diagnostic extends Partial<ParseDiagnostic> {
1389
- /** A stable, branch-on-able code — never scrape `message`. */
1390
- code: DiagnosticCode;
1391
- /** The human-readable summary (always present; the producer's or kf's). */
1392
- message: string;
1393
- /** The CSS property a `COMPOSITION_FALLBACK` refuses to composite. */
1394
- property?: string;
1395
- }
1558
+ declare const FILL_MODES: readonly ["none", "forwards", "backwards", "both"];
1396
1559
 
1397
1560
  /**
1398
- * The stable diagnostic `code`s the kf-side sink emits (K.W7 S4). A FLAT,
1399
- * additive enum — NOT a logging framework — so a programmatic consumer branches
1400
- * on the reason without scraping a message string (the J.W1 typed-throw idiom
1401
- * lifted onto the structured field). The engine-internal rows
1402
- * (`EMPTY_PARSE`/`UNKNOWN_TIMING_FN`) were J.W1-landed as typed throws; W7 lifts
1403
- * them onto this field. `COMPOSITION_FALLBACK` is the K.W7 honesty row (the
1404
- * non-numeric composite leaf's refusal). `PARSE_ERROR` carries the value.js
1405
- * `OnParseError` producer's structured diagnostic verbatim. The CORS-skip /
1406
- * WAAPI-reason rows are AUTHORED here but POPULATED by K.W8 (which owns the
1407
- * CSSOM walk that produces them).
1561
+ * Animate a layout change on `element`: measure (First), run `mutate` (Last),
1562
+ * measure again, then invert + play the transform between them via
1563
+ * {@link ElementMorph}. Returns the play promise.
1564
+ *
1565
+ * @param element — the element whose layout `mutate` changes.
1566
+ * @param mutate — a synchronous DOM mutation (class toggle, reparent, …).
1567
+ * @param options — `{ duration, timingFunction, transformOrigin }`.
1408
1568
  */
1409
- declare type DiagnosticCode = "EMPTY_PARSE" | "UNKNOWN_TIMING_FN" | "COMPOSITION_FALLBACK" | "PARSE_ERROR" | "CORS_SKIP" | "WAAPI_INELIGIBLE";
1569
+ export declare function flip(element: HTMLElement, mutate: () => void, options?: FlipOptions): Promise<void>;
1410
1570
 
1411
- declare const DIRECTIONS: readonly ["normal", "reverse", "alternate", "alternate-reverse"];
1571
+ export declare interface FlipOptions {
1572
+ /** Playback duration in milliseconds. Defaults to `300`. */
1573
+ duration?: number;
1574
+ /**
1575
+ * Easing for the play phase — a callable {@link TimingFunction} or typed
1576
+ * {@link Easing} (e.g. `springTimingFunction(...)` for a springy FLIP).
1577
+ * A string name is rejected; resolve it via `await resolveEasing(name)`.
1578
+ */
1579
+ timingFunction?: TimingFunction | Easing;
1580
+ transformOrigin?: string;
1581
+ }
1412
1582
 
1413
1583
  /**
1414
- * SO-1/SO-2 the DISPATCH (conservative-correct, with a queryable reason). The
1415
- * WAAPI-eligibility seam pointed at the scroll clock:
1416
- *
1417
- * DOM target + WAAPI-eligible + native ScrollTimeline present + NO scrub/snap/
1418
- * velocity → NATIVE (zero main-thread)
1419
- * scrub OR snap OR velocity requested → JS (native has no smoother/snap)
1420
- * non-DOM target / no animation → JS (the universal driver)
1421
- * WAAPI-ineligible (computed unit / color / custom curve) → JS (the ineligible set)
1422
- * native ScrollTimeline ABSENT (Firefox, jsdom, SSR) → JS (createNativeTimeline → null)
1584
+ * The card-flip attention preset.
1423
1585
  *
1424
- * The JS path NEVER deletes the native lane and the native path NEVER swallows
1425
- * an ineligible animation — the reason string is the honesty surface (the
1426
- * `waapiIneligibleReason` idiom). This ADDS a tier; it deletes no driver.
1586
+ * ── PKG-3 RENAME (L.W8 §S4 · audit W126). Formerly the preset `flip`. Renamed
1587
+ * `flip` → `flipPreset` because the rolled-up `dist/keyframes.d.ts` placed this
1588
+ * preset (reachable as `presets.flip`) and the LIGHT top-level `flip` export
1589
+ * (the FLIP-layout helper in `flip.ts`) under the same name `flip`, so API
1590
+ * Extractor renamed this one with a numeric suffix and re-exported it under the
1591
+ * `flip` name inside the `AnimationPresets` namespace — a numeric-suffixed alias
1592
+ * `proof:pkg3-clean` greps for. Naming the preset `flipPreset` (distinct from the
1593
+ * light `flip`) clears the collision. BREAKING (5.0.0): the access path is now
1594
+ * `presets.flipPreset`; the nested taxonomy key `attentionPresets.flip` is
1595
+ * unchanged (a property name, not a top-level declaration — no collision).
1427
1596
  */
1428
- declare function dispatchScrollBackend<V extends Vars>(request: ScrollDispatchRequest<V>): ScrollDispatch;
1597
+ declare const flipPreset: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
1429
1598
 
1430
1599
  /**
1431
- * Functional sugar over {@link Draggable}: construct, `attach(element)`,
1432
- * and return the instance — the one-call front door for the common case.
1433
- * The returned `Draggable` exposes `.spring` (for `.play()` / fling-loop
1434
- * ownership), `.subscribe()`, `.value`/`.velocity`/`.settled`, and
1435
- * `.detach()`/`.dispose()`.
1600
+ * Shared-element FLIP: animate element `a` onto the rect of element `b`
1601
+ * (Motion's `layoutId` / GSAP Flip shared-element style). Unlike `flip`, `a`
1602
+ * does NOT move in the DOM — it stays at its own rect (First) and the morph
1603
+ * carries it FORWARD onto `b`'s rect (Last). So this is a plain forward
1604
+ * {@link ElementMorph} play (identity at t=0 → full delta at t=1), not the
1605
+ * inversion `flip` runs.
1606
+ *
1607
+ * The two reads are batched — one forced layout each, before any write.
1608
+ *
1609
+ * @param a — the element to animate.
1610
+ * @param b — the element whose rect `a` morphs onto.
1611
+ * @param options — `{ duration, timingFunction, transformOrigin }`.
1436
1612
  */
1437
- export declare function drag(element: HTMLElement, options?: DragOptions): Draggable;
1613
+ export declare function flipShared(a: HTMLElement, b: HTMLElement, options?: FlipOptions): Promise<void>;
1438
1614
 
1439
- /**
1440
- * The single scalar axis a {@link Draggable} tracks. A 2-D drag composes
1441
- * two `Draggable`s (one per axis) — the engine stays one-dimensional, the
1442
- * caller owns the composition (KISS).
1443
- */
1444
- export declare type DragAxis = "x" | "y";
1615
+ declare function formatCSSKeyframeString(keyframe: string): string;
1445
1616
 
1446
- /**
1447
- * A one-axis draggable: pointer-capture follow + release-velocity fling
1448
- * over a `SpringProgress`. The hard physics (a continuous analytic
1449
- * trajectory seeded from the release velocity) is the spring's; this class
1450
- * is the pointer-event plumbing that feeds it.
1451
- *
1452
- * Lifecycle: `attach(element)` binds `pointerdown`; a down captures the
1453
- * pointer and binds `pointermove`/`pointerup` for the gesture's duration;
1454
- * `up` re-seats the spring from `(value, releaseVelocity)` and lets it
1455
- * fling. `detach()` removes every listener and releases capture. The
1456
- * underlying spring is reachable via `.spring` for `.play()` /
1457
- * `.subscribe()` / fling-loop ownership.
1458
- */
1459
- export declare class Draggable {
1460
- /** The spring the drag follows + flings — the physics core. */
1461
- readonly spring: SpringProgress;
1462
- private readonly axis;
1463
- private readonly transform;
1464
- private readonly velocityWindow;
1465
- private element;
1466
- private capturedPointerId;
1467
- /** Rolling pointer samples for release-velocity estimation. */
1468
- private samples;
1469
- private subscribers;
1470
- private springUnsub;
1471
- private readonly onPointerDown;
1472
- private readonly onPointerMove;
1473
- private readonly onPointerUp;
1474
- constructor(options?: DragOptions);
1475
- /** True while a pointer gesture is in progress (down, not yet up). */
1476
- get dragging(): boolean;
1477
- /** Current spring position. */
1478
- get value(): number;
1479
- /** Current spring velocity (units/s). */
1480
- get velocity(): number;
1481
- /** True once the post-release fling has settled. */
1482
- get settled(): boolean;
1483
- /**
1484
- * Bind the drag to `element`. Adds the `pointerdown` listener; the
1485
- * per-gesture `pointermove`/`pointerup` listeners are added on down and
1486
- * removed on up. Idempotent re-attach detaches the previous element
1487
- * first. Returns a detach handle (calling it is equivalent to
1488
- * {@link detach}).
1489
- */
1490
- attach(element: HTMLElement): () => void;
1491
- /**
1492
- * Remove every listener, release any active pointer capture, and end an
1493
- * in-flight gesture. Leaves the spring's current state intact (a fling
1494
- * already in progress continues unless the caller stops it).
1495
- */
1496
- detach(): void;
1497
- /**
1498
- * Subscribe to `(value, velocity)` emissions — both the live drag-
1499
- * follow and the post-release fling. Returns an unsubscribe handle.
1500
- * Lazily bridges to the spring's own subscription so the spring stays
1501
- * the single source of truth.
1502
- */
1503
- subscribe(fn: DragSubscriber): () => void;
1504
- private emit;
1617
+ declare class FrameCompiler<V extends Vars = any> {
1618
+ private readonly _options;
1619
+ templateFrames: TemplateAnimationFrame<V>[];
1620
+ parsedVars: ParsedVarMap[];
1621
+ frames: AnimationFrame<V>[];
1505
1622
  /**
1506
- * Tear down: detach listeners + dispose the spring. After `dispose()`
1507
- * the draggable is inert.
1623
+ * Next TEMPLATE frame id — a monotonic handle assigned in `addFrame`
1624
+ * (stable across re-parse, since `parse` does not re-add templates).
1625
+ * Compiled-frame ids are content-derived from `(startIx, stopIx)`
1626
+ * (see `createFrame`), NOT this counter, so `parse()` is idempotent.
1508
1627
  */
1509
- dispose(): void;
1510
- private coordOf;
1511
- private handleDown;
1512
- private handleMove;
1513
- private handleUp;
1628
+ frameId: number;
1514
1629
  /**
1515
- * End the current gesture: release capture + remove the per-gesture
1516
- * listeners. Idempotent — safe when no gesture is active.
1630
+ * The compile inputs live on the owning `Animation`'s `options` object.
1631
+ * The compiler holds a REFERENCE to it (the setters mutate it in place,
1632
+ * never replace it), so the NEXT compile always reads the current
1633
+ * `duration`/`easing`/`colorSpace` without re-linking. For values baked
1634
+ * into already-compiled frames, the setter triggers a targeted re-derive:
1635
+ * `setDuration` rescales `frame.time` in place; `setColorSpace`/
1636
+ * `setHueMethod` call {@link renormalizeColors} (the color resolution is
1637
+ * the only baked state that depends on them). No setter silently no-ops a
1638
+ * change to compiled state.
1517
1639
  */
1518
- private endGesture;
1519
- private pushSample;
1640
+ constructor(_options: AnimationOptions);
1520
1641
  /**
1521
- * Release velocity = average pointer velocity over the sample window,
1522
- * in units PER SECOND (the spring's clock). Estimated as `Δvalue / Δt`
1523
- * across the oldest and newest retained samples — robust to a single
1524
- * jittery last frame, unlike a two-point last-pair difference. Returns
1525
- * 0 when there is insufficient motion (a tap, or a held release).
1642
+ * The live options object the compiler reads (a REFERENCE to the owning
1643
+ * `Animation`'s `options` — the setters mutate it in place). Read-only:
1644
+ * the compiler never replaces it. Exposed so `Animation.adoptCompiled`
1645
+ * can re-bind `Animation.options` to the adopted compiler's options object
1646
+ * BY CONSTRUCTION (`this.options === this.compiler.options`, the live-options
1647
+ * invariant — G.W19 / the `6e29236` lock), without poking a private field.
1526
1648
  */
1527
- private estimateVelocity;
1528
- }
1529
-
1530
- export declare interface DragOptions {
1649
+ get options(): AnimationOptions;
1650
+ addFrame<K extends V>(start: number | string | ValueUnit<number>, vars: Partial<K>, transform?: TransformFunction<K>, timingFunction?: InputAnimationOptions["timingFunction"], composition?: CompositeOperator): void;
1651
+ createFrame(startIx: number, endIx: number): AnimationFrame<V>;
1531
1652
  /**
1532
- * Which pointer axis drives the spring target — `clientX` (`"x"`) or
1533
- * `clientY` (`"y"`). Default `"x"`.
1653
+ * Build an index mapping each variable name to the frame indices where
1654
+ * it appears. Used by reconcileVars() for O(1) "next occurrence" lookups
1655
+ * instead of O(N) findIndex scans per variable.
1534
1656
  */
1535
- axis?: DragAxis;
1657
+ private buildVarIndex;
1536
1658
  /**
1537
- * Map a raw pointer coordinate (px, in client space) to the spring's
1538
- * value domain. Default identity (track pointer pixels directly). Use
1539
- * e.g. `(px) => px - originPx` to track an offset, or a scale factor
1540
- * for a normalized [0, 1] domain.
1659
+ * Reconcile interpolation variables across non-adjacent keyframes.
1660
+ * For each variable at frame `ix`, find the next frame that also
1661
+ * defines that variable and create an interpolation segment between them.
1662
+ *
1663
+ * Uses a pre-built variable index (from buildVarIndex) to avoid
1664
+ * O(frames²) findIndex scans.
1541
1665
  */
1542
- transform?: (clientCoord: number) => number;
1666
+ reconcileVars(ix: number, varIndex: Map<string, number[]>): void;
1543
1667
  /**
1544
- * The spring the drag drives. Supplies the physics — the fling on
1545
- * release re-seats THIS spring from `(currentValue, releaseVelocity)`.
1546
- * Defaults to a fresh `SpringProgress` with the engine defaults.
1668
+ * Compile `templateFrames` into the sampled `frames[]`. `targets` is the
1669
+ * one DOM input — each parsed var is bound to it so computed-unit
1670
+ * resolution can read the live box. Pure otherwise.
1547
1671
  */
1548
- spring?: SpringProgress;
1672
+ parse(targets: HTMLElement[]): void;
1549
1673
  /**
1550
- * Options for the default spring (ignored when `spring` is supplied).
1674
+ * Derive a frame's `flatVars`/`vars`/`allInterpVars` from its
1675
+ * `interpVars` — the pre-flattened forms the hot path
1676
+ * (`interpFrames`) iterates without re-walking. Called once per frame
1677
+ * at the tail of `parse`, and again by `renormalizeColors` after a
1678
+ * color-space change re-derives the interp carriers in place.
1551
1679
  */
1552
- springOptions?: Partial<SpringProgressOptions>;
1680
+ private finalizeFrameVars;
1553
1681
  /**
1554
- * Velocity-sampling window in milliseconds. The release velocity is the
1555
- * average pointer velocity over the last `velocityWindow` ms of moves —
1556
- * a short window tracks flicks, a longer one smooths jitter. Default
1557
- * 100ms.
1682
+ * Re-derive the color-resolved interpolation carriers in place after a
1683
+ * `colorSpace`/`hueMethod` change on already-compiled frames. Only the
1684
+ * per-`InterpolatedVar` color resolution depends on the color space —
1685
+ * the flatten/sort/reconcile structure does not — so this re-runs
1686
+ * `createInterpVarValue` over the existing `frames`/`parsedVars` and
1687
+ * rebuilds the hot-path arrays, with NO re-flatten and NO re-sort. The
1688
+ * new carriers derive from the already-target-bound `parsedVars`, the
1689
+ * same provenance `parse` gives them, so DOM binding is preserved.
1690
+ *
1691
+ * The owning `Animation`'s `setColorSpace`/`setHueMethod` call this when
1692
+ * frames already exist; before `parse`, the option is simply read by the
1693
+ * next compile.
1558
1694
  */
1559
- velocityWindow?: number;
1695
+ renormalizeColors(): void;
1560
1696
  }
1561
1697
 
1562
1698
  /**
1563
- * Drag / fling adapter — the INPUT layer over the already-SOTA spring
1564
- * velocity core. It captures the pointer, tracks the drag as a live
1565
- * `SpringProgress` target on every `pointermove`, samples the pointer
1566
- * velocity over a short window, and on release hands that velocity to the
1567
- * spring's re-seat (`SpringProgress` re-seats the closed-form solution from
1568
- * `(x, v)` so the fling trajectory is continuous with the gesture).
1699
+ * Build a CSS-native SVG line-drawing animation: read the target's path length
1700
+ * ONCE, set `stroke-dasharray` to that length (one solid full-length dash), and
1701
+ * sweep `stroke-dashoffset` from → to (default `0% → 100%` ⇒ offset `L → 0`,
1702
+ * the line draws in). Returns the constructed {@link CSSKeyframesAnimation} as
1703
+ * the control handle (the `animate()` contract — `.play()` / `.pause()` /
1704
+ * `.stop()` / `.finished`), consistent with the `from*` factory family.
1569
1705
  *
1570
- * LIGHT module: zero static `@mkbabb/value.js` edge. The physics is
1571
- * keyframes-local (the spring solver); this file is pure input plumbing.
1706
+ * The returned animation passes the EXISTING WAAPI eligibility gate
1707
+ * (`isWAAPIEligible`) for an SVG DOM target with a uniform CSS-twin easing, and
1708
+ * delegates compositor-thread via `playWAAPI` — no new eligibility predicate.
1572
1709
  *
1573
- * Framework-free by design — plain `addEventListener` + Pointer Capture
1574
- * with explicit teardown. This is library code, not a Vue demo: a consumer
1575
- * wires the returned `value`/`velocity`/`settled` reads (or `subscribe`)
1576
- * into their own render layer. SSR-safe: construction does not touch the
1577
- * DOM until `attach()`.
1578
- */
1579
- /** A drag emission: the spring's current position + velocity. */
1580
- export declare type DragSubscriber = (value: number, velocity: number) => void;
1581
-
1582
- /**
1583
- * `DrawSVG` — the class form of {@link fromDrawSVG}, for callers who prefer a
1584
- * named primitive alongside `CSSKeyframesAnimation` / `MotionPath`. Construction
1585
- * is the factory: `new DrawSVG(target).animation` is the control handle. The
1586
- * factory is the canonical entry; this is a thin ergonomic wrapper.
1710
+ * The line length `L` is read a SINGLE time at construction (the
1711
+ * `motion-path.ts` "browser owns the geometry" pattern). A path mutated mid-draw
1712
+ * is a re-construct, not a per-frame re-measure — a per-frame `getTotalLength`
1713
+ * would be a layout round-trip the Mandate's measure-first forbids.
1714
+ *
1715
+ * @param target an SVG geometry element exposing `getTotalLength()`.
1716
+ * @param options `{ from?, to?, ...animationOptions }`.
1717
+ *
1718
+ * @example
1719
+ * // Draw a path stroke in over 2s:
1720
+ * fromDrawSVG(pathEl, { duration: 2000 });
1587
1721
  */
1588
- declare class DrawSVG<V extends Record<string, any> = any> {
1589
- /** The underlying stroke-dashoffset animation — the control handle. */
1590
- readonly animation: CSSKeyframesAnimation<V>;
1591
- constructor(target: SVGDrawTarget, options?: DrawSVGOptions);
1592
- /** Start (or re-enter) the line-drawing play loop. */
1593
- play(): Promise<void>;
1594
- /** Pause the play loop, retaining the playhead. */
1595
- pause(): this;
1596
- /** Halt and rewind the play loop. */
1597
- stop(): this;
1598
- /** Resolve once the draw completes — the {@link Animation.finished} front-door. */
1599
- get finished(): Promise<void>;
1600
- }
1601
-
1602
- export declare interface DrawSVGOptions extends Partial<InputAnimationOptions> {
1603
- /**
1604
- * Start of the draw sweep — a percent STRING (`"0%"` → `"100%"`) or a 0..1
1605
- * NUMBER fraction (`0` → `1`), the two unambiguous forms. Default `"0%"` —
1606
- * the stroke starts undrawn (full `stroke-dashoffset`) and draws IN; `"100%"`
1607
- * → `"0%"` (or `1` → `0`) erases it. A number outside `[0, 1]` throws (a
1608
- * percent must be a string — no silent `50`-means-5000% footgun).
1609
- */
1610
- from?: string | number;
1611
- /** End of the draw sweep — same `"100%"`/`1` two-form contract. Default `"100%"`. */
1612
- to?: string | number;
1613
- /**
1614
- * Auto-start the play loop after construction + targeting. Default true.
1615
- * `false` returns a constructed, targeted, NOT-yet-playing handle so the
1616
- * caller can drive the returned animation (`.play()` / `.pause()` / `.stop()`).
1617
- */
1618
- autoPlay?: boolean;
1619
- }
1722
+ declare function fromDrawSVG<V extends Record<string, any> = any>(target: SVGDrawTarget, options?: DrawSVGOptions): CSSKeyframesAnimation<V>;
1620
1723
 
1621
1724
  /**
1622
- * The typed easing value — a callable curve plus, when one exists, the CSS
1623
- * easing string that reproduces it (e.g. a spring's `linear()` stops).
1725
+ * K1 — `fromLiveAnimations`: adopt every RUNNING CSS animation on the document
1726
+ * (or a single element) by reconstructing each from its source `@keyframes`
1727
+ * RULE (via the CSSOM walk — NOT from `getAnimations().getKeyframes()`, the
1728
+ * computed form that has lost `var()`/`cqw`/oklab). The `getAnimations()` read
1729
+ * provides the SET of live animation names; the reconstruction provides the
1730
+ * authored keyframes. The result maps each live animation name → its
1731
+ * reconstructed kf object (the recovered, axis-preserving source).
1624
1732
  *
1625
- * Replaces the former Symbol-on-a-closure side channel: the "this closure
1626
- * has a CSS twin" fact now flows through the type system, so wrapping or
1627
- * binding the callable can no longer silently drop it. `waapi.ts` reads
1628
- * `.css` to run the true curve on the compositor; everything else reads
1629
- * `.fn`.
1733
+ * Distinct from {@link fromStyleSheets} (which walks EVERY declared `@keyframes`
1734
+ * rule, running or not): `fromLiveAnimations` narrows to the names currently
1735
+ * RUNNING on the page — the animations a user actually sees in motion.
1630
1736
  */
1631
- export declare interface Easing {
1632
- /** The callable curve — the hot-path interpolation function. */
1633
- fn: TimingFunction;
1634
- /** CSS easing string that faithfully reproduces `fn`, when one exists. */
1635
- css?: string;
1636
- }
1737
+ declare const fromLiveAnimations: <V extends Vars = any>(target?: Document | Element, options?: IngestOptions) => IngestResult<V>;
1637
1738
 
1638
1739
  /**
1639
- * Interpolate position and scale between two elements or rects.
1740
+ * Build an SVG path-shape morph: sample two `d` strings at `samples` uniform
1741
+ * arc-length steps each, pair the point sets, and interpolate the `(x, y)`
1742
+ * pairs from the `from`-polyline (`0%`) to the `to`-polyline (`100%`). Returns
1743
+ * the constructed {@link CSSKeyframesAnimation} as the control handle (the
1744
+ * `animate()` contract — `.play()` / `.pause()` / `.stop()` / `.finished`),
1745
+ * consistent with the `from*` factory family.
1640
1746
  *
1641
- * Two usage modes:
1642
- * - **Stateless**: call `.at(progress)` or `.toCSSTransform(progress)`
1643
- * - **Managed**: call `.play(element)` to animate an element from source
1644
- * to destination over the configured duration
1747
+ * value.js's `PathGeometry` owns the geometry (the `d`-parse + arc-length
1748
+ * table, built ONCE per path at construction); the engine's native numeric
1749
+ * `lerp` traverses the per-point coordinate keys. The morphed `d` at any `t` is
1750
+ * reassembled from the interpolated points — read it via the `MorphSVG` class's
1751
+ * {@link MorphSVG.sampleD}.
1752
+ *
1753
+ * Refuses a degenerate input: a zero-length `from` or `to` path throws a typed
1754
+ * {@link AnimationOptionError} rather than faking a silent zero-frame / identity
1755
+ * morph (the honest-or-refuse law — a morph between a zero-length path and
1756
+ * anything is a malformed input, not a morph).
1757
+ *
1758
+ * @param from the source SVG path `d` string.
1759
+ * @param to the target SVG path `d` string (differing geometry).
1760
+ * @param options `{ samples?, target?, orient?, autoPlay?, ...animationOptions }`.
1761
+ *
1762
+ * @example
1763
+ * // Morph a triangle into a square over 1s, RENDERING onto a live <path>:
1764
+ * const path = document.querySelector("path");
1765
+ * const m = fromMorphSVG(
1766
+ * "M 0 0 L 100 0 L 50 100 Z",
1767
+ * "M 0 0 L 100 0 L 100 100 L 0 100 Z",
1768
+ * { duration: 1000, target: path },
1769
+ * );
1770
+ * // each frame the engine writes path.style.d = path("…") + --morph-d so the
1771
+ * // morphing shape paints directly (no author-side reader needed on Chromium/
1772
+ * // Safari; `<path style="d: var(--morph-d)">` is the Firefox-lags fallback).
1645
1773
  */
1646
- export declare class ElementMorph {
1647
- private animation;
1648
- private transformOrigin;
1649
- private timingFunction;
1650
- private duration;
1651
- constructor(from: HTMLElement | MorphRect, to: HTMLElement | MorphRect, options?: ElementMorphOptions);
1652
- /** Re-measure source and destination, rebuilding the internal animation. */
1653
- measure(from: HTMLElement | MorphRect, to: HTMLElement | MorphRect): this;
1654
- /** Get raw transform values at the given progress [0, 1]. */
1655
- at(progress: number): MorphValues;
1656
- /** Get a CSS transform string at the given progress [0, 1]. */
1657
- toCSSTransform(progress: number): string;
1658
- /** Apply the morph transform to an element at the given progress [0, 1]. */
1659
- apply(element: HTMLElement, progress: number): void;
1660
- /**
1661
- * Animate an element from source to destination over the configured duration.
1662
- *
1663
- * @param element — the element to apply transforms to
1664
- * @param duration — override the duration set in constructor options (ms)
1665
- */
1666
- play(element: HTMLElement, duration?: number): Promise<void>;
1667
- /** Cancel a running `.play()` animation. */
1668
- stop(): void;
1669
- }
1774
+ declare function fromMorphSVG<V extends Record<string, any> = any>(from: string, to: string, options?: MorphSVGOptions): CSSKeyframesAnimation<V>;
1670
1775
 
1671
- export declare interface ElementMorphOptions {
1672
- /**
1673
- * Easing as a callable `TimingFunction` or a typed `Easing` —
1674
- * synchronous and value.js-free (`ElementMorph` composes
1675
- * `NumericAnimation`, which enforces the same contract). Resolve a
1676
- * string name first via `await resolveEasing(name)`.
1677
- */
1678
- timingFunction?: TimingFunction | Easing;
1679
- /** Playback duration in milliseconds. Required for `.play()`. */
1680
- duration?: number;
1681
- transformOrigin?: string;
1682
- }
1776
+ /**
1777
+ * Build a CSS-native path-motion animation: set the author `offset-path` (and
1778
+ * optional `offset-rotate`) on the target(s), and sweep `offset-distance` from
1779
+ * → to. Returns the constructed {@link CSSKeyframesAnimation} as the control
1780
+ * handle (the `animate()` contract — `.play()` / `.pause()` / `.stop()` / the
1781
+ * awaitable play promise), consistent with the `from*` factory family.
1782
+ *
1783
+ * The returned animation passes the EXISTING WAAPI eligibility gate
1784
+ * (`isWAAPIEligible`) for a DOM target with a uniform CSS-twin easing, and
1785
+ * delegates compositor-thread via `playWAAPI` — no new eligibility predicate.
1786
+ *
1787
+ * @param target one or more DOM elements (or a single element) to move.
1788
+ * @param options `{ path, from?, to?, rotate?, ...animationOptions }`.
1789
+ *
1790
+ * @example
1791
+ * // Move a box along a quadratic path, facing along it, over 2s:
1792
+ * fromMotionPath(box, {
1793
+ * path: "path('M 0 0 Q 100 -100 200 0')",
1794
+ * rotate: "auto",
1795
+ * duration: 2000,
1796
+ * });
1797
+ */
1798
+ declare function fromMotionPath<V extends Record<string, any> = any>(target: HTMLElement | HTMLElement[], options: MotionPathOptions): CSSKeyframesAnimation<V>;
1683
1799
 
1684
- /** Entrance animations — bring an element INTO view. */
1685
- declare const enterPresets: {
1686
- readonly fadeIn: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
1687
- readonly slideIn: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
1688
- readonly slideInLeft: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
1689
- readonly slideInRight: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
1690
- readonly rotateIn: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
1691
- readonly blurIn: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
1692
- readonly springScaleIn: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
1693
- readonly springSlideIn: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
1694
- readonly jumpUp: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
1695
- };
1800
+ /**
1801
+ * K1 — `fromStyleSheets`: the consumer-facing front door over
1802
+ * {@link resolveLiveKeyframes}. Walk the document's (or the given list's)
1803
+ * stylesheets and return every reconstructed `@keyframes` animation. The honest
1804
+ * `CORS_SKIP`/`PARSE_ERROR` rows ride the returned {@link IngestResult}.
1805
+ *
1806
+ * @example
1807
+ * const { CSSKeyframesAnimation, fromStyleSheets } = await loadAnimationEngine();
1808
+ * const { animations, diagnostics } = fromStyleSheets();
1809
+ * const pulse = animations.get("pulse")?.animation;
1810
+ * pulse?.setTargets(el).play(); // re-drive the page's OWN animation
1811
+ * for (const d of diagnostics) console.warn(d.code, d.message); // honest skips
1812
+ */
1813
+ declare const fromStyleSheets: <V extends Vars = any>(source?: Document | ShadowRoot | CSSStyleSheet[] | CSSStyleSheet, options?: IngestOptions) => IngestResult<V>;
1696
1814
 
1697
- /** Exit animations — take an element OUT of view. */
1698
- declare const exitPresets: {
1699
- readonly fadeOut: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
1700
- readonly slideOutLeft: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
1701
- readonly slideOutRight: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
1702
- readonly blurOut: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
1703
- readonly warpLeft: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
1704
- readonly warpRight: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
1705
- readonly jumpDown: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
1706
- };
1815
+ declare const glow: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
1707
1816
 
1708
- declare const fadeIn: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
1817
+ declare const gradientBackground: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
1709
1818
 
1710
- declare const fadeOut: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
1819
+ declare const heartbeat: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
1711
1820
 
1712
- declare const FILL_MODES: readonly ["none", "forwards", "backwards", "both"];
1821
+ declare const hover: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
1713
1822
 
1714
1823
  /**
1715
- * Animate a layout change on `element`: measure (First), run `mutate` (Last),
1716
- * measure again, then invert + play the transform between them via
1717
- * {@link ElementMorph}. Returns the play promise.
1718
- *
1719
- * @param element — the element whose layout `mutate` changes.
1720
- * @param mutate — a synchronous DOM mutation (class toggle, reparent, …).
1721
- * @param options — `{ duration, timingFunction, transformOrigin }`.
1824
+ * One ingested animation + the diagnostics its reconstruction produced. The
1825
+ * `name` is the `@keyframes` identifier (the CSSOM `CSSKeyframesRule.name`); the
1826
+ * `animation` is the reconstructed `CSSKeyframesAnimation`, already carrying any
1827
+ * sibling-style-rule `animation-*` options. `diagnostics` carries the honesty
1828
+ * rows for THIS rule (a malformed body → `PARSE_ERROR`, etc.); the walk-level
1829
+ * rows (`CORS_SKIP`) ride {@link IngestResult.diagnostics}.
1722
1830
  */
1723
- export declare function flip(element: HTMLElement, mutate: () => void, options?: FlipOptions): Promise<void>;
1831
+ export declare interface IngestedAnimation<V extends Vars = any> {
1832
+ /** The `@keyframes` identifier (CSSOM `CSSKeyframesRule.name`). */
1833
+ name: string;
1834
+ /** The reconstructed kf animation — replay-equal to the source CSS. */
1835
+ animation: CSSKeyframesAnimation<V>;
1836
+ /** Per-rule reconstruction diagnostics (empty on a clean ingest). */
1837
+ diagnostics: Diagnostic[];
1838
+ }
1724
1839
 
1725
- declare const flip_2: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
1840
+ /** Options shared by the ingest entry points. */
1841
+ export declare interface IngestOptions {
1842
+ /**
1843
+ * Restrict the ingest to a single `@keyframes` name. When set, only the
1844
+ * matching rule is reconstructed (the rest are skipped without a
1845
+ * diagnostic — a name filter is an intentional narrowing, not a failure).
1846
+ */
1847
+ animationName?: string;
1848
+ /**
1849
+ * Animation options applied as the BASE for each reconstructed animation,
1850
+ * BELOW any sibling-style-rule `animation-*` declarations the source CSS
1851
+ * carries (the source's declared options win — the round-trip preserves the
1852
+ * AUTHORED timing). Empty by default.
1853
+ */
1854
+ options?: Partial<InputAnimationOptions>;
1855
+ }
1726
1856
 
1727
- export declare interface FlipOptions {
1728
- /** Playback duration in milliseconds. Defaults to `300`. */
1729
- duration?: number;
1857
+ /**
1858
+ * The result of a CSSOM walk: every `@keyframes` rule reconstructed into a kf
1859
+ * animation, plus the WALK-LEVEL diagnostics (the `CORS_SKIP` rows a
1860
+ * cross-origin sheet produces — the honesty surface S3). A consumer reads
1861
+ * `animations` for the recovered objects and `diagnostics` for the citable
1862
+ * reasons the walk could not complete a step faithfully — NEVER a silent drop.
1863
+ */
1864
+ export declare interface IngestResult<V extends Vars = any> {
1865
+ /** Every `@keyframes` rule reconstructed, keyed by its CSS name. */
1866
+ animations: Map<string, IngestedAnimation<V>>;
1730
1867
  /**
1731
- * Easing for the play phase — a callable {@link TimingFunction} or typed
1732
- * {@link Easing} (e.g. `springTimingFunction(...)` for a springy FLIP).
1733
- * A string name is rejected; resolve it via `await resolveEasing(name)`.
1868
+ * Walk-level diagnostics — the `CORS_SKIP` rows (a cross-origin sheet whose
1869
+ * `cssRules` throws `SecurityError`) and any other reason the walk could not
1870
+ * read a sheet. A typed {@link Diagnostic}[] on the same stable-`code` idiom
1871
+ * as `resolveKeyframes`; empty when every sheet was same-origin + parsed.
1734
1872
  */
1735
- timingFunction?: TimingFunction | Easing;
1736
- transformOrigin?: string;
1873
+ diagnostics: Diagnostic[];
1737
1874
  }
1738
1875
 
1739
1876
  /**
1740
- * Shared-element FLIP: animate element `a` onto the rect of element `b`
1741
- * (Motion's `layoutId` / GSAP Flip shared-element style). Unlike `flip`, `a`
1742
- * does NOT move in the DOM — it stays at its own rect (First) and the morph
1743
- * carries it FORWARD onto `b`'s rect (Last). So this is a plain forward
1744
- * {@link ElementMorph} play (identity at t=0 → full delta at t=1), not the
1745
- * inversion `flip` runs.
1746
- *
1747
- * The two reads are batched — one forced layout each, before any write.
1748
- *
1749
- * @param a — the element to animate.
1750
- * @param b — the element whose rect `a` morphs onto.
1751
- * @param options — `{ duration, timingFunction, transformOrigin }`.
1877
+ * The INGEST surface (L.W7 S3 `loadIngest()`) — the engine core PLUS the
1878
+ * forward-pointed live-web walk (`fromStyleSheets` / `fromLiveAnimations` /
1879
+ * `resolveLiveKeyframes` / `adoptRunning`) and the scroll-grammar round-trip
1880
+ * (`ScrollScene` + `parseScrollCSS` / `serializeScrollOptions` / …). A
1881
+ * consumer ingesting CSSOM / adopting a running animation / driving a scroll
1882
+ * scene pays for `engine` + `ingest` + `scroll-scene`, not the compile /
1883
+ * motion / draw / preset weight.
1752
1884
  */
1753
- export declare function flipShared(a: HTMLElement, b: HTMLElement, options?: FlipOptions): Promise<void>;
1885
+ export declare interface IngestSurface extends EngineCore {
1886
+ fromStyleSheets: typeof fromStyleSheets;
1887
+ fromLiveAnimations: typeof fromLiveAnimations;
1888
+ resolveLiveKeyframes: typeof resolveLiveKeyframes;
1889
+ adoptRunning: typeof adoptRunning;
1890
+ ScrollScene: typeof ScrollScene;
1891
+ createScrollScene: typeof createScrollScene;
1892
+ parseScrollCSS: typeof parseScrollCSS;
1893
+ parseScrollTimeline: typeof parseScrollTimeline;
1894
+ parseScrollRange: typeof parseScrollRange;
1895
+ serializeScrollOptions: typeof serializeScrollOptions;
1896
+ roundTripScrollCSS: typeof roundTripScrollCSS;
1897
+ dispatchScrollBackend: typeof dispatchScrollBackend;
1898
+ resolveRange: typeof resolveRange;
1899
+ pinCSS: typeof pinCSS;
1900
+ }
1754
1901
 
1755
- declare class FrameCompiler<V extends Vars = any> {
1756
- private readonly _options;
1757
- templateFrames: TemplateAnimationFrame<V>[];
1758
- parsedVars: ParsedVarMap[];
1759
- frames: AnimationFrame<V>[];
1902
+ export declare type InputAnimationOptions = Partial<{
1903
+ duration: number | string;
1904
+ delay: number | string;
1905
+ iterationCount: number | string | "infinite" | undefined;
1906
+ direction: (typeof DIRECTIONS)[number];
1907
+ fillMode: (typeof FILL_MODES)[number];
1908
+ timingFunction: TimingFunction | Easing | TimingFunctionNames | string | undefined;
1909
+ /** When true (default), eligible animations may use the Web Animations API for compositor-thread execution. Set to false to force rAF. */
1910
+ useWAAPI: boolean;
1911
+ /** When true, snap `play()` to the final frame under `prefers-reduced-motion: reduce`. Default false. */
1912
+ respectReducedMotion: boolean;
1913
+ colorSpace?: ColorSpace;
1914
+ hueMethod?: HueInterpolationMethod;
1915
+ /** The LAYER-level `animation-composition` operator (L.W1 S5). Omission ⇒ `replace`. */
1916
+ composite?: CompositeOperator;
1917
+ }>;
1918
+
1919
+ export { InterpolatedVar }
1920
+
1921
+ declare const jumpDown: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
1922
+
1923
+ declare const jumpUp: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
1924
+
1925
+ /** A keyframe map: percent/keyword stops → partial var frames. */
1926
+ export declare type KeyframeMap<V extends Vars> = Map<string, Partial<V>> | Record<string, Partial<V>>;
1927
+
1928
+ /**
1929
+ * The core animation engine — keyframes, timing, interpolation, playback.
1930
+ *
1931
+ * ── PKG-3 RENAME (L.W8 §S4 · audit W126). Formerly `Animation`; renamed to
1932
+ * `KeyframesAnimation` because the old name collided with the ambient
1933
+ * `globalThis.Animation` (WAAPI), leaking a numeric-suffixed collision alias
1934
+ * into the d.ts roll-up (packaging-k.md:118-127). The legacy `Animation`
1935
+ * backward-compat RE-EXPORT alias was DROPPED in 5.0.0 (Q.WE1 — NO-LEGACY).
1936
+ * Gated by `proof:pkg3-clean`. The runtime constructor is `KeyframesAnimation`.
1937
+ */
1938
+ export declare class KeyframesAnimation<V extends Vars = any> {
1939
+ id: number;
1940
+ name: string | undefined;
1941
+ superKey: string | undefined;
1942
+ targets: HTMLElement[];
1943
+ options: AnimationOptions;
1944
+ /**
1945
+ * The frame-compilation half — template frames → sampled `frames[]`.
1946
+ * `Animation` composes one and delegates `addFrame`/`parse` + the frame
1947
+ * accessors (`templateFrames`/`parsedVars`/`frames`/`frameId`) to it.
1948
+ * Assigned in the constructor once `options` exists (the compiler holds a
1949
+ * live reference to that options object).
1950
+ *
1951
+ * READ-ONLY surface (G.W19): the backing `_compiler` is written ONLY by the
1952
+ * constructor and {@link adoptCompiled}. An external `animation.compiler = …`
1953
+ * write was the one cross-boundary reach-in vector that could desync the
1954
+ * live-options reference (`this.options !== this.compiler.options`); making
1955
+ * `compiler` a get-only accessor makes that reach-in a COMPILE error, not a
1956
+ * convention. Adopt a compiled state via `adoptCompiled(source)`.
1957
+ */
1958
+ private _compiler;
1959
+ get compiler(): FrameCompiler<V>;
1960
+ /**
1961
+ * THE rAF owner for this animation — the standalone rAF play loop and
1962
+ * the WAAPI shadow tick both ride it, so `stop()` halts either
1963
+ * uniformly and no raw rAF handle leaks onto the instance.
1964
+ */
1965
+ readonly playback: RAFPlayback;
1966
+ /**
1967
+ * The live WAAPI compositor animations during a `_playWAAPI` delegation
1968
+ * (one per target), populated by `playWAAPI` and cleared on teardown.
1969
+ * The lifecycle methods (`stop`/`reset`) cancel these so a stopped
1970
+ * compositor animation never keeps painting and the awaited play
1971
+ * promise never hangs. Empty on the rAF path.
1972
+ */
1973
+ _waAnimations: globalThis.Animation[];
1974
+ startTime: number | undefined;
1975
+ pausedTime: number;
1976
+ t: number;
1977
+ iteration: number;
1978
+ /**
1979
+ * Structured parse/honoring diagnostics (K.W7 S4) — surfaced from the
1980
+ * adapter's `resolveKeyframes` ({@link CSSKeyframesAnimation.fromString})
1981
+ * and joined by the engine's own composition-fallback rows. A FLAT additive
1982
+ * array of stable-coded {@link Diagnostic} rows; empty on a clean parse with
1983
+ * no fallback. Every SILENT fallback site is mirrored here — the honesty
1984
+ * surface (`proof:diagnostics-channel`). Queryable; no console output.
1985
+ */
1986
+ diagnostics: Diagnostic[];
1987
+ /**
1988
+ * The captured UNDERLYING base value for each composited leaf (K.W7 S1),
1989
+ * keyed by the flat property key — the per-element numeric base the
1990
+ * `add`/`accumulate` operator accumulates ONTO (snapshotted the first time a
1991
+ * composited leaf is applied). Empty for a pure-`replace` animation (the
1992
+ * zero-overhead path). The capture/accumulate logic lives in
1993
+ * `./engine-composition` ({@link applyComposition}/`captureUnderlyingBase`).
1994
+ */
1995
+ private _compositionBase;
1996
+ /** Properties whose non-numeric composite already emitted its
1997
+ * `COMPOSITION_FALLBACK` row — so a long playback emits the honesty row
1998
+ * ONCE per property, not once per frame (S3/S4). */
1999
+ private _compositionFallbackSeen;
2000
+ /** True once `fromString`/`addFrame` saw a non-`replace` operator — the hot
2001
+ * path skips ALL composition work when this is false (the predictable
2002
+ * per-animation-constant branch the §gate's clause (f) measures free). */
2003
+ private _hasComposition;
2004
+ started: boolean;
2005
+ done: boolean;
2006
+ reversed: boolean;
2007
+ paused: boolean;
2008
+ /**
2009
+ * True when an `AnimationGroup` is driving this animation's
2010
+ * `advanceTo()` and `interpFrames()` from its own rAF loop. Set by
2011
+ * the group at construction; standalone `.play()` / `.draw()`
2012
+ * throw when this is true rather than racing the group.
2013
+ */
2014
+ managed: boolean;
2015
+ /**
2016
+ * If the most recent `play()` was rejected by WAAPI eligibility
2017
+ * but `useWAAPI: true` was requested, this records the reason.
2018
+ * Queryable by debug builds — no console output is produced.
2019
+ */
2020
+ waapiIneligibleReason: string | undefined;
2021
+ unflatten: boolean;
2022
+ private resolvePromise;
2023
+ private _playingPromise;
2024
+ /**
2025
+ * Pre-bound frame callback — allocated once to avoid creating a new
2026
+ * closure on every playback loop start.
2027
+ */
2028
+ private _boundFrame;
2029
+ /**
2030
+ * The ONE output buffer for the standalone play loop's `interpFrames`
2031
+ * calls — reused every frame so steady-state playback allocates no
2032
+ * per-frame result object (the primitive-level analogue of the group's
2033
+ * hoisted `_grouped` buffer, gated by `proof:standalone-zero-alloc`).
2034
+ * The play path (`_frame`) never returns this object to a consumer, so
2035
+ * reuse is safe; `at()` (a query whose result the caller keeps) still
2036
+ * allocates a fresh object.
2037
+ */
2038
+ private _interpOut;
2039
+ /**
2040
+ * The compile-stable union of every frame's `flatVars` keys — the maximal
2041
+ * key-set any `interpFrames` call can write. Fixed at `parse` (the keys
2042
+ * never change across frames; a color-space renormalize re-derives the same
2043
+ * carriers under the same keys). It is what `clearBuffer` null-fills to keep
2044
+ * a reused buffer stale-free WITHOUT `delete` (F.W4 S1 — the V8 dictionary-
2045
+ * mode trap the delete-loop fell into). Exposed (read-only) as `flatKeys`
2046
+ * so the `AnimationGroup` can size its own composite buffer the same way.
2047
+ */
2048
+ private _stableKeys;
2049
+ /**
2050
+ * The consumer's EXPLICIT constructor options (NOT merged with defaults) —
2051
+ * retained so `fromString` can layer a parsed style-rule `animation`
2052
+ * shorthand UNDER them (constructor-explicit wins over parsed-from-CSS, F.W8).
2053
+ */
2054
+ protected _ctorOptions: Partial<InputAnimationOptions>;
2055
+ /** The compile-stable union of this animation's interpolated keys. */
2056
+ get flatKeys(): readonly string[];
2057
+ /**
2058
+ * The instance's ONE default DOM-style renderer, allocated once.
2059
+ * "Did the consumer supply a custom transform?" is a reference
2060
+ * comparison against this single value ({@link usesDefaultRenderer}) —
2061
+ * typed and bind-proof, unlike a Symbol tag on a closure, which
2062
+ * `Function.prototype.bind` silently drops.
2063
+ */
2064
+ protected readonly _defaultTransform: TransformFunction<V>;
2065
+ /** True when `fn` is this instance's default DOM-style renderer. */
2066
+ usesDefaultRenderer(fn: TransformFunction<V> | undefined): boolean;
2067
+ private dispatchAnimationEvent;
2068
+ constructor(options?: Partial<InputAnimationOptions>, targets?: HTMLElement[] | HTMLElement | undefined, name?: string | undefined, superKey?: string | undefined);
2069
+ get templateFrames(): TemplateAnimationFrame<V>[];
2070
+ set templateFrames(value: TemplateAnimationFrame<V>[]);
2071
+ get parsedVars(): ParsedVarMap[];
2072
+ get frames(): AnimationFrame<V>[];
2073
+ get frameId(): number;
2074
+ /** Append a template frame (delegated to the compiler). Chainable. */
2075
+ addFrame<K extends V>(start: number | string | ValueUnit<number>, vars: Partial<K>, transform?: TransformFunction<K>, timingFunction?: InputAnimationOptions["timingFunction"], composition?: CompositeOperator): KeyframesAnimation<K>;
2076
+ /** Compile the template frames into the sampled `frames[]`. Chainable. */
2077
+ parse(): this;
2078
+ /**
2079
+ * Set `_hasComposition` (K.W7 S1) — true iff ANY compiled frame carries a
2080
+ * non-`replace` `animation-composition` operator (the hot-path branch reads
2081
+ * this ONE per-animation constant; a pure-`replace` animation never pays for
2082
+ * the composition work) — and reset the per-run base/fallback caches so a
2083
+ * re-parse re-snapshots the underlying base. See `./engine-composition`.
2084
+ */
2085
+ private computeHasComposition;
2086
+ /**
2087
+ * Adopt another animation's ALREADY-COMPILED state as ONE atomic motion
2088
+ * (G.W19) — the first-class verb for the "single-compile, then transplant"
2089
+ * pattern (E.W8 S0): a throwaway animation is built + compiled ONCE off the
2090
+ * new keyframes, and the live animation adopts that compiled state without a
2091
+ * second compile.
2092
+ *
2093
+ * The transplant moves the `{ compiler, options, unflatten }` triad together
2094
+ * and re-binds the live-options reference BY CONSTRUCTION — `this.options` is
2095
+ * read OFF the adopted compiler, so `this.options === this.compiler.options`
2096
+ * holds without relying on the caller's assignment order. This is the
2097
+ * invariant the demo formerly held by a comment + three ordered field writes;
2098
+ * here it is the method's contract, enforced by `proof:adopt-compiled`. A
2099
+ * `compiler` adopted WITHOUT re-binding `options` would leave the setters
2100
+ * mutating one object while the compiler reads another — the exact desync
2101
+ * the `6e29236` live-options lock guards against.
2102
+ *
2103
+ * Recomputes `_stableKeys` so `flatKeys` (the buffer-sizing contract)
2104
+ * reflects the adopted compiled frames, not the pre-adopt key-set. Chainable.
2105
+ *
2106
+ * @param source an animation whose `compiler` is already compiled.
2107
+ */
2108
+ adoptCompiled(source: KeyframesAnimation<V>): this;
2109
+ /**
2110
+ * Recompute `_stableKeys` — the union of every compiled frame's `flatVars`
2111
+ * keys — after a (re)compile. The maximal key-set the `clearBuffer`
2112
+ * null-fill resets, so a reused interpolation buffer stays in V8
2113
+ * fast-properties mode without ever calling `delete` (F.W4 S1).
2114
+ */
2115
+ private computeStableKeys;
2116
+ /**
2117
+ * Option setters — the fail-explicit contract.
2118
+ *
2119
+ * Genuine omission (`undefined`/`null`) means "use the default" and is
2120
+ * always accepted; present-but-malformed input THROWS a typed
2121
+ * `AnimationOptionError` naming the option and the offending value.
2122
+ * This is the same posture the layer API chose ("silent no-ops were
2123
+ * hiding consumer bugs") applied to the whole options surface — no
2124
+ * silent fallback, no silently-preserved previous value.
2125
+ */
2126
+ setTimingFunction(timingFunction: InputAnimationOptions["timingFunction"]): this;
2127
+ setIterationCount(iterationCount: InputAnimationOptions["iterationCount"]): this;
2128
+ setDuration(duration: InputAnimationOptions["duration"]): this;
2129
+ setDelay(delay: InputAnimationOptions["delay"]): this;
2130
+ setDirection(direction: InputAnimationOptions["direction"]): this;
2131
+ setFillMode(fillMode: InputAnimationOptions["fillMode"]): this;
2132
+ setUseWAAPI(useWAAPI: InputAnimationOptions["useWAAPI"]): this;
2133
+ setRespectReducedMotion(respectReducedMotion: InputAnimationOptions["respectReducedMotion"]): this;
2134
+ setColorSpace(colorSpace: InputAnimationOptions["colorSpace"]): this;
2135
+ setHueMethod(hueMethod: InputAnimationOptions["hueMethod"]): this;
2136
+ /**
2137
+ * Set the LAYER-level `animation-composition` operator (L.W1 S5, Band A).
2138
+ * Genuine omission (`undefined`) leaves the field unset — the serializer
2139
+ * treats it as the CSS default `replace` and omits the longhand. A present
2140
+ * value is stored verbatim (`replace` | `add` | `accumulate`), so a sibling
2141
+ * `.class { animation-composition: add }` ingested by `fromString`
2142
+ * round-trips on re-serialize.
2143
+ */
2144
+ setComposite(composite: InputAnimationOptions["composite"]): this;
2145
+ setOptions(options: Partial<InputAnimationOptions>): this;
2146
+ reverse(): this;
2147
+ fillForwards(): void;
2148
+ fillBackwards(): void;
1760
2149
  /**
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.
2150
+ * Where the playhead rests after a completed play — derived ONCE from
2151
+ * `fillMode` (forwards/both → final; none/backwards → initial). This is
2152
+ * the explicit rest-position contract: completion paints the rest frame
2153
+ * per this derivation, and the reduced-motion snap is "rest = final,
2154
+ * paint it, settle" — the same path a `fillMode: forwards` completion
2155
+ * takes, not a separate code path.
1765
2156
  */
1766
- frameId: number;
2157
+ get restPosition(): "initial" | "final";
2158
+ /** Paint the rest frame per the fill contract. */
2159
+ paintRest(): void;
1767
2160
  /**
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.
2161
+ * Q.WD1 S3 (DM-22) — the named-selector PLAY-TIME guard. A scroll-range named
2162
+ * selector (`entry`/`exit`/`cover`/`contain`) ingests + round-trips opaquely
2163
+ * (the L.W1 S4 floor — `fromString`/`parse()` NEVER throw); it is RESOLVABLE to
2164
+ * a numeric `%` only under a `ScrollTimeline`/`ManualTimeline` via
2165
+ * `bindTimeline`. If a numeric position is genuinely DEMANDED (`play()`/`at()`)
2166
+ * while a template frame still carries `NAMED_SELECTOR_SUPERTYPE` (unresolved —
2167
+ * `bindTimeline` was never called), refuse with the TYPED
2168
+ * `NAMED_SELECTOR_NO_TIMELINE` rather than silently producing NaN frames that
2169
+ * `binarySearchRange` treats as ALWAYS-ACTIVE. Fired ONLY at the genuinely-
2170
+ * demanded point — NEVER at parse/ingest (the reverted Path-A trap). A resolved
2171
+ * frame (the superType tag CLEARED by `bindTimeline`) passes silently — this is
2172
+ * a zero-cost `Array.find` over `templateFrames` whose starts are `%`/`from`/
2173
+ * `to` (no `superType`) on a non-named animation.
2174
+ */
2175
+ private assertNoUnresolvedNamedSelector;
2176
+ /**
2177
+ * Stateless progress query. Maps [0,1] from first keyframe to last,
2178
+ * regardless of playback direction. `apply=true` invokes transform callbacks.
1777
2179
  */
1778
- constructor(_options: AnimationOptions);
2180
+ at(progress: number, apply?: boolean): Record<string, ValueUnit[]>;
1779
2181
  /**
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.
2182
+ * Interpolate all active frames at time `t`. This is the hot path —
2183
+ * called once per rAF frame during playback.
2184
+ *
2185
+ * Uses binary search (O(log N)) to find the first matching frame,
2186
+ * then scans neighbors to collect all overlapping frames at `t`
2187
+ * (multiple properties may share the same time range).
2188
+ *
2189
+ * @param t - Current animation time in milliseconds
2190
+ * @param transformFrames - If true, applies each frame's transform function to targets
2191
+ * @param out - Optional output object to write results into. When
2192
+ * provided, its keys are cleared first so no stale keys from a
2193
+ * previous call leak through. Pass this per-animation to achieve
2194
+ * zero-allocation steady-state playback.
2195
+ * @returns Merged flat vars from all active frames
1786
2196
  */
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>;
2197
+ interpFrames(t: number, transformFrames?: boolean, out?: Record<string, ValueUnit[]>): Record<string, ValueUnit[]>;
1790
2198
  /**
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.
2199
+ * Clear a reused interpolation buffer to a stale-free state WITHOUT
2200
+ * `delete` — the V8-correct stable-key null-fill (F.W4 S1). The key-set is
2201
+ * compile-stable (`_stableKeys` is the union of every frame's `flatVars`
2202
+ * keys, fixed at `parse`), so null-filling it keeps the buffer in
2203
+ * fast-properties mode AND zero-alloc. Inactive keys read back `undefined`;
2204
+ * every consumer of a reused buffer (the group blend, the unused play-loop
2205
+ * `_interpOut`) skips them — only the standalone return path (which never
2206
+ * reuses a buffer) must be `undefined`-free, and it takes the alias / fresh
2207
+ * merge above.
1794
2208
  */
1795
- private buildVarIndex;
2209
+ private clearBuffer;
1796
2210
  /**
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.
2211
+ * Interpolate ONE active frame at time `t` in place (lerp + optional
2212
+ * transform). Lifted off the `interpFrames` hot loop so playback allocates
2213
+ * no per-frame closure. A zero-width frame (`start === stop`, a degenerate
2214
+ * keyframe pair) snaps to the endpoint instead of dividing by zero in
2215
+ * `scale` (E-RT-5). The merge into the result buffer is done by the caller
2216
+ * (F.W4 S3 — so the single-frame path can alias `flatVars` with no copy).
2217
+ */
2218
+ private processFrame;
2219
+ /**
2220
+ * Composite ONE frame's lerped numeric leaves onto the captured underlying
2221
+ * base per its `animation-composition` operator (K.W7 S1) — the thin engine
2222
+ * seam threading the live per-run state into the pure `./engine-composition`
2223
+ * honoring (where the un-clamped add, repeat-aware accumulate, captured base,
2224
+ * and non-numeric `replace`-fallback + `COMPOSITION_FALLBACK` row live).
2225
+ */
2226
+ private applyComposition;
2227
+ /** SYNC unless `delay > 0` — then a thenable resolving after the sleep. */
2228
+ onStart(): Promise<void> | undefined;
2229
+ onEnd(): void;
2230
+ /**
2231
+ * Advance the playhead to absolute clock `t` (a rAF timestamp, NOT a
2232
+ * delta). Lazily runs `onStart` on the first call, reconciles the
2233
+ * pause/resume clock, and ends the iteration once `t` reaches the
2234
+ * duration. This is the DRIVER-layer advance — the one meaning of the
2235
+ * absolute-clock step, distinct from the `tickDt(dt)` stepper surface
2236
+ * the rest of the engine canonicalized to.
1800
2237
  *
1801
- * Uses a pre-built variable index (from buildVarIndex) to avoid
1802
- * O(frames²) findIndex scans.
2238
+ * SYNC on the steady path (J.W6 S1 — the F.W5 held half, landed): every
2239
+ * post-start frame returns a plain number (no per-frame promise+microtask
2240
+ * hop); a thenable ONLY when the FIRST tick awaits the genuinely-async
2241
+ * delay sleep. Ordering locked by proof:event-ordering.
1803
2242
  */
1804
- reconcileVars(ix: number, varIndex: Map<string, number[]>): void;
2243
+ advanceTo(t: number): number | Promise<number>;
2244
+ private get _host();
1805
2245
  /**
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.
2246
+ * One frame of the standalone rAF play path, driven by the shared
2247
+ * `RAFPlayback.loop`. Returns whether the loop should continue.
1809
2248
  */
1810
- parse(targets: HTMLElement[]): void;
2249
+ private _frame;
1811
2250
  /**
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.
2251
+ * The completion front-door (G.W13) — `await anim.finished` resolves once
2252
+ * the in-flight play settles. It exposes the ONE held `_playingPromise`
2253
+ * `play()` already constructs (the re-entrant guard returns it; the
2254
+ * `finally`-clear nulls it on settle) — NOT a second completion lifecycle.
2255
+ * Two reads mid-play return the SAME promise. A settled (or never-played)
2256
+ * animation reads `null` and resolves immediately: "not running" = "nothing
2257
+ * to await" — the honest semantics for a getter that reports current
2258
+ * settledness, not a pre-armed future run.
1817
2259
  */
1818
- private finalizeFrameVars;
2260
+ get finished(): Promise<void>;
2261
+ play(): Promise<void>;
1819
2262
  /**
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.
2263
+ * Pause playback — idempotent. Pausing an already-paused (or
2264
+ * not-yet-started) animation is a no-op, never a resume: a method named
2265
+ * `pause` pauses. Use {@link resume} for the explicit resume.
1832
2266
  */
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 {
2267
+ pause(): this;
2268
+ resume(): this;
2269
+ /** The explicit flip: pauses if playing, resumes if paused. */
2270
+ toggle(): this;
2271
+ /**
2272
+ * Halt playback where it stands: cancel the loop AND the WAAPI
2273
+ * compositor animations, settle state, and resolve any pending `play()`
2274
+ * promise. Never paints — `reset()` is the explicit rewind.
2275
+ */
2276
+ stop(): void;
2277
+ playing(): boolean;
2278
+ /** Returns the effective time accounting for direction reversal. */
2279
+ get effectiveT(): number;
1943
2280
  /**
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).
2281
+ * Pure state teardown — flags, clocks, iteration. NEVER paints. This is
2282
+ * the terminal half of the rest-position contract: completion paints
2283
+ * the rest frame (via `onEnd` → `paintRest`) and then settles; the
2284
+ * reduced-motion snap paints final and then settles. Settling is
2285
+ * orthogonal to where the pixels rest.
1947
2286
  */
1948
- animationName?: string;
2287
+ settle(): this;
1949
2288
  /**
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.
2289
+ * Explicit rewind: paint the INITIAL frame, then settle. This is the
2290
+ * user-facing "return to start" — rest position `initial`, painted
2291
+ * deliberately — distinct from `settle()`, which tears down state and
2292
+ * leaves the pixels where they rest.
1954
2293
  */
1955
- options?: Partial<InputAnimationOptions>;
2294
+ reset(): this;
2295
+ setTargets(...targets: HTMLElement[]): this;
2296
+ /**
2297
+ * Q.WB1 — the emerging-CSS Phase-2 SECOND resolution pass (the gestalt P.W13
2298
+ * designed: ONE rewriter, a SECOND lifecycle point — element-populated env,
2299
+ * SAME `ResolveContext` shape). Runs over the PRE-FLATTEN
2300
+ * `compiler.templateFrames[i].vars` snapshot (the Phase-1-resolved, unflattened
2301
+ * `Record<string, ValueArray>` `parse()` re-flattens via
2302
+ * `parseAndFlattenObject`), so a Phase-1-resolved leaf — already a concrete
2303
+ * `ValueUnit` — is returned as-is by `resolveNode`, making the pass idempotent
2304
+ * over the Phase-1 result. Gated by `hasPhase2Node`: a declaration with NO
2305
+ * element-aware node is never re-resolved (zero second-pass cost).
2306
+ *
2307
+ * SSR-safe: with no bound target (or a target with no `parentElement`) the env
2308
+ * fields are OMITTED, so a residual node stays unresolved (never a throw on
2309
+ * `getComputedStyle(undefined)`) — the same posture Phase 1 holds for
2310
+ * `style(--p)` today.
2311
+ *
2312
+ * @returns `true` iff at least one template carried a Phase-2 node and the
2313
+ * compiler was re-`parse()`d (so `setTargets` skips its fast propagate).
2314
+ */
2315
+ private _resolveElementAwareValues;
2316
+ /**
2317
+ * Q.WB1 — build the element-AWARE {@link ResolveEnv} from the bound target (the
2318
+ * precondition for the Phase-2 second pass). SSR-safe: with no target / no
2319
+ * `parentElement`, the relevant field is OMITTED (not assigned), so the residual
2320
+ * node stays unresolved rather than throwing. Built ONCE per `setTargets` — the
2321
+ * pass is a compile-time lowering, never on the hot path.
2322
+ *
2323
+ * @returns the populated env, or `undefined` when no target is bound at all
2324
+ * (the whole pass is skipped — nothing element-aware can resolve).
2325
+ */
2326
+ private _buildElementAwareEnv;
2327
+ group(...animations: KeyframesAnimation<V>[]): AnimationGroup<V>;
1956
2328
  }
1957
2329
 
1958
2330
  /**
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.
2331
+ * The JS scroll-progress sampler.
2332
+ *
2333
+ * ── PKG-3 RENAME (L.W8 §S4 · audit W126). Formerly `ScrollTimeline`. Renamed
2334
+ * `ScrollTimeline` → `KeyframesScrollTimeline` because the rolled-up d.ts
2335
+ * declaration `ScrollTimeline` collided with the ambient `globalThis.ScrollTimeline`
2336
+ * (the Houdini native scroll timeline): API Extractor renamed the colliding
2337
+ * source class and re-exported it under a numeric-suffixed alias that leaked
2338
+ * into IDE hover text. Naming the class `KeyframesScrollTimeline` (no ambient
2339
+ * collision) clears the rename; gated by `proof:pkg3-clean`. The legacy
2340
+ * `ScrollTimeline` backward-compat RE-EXPORT alias was DROPPED in 5.0.0
2341
+ * (Q.WE1 — NO-LEGACY).
1964
2342
  */
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[];
2343
+ export declare class KeyframesScrollTimeline extends Timeline {
2344
+ private threshold;
2345
+ private getScrollY;
2346
+ private getViewportHeight;
2347
+ constructor(options?: KeyframesScrollTimelineOptions);
2348
+ protected sample(): number;
1975
2349
  }
1976
2350
 
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>>;
2351
+ export declare interface KeyframesScrollTimelineOptions extends TimelineOptions {
2352
+ /** Viewport fraction for full progress. Default 0.35. */
2353
+ threshold?: number | undefined;
2354
+ /** Custom scroll position supplier. Default: window.scrollY. */
2355
+ getScrollY?: (() => number) | undefined;
2356
+ /** Custom viewport height supplier. Default: window.innerHeight. */
2357
+ getViewportHeight?: (() => number) | undefined;
2358
+ }
2000
2359
 
2001
2360
  /**
2002
2361
  * Options for `AnimationGroup.transitionLayer` / `crossfade` (K.W11 PHYS-C).
@@ -2007,26 +2366,14 @@ export declare type KeyframeMap<V extends Vars> = Map<string, Partial<V>> | Reco
2007
2366
  */
2008
2367
  declare type LayerTransitionSpring = Partial<Omit<SpringProgressOptions, "initial" | "initialVelocity">>;
2009
2368
 
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
2369
  export declare const loadAnimationEngine: () => Promise<AnimationEngine>;
2029
2370
 
2371
+ export declare const loadCompiler: () => Promise<CompilerSurface>;
2372
+
2373
+ export declare const loadEngine: () => Promise<EngineCore>;
2374
+
2375
+ export declare const loadIngest: () => Promise<IngestSurface>;
2376
+
2030
2377
  /** Looping animations — run continuously (`iterationCount: Infinity`). */
2031
2378
  declare const loopPresets: {
2032
2379
  readonly heartbeat: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
@@ -2048,6 +2395,19 @@ export declare class ManualTimeline extends Timeline {
2048
2395
  protected sample(): number;
2049
2396
  }
2050
2397
 
2398
+ /** A sampled point on a path polyline. */
2399
+ export declare interface MorphPoint {
2400
+ x: number;
2401
+ y: number;
2402
+ /**
2403
+ * The tangent angle (radians) of the source path at this point — populated
2404
+ * ONLY when the morph is built with `orient: true` (the
2405
+ * `PathGeometry.sampleAtLength` tangent, the `rotate: auto` value). Absent
2406
+ * (`undefined`) on a position-only morph (the default ~130-key floor).
2407
+ */
2408
+ angle?: number;
2409
+ }
2410
+
2051
2411
  export declare interface MorphRect {
2052
2412
  x: number;
2053
2413
  y: number;
@@ -2055,6 +2415,88 @@ export declare interface MorphRect {
2055
2415
  height: number;
2056
2416
  }
2057
2417
 
2418
+ /**
2419
+ * `MorphSVG` — the class form of {@link fromMorphSVG}, for callers who prefer a
2420
+ * named primitive alongside `CSSKeyframesAnimation` / `MotionPath` / `DrawSVG`.
2421
+ * Construction is the factory: `new MorphSVG(from, to).animation` is the control
2422
+ * handle. The factory is the canonical entry; this is a thin ergonomic wrapper
2423
+ * that ALSO exposes {@link sampleD} — the morphed `d` string at a normalized
2424
+ * `t`, reassembled from the interpolated point coordinates.
2425
+ */
2426
+ declare class MorphSVG<V extends Record<string, any> = any> {
2427
+ /** The underlying coordinate-interpolating animation — the control handle. */
2428
+ readonly animation: CSSKeyframesAnimation<V>;
2429
+ /** The uniform-sample count (point pairs = samples + 1). */
2430
+ readonly samples: number;
2431
+ constructor(from: string, to: string, options?: MorphSVGOptions);
2432
+ /**
2433
+ * The morphed SVG path `d` string at a normalized `t` in `[0, 1]`, built
2434
+ * from the engine's interpolated point coordinates (`0` → the `from`
2435
+ * polyline, `1` → the `to` polyline, `0.5` → the point-wise midpoint). The
2436
+ * value a consumer renders (`<path d>` / a `d:` custom property), distinct
2437
+ * from BOTH endpoint polylines at any interior `t`.
2438
+ */
2439
+ sampleD(t: number): string;
2440
+ /** Start (or re-enter) the morph play loop. */
2441
+ play(): Promise<void>;
2442
+ /** Pause the play loop, retaining the playhead. */
2443
+ pause(): this;
2444
+ /** Halt and rewind the play loop. */
2445
+ stop(): this;
2446
+ /** Resolve once the morph completes — the {@link Animation.finished} front-door. */
2447
+ get finished(): Promise<void>;
2448
+ }
2449
+
2450
+ export declare interface MorphSVGOptions extends Partial<InputAnimationOptions> {
2451
+ /**
2452
+ * The number of uniform arc-length steps each path is sampled at. The
2453
+ * morph emits `samples + 1` point-pairs (the endpoints inclusive), and the
2454
+ * MATCHED count between the `0%` and `100%` frames is what makes the
2455
+ * polyline channel interpolable. Default `64` — the keystone-validated
2456
+ * resolution. Must be an integer `>= 2` (a 1-sample "morph" is just the two
2457
+ * endpoints with no body); a smaller / non-integer value throws.
2458
+ */
2459
+ samples?: number;
2460
+ /**
2461
+ * Optional target the morph drives. When given, the morph reassembles the
2462
+ * interpolated polyline into a `d` string EACH FRAME and writes it onto the
2463
+ * target's style as BOTH:
2464
+ * • the `d:` CSS property — `target.style.d = path("M … L …")` — which
2465
+ * Chromium and recent Safari render DIRECTLY on a `<path>`/`<svg>`
2466
+ * (no author wiring needed), and
2467
+ * • the `--morph-d` custom property — `var(--morph-d)` — the cross-browser
2468
+ * author channel + the Firefox-lags fallback (`<path style="d:
2469
+ * var(--morph-d)">`, or a JS reader via {@link MorphSVG.sampleD}).
2470
+ *
2471
+ * The render rides the engine's per-frame renderer seam (a custom
2472
+ * `transform` supplied to `fromKeyframes`), NOT the default DOM-style
2473
+ * renderer — so the morph is WAAPI-ineligible by construction and always
2474
+ * runs the rAF path where the renderer fires. The reassembly reuses an
2475
+ * instance-level scratch point-array, so the steady frame mints nothing.
2476
+ *
2477
+ * Default target-less: the returned handle IS the control surface, exactly
2478
+ * like `fromDrawSVG`'s target-less form — {@link MorphSVG.sampleD}(t) reads
2479
+ * the morphed `d` directly without a DOM write.
2480
+ */
2481
+ target?: HTMLElement | SVGElement;
2482
+ /**
2483
+ * Orient-along-path: when `true`, the morph ALSO samples each point's
2484
+ * tangent angle (radians) from `PathGeometry.sampleAtLength` and emits a
2485
+ * per-point `--morph-{i}-angle` channel that interpolates the `from`→`to`
2486
+ * tangent across `t` — the `rotate: auto` value a consumer reads to bank a
2487
+ * glyph along the morphed outline. Default `false` (a position-only morph
2488
+ * stays at the ~130-key floor; orient adds ~65 angle keys ONLY when asked,
2489
+ * pre-empting a "morph is too heavy" perf concern).
2490
+ */
2491
+ orient?: boolean;
2492
+ /**
2493
+ * Auto-start the play loop after construction + targeting. Default true.
2494
+ * `false` returns a constructed, NOT-yet-playing handle so the caller can
2495
+ * drive the returned animation (`.play()` / `.pause()` / `.stop()`).
2496
+ */
2497
+ autoPlay?: boolean;
2498
+ }
2499
+
2058
2500
  declare interface MorphValues {
2059
2501
  [key: string]: number;
2060
2502
  translateX: number;
@@ -2227,6 +2669,31 @@ export declare interface NumericAnimationOptions {
2227
2669
  respectReducedMotion?: boolean | undefined;
2228
2670
  }
2229
2671
 
2672
+ /**
2673
+ * Q.WB3 S2 — the precomputed SoA fold layout for ONE compiled frame's NUMERIC
2674
+ * interp subset (the single-animation `processFrame` analog of the compositor's
2675
+ * `SoALayerPlan`). Built ONCE at `parse` over the STABLE iv set (the F.W4
2676
+ * zero-alloc discipline — NO per-frame allocation):
2677
+ * - `numeric` — the numeric ivs (numeric start+stop, NOT computed, NOT color),
2678
+ * in slot order. Each iv's interp-carrier `value` is the `ValueUnit` slot the
2679
+ * strided write-back fills (the SAME slot `lerpValue` writes today).
2680
+ * - `from` / `to` — the packed endpoint `Float64Array`s (`start.value` /
2681
+ * `stop.value`), one slot per `numeric[s]`.
2682
+ * - `out` — the per-frame scratch the `lerpArray` fold writes into (reused
2683
+ * across every frame — zero per-frame alloc).
2684
+ * - `boxed` — the residual ivs (color / computed / mixed) the fold CANNOT cover
2685
+ * — walked by the existing per-element `lerpValue`, UNCHANGED.
2686
+ * The boxed-color tail is the GATED `ColorChannelPlan` consume's frontier (S4,
2687
+ * value.js 1.2.0) — NOT this NOW numeric arm.
2688
+ */
2689
+ declare interface NumericFoldPlan<V extends Vars> {
2690
+ numeric: Array<InterpolatedVar<V>>;
2691
+ from: Float64Array;
2692
+ to: Float64Array;
2693
+ out: Float64Array;
2694
+ boxed: Array<InterpolatedVar<V>>;
2695
+ }
2696
+
2230
2697
  /** Callback invoked each frame during `.play()` with the interpolated values. */
2231
2698
  export declare type NumericFrameCallback<T extends Record<string, number>> = (values: T) => void;
2232
2699
 
@@ -2238,6 +2705,98 @@ export declare type NumericFrameCallback<T extends Record<string, number>> = (va
2238
2705
  */
2239
2706
  export declare type OffsetPath = string;
2240
2707
 
2708
+ /**
2709
+ * A periodic phase clock: a linear phase ramp ∈ [0, 1) advanced by
2710
+ * `frequency × dt` per {@link tick}, plus a pure {@link sample} that maps a raw
2711
+ * time to its waveform value WITHOUT touching the running phase.
2712
+ *
2713
+ * LIGHT (value.js-free) — plain trig/floor math, no CSS parsing, no rAF
2714
+ * ownership. The caller drives the loop (mirrors `SmoothProgress` /
2715
+ * `SpringProgress`): feed `dt` (seconds) from a `RAFPlayback` loop or a
2716
+ * `ScrollTimeline`, read {@link phase} (or {@link value}) per frame.
2717
+ */
2718
+ export declare class Oscillator {
2719
+ private readonly frequency;
2720
+ private readonly waveform;
2721
+ /** The current phase ∈ [0, 1) — a linear ramp modulo 1 driven by {@link tick}. */
2722
+ phase: number;
2723
+ constructor(opts: OscillatorConfig);
2724
+ /**
2725
+ * Advance the phase by `frequency × dt` and wrap into [0, 1). Returns the
2726
+ * new phase. `dt` is in the caller's units (seconds for a `RAFPlayback`
2727
+ * frame, a normalized scroll delta for a `ScrollTimeline`); the consumer
2728
+ * owns the clock, so a negative `dt` runs the phase backward (and wraps
2729
+ * correctly, never going negative). No rAF — a pure stepper.
2730
+ */
2731
+ tick(dt: number): number;
2732
+ /**
2733
+ * The waveform value of the CURRENT running phase ∈ [-1, 1]. A pure read
2734
+ * over {@link phase} — does not advance the clock. Pair with {@link tick}:
2735
+ * `osc.tick(dt); const v = osc.value;`.
2736
+ */
2737
+ get value(): number;
2738
+ /**
2739
+ * Pure stateless sample: `t → waveform(t × frequency)`. Independent of the
2740
+ * running {@link phase} — it never reads or mutates it, so a consumer can
2741
+ * sample an absolute clock (`osc.sample(elapsedSeconds)`) without disturbing
2742
+ * a concurrently-`tick`ed phase. `t` is in the same units as `dt`.
2743
+ */
2744
+ sample(t: number): number;
2745
+ /** Reset the running phase (default 0). Does not change frequency/waveform. */
2746
+ reset(phase?: number): void;
2747
+ }
2748
+
2749
+ /**
2750
+ * Construction options for {@link Oscillator}.
2751
+ *
2752
+ * Named `OscillatorConfig` (NOT `OscillatorOptions`, the `…Options` convention
2753
+ * of the sibling steppers) deliberately: the Web Audio API declares a GLOBAL
2754
+ * `interface OscillatorOptions` (`lib.dom.d.ts`), so an `OscillatorOptions`
2755
+ * source type collides with `globalThis.OscillatorOptions` in the API-Extractor
2756
+ * d.ts roll-up — it renames to `OscillatorOptions_2`, which leaks into every IDE
2757
+ * hover (the PKG-3 defect `proof:published-surface` clause (h) gates, the same
2758
+ * `globalThis.Animation`/`ScrollTimeline` collision L.W8 S4 renamed away). The
2759
+ * non-colliding `OscillatorConfig` keeps the surface clean.
2760
+ */
2761
+ export declare interface OscillatorConfig {
2762
+ /**
2763
+ * Cycles per unit of `dt` — the phase advances `frequency × dt` per
2764
+ * {@link Oscillator.tick}. With `dt` in seconds a `frequency` of `1` is one
2765
+ * full cycle per second (1 Hz). Required; no implicit default rate.
2766
+ */
2767
+ frequency: number;
2768
+ /**
2769
+ * The periodic shape `phase ∈ [0, 1) → value ∈ [-1, 1]` that
2770
+ * {@link Oscillator.sample} (and a consumer reading {@link Oscillator.phase}
2771
+ * through {@link waveformValue}) applies. Default `"sine"`.
2772
+ */
2773
+ waveform?: OscillatorWaveform;
2774
+ }
2775
+
2776
+ /**
2777
+ * Oscillator — a LIGHT periodic phase clock (L.W9 S5 · W128 KF-OSCILLATOR).
2778
+ *
2779
+ * A frequency-driven phase ramp ∈ [0, 1) with a pure waveform shaper over it.
2780
+ * The boundary law places "playback/phase = kf", so the primitive belongs here
2781
+ * beside `SmoothProgress` / `SpringProgress` / `RAFPlayback`: it is a periodic
2782
+ * phase clock, NOT a CSS value parser, so it carries ZERO static edge to
2783
+ * `@mkbabb/value.js` (proof:boundary gates it as a value.js-free LIGHT entry).
2784
+ *
2785
+ * The consume signal is glass-ui BB's `W-EASING-PRIMITIVE` wave — its speedtest
2786
+ * idle-breath and the demo's `KF-OSCILLATOR` scene read the phase to drive a
2787
+ * looping motion. glass-ui co-schedules; kf owns the phase math
2788
+ * (`docs/tranches/L/waves/L.W9.md §S5`).
2789
+ *
2790
+ * NO rAF ownership — the caller drives the loop. `tick(dt)` advances the phase
2791
+ * by `frequency × dt` (with `dt` in SECONDS from the caller's `RAFPlayback`
2792
+ * loop or `ScrollTimeline`), mirroring the `SmoothProgress` / `SpringProgress`
2793
+ * stepper discipline (a pure step, the consumer owns the clock). `sample(t)` is
2794
+ * a stateless pure mapping `t → waveform(t × frequency)` — it never touches the
2795
+ * running phase, so the two surfaces are independent on the one primitive.
2796
+ */
2797
+ /** The four canonical periodic waveforms the phase clock shapes a phase into. */
2798
+ export declare type OscillatorWaveform = "sine" | "triangle" | "square" | "sawtooth";
2799
+
2241
2800
  declare const parallaxScroll: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
2242
2801
 
2243
2802
  declare type ParsedVarMap = Record<string, ValueArray>;
@@ -2570,6 +3129,17 @@ export declare interface ResolvedKeyframes {
2570
3129
  composition: Map<string, string>;
2571
3130
  /** `@property --foo { ... }` registry */
2572
3131
  properties: Map<string, PropertyDescriptor_2>;
3132
+ /**
3133
+ * `@function --foo(...) { ... }` descriptor registry (P.W13 — the emerging-CSS
3134
+ * resolve seam). Collected via value.js `extractFunctions` exactly as
3135
+ * `properties` is collected via `extractProperties`. Threaded into the
3136
+ * {@link resolveValues} pass's {@link ResolveContext} so the dashed-function
3137
+ * `@function` CALL-inlining lands greenable the moment value.js-P publishes
3138
+ * the call-parse arm; the descriptor is captured NOW (a read-only registry —
3139
+ * the inlining that CONSUMES it is the value.js-P-gated seam in
3140
+ * `resolve-values.ts`).
3141
+ */
3142
+ functions: Map<string, CustomFunctionDescriptor>;
2573
3143
  /**
2574
3144
  * Animation options recovered from a top-level style rule's
2575
3145
  * `animation` shorthand or longhand declarations (if any). Empty
@@ -2587,6 +3157,15 @@ export declare interface ResolvedKeyframes {
2587
3157
  * K.W8 populates the ingest rows (`CORS_SKIP`, `WAAPI_INELIGIBLE`) it owns.
2588
3158
  */
2589
3159
  diagnostics: Diagnostic[];
3160
+ /**
3161
+ * The parsed CSS `Stylesheet` AST the resolve walked (L.W2 S1). Surfaced so a
3162
+ * caller can recover scroll-grammar (`animation-timeline`/`animation-range`)
3163
+ * from the SAME parse via `extractTimelineOptions(resolved.stylesheet)` —
3164
+ * `CSSKeyframesAnimation.fromString` threads it onto `scrollOptions` so the
3165
+ * compiler's EMIT half (CC-6) can serialize the scroll longhands back out. A
3166
+ * read-only metadata field; the keyframe/option resolution is unchanged.
3167
+ */
3168
+ stylesheet: Stylesheet;
2590
3169
  }
2591
3170
 
2592
3171
  /**
@@ -2631,7 +3210,7 @@ export declare function resolveEasing(name: string): Promise<Easing>;
2631
3210
  * normalises a STRING of CSS, `resolveLiveKeyframes` normalises the LIVE CSSOM —
2632
3211
  * the parser pointed forward at the web the page already ships.
2633
3212
  */
2634
- declare const resolveLiveKeyframes: <V extends Vars = any>(source?: Document | CSSStyleSheet[] | CSSStyleSheet, options?: IngestOptions) => IngestResult<V>;
3213
+ declare const resolveLiveKeyframes: <V extends Vars = any>(source?: Document | ShadowRoot | CSSStyleSheet[] | CSSStyleSheet, options?: IngestOptions) => IngestResult<V>;
2635
3214
 
2636
3215
  /**
2637
3216
  * Resolve a parsed `AnimationRangeValue` (or `undefined` → the whole [0,1]
@@ -2675,7 +3254,7 @@ export declare type ScrollDispatch = {
2675
3254
  */
2676
3255
  export declare interface ScrollDispatchRequest<V extends Vars> {
2677
3256
  /** The animation to drive over the scroll clock. */
2678
- animation?: Animation_2<V> | undefined;
3257
+ animation?: KeyframesAnimation<V> | undefined;
2679
3258
  /** The native timeline spec (`scroll`/`view`) for the eligible fast lane. */
2680
3259
  nativeSpec?: NativeTimelineSpec | undefined;
2681
3260
  /** True if scrub smoothing was requested (forces JS — native has no smoother). */
@@ -2795,25 +3374,6 @@ export declare interface ScrollSceneOptions {
2795
3374
  /** A `.on(event, cb)` subscriber. Receives the local progress at the crossing. */
2796
3375
  export declare type ScrollSceneSubscriber = (progress: number) => void;
2797
3376
 
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
3377
  /**
2818
3378
  * The master-playhead orchestrator. Positions child animations along one clock
2819
3379
  * and drives them via `Animation.advanceTo`. See the module docstring for the
@@ -2824,6 +3384,13 @@ export declare class Sequence<V extends Vars = any> {
2824
3384
  readonly entries: SequenceEntry<V>[];
2825
3385
  /** Named positions on the master clock, registered via {@link label}. */
2826
3386
  private readonly labels;
3387
+ /**
3388
+ * The transport-events bus — the per-event subscriber registry + the
3389
+ * crossing detector (segment-lifecycle + label straddle). `on(...)` forwards
3390
+ * to `_events.subscribe`, and `_fireCrossings` to `_events.fire`. See
3391
+ * `./sequence-events` for the channel + detector body.
3392
+ */
3393
+ private readonly _events;
2827
3394
  /**
2828
3395
  * The running insertion cursor (ms) — the end of the last-inserted
2829
3396
  * segment. Relative `"+="`/`"-="` positions and auto-append (`at` omitted)
@@ -2887,13 +3454,32 @@ export declare class Sequence<V extends Vars = any> {
2887
3454
  get rate(): number;
2888
3455
  /** Register a named position on the master clock. Chainable. */
2889
3456
  label(name: string, at?: SequencePosition): this;
3457
+ /**
3458
+ * Subscribe to a segment-lifecycle or label crossing. Returns an
3459
+ * unsubscribe handle — the `ScrollScene.on` idiom (`scroll-scene.ts:506-514`).
3460
+ *
3461
+ * - `"segment:enter"` fires when the playhead enters a segment's
3462
+ * `[at, at + duration)` span (forward across `at`, or backward across the
3463
+ * span end); the callback receives that segment's `animation` reference
3464
+ * and the master-clock position at the crossing.
3465
+ * - `"segment:leave"` fires on the complementary crossing OUT of the span.
3466
+ * - `"label"` fires when the playhead straddles a registered label position
3467
+ * in EITHER direction; the callback receives `(name, masterClock)`.
3468
+ *
3469
+ * Crossings fire on EVERY paint — `seek` (scrub) and the rAF play loop,
3470
+ * forward, reverse, and yoyo. The callback's `masterClock` lets the consumer
3471
+ * infer direction; there is no `once` idiom — unsubscribe in the callback
3472
+ * (via the returned handle) for one-shot behaviour.
3473
+ */
3474
+ on(event: "segment:enter" | "segment:leave", cb: SequenceSegmentSubscriber): () => void;
3475
+ on(event: "label", cb: SequenceLabelSubscriber): () => void;
2890
3476
  /**
2891
3477
  * Append a child animation at `at` (absolute ms, a label, a `"+="`/`"-="`
2892
3478
  * relative token, or — omitted — the running cursor, i.e. after the
2893
3479
  * previous segment). Advances the insertion cursor to this segment's end.
2894
3480
  * Chainable.
2895
3481
  */
2896
- add(animation: Animation_2<V>, at?: SequencePosition): this;
3482
+ add(animation: KeyframesAnimation<V>, at?: SequencePosition): this;
2897
3483
  /**
2898
3484
  * Resolve a {@link SequencePosition} to an absolute ms offset.
2899
3485
  *
@@ -2925,6 +3511,17 @@ export declare class Sequence<V extends Vars = any> {
2925
3511
  * forward-monotone re-anchor window to break (F.W9 §S3 MEASURE-FIRST).
2926
3512
  */
2927
3513
  private _applyAt;
3514
+ /**
3515
+ * Detect and fire segment-lifecycle + label crossings between the previous
3516
+ * painted phase and `phase` — the ONE detector both `seek` (scrub) and
3517
+ * `_frame` (the rAF play loop) drive, so play fires the identical crossings a
3518
+ * scrub would. The detector + the per-event subscriber state live on the
3519
+ * `_events` bus (`./sequence-events`); this thin wrapper threads the segments
3520
+ * and labels the bus reads. The bus updates its own `_prevPhase` on EVERY
3521
+ * call (even the early-exit) so a subscriber registered mid-transport
3522
+ * straddles from the true prior playhead.
3523
+ */
3524
+ private _fireCrossings;
2928
3525
  /**
2929
3526
  * Fold a raw, repeat-extended master clock down to an effective phase in
2930
3527
  * `[0, duration]` per the `repeat`/`yoyo` transport. With `repeat(1)` +
@@ -3038,13 +3635,39 @@ export declare class Sequence<V extends Vars = any> {
3038
3635
  yoyo(on?: boolean): this;
3039
3636
  }
3040
3637
 
3041
- /** A resolved sequence segment: a child animation anchored at an absolute ms offset. */
3638
+ /**
3639
+ * A resolved sequence segment: a child animation anchored at an absolute ms
3640
+ * offset. The shape {@link SequenceEventBus.fire} reads to test segment
3641
+ * membership.
3642
+ */
3042
3643
  export declare interface SequenceEntry<V extends Vars> {
3043
- animation: Animation_2<V>;
3644
+ animation: KeyframesAnimation<V>;
3044
3645
  /** Absolute offset (ms) of this segment's local t=0 on the master clock. */
3045
3646
  at: number;
3046
3647
  }
3047
3648
 
3649
+ /**
3650
+ * The transport-crossing events a `Sequence` fires via {@link Sequence.on} —
3651
+ * the segment-lifecycle pair plus the named-label crossing.
3652
+ *
3653
+ * - `"segment:enter"` — the playhead crossed INTO a segment's
3654
+ * `[at, at + duration)` span (forward across `at`, or backward across the
3655
+ * span's end).
3656
+ * - `"segment:leave"` — the complementary crossing OUT of that span.
3657
+ * - `"label"` — the playhead straddled a position registered via
3658
+ * {@link Sequence.label}, in EITHER direction.
3659
+ *
3660
+ * Mirror of `ScrollSceneEvent` (`scroll-scene.ts:190`) — a typed, per-event
3661
+ * subscribe channel.
3662
+ */
3663
+ export declare type SequenceEvent = "segment:enter" | "segment:leave" | "label";
3664
+
3665
+ /**
3666
+ * A `label` subscriber. Receives the crossed label's `name` and the
3667
+ * master-clock position (ms) at the crossing.
3668
+ */
3669
+ export declare type SequenceLabelSubscriber = (name: string, masterClock: number) => void;
3670
+
3048
3671
  export declare interface SequenceOptions {
3049
3672
  /**
3050
3673
  * When true, `play()` honors `prefers-reduced-motion: reduce` by snapping
@@ -3066,6 +3689,17 @@ export declare interface SequenceOptions {
3066
3689
  */
3067
3690
  export declare type SequencePosition = number | `+=${number}` | `-=${number}` | string;
3068
3691
 
3692
+ /**
3693
+ * A `segment:enter` / `segment:leave` subscriber. Receives the crossing
3694
+ * segment's own `animation` reference and the master-clock position (ms) at the
3695
+ * crossing. The clock lets the consumer infer direction (a backward crossing
3696
+ * arrives with a smaller `masterClock` than the prior call).
3697
+ */
3698
+ export declare type SequenceSegmentSubscriber = (animation: KeyframesAnimation<any>, masterClock: number) => void;
3699
+
3700
+ /** The union over the two subscriber shapes (the {@link Sequence.on} fallthrough). */
3701
+ export declare type SequenceSubscriber = SequenceSegmentSubscriber | SequenceLabelSubscriber;
3702
+
3069
3703
  /**
3070
3704
  * SO-1 SERIALIZE — round-trip a typed `CSSTimelineOptions` BACK to its CSS
3071
3705
  * longhand declarations (`{ "animation-timeline"?, "animation-range"?,
@@ -3328,6 +3962,12 @@ export declare class SpringProgress {
3328
3962
  private omegaD;
3329
3963
  private subscribers;
3330
3964
  private disposed;
3965
+ private vecOrigin;
3966
+ private vecOriginVel;
3967
+ private vecTarget;
3968
+ private vecCurrent;
3969
+ private vecVelocity;
3970
+ private vecElapsed;
3331
3971
  private _playback;
3332
3972
  private _onFrame;
3333
3973
  constructor(options?: Partial<SpringProgressOptions>);
@@ -3390,6 +4030,51 @@ export declare class SpringProgress {
3390
4030
  snap(): void;
3391
4031
  /** Reset position + velocity to a specified value (default 0). */
3392
4032
  reset(value?: number, velocity?: number): void;
4033
+ /**
4034
+ * Re-seat a MULTI-CHANNEL spring vector onto `targets` (one lane per
4035
+ * element), under this spring's `(response, dampingFraction)`. The lanes
4036
+ * ring identically to a scalar `SpringProgress` of the same config — the
4037
+ * solver is the SAME closed form (`evaluateAt`) shared across channels — but
4038
+ * step in ONE `tickVector(dt)` call into one `Float64Array` per tick, the
4039
+ * dispatch/alloc amortization the W122 probe measured at 2.97–3.78× over K
4040
+ * independent scalar instances (ADOPT @ K=8, `proof:spring-vector`).
4041
+ *
4042
+ * First call ARMS the lanes (lazily — a scalar-only spring never allocates
4043
+ * the vector buffers, so the scalar hot path is unchanged). Subsequent calls
4044
+ * re-seat each lane's origin from the lane's CURRENT `(x, v)`, so a mid-flight
4045
+ * target change is continuous per channel — the vector analogue of the scalar
4046
+ * `set target` re-seat. The lane count is fixed by the FIRST `setTargets`
4047
+ * length; a later call with a different length throws (the buffers are
4048
+ * stable references the consumer reads via {@link values}).
4049
+ *
4050
+ * `initialVelocity` (the scalar seed) does NOT carry into the lanes — a fresh
4051
+ * vector starts each lane at rest unless re-seated from prior motion. The
4052
+ * scalar `currentValue` / `target` are untouched; the two modes are
4053
+ * independent surfaces on one solver.
4054
+ */
4055
+ setTargets(targets: Float64Array): void;
4056
+ /**
4057
+ * The shared output lane buffer — the K channels' current values, written
4058
+ * in place by {@link tickVector}. A STABLE reference (never re-allocated
4059
+ * after the first {@link setTargets}); read it after each tick. Returns an
4060
+ * empty `Float64Array` before the first `setTargets` arms the lanes.
4061
+ */
4062
+ get values(): Float64Array;
4063
+ /**
4064
+ * The shared output velocity lane buffer — the K channels' current
4065
+ * velocities, written in place by {@link tickVector}. A STABLE reference;
4066
+ * empty before the first {@link setTargets}.
4067
+ */
4068
+ get velocities(): Float64Array;
4069
+ /**
4070
+ * Advance EVERY lane by `dt` MILLISECONDS — one call, K channels, one buffer
4071
+ * write. The analytic per-channel step is the same closed form `evaluateAt`
4072
+ * uses (the shared `omega`/`zeta`/`omegaD`), with the transcendentals
4073
+ * (`exp`/`cos`/`sin`) hoisted once per tick and reused across lanes — the
4074
+ * amortization the W122 probe measured. No-op (returns the same buffer)
4075
+ * before the first {@link setTargets}, when disposed, or for `dt <= 0`.
4076
+ */
4077
+ tickVector(dt: number): Float64Array;
3393
4078
  /**
3394
4079
  * Subscribe to per-tick updates. Returns an unsubscribe handle.
3395
4080
  * Called with `(value, velocity)` on every `tick`/`snap`/`reset`/
@@ -3719,6 +4404,15 @@ export declare const toEasing: (input: TimingFunction | Easing) => Easing;
3719
4404
 
3720
4405
  export declare type TransformFunction<V extends Vars> = (v: V, t: number) => void;
3721
4406
 
4407
+ /**
4408
+ * Default DOM-style renderer used by `Animation.transform` when no
4409
+ * user-supplied transform is provided. "Is this the default renderer?"
4410
+ * is decided by reference comparison against the Animation instance's
4411
+ * one `_defaultTransform` (`usesDefaultRenderer`) — typed and
4412
+ * bind-proof, not a Symbol tag a wrapper would silently drop.
4413
+ */
4414
+ declare function transformTargetsStyle<V extends Vars>(vars: V, targets: HTMLElement[], flat?: boolean): void;
4415
+
3722
4416
  declare const typewriter: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
3723
4417
 
3724
4418
  declare const typingCursor: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
@@ -3729,6 +4423,81 @@ export declare class UnknownEasingError extends Error {
3729
4423
  constructor(easingName: string);
3730
4424
  }
3731
4425
 
4426
+ /**
4427
+ * `validate(css, opts?)` — the READ-ONLY projection over the three typed channels
4428
+ * onto one {@link ValidateResult} envelope. Async because `compileToCSS` is (its
4429
+ * Prettier pass).
4430
+ *
4431
+ * The pipeline:
4432
+ * 1. `parseCSSStylesheet(css)` → the AST; `parseable` is true when value.js
4433
+ * surfaced at least one recognized item and the resolve raised no
4434
+ * `PARSE_ERROR` (the spec-faithful reality — a dropped `!important` decl is
4435
+ * not a parse failure).
4436
+ * 2. `CSSKeyframesAnimation.fromString(css)` → the parsed animation +
4437
+ * `anim.diagnostics` (the adapter's silent-fallback channel).
4438
+ * 3. `compileToCSS([anim], opts.compile)` → `{ eligible, refusals }`.
4439
+ * 4. `isWAAPIEligible(anim)` → the compositor-thread verdict.
4440
+ */
4441
+ declare function validate(css: string, opts?: ValidateOptions): Promise<ValidateResult>;
4442
+
4443
+ /**
4444
+ * Options for {@link validate} / {@link explain}. A thin pass-through to the
4445
+ * underlying channels — NOT a new option surface. `compile` forwards verbatim to
4446
+ * `compileToCSS` (the ΔE-ε / densify-stop knobs the refusal arm reads).
4447
+ */
4448
+ export declare interface ValidateOptions {
4449
+ /**
4450
+ * Forwarded verbatim to `compileToCSS` — the CC-2 densify-stop count + the
4451
+ * ΔE-ε ship-vs-refuse threshold the perceptual-oklab refusal arm reads. Omit
4452
+ * for the compiler defaults.
4453
+ */
4454
+ compile?: CompileOptions;
4455
+ }
4456
+
4457
+ /**
4458
+ * The flat, agent-shaped envelope `validate` returns — the JOIN over the three
4459
+ * typed channels. An LLM agent branches on these fields WITHOUT scraping a
4460
+ * message string. Every constituent type (`CompileRefusal`, `Diagnostic`,
4461
+ * `WAAPIEligibility`) is already exported from the barrel — the ONLY new type is
4462
+ * this envelope.
4463
+ */
4464
+ export declare interface ValidateResult {
4465
+ /**
4466
+ * True iff value.js parsed the CSS without a `PARSE_ERROR` diagnostic — the
4467
+ * block surfaced at least one recognized stylesheet item (a `@keyframes` /
4468
+ * `@property` / style rule). A spec-invalid keyframe `!important` declaration
4469
+ * is SILENTLY dropped at the AST by value.js (the L.W1 S1 reality) — that drop
4470
+ * is NOT a parse failure, so a block carrying it stays `parseable:true`.
4471
+ */
4472
+ parseable: boolean;
4473
+ /**
4474
+ * True iff `compileToCSS` produced an artifact for every child — the compile
4475
+ * surface's own `eligible` flag. False when any child refused (see
4476
+ * {@link refusals}). Separate from {@link waapi}: a block can be compile-
4477
+ * eligible (the CSS round-trips faithfully) yet WAAPI-ineligible (color
4478
+ * interpolation, computed units) and vice versa.
4479
+ */
4480
+ eligible: boolean;
4481
+ /**
4482
+ * The CC-3 refusals — one per child that could not compile faithfully (the
4483
+ * `{ name, reason, message }` trust surface). Empty on a clean compile.
4484
+ */
4485
+ refusals: CompileRefusal[];
4486
+ /**
4487
+ * All parse/honoring diagnostics from `resolveKeyframes` — every SILENT
4488
+ * fallback the adapter used to swallow, now a citable row with a stable
4489
+ * {@link Diagnostic.code}. Empty on a clean parse.
4490
+ */
4491
+ diagnostics: Diagnostic[];
4492
+ /**
4493
+ * The WAAPI eligibility verdict — `{ eligible: true }` or
4494
+ * `{ eligible: false; reason: string }`. Separate from {@link eligible}: the
4495
+ * compositor-thread delegation has its own, narrower bar (no color interp, no
4496
+ * computed units, a uniform CSS-twinned easing).
4497
+ */
4498
+ waapi: WAAPIEligibility;
4499
+ }
4500
+
3732
4501
  export declare type Vars<T = any> = {
3733
4502
  [arg: string]: number | string | T;
3734
4503
  };
@@ -3755,10 +4524,63 @@ export declare interface VelocityProbe {
3755
4524
  };
3756
4525
  }
3757
4526
 
4527
+ declare type WAAPIEligibility = {
4528
+ eligible: true;
4529
+ } | {
4530
+ eligible: false;
4531
+ reason: string;
4532
+ };
4533
+
4534
+ /**
4535
+ * Fire-and-forget idle-warmer for the heavy engine (L.W7 S1, W121).
4536
+ *
4537
+ * Pre-flights `loadAnimationEngine()`'s dynamic import so the first
4538
+ * `.animate()` / `new CSSKeyframesAnimation()` call on a cold page resolves
4539
+ * against an already-in-flight (or already-resolved) Promise instead of paying
4540
+ * network + parse + compile latency inline. Call it during idle —
4541
+ * `requestIdleCallback`, `visibilitychange`, or `mouseenter` on the app shell:
4542
+ *
4543
+ * ```ts
4544
+ * requestIdleCallback(() => warmEngine());
4545
+ * ```
4546
+ *
4547
+ * Idempotent and value.js-free by construction: it shares the SAME
4548
+ * module-scope `_enginePromise` with `loadAnimationEngine()`, so a
4549
+ * `loadAnimationEngine()` after `warmEngine()` returns the same in-flight
4550
+ * Promise — no double import. It fires a DYNAMIC import only; it names no
4551
+ * static value.js specifier, so `proof:boundary` stays green.
4552
+ *
4553
+ * L.W7 S4 (MEASURE-FIRST — the `scheduler.postTask` adoption is DEFERRED, not
4554
+ * shipped). `scheduler.postTask("background", …)` would be the idiomatic home
4555
+ * for an idle warm, but the `proof:scheduler-posttask` probe only SKIPS in
4556
+ * jsdom (the API is absent there) — it has NOT positively MEASURED that the
4557
+ * `"background"` call does not degrade INP on a real engine. Per the wave's own
4558
+ * measure-first law (and inv ε — no claim without an observed oracle), warmEngine
4559
+ * stays on the PROVEN bare `void loadAnimationEngine()` path. The probe + gate are
4560
+ * ARMED: when a real-browser run (Playwright with `scheduler.postTask`) measures
4561
+ * the background dispatch safe, warmEngine adopts `postTask("background")` then —
4562
+ * a gated future change, not an unmeasured ship today.
4563
+ */
4564
+ export declare const warmEngine: () => void;
4565
+
3758
4566
  declare const warpLeft: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
3759
4567
 
3760
4568
  declare const warpRight: (options?: InputAnimationOptions) => CSSKeyframesAnimation< Vars>;
3761
4569
 
4570
+ /**
4571
+ * Map a phase ∈ ℝ to its waveform value ∈ [-1, 1]. Pure — the phase is reduced
4572
+ * to its fractional cycle position internally, so a phase outside [0, 1) (e.g. a
4573
+ * raw `t × frequency` from {@link Oscillator.sample}) shapes the same as its
4574
+ * wrapped equivalent. Exported as a value.js-free leaf a consumer can apply to
4575
+ * its own phase without constructing an `Oscillator`.
4576
+ *
4577
+ * - `sine` — `sin(2π·p)`, smooth.
4578
+ * - `triangle` — linear up then down, peaks at `p = 0.25` / `0.75`.
4579
+ * - `square` — `+1` for the first half-cycle, `-1` for the second.
4580
+ * - `sawtooth` — linear ramp `-1 → +1` across the cycle.
4581
+ */
4582
+ export declare function waveformValue(phase: number, waveform: OscillatorWaveform): number;
4583
+
3762
4584
  /**
3763
4585
  * The minimal stepper surface a spring-driven blend weight reads (K.W11
3764
4586
  * PHYS-C). A `SpringProgress` satisfies it structurally (`value` getter +
@@ -3777,4 +4599,18 @@ export declare interface WeightStepper {
3777
4599
  readonly settled: boolean;
3778
4600
  }
3779
4601
 
4602
+ /**
4603
+ * `yieldToMain()` — break a long main-thread task so the browser can service
4604
+ * input/render between slices (INP relief). Used by `AnimationGroup.advanceTo()`
4605
+ * to keep a large group's per-frame composite from monopolizing the main
4606
+ * thread as one long task.
4607
+ *
4608
+ * Baseline-Newly: prefers the native `scheduler.yield()` (continuation runs
4609
+ * at the FRONT of the task queue, so yielding stays cheap); falls back to a
4610
+ * `MessageChannel` macrotask, then `setTimeout(0)` — a ≤20 LOC progressive
4611
+ * fallback per the Baseline browser policy. SSR-safe: resolves immediately
4612
+ * off-DOM (no event loop to yield to that matters for a headless render).
4613
+ */
4614
+ declare function yieldToMain(): Promise<void>;
4615
+
3780
4616
  export { }