use-scroll-animate 4.6.0 → 4.8.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.
Files changed (78) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/README.md +1 -1
  3. package/README_ja.md +1 -1
  4. package/README_zh.md +1 -1
  5. package/dist/chunks/{index-tags-BQh_uGqH.cjs → index-tags-CIRY2KnU.cjs} +2 -2
  6. package/dist/chunks/{index-tags-BQh_uGqH.cjs.map → index-tags-CIRY2KnU.cjs.map} +1 -1
  7. package/dist/chunks/{index-tags-43Xtd01A.js → index-tags-Dh8nwXqw.js} +2 -2
  8. package/dist/chunks/{index-tags-43Xtd01A.js.map → index-tags-Dh8nwXqw.js.map} +1 -1
  9. package/dist/components/a11y.cjs +1 -1
  10. package/dist/components/a11y.d.cts +1 -1
  11. package/dist/components/a11y.d.ts +1 -1
  12. package/dist/components/a11y.js +1 -1
  13. package/dist/components/angular.cjs +2 -1
  14. package/dist/components/angular.cjs.map +1 -1
  15. package/dist/components/angular.d.cts +2 -1
  16. package/dist/components/angular.d.ts +2 -1
  17. package/dist/components/angular.js +2 -1
  18. package/dist/components/angular.js.map +1 -1
  19. package/dist/components/bridge.cjs +154 -0
  20. package/dist/components/bridge.cjs.map +1 -0
  21. package/dist/components/bridge.d.cts +63 -0
  22. package/dist/components/bridge.d.ts +63 -0
  23. package/dist/components/bridge.js +147 -0
  24. package/dist/components/bridge.js.map +1 -0
  25. package/dist/components/jsx.d.cts +1 -1
  26. package/dist/components/jsx.d.ts +1 -1
  27. package/dist/components/lazy.cjs +1 -1
  28. package/dist/components/lazy.d.cts +1 -1
  29. package/dist/components/lazy.d.ts +1 -1
  30. package/dist/components/lazy.js +1 -1
  31. package/dist/components/lite.cjs +333 -10
  32. package/dist/components/lite.cjs.map +1 -1
  33. package/dist/components/lite.js +320 -11
  34. package/dist/components/lite.js.map +1 -1
  35. package/dist/components/perf.cjs +1 -1
  36. package/dist/components/perf.d.cts +1 -1
  37. package/dist/components/perf.d.ts +1 -1
  38. package/dist/components/perf.js +1 -1
  39. package/dist/components/react.cjs +1 -1
  40. package/dist/components/react.js +1 -1
  41. package/dist/components/solid.cjs +2 -1
  42. package/dist/components/solid.cjs.map +1 -1
  43. package/dist/components/solid.d.cts +2 -1
  44. package/dist/components/solid.d.ts +2 -1
  45. package/dist/components/solid.js +2 -1
  46. package/dist/components/solid.js.map +1 -1
  47. package/dist/components/svelte.cjs +2 -1
  48. package/dist/components/svelte.cjs.map +1 -1
  49. package/dist/components/svelte.d.cts +2 -1
  50. package/dist/components/svelte.d.ts +2 -1
  51. package/dist/components/svelte.js +2 -1
  52. package/dist/components/svelte.js.map +1 -1
  53. package/dist/components/vue.cjs +2 -1
  54. package/dist/components/vue.cjs.map +1 -1
  55. package/dist/components/vue.d.cts +2 -1
  56. package/dist/components/vue.d.ts +2 -1
  57. package/dist/components/vue.js +2 -1
  58. package/dist/components/vue.js.map +1 -1
  59. package/dist/components/webgl.cjs +184 -10
  60. package/dist/components/webgl.cjs.map +1 -1
  61. package/dist/components/webgl.css +1 -1
  62. package/dist/components/webgl.d.cts +59 -5
  63. package/dist/components/webgl.d.ts +59 -5
  64. package/dist/components/webgl.js +178 -12
  65. package/dist/components/webgl.js.map +1 -1
  66. package/dist/components.cjs +16 -1
  67. package/dist/components.cjs.map +1 -1
  68. package/dist/components.css +1 -1
  69. package/dist/components.d.cts +119 -6
  70. package/dist/components.d.ts +119 -6
  71. package/dist/components.js +3 -2
  72. package/dist/components.js.map +1 -1
  73. package/dist/components.umd.js +3 -2
  74. package/dist/components.umd.js.map +1 -1
  75. package/docs/ROADMAP.md +2 -2
  76. package/docs/components.md +7 -0
  77. package/docs/hybrid-apps.md +15 -0
  78. package/package.json +11 -1
@@ -12,6 +12,12 @@ const SHADERS = {
12
12
  waves: 'void main(){vec2 u=v_uv;float t=u_time*.4;float w=0.;for(int i=0;i<4;i++){float f=float(i)+1.;w+=sin(u.x*6.*f+t*f)*.08/f;}float l=smoothstep(.0,.02,abs(u.y-.5-w));vec3 col=mix(vec3(.2,.5,1.),vec3(.04,.06,.15),l)+vec3(.1,.0,.2)*u.y;gl_FragColor=vec4(col,1.);}',
13
13
  aurora: 'void main(){vec2 u=v_uv;float t=u_time*.2;float b=0.;for(int i=0;i<3;i++){float f=float(i);b+=.4/abs((u.y-.6+.15*sin(u.x*3.+t+f*1.7))*(8.+f*4.));}vec3 col=vec3(.02,.03,.08)+b*mix(vec3(.1,.9,.6),vec3(.6,.3,1.),u.x)*.35;gl_FragColor=vec4(col,1.);}',
14
14
  distort: 'void main(){vec2 u=v_uv;vec2 d=u-u_mouse;float r=length(d);float k=u_hover*.08*exp(-r*r*18.);u-=normalize(d+1e-4)*k;float s=u_hover*.006;vec3 col=vec3(texture2D(u_tex,u+vec2(s,0.)).r,texture2D(u_tex,u).g,texture2D(u_tex,u-vec2(s,0.)).b);gl_FragColor=vec4(col,1.);}',
15
+ // 4.8 particle presets (procedural, one quad: no buffers, no per-particle JS)
16
+ snow: 'float h(vec2 p){return fract(sin(dot(p,vec2(127.1,311.7)))*43758.5453);}void main(){vec2 u=v_uv;u.x*=u_resolution.x/max(u_resolution.y,1.);vec3 col=mix(vec3(.05,.08,.16),vec3(.12,.16,.3),v_uv.y);for(int l=0;l<3;l++){float s=8.+float(l)*7.;vec2 q=u*s;q.y+=u_time*(.6+float(l)*.35);q.x+=sin(q.y*.7+float(l))*.3;vec2 id=floor(q);vec2 f=fract(q)-.5;float r=h(id);if(r>.6){vec2 o=vec2(h(id+3.)-.5,h(id+7.)-.5)*.6;float d=length(f-o);col+=smoothstep(.09-float(l)*.02,0.,d)*(.5+.5*r);}}gl_FragColor=vec4(col,1.);}',
17
+ fireflies: 'float h(vec2 p){return fract(sin(dot(p,vec2(127.1,311.7)))*43758.5453);}void main(){vec2 u=v_uv;u.x*=u_resolution.x/max(u_resolution.y,1.);vec3 col=vec3(.02,.04,.03);for(int l=0;l<2;l++){vec2 q=u*(5.+float(l)*4.);vec2 id=floor(q);vec2 f=fract(q)-.5;float r=h(id+float(l)*13.);vec2 o=.35*vec2(sin(u_time*(.4+r)+r*6.28),cos(u_time*(.3+r)+r*12.));float d=length(f-o);float tw=.5+.5*sin(u_time*3.*r+r*20.);col+=vec3(1.,.85,.3)*smoothstep(.12,0.,d)*tw*step(.45,r);}gl_FragColor=vec4(col,1.);}',
18
+ stars: 'float h(vec2 p){return fract(sin(dot(p,vec2(127.1,311.7)))*43758.5453);}void main(){vec2 c=v_uv-.5;c.x*=u_resolution.x/max(u_resolution.y,1.);vec3 col=vec3(.01,.01,.04);for(int l=0;l<4;l++){float z=fract(float(l)*.25+u_time*.05);float sc=mix(20.,.5,z);vec2 q=c*sc+float(l)*7.;vec2 id=floor(q);vec2 f=fract(q)-.5;float r=h(id);float d=length(f-(vec2(h(id+1.),h(id+2.))-.5)*.7);col+=vec3(.8,.9,1.)*smoothstep(.06,0.,d)*step(.8,r)*smoothstep(0.,.5,z)*smoothstep(1.,.8,z)*2.;}gl_FragColor=vec4(col,1.);}',
19
+ bokeh: 'float h(vec2 p){return fract(sin(dot(p,vec2(127.1,311.7)))*43758.5453);}void main(){vec2 u=v_uv;u.x*=u_resolution.x/max(u_resolution.y,1.);vec3 col=mix(vec3(.08,.03,.12),vec3(.02,.05,.12),v_uv.y);for(int l=0;l<3;l++){vec2 q=u*(2.5+float(l)*1.5);q.y-=u_time*.05*(1.+float(l));vec2 id=floor(q);vec2 f=fract(q)-.5;float r=h(id+float(l)*5.);float d=length(f-(vec2(h(id+4.),h(id+9.))-.5)*.5);vec3 tint=.5+.5*cos(r*6.28+vec3(0.,2.,4.));col+=tint*smoothstep(.3,.26,d)*.18*step(.35,r);}gl_FragColor=vec4(col,1.);}',
20
+ rain: 'float h(float n){return fract(sin(n)*43758.5453);}void main(){vec2 u=v_uv;vec3 col=mix(vec3(.04,.06,.1),vec3(.1,.13,.2),u.y);float n=floor(u.x*120.);float sp=.8+h(n)*1.2;float y=fract(u.y+u_time*sp+h(n+1.));float drop=smoothstep(.0,.08,y)*smoothstep(.16,.08,y)*step(.7,h(n+2.));col+=vec3(.5,.6,.8)*drop*.6;gl_FragColor=vec4(col,1.);}',
15
21
  liquid: 'void main(){vec2 u=v_uv;vec2 o=vec2(0.);for(int i=0;i<4;i++){vec4 r=u_ripples[i];if(r.w>0.){float d=distance(u,r.xy);float w=sin(d*60.-r.z*12.)*exp(-d*6.)*exp(-r.z*1.6)*r.w*.02;o+=normalize(u-r.xy+1e-4)*w;}}o+=vec2(sin(u.y*10.+u_time),cos(u.x*10.+u_time))*.002*u_hover;gl_FragColor=texture2D(u_tex,u+o);}',
16
22
  };
17
23
  /** Full fragment source for a preset or custom body (adds the shared header). */
@@ -71,9 +77,10 @@ function glQuad(canvas, frag) {
71
77
  const U = (n) => g.getUniformLocation(prog, n);
72
78
  const uT = U('u_time'), uR = U('u_resolution'), uM = U('u_mouse'), uH = U('u_hover'), uRp = U('u_ripples');
73
79
  let tex = null;
80
+ const extraLoc = {};
74
81
  const quad = {
75
- resize() {
76
- const dpr = Math.min(2, (typeof devicePixelRatio === 'number' && devicePixelRatio) || 1);
82
+ resize(scale = 1) {
83
+ const dpr = Math.min(2, (typeof devicePixelRatio === 'number' && devicePixelRatio) || 1) * Math.min(1, Math.max(0.25, scale));
77
84
  const w = Math.max(1, Math.round((canvas.clientWidth || 300) * dpr));
78
85
  const h = Math.max(1, Math.round((canvas.clientHeight || 150) * dpr));
79
86
  if (canvas.width !== w || canvas.height !== h)
@@ -96,6 +103,9 @@ function glQuad(canvas, frag) {
96
103
  g.uniform1f(uH, u.hover ?? 0);
97
104
  if (uRp)
98
105
  g.uniform4fv(uRp, new Float32Array((u.ripples ?? []).concat(Array(16).fill(0)).slice(0, 16)));
106
+ if (u.extra)
107
+ for (const [k, v] of Object.entries(u.extra))
108
+ g.uniform1f((extraLoc[k] ?? (extraLoc[k] = U(k))), v);
99
109
  g.drawArrays(g.TRIANGLES, 0, 6);
100
110
  },
101
111
  dispose() {
@@ -110,7 +120,132 @@ function glQuad(canvas, frag) {
110
120
  return quad;
111
121
  }
112
122
 
113
- var css = "usa-shader,usa-distort,usa-liquid{display:block;position:relative;isolation:isolate;overflow:hidden}usa-shader{background:linear-gradient(120deg,#6366f1,#ec4899 50%,#22d3ee)}usa-shader>canvas.usa-gl{position:absolute;inset:0;width:100%;height:100%;z-index:-1;display:block}usa-distort>canvas.usa-gl,usa-liquid>canvas.usa-gl{position:absolute;inset:0;width:100%;height:100%;display:block;pointer-events:none}usa-distort>img,usa-liquid>img{display:block;width:100%;height:auto}usa-distort[data-active]>img,usa-liquid[data-active]>img{visibility:hidden}usa-distort[data-fallback]>img{transition:transform 0.6s cubic-bezier(0.22,1,0.36,1),filter 0.6s}usa-distort[data-fallback]:hover>img{transform:scale(1.04);filter:saturate(1.2)}@media (prefers-reduced-motion:reduce){usa-distort[data-fallback]:hover>img{transform:none}}";
123
+ /**
124
+ * 4.8 — WebGL preset library on `glQuad()`: particle presets (`snow`,
125
+ * `fireflies`, `stars`, `bokeh`, `rain` — usable as `<usa-shader preset>`),
126
+ * chainable post-processing passes for images (`<usa-post-fx>`), one CSS
127
+ * fallback per preset, and an adaptive quality governor (fps + battery).
128
+ */
129
+ const PARTICLE_PRESETS = ['snow', 'fireflies', 'stars', 'bokeh', 'rain'];
130
+ /** Post-processing passes: `vec3 fx(vec3 c, vec2 uv)` bodies, applied in order. `u_intensity` 0–1. */
131
+ const POST_EFFECTS = {
132
+ vignette: 'c*=mix(1.,smoothstep(.85,.25,length(uv-.5)),u_intensity);',
133
+ grain: 'c+=(fract(sin(dot(uv*u_resolution+u_time,vec2(12.9898,78.233)))*43758.5453)-.5)*.18*u_intensity;',
134
+ chromatic: 'float s=.008*u_intensity;c=vec3(texture2D(u_tex,uv+vec2(s,0.)).r,c.g,texture2D(u_tex,uv-vec2(s,0.)).b);',
135
+ scanlines: 'c*=1.-.25*u_intensity*step(.5,fract(uv.y*u_resolution.y*.5));',
136
+ crt: 'vec2 d=uv-.5;float r=dot(d,d);c*=1.-.6*u_intensity*r;c*=.92+.08*sin(uv.y*u_resolution.y*3.14159);c.r*=1.+.05*u_intensity;',
137
+ bloom: 'vec3 b=vec3(0.);for(int i=0;i<8;i++){float a=float(i)*.785;b+=max(texture2D(u_tex,uv+vec2(cos(a),sin(a))*.012).rgb-.6,0.);}c+=b*.35*u_intensity;',
138
+ pixelate: 'float px=mix(1.,48.,u_intensity);vec2 g=floor(uv*u_resolution/px)*px/u_resolution;c=texture2D(u_tex,g+.5*px/u_resolution).rgb;',
139
+ duotone: 'float l=dot(c,vec3(.299,.587,.114));c=mix(c,mix(vec3(.12,.05,.35),vec3(1.,.55,.4),l),u_intensity);',
140
+ glitch: 'float k=step(.97,fract(sin(floor(uv.y*24.)+floor(u_time*6.))*4375.5));c=mix(c,texture2D(u_tex,uv+vec2(k*.04*u_intensity,0.)).rgb,k);',
141
+ };
142
+ /** One fragment shader running the passes in order over `u_tex` (pixel-sampling passes read the source). */
143
+ function postFxShader(effects) {
144
+ const list = effects.filter((e) => POST_EFFECTS[e]);
145
+ const body = list.map((e) => `{${POST_EFFECTS[e]}}`).join('');
146
+ return `uniform float u_intensity;void main(){vec2 uv=v_uv;vec3 c=texture2D(u_tex,uv).rgb;${body}gl_FragColor=vec4(clamp(c,0.,1.),1.);}`;
147
+ }
148
+ /** The unified CSS fallback (no WebGL / reduced data): a still background or image filter per preset. */
149
+ const GL_FALLBACKS = {
150
+ gradient: 'linear-gradient(120deg,#6366f1,#ec4899 50%,#22d3ee)',
151
+ plasma: 'conic-gradient(from 90deg,#f43f5e,#a855f7,#06b6d4,#f43f5e)',
152
+ waves: 'linear-gradient(#0a0f26,#1e3a8a)',
153
+ aurora: 'radial-gradient(120% 60% at 30% 40%,#10b98155,transparent),radial-gradient(100% 50% at 70% 50%,#8b5cf655,transparent),#05070f',
154
+ snow: 'radial-gradient(2px 2px at 20% 30%,#fff,transparent),radial-gradient(2px 2px at 70% 60%,#fff,transparent),radial-gradient(1.5px 1.5px at 40% 80%,#fff,transparent),linear-gradient(#0d1428,#1f2a4d)',
155
+ fireflies: 'radial-gradient(3px 3px at 25% 40%,#fde68a,transparent),radial-gradient(3px 3px at 65% 70%,#fde68a,transparent),#05090a',
156
+ stars: 'radial-gradient(1px 1px at 10% 20%,#fff,transparent),radial-gradient(1px 1px at 80% 30%,#fff,transparent),radial-gradient(1.5px 1.5px at 50% 70%,#cfe0ff,transparent),#02020a',
157
+ bokeh: 'radial-gradient(40px 40px at 30% 40%,#f472b633,transparent),radial-gradient(60px 60px at 70% 60%,#60a5fa33,transparent),#140820',
158
+ rain: 'repeating-linear-gradient(100deg,#ffffff10 0 1px,transparent 1px 14px),linear-gradient(#0a0f1a,#1a2133)',
159
+ // post-fx fallbacks are CSS filters on the <img>
160
+ 'post:duotone': 'grayscale(1) sepia(.6) hue-rotate(220deg) saturate(2)',
161
+ 'post:vignette': 'brightness(.95) contrast(1.05)',
162
+ 'post:crt': 'contrast(1.15) saturate(1.2)',
163
+ 'post:bloom': 'brightness(1.08) saturate(1.15)',
164
+ };
165
+ /** CSS fallback for a shader preset / post effect list. */
166
+ function glFallbackCss(preset, post = false) {
167
+ if (post)
168
+ return preset.split(/\s+/).map((e) => GL_FALLBACKS[`post:${e}`]).filter(Boolean).join(' ');
169
+ return GL_FALLBACKS[preset] || GL_FALLBACKS.gradient;
170
+ }
171
+ /**
172
+ * Adaptive quality for GL loops: measures fps, steps the resolution scale
173
+ * down (1 → 0.5 → 0.35) after two slow seconds and back up after five good
174
+ * ones, and caps the frame rate in battery-saver mode. Pure — feed it times.
175
+ */
176
+ function glGovernor(options = {}) {
177
+ const { minFps = 40, saverFps = 30 } = options;
178
+ const STEPS = [1, 0.5, 0.35];
179
+ let step = 0;
180
+ let frames = 0;
181
+ let winStart = -1;
182
+ let last = -Infinity;
183
+ let slow = 0;
184
+ let good = 0;
185
+ let fps = 60;
186
+ const g = {
187
+ saver: false,
188
+ get scale() {
189
+ return Math.min(STEPS[step], g.saver ? 0.6 : 1);
190
+ },
191
+ get fps() {
192
+ return fps;
193
+ },
194
+ tick(t) {
195
+ if (winStart < 0)
196
+ winStart = t;
197
+ if (g.saver && t - last < 1000 / saverFps - 1)
198
+ return false;
199
+ last = t;
200
+ frames++;
201
+ if (t - winStart >= 1000) {
202
+ fps = Math.round((frames * 1000) / (t - winStart));
203
+ frames = 0;
204
+ winStart = t;
205
+ const before = g.scale;
206
+ if (fps < minFps && !g.saver) {
207
+ good = 0;
208
+ if (++slow >= 2 && step < STEPS.length - 1)
209
+ ((step++), (slow = 0));
210
+ }
211
+ else {
212
+ slow = 0;
213
+ if (++good >= 5 && step > 0)
214
+ ((step--), (good = 0));
215
+ }
216
+ if (g.scale !== before)
217
+ g.onScale?.(g.scale);
218
+ }
219
+ return true;
220
+ },
221
+ };
222
+ return g;
223
+ }
224
+ /** Watch the Battery Status API (where available) and Save-Data; calls `cb(true)` in saver conditions. Returns a stop function. */
225
+ function watchPowerSaver(cb) {
226
+ let stopped = false;
227
+ const nav = (typeof navigator !== 'undefined' ? navigator : {});
228
+ const saveData = !!nav.connection?.saveData;
229
+ if (saveData)
230
+ cb(true);
231
+ if (typeof nav.getBattery !== 'function')
232
+ return () => undefined;
233
+ let battery = null;
234
+ const update = () => !stopped && cb(saveData || (!!battery && !battery.charging && battery.level <= 0.2));
235
+ nav.getBattery().then((b) => {
236
+ battery = b;
237
+ update();
238
+ b.addEventListener?.('levelchange', update);
239
+ b.addEventListener?.('chargingchange', update);
240
+ }, () => undefined);
241
+ return () => {
242
+ stopped = true;
243
+ battery?.removeEventListener?.('levelchange', update);
244
+ battery?.removeEventListener?.('chargingchange', update);
245
+ };
246
+ }
247
+
248
+ var css = "usa-shader,usa-distort,usa-liquid,usa-post-fx{display:block;position:relative;isolation:isolate;overflow:hidden}usa-shader{background:linear-gradient(120deg,#6366f1,#ec4899 50%,#22d3ee)}usa-shader>canvas.usa-gl{position:absolute;inset:0;width:100%;height:100%;z-index:-1;display:block}usa-distort>canvas.usa-gl,usa-liquid>canvas.usa-gl{position:absolute;inset:0;width:100%;height:100%;display:block;pointer-events:none}usa-distort>img,usa-liquid>img{display:block;width:100%;height:auto}usa-distort[data-active]>img,usa-liquid[data-active]>img{visibility:hidden}usa-distort[data-fallback]>img{transition:transform 0.6s cubic-bezier(0.22,1,0.36,1),filter 0.6s}usa-distort[data-fallback]:hover>img{transform:scale(1.04);filter:saturate(1.2)}@media (prefers-reduced-motion:reduce){usa-distort[data-fallback]:hover>img{transform:none}}usa-shader[data-fallback]{background:var(--usa-gl-fallback,linear-gradient(120deg,#6366f1,#ec4899 50%,#22d3ee))}usa-post-fx>canvas.usa-gl{position:absolute;inset:0;width:100%;height:100%;display:block;pointer-events:none}usa-post-fx>img{display:block;width:100%;height:auto}usa-post-fx[data-active]>img{visibility:hidden}usa-post-fx[data-fallback]>img{filter:var(--usa-gl-filter,none)}";
114
249
 
115
250
  function make(kind) {
116
251
  return (Base) => class extends Base {
@@ -123,15 +258,23 @@ function make(kind) {
123
258
  this._hover = 0;
124
259
  this._hoverTo = 0;
125
260
  this._ripples = [];
261
+ this._scale = 1;
126
262
  }
127
263
  static get observedAttributes() {
128
- return kind === 'shader' ? ['preset', 'speed'] : ['src'];
264
+ return kind === 'shader' ? ['preset', 'speed', 'quality'] : kind === 'post' ? ['effects', 'intensity', 'quality'] : ['src'];
129
265
  }
130
266
  get active() {
131
267
  return !!this._q;
132
268
  }
133
269
  fallback(reason) {
134
270
  this.setAttribute('data-fallback', reason);
271
+ // 4.8 unified fallback: a still CSS rendering of the preset / effects
272
+ if (reason !== 'off') {
273
+ if (kind === 'shader')
274
+ this.style.setProperty('--usa-gl-fallback', glFallbackCss(this.str('preset', 'gradient')));
275
+ if (kind === 'post')
276
+ this.style.setProperty('--usa-gl-filter', glFallbackCss(this.str('effects', 'vignette grain'), true) || 'none');
277
+ }
135
278
  this._c?.remove();
136
279
  this._c = null;
137
280
  this._q?.dispose();
@@ -149,12 +292,13 @@ function make(kind) {
149
292
  mouse: this._mouse,
150
293
  hover: this._hover,
151
294
  ripples: this._ripples.flatMap((r) => [r.x, r.y, (t - r.t) / 1000, this.num('strength', 1)]),
295
+ extra: kind === 'post' ? { u_intensity: base.clamp(this.num('intensity', 0.6), 0, 1) } : undefined,
152
296
  });
153
297
  }
154
298
  mount() {
155
299
  this.removeAttribute('data-fallback');
156
300
  const custom = this.querySelector('script[type="x-shader/x-fragment"]');
157
- const frag = kind === 'shader' ? custom?.textContent || this.str('preset', 'gradient') : kind;
301
+ const frag = kind === 'shader' ? custom?.textContent || this.str('preset', 'gradient') : kind === 'post' ? postFxShader(this.str('effects', 'vignette grain').split(/[\s,]+/)) : kind;
158
302
  const img = kind === 'shader' ? null : this.querySelector('img');
159
303
  if (kind !== 'shader' && !img)
160
304
  return this.fallback('no-image');
@@ -179,7 +323,7 @@ function make(kind) {
179
323
  }
180
324
  };
181
325
  const draw = () => {
182
- q.resize();
326
+ q.resize(this._scale);
183
327
  this.frame();
184
328
  };
185
329
  if (img && !(img.complete && img.naturalWidth)) {
@@ -193,7 +337,7 @@ function make(kind) {
193
337
  this.setAttribute('data-active', '');
194
338
  this.onCleanup(() => this.removeAttribute('data-active'));
195
339
  draw();
196
- if (kind !== 'shader') {
340
+ if (kind === 'distort' || kind === 'liquid') {
197
341
  const pos = (e) => {
198
342
  const r = this.getBoundingClientRect();
199
343
  this._mouse = [base.clamp((e.clientX - r.left) / (r.width || 1), 0, 1), base.clamp(1 - (e.clientY - r.top) / (r.height || 1), 0, 1)];
@@ -210,7 +354,7 @@ function make(kind) {
210
354
  // 4.0.1: also follow the element's own size (grid reflow, card expand…)
211
355
  if (typeof ResizeObserver !== 'undefined') {
212
356
  const ro = new ResizeObserver(() => {
213
- q.resize();
357
+ q.resize(this._scale);
214
358
  if (!this._id)
215
359
  this.frame();
216
360
  });
@@ -219,9 +363,20 @@ function make(kind) {
219
363
  }
220
364
  if (this.reduced)
221
365
  return; // one static frame, no loop
366
+ // 4.8 adaptive quality: fps-driven resolution steps + battery saver frame cap
367
+ const gov = glGovernor();
368
+ const auto = this.str('quality', 'auto') !== 'high';
369
+ gov.onScale = (sc) => {
370
+ this._scale = sc;
371
+ this.setAttribute('data-quality', String(sc));
372
+ q.resize(sc);
373
+ };
374
+ if (auto)
375
+ this.onCleanup(watchPowerSaver((saver) => ((gov.saver = saver), gov.onScale?.(gov.scale))));
222
376
  let visible = false;
223
377
  const loop = () => {
224
- this.frame();
378
+ if (!auto || gov.tick(base.now()))
379
+ this.frame();
225
380
  this._id = base.raf(loop);
226
381
  };
227
382
  const sync = () => {
@@ -232,7 +387,7 @@ function make(kind) {
232
387
  };
233
388
  this.inView((v) => ((visible = v), sync()));
234
389
  this.listen(document, 'visibilitychange', sync);
235
- this.listen(window, 'resize', () => q.resize(), { passive: true });
390
+ this.listen(window, 'resize', () => q.resize(this._scale), { passive: true });
236
391
  this.onCleanup(() => base.caf(this._id));
237
392
  }
238
393
  };
@@ -260,6 +415,16 @@ function defineDistort(tag = 'usa-distort') {
260
415
  function defineLiquid(tag = 'usa-liquid') {
261
416
  return base.defineElement(tag, make('liquid'), { id: 'webgl', text: css });
262
417
  }
418
+ /**
419
+ * `<usa-post-fx effects="vignette grain crt" intensity="0.6">` — GPU
420
+ * post-processing over the `<img>` inside (4.8): `vignette` · `grain` ·
421
+ * `chromatic` · `scanlines` · `crt` · `bloom` · `pixelate` · `duotone` ·
422
+ * `glitch`, chained in order. `quality="high"` disables adaptive quality.
423
+ * Fallback: the image with an approximate CSS filter.
424
+ */
425
+ function definePostFx(tag = 'usa-post-fx') {
426
+ return base.defineElement(tag, make('post'), { id: 'webgl', text: css });
427
+ }
263
428
 
264
429
  /**
265
430
  * use-scroll-animate/components/webgl — lightweight canvas / WebGL (v3.4).
@@ -272,16 +437,25 @@ function defineWebglComponents() {
272
437
  defineShader();
273
438
  defineDistort();
274
439
  defineLiquid();
440
+ definePostFx();
275
441
  }
276
442
 
277
443
  exports.configureComponents = base.configureComponents;
278
444
  exports.prefersReducedMotion = base.prefersReducedMotion;
445
+ exports.GL_FALLBACKS = GL_FALLBACKS;
446
+ exports.PARTICLE_PRESETS = PARTICLE_PRESETS;
447
+ exports.POST_EFFECTS = POST_EFFECTS;
279
448
  exports.SHADERS = SHADERS;
280
449
  exports.defineDistort = defineDistort;
281
450
  exports.defineLiquid = defineLiquid;
451
+ exports.definePostFx = definePostFx;
282
452
  exports.defineShader = defineShader;
283
453
  exports.defineWebglComponents = defineWebglComponents;
284
454
  exports.fragmentSource = fragmentSource;
455
+ exports.glFallbackCss = glFallbackCss;
456
+ exports.glGovernor = glGovernor;
285
457
  exports.glQuad = glQuad;
458
+ exports.postFxShader = postFxShader;
286
459
  exports.supportsWebGL = supportsWebGL;
460
+ exports.watchPowerSaver = watchPowerSaver;
287
461
  //# sourceMappingURL=webgl.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"webgl.cjs","sources":["../../src/components/webgl/gl.ts","../../src/components/webgl/elements.ts","../../src/components/webgl/index.ts"],"sourcesContent":["/** Minimal WebGL runner: one full-canvas quad, one fragment shader, optional image texture. */\n\nexport const VERTEX = 'attribute vec2 p;varying vec2 v_uv;void main(){v_uv=p*.5+.5;gl_Position=vec4(p,0.,1.);}';\nconst HEAD = 'precision mediump float;varying vec2 v_uv;uniform float u_time;uniform vec2 u_resolution;uniform vec2 u_mouse;uniform float u_hover;uniform sampler2D u_tex;uniform vec4 u_ripples[4];\\n';\n\n/** 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). */\nexport const SHADERS: Record<string, string> = {\n gradient: 'void main(){vec2 u=v_uv;float t=u_time*.15;vec3 a=vec3(.39,.4,.95),b=vec3(.93,.29,.6),c=vec3(.13,.83,.93);float k=.5+.5*sin(u.x*3.+t*2.)*cos(u.y*2.-t);vec3 col=mix(mix(a,b,u.x+.2*sin(t)),c,k*.6);gl_FragColor=vec4(col,1.);}',\n plasma: 'void main(){vec2 u=v_uv*4.;float t=u_time*.6;float v=sin(u.x+t)+sin(u.y+t*.7)+sin(u.x+u.y+t*.5)+sin(length(u-2.+vec2(sin(t),cos(t)))*2.);vec3 col=.5+.5*cos(v+vec3(0.,2.,4.));gl_FragColor=vec4(col,1.);}',\n waves: 'void main(){vec2 u=v_uv;float t=u_time*.4;float w=0.;for(int i=0;i<4;i++){float f=float(i)+1.;w+=sin(u.x*6.*f+t*f)*.08/f;}float l=smoothstep(.0,.02,abs(u.y-.5-w));vec3 col=mix(vec3(.2,.5,1.),vec3(.04,.06,.15),l)+vec3(.1,.0,.2)*u.y;gl_FragColor=vec4(col,1.);}',\n aurora: 'void main(){vec2 u=v_uv;float t=u_time*.2;float b=0.;for(int i=0;i<3;i++){float f=float(i);b+=.4/abs((u.y-.6+.15*sin(u.x*3.+t+f*1.7))*(8.+f*4.));}vec3 col=vec3(.02,.03,.08)+b*mix(vec3(.1,.9,.6),vec3(.6,.3,1.),u.x)*.35;gl_FragColor=vec4(col,1.);}',\n distort: 'void main(){vec2 u=v_uv;vec2 d=u-u_mouse;float r=length(d);float k=u_hover*.08*exp(-r*r*18.);u-=normalize(d+1e-4)*k;float s=u_hover*.006;vec3 col=vec3(texture2D(u_tex,u+vec2(s,0.)).r,texture2D(u_tex,u).g,texture2D(u_tex,u-vec2(s,0.)).b);gl_FragColor=vec4(col,1.);}',\n liquid: 'void main(){vec2 u=v_uv;vec2 o=vec2(0.);for(int i=0;i<4;i++){vec4 r=u_ripples[i];if(r.w>0.){float d=distance(u,r.xy);float w=sin(d*60.-r.z*12.)*exp(-d*6.)*exp(-r.z*1.6)*r.w*.02;o+=normalize(u-r.xy+1e-4)*w;}}o+=vec2(sin(u.y*10.+u_time),cos(u.x*10.+u_time))*.002*u_hover;gl_FragColor=texture2D(u_tex,u+o);}',\n};\n\n/** Full fragment source for a preset or custom body (adds the shared header). */\nexport function fragmentSource(body: string): string {\n const src = SHADERS[body] || body;\n return /precision\\s+\\w+\\s+float/.test(src) ? src : HEAD + src;\n}\n\n/** `true` when the browser can create a WebGL context (cached). */\nlet support: boolean | undefined;\nexport function supportsWebGL(): boolean {\n if (support !== undefined) return support;\n try {\n const c = typeof document !== 'undefined' ? document.createElement('canvas') : null;\n support = !!(c && (c.getContext('webgl') || c.getContext('experimental-webgl')));\n } catch {\n support = false;\n }\n return support;\n}\n\nexport interface GLQuad {\n /** Draw a frame with these uniform values. */\n render(u: { time?: number; mouse?: [number, number]; hover?: number; ripples?: number[] }): void;\n /** Resize the drawing buffer to the canvas' CSS size × DPR (≤ 2). */\n resize(): void;\n /** Upload an image as `u_tex`. */\n texture(img: TexImageSource): void;\n dispose(): void;\n}\n\n/** Compile `frag` on a full-canvas quad, or `null` when WebGL / compilation is unavailable. */\nexport function glQuad(canvas: HTMLCanvasElement, frag: string): GLQuad | null {\n let gl: WebGLRenderingContext | null = null;\n try {\n gl = (canvas.getContext('webgl', { premultipliedAlpha: false, antialias: false }) || canvas.getContext('experimental-webgl')) as WebGLRenderingContext | null;\n } catch {\n gl = null;\n }\n if (!gl) return null;\n const g = gl;\n const sh = (type: number, src: string) => {\n const s = g.createShader(type)!;\n g.shaderSource(s, src);\n g.compileShader(s);\n return g.getShaderParameter(s, g.COMPILE_STATUS) ? s : null;\n };\n const vs = sh(g.VERTEX_SHADER, VERTEX);\n const fs = sh(g.FRAGMENT_SHADER, fragmentSource(frag));\n if (!vs || !fs) return null;\n const prog = g.createProgram()!;\n g.attachShader(prog, vs);\n g.attachShader(prog, fs);\n g.linkProgram(prog);\n if (!g.getProgramParameter(prog, g.LINK_STATUS)) return null;\n g.useProgram(prog);\n const buf = g.createBuffer();\n g.bindBuffer(g.ARRAY_BUFFER, buf);\n g.bufferData(g.ARRAY_BUFFER, new Float32Array([-1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, 1]), g.STATIC_DRAW);\n const loc = g.getAttribLocation(prog, 'p');\n g.enableVertexAttribArray(loc);\n g.vertexAttribPointer(loc, 2, g.FLOAT, false, 0, 0);\n const U = (n: string) => g.getUniformLocation(prog, n);\n const uT = U('u_time'), uR = U('u_resolution'), uM = U('u_mouse'), uH = U('u_hover'), uRp = U('u_ripples');\n let tex: WebGLTexture | null = null;\n const quad: GLQuad = {\n resize() {\n const dpr = Math.min(2, (typeof devicePixelRatio === 'number' && devicePixelRatio) || 1);\n const w = Math.max(1, Math.round((canvas.clientWidth || 300) * dpr));\n const h = Math.max(1, Math.round((canvas.clientHeight || 150) * dpr));\n if (canvas.width !== w || canvas.height !== h) ((canvas.width = w), (canvas.height = h));\n g.viewport(0, 0, w, h);\n },\n texture(img) {\n tex = tex || g.createTexture();\n g.bindTexture(g.TEXTURE_2D, tex);\n g.pixelStorei(g.UNPACK_FLIP_Y_WEBGL, true);\n g.texParameteri(g.TEXTURE_2D, g.TEXTURE_WRAP_S, g.CLAMP_TO_EDGE);\n g.texParameteri(g.TEXTURE_2D, g.TEXTURE_WRAP_T, g.CLAMP_TO_EDGE);\n g.texParameteri(g.TEXTURE_2D, g.TEXTURE_MIN_FILTER, g.LINEAR);\n g.texImage2D(g.TEXTURE_2D, 0, g.RGBA, g.RGBA, g.UNSIGNED_BYTE, img);\n },\n render(u) {\n g.uniform1f(uT, u.time ?? 0);\n g.uniform2f(uR, canvas.width, canvas.height);\n g.uniform2f(uM, ...(u.mouse ?? [0.5, 0.5]));\n g.uniform1f(uH, u.hover ?? 0);\n if (uRp) g.uniform4fv(uRp, new Float32Array((u.ripples ?? []).concat(Array(16).fill(0)).slice(0, 16)));\n g.drawArrays(g.TRIANGLES, 0, 6);\n },\n dispose() {\n g.deleteProgram(prog);\n g.deleteBuffer(buf);\n if (tex) g.deleteTexture(tex);\n g.getExtension('WEBGL_lose_context')?.loseContext();\n },\n };\n quad.resize();\n return quad;\n}\n","import { defineElement, raf, caf, now, clamp, type UsaElement, getBase } from '../base';\n\ntype BaseCtor = ReturnType<typeof getBase>;\nimport { glQuad, type GLQuad } from './gl';\nimport css from './webgl.css?raw';\n\n/**\n * Shared shell for the WebGL elements: a canvas over (or behind) the\n * content that renders only while visible and the tab is shown, a DPR cap\n * of 2, and a graceful fallback (`data-fallback`) when WebGL, the shader\n * or the image (CORS) is unavailable — the original content / CSS stays.\n */\nexport interface UsaGLElement extends UsaElement {\n /** `true` once WebGL rendering is active (otherwise the CSS fallback shows). */\n readonly active: boolean;\n}\n\ntype Kind = 'shader' | 'distort' | 'liquid';\n\nfunction make(kind: Kind) {\n return (Base: BaseCtor): CustomElementConstructor =>\n class extends Base {\n static get observedAttributes(): string[] {\n return kind === 'shader' ? ['preset', 'speed'] : ['src'];\n }\n private _q: GLQuad | null = null;\n private _c: HTMLCanvasElement | null = null;\n private _id = 0;\n private _mouse: [number, number] = [0.5, 0.5];\n private _hover = 0;\n private _hoverTo = 0;\n private _ripples: { x: number; y: number; t: number }[] = [];\n\n get active(): boolean {\n return !!this._q;\n }\n\n private fallback(reason: string): void {\n this.setAttribute('data-fallback', reason);\n this._c?.remove();\n this._c = null;\n this._q?.dispose();\n this._q = null;\n }\n\n private frame(): void {\n const q = this._q;\n if (!q) return;\n this._hover += (this._hoverTo - this._hover) * 0.12;\n const t = now();\n this._ripples = this._ripples.filter((r) => t - r.t < 2500);\n q.render({\n time: (t / 1000) * this.num('speed', 1),\n mouse: this._mouse,\n hover: this._hover,\n ripples: this._ripples.flatMap((r) => [r.x, r.y, (t - r.t) / 1000, this.num('strength', 1)]),\n });\n }\n\n mount(): void {\n this.removeAttribute('data-fallback');\n const custom = this.querySelector('script[type=\"x-shader/x-fragment\"]');\n const frag = kind === 'shader' ? custom?.textContent || this.str('preset', 'gradient') : kind;\n const img = kind === 'shader' ? null : (this.querySelector('img') as HTMLImageElement | null);\n if (kind !== 'shader' && !img) return this.fallback('no-image');\n const c = (this._c = document.createElement('canvas'));\n c.setAttribute('aria-hidden', 'true');\n c.className = 'usa-gl';\n this.prepend(c);\n const q = (this._q = glQuad(c, frag));\n if (!q) return this.fallback('webgl');\n this.onCleanup(() => this.fallback('off'));\n const start = () => {\n if (!img) return true;\n try {\n q.texture(img);\n return true;\n } catch {\n this.fallback('image');\n return false;\n }\n };\n const draw = () => {\n q.resize();\n this.frame();\n };\n if (img && !(img.complete && img.naturalWidth)) {\n if (!img.crossOrigin && /^https?:/.test(img.src) && !img.src.startsWith(location.origin)) img.crossOrigin = 'anonymous';\n this.listen(img, 'load', () => start() && draw());\n this.listen(img, 'error', () => this.fallback('image'));\n } else if (!start()) return;\n this.setAttribute('data-active', '');\n this.onCleanup(() => this.removeAttribute('data-active'));\n draw();\n if (kind !== 'shader') {\n const pos = (e: PointerEvent) => {\n const r = this.getBoundingClientRect();\n this._mouse = [clamp((e.clientX - r.left) / (r.width || 1), 0, 1), clamp(1 - (e.clientY - r.top) / (r.height || 1), 0, 1)];\n };\n this.listen(this, 'pointermove', pos);\n this.listen(this, 'pointerenter', (e: PointerEvent) => (pos(e), (this._hoverTo = 1)));\n this.listen(this, 'pointerleave', () => (this._hoverTo = 0));\n if (kind === 'liquid')\n this.listen(this, 'pointerdown', (e: PointerEvent) => {\n pos(e);\n this._ripples = [...this._ripples.slice(-3), { x: this._mouse[0], y: this._mouse[1], t: now() }];\n });\n }\n // 4.0.1: also follow the element's own size (grid reflow, card expand…)\n if (typeof ResizeObserver !== 'undefined') {\n const ro = new ResizeObserver(() => {\n q.resize();\n if (!this._id) this.frame();\n });\n ro.observe(this);\n this.onCleanup(() => ro.disconnect());\n }\n if (this.reduced) return; // one static frame, no loop\n let visible = false;\n const loop = () => {\n this.frame();\n this._id = raf(loop);\n };\n const sync = () => {\n caf(this._id);\n this._id = 0;\n if (visible && !document.hidden) this._id = raf(loop);\n };\n this.inView((v: boolean) => ((visible = v), sync()));\n this.listen(document, 'visibilitychange', sync);\n this.listen(window, 'resize', () => q.resize(), { passive: true });\n this.onCleanup(() => caf(this._id));\n }\n };\n}\n\n/**\n * `<usa-shader>` — GPU shader background behind its content. `preset`\n * (`gradient` · `plasma` · `waves` · `aurora`) or your own fragment shader in\n * `<script type=\"x-shader/x-fragment\">` (uniforms `u_time`, `u_resolution`,\n * `u_mouse`, `v_uv`); `speed`. Without WebGL: the element's CSS background.\n */\nexport function defineShader(tag = 'usa-shader'): CustomElementConstructor | undefined {\n return defineElement(tag, make('shader'), { id: 'webgl', text: css });\n}\n\n/**\n * `<usa-distort>` — hover distortion + RGB split on the `<img>` inside,\n * following the pointer. Without WebGL / CORS: a gentle CSS zoom.\n */\nexport function defineDistort(tag = 'usa-distort'): CustomElementConstructor | undefined {\n return defineElement(tag, make('distort'), { id: 'webgl', text: css });\n}\n\n/**\n * `<usa-liquid>` — liquid image: clicks / taps send ripples through the\n * `<img>` inside, hover adds a gentle wobble; `strength`. Fallback: plain image.\n */\nexport function defineLiquid(tag = 'usa-liquid'): CustomElementConstructor | undefined {\n return defineElement(tag, make('liquid'), { id: 'webgl', text: css });\n}\n","/**\n * use-scroll-animate/components/webgl — lightweight canvas / WebGL (v3.4).\n * `<usa-shader>` (shader backgrounds), `<usa-distort>` (hover image\n * distortion), `<usa-liquid>` (ripple images) on a tiny single-quad runner\n * (`glQuad()`), with graceful fallbacks when WebGL is unavailable.\n */\nimport { defineShader, defineDistort, defineLiquid, type UsaGLElement } from './elements';\n\nexport { defineShader, defineDistort, defineLiquid };\nexport { glQuad, supportsWebGL, fragmentSource, SHADERS } from './gl';\nexport type { GLQuad } from './gl';\nexport type { UsaGLElement };\nexport { configureComponents, prefersReducedMotion } from '../base';\nexport type { ComponentsConfig, UsaElement } from '../base';\n\n/** Register every component of this category under its default tag. */\nexport function defineWebglComponents(): void {\n defineShader();\n defineDistort();\n defineLiquid();\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'usa-shader': UsaGLElement;\n 'usa-distort': UsaGLElement;\n 'usa-liquid': UsaGLElement;\n }\n}\n"],"names":["now","clamp","raf","caf","defineElement"],"mappings":";;;;AAAA;AAEO,MAAM,MAAM,GAAG,yFAAyF;AAC/G,MAAM,IAAI,GAAG,0LAA0L;AAEvM;AACO,MAAM,OAAO,GAA2B;AAC7C,IAA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O,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC;AACvE;AAEA;;;AAGG;AACG,SAAU,aAAa,CAAC,GAAG,GAAG,aAAa,EAAA;AAC/C,IAAA,OAAOA,kBAAa,CAAC,GAAG,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC;AACxE;AAEA;;;AAGG;AACG,SAAU,YAAY,CAAC,GAAG,GAAG,YAAY,EAAA;AAC7C,IAAA,OAAOA,kBAAa,CAAC,GAAG,EAAE,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC;AACvE;;AChKA;;;;;AAKG;AAUH;SACgB,qBAAqB,GAAA;AACnC,IAAA,YAAY,EAAE;AACd,IAAA,aAAa,EAAE;AACf,IAAA,YAAY,EAAE;AAChB;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"webgl.cjs","sources":["../../src/components/webgl/gl.ts","../../src/components/webgl/presets.ts","../../src/components/webgl/elements.ts","../../src/components/webgl/index.ts"],"sourcesContent":["/** Minimal WebGL runner: one full-canvas quad, one fragment shader, optional image texture. */\n\nexport const VERTEX = 'attribute vec2 p;varying vec2 v_uv;void main(){v_uv=p*.5+.5;gl_Position=vec4(p,0.,1.);}';\nconst HEAD = 'precision mediump float;varying vec2 v_uv;uniform float u_time;uniform vec2 u_resolution;uniform vec2 u_mouse;uniform float u_hover;uniform sampler2D u_tex;uniform vec4 u_ripples[4];\\n';\n\n/** 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). */\nexport const SHADERS: Record<string, string> = {\n gradient: 'void main(){vec2 u=v_uv;float t=u_time*.15;vec3 a=vec3(.39,.4,.95),b=vec3(.93,.29,.6),c=vec3(.13,.83,.93);float k=.5+.5*sin(u.x*3.+t*2.)*cos(u.y*2.-t);vec3 col=mix(mix(a,b,u.x+.2*sin(t)),c,k*.6);gl_FragColor=vec4(col,1.);}',\n plasma: 'void main(){vec2 u=v_uv*4.;float t=u_time*.6;float v=sin(u.x+t)+sin(u.y+t*.7)+sin(u.x+u.y+t*.5)+sin(length(u-2.+vec2(sin(t),cos(t)))*2.);vec3 col=.5+.5*cos(v+vec3(0.,2.,4.));gl_FragColor=vec4(col,1.);}',\n waves: 'void main(){vec2 u=v_uv;float t=u_time*.4;float w=0.;for(int i=0;i<4;i++){float f=float(i)+1.;w+=sin(u.x*6.*f+t*f)*.08/f;}float l=smoothstep(.0,.02,abs(u.y-.5-w));vec3 col=mix(vec3(.2,.5,1.),vec3(.04,.06,.15),l)+vec3(.1,.0,.2)*u.y;gl_FragColor=vec4(col,1.);}',\n aurora: 'void main(){vec2 u=v_uv;float t=u_time*.2;float b=0.;for(int i=0;i<3;i++){float f=float(i);b+=.4/abs((u.y-.6+.15*sin(u.x*3.+t+f*1.7))*(8.+f*4.));}vec3 col=vec3(.02,.03,.08)+b*mix(vec3(.1,.9,.6),vec3(.6,.3,1.),u.x)*.35;gl_FragColor=vec4(col,1.);}',\n distort: 'void main(){vec2 u=v_uv;vec2 d=u-u_mouse;float r=length(d);float k=u_hover*.08*exp(-r*r*18.);u-=normalize(d+1e-4)*k;float s=u_hover*.006;vec3 col=vec3(texture2D(u_tex,u+vec2(s,0.)).r,texture2D(u_tex,u).g,texture2D(u_tex,u-vec2(s,0.)).b);gl_FragColor=vec4(col,1.);}',\n // 4.8 particle presets (procedural, one quad: no buffers, no per-particle JS)\n snow: 'float h(vec2 p){return fract(sin(dot(p,vec2(127.1,311.7)))*43758.5453);}void main(){vec2 u=v_uv;u.x*=u_resolution.x/max(u_resolution.y,1.);vec3 col=mix(vec3(.05,.08,.16),vec3(.12,.16,.3),v_uv.y);for(int l=0;l<3;l++){float s=8.+float(l)*7.;vec2 q=u*s;q.y+=u_time*(.6+float(l)*.35);q.x+=sin(q.y*.7+float(l))*.3;vec2 id=floor(q);vec2 f=fract(q)-.5;float r=h(id);if(r>.6){vec2 o=vec2(h(id+3.)-.5,h(id+7.)-.5)*.6;float d=length(f-o);col+=smoothstep(.09-float(l)*.02,0.,d)*(.5+.5*r);}}gl_FragColor=vec4(col,1.);}',\n fireflies: 'float h(vec2 p){return fract(sin(dot(p,vec2(127.1,311.7)))*43758.5453);}void main(){vec2 u=v_uv;u.x*=u_resolution.x/max(u_resolution.y,1.);vec3 col=vec3(.02,.04,.03);for(int l=0;l<2;l++){vec2 q=u*(5.+float(l)*4.);vec2 id=floor(q);vec2 f=fract(q)-.5;float r=h(id+float(l)*13.);vec2 o=.35*vec2(sin(u_time*(.4+r)+r*6.28),cos(u_time*(.3+r)+r*12.));float d=length(f-o);float tw=.5+.5*sin(u_time*3.*r+r*20.);col+=vec3(1.,.85,.3)*smoothstep(.12,0.,d)*tw*step(.45,r);}gl_FragColor=vec4(col,1.);}',\n stars: 'float h(vec2 p){return fract(sin(dot(p,vec2(127.1,311.7)))*43758.5453);}void main(){vec2 c=v_uv-.5;c.x*=u_resolution.x/max(u_resolution.y,1.);vec3 col=vec3(.01,.01,.04);for(int l=0;l<4;l++){float z=fract(float(l)*.25+u_time*.05);float sc=mix(20.,.5,z);vec2 q=c*sc+float(l)*7.;vec2 id=floor(q);vec2 f=fract(q)-.5;float r=h(id);float d=length(f-(vec2(h(id+1.),h(id+2.))-.5)*.7);col+=vec3(.8,.9,1.)*smoothstep(.06,0.,d)*step(.8,r)*smoothstep(0.,.5,z)*smoothstep(1.,.8,z)*2.;}gl_FragColor=vec4(col,1.);}',\n bokeh: 'float h(vec2 p){return fract(sin(dot(p,vec2(127.1,311.7)))*43758.5453);}void main(){vec2 u=v_uv;u.x*=u_resolution.x/max(u_resolution.y,1.);vec3 col=mix(vec3(.08,.03,.12),vec3(.02,.05,.12),v_uv.y);for(int l=0;l<3;l++){vec2 q=u*(2.5+float(l)*1.5);q.y-=u_time*.05*(1.+float(l));vec2 id=floor(q);vec2 f=fract(q)-.5;float r=h(id+float(l)*5.);float d=length(f-(vec2(h(id+4.),h(id+9.))-.5)*.5);vec3 tint=.5+.5*cos(r*6.28+vec3(0.,2.,4.));col+=tint*smoothstep(.3,.26,d)*.18*step(.35,r);}gl_FragColor=vec4(col,1.);}',\n rain: 'float h(float n){return fract(sin(n)*43758.5453);}void main(){vec2 u=v_uv;vec3 col=mix(vec3(.04,.06,.1),vec3(.1,.13,.2),u.y);float n=floor(u.x*120.);float sp=.8+h(n)*1.2;float y=fract(u.y+u_time*sp+h(n+1.));float drop=smoothstep(.0,.08,y)*smoothstep(.16,.08,y)*step(.7,h(n+2.));col+=vec3(.5,.6,.8)*drop*.6;gl_FragColor=vec4(col,1.);}',\n liquid: 'void main(){vec2 u=v_uv;vec2 o=vec2(0.);for(int i=0;i<4;i++){vec4 r=u_ripples[i];if(r.w>0.){float d=distance(u,r.xy);float w=sin(d*60.-r.z*12.)*exp(-d*6.)*exp(-r.z*1.6)*r.w*.02;o+=normalize(u-r.xy+1e-4)*w;}}o+=vec2(sin(u.y*10.+u_time),cos(u.x*10.+u_time))*.002*u_hover;gl_FragColor=texture2D(u_tex,u+o);}',\n};\n\n/** Full fragment source for a preset or custom body (adds the shared header). */\nexport function fragmentSource(body: string): string {\n const src = SHADERS[body] || body;\n return /precision\\s+\\w+\\s+float/.test(src) ? src : HEAD + src;\n}\n\n/** `true` when the browser can create a WebGL context (cached). */\nlet support: boolean | undefined;\nexport function supportsWebGL(): boolean {\n if (support !== undefined) return support;\n try {\n const c = typeof document !== 'undefined' ? document.createElement('canvas') : null;\n support = !!(c && (c.getContext('webgl') || c.getContext('experimental-webgl')));\n } catch {\n support = false;\n }\n return support;\n}\n\nexport interface GLQuad {\n /** Draw a frame with these uniform values (`extra`: any other float uniforms by name, 4.8). */\n render(u: { time?: number; mouse?: [number, number]; hover?: number; ripples?: number[]; extra?: Record<string, number> }): void;\n /** Resize the drawing buffer to the canvas' CSS size × DPR (≤ 2) × `scale` (4.8 adaptive quality). */\n resize(scale?: number): void;\n /** Upload an image as `u_tex`. */\n texture(img: TexImageSource): void;\n dispose(): void;\n}\n\n/** Compile `frag` on a full-canvas quad, or `null` when WebGL / compilation is unavailable. */\nexport function glQuad(canvas: HTMLCanvasElement, frag: string): GLQuad | null {\n let gl: WebGLRenderingContext | null = null;\n try {\n gl = (canvas.getContext('webgl', { premultipliedAlpha: false, antialias: false }) || canvas.getContext('experimental-webgl')) as WebGLRenderingContext | null;\n } catch {\n gl = null;\n }\n if (!gl) return null;\n const g = gl;\n const sh = (type: number, src: string) => {\n const s = g.createShader(type)!;\n g.shaderSource(s, src);\n g.compileShader(s);\n return g.getShaderParameter(s, g.COMPILE_STATUS) ? s : null;\n };\n const vs = sh(g.VERTEX_SHADER, VERTEX);\n const fs = sh(g.FRAGMENT_SHADER, fragmentSource(frag));\n if (!vs || !fs) return null;\n const prog = g.createProgram()!;\n g.attachShader(prog, vs);\n g.attachShader(prog, fs);\n g.linkProgram(prog);\n if (!g.getProgramParameter(prog, g.LINK_STATUS)) return null;\n g.useProgram(prog);\n const buf = g.createBuffer();\n g.bindBuffer(g.ARRAY_BUFFER, buf);\n g.bufferData(g.ARRAY_BUFFER, new Float32Array([-1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, 1]), g.STATIC_DRAW);\n const loc = g.getAttribLocation(prog, 'p');\n g.enableVertexAttribArray(loc);\n g.vertexAttribPointer(loc, 2, g.FLOAT, false, 0, 0);\n const U = (n: string) => g.getUniformLocation(prog, n);\n const uT = U('u_time'), uR = U('u_resolution'), uM = U('u_mouse'), uH = U('u_hover'), uRp = U('u_ripples');\n let tex: WebGLTexture | null = null;\n const extraLoc: Record<string, WebGLUniformLocation | null> = {};\n const quad: GLQuad = {\n resize(scale = 1) {\n const dpr = Math.min(2, (typeof devicePixelRatio === 'number' && devicePixelRatio) || 1) * Math.min(1, Math.max(0.25, scale));\n const w = Math.max(1, Math.round((canvas.clientWidth || 300) * dpr));\n const h = Math.max(1, Math.round((canvas.clientHeight || 150) * dpr));\n if (canvas.width !== w || canvas.height !== h) ((canvas.width = w), (canvas.height = h));\n g.viewport(0, 0, w, h);\n },\n texture(img) {\n tex = tex || g.createTexture();\n g.bindTexture(g.TEXTURE_2D, tex);\n g.pixelStorei(g.UNPACK_FLIP_Y_WEBGL, true);\n g.texParameteri(g.TEXTURE_2D, g.TEXTURE_WRAP_S, g.CLAMP_TO_EDGE);\n g.texParameteri(g.TEXTURE_2D, g.TEXTURE_WRAP_T, g.CLAMP_TO_EDGE);\n g.texParameteri(g.TEXTURE_2D, g.TEXTURE_MIN_FILTER, g.LINEAR);\n g.texImage2D(g.TEXTURE_2D, 0, g.RGBA, g.RGBA, g.UNSIGNED_BYTE, img);\n },\n render(u) {\n g.uniform1f(uT, u.time ?? 0);\n g.uniform2f(uR, canvas.width, canvas.height);\n g.uniform2f(uM, ...(u.mouse ?? [0.5, 0.5]));\n g.uniform1f(uH, u.hover ?? 0);\n if (uRp) g.uniform4fv(uRp, new Float32Array((u.ripples ?? []).concat(Array(16).fill(0)).slice(0, 16)));\n if (u.extra) for (const [k, v] of Object.entries(u.extra)) g.uniform1f((extraLoc[k] ??= U(k)), v);\n g.drawArrays(g.TRIANGLES, 0, 6);\n },\n dispose() {\n g.deleteProgram(prog);\n g.deleteBuffer(buf);\n if (tex) g.deleteTexture(tex);\n g.getExtension('WEBGL_lose_context')?.loseContext();\n },\n };\n quad.resize();\n return quad;\n}\n","/**\n * 4.8 — WebGL preset library on `glQuad()`: particle presets (`snow`,\n * `fireflies`, `stars`, `bokeh`, `rain` — usable as `<usa-shader preset>`),\n * chainable post-processing passes for images (`<usa-post-fx>`), one CSS\n * fallback per preset, and an adaptive quality governor (fps + battery).\n */\nexport const PARTICLE_PRESETS = ['snow', 'fireflies', 'stars', 'bokeh', 'rain'] as const;\nexport type ParticlePreset = (typeof PARTICLE_PRESETS)[number];\n\n/** Post-processing passes: `vec3 fx(vec3 c, vec2 uv)` bodies, applied in order. `u_intensity` 0–1. */\nexport const POST_EFFECTS: Record<string, string> = {\n vignette: 'c*=mix(1.,smoothstep(.85,.25,length(uv-.5)),u_intensity);',\n grain: 'c+=(fract(sin(dot(uv*u_resolution+u_time,vec2(12.9898,78.233)))*43758.5453)-.5)*.18*u_intensity;',\n chromatic: 'float s=.008*u_intensity;c=vec3(texture2D(u_tex,uv+vec2(s,0.)).r,c.g,texture2D(u_tex,uv-vec2(s,0.)).b);',\n scanlines: 'c*=1.-.25*u_intensity*step(.5,fract(uv.y*u_resolution.y*.5));',\n crt: 'vec2 d=uv-.5;float r=dot(d,d);c*=1.-.6*u_intensity*r;c*=.92+.08*sin(uv.y*u_resolution.y*3.14159);c.r*=1.+.05*u_intensity;',\n bloom: 'vec3 b=vec3(0.);for(int i=0;i<8;i++){float a=float(i)*.785;b+=max(texture2D(u_tex,uv+vec2(cos(a),sin(a))*.012).rgb-.6,0.);}c+=b*.35*u_intensity;',\n pixelate: 'float px=mix(1.,48.,u_intensity);vec2 g=floor(uv*u_resolution/px)*px/u_resolution;c=texture2D(u_tex,g+.5*px/u_resolution).rgb;',\n duotone: 'float l=dot(c,vec3(.299,.587,.114));c=mix(c,mix(vec3(.12,.05,.35),vec3(1.,.55,.4),l),u_intensity);',\n glitch: 'float k=step(.97,fract(sin(floor(uv.y*24.)+floor(u_time*6.))*4375.5));c=mix(c,texture2D(u_tex,uv+vec2(k*.04*u_intensity,0.)).rgb,k);',\n};\nexport type PostEffect = keyof typeof POST_EFFECTS;\n\n/** One fragment shader running the passes in order over `u_tex` (pixel-sampling passes read the source). */\nexport function postFxShader(effects: string[]): string {\n const list = effects.filter((e) => POST_EFFECTS[e]);\n const body = list.map((e) => `{${POST_EFFECTS[e]}}`).join('');\n return `uniform float u_intensity;void main(){vec2 uv=v_uv;vec3 c=texture2D(u_tex,uv).rgb;${body}gl_FragColor=vec4(clamp(c,0.,1.),1.);}`;\n}\n\n/** The unified CSS fallback (no WebGL / reduced data): a still background or image filter per preset. */\nexport const GL_FALLBACKS: Record<string, string> = {\n gradient: 'linear-gradient(120deg,#6366f1,#ec4899 50%,#22d3ee)',\n plasma: 'conic-gradient(from 90deg,#f43f5e,#a855f7,#06b6d4,#f43f5e)',\n waves: 'linear-gradient(#0a0f26,#1e3a8a)',\n aurora: 'radial-gradient(120% 60% at 30% 40%,#10b98155,transparent),radial-gradient(100% 50% at 70% 50%,#8b5cf655,transparent),#05070f',\n snow: 'radial-gradient(2px 2px at 20% 30%,#fff,transparent),radial-gradient(2px 2px at 70% 60%,#fff,transparent),radial-gradient(1.5px 1.5px at 40% 80%,#fff,transparent),linear-gradient(#0d1428,#1f2a4d)',\n fireflies: 'radial-gradient(3px 3px at 25% 40%,#fde68a,transparent),radial-gradient(3px 3px at 65% 70%,#fde68a,transparent),#05090a',\n stars: 'radial-gradient(1px 1px at 10% 20%,#fff,transparent),radial-gradient(1px 1px at 80% 30%,#fff,transparent),radial-gradient(1.5px 1.5px at 50% 70%,#cfe0ff,transparent),#02020a',\n bokeh: 'radial-gradient(40px 40px at 30% 40%,#f472b633,transparent),radial-gradient(60px 60px at 70% 60%,#60a5fa33,transparent),#140820',\n rain: 'repeating-linear-gradient(100deg,#ffffff10 0 1px,transparent 1px 14px),linear-gradient(#0a0f1a,#1a2133)',\n // post-fx fallbacks are CSS filters on the <img>\n 'post:duotone': 'grayscale(1) sepia(.6) hue-rotate(220deg) saturate(2)',\n 'post:vignette': 'brightness(.95) contrast(1.05)',\n 'post:crt': 'contrast(1.15) saturate(1.2)',\n 'post:bloom': 'brightness(1.08) saturate(1.15)',\n};\n\n/** CSS fallback for a shader preset / post effect list. */\nexport function glFallbackCss(preset: string, post = false): string {\n if (post) return preset.split(/\\s+/).map((e) => GL_FALLBACKS[`post:${e}`]).filter(Boolean).join(' ');\n return GL_FALLBACKS[preset] || GL_FALLBACKS.gradient;\n}\n\nexport interface GLGovernorOptions {\n /** Below this fps quality drops (default 40). */\n minFps?: number;\n /** Frame-rate cap on battery saver / low battery (default 30). */\n saverFps?: number;\n}\n\nexport interface GLGovernor {\n /** Feed a frame time (ms); returns `true` when this frame should render. */\n tick(t: number): boolean;\n /** Current resolution scale (1 → 0.5 → 0.35). */\n readonly scale: number;\n /** Measured fps over the last second. */\n readonly fps: number;\n /** Battery saver / low battery: renders at `saverFps` and scale ≤ 0.6. */\n saver: boolean;\n /** Called when `scale` changes (resize the canvas). */\n onScale?: (scale: number) => void;\n}\n\n/**\n * Adaptive quality for GL loops: measures fps, steps the resolution scale\n * down (1 → 0.5 → 0.35) after two slow seconds and back up after five good\n * ones, and caps the frame rate in battery-saver mode. Pure — feed it times.\n */\nexport function glGovernor(options: GLGovernorOptions = {}): GLGovernor {\n const { minFps = 40, saverFps = 30 } = options;\n const STEPS = [1, 0.5, 0.35];\n let step = 0;\n let frames = 0;\n let winStart = -1;\n let last = -Infinity;\n let slow = 0;\n let good = 0;\n let fps = 60;\n const g: GLGovernor = {\n saver: false,\n get scale() {\n return Math.min(STEPS[step], g.saver ? 0.6 : 1);\n },\n get fps() {\n return fps;\n },\n tick(t: number) {\n if (winStart < 0) winStart = t;\n if (g.saver && t - last < 1000 / saverFps - 1) return false;\n last = t;\n frames++;\n if (t - winStart >= 1000) {\n fps = Math.round((frames * 1000) / (t - winStart));\n frames = 0;\n winStart = t;\n const before = g.scale;\n if (fps < minFps && !g.saver) {\n good = 0;\n if (++slow >= 2 && step < STEPS.length - 1) ((step++), (slow = 0));\n } else {\n slow = 0;\n if (++good >= 5 && step > 0) ((step--), (good = 0));\n }\n if (g.scale !== before) g.onScale?.(g.scale);\n }\n return true;\n },\n };\n return g;\n}\n\n/** Watch the Battery Status API (where available) and Save-Data; calls `cb(true)` in saver conditions. Returns a stop function. */\nexport function watchPowerSaver(cb: (saver: boolean) => void): () => void {\n let stopped = false;\n const nav = (typeof navigator !== 'undefined' ? navigator : {}) as any;\n const saveData = !!nav.connection?.saveData;\n if (saveData) cb(true);\n if (typeof nav.getBattery !== 'function') return () => undefined;\n let battery: any = null;\n const update = () => !stopped && cb(saveData || (!!battery && !battery.charging && battery.level <= 0.2));\n nav.getBattery().then((b: any) => {\n battery = b;\n update();\n b.addEventListener?.('levelchange', update);\n b.addEventListener?.('chargingchange', update);\n }, () => undefined);\n return () => {\n stopped = true;\n battery?.removeEventListener?.('levelchange', update);\n battery?.removeEventListener?.('chargingchange', update);\n };\n}\n","import { defineElement, raf, caf, now, clamp, type UsaElement, getBase } from '../base';\n\ntype BaseCtor = ReturnType<typeof getBase>;\nimport { glQuad, type GLQuad } from './gl';\nimport { postFxShader, glFallbackCss, glGovernor, watchPowerSaver } from './presets';\nimport css from './webgl.css?raw';\n\n/**\n * Shared shell for the WebGL elements: a canvas over (or behind) the\n * content that renders only while visible and the tab is shown, a DPR cap\n * of 2, and a graceful fallback (`data-fallback`) when WebGL, the shader\n * or the image (CORS) is unavailable — the original content / CSS stays.\n */\nexport interface UsaGLElement extends UsaElement {\n /** `true` once WebGL rendering is active (otherwise the CSS fallback shows). */\n readonly active: boolean;\n}\n\ntype Kind = 'shader' | 'distort' | 'liquid' | 'post';\n\nfunction make(kind: Kind) {\n return (Base: BaseCtor): CustomElementConstructor =>\n class extends Base {\n static get observedAttributes(): string[] {\n return kind === 'shader' ? ['preset', 'speed', 'quality'] : kind === 'post' ? ['effects', 'intensity', 'quality'] : ['src'];\n }\n private _q: GLQuad | null = null;\n private _c: HTMLCanvasElement | null = null;\n private _id = 0;\n private _mouse: [number, number] = [0.5, 0.5];\n private _hover = 0;\n private _hoverTo = 0;\n private _ripples: { x: number; y: number; t: number }[] = [];\n\n get active(): boolean {\n return !!this._q;\n }\n\n private _scale = 1;\n\n private fallback(reason: string): void {\n this.setAttribute('data-fallback', reason);\n // 4.8 unified fallback: a still CSS rendering of the preset / effects\n if (reason !== 'off') {\n if (kind === 'shader') this.style.setProperty('--usa-gl-fallback', glFallbackCss(this.str('preset', 'gradient')));\n if (kind === 'post') this.style.setProperty('--usa-gl-filter', glFallbackCss(this.str('effects', 'vignette grain'), true) || 'none');\n }\n this._c?.remove();\n this._c = null;\n this._q?.dispose();\n this._q = null;\n }\n\n private frame(): void {\n const q = this._q;\n if (!q) return;\n this._hover += (this._hoverTo - this._hover) * 0.12;\n const t = now();\n this._ripples = this._ripples.filter((r) => t - r.t < 2500);\n q.render({\n time: (t / 1000) * this.num('speed', 1),\n mouse: this._mouse,\n hover: this._hover,\n ripples: this._ripples.flatMap((r) => [r.x, r.y, (t - r.t) / 1000, this.num('strength', 1)]),\n extra: kind === 'post' ? { u_intensity: clamp(this.num('intensity', 0.6), 0, 1) } : undefined,\n });\n }\n\n mount(): void {\n this.removeAttribute('data-fallback');\n const custom = this.querySelector('script[type=\"x-shader/x-fragment\"]');\n const frag = kind === 'shader' ? custom?.textContent || this.str('preset', 'gradient') : kind === 'post' ? postFxShader(this.str('effects', 'vignette grain').split(/[\\s,]+/)) : kind;\n const img = kind === 'shader' ? null : (this.querySelector('img') as HTMLImageElement | null);\n if (kind !== 'shader' && !img) return this.fallback('no-image');\n const c = (this._c = document.createElement('canvas'));\n c.setAttribute('aria-hidden', 'true');\n c.className = 'usa-gl';\n this.prepend(c);\n const q = (this._q = glQuad(c, frag));\n if (!q) return this.fallback('webgl');\n this.onCleanup(() => this.fallback('off'));\n const start = () => {\n if (!img) return true;\n try {\n q.texture(img);\n return true;\n } catch {\n this.fallback('image');\n return false;\n }\n };\n const draw = () => {\n q.resize(this._scale);\n this.frame();\n };\n if (img && !(img.complete && img.naturalWidth)) {\n if (!img.crossOrigin && /^https?:/.test(img.src) && !img.src.startsWith(location.origin)) img.crossOrigin = 'anonymous';\n this.listen(img, 'load', () => start() && draw());\n this.listen(img, 'error', () => this.fallback('image'));\n } else if (!start()) return;\n this.setAttribute('data-active', '');\n this.onCleanup(() => this.removeAttribute('data-active'));\n draw();\n if (kind === 'distort' || kind === 'liquid') {\n const pos = (e: PointerEvent) => {\n const r = this.getBoundingClientRect();\n this._mouse = [clamp((e.clientX - r.left) / (r.width || 1), 0, 1), clamp(1 - (e.clientY - r.top) / (r.height || 1), 0, 1)];\n };\n this.listen(this, 'pointermove', pos);\n this.listen(this, 'pointerenter', (e: PointerEvent) => (pos(e), (this._hoverTo = 1)));\n this.listen(this, 'pointerleave', () => (this._hoverTo = 0));\n if (kind === 'liquid')\n this.listen(this, 'pointerdown', (e: PointerEvent) => {\n pos(e);\n this._ripples = [...this._ripples.slice(-3), { x: this._mouse[0], y: this._mouse[1], t: now() }];\n });\n }\n // 4.0.1: also follow the element's own size (grid reflow, card expand…)\n if (typeof ResizeObserver !== 'undefined') {\n const ro = new ResizeObserver(() => {\n q.resize(this._scale);\n if (!this._id) this.frame();\n });\n ro.observe(this);\n this.onCleanup(() => ro.disconnect());\n }\n if (this.reduced) return; // one static frame, no loop\n // 4.8 adaptive quality: fps-driven resolution steps + battery saver frame cap\n const gov = glGovernor();\n const auto = this.str('quality', 'auto') !== 'high';\n gov.onScale = (sc) => {\n this._scale = sc;\n this.setAttribute('data-quality', String(sc));\n q.resize(sc);\n };\n if (auto) this.onCleanup(watchPowerSaver((saver) => ((gov.saver = saver), gov.onScale?.(gov.scale))));\n let visible = false;\n const loop = () => {\n if (!auto || gov.tick(now())) this.frame();\n this._id = raf(loop);\n };\n const sync = () => {\n caf(this._id);\n this._id = 0;\n if (visible && !document.hidden) this._id = raf(loop);\n };\n this.inView((v: boolean) => ((visible = v), sync()));\n this.listen(document, 'visibilitychange', sync);\n this.listen(window, 'resize', () => q.resize(this._scale), { passive: true });\n this.onCleanup(() => caf(this._id));\n }\n };\n}\n\n/**\n * `<usa-shader>` — GPU shader background behind its content. `preset`\n * (`gradient` · `plasma` · `waves` · `aurora`) or your own fragment shader in\n * `<script type=\"x-shader/x-fragment\">` (uniforms `u_time`, `u_resolution`,\n * `u_mouse`, `v_uv`); `speed`. Without WebGL: the element's CSS background.\n */\nexport function defineShader(tag = 'usa-shader'): CustomElementConstructor | undefined {\n return defineElement(tag, make('shader'), { id: 'webgl', text: css });\n}\n\n/**\n * `<usa-distort>` — hover distortion + RGB split on the `<img>` inside,\n * following the pointer. Without WebGL / CORS: a gentle CSS zoom.\n */\nexport function defineDistort(tag = 'usa-distort'): CustomElementConstructor | undefined {\n return defineElement(tag, make('distort'), { id: 'webgl', text: css });\n}\n\n/**\n * `<usa-liquid>` — liquid image: clicks / taps send ripples through the\n * `<img>` inside, hover adds a gentle wobble; `strength`. Fallback: plain image.\n */\nexport function defineLiquid(tag = 'usa-liquid'): CustomElementConstructor | undefined {\n return defineElement(tag, make('liquid'), { id: 'webgl', text: css });\n}\n\n/**\n * `<usa-post-fx effects=\"vignette grain crt\" intensity=\"0.6\">` — GPU\n * post-processing over the `<img>` inside (4.8): `vignette` · `grain` ·\n * `chromatic` · `scanlines` · `crt` · `bloom` · `pixelate` · `duotone` ·\n * `glitch`, chained in order. `quality=\"high\"` disables adaptive quality.\n * Fallback: the image with an approximate CSS filter.\n */\nexport function definePostFx(tag = 'usa-post-fx'): CustomElementConstructor | undefined {\n return defineElement(tag, make('post'), { id: 'webgl', text: css });\n}\n","/**\n * use-scroll-animate/components/webgl — lightweight canvas / WebGL (v3.4).\n * `<usa-shader>` (shader backgrounds), `<usa-distort>` (hover image\n * distortion), `<usa-liquid>` (ripple images) on a tiny single-quad runner\n * (`glQuad()`), with graceful fallbacks when WebGL is unavailable.\n */\nimport { defineShader, defineDistort, defineLiquid, definePostFx, type UsaGLElement } from './elements';\n\nexport { defineShader, defineDistort, defineLiquid, definePostFx };\nexport { PARTICLE_PRESETS, POST_EFFECTS, postFxShader, GL_FALLBACKS, glFallbackCss, glGovernor, watchPowerSaver } from './presets';\nexport type { ParticlePreset, PostEffect, GLGovernor, GLGovernorOptions } from './presets';\nexport { glQuad, supportsWebGL, fragmentSource, SHADERS } from './gl';\nexport type { GLQuad } from './gl';\nexport type { UsaGLElement };\nexport { configureComponents, prefersReducedMotion } from '../base';\nexport type { ComponentsConfig, UsaElement } from '../base';\n\n/** Register every component of this category under its default tag. */\nexport function defineWebglComponents(): void {\n defineShader();\n defineDistort();\n defineLiquid();\n definePostFx();\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'usa-shader': UsaGLElement;\n 'usa-distort': UsaGLElement;\n 'usa-liquid': UsaGLElement;\n 'usa-post-fx': UsaGLElement;\n }\n}\n"],"names":["now","clamp","raf","caf","defineElement"],"mappings":";;;;AAAA;AAEO,MAAM,MAAM,GAAG,yFAAyF;AAC/G,MAAM,IAAI,GAAG,0LAA0L;AAEvM;AACO,MAAM,OAAO,GAA2B;AAC7C,IAAA,QAAQ,EAAE,gOAAgO;AAC1O,IAAA,MAAM,EAAE,2MAA2M;AACnN,IAAA,KAAK,EAAE,oQAAoQ;AAC3Q,IAAA,MAAM,EAAE,uPAAuP;AAC/P,IAAA,OAAO,EAAE,0QAA0Q;;AAEnR,IAAA,IAAI,EAAE,4fAA4f;AAClgB,IAAA,SAAS,EAAE,yeAAye;AACpf,IAAA,KAAK,EAAE,qfAAqf;AAC5f,IAAA,KAAK,EAAE,2fAA2f;AAClgB,IAAA,IAAI,EAAE,+UAA+U;AACrV,IAAA,MAAM,EAAE,kTAAkT;;AAG5T;AACM,SAAU,cAAc,CAAC,IAAY,EAAA;IACzC,MAAM,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,IAAI;AACjC,IAAA,OAAO,yBAAyB,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,GAAG,GAAG,IAAI,GAAG,GAAG;AAC/D;AAEA;AACA,IAAI,OAA4B;SAChB,aAAa,GAAA;IAC3B,IAAI,OAAO,KAAK,SAAS;AAAE,QAAA,OAAO,OAAO;AACzC,IAAA,IAAI;AACF,QAAA,MAAM,CAAC,GAAG,OAAO,QAAQ,KAAK,WAAW,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,GAAG,IAAI;QACnF,OAAO,GAAG,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC,oBAAoB,CAAC,CAAC,CAAC;IAClF;AAAE,IA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I,EAAE,GAAG,EAAE,CAAC;AACvE;AAEA;;;;;;AAMG;AACG,SAAU,YAAY,CAAC,GAAG,GAAG,aAAa,EAAA;AAC9C,IAAA,OAAOA,kBAAa,CAAC,GAAG,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC;AACrE;;AC7LA;;;;;AAKG;AAYH;SACgB,qBAAqB,GAAA;AACnC,IAAA,YAAY,EAAE;AACd,IAAA,aAAa,EAAE;AACf,IAAA,YAAY,EAAE;AACd,IAAA,YAAY,EAAE;AAChB;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,3 +1,3 @@
1
1
  /* use-scroll-animate/components/webgl */
2
2
  .usa-sr{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0 0 0 0);clip-path:inset(50%);white-space:nowrap;border:0}
3
- usa-shader,usa-distort,usa-liquid{display:block;position:relative;isolation:isolate;overflow:hidden}usa-shader{background:linear-gradient(120deg,#6366f1,#ec4899 50%,#22d3ee)}usa-shader>canvas.usa-gl{position:absolute;inset:0;width:100%;height:100%;z-index:-1;display:block}usa-distort>canvas.usa-gl,usa-liquid>canvas.usa-gl{position:absolute;inset:0;width:100%;height:100%;display:block;pointer-events:none}usa-distort>img,usa-liquid>img{display:block;width:100%;height:auto}usa-distort[data-active]>img,usa-liquid[data-active]>img{visibility:hidden}usa-distort[data-fallback]>img{transition:transform 0.6s cubic-bezier(0.22,1,0.36,1),filter 0.6s}usa-distort[data-fallback]:hover>img{transform:scale(1.04);filter:saturate(1.2)}@media (prefers-reduced-motion:reduce){usa-distort[data-fallback]:hover>img{transform:none}}
3
+ usa-shader,usa-distort,usa-liquid,usa-post-fx{display:block;position:relative;isolation:isolate;overflow:hidden}usa-shader{background:linear-gradient(120deg,#6366f1,#ec4899 50%,#22d3ee)}usa-shader>canvas.usa-gl{position:absolute;inset:0;width:100%;height:100%;z-index:-1;display:block}usa-distort>canvas.usa-gl,usa-liquid>canvas.usa-gl{position:absolute;inset:0;width:100%;height:100%;display:block;pointer-events:none}usa-distort>img,usa-liquid>img{display:block;width:100%;height:auto}usa-distort[data-active]>img,usa-liquid[data-active]>img{visibility:hidden}usa-distort[data-fallback]>img{transition:transform 0.6s cubic-bezier(0.22,1,0.36,1),filter 0.6s}usa-distort[data-fallback]:hover>img{transform:scale(1.04);filter:saturate(1.2)}@media (prefers-reduced-motion:reduce){usa-distort[data-fallback]:hover>img{transform:none}}usa-shader[data-fallback]{background:var(--usa-gl-fallback,linear-gradient(120deg,#6366f1,#ec4899 50%,#22d3ee))}usa-post-fx>canvas.usa-gl{position:absolute;inset:0;width:100%;height:100%;display:block;pointer-events:none}usa-post-fx>img{display:block;width:100%;height:auto}usa-post-fx[data-active]>img{visibility:hidden}usa-post-fx[data-fallback]>img{filter:var(--usa-gl-filter,none)}
@@ -80,6 +80,58 @@ declare function defineDistort(tag?: string): CustomElementConstructor | undefin
80
80
  * `<img>` inside, hover adds a gentle wobble; `strength`. Fallback: plain image.
81
81
  */
82
82
  declare function defineLiquid(tag?: string): CustomElementConstructor | undefined;
83
+ /**
84
+ * `<usa-post-fx effects="vignette grain crt" intensity="0.6">` — GPU
85
+ * post-processing over the `<img>` inside (4.8): `vignette` · `grain` ·
86
+ * `chromatic` · `scanlines` · `crt` · `bloom` · `pixelate` · `duotone` ·
87
+ * `glitch`, chained in order. `quality="high"` disables adaptive quality.
88
+ * Fallback: the image with an approximate CSS filter.
89
+ */
90
+ declare function definePostFx(tag?: string): CustomElementConstructor | undefined;
91
+
92
+ /**
93
+ * 4.8 — WebGL preset library on `glQuad()`: particle presets (`snow`,
94
+ * `fireflies`, `stars`, `bokeh`, `rain` — usable as `<usa-shader preset>`),
95
+ * chainable post-processing passes for images (`<usa-post-fx>`), one CSS
96
+ * fallback per preset, and an adaptive quality governor (fps + battery).
97
+ */
98
+ declare const PARTICLE_PRESETS: readonly ["snow", "fireflies", "stars", "bokeh", "rain"];
99
+ type ParticlePreset = (typeof PARTICLE_PRESETS)[number];
100
+ /** Post-processing passes: `vec3 fx(vec3 c, vec2 uv)` bodies, applied in order. `u_intensity` 0–1. */
101
+ declare const POST_EFFECTS: Record<string, string>;
102
+ type PostEffect = keyof typeof POST_EFFECTS;
103
+ /** One fragment shader running the passes in order over `u_tex` (pixel-sampling passes read the source). */
104
+ declare function postFxShader(effects: string[]): string;
105
+ /** The unified CSS fallback (no WebGL / reduced data): a still background or image filter per preset. */
106
+ declare const GL_FALLBACKS: Record<string, string>;
107
+ /** CSS fallback for a shader preset / post effect list. */
108
+ declare function glFallbackCss(preset: string, post?: boolean): string;
109
+ interface GLGovernorOptions {
110
+ /** Below this fps quality drops (default 40). */
111
+ minFps?: number;
112
+ /** Frame-rate cap on battery saver / low battery (default 30). */
113
+ saverFps?: number;
114
+ }
115
+ interface GLGovernor {
116
+ /** Feed a frame time (ms); returns `true` when this frame should render. */
117
+ tick(t: number): boolean;
118
+ /** Current resolution scale (1 → 0.5 → 0.35). */
119
+ readonly scale: number;
120
+ /** Measured fps over the last second. */
121
+ readonly fps: number;
122
+ /** Battery saver / low battery: renders at `saverFps` and scale ≤ 0.6. */
123
+ saver: boolean;
124
+ /** Called when `scale` changes (resize the canvas). */
125
+ onScale?: (scale: number) => void;
126
+ }
127
+ /**
128
+ * Adaptive quality for GL loops: measures fps, steps the resolution scale
129
+ * down (1 → 0.5 → 0.35) after two slow seconds and back up after five good
130
+ * ones, and caps the frame rate in battery-saver mode. Pure — feed it times.
131
+ */
132
+ declare function glGovernor(options?: GLGovernorOptions): GLGovernor;
133
+ /** Watch the Battery Status API (where available) and Save-Data; calls `cb(true)` in saver conditions. Returns a stop function. */
134
+ declare function watchPowerSaver(cb: (saver: boolean) => void): () => void;
83
135
 
84
136
  /** 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). */
85
137
  declare const SHADERS: Record<string, string>;
@@ -87,15 +139,16 @@ declare const SHADERS: Record<string, string>;
87
139
  declare function fragmentSource(body: string): string;
88
140
  declare function supportsWebGL(): boolean;
89
141
  interface GLQuad {
90
- /** Draw a frame with these uniform values. */
142
+ /** Draw a frame with these uniform values (`extra`: any other float uniforms by name, 4.8). */
91
143
  render(u: {
92
144
  time?: number;
93
145
  mouse?: [number, number];
94
146
  hover?: number;
95
147
  ripples?: number[];
148
+ extra?: Record<string, number>;
96
149
  }): void;
97
- /** Resize the drawing buffer to the canvas' CSS size × DPR (≤ 2). */
98
- resize(): void;
150
+ /** Resize the drawing buffer to the canvas' CSS size × DPR (≤ 2) × `scale` (4.8 adaptive quality). */
151
+ resize(scale?: number): void;
99
152
  /** Upload an image as `u_tex`. */
100
153
  texture(img: TexImageSource): void;
101
154
  dispose(): void;
@@ -117,8 +170,9 @@ declare global {
117
170
  'usa-shader': UsaGLElement;
118
171
  'usa-distort': UsaGLElement;
119
172
  'usa-liquid': UsaGLElement;
173
+ 'usa-post-fx': UsaGLElement;
120
174
  }
121
175
  }
122
176
 
123
- export { SHADERS, configureComponents, defineDistort, defineLiquid, defineShader, defineWebglComponents, fragmentSource, glQuad, prefersReducedMotion, supportsWebGL };
124
- export type { ComponentsConfig, GLQuad, UsaElement, UsaGLElement };
177
+ export { GL_FALLBACKS, PARTICLE_PRESETS, POST_EFFECTS, SHADERS, configureComponents, defineDistort, defineLiquid, definePostFx, defineShader, defineWebglComponents, fragmentSource, glFallbackCss, glGovernor, glQuad, postFxShader, prefersReducedMotion, supportsWebGL, watchPowerSaver };
178
+ export type { ComponentsConfig, GLGovernor, GLGovernorOptions, GLQuad, ParticlePreset, PostEffect, UsaElement, UsaGLElement };