motionary 0.0.0-stage → 6.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/CHANGELOG.md +803 -0
- package/LICENSE +21 -0
- package/README.md +218 -2
- package/README_ja.md +219 -0
- package/README_zh.md +219 -0
- package/bin/usa-codemod-5.mjs +79 -0
- package/bin/usa-codemod-6.mjs +146 -0
- package/dist/chunks/base-BaQV-2ha.cjs +436 -0
- package/dist/chunks/base-BaQV-2ha.cjs.map +1 -0
- package/dist/chunks/base-C_3cAoRz.js +404 -0
- package/dist/chunks/base-C_3cAoRz.js.map +1 -0
- package/dist/chunks/bind-B_CTL6Qn.js +22 -0
- package/dist/chunks/bind-B_CTL6Qn.js.map +1 -0
- package/dist/chunks/bind-Ui43-n2d.cjs +25 -0
- package/dist/chunks/bind-Ui43-n2d.cjs.map +1 -0
- package/dist/chunks/core-B5T0dhFH.cjs +920 -0
- package/dist/chunks/core-B5T0dhFH.cjs.map +1 -0
- package/dist/chunks/core-BGAyaY6L.cjs +265 -0
- package/dist/chunks/core-BGAyaY6L.cjs.map +1 -0
- package/dist/chunks/core-D7cVumUu.js +909 -0
- package/dist/chunks/core-D7cVumUu.js.map +1 -0
- package/dist/chunks/core-VEBw36QK.js +260 -0
- package/dist/chunks/core-VEBw36QK.js.map +1 -0
- package/dist/chunks/core-ps8uvYuN.js +181 -0
- package/dist/chunks/core-ps8uvYuN.js.map +1 -0
- package/dist/chunks/core-zq17EeCI.cjs +185 -0
- package/dist/chunks/core-zq17EeCI.cjs.map +1 -0
- package/dist/chunks/fx-Bs6IrV4Q.js +109 -0
- package/dist/chunks/fx-Bs6IrV4Q.js.map +1 -0
- package/dist/chunks/fx-lBGVtQO1.cjs +114 -0
- package/dist/chunks/fx-lBGVtQO1.cjs.map +1 -0
- package/dist/chunks/generative-D2YyhaeO.js +336 -0
- package/dist/chunks/generative-D2YyhaeO.js.map +1 -0
- package/dist/chunks/generative-DzIZq-_g.cjs +348 -0
- package/dist/chunks/generative-DzIZq-_g.cjs.map +1 -0
- package/dist/chunks/gpu-Bu7qwugO.js +380 -0
- package/dist/chunks/gpu-Bu7qwugO.js.map +1 -0
- package/dist/chunks/gpu-CenK2l6b.cjs +387 -0
- package/dist/chunks/gpu-CenK2l6b.cjs.map +1 -0
- package/dist/chunks/index-tags-DucKMQr_.js +26 -0
- package/dist/chunks/index-tags-DucKMQr_.js.map +1 -0
- package/dist/chunks/index-tags-wv0R_vkO.cjs +28 -0
- package/dist/chunks/index-tags-wv0R_vkO.cjs.map +1 -0
- package/dist/chunks/presets-BYBVJVeP.js +226 -0
- package/dist/chunks/presets-BYBVJVeP.js.map +1 -0
- package/dist/chunks/presets-CUHys3sK.cjs +233 -0
- package/dist/chunks/presets-CUHys3sK.cjs.map +1 -0
- package/dist/chunks/registry-CKNLQpwd.js +121 -0
- package/dist/chunks/registry-CKNLQpwd.js.map +1 -0
- package/dist/chunks/registry-DehBVRDV.cjs +131 -0
- package/dist/chunks/registry-DehBVRDV.cjs.map +1 -0
- package/dist/chunks/spring-CbvHfVtP.js +219 -0
- package/dist/chunks/spring-CbvHfVtP.js.map +1 -0
- package/dist/chunks/spring-Dgx187Vh.cjs +232 -0
- package/dist/chunks/spring-Dgx187Vh.cjs.map +1 -0
- package/dist/chunks/stagger-CCFyhzSw.cjs +86 -0
- package/dist/chunks/stagger-CCFyhzSw.cjs.map +1 -0
- package/dist/chunks/stagger-DtMKo2SK.js +84 -0
- package/dist/chunks/stagger-DtMKo2SK.js.map +1 -0
- package/dist/chunks/variants-BhjyddG8.cjs +39 -0
- package/dist/chunks/variants-BhjyddG8.cjs.map +1 -0
- package/dist/chunks/variants-DRlKVHvu.js +35 -0
- package/dist/chunks/variants-DRlKVHvu.js.map +1 -0
- package/dist/components/a11y.cjs +276 -0
- package/dist/components/a11y.cjs.map +1 -0
- package/dist/components/a11y.d.cts +131 -0
- package/dist/components/a11y.d.ts +131 -0
- package/dist/components/a11y.js +259 -0
- package/dist/components/a11y.js.map +1 -0
- package/dist/components/angular.cjs +76 -0
- package/dist/components/angular.cjs.map +1 -0
- package/dist/components/angular.d.cts +1734 -0
- package/dist/components/angular.d.ts +1734 -0
- package/dist/components/angular.js +70 -0
- package/dist/components/angular.js.map +1 -0
- package/dist/components/background.cjs +659 -0
- package/dist/components/background.cjs.map +1 -0
- package/dist/components/background.css +9 -0
- package/dist/components/background.d.cts +166 -0
- package/dist/components/background.d.ts +166 -0
- package/dist/components/background.js +647 -0
- package/dist/components/background.js.map +1 -0
- package/dist/components/bridge.cjs +154 -0
- package/dist/components/bridge.cjs.map +1 -0
- package/dist/components/bridge.d.cts +63 -0
- package/dist/components/bridge.d.ts +63 -0
- package/dist/components/bridge.js +147 -0
- package/dist/components/bridge.js.map +1 -0
- package/dist/components/cards.cjs +561 -0
- package/dist/components/cards.cjs.map +1 -0
- package/dist/components/cards.css +6 -0
- package/dist/components/cards.d.cts +115 -0
- package/dist/components/cards.d.ts +115 -0
- package/dist/components/cards.js +554 -0
- package/dist/components/cards.js.map +1 -0
- package/dist/components/click.cjs +877 -0
- package/dist/components/click.cjs.map +1 -0
- package/dist/components/click.css +9 -0
- package/dist/components/click.d.cts +218 -0
- package/dist/components/click.d.ts +218 -0
- package/dist/components/click.js +863 -0
- package/dist/components/click.js.map +1 -0
- package/dist/components/depth.cjs +250 -0
- package/dist/components/depth.cjs.map +1 -0
- package/dist/components/depth.css +3 -0
- package/dist/components/depth.d.cts +86 -0
- package/dist/components/depth.d.ts +86 -0
- package/dist/components/depth.js +242 -0
- package/dist/components/depth.js.map +1 -0
- package/dist/components/effects.cjs +2258 -0
- package/dist/components/effects.cjs.map +1 -0
- package/dist/components/effects.d.cts +545 -0
- package/dist/components/effects.d.ts +545 -0
- package/dist/components/effects.js +2200 -0
- package/dist/components/effects.js.map +1 -0
- package/dist/components/feedback.cjs +442 -0
- package/dist/components/feedback.cjs.map +1 -0
- package/dist/components/feedback.css +7 -0
- package/dist/components/feedback.d.cts +144 -0
- package/dist/components/feedback.d.ts +144 -0
- package/dist/components/feedback.js +433 -0
- package/dist/components/feedback.js.map +1 -0
- package/dist/components/fx-gpu.cjs +12 -0
- package/dist/components/fx-gpu.cjs.map +1 -0
- package/dist/components/fx-gpu.d.cts +63 -0
- package/dist/components/fx-gpu.d.ts +63 -0
- package/dist/components/fx-gpu.js +5 -0
- package/dist/components/fx-gpu.js.map +1 -0
- package/dist/components/fx.cjs +169 -0
- package/dist/components/fx.cjs.map +1 -0
- package/dist/components/fx.css +3 -0
- package/dist/components/fx.d.cts +114 -0
- package/dist/components/fx.d.ts +114 -0
- package/dist/components/fx.js +156 -0
- package/dist/components/fx.js.map +1 -0
- package/dist/components/fx2.cjs +25 -0
- package/dist/components/fx2.cjs.map +1 -0
- package/dist/components/fx2.d.cts +136 -0
- package/dist/components/fx2.d.ts +136 -0
- package/dist/components/fx2.js +17 -0
- package/dist/components/fx2.js.map +1 -0
- package/dist/components/gesture.cjs +209 -0
- package/dist/components/gesture.cjs.map +1 -0
- package/dist/components/gesture.css +3 -0
- package/dist/components/gesture.d.cts +134 -0
- package/dist/components/gesture.d.ts +134 -0
- package/dist/components/gesture.js +203 -0
- package/dist/components/gesture.js.map +1 -0
- package/dist/components/interaction.cjs +424 -0
- package/dist/components/interaction.cjs.map +1 -0
- package/dist/components/interaction.css +8 -0
- package/dist/components/interaction.d.cts +115 -0
- package/dist/components/interaction.d.ts +115 -0
- package/dist/components/interaction.js +416 -0
- package/dist/components/interaction.js.map +1 -0
- package/dist/components/jsx.cjs +3 -0
- package/dist/components/jsx.cjs.map +1 -0
- package/dist/components/jsx.d.cts +53 -0
- package/dist/components/jsx.d.ts +53 -0
- package/dist/components/jsx.js +2 -0
- package/dist/components/jsx.js.map +1 -0
- package/dist/components/layout.cjs +257 -0
- package/dist/components/layout.cjs.map +1 -0
- package/dist/components/layout.css +3 -0
- package/dist/components/layout.d.cts +99 -0
- package/dist/components/layout.d.ts +99 -0
- package/dist/components/layout.js +249 -0
- package/dist/components/layout.js.map +1 -0
- package/dist/components/lazy.cjs +92 -0
- package/dist/components/lazy.cjs.map +1 -0
- package/dist/components/lazy.d.cts +48 -0
- package/dist/components/lazy.d.ts +48 -0
- package/dist/components/lazy.js +87 -0
- package/dist/components/lazy.js.map +1 -0
- package/dist/components/lite.cjs +11095 -0
- package/dist/components/lite.cjs.map +1 -0
- package/dist/components/lite.d.cts +4 -0
- package/dist/components/lite.d.ts +4 -0
- package/dist/components/lite.js +10827 -0
- package/dist/components/lite.js.map +1 -0
- package/dist/components/packs.cjs +192 -0
- package/dist/components/packs.cjs.map +1 -0
- package/dist/components/packs.css +3 -0
- package/dist/components/packs.d.cts +72 -0
- package/dist/components/packs.d.ts +72 -0
- package/dist/components/packs.js +184 -0
- package/dist/components/packs.js.map +1 -0
- package/dist/components/page.cjs +824 -0
- package/dist/components/page.cjs.map +1 -0
- package/dist/components/page.css +11 -0
- package/dist/components/page.d.cts +249 -0
- package/dist/components/page.d.ts +249 -0
- package/dist/components/page.js +799 -0
- package/dist/components/page.js.map +1 -0
- package/dist/components/perf.cjs +120 -0
- package/dist/components/perf.cjs.map +1 -0
- package/dist/components/perf.d.cts +98 -0
- package/dist/components/perf.d.ts +98 -0
- package/dist/components/perf.js +110 -0
- package/dist/components/perf.js.map +1 -0
- package/dist/components/physics.cjs +448 -0
- package/dist/components/physics.cjs.map +1 -0
- package/dist/components/physics.css +5 -0
- package/dist/components/physics.d.cts +189 -0
- package/dist/components/physics.d.ts +189 -0
- package/dist/components/physics.js +430 -0
- package/dist/components/physics.js.map +1 -0
- package/dist/components/react.cjs +96 -0
- package/dist/components/react.cjs.map +1 -0
- package/dist/components/react.d.cts +18 -0
- package/dist/components/react.d.ts +18 -0
- package/dist/components/react.js +91 -0
- package/dist/components/react.js.map +1 -0
- package/dist/components/reveal.cjs +362 -0
- package/dist/components/reveal.cjs.map +1 -0
- package/dist/components/reveal.css +5 -0
- package/dist/components/reveal.d.cts +105 -0
- package/dist/components/reveal.d.ts +105 -0
- package/dist/components/reveal.js +353 -0
- package/dist/components/reveal.js.map +1 -0
- package/dist/components/solid.cjs +86 -0
- package/dist/components/solid.cjs.map +1 -0
- package/dist/components/solid.d.cts +1751 -0
- package/dist/components/solid.d.ts +1751 -0
- package/dist/components/solid.js +82 -0
- package/dist/components/solid.js.map +1 -0
- package/dist/components/svelte.cjs +68 -0
- package/dist/components/svelte.cjs.map +1 -0
- package/dist/components/svelte.d.cts +1733 -0
- package/dist/components/svelte.d.ts +1733 -0
- package/dist/components/svelte.js +64 -0
- package/dist/components/svelte.js.map +1 -0
- package/dist/components/svg.cjs +359 -0
- package/dist/components/svg.cjs.map +1 -0
- package/dist/components/svg.css +3 -0
- package/dist/components/svg.d.cts +113 -0
- package/dist/components/svg.d.ts +113 -0
- package/dist/components/svg.js +347 -0
- package/dist/components/svg.js.map +1 -0
- package/dist/components/text.cjs +968 -0
- package/dist/components/text.cjs.map +1 -0
- package/dist/components/text.css +8 -0
- package/dist/components/text.d.cts +342 -0
- package/dist/components/text.d.ts +342 -0
- package/dist/components/text.js +947 -0
- package/dist/components/text.js.map +1 -0
- package/dist/components/timeline.cjs +109 -0
- package/dist/components/timeline.cjs.map +1 -0
- package/dist/components/timeline.css +3 -0
- package/dist/components/timeline.d.cts +155 -0
- package/dist/components/timeline.d.ts +155 -0
- package/dist/components/timeline.js +103 -0
- package/dist/components/timeline.js.map +1 -0
- package/dist/components/tokens.cjs +226 -0
- package/dist/components/tokens.cjs.map +1 -0
- package/dist/components/tokens.d.cts +74 -0
- package/dist/components/tokens.d.ts +74 -0
- package/dist/components/tokens.js +211 -0
- package/dist/components/tokens.js.map +1 -0
- package/dist/components/transitions.cjs +430 -0
- package/dist/components/transitions.cjs.map +1 -0
- package/dist/components/transitions.css +5 -0
- package/dist/components/transitions.d.cts +126 -0
- package/dist/components/transitions.d.ts +126 -0
- package/dist/components/transitions.js +423 -0
- package/dist/components/transitions.js.map +1 -0
- package/dist/components/ui.cjs +1050 -0
- package/dist/components/ui.cjs.map +1 -0
- package/dist/components/ui.css +14 -0
- package/dist/components/ui.d.cts +224 -0
- package/dist/components/ui.d.ts +224 -0
- package/dist/components/ui.js +1034 -0
- package/dist/components/ui.js.map +1 -0
- package/dist/components/vue.cjs +67 -0
- package/dist/components/vue.cjs.map +1 -0
- package/dist/components/vue.d.cts +1722 -0
- package/dist/components/vue.d.ts +1722 -0
- package/dist/components/vue.js +64 -0
- package/dist/components/vue.js.map +1 -0
- package/dist/components/webgl.cjs +459 -0
- package/dist/components/webgl.cjs.map +1 -0
- package/dist/components/webgl.css +3 -0
- package/dist/components/webgl.d.cts +133 -0
- package/dist/components/webgl.d.ts +133 -0
- package/dist/components/webgl.js +442 -0
- package/dist/components/webgl.js.map +1 -0
- package/dist/components/widgets.cjs +591 -0
- package/dist/components/widgets.cjs.map +1 -0
- package/dist/components/widgets.d.cts +110 -0
- package/dist/components/widgets.d.ts +110 -0
- package/dist/components/widgets.js +581 -0
- package/dist/components/widgets.js.map +1 -0
- package/dist/components.cjs +351 -0
- package/dist/components.cjs.map +1 -0
- package/dist/components.css +75 -0
- package/dist/components.d.cts +2997 -0
- package/dist/components.d.ts +2997 -0
- package/dist/components.js +106 -0
- package/dist/components.js.map +1 -0
- package/dist/components.umd.js +23 -0
- package/dist/components.umd.js.map +1 -0
- package/dist/element.cjs +97 -0
- package/dist/element.cjs.map +1 -0
- package/dist/element.d.cts +215 -0
- package/dist/element.d.ts +215 -0
- package/dist/element.js +95 -0
- package/dist/element.js.map +1 -0
- package/dist/element.umd.js +2 -0
- package/dist/element.umd.js.map +1 -0
- package/dist/index.cjs +149 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +425 -0
- package/dist/index.d.ts +425 -0
- package/dist/index.js +131 -0
- package/dist/index.js.map +1 -0
- package/dist/index.umd.js +15 -0
- package/dist/index.umd.js.map +1 -0
- package/dist/presets/extended.cjs +243 -0
- package/dist/presets/extended.cjs.map +1 -0
- package/dist/presets/extended.d.cts +37 -0
- package/dist/presets/extended.d.ts +37 -0
- package/dist/presets/extended.js +239 -0
- package/dist/presets/extended.js.map +1 -0
- package/dist/presets-extended.umd.js +2 -0
- package/dist/presets-extended.umd.js.map +1 -0
- package/dist/react.cjs +68 -0
- package/dist/react.cjs.map +1 -0
- package/dist/react.d.cts +158 -0
- package/dist/react.d.ts +158 -0
- package/dist/react.js +65 -0
- package/dist/react.js.map +1 -0
- package/dist/solid.cjs +93 -0
- package/dist/solid.cjs.map +1 -0
- package/dist/solid.d.cts +249 -0
- package/dist/solid.d.ts +249 -0
- package/dist/solid.js +89 -0
- package/dist/solid.js.map +1 -0
- package/dist/svelte.cjs +66 -0
- package/dist/svelte.cjs.map +1 -0
- package/dist/svelte.d.cts +243 -0
- package/dist/svelte.d.ts +243 -0
- package/dist/svelte.js +63 -0
- package/dist/svelte.js.map +1 -0
- package/dist/vue.cjs +62 -0
- package/dist/vue.cjs.map +1 -0
- package/dist/vue.d.cts +158 -0
- package/dist/vue.d.ts +158 -0
- package/dist/vue.js +60 -0
- package/dist/vue.js.map +1 -0
- package/dist/widgets.umd.js +2 -0
- package/dist/widgets.umd.js.map +1 -0
- package/docs/API.md +147 -0
- package/docs/ROADMAP.md +14 -0
- package/docs/accessibility.md +60 -0
- package/docs/components.md +564 -0
- package/docs/deprecations.md +30 -0
- package/docs/frameworks-ssr.md +100 -0
- package/docs/hybrid-apps.md +145 -0
- package/docs/images/showcase-detail.png +0 -0
- package/docs/images/showcase-grid.png +0 -0
- package/docs/images/showcase-mobile.png +0 -0
- package/docs/migration-from-aos.md +67 -0
- package/docs/migration-from-gsap-scrolltrigger.md +80 -0
- package/docs/motion-tokens.css +31 -0
- package/docs/motion-tokens.md +46 -0
- package/docs/motion.tokens.json +132 -0
- package/docs/performance.md +24 -0
- package/docs/presets.md +310 -0
- package/docs/upgrading-3.md +21 -0
- package/docs/upgrading-4.md +65 -0
- package/docs/upgrading-5.md +31 -0
- package/docs/upgrading-6.md +32 -0
- package/docs/windows-apps.md +119 -0
- package/package.json +562 -4
|
@@ -0,0 +1,545 @@
|
|
|
1
|
+
type MotionSensitivity = 'full' | 'gentle' | 'minimal' | 'static';
|
|
2
|
+
type Cleanup = () => void;
|
|
3
|
+
/**
|
|
4
|
+
* Members shared by every `<usa-*>` element. Attribute helpers, a cleanup
|
|
5
|
+
* bag that is emptied on disconnect, and motion helpers that degrade to the
|
|
6
|
+
* final state without WAAPI or under reduced motion.
|
|
7
|
+
*/
|
|
8
|
+
interface UsaElement extends HTMLElement {
|
|
9
|
+
/** `true` while reduced motion applies to this element. */
|
|
10
|
+
readonly reduced: boolean;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* 5.0 — unified plugin-style effect registration. Every effect (built-in or
|
|
15
|
+
* yours) is a plain object registered once and played the same way:
|
|
16
|
+
* `playEffect(el, name)`, `bindEffect(el, name, { trigger })` or
|
|
17
|
+
* `<usa-fx effect="name" trigger="click">`. Effects get a context that
|
|
18
|
+
* already applies reduced motion, motion sensitivity, intensity and the
|
|
19
|
+
* animation budget.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
declare const EFFECT_KINDS: readonly ["enter", "exit", "attention", "click", "hover", "card", "loop", "page", "background", "text", "cursor", "scroll"];
|
|
23
|
+
type EffectKind = (typeof EFFECT_KINDS)[number];
|
|
24
|
+
interface EffectContext {
|
|
25
|
+
/** Reduced motion applies (OS setting, `minimal` / `static` sensitivity). */
|
|
26
|
+
readonly reduced: boolean;
|
|
27
|
+
readonly sensitivity: MotionSensitivity;
|
|
28
|
+
/** The triggering event (pointer position for click effects), if any. */
|
|
29
|
+
readonly event?: Event;
|
|
30
|
+
/** `el.animate()` with the library's motion rules (may return `null`). */
|
|
31
|
+
animate(el: Element, keyframes: Keyframe[], options: KeyframeAnimationOptions): Animation | null;
|
|
32
|
+
/** Register teardown for long-running effects (loops, listeners). */
|
|
33
|
+
onCleanup(fn: Cleanup): void;
|
|
34
|
+
}
|
|
35
|
+
interface EffectDefinition<O extends Record<string, unknown> = Record<string, any>> {
|
|
36
|
+
/** Unique, kebab-case. */
|
|
37
|
+
name: string;
|
|
38
|
+
kind: EffectKind;
|
|
39
|
+
/** One line for docs and the gallery. */
|
|
40
|
+
description?: string;
|
|
41
|
+
/** Option defaults (merged under the caller's options). */
|
|
42
|
+
defaults?: Partial<O>;
|
|
43
|
+
/**
|
|
44
|
+
* Under reduced motion: `'skip'` (do nothing — default for loop, background
|
|
45
|
+
* and cursor effects) or `'run'` (run with `ctx.reduced === true`, the
|
|
46
|
+
* effect degrades itself — default for everything else).
|
|
47
|
+
*/
|
|
48
|
+
reduced?: 'skip' | 'run';
|
|
49
|
+
/** Play the effect. Return an Animation / Promise to be awaited, or a cleanup. */
|
|
50
|
+
run(el: HTMLElement, options: O, ctx: EffectContext): void | Cleanup | Animation | null | Promise<unknown>;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* 5.1 — card & click effects 2.0, registered through `registerEffect()`.
|
|
55
|
+
* Card: `holo` (holographic foil following the pointer), `glare-sweep`,
|
|
56
|
+
* `book-open`, `card-fan`, `topple`, `float-tilt`. Click: `shockwave`,
|
|
57
|
+
* `ink-splash`, `star-burst`, `jelly-press`, `ring-ripple`, `emoji-rain`.
|
|
58
|
+
*/
|
|
59
|
+
|
|
60
|
+
declare const CARD_FX: EffectDefinition[];
|
|
61
|
+
declare const CLICK_FX: EffectDefinition[];
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* 5.2 — bounce & physics micro-interactions, registered through
|
|
65
|
+
* `registerEffect()`. Keyframes come from a damped-spring / gravity solver
|
|
66
|
+
* (`springKeyframes()`, `bounceKeyframes()`), so the motion is physical but
|
|
67
|
+
* still runs on the Web Animations API (compositor, reduced-motion aware).
|
|
68
|
+
* Effects: `bounce-in`, `rubber-band`, `elastic-hover`, `drop-bounce`,
|
|
69
|
+
* `gravity-text`, `spring-follow`, `bell-swing`.
|
|
70
|
+
*/
|
|
71
|
+
|
|
72
|
+
interface SpringOptions {
|
|
73
|
+
stiffness?: number;
|
|
74
|
+
damping?: number;
|
|
75
|
+
mass?: number;
|
|
76
|
+
/** Samples (keyframes). */
|
|
77
|
+
steps?: number;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Sample a damped spring from 0 → 1 and return the progress values plus the
|
|
81
|
+
* time (ms) it takes to settle. Pure, deterministic.
|
|
82
|
+
*/
|
|
83
|
+
declare function solveSpring({ stiffness, damping, mass, steps }?: SpringOptions): {
|
|
84
|
+
values: number[];
|
|
85
|
+
duration: number;
|
|
86
|
+
};
|
|
87
|
+
/** Keyframes for a property driven by a spring: `map(progress)` → keyframe. */
|
|
88
|
+
declare function springKeyframes(map: (p: number) => Keyframe, spring?: SpringOptions): {
|
|
89
|
+
frames: Keyframe[];
|
|
90
|
+
duration: number;
|
|
91
|
+
};
|
|
92
|
+
/** Height (0 = floor, 1 = drop height) of a ball dropped with restitution `bounce`, sampled `steps` times. */
|
|
93
|
+
declare function bounceKeyframes(bounce?: number, steps?: number): number[];
|
|
94
|
+
declare const PHYSICS_FX: EffectDefinition[];
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* 5.3 — page-wide effects, registered through `registerEffect()`.
|
|
98
|
+
* Transitions (cover → `onCovered()` → reveal): `curtain`, `iris`,
|
|
99
|
+
* `pixel-dissolve`, `blinds`. Persistent page effects: `velocity-skew`,
|
|
100
|
+
* `spotlight`, `edge-glow`.
|
|
101
|
+
*
|
|
102
|
+
* ```ts
|
|
103
|
+
* await playEffect(document.body, 'iris', { onCovered: () => router.go('/next') });
|
|
104
|
+
* ```
|
|
105
|
+
*/
|
|
106
|
+
|
|
107
|
+
declare const PAGE_FX: EffectDefinition[];
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* 5.5 — generative backgrounds on Canvas 2D, registered through
|
|
111
|
+
* `registerEffect()` (kind `background`): `flow-field`, `voronoi`,
|
|
112
|
+
* `mesh-gradient`, `starfield`, `metaballs`, `contours`.
|
|
113
|
+
*
|
|
114
|
+
* Shared runner (`canvasBackground()`): a canvas behind the element's content
|
|
115
|
+
* (`aria-hidden`, pointer-transparent), rendering only while visible
|
|
116
|
+
* (IntersectionObserver) and the tab is shown, with adaptive quality — the
|
|
117
|
+
* render scale drops when frames get slow and recovers when they are fast.
|
|
118
|
+
* Reduced motion: one static frame, no loop.
|
|
119
|
+
*/
|
|
120
|
+
|
|
121
|
+
interface GenFrame {
|
|
122
|
+
ctx: CanvasRenderingContext2D;
|
|
123
|
+
/** CSS-pixel size of the canvas. */
|
|
124
|
+
w: number;
|
|
125
|
+
h: number;
|
|
126
|
+
/** Seconds since start (0 for the static reduced-motion frame). */
|
|
127
|
+
t: number;
|
|
128
|
+
/** Render scale 0.35–1 (adaptive quality). */
|
|
129
|
+
quality: number;
|
|
130
|
+
/** Per-effect state, created by `init`. */
|
|
131
|
+
state: any;
|
|
132
|
+
/** Merged options. */
|
|
133
|
+
o: any;
|
|
134
|
+
}
|
|
135
|
+
interface GenerativeSpec {
|
|
136
|
+
init?: (w: number, h: number, o: any) => any;
|
|
137
|
+
draw: (f: GenFrame) => void;
|
|
138
|
+
}
|
|
139
|
+
/** Deterministic smooth pseudo-noise in [-1, 1] (sum of sines — cheap, no tables). */
|
|
140
|
+
declare function noise2(x: number, y: number, t?: number): number;
|
|
141
|
+
/** Hex `#rrggbb` → [r, g, b]. */
|
|
142
|
+
declare function hexRgb(hex: string): [number, number, number];
|
|
143
|
+
/**
|
|
144
|
+
* Mount a generative canvas behind `el` and run `spec` on it. Returns the
|
|
145
|
+
* cleanup. Exposed for custom generative effects.
|
|
146
|
+
*/
|
|
147
|
+
declare function canvasBackground(el: HTMLElement, fx: EffectContext, spec: GenerativeSpec, o: any): () => void;
|
|
148
|
+
declare const GENERATIVE_FX: EffectDefinition[];
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* 5.6 — sound-reactive effects (Web Audio).
|
|
152
|
+
*
|
|
153
|
+
* - `enableAudio(input)` — start analysing the microphone (`'mic'`), an
|
|
154
|
+
* `<audio>` / `<video>` element (or a selector for one) or a `MediaStream`.
|
|
155
|
+
* Browsers only allow an `AudioContext` to start inside a user gesture, so
|
|
156
|
+
* call it from a click handler (or use `<usa-audio>`, which renders the
|
|
157
|
+
* toggle button for you).
|
|
158
|
+
* - Background effects (kind `background`, Canvas 2D through
|
|
159
|
+
* `canvasBackground()`): `spectrum-bars`, `pulse-ring`, `wave-ring`. Before
|
|
160
|
+
* audio is enabled they idle gently.
|
|
161
|
+
* - Beat detection: `createBeatDetector()` (pure: energy → beat?), `onBeat(cb)`
|
|
162
|
+
* and `bindBeat(el, effect, options)`, which plays any registered effect on
|
|
163
|
+
* every beat. `<usa-audio>` does the same for `[data-usa-beat="effect"]`
|
|
164
|
+
* children and emits `usa-beat`.
|
|
165
|
+
* - While audio runs, `--usa-audio-level` and `--usa-audio-bass` (0–1) are set
|
|
166
|
+
* on `<html>` for CSS-driven reactions.
|
|
167
|
+
*
|
|
168
|
+
* Reduced motion: the visual effects are skipped, beats play no effects and
|
|
169
|
+
* the CSS variables stay at 0 — audio itself keeps playing.
|
|
170
|
+
*/
|
|
171
|
+
|
|
172
|
+
type AudioInput = 'mic' | HTMLMediaElement | MediaStream | string;
|
|
173
|
+
interface AudioSample {
|
|
174
|
+
/** Overall loudness (RMS of the waveform), 0–1. */
|
|
175
|
+
level: number;
|
|
176
|
+
/** Low-frequency energy (first ~8 % of the spectrum), 0–1. */
|
|
177
|
+
bass: number;
|
|
178
|
+
/** Frequency bins, 0–255 each. */
|
|
179
|
+
freq: Uint8Array;
|
|
180
|
+
/** Time-domain waveform, 0–255 (128 = silence). */
|
|
181
|
+
wave: Uint8Array;
|
|
182
|
+
}
|
|
183
|
+
interface AudioReactive {
|
|
184
|
+
readonly context: AudioContext;
|
|
185
|
+
readonly analyser: AnalyserNode;
|
|
186
|
+
/** Read the analyser now. */
|
|
187
|
+
sample(): AudioSample;
|
|
188
|
+
/** Stop analysing (media keeps playing; the microphone is released). */
|
|
189
|
+
stop(): void;
|
|
190
|
+
}
|
|
191
|
+
interface BeatOptions {
|
|
192
|
+
/** A beat is energy above `threshold` × the recent average (default 1.35). */
|
|
193
|
+
threshold?: number;
|
|
194
|
+
/** Minimum ms between beats (default 250). */
|
|
195
|
+
cooldown?: number;
|
|
196
|
+
/** Frames of history for the average (default 43 ≈ 0.7 s). */
|
|
197
|
+
history?: number;
|
|
198
|
+
/** Ignore energy below this floor, 0–1 (default 0.08). */
|
|
199
|
+
floor?: number;
|
|
200
|
+
}
|
|
201
|
+
/** The running analyser, if `enableAudio()` was called. */
|
|
202
|
+
declare const getAudio: () => AudioReactive | null;
|
|
203
|
+
/**
|
|
204
|
+
* Start analysing `input` and make it the source of every sound-reactive
|
|
205
|
+
* effect. Call from a user gesture. Replaces a previous source.
|
|
206
|
+
*/
|
|
207
|
+
declare function enableAudio(input?: AudioInput, opts?: {
|
|
208
|
+
fftSize?: number;
|
|
209
|
+
smoothing?: number;
|
|
210
|
+
}): Promise<AudioReactive>;
|
|
211
|
+
/** Stop the current audio source (if any). */
|
|
212
|
+
declare function disableAudio(): void;
|
|
213
|
+
/** A pure beat detector: feed it energy (0–1) and a timestamp per frame; it answers "beat?". */
|
|
214
|
+
declare function createBeatDetector(o?: BeatOptions): (energy: number, now: number) => boolean;
|
|
215
|
+
/** Call `cb` on every detected beat of the current audio source. Returns an unsubscribe. */
|
|
216
|
+
declare function onBeat(cb: (detail: {
|
|
217
|
+
energy: number;
|
|
218
|
+
time: number;
|
|
219
|
+
}) => void, o?: BeatOptions): () => void;
|
|
220
|
+
/** Play the registered effect `name` on `el` at every beat (not under reduced motion). Returns an unbind. */
|
|
221
|
+
declare function bindBeat(el: HTMLElement, name: string, options?: Record<string, unknown> & BeatOptions): () => void;
|
|
222
|
+
declare const AUDIO_FX: EffectDefinition[];
|
|
223
|
+
interface UsaAudioElement extends UsaElement {
|
|
224
|
+
/** `true` while this element's audio source is being analysed. */
|
|
225
|
+
readonly active: boolean;
|
|
226
|
+
/** Start (from a user gesture) or stop analysing. */
|
|
227
|
+
toggle(): Promise<void>;
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* `<usa-audio source="#track | mic" label="…">` — a toggle button (yours, as
|
|
231
|
+
* `[data-audio-toggle]`, or one it renders) that enables the audio source on
|
|
232
|
+
* click; children with `data-usa-beat="effect"` play that effect on every
|
|
233
|
+
* beat (`data-usa-beat-options` JSON; `threshold` / `cooldown` attributes).
|
|
234
|
+
* Emits `usa-beat` and `usa-audio-error`.
|
|
235
|
+
*/
|
|
236
|
+
declare function defineAudio(tag?: string): CustomElementConstructor | undefined;
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* 5.7 — cursor & gesture packs.
|
|
240
|
+
*
|
|
241
|
+
* Cursor effects (kind `cursor`, persistent, scoped to the element they are
|
|
242
|
+
* bound to; skipped under reduced motion and — unless `touch: true` — for
|
|
243
|
+
* touch pointers): `comet-trail`, `sparkle-trail`, `ribbon-trail`,
|
|
244
|
+
* `magnetic-dots`, `spotlight-cursor`.
|
|
245
|
+
*
|
|
246
|
+
* Gestures → effects: `bindGesture(el, 'fling' | 'twist' | 'long-press',
|
|
247
|
+
* effectOrCallback, options)` and `<usa-gesture-fx gesture effect>`. A fling
|
|
248
|
+
* is a fast release, a twist a two-finger rotation past `angle` degrees, a
|
|
249
|
+
* long press "charges" `--usa-charge` 0 → 1 and fires when full. Every fire
|
|
250
|
+
* dispatches `usa-gesture` (`detail: { gesture, … }`). The effect itself goes
|
|
251
|
+
* through `playEffect()`, so reduced motion is honoured there.
|
|
252
|
+
*/
|
|
253
|
+
|
|
254
|
+
type Pt = {
|
|
255
|
+
x: number;
|
|
256
|
+
y: number;
|
|
257
|
+
t: number;
|
|
258
|
+
};
|
|
259
|
+
declare const CURSOR_FX: EffectDefinition[];
|
|
260
|
+
declare const GESTURES: readonly ["fling", "twist", "long-press"];
|
|
261
|
+
type GestureName = (typeof GESTURES)[number];
|
|
262
|
+
interface GestureFxOptions {
|
|
263
|
+
/** fling: minimum release speed in px/ms (default 0.8). */
|
|
264
|
+
velocity?: number;
|
|
265
|
+
/** twist: degrees of rotation that fire (default 30). */
|
|
266
|
+
angle?: number;
|
|
267
|
+
/** long-press: ms to fully charge (default 650). */
|
|
268
|
+
duration?: number;
|
|
269
|
+
/** long-press: px the pointer may move before the press is cancelled (default 10). */
|
|
270
|
+
tolerance?: number;
|
|
271
|
+
/** Options passed to the effect. */
|
|
272
|
+
effectOptions?: Record<string, unknown>;
|
|
273
|
+
}
|
|
274
|
+
interface GestureDetail {
|
|
275
|
+
gesture: GestureName;
|
|
276
|
+
/** fling */
|
|
277
|
+
vx?: number;
|
|
278
|
+
vy?: number;
|
|
279
|
+
speed?: number;
|
|
280
|
+
direction?: 'left' | 'right' | 'up' | 'down' | 'cw' | 'ccw';
|
|
281
|
+
/** twist: signed degrees since the last fire. */
|
|
282
|
+
angle?: number;
|
|
283
|
+
/** long-press: 1 when fired. */
|
|
284
|
+
charge?: number;
|
|
285
|
+
}
|
|
286
|
+
/** Release velocity (px/ms) from recent pointer samples: uses the last `window` ms (pure). */
|
|
287
|
+
declare function flingVelocity(pts: Pt[], window?: number): {
|
|
288
|
+
vx: number;
|
|
289
|
+
vy: number;
|
|
290
|
+
speed: number;
|
|
291
|
+
};
|
|
292
|
+
/** Signed smallest difference between two angles in degrees, in (-180, 180] (pure). */
|
|
293
|
+
declare function angleDelta(a: number, b: number): number;
|
|
294
|
+
/**
|
|
295
|
+
* Fire `effect` (a registered effect name, or a callback) when `gesture`
|
|
296
|
+
* happens on `el`. Returns an unbind.
|
|
297
|
+
*/
|
|
298
|
+
declare function bindGesture(el: HTMLElement, gesture: GestureName, effect: string | ((d: GestureDetail, e: Event) => void), o?: GestureFxOptions): () => void;
|
|
299
|
+
interface UsaGestureFxElement extends UsaElement {
|
|
300
|
+
readonly gesture: GestureName;
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* `<usa-gesture-fx gesture="fling | twist | long-press" effect="tada"
|
|
304
|
+
* options='{"…"}' velocity angle duration>` — plays `effect` on its first
|
|
305
|
+
* child (or itself with `self`) when the gesture happens.
|
|
306
|
+
*/
|
|
307
|
+
declare function defineGestureFx(tag?: string): CustomElementConstructor | undefined;
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* 5.8 — micro-interaction library (23 effects, registered through
|
|
311
|
+
* `registerEffect()`). Each one does the small piece of UI work as well as the
|
|
312
|
+
* motion — toggling `aria-pressed`, swapping a label, bumping a count, copying
|
|
313
|
+
* to the clipboard — so the state change still happens under reduced motion;
|
|
314
|
+
* only the animation is dropped (`ctx.animate` returns `null` there).
|
|
315
|
+
*
|
|
316
|
+
* Click: `copy-success`, `toggle-morph`, `password-reveal`, `favorite-star`,
|
|
317
|
+
* `like-heart`, `bookmark-flip`, `download-progress`, `submit-loading`,
|
|
318
|
+
* `send-plane`, `add-to-cart`, `counter-bump`, `upvote`, `clap`,
|
|
319
|
+
* `emoji-react`, `refresh-spin`, `trash-shake`, `check-toggle`.
|
|
320
|
+
* Attention: `input-shake`, `error-flash`, `success-check`, `nudge-hint`,
|
|
321
|
+
* `focus-pulse`, `notify-badge`.
|
|
322
|
+
*/
|
|
323
|
+
|
|
324
|
+
/** Toggle `aria-pressed` (or set it) and return the new state. */
|
|
325
|
+
declare function togglePressed(el: HTMLElement, force?: boolean): boolean;
|
|
326
|
+
/** Swap `el`'s label for `ms` (polite live region), then restore it. */
|
|
327
|
+
declare function swapLabel(el: HTMLElement, text: string, ms: number): Promise<void>;
|
|
328
|
+
/** Add `delta` to the number in `[data-count]` (or `el`), keeping it in `data-count`. Returns the new value. */
|
|
329
|
+
declare function bumpCount(el: HTMLElement, delta: number, ctx?: EffectContext): number;
|
|
330
|
+
declare const MICRO_FX: EffectDefinition[];
|
|
331
|
+
|
|
332
|
+
/**
|
|
333
|
+
* motionary/components/tokens — motion design tokens (4.2).
|
|
334
|
+
*
|
|
335
|
+
* One source of truth for durations, easings and springs: as CSS custom
|
|
336
|
+
* properties (`--usa-duration-fast`, `--usa-easing-emphasized`,
|
|
337
|
+
* `--usa-spring-bouncy-stiffness`…), as W3C Design Tokens JSON, and importable
|
|
338
|
+
* from Figma Tokens (Tokens Studio) or Style Dictionary exports.
|
|
339
|
+
*
|
|
340
|
+
* ```ts
|
|
341
|
+
* import { applyMotionTokens, importMotionTokens, motionToken } from 'motionary/components/tokens';
|
|
342
|
+
* applyMotionTokens(importMotionTokens(await (await fetch('/tokens.json')).json()));
|
|
343
|
+
* el.animate(frames, { duration: motionToken('duration', 'slow'), easing: motionToken('easing', 'emphasized') });
|
|
344
|
+
* ```
|
|
345
|
+
*/
|
|
346
|
+
interface SpringToken {
|
|
347
|
+
stiffness: number;
|
|
348
|
+
damping: number;
|
|
349
|
+
mass: number;
|
|
350
|
+
}
|
|
351
|
+
interface MotionTokens {
|
|
352
|
+
/** Durations in ms. */
|
|
353
|
+
duration: Record<string, number>;
|
|
354
|
+
/** CSS easing strings. */
|
|
355
|
+
easing: Record<string, string>;
|
|
356
|
+
/** Spring physics parameters. */
|
|
357
|
+
spring: Record<string, SpringToken>;
|
|
358
|
+
}
|
|
359
|
+
type DeepPartialTokens = {
|
|
360
|
+
[K in keyof MotionTokens]?: Partial<MotionTokens[K]>;
|
|
361
|
+
};
|
|
362
|
+
|
|
363
|
+
/**
|
|
364
|
+
* 5.8 — theme packs: `neon`, `paper`, `glass`, `retro`, `brutalist`.
|
|
365
|
+
*
|
|
366
|
+
* A theme pack is design tokens (`--usa-theme-*` custom properties), motion
|
|
367
|
+
* tokens (merged over the 3.x motion scale) and effect presets per role
|
|
368
|
+
* (`enter`, `hover`, `click`, `attention`, `background`). Five theme effects
|
|
369
|
+
* ship with them: `neon-flicker`, `paper-fold`, `glass-shine`,
|
|
370
|
+
* `retro-scanlines`, `brutal-shift`.
|
|
371
|
+
*
|
|
372
|
+
* - `applyTheme(name, root?)` — on `<html>` (default) it also makes the motion
|
|
373
|
+
* tokens active for `motionToken()`; on any other element the tokens are
|
|
374
|
+
* only written as variables there. Returns an undo.
|
|
375
|
+
* - `themePreset(name, role)`, `playThemeEffect(el, role)` (theme of the
|
|
376
|
+
* closest `[data-usa-theme]`).
|
|
377
|
+
* - `<usa-theme name="neon">` — scopes a theme to its subtree and binds the
|
|
378
|
+
* presets to children with `data-theme-fx="click | hover | enter | attention"`.
|
|
379
|
+
*/
|
|
380
|
+
|
|
381
|
+
declare const THEME_ROLES: readonly ["enter", "hover", "click", "attention", "background"];
|
|
382
|
+
type ThemeRole = (typeof THEME_ROLES)[number];
|
|
383
|
+
interface ThemePack {
|
|
384
|
+
name: string;
|
|
385
|
+
/** Design tokens, written as `--usa-theme-<key>`. */
|
|
386
|
+
vars: Record<'bg' | 'fg' | 'accent' | 'accent-2' | 'surface' | 'border' | 'radius' | 'shadow' | 'font', string>;
|
|
387
|
+
/** Motion tokens merged over the defaults. */
|
|
388
|
+
motion: DeepPartialTokens;
|
|
389
|
+
/** Effect preset per role. */
|
|
390
|
+
presets: Record<ThemeRole, {
|
|
391
|
+
effect: string;
|
|
392
|
+
options?: Record<string, unknown>;
|
|
393
|
+
}>;
|
|
394
|
+
}
|
|
395
|
+
declare const THEMES: Record<string, ThemePack>;
|
|
396
|
+
declare const THEME_NAMES: string[];
|
|
397
|
+
/** The CSS custom properties of a theme (design + motion tokens). */
|
|
398
|
+
declare function themeVars(t: string | ThemePack): Record<string, string>;
|
|
399
|
+
/** A theme as a CSS rule (`selector` default `[data-usa-theme=<name>]`) — for SSR / static CSS. */
|
|
400
|
+
declare function themeCss(t: string | ThemePack, selector?: string): string;
|
|
401
|
+
/** Apply a theme to `root` (default `<html>`). Returns an undo. */
|
|
402
|
+
declare function applyTheme(t: string | ThemePack, root?: HTMLElement): () => void;
|
|
403
|
+
/** The effect preset of a theme for a role. */
|
|
404
|
+
declare function themePreset(t: string | ThemePack, role: ThemeRole): {
|
|
405
|
+
effect: string;
|
|
406
|
+
options?: Record<string, unknown>;
|
|
407
|
+
};
|
|
408
|
+
/** Play the preset for `role` of the theme on the closest `[data-usa-theme]` (or `theme`). */
|
|
409
|
+
declare function playThemeEffect(el: HTMLElement, role: ThemeRole, theme?: string): Promise<void>;
|
|
410
|
+
declare const THEME_FX: EffectDefinition[];
|
|
411
|
+
interface UsaThemeElement extends UsaElement {
|
|
412
|
+
readonly theme: string;
|
|
413
|
+
}
|
|
414
|
+
/** `<usa-theme name="neon | paper | glass | retro | brutalist">` — a themed subtree. */
|
|
415
|
+
declare function defineTheme(tag?: string): CustomElementConstructor | undefined;
|
|
416
|
+
|
|
417
|
+
interface AnimationTrack {
|
|
418
|
+
/** Selector inside the player (`:scope` = the player). */
|
|
419
|
+
target?: string;
|
|
420
|
+
/** Start time in ms. */
|
|
421
|
+
start?: number;
|
|
422
|
+
duration?: number;
|
|
423
|
+
/** A timeline preset (`fade-up`, `scale`, `blur`…). */
|
|
424
|
+
preset?: string;
|
|
425
|
+
keyframes?: Keyframe[];
|
|
426
|
+
easing?: string;
|
|
427
|
+
/** A registered effect fired at `start` (instead of keyframes). */
|
|
428
|
+
effect?: string;
|
|
429
|
+
options?: Record<string, unknown>;
|
|
430
|
+
label?: string;
|
|
431
|
+
}
|
|
432
|
+
interface AnimationJSON {
|
|
433
|
+
format?: string;
|
|
434
|
+
version?: number;
|
|
435
|
+
name?: string;
|
|
436
|
+
loop?: boolean;
|
|
437
|
+
/** Total length; defaults to the end of the last track. */
|
|
438
|
+
duration?: number;
|
|
439
|
+
tracks: AnimationTrack[];
|
|
440
|
+
}
|
|
441
|
+
declare const ANIMATION_FORMAT = "use-scroll-animate/animation";
|
|
442
|
+
/** Validate / normalise an animation (object or JSON text). Throws on anything unusable. */
|
|
443
|
+
declare function normalizeAnimation(input: string | AnimationJSON | Record<string, any>): Required<Pick<AnimationJSON, 'tracks' | 'duration' | 'loop' | 'name'>>;
|
|
444
|
+
interface Player {
|
|
445
|
+
readonly duration: number;
|
|
446
|
+
readonly currentTime: number;
|
|
447
|
+
readonly playing: boolean;
|
|
448
|
+
play(): void;
|
|
449
|
+
pause(): void;
|
|
450
|
+
/** Jump to `ms` (effects between are not replayed). */
|
|
451
|
+
seek(ms: number): void;
|
|
452
|
+
/** Playback rate (default 1). */
|
|
453
|
+
rate: number;
|
|
454
|
+
/** Resolves each time the animation reaches its end (not when looping). */
|
|
455
|
+
readonly finished: Promise<void>;
|
|
456
|
+
destroy(): void;
|
|
457
|
+
}
|
|
458
|
+
/** Bind an animation to `root` and return its controller (paused at 0 unless `autoplay`). */
|
|
459
|
+
declare function createPlayer(root: HTMLElement, animation: string | AnimationJSON, o?: {
|
|
460
|
+
autoplay?: boolean;
|
|
461
|
+
loop?: boolean;
|
|
462
|
+
rate?: number;
|
|
463
|
+
onFinish?: () => void;
|
|
464
|
+
}): Player;
|
|
465
|
+
interface UsaPlayerElement extends UsaElement {
|
|
466
|
+
readonly player: Player | null;
|
|
467
|
+
/** Load an animation (object or JSON text) and restart. */
|
|
468
|
+
load(animation: string | AnimationJSON): void;
|
|
469
|
+
play(): void;
|
|
470
|
+
pause(): void;
|
|
471
|
+
seek(ms: number): void;
|
|
472
|
+
}
|
|
473
|
+
/**
|
|
474
|
+
* `<usa-player src="hero.json" | <script type="application/json"> child
|
|
475
|
+
* trigger="load | view | scroll | click | manual" loop rate controls>`.
|
|
476
|
+
* Emits `usa-player-ready` and `usa-player-finish`; sets `data-error` when the
|
|
477
|
+
* animation cannot be loaded.
|
|
478
|
+
*/
|
|
479
|
+
declare function definePlayer(tag?: string): CustomElementConstructor | undefined;
|
|
480
|
+
|
|
481
|
+
/**
|
|
482
|
+
* 5.4 — `<usa-story template="…">` scroll-storytelling templates.
|
|
483
|
+
*
|
|
484
|
+
* - `pin` — a sticky `[data-stage]` while `[data-step]` sections scroll past; the
|
|
485
|
+
* step in view gets `data-active`, the stage gets `data-active-step="<index>"`.
|
|
486
|
+
* - `gallery` — a horizontal `[data-track]` slides sideways as you scroll down.
|
|
487
|
+
* - `zoom` — the `[data-stage]` zooms toward the viewer (`zoom="6"`) and fades.
|
|
488
|
+
* - `compare` — before / after (`[data-before]`, `[data-after]`) wipe driven by
|
|
489
|
+
* scroll, plus a draggable, keyboard-accessible handle (`role="slider"`).
|
|
490
|
+
* - `counter` — `[data-count="1234"]` numbers count up when they enter view.
|
|
491
|
+
* - `highlight` — paragraphs dim except the one crossing the viewport center.
|
|
492
|
+
*
|
|
493
|
+
* Every template sets `--usa-story-progress` (0–1) on the host and dispatches
|
|
494
|
+
* `usa-story-step` (`detail: { index }`). Reduced motion: no sliding / zooming
|
|
495
|
+
* (the gallery stacks vertically), counters show final values, the rest is
|
|
496
|
+
* class changes only.
|
|
497
|
+
*/
|
|
498
|
+
|
|
499
|
+
declare const STORY_TEMPLATES: readonly ["pin", "gallery", "zoom", "compare", "counter", "highlight"];
|
|
500
|
+
type StoryTemplate = (typeof STORY_TEMPLATES)[number];
|
|
501
|
+
interface UsaStoryElement extends UsaElement {
|
|
502
|
+
/** Scroll progress through the story, 0–1. */
|
|
503
|
+
readonly progress: number;
|
|
504
|
+
/** Index of the active step (pin / highlight), or -1. */
|
|
505
|
+
readonly step: number;
|
|
506
|
+
}
|
|
507
|
+
/** Progress of `el` through the viewport: 0 when its top hits the viewport top, 1 when its bottom hits the viewport bottom. */
|
|
508
|
+
declare function storyProgress(el: Element, vh?: number): number;
|
|
509
|
+
/** Format a counted value like the target (`1,234`, `12.5`, prefix / suffix kept). */
|
|
510
|
+
declare function formatCount(target: string, t: number): string;
|
|
511
|
+
declare function defineStory(tag?: string): CustomElementConstructor | undefined;
|
|
512
|
+
declare global {
|
|
513
|
+
interface HTMLElementTagNameMap {
|
|
514
|
+
'usa-story': UsaStoryElement;
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
/** Helpers shared by the 5.x effect packs. */
|
|
519
|
+
|
|
520
|
+
/** A fixed, pointer-transparent, aria-hidden layer for transient particles. */
|
|
521
|
+
declare function fxLayer(): HTMLElement;
|
|
522
|
+
|
|
523
|
+
/** The effect packs by version, in release order. */
|
|
524
|
+
declare const EFFECT_PACKS: Record<string, EffectDefinition[]>;
|
|
525
|
+
/** 5.1: card & click effects 2.0. */
|
|
526
|
+
declare function registerCardClickEffects(): void;
|
|
527
|
+
/** 5.2: bounce & physics micro-interactions. */
|
|
528
|
+
declare function registerPhysicsEffects(): void;
|
|
529
|
+
/** 5.3: page-wide transitions and effects. */
|
|
530
|
+
declare function registerPageEffects(): void;
|
|
531
|
+
/** 5.5: generative Canvas 2D backgrounds. */
|
|
532
|
+
declare function registerGenerativeEffects(): void;
|
|
533
|
+
/** 5.6: sound-reactive (Web Audio) backgrounds. */
|
|
534
|
+
declare function registerAudioEffects(): void;
|
|
535
|
+
/** 5.7: cursor trails, magnetic dots, spotlight cursor. */
|
|
536
|
+
declare function registerCursorEffects(): void;
|
|
537
|
+
/** 5.8: micro-interactions + theme-pack effects. */
|
|
538
|
+
declare function registerMicroEffects(): void;
|
|
539
|
+
/** Define the 5.x elements of this entry (`<usa-story>`, …) under their default tags. */
|
|
540
|
+
declare function defineEffectElements(): void;
|
|
541
|
+
/** Register the built-ins and every pack (idempotent). */
|
|
542
|
+
declare function registerAllEffects(): void;
|
|
543
|
+
|
|
544
|
+
export { ANIMATION_FORMAT, AUDIO_FX, CARD_FX, CLICK_FX, CURSOR_FX, EFFECT_PACKS, GENERATIVE_FX, GESTURES, MICRO_FX, PAGE_FX, PHYSICS_FX, STORY_TEMPLATES, THEMES, THEME_FX, THEME_NAMES, THEME_ROLES, angleDelta, applyTheme, bindBeat, bindGesture, bounceKeyframes, bumpCount, canvasBackground, createBeatDetector, createPlayer, defineAudio, defineEffectElements, defineGestureFx, definePlayer, defineStory, defineTheme, disableAudio, enableAudio, flingVelocity, formatCount, fxLayer, getAudio, hexRgb, noise2, normalizeAnimation, onBeat, playThemeEffect, registerAllEffects, registerAudioEffects, registerCardClickEffects, registerCursorEffects, registerGenerativeEffects, registerMicroEffects, registerPageEffects, registerPhysicsEffects, solveSpring, springKeyframes, storyProgress, swapLabel, themeCss, themePreset, themeVars, togglePressed };
|
|
545
|
+
export type { AnimationJSON, AnimationTrack, AudioInput, AudioReactive, AudioSample, BeatOptions, GenFrame, GenerativeSpec, GestureDetail, GestureFxOptions, GestureName, Player, SpringOptions, StoryTemplate, ThemePack, ThemeRole, UsaAudioElement, UsaGestureFxElement, UsaPlayerElement, UsaStoryElement, UsaThemeElement };
|