oops-ui 0.0.4 → 0.0.5
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/types/components/ripples/index.d.ts +1 -0
- package/dist/types/customHooks/index.d.ts +1 -0
- package/dist/types/customHooks/useRipples/index.d.ts +2 -2
- package/dist/types/index.d.ts +1 -0
- package/dist/useRipples/index.cjs +1 -1
- package/dist/useRipples/index.mjs +1 -1
- package/package.json +8 -4
|
@@ -2,3 +2,4 @@ export { useInputIsComposing } from './useInputIsComposing';
|
|
|
2
2
|
export { useTimeId } from './useTimeId';
|
|
3
3
|
export { useAnimationFrameId } from './useAnimationFrame';
|
|
4
4
|
export { useRipples } from './useRipples/index';
|
|
5
|
+
export type { Ripples, BackgroundRipplesProps, RipplesOptions } from './useRipples/index';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BackgroundRipplesProps } from './interface';
|
|
1
|
+
import { BackgroundRipplesProps, RipplesOptions } from './interface';
|
|
2
2
|
import { Ripples } from './ripplesClass';
|
|
3
3
|
/**************************************
|
|
4
4
|
*
|
|
@@ -43,4 +43,4 @@ import { Ripples } from './ripplesClass';
|
|
|
43
43
|
*
|
|
44
44
|
**************************************/
|
|
45
45
|
export declare function useRipples(canvas: React.RefObject<HTMLCanvasElement>, props?: BackgroundRipplesProps): React.RefObject<Ripples>;
|
|
46
|
-
export { Ripples };
|
|
46
|
+
export type { Ripples, BackgroundRipplesProps, RipplesOptions };
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(()=>{"use strict";var e={953:e=>{e.exports=require("react")}},t={};function r(n){var i=t[n];if(void 0!==i)return i.exports;var o=t[n]={exports:{}};return e[n](o,o.exports,r),o.exports}r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};r.r(n),r.d(n,{Ripples:()=>oe,useRipples:()=>ye});var i=r(953);const o=require("a-element-inline-style");function a(e){var t=/url\(["']?([^"']*)["']?\)/.exec(e);return null==t?null:t[1]}function s(e,t,r,n){function i(e,t){var n=r.createShader(e);if(r.shaderSource(n,t),r.compileShader(n),!r.getShaderParameter(n,r.COMPILE_STATUS))throw new Error("compile error: "+r.getShaderInfoLog(n));return n}var o,a={id:r.createProgram(),uniforms:{},locations:{}};if(r.attachShader(a.id,i(r.VERTEX_SHADER,e)),r.attachShader(a.id,i(r.FRAGMENT_SHADER,t)),r.linkProgram(a.id),!r.getProgramParameter(a.id,r.LINK_STATUS))throw new Error("link error: "+r.getProgramInfoLog(a.id));r.useProgram(a.id),r.enableVertexAttribArray(0);for(var s=e+t,l=/uniform (\w+) (\w+)/g;null!==(o=l.exec(s));){var u=o[2];a.locations[u]=r.getUniformLocation(a.id,u)}return a}function l(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=this.gl;r.activeTexture(r.TEXTURE0+(t||0)),r.bindTexture(r.TEXTURE_2D,e)}function u(e){return e.endsWith("%")}function c(){var e=this,t=function(){return e.initState=!1,null};if(!this.gl)return t();var r=this.gl,n=Object.fromEntries(["OES_texture_float","OES_texture_half_float","OES_texture_float_linear","OES_texture_half_float_linear"].reduce((function(e,t){var n=r.getExtension(t);return n&&e.push([t,n]),e}),[]));if(!n.OES_texture_float)return t();var i=[];function o(e,t,r){var i="OES_texture_"+e,o=i+"_linear",a=o in n;return{type:t,linearSupport:a,arrayType:r,extensions:a?[i,o]:[i]}}i.push(o("float",r.FLOAT,Float32Array)),n.OES_texture_half_float&&i.push(o("half_float",n.OES_texture_half_float.HALF_FLOAT_OES,null));var a=r.createTexture(),s=r.createFramebuffer();r.bindFramebuffer(r.FRAMEBUFFER,s),r.bindTexture(r.TEXTURE_2D,a),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.NEAREST),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.NEAREST),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE);for(var l=null,u=0;u<i.length;u++)if(r.texImage2D(r.TEXTURE_2D,0,r.RGBA,32,32,0,r.RGBA,i[u].type,null),r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,a,0),r.checkFramebufferStatus(r.FRAMEBUFFER)===r.FRAMEBUFFER_COMPLETE){l=i[u];break}return l}function f(e){return f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},f(e)}function h(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,m(n.key),n)}}function p(e,t,r){return t&&h(e.prototype,t),r&&h(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function d(e,t,r){return(t=m(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function m(e){var t=function(e){if("object"!=f(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=f(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==f(t)?t:t+""}var v="lmssee_ripper_element_style",g=p((function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),d(this,"styleElement",document.createElement("style")),d(this,"canvas",void 0),d(this,"gl",void 0),d(this,"config",void 0),d(this,"transparentPixels",function(){try{return new ImageData(32,32)}catch(e){return console.log(e&&""),document.createElement("canvas").getContext("2d").createImageData(32,32)}}()),d(this,"initState",!0),this.canvas=t;var r=t.getContext("webgl");if(null===r)return this.initState=!1,void(this.config=null);if(this.gl=r,null===document.querySelector("style#".concat(v))){var n=this.styleElement;n.id=v,n.innerHTML="\n .lmssee-ripples { \n position: relative; \n z-index: 0; \n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n transform: translate(0,0);\n }\n ";var i=document.head;i.prepend?i.prepend(n):i.insertBefore(n,i.firstChild)}this.config=Reflect.apply(c,this,[])})),E={imageUrl:"",resolution:360,dropRadius:10,perturbance:.03,interactive:!0,crossOrigin:"",playingState:!0,accelerating:3,raindropsTimeInterval:660,idleFluctuations:!0};function b(e){return b="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},b(e)}function y(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function T(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?y(Object(r),!0).forEach((function(t){A(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):y(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function R(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,O(n.key),n)}}function w(e,t){if(t&&("object"==b(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function _(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(_=function(){return!!e})()}function x(e){return x=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},x(e)}function P(e,t){return P=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},P(e,t)}function S(e,t,r){F(e,t),t.set(e,r)}function F(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function A(e,t,r){return(t=O(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function O(e){var t=function(e){if("object"!=b(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=b(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==b(t)?t:t+""}function D(e,t){return e.get(U(e,t))}function k(e,t,r){return e.set(U(e,t),r),r}function U(e,t,r){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:r;throw new TypeError("Private element is not present on this object")}Object.freeze(E);var M=new WeakMap,L=new WeakMap,C=new WeakMap,I=new WeakMap,W=new WeakMap,X=new WeakMap,j=new WeakMap,B=new WeakMap,N=new WeakMap,G=new WeakMap,z=new WeakMap,H=new WeakMap,Y=new WeakMap,q=new WeakMap,K=new WeakMap,V=new WeakMap,J=new WeakMap,Q=new WeakMap,Z=new WeakMap,$=new WeakMap,ee=new WeakMap,te=new WeakMap,re=new WeakMap,ne=new WeakMap,ie=new WeakSet,oe=function(e){function t(e,r,n){var i,a,s;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),i=function(e,t,r){return t=x(t),w(e,_()?Reflect.construct(t,r||[],x(e).constructor):t.apply(e,r))}(this,t,[e]),F(a=i,s=ie),s.add(a),A(i,"defaults",E),A(i,"interactive",i.defaults.interactive),S(i,M,i.defaults.accelerating),S(i,L,i.defaults.resolution),S(i,C,i.defaults.perturbance),A(i,"dropRadius",void 0),A(i,"crossOrigin",""),A(i,"imageUrl",void 0),A(i,"idleFluctuations",!0),S(i,I,void 0),S(i,W,void 0),S(i,X,[]),S(i,j,[]),S(i,B,0),S(i,N,1),S(i,G,void 0),S(i,z,!1),S(i,H,!1),S(i,Y,!1),S(i,q,0),S(i,K,""),A(i,"imageSource",""),A(i,"renderProgram",void 0),S(i,V,void 0),S(i,J,void 0),S(i,Q,void 0),S(i,Z,void 0),S(i,$,void 0),S(i,ee,void 0),S(i,te,Date.now()),S(i,re,i.defaults.raindropsTimeInterval),S(i,ne,{mousemove:function(e){return console.log(e)},mousedown:function(e){return console.log(e)},touchmove:function(e){return console.log(e)},touchstart:function(e){return console.log(e)}}),Object.defineProperties(i,{defaults:{value:i.defaults,writable:!1,enumerable:!1,configurable:!1}}),n&&"boolean"!=typeof n.interactive&&delete n.interactive;var l=T(T({},i.defaults),n);if(i.interactive=l.interactive,i.resolution=l.resolution,i.perturbance=l.perturbance,i.dropRadius=l.dropRadius,i.crossOrigin=l.crossOrigin,i.imageUrl=l.imageUrl,i.idleFluctuations=l.idleFluctuations,!1===i.initState||null===e.parentElement||null===i.config||null===i.gl)return i.initState=!1,w(i);var u=i.gl,c=1/D(L,i);k(W,i,new Float32Array([c,c])),k(I,i,e.parentElement),function(e){var t=e.parentElement;e.width=t.clientWidth,e.height=t.clientHeight,(0,o.setStyle)(e,{position:"absolute",left:0,top:0,right:0,bottom:0,zIndex:-1})}(e),i.config.extensions.forEach((function(e){return u.getExtension(e)})),i.updateSize=i.updateSize.bind(i),window.addEventListener("resize",i.updateSize);for(var f=i.config.arrayType,h=f?new f(D(L,i)*D(L,i)*4):null,p=i.config,d=0;d<2;d++){var m=u.createTexture(),v=u.createFramebuffer();u.bindFramebuffer(u.FRAMEBUFFER,v),u.bindTexture(u.TEXTURE_2D,m),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_MIN_FILTER,p.linearSupport?u.LINEAR:u.NEAREST),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_MAG_FILTER,p.linearSupport?u.LINEAR:u.NEAREST),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_WRAP_S,u.CLAMP_TO_EDGE),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_WRAP_T,u.CLAMP_TO_EDGE),u.texImage2D(u.TEXTURE_2D,0,u.RGBA,D(L,i),D(L,i),0,u.RGBA,p.type,h),u.framebufferTexture2D(u.FRAMEBUFFER,u.COLOR_ATTACHMENT0,u.TEXTURE_2D,m,0),D(X,i).push(m),D(j,i).push(v)}return k(G,i,u.createBuffer()),u.bindBuffer(u.ARRAY_BUFFER,D(G,i)),u.bufferData(u.ARRAY_BUFFER,new Float32Array([-1,-1,1,-1,1,1,-1,1]),u.STATIC_DRAW),U(ie,i,de).call(i),U(ie,i,me).call(i),U(ie,i,ve).call(i),U(ie,i,se).call(i),u.clearColor(0,0,0,0),u.blendFunc(u.SRC_ALPHA,u.ONE_MINUS_SRC_ALPHA),k(z,i,!0),k(H,i,!0),k(Y,i,!0),U(ie,i,ae).call(i),k(q,i,requestAnimationFrame((function(){return U(ie,i,le).call(i)}))),i}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&P(e,t)}(t,e),r=t,n=[{key:"accelerating",set:function(e){e>100||e<2||k(M,this,e)}},{key:"resolution",set:function(e){e<100||e>550||k(L,this,e)}},{key:"perturbance",set:function(e){e<1e-4||e>1||k(C,this,e)}},{key:"playingState",set:function(e){k(H,this,!1!==e)}},{key:"initialized",get:function(){return D(Y,this)}},{key:"raindropsTimeInterval",set:function(e){e<10||e>12e3||k(re,this,e)}},{key:"raindropsFall",value:function(){var e=window.getComputedStyle(D(I,this)),t=function(e){return function(e=1,t=0){let r=Math.ceil(Number(t)),n=Math.floor(Number(e));return r>n&&([n,r]=[r,n]),Math.floor(Math.random()*(n-r+1)+r)}(parseInt(e))},r=e.width,n=e.height;this.drop(t(r),t(n),1.5*this.dropRadius,.14)}},{key:"drop",value:function(e,t,r,n){var i=this.gl,o=D(I,this).offsetWidth,a=D(I,this).offsetHeight,s=Math.max(o,a);r/=s;var u=new Float32Array([(2*e-o)/s,(a-2*t)/s]);i.viewport(0,0,D(L,this),D(L,this)),i.bindFramebuffer(i.FRAMEBUFFER,D(j,this)[D(B,this)]),Reflect.apply(l,this,[D(X,this)[D(N,this)]]),i.useProgram(D(Q,this).id),i.uniform2fv(D(Q,this).locations.center,u),i.uniform1f(D(Q,this).locations.radius,r),i.uniform1f(D(Q,this).locations.strength,n),U(ie,this,ue).call(this),U(ie,this,he).call(this)}},{key:"updateSize",value:function(){var e=D(I,this).offsetWidth,t=D(I,this).offsetHeight;e==this.canvas.width&&t==this.canvas.height||(this.canvas.width=e,this.canvas.height=t)}},{key:"destroy",value:function(){var e=this,t=D(I,this);t&&(Object.keys(D(ne,this)).forEach((function(r){return t.removeEventListener&&t.removeEventListener(r,D(ne,e)[r])})),t.removeAttribute&&t.removeAttribute("data-ripples")),this.styleElement&&this.styleElement.remove(),this.gl=null,this.gl&&(this.gl=null),window.removeEventListener("resize",this.updateSize),U(ie,this,Ee).call(this),D(q,this)&&window.cancelAnimationFrame(D(q,this))}},{key:"show",value:function(){k(z,this,!0),this.canvas.style.visibility="visible",U(ie,this,ge).call(this)}},{key:"hide",value:function(){k(z,this,!1),this.canvas.style.visibility="hidden",U(ie,this,Ee).call(this)}},{key:"pause",value:function(){k(H,this,!1)}},{key:"play",value:function(){k(H,this,!0)}},{key:"changePlayingState",value:function(){k(H,this,!D(H,this))}},{key:"set",value:function(e,t){"imageUrl"===e?(this.imageUrl=t,U(ie,this,se).call(this)):this[e]=t}}],n&&R(r.prototype,n),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n}(g);function ae(){var e=this,t=function(t){var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];D(z,e)&&D(H,e)&&e.interactive&&(k(te,e,Date.now()),U(ie,e,be).call(e,t,e.dropRadius*(r?1.5:1),r?.14:.01))};D(ne,this).mousemove=function(r){for(var n=D(M,e);n--;)t(r)},D(ne,this).touchmove=D(ne,this).touchstart=function(e){for(var r=e.touches,n=0;n<r.length;n++)t(r[n])},D(ne,this).mousedown=function(e){return t(e,!0)},Object.keys(D(ne,this)).forEach((function(t){return D(I,e)&&D(I,e).addEventListener(t,D(ne,e)[t],{passive:!0})}))}function se(){var e=this,t=this.gl,r=this.imageUrl||a(D(K,this))||a(window.getComputedStyle(D(I,this)).backgroundImage);if(r!==this.imageSource)if(this.imageSource=r,this.imageSource){var n=new Image;n.onload=function(){var r=function(e){return!(e&e-1)},i=r(n.width)&&r(n.height)?t.REPEAT:t.CLAMP_TO_EDGE;t.bindTexture(t.TEXTURE_2D,D(V,e)),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,i),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,i),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,n),k(Z,e,n.width),k($,e,n.height),U(ie,e,ge).call(e)},n.onerror=function(){return U(ie,e,ve).call(e)},n.crossOrigin=this.imageSource.match(/^data:/)?null:this.crossOrigin,n.src=this.imageSource}else U(ie,this,ve).call(this)}function le(){var e=this;D(z,this)&&(U(ie,this,pe).call(this),D(H,this)&&U(ie,this,fe).call(this),U(ie,this,ce).call(this),k(q,this,requestAnimationFrame((function(){return U(ie,e,le).call(e)}))))}function ue(){var e=this.gl;e.bindBuffer(e.ARRAY_BUFFER,D(G,this)),e.vertexAttribPointer(0,2,e.FLOAT,!1,0,0),e.drawArrays(e.TRIANGLE_FAN,0,4)}function ce(){var e=this.gl;e.bindFramebuffer(e.FRAMEBUFFER,null),e.viewport(0,0,this.canvas.width,this.canvas.height),e.enable(e.BLEND),e.clear(e.COLOR_BUFFER_BIT|e.DEPTH_BUFFER_BIT),e.useProgram(this.renderProgram.id),Reflect.apply(l,this,[D(V,this),0]),Reflect.apply(l,this,[D(X,this)[0],1]),e.uniform1f(this.renderProgram.locations.perturbance,D(C,this)),e.uniform2fv(this.renderProgram.locations.topLeft,this.renderProgram.uniforms.topLeft),e.uniform2fv(this.renderProgram.locations.bottomRight,this.renderProgram.uniforms.bottomRight),e.uniform2fv(this.renderProgram.locations.containerRatio,this.renderProgram.uniforms.containerRatio),e.uniform1i(this.renderProgram.locations.samplerBackground,0),e.uniform1i(this.renderProgram.locations.samplerRipples,1),U(ie,this,ue).call(this),e.disable(e.BLEND)}function fe(){if(this.idleFluctuations){var e=Date.now();e-D(te,this)>D(re,this)&&(k(te,this,e),this.raindropsFall())}var t=this.gl;t.viewport(0,0,D(L,this),D(L,this)),t.bindFramebuffer(t.FRAMEBUFFER,D(j,this)[D(B,this)]),Reflect.apply(l,this,[D(X,this)[D(N,this)]]),t.useProgram(D(J,this).id),U(ie,this,ue).call(this),U(ie,this,he).call(this)}function he(){k(B,this,1-D(B,this)),k(N,this,1-D(N,this))}function pe(){var e,t,r,n=window.getComputedStyle(D(I,this)).backgroundSize,i=window.getComputedStyle(D(I,this)).backgroundAttachment,o=(e=window.getComputedStyle(D(I,this)).backgroundPosition,/\s+/.test(e)?e.replace(/center/,"50%").replace(/top|left/,"0%").replace(/bottom/,"100%").replace(/\s+/," ").split(" "):u(e)?[e,"50%"]:{center:["50%","50%"],top:["50%","0%"],bottom:["50%","100%"],left:["0%","50%"],right:["100%","50%"]}[e]),a="fixed"==i?{left:window.scrollX,top:window.scrollY,width:window.innerWidth,height:window.innerHeight}:{left:D(I,this).getBoundingClientRect().left,top:D(I,this).getBoundingClientRect().top,width:D(I,this).scrollWidth,height:D(I,this).scrollHeight};if("cover"==n){var s=Math.max(a.width/D(Z,this),a.height/D($,this));t=D(Z,this)*s,r=D($,this)*s}else if("contain"==n){var l=Math.min(a.width/D(Z,this),a.height/D($,this));t=D(Z,this)*l,r=D($,this)*l}else{var c=n.split(" ");t=c[0]||"",r=c[1]||t,u(t)?t=a.width*parseFloat(t)/100:"auto"!==t&&(t=parseFloat(t)),u(r)?r=a.height*parseFloat(r)/100:"auto"!==r&&(r=parseFloat(r)),"auto"==t&&"auto"==r?(t=D(Z,this),r=D($,this)):("auto"==t&&(t=D(Z,this)*(Number(r)/D($,this))),"auto"==r&&(r=D($,this)*(Number(t)/D(Z,this))))}var f=o&&o[0]||"0%",h=o&&o[1]||"0%";f=u(f)?(a.left+(a.width-Number(t))*parseFloat(f)/100).toString():(a.left+parseFloat(f)).toString(),h=u(h)?(a.top+(a.height-Number(r))*parseFloat(h)/100).toString():(a.top+parseFloat(h)).toString(),this.renderProgram.uniforms.topLeft=new Float32Array([(D(I,this).offsetLeft-Number(f))/Number(t),(D(I,this).offsetTop-Number(h))/Number(r)]),this.renderProgram.uniforms.bottomRight=new Float32Array([this.renderProgram.uniforms.topLeft[0]+D(I,this).clientWidth/Number(t),this.renderProgram.uniforms.topLeft[1]+D(I,this).clientHeight/Number(r)]);var p=Math.max(this.canvas.width,this.canvas.height);this.renderProgram.uniforms.containerRatio=new Float32Array([this.canvas.width/p,this.canvas.height/p])}function de(){var e=this.gl,t="\n attribute vec2 vertex;\n varying vec2 coord;\n void main() {\n coord = vertex * 0.5 + 0.5;\n gl_Position = vec4(vertex, 0.0, 1.0);\n }";k(Q,this,s(t,"precision highp float;\n\n const float PI = 3.141592653589793;\n uniform sampler2D texture;\n uniform vec2 center;\n uniform float radius;\n uniform float strength;\n\n varying vec2 coord;\n\n void main() {\n vec4 info = texture2D(texture, coord);\n\n float drop = max(0.0, 1.0 - length(center * 0.5 + 0.5 - coord) / radius);\n drop = 0.5 - cos(drop * PI) * 0.5;\n info.r += drop * strength;\n gl_FragColor = info;\n }",e)),k(J,this,s(t,"precision highp float;\n\n uniform sampler2D texture;\n uniform vec2 delta;\n\n varying vec2 coord;\n\n void main() {\n vec4 info = texture2D(texture, coord);\n \n vec2 dx = vec2(delta.x, 0.0);\n vec2 dy = vec2(0.0, delta.y);\n \n float average = (\n texture2D(texture, coord - dx).r +\n texture2D(texture, coord - dy).r +\n texture2D(texture, coord + dx).r +\n texture2D(texture, coord + dy).r\n ) * 0.25;\n \n info.g += (average - info.r) * 2.0;\n info.g *= 0.995;\n info.r += info.g;\n \n gl_FragColor = info;\n }\n ",this.gl)),e.uniform2fv(D(J,this).locations.delta,D(W,this)),this.renderProgram=s("\n precision highp float;\n\n attribute vec2 vertex;\n uniform vec2 topLeft;\n uniform vec2 bottomRight;\n uniform vec2 containerRatio;\n varying vec2 ripplesCoord;\n varying vec2 backgroundCoord;\n void main() {\n backgroundCoord = mix(topLeft, bottomRight, vertex * 0.5 + 0.5);\n backgroundCoord.y = 1.0 - backgroundCoord.y;\n ripplesCoord = vec2(vertex.x, -vertex.y) * containerRatio * 0.5 + 0.5;\n gl_Position = vec4(vertex.x, -vertex.y, 0.0, 1.0);\n }\n ","\n precision highp float;\n\n uniform sampler2D samplerBackground;\n uniform sampler2D samplerRipples;\n uniform vec2 delta;\n\n uniform float perturbance;\n varying vec2 ripplesCoord;\n varying vec2 backgroundCoord;\n\n void main() {\n float height = texture2D(samplerRipples, ripplesCoord).r;\n float heightX = texture2D(samplerRipples, vec2(ripplesCoord.x + delta.x, ripplesCoord.y)).r;\n float heightY = texture2D(samplerRipples, vec2(ripplesCoord.x, ripplesCoord.y + delta.y)).r;\n vec3 dx = vec3(delta.x, heightX - height, 0.0);\n vec3 dy = vec3(0.0, heightY - height, delta.y);\n vec2 offset = -normalize(cross(dy, dx)).xz;\n float specular = pow(max(0.0, dot(offset, normalize(vec2(-0.6, 1.0)))), 4.0);\n gl_FragColor = texture2D(samplerBackground, backgroundCoord + offset * perturbance) + specular;\n }",e),e.uniform2fv(this.renderProgram.locations.delta,D(W,this))}function me(){var e=this.gl;k(V,this,e.createTexture()),e.bindTexture(e.TEXTURE_2D,D(V,this)),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,1),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR)}function ve(){var e=this.gl;e.bindTexture(e.TEXTURE_2D,D(V,this)),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,this.transparentPixels)}function ge(){var e=D(I,this).style.backgroundImage;"none"!=e&&(k(ee,this,e),k(K,this,window.getComputedStyle(D(I,this)).backgroundImage),D(I,this).style.backgroundImage="none")}function Ee(){D(I,this).style.backgroundImage=D(ee,this)||""}function be(e,t,r){var n=window.getComputedStyle(D(I,this)),i=parseInt(n.borderLeftWidth)||0,o=parseInt(n.borderTopWidth)||0;this.drop(e.pageX-D(I,this).offsetLeft-i,e.pageY-D(I,this).offsetTop-o,t,r)}function ye(e,t){var r=(0,i.useRef)(null);return(0,i.useEffect)((function(){return r.current=new oe(e.current,void 0===t.children,t.option),function(){return r.current.destroy()}}),[]),r}module.exports["oops-ui"]=n})();
|
|
1
|
+
(()=>{"use strict";var e={953:e=>{e.exports=require("react")}},t={};function r(n){var i=t[n];if(void 0!==i)return i.exports;var o=t[n]={exports:{}};return e[n](o,o.exports,r),o.exports}r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};r.r(n),r.d(n,{useRipples:()=>ye});var i=r(953);const o=require("a-element-inline-style");function a(e){var t=/url\(["']?([^"']*)["']?\)/.exec(e);return null==t?null:t[1]}function s(e,t,r,n){function i(e,t){var n=r.createShader(e);if(r.shaderSource(n,t),r.compileShader(n),!r.getShaderParameter(n,r.COMPILE_STATUS))throw new Error("compile error: "+r.getShaderInfoLog(n));return n}var o,a={id:r.createProgram(),uniforms:{},locations:{}};if(r.attachShader(a.id,i(r.VERTEX_SHADER,e)),r.attachShader(a.id,i(r.FRAGMENT_SHADER,t)),r.linkProgram(a.id),!r.getProgramParameter(a.id,r.LINK_STATUS))throw new Error("link error: "+r.getProgramInfoLog(a.id));r.useProgram(a.id),r.enableVertexAttribArray(0);for(var s=e+t,l=/uniform (\w+) (\w+)/g;null!==(o=l.exec(s));){var u=o[2];a.locations[u]=r.getUniformLocation(a.id,u)}return a}function l(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=this.gl;r.activeTexture(r.TEXTURE0+(t||0)),r.bindTexture(r.TEXTURE_2D,e)}function u(e){return e.endsWith("%")}function c(){var e=this,t=function(){return e.initState=!1,null};if(!this.gl)return t();var r=this.gl,n=Object.fromEntries(["OES_texture_float","OES_texture_half_float","OES_texture_float_linear","OES_texture_half_float_linear"].reduce((function(e,t){var n=r.getExtension(t);return n&&e.push([t,n]),e}),[]));if(!n.OES_texture_float)return t();var i=[];function o(e,t,r){var i="OES_texture_"+e,o=i+"_linear",a=o in n;return{type:t,linearSupport:a,arrayType:r,extensions:a?[i,o]:[i]}}i.push(o("float",r.FLOAT,Float32Array)),n.OES_texture_half_float&&i.push(o("half_float",n.OES_texture_half_float.HALF_FLOAT_OES,null));var a=r.createTexture(),s=r.createFramebuffer();r.bindFramebuffer(r.FRAMEBUFFER,s),r.bindTexture(r.TEXTURE_2D,a),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.NEAREST),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.NEAREST),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE);for(var l=null,u=0;u<i.length;u++)if(r.texImage2D(r.TEXTURE_2D,0,r.RGBA,32,32,0,r.RGBA,i[u].type,null),r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,a,0),r.checkFramebufferStatus(r.FRAMEBUFFER)===r.FRAMEBUFFER_COMPLETE){l=i[u];break}return l}function f(e){return f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},f(e)}function h(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,m(n.key),n)}}function d(e,t,r){return t&&h(e.prototype,t),r&&h(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function p(e,t,r){return(t=m(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function m(e){var t=function(e){if("object"!=f(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=f(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==f(t)?t:t+""}var v="lmssee_ripper_element_style",g=d((function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),p(this,"styleElement",document.createElement("style")),p(this,"canvas",void 0),p(this,"gl",void 0),p(this,"config",void 0),p(this,"transparentPixels",function(){try{return new ImageData(32,32)}catch(e){return console.log(e&&""),document.createElement("canvas").getContext("2d").createImageData(32,32)}}()),p(this,"initState",!0),this.canvas=t;var r=t.getContext("webgl");if(null===r)return this.initState=!1,void(this.config=null);if(this.gl=r,null===document.querySelector("style#".concat(v))){var n=this.styleElement;n.id=v,n.innerHTML="\n .lmssee-ripples { \n position: relative; \n z-index: 0; \n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n transform: translate(0,0);\n }\n ";var i=document.head;i.prepend?i.prepend(n):i.insertBefore(n,i.firstChild)}this.config=Reflect.apply(c,this,[])})),E={imageUrl:"",resolution:360,dropRadius:10,perturbance:.03,interactive:!0,crossOrigin:"",playingState:!0,accelerating:3,raindropsTimeInterval:660,idleFluctuations:!0};function b(e){return b="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},b(e)}function y(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function T(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?y(Object(r),!0).forEach((function(t){A(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):y(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function R(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,O(n.key),n)}}function w(e,t){if(t&&("object"==b(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function _(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(_=function(){return!!e})()}function x(e){return x=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},x(e)}function P(e,t){return P=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},P(e,t)}function S(e,t,r){F(e,t),t.set(e,r)}function F(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function A(e,t,r){return(t=O(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function O(e){var t=function(e){if("object"!=b(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=b(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==b(t)?t:t+""}function D(e,t){return e.get(U(e,t))}function k(e,t,r){return e.set(U(e,t),r),r}function U(e,t,r){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:r;throw new TypeError("Private element is not present on this object")}Object.freeze(E);var M=new WeakMap,L=new WeakMap,C=new WeakMap,I=new WeakMap,W=new WeakMap,X=new WeakMap,j=new WeakMap,B=new WeakMap,N=new WeakMap,G=new WeakMap,z=new WeakMap,H=new WeakMap,Y=new WeakMap,q=new WeakMap,K=new WeakMap,V=new WeakMap,J=new WeakMap,Q=new WeakMap,Z=new WeakMap,$=new WeakMap,ee=new WeakMap,te=new WeakMap,re=new WeakMap,ne=new WeakMap,ie=new WeakSet,oe=function(e){function t(e,r,n){var i,a,s;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),i=function(e,t,r){return t=x(t),w(e,_()?Reflect.construct(t,r||[],x(e).constructor):t.apply(e,r))}(this,t,[e]),F(a=i,s=ie),s.add(a),A(i,"defaults",E),A(i,"interactive",i.defaults.interactive),S(i,M,i.defaults.accelerating),S(i,L,i.defaults.resolution),S(i,C,i.defaults.perturbance),A(i,"dropRadius",void 0),A(i,"crossOrigin",""),A(i,"imageUrl",void 0),A(i,"idleFluctuations",!0),S(i,I,void 0),S(i,W,void 0),S(i,X,[]),S(i,j,[]),S(i,B,0),S(i,N,1),S(i,G,void 0),S(i,z,!1),S(i,H,!1),S(i,Y,!1),S(i,q,0),S(i,K,""),A(i,"imageSource",""),A(i,"renderProgram",void 0),S(i,V,void 0),S(i,J,void 0),S(i,Q,void 0),S(i,Z,void 0),S(i,$,void 0),S(i,ee,void 0),S(i,te,Date.now()),S(i,re,i.defaults.raindropsTimeInterval),S(i,ne,{mousemove:function(e){return console.log(e)},mousedown:function(e){return console.log(e)},touchmove:function(e){return console.log(e)},touchstart:function(e){return console.log(e)}}),Object.defineProperties(i,{defaults:{value:i.defaults,writable:!1,enumerable:!1,configurable:!1}}),n&&"boolean"!=typeof n.interactive&&delete n.interactive;var l=T(T({},i.defaults),n);if(i.interactive=l.interactive,i.resolution=l.resolution,i.perturbance=l.perturbance,i.dropRadius=l.dropRadius,i.crossOrigin=l.crossOrigin,i.imageUrl=l.imageUrl,i.idleFluctuations=l.idleFluctuations,!1===i.initState||null===e.parentElement||null===i.config||null===i.gl)return i.initState=!1,w(i);var u=i.gl,c=1/D(L,i);k(W,i,new Float32Array([c,c])),k(I,i,e.parentElement),function(e){var t=e.parentElement;e.width=t.clientWidth,e.height=t.clientHeight,(0,o.setStyle)(e,{position:"absolute",left:0,top:0,right:0,bottom:0,zIndex:-1})}(e),i.config.extensions.forEach((function(e){return u.getExtension(e)})),i.updateSize=i.updateSize.bind(i),window.addEventListener("resize",i.updateSize);for(var f=i.config.arrayType,h=f?new f(D(L,i)*D(L,i)*4):null,d=i.config,p=0;p<2;p++){var m=u.createTexture(),v=u.createFramebuffer();u.bindFramebuffer(u.FRAMEBUFFER,v),u.bindTexture(u.TEXTURE_2D,m),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_MIN_FILTER,d.linearSupport?u.LINEAR:u.NEAREST),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_MAG_FILTER,d.linearSupport?u.LINEAR:u.NEAREST),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_WRAP_S,u.CLAMP_TO_EDGE),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_WRAP_T,u.CLAMP_TO_EDGE),u.texImage2D(u.TEXTURE_2D,0,u.RGBA,D(L,i),D(L,i),0,u.RGBA,d.type,h),u.framebufferTexture2D(u.FRAMEBUFFER,u.COLOR_ATTACHMENT0,u.TEXTURE_2D,m,0),D(X,i).push(m),D(j,i).push(v)}return k(G,i,u.createBuffer()),u.bindBuffer(u.ARRAY_BUFFER,D(G,i)),u.bufferData(u.ARRAY_BUFFER,new Float32Array([-1,-1,1,-1,1,1,-1,1]),u.STATIC_DRAW),U(ie,i,pe).call(i),U(ie,i,me).call(i),U(ie,i,ve).call(i),U(ie,i,se).call(i),u.clearColor(0,0,0,0),u.blendFunc(u.SRC_ALPHA,u.ONE_MINUS_SRC_ALPHA),k(z,i,!0),k(H,i,!0),k(Y,i,!0),U(ie,i,ae).call(i),k(q,i,requestAnimationFrame((function(){return U(ie,i,le).call(i)}))),i}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&P(e,t)}(t,e),r=t,n=[{key:"accelerating",set:function(e){e>100||e<2||k(M,this,e)}},{key:"resolution",set:function(e){e<100||e>550||k(L,this,e)}},{key:"perturbance",set:function(e){e<1e-4||e>1||k(C,this,e)}},{key:"playingState",set:function(e){k(H,this,!1!==e)}},{key:"initialized",get:function(){return D(Y,this)}},{key:"raindropsTimeInterval",set:function(e){e<10||e>12e3||k(re,this,e)}},{key:"raindropsFall",value:function(){var e=window.getComputedStyle(D(I,this)),t=function(e){return function(e=1,t=0){let r=Math.ceil(Number(t)),n=Math.floor(Number(e));return r>n&&([n,r]=[r,n]),Math.floor(Math.random()*(n-r+1)+r)}(parseInt(e))},r=e.width,n=e.height;this.drop(t(r),t(n),1.5*this.dropRadius,.14)}},{key:"drop",value:function(e,t,r,n){var i=this.gl,o=D(I,this).offsetWidth,a=D(I,this).offsetHeight,s=Math.max(o,a);r/=s;var u=new Float32Array([(2*e-o)/s,(a-2*t)/s]);i.viewport(0,0,D(L,this),D(L,this)),i.bindFramebuffer(i.FRAMEBUFFER,D(j,this)[D(B,this)]),Reflect.apply(l,this,[D(X,this)[D(N,this)]]),i.useProgram(D(Q,this).id),i.uniform2fv(D(Q,this).locations.center,u),i.uniform1f(D(Q,this).locations.radius,r),i.uniform1f(D(Q,this).locations.strength,n),U(ie,this,ue).call(this),U(ie,this,he).call(this)}},{key:"updateSize",value:function(){var e=D(I,this).offsetWidth,t=D(I,this).offsetHeight;e==this.canvas.width&&t==this.canvas.height||(this.canvas.width=e,this.canvas.height=t)}},{key:"destroy",value:function(){var e=this,t=D(I,this);t&&(Object.keys(D(ne,this)).forEach((function(r){return t.removeEventListener&&t.removeEventListener(r,D(ne,e)[r])})),t.removeAttribute&&t.removeAttribute("data-ripples")),this.styleElement&&this.styleElement.remove(),this.gl=null,this.gl&&(this.gl=null),window.removeEventListener("resize",this.updateSize),U(ie,this,Ee).call(this),D(q,this)&&window.cancelAnimationFrame(D(q,this))}},{key:"show",value:function(){k(z,this,!0),this.canvas.style.visibility="visible",U(ie,this,ge).call(this)}},{key:"hide",value:function(){k(z,this,!1),this.canvas.style.visibility="hidden",U(ie,this,Ee).call(this)}},{key:"pause",value:function(){k(H,this,!1)}},{key:"play",value:function(){k(H,this,!0)}},{key:"changePlayingState",value:function(){k(H,this,!D(H,this))}},{key:"set",value:function(e,t){"imageUrl"===e?(this.imageUrl=t,U(ie,this,se).call(this)):this[e]=t}}],n&&R(r.prototype,n),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n}(g);function ae(){var e=this,t=function(t){var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];D(z,e)&&D(H,e)&&e.interactive&&(k(te,e,Date.now()),U(ie,e,be).call(e,t,e.dropRadius*(r?1.5:1),r?.14:.01))};D(ne,this).mousemove=function(r){for(var n=D(M,e);n--;)t(r)},D(ne,this).touchmove=D(ne,this).touchstart=function(e){for(var r=e.touches,n=0;n<r.length;n++)t(r[n])},D(ne,this).mousedown=function(e){return t(e,!0)},Object.keys(D(ne,this)).forEach((function(t){return D(I,e)&&D(I,e).addEventListener(t,D(ne,e)[t],{passive:!0})}))}function se(){var e=this,t=this.gl,r=this.imageUrl||a(D(K,this))||a(window.getComputedStyle(D(I,this)).backgroundImage);if(r!==this.imageSource)if(this.imageSource=r,this.imageSource){var n=new Image;n.onload=function(){var r=function(e){return!(e&e-1)},i=r(n.width)&&r(n.height)?t.REPEAT:t.CLAMP_TO_EDGE;t.bindTexture(t.TEXTURE_2D,D(V,e)),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,i),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,i),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,n),k(Z,e,n.width),k($,e,n.height),U(ie,e,ge).call(e)},n.onerror=function(){return U(ie,e,ve).call(e)},n.crossOrigin=this.imageSource.match(/^data:/)?null:this.crossOrigin,n.src=this.imageSource}else U(ie,this,ve).call(this)}function le(){var e=this;D(z,this)&&(U(ie,this,de).call(this),D(H,this)&&U(ie,this,fe).call(this),U(ie,this,ce).call(this),k(q,this,requestAnimationFrame((function(){return U(ie,e,le).call(e)}))))}function ue(){var e=this.gl;e.bindBuffer(e.ARRAY_BUFFER,D(G,this)),e.vertexAttribPointer(0,2,e.FLOAT,!1,0,0),e.drawArrays(e.TRIANGLE_FAN,0,4)}function ce(){var e=this.gl;e.bindFramebuffer(e.FRAMEBUFFER,null),e.viewport(0,0,this.canvas.width,this.canvas.height),e.enable(e.BLEND),e.clear(e.COLOR_BUFFER_BIT|e.DEPTH_BUFFER_BIT),e.useProgram(this.renderProgram.id),Reflect.apply(l,this,[D(V,this),0]),Reflect.apply(l,this,[D(X,this)[0],1]),e.uniform1f(this.renderProgram.locations.perturbance,D(C,this)),e.uniform2fv(this.renderProgram.locations.topLeft,this.renderProgram.uniforms.topLeft),e.uniform2fv(this.renderProgram.locations.bottomRight,this.renderProgram.uniforms.bottomRight),e.uniform2fv(this.renderProgram.locations.containerRatio,this.renderProgram.uniforms.containerRatio),e.uniform1i(this.renderProgram.locations.samplerBackground,0),e.uniform1i(this.renderProgram.locations.samplerRipples,1),U(ie,this,ue).call(this),e.disable(e.BLEND)}function fe(){if(this.idleFluctuations){var e=Date.now();e-D(te,this)>D(re,this)&&(k(te,this,e),this.raindropsFall())}var t=this.gl;t.viewport(0,0,D(L,this),D(L,this)),t.bindFramebuffer(t.FRAMEBUFFER,D(j,this)[D(B,this)]),Reflect.apply(l,this,[D(X,this)[D(N,this)]]),t.useProgram(D(J,this).id),U(ie,this,ue).call(this),U(ie,this,he).call(this)}function he(){k(B,this,1-D(B,this)),k(N,this,1-D(N,this))}function de(){var e,t,r,n=window.getComputedStyle(D(I,this)).backgroundSize,i=window.getComputedStyle(D(I,this)).backgroundAttachment,o=(e=window.getComputedStyle(D(I,this)).backgroundPosition,/\s+/.test(e)?e.replace(/center/,"50%").replace(/top|left/,"0%").replace(/bottom/,"100%").replace(/\s+/," ").split(" "):u(e)?[e,"50%"]:{center:["50%","50%"],top:["50%","0%"],bottom:["50%","100%"],left:["0%","50%"],right:["100%","50%"]}[e]),a="fixed"==i?{left:window.scrollX,top:window.scrollY,width:window.innerWidth,height:window.innerHeight}:{left:D(I,this).getBoundingClientRect().left,top:D(I,this).getBoundingClientRect().top,width:D(I,this).scrollWidth,height:D(I,this).scrollHeight};if("cover"==n){var s=Math.max(a.width/D(Z,this),a.height/D($,this));t=D(Z,this)*s,r=D($,this)*s}else if("contain"==n){var l=Math.min(a.width/D(Z,this),a.height/D($,this));t=D(Z,this)*l,r=D($,this)*l}else{var c=n.split(" ");t=c[0]||"",r=c[1]||t,u(t)?t=a.width*parseFloat(t)/100:"auto"!==t&&(t=parseFloat(t)),u(r)?r=a.height*parseFloat(r)/100:"auto"!==r&&(r=parseFloat(r)),"auto"==t&&"auto"==r?(t=D(Z,this),r=D($,this)):("auto"==t&&(t=D(Z,this)*(Number(r)/D($,this))),"auto"==r&&(r=D($,this)*(Number(t)/D(Z,this))))}var f=o&&o[0]||"0%",h=o&&o[1]||"0%";f=u(f)?(a.left+(a.width-Number(t))*parseFloat(f)/100).toString():(a.left+parseFloat(f)).toString(),h=u(h)?(a.top+(a.height-Number(r))*parseFloat(h)/100).toString():(a.top+parseFloat(h)).toString(),this.renderProgram.uniforms.topLeft=new Float32Array([(D(I,this).offsetLeft-Number(f))/Number(t),(D(I,this).offsetTop-Number(h))/Number(r)]),this.renderProgram.uniforms.bottomRight=new Float32Array([this.renderProgram.uniforms.topLeft[0]+D(I,this).clientWidth/Number(t),this.renderProgram.uniforms.topLeft[1]+D(I,this).clientHeight/Number(r)]);var d=Math.max(this.canvas.width,this.canvas.height);this.renderProgram.uniforms.containerRatio=new Float32Array([this.canvas.width/d,this.canvas.height/d])}function pe(){var e=this.gl,t="\n attribute vec2 vertex;\n varying vec2 coord;\n void main() {\n coord = vertex * 0.5 + 0.5;\n gl_Position = vec4(vertex, 0.0, 1.0);\n }";k(Q,this,s(t,"precision highp float;\n\n const float PI = 3.141592653589793;\n uniform sampler2D texture;\n uniform vec2 center;\n uniform float radius;\n uniform float strength;\n\n varying vec2 coord;\n\n void main() {\n vec4 info = texture2D(texture, coord);\n\n float drop = max(0.0, 1.0 - length(center * 0.5 + 0.5 - coord) / radius);\n drop = 0.5 - cos(drop * PI) * 0.5;\n info.r += drop * strength;\n gl_FragColor = info;\n }",e)),k(J,this,s(t,"precision highp float;\n\n uniform sampler2D texture;\n uniform vec2 delta;\n\n varying vec2 coord;\n\n void main() {\n vec4 info = texture2D(texture, coord);\n \n vec2 dx = vec2(delta.x, 0.0);\n vec2 dy = vec2(0.0, delta.y);\n \n float average = (\n texture2D(texture, coord - dx).r +\n texture2D(texture, coord - dy).r +\n texture2D(texture, coord + dx).r +\n texture2D(texture, coord + dy).r\n ) * 0.25;\n \n info.g += (average - info.r) * 2.0;\n info.g *= 0.995;\n info.r += info.g;\n \n gl_FragColor = info;\n }\n ",this.gl)),e.uniform2fv(D(J,this).locations.delta,D(W,this)),this.renderProgram=s("\n precision highp float;\n\n attribute vec2 vertex;\n uniform vec2 topLeft;\n uniform vec2 bottomRight;\n uniform vec2 containerRatio;\n varying vec2 ripplesCoord;\n varying vec2 backgroundCoord;\n void main() {\n backgroundCoord = mix(topLeft, bottomRight, vertex * 0.5 + 0.5);\n backgroundCoord.y = 1.0 - backgroundCoord.y;\n ripplesCoord = vec2(vertex.x, -vertex.y) * containerRatio * 0.5 + 0.5;\n gl_Position = vec4(vertex.x, -vertex.y, 0.0, 1.0);\n }\n ","\n precision highp float;\n\n uniform sampler2D samplerBackground;\n uniform sampler2D samplerRipples;\n uniform vec2 delta;\n\n uniform float perturbance;\n varying vec2 ripplesCoord;\n varying vec2 backgroundCoord;\n\n void main() {\n float height = texture2D(samplerRipples, ripplesCoord).r;\n float heightX = texture2D(samplerRipples, vec2(ripplesCoord.x + delta.x, ripplesCoord.y)).r;\n float heightY = texture2D(samplerRipples, vec2(ripplesCoord.x, ripplesCoord.y + delta.y)).r;\n vec3 dx = vec3(delta.x, heightX - height, 0.0);\n vec3 dy = vec3(0.0, heightY - height, delta.y);\n vec2 offset = -normalize(cross(dy, dx)).xz;\n float specular = pow(max(0.0, dot(offset, normalize(vec2(-0.6, 1.0)))), 4.0);\n gl_FragColor = texture2D(samplerBackground, backgroundCoord + offset * perturbance) + specular;\n }",e),e.uniform2fv(this.renderProgram.locations.delta,D(W,this))}function me(){var e=this.gl;k(V,this,e.createTexture()),e.bindTexture(e.TEXTURE_2D,D(V,this)),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,1),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR)}function ve(){var e=this.gl;e.bindTexture(e.TEXTURE_2D,D(V,this)),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,this.transparentPixels)}function ge(){var e=D(I,this).style.backgroundImage;"none"!=e&&(k(ee,this,e),k(K,this,window.getComputedStyle(D(I,this)).backgroundImage),D(I,this).style.backgroundImage="none")}function Ee(){D(I,this).style.backgroundImage=D(ee,this)||""}function be(e,t,r){var n=window.getComputedStyle(D(I,this)),i=parseInt(n.borderLeftWidth)||0,o=parseInt(n.borderTopWidth)||0;this.drop(e.pageX-D(I,this).offsetLeft-i,e.pageY-D(I,this).offsetTop-o,t,r)}function ye(e,t){var r=(0,i.useRef)(null);return(0,i.useEffect)((function(){return r.current=new oe(e.current,void 0===t.children,t.option),function(){return r.current.destroy()}}),[]),r}module.exports["oops-ui"]=n})();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as e from"react";import*as t from"a-element-inline-style";var r={649:(t,r,n)=>{var i,o;t.exports=(i={useEffect:()=>e.useEffect,useRef:()=>e.useRef},o={},n.d(o,i),o)}},n={};function i(e){var t=n[e];if(void 0!==t)return t.exports;var o=n[e]={exports:{}};return r[e](o,o.exports,i),o.exports}i.d=(e,t)=>{for(var r in t)i.o(t,r)&&!i.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var o={};i.d(o,{q:()=>ue,n:()=>_e});var a=i(649);const s=(l={setStyle:()=>t.setStyle},u={},i.d(u,l),u);var l,u;function c(e){var t=/url\(["']?([^"']*)["']?\)/.exec(e);return null==t?null:t[1]}function f(e,t,r,n){function i(e,t){var n=r.createShader(e);if(r.shaderSource(n,t),r.compileShader(n),!r.getShaderParameter(n,r.COMPILE_STATUS))throw new Error("compile error: "+r.getShaderInfoLog(n));return n}var o,a={id:r.createProgram(),uniforms:{},locations:{}};if(r.attachShader(a.id,i(r.VERTEX_SHADER,e)),r.attachShader(a.id,i(r.FRAGMENT_SHADER,t)),r.linkProgram(a.id),!r.getProgramParameter(a.id,r.LINK_STATUS))throw new Error("link error: "+r.getProgramInfoLog(a.id));r.useProgram(a.id),r.enableVertexAttribArray(0);for(var s=e+t,l=/uniform (\w+) (\w+)/g;null!==(o=l.exec(s));){var u=o[2];a.locations[u]=r.getUniformLocation(a.id,u)}return a}function h(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=this.gl;r.activeTexture(r.TEXTURE0+(t||0)),r.bindTexture(r.TEXTURE_2D,e)}function p(e){return e.endsWith("%")}function d(){var e=this,t=function(){return e.initState=!1,null};if(!this.gl)return t();var r=this.gl,n=Object.fromEntries(["OES_texture_float","OES_texture_half_float","OES_texture_float_linear","OES_texture_half_float_linear"].reduce((function(e,t){var n=r.getExtension(t);return n&&e.push([t,n]),e}),[]));if(!n.OES_texture_float)return t();var i=[];function o(e,t,r){var i="OES_texture_"+e,o=i+"_linear",a=o in n;return{type:t,linearSupport:a,arrayType:r,extensions:a?[i,o]:[i]}}i.push(o("float",r.FLOAT,Float32Array)),n.OES_texture_half_float&&i.push(o("half_float",n.OES_texture_half_float.HALF_FLOAT_OES,null));var a=r.createTexture(),s=r.createFramebuffer();r.bindFramebuffer(r.FRAMEBUFFER,s),r.bindTexture(r.TEXTURE_2D,a),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.NEAREST),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.NEAREST),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE);for(var l=null,u=0;u<i.length;u++)if(r.texImage2D(r.TEXTURE_2D,0,r.RGBA,32,32,0,r.RGBA,i[u].type,null),r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,a,0),r.checkFramebufferStatus(r.FRAMEBUFFER)===r.FRAMEBUFFER_COMPLETE){l=i[u];break}return l}function m(e){return m="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},m(e)}function v(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,y(n.key),n)}}function g(e,t,r){return t&&v(e.prototype,t),r&&v(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function E(e,t,r){return(t=y(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function y(e){var t=function(e){if("object"!=m(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=m(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==m(t)?t:t+""}var b="lmssee_ripper_element_style",T=g((function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),E(this,"styleElement",document.createElement("style")),E(this,"canvas",void 0),E(this,"gl",void 0),E(this,"config",void 0),E(this,"transparentPixels",function(){try{return new ImageData(32,32)}catch(e){return console.log(e&&""),document.createElement("canvas").getContext("2d").createImageData(32,32)}}()),E(this,"initState",!0),this.canvas=t;var r=t.getContext("webgl");if(null===r)return this.initState=!1,void(this.config=null);if(this.gl=r,null===document.querySelector("style#".concat(b))){var n=this.styleElement;n.id=b,n.innerHTML="\n .lmssee-ripples { \n position: relative; \n z-index: 0; \n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n transform: translate(0,0);\n }\n ";var i=document.head;i.prepend?i.prepend(n):i.insertBefore(n,i.firstChild)}this.config=Reflect.apply(d,this,[])})),R={imageUrl:"",resolution:360,dropRadius:10,perturbance:.03,interactive:!0,crossOrigin:"",playingState:!0,accelerating:3,raindropsTimeInterval:660,idleFluctuations:!0};function w(e){return w="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},w(e)}function _(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function x(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?_(Object(r),!0).forEach((function(t){U(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):_(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function P(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,M(n.key),n)}}function S(e,t){if(t&&("object"==w(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function F(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(F=function(){return!!e})()}function A(e){return A=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},A(e)}function O(e,t){return O=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},O(e,t)}function D(e,t,r){k(e,t),t.set(e,r)}function k(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function U(e,t,r){return(t=M(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function M(e){var t=function(e){if("object"!=w(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=w(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==w(t)?t:t+""}function L(e,t){return e.get(I(e,t))}function C(e,t,r){return e.set(I(e,t),r),r}function I(e,t,r){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:r;throw new TypeError("Private element is not present on this object")}Object.freeze(R);var W=new WeakMap,X=new WeakMap,B=new WeakMap,j=new WeakMap,N=new WeakMap,G=new WeakMap,z=new WeakMap,H=new WeakMap,Y=new WeakMap,q=new WeakMap,K=new WeakMap,V=new WeakMap,J=new WeakMap,Q=new WeakMap,Z=new WeakMap,$=new WeakMap,ee=new WeakMap,te=new WeakMap,re=new WeakMap,ne=new WeakMap,ie=new WeakMap,oe=new WeakMap,ae=new WeakMap,se=new WeakMap,le=new WeakSet,ue=function(){function e(t,r,n){var i,o,a;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),i=function(e,t,r){return t=A(t),S(e,F()?Reflect.construct(t,r||[],A(e).constructor):t.apply(e,r))}(this,e,[t]),k(o=i,a=le),a.add(o),U(i,"defaults",R),U(i,"interactive",i.defaults.interactive),D(i,W,i.defaults.accelerating),D(i,X,i.defaults.resolution),D(i,B,i.defaults.perturbance),U(i,"dropRadius",void 0),U(i,"crossOrigin",""),U(i,"imageUrl",void 0),U(i,"idleFluctuations",!0),D(i,j,void 0),D(i,N,void 0),D(i,G,[]),D(i,z,[]),D(i,H,0),D(i,Y,1),D(i,q,void 0),D(i,K,!1),D(i,V,!1),D(i,J,!1),D(i,Q,0),D(i,Z,""),U(i,"imageSource",""),U(i,"renderProgram",void 0),D(i,$,void 0),D(i,ee,void 0),D(i,te,void 0),D(i,re,void 0),D(i,ne,void 0),D(i,ie,void 0),D(i,oe,Date.now()),D(i,ae,i.defaults.raindropsTimeInterval),D(i,se,{mousemove:function(e){return console.log(e)},mousedown:function(e){return console.log(e)},touchmove:function(e){return console.log(e)},touchstart:function(e){return console.log(e)}}),Object.defineProperties(i,{defaults:{value:i.defaults,writable:!1,enumerable:!1,configurable:!1}}),n&&"boolean"!=typeof n.interactive&&delete n.interactive;var l=x(x({},i.defaults),n);if(i.interactive=l.interactive,i.resolution=l.resolution,i.perturbance=l.perturbance,i.dropRadius=l.dropRadius,i.crossOrigin=l.crossOrigin,i.imageUrl=l.imageUrl,i.idleFluctuations=l.idleFluctuations,!1===i.initState||null===t.parentElement||null===i.config||null===i.gl)return i.initState=!1,S(i);var u=i.gl,c=1/L(X,i);C(N,i,new Float32Array([c,c])),C(j,i,t.parentElement),function(e){var t=e.parentElement;e.width=t.clientWidth,e.height=t.clientHeight,(0,s.setStyle)(e,{position:"absolute",left:0,top:0,right:0,bottom:0,zIndex:-1})}(t),i.config.extensions.forEach((function(e){return u.getExtension(e)})),i.updateSize=i.updateSize.bind(i),window.addEventListener("resize",i.updateSize);for(var f=i.config.arrayType,h=f?new f(L(X,i)*L(X,i)*4):null,p=i.config,d=0;d<2;d++){var m=u.createTexture(),v=u.createFramebuffer();u.bindFramebuffer(u.FRAMEBUFFER,v),u.bindTexture(u.TEXTURE_2D,m),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_MIN_FILTER,p.linearSupport?u.LINEAR:u.NEAREST),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_MAG_FILTER,p.linearSupport?u.LINEAR:u.NEAREST),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_WRAP_S,u.CLAMP_TO_EDGE),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_WRAP_T,u.CLAMP_TO_EDGE),u.texImage2D(u.TEXTURE_2D,0,u.RGBA,L(X,i),L(X,i),0,u.RGBA,p.type,h),u.framebufferTexture2D(u.FRAMEBUFFER,u.COLOR_ATTACHMENT0,u.TEXTURE_2D,m,0),L(G,i).push(m),L(z,i).push(v)}return C(q,i,u.createBuffer()),u.bindBuffer(u.ARRAY_BUFFER,L(q,i)),u.bufferData(u.ARRAY_BUFFER,new Float32Array([-1,-1,1,-1,1,1,-1,1]),u.STATIC_DRAW),I(le,i,Ee).call(i),I(le,i,ye).call(i),I(le,i,be).call(i),I(le,i,fe).call(i),u.clearColor(0,0,0,0),u.blendFunc(u.SRC_ALPHA,u.ONE_MINUS_SRC_ALPHA),C(K,i,!0),C(V,i,!0),C(J,i,!0),I(le,i,ce).call(i),C(Q,i,requestAnimationFrame((function(){return I(le,i,he).call(i)}))),i}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&O(e,t)}(e,T),t=e,r=[{key:"accelerating",set:function(e){e>100||e<2||C(W,this,e)}},{key:"resolution",set:function(e){e<100||e>550||C(X,this,e)}},{key:"perturbance",set:function(e){e<1e-4||e>1||C(B,this,e)}},{key:"playingState",set:function(e){C(V,this,!1!==e)}},{key:"initialized",get:function(){return L(J,this)}},{key:"raindropsTimeInterval",set:function(e){e<10||e>12e3||C(ae,this,e)}},{key:"raindropsFall",value:function(){var e=window.getComputedStyle(L(j,this)),t=function(e){return function(e=1,t=0){let r=Math.ceil(Number(t)),n=Math.floor(Number(e));return r>n&&([n,r]=[r,n]),Math.floor(Math.random()*(n-r+1)+r)}(parseInt(e))},r=e.width,n=e.height;this.drop(t(r),t(n),1.5*this.dropRadius,.14)}},{key:"drop",value:function(e,t,r,n){var i=this.gl,o=L(j,this).offsetWidth,a=L(j,this).offsetHeight,s=Math.max(o,a);r/=s;var l=new Float32Array([(2*e-o)/s,(a-2*t)/s]);i.viewport(0,0,L(X,this),L(X,this)),i.bindFramebuffer(i.FRAMEBUFFER,L(z,this)[L(H,this)]),Reflect.apply(h,this,[L(G,this)[L(Y,this)]]),i.useProgram(L(te,this).id),i.uniform2fv(L(te,this).locations.center,l),i.uniform1f(L(te,this).locations.radius,r),i.uniform1f(L(te,this).locations.strength,n),I(le,this,pe).call(this),I(le,this,ve).call(this)}},{key:"updateSize",value:function(){var e=L(j,this).offsetWidth,t=L(j,this).offsetHeight;e==this.canvas.width&&t==this.canvas.height||(this.canvas.width=e,this.canvas.height=t)}},{key:"destroy",value:function(){var e=this,t=L(j,this);t&&(Object.keys(L(se,this)).forEach((function(r){return t.removeEventListener&&t.removeEventListener(r,L(se,e)[r])})),t.removeAttribute&&t.removeAttribute("data-ripples")),this.styleElement&&this.styleElement.remove(),this.gl=null,this.gl&&(this.gl=null),window.removeEventListener("resize",this.updateSize),I(le,this,Re).call(this),L(Q,this)&&window.cancelAnimationFrame(L(Q,this))}},{key:"show",value:function(){C(K,this,!0),this.canvas.style.visibility="visible",I(le,this,Te).call(this)}},{key:"hide",value:function(){C(K,this,!1),this.canvas.style.visibility="hidden",I(le,this,Re).call(this)}},{key:"pause",value:function(){C(V,this,!1)}},{key:"play",value:function(){C(V,this,!0)}},{key:"changePlayingState",value:function(){C(V,this,!L(V,this))}},{key:"set",value:function(e,t){"imageUrl"===e?(this.imageUrl=t,I(le,this,fe).call(this)):this[e]=t}}],r&&P(t.prototype,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,r}();function ce(){var e=this,t=function(t){var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];L(K,e)&&L(V,e)&&e.interactive&&(C(oe,e,Date.now()),I(le,e,we).call(e,t,e.dropRadius*(r?1.5:1),r?.14:.01))};L(se,this).mousemove=function(r){for(var n=L(W,e);n--;)t(r)},L(se,this).touchmove=L(se,this).touchstart=function(e){for(var r=e.touches,n=0;n<r.length;n++)t(r[n])},L(se,this).mousedown=function(e){return t(e,!0)},Object.keys(L(se,this)).forEach((function(t){return L(j,e)&&L(j,e).addEventListener(t,L(se,e)[t],{passive:!0})}))}function fe(){var e=this,t=this.gl,r=this.imageUrl||c(L(Z,this))||c(window.getComputedStyle(L(j,this)).backgroundImage);if(r!==this.imageSource)if(this.imageSource=r,this.imageSource){var n=new Image;n.onload=function(){var r=function(e){return!(e&e-1)},i=r(n.width)&&r(n.height)?t.REPEAT:t.CLAMP_TO_EDGE;t.bindTexture(t.TEXTURE_2D,L($,e)),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,i),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,i),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,n),C(re,e,n.width),C(ne,e,n.height),I(le,e,Te).call(e)},n.onerror=function(){return I(le,e,be).call(e)},n.crossOrigin=this.imageSource.match(/^data:/)?null:this.crossOrigin,n.src=this.imageSource}else I(le,this,be).call(this)}function he(){var e=this;L(K,this)&&(I(le,this,ge).call(this),L(V,this)&&I(le,this,me).call(this),I(le,this,de).call(this),C(Q,this,requestAnimationFrame((function(){return I(le,e,he).call(e)}))))}function pe(){var e=this.gl;e.bindBuffer(e.ARRAY_BUFFER,L(q,this)),e.vertexAttribPointer(0,2,e.FLOAT,!1,0,0),e.drawArrays(e.TRIANGLE_FAN,0,4)}function de(){var e=this.gl;e.bindFramebuffer(e.FRAMEBUFFER,null),e.viewport(0,0,this.canvas.width,this.canvas.height),e.enable(e.BLEND),e.clear(e.COLOR_BUFFER_BIT|e.DEPTH_BUFFER_BIT),e.useProgram(this.renderProgram.id),Reflect.apply(h,this,[L($,this),0]),Reflect.apply(h,this,[L(G,this)[0],1]),e.uniform1f(this.renderProgram.locations.perturbance,L(B,this)),e.uniform2fv(this.renderProgram.locations.topLeft,this.renderProgram.uniforms.topLeft),e.uniform2fv(this.renderProgram.locations.bottomRight,this.renderProgram.uniforms.bottomRight),e.uniform2fv(this.renderProgram.locations.containerRatio,this.renderProgram.uniforms.containerRatio),e.uniform1i(this.renderProgram.locations.samplerBackground,0),e.uniform1i(this.renderProgram.locations.samplerRipples,1),I(le,this,pe).call(this),e.disable(e.BLEND)}function me(){if(this.idleFluctuations){var e=Date.now();e-L(oe,this)>L(ae,this)&&(C(oe,this,e),this.raindropsFall())}var t=this.gl;t.viewport(0,0,L(X,this),L(X,this)),t.bindFramebuffer(t.FRAMEBUFFER,L(z,this)[L(H,this)]),Reflect.apply(h,this,[L(G,this)[L(Y,this)]]),t.useProgram(L(ee,this).id),I(le,this,pe).call(this),I(le,this,ve).call(this)}function ve(){C(H,this,1-L(H,this)),C(Y,this,1-L(Y,this))}function ge(){var e,t,r,n=window.getComputedStyle(L(j,this)).backgroundSize,i=window.getComputedStyle(L(j,this)).backgroundAttachment,o=(e=window.getComputedStyle(L(j,this)).backgroundPosition,/\s+/.test(e)?e.replace(/center/,"50%").replace(/top|left/,"0%").replace(/bottom/,"100%").replace(/\s+/," ").split(" "):p(e)?[e,"50%"]:{center:["50%","50%"],top:["50%","0%"],bottom:["50%","100%"],left:["0%","50%"],right:["100%","50%"]}[e]),a="fixed"==i?{left:window.scrollX,top:window.scrollY,width:window.innerWidth,height:window.innerHeight}:{left:L(j,this).getBoundingClientRect().left,top:L(j,this).getBoundingClientRect().top,width:L(j,this).scrollWidth,height:L(j,this).scrollHeight};if("cover"==n){var s=Math.max(a.width/L(re,this),a.height/L(ne,this));t=L(re,this)*s,r=L(ne,this)*s}else if("contain"==n){var l=Math.min(a.width/L(re,this),a.height/L(ne,this));t=L(re,this)*l,r=L(ne,this)*l}else{var u=n.split(" ");t=u[0]||"",r=u[1]||t,p(t)?t=a.width*parseFloat(t)/100:"auto"!==t&&(t=parseFloat(t)),p(r)?r=a.height*parseFloat(r)/100:"auto"!==r&&(r=parseFloat(r)),"auto"==t&&"auto"==r?(t=L(re,this),r=L(ne,this)):("auto"==t&&(t=L(re,this)*(Number(r)/L(ne,this))),"auto"==r&&(r=L(ne,this)*(Number(t)/L(re,this))))}var c=o&&o[0]||"0%",f=o&&o[1]||"0%";c=p(c)?(a.left+(a.width-Number(t))*parseFloat(c)/100).toString():(a.left+parseFloat(c)).toString(),f=p(f)?(a.top+(a.height-Number(r))*parseFloat(f)/100).toString():(a.top+parseFloat(f)).toString(),this.renderProgram.uniforms.topLeft=new Float32Array([(L(j,this).offsetLeft-Number(c))/Number(t),(L(j,this).offsetTop-Number(f))/Number(r)]),this.renderProgram.uniforms.bottomRight=new Float32Array([this.renderProgram.uniforms.topLeft[0]+L(j,this).clientWidth/Number(t),this.renderProgram.uniforms.topLeft[1]+L(j,this).clientHeight/Number(r)]);var h=Math.max(this.canvas.width,this.canvas.height);this.renderProgram.uniforms.containerRatio=new Float32Array([this.canvas.width/h,this.canvas.height/h])}function Ee(){var e=this.gl,t="\n attribute vec2 vertex;\n varying vec2 coord;\n void main() {\n coord = vertex * 0.5 + 0.5;\n gl_Position = vec4(vertex, 0.0, 1.0);\n }";C(te,this,f(t,"precision highp float;\n\n const float PI = 3.141592653589793;\n uniform sampler2D texture;\n uniform vec2 center;\n uniform float radius;\n uniform float strength;\n\n varying vec2 coord;\n\n void main() {\n vec4 info = texture2D(texture, coord);\n\n float drop = max(0.0, 1.0 - length(center * 0.5 + 0.5 - coord) / radius);\n drop = 0.5 - cos(drop * PI) * 0.5;\n info.r += drop * strength;\n gl_FragColor = info;\n }",e)),C(ee,this,f(t,"precision highp float;\n\n uniform sampler2D texture;\n uniform vec2 delta;\n\n varying vec2 coord;\n\n void main() {\n vec4 info = texture2D(texture, coord);\n \n vec2 dx = vec2(delta.x, 0.0);\n vec2 dy = vec2(0.0, delta.y);\n \n float average = (\n texture2D(texture, coord - dx).r +\n texture2D(texture, coord - dy).r +\n texture2D(texture, coord + dx).r +\n texture2D(texture, coord + dy).r\n ) * 0.25;\n \n info.g += (average - info.r) * 2.0;\n info.g *= 0.995;\n info.r += info.g;\n \n gl_FragColor = info;\n }\n ",this.gl)),e.uniform2fv(L(ee,this).locations.delta,L(N,this)),this.renderProgram=f("\n precision highp float;\n\n attribute vec2 vertex;\n uniform vec2 topLeft;\n uniform vec2 bottomRight;\n uniform vec2 containerRatio;\n varying vec2 ripplesCoord;\n varying vec2 backgroundCoord;\n void main() {\n backgroundCoord = mix(topLeft, bottomRight, vertex * 0.5 + 0.5);\n backgroundCoord.y = 1.0 - backgroundCoord.y;\n ripplesCoord = vec2(vertex.x, -vertex.y) * containerRatio * 0.5 + 0.5;\n gl_Position = vec4(vertex.x, -vertex.y, 0.0, 1.0);\n }\n ","\n precision highp float;\n\n uniform sampler2D samplerBackground;\n uniform sampler2D samplerRipples;\n uniform vec2 delta;\n\n uniform float perturbance;\n varying vec2 ripplesCoord;\n varying vec2 backgroundCoord;\n\n void main() {\n float height = texture2D(samplerRipples, ripplesCoord).r;\n float heightX = texture2D(samplerRipples, vec2(ripplesCoord.x + delta.x, ripplesCoord.y)).r;\n float heightY = texture2D(samplerRipples, vec2(ripplesCoord.x, ripplesCoord.y + delta.y)).r;\n vec3 dx = vec3(delta.x, heightX - height, 0.0);\n vec3 dy = vec3(0.0, heightY - height, delta.y);\n vec2 offset = -normalize(cross(dy, dx)).xz;\n float specular = pow(max(0.0, dot(offset, normalize(vec2(-0.6, 1.0)))), 4.0);\n gl_FragColor = texture2D(samplerBackground, backgroundCoord + offset * perturbance) + specular;\n }",e),e.uniform2fv(this.renderProgram.locations.delta,L(N,this))}function ye(){var e=this.gl;C($,this,e.createTexture()),e.bindTexture(e.TEXTURE_2D,L($,this)),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,1),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR)}function be(){var e=this.gl;e.bindTexture(e.TEXTURE_2D,L($,this)),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,this.transparentPixels)}function Te(){var e=L(j,this).style.backgroundImage;"none"!=e&&(C(ie,this,e),C(Z,this,window.getComputedStyle(L(j,this)).backgroundImage),L(j,this).style.backgroundImage="none")}function Re(){L(j,this).style.backgroundImage=L(ie,this)||""}function we(e,t,r){var n=window.getComputedStyle(L(j,this)),i=parseInt(n.borderLeftWidth)||0,o=parseInt(n.borderTopWidth)||0;this.drop(e.pageX-L(j,this).offsetLeft-i,e.pageY-L(j,this).offsetTop-o,t,r)}function _e(e,t){var r=(0,a.useRef)(null);return(0,a.useEffect)((function(){return r.current=new ue(e.current,void 0===t.children,t.option),function(){return r.current.destroy()}}),[]),r}var xe=o.q,Pe=o.n;export{xe as Ripples,Pe as useRipples};
|
|
1
|
+
import*as e from"react";import*as t from"a-element-inline-style";var r={649:(t,r,n)=>{var i,o;t.exports=(i={useEffect:()=>e.useEffect,useRef:()=>e.useRef},o={},n.d(o,i),o)}},n={};function i(e){var t=n[e];if(void 0!==t)return t.exports;var o=n[e]={exports:{}};return r[e](o,o.exports,i),o.exports}i.d=(e,t)=>{for(var r in t)i.o(t,r)&&!i.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var o={};i.d(o,{n:()=>_e});var a=i(649);const s=(l={setStyle:()=>t.setStyle},u={},i.d(u,l),u);var l,u;function c(e){var t=/url\(["']?([^"']*)["']?\)/.exec(e);return null==t?null:t[1]}function f(e,t,r,n){function i(e,t){var n=r.createShader(e);if(r.shaderSource(n,t),r.compileShader(n),!r.getShaderParameter(n,r.COMPILE_STATUS))throw new Error("compile error: "+r.getShaderInfoLog(n));return n}var o,a={id:r.createProgram(),uniforms:{},locations:{}};if(r.attachShader(a.id,i(r.VERTEX_SHADER,e)),r.attachShader(a.id,i(r.FRAGMENT_SHADER,t)),r.linkProgram(a.id),!r.getProgramParameter(a.id,r.LINK_STATUS))throw new Error("link error: "+r.getProgramInfoLog(a.id));r.useProgram(a.id),r.enableVertexAttribArray(0);for(var s=e+t,l=/uniform (\w+) (\w+)/g;null!==(o=l.exec(s));){var u=o[2];a.locations[u]=r.getUniformLocation(a.id,u)}return a}function h(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=this.gl;r.activeTexture(r.TEXTURE0+(t||0)),r.bindTexture(r.TEXTURE_2D,e)}function p(e){return e.endsWith("%")}function d(){var e=this,t=function(){return e.initState=!1,null};if(!this.gl)return t();var r=this.gl,n=Object.fromEntries(["OES_texture_float","OES_texture_half_float","OES_texture_float_linear","OES_texture_half_float_linear"].reduce((function(e,t){var n=r.getExtension(t);return n&&e.push([t,n]),e}),[]));if(!n.OES_texture_float)return t();var i=[];function o(e,t,r){var i="OES_texture_"+e,o=i+"_linear",a=o in n;return{type:t,linearSupport:a,arrayType:r,extensions:a?[i,o]:[i]}}i.push(o("float",r.FLOAT,Float32Array)),n.OES_texture_half_float&&i.push(o("half_float",n.OES_texture_half_float.HALF_FLOAT_OES,null));var a=r.createTexture(),s=r.createFramebuffer();r.bindFramebuffer(r.FRAMEBUFFER,s),r.bindTexture(r.TEXTURE_2D,a),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.NEAREST),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.NEAREST),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE);for(var l=null,u=0;u<i.length;u++)if(r.texImage2D(r.TEXTURE_2D,0,r.RGBA,32,32,0,r.RGBA,i[u].type,null),r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,a,0),r.checkFramebufferStatus(r.FRAMEBUFFER)===r.FRAMEBUFFER_COMPLETE){l=i[u];break}return l}function m(e){return m="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},m(e)}function v(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,y(n.key),n)}}function g(e,t,r){return t&&v(e.prototype,t),r&&v(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function E(e,t,r){return(t=y(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function y(e){var t=function(e){if("object"!=m(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=m(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==m(t)?t:t+""}var b="lmssee_ripper_element_style",T=g((function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),E(this,"styleElement",document.createElement("style")),E(this,"canvas",void 0),E(this,"gl",void 0),E(this,"config",void 0),E(this,"transparentPixels",function(){try{return new ImageData(32,32)}catch(e){return console.log(e&&""),document.createElement("canvas").getContext("2d").createImageData(32,32)}}()),E(this,"initState",!0),this.canvas=t;var r=t.getContext("webgl");if(null===r)return this.initState=!1,void(this.config=null);if(this.gl=r,null===document.querySelector("style#".concat(b))){var n=this.styleElement;n.id=b,n.innerHTML="\n .lmssee-ripples { \n position: relative; \n z-index: 0; \n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n transform: translate(0,0);\n }\n ";var i=document.head;i.prepend?i.prepend(n):i.insertBefore(n,i.firstChild)}this.config=Reflect.apply(d,this,[])})),R={imageUrl:"",resolution:360,dropRadius:10,perturbance:.03,interactive:!0,crossOrigin:"",playingState:!0,accelerating:3,raindropsTimeInterval:660,idleFluctuations:!0};function w(e){return w="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},w(e)}function _(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function x(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?_(Object(r),!0).forEach((function(t){U(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):_(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function P(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,M(n.key),n)}}function S(e,t){if(t&&("object"==w(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function F(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(F=function(){return!!e})()}function A(e){return A=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},A(e)}function O(e,t){return O=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},O(e,t)}function D(e,t,r){k(e,t),t.set(e,r)}function k(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function U(e,t,r){return(t=M(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function M(e){var t=function(e){if("object"!=w(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=w(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==w(t)?t:t+""}function L(e,t){return e.get(I(e,t))}function C(e,t,r){return e.set(I(e,t),r),r}function I(e,t,r){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:r;throw new TypeError("Private element is not present on this object")}Object.freeze(R);var W=new WeakMap,X=new WeakMap,B=new WeakMap,j=new WeakMap,N=new WeakMap,G=new WeakMap,z=new WeakMap,H=new WeakMap,Y=new WeakMap,q=new WeakMap,K=new WeakMap,V=new WeakMap,J=new WeakMap,Q=new WeakMap,Z=new WeakMap,$=new WeakMap,ee=new WeakMap,te=new WeakMap,re=new WeakMap,ne=new WeakMap,ie=new WeakMap,oe=new WeakMap,ae=new WeakMap,se=new WeakMap,le=new WeakSet,ue=function(){function e(t,r,n){var i,o,a;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),i=function(e,t,r){return t=A(t),S(e,F()?Reflect.construct(t,r||[],A(e).constructor):t.apply(e,r))}(this,e,[t]),k(o=i,a=le),a.add(o),U(i,"defaults",R),U(i,"interactive",i.defaults.interactive),D(i,W,i.defaults.accelerating),D(i,X,i.defaults.resolution),D(i,B,i.defaults.perturbance),U(i,"dropRadius",void 0),U(i,"crossOrigin",""),U(i,"imageUrl",void 0),U(i,"idleFluctuations",!0),D(i,j,void 0),D(i,N,void 0),D(i,G,[]),D(i,z,[]),D(i,H,0),D(i,Y,1),D(i,q,void 0),D(i,K,!1),D(i,V,!1),D(i,J,!1),D(i,Q,0),D(i,Z,""),U(i,"imageSource",""),U(i,"renderProgram",void 0),D(i,$,void 0),D(i,ee,void 0),D(i,te,void 0),D(i,re,void 0),D(i,ne,void 0),D(i,ie,void 0),D(i,oe,Date.now()),D(i,ae,i.defaults.raindropsTimeInterval),D(i,se,{mousemove:function(e){return console.log(e)},mousedown:function(e){return console.log(e)},touchmove:function(e){return console.log(e)},touchstart:function(e){return console.log(e)}}),Object.defineProperties(i,{defaults:{value:i.defaults,writable:!1,enumerable:!1,configurable:!1}}),n&&"boolean"!=typeof n.interactive&&delete n.interactive;var l=x(x({},i.defaults),n);if(i.interactive=l.interactive,i.resolution=l.resolution,i.perturbance=l.perturbance,i.dropRadius=l.dropRadius,i.crossOrigin=l.crossOrigin,i.imageUrl=l.imageUrl,i.idleFluctuations=l.idleFluctuations,!1===i.initState||null===t.parentElement||null===i.config||null===i.gl)return i.initState=!1,S(i);var u=i.gl,c=1/L(X,i);C(N,i,new Float32Array([c,c])),C(j,i,t.parentElement),function(e){var t=e.parentElement;e.width=t.clientWidth,e.height=t.clientHeight,(0,s.setStyle)(e,{position:"absolute",left:0,top:0,right:0,bottom:0,zIndex:-1})}(t),i.config.extensions.forEach((function(e){return u.getExtension(e)})),i.updateSize=i.updateSize.bind(i),window.addEventListener("resize",i.updateSize);for(var f=i.config.arrayType,h=f?new f(L(X,i)*L(X,i)*4):null,p=i.config,d=0;d<2;d++){var m=u.createTexture(),v=u.createFramebuffer();u.bindFramebuffer(u.FRAMEBUFFER,v),u.bindTexture(u.TEXTURE_2D,m),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_MIN_FILTER,p.linearSupport?u.LINEAR:u.NEAREST),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_MAG_FILTER,p.linearSupport?u.LINEAR:u.NEAREST),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_WRAP_S,u.CLAMP_TO_EDGE),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_WRAP_T,u.CLAMP_TO_EDGE),u.texImage2D(u.TEXTURE_2D,0,u.RGBA,L(X,i),L(X,i),0,u.RGBA,p.type,h),u.framebufferTexture2D(u.FRAMEBUFFER,u.COLOR_ATTACHMENT0,u.TEXTURE_2D,m,0),L(G,i).push(m),L(z,i).push(v)}return C(q,i,u.createBuffer()),u.bindBuffer(u.ARRAY_BUFFER,L(q,i)),u.bufferData(u.ARRAY_BUFFER,new Float32Array([-1,-1,1,-1,1,1,-1,1]),u.STATIC_DRAW),I(le,i,Ee).call(i),I(le,i,ye).call(i),I(le,i,be).call(i),I(le,i,fe).call(i),u.clearColor(0,0,0,0),u.blendFunc(u.SRC_ALPHA,u.ONE_MINUS_SRC_ALPHA),C(K,i,!0),C(V,i,!0),C(J,i,!0),I(le,i,ce).call(i),C(Q,i,requestAnimationFrame((function(){return I(le,i,he).call(i)}))),i}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&O(e,t)}(e,T),t=e,r=[{key:"accelerating",set:function(e){e>100||e<2||C(W,this,e)}},{key:"resolution",set:function(e){e<100||e>550||C(X,this,e)}},{key:"perturbance",set:function(e){e<1e-4||e>1||C(B,this,e)}},{key:"playingState",set:function(e){C(V,this,!1!==e)}},{key:"initialized",get:function(){return L(J,this)}},{key:"raindropsTimeInterval",set:function(e){e<10||e>12e3||C(ae,this,e)}},{key:"raindropsFall",value:function(){var e=window.getComputedStyle(L(j,this)),t=function(e){return function(e=1,t=0){let r=Math.ceil(Number(t)),n=Math.floor(Number(e));return r>n&&([n,r]=[r,n]),Math.floor(Math.random()*(n-r+1)+r)}(parseInt(e))},r=e.width,n=e.height;this.drop(t(r),t(n),1.5*this.dropRadius,.14)}},{key:"drop",value:function(e,t,r,n){var i=this.gl,o=L(j,this).offsetWidth,a=L(j,this).offsetHeight,s=Math.max(o,a);r/=s;var l=new Float32Array([(2*e-o)/s,(a-2*t)/s]);i.viewport(0,0,L(X,this),L(X,this)),i.bindFramebuffer(i.FRAMEBUFFER,L(z,this)[L(H,this)]),Reflect.apply(h,this,[L(G,this)[L(Y,this)]]),i.useProgram(L(te,this).id),i.uniform2fv(L(te,this).locations.center,l),i.uniform1f(L(te,this).locations.radius,r),i.uniform1f(L(te,this).locations.strength,n),I(le,this,pe).call(this),I(le,this,ve).call(this)}},{key:"updateSize",value:function(){var e=L(j,this).offsetWidth,t=L(j,this).offsetHeight;e==this.canvas.width&&t==this.canvas.height||(this.canvas.width=e,this.canvas.height=t)}},{key:"destroy",value:function(){var e=this,t=L(j,this);t&&(Object.keys(L(se,this)).forEach((function(r){return t.removeEventListener&&t.removeEventListener(r,L(se,e)[r])})),t.removeAttribute&&t.removeAttribute("data-ripples")),this.styleElement&&this.styleElement.remove(),this.gl=null,this.gl&&(this.gl=null),window.removeEventListener("resize",this.updateSize),I(le,this,Re).call(this),L(Q,this)&&window.cancelAnimationFrame(L(Q,this))}},{key:"show",value:function(){C(K,this,!0),this.canvas.style.visibility="visible",I(le,this,Te).call(this)}},{key:"hide",value:function(){C(K,this,!1),this.canvas.style.visibility="hidden",I(le,this,Re).call(this)}},{key:"pause",value:function(){C(V,this,!1)}},{key:"play",value:function(){C(V,this,!0)}},{key:"changePlayingState",value:function(){C(V,this,!L(V,this))}},{key:"set",value:function(e,t){"imageUrl"===e?(this.imageUrl=t,I(le,this,fe).call(this)):this[e]=t}}],r&&P(t.prototype,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,r}();function ce(){var e=this,t=function(t){var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];L(K,e)&&L(V,e)&&e.interactive&&(C(oe,e,Date.now()),I(le,e,we).call(e,t,e.dropRadius*(r?1.5:1),r?.14:.01))};L(se,this).mousemove=function(r){for(var n=L(W,e);n--;)t(r)},L(se,this).touchmove=L(se,this).touchstart=function(e){for(var r=e.touches,n=0;n<r.length;n++)t(r[n])},L(se,this).mousedown=function(e){return t(e,!0)},Object.keys(L(se,this)).forEach((function(t){return L(j,e)&&L(j,e).addEventListener(t,L(se,e)[t],{passive:!0})}))}function fe(){var e=this,t=this.gl,r=this.imageUrl||c(L(Z,this))||c(window.getComputedStyle(L(j,this)).backgroundImage);if(r!==this.imageSource)if(this.imageSource=r,this.imageSource){var n=new Image;n.onload=function(){var r=function(e){return!(e&e-1)},i=r(n.width)&&r(n.height)?t.REPEAT:t.CLAMP_TO_EDGE;t.bindTexture(t.TEXTURE_2D,L($,e)),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,i),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,i),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,n),C(re,e,n.width),C(ne,e,n.height),I(le,e,Te).call(e)},n.onerror=function(){return I(le,e,be).call(e)},n.crossOrigin=this.imageSource.match(/^data:/)?null:this.crossOrigin,n.src=this.imageSource}else I(le,this,be).call(this)}function he(){var e=this;L(K,this)&&(I(le,this,ge).call(this),L(V,this)&&I(le,this,me).call(this),I(le,this,de).call(this),C(Q,this,requestAnimationFrame((function(){return I(le,e,he).call(e)}))))}function pe(){var e=this.gl;e.bindBuffer(e.ARRAY_BUFFER,L(q,this)),e.vertexAttribPointer(0,2,e.FLOAT,!1,0,0),e.drawArrays(e.TRIANGLE_FAN,0,4)}function de(){var e=this.gl;e.bindFramebuffer(e.FRAMEBUFFER,null),e.viewport(0,0,this.canvas.width,this.canvas.height),e.enable(e.BLEND),e.clear(e.COLOR_BUFFER_BIT|e.DEPTH_BUFFER_BIT),e.useProgram(this.renderProgram.id),Reflect.apply(h,this,[L($,this),0]),Reflect.apply(h,this,[L(G,this)[0],1]),e.uniform1f(this.renderProgram.locations.perturbance,L(B,this)),e.uniform2fv(this.renderProgram.locations.topLeft,this.renderProgram.uniforms.topLeft),e.uniform2fv(this.renderProgram.locations.bottomRight,this.renderProgram.uniforms.bottomRight),e.uniform2fv(this.renderProgram.locations.containerRatio,this.renderProgram.uniforms.containerRatio),e.uniform1i(this.renderProgram.locations.samplerBackground,0),e.uniform1i(this.renderProgram.locations.samplerRipples,1),I(le,this,pe).call(this),e.disable(e.BLEND)}function me(){if(this.idleFluctuations){var e=Date.now();e-L(oe,this)>L(ae,this)&&(C(oe,this,e),this.raindropsFall())}var t=this.gl;t.viewport(0,0,L(X,this),L(X,this)),t.bindFramebuffer(t.FRAMEBUFFER,L(z,this)[L(H,this)]),Reflect.apply(h,this,[L(G,this)[L(Y,this)]]),t.useProgram(L(ee,this).id),I(le,this,pe).call(this),I(le,this,ve).call(this)}function ve(){C(H,this,1-L(H,this)),C(Y,this,1-L(Y,this))}function ge(){var e,t,r,n=window.getComputedStyle(L(j,this)).backgroundSize,i=window.getComputedStyle(L(j,this)).backgroundAttachment,o=(e=window.getComputedStyle(L(j,this)).backgroundPosition,/\s+/.test(e)?e.replace(/center/,"50%").replace(/top|left/,"0%").replace(/bottom/,"100%").replace(/\s+/," ").split(" "):p(e)?[e,"50%"]:{center:["50%","50%"],top:["50%","0%"],bottom:["50%","100%"],left:["0%","50%"],right:["100%","50%"]}[e]),a="fixed"==i?{left:window.scrollX,top:window.scrollY,width:window.innerWidth,height:window.innerHeight}:{left:L(j,this).getBoundingClientRect().left,top:L(j,this).getBoundingClientRect().top,width:L(j,this).scrollWidth,height:L(j,this).scrollHeight};if("cover"==n){var s=Math.max(a.width/L(re,this),a.height/L(ne,this));t=L(re,this)*s,r=L(ne,this)*s}else if("contain"==n){var l=Math.min(a.width/L(re,this),a.height/L(ne,this));t=L(re,this)*l,r=L(ne,this)*l}else{var u=n.split(" ");t=u[0]||"",r=u[1]||t,p(t)?t=a.width*parseFloat(t)/100:"auto"!==t&&(t=parseFloat(t)),p(r)?r=a.height*parseFloat(r)/100:"auto"!==r&&(r=parseFloat(r)),"auto"==t&&"auto"==r?(t=L(re,this),r=L(ne,this)):("auto"==t&&(t=L(re,this)*(Number(r)/L(ne,this))),"auto"==r&&(r=L(ne,this)*(Number(t)/L(re,this))))}var c=o&&o[0]||"0%",f=o&&o[1]||"0%";c=p(c)?(a.left+(a.width-Number(t))*parseFloat(c)/100).toString():(a.left+parseFloat(c)).toString(),f=p(f)?(a.top+(a.height-Number(r))*parseFloat(f)/100).toString():(a.top+parseFloat(f)).toString(),this.renderProgram.uniforms.topLeft=new Float32Array([(L(j,this).offsetLeft-Number(c))/Number(t),(L(j,this).offsetTop-Number(f))/Number(r)]),this.renderProgram.uniforms.bottomRight=new Float32Array([this.renderProgram.uniforms.topLeft[0]+L(j,this).clientWidth/Number(t),this.renderProgram.uniforms.topLeft[1]+L(j,this).clientHeight/Number(r)]);var h=Math.max(this.canvas.width,this.canvas.height);this.renderProgram.uniforms.containerRatio=new Float32Array([this.canvas.width/h,this.canvas.height/h])}function Ee(){var e=this.gl,t="\n attribute vec2 vertex;\n varying vec2 coord;\n void main() {\n coord = vertex * 0.5 + 0.5;\n gl_Position = vec4(vertex, 0.0, 1.0);\n }";C(te,this,f(t,"precision highp float;\n\n const float PI = 3.141592653589793;\n uniform sampler2D texture;\n uniform vec2 center;\n uniform float radius;\n uniform float strength;\n\n varying vec2 coord;\n\n void main() {\n vec4 info = texture2D(texture, coord);\n\n float drop = max(0.0, 1.0 - length(center * 0.5 + 0.5 - coord) / radius);\n drop = 0.5 - cos(drop * PI) * 0.5;\n info.r += drop * strength;\n gl_FragColor = info;\n }",e)),C(ee,this,f(t,"precision highp float;\n\n uniform sampler2D texture;\n uniform vec2 delta;\n\n varying vec2 coord;\n\n void main() {\n vec4 info = texture2D(texture, coord);\n \n vec2 dx = vec2(delta.x, 0.0);\n vec2 dy = vec2(0.0, delta.y);\n \n float average = (\n texture2D(texture, coord - dx).r +\n texture2D(texture, coord - dy).r +\n texture2D(texture, coord + dx).r +\n texture2D(texture, coord + dy).r\n ) * 0.25;\n \n info.g += (average - info.r) * 2.0;\n info.g *= 0.995;\n info.r += info.g;\n \n gl_FragColor = info;\n }\n ",this.gl)),e.uniform2fv(L(ee,this).locations.delta,L(N,this)),this.renderProgram=f("\n precision highp float;\n\n attribute vec2 vertex;\n uniform vec2 topLeft;\n uniform vec2 bottomRight;\n uniform vec2 containerRatio;\n varying vec2 ripplesCoord;\n varying vec2 backgroundCoord;\n void main() {\n backgroundCoord = mix(topLeft, bottomRight, vertex * 0.5 + 0.5);\n backgroundCoord.y = 1.0 - backgroundCoord.y;\n ripplesCoord = vec2(vertex.x, -vertex.y) * containerRatio * 0.5 + 0.5;\n gl_Position = vec4(vertex.x, -vertex.y, 0.0, 1.0);\n }\n ","\n precision highp float;\n\n uniform sampler2D samplerBackground;\n uniform sampler2D samplerRipples;\n uniform vec2 delta;\n\n uniform float perturbance;\n varying vec2 ripplesCoord;\n varying vec2 backgroundCoord;\n\n void main() {\n float height = texture2D(samplerRipples, ripplesCoord).r;\n float heightX = texture2D(samplerRipples, vec2(ripplesCoord.x + delta.x, ripplesCoord.y)).r;\n float heightY = texture2D(samplerRipples, vec2(ripplesCoord.x, ripplesCoord.y + delta.y)).r;\n vec3 dx = vec3(delta.x, heightX - height, 0.0);\n vec3 dy = vec3(0.0, heightY - height, delta.y);\n vec2 offset = -normalize(cross(dy, dx)).xz;\n float specular = pow(max(0.0, dot(offset, normalize(vec2(-0.6, 1.0)))), 4.0);\n gl_FragColor = texture2D(samplerBackground, backgroundCoord + offset * perturbance) + specular;\n }",e),e.uniform2fv(this.renderProgram.locations.delta,L(N,this))}function ye(){var e=this.gl;C($,this,e.createTexture()),e.bindTexture(e.TEXTURE_2D,L($,this)),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,1),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR)}function be(){var e=this.gl;e.bindTexture(e.TEXTURE_2D,L($,this)),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,this.transparentPixels)}function Te(){var e=L(j,this).style.backgroundImage;"none"!=e&&(C(ie,this,e),C(Z,this,window.getComputedStyle(L(j,this)).backgroundImage),L(j,this).style.backgroundImage="none")}function Re(){L(j,this).style.backgroundImage=L(ie,this)||""}function we(e,t,r){var n=window.getComputedStyle(L(j,this)),i=parseInt(n.borderLeftWidth)||0,o=parseInt(n.borderTopWidth)||0;this.drop(e.pageX-L(j,this).offsetLeft-i,e.pageY-L(j,this).offsetTop-o,t,r)}function _e(e,t){var r=(0,a.useRef)(null);return(0,a.useEffect)((function(){return r.current=new ue(e.current,void 0===t.children,t.option),function(){return r.current.destroy()}}),[]),r}var xe=o.n;export{xe as useRipples};
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oops-ui",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
7
7
|
"typings": "dist/types/index.d.ts",
|
|
8
8
|
"scripts": {
|
|
9
9
|
"build": "npx ixxx rm dist && webpack --env t=mjs && webpack --env t=cjs && tsc -p tsconfig.build.json && npm run styles",
|
|
10
|
-
"
|
|
10
|
+
"local": "node build",
|
|
11
11
|
"styles": "sass --no-source-map src/css/common.scss dist/styles/common.css",
|
|
12
12
|
"versionPatch": "npm version patch --force --no-git-tag-version --allow-same-version=true",
|
|
13
13
|
"prepublish": "npm run build",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"./BackgroundRipple": {
|
|
44
44
|
"types": "./dist/types/components/ripples/index.d.ts",
|
|
45
45
|
"require": "./dist/BackgroundRipple/index.cjs",
|
|
46
|
-
"import": "./dist
|
|
46
|
+
"import": "./dist/BackgroundRipple/index.mjs"
|
|
47
47
|
},
|
|
48
48
|
"./useTimeId": {
|
|
49
49
|
"types": "./dist/types/customHooks/useTimeId.d.ts",
|
|
@@ -100,6 +100,7 @@
|
|
|
100
100
|
"@typescript-eslint/eslint-plugin": "^8.18.1",
|
|
101
101
|
"@typescript-eslint/parser": "^8.18.1",
|
|
102
102
|
"a-element-inline-style": "^0.0.0",
|
|
103
|
+
"a-node-tools": "^0.0.5",
|
|
103
104
|
"babel-loader": "^9.2.1",
|
|
104
105
|
"babel-plugin-import": "^1.13.8",
|
|
105
106
|
"commitizen": "^4.3.1",
|
|
@@ -126,5 +127,8 @@
|
|
|
126
127
|
"webpack": "^5.97.1",
|
|
127
128
|
"webpack-cli": "^5.1.4",
|
|
128
129
|
"webpack-dev-server": "^5.2.0"
|
|
130
|
+
},
|
|
131
|
+
"dependencies": {
|
|
132
|
+
"oops-ui": "file:"
|
|
129
133
|
}
|
|
130
|
-
}
|
|
134
|
+
}
|