Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
wavesurfer-react
Advanced tools
A simple wrapper around an awesome library called wavesurfer.js.
The purpose of the package is to provide an abstraction over wavesurfer.js API and to do it as close to react style of doing things as its maintainer(-s) can provide.
LiveDemo:
[!IMPORTANT]
Since October 2023 I am occupied on a full-time job where it's not currently required to use any audio related modules.
I'll try to pay as much attention as possible for this repo, but not as much as previously because I need to prioritize things.
I'll keep this module to be as simple as possible and open to contributions.
Package provides the following set of components:
Core component of the package.
It creates wavesurfer instance and watches for changes in plugins list.
It accepts the following props set:
It is a list of plugins to use by WaveSurfer and has the following format:
import { WaveSurfer } from 'wavesurfer-react';
import RegionsPlugin from "wavesurfer.js/dist/plugins/regions";
import TimelinePlugin from "wavesurfer.js/dist/plugins/timeline";
import MyCustomPlugin from 'my-custom-plugin-path';
const plugins = [
{
plugin: RegionsPlugin,
key: "regions",
options: { dragSelection: true }
},
{
plugin: TimelinePlugin,
key: "timeline",
options: {
container: "#timeline"
}
},
{
plugin: MyCustomPlugin,
key: "my-custom-plugin",
options: {
someGreatOption: 'someGreatValue'
},
creator: 'myCustomCreate'
}
];
<WaveSurfer plugins={plugins} />
The plugins
prop is watched inside WaveSurfer.
If plugin was disabled (it's not enlisted in plugins
prop) it will be destroyed,
otherwise added to wavesurfer plugins list and immediately initialized.
To correctly track initialized plugins, key
property is used in item of plugins
array.
It is a function, that is called after WaveSurfer instance has been mounted.
It has only one argument - WaveSurfer instance.
You can pass here all options that is used to configure wavesurfer, i.e. full list of available options.
It is used as an alias for:
<div id="waveform"></div>
Think of it as a some kind of helper component.
It can be used to imperatively control regions, appearing on WaveForm if you're using RegionsPlugin.
If region is already present of WaveForm it creation will be avoided and existing instance is used.
On mount, it will try to find region with the same region identifier and then attaches itself to it.
If the Region component did not find an appropriate region, then it creates a region itself.
It accepts the following props:
Rest given props are passed as region's data into wavesurfer.
Special component using Region under the hood to display only markers.
Marker await all props of Region except end
prop.
Package provides the following set of hooks:
This hook is used inside WaveSurfer and its purpose is to create wavesurfer instance and return it.
It also handles a task of creating and destroying wavesurfer plugins, after plugins
prop update detection.
You can use it standalone to create you own (more specific) wavesurfer component that will handle more than a component that is provided out-of-the-box.
Is used inside the Region
component to subscribe to region-related events.
Can be used by developers, if they wanna to, inside a HOC-like component over Region
component
that is provided by the package or any other component, that is rendered inside WaveSurfer
component,
but for the latter task you will have to get region instance first.
Is used inside the Region
component to subscribe to region plugin related events.
Can be used by developers, if they wanna to, inside a HOC-like component over Region
component
that is provided by the package or any other component, that is rendered inside WaveSurfer
component,
but for the latter task you will have to get regions plugin instance first.
Returns a tuple of:
key
property passed alongside a plugin,Issues with regions synchronization when using redux and Region
component.
Try to not hard-bind redux-state with wavesurfer-react too tight or use an instance of wavesurfer to operate regions.
FIXED: Timeline is not visible after removing it from plugins array and adding again. I hope it is a temporal issue with the original package.
Comments related to this issue are:
Comment #1
Comment #2
Comment #3
INFO: use wavesurfer.js@^7.4.5
to have this issue fixed
Solution to this problem is to execute wavesurfer.setOptions({})
, right after Timeline plugin is added again via plugins
prop second time and further.
Thanks for your support and contributions!
Logo: Facebook, React-icon, place another image at the center of this image by shiirochi@yandex.ru, CC BY-SA 1.0
FAQs
react wrapper for wavesurfer.js
We found that wavesurfer-react demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.