New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

rive-react

Package Overview
Dependencies
Maintainers
4
Versions
209
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rive-react - npm Package Compare versions

Comparing version 1.0.4 to 1.0.5

2

dist/index.js

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

Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("@rive-app/webgl");function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var r=n(e),i=function(){return i=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},i.apply(this,arguments)};function a(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]])}return n}function u(e){var t=e.setContainerRef,n=e.setCanvasRef,u=a(e,["setContainerRef","setCanvasRef"]);return r.default.createElement("div",i({ref:t,style:"className"in u?void 0:{width:"100%",height:"100%"}},u),r.default.createElement("canvas",{ref:n,style:{verticalAlign:"top"}}))}var o={useDevicePixelRatio:!0,fitCanvasToArtboardHeight:!1,useOffscreenRenderer:!0};function s(n,a){void 0===a&&(a={});var s=e.useRef(null),c=e.useRef(null),f=e.useState(null),l=f[0],d=f[1],v=e.useState({height:0,width:0}),h=v[0],p=v[1],w=function(){var t=e.useState({width:0,height:0}),n=t[0],r=t[1];return e.useEffect(function(){if("undefined"!=typeof window){var e=function(){r({width:window.innerWidth,height:window.innerHeight})};return window.addEventListener("resize",e),e(),function(){return window.removeEventListener("resize",e)}}},[]),n}(),g=Boolean(n),y=function(e){return Object.assign({},o,e)}(a);function b(){if(c.current){var e=function(){var e,t,n=null!==(t=null===(e=c.current)||void 0===e?void 0:e.getBoundingClientRect())&&void 0!==t?t:new DOMRect(0,0,0,0),r=n.width,i=n.height;if(l&&y.fitCanvasToArtboardHeight){var a=l.bounds;return{width:r,height:r*(a.maxY/a.maxX)}}return{width:r,height:i}}(),t=e.width,n=e.height,r=t!==h.width||n!==h.height;if(s.current&&l&&r){if(y.fitCanvasToArtboardHeight&&(c.current.style.height=n+"px"),y.useDevicePixelRatio){var i=window.devicePixelRatio||1;s.current.width=i*t,s.current.height=i*n,s.current.style.width=t+"px",s.current.style.height=n+"px"}else s.current.width=t,s.current.height=n;p({width:t,height:n}),l.startRendering()}l&&l.resizeToCanvas()}}e.useEffect(function(){l&&b()},[l,w]);var R=e.useCallback(function(e){if(e&&n){var r=y.useOffscreenRenderer,a=new t.Rive(i(i({useOffscreenRenderer:r},n),{canvas:e}));a.on(t.EventType.Load,function(){return d(a)})}else null===e&&s.current&&(s.current.height=0,s.current.width=0);s.current=e},[g]),O=e.useCallback(function(e){c.current=e},[]);e.useEffect(function(){var e=new IntersectionObserver(function(e){e[0].isIntersecting?l&&l.startRendering():l&&l.stopRendering()});return s.current&&e.observe(s.current),function(){e.disconnect()}},[l]),e.useEffect(function(){return function(){l&&(l.stop(),d(null))}},[l]);var m=null==n?void 0:n.animations;e.useEffect(function(){l&&m&&(l.stop(l.animationNames),l.play(m))},[m,l]);var C=e.useCallback(function(e){return r.default.createElement(u,i({setContainerRef:O,setCanvasRef:R},e))},[]);return{canvas:s.current,setCanvasRef:R,setContainerRef:O,rive:l,RiveComponent:C}}exports.default=function(e){var t=e.src,n=e.artboard,u=e.animations,o=e.layout,c=e.useOffscreenRenderer,f=void 0===c||c,l=a(e,["src","artboard","animations","layout","useOffscreenRenderer"]),d=s({src:t,artboard:n,animations:u,layout:o,autoplay:!0},{useOffscreenRenderer:f}).RiveComponent;return r.default.createElement(d,i({},l))},exports.useRive=s,exports.useStateMachineInput=function(t,n,r){var i=e.useState(null),a=i[0],u=i[1];return e.useEffect(function(){if(t&&n&&r||u(null),t&&n&&r){var e=t.stateMachineInputs(n);if(e){var i=e.find(function(e){return e.name===r});u(i||null)}}else u(null)},[t]),a},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/webgl");function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var r=n(e),i=function(){return i=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},i.apply(this,arguments)};function a(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]])}return n}function u(e){var t=e.setContainerRef,n=e.setCanvasRef,u=a(e,["setContainerRef","setCanvasRef"]);return r.default.createElement("div",i({ref:t,style:"className"in u?void 0:{width:"100%",height:"100%"}},u),r.default.createElement("canvas",{ref:n,style:{verticalAlign:"top"}}))}var o={useDevicePixelRatio:!0,fitCanvasToArtboardHeight:!1,useOffscreenRenderer:!0};function s(n,a){void 0===a&&(a={});var s=e.useRef(null),c=e.useRef(null),f=e.useState(null),l=f[0],d=f[1],v=e.useState({height:0,width:0}),h=v[0],p=v[1],w=function(){var t=e.useState({width:0,height:0}),n=t[0],r=t[1];return e.useEffect(function(){if("undefined"!=typeof window){var e=function(){r({width:window.innerWidth,height:window.innerHeight})};return window.addEventListener("resize",e),e(),function(){return window.removeEventListener("resize",e)}}},[]),n}(),g=Boolean(n),y=function(e){return Object.assign({},o,e)}(a);function b(){if(c.current){var e=function(){var e,t,n=null!==(t=null===(e=c.current)||void 0===e?void 0:e.getBoundingClientRect())&&void 0!==t?t:new DOMRect(0,0,0,0),r=n.width,i=n.height;if(l&&y.fitCanvasToArtboardHeight){var a=l.bounds;return{width:r,height:r*(a.maxY/a.maxX)}}return{width:r,height:i}}(),t=e.width,n=e.height,r=t!==h.width||n!==h.height;if(s.current&&l&&r){if(y.fitCanvasToArtboardHeight&&(c.current.style.height=n+"px"),y.useDevicePixelRatio){var i=window.devicePixelRatio||1;s.current.width=i*t,s.current.height=i*n,s.current.style.width=t+"px",s.current.style.height=n+"px"}else s.current.width=t,s.current.height=n;p({width:t,height:n}),l.startRendering()}l&&l.resizeToCanvas()}}e.useEffect(function(){l&&b()},[l,w]);var R=e.useCallback(function(e){if(e&&n){var r=y.useOffscreenRenderer,a=new t.Rive(i(i({useOffscreenRenderer:r},n),{canvas:e}));a.on(t.EventType.Load,function(){return d(a)})}else null===e&&s.current&&(s.current.height=0,s.current.width=0);s.current=e},[g]),O=e.useCallback(function(e){c.current=e},[]);e.useEffect(function(){var e=new IntersectionObserver(function(e){e[0].isIntersecting?l&&l.startRendering():l&&l.stopRendering()});return s.current&&e.observe(s.current),function(){e.disconnect()}},[l]),e.useEffect(function(){return function(){l&&(l.stop(),d(null))}},[l]);var m=null==n?void 0:n.animations;e.useEffect(function(){l&&m&&(l.stop(l.animationNames),l.play(m))},[m,l]);var C=e.useCallback(function(e){return r.default.createElement(u,i({setContainerRef:O,setCanvasRef:R},e))},[]);return{canvas:s.current,setCanvasRef:R,setContainerRef:O,rive:l,RiveComponent:C}}exports.default=function(e){var t=e.src,n=e.artboard,u=e.animations,o=e.layout,c=e.useOffscreenRenderer,f=void 0===c||c,l=a(e,["src","artboard","animations","layout","useOffscreenRenderer"]),d=s({src:t,artboard:n,animations:u,layout:o,autoplay:!0},{useOffscreenRenderer:f}).RiveComponent;return r.default.createElement(d,i({},l))},exports.useRive=s,exports.useStateMachineInput=function(t,n,r,i){var a=e.useState(null),u=a[0],o=a[1];return e.useEffect(function(){if(t&&n&&r||o(null),t&&n&&r){var e=t.stateMachineInputs(n);if(e){var a=e.find(function(e){return e.name===r});void 0!==i&&a&&(a.value=i),o(a||null)}}else o(null)},[t]),u},Object.keys(t).forEach(function(e){"default"===e||exports.hasOwnProperty(e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return t[e]}})});

@@ -10,2 +10,2 @@ import { Rive, StateMachineInput } from '@rive-app/webgl';

*/
export default function useStateMachineInput(rive: Rive | null, stateMachineName?: string, inputName?: string): StateMachineInput | null;
export default function useStateMachineInput(rive: Rive | null, stateMachineName?: string, inputName?: string, initialValue?: number | boolean): StateMachineInput | null;
{
"name": "rive-react",
"version": "1.0.4",
"version": "1.0.5",
"description": "React wrapper around the rive-js library",

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

@@ -172,2 +172,3 @@ ![Build Status](https://github.com/rive-app/rive-react/actions/workflows/tests.yml/badge.svg)

- `inputName`: Name of the state machine input.
- `initialValue`: Initial value to set on a state machine input when it's loaded in, for number or boolean inputs. **Note** that this may trigger any transitional animations between the initial state and any next states that depend on the input this `initialValue` is being set to. If this is problematic or conflicting for your case, we recommend setting the true initial value of the input on your state machine in the Rive editor.

@@ -174,0 +175,0 @@ #### Return Value

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