@rive-app/react-canvas
Advanced tools
Comparing version 4.15.1 to 4.15.2
@@ -1,1 +0,1 @@ | ||
Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("@rive-app/canvas");function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var i=/*#__PURE__*/n(e),r=function(){return r=Object.assign||function(e){for(var t,n=1,i=arguments.length;n<i;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},r.apply(this,arguments)};function o(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(e);r<i.length;r++)t.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(n[i[r]]=e[i[r]])}return n}function a(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{s(i.next(e))}catch(e){o(e)}}function u(e){try{s(i.throw(e))}catch(e){o(e)}}function s(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,u)}s((i=i.apply(e,t||[])).next())})}function u(e,t){var n,i,r,o={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=u(0),a.throw=u(1),a.return=u(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(u){return function(s){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(o=0)),o;)try{if(n=1,i&&(r=2&u[0]?i.return:u[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,u[1])).done)return r;switch(i=0,r&&(u=[2&u[0],r.value]),u[0]){case 0:case 1:r=u;break;case 4:return o.label++,{value:u[1],done:!1};case 5:o.label++,i=u[1],u=[0];continue;case 7:u=o.ops.pop(),o.trys.pop();continue;default:if(!(r=o.trys,(r=r.length>0&&r[r.length-1])||6!==u[0]&&2!==u[0])){o=0;continue}if(3===u[0]&&(!r||u[1]>r[0]&&u[1]<r[3])){o.label=u[1];break}if(6===u[0]&&o.label<r[1]){o.label=r[1],r=u;break}if(r&&o.label<r[2]){o.label=r[2],o.ops.push(u);break}r[2]&&o.ops.pop(),o.trys.pop();continue}u=t.call(e,o)}catch(e){u=[6,e],i=0}finally{n=r=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,s])}}}function s(t){var n=t||c(),i=e.useState(n),r=i[0],o=i[1];return e.useEffect(function(){if("undefined"!=typeof window&&"matchMedia"in window){var e=function(){var e=t||c();o(e)},n=window.matchMedia("screen and (resolution: ".concat(r,"dppx)"));return n.hasOwnProperty("addEventListener")?n.addEventListener("change",e):n.addListener(e),function(){n.hasOwnProperty("removeEventListener")?n.removeEventListener("change",e):n.removeListener(e)}}},[r,t]),r}function c(){var e="undefined"!=typeof window&&"number"==typeof window.devicePixelRatio?window.devicePixelRatio:1;return Math.min(Math.max(1,e),3)}"function"==typeof SuppressedError&&SuppressedError;var l=function(){function e(){}return e.prototype.observe=function(){},e.prototype.unobserve=function(){},e.prototype.disconnect=function(){},e}();var f=globalThis.ResizeObserver||l,d=void 0!==globalThis.ResizeObserver,v=!d;function h(t,n){void 0===n&&(n=!0);var i=e.useState({width:0,height:0}),r=i[0],o=i[1];e.useEffect(function(){if("undefined"!=typeof window&&n){var e=function(){o({width:window.innerWidth,height:window.innerHeight})};return v&&(e(),window.addEventListener("resize",e)),function(){return window.removeEventListener("resize",e)}}},[]);var a,u,s,c=e.useRef(new f((a=function(e){d&&o({width:e[e.length-1].contentRect.width,height:e[e.length-1].contentRect.height})},u=0,s=0,function(){for(var e=this,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];clearTimeout(s),s=window.setTimeout(function(){return a.apply(e,t)},u)})));return e.useEffect(function(){var e=c.current;if(n){var i=t.current;return t.current&&d&&e.observe(t.current),function(){e.disconnect(),i&&d&&e.unobserve(i)}}e.disconnect()},[t,c]),r}var p={useDevicePixelRatio:!0,fitCanvasToArtboardHeight:!1,useOffscreenRenderer:!0,shouldResizeCanvasToContainer:!0};function b(e){return Object.assign({},p,e)}function w(t){var n=t.riveLoaded,i=void 0!==n&&n,r=t.canvasElem,o=t.containerRef,a=t.options,u=void 0===a?{}:a,c=t.onCanvasHasResized,l=t.artboardBounds,f=b(u),d=e.useState({height:0,width:0}),v=d[0],p=v.height,w=v.width,y=d[1],g=e.useState({height:0,width:0}),m=g[0],R=m.height,C=m.width,E=g[1],O=e.useState(!0),x=O[0],T=O[1],P=f.fitCanvasToArtboardHeight,L=f.shouldResizeCanvasToContainer,S=f.useDevicePixelRatio,k=f.customDevicePixelRatio,M=h(o,L),j=s(k),z=null!=l?l:{},H=z.maxX,I=z.maxY,D=e.useCallback(function(){var e,t,n,i,r=null!==(t=null===(e=o.current)||void 0===e?void 0:e.clientWidth)&&void 0!==t?t:0,a=null!==(i=null===(n=o.current)||void 0===n?void 0:n.clientHeight)&&void 0!==i?i:0;return P&&l?{width:r,height:r*(l.maxY/l.maxX)}:{width:r,height:a}},[o,P,H,I]);e.useEffect(function(){if(L&&o.current&&i){var e=D(),t=e.width,n=e.height,a=!1;if(r){var u=t!==w||n!==p;if(f.fitCanvasToArtboardHeight&&u&&(o.current.style.height=n+"px",a=!0),f.useDevicePixelRatio){if(u||(t*j!==C||n*j!==R)){var s=j*t,l=j*n;r.width=s,r.height=l,r.style.width=t+"px",r.style.height=n+"px",E({width:s,height:l}),a=!0}}else u&&(r.width=t,r.height=n,E({width:t,height:n}),a=!0);y({width:t,height:n})}c&&(x||a)&&c&&c(),x&&T(!1)}},[r,o,M,j,D,x,T,R,C,p,w,c,L,P,S,i]),e.useEffect(function(){E({width:0,height:0})},[r])}var y,g=function(){function e(){}return e.prototype.observe=function(){},e.prototype.unobserve=function(){},e.prototype.disconnect=function(){},e}(),m=globalThis.IntersectionObserver||g,R=function(){function e(){var e=this;this.elementsMap=new Map,this.onObserved=function(t){t.forEach(function(t){var n=e.elementsMap.get(t.target);n&&n(t)})},this.observer=new m(this.onObserved)}return e.prototype.registerCallback=function(e,t){this.observer.observe(e),this.elementsMap.set(e,t)},e.prototype.removeCallback=function(e){this.observer.unobserve(e),this.elementsMap.delete(e)},e}(),C=function(){return y||(y=new R),y};function E(e){var t=e.setContainerRef,n=e.setCanvasRef,a=e.className,u=void 0===a?"":a,s=e.style,c=e.children,l=o(e,["setContainerRef","setCanvasRef","className","style","children"]),f=r({width:"100%",height:"100%"},s);return i.default.createElement("div",r({ref:t,className:u},!u&&{style:f}),i.default.createElement("canvas",r({ref:n,style:{verticalAlign:"top",width:0,height:0}},l),c))}function O(n,o){void 0===o&&(o={});var a=e.useState(null),u=a[0],c=a[1],l=e.useRef(null),f=e.useState(null),d=f[0],v=f[1],h=Boolean(n),p=b(o),y=s(),g=e.useCallback(function(){d&&(d.layout&&d.layout.fit===t.Fit.Layout&&u&&(d._devicePixelRatioUsed=y,d.artboard.width=(null==u?void 0:u.width)/y,d.artboard.height=(null==u?void 0:u.height)/y),d.startRendering(),d.resizeToCanvas())},[d,y]);w({riveLoaded:!!d,canvasElem:u,containerRef:l,options:p,onCanvasHasResized:g,artboardBounds:null==d?void 0:d.bounds});var m=e.useCallback(function(e){null===e&&u&&(u.height=0,u.width=0),c(e)},[]);e.useEffect(function(){if(u&&n&&null==d){var e=p.useOffscreenRenderer,i=new t.Rive(r(r({useOffscreenRenderer:e},n),{canvas:u}));i.on(t.EventType.Load,function(){u?v(i):i.cleanup()})}},[u,h,d]);var R=e.useCallback(function(e){l.current=e},[]),O={observe:e.useCallback(function(e,t){C().registerCallback(e,t)},[]),unobserve:e.useCallback(function(e){C().removeCallback(e)},[])},x=O.observe,T=O.unobserve;e.useEffect(function(){var e,t=!1,n=function(){if(u&&t){var e=u.getBoundingClientRect();e.width>0&&e.height>0&&e.top<(window.innerHeight||document.documentElement.clientHeight)&&e.bottom>0&&e.left<(window.innerWidth||document.documentElement.clientWidth)&&e.right>0&&(null==d||d.startRendering(),t=!1)}};return u&&!1!==p.shouldUseIntersectionObserver&&x(u,function(i){i.isIntersecting?d&&d.startRendering():d&&d.stopRendering(),t=!i.isIntersecting,clearTimeout(e),i.isIntersecting||0!==i.boundingClientRect.width||(e=setTimeout(n,10))}),function(){u&&T(u)}},[x,T,d,u,p.shouldUseIntersectionObserver]),e.useEffect(function(){return function(){d&&(d.cleanup(),v(null))}},[d,u]);var P=null==n?void 0:n.animations;e.useEffect(function(){d&&P&&(d.isPlaying?(d.stop(d.animationNames),d.play(P)):d.isPaused&&(d.stop(d.animationNames),d.pause(P)))},[P,d]);var L=e.useCallback(function(e){return i.default.createElement(E,r({setContainerRef:R,setCanvasRef:m},e))},[m,R]);return{canvas:u,container:l.current,setCanvasRef:m,setContainerRef:R,rive:d,RiveComponent:L}}exports.default=function(e){var t=e.src,n=e.artboard,a=e.animations,u=e.stateMachines,s=e.layout,c=e.useOffscreenRenderer,l=void 0===c||c,f=e.shouldDisableRiveListeners,d=void 0!==f&&f,v=e.shouldResizeCanvasToContainer,h=void 0===v||v,p=e.automaticallyHandleEvents,b=void 0!==p&&p,w=e.children,y=o(e,["src","artboard","animations","stateMachines","layout","useOffscreenRenderer","shouldDisableRiveListeners","shouldResizeCanvasToContainer","automaticallyHandleEvents","children"]),g=O({src:t,artboard:n,animations:a,layout:s,stateMachines:u,autoplay:!0,shouldDisableRiveListeners:d,automaticallyHandleEvents:b},{useOffscreenRenderer:l,shouldResizeCanvasToContainer:h}).RiveComponent;return i.default.createElement(g,r({},y),w)},exports.useResizeCanvas=w,exports.useRive=O,exports.useRiveFile=function(n){var i=this,r=e.useState(null),o=r[0],s=r[1],c=e.useState("idle"),l=c[0],f=c[1];return e.useEffect(function(){var e=null;return a(i,void 0,void 0,function(){return u(this,function(i){try{f("loading"),(e=new t.RiveFile(n)).init(),e.on(t.EventType.Load,function(){null==e||e.getInstance(),s(e),f("success")}),e.on(t.EventType.LoadError,function(){f("failed")}),s(e)}catch(e){console.error(e),f("failed")}return[2]})}),function(){null==e||e.cleanup()}},[n.src,n.buffer]),{riveFile:o,status:l}},exports.useStateMachineInput=function(n,i,r,o){var a=e.useState(null),u=a[0],s=a[1];return e.useEffect(function(){function e(){if(n&&i&&r||s(null),n&&i&&r){var e=n.stateMachineInputs(i);if(e){var t=e.find(function(e){return e.name===r});void 0!==o&&t&&(t.value=o),s(t||null)}}else s(null)}e(),n&&n.on(t.EventType.Load,function(){e()})},[n]),u},Object.keys(t).forEach(function(e){"default"===e||exports.hasOwnProperty(e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return t[e]}})}); | ||
Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("@rive-app/canvas");function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var i=/*#__PURE__*/n(e),r=function(){return r=Object.assign||function(e){for(var t,n=1,i=arguments.length;n<i;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},r.apply(this,arguments)};function o(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(e);r<i.length;r++)t.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(n[i[r]]=e[i[r]])}return n}function a(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{s(i.next(e))}catch(e){o(e)}}function u(e){try{s(i.throw(e))}catch(e){o(e)}}function s(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,u)}s((i=i.apply(e,t||[])).next())})}function u(e,t){var n,i,r,o={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=u(0),a.throw=u(1),a.return=u(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(u){return function(s){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(o=0)),o;)try{if(n=1,i&&(r=2&u[0]?i.return:u[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,u[1])).done)return r;switch(i=0,r&&(u=[2&u[0],r.value]),u[0]){case 0:case 1:r=u;break;case 4:return o.label++,{value:u[1],done:!1};case 5:o.label++,i=u[1],u=[0];continue;case 7:u=o.ops.pop(),o.trys.pop();continue;default:if(!(r=o.trys,(r=r.length>0&&r[r.length-1])||6!==u[0]&&2!==u[0])){o=0;continue}if(3===u[0]&&(!r||u[1]>r[0]&&u[1]<r[3])){o.label=u[1];break}if(6===u[0]&&o.label<r[1]){o.label=r[1],r=u;break}if(r&&o.label<r[2]){o.label=r[2],o.ops.push(u);break}r[2]&&o.ops.pop(),o.trys.pop();continue}u=t.call(e,o)}catch(e){u=[6,e],i=0}finally{n=r=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,s])}}}function s(t){var n=t||c(),i=e.useState(n),r=i[0],o=i[1];return e.useEffect(function(){if("undefined"!=typeof window&&"matchMedia"in window){var e=function(){var e=t||c();o(e)},n=window.matchMedia("screen and (resolution: ".concat(r,"dppx)"));return n.hasOwnProperty("addEventListener")?n.addEventListener("change",e):n.addListener(e),function(){n.hasOwnProperty("removeEventListener")?n.removeEventListener("change",e):n.removeListener(e)}}},[r,t]),r}function c(){var e="undefined"!=typeof window&&"number"==typeof window.devicePixelRatio?window.devicePixelRatio:1;return Math.min(Math.max(1,e),3)}"function"==typeof SuppressedError&&SuppressedError;var l=function(){function e(){}return e.prototype.observe=function(){},e.prototype.unobserve=function(){},e.prototype.disconnect=function(){},e}();var f=globalThis.ResizeObserver||l,d=void 0!==globalThis.ResizeObserver,v=!d;function h(t,n){void 0===n&&(n=!0);var i=e.useState({width:0,height:0}),r=i[0],o=i[1];e.useEffect(function(){if("undefined"!=typeof window&&n){var e=function(){o({width:window.innerWidth,height:window.innerHeight})};return v&&(e(),window.addEventListener("resize",e)),function(){return window.removeEventListener("resize",e)}}},[]);var a,u,s,c=e.useRef(new f((a=function(e){d&&o({width:e[e.length-1].contentRect.width,height:e[e.length-1].contentRect.height})},u=0,s=0,function(){for(var e=this,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];clearTimeout(s),s=window.setTimeout(function(){return a.apply(e,t)},u)})));return e.useEffect(function(){var e=c.current;if(n){var i=t.current;return t.current&&d&&e.observe(t.current),function(){e.disconnect(),i&&d&&e.unobserve(i)}}e.disconnect()},[t,c]),r}var p={useDevicePixelRatio:!0,fitCanvasToArtboardHeight:!1,useOffscreenRenderer:!0,shouldResizeCanvasToContainer:!0};function b(e){return Object.assign({},p,e)}function w(t){var n=t.riveLoaded,i=void 0!==n&&n,r=t.canvasElem,o=t.containerRef,a=t.options,u=void 0===a?{}:a,c=t.onCanvasHasResized,l=t.artboardBounds,f=b(u),d=e.useState({height:0,width:0}),v=d[0],p=v.height,w=v.width,y=d[1],g=e.useState({height:0,width:0}),m=g[0],R=m.height,C=m.width,E=g[1],O=e.useState(!0),x=O[0],T=O[1],P=f.fitCanvasToArtboardHeight,L=f.shouldResizeCanvasToContainer,S=f.useDevicePixelRatio,k=f.customDevicePixelRatio,M=h(o,L),j=s(k),z=null!=l?l:{},H=z.maxX,I=z.maxY,D=e.useCallback(function(){var e,t,n,i,r=null!==(t=null===(e=o.current)||void 0===e?void 0:e.clientWidth)&&void 0!==t?t:0,a=null!==(i=null===(n=o.current)||void 0===n?void 0:n.clientHeight)&&void 0!==i?i:0;return P&&l?{width:r,height:r*(l.maxY/l.maxX)}:{width:r,height:a}},[o,P,H,I]);e.useEffect(function(){if(L&&o.current&&i){var e=D(),t=e.width,n=e.height,a=!1;if(r){var u=t!==w||n!==p;if(f.fitCanvasToArtboardHeight&&u&&(o.current.style.height=n+"px",a=!0),f.useDevicePixelRatio){if(u||(t*j!==C||n*j!==R)){var s=j*t,l=j*n;r.width=s,r.height=l,r.style.width=t+"px",r.style.height=n+"px",E({width:s,height:l}),a=!0}}else u&&(r.width=t,r.height=n,E({width:t,height:n}),a=!0);y({width:t,height:n})}c&&(x||a)&&c&&c(),x&&T(!1)}},[r,o,M,j,D,x,T,R,C,p,w,c,L,P,S,i]),e.useEffect(function(){E({width:0,height:0})},[r])}var y,g=function(){function e(){}return e.prototype.observe=function(){},e.prototype.unobserve=function(){},e.prototype.disconnect=function(){},e}(),m=globalThis.IntersectionObserver||g,R=function(){function e(){var e=this;this.elementsMap=new Map,this.onObserved=function(t){t.forEach(function(t){var n=e.elementsMap.get(t.target);n&&n(t)})},this.observer=new m(this.onObserved)}return e.prototype.registerCallback=function(e,t){this.observer.observe(e),this.elementsMap.set(e,t)},e.prototype.removeCallback=function(e){this.observer.unobserve(e),this.elementsMap.delete(e)},e}(),C=function(){return y||(y=new R),y};function E(e){var t=e.setContainerRef,n=e.setCanvasRef,a=e.className,u=void 0===a?"":a,s=e.style,c=e.children,l=o(e,["setContainerRef","setCanvasRef","className","style","children"]),f=r({width:"100%",height:"100%"},s);return i.default.createElement("div",r({ref:t,className:u},!u&&{style:f}),i.default.createElement("canvas",r({ref:n,style:{verticalAlign:"top",width:0,height:0}},l),c))}function O(n,o){void 0===o&&(o={});var a=e.useState(null),u=a[0],c=a[1],l=e.useRef(null),f=e.useState(null),d=f[0],v=f[1],h=Boolean(n),p=b(o),y=s(),g=e.useCallback(function(){if(d){if(d.layout&&d.layout.fit===t.Fit.Layout&&u){var e=y*d.layout.layoutScaleFactor;d._devicePixelRatioUsed=y,d.artboard.width=(null==u?void 0:u.width)/e,d.artboard.height=(null==u?void 0:u.height)/e}d.startRendering(),d.resizeToCanvas()}},[d,y]);w({riveLoaded:!!d,canvasElem:u,containerRef:l,options:p,onCanvasHasResized:g,artboardBounds:null==d?void 0:d.bounds});var m=e.useCallback(function(e){null===e&&u&&(u.height=0,u.width=0),c(e)},[]);e.useEffect(function(){if(u&&n&&null==d){var e=p.useOffscreenRenderer,i=new t.Rive(r(r({useOffscreenRenderer:e},n),{canvas:u}));i.on(t.EventType.Load,function(){u?v(i):i.cleanup()})}},[u,h,d]);var R=e.useCallback(function(e){l.current=e},[]),O={observe:e.useCallback(function(e,t){C().registerCallback(e,t)},[]),unobserve:e.useCallback(function(e){C().removeCallback(e)},[])},x=O.observe,T=O.unobserve;e.useEffect(function(){var e,t=!1,n=function(){if(u&&t){var e=u.getBoundingClientRect();e.width>0&&e.height>0&&e.top<(window.innerHeight||document.documentElement.clientHeight)&&e.bottom>0&&e.left<(window.innerWidth||document.documentElement.clientWidth)&&e.right>0&&(null==d||d.startRendering(),t=!1)}};return u&&!1!==p.shouldUseIntersectionObserver&&x(u,function(i){i.isIntersecting?d&&d.startRendering():d&&d.stopRendering(),t=!i.isIntersecting,clearTimeout(e),i.isIntersecting||0!==i.boundingClientRect.width||(e=setTimeout(n,10))}),function(){u&&T(u)}},[x,T,d,u,p.shouldUseIntersectionObserver]),e.useEffect(function(){return function(){d&&(d.cleanup(),v(null))}},[d,u]);var P=null==n?void 0:n.animations;e.useEffect(function(){d&&P&&(d.isPlaying?(d.stop(d.animationNames),d.play(P)):d.isPaused&&(d.stop(d.animationNames),d.pause(P)))},[P,d]);var L=e.useCallback(function(e){return i.default.createElement(E,r({setContainerRef:R,setCanvasRef:m},e))},[m,R]);return{canvas:u,container:l.current,setCanvasRef:m,setContainerRef:R,rive:d,RiveComponent:L}}exports.default=function(e){var t=e.src,n=e.artboard,a=e.animations,u=e.stateMachines,s=e.layout,c=e.useOffscreenRenderer,l=void 0===c||c,f=e.shouldDisableRiveListeners,d=void 0!==f&&f,v=e.shouldResizeCanvasToContainer,h=void 0===v||v,p=e.automaticallyHandleEvents,b=void 0!==p&&p,w=e.children,y=o(e,["src","artboard","animations","stateMachines","layout","useOffscreenRenderer","shouldDisableRiveListeners","shouldResizeCanvasToContainer","automaticallyHandleEvents","children"]),g=O({src:t,artboard:n,animations:a,layout:s,stateMachines:u,autoplay:!0,shouldDisableRiveListeners:d,automaticallyHandleEvents:b},{useOffscreenRenderer:l,shouldResizeCanvasToContainer:h}).RiveComponent;return i.default.createElement(g,r({},y),w)},exports.useResizeCanvas=w,exports.useRive=O,exports.useRiveFile=function(n){var i=this,r=e.useState(null),o=r[0],s=r[1],c=e.useState("idle"),l=c[0],f=c[1];return e.useEffect(function(){var e=null;return a(i,void 0,void 0,function(){return u(this,function(i){try{f("loading"),(e=new t.RiveFile(n)).init(),e.on(t.EventType.Load,function(){null==e||e.getInstance(),s(e),f("success")}),e.on(t.EventType.LoadError,function(){f("failed")}),s(e)}catch(e){console.error(e),f("failed")}return[2]})}),function(){null==e||e.cleanup()}},[n.src,n.buffer]),{riveFile:o,status:l}},exports.useStateMachineInput=function(n,i,r,o){var a=e.useState(null),u=a[0],s=a[1];return e.useEffect(function(){function e(){if(n&&i&&r||s(null),n&&i&&r){var e=n.stateMachineInputs(i);if(e){var t=e.find(function(e){return e.name===r});void 0!==o&&t&&(t.value=o),s(t||null)}}else s(null)}e(),n&&n.on(t.EventType.Load,function(){e()})},[n]),u},Object.keys(t).forEach(function(e){"default"===e||exports.hasOwnProperty(e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return t[e]}})}); |
{ | ||
"name": "@rive-app/react-canvas", | ||
"version": "4.15.1", | ||
"version": "4.15.2", | ||
"description": "React wrapper around the @rive-app/canvas library", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
21563