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

use-sound

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

use-sound - npm Package Compare versions

Comparing version 4.0.4 to 5.0.0

5

dist/use-sound.cjs.development.js

@@ -130,3 +130,6 @@ 'use strict';

sound.volume(volume);
sound.rate(playbackRate);
// HACK: When a sprite is defined, `sound.rate()` throws an error, because Howler tries to reset the "_default" sprite, which doesn't exist. This is likely a bug within Howler, but I don’t have the bandwidth to investigate, so instead, we’re ignoring playbackRate changes when a sprite is defined.
if (!delegated.sprite) {
sound.rate(playbackRate);
}
}

@@ -133,0 +136,0 @@ }, [sound, volume, playbackRate]);

2

dist/use-sound.cjs.production.min.js

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

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,n=require("react"),r=(e=n)&&"object"==typeof e&&"default"in e?e.default:e;function t(){return(t=Object.assign?Object.assign.bind():function(e){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var t in r)({}).hasOwnProperty.call(r,t)&&(e[t]=r[t])}return e}).apply(null,arguments)}var u=["id","volume","playbackRate","soundEnabled","interrupt","onload"];function o(e,o){var a=void 0===o?{}:o,i=a.volume,l=void 0===i?1:i,c=a.playbackRate,f=void 0===c?1:c,s=a.soundEnabled,d=void 0===s||s,p=a.interrupt,v=void 0!==p&&p,b=a.onload,y=function(e,n){if(null==e)return{};var r={};for(var t in e)if({}.hasOwnProperty.call(e,t)){if(-1!==n.indexOf(t))continue;r[t]=e[t]}return r}(a,u),O=r.useRef(null),h=r.useRef(!1),w=r.useState(null),k=w[0],g=w[1],j=r.useState(null),m=j[0],E=j[1],P=function(){"function"==typeof b&&b.call(this),h.current&&g(1e3*this.duration()),E(this)};n.useEffect((function(){return new Promise((function(e){e(function(e){if(e&&e.__esModule)return e;var n={};return e&&Object.keys(e).forEach((function(r){var t=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(n,r,t.get?t:{enumerable:!0,get:function(){return e[r]}})})),n.default=e,n}(require("howler")))})).then((function(n){var r;h.current||(O.current=null!==(r=n.Howl)&&void 0!==r?r:n.default.Howl,h.current=!0,new O.current(t({src:Array.isArray(e)?e:[e],volume:l,rate:f,onload:P},y)))})),function(){h.current=!1}}),[]),r.useEffect((function(){O.current&&m&&E(new O.current(t({src:Array.isArray(e)?e:[e],volume:l,onload:P},y)))}),[JSON.stringify(e)]),r.useEffect((function(){m&&(m.volume(l),m.rate(f))}),[m,l,f]);var R=r.useCallback((function(e){void 0===e&&(e={}),m&&(d||e.forceSoundEnabled)&&(v&&m.stop(),e.playbackRate&&m.rate(e.playbackRate),m.play(e.id))}),[m,d,v]),S=r.useCallback((function(e){m&&m.stop(e)}),[m]),x=r.useCallback((function(e){m&&m.pause(e)}),[m]);return[R,{sound:m,stop:S,pause:x,duration:k}]}exports.default=o,exports.useSound=o;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,n=require("react"),r=(e=n)&&"object"==typeof e&&"default"in e?e.default:e;function t(){return(t=Object.assign?Object.assign.bind():function(e){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var t in r)({}).hasOwnProperty.call(r,t)&&(e[t]=r[t])}return e}).apply(null,arguments)}var u=["id","volume","playbackRate","soundEnabled","interrupt","onload"];function o(e,o){var a=void 0===o?{}:o,i=a.volume,l=void 0===i?1:i,c=a.playbackRate,f=void 0===c?1:c,s=a.soundEnabled,d=void 0===s||s,p=a.interrupt,v=void 0!==p&&p,b=a.onload,y=function(e,n){if(null==e)return{};var r={};for(var t in e)if({}.hasOwnProperty.call(e,t)){if(-1!==n.indexOf(t))continue;r[t]=e[t]}return r}(a,u),O=r.useRef(null),h=r.useRef(!1),w=r.useState(null),k=w[0],g=w[1],j=r.useState(null),m=j[0],E=j[1],P=function(){"function"==typeof b&&b.call(this),h.current&&g(1e3*this.duration()),E(this)};n.useEffect((function(){return new Promise((function(e){e(function(e){if(e&&e.__esModule)return e;var n={};return e&&Object.keys(e).forEach((function(r){var t=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(n,r,t.get?t:{enumerable:!0,get:function(){return e[r]}})})),n.default=e,n}(require("howler")))})).then((function(n){var r;h.current||(O.current=null!==(r=n.Howl)&&void 0!==r?r:n.default.Howl,h.current=!0,new O.current(t({src:Array.isArray(e)?e:[e],volume:l,rate:f,onload:P},y)))})),function(){h.current=!1}}),[]),r.useEffect((function(){O.current&&m&&E(new O.current(t({src:Array.isArray(e)?e:[e],volume:l,onload:P},y)))}),[JSON.stringify(e)]),r.useEffect((function(){m&&(m.volume(l),y.sprite||m.rate(f))}),[m,l,f]);var R=r.useCallback((function(e){void 0===e&&(e={}),m&&(d||e.forceSoundEnabled)&&(v&&m.stop(),e.playbackRate&&m.rate(e.playbackRate),m.play(e.id))}),[m,d,v]),S=r.useCallback((function(e){m&&m.stop(e)}),[m]),x=r.useCallback((function(e){m&&m.pause(e)}),[m]);return[R,{sound:m,stop:S,pause:x,duration:k}]}exports.default=o,exports.useSound=o;
//# sourceMappingURL=use-sound.cjs.production.min.js.map

@@ -104,3 +104,6 @@ import React__default, { useEffect } from 'react';

sound.volume(volume);
sound.rate(playbackRate);
// HACK: When a sprite is defined, `sound.rate()` throws an error, because Howler tries to reset the "_default" sprite, which doesn't exist. This is likely a bug within Howler, but I don’t have the bandwidth to investigate, so instead, we’re ignoring playbackRate changes when a sprite is defined.
if (!delegated.sprite) {
sound.rate(playbackRate);
}
}

@@ -107,0 +110,0 @@ }, [sound, volume, playbackRate]);

{
"name": "use-sound",
"author": "Josh Comeau",
"version": "4.0.4",
"version": "5.0.0",
"module": "dist/use-sound.esm.js",

@@ -6,0 +6,0 @@ "exports": {

@@ -131,2 +131,4 @@ # useSound

> NOTE: This example won’t work if you’re using sprites (defined below). The `playbackRate` option is only reactive when using a single sound.
---

@@ -228,2 +230,4 @@

> NOTE: If a `sprite` is passed, `playbackRate` will not be reactive. This means that only the _initial_ value for `playbackRate` will be used.
### The `play` function

@@ -320,2 +324,4 @@

> NOTE: When using sprites, the `playbackRate` parameter will not be reactive. This means that only the _initial_ value for `playbackRate` will be used.
### Escape hatches

@@ -322,0 +328,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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