Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@rive-app/react-canvas-lite

Package Overview
Dependencies
Maintainers
0
Versions
70
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rive-app/react-canvas-lite - npm Package Compare versions

Comparing version 4.15.0 to 4.15.1

2

dist/index.js

@@ -1,1 +0,1 @@

Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("@rive-app/canvas-lite");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{u(i.next(e))}catch(e){o(e)}}function s(e){try{u(i.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}u((i=i.apply(e,t||[])).next())})}function s(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=s(0),a.throw=s(1),a.return=s(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(o=0)),o;)try{if(n=1,i&&(r=2&s[0]?i.return:s[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,s[1])).done)return r;switch(i=0,r&&(s=[2&s[0],r.value]),s[0]){case 0:case 1:r=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,i=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(r=o.trys,(r=r.length>0&&r[r.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!r||s[1]>r[0]&&s[1]<r[3])){o.label=s[1];break}if(6===s[0]&&o.label<r[1]){o.label=r[1],r=s;break}if(r&&o.label<r[2]){o.label=r[2],o.ops.push(s);break}r[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],i=0}finally{n=r=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}}function u(){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 c=function(){function e(){}return e.prototype.observe=function(){},e.prototype.unobserve=function(){},e.prototype.disconnect=function(){},e}();var l=globalThis.ResizeObserver||c,f=void 0!==globalThis.ResizeObserver,d=!f;function v(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 d&&(e(),window.addEventListener("resize",e)),function(){return window.removeEventListener("resize",e)}}},[]);var a,s,u,c=e.useRef(new l((a=function(e){f&&o({width:e[e.length-1].contentRect.width,height:e[e.length-1].contentRect.height})},s=0,u=0,function(){for(var e=this,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];clearTimeout(u),u=window.setTimeout(function(){return a.apply(e,t)},s)})));return e.useEffect(function(){var e=c.current;if(n){var i=t.current;return t.current&&f&&e.observe(t.current),function(){e.disconnect(),i&&f&&e.unobserve(i)}}e.disconnect()},[t,c]),r}var h={useDevicePixelRatio:!0,fitCanvasToArtboardHeight:!1,useOffscreenRenderer:!0,shouldResizeCanvasToContainer:!0};function p(e){return Object.assign({},h,e)}function b(t){var n=t.riveLoaded,i=void 0!==n&&n,r=t.canvasElem,o=t.containerRef,a=t.options,s=void 0===a?{}:a,c=t.onCanvasHasResized,l=t.artboardBounds,f=p(s),d=e.useState({height:0,width:0}),h=d[0],b=h.height,w=h.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=v(o,L),j=function(t){var n=t||u(),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||u();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}(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 s=t!==w||n!==b;if(f.fitCanvasToArtboardHeight&&s&&(o.current.style.height=n+"px",a=!0),f.useDevicePixelRatio){if(s||(t*j!==C||n*j!==R)){var u=j*t,l=j*n;r.width=u,r.height=l,r.style.width=t+"px",r.style.height=n+"px",E({width:u,height:l}),a=!0}}else s&&(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,b,w,c,L,P,S,i]),e.useEffect(function(){E({width:0,height:0})},[r])}var w,y=function(){function e(){}return e.prototype.observe=function(){},e.prototype.unobserve=function(){},e.prototype.disconnect=function(){},e}(),g=globalThis.IntersectionObserver||y,m=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 g(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}(),R=function(){return w||(w=new m),w};function C(e){var t=e.setContainerRef,n=e.setCanvasRef,a=e.className,s=void 0===a?"":a,u=e.style,c=e.children,l=o(e,["setContainerRef","setCanvasRef","className","style","children"]),f=r({width:"100%",height:"100%"},u);return i.default.createElement("div",r({ref:t,className:s},!s&&{style:f}),i.default.createElement("canvas",r({ref:n,style:{verticalAlign:"top",width:0,height:0}},l),c))}function E(n,o){void 0===o&&(o={});var a=e.useState(null),s=a[0],u=a[1],c=e.useRef(null),l=e.useState(null),f=l[0],d=l[1],v=Boolean(n),h=p(o),w=e.useCallback(function(){f&&(f.startRendering(),f.resizeToCanvas())},[f]);b({riveLoaded:!!f,canvasElem:s,containerRef:c,options:h,onCanvasHasResized:w,artboardBounds:null==f?void 0:f.bounds});var y=e.useCallback(function(e){null===e&&s&&(s.height=0,s.width=0),u(e)},[]);e.useEffect(function(){if(s&&n&&null==f){var e=h.useOffscreenRenderer,i=new t.Rive(r(r({useOffscreenRenderer:e},n),{canvas:s}));i.on(t.EventType.Load,function(){s?d(i):i.cleanup()})}},[s,v,f]);var g=e.useCallback(function(e){c.current=e},[]),m={observe:e.useCallback(function(e,t){R().registerCallback(e,t)},[]),unobserve:e.useCallback(function(e){R().removeCallback(e)},[])},E=m.observe,O=m.unobserve;e.useEffect(function(){var e,t=!1,n=function(){if(s&&t){var e=s.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==f||f.startRendering(),t=!1)}};return s&&!1!==h.shouldUseIntersectionObserver&&E(s,function(i){i.isIntersecting?f&&f.startRendering():f&&f.stopRendering(),t=!i.isIntersecting,clearTimeout(e),i.isIntersecting||0!==i.boundingClientRect.width||(e=setTimeout(n,10))}),function(){s&&O(s)}},[E,O,f,s,h.shouldUseIntersectionObserver]),e.useEffect(function(){return function(){f&&(f.cleanup(),d(null))}},[f,s]);var x=null==n?void 0:n.animations;e.useEffect(function(){f&&x&&(f.isPlaying?(f.stop(f.animationNames),f.play(x)):f.isPaused&&(f.stop(f.animationNames),f.pause(x)))},[x,f]);var T=e.useCallback(function(e){return i.default.createElement(C,r({setContainerRef:g,setCanvasRef:y},e))},[y,g]);return{canvas:s,container:c.current,setCanvasRef:y,setContainerRef:g,rive:f,RiveComponent:T}}exports.default=function(e){var t=e.src,n=e.artboard,a=e.animations,s=e.stateMachines,u=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=E({src:t,artboard:n,animations:a,layout:u,stateMachines:s,autoplay:!0,shouldDisableRiveListeners:d,automaticallyHandleEvents:b},{useOffscreenRenderer:l,shouldResizeCanvasToContainer:h}).RiveComponent;return i.default.createElement(g,r({},y),w)},exports.useResizeCanvas=b,exports.useRive=E,exports.useRiveFile=function(n){var i=this,r=e.useState(null),o=r[0],u=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 s(this,function(i){try{f("loading"),(e=new t.RiveFile(n)).init(),e.on(t.EventType.Load,function(){null==e||e.getInstance(),u(e),f("success")}),e.on(t.EventType.LoadError,function(){f("failed")}),u(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),s=a[0],u=a[1];return e.useEffect(function(){function e(){if(n&&i&&r||u(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),u(t||null)}}else u(null)}e(),n&&n.on(t.EventType.Load,function(){e()})},[n]),s},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-lite");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]}})});
{
"name": "@rive-app/react-canvas-lite",
"version": "4.15.0",
"version": "4.15.1",
"description": "React wrapper around the @rive-app/canvas-lite library",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc