@mkbabb/keyframes.js 5.1.0 → 5.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +83 -3
- package/dist/backward-color-BtbRcnna.js +108 -0
- package/dist/compile-BHCTPerD.js +30 -0
- package/dist/{delegation-DWwr4IXr.js → delegation-BQYCrP2p.js} +5 -9
- package/dist/{draw-svg-GURj9nin.js → draw-svg-CK9Qrly8.js} +13 -25
- package/dist/easing-serialize-D4LZCB6i.js +21 -0
- package/dist/engine/index.d.ts +422 -156
- package/dist/engine/index.js +16 -17
- package/dist/engine-CPK_udUQ.js +1172 -0
- package/dist/engine-DlpimZtM.js +3 -0
- package/dist/entry-D82NKUhP.js +148 -0
- package/dist/format-BdIvdLzG.js +114 -0
- package/dist/{group-vJcsHKN9.js → group-HM7N4uOE.js} +153 -123
- package/dist/handle-D4xrf_ya.js +21 -0
- package/dist/{ingest-S5hUe20K.js → ingest-_g6tfk2e.js} +2 -2
- package/dist/keyframes.d.ts +702 -178
- package/dist/keyframes.js +295 -74
- package/dist/morph-svg-KUrH9KnK.js +79 -0
- package/dist/motion-path-wM5tPfrY.js +26 -0
- package/dist/presets-DeDJYL4G.js +275 -0
- package/dist/{scheduler-CUtVnuoU.js → scheduler-CfGIC3GX.js} +1 -1
- package/dist/{scroll-CxpYFO4u.js → scroll-BEyCx0b_.js} +165 -58
- package/dist/{sequence-C_DCiOIQ.js → sequence-s0bL7Uul.js} +118 -90
- package/dist/{validate-DDeGnvSt.js → validate-xFZ_Ld1k.js} +7 -7
- package/dist/view-transition-BPJQxUTC.js +305 -0
- package/package.json +113 -83
- package/dist/animation-BGyzfzBq.js +0 -947
- package/dist/compile-CcSUwM8R.js +0 -276
- package/dist/engine-DEVgCTUy.js +0 -156
- package/dist/engine-DrBtsKaf.js +0 -4
- package/dist/format-C-Gi9r7L.js +0 -123
- package/dist/grammar-BLucehC4.js +0 -23
- package/dist/morph-svg-BToeumw5.js +0 -89
- package/dist/motion-path-pQVbamWT.js +0 -35
- package/dist/presets-BG2Fczzq.js +0 -275
package/README.md
CHANGED
|
@@ -193,6 +193,31 @@ const dAtMid = morph.sampleD(0.5); // the interpolated `d` at t = 0.5
|
|
|
193
193
|
|
|
194
194
|
Options: `samples` (point count per path; default `64`), plus every `AnimationOptions` key. Both inputs must be non-degenerate path `d` strings (non-zero arc length, ≥ 2 samples) — a degenerate input refuses with a typed `AnimationOptionError`. `MorphSVG.sampleD(t)` reassembles the morphed `d` at any `t`; the per-point coordinates also surface as `--morph-{i}-x`/`--morph-{i}-y` custom properties for direct CSS binding.
|
|
195
195
|
|
|
196
|
+
### The emerging-CSS resolver
|
|
197
|
+
|
|
198
|
+
kf's parser accepts CSS the platform can't animate yet. The `resolve/` zone lowers `if(supports(...))` / `if(media(...))` / `if(style(--custom-prop))` and `@function` calls to concrete values **in JS, at parse/bind time** — so a `@keyframes` block authored against tomorrow's conditional grammar plays correctly **today, in every browser kf runs in**, even though the native CSS features themselves are Chromium-only (`if()` shipped Chrome 137; `@function`, Chrome 139 — neither ships in Firefox or Safari). `env()` sits outside this: it's ordinary CSS the platform has resolved for years, so there's no cross-browser gap for kf to bridge there.
|
|
199
|
+
|
|
200
|
+
This is a **resolve-once, not react-forever** lowering, not a live binding. The element-independent forms (`if(supports)`, `if(media)`, `@function`) resolve once when the keyframes parse; the element-aware forms (`if(style(--p))`, `sibling-index()`, `sibling-count()`) resolve once per `setTargets()`. None of them re-evaluate on a later media-query flip or custom-property write — rebuild the animation to re-resolve.
|
|
201
|
+
|
|
202
|
+
```ts run
|
|
203
|
+
const { resolveKeyframes } = await loadAnimationEngine();
|
|
204
|
+
|
|
205
|
+
// Author against a condition the browser can't natively evaluate in if() yet —
|
|
206
|
+
// kf resolves it in JS and bakes the concrete branch into the parsed frame.
|
|
207
|
+
// Off-DOM (no CSS.supports), the SSR-safe default deterministically picks `else`:
|
|
208
|
+
const { keyframes } = resolveKeyframes(`
|
|
209
|
+
@keyframes x {
|
|
210
|
+
0% { color: if(supports(color: lch(0 0 0)): red; else: blue) }
|
|
211
|
+
100% { color: green }
|
|
212
|
+
}
|
|
213
|
+
`);
|
|
214
|
+
String(keyframes.get("0%")?.color); // => "rgb(0 0 255)"
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
**What it refuses.** A condition that resolves to nothing is a CSS *guaranteed-invalid value* — `if()` with no matching branch and no `else`, or an over-deep/self-referential `@function` chain (cycle-guarded at depth 32) — **drops the declaration** (the prior/initial value wins), never an empty or malformed string. A `@function` call whose argument can't be coerced to the parameter's declared syntax drops the whole call too, surfaced as a named `CUSTOM_FN_ARG_DROP` diagnostic on `resolveKeyframes`'s `diagnostics` channel — never a silent `NaN`.
|
|
218
|
+
|
|
219
|
+
Gated by `npm run proof:emerging-css-resolve` (the `if(supports)`/`if(media)` pass, the element-aware `if(style)`/`sibling-index()`/`sibling-count()` pass, and `@function` call-inlining) — all jsdom-clean, behavior-level; no browser required, because the resolution is kf's JS, not a platform feature.
|
|
220
|
+
|
|
196
221
|
## `CSSKeyframesAnimation`
|
|
197
222
|
|
|
198
223
|
An abstraction over `KeyframesAnimation` that parses CSS `@keyframes` into `TemplateAnimationFrame` objects, then adds them to a base `KeyframesAnimation`.
|
|
@@ -275,7 +300,7 @@ keyframes.js's authoring object **is** parsed CSS `@keyframes`. That one fact op
|
|
|
275
300
|
|
|
276
301
|
1. **Ingest** — read the live web's CSS (`@keyframes` in a stylesheet, or a *running* CSS animation) straight into a kf `CSSKeyframesAnimation`.
|
|
277
302
|
2. **Drive** — run it through the engine: physics-shaped springs, perceptual `oklab` color, scroll-driven progress, weighted blending.
|
|
278
|
-
3. **Compile** — emit the result **back** to zero-runtime CSS
|
|
303
|
+
3. **Compile** — emit the result **back** to zero-runtime CSS. Three sibling emitters run the SAME parser *backward* over the same data model (`format.ts` is `keyframes.ts` in reverse): [`compileToCSS`](#compile--the-parser-run-backward) (plain `@keyframes`), [`compileToViewTransition`](#compiletoviewtransition) (the `::view-transition-*` pseudo tree), and [`compileToEntry`](#compiletoentry) (`@starting-style`/`allow-discrete` entry-exit).
|
|
279
304
|
|
|
280
305
|
This is the moat. GSAP, Motion, and anime author in a bespoke tween model — for them "export to CSS" is a lossy re-derivation nobody ships, and "import the page's CSS" has no meaning. Because kf's internal model is *already* CSS, the forward and backward halves are inverses over one structure: a `var()`, a `matrix3d()`, a `cqw` round-trips **verbatim**. The whole round-trip rides the heavy engine, reached through one `await loadAnimationEngine()`.
|
|
281
306
|
|
|
@@ -341,7 +366,7 @@ pinCSS({ top: 24 }); // => "position: sticky; top: 24px;"
|
|
|
341
366
|
|
|
342
367
|
### Compile — the parser run backward
|
|
343
368
|
|
|
344
|
-
`compileToCSS` walks an orchestration graph — an [`AnimationGroup`](#animationgroup), a [`Sequence`](#sequence), or a bare child list (e.g. a [`stagger`](#stagger)-delayed cohort) — and emits a **pure, zero-runtime CSS** artifact: one `@keyframes` block + an `animation` shorthand per child, `replace`/`add` layering as `animation-composition`, springs as `linear()`, materialized stagger delays, and computed units (`vh`/`cqw`/`calc()`/`var()`) verbatim. A human pastes the result and ships with **zero kf bytes on the page**.
|
|
369
|
+
`compileToCSS` walks an orchestration graph — an [`AnimationGroup`](#animationgroup), a [`Sequence`](#sequence), or a bare child list (e.g. a [`stagger`](#stagger)-delayed cohort) — and emits a **pure, zero-runtime CSS** artifact: one `@keyframes` block + an `animation` shorthand per child, `replace`/`add` layering as `animation-composition`, springs as `linear()`, materialized stagger delays, and computed units (`vh`/`cqw`/`calc()`/`var()`) verbatim. A human pastes the result and ships with **zero kf bytes on the page**. Two siblings emit from the same substrate for two other target surfaces — [`compileToViewTransition`](#compiletoviewtransition) (the `::view-transition-*` pseudo tree) and [`compileToEntry`](#compiletoentry) (`@starting-style`/`allow-discrete` entry-exit) — both taught under [Beyond CSS](#beyond-css).
|
|
345
370
|
|
|
346
371
|
```ts
|
|
347
372
|
const { CSSKeyframesAnimation, compileToCSS } = await loadAnimationEngine();
|
|
@@ -383,6 +408,8 @@ When `useWAAPI` is `true` (default), eligible animations run on the compositor t
|
|
|
383
408
|
|
|
384
409
|
A spring timing function (`springTimingFunction`) carries its CSS `linear()` equivalent, so a WAAPI-delegated spring animation runs the true overshoot/settle curve on the compositor instead of a flattened `linear` ramp — the JS easing and the compositor curve are one solver.
|
|
385
410
|
|
|
411
|
+
A spring keyframed across **multiple** declared stops is compositor-eligible too: rather than restart the curve at each stop (WAAPI's one-easing-per-segment model would), kf **densifies** the composite curve into extra keyframe stops fed a single bare `linear` effect easing, so the compositor's piecewise-linear fill still tracks the true multi-segment curve. Gated by `proof:waapi-adaptive-densify`.
|
|
412
|
+
|
|
386
413
|
## Baseline, tree-shaking & reduced motion
|
|
387
414
|
|
|
388
415
|
keyframes.js targets a modern-web Baseline and documents the tier of every platform facility it leans on:
|
|
@@ -393,8 +420,9 @@ keyframes.js targets a modern-web Baseline and documents the tier of every platf
|
|
|
393
420
|
| `scheduler.yield()` | Newly available | Feature-detected; falls back to a `MessageChannel` macrotask (≤20 LOC) |
|
|
394
421
|
| WAAPI `linear()` springs | Newly available | Feature-detected; the rAF spring path is the default fallback |
|
|
395
422
|
| `Element.animate()` (WAAPI) | Widely available | Opt-out via `useWAAPI: false` |
|
|
423
|
+
| CSS `if()` / `@function` | Limited availability (Chromium) | kf resolves both in JS at parse/bind time — see [The emerging-CSS resolver](#the-emerging-css-resolver) |
|
|
396
424
|
|
|
397
|
-
**Tree-shaking — the value.js boundary.** The package is `"sideEffects": false` and splits along a static/dynamic boundary. The light physics/interpolation engines — `SpringProgress`, `SmoothProgress`, `NumericAnimation`, `ElementMorph`, the `Timeline` family, `RAFPlayback`, and the spring-stop helpers — carry **zero** static import edge to `@mkbabb/value.js`. A consumer that imports only these never pulls value.js (or the heavy CSS-keyframe parser) into its graph; the heavy engine (`KeyframesAnimation`, `CSSKeyframesAnimation`, `AnimationGroup`) is reached only through `loadAnimationEngine()`'s dynamic `import()`. This boundary is **gated in CI** by `proof:boundary`, which builds a spring-only entry and fails the build if any light module reintroduces a static value.js edge.
|
|
425
|
+
**Tree-shaking — the value.js boundary.** The package is `"sideEffects": false` and splits along a static/dynamic boundary. The light physics/interpolation engines — `SpringProgress`, `SmoothProgress`, `NumericAnimation`, `ElementMorph`, the `Timeline` family, `RAFPlayback`, and the spring-stop helpers — carry **zero** static import edge to `@mkbabb/value.js`. A consumer that imports only these never pulls value.js (or the heavy CSS-keyframe parser) into its graph; the heavy engine (`KeyframesAnimation`, `CSSKeyframesAnimation`, `AnimationGroup`) is reached only through `loadAnimationEngine()`'s dynamic `import()`. This boundary is **gated in CI** by `proof:boundary`, which builds a spring-only entry from SOURCE and fails the build if any light module reintroduces a static value.js edge. `proof:consume-bundle` re-proves the same claim from the CONSUMER side — it bundles the PUBLISHED `dist/keyframes.js` (value.js/parse-that kept non-external, so any leak must surface) exactly as a downstream app's bundler would, and fails if that eager graph carries a single value.js/parse-that module or a statically-inlined engine class. (Deliberately no prose kB figure here: `proof:consume-bundle` floors the LIGHT edge's *composition* — zero value.js, zero engine — not a byte count, so a specific kB number would be a claim neither gate actually verifies; re-run `npm run proof:consume-bundle` against a fresh build for the current graph, not a number frozen in prose.)
|
|
398
426
|
|
|
399
427
|
**Reduced motion.** Both the light and heavy engines honor `prefers-reduced-motion: reduce`. Opt in per surface:
|
|
400
428
|
|
|
@@ -694,6 +722,58 @@ Positions: a number (absolute ms), `"+=n"` / `"-=n"` (relative to the insertion
|
|
|
694
722
|
| `SequenceEffect` / proposed `EffectTiming` `align: sequence` | `Sequence` auto-append |
|
|
695
723
|
| `EffectTiming` `align: start` | `Sequence` `at: 0` |
|
|
696
724
|
|
|
725
|
+
### `viewTransition`
|
|
726
|
+
|
|
727
|
+
The LIGHT View-Transitions dispatch: mutate the DOM behind a native View Transition where the platform ships one, and fall back to a `flipShared` shared-element morph (or a bare immediate mutation) everywhere else — behind ONE normalized handle whose `backend` is queryable and whose promises never reject. Feature-detects `startViewTransition` (and its typed-`update` object overload); PRM routes through the ONE `withReducedMotion` gate (mutate directly, settle).
|
|
728
|
+
|
|
729
|
+
```ts run
|
|
730
|
+
// Off-platform (no `document.startViewTransition`, no shared pairs) it degrades
|
|
731
|
+
// to a bare immediate mutation — backend queryable SYNCHRONOUSLY at dispatch:
|
|
732
|
+
const vt = viewTransition(() => box.classList.add("open"), { types: ["forward"] });
|
|
733
|
+
vt.backend; // => "immediate"
|
|
734
|
+
await vt.finished; // never rejects — a skipped/aborted transition settles cleanly
|
|
735
|
+
```
|
|
736
|
+
|
|
737
|
+
Options: `types` (typed same-doc VT), `shared` (`[from, to]` `flipShared` fallback pairs — `backend: "flip"`), `duration`/`timingFunction` (the fallback play), `fallback` (`"flip"` | `"none"` | a custom async runner), `respectReducedMotion` (default `true` — PRM snaps to `"immediate"`). The `backend` is `"view-transition"` (native), `"flip"` (the `flipShared` fallback), or `"immediate"` (bare mutate). Its zero-runtime CSS twin is [`compileToViewTransition`](#compiletoviewtransition).
|
|
738
|
+
|
|
739
|
+
### `compileToViewTransition`
|
|
740
|
+
|
|
741
|
+
The round-trip engine pointed at native View Transitions: compile a **name-keyed role spec** to a PURE, ZERO-RUNTIME CSS artifact over the `::view-transition-*` pseudo tree (HEAVY — reached via `loadAnimationEngine()`). Each name's `old`/`new` get a full kf `@keyframes` block + `animation` shorthand (springs → `linear()`); `::view-transition-group(name)` gets a **timing-only** override (duration + timing-function, never `animation-name` — the UA's rect-morph keyframes ARE the free zero-runtime FLIP), so the group stays temporally coherent with the tracks. Non-round-trippable shapes REFUSE with a named reason (the CC-3 four ∪ `vt-scroll-grammar` / `vt-element-scoped-computed` / `vt-snapshot-inapplicable` / `vt-name-collision`).
|
|
742
|
+
|
|
743
|
+
```ts run
|
|
744
|
+
const { CSSKeyframesAnimation, compileToViewTransition } = await loadAnimationEngine();
|
|
745
|
+
|
|
746
|
+
const out = new CSSKeyframesAnimation({ duration: 300 });
|
|
747
|
+
out.fromString(`@keyframes o { from { opacity: 1 } to { opacity: 0; transform: scale(0.9) } }`);
|
|
748
|
+
const enter = new CSSKeyframesAnimation({ duration: 300 });
|
|
749
|
+
enter.fromString(`@keyframes n { from { opacity: 0; transform: scale(1.05) } to { opacity: 1 } }`);
|
|
750
|
+
|
|
751
|
+
const vt = await compileToViewTransition({ hero: { old: out, new: enter } }, { types: ["forward"] });
|
|
752
|
+
vt.names; // => ["hero"]
|
|
753
|
+
vt.css.includes("::view-transition-group(hero)"); // => true
|
|
754
|
+
vt.css.includes("animation-name"); // => false // the group override is timing-only
|
|
755
|
+
```
|
|
756
|
+
|
|
757
|
+
Options: `types` (wraps rules in `:active-view-transition-type(...)`), `crossDocument` (prepend `@view-transition { navigation: auto }`), `reducedMotion` (append the PRM `animation: none` block, default `true`), plus every `CompileOptions` key. The consumer assigns `view-transition-name: <name>` to its elements from the returned `names`.
|
|
758
|
+
|
|
759
|
+
### `compileToEntry`
|
|
760
|
+
|
|
761
|
+
Modern entry/exit compilation: compile a selector-keyed `{ enter?, exit? }` spec to zero-runtime **`@starting-style` + `transition-behavior: allow-discrete`** CSS — the two-endpoint entrance/exit grammar the platform shipped (Chromium 117+/Safari 26). HEAVY (reached via `loadAnimationEngine()`). It is a **declared-endpoint projection** (each animation is a 2-stop transition endpoint pair), emitting the three-rule grammar: a base/closed rule (exit's last frame + `display: none` + the exit transition list), an open rule (enter's last frame + `display` + the entry list), and `@starting-style { <open> { enter's first frame } }`. Asymmetric entry/exit duration+easing ride the two lists; `display`/`overlay <dur> allow-discrete` ride BOTH (`overlay` is inert-but-harmless off the top layer); spring `linear()`s ride verbatim; **color endpoints canonicalize to `oklab()`** so the transition interpolates in kf's default perceptual space natively — NO densify, ZERO intermediate stops (the `@keyframes` `perceptual-oklab` refusal INVERTED to a feature). Non-two-endpoint shapes REFUSE (3 inherited + 6 entry-specific: `entry-multi-keyframe` / `entry-iteration` / `entry-composition` / `entry-scroll-grammar` / `entry-color-space` / `entry-easing-twin`).
|
|
762
|
+
|
|
763
|
+
```ts run
|
|
764
|
+
const { CSSKeyframesAnimation, compileToEntry } = await loadAnimationEngine();
|
|
765
|
+
|
|
766
|
+
const enter = new CSSKeyframesAnimation({ duration: 350 });
|
|
767
|
+
enter.fromString(`@keyframes en { from { opacity: 0; transform: translateY(8px) } to { opacity: 1; transform: translateY(0) } }`);
|
|
768
|
+
|
|
769
|
+
const dialog = await compileToEntry({ ".dialog": { enter } }, { openSelector: "[open]" });
|
|
770
|
+
dialog.eligible; // => true
|
|
771
|
+
dialog.css.includes("@starting-style"); // => true
|
|
772
|
+
dialog.css.includes("display 350ms allow-discrete"); // => true
|
|
773
|
+
```
|
|
774
|
+
|
|
775
|
+
Options: `openSelector` (`".open"` | `"[data-open]"` | `":popover-open"` | `"[open]"`, concatenated onto the base selector), `display` (the open display, default `"block"`), `overlay` (emit `overlay allow-discrete`, default `true`), `printWidth`. The `exit` defaults to `enter` reversed. **Born-open elements RUN the entry at first render** (an `@starting-style` platform semantic — an SSR'd open dialog animates in on load; opt out by not matching the open selector at initial render). Where `transition-behavior` is unsupported the artifact **degrades honestly** — snap-entry, correct end state, no broken half-transition.
|
|
776
|
+
|
|
697
777
|
## Ecosystem & agents
|
|
698
778
|
|
|
699
779
|
- **`llms.txt`** — the agent surface: a machine-readable index of every capability, generated
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { COLOR_SPACE_RANGES as e, color2 as t, deltaEOK as n, normalizeColorUnit as r, sampleColorRamp as i, scale as a } from "@mkbabb/value.js";
|
|
2
|
+
//#region src/animation/compile/backward/backward-color.ts
|
|
3
|
+
var o = e.oklab.a.number.min, s = e.oklab.a.number.max, c = e.oklab.b.number.min, l = e.oklab.b.number.max, u = (e) => Math.round(e * 1e4) / 1e4, d = (e) => typeof e == "object" && !!e && e.unit === "color", f = (e) => r(e).value, p = (e) => {
|
|
4
|
+
let n = t(e, "oklab");
|
|
5
|
+
return [
|
|
6
|
+
n.l,
|
|
7
|
+
a(n.a, 0, 1, o, s),
|
|
8
|
+
a(n.b, 0, 1, c, l)
|
|
9
|
+
];
|
|
10
|
+
}, m = (e) => {
|
|
11
|
+
let [t, n, r] = p(e);
|
|
12
|
+
return `oklab(${u(t)} ${u(n)} ${u(r)})`;
|
|
13
|
+
}, h = (e) => m(f(e)), g = (e, t) => {
|
|
14
|
+
let [r, i, a] = p(e), [o, s, c] = p(t);
|
|
15
|
+
return n(r, i, a, o, s, c);
|
|
16
|
+
}, _ = (e, n, r) => t({
|
|
17
|
+
colorSpace: "oklab",
|
|
18
|
+
l: e,
|
|
19
|
+
a: a(n, o, s, 0, 1),
|
|
20
|
+
b: a(r, c, l, 0, 1),
|
|
21
|
+
alpha: 1
|
|
22
|
+
}, "oklab"), v = (e, t) => {
|
|
23
|
+
let [n, r, i] = p(e), [a, o, s] = p(t);
|
|
24
|
+
return _((n + a) / 2, (r + o) / 2, (i + s) / 2);
|
|
25
|
+
}, y = (e) => {
|
|
26
|
+
let t = /([\d.]+)\s*%/.exec(e.toString());
|
|
27
|
+
return t ? parseFloat(t[1]) : 0;
|
|
28
|
+
}, b = (e, t, n) => {
|
|
29
|
+
let r = (e.parsedVars[t] ?? {})[n];
|
|
30
|
+
if (Array.isArray(r)) return r.find((e) => d(e));
|
|
31
|
+
};
|
|
32
|
+
function x(e, t, n, r, a) {
|
|
33
|
+
let o = t.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), s = [], c = 0;
|
|
34
|
+
for (let o = 0; o + 1 < e.templateFrames.length; o++) {
|
|
35
|
+
let l = b(e, o, t), d = b(e, o + 1, t);
|
|
36
|
+
if (!l || !d) continue;
|
|
37
|
+
let p = y(e.templateFrames[o].start), h = y(e.templateFrames[o + 1].start);
|
|
38
|
+
if (l.toString() === d.toString()) {
|
|
39
|
+
s.push({
|
|
40
|
+
pct: p,
|
|
41
|
+
css: l.toString()
|
|
42
|
+
});
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
let _ = f(l), x = f(d), S = i(_, x, n, {
|
|
46
|
+
space: r,
|
|
47
|
+
...a
|
|
48
|
+
});
|
|
49
|
+
for (let e = 0; e < S.length; e++) {
|
|
50
|
+
let t = e / (S.length - 1), n = p + (h - p) * t;
|
|
51
|
+
s.push({
|
|
52
|
+
pct: u(n),
|
|
53
|
+
css: m(S[e])
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
let C = i(_, x, 1024, {
|
|
57
|
+
space: r,
|
|
58
|
+
...a
|
|
59
|
+
});
|
|
60
|
+
for (let e = 0; e + 1 < S.length; e++) {
|
|
61
|
+
let t = (e + .5) / (S.length - 1), n = C[Math.round(t * 1023)], r = v(S[e], S[e + 1]);
|
|
62
|
+
c = Math.max(c, g(r, n));
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
let l = e.templateFrames.length - 1, d = b(e, l, t);
|
|
66
|
+
if (d) {
|
|
67
|
+
let t = y(e.templateFrames[l].start);
|
|
68
|
+
s[s.length - 1]?.pct !== t && s.push({
|
|
69
|
+
pct: t,
|
|
70
|
+
css: d.toString()
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
return {
|
|
74
|
+
cssProp: o,
|
|
75
|
+
stops: s,
|
|
76
|
+
worstDelta: c
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
function S(e, t, n) {
|
|
80
|
+
let r = [], i = /* @__PURE__ */ new Set();
|
|
81
|
+
for (let t = 0; t + 1 < e.templateFrames.length; t++) {
|
|
82
|
+
let n = e.parsedVars[t] ?? {};
|
|
83
|
+
for (let [a, o] of Object.entries(n)) {
|
|
84
|
+
if (i.has(a) || !Array.isArray(o) || !o.some((e) => d(e))) continue;
|
|
85
|
+
let n = b(e, t, a), s = b(e, t + 1, a);
|
|
86
|
+
n && s && n.toString() !== s.toString() && (r.push(a), i.add(a));
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
if (r.length === 0) return null;
|
|
90
|
+
let a = Math.max(3, t), o = e.options.colorSpace === "oklch" ? "oklch" : "oklab", s = e.options.hueMethod ? { hueMethod: e.options.hueMethod } : {}, c = 0, l = /* @__PURE__ */ new Map();
|
|
91
|
+
for (let t of r) {
|
|
92
|
+
let n = x(e, t, a, o, s);
|
|
93
|
+
c = Math.max(c, n.worstDelta);
|
|
94
|
+
for (let { pct: e, css: t } of n.stops) {
|
|
95
|
+
let r = l.get(e);
|
|
96
|
+
r || (r = [], l.set(e, r)), r.push(`${n.cssProp}: ${t};`);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return c > n ? {
|
|
100
|
+
refused: !0,
|
|
101
|
+
delta: c
|
|
102
|
+
} : {
|
|
103
|
+
byPct: l,
|
|
104
|
+
keys: r
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
//#endregion
|
|
108
|
+
export { u as i, S as n, d as r, h as t };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { n as e } from "./presets-DeDJYL4G.js";
|
|
2
|
+
import { c as t, l as n, s as r, u as i } from "./engine-CPK_udUQ.js";
|
|
3
|
+
import { n as a, r as o, t as s } from "./parse-flatten-ZZUSEQEL.js";
|
|
4
|
+
import { t as c } from "./easing-registry-DHV2-5gA.js";
|
|
5
|
+
import { a as l, r as u, t as d } from "./view-transition-BPJQxUTC.js";
|
|
6
|
+
import { t as f } from "./easing-serialize-D4LZCB6i.js";
|
|
7
|
+
import { i as p, n as m, t as h } from "./format-BdIvdLzG.js";
|
|
8
|
+
import { t as g } from "./entry-D82NKUhP.js";
|
|
9
|
+
//#region src/animation/compile/index.ts
|
|
10
|
+
var _ = /* @__PURE__ */ e({
|
|
11
|
+
CSSKeyframesToString: () => h,
|
|
12
|
+
CSSKeyframesToStrings: () => m,
|
|
13
|
+
DEFAULT_DELTA_E_EPSILON: () => u,
|
|
14
|
+
DEFAULT_DENSIFY_STOPS: () => 16,
|
|
15
|
+
FrameCompiler: () => r,
|
|
16
|
+
NAMED_SELECTOR_SUPERTYPE: () => n,
|
|
17
|
+
compileToCSS: () => l,
|
|
18
|
+
compileToEntry: () => g,
|
|
19
|
+
compileToViewTransition: () => d,
|
|
20
|
+
createInterpVarValue: () => s,
|
|
21
|
+
formatCSSKeyframeString: () => p,
|
|
22
|
+
getTimingFunction: () => c,
|
|
23
|
+
namedSelectorToFraction: () => i,
|
|
24
|
+
parseAndFlattenObject: () => a,
|
|
25
|
+
resolveEasingOption: () => t,
|
|
26
|
+
serializeEasing: () => f,
|
|
27
|
+
transformTargetsStyle: () => o
|
|
28
|
+
});
|
|
29
|
+
//#endregion
|
|
30
|
+
export { _ as t };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { f as e, i as t } from "./sequence-
|
|
1
|
+
import { f as e, i as t } from "./sequence-s0bL7Uul.js";
|
|
2
2
|
import { COMPUTED_UNITS as n, unflattenObjectToString as r } from "@mkbabb/value.js";
|
|
3
3
|
//#region src/animation/internal/scroll-phases.ts
|
|
4
4
|
var i = {
|
|
@@ -71,10 +71,6 @@ function u(e) {
|
|
|
71
71
|
eligible: !1,
|
|
72
72
|
reason: "non-uniform per-frame timing function (WAAPI supports one easing per animation)"
|
|
73
73
|
};
|
|
74
|
-
if (t.css !== void 0) return {
|
|
75
|
-
eligible: !1,
|
|
76
|
-
reason: "CSS-twinned easing across multiple segments (WAAPI restarts the curve per segment)"
|
|
77
|
-
};
|
|
78
74
|
}
|
|
79
75
|
if (t && t.css === void 0) return {
|
|
80
76
|
eligible: !1,
|
|
@@ -184,7 +180,7 @@ function _(t) {
|
|
|
184
180
|
return i;
|
|
185
181
|
}
|
|
186
182
|
//#endregion
|
|
187
|
-
//#region src/animation/waapi/options.ts
|
|
183
|
+
//#region src/animation/waapi/waapi-options.ts
|
|
188
184
|
var v = {
|
|
189
185
|
normal: "normal",
|
|
190
186
|
reverse: "reverse",
|
|
@@ -210,15 +206,15 @@ function S(e) {
|
|
|
210
206
|
let t = e.options, n = v[t.direction], r = y[t.fillMode];
|
|
211
207
|
if (n == null) throw TypeError(`Unrecognised animation direction "${t.direction}".`);
|
|
212
208
|
if (r == null) throw TypeError(`Unrecognised animation fill mode "${t.fillMode}".`);
|
|
213
|
-
let i =
|
|
209
|
+
let i = e.frames[0]?.timingFunction ?? e.options.timingFunction, a = e.frames.length > 1 ? "linear" : i.css ?? "linear", o = x(e), s = {
|
|
214
210
|
duration: t.duration,
|
|
215
211
|
delay: t.delay,
|
|
216
212
|
iterations: t.iterationCount === Infinity ? Infinity : t.iterationCount,
|
|
217
213
|
direction: n,
|
|
218
214
|
fill: r,
|
|
219
|
-
easing:
|
|
215
|
+
easing: a
|
|
220
216
|
};
|
|
221
|
-
return
|
|
217
|
+
return o !== "replace" && (s.composite = o), s;
|
|
222
218
|
}
|
|
223
219
|
//#endregion
|
|
224
220
|
//#region src/animation/waapi/delegation.ts
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { n as e } from "./presets-
|
|
2
|
-
import { t } from "./engine-
|
|
1
|
+
import { n as e } from "./presets-DeDJYL4G.js";
|
|
2
|
+
import { t } from "./engine-CPK_udUQ.js";
|
|
3
|
+
import { t as n } from "./handle-D4xrf_ya.js";
|
|
3
4
|
//#region src/animation/svg/draw-svg.ts
|
|
4
|
-
var
|
|
5
|
-
DrawSVG: () =>
|
|
6
|
-
fromDrawSVG: () =>
|
|
7
|
-
}),
|
|
5
|
+
var r = /* @__PURE__ */ e({
|
|
6
|
+
DrawSVG: () => o,
|
|
7
|
+
fromDrawSVG: () => a
|
|
8
|
+
}), i = (e) => {
|
|
8
9
|
if (typeof e == "number") {
|
|
9
10
|
if (!Number.isFinite(e) || e < 0 || e > 1) throw Error(`fromDrawSVG(): a numeric draw position is a 0..1 fraction, got ${JSON.stringify(e)} — pass a fraction in [0, 1] or a percent string ("0%".."100%").`);
|
|
10
11
|
return e;
|
|
@@ -12,10 +13,10 @@ var n = /* @__PURE__ */ e({
|
|
|
12
13
|
if (!/^\s*\d*\.?\d+\s*%\s*$/.test(e)) throw Error(`fromDrawSVG(): invalid draw position ${JSON.stringify(e)} — pass a percent string ("0%".."100%") or a 0..1 number.`);
|
|
13
14
|
return parseFloat(e) / 100;
|
|
14
15
|
};
|
|
15
|
-
function
|
|
16
|
-
let { from:
|
|
16
|
+
function a(e, n = {}) {
|
|
17
|
+
let { from: r = "0%", to: a = "100%", autoPlay: o = !0, ...s } = n;
|
|
17
18
|
if (e == null || typeof e.getTotalLength != "function") throw Error("fromDrawSVG(): `target` must be an SVG geometry element exposing getTotalLength() (a <path>/<line>/<circle>/<rect>/<polygon>/…).");
|
|
18
|
-
let c = r
|
|
19
|
+
let c = i(r), l = i(a), u = e.getTotalLength();
|
|
19
20
|
e.style.strokeDasharray = `${u}`;
|
|
20
21
|
let d = {
|
|
21
22
|
"0%": { "stroke-dashoffset": u * (1 - c) },
|
|
@@ -23,23 +24,10 @@ function i(e, n = {}) {
|
|
|
23
24
|
}, f = new t(s).fromKeyframes(d);
|
|
24
25
|
return f.setTargets(e), o && f.play(), f;
|
|
25
26
|
}
|
|
26
|
-
var
|
|
27
|
-
animation;
|
|
27
|
+
var o = class extends n {
|
|
28
28
|
constructor(e, t = {}) {
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
play() {
|
|
32
|
-
return this.animation.play();
|
|
33
|
-
}
|
|
34
|
-
pause() {
|
|
35
|
-
return this.animation.pause(), this;
|
|
36
|
-
}
|
|
37
|
-
stop() {
|
|
38
|
-
return this.animation.stop(), this;
|
|
39
|
-
}
|
|
40
|
-
get finished() {
|
|
41
|
-
return this.animation.finished;
|
|
29
|
+
super(a(e, t));
|
|
42
30
|
}
|
|
43
31
|
};
|
|
44
32
|
//#endregion
|
|
45
|
-
export { n,
|
|
33
|
+
export { r as n, a as r, o as t };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { y as e } from "./sequence-s0bL7Uul.js";
|
|
2
|
+
import { camelCaseToHyphen as t, timingFunctions as n } from "@mkbabb/value.js";
|
|
3
|
+
//#region src/animation/compile/backward/easing-serialize.ts
|
|
4
|
+
var r = /^(linear|ease|ease-in|ease-out|ease-in-out|step-start|step-end)$/, i = (e) => Math.round(e * 1e5) / 1e5;
|
|
5
|
+
function a(e, t = 32) {
|
|
6
|
+
let n = [];
|
|
7
|
+
for (let r = 0; r <= t; r++) {
|
|
8
|
+
let a = r / t;
|
|
9
|
+
n.push(`${i(e(a))} ${i(a * 100)}%`);
|
|
10
|
+
}
|
|
11
|
+
return `linear(${n.join(", ")})`;
|
|
12
|
+
}
|
|
13
|
+
function o(i) {
|
|
14
|
+
if (i.css !== void 0) return i.css;
|
|
15
|
+
let o = Object.entries(n).find(([e, t]) => t === i.fn)?.[0];
|
|
16
|
+
if (o === void 0) throw new e("timingFunction", i.fn, "a custom TimingFunction has no CSS animation-timing-function representation — attach a faithful Easing.css twin, or use a registry name / cubic-bezier() / linear() literal");
|
|
17
|
+
let s = t(o);
|
|
18
|
+
return r.test(s) ? s : a(i.fn);
|
|
19
|
+
}
|
|
20
|
+
//#endregion
|
|
21
|
+
export { o as t };
|