Build 541864stable
Module 294814
5,246 characters · in no known chunkDependencies
Source Raw
function(e,t,n){"use strict";function i(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(t,"__esModule",{value:!0});var r=n(675106),s=i(n(269274)),a=i(n(394320)),o=i(n(984101)),l=n(672722),u=n(64700),c=n(131981),d=Symbol.for("Animated:node"),_=function(e){return!!e&&e[d]===e},f=function(e,t){return r.defineHidden(e,d,t)},h=function(e){return e&&e[d]&&e[d].getPayload()},p=function(){function e(){this.payload=void 0,f(this,this)}return e.prototype.getPayload=function(){return this.payload||[]},e}(),E=function(e){function t(t){var n;return(n=e.call(this)||this)._value=t,n.done=!0,n.elapsedTime=void 0,n.lastPosition=void 0,n.lastVelocity=void 0,n.v0=void 0,r.is.num(n._value)&&(n.lastPosition=n._value),n}s(t,e),t.create=function(e,n){return new t(e)};var n=t.prototype;return n.getPayload=function(){return[this]},n.getValue=function(){return this._value},n.setValue=function(e,t){return r.is.num(e)&&(this.lastPosition=e,t&&(e=Math.round(e/t)*t,this.done&&(this.lastPosition=e))),this._value!==e&&(this._value=e,!0)},n.reset=function(){var e=this.done;this.done=!1,r.is.num(this._value)&&(this.elapsedTime=0,this.lastPosition=this._value,e&&(this.lastVelocity=null),this.v0=null)},t}(p),m=function(e){function t(t,n){var i;return(i=e.call(this,0)||this)._value=void 0,i._string=null,i._toString=void 0,i._toString=r.createInterpolator({output:[t,n]}),i}s(t,e),t.create=function(e,n){if(void 0===n&&(n=e),r.is.str(e)&&r.is.str(n))return new t(e,n);throw TypeError('Expected "from" and "to" to be strings')};var n=t.prototype;return n.getValue=function(){var e=this._string;return null==e?this._string=this._toString(this._value):e},n.setValue=function(t){if(r.is.num(t))if(!e.prototype.setValue.call(this,t))return!1;else this._string=null;else this._string=t,this._value=1;return!0},n.reset=function(t){t&&(this._toString=r.createInterpolator({output:[this.getValue(),t]})),this._value=0,e.prototype.reset.call(this)},t}(E),g={current:null},A=function(e){function t(t){var n;return void 0===t&&(t=null),(n=e.call(this)||this).source=void 0,n.setValue(t),n}s(t,e);var n=t.prototype;return n.getValue=function(e){if(!this.source)return null;var t={};return r.each(this.source,function(n,i){if(_(n))t[i]=n.getValue(e);else{var s=r.getFluidConfig(n);s?t[i]=s.get():e||(t[i]=n)}}),t},n.setValue=function(e){this.source=e,this.payload=this._makePayload(e)},n.reset=function(){this.payload&&r.each(this.payload,function(e){return e.reset()})},n._makePayload=function(e){if(e){var t=new Set;return r.each(e,this._addToPayload,t),Array.from(t)}},n._addToPayload=function(e){var t=this;r.getFluidConfig(e)&&g.current&&g.current.dependencies.add(e);var n=h(e);n&&r.each(n,function(e){return t.add(e)})},t}(p),I=function(e){function t(t,n){var i;return(i=e.call(this,null)||this).source=void 0,e.prototype.setValue.call(a(i),i._makeAnimated(t,n)),i}s(t,e),t.create=function(e,n){return new t(e,n)};var n=t.prototype;return n.getValue=function(){return this.source.map(function(e){return e.getValue()})},n.setValue=function(e){var t=this.getPayload();e&&e.length==t.length?r.each(t,function(t,n){return t.setValue(e[n])}):(this.source=this._makeAnimated(e),this.payload=this._makePayload(this.source))},n._makeAnimated=function(e,t){return void 0===t&&(t=e),e?e.map(function(e,n){return(r.isAnimatedString(e)?m:E).create(e,t[n])}):[]},t}(A),T=function(e){function t(t){var n;return(n=e.call(this,null)||this).update=t,n.dirty=!1,n}s(t,e);var n=t.prototype;return n.setValue=function(t,n){if(t){if(n&&(g.current=n,t.style)){var i=n.host.createAnimatedStyle;t=o(o({},t),{},{style:i(t.style)})}e.prototype.setValue.call(this,t),g.current=null}},n.onParentChange=function(e){var t=this,n=e.type;this.dirty||"change"!==n||(this.dirty=!0,l.frameLoop.onFrame(function(){t.dirty=!1,t.update()}))},t}(A),S=function(e,t){return u.forwardRef(function(n,i){var s=u.useRef(null),a=!r.is.fun(e)||e.prototype&&e.prototype.isReactComponent,l=r.useForceUpdate(),d=new T(function(){var e=s.current;(!a||e)&&!1===(!!e&&t.applyAnimatedValues(e,d.getValue(!0)))&&l()}),_=new Set;return d.setValue(n,{dependencies:_,host:t}),c.useLayoutEffect(function(){return r.each(_,function(e){return e.addChild(d)}),function(){return r.each(_,function(e){return e.removeChild(d)})}}),u.createElement(e,o({},t.getComponentProps(d.getValue()),{ref:a&&function(e){var t,n;t=i,n=e,t&&(r.is.fun(t)?t(n):t.current=n),s.current=n}}))})},N=Symbol.for("AnimatedComponent"),y=function(e){return r.is.str(e)?e:e&&r.is.str(e.displayName)?e.displayName:r.is.fun(e)&&e.name||null};t.Animated=p,t.AnimatedArray=I,t.AnimatedObject=A,t.AnimatedProps=T,t.AnimatedString=m,t.AnimatedValue=E,t.createHost=function(e,t){var n=void 0===t?{}:t,i=n.applyAnimatedValues,s=n.createAnimatedStyle,a=void 0===s?function(e){return new A(e)}:s,o=n.getComponentProps,l={applyAnimatedValues:void 0===i?function(){return!1}:i,createAnimatedStyle:a,getComponentProps:void 0===o?function(e){return e}:o},u=function(e){var t=y(e)||"Anonymous";return(e=r.is.str(e)?S(e,l):e[N]||(e[N]=S(e,l))).displayName="Animated("+t+")",e};return r.each(e,function(e,t){r.is.str(t)||(t=y(e)),u[t]=u(e)}),{animated:u}},t.getAnimated=function(e){return e&&e[d]},t.getPayload=h,t.isAnimated=_,t.setAnimated=f}