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,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Members shared by every `<usa-*>` element. Attribute helpers, a cleanup
|
|
3
|
+
* bag that is emptied on disconnect, and motion helpers that degrade to the
|
|
4
|
+
* final state without WAAPI or under reduced motion.
|
|
5
|
+
*/
|
|
6
|
+
interface UsaElement extends HTMLElement {
|
|
7
|
+
/** `true` while reduced motion applies to this element. */
|
|
8
|
+
readonly reduced: boolean;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Shared shell for the WebGL elements: a canvas over (or behind) the
|
|
13
|
+
* content that renders only while visible and the tab is shown, a DPR cap
|
|
14
|
+
* of 2, and a graceful fallback (`data-fallback`) when WebGL, the shader
|
|
15
|
+
* or the image (CORS) is unavailable — the original content / CSS stays.
|
|
16
|
+
*/
|
|
17
|
+
interface UsaGLElement extends UsaElement {
|
|
18
|
+
/** `true` once WebGL rendering is active (otherwise the CSS fallback shows). */
|
|
19
|
+
readonly active: boolean;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* `<usa-shader>` — GPU shader background behind its content. `preset`
|
|
23
|
+
* (`gradient` · `plasma` · `waves` · `aurora`) or your own fragment shader in
|
|
24
|
+
* `<script type="x-shader/x-fragment">` (uniforms `u_time`, `u_resolution`,
|
|
25
|
+
* `u_mouse`, `v_uv`); `speed`. Without WebGL: the element's CSS background.
|
|
26
|
+
*/
|
|
27
|
+
declare function defineShader(tag?: string): CustomElementConstructor | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* `<usa-distort>` — hover distortion + RGB split on the `<img>` inside,
|
|
30
|
+
* following the pointer. Without WebGL / CORS: a gentle CSS zoom.
|
|
31
|
+
*/
|
|
32
|
+
declare function defineDistort(tag?: string): CustomElementConstructor | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* `<usa-liquid>` — liquid image: clicks / taps send ripples through the
|
|
35
|
+
* `<img>` inside, hover adds a gentle wobble; `strength`. Fallback: plain image.
|
|
36
|
+
*/
|
|
37
|
+
declare function defineLiquid(tag?: string): CustomElementConstructor | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* `<usa-post-fx effects="vignette grain crt" intensity="0.6">` — GPU
|
|
40
|
+
* post-processing over the `<img>` inside (4.8): `vignette` · `grain` ·
|
|
41
|
+
* `chromatic` · `scanlines` · `crt` · `bloom` · `pixelate` · `duotone` ·
|
|
42
|
+
* `glitch`, chained in order. `quality="high"` disables adaptive quality.
|
|
43
|
+
* Fallback: the image with an approximate CSS filter.
|
|
44
|
+
*/
|
|
45
|
+
declare function definePostFx(tag?: string): CustomElementConstructor | undefined;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* 4.8 — WebGL preset library on `glQuad()`: particle presets (`snow`,
|
|
49
|
+
* `fireflies`, `stars`, `bokeh`, `rain` — usable as `<usa-shader preset>`),
|
|
50
|
+
* chainable post-processing passes for images (`<usa-post-fx>`), one CSS
|
|
51
|
+
* fallback per preset, and an adaptive quality governor (fps + battery).
|
|
52
|
+
*/
|
|
53
|
+
declare const PARTICLE_PRESETS: readonly ["snow", "fireflies", "stars", "bokeh", "rain"];
|
|
54
|
+
type ParticlePreset = (typeof PARTICLE_PRESETS)[number];
|
|
55
|
+
/** Post-processing passes: `vec3 fx(vec3 c, vec2 uv)` bodies, applied in order. `u_intensity` 0–1. */
|
|
56
|
+
declare const POST_EFFECTS: Record<string, string>;
|
|
57
|
+
type PostEffect = keyof typeof POST_EFFECTS;
|
|
58
|
+
/** One fragment shader running the passes in order over `u_tex` (pixel-sampling passes read the source). */
|
|
59
|
+
declare function postFxShader(effects: string[]): string;
|
|
60
|
+
/** The unified CSS fallback (no WebGL / reduced data): a still background or image filter per preset. */
|
|
61
|
+
declare const GL_FALLBACKS: Record<string, string>;
|
|
62
|
+
/** CSS fallback for a shader preset / post effect list. */
|
|
63
|
+
declare function glFallbackCss(preset: string, post?: boolean): string;
|
|
64
|
+
interface GLGovernorOptions {
|
|
65
|
+
/** Below this fps quality drops (default 40). */
|
|
66
|
+
minFps?: number;
|
|
67
|
+
/** Frame-rate cap on battery saver / low battery (default 30). */
|
|
68
|
+
saverFps?: number;
|
|
69
|
+
}
|
|
70
|
+
interface GLGovernor {
|
|
71
|
+
/** Feed a frame time (ms); returns `true` when this frame should render. */
|
|
72
|
+
tick(t: number): boolean;
|
|
73
|
+
/** Current resolution scale (1 → 0.5 → 0.35). */
|
|
74
|
+
readonly scale: number;
|
|
75
|
+
/** Measured fps over the last second. */
|
|
76
|
+
readonly fps: number;
|
|
77
|
+
/** Battery saver / low battery: renders at `saverFps` and scale ≤ 0.6. */
|
|
78
|
+
saver: boolean;
|
|
79
|
+
/** Called when `scale` changes (resize the canvas). */
|
|
80
|
+
onScale?: (scale: number) => void;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Adaptive quality for GL loops: measures fps, steps the resolution scale
|
|
84
|
+
* down (1 → 0.5 → 0.35) after two slow seconds and back up after five good
|
|
85
|
+
* ones, and caps the frame rate in battery-saver mode. Pure — feed it times.
|
|
86
|
+
*/
|
|
87
|
+
declare function glGovernor(options?: GLGovernorOptions): GLGovernor;
|
|
88
|
+
/** Watch the Battery Status API (where available) and Save-Data; calls `cb(true)` in saver conditions. Returns a stop function. */
|
|
89
|
+
declare function watchPowerSaver(cb: (saver: boolean) => void): () => void;
|
|
90
|
+
|
|
91
|
+
/** Built-in fragment shaders (bodies; uniforms `u_time`, `u_resolution`, `u_mouse` 0–1, `u_hover` 0–1, `u_tex`, `u_ripples[4]` = x, y, age, strength). */
|
|
92
|
+
declare const SHADERS: Record<string, string>;
|
|
93
|
+
/** Full fragment source for a preset or custom body (adds the shared header). */
|
|
94
|
+
declare function fragmentSource(body: string): string;
|
|
95
|
+
declare function supportsWebGL(): boolean;
|
|
96
|
+
interface GLQuad {
|
|
97
|
+
/** Draw a frame with these uniform values (`extra`: any other float uniforms by name, 4.8). */
|
|
98
|
+
render(u: {
|
|
99
|
+
time?: number;
|
|
100
|
+
mouse?: [number, number];
|
|
101
|
+
hover?: number;
|
|
102
|
+
ripples?: number[];
|
|
103
|
+
extra?: Record<string, number>;
|
|
104
|
+
}): void;
|
|
105
|
+
/** Resize the drawing buffer to the canvas' CSS size × DPR (≤ 2) × `scale` (4.8 adaptive quality). */
|
|
106
|
+
resize(scale?: number): void;
|
|
107
|
+
/** Upload an image as `u_tex`. */
|
|
108
|
+
texture(img: TexImageSource): void;
|
|
109
|
+
dispose(): void;
|
|
110
|
+
}
|
|
111
|
+
/** Compile `frag` on a full-canvas quad, or `null` when WebGL / compilation is unavailable. */
|
|
112
|
+
declare function glQuad(canvas: HTMLCanvasElement, frag: string): GLQuad | null;
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* motionary/components/webgl — lightweight canvas / WebGL (v3.4).
|
|
116
|
+
* `<usa-shader>` (shader backgrounds), `<usa-distort>` (hover image
|
|
117
|
+
* distortion), `<usa-liquid>` (ripple images) on a tiny single-quad runner
|
|
118
|
+
* (`glQuad()`), with graceful fallbacks when WebGL is unavailable.
|
|
119
|
+
*/
|
|
120
|
+
|
|
121
|
+
/** Register every component of this category under its default tag. */
|
|
122
|
+
declare function defineWebglComponents(): void;
|
|
123
|
+
declare global {
|
|
124
|
+
interface HTMLElementTagNameMap {
|
|
125
|
+
'usa-shader': UsaGLElement;
|
|
126
|
+
'usa-distort': UsaGLElement;
|
|
127
|
+
'usa-liquid': UsaGLElement;
|
|
128
|
+
'usa-post-fx': UsaGLElement;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export { GL_FALLBACKS, PARTICLE_PRESETS, POST_EFFECTS, SHADERS, defineDistort, defineLiquid, definePostFx, defineShader, defineWebglComponents, fragmentSource, glFallbackCss, glGovernor, glQuad, postFxShader, supportsWebGL, watchPowerSaver };
|
|
133
|
+
export type { GLGovernor, GLGovernorOptions, GLQuad, ParticlePreset, PostEffect, UsaGLElement };
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Members shared by every `<usa-*>` element. Attribute helpers, a cleanup
|
|
3
|
+
* bag that is emptied on disconnect, and motion helpers that degrade to the
|
|
4
|
+
* final state without WAAPI or under reduced motion.
|
|
5
|
+
*/
|
|
6
|
+
interface UsaElement extends HTMLElement {
|
|
7
|
+
/** `true` while reduced motion applies to this element. */
|
|
8
|
+
readonly reduced: boolean;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Shared shell for the WebGL elements: a canvas over (or behind) the
|
|
13
|
+
* content that renders only while visible and the tab is shown, a DPR cap
|
|
14
|
+
* of 2, and a graceful fallback (`data-fallback`) when WebGL, the shader
|
|
15
|
+
* or the image (CORS) is unavailable — the original content / CSS stays.
|
|
16
|
+
*/
|
|
17
|
+
interface UsaGLElement extends UsaElement {
|
|
18
|
+
/** `true` once WebGL rendering is active (otherwise the CSS fallback shows). */
|
|
19
|
+
readonly active: boolean;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* `<usa-shader>` — GPU shader background behind its content. `preset`
|
|
23
|
+
* (`gradient` · `plasma` · `waves` · `aurora`) or your own fragment shader in
|
|
24
|
+
* `<script type="x-shader/x-fragment">` (uniforms `u_time`, `u_resolution`,
|
|
25
|
+
* `u_mouse`, `v_uv`); `speed`. Without WebGL: the element's CSS background.
|
|
26
|
+
*/
|
|
27
|
+
declare function defineShader(tag?: string): CustomElementConstructor | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* `<usa-distort>` — hover distortion + RGB split on the `<img>` inside,
|
|
30
|
+
* following the pointer. Without WebGL / CORS: a gentle CSS zoom.
|
|
31
|
+
*/
|
|
32
|
+
declare function defineDistort(tag?: string): CustomElementConstructor | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* `<usa-liquid>` — liquid image: clicks / taps send ripples through the
|
|
35
|
+
* `<img>` inside, hover adds a gentle wobble; `strength`. Fallback: plain image.
|
|
36
|
+
*/
|
|
37
|
+
declare function defineLiquid(tag?: string): CustomElementConstructor | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* `<usa-post-fx effects="vignette grain crt" intensity="0.6">` — GPU
|
|
40
|
+
* post-processing over the `<img>` inside (4.8): `vignette` · `grain` ·
|
|
41
|
+
* `chromatic` · `scanlines` · `crt` · `bloom` · `pixelate` · `duotone` ·
|
|
42
|
+
* `glitch`, chained in order. `quality="high"` disables adaptive quality.
|
|
43
|
+
* Fallback: the image with an approximate CSS filter.
|
|
44
|
+
*/
|
|
45
|
+
declare function definePostFx(tag?: string): CustomElementConstructor | undefined;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* 4.8 — WebGL preset library on `glQuad()`: particle presets (`snow`,
|
|
49
|
+
* `fireflies`, `stars`, `bokeh`, `rain` — usable as `<usa-shader preset>`),
|
|
50
|
+
* chainable post-processing passes for images (`<usa-post-fx>`), one CSS
|
|
51
|
+
* fallback per preset, and an adaptive quality governor (fps + battery).
|
|
52
|
+
*/
|
|
53
|
+
declare const PARTICLE_PRESETS: readonly ["snow", "fireflies", "stars", "bokeh", "rain"];
|
|
54
|
+
type ParticlePreset = (typeof PARTICLE_PRESETS)[number];
|
|
55
|
+
/** Post-processing passes: `vec3 fx(vec3 c, vec2 uv)` bodies, applied in order. `u_intensity` 0–1. */
|
|
56
|
+
declare const POST_EFFECTS: Record<string, string>;
|
|
57
|
+
type PostEffect = keyof typeof POST_EFFECTS;
|
|
58
|
+
/** One fragment shader running the passes in order over `u_tex` (pixel-sampling passes read the source). */
|
|
59
|
+
declare function postFxShader(effects: string[]): string;
|
|
60
|
+
/** The unified CSS fallback (no WebGL / reduced data): a still background or image filter per preset. */
|
|
61
|
+
declare const GL_FALLBACKS: Record<string, string>;
|
|
62
|
+
/** CSS fallback for a shader preset / post effect list. */
|
|
63
|
+
declare function glFallbackCss(preset: string, post?: boolean): string;
|
|
64
|
+
interface GLGovernorOptions {
|
|
65
|
+
/** Below this fps quality drops (default 40). */
|
|
66
|
+
minFps?: number;
|
|
67
|
+
/** Frame-rate cap on battery saver / low battery (default 30). */
|
|
68
|
+
saverFps?: number;
|
|
69
|
+
}
|
|
70
|
+
interface GLGovernor {
|
|
71
|
+
/** Feed a frame time (ms); returns `true` when this frame should render. */
|
|
72
|
+
tick(t: number): boolean;
|
|
73
|
+
/** Current resolution scale (1 → 0.5 → 0.35). */
|
|
74
|
+
readonly scale: number;
|
|
75
|
+
/** Measured fps over the last second. */
|
|
76
|
+
readonly fps: number;
|
|
77
|
+
/** Battery saver / low battery: renders at `saverFps` and scale ≤ 0.6. */
|
|
78
|
+
saver: boolean;
|
|
79
|
+
/** Called when `scale` changes (resize the canvas). */
|
|
80
|
+
onScale?: (scale: number) => void;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Adaptive quality for GL loops: measures fps, steps the resolution scale
|
|
84
|
+
* down (1 → 0.5 → 0.35) after two slow seconds and back up after five good
|
|
85
|
+
* ones, and caps the frame rate in battery-saver mode. Pure — feed it times.
|
|
86
|
+
*/
|
|
87
|
+
declare function glGovernor(options?: GLGovernorOptions): GLGovernor;
|
|
88
|
+
/** Watch the Battery Status API (where available) and Save-Data; calls `cb(true)` in saver conditions. Returns a stop function. */
|
|
89
|
+
declare function watchPowerSaver(cb: (saver: boolean) => void): () => void;
|
|
90
|
+
|
|
91
|
+
/** Built-in fragment shaders (bodies; uniforms `u_time`, `u_resolution`, `u_mouse` 0–1, `u_hover` 0–1, `u_tex`, `u_ripples[4]` = x, y, age, strength). */
|
|
92
|
+
declare const SHADERS: Record<string, string>;
|
|
93
|
+
/** Full fragment source for a preset or custom body (adds the shared header). */
|
|
94
|
+
declare function fragmentSource(body: string): string;
|
|
95
|
+
declare function supportsWebGL(): boolean;
|
|
96
|
+
interface GLQuad {
|
|
97
|
+
/** Draw a frame with these uniform values (`extra`: any other float uniforms by name, 4.8). */
|
|
98
|
+
render(u: {
|
|
99
|
+
time?: number;
|
|
100
|
+
mouse?: [number, number];
|
|
101
|
+
hover?: number;
|
|
102
|
+
ripples?: number[];
|
|
103
|
+
extra?: Record<string, number>;
|
|
104
|
+
}): void;
|
|
105
|
+
/** Resize the drawing buffer to the canvas' CSS size × DPR (≤ 2) × `scale` (4.8 adaptive quality). */
|
|
106
|
+
resize(scale?: number): void;
|
|
107
|
+
/** Upload an image as `u_tex`. */
|
|
108
|
+
texture(img: TexImageSource): void;
|
|
109
|
+
dispose(): void;
|
|
110
|
+
}
|
|
111
|
+
/** Compile `frag` on a full-canvas quad, or `null` when WebGL / compilation is unavailable. */
|
|
112
|
+
declare function glQuad(canvas: HTMLCanvasElement, frag: string): GLQuad | null;
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* motionary/components/webgl — lightweight canvas / WebGL (v3.4).
|
|
116
|
+
* `<usa-shader>` (shader backgrounds), `<usa-distort>` (hover image
|
|
117
|
+
* distortion), `<usa-liquid>` (ripple images) on a tiny single-quad runner
|
|
118
|
+
* (`glQuad()`), with graceful fallbacks when WebGL is unavailable.
|
|
119
|
+
*/
|
|
120
|
+
|
|
121
|
+
/** Register every component of this category under its default tag. */
|
|
122
|
+
declare function defineWebglComponents(): void;
|
|
123
|
+
declare global {
|
|
124
|
+
interface HTMLElementTagNameMap {
|
|
125
|
+
'usa-shader': UsaGLElement;
|
|
126
|
+
'usa-distort': UsaGLElement;
|
|
127
|
+
'usa-liquid': UsaGLElement;
|
|
128
|
+
'usa-post-fx': UsaGLElement;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export { GL_FALLBACKS, PARTICLE_PRESETS, POST_EFFECTS, SHADERS, defineDistort, defineLiquid, definePostFx, defineShader, defineWebglComponents, fragmentSource, glFallbackCss, glGovernor, glQuad, postFxShader, supportsWebGL, watchPowerSaver };
|
|
133
|
+
export type { GLGovernor, GLGovernorOptions, GLQuad, ParticlePreset, PostEffect, UsaGLElement };
|