@votax572002/fluxfx 0.1.0 → 0.1.1
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/dist/fluxfx.min.js +20 -15
- package/dist/index.cjs +20 -15
- package/dist/index.js +22 -17
- package/dist/react.cjs +23 -18
- package/dist/react.js +20 -15
- package/package.json +11 -20
package/dist/react.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
"use client";import w,{useEffect as he,useRef as O}from"react";var V=class{constructor(){this.listeners=new Set;this.rafId=null;this.startTime=0;this.lastTime=0;this.isDocumentHidden=!1;this.handleVisibilityChange=()=>{this.isDocumentHidden=document.hidden,this.isDocumentHidden?this.stopLoop():this.listeners.size>0&&(this.lastTime=0,this.startLoop())};this.tick=e=>{if(this.listeners.size===0||this.isDocumentHidden){this.stopLoop();return}this.startTime===0&&(this.startTime=e);let i=this.lastTime===0?16.67:Math.min(e-this.lastTime,100);this.lastTime=e;let t=(e-this.startTime)*.001,r=i*.001;this.listeners.forEach(s=>{s(t,r,e)}),this.rafId=window.requestAnimationFrame(this.tick)};typeof document<"u"&&document.addEventListener("visibilitychange",this.handleVisibilityChange)}startLoop(){this.rafId!==null||typeof window>"u"||this.isDocumentHidden||(this.lastTime=0,this.rafId=window.requestAnimationFrame(this.tick))}stopLoop(){this.rafId!==null&&typeof window<"u"&&(window.cancelAnimationFrame(this.rafId),this.rafId=null)}add(e){return this.listeners.add(e),this.listeners.size===1&&this.startLoop(),()=>this.remove(e)}remove(e){this.listeners.delete(e),this.listeners.size===0&&this.stopLoop()}get activeCount(){return this.listeners.size}get isRunning(){return this.rafId!==null}},
|
|
2
|
+
"use client";import w,{useEffect as he,useRef as O}from"react";var V=class{constructor(){this.listeners=new Set;this.rafId=null;this.startTime=0;this.lastTime=0;this.isDocumentHidden=!1;this.handleVisibilityChange=()=>{this.isDocumentHidden=document.hidden,this.isDocumentHidden?this.stopLoop():this.listeners.size>0&&(this.lastTime=0,this.startLoop())};this.tick=e=>{if(this.listeners.size===0||this.isDocumentHidden){this.stopLoop();return}this.startTime===0&&(this.startTime=e);let i=this.lastTime===0?16.67:Math.min(e-this.lastTime,100);this.lastTime=e;let t=(e-this.startTime)*.001,r=i*.001;this.listeners.forEach(s=>{s(t,r,e)}),this.rafId=window.requestAnimationFrame(this.tick)};typeof document<"u"&&document.addEventListener("visibilitychange",this.handleVisibilityChange)}startLoop(){this.rafId!==null||typeof window>"u"||this.isDocumentHidden||(this.lastTime=0,this.rafId=window.requestAnimationFrame(this.tick))}stopLoop(){this.rafId!==null&&typeof window<"u"&&(window.cancelAnimationFrame(this.rafId),this.rafId=null)}add(e){return this.listeners.add(e),this.listeners.size===1&&this.startLoop(),()=>this.remove(e)}remove(e){this.listeners.delete(e),this.listeners.size===0&&this.stopLoop()}get activeCount(){return this.listeners.size}get isRunning(){return this.rafId!==null}},B=new V;var g=class{static acquireVec2(e=0,i=0){let t=this.vec2Pool.pop()??new Float32Array(2);return t[0]=e,t[1]=i,t}static releaseVec2(e){this.vec2Pool.length<128&&this.vec2Pool.push(e)}static acquireVec3(e=0,i=0,t=0){let r=this.vec3Pool.pop()??new Float32Array(3);return r[0]=e,r[1]=i,r[2]=t,r}static releaseVec3(e){this.vec3Pool.length<128&&this.vec3Pool.push(e)}static acquireVec4(e=0,i=0,t=0,r=1){let s=this.vec4Pool.pop()??new Float32Array(4);return s[0]=e,s[1]=i,s[2]=t,s[3]=r,s}static releaseVec4(e){this.vec4Pool.length<128&&this.vec4Pool.push(e)}static hexToVec3Into(e,i){let t=e.charCodeAt(0)===35?e.slice(1):e;if(t.length===3){let s=parseInt(t[0],16),a=parseInt(t[1],16),n=parseInt(t[2],16);return i[0]=(s<<4|s)/255,i[1]=(a<<4|a)/255,i[2]=(n<<4|n)/255,i}let r=parseInt(t,16);return Number.isNaN(r)?(i[0]=1,i[1]=1,i[2]=1,i):(i[0]=(r>>16&255)/255,i[1]=(r>>8&255)/255,i[2]=(r&255)/255,i)}};g.vec2Pool=[],g.vec3Pool=[],g.vec4Pool=[],g.scratchVec2=new Float32Array(2),g.scratchVec3=new Float32Array(3),g.scratchVec4=new Float32Array(4);var D=class{constructor(e){this.samples=new Float32Array(30);this.sampleIdx=0;this.sampleCount=0;this.stableUpWindows=0;this.lastAdjustAt=0;this.minScale=Math.max(.5,e.minScale),this.maxScale=Math.max(this.minScale,e.maxScale),this.currentScale=this.maxScale,this.downThresholdMs=e.downThresholdMs??20.5,this.upThresholdMs=e.upThresholdMs??17.2,this.cooldownMs=e.cooldownMs??750}get scale(){return this.currentScale}setBounds(e,i){let t=Math.max(.5,e),r=Math.max(t,i),s=this.currentScale;return this.minScale=t,this.maxScale=r,this.currentScale=Math.min(r,Math.max(t,this.currentScale)),r>s&&(this.currentScale=r),this.sampleCount=0,this.sampleIdx=0,this.stableUpWindows=0,Math.abs(this.currentScale-s)>.01}recordFrame(e,i){if(this.minScale>=this.maxScale||e<=0||e>60)return!1;if(this.samples[this.sampleIdx]=e,this.sampleIdx=(this.sampleIdx+1)%this.samples.length,this.sampleCount<this.samples.length)return this.sampleCount++,!1;if(i-this.lastAdjustAt<this.cooldownMs)return!1;let t=0;for(let s=0;s<this.samples.length;s++)t+=this.samples[s];let r=t/this.samples.length;if(r>this.downThresholdMs&&this.currentScale>this.minScale)return this.currentScale=Math.max(this.minScale,Number((this.currentScale-.15).toFixed(2))),this.stableUpWindows=0,this.lastAdjustAt=i,!0;if(r<this.upThresholdMs&&this.currentScale<this.maxScale){if(this.stableUpWindows++,this.stableUpWindows>=2)return this.currentScale=Math.min(this.maxScale,Number((this.currentScale+.1).toFixed(2))),this.stableUpWindows=0,this.lastAdjustAt=i,!0}else this.stableUpWindows=0;return!1}};var T=null;function c(o,e="#ffffff"){if(typeof o!="string")return e;let i=o.trim();if(!i)return e;if(typeof document<"u"){if(!T){let t=document.createElement("canvas");t.width=1,t.height=1,T=t.getContext("2d")}if(T){T.fillStyle="#010203",T.fillStyle=i;let t=T.fillStyle;if(/^#[0-9a-f]{6}$/i.test(t))return t;let r=t.match(/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/i);if(r)return"#"+[Number(r[1]),Number(r[2]),Number(r[3])].map(s=>Math.max(0,Math.min(255,s)).toString(16).padStart(2,"0")).join("")}}return e}var P=`#version 300 es
|
|
3
3
|
precision highp float;
|
|
4
4
|
layout(location = 0) in vec2 aPosition;
|
|
5
5
|
out vec2 vUv;
|
|
@@ -677,7 +677,7 @@ self.onmessage = function(e) {
|
|
|
677
677
|
break;
|
|
678
678
|
}
|
|
679
679
|
};
|
|
680
|
-
`,B=null;function N(){if(typeof window>"u"||typeof Worker>"u"||typeof OffscreenCanvas>"u"||typeof HTMLCanvasElement>"u"||!("transferControlToOffscreen"in HTMLCanvasElement.prototype))return!1;let o=typeof navigator<"u"?navigator.userAgent:"";return!(/iP(ad|hone|od)/i.test(o)||/^((?!chrome|android).)*safari/i.test(o))}function q(){if(!B){let o=new Blob([pe],{type:"application/javascript"});B=URL.createObjectURL(o)}return new Worker(B)}var Q=P;var C={low:{max:1,min:.65,retinaMin:.85,fboMaxDim:512},medium:{max:2,min:.75,retinaMin:1,fboMaxDim:896},high:{max:2,min:1,retinaMin:1.25,fboMaxDim:1152}},ve=new Float32Array([-1,-1,3,-1,-1,3]),ge=12;function k(o,e){return 1-Math.exp(-o*e)}var R=class R{constructor(e,i){this.resizeObserver=null;this.visibilityObserver=null;this.reducedMotionQuery=null;this.dprMediaQuery=null;this.worker=null;this.isOffscreen=!1;this.gl=null;this.programEntry=null;this.feedbackProgramEntry=null;this.vao=null;this.vbo=null;this.dynamicRes=null;this.lastRenderNow=0;this.elapsedSec=0;this.lastDeltaSec=.01667;this.currentSpeed=1;this.targetSpeed=1;this.needsResize=!1;this.pingPong=null;this.fboW=1;this.fboH=1;this.fboFormat=0;this.fboType=0;this.readIdx=0;this.writeIdx=1;this.customUniforms=new Map;this.mouse=g.acquireVec2(.5,.5);this.targetMouse=g.acquireVec2(.5,.5);this.mouseVel=g.acquireVec2(0,0);this.mouseDown=0;this.mouseActive=0;this.targetMouseActive=0;this.isPointerInside=!1;this.scroll=0;this.targetScroll=0;this.scrollVel=0;this.hasScrollListener=!1;this.width=1;this.height=1;this.isPaused=!1;this.isHiddenByViewport=!1;this.isContextLost=!1;this.isReducedMotion=!1;this.isDestroyed=!1;this.hasPointerListener=!1;this.countedContext=!1;this.handleContextLost=e=>{e.preventDefault(),this.isContextLost=!0,this.lastRenderNow=0,this.gl&&v.disposeContext(this.gl),this.programEntry=null,this.feedbackProgramEntry=null,this.pingPong=null,this.vao=null,this.vbo=null};this.handleContextRestored=()=>{if(!(this.isDestroyed||!this.gl))try{this.isContextLost=!1,this.initMainThreadPipeline(this.gl),this.drawMainThreadFrame()}catch(e){console.error("[FluxFX] Failed to restore WebGL2 context:",e)}};this.handleDprChange=()=>{this.isDestroyed||(this.syncDprBounds(),this.watchDevicePixelRatio())};this.handleReducedMotionChange=e=>{this.applyReducedMotionState(this.respectReducedMotion&&e.matches)};this.handlePointerEnter=e=>{if(this.isPaused||this.isHiddenByViewport||this.isReducedMotion)return;let i=this.getLocalPointerCoords(e);if(!i)return;let[t,r]=i;this.isPointerInside=!0,this.targetMouseActive=1,this.isOffscreen&&this.worker?this.worker.postMessage({type:"mouseEnter",x:t,y:r}):(this.mouse[0]=t,this.mouse[1]=r,this.targetMouse[0]=t,this.targetMouse[1]=r,this.mouseVel[0]=0,this.mouseVel[1]=0)};this.handlePointerMove=e=>{if(this.isPaused||this.isHiddenByViewport||this.isReducedMotion)return;let i=this.getLocalPointerCoords(e);if(!i){this.isPointerInside&&this.handlePointerLeave();return}let[t,r]=i;if(!this.isPointerInside){this.handlePointerEnter(e);return}this.isOffscreen&&this.worker?this.worker.postMessage({type:"mouse",x:t,y:r}):(this.targetMouse[0]=t,this.targetMouse[1]=r)};this.handlePointerLeave=()=>{!this.isPointerInside&&this.targetMouseActive===0||(this.isPointerInside=!1,this.targetMouseActive=0,this.mouseDown=0,this.mouseVel[0]=0,this.mouseVel[1]=0,this.isOffscreen&&this.worker&&this.worker.postMessage({type:"mouseLeave"}))};this.handlePointerDown=e=>{this.isPaused||this.isHiddenByViewport||this.isReducedMotion||(this.isPointerInside||this.handlePointerEnter(e),this.mouseDown=1,this.isOffscreen&&this.worker&&this.worker.postMessage({type:"mouseDown",down:!0}))};this.handlePointerUp=()=>{this.mouseDown!==0&&(this.mouseDown=0,this.isOffscreen&&this.worker&&this.worker.postMessage({type:"mouseDown",down:!1}))};this.handleScroll=()=>{if(!this.trackScroll||this.isDestroyed)return;let e=this.computeScrollProgress();this.isOffscreen&&this.worker?this.worker.postMessage({type:"scroll",progress:e}):(this.targetScroll=e,this.isReducedMotion&&!this.isPaused&&!this.isHiddenByViewport&&(this.scroll=e,this.scrollVel=0,this.drawMainThreadFrame()))};this.handleDocVisibility=()=>{!this.isOffscreen||!this.worker||(document.hidden?this.worker.postMessage({type:"pause"}):!this.isPaused&&!this.isHiddenByViewport&&this.worker.postMessage({type:"resume"}))};this.container=e,this.options={...i},this.interactive=i.interactive??!0,this.respectReducedMotion=i.respectReducedMotion??!0,this.trackScroll=i.trackScroll??!1,this.feedbackScale=i.feedbackScale??.5,this.feedbackFloat=i.feedbackFloat??!0;let t=i.quality??"medium",r=C[t]??C.medium;this.feedbackMaxDim=i.feedbackMaxDim??r.fboMaxDim,typeof window<"u"&&typeof window.matchMedia=="function"&&(this.reducedMotionQuery=window.matchMedia("(prefers-reduced-motion: reduce)"),this.isReducedMotion=this.respectReducedMotion&&this.reducedMotionQuery.matches),window.getComputedStyle(this.container).position==="static"&&(this.container.style.position="relative"),this.container.style.isolation="isolate",this.canvas=document.createElement("canvas"),this.canvas.setAttribute("data-fluxfx-canvas","true"),this.canvas.style.position="absolute",this.canvas.style.inset="0",this.canvas.style.width="100%",this.canvas.style.height="100%",this.canvas.style.zIndex="-1",this.canvas.style.pointerEvents="none",this.canvas.style.display="block",this.container.prepend(this.canvas);let a=this.container.getBoundingClientRect();if(this.width=Math.max(1,Math.floor(a.width)),this.height=Math.max(1,Math.floor(a.height)),this.trackScroll){let f=this.computeScrollProgress();this.scroll=f,this.targetScroll=f}let{minDpr:n,maxDpr:l}=this.resolveDprBounds(),u=i.dynamicResolution??!0,d=i.offscreen??!0;this.seedUniformsFromOptions(i,!0),d&&N()?this.initOffscreenMode(i,n,l,u):this.initMainThreadMode(i,n,l,u),this.bindObservers(i.pauseWhenHidden??!0)}static get activeContexts(){return this._activeContexts}resolveDprBounds(){let e=this.options.quality??"medium",i=C[e]??C.medium,t=typeof window<"u"&&window.devicePixelRatio||1,r=t>=1.5,s=this.options.maxDpr??Math.min(t,i.max),a=r?i.retinaMin:i.min;return{minDpr:this.options.minDpr??Math.min(a,s),maxDpr:s}}computeScrollProgress(){if(typeof window>"u")return 0;let e=this.container.getBoundingClientRect(),i=window.innerHeight||1,t=i+e.height;return t<=0?0:Math.min(1,Math.max(0,(i-e.top)/t))}markContextActive(){this.countedContext||(this.countedContext=!0,R._activeContexts++,R._activeContexts>ge&&console.warn(`[FluxFX] ${R._activeContexts} active WebGL contexts detected. Browsers typically cap contexts around 8\u201316; consider limiting simultaneous WebGL backgrounds.`))}markContextReleased(){this.countedContext&&(this.countedContext=!1,R._activeContexts=Math.max(0,R._activeContexts-1))}seedUniformsFromOptions(e,i=!1){let t={};if(typeof e.speed=="number"?(this.targetSpeed=e.speed,i&&(this.currentSpeed=e.speed),this.customUniforms.set("uSpeed",e.speed),t.uSpeed=e.speed):this.customUniforms.has("uSpeed")||(this.targetSpeed=1,this.currentSpeed=1,this.customUniforms.set("uSpeed",1),t.uSpeed=1),e.colors&&e.colors.length>0){let r=Array.isArray(e.colors)?e.colors:String(e.colors).split(",").map(n=>n.trim()).filter(Boolean),s=c(r[0],"#ffffff"),a=Math.min(r.length,3);for(let n=0;n<a;n++){let l=c(r[n],s),u=g.hexToVec3Into(l,g.scratchVec3),d=[u[0],u[1],u[2]];this.customUniforms.set(`uColor${n+1}`,d),t[`uColor${n+1}`]=d}if(a===1){let n=this.customUniforms.get("uColor1");this.customUniforms.set("uColor2",[n[0],n[1],n[2]]),t.uColor2=[n[0],n[1],n[2]]}}if(e.uniforms)for(let[r,s]of Object.entries(e.uniforms))this.customUniforms.set(r,s),t[r]=typeof s=="number"?s:Array.from(s);return t}fallbackToMainThread(e,i,t,r){if(this.isDestroyed)return;this.worker&&(this.worker.terminate(),this.worker=null),this.isOffscreen=!1,this.markContextReleased();let s=this.canvas.cloneNode(!1);this.canvas.replaceWith(s),this.canvas=s,this.initMainThreadMode(e,i,t,r)}initOffscreenMode(e,i,t,r){try{let s=q(),a=this.canvas.transferControlToOffscreen();this.worker=s,this.isOffscreen=!0,this.markContextActive(),s.onmessage=l=>{l.data?.type==="error"&&this.fallbackToMainThread(e,i,t,r)},s.onerror=()=>{this.fallbackToMainThread(e,i,t,r)};let n={};this.customUniforms.forEach((l,u)=>{n[u]=typeof l=="number"?l:Array.from(l)}),s.postMessage({type:"init",canvas:a,width:this.width,height:this.height,minDpr:i,maxDpr:t,dynamicRes:r,reducedMotion:this.isReducedMotion,vertexShader:e.vertexShader??Q,fragmentShader:e.fragmentShader,feedbackShader:e.feedbackShader??null,feedbackScale:this.feedbackScale,feedbackMaxDim:this.feedbackMaxDim,feedbackFloat:this.feedbackFloat,initialScroll:this.scroll,uniforms:n},[a])}catch{this.isOffscreen=!1,this.markContextReleased(),this.initMainThreadMode(e,i,t,r)}}computeFboDimsMain(e,i){let t=Math.max(1,Math.floor(e*this.feedbackScale)),r=Math.max(1,Math.floor(i*this.feedbackScale)),s=Math.max(t,r);if(s>this.feedbackMaxDim){let a=this.feedbackMaxDim/s;t=Math.max(1,Math.floor(t*a)),r=Math.max(1,Math.floor(r*a))}return[t,r]}destroyPingPongMain(){if(!this.pingPong||!this.gl){this.pingPong=null;return}for(let e=0;e<2;e++)this.gl.deleteFramebuffer(this.pingPong[e].fbo),this.gl.deleteTexture(this.pingPong[e].tex);this.pingPong=null}createPingPongMain(e){if(this.destroyPingPongMain(),!this.options.feedbackShader||this.isContextLost)return;let[i,t]=this.computeFboDimsMain(this.canvas.width,this.canvas.height);this.fboW=i,this.fboH=t;let r=e.RGBA8,s=e.UNSIGNED_BYTE;this.feedbackFloat&&(e.getExtension("EXT_color_buffer_float")||e.getExtension("EXT_color_buffer_half_float"))&&(r=e.RGBA16F,s=e.HALF_FLOAT);let n=(u,d)=>{let f=[];for(let h=0;h<2;h++){let m=e.createTexture(),p=e.createFramebuffer();if(!m||!p)return m&&e.deleteTexture(m),p&&e.deleteFramebuffer(p),f.forEach(b=>{e.deleteFramebuffer(b.fbo),e.deleteTexture(b.tex)}),null;if(e.bindTexture(e.TEXTURE_2D,m),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texImage2D(e.TEXTURE_2D,0,u,this.fboW,this.fboH,0,e.RGBA,d,null),e.bindFramebuffer(e.FRAMEBUFFER,p),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,m,0),e.checkFramebufferStatus(e.FRAMEBUFFER)!==e.FRAMEBUFFER_COMPLETE)return e.deleteFramebuffer(p),e.deleteTexture(m),f.forEach(b=>{e.deleteFramebuffer(b.fbo),e.deleteTexture(b.tex)}),e.bindFramebuffer(e.FRAMEBUFFER,null),e.bindTexture(e.TEXTURE_2D,null),null;e.clearColor(0,0,0,0),e.clear(e.COLOR_BUFFER_BIT),f.push({fbo:p,tex:m})}return e.bindFramebuffer(e.FRAMEBUFFER,null),e.bindTexture(e.TEXTURE_2D,null),[f[0],f[1]]},l=n(r,s);!l&&r!==e.RGBA8&&(r=e.RGBA8,s=e.UNSIGNED_BYTE,l=n(r,s)),this.fboFormat=r,this.fboType=s,this.pingPong=l,this.readIdx=0,this.writeIdx=1}resizePingPongMain(){if(!this.pingPong||!this.gl||this.isContextLost)return;let[e,i]=this.computeFboDimsMain(this.canvas.width,this.canvas.height);if(e===this.fboW&&i===this.fboH)return;let t=this.gl,r=this.fboW,s=this.fboH,a=this.pingPong[this.readIdx],n=[];for(let l=0;l<2;l++){let u=t.createTexture(),d=t.createFramebuffer();t.bindTexture(t.TEXTURE_2D,u),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.texImage2D(t.TEXTURE_2D,0,this.fboFormat,e,i,0,t.RGBA,this.fboType,null),t.bindFramebuffer(t.FRAMEBUFFER,d),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,u,0),n.push({fbo:d,tex:u})}t.bindFramebuffer(t.READ_FRAMEBUFFER,a.fbo),t.bindFramebuffer(t.DRAW_FRAMEBUFFER,n[0].fbo),t.blitFramebuffer(0,0,r,s,0,0,e,i,t.COLOR_BUFFER_BIT,t.LINEAR),t.bindFramebuffer(t.READ_FRAMEBUFFER,null),t.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),t.bindTexture(t.TEXTURE_2D,null);for(let l=0;l<2;l++)t.deleteFramebuffer(this.pingPong[l].fbo),t.deleteTexture(this.pingPong[l].tex);this.pingPong=[n[0],n[1]],this.fboW=e,this.fboH=i,this.readIdx=0,this.writeIdx=1}initMainThreadPipeline(e){let i=this.options.vertexShader??P;this.programEntry=v.getOrCreateProgram(e,this.options.fragmentShader,i),this.options.feedbackShader?this.feedbackProgramEntry=v.getOrCreateProgram(e,this.options.feedbackShader,i):this.feedbackProgramEntry=null,this.vao=e.createVertexArray(),e.bindVertexArray(this.vao),this.vbo=e.createBuffer(),e.bindBuffer(e.ARRAY_BUFFER,this.vbo),e.bufferData(e.ARRAY_BUFFER,ve,e.STATIC_DRAW),e.enableVertexAttribArray(0),e.vertexAttribPointer(0,2,e.FLOAT,!1,0,0),e.bindVertexArray(null),this.needsResize=!1,this.applyCanvasSize(),this.options.feedbackShader&&this.createPingPongMain(e)}initMainThreadMode(e,i,t,r){let s=this.canvas.getContext("webgl2",{alpha:!0,antialias:!1,depth:!1,stencil:!1,powerPreference:"high-performance",preserveDrawingBuffer:!1});if(!s){console.warn("[FluxFX] WebGL2 is not supported on this device.");return}this.gl=s,this.markContextActive(),this.canvas.addEventListener("webglcontextlost",this.handleContextLost,!1),this.canvas.addEventListener("webglcontextrestored",this.handleContextRestored,!1),this.dynamicRes=new A({minScale:r?i:t,maxScale:t}),this.initMainThreadPipeline(s),this.drawMainThreadFrame()}applyCanvasSize(){if(!this.gl||!this.dynamicRes||this.isContextLost)return;let e=this.dynamicRes.scale,i=Math.max(1,Math.round(this.width*e)),t=Math.max(1,Math.round(this.height*e));(this.canvas.width!==i||this.canvas.height!==t)&&(this.canvas.width=i,this.canvas.height=t,this.gl.viewport(0,0,i,t),this.pingPong&&this.resizePingPongMain())}bindCommonUniformsMain(e,i,t,r){let s=v.getUniformLocation(e,i,"uTime");s&&e.uniform1f(s,this.elapsedSec);let a=v.getUniformLocation(e,i,"uDelta");a&&e.uniform1f(a,this.lastDeltaSec);let n=v.getUniformLocation(e,i,"uResolution");n&&e.uniform2f(n,t,r);let l=v.getUniformLocation(e,i,"uCanvasResolution");l&&e.uniform2f(l,this.canvas.width,this.canvas.height);let u=v.getUniformLocation(e,i,"uDpr");u&&this.dynamicRes&&e.uniform1f(u,this.dynamicRes.scale);let d=v.getUniformLocation(e,i,"uMouse");d&&e.uniform2f(d,this.mouse[0],this.mouse[1]);let f=v.getUniformLocation(e,i,"uMouseVel");f&&e.uniform2f(f,this.mouseVel[0],this.mouseVel[1]);let h=v.getUniformLocation(e,i,"uMouseDown");h&&e.uniform1f(h,this.mouseDown);let m=v.getUniformLocation(e,i,"uMouseActive");m&&e.uniform1f(m,this.mouseActive);let p=v.getUniformLocation(e,i,"uScroll");p&&e.uniform1f(p,this.scroll);let b=v.getUniformLocation(e,i,"uScrollVel");b&&e.uniform1f(b,this.scrollVel),this.customUniforms.forEach((y,S)=>{let M=v.getUniformLocation(e,i,S);M&&(S==="uSpeed"?e.uniform1f(M,this.currentSpeed):typeof y=="number"?e.uniform1f(M,y):y.length===2?e.uniform2f(M,y[0],y[1]):y.length===3?e.uniform3f(M,y[0],y[1],y[2]):y.length===4&&e.uniform4f(M,y[0],y[1],y[2],y[3]))})}drawMainThreadFrame(){if(!this.gl||!this.programEntry||this.isContextLost)return;let e=this.gl;if(e.bindVertexArray(this.vao),this.feedbackProgramEntry&&this.pingPong){e.bindFramebuffer(e.FRAMEBUFFER,this.pingPong[this.writeIdx].fbo),e.viewport(0,0,this.fboW,this.fboH),e.useProgram(this.feedbackProgramEntry.program),e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,this.pingPong[this.readIdx].tex);let i=v.getUniformLocation(e,this.feedbackProgramEntry,"uPrevFrame");i&&e.uniform1i(i,0),this.bindCommonUniformsMain(e,this.feedbackProgramEntry,this.fboW,this.fboH),e.drawArrays(e.TRIANGLES,0,3);let t=this.readIdx;this.readIdx=this.writeIdx,this.writeIdx=t,e.bindFramebuffer(e.FRAMEBUFFER,null),e.viewport(0,0,this.canvas.width,this.canvas.height)}if(e.useProgram(this.programEntry.program),this.pingPong){e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,this.pingPong[this.readIdx].tex);let i=v.getUniformLocation(e,this.programEntry,"uFeedback");i&&e.uniform1i(i,0);let t=v.getUniformLocation(e,this.programEntry,"uPrevFrame");t&&e.uniform1i(t,0)}this.bindCommonUniformsMain(e,this.programEntry,this.canvas.width,this.canvas.height),e.drawArrays(e.TRIANGLES,0,3)}render(e,i){if(this.isOffscreen||this.isPaused||this.isHiddenByViewport||this.isReducedMotion||this.isContextLost||this.isDestroyed||!this.gl||!this.programEntry)return;let t=performance.now(),r=this.lastRenderNow?t-this.lastRenderNow:16.67;this.lastRenderNow=t;let s=Math.max(.001,Math.min(r*.001,.05));this.lastDeltaSec=s,this.currentSpeed+=(this.targetSpeed-this.currentSpeed)*k(7.5,s),this.elapsedSec+=s*this.currentSpeed;let a=!1;if(this.needsResize&&(this.needsResize=!1,a=!0),this.dynamicRes&&this.dynamicRes.recordFrame(r,t)&&(a=!0),a&&this.applyCanvasSize(),this.mouseActive+=(this.targetMouseActive-this.mouseActive)*k(7,s),this.mouseActive<.001&&this.targetMouseActive===0&&(this.mouseActive=0),this.targetMouseActive>.5){let n=this.mouse[0],l=this.mouse[1],u=k(13,s);this.mouse[0]+=(this.targetMouse[0]-this.mouse[0])*u,this.mouse[1]+=(this.targetMouse[1]-this.mouse[1])*u,this.mouseVel[0]=Math.max(-8,Math.min(8,(this.mouse[0]-n)/s)),this.mouseVel[1]=Math.max(-8,Math.min(8,(this.mouse[1]-l)/s))}else this.mouseVel[0]=0,this.mouseVel[1]=0;if(this.trackScroll){let n=this.scroll;this.scroll+=(this.targetScroll-this.scroll)*k(9.5,s),this.scrollVel=Math.max(-6,Math.min(6,(this.scroll-n)/s))}this.drawMainThreadFrame()}syncDprBounds(){let{minDpr:e,maxDpr:i}=this.resolveDprBounds(),r=this.options.dynamicResolution??!0?e:i;this.isOffscreen&&this.worker?this.worker.postMessage({type:"dprBounds",minDpr:r,maxDpr:i}):this.dynamicRes&&this.dynamicRes.setBounds(r,i)&&(this.isReducedMotion&&!this.isPaused&&!this.isHiddenByViewport?(this.needsResize=!1,this.applyCanvasSize(),this.drawMainThreadFrame()):this.needsResize=!0)}watchDevicePixelRatio(){if(this.dprMediaQuery&&(this.dprMediaQuery.removeEventListener("change",this.handleDprChange),this.dprMediaQuery=null),typeof window>"u"||typeof window.matchMedia!="function")return;let e=window.devicePixelRatio||1;this.dprMediaQuery=window.matchMedia(`(resolution: ${e}dppx)`),this.dprMediaQuery.addEventListener("change",this.handleDprChange)}updateOptions(e){if(this.isDestroyed)return;let i=this.options.quality;this.options={...this.options,...e};let t=this.seedUniformsFromOptions(e,!1);if((e.quality!==void 0&&e.quality!==i||e.minDpr!==void 0||e.maxDpr!==void 0||e.dynamicResolution!==void 0)&&this.syncDprBounds(),typeof e.interactive=="boolean"&&e.interactive!==this.interactive&&(this.interactive=e.interactive,this.syncPointerListener()),typeof e.trackScroll=="boolean"&&e.trackScroll!==this.trackScroll&&(this.trackScroll=e.trackScroll,this.syncScrollListener()),typeof e.respectReducedMotion=="boolean"){this.respectReducedMotion=e.respectReducedMotion;let r=this.reducedMotionQuery?.matches??!1;this.applyReducedMotionState(this.respectReducedMotion&&r)}this.isOffscreen&&this.worker?Object.keys(t).length>0&&this.worker.postMessage({type:"uniformsBatch",uniforms:t}):this.isReducedMotion&&(this.needsResize&&(this.needsResize=!1,this.applyCanvasSize()),this.drawMainThreadFrame())}applyReducedMotionState(e){this.isReducedMotion!==e&&(this.isReducedMotion=e,this.lastRenderNow=0,this.isOffscreen&&this.worker?this.worker.postMessage({type:"reducedMotion",value:e}):e&&(this.needsResize&&(this.needsResize=!1,this.applyCanvasSize()),this.drawMainThreadFrame()))}getLocalPointerCoords(e){let i=this.container.getBoundingClientRect();if(i.width<=0||i.height<=0||e.clientX<i.left||e.clientX>i.right||e.clientY<i.top||e.clientY>i.bottom)return null;let t=(e.clientX-i.left)/i.width,r=1-(e.clientY-i.top)/i.height;return[t,r]}syncPointerListener(){this.interactive&&!this.hasPointerListener?(this.container.addEventListener("pointerenter",this.handlePointerEnter,{passive:!0}),this.container.addEventListener("pointermove",this.handlePointerMove,{passive:!0}),this.container.addEventListener("pointerleave",this.handlePointerLeave,{passive:!0}),this.container.addEventListener("pointerdown",this.handlePointerDown,{passive:!0}),window.addEventListener("pointerup",this.handlePointerUp,{passive:!0}),window.addEventListener("pointercancel",this.handlePointerUp,{passive:!0}),this.hasPointerListener=!0):!this.interactive&&this.hasPointerListener&&(this.container.removeEventListener("pointerenter",this.handlePointerEnter),this.container.removeEventListener("pointermove",this.handlePointerMove),this.container.removeEventListener("pointerleave",this.handlePointerLeave),this.container.removeEventListener("pointerdown",this.handlePointerDown),window.removeEventListener("pointerup",this.handlePointerUp),window.removeEventListener("pointercancel",this.handlePointerUp),this.handlePointerLeave(),this.hasPointerListener=!1)}syncScrollListener(){this.trackScroll&&!this.hasScrollListener?(window.addEventListener("scroll",this.handleScroll,{passive:!0}),this.hasScrollListener=!0,this.handleScroll()):!this.trackScroll&&this.hasScrollListener&&(window.removeEventListener("scroll",this.handleScroll),this.hasScrollListener=!1)}bindObservers(e){typeof ResizeObserver<"u"&&(this.resizeObserver=new ResizeObserver(i=>{let t=i[0];if(!t)return;let r=Math.max(1,Math.floor(t.contentRect.width)),s=Math.max(1,Math.floor(t.contentRect.height));r===this.width&&s===this.height||(this.width=r,this.height=s,this.trackScroll&&this.handleScroll(),this.isOffscreen&&this.worker?this.worker.postMessage({type:"resize",width:this.width,height:this.height}):this.isReducedMotion&&!this.isPaused&&!this.isHiddenByViewport?(this.needsResize=!1,this.applyCanvasSize(),this.drawMainThreadFrame()):this.needsResize=!0)}),this.resizeObserver.observe(this.container)),e&&typeof IntersectionObserver<"u"&&(this.visibilityObserver=new IntersectionObserver(i=>{let t=i[0]?.isIntersecting??!0;this.isHiddenByViewport=!t,t||this.handlePointerLeave(),this.isOffscreen&&this.worker?this.worker.postMessage({type:t&&!this.isPaused?"resume":"pause"}):t||(this.lastRenderNow=0)},{rootMargin:"50px"}),this.visibilityObserver.observe(this.container)),this.reducedMotionQuery&&this.reducedMotionQuery.addEventListener("change",this.handleReducedMotionChange),this.isOffscreen&&typeof document<"u"&&document.addEventListener("visibilitychange",this.handleDocVisibility),this.watchDevicePixelRatio(),this.syncPointerListener(),this.syncScrollListener()}setUniform(e,i){this.isDestroyed||(this.customUniforms.set(e,i),e==="uSpeed"&&typeof i=="number"&&(this.targetSpeed=i),this.isOffscreen&&this.worker?this.worker.postMessage({type:"uniform",name:e,value:typeof i=="number"?i:Array.from(i)}):this.isReducedMotion&&this.drawMainThreadFrame())}setColor(e,i){let t=c(i,"#ffffff"),r=g.hexToVec3Into(t,g.scratchVec3);this.setUniform(e,[r[0],r[1],r[2]])}pause(){this.isPaused||this.isDestroyed||(this.isPaused=!0,this.lastRenderNow=0,this.handlePointerLeave(),this.isOffscreen&&this.worker&&this.worker.postMessage({type:"pause"}))}resume(){!this.isPaused||this.isDestroyed||(this.isPaused=!1,this.lastRenderNow=0,this.isOffscreen&&this.worker&&!this.isHiddenByViewport?this.worker.postMessage({type:"resume"}):this.isReducedMotion&&!this.isHiddenByViewport&&(this.needsResize&&(this.needsResize=!1,this.applyCanvasSize()),this.drawMainThreadFrame()))}destroy(){this.isDestroyed||(this.isDestroyed=!0,this.resizeObserver?.disconnect(),this.resizeObserver=null,this.visibilityObserver?.disconnect(),this.visibilityObserver=null,this.reducedMotionQuery&&(this.reducedMotionQuery.removeEventListener("change",this.handleReducedMotionChange),this.reducedMotionQuery=null),this.dprMediaQuery&&(this.dprMediaQuery.removeEventListener("change",this.handleDprChange),this.dprMediaQuery=null),typeof document<"u"&&document.removeEventListener("visibilitychange",this.handleDocVisibility),this.hasPointerListener&&(this.container.removeEventListener("pointerenter",this.handlePointerEnter),this.container.removeEventListener("pointermove",this.handlePointerMove),this.container.removeEventListener("pointerleave",this.handlePointerLeave),this.container.removeEventListener("pointerdown",this.handlePointerDown),window.removeEventListener("pointerup",this.handlePointerUp),window.removeEventListener("pointercancel",this.handlePointerUp),this.hasPointerListener=!1),this.hasScrollListener&&(window.removeEventListener("scroll",this.handleScroll),this.hasScrollListener=!1),this.canvas.removeEventListener("webglcontextlost",this.handleContextLost,!1),this.canvas.removeEventListener("webglcontextrestored",this.handleContextRestored,!1),this.isOffscreen&&this.worker&&(this.worker.postMessage({type:"destroy"}),this.worker=null),this.gl&&(this.destroyPingPongMain(),this.vbo&&this.gl.deleteBuffer(this.vbo),this.vao&&this.gl.deleteVertexArray(this.vao),v.disposeContext(this.gl),this.gl.getExtension("WEBGL_lose_context")?.loseContext(),this.gl=null),this.markContextReleased(),g.releaseVec2(this.mouse),g.releaseVec2(this.targetMouse),g.releaseVec2(this.mouseVel),this.customUniforms.clear(),this.canvas.remove())}};R._activeContexts=0;var x=R;var U=class{constructor(){this.plugins=new Map;this.activeByElement=new WeakMap;this.activeSet=new Set;this.visibilityObserver=null;this.visibilityCallbacks=new WeakMap;this.removeTicker=null}ensureObserver(){return typeof window>"u"||typeof IntersectionObserver>"u"?null:(this.visibilityObserver||(this.visibilityObserver=new IntersectionObserver(e=>{for(let i=0;i<e.length;i++){let t=e[i],r=this.visibilityCallbacks.get(t.target);r&&r.forEach(s=>s(t.isIntersecting))}},{rootMargin:"50px"})),this.visibilityObserver)}ensureTicker(){this.removeTicker||(this.removeTicker=H.add((e,i)=>{this.activeSet.forEach(t=>{if(!(!t.visible||t.faulted||!t.instance.update))try{t.instance.update(e,i)}catch(r){t.faulted=!0,console.error(`[FluxFX] Runtime error in "${t.name}" (auto-paused):`,r)}})}))}stopTickerIfEmpty(){this.activeSet.size===0&&this.removeTicker&&(this.removeTicker(),this.removeTicker=null)}register(e){return this.plugins.set(e.name,e),this}has(e){return this.plugins.has(e)}getStats(){let e=0;this.activeSet.forEach(t=>{t.visible&&e++});let i=typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches;return{mounted:this.activeSet.size,visible:e,activeLoops:H.isRunning?1:0,registered:this.plugins.size,webglContexts:x.activeContexts,reducedMotion:i}}apply(e,i,t={}){let r=this.plugins.get(i);if(!r)return console.warn(`[FluxFX] Effect "${i}" is not registered.`),()=>{};let s=this.activeByElement.get(e);s||(s=new Map,this.activeByElement.set(e,s));let a=s.get(i);a&&a.destroy();let n;try{n=r.mount(e,t)}catch(h){return console.error(`[FluxFX] Failed to mount "${i}":`,h),()=>{}}let l=t.pauseWhenHidden??!0,u=null,d=!1,f={el:e,name:i,plugin:r,instance:n,visible:!0,faulted:!1,destroy:()=>{if(!d){d=!0,u?.(),this.activeSet.delete(f),s?.delete(i);try{f.instance.destroy()}catch(h){console.error(`[FluxFX] Cleanup error in "${i}":`,h)}this.stopTickerIfEmpty()}}};if(l){let h=this.ensureObserver();if(h){let m=this.visibilityCallbacks.get(e);m||(m=new Set,this.visibilityCallbacks.set(e,m),h.observe(e));let p=b=>{f.visible=b,b?f.instance.resume?.():f.instance.pause?.()};m.add(p),u=()=>{m?.delete(p),m&&m.size===0&&(h.unobserve(e),this.visibilityCallbacks.delete(e))}}}return s.set(i,f),this.activeSet.add(f),f.instance.update&&this.ensureTicker(),f.destroy}update(e,i,t={}){let s=this.activeByElement.get(e)?.get(i);if(!s)return!1;if(s.instance.setOptions)try{return s.instance.setOptions(t),!0}catch(a){return console.error(`[FluxFX] Hot-update error in "${i}":`,a),!1}try{return s.instance.destroy(),s.instance=s.plugin.mount(e,t),s.faulted=!1,s.visible||s.instance.pause?.(),s.instance.update&&this.ensureTicker(),!0}catch(a){return s.faulted=!0,console.error(`[FluxFX] Fallback remount error in "${i}":`,a),!1}}scan(e=document){if(typeof document>"u")return;e.querySelectorAll("[data-fx]").forEach(t=>{let r=t.getAttribute("data-fx");if(!r)return;let s=r.trim().split(/\s+/).filter(Boolean),a=this.parseDatasetOptions(t),n=this.activeByElement.get(t);s.forEach(l=>{n?.has(l)||this.apply(t,l,a)})})}init(e){typeof document>"u"||(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>this.scan(e??document),{once:!0}):this.scan(e??document))}destroyAll(){let e=Array.from(this.activeSet);for(let i=0;i<e.length;i++)e[i].destroy()}parseDatasetOptions(e){let i={};for(let[t,r]of Object.entries(e.dataset)){if(!t.startsWith("fx")||t==="fx"||r===void 0)continue;let s=t.slice(2),a=s.charAt(0).toLowerCase()+s.slice(1);r==="true"?i[a]=!0:r==="false"?i[a]=!1:r!==""&&!Number.isNaN(Number(r))?i[a]=Number(r):i[a]=r}return i}},_=new U;var be=`#version 300 es
|
|
680
|
+
`,H=null;function q(){if(typeof window>"u"||typeof Worker>"u"||typeof OffscreenCanvas>"u"||typeof HTMLCanvasElement>"u"||!("transferControlToOffscreen"in HTMLCanvasElement.prototype))return!1;let o=typeof navigator<"u"?navigator.userAgent:"";return!(/iP(ad|hone|od)/i.test(o)||/^((?!chrome|android).)*safari/i.test(o))}function N(){if(!H){let o=new Blob([pe],{type:"application/javascript"});H=URL.createObjectURL(o)}return new Worker(H)}var Q=P;var C={low:{max:1,min:.65,retinaMin:.85,fboMaxDim:512},medium:{max:2,min:.75,retinaMin:1,fboMaxDim:896},high:{max:2,min:1,retinaMin:1.25,fboMaxDim:1152}},ve=new Float32Array([-1,-1,3,-1,-1,3]),ge=12;function k(o,e){return 1-Math.exp(-o*e)}var R=class R{constructor(e,i){this.resizeObserver=null;this.visibilityObserver=null;this.reducedMotionQuery=null;this.dprMediaQuery=null;this.worker=null;this.isOffscreen=!1;this.gl=null;this.programEntry=null;this.feedbackProgramEntry=null;this.vao=null;this.vbo=null;this.dynamicRes=null;this.lastRenderNow=0;this.elapsedSec=0;this.lastDeltaSec=.01667;this.currentSpeed=1;this.targetSpeed=1;this.needsResize=!1;this.pingPong=null;this.fboW=1;this.fboH=1;this.fboFormat=0;this.fboType=0;this.readIdx=0;this.writeIdx=1;this.customUniforms=new Map;this.mouse=g.acquireVec2(.5,.5);this.targetMouse=g.acquireVec2(.5,.5);this.mouseVel=g.acquireVec2(0,0);this.mouseDown=0;this.mouseActive=0;this.targetMouseActive=0;this.isPointerInside=!1;this.scroll=0;this.targetScroll=0;this.scrollVel=0;this.hasScrollListener=!1;this.width=1;this.height=1;this.isPaused=!1;this.isHiddenByViewport=!1;this.isContextLost=!1;this.isReducedMotion=!1;this.isDestroyed=!1;this.hasPointerListener=!1;this.countedContext=!1;this.handleContextLost=e=>{e.preventDefault(),this.isContextLost=!0,this.lastRenderNow=0,this.gl&&v.disposeContext(this.gl),this.programEntry=null,this.feedbackProgramEntry=null,this.pingPong=null,this.vao=null,this.vbo=null};this.handleContextRestored=()=>{if(!(this.isDestroyed||!this.gl))try{this.isContextLost=!1,this.initMainThreadPipeline(this.gl),this.drawMainThreadFrame()}catch(e){console.error("[FluxFX] Failed to restore WebGL2 context:",e)}};this.handleDprChange=()=>{this.isDestroyed||(this.syncDprBounds(),this.watchDevicePixelRatio())};this.handleReducedMotionChange=e=>{this.applyReducedMotionState(this.respectReducedMotion&&e.matches)};this.handlePointerEnter=e=>{if(this.isPaused||this.isHiddenByViewport||this.isReducedMotion)return;let i=this.getLocalPointerCoords(e);if(!i)return;let[t,r]=i;this.isPointerInside=!0,this.targetMouseActive=1,this.isOffscreen&&this.worker?this.worker.postMessage({type:"mouseEnter",x:t,y:r}):(this.mouse[0]=t,this.mouse[1]=r,this.targetMouse[0]=t,this.targetMouse[1]=r,this.mouseVel[0]=0,this.mouseVel[1]=0)};this.handlePointerMove=e=>{if(this.isPaused||this.isHiddenByViewport||this.isReducedMotion)return;let i=this.getLocalPointerCoords(e);if(!i){this.isPointerInside&&this.handlePointerLeave();return}let[t,r]=i;if(!this.isPointerInside){this.handlePointerEnter(e);return}this.isOffscreen&&this.worker?this.worker.postMessage({type:"mouse",x:t,y:r}):(this.targetMouse[0]=t,this.targetMouse[1]=r)};this.handlePointerLeave=()=>{!this.isPointerInside&&this.targetMouseActive===0||(this.isPointerInside=!1,this.targetMouseActive=0,this.mouseDown=0,this.mouseVel[0]=0,this.mouseVel[1]=0,this.isOffscreen&&this.worker&&this.worker.postMessage({type:"mouseLeave"}))};this.handlePointerDown=e=>{this.isPaused||this.isHiddenByViewport||this.isReducedMotion||(this.isPointerInside||this.handlePointerEnter(e),this.mouseDown=1,this.isOffscreen&&this.worker&&this.worker.postMessage({type:"mouseDown",down:!0}))};this.handlePointerUp=()=>{this.mouseDown!==0&&(this.mouseDown=0,this.isOffscreen&&this.worker&&this.worker.postMessage({type:"mouseDown",down:!1}))};this.handleScroll=()=>{if(!this.trackScroll||this.isDestroyed)return;let e=this.computeScrollProgress();this.isOffscreen&&this.worker?this.worker.postMessage({type:"scroll",progress:e}):(this.targetScroll=e,this.isReducedMotion&&!this.isPaused&&!this.isHiddenByViewport&&(this.scroll=e,this.scrollVel=0,this.drawMainThreadFrame()))};this.handleDocVisibility=()=>{!this.isOffscreen||!this.worker||(document.hidden?this.worker.postMessage({type:"pause"}):!this.isPaused&&!this.isHiddenByViewport&&this.worker.postMessage({type:"resume"}))};this.container=e,this.options={...i},this.interactive=i.interactive??!0,this.respectReducedMotion=i.respectReducedMotion??!0,this.trackScroll=i.trackScroll??!1,this.feedbackScale=i.feedbackScale??.5,this.feedbackFloat=i.feedbackFloat??!0;let t=i.quality??"medium",r=C[t]??C.medium;this.feedbackMaxDim=i.feedbackMaxDim??r.fboMaxDim,typeof window<"u"&&typeof window.matchMedia=="function"&&(this.reducedMotionQuery=window.matchMedia("(prefers-reduced-motion: reduce)"),this.isReducedMotion=this.respectReducedMotion&&this.reducedMotionQuery.matches),window.getComputedStyle(this.container).position==="static"&&(this.container.style.position="relative"),this.container.style.isolation="isolate",this.canvas=document.createElement("canvas"),this.canvas.setAttribute("data-fluxfx-canvas","true"),this.canvas.style.position="absolute",this.canvas.style.inset="0",this.canvas.style.width="100%",this.canvas.style.height="100%",this.canvas.style.zIndex="-1",this.canvas.style.pointerEvents="none",this.canvas.style.display="block",this.container.prepend(this.canvas);let a=this.container.getBoundingClientRect();if(this.width=Math.max(1,Math.floor(a.width)),this.height=Math.max(1,Math.floor(a.height)),this.trackScroll){let f=this.computeScrollProgress();this.scroll=f,this.targetScroll=f}let{minDpr:n,maxDpr:l}=this.resolveDprBounds(),u=i.dynamicResolution??!0,d=i.offscreen??!0;this.seedUniformsFromOptions(i,!0),d&&q()?this.initOffscreenMode(i,n,l,u):this.initMainThreadMode(i,n,l,u),this.bindObservers(i.pauseWhenHidden??!0)}static get activeContexts(){return this._activeContexts}resolveDprBounds(){let e=this.options.quality??"medium",i=C[e]??C.medium,t=typeof window<"u"&&window.devicePixelRatio||1,r=t>=1.5,s=this.options.maxDpr??Math.min(t,i.max),a=r?i.retinaMin:i.min;return{minDpr:this.options.minDpr??Math.min(a,s),maxDpr:s}}computeScrollProgress(){if(typeof window>"u")return 0;let e=this.container.getBoundingClientRect(),i=window.innerHeight||1,t=i+e.height;return t<=0?0:Math.min(1,Math.max(0,(i-e.top)/t))}markContextActive(){this.countedContext||(this.countedContext=!0,R._activeContexts++,R._activeContexts>ge&&console.warn(`[FluxFX] ${R._activeContexts} active WebGL contexts detected. Browsers typically cap contexts around 8\u201316; consider limiting simultaneous WebGL backgrounds.`))}markContextReleased(){this.countedContext&&(this.countedContext=!1,R._activeContexts=Math.max(0,R._activeContexts-1))}seedUniformsFromOptions(e,i=!1){let t={};if(typeof e.speed=="number"?(this.targetSpeed=e.speed,i&&(this.currentSpeed=e.speed),this.customUniforms.set("uSpeed",e.speed),t.uSpeed=e.speed):this.customUniforms.has("uSpeed")||(this.targetSpeed=1,this.currentSpeed=1,this.customUniforms.set("uSpeed",1),t.uSpeed=1),e.colors&&e.colors.length>0){let r=Array.isArray(e.colors)?e.colors:String(e.colors).split(",").map(n=>n.trim()).filter(Boolean),s=c(r[0],"#ffffff"),a=Math.min(r.length,3);for(let n=0;n<a;n++){let l=c(r[n],s),u=g.hexToVec3Into(l,g.scratchVec3),d=[u[0],u[1],u[2]];this.customUniforms.set(`uColor${n+1}`,d),t[`uColor${n+1}`]=d}if(a===1){let n=this.customUniforms.get("uColor1");this.customUniforms.set("uColor2",[n[0],n[1],n[2]]),t.uColor2=[n[0],n[1],n[2]]}}if(e.uniforms)for(let[r,s]of Object.entries(e.uniforms))this.customUniforms.set(r,s),t[r]=typeof s=="number"?s:Array.from(s);return t}fallbackToMainThread(e,i,t,r){if(this.isDestroyed)return;this.worker&&(this.worker.terminate(),this.worker=null),this.isOffscreen=!1,this.markContextReleased();let s=this.canvas.cloneNode(!1);this.canvas.replaceWith(s),this.canvas=s,this.initMainThreadMode(e,i,t,r)}initOffscreenMode(e,i,t,r){try{let s=N(),a=this.canvas.transferControlToOffscreen();this.worker=s,this.isOffscreen=!0,this.markContextActive(),s.onmessage=l=>{l.data?.type==="error"&&this.fallbackToMainThread(e,i,t,r)},s.onerror=()=>{this.fallbackToMainThread(e,i,t,r)};let n={};this.customUniforms.forEach((l,u)=>{n[u]=typeof l=="number"?l:Array.from(l)}),s.postMessage({type:"init",canvas:a,width:this.width,height:this.height,minDpr:i,maxDpr:t,dynamicRes:r,reducedMotion:this.isReducedMotion,vertexShader:e.vertexShader??Q,fragmentShader:e.fragmentShader,feedbackShader:e.feedbackShader??null,feedbackScale:this.feedbackScale,feedbackMaxDim:this.feedbackMaxDim,feedbackFloat:this.feedbackFloat,initialScroll:this.scroll,uniforms:n},[a])}catch{this.isOffscreen=!1,this.markContextReleased(),this.initMainThreadMode(e,i,t,r)}}computeFboDimsMain(e,i){let t=Math.max(1,Math.floor(e*this.feedbackScale)),r=Math.max(1,Math.floor(i*this.feedbackScale)),s=Math.max(t,r);if(s>this.feedbackMaxDim){let a=this.feedbackMaxDim/s;t=Math.max(1,Math.floor(t*a)),r=Math.max(1,Math.floor(r*a))}return[t,r]}destroyPingPongMain(){if(!this.pingPong||!this.gl){this.pingPong=null;return}for(let e=0;e<2;e++)this.gl.deleteFramebuffer(this.pingPong[e].fbo),this.gl.deleteTexture(this.pingPong[e].tex);this.pingPong=null}createPingPongMain(e){if(this.destroyPingPongMain(),!this.options.feedbackShader||this.isContextLost)return;let[i,t]=this.computeFboDimsMain(this.canvas.width,this.canvas.height);this.fboW=i,this.fboH=t;let r=e.RGBA8,s=e.UNSIGNED_BYTE;this.feedbackFloat&&(e.getExtension("EXT_color_buffer_float")||e.getExtension("EXT_color_buffer_half_float"))&&(r=e.RGBA16F,s=e.HALF_FLOAT);let n=(u,d)=>{let f=[];for(let h=0;h<2;h++){let m=e.createTexture(),p=e.createFramebuffer();if(!m||!p)return m&&e.deleteTexture(m),p&&e.deleteFramebuffer(p),f.forEach(b=>{e.deleteFramebuffer(b.fbo),e.deleteTexture(b.tex)}),null;if(e.bindTexture(e.TEXTURE_2D,m),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texImage2D(e.TEXTURE_2D,0,u,this.fboW,this.fboH,0,e.RGBA,d,null),e.bindFramebuffer(e.FRAMEBUFFER,p),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,m,0),e.checkFramebufferStatus(e.FRAMEBUFFER)!==e.FRAMEBUFFER_COMPLETE)return e.deleteFramebuffer(p),e.deleteTexture(m),f.forEach(b=>{e.deleteFramebuffer(b.fbo),e.deleteTexture(b.tex)}),e.bindFramebuffer(e.FRAMEBUFFER,null),e.bindTexture(e.TEXTURE_2D,null),null;e.clearColor(0,0,0,0),e.clear(e.COLOR_BUFFER_BIT),f.push({fbo:p,tex:m})}return e.bindFramebuffer(e.FRAMEBUFFER,null),e.bindTexture(e.TEXTURE_2D,null),[f[0],f[1]]},l=n(r,s);!l&&r!==e.RGBA8&&(r=e.RGBA8,s=e.UNSIGNED_BYTE,l=n(r,s)),this.fboFormat=r,this.fboType=s,this.pingPong=l,this.readIdx=0,this.writeIdx=1}resizePingPongMain(){if(!this.pingPong||!this.gl||this.isContextLost)return;let[e,i]=this.computeFboDimsMain(this.canvas.width,this.canvas.height);if(e===this.fboW&&i===this.fboH)return;let t=this.gl,r=this.fboW,s=this.fboH,a=this.pingPong[this.readIdx],n=[];for(let l=0;l<2;l++){let u=t.createTexture(),d=t.createFramebuffer();t.bindTexture(t.TEXTURE_2D,u),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.texImage2D(t.TEXTURE_2D,0,this.fboFormat,e,i,0,t.RGBA,this.fboType,null),t.bindFramebuffer(t.FRAMEBUFFER,d),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,u,0),n.push({fbo:d,tex:u})}t.bindFramebuffer(t.READ_FRAMEBUFFER,a.fbo),t.bindFramebuffer(t.DRAW_FRAMEBUFFER,n[0].fbo),t.blitFramebuffer(0,0,r,s,0,0,e,i,t.COLOR_BUFFER_BIT,t.LINEAR),t.bindFramebuffer(t.READ_FRAMEBUFFER,null),t.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),t.bindTexture(t.TEXTURE_2D,null);for(let l=0;l<2;l++)t.deleteFramebuffer(this.pingPong[l].fbo),t.deleteTexture(this.pingPong[l].tex);this.pingPong=[n[0],n[1]],this.fboW=e,this.fboH=i,this.readIdx=0,this.writeIdx=1}initMainThreadPipeline(e){let i=this.options.vertexShader??P;this.programEntry=v.getOrCreateProgram(e,this.options.fragmentShader,i),this.options.feedbackShader?this.feedbackProgramEntry=v.getOrCreateProgram(e,this.options.feedbackShader,i):this.feedbackProgramEntry=null,this.vao=e.createVertexArray(),e.bindVertexArray(this.vao),this.vbo=e.createBuffer(),e.bindBuffer(e.ARRAY_BUFFER,this.vbo),e.bufferData(e.ARRAY_BUFFER,ve,e.STATIC_DRAW),e.enableVertexAttribArray(0),e.vertexAttribPointer(0,2,e.FLOAT,!1,0,0),e.bindVertexArray(null),this.needsResize=!1,this.applyCanvasSize(),this.options.feedbackShader&&this.createPingPongMain(e)}initMainThreadMode(e,i,t,r){let s=this.canvas.getContext("webgl2",{alpha:!0,antialias:!1,depth:!1,stencil:!1,powerPreference:"high-performance",preserveDrawingBuffer:!1});if(!s){console.warn("[FluxFX] WebGL2 is not supported on this device.");return}this.gl=s,this.markContextActive(),this.canvas.addEventListener("webglcontextlost",this.handleContextLost,!1),this.canvas.addEventListener("webglcontextrestored",this.handleContextRestored,!1),this.dynamicRes=new D({minScale:r?i:t,maxScale:t}),this.initMainThreadPipeline(s),this.drawMainThreadFrame()}applyCanvasSize(){if(!this.gl||!this.dynamicRes||this.isContextLost)return;let e=this.dynamicRes.scale,i=Math.max(1,Math.round(this.width*e)),t=Math.max(1,Math.round(this.height*e));(this.canvas.width!==i||this.canvas.height!==t)&&(this.canvas.width=i,this.canvas.height=t,this.gl.viewport(0,0,i,t),this.pingPong&&this.resizePingPongMain())}bindCommonUniformsMain(e,i,t,r){let s=v.getUniformLocation(e,i,"uTime");s&&e.uniform1f(s,this.elapsedSec);let a=v.getUniformLocation(e,i,"uDelta");a&&e.uniform1f(a,this.lastDeltaSec);let n=v.getUniformLocation(e,i,"uResolution");n&&e.uniform2f(n,t,r);let l=v.getUniformLocation(e,i,"uCanvasResolution");l&&e.uniform2f(l,this.canvas.width,this.canvas.height);let u=v.getUniformLocation(e,i,"uDpr");u&&this.dynamicRes&&e.uniform1f(u,this.dynamicRes.scale);let d=v.getUniformLocation(e,i,"uMouse");d&&e.uniform2f(d,this.mouse[0],this.mouse[1]);let f=v.getUniformLocation(e,i,"uMouseVel");f&&e.uniform2f(f,this.mouseVel[0],this.mouseVel[1]);let h=v.getUniformLocation(e,i,"uMouseDown");h&&e.uniform1f(h,this.mouseDown);let m=v.getUniformLocation(e,i,"uMouseActive");m&&e.uniform1f(m,this.mouseActive);let p=v.getUniformLocation(e,i,"uScroll");p&&e.uniform1f(p,this.scroll);let b=v.getUniformLocation(e,i,"uScrollVel");b&&e.uniform1f(b,this.scrollVel),this.customUniforms.forEach((y,S)=>{let M=v.getUniformLocation(e,i,S);M&&(S==="uSpeed"?e.uniform1f(M,this.currentSpeed):typeof y=="number"?e.uniform1f(M,y):y.length===2?e.uniform2f(M,y[0],y[1]):y.length===3?e.uniform3f(M,y[0],y[1],y[2]):y.length===4&&e.uniform4f(M,y[0],y[1],y[2],y[3]))})}drawMainThreadFrame(){if(!this.gl||!this.programEntry||this.isContextLost)return;let e=this.gl;if(e.bindVertexArray(this.vao),this.feedbackProgramEntry&&this.pingPong){e.bindFramebuffer(e.FRAMEBUFFER,this.pingPong[this.writeIdx].fbo),e.viewport(0,0,this.fboW,this.fboH),e.useProgram(this.feedbackProgramEntry.program),e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,this.pingPong[this.readIdx].tex);let i=v.getUniformLocation(e,this.feedbackProgramEntry,"uPrevFrame");i&&e.uniform1i(i,0),this.bindCommonUniformsMain(e,this.feedbackProgramEntry,this.fboW,this.fboH),e.drawArrays(e.TRIANGLES,0,3);let t=this.readIdx;this.readIdx=this.writeIdx,this.writeIdx=t,e.bindFramebuffer(e.FRAMEBUFFER,null),e.viewport(0,0,this.canvas.width,this.canvas.height)}if(e.useProgram(this.programEntry.program),this.pingPong){e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,this.pingPong[this.readIdx].tex);let i=v.getUniformLocation(e,this.programEntry,"uFeedback");i&&e.uniform1i(i,0);let t=v.getUniformLocation(e,this.programEntry,"uPrevFrame");t&&e.uniform1i(t,0)}this.bindCommonUniformsMain(e,this.programEntry,this.canvas.width,this.canvas.height),e.drawArrays(e.TRIANGLES,0,3)}render(e,i){if(this.isOffscreen||this.isPaused||this.isHiddenByViewport||this.isReducedMotion||this.isContextLost||this.isDestroyed||!this.gl||!this.programEntry)return;let t=performance.now(),r=this.lastRenderNow?t-this.lastRenderNow:16.67;this.lastRenderNow=t;let s=Math.max(.001,Math.min(r*.001,.05));this.lastDeltaSec=s,this.currentSpeed+=(this.targetSpeed-this.currentSpeed)*k(7.5,s),this.elapsedSec+=s*this.currentSpeed;let a=!1;if(this.needsResize&&(this.needsResize=!1,a=!0),this.dynamicRes&&this.dynamicRes.recordFrame(r,t)&&(a=!0),a&&this.applyCanvasSize(),this.mouseActive+=(this.targetMouseActive-this.mouseActive)*k(7,s),this.mouseActive<.001&&this.targetMouseActive===0&&(this.mouseActive=0),this.targetMouseActive>.5){let n=this.mouse[0],l=this.mouse[1],u=k(13,s);this.mouse[0]+=(this.targetMouse[0]-this.mouse[0])*u,this.mouse[1]+=(this.targetMouse[1]-this.mouse[1])*u,this.mouseVel[0]=Math.max(-8,Math.min(8,(this.mouse[0]-n)/s)),this.mouseVel[1]=Math.max(-8,Math.min(8,(this.mouse[1]-l)/s))}else this.mouseVel[0]=0,this.mouseVel[1]=0;if(this.trackScroll){let n=this.scroll;this.scroll+=(this.targetScroll-this.scroll)*k(9.5,s),this.scrollVel=Math.max(-6,Math.min(6,(this.scroll-n)/s))}this.drawMainThreadFrame()}syncDprBounds(){let{minDpr:e,maxDpr:i}=this.resolveDprBounds(),r=this.options.dynamicResolution??!0?e:i;this.isOffscreen&&this.worker?this.worker.postMessage({type:"dprBounds",minDpr:r,maxDpr:i}):this.dynamicRes&&this.dynamicRes.setBounds(r,i)&&(this.isReducedMotion&&!this.isPaused&&!this.isHiddenByViewport?(this.needsResize=!1,this.applyCanvasSize(),this.drawMainThreadFrame()):this.needsResize=!0)}watchDevicePixelRatio(){if(this.dprMediaQuery&&(this.dprMediaQuery.removeEventListener("change",this.handleDprChange),this.dprMediaQuery=null),typeof window>"u"||typeof window.matchMedia!="function")return;let e=window.devicePixelRatio||1;this.dprMediaQuery=window.matchMedia(`(resolution: ${e}dppx)`),this.dprMediaQuery.addEventListener("change",this.handleDprChange)}updateOptions(e){if(this.isDestroyed)return;let i=this.options.quality;this.options={...this.options,...e};let t=this.seedUniformsFromOptions(e,!1);if((e.quality!==void 0&&e.quality!==i||e.minDpr!==void 0||e.maxDpr!==void 0||e.dynamicResolution!==void 0)&&this.syncDprBounds(),typeof e.interactive=="boolean"&&e.interactive!==this.interactive&&(this.interactive=e.interactive,this.syncPointerListener()),typeof e.trackScroll=="boolean"&&e.trackScroll!==this.trackScroll&&(this.trackScroll=e.trackScroll,this.syncScrollListener()),typeof e.respectReducedMotion=="boolean"){this.respectReducedMotion=e.respectReducedMotion;let r=this.reducedMotionQuery?.matches??!1;this.applyReducedMotionState(this.respectReducedMotion&&r)}this.isOffscreen&&this.worker?Object.keys(t).length>0&&this.worker.postMessage({type:"uniformsBatch",uniforms:t}):this.isReducedMotion&&(this.needsResize&&(this.needsResize=!1,this.applyCanvasSize()),this.drawMainThreadFrame())}applyReducedMotionState(e){this.isReducedMotion!==e&&(this.isReducedMotion=e,this.lastRenderNow=0,this.isOffscreen&&this.worker?this.worker.postMessage({type:"reducedMotion",value:e}):e&&(this.needsResize&&(this.needsResize=!1,this.applyCanvasSize()),this.drawMainThreadFrame()))}getLocalPointerCoords(e){let i=this.container.getBoundingClientRect();if(i.width<=0||i.height<=0||e.clientX<i.left||e.clientX>i.right||e.clientY<i.top||e.clientY>i.bottom)return null;let t=(e.clientX-i.left)/i.width,r=1-(e.clientY-i.top)/i.height;return[t,r]}syncPointerListener(){this.interactive&&!this.hasPointerListener?(this.container.addEventListener("pointerenter",this.handlePointerEnter,{passive:!0}),this.container.addEventListener("pointermove",this.handlePointerMove,{passive:!0}),this.container.addEventListener("pointerleave",this.handlePointerLeave,{passive:!0}),this.container.addEventListener("pointerdown",this.handlePointerDown,{passive:!0}),window.addEventListener("pointerup",this.handlePointerUp,{passive:!0}),window.addEventListener("pointercancel",this.handlePointerUp,{passive:!0}),this.hasPointerListener=!0):!this.interactive&&this.hasPointerListener&&(this.container.removeEventListener("pointerenter",this.handlePointerEnter),this.container.removeEventListener("pointermove",this.handlePointerMove),this.container.removeEventListener("pointerleave",this.handlePointerLeave),this.container.removeEventListener("pointerdown",this.handlePointerDown),window.removeEventListener("pointerup",this.handlePointerUp),window.removeEventListener("pointercancel",this.handlePointerUp),this.handlePointerLeave(),this.hasPointerListener=!1)}syncScrollListener(){this.trackScroll&&!this.hasScrollListener?(window.addEventListener("scroll",this.handleScroll,{passive:!0}),this.hasScrollListener=!0,this.handleScroll()):!this.trackScroll&&this.hasScrollListener&&(window.removeEventListener("scroll",this.handleScroll),this.hasScrollListener=!1)}bindObservers(e){typeof ResizeObserver<"u"&&(this.resizeObserver=new ResizeObserver(i=>{let t=i[0];if(!t)return;let r=Math.max(1,Math.floor(t.contentRect.width)),s=Math.max(1,Math.floor(t.contentRect.height));r===this.width&&s===this.height||(this.width=r,this.height=s,this.trackScroll&&this.handleScroll(),this.isOffscreen&&this.worker?this.worker.postMessage({type:"resize",width:this.width,height:this.height}):this.isReducedMotion&&!this.isPaused&&!this.isHiddenByViewport?(this.needsResize=!1,this.applyCanvasSize(),this.drawMainThreadFrame()):this.needsResize=!0)}),this.resizeObserver.observe(this.container)),e&&typeof IntersectionObserver<"u"&&(this.visibilityObserver=new IntersectionObserver(i=>{let t=i[0]?.isIntersecting??!0;this.isHiddenByViewport=!t,t||this.handlePointerLeave(),this.isOffscreen&&this.worker?this.worker.postMessage({type:t&&!this.isPaused?"resume":"pause"}):t||(this.lastRenderNow=0)},{rootMargin:"50px"}),this.visibilityObserver.observe(this.container)),this.reducedMotionQuery&&this.reducedMotionQuery.addEventListener("change",this.handleReducedMotionChange),this.isOffscreen&&typeof document<"u"&&document.addEventListener("visibilitychange",this.handleDocVisibility),this.watchDevicePixelRatio(),this.syncPointerListener(),this.syncScrollListener()}setUniform(e,i){this.isDestroyed||(this.customUniforms.set(e,i),e==="uSpeed"&&typeof i=="number"&&(this.targetSpeed=i),this.isOffscreen&&this.worker?this.worker.postMessage({type:"uniform",name:e,value:typeof i=="number"?i:Array.from(i)}):this.isReducedMotion&&this.drawMainThreadFrame())}setColor(e,i){let t=c(i,"#ffffff"),r=g.hexToVec3Into(t,g.scratchVec3);this.setUniform(e,[r[0],r[1],r[2]])}pause(){this.isPaused||this.isDestroyed||(this.isPaused=!0,this.lastRenderNow=0,this.handlePointerLeave(),this.isOffscreen&&this.worker&&this.worker.postMessage({type:"pause"}))}resume(){!this.isPaused||this.isDestroyed||(this.isPaused=!1,this.lastRenderNow=0,this.isOffscreen&&this.worker&&!this.isHiddenByViewport?this.worker.postMessage({type:"resume"}):this.isReducedMotion&&!this.isHiddenByViewport&&(this.needsResize&&(this.needsResize=!1,this.applyCanvasSize()),this.drawMainThreadFrame()))}destroy(){this.isDestroyed||(this.isDestroyed=!0,this.resizeObserver?.disconnect(),this.resizeObserver=null,this.visibilityObserver?.disconnect(),this.visibilityObserver=null,this.reducedMotionQuery&&(this.reducedMotionQuery.removeEventListener("change",this.handleReducedMotionChange),this.reducedMotionQuery=null),this.dprMediaQuery&&(this.dprMediaQuery.removeEventListener("change",this.handleDprChange),this.dprMediaQuery=null),typeof document<"u"&&document.removeEventListener("visibilitychange",this.handleDocVisibility),this.hasPointerListener&&(this.container.removeEventListener("pointerenter",this.handlePointerEnter),this.container.removeEventListener("pointermove",this.handlePointerMove),this.container.removeEventListener("pointerleave",this.handlePointerLeave),this.container.removeEventListener("pointerdown",this.handlePointerDown),window.removeEventListener("pointerup",this.handlePointerUp),window.removeEventListener("pointercancel",this.handlePointerUp),this.hasPointerListener=!1),this.hasScrollListener&&(window.removeEventListener("scroll",this.handleScroll),this.hasScrollListener=!1),this.canvas.removeEventListener("webglcontextlost",this.handleContextLost,!1),this.canvas.removeEventListener("webglcontextrestored",this.handleContextRestored,!1),this.isOffscreen&&this.worker&&(this.worker.postMessage({type:"destroy"}),this.worker=null),this.gl&&(this.destroyPingPongMain(),this.vbo&&this.gl.deleteBuffer(this.vbo),this.vao&&this.gl.deleteVertexArray(this.vao),v.disposeContext(this.gl),this.gl.getExtension("WEBGL_lose_context")?.loseContext(),this.gl=null),this.markContextReleased(),g.releaseVec2(this.mouse),g.releaseVec2(this.targetMouse),g.releaseVec2(this.mouseVel),this.customUniforms.clear(),this.canvas.remove())}};R._activeContexts=0;var x=R;var U=class{constructor(){this.plugins=new Map;this.activeByElement=new WeakMap;this.activeSet=new Set;this.visibilityObserver=null;this.visibilityCallbacks=new WeakMap;this.removeTicker=null}ensureObserver(){return typeof window>"u"||typeof IntersectionObserver>"u"?null:(this.visibilityObserver||(this.visibilityObserver=new IntersectionObserver(e=>{for(let i=0;i<e.length;i++){let t=e[i],r=this.visibilityCallbacks.get(t.target);r&&r.forEach(s=>s(t.isIntersecting))}},{rootMargin:"50px"})),this.visibilityObserver)}ensureTicker(){this.removeTicker||(this.removeTicker=B.add((e,i)=>{this.activeSet.forEach(t=>{if(!(!t.visible||t.faulted||!t.instance.update))try{t.instance.update(e,i)}catch(r){t.faulted=!0,console.error(`[FluxFX] Runtime error in "${t.name}" (auto-paused):`,r)}})}))}stopTickerIfEmpty(){this.activeSet.size===0&&this.removeTicker&&(this.removeTicker(),this.removeTicker=null)}register(e){return this.plugins.set(e.name,e),this}has(e){return this.plugins.has(e)}getStats(){let e=0;this.activeSet.forEach(t=>{t.visible&&e++});let i=typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches;return{mounted:this.activeSet.size,visible:e,activeLoops:B.isRunning?1:0,registered:this.plugins.size,webglContexts:x.activeContexts,reducedMotion:i}}apply(e,i,t={}){let r=this.plugins.get(i);if(!r)return console.warn(`[FluxFX] Effect "${i}" is not registered.`),()=>{};let s=this.activeByElement.get(e);s||(s=new Map,this.activeByElement.set(e,s));let a=s.get(i);a&&a.destroy();let n;try{n=r.mount(e,t)}catch(h){return console.error(`[FluxFX] Failed to mount "${i}":`,h),()=>{}}let l=t.pauseWhenHidden??!0,u=null,d=!1,f={el:e,name:i,plugin:r,instance:n,visible:!0,faulted:!1,destroy:()=>{if(!d){d=!0,u?.(),this.activeSet.delete(f),s?.delete(i);try{f.instance.destroy()}catch(h){console.error(`[FluxFX] Cleanup error in "${i}":`,h)}this.stopTickerIfEmpty()}}};if(l){let h=this.ensureObserver();if(h){let m=this.visibilityCallbacks.get(e);m||(m=new Set,this.visibilityCallbacks.set(e,m),h.observe(e));let p=b=>{f.visible=b,b?f.instance.resume?.():f.instance.pause?.()};m.add(p),u=()=>{m?.delete(p),m&&m.size===0&&(h.unobserve(e),this.visibilityCallbacks.delete(e))}}}return s.set(i,f),this.activeSet.add(f),f.instance.update&&this.ensureTicker(),f.destroy}update(e,i,t={}){let s=this.activeByElement.get(e)?.get(i);if(!s)return!1;if(s.instance.setOptions)try{return s.instance.setOptions(t),!0}catch(a){return console.error(`[FluxFX] Hot-update error in "${i}":`,a),!1}try{return s.instance.destroy(),s.instance=s.plugin.mount(e,t),s.faulted=!1,s.visible||s.instance.pause?.(),s.instance.update&&this.ensureTicker(),!0}catch(a){return s.faulted=!0,console.error(`[FluxFX] Fallback remount error in "${i}":`,a),!1}}scan(e=document){if(typeof document>"u")return;e.querySelectorAll("[data-fx]").forEach(t=>{let r=t.getAttribute("data-fx");if(!r)return;let s=r.trim().split(/\s+/).filter(Boolean),a=this.parseDatasetOptions(t),n=this.activeByElement.get(t);s.forEach(l=>{n?.has(l)||this.apply(t,l,a)})})}init(e){typeof document>"u"||(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>this.scan(e??document),{once:!0}):this.scan(e??document))}destroyAll(){let e=Array.from(this.activeSet);for(let i=0;i<e.length;i++)e[i].destroy()}parseDatasetOptions(e){let i={};for(let[t,r]of Object.entries(e.dataset)){if(!t.startsWith("fx")||t==="fx"||r===void 0)continue;let s=t.slice(2),a=s.charAt(0).toLowerCase()+s.slice(1);r==="true"?i[a]=!0:r==="false"?i[a]=!1:r!==""&&!Number.isNaN(Number(r))?i[a]=Number(r):i[a]=r}return i}},_=new U;var be=`#version 300 es
|
|
681
681
|
precision highp float;
|
|
682
682
|
|
|
683
683
|
in vec2 vUv;
|
|
@@ -1137,10 +1137,6 @@ vec2 decodeVel(vec4 s) {
|
|
|
1137
1137
|
return (s.rg - 0.5) * 2.0;
|
|
1138
1138
|
}
|
|
1139
1139
|
|
|
1140
|
-
float hash11(float n) {
|
|
1141
|
-
return fract(sin(n) * 43758.5453123);
|
|
1142
|
-
}
|
|
1143
|
-
|
|
1144
1140
|
void main() {
|
|
1145
1141
|
vec2 texel = 1.0 / max(uResolution, vec2(1.0));
|
|
1146
1142
|
float dt = clamp(uDelta, 0.004, 0.033);
|
|
@@ -1238,6 +1234,7 @@ uniform sampler2D uFeedback;
|
|
|
1238
1234
|
uniform float uTime;
|
|
1239
1235
|
uniform vec2 uResolution;
|
|
1240
1236
|
uniform vec3 uBgColor;
|
|
1237
|
+
uniform float uTransparentBg;
|
|
1241
1238
|
uniform float uLightMode;
|
|
1242
1239
|
uniform float uAbsorptionGain;
|
|
1243
1240
|
uniform vec3 uColor1;
|
|
@@ -1273,26 +1270,34 @@ void main() {
|
|
|
1273
1270
|
vec3 tintMix = normalize(uColor1 * pA + uColor2 * pB + uColor3 * (pA * pB * 1.8) + vec3(0.0001));
|
|
1274
1271
|
float totalInk = (pA + pB * 0.85) * uAbsorptionGain;
|
|
1275
1272
|
|
|
1276
|
-
// Light water: Beer-Lambert exponential light absorption
|
|
1273
|
+
// Light water: Beer-Lambert exponential light absorption on solid bg
|
|
1277
1274
|
vec3 transmittance = exp(-tintMix * totalInk * 1.35);
|
|
1278
1275
|
float inkMask = clamp(1.0 - exp(-hC * 1.5), 0.0, 1.0);
|
|
1279
1276
|
vec3 lightCol = uBgColor * transmittance;
|
|
1280
1277
|
lightCol *= mix(1.0, 0.90 + 0.16 * diffuse, inkMask * 0.72);
|
|
1281
1278
|
lightCol += vec3(0.025) * rimSheen * inkMask * (1.0 - inkMask * 0.45);
|
|
1282
1279
|
|
|
1283
|
-
// Dark water: Luminous bioluminescent plumes on
|
|
1280
|
+
// Dark water: Luminous bioluminescent plumes on solid bg
|
|
1284
1281
|
vec3 luminous = (vec3(1.0) - exp(-tintMix * totalInk * 1.25)) * (0.86 + 0.24 * diffuse);
|
|
1285
1282
|
vec3 darkCol = uBgColor + luminous + luminous * rimSheen * 0.12;
|
|
1286
1283
|
|
|
1287
|
-
vec3
|
|
1284
|
+
vec3 opaqueCol = mix(darkCol, lightCol, clamp(uLightMode, 0.0, 1.0));
|
|
1288
1285
|
|
|
1289
|
-
// Subtle vignette + fine organic grain
|
|
1286
|
+
// Subtle vignette + fine organic grain on solid bg
|
|
1290
1287
|
vec2 centered = vUv - 0.5;
|
|
1291
1288
|
float vignetteStrength = mix(0.36, 0.085, clamp(uLightMode, 0.0, 1.0));
|
|
1292
|
-
|
|
1293
|
-
|
|
1289
|
+
opaqueCol *= (1.0 - dot(centered, centered) * vignetteStrength);
|
|
1294
1290
|
float grain = (hash12(vUv * 900.0 + fract(uTime * 0.05)) - 0.5) * 0.011;
|
|
1295
|
-
|
|
1291
|
+
opaqueCol = clamp(opaqueCol + grain, 0.0, 1.0);
|
|
1296
1292
|
|
|
1297
|
-
|
|
1298
|
-
|
|
1293
|
+
// Transparent backdrop mode: only render pigment/ink with alpha over page/body bg
|
|
1294
|
+
float inkAlpha = clamp(1.0 - exp(-totalInk * 1.35), 0.0, 1.0);
|
|
1295
|
+
vec3 inkRgb = clamp(tintMix * (0.82 + 0.28 * diffuse) + vec3(0.04) * rimSheen, 0.0, 1.0);
|
|
1296
|
+
|
|
1297
|
+
if (uTransparentBg > 0.5) {
|
|
1298
|
+
// Premultiplied alpha works cleanly with standard canvas alpha blending
|
|
1299
|
+
fragColor = vec4(inkRgb * inkAlpha, inkAlpha);
|
|
1300
|
+
} else {
|
|
1301
|
+
fragColor = vec4(opaqueCol, 1.0);
|
|
1302
|
+
}
|
|
1303
|
+
}`,ce=["#1e3a5f","#2d3748","#0284c7"],Le="#f5f3ee";function Te(o){if(o==null)return!1;let e=String(o).trim().toLowerCase();if(!e||e==="transparent"||e==="none")return!0;let i=e.match(/^rgba?\(\s*[\d.]+\s*,\s*[\d.]+\s*,\s*[\d.]+(?:\s*,\s*([\d.]+))?\s*\)$/);return i&&i[1]!==void 0?parseFloat(i[1])<=.001:!1}function Se(o){let e=o.replace("#","").trim(),i=e.length===3?e.split("").map(n=>n+n).join(""):e;if(i.length!==6)return!0;let t=parseInt(i.slice(0,2),16)/255,r=parseInt(i.slice(2,4),16)/255,s=parseInt(i.slice(4,6),16)/255;return .2126*t+.7152*r+.0722*s>.45}function le(o,e){if(Array.isArray(o.colors)){let t=c(o.colors[0],e[0]),r=c(o.colors[1]??t,e[1]),s=c(o.colors[2]??t,e[2]);return[t,r,s]}if(typeof o.colors=="string"){let t=o.colors.split(",").map(r=>r.trim()).filter(Boolean);if(t.length===1){let r=c(t[0],e[0]);return[r,r,c(e[2],e[2])]}return[c(t[0],e[0]),c(t[1],e[1]),c(t[2]??t[0],e[2])]}return[c(o.color1,e[0]),c(o.color2,e[1]),c(o.color3,e[2])]}function ue(o){let e=Te(o.bgColor),i=e?"#000000":c(o.bgColor,Le),t=g.hexToVec3Into(i,g.scratchVec3),r=Se(i)?1:0,s=typeof o.lightMode=="number"?o.lightMode:typeof o.lightMode=="boolean"?o.lightMode?1:0:r;return{uBgColor:[t[0],t[1],t[2]],uTransparentBg:e?1:0,uLightMode:s,uAbsorptionGain:typeof o.absorptionGain=="number"?o.absorptionGain:1.45,uDissipation:typeof o.dissipation=="number"?o.dissipation:.978,uRadius:typeof o.radius=="number"?o.radius:.0032,uCurl:typeof o.curl=="number"?o.curl:1.85}}var de={name:"aetheria",mount(o,e){let i=new x(o,{fragmentShader:Fe,feedbackShader:Ee,feedbackScale:e.quality==="high"?.65:e.quality==="low"?.35:.5,feedbackFloat:!0,speed:typeof e.speed=="number"?e.speed:1,quality:e.quality??"medium",colors:le(e,ce),uniforms:ue(e),interactive:e.interactive!==!1,dynamicResolution:e.dynamicResolution,minDpr:e.minDpr,maxDpr:e.maxDpr,offscreen:e.offscreen,pauseWhenHidden:e.pauseWhenHidden,respectReducedMotion:e.respectReducedMotion});return{update(t,r){i.render(t,r)},setOptions(t){i.updateOptions({speed:typeof t.speed=="number"?t.speed:1,quality:t.quality,colors:le(t,ce),uniforms:ue(t),interactive:t.interactive!==!1,respectReducedMotion:t.respectReducedMotion})},pause(){i.pause()},resume(){i.resume()},destroy(){i.destroy()}}}};var fe={name:"tilt-3d",mount(o,e){let i=typeof e.maxTilt=="number"?e.maxTilt:12,t=typeof e.scale=="number"?e.scale:1.03,r=typeof e.perspective=="number"?e.perspective:900,s=e.glare!==!1,a=o.style.transform,n=o.style.position,l=o.style.overflow,u=o.style.willChange;o.style.willChange="transform";let d=null;s&&(getComputedStyle(o).position==="static"&&(o.style.position="relative"),o.style.overflow="hidden",d=document.createElement("div"),Object.assign(d.style,{position:"absolute",inset:"0",pointerEvents:"none",borderRadius:"inherit",opacity:"0",transition:"opacity 0.25s ease",zIndex:"2"}),o.appendChild(d));let f=0,h=0,m=1,p=0,b=0,y=1,S=50,M=50,A=!1,W=I=>{let F=o.getBoundingClientRect(),L=(I.clientX-F.left)/F.width,G=(I.clientY-F.top)/F.height;f=(.5-G)*i*2,h=(L-.5)*i*2,m=t,S=L*100,M=G*100,A=!0,d&&(d.style.opacity="1")},z=()=>{f=0,h=0,m=1,A=!0,d&&(d.style.opacity="0")};return o.addEventListener("pointermove",W,{passive:!0}),o.addEventListener("pointerleave",z,{passive:!0}),{update(I,F){if(!A)return;let L=1-Math.exp(-12*F);p+=(f-p)*L,b+=(h-b)*L,y+=(m-y)*L,o.style.transform=`perspective(${r}px) rotateX(${p.toFixed(2)}deg) rotateY(${b.toFixed(2)}deg) scale3d(${y.toFixed(3)}, ${y.toFixed(3)}, 1)`,d&&(d.style.background=`radial-gradient(circle at ${S.toFixed(1)}% ${M.toFixed(1)}%, rgba(255,255,255,0.22), transparent 60%)`),Math.abs(f-p)<.02&&Math.abs(h-b)<.02&&Math.abs(m-y)<.001&&(A=!1,m===1&&(o.style.transform=a))},destroy(){o.removeEventListener("pointermove",W),o.removeEventListener("pointerleave",z),d?.remove(),o.style.transform=a,o.style.position=n,o.style.overflow=l,o.style.willChange=u}}}};var me={name:"magnetic",mount(o,e){let i=typeof e.strength=="number"?e.strength:.35,t=o.style.transform,r=o.style.willChange;o.style.willChange="transform";let s=0,a=0,n=0,l=0,u=!1,d=h=>{let m=o.getBoundingClientRect(),p=m.left+m.width/2,b=m.top+m.height/2;s=(h.clientX-p)*i,a=(h.clientY-b)*i,u=!0},f=()=>{s=0,a=0,u=!0};return o.addEventListener("pointermove",d,{passive:!0}),o.addEventListener("pointerleave",f,{passive:!0}),{update(h,m){if(!u)return;let p=1-Math.exp(-10*m);n+=(s-n)*p,l+=(a-l)*p,o.style.transform=`translate3d(${n.toFixed(2)}px, ${l.toFixed(2)}px, 0)`,Math.abs(s-n)<.05&&Math.abs(a-l)<.05&&(u=!1,s===0&&a===0&&(o.style.transform=t))},destroy(){o.removeEventListener("pointermove",d),o.removeEventListener("pointerleave",f),o.style.transform=t,o.style.willChange=r}}}};_.register(K).register(Z).register(re).register(ae).register(de).register(fe).register(me);var X=_;typeof window<"u"&&(window.FluxFX=_);function E(o,e={},i=!1){let t=O(null),r=Array.isArray(o)?o.join(" "):o,s=JSON.stringify(e),a=O(s);a.current=s;let n=O(!1),l=O(null);return he(()=>{if(i||typeof window>"u")return;let u=t.current;if(!u||!r.trim())return;let d=a.current,f=JSON.parse(d),m=r.trim().split(/\s+/).map(p=>X.apply(u,p,f));return n.current=!0,l.current=d,()=>{n.current=!1,l.current=null,m.forEach(p=>p())}},[r,i]),he(()=>{if(!n.current||i||typeof window>"u"||l.current===s)return;let u=t.current;if(!u||!r.trim())return;let d=JSON.parse(s);r.trim().split(/\s+/).forEach(h=>{X.update(u,h,d)}),l.current=s},[s,r,i]),t}function xt({as:o="section",speed:e=1,quality:i="medium",colors:t=["#4f46e5","#06b6d4","#ec4899"],interactive:r=!0,respectReducedMotion:s=!0,disabled:a=!1,children:n,...l}){let u=E("aurora",{speed:e,quality:i,color1:t[0],color2:t[1],color3:t[2],interactive:r,respectReducedMotion:s},a);return w.createElement(o,{ref:u,...l},n)}function Mt({as:o="section",speed:e=1,quality:i="medium",colors:t=["#0f172a","#94a3b8","#38bdf8"],interactive:r=!0,respectReducedMotion:s=!0,disabled:a=!1,children:n,...l}){let u=E("liquid-metal",{speed:e,quality:i,color1:t[0],color2:t[1],color3:t[2],interactive:r,respectReducedMotion:s},a);return w.createElement(o,{ref:u,...l},n)}function Rt({as:o="section",speed:e=1,quality:i="medium",colors:t=["#6366f1","#06b6d4","#f43f5e"],dissipation:r=.975,radius:s=.0045,swirl:a=1.4,interactive:n=!0,respectReducedMotion:l=!0,disabled:u=!1,children:d,...f}){let h=E("fluid",{speed:e,quality:i,color1:t[0],color2:t[1],color3:t[2],dissipation:r,radius:s,swirl:a,interactive:n,respectReducedMotion:l},u);return w.createElement(o,{ref:h,...f},d)}function wt({as:o="div",maxTilt:e=12,scale:i=1.03,perspective:t=900,glare:r=!0,disabled:s=!1,children:a,...n}){let l=E("tilt-3d",{maxTilt:e,scale:i,perspective:t,glare:r},s);return w.createElement(o,{ref:l,...n},a)}function Et({as:o="div",strength:e=.35,disabled:i=!1,style:t,children:r,...s}){let a=E("magnetic",{strength:e},i);return w.createElement(o,{ref:a,style:{display:"inline-block",...t},...s},r)}function Ft({as:o="section",speed:e=1,quality:i="medium",colors:t=["#1e1b4b","#0284c7","#e11d48"],dissipation:r=.982,radius:s=.004,curl:a=1.75,interactive:n=!0,respectReducedMotion:l=!0,disabled:u=!1,children:d,...f}){let h=E("ink",{speed:e,quality:i,color1:t[0],color2:t[1],color3:t[2],dissipation:r,radius:s,curl:a,interactive:n,respectReducedMotion:l},u);return w.createElement(o,{ref:h,...f},d)}function Lt({as:o="section",speed:e=1,quality:i="medium",colors:t=["#1e3a5f","#2d3748","#0284c7"],bgColor:r="#f5f3ee",lightMode:s,absorptionGain:a=1.45,dissipation:n=.978,radius:l=.0032,curl:u=1.85,interactive:d=!0,respectReducedMotion:f=!0,disabled:h=!1,children:m,...p}){let b=E("aetheria",{speed:e,quality:i,color1:t[0],color2:t[1],color3:t[2],bgColor:r,lightMode:s,absorptionGain:a,dissipation:n,radius:l,curl:u,interactive:d,respectReducedMotion:f},h);return w.createElement(o,{ref:b,...p},m)}export{Lt as Aetheria,xt as Aurora,Rt as Fluid,Ft as Ink,Mt as LiquidMetal,Et as Magnetic,wt as TiltCard,E as useFX};
|
package/package.json
CHANGED
|
@@ -1,50 +1,41 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@votax572002/fluxfx",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "A collection of WebGL shaders and DOM effects for creative coding.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
7
|
-
"files":
|
|
8
|
-
[
|
|
7
|
+
"files": [
|
|
9
8
|
"dist"
|
|
10
9
|
],
|
|
11
10
|
"main": "./dist/index.cjs",
|
|
12
11
|
"module": "./dist/index.js",
|
|
13
12
|
"types": "./dist/index.d.ts",
|
|
14
|
-
"exports":
|
|
15
|
-
|
|
16
|
-
".":
|
|
17
|
-
{
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
18
15
|
"types": "./dist/index.d.ts",
|
|
19
16
|
"import": "./dist/index.js",
|
|
20
17
|
"require": "./dist/index.cjs"
|
|
21
18
|
},
|
|
22
|
-
"./react":
|
|
23
|
-
{
|
|
19
|
+
"./react": {
|
|
24
20
|
"types": "./dist/react.d.ts",
|
|
25
21
|
"import": "./dist/react.js",
|
|
26
22
|
"require": "./dist/react.cjs"
|
|
27
23
|
}
|
|
28
24
|
},
|
|
29
|
-
"peerDependencies":
|
|
30
|
-
{
|
|
25
|
+
"peerDependencies": {
|
|
31
26
|
"react": ">=18.0.0"
|
|
32
27
|
},
|
|
33
|
-
"peerDependenciesMeta":
|
|
34
|
-
|
|
35
|
-
"react":
|
|
36
|
-
{
|
|
28
|
+
"peerDependenciesMeta": {
|
|
29
|
+
"react": {
|
|
37
30
|
"optional": true
|
|
38
31
|
}
|
|
39
32
|
},
|
|
40
|
-
"scripts":
|
|
41
|
-
{
|
|
33
|
+
"scripts": {
|
|
42
34
|
"dev": "vite",
|
|
43
35
|
"build": "tsup",
|
|
44
36
|
"prepublishOnly": "npm run build"
|
|
45
37
|
},
|
|
46
|
-
"devDependencies":
|
|
47
|
-
{
|
|
38
|
+
"devDependencies": {
|
|
48
39
|
"@types/react": "^19.0.0",
|
|
49
40
|
"@types/react-dom": "^19.0.0",
|
|
50
41
|
"@vitejs/plugin-react": "^4.3.4",
|
|
@@ -54,4 +45,4 @@
|
|
|
54
45
|
"typescript": "^5.6.0",
|
|
55
46
|
"vite": "^6.0.0"
|
|
56
47
|
}
|
|
57
|
-
}
|
|
48
|
+
}
|