use-scroll-animate 4.4.0 → 4.6.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 +18 -0
- package/dist/chunks/{base-BtJDNCB6.js → base-CZiIAMBc.js} +97 -10
- package/dist/chunks/base-CZiIAMBc.js.map +1 -0
- package/dist/chunks/{base-DE2yzxE7.cjs → base-CxYU2NK_.cjs} +102 -9
- package/dist/chunks/base-CxYU2NK_.cjs.map +1 -0
- package/dist/chunks/{core-DS1nrx5L.js → core-CJHJeMI_.js} +2 -2
- package/dist/chunks/{core-DS1nrx5L.js.map → core-CJHJeMI_.js.map} +1 -1
- package/dist/chunks/{core-DX6pdOoY.js → core-COi3DrLx.js} +2 -2
- package/dist/chunks/{core-DX6pdOoY.js.map → core-COi3DrLx.js.map} +1 -1
- package/dist/chunks/{core-DPYjLqA0.cjs → core-CctNfzuP.cjs} +2 -2
- package/dist/chunks/{core-DPYjLqA0.cjs.map → core-CctNfzuP.cjs.map} +1 -1
- package/dist/chunks/{core-BC9S2osy.cjs → core-HLqH3qkA.cjs} +2 -2
- package/dist/chunks/{core-BC9S2osy.cjs.map → core-HLqH3qkA.cjs.map} +1 -1
- package/dist/chunks/{spring-CxRz49Wk.js → spring-BS5tg6aK.js} +2 -2
- package/dist/chunks/{spring-CxRz49Wk.js.map → spring-BS5tg6aK.js.map} +1 -1
- package/dist/chunks/{spring-hsmgd7ml.cjs → spring-Dkpygsuj.cjs} +2 -2
- package/dist/chunks/{spring-hsmgd7ml.cjs.map → spring-Dkpygsuj.cjs.map} +1 -1
- package/dist/chunks/{variants-CM2zaG8v.cjs → variants-CfJzrzMh.cjs} +2 -2
- package/dist/chunks/{variants-CM2zaG8v.cjs.map → variants-CfJzrzMh.cjs.map} +1 -1
- package/dist/chunks/{variants-dD6SbUMR.js → variants-D9n-3x27.js} +2 -2
- package/dist/chunks/{variants-dD6SbUMR.js.map → variants-D9n-3x27.js.map} +1 -1
- package/dist/components/a11y.cjs +1 -1
- package/dist/components/a11y.js +2 -2
- package/dist/components/angular.cjs +6 -5
- package/dist/components/angular.cjs.map +1 -1
- package/dist/components/angular.js +6 -5
- package/dist/components/angular.js.map +1 -1
- package/dist/components/background.cjs +2 -2
- package/dist/components/background.js +3 -3
- package/dist/components/cards.cjs +2 -2
- package/dist/components/cards.js +3 -3
- package/dist/components/click.cjs +2 -2
- package/dist/components/click.js +3 -3
- package/dist/components/depth.cjs +3 -3
- package/dist/components/depth.js +4 -4
- package/dist/components/feedback.cjs +1 -1
- package/dist/components/feedback.js +2 -2
- package/dist/components/gesture.cjs +3 -3
- package/dist/components/gesture.js +5 -5
- package/dist/components/interaction.cjs +1 -1
- package/dist/components/interaction.js +2 -2
- package/dist/components/layout.cjs +1 -1
- package/dist/components/layout.js +2 -2
- package/dist/components/lite.cjs +10398 -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 +10161 -0
- package/dist/components/lite.js.map +1 -0
- package/dist/components/packs.cjs +1 -1
- package/dist/components/packs.js +2 -2
- package/dist/components/page.cjs +2 -2
- package/dist/components/page.js +3 -3
- package/dist/components/perf.cjs +121 -0
- package/dist/components/perf.cjs.map +1 -0
- package/dist/components/perf.d.cts +97 -0
- package/dist/components/perf.d.ts +97 -0
- package/dist/components/perf.js +111 -0
- package/dist/components/perf.js.map +1 -0
- package/dist/components/physics.cjs +2 -2
- package/dist/components/physics.js +4 -4
- package/dist/components/reveal.cjs +1 -1
- package/dist/components/reveal.js +2 -2
- package/dist/components/solid.cjs +6 -5
- package/dist/components/solid.cjs.map +1 -1
- package/dist/components/solid.js +6 -5
- package/dist/components/solid.js.map +1 -1
- package/dist/components/svelte.cjs +6 -5
- package/dist/components/svelte.cjs.map +1 -1
- package/dist/components/svelte.js +6 -5
- package/dist/components/svelte.js.map +1 -1
- package/dist/components/svg.cjs +1 -1
- package/dist/components/svg.js +2 -2
- package/dist/components/text.cjs +2 -2
- package/dist/components/text.js +3 -3
- package/dist/components/timeline.cjs +2 -2
- package/dist/components/timeline.js +4 -4
- package/dist/components/transitions.cjs +1 -1
- package/dist/components/transitions.js +2 -2
- package/dist/components/ui.cjs +3 -3
- package/dist/components/ui.js +5 -5
- package/dist/components/vue.cjs +6 -5
- package/dist/components/vue.cjs.map +1 -1
- package/dist/components/vue.js +6 -5
- package/dist/components/vue.js.map +1 -1
- package/dist/components/webgl.cjs +1 -1
- package/dist/components/webgl.js +2 -2
- package/dist/components.cjs +16 -5
- package/dist/components.cjs.map +1 -1
- package/dist/components.d.cts +73 -2
- package/dist/components.d.ts +73 -2
- package/dist/components.js +8 -7
- package/dist/components.js.map +1 -1
- package/dist/components.umd.js +2 -2
- package/dist/components.umd.js.map +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.js +2 -2
- package/dist/index.umd.js +2 -2
- package/dist/index.umd.js.map +1 -1
- package/docs/ROADMAP.md +2 -2
- package/docs/performance.md +24 -0
- package/package.json +21 -1
- package/dist/chunks/base-BtJDNCB6.js.map +0 -1
- package/dist/chunks/base-DE2yzxE7.cjs.map +0 -1
package/dist/components/packs.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { p as prefersReducedMotion, n as now, m as motionScale, r as raf,
|
|
2
|
-
export {
|
|
1
|
+
import { p as prefersReducedMotion, n as now, m as motionScale, r as raf, v as EASE_OUT, j as clamp, E as EASE_SPRING, u as defineElement } from '../chunks/base-CZiIAMBc.js';
|
|
2
|
+
export { f as configureComponents } from '../chunks/base-CZiIAMBc.js';
|
|
3
3
|
|
|
4
4
|
const anim = (el, frames, o) => {
|
|
5
5
|
if (typeof el.animate !== 'function')
|
package/dist/components/page.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var base = require('../chunks/base-
|
|
4
|
-
var spring = require('../chunks/spring-
|
|
3
|
+
var base = require('../chunks/base-CxYU2NK_.cjs');
|
|
4
|
+
var spring = require('../chunks/spring-Dkpygsuj.cjs');
|
|
5
5
|
|
|
6
6
|
var css$8 = "usa-cursor{--usa-cursor-color:var(--usa-accent,#7c5cff);--usa-cursor-size:28px;position:fixed;inset:0;pointer-events:none;z-index:2147483600;opacity:0;transition:opacity 0.2s ease;contain:strict}usa-cursor[data-active]{opacity:1}usa-cursor .usa-cursor-ring{position:absolute;left:0;top:0;width:var(--usa-cursor-size);height:var(--usa-cursor-size);margin:calc(var(--usa-cursor-size) / -2) 0 0 calc(var(--usa-cursor-size) / -2);border:1.5px solid var(--usa-cursor-color);border-radius:999px;box-sizing:border-box;transition:width 0.25s cubic-bezier(0.34,1.56,0.64,1),height 0.25s cubic-bezier(0.34,1.56,0.64,1),margin 0.25s ease,border-radius 0.25s ease,background-color 0.2s ease;will-change:transform}usa-cursor[mode=\"trail\"] .usa-cursor-ring{border:0;background:var(--usa-cursor-color);width:calc(var(--usa-cursor-size) * (0.45 - var(--i) * 0.04));height:calc(var(--usa-cursor-size) * (0.45 - var(--i) * 0.04));margin:calc(var(--usa-cursor-size) * (0.45 - var(--i) * 0.04) / -2) 0 0 calc(var(--usa-cursor-size) * (0.45 - var(--i) * 0.04) / -2);opacity:calc(1 - var(--i) * 0.11)}usa-cursor[data-hover] .usa-cursor-ring:first-child{width:calc(var(--usa-cursor-size) * 1.6);height:calc(var(--usa-cursor-size) * 1.6);margin:calc(var(--usa-cursor-size) * -0.8) 0 0 calc(var(--usa-cursor-size) * -0.8);background:color-mix(in srgb,var(--usa-cursor-color) 15%,transparent)}usa-cursor[data-snapped] .usa-cursor-ring{border-radius:12px;background:color-mix(in srgb,var(--usa-cursor-color) 12%,transparent);translate:-50% -50%;margin:0}usa-cursor[data-down] .usa-cursor-ring:first-child{scale:0.8}usa-cursor .usa-cursor-dot{position:absolute;left:-3px;top:-3px;width:6px;height:6px;border-radius:50%;background:var(--usa-cursor-color)}usa-cursor[data-snapped] .usa-cursor-dot{opacity:0}usa-cursor .usa-cursor-glow{position:absolute;left:-200px;top:-200px;width:400px;height:400px;border-radius:50%;background:radial-gradient(circle,color-mix(in srgb,var(--usa-cursor-color) 35%,transparent),transparent 65%);mix-blend-mode:screen}.usa-cursor-none,.usa-cursor-none *{cursor:none !important}@media (pointer:coarse),(prefers-reduced-motion:reduce){usa-cursor{display:none}.usa-cursor-none,.usa-cursor-none *{cursor:auto !important}}";
|
|
7
7
|
|
package/dist/components/page.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { M as MOTION_SCALE } from '../chunks/base-
|
|
3
|
-
import { e as springSamples } from '../chunks/spring-
|
|
1
|
+
import { u as defineElement, k as caf, r as raf, p as prefersReducedMotion, n as now, g as getMotionIntensity, f as configureComponents, q as adoptStyles } from '../chunks/base-CZiIAMBc.js';
|
|
2
|
+
export { M as MOTION_SCALE } from '../chunks/base-CZiIAMBc.js';
|
|
3
|
+
import { e as springSamples } from '../chunks/spring-BS5tg6aK.js';
|
|
4
4
|
|
|
5
5
|
var css$8 = "usa-cursor{--usa-cursor-color:var(--usa-accent,#7c5cff);--usa-cursor-size:28px;position:fixed;inset:0;pointer-events:none;z-index:2147483600;opacity:0;transition:opacity 0.2s ease;contain:strict}usa-cursor[data-active]{opacity:1}usa-cursor .usa-cursor-ring{position:absolute;left:0;top:0;width:var(--usa-cursor-size);height:var(--usa-cursor-size);margin:calc(var(--usa-cursor-size) / -2) 0 0 calc(var(--usa-cursor-size) / -2);border:1.5px solid var(--usa-cursor-color);border-radius:999px;box-sizing:border-box;transition:width 0.25s cubic-bezier(0.34,1.56,0.64,1),height 0.25s cubic-bezier(0.34,1.56,0.64,1),margin 0.25s ease,border-radius 0.25s ease,background-color 0.2s ease;will-change:transform}usa-cursor[mode=\"trail\"] .usa-cursor-ring{border:0;background:var(--usa-cursor-color);width:calc(var(--usa-cursor-size) * (0.45 - var(--i) * 0.04));height:calc(var(--usa-cursor-size) * (0.45 - var(--i) * 0.04));margin:calc(var(--usa-cursor-size) * (0.45 - var(--i) * 0.04) / -2) 0 0 calc(var(--usa-cursor-size) * (0.45 - var(--i) * 0.04) / -2);opacity:calc(1 - var(--i) * 0.11)}usa-cursor[data-hover] .usa-cursor-ring:first-child{width:calc(var(--usa-cursor-size) * 1.6);height:calc(var(--usa-cursor-size) * 1.6);margin:calc(var(--usa-cursor-size) * -0.8) 0 0 calc(var(--usa-cursor-size) * -0.8);background:color-mix(in srgb,var(--usa-cursor-color) 15%,transparent)}usa-cursor[data-snapped] .usa-cursor-ring{border-radius:12px;background:color-mix(in srgb,var(--usa-cursor-color) 12%,transparent);translate:-50% -50%;margin:0}usa-cursor[data-down] .usa-cursor-ring:first-child{scale:0.8}usa-cursor .usa-cursor-dot{position:absolute;left:-3px;top:-3px;width:6px;height:6px;border-radius:50%;background:var(--usa-cursor-color)}usa-cursor[data-snapped] .usa-cursor-dot{opacity:0}usa-cursor .usa-cursor-glow{position:absolute;left:-200px;top:-200px;width:400px;height:400px;border-radius:50%;background:radial-gradient(circle,color-mix(in srgb,var(--usa-cursor-color) 35%,transparent),transparent 65%);mix-blend-mode:screen}.usa-cursor-none,.usa-cursor-none *{cursor:none !important}@media (pointer:coarse),(prefers-reduced-motion:reduce){usa-cursor{display:none}.usa-cursor-none,.usa-cursor-none *{cursor:auto !important}}";
|
|
6
6
|
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var base = require('../chunks/base-CxYU2NK_.cjs');
|
|
4
|
+
var indexTags = require('../chunks/index-tags-BQh_uGqH.cjs');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* use-scroll-animate/components/perf — performance toolkit (4.5).
|
|
8
|
+
*
|
|
9
|
+
* - One shared rAF scheduler for every component loop (`onFrame()`, `schedulerStats()`).
|
|
10
|
+
* - Animation budget: `setAnimationBudget(n)` caps concurrent component
|
|
11
|
+
* animations; extra ones land on their final frame.
|
|
12
|
+
* - `autoDegrade()`: watches frame rate and animation count and steps motion
|
|
13
|
+
* down (`low`, then a tighter budget) while the device struggles, restoring
|
|
14
|
+
* it when frames recover.
|
|
15
|
+
* - On-demand CSS: `loadCategoryStyles()` / `onDemandStyles()` — used by
|
|
16
|
+
* `use-scroll-animate/components/lite`, the build without inlined CSS.
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* Watch frame rate and animation count; while the device struggles, set
|
|
20
|
+
* motion intensity to `low` and cap concurrent animations at `maxActive / 2`,
|
|
21
|
+
* then restore the previous settings once frames recover. Dispatches
|
|
22
|
+
* `usa:degrade` on `document`. Returns a stop function (restores settings).
|
|
23
|
+
*/
|
|
24
|
+
function autoDegrade(options = {}) {
|
|
25
|
+
const { minFps = 45, maxActive = 40, sample = 1000, patience = 2, recovery = 3, onChange } = options;
|
|
26
|
+
let frames = 0;
|
|
27
|
+
let elapsed = 0;
|
|
28
|
+
let bad = 0;
|
|
29
|
+
let good = 0;
|
|
30
|
+
let prev = null;
|
|
31
|
+
const state = { degraded: false, fps: 60, active: 0, reason: '' };
|
|
32
|
+
const set = (degraded, reason) => {
|
|
33
|
+
if (degraded === state.degraded)
|
|
34
|
+
return;
|
|
35
|
+
state.degraded = degraded;
|
|
36
|
+
state.reason = reason;
|
|
37
|
+
if (degraded) {
|
|
38
|
+
prev = { intensity: base.getMotionIntensity(), budget: base.animationBudget() };
|
|
39
|
+
if (prev.intensity !== 'off')
|
|
40
|
+
base.configureComponents({ motionIntensity: 'low' });
|
|
41
|
+
base.setAnimationBudget(Math.max(4, Math.floor(maxActive / 2)));
|
|
42
|
+
}
|
|
43
|
+
else if (prev) {
|
|
44
|
+
base.configureComponents({ motionIntensity: prev.intensity });
|
|
45
|
+
base.setAnimationBudget(prev.budget);
|
|
46
|
+
prev = null;
|
|
47
|
+
}
|
|
48
|
+
onChange?.({ ...state });
|
|
49
|
+
if (typeof document !== 'undefined')
|
|
50
|
+
document.dispatchEvent(new CustomEvent('usa:degrade', { detail: { ...state } }));
|
|
51
|
+
};
|
|
52
|
+
const stop = base.onFrame((_t, dt) => {
|
|
53
|
+
frames++;
|
|
54
|
+
elapsed += Math.min(dt, 250);
|
|
55
|
+
if (elapsed < sample)
|
|
56
|
+
return;
|
|
57
|
+
state.fps = Math.round((frames * 1000) / elapsed);
|
|
58
|
+
state.active = base.activeAnimations();
|
|
59
|
+
frames = 0;
|
|
60
|
+
elapsed = 0;
|
|
61
|
+
const reason = state.fps < minFps ? 'fps' : state.active > maxActive ? 'count' : '';
|
|
62
|
+
if (reason) {
|
|
63
|
+
good = 0;
|
|
64
|
+
if (++bad >= patience)
|
|
65
|
+
set(true, reason);
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
bad = 0;
|
|
69
|
+
if (++good >= recovery)
|
|
70
|
+
set(false, '');
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
return () => {
|
|
74
|
+
stop();
|
|
75
|
+
set(false, '');
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
const TAG_CATEGORY = {};
|
|
79
|
+
for (const [cat, tags] of Object.entries(indexTags.COMPONENT_CATEGORIES))
|
|
80
|
+
for (const t of tags)
|
|
81
|
+
TAG_CATEGORY[t] = cat;
|
|
82
|
+
/** The category of a default `<usa-*>` tag. */
|
|
83
|
+
const categoryOf = (tag) => TAG_CATEGORY[tag];
|
|
84
|
+
const loaded = new Set();
|
|
85
|
+
/**
|
|
86
|
+
* Add `<link rel="stylesheet" href="{base}components/{category}.css">` once.
|
|
87
|
+
* `base` is the URL of the package's `dist/` folder.
|
|
88
|
+
*/
|
|
89
|
+
function loadCategoryStyles(category, base) {
|
|
90
|
+
if (typeof document === 'undefined' || loaded.has(category))
|
|
91
|
+
return null;
|
|
92
|
+
loaded.add(category);
|
|
93
|
+
const link = document.createElement('link');
|
|
94
|
+
link.rel = 'stylesheet';
|
|
95
|
+
link.href = `${base.replace(/\/?$/, '/')}${category === 'all' ? 'components.css' : `components/${category}.css`}`;
|
|
96
|
+
link.setAttribute('data-usa-css', category);
|
|
97
|
+
document.head.appendChild(link);
|
|
98
|
+
return link;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Load each category's CSS the first time one of its elements connects
|
|
102
|
+
* (custom tags fall back to the full stylesheet). Returns an undo.
|
|
103
|
+
*/
|
|
104
|
+
function onDemandStyles(base$1) {
|
|
105
|
+
base.setStyleLoader((tag) => loadCategoryStyles(categoryOf(tag) || 'all', base$1));
|
|
106
|
+
return () => base.setStyleLoader(null);
|
|
107
|
+
}
|
|
108
|
+
/** Categories whose CSS has been requested so far. */
|
|
109
|
+
const loadedStyles = () => Array.from(loaded);
|
|
110
|
+
|
|
111
|
+
exports.activeAnimations = base.activeAnimations;
|
|
112
|
+
exports.animationBudget = base.animationBudget;
|
|
113
|
+
exports.onFrame = base.onFrame;
|
|
114
|
+
exports.schedulerStats = base.schedulerStats;
|
|
115
|
+
exports.setAnimationBudget = base.setAnimationBudget;
|
|
116
|
+
exports.autoDegrade = autoDegrade;
|
|
117
|
+
exports.categoryOf = categoryOf;
|
|
118
|
+
exports.loadCategoryStyles = loadCategoryStyles;
|
|
119
|
+
exports.loadedStyles = loadedStyles;
|
|
120
|
+
exports.onDemandStyles = onDemandStyles;
|
|
121
|
+
//# sourceMappingURL=perf.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"perf.cjs","sources":["../../src/components/perf/index.ts"],"sourcesContent":["/**\n * use-scroll-animate/components/perf — performance toolkit (4.5).\n *\n * - One shared rAF scheduler for every component loop (`onFrame()`, `schedulerStats()`).\n * - Animation budget: `setAnimationBudget(n)` caps concurrent component\n * animations; extra ones land on their final frame.\n * - `autoDegrade()`: watches frame rate and animation count and steps motion\n * down (`low`, then a tighter budget) while the device struggles, restoring\n * it when frames recover.\n * - On-demand CSS: `loadCategoryStyles()` / `onDemandStyles()` — used by\n * `use-scroll-animate/components/lite`, the build without inlined CSS.\n */\nimport {\n onFrame,\n schedulerStats,\n activeAnimations,\n setAnimationBudget,\n animationBudget,\n setStyleLoader,\n configureComponents,\n getMotionIntensity,\n type MotionIntensity,\n} from '../base';\nimport { COMPONENT_CATEGORIES, type ComponentCategory } from '../index-tags';\n\nexport { onFrame, schedulerStats, activeAnimations, setAnimationBudget, animationBudget };\n\nexport interface AutoDegradeOptions {\n /** Frame rate below which motion is degraded (default 45). */\n minFps?: number;\n /** Concurrent animations above which motion is degraded (default 40). */\n maxActive?: number;\n /** Sample window in ms (default 1000). */\n sample?: number;\n /** Bad samples in a row before degrading (default 2). */\n patience?: number;\n /** Good samples in a row before restoring (default 3). */\n recovery?: number;\n /** Called on every change. */\n onChange?: (state: DegradeState) => void;\n}\n\nexport interface DegradeState {\n degraded: boolean;\n fps: number;\n active: number;\n reason: '' | 'fps' | 'count';\n}\n\n/**\n * Watch frame rate and animation count; while the device struggles, set\n * motion intensity to `low` and cap concurrent animations at `maxActive / 2`,\n * then restore the previous settings once frames recover. Dispatches\n * `usa:degrade` on `document`. Returns a stop function (restores settings).\n */\nexport function autoDegrade(options: AutoDegradeOptions = {}): () => void {\n const { minFps = 45, maxActive = 40, sample = 1000, patience = 2, recovery = 3, onChange } = options;\n let frames = 0;\n let elapsed = 0;\n let bad = 0;\n let good = 0;\n let prev: { intensity: MotionIntensity; budget: number } | null = null;\n const state: DegradeState = { degraded: false, fps: 60, active: 0, reason: '' };\n const set = (degraded: boolean, reason: DegradeState['reason']) => {\n if (degraded === state.degraded) return;\n state.degraded = degraded;\n state.reason = reason;\n if (degraded) {\n prev = { intensity: getMotionIntensity(), budget: animationBudget() };\n if (prev.intensity !== 'off') configureComponents({ motionIntensity: 'low' });\n setAnimationBudget(Math.max(4, Math.floor(maxActive / 2)));\n } else if (prev) {\n configureComponents({ motionIntensity: prev.intensity });\n setAnimationBudget(prev.budget);\n prev = null;\n }\n onChange?.({ ...state });\n if (typeof document !== 'undefined') document.dispatchEvent(new CustomEvent('usa:degrade', { detail: { ...state } }));\n };\n const stop = onFrame((_t, dt) => {\n frames++;\n elapsed += Math.min(dt, 250);\n if (elapsed < sample) return;\n state.fps = Math.round((frames * 1000) / elapsed);\n state.active = activeAnimations();\n frames = 0;\n elapsed = 0;\n const reason = state.fps < minFps ? 'fps' : state.active > maxActive ? 'count' : '';\n if (reason) {\n good = 0;\n if (++bad >= patience) set(true, reason);\n } else {\n bad = 0;\n if (++good >= recovery) set(false, '');\n }\n });\n return () => {\n stop();\n set(false, '');\n };\n}\n\nconst TAG_CATEGORY: Record<string, ComponentCategory> = {};\nfor (const [cat, tags] of Object.entries(COMPONENT_CATEGORIES)) for (const t of tags) TAG_CATEGORY[t] = cat as ComponentCategory;\n/** The category of a default `<usa-*>` tag. */\nexport const categoryOf = (tag: string): ComponentCategory | undefined => TAG_CATEGORY[tag];\n\nconst loaded = new Set<string>();\n/**\n * Add `<link rel=\"stylesheet\" href=\"{base}components/{category}.css\">` once.\n * `base` is the URL of the package's `dist/` folder.\n */\nexport function loadCategoryStyles(category: ComponentCategory | 'all', base: string): HTMLLinkElement | null {\n if (typeof document === 'undefined' || loaded.has(category)) return null;\n loaded.add(category);\n const link = document.createElement('link');\n link.rel = 'stylesheet';\n link.href = `${base.replace(/\\/?$/, '/')}${category === 'all' ? 'components.css' : `components/${category}.css`}`;\n link.setAttribute('data-usa-css', category);\n document.head.appendChild(link);\n return link;\n}\n\n/**\n * Load each category's CSS the first time one of its elements connects\n * (custom tags fall back to the full stylesheet). Returns an undo.\n */\nexport function onDemandStyles(base: string): () => void {\n setStyleLoader((tag) => loadCategoryStyles(categoryOf(tag) || 'all', base));\n return () => setStyleLoader(null);\n}\n\n/** Categories whose CSS has been requested so far. */\nexport const loadedStyles = (): string[] => Array.from(loaded);\n"],"names":["getMotionIntensity","animationBudget","configureComponents","setAnimationBudget","onFrame","activeAnimations","COMPONENT_CATEGORIES","base","setStyleLoader"],"mappings":";;;;;AAAA;;;;;;;;;;;AAWG;AAsCH;;;;;AAKG;AACG,SAAU,WAAW,CAAC,OAAA,GAA8B,EAAE,EAA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
+
/** Run `fn(time, dt)` every frame on the shared scheduler until the returned function is called. */
|
|
2
|
+
declare function onFrame(fn: (t: number, dt: number) => void): () => void;
|
|
3
|
+
/** Scheduler counters: frames flushed, callbacks run, peak callbacks in one frame, pending now. */
|
|
4
|
+
declare function schedulerStats(): {
|
|
5
|
+
frames: number;
|
|
6
|
+
callbacks: number;
|
|
7
|
+
peak: number;
|
|
8
|
+
pending: number;
|
|
9
|
+
loops: number;
|
|
10
|
+
};
|
|
11
|
+
/** Number of component animations running right now. */
|
|
12
|
+
declare const activeAnimations: () => number;
|
|
13
|
+
/** Cap concurrent component animations; extra ones jump to their final frame (`Infinity` = no cap). */
|
|
14
|
+
declare function setAnimationBudget(max: number): void;
|
|
15
|
+
/** The current cap. */
|
|
16
|
+
declare const animationBudget: () => number;
|
|
17
|
+
|
|
18
|
+
/** The component categories and their default tags. */
|
|
19
|
+
declare const COMPONENT_CATEGORIES: {
|
|
20
|
+
readonly reveal: readonly ["usa-reveal", "usa-stagger", "usa-scroll-progress", "usa-scrolly"];
|
|
21
|
+
readonly text: readonly ["usa-typewriter", "usa-split-text", "usa-scramble", "usa-counter", "usa-shimmer-text", "usa-text-rotate", "usa-wave-text", "usa-glitch", "usa-gradient-text", "usa-handwriting", "usa-scroll-highlight"];
|
|
22
|
+
readonly interaction: readonly ["usa-ripple", "usa-magnetic", "usa-tilt", "usa-spotlight", "usa-press", "usa-toggle"];
|
|
23
|
+
readonly feedback: readonly ["usa-spinner", "usa-skeleton", "usa-progress", "usa-toaster", "usa-check"];
|
|
24
|
+
readonly background: readonly ["usa-aurora", "usa-particles", "usa-grain", "usa-marquee", "usa-acrylic", "usa-grid-glow", "usa-blobs", "usa-water-ripple", "usa-dot-network"];
|
|
25
|
+
readonly transitions: readonly ["usa-dialog", "usa-accordion", "usa-view-switch"];
|
|
26
|
+
readonly physics: readonly ["usa-spring", "usa-draggable", "usa-overscroll"];
|
|
27
|
+
readonly cards: readonly ["usa-card", "usa-card-stack", "usa-sticky-stack", "usa-carousel-3d"];
|
|
28
|
+
readonly click: readonly ["usa-click", "usa-button", "usa-icon-morph", "usa-like", "usa-hold", "usa-double-tap", "usa-checkbox"];
|
|
29
|
+
readonly ui: readonly ["usa-tabs", "usa-drawer", "usa-bottom-sheet", "usa-pull-refresh", "usa-fab", "usa-navbar", "usa-slider", "usa-rating", "usa-tooltip", "usa-popover", "usa-badge", "usa-avatar-stack"];
|
|
30
|
+
readonly page: readonly ["usa-cursor", "usa-fullpage", "usa-loading-bar", "usa-back-to-top", "usa-ambient", "usa-splash", "usa-auto-skeleton", "usa-motion-switch"];
|
|
31
|
+
readonly timeline: readonly ["usa-timeline"];
|
|
32
|
+
readonly gesture: readonly ["usa-swipeable", "usa-pinch-zoom"];
|
|
33
|
+
readonly svg: readonly ["usa-draw", "usa-morph", "usa-mask-reveal", "usa-anim-icon"];
|
|
34
|
+
readonly webgl: readonly ["usa-shader", "usa-distort", "usa-liquid"];
|
|
35
|
+
readonly depth: readonly ["usa-cube", "usa-depth"];
|
|
36
|
+
readonly layout: readonly ["usa-auto-animate", "usa-masonry"];
|
|
37
|
+
readonly packs: readonly ["usa-pack"];
|
|
38
|
+
};
|
|
39
|
+
type ComponentCategory = keyof typeof COMPONENT_CATEGORIES;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* use-scroll-animate/components/perf — performance toolkit (4.5).
|
|
43
|
+
*
|
|
44
|
+
* - One shared rAF scheduler for every component loop (`onFrame()`, `schedulerStats()`).
|
|
45
|
+
* - Animation budget: `setAnimationBudget(n)` caps concurrent component
|
|
46
|
+
* animations; extra ones land on their final frame.
|
|
47
|
+
* - `autoDegrade()`: watches frame rate and animation count and steps motion
|
|
48
|
+
* down (`low`, then a tighter budget) while the device struggles, restoring
|
|
49
|
+
* it when frames recover.
|
|
50
|
+
* - On-demand CSS: `loadCategoryStyles()` / `onDemandStyles()` — used by
|
|
51
|
+
* `use-scroll-animate/components/lite`, the build without inlined CSS.
|
|
52
|
+
*/
|
|
53
|
+
|
|
54
|
+
interface AutoDegradeOptions {
|
|
55
|
+
/** Frame rate below which motion is degraded (default 45). */
|
|
56
|
+
minFps?: number;
|
|
57
|
+
/** Concurrent animations above which motion is degraded (default 40). */
|
|
58
|
+
maxActive?: number;
|
|
59
|
+
/** Sample window in ms (default 1000). */
|
|
60
|
+
sample?: number;
|
|
61
|
+
/** Bad samples in a row before degrading (default 2). */
|
|
62
|
+
patience?: number;
|
|
63
|
+
/** Good samples in a row before restoring (default 3). */
|
|
64
|
+
recovery?: number;
|
|
65
|
+
/** Called on every change. */
|
|
66
|
+
onChange?: (state: DegradeState) => void;
|
|
67
|
+
}
|
|
68
|
+
interface DegradeState {
|
|
69
|
+
degraded: boolean;
|
|
70
|
+
fps: number;
|
|
71
|
+
active: number;
|
|
72
|
+
reason: '' | 'fps' | 'count';
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Watch frame rate and animation count; while the device struggles, set
|
|
76
|
+
* motion intensity to `low` and cap concurrent animations at `maxActive / 2`,
|
|
77
|
+
* then restore the previous settings once frames recover. Dispatches
|
|
78
|
+
* `usa:degrade` on `document`. Returns a stop function (restores settings).
|
|
79
|
+
*/
|
|
80
|
+
declare function autoDegrade(options?: AutoDegradeOptions): () => void;
|
|
81
|
+
/** The category of a default `<usa-*>` tag. */
|
|
82
|
+
declare const categoryOf: (tag: string) => ComponentCategory | undefined;
|
|
83
|
+
/**
|
|
84
|
+
* Add `<link rel="stylesheet" href="{base}components/{category}.css">` once.
|
|
85
|
+
* `base` is the URL of the package's `dist/` folder.
|
|
86
|
+
*/
|
|
87
|
+
declare function loadCategoryStyles(category: ComponentCategory | 'all', base: string): HTMLLinkElement | null;
|
|
88
|
+
/**
|
|
89
|
+
* Load each category's CSS the first time one of its elements connects
|
|
90
|
+
* (custom tags fall back to the full stylesheet). Returns an undo.
|
|
91
|
+
*/
|
|
92
|
+
declare function onDemandStyles(base: string): () => void;
|
|
93
|
+
/** Categories whose CSS has been requested so far. */
|
|
94
|
+
declare const loadedStyles: () => string[];
|
|
95
|
+
|
|
96
|
+
export { activeAnimations, animationBudget, autoDegrade, categoryOf, loadCategoryStyles, loadedStyles, onDemandStyles, onFrame, schedulerStats, setAnimationBudget };
|
|
97
|
+
export type { AutoDegradeOptions, DegradeState };
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/** Run `fn(time, dt)` every frame on the shared scheduler until the returned function is called. */
|
|
2
|
+
declare function onFrame(fn: (t: number, dt: number) => void): () => void;
|
|
3
|
+
/** Scheduler counters: frames flushed, callbacks run, peak callbacks in one frame, pending now. */
|
|
4
|
+
declare function schedulerStats(): {
|
|
5
|
+
frames: number;
|
|
6
|
+
callbacks: number;
|
|
7
|
+
peak: number;
|
|
8
|
+
pending: number;
|
|
9
|
+
loops: number;
|
|
10
|
+
};
|
|
11
|
+
/** Number of component animations running right now. */
|
|
12
|
+
declare const activeAnimations: () => number;
|
|
13
|
+
/** Cap concurrent component animations; extra ones jump to their final frame (`Infinity` = no cap). */
|
|
14
|
+
declare function setAnimationBudget(max: number): void;
|
|
15
|
+
/** The current cap. */
|
|
16
|
+
declare const animationBudget: () => number;
|
|
17
|
+
|
|
18
|
+
/** The component categories and their default tags. */
|
|
19
|
+
declare const COMPONENT_CATEGORIES: {
|
|
20
|
+
readonly reveal: readonly ["usa-reveal", "usa-stagger", "usa-scroll-progress", "usa-scrolly"];
|
|
21
|
+
readonly text: readonly ["usa-typewriter", "usa-split-text", "usa-scramble", "usa-counter", "usa-shimmer-text", "usa-text-rotate", "usa-wave-text", "usa-glitch", "usa-gradient-text", "usa-handwriting", "usa-scroll-highlight"];
|
|
22
|
+
readonly interaction: readonly ["usa-ripple", "usa-magnetic", "usa-tilt", "usa-spotlight", "usa-press", "usa-toggle"];
|
|
23
|
+
readonly feedback: readonly ["usa-spinner", "usa-skeleton", "usa-progress", "usa-toaster", "usa-check"];
|
|
24
|
+
readonly background: readonly ["usa-aurora", "usa-particles", "usa-grain", "usa-marquee", "usa-acrylic", "usa-grid-glow", "usa-blobs", "usa-water-ripple", "usa-dot-network"];
|
|
25
|
+
readonly transitions: readonly ["usa-dialog", "usa-accordion", "usa-view-switch"];
|
|
26
|
+
readonly physics: readonly ["usa-spring", "usa-draggable", "usa-overscroll"];
|
|
27
|
+
readonly cards: readonly ["usa-card", "usa-card-stack", "usa-sticky-stack", "usa-carousel-3d"];
|
|
28
|
+
readonly click: readonly ["usa-click", "usa-button", "usa-icon-morph", "usa-like", "usa-hold", "usa-double-tap", "usa-checkbox"];
|
|
29
|
+
readonly ui: readonly ["usa-tabs", "usa-drawer", "usa-bottom-sheet", "usa-pull-refresh", "usa-fab", "usa-navbar", "usa-slider", "usa-rating", "usa-tooltip", "usa-popover", "usa-badge", "usa-avatar-stack"];
|
|
30
|
+
readonly page: readonly ["usa-cursor", "usa-fullpage", "usa-loading-bar", "usa-back-to-top", "usa-ambient", "usa-splash", "usa-auto-skeleton", "usa-motion-switch"];
|
|
31
|
+
readonly timeline: readonly ["usa-timeline"];
|
|
32
|
+
readonly gesture: readonly ["usa-swipeable", "usa-pinch-zoom"];
|
|
33
|
+
readonly svg: readonly ["usa-draw", "usa-morph", "usa-mask-reveal", "usa-anim-icon"];
|
|
34
|
+
readonly webgl: readonly ["usa-shader", "usa-distort", "usa-liquid"];
|
|
35
|
+
readonly depth: readonly ["usa-cube", "usa-depth"];
|
|
36
|
+
readonly layout: readonly ["usa-auto-animate", "usa-masonry"];
|
|
37
|
+
readonly packs: readonly ["usa-pack"];
|
|
38
|
+
};
|
|
39
|
+
type ComponentCategory = keyof typeof COMPONENT_CATEGORIES;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* use-scroll-animate/components/perf — performance toolkit (4.5).
|
|
43
|
+
*
|
|
44
|
+
* - One shared rAF scheduler for every component loop (`onFrame()`, `schedulerStats()`).
|
|
45
|
+
* - Animation budget: `setAnimationBudget(n)` caps concurrent component
|
|
46
|
+
* animations; extra ones land on their final frame.
|
|
47
|
+
* - `autoDegrade()`: watches frame rate and animation count and steps motion
|
|
48
|
+
* down (`low`, then a tighter budget) while the device struggles, restoring
|
|
49
|
+
* it when frames recover.
|
|
50
|
+
* - On-demand CSS: `loadCategoryStyles()` / `onDemandStyles()` — used by
|
|
51
|
+
* `use-scroll-animate/components/lite`, the build without inlined CSS.
|
|
52
|
+
*/
|
|
53
|
+
|
|
54
|
+
interface AutoDegradeOptions {
|
|
55
|
+
/** Frame rate below which motion is degraded (default 45). */
|
|
56
|
+
minFps?: number;
|
|
57
|
+
/** Concurrent animations above which motion is degraded (default 40). */
|
|
58
|
+
maxActive?: number;
|
|
59
|
+
/** Sample window in ms (default 1000). */
|
|
60
|
+
sample?: number;
|
|
61
|
+
/** Bad samples in a row before degrading (default 2). */
|
|
62
|
+
patience?: number;
|
|
63
|
+
/** Good samples in a row before restoring (default 3). */
|
|
64
|
+
recovery?: number;
|
|
65
|
+
/** Called on every change. */
|
|
66
|
+
onChange?: (state: DegradeState) => void;
|
|
67
|
+
}
|
|
68
|
+
interface DegradeState {
|
|
69
|
+
degraded: boolean;
|
|
70
|
+
fps: number;
|
|
71
|
+
active: number;
|
|
72
|
+
reason: '' | 'fps' | 'count';
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Watch frame rate and animation count; while the device struggles, set
|
|
76
|
+
* motion intensity to `low` and cap concurrent animations at `maxActive / 2`,
|
|
77
|
+
* then restore the previous settings once frames recover. Dispatches
|
|
78
|
+
* `usa:degrade` on `document`. Returns a stop function (restores settings).
|
|
79
|
+
*/
|
|
80
|
+
declare function autoDegrade(options?: AutoDegradeOptions): () => void;
|
|
81
|
+
/** The category of a default `<usa-*>` tag. */
|
|
82
|
+
declare const categoryOf: (tag: string) => ComponentCategory | undefined;
|
|
83
|
+
/**
|
|
84
|
+
* Add `<link rel="stylesheet" href="{base}components/{category}.css">` once.
|
|
85
|
+
* `base` is the URL of the package's `dist/` folder.
|
|
86
|
+
*/
|
|
87
|
+
declare function loadCategoryStyles(category: ComponentCategory | 'all', base: string): HTMLLinkElement | null;
|
|
88
|
+
/**
|
|
89
|
+
* Load each category's CSS the first time one of its elements connects
|
|
90
|
+
* (custom tags fall back to the full stylesheet). Returns an undo.
|
|
91
|
+
*/
|
|
92
|
+
declare function onDemandStyles(base: string): () => void;
|
|
93
|
+
/** Categories whose CSS has been requested so far. */
|
|
94
|
+
declare const loadedStyles: () => string[];
|
|
95
|
+
|
|
96
|
+
export { activeAnimations, animationBudget, autoDegrade, categoryOf, loadCategoryStyles, loadedStyles, onDemandStyles, onFrame, schedulerStats, setAnimationBudget };
|
|
97
|
+
export type { AutoDegradeOptions, DegradeState };
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { o as onFrame, t as setStyleLoader, e as animationBudget, g as getMotionIntensity, f as configureComponents, i as setAnimationBudget, b as activeAnimations } from '../chunks/base-CZiIAMBc.js';
|
|
2
|
+
export { s as schedulerStats } from '../chunks/base-CZiIAMBc.js';
|
|
3
|
+
import { C as COMPONENT_CATEGORIES } from '../chunks/index-tags-43Xtd01A.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* use-scroll-animate/components/perf — performance toolkit (4.5).
|
|
7
|
+
*
|
|
8
|
+
* - One shared rAF scheduler for every component loop (`onFrame()`, `schedulerStats()`).
|
|
9
|
+
* - Animation budget: `setAnimationBudget(n)` caps concurrent component
|
|
10
|
+
* animations; extra ones land on their final frame.
|
|
11
|
+
* - `autoDegrade()`: watches frame rate and animation count and steps motion
|
|
12
|
+
* down (`low`, then a tighter budget) while the device struggles, restoring
|
|
13
|
+
* it when frames recover.
|
|
14
|
+
* - On-demand CSS: `loadCategoryStyles()` / `onDemandStyles()` — used by
|
|
15
|
+
* `use-scroll-animate/components/lite`, the build without inlined CSS.
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* Watch frame rate and animation count; while the device struggles, set
|
|
19
|
+
* motion intensity to `low` and cap concurrent animations at `maxActive / 2`,
|
|
20
|
+
* then restore the previous settings once frames recover. Dispatches
|
|
21
|
+
* `usa:degrade` on `document`. Returns a stop function (restores settings).
|
|
22
|
+
*/
|
|
23
|
+
function autoDegrade(options = {}) {
|
|
24
|
+
const { minFps = 45, maxActive = 40, sample = 1000, patience = 2, recovery = 3, onChange } = options;
|
|
25
|
+
let frames = 0;
|
|
26
|
+
let elapsed = 0;
|
|
27
|
+
let bad = 0;
|
|
28
|
+
let good = 0;
|
|
29
|
+
let prev = null;
|
|
30
|
+
const state = { degraded: false, fps: 60, active: 0, reason: '' };
|
|
31
|
+
const set = (degraded, reason) => {
|
|
32
|
+
if (degraded === state.degraded)
|
|
33
|
+
return;
|
|
34
|
+
state.degraded = degraded;
|
|
35
|
+
state.reason = reason;
|
|
36
|
+
if (degraded) {
|
|
37
|
+
prev = { intensity: getMotionIntensity(), budget: animationBudget() };
|
|
38
|
+
if (prev.intensity !== 'off')
|
|
39
|
+
configureComponents({ motionIntensity: 'low' });
|
|
40
|
+
setAnimationBudget(Math.max(4, Math.floor(maxActive / 2)));
|
|
41
|
+
}
|
|
42
|
+
else if (prev) {
|
|
43
|
+
configureComponents({ motionIntensity: prev.intensity });
|
|
44
|
+
setAnimationBudget(prev.budget);
|
|
45
|
+
prev = null;
|
|
46
|
+
}
|
|
47
|
+
onChange?.({ ...state });
|
|
48
|
+
if (typeof document !== 'undefined')
|
|
49
|
+
document.dispatchEvent(new CustomEvent('usa:degrade', { detail: { ...state } }));
|
|
50
|
+
};
|
|
51
|
+
const stop = onFrame((_t, dt) => {
|
|
52
|
+
frames++;
|
|
53
|
+
elapsed += Math.min(dt, 250);
|
|
54
|
+
if (elapsed < sample)
|
|
55
|
+
return;
|
|
56
|
+
state.fps = Math.round((frames * 1000) / elapsed);
|
|
57
|
+
state.active = activeAnimations();
|
|
58
|
+
frames = 0;
|
|
59
|
+
elapsed = 0;
|
|
60
|
+
const reason = state.fps < minFps ? 'fps' : state.active > maxActive ? 'count' : '';
|
|
61
|
+
if (reason) {
|
|
62
|
+
good = 0;
|
|
63
|
+
if (++bad >= patience)
|
|
64
|
+
set(true, reason);
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
bad = 0;
|
|
68
|
+
if (++good >= recovery)
|
|
69
|
+
set(false, '');
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
return () => {
|
|
73
|
+
stop();
|
|
74
|
+
set(false, '');
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
const TAG_CATEGORY = {};
|
|
78
|
+
for (const [cat, tags] of Object.entries(COMPONENT_CATEGORIES))
|
|
79
|
+
for (const t of tags)
|
|
80
|
+
TAG_CATEGORY[t] = cat;
|
|
81
|
+
/** The category of a default `<usa-*>` tag. */
|
|
82
|
+
const categoryOf = (tag) => TAG_CATEGORY[tag];
|
|
83
|
+
const loaded = new Set();
|
|
84
|
+
/**
|
|
85
|
+
* Add `<link rel="stylesheet" href="{base}components/{category}.css">` once.
|
|
86
|
+
* `base` is the URL of the package's `dist/` folder.
|
|
87
|
+
*/
|
|
88
|
+
function loadCategoryStyles(category, base) {
|
|
89
|
+
if (typeof document === 'undefined' || loaded.has(category))
|
|
90
|
+
return null;
|
|
91
|
+
loaded.add(category);
|
|
92
|
+
const link = document.createElement('link');
|
|
93
|
+
link.rel = 'stylesheet';
|
|
94
|
+
link.href = `${base.replace(/\/?$/, '/')}${category === 'all' ? 'components.css' : `components/${category}.css`}`;
|
|
95
|
+
link.setAttribute('data-usa-css', category);
|
|
96
|
+
document.head.appendChild(link);
|
|
97
|
+
return link;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Load each category's CSS the first time one of its elements connects
|
|
101
|
+
* (custom tags fall back to the full stylesheet). Returns an undo.
|
|
102
|
+
*/
|
|
103
|
+
function onDemandStyles(base) {
|
|
104
|
+
setStyleLoader((tag) => loadCategoryStyles(categoryOf(tag) || 'all', base));
|
|
105
|
+
return () => setStyleLoader(null);
|
|
106
|
+
}
|
|
107
|
+
/** Categories whose CSS has been requested so far. */
|
|
108
|
+
const loadedStyles = () => Array.from(loaded);
|
|
109
|
+
|
|
110
|
+
export { activeAnimations, animationBudget, autoDegrade, categoryOf, loadCategoryStyles, loadedStyles, onDemandStyles, onFrame, setAnimationBudget };
|
|
111
|
+
//# sourceMappingURL=perf.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"perf.js","sources":["../../src/components/perf/index.ts"],"sourcesContent":["/**\n * use-scroll-animate/components/perf — performance toolkit (4.5).\n *\n * - One shared rAF scheduler for every component loop (`onFrame()`, `schedulerStats()`).\n * - Animation budget: `setAnimationBudget(n)` caps concurrent component\n * animations; extra ones land on their final frame.\n * - `autoDegrade()`: watches frame rate and animation count and steps motion\n * down (`low`, then a tighter budget) while the device struggles, restoring\n * it when frames recover.\n * - On-demand CSS: `loadCategoryStyles()` / `onDemandStyles()` — used by\n * `use-scroll-animate/components/lite`, the build without inlined CSS.\n */\nimport {\n onFrame,\n schedulerStats,\n activeAnimations,\n setAnimationBudget,\n animationBudget,\n setStyleLoader,\n configureComponents,\n getMotionIntensity,\n type MotionIntensity,\n} from '../base';\nimport { COMPONENT_CATEGORIES, type ComponentCategory } from '../index-tags';\n\nexport { onFrame, schedulerStats, activeAnimations, setAnimationBudget, animationBudget };\n\nexport interface AutoDegradeOptions {\n /** Frame rate below which motion is degraded (default 45). */\n minFps?: number;\n /** Concurrent animations above which motion is degraded (default 40). */\n maxActive?: number;\n /** Sample window in ms (default 1000). */\n sample?: number;\n /** Bad samples in a row before degrading (default 2). */\n patience?: number;\n /** Good samples in a row before restoring (default 3). */\n recovery?: number;\n /** Called on every change. */\n onChange?: (state: DegradeState) => void;\n}\n\nexport interface DegradeState {\n degraded: boolean;\n fps: number;\n active: number;\n reason: '' | 'fps' | 'count';\n}\n\n/**\n * Watch frame rate and animation count; while the device struggles, set\n * motion intensity to `low` and cap concurrent animations at `maxActive / 2`,\n * then restore the previous settings once frames recover. Dispatches\n * `usa:degrade` on `document`. Returns a stop function (restores settings).\n */\nexport function autoDegrade(options: AutoDegradeOptions = {}): () => void {\n const { minFps = 45, maxActive = 40, sample = 1000, patience = 2, recovery = 3, onChange } = options;\n let frames = 0;\n let elapsed = 0;\n let bad = 0;\n let good = 0;\n let prev: { intensity: MotionIntensity; budget: number } | null = null;\n const state: DegradeState = { degraded: false, fps: 60, active: 0, reason: '' };\n const set = (degraded: boolean, reason: DegradeState['reason']) => {\n if (degraded === state.degraded) return;\n state.degraded = degraded;\n state.reason = reason;\n if (degraded) {\n prev = { intensity: getMotionIntensity(), budget: animationBudget() };\n if (prev.intensity !== 'off') configureComponents({ motionIntensity: 'low' });\n setAnimationBudget(Math.max(4, Math.floor(maxActive / 2)));\n } else if (prev) {\n configureComponents({ motionIntensity: prev.intensity });\n setAnimationBudget(prev.budget);\n prev = null;\n }\n onChange?.({ ...state });\n if (typeof document !== 'undefined') document.dispatchEvent(new CustomEvent('usa:degrade', { detail: { ...state } }));\n };\n const stop = onFrame((_t, dt) => {\n frames++;\n elapsed += Math.min(dt, 250);\n if (elapsed < sample) return;\n state.fps = Math.round((frames * 1000) / elapsed);\n state.active = activeAnimations();\n frames = 0;\n elapsed = 0;\n const reason = state.fps < minFps ? 'fps' : state.active > maxActive ? 'count' : '';\n if (reason) {\n good = 0;\n if (++bad >= patience) set(true, reason);\n } else {\n bad = 0;\n if (++good >= recovery) set(false, '');\n }\n });\n return () => {\n stop();\n set(false, '');\n };\n}\n\nconst TAG_CATEGORY: Record<string, ComponentCategory> = {};\nfor (const [cat, tags] of Object.entries(COMPONENT_CATEGORIES)) for (const t of tags) TAG_CATEGORY[t] = cat as ComponentCategory;\n/** The category of a default `<usa-*>` tag. */\nexport const categoryOf = (tag: string): ComponentCategory | undefined => TAG_CATEGORY[tag];\n\nconst loaded = new Set<string>();\n/**\n * Add `<link rel=\"stylesheet\" href=\"{base}components/{category}.css\">` once.\n * `base` is the URL of the package's `dist/` folder.\n */\nexport function loadCategoryStyles(category: ComponentCategory | 'all', base: string): HTMLLinkElement | null {\n if (typeof document === 'undefined' || loaded.has(category)) return null;\n loaded.add(category);\n const link = document.createElement('link');\n link.rel = 'stylesheet';\n link.href = `${base.replace(/\\/?$/, '/')}${category === 'all' ? 'components.css' : `components/${category}.css`}`;\n link.setAttribute('data-usa-css', category);\n document.head.appendChild(link);\n return link;\n}\n\n/**\n * Load each category's CSS the first time one of its elements connects\n * (custom tags fall back to the full stylesheet). Returns an undo.\n */\nexport function onDemandStyles(base: string): () => void {\n setStyleLoader((tag) => loadCategoryStyles(categoryOf(tag) || 'all', base));\n return () => setStyleLoader(null);\n}\n\n/** Categories whose CSS has been requested so far. */\nexport const loadedStyles = (): string[] => Array.from(loaded);\n"],"names":[],"mappings":";;;;AAAA;;;;;;;;;;;AAWG;AAsCH;;;;;AAKG;AACG,SAAU,WAAW,CAAC,OAAA,GAA8B,EAAE,EAAA;IAC1D,MAAM,EAAE,MAAM,GAAG,EAAE,EAAE,SAAS,GAAG,EAAE,EAAE,MAAM,GAAG,IAAI,EAAE,QAAQ,GAAG,CAAC,EAAE,QAAQ,GAAG,CAAC,EAAE,QAAQ,EAAE,GAAG,OAAO;IACpG,IAAI,MAAM,GAAG,CAAC;IACd,IAAI,OAAO,GAAG,CAAC;IACf,IAAI,GAAG,GAAG,CAAC;IACX,IAAI,IAAI,GAAG,CAAC;IACZ,IAAI,IAAI,GAA0D,IAAI;AACtE,IAAA,MAAM,KAAK,GAAiB,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE;AAC/E,IAAA,MAAM,GAAG,GAAG,CAAC,QAAiB,EAAE,MAA8B,KAAI;AAChE,QAAA,IAAI,QAAQ,KAAK,KAAK,CAAC,QAAQ;YAAE;AACjC,QAAA,KAAK,CAAC,QAAQ,GAAG,QAAQ;AACzB,QAAA,KAAK,CAAC,MAAM,GAAG,MAAM;QACrB,IAAI,QAAQ,EAAE;AACZ,YAAA,IAAI,GAAG,EAAE,SAAS,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;AACjH,IAAA,IAAI,CAAC,YAAY,CAAC,cAAc,EAAE,QAAQ,CAAC;AAC3C,IAAA,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;AAC/B,IAAA,OAAO,IAAI;AACb;AAEA;;;AAGG;AACG,SAAU,cAAc,CAAC,IAAY,EAAA;AACzC,IAAA,cAAc,CAAC,CAAC,GAAG,KAAK,kBAAkB,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,KAAK,EAAE,IAAI,CAAC,CAAC;AAC3E,IAAA,OAAO,MAAM,cAAc,CAAC,IAAI,CAAC;AACnC;AAEA;AACO,MAAM,YAAY,GAAG,MAAgB,KAAK,CAAC,IAAI,CAAC,MAAM;;;;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var base = require('../chunks/base-
|
|
4
|
-
var spring = require('../chunks/spring-
|
|
3
|
+
var base = require('../chunks/base-CxYU2NK_.cjs');
|
|
4
|
+
var spring = require('../chunks/spring-Dkpygsuj.cjs');
|
|
5
5
|
|
|
6
6
|
var css$2 = "usa-spring{display:inline-block;transform-origin:50% 70%}usa-spring[block]{display:block}usa-spring[effect=\"drop\"]{transform-origin:50% 100%}usa-spring[data-state=\"hidden\"]{opacity:0}usa-spring[trigger=\"click\"],usa-spring[trigger=\"hover\"]{cursor:pointer;-webkit-tap-highlight-color:transparent}";
|
|
7
7
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
3
|
-
import { d as springEasing, c as createSpring, s as snapTo, a as rubberBand, p as projectInertia } from '../chunks/spring-
|
|
4
|
-
export { S as SPRING_PRESETS, l as linearEasing, r as resolveSpring, b as spring, e as springSamples, f as stepSpring, g as supportsLinearEasing } from '../chunks/spring-
|
|
1
|
+
import { u as defineElement, j as clamp } from '../chunks/base-CZiIAMBc.js';
|
|
2
|
+
export { f as configureComponents, p as prefersReducedMotion } from '../chunks/base-CZiIAMBc.js';
|
|
3
|
+
import { d as springEasing, c as createSpring, s as snapTo, a as rubberBand, p as projectInertia } from '../chunks/spring-BS5tg6aK.js';
|
|
4
|
+
export { S as SPRING_PRESETS, l as linearEasing, r as resolveSpring, b as spring, e as springSamples, f as stepSpring, g as supportsLinearEasing } from '../chunks/spring-BS5tg6aK.js';
|
|
5
5
|
|
|
6
6
|
var css$2 = "usa-spring{display:inline-block;transform-origin:50% 70%}usa-spring[block]{display:block}usa-spring[effect=\"drop\"]{transform-origin:50% 100%}usa-spring[data-state=\"hidden\"]{opacity:0}usa-spring[trigger=\"click\"],usa-spring[trigger=\"hover\"]{cursor:pointer;-webkit-tap-highlight-color:transparent}";
|
|
7
7
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
1
|
+
import { u as defineElement, v as EASE_OUT, j as clamp, k as caf, r as raf } from '../chunks/base-CZiIAMBc.js';
|
|
2
|
+
export { f as configureComponents, p as prefersReducedMotion } from '../chunks/base-CZiIAMBc.js';
|
|
3
3
|
|
|
4
4
|
/** Entrance effects shared by `<usa-reveal>` and `<usa-stagger>` (transform / opacity / filter only). */
|
|
5
5
|
const REVEAL_EFFECTS = [
|
|
@@ -4,24 +4,24 @@ var solidJs = require('solid-js');
|
|
|
4
4
|
var components = require('../components.cjs');
|
|
5
5
|
var bind = require('../chunks/bind-Ui43-n2d.cjs');
|
|
6
6
|
require('./reveal.cjs');
|
|
7
|
-
require('../chunks/base-
|
|
7
|
+
require('../chunks/base-CxYU2NK_.cjs');
|
|
8
8
|
require('./text.cjs');
|
|
9
|
-
require('../chunks/core-
|
|
9
|
+
require('../chunks/core-HLqH3qkA.cjs');
|
|
10
10
|
require('./tokens.cjs');
|
|
11
11
|
require('./interaction.cjs');
|
|
12
12
|
require('./feedback.cjs');
|
|
13
13
|
require('./background.cjs');
|
|
14
|
-
require('../chunks/variants-
|
|
14
|
+
require('../chunks/variants-CfJzrzMh.cjs');
|
|
15
15
|
require('./transitions.cjs');
|
|
16
16
|
require('./physics.cjs');
|
|
17
|
-
require('../chunks/spring-
|
|
17
|
+
require('../chunks/spring-Dkpygsuj.cjs');
|
|
18
18
|
require('./cards.cjs');
|
|
19
19
|
require('./click.cjs');
|
|
20
20
|
require('./ui.cjs');
|
|
21
21
|
require('./page.cjs');
|
|
22
22
|
require('./timeline.cjs');
|
|
23
23
|
require('./gesture.cjs');
|
|
24
|
-
require('../chunks/core-
|
|
24
|
+
require('../chunks/core-CctNfzuP.cjs');
|
|
25
25
|
require('./svg.cjs');
|
|
26
26
|
require('./webgl.cjs');
|
|
27
27
|
require('./depth.cjs');
|
|
@@ -29,6 +29,7 @@ require('./layout.cjs');
|
|
|
29
29
|
require('./packs.cjs');
|
|
30
30
|
require('./a11y.cjs');
|
|
31
31
|
require('../chunks/index-tags-BQh_uGqH.cjs');
|
|
32
|
+
require('./perf.cjs');
|
|
32
33
|
|
|
33
34
|
/**
|
|
34
35
|
* use-scroll-animate/components/solid — Solid integration (v3.8).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"solid.cjs","sources":["../../src/components/frameworks/solid.ts"],"sourcesContent":["/**\n * use-scroll-animate/components/solid — Solid integration (v3.8).\n * Solid renders custom elements natively: set properties with `prop:` and\n * listen with `on:` (`<usa-toggle prop:checked={on()} on:usa:change={…}>`).\n * This entry adds `defineUsa()` (client only, SolidStart-safe), a `usa`\n * directive for `use:usa={{ props, on }}`, and JSX types.\n *\n * ```tsx\n * import { defineUsa, usa } from 'use-scroll-animate/components/solid';\n * import type {} from 'use-scroll-animate/components/solid'; // JSX types\n * onMount(() => defineUsa());\n * false && usa; // keep the directive import (Solid convention)\n * <usa-card use:usa={{ on: { flip: (e) => console.log(e.detail) } }} effect=\"flip\">…</usa-card>\n * ```\n */\nimport { createRenderEffect, onCleanup } from 'solid-js';\nimport { defineComponents, type ComponentCategory } from '../index';\nimport { bindUsa, type UsaBinding } from './bind';\nimport type { UsaIntrinsicElements } from './jsx';\n\nexport { bindUsa, usaEventName } from './bind';\nexport type { UsaBinding } from './bind';\n\n/**\n * Solid directive (`use:usa`). Solid calls it with the element and an\n * accessor; since 4.0.1 the binding is tracked with `createRenderEffect`, so\n * signals read inside `{{ props, on }}` update the element automatically and\n * the listeners are removed on cleanup. `refresh()` is kept for code that\n * calls the directive outside a reactive owner.\n */\nexport function usa(el: HTMLElement, accessor: () => UsaBinding | undefined): { refresh(): void; destroy(): void } {\n let b: ReturnType<typeof bindUsa> | null = null;\n const run = () => {\n const v = accessor() || {};\n if (b) b.update(v);\n else b = bindUsa(el, v);\n };\n createRenderEffect(run);\n if (!b) run();\n const destroy = () => b?.destroy();\n onCleanup(destroy);\n return { refresh: run, destroy };\n}\n\n/** Register the elements (all, or some categories) — call from `onMount` in SSR apps. */\nexport function defineUsa(categories?: ComponentCategory[]): void {\n if (typeof window !== 'undefined') defineComponents(categories);\n}\n\n/** JSX intrinsic elements for Solid (same attribute types as the React/Preact ones). */\nexport type SolidUsaIntrinsicElements = UsaIntrinsicElements;\n"],"names":["bindUsa","createRenderEffect","onCleanup","defineComponents"],"mappings":"
|
|
1
|
+
{"version":3,"file":"solid.cjs","sources":["../../src/components/frameworks/solid.ts"],"sourcesContent":["/**\n * use-scroll-animate/components/solid — Solid integration (v3.8).\n * Solid renders custom elements natively: set properties with `prop:` and\n * listen with `on:` (`<usa-toggle prop:checked={on()} on:usa:change={…}>`).\n * This entry adds `defineUsa()` (client only, SolidStart-safe), a `usa`\n * directive for `use:usa={{ props, on }}`, and JSX types.\n *\n * ```tsx\n * import { defineUsa, usa } from 'use-scroll-animate/components/solid';\n * import type {} from 'use-scroll-animate/components/solid'; // JSX types\n * onMount(() => defineUsa());\n * false && usa; // keep the directive import (Solid convention)\n * <usa-card use:usa={{ on: { flip: (e) => console.log(e.detail) } }} effect=\"flip\">…</usa-card>\n * ```\n */\nimport { createRenderEffect, onCleanup } from 'solid-js';\nimport { defineComponents, type ComponentCategory } from '../index';\nimport { bindUsa, type UsaBinding } from './bind';\nimport type { UsaIntrinsicElements } from './jsx';\n\nexport { bindUsa, usaEventName } from './bind';\nexport type { UsaBinding } from './bind';\n\n/**\n * Solid directive (`use:usa`). Solid calls it with the element and an\n * accessor; since 4.0.1 the binding is tracked with `createRenderEffect`, so\n * signals read inside `{{ props, on }}` update the element automatically and\n * the listeners are removed on cleanup. `refresh()` is kept for code that\n * calls the directive outside a reactive owner.\n */\nexport function usa(el: HTMLElement, accessor: () => UsaBinding | undefined): { refresh(): void; destroy(): void } {\n let b: ReturnType<typeof bindUsa> | null = null;\n const run = () => {\n const v = accessor() || {};\n if (b) b.update(v);\n else b = bindUsa(el, v);\n };\n createRenderEffect(run);\n if (!b) run();\n const destroy = () => b?.destroy();\n onCleanup(destroy);\n return { refresh: run, destroy };\n}\n\n/** Register the elements (all, or some categories) — call from `onMount` in SSR apps. */\nexport function defineUsa(categories?: ComponentCategory[]): void {\n if (typeof window !== 'undefined') defineComponents(categories);\n}\n\n/** JSX intrinsic elements for Solid (same attribute types as the React/Preact ones). */\nexport type SolidUsaIntrinsicElements = UsaIntrinsicElements;\n"],"names":["bindUsa","createRenderEffect","onCleanup","defineComponents"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;AAcG;AASH;;;;;;AAMG;AACG,SAAU,GAAG,CAAC,EAAe,EAAE,QAAsC,EAAA;IACzE,IAAI,CAAC,GAAsC,IAAI;IAC/C,MAAM,GAAG,GAAG,MAAK;AACf,QAAA,MAAM,CAAC,GAAG,QAAQ,EAAE,IAAI,EAAE;AAC1B,QAAA,IAAI,CAAC;AAAE,YAAA,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;;AACb,YAAA,CAAC,GAAGA,YAAO,CAAC,EAAE,EAAE,CAAC,CAAC;AACzB,IAAA,CAAC;IACDC,0BAAkB,CAAC,GAAG,CAAC;AACvB,IAAA,IAAI,CAAC,CAAC;AAAE,QAAA,GAAG,EAAE;IACb,MAAM,OAAO,GAAG,MAAM,CAAC,EAAE,OAAO,EAAE;IAClCC,iBAAS,CAAC,OAAO,CAAC;AAClB,IAAA,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE;AAClC;AAEA;AACM,SAAU,SAAS,CAAC,UAAgC,EAAA;IACxD,IAAI,OAAO,MAAM,KAAK,WAAW;QAAEC,2BAAgB,CAAC,UAAU,CAAC;AACjE;;;;;;;"}
|