wavesurfer.js
Advanced tools
Comparing version 7.5.0 to 7.5.1
@@ -9,3 +9,3 @@ /** | ||
insertPosition?: InsertPosition; | ||
} & WaveSurferOptions; | ||
} & Partial<WaveSurferOptions>; | ||
declare const defaultOptions: { | ||
@@ -12,0 +12,0 @@ height: number; |
@@ -9,3 +9,3 @@ /** | ||
insertPosition?: InsertPosition; | ||
} & WaveSurferOptions; | ||
} & Partial<WaveSurferOptions>; | ||
declare const defaultOptions: { | ||
@@ -12,0 +12,0 @@ height: number; |
@@ -22,2 +22,3 @@ /** | ||
scale?: number; | ||
maxZoom?: number; | ||
}; | ||
@@ -36,4 +37,5 @@ declare const defaultOptions: { | ||
private onWheel; | ||
private calculateNewZoom; | ||
destroy(): void; | ||
} | ||
export default ZoomPlugin; |
@@ -22,2 +22,3 @@ /** | ||
scale?: number; | ||
maxZoom?: number; | ||
}; | ||
@@ -36,4 +37,5 @@ declare const defaultOptions: { | ||
private onWheel; | ||
private calculateNewZoom; | ||
destroy(): void; | ||
} | ||
export default ZoomPlugin; |
@@ -1,1 +0,1 @@ | ||
class e{constructor(){this.listeners={},this.on=this.addEventListener,this.un=this.removeEventListener}addEventListener(e,t,s){if(this.listeners[e]||(this.listeners[e]=new Set),this.listeners[e].add(t),null==s?void 0:s.once){const s=()=>{this.removeEventListener(e,s),this.removeEventListener(e,t)};return this.addEventListener(e,s),s}return()=>this.removeEventListener(e,t)}removeEventListener(e,t){var s;null===(s=this.listeners[e])||void 0===s||s.delete(t)}once(e,t){return this.on(e,t,{once:!0})}unAll(){this.listeners={}}emit(e,...t){this.listeners[e]&&this.listeners[e].forEach((e=>e(...t)))}}class t extends e{constructor(e){super(),this.subscriptions=[],this.options=e}onInit(){}init(e){this.wavesurfer=e,this.onInit()}destroy(){this.emit("destroy"),this.subscriptions.forEach((e=>e()))}}const s={scale:.2};class i extends t{constructor(e){super(e||{}),this.wrapper=void 0,this.container=null,this.onWheel=e=>{var t;if(!(null===(t=this.wavesurfer)||void 0===t?void 0:t.options.minPxPerSec)||!this.container)return;e.preventDefault();const s=this.wavesurfer.getDuration(),i=this.wavesurfer.options.minPxPerSec,r=e.clientX,n=this.container.clientWidth,o=(this.wavesurfer.getScroll()+r)/i,h=i*(e.deltaY>0?1-this.options.scale:1+this.options.scale),a=n/h*(r/n);h*s<n?(this.wavesurfer.zoom(n/s),this.container.scrollLeft=0):(this.wavesurfer.zoom(h),this.container.scrollLeft=(o-a)*h)},this.options=Object.assign({},s,e)}static create(e){return new i(e)}onInit(){var e;this.wrapper=null===(e=this.wavesurfer)||void 0===e?void 0:e.getWrapper(),this.wrapper&&(this.container=this.wrapper.parentElement,this.wrapper.addEventListener("wheel",this.onWheel))}destroy(){this.wrapper&&this.wrapper.removeEventListener("wheel",this.onWheel),super.destroy()}}export{i as default}; | ||
class e{constructor(){this.listeners={},this.on=this.addEventListener,this.un=this.removeEventListener}addEventListener(e,t,s){if(this.listeners[e]||(this.listeners[e]=new Set),this.listeners[e].add(t),null==s?void 0:s.once){const s=()=>{this.removeEventListener(e,s),this.removeEventListener(e,t)};return this.addEventListener(e,s),s}return()=>this.removeEventListener(e,t)}removeEventListener(e,t){var s;null===(s=this.listeners[e])||void 0===s||s.delete(t)}once(e,t){return this.on(e,t,{once:!0})}unAll(){this.listeners={}}emit(e,...t){this.listeners[e]&&this.listeners[e].forEach((e=>e(...t)))}}class t extends e{constructor(e){super(),this.subscriptions=[],this.options=e}onInit(){}init(e){this.wavesurfer=e,this.onInit()}destroy(){this.emit("destroy"),this.subscriptions.forEach((e=>e()))}}const s={scale:.5};class i extends t{constructor(e){super(e||{}),this.wrapper=void 0,this.container=null,this.onWheel=e=>{if(!this.wavesurfer||!this.container||Math.abs(e.deltaX)>=Math.abs(e.deltaY))return;e.preventDefault();const t=this.wavesurfer.getDuration(),s=this.wavesurfer.options.minPxPerSec,i=e.clientX,r=this.container.clientWidth,n=(this.wavesurfer.getScroll()+i)/s,o=this.calculateNewZoom(s,-e.deltaY),h=r/o*(i/r);o*t<r?(this.wavesurfer.zoom(r/t),this.container.scrollLeft=0):(this.wavesurfer.zoom(o),this.container.scrollLeft=(n-h)*o)},this.calculateNewZoom=(e,t)=>{const s=Math.max(0,e+t*this.options.scale);return void 0===this.options.maxZoom?s:Math.min(s,this.options.maxZoom)},this.options=Object.assign({},s,e)}static create(e){return new i(e)}onInit(){var e;this.wrapper=null===(e=this.wavesurfer)||void 0===e?void 0:e.getWrapper(),this.wrapper&&(this.container=this.wrapper.parentElement,this.wrapper.addEventListener("wheel",this.onWheel))}destroy(){this.wrapper&&this.wrapper.removeEventListener("wheel",this.onWheel),super.destroy()}}export{i as default}; |
@@ -1,1 +0,1 @@ | ||
class e{constructor(){this.listeners={},this.on=this.addEventListener,this.un=this.removeEventListener}addEventListener(e,t,s){if(this.listeners[e]||(this.listeners[e]=new Set),this.listeners[e].add(t),null==s?void 0:s.once){const s=()=>{this.removeEventListener(e,s),this.removeEventListener(e,t)};return this.addEventListener(e,s),s}return()=>this.removeEventListener(e,t)}removeEventListener(e,t){var s;null===(s=this.listeners[e])||void 0===s||s.delete(t)}once(e,t){return this.on(e,t,{once:!0})}unAll(){this.listeners={}}emit(e,...t){this.listeners[e]&&this.listeners[e].forEach((e=>e(...t)))}}class t extends e{constructor(e){super(),this.subscriptions=[],this.options=e}onInit(){}init(e){this.wavesurfer=e,this.onInit()}destroy(){this.emit("destroy"),this.subscriptions.forEach((e=>e()))}}const s={scale:.2};class i extends t{constructor(e){super(e||{}),this.wrapper=void 0,this.container=null,this.onWheel=e=>{var t;if(!(null===(t=this.wavesurfer)||void 0===t?void 0:t.options.minPxPerSec)||!this.container)return;e.preventDefault();const s=this.wavesurfer.getDuration(),i=this.wavesurfer.options.minPxPerSec,r=e.clientX,n=this.container.clientWidth,o=(this.wavesurfer.getScroll()+r)/i,h=i*(e.deltaY>0?1-this.options.scale:1+this.options.scale),a=n/h*(r/n);h*s<n?(this.wavesurfer.zoom(n/s),this.container.scrollLeft=0):(this.wavesurfer.zoom(h),this.container.scrollLeft=(o-a)*h)},this.options=Object.assign({},s,e)}static create(e){return new i(e)}onInit(){var e;this.wrapper=null===(e=this.wavesurfer)||void 0===e?void 0:e.getWrapper(),this.wrapper&&(this.container=this.wrapper.parentElement,this.wrapper.addEventListener("wheel",this.onWheel))}destroy(){this.wrapper&&this.wrapper.removeEventListener("wheel",this.onWheel),super.destroy()}}export{i as default}; | ||
class e{constructor(){this.listeners={},this.on=this.addEventListener,this.un=this.removeEventListener}addEventListener(e,t,s){if(this.listeners[e]||(this.listeners[e]=new Set),this.listeners[e].add(t),null==s?void 0:s.once){const s=()=>{this.removeEventListener(e,s),this.removeEventListener(e,t)};return this.addEventListener(e,s),s}return()=>this.removeEventListener(e,t)}removeEventListener(e,t){var s;null===(s=this.listeners[e])||void 0===s||s.delete(t)}once(e,t){return this.on(e,t,{once:!0})}unAll(){this.listeners={}}emit(e,...t){this.listeners[e]&&this.listeners[e].forEach((e=>e(...t)))}}class t extends e{constructor(e){super(),this.subscriptions=[],this.options=e}onInit(){}init(e){this.wavesurfer=e,this.onInit()}destroy(){this.emit("destroy"),this.subscriptions.forEach((e=>e()))}}const s={scale:.5};class i extends t{constructor(e){super(e||{}),this.wrapper=void 0,this.container=null,this.onWheel=e=>{if(!this.wavesurfer||!this.container||Math.abs(e.deltaX)>=Math.abs(e.deltaY))return;e.preventDefault();const t=this.wavesurfer.getDuration(),s=this.wavesurfer.options.minPxPerSec,i=e.clientX,r=this.container.clientWidth,n=(this.wavesurfer.getScroll()+i)/s,o=this.calculateNewZoom(s,-e.deltaY),h=r/o*(i/r);o*t<r?(this.wavesurfer.zoom(r/t),this.container.scrollLeft=0):(this.wavesurfer.zoom(o),this.container.scrollLeft=(n-h)*o)},this.calculateNewZoom=(e,t)=>{const s=Math.max(0,e+t*this.options.scale);return void 0===this.options.maxZoom?s:Math.min(s,this.options.maxZoom)},this.options=Object.assign({},s,e)}static create(e){return new i(e)}onInit(){var e;this.wrapper=null===(e=this.wavesurfer)||void 0===e?void 0:e.getWrapper(),this.wrapper&&(this.container=this.wrapper.parentElement,this.wrapper.addEventListener("wheel",this.onWheel))}destroy(){this.wrapper&&this.wrapper.removeEventListener("wheel",this.onWheel),super.destroy()}}export{i as default}; |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):((e="undefined"!=typeof globalThis?globalThis:e||self).WaveSurfer=e.WaveSurfer||{},e.WaveSurfer.Zoom=t())}(this,(function(){"use strict";class e{constructor(){this.listeners={},this.on=this.addEventListener,this.un=this.removeEventListener}addEventListener(e,t,s){if(this.listeners[e]||(this.listeners[e]=new Set),this.listeners[e].add(t),null==s?void 0:s.once){const s=()=>{this.removeEventListener(e,s),this.removeEventListener(e,t)};return this.addEventListener(e,s),s}return()=>this.removeEventListener(e,t)}removeEventListener(e,t){var s;null===(s=this.listeners[e])||void 0===s||s.delete(t)}once(e,t){return this.on(e,t,{once:!0})}unAll(){this.listeners={}}emit(e,...t){this.listeners[e]&&this.listeners[e].forEach((e=>e(...t)))}}class t extends e{constructor(e){super(),this.subscriptions=[],this.options=e}onInit(){}init(e){this.wavesurfer=e,this.onInit()}destroy(){this.emit("destroy"),this.subscriptions.forEach((e=>e()))}}const s={scale:.2};class i extends t{constructor(e){super(e||{}),this.wrapper=void 0,this.container=null,this.onWheel=e=>{var t;if(!(null===(t=this.wavesurfer)||void 0===t?void 0:t.options.minPxPerSec)||!this.container)return;e.preventDefault();const s=this.wavesurfer.getDuration(),i=this.wavesurfer.options.minPxPerSec,r=e.clientX,n=this.container.clientWidth,o=(this.wavesurfer.getScroll()+r)/i,h=i*(e.deltaY>0?1-this.options.scale:1+this.options.scale),a=n/h*(r/n);h*s<n?(this.wavesurfer.zoom(n/s),this.container.scrollLeft=0):(this.wavesurfer.zoom(h),this.container.scrollLeft=(o-a)*h)},this.options=Object.assign({},s,e)}static create(e){return new i(e)}onInit(){var e;this.wrapper=null===(e=this.wavesurfer)||void 0===e?void 0:e.getWrapper(),this.wrapper&&(this.container=this.wrapper.parentElement,this.wrapper.addEventListener("wheel",this.onWheel))}destroy(){this.wrapper&&this.wrapper.removeEventListener("wheel",this.onWheel),super.destroy()}}return i})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):((e="undefined"!=typeof globalThis?globalThis:e||self).WaveSurfer=e.WaveSurfer||{},e.WaveSurfer.Zoom=t())}(this,(function(){"use strict";class e{constructor(){this.listeners={},this.on=this.addEventListener,this.un=this.removeEventListener}addEventListener(e,t,s){if(this.listeners[e]||(this.listeners[e]=new Set),this.listeners[e].add(t),null==s?void 0:s.once){const s=()=>{this.removeEventListener(e,s),this.removeEventListener(e,t)};return this.addEventListener(e,s),s}return()=>this.removeEventListener(e,t)}removeEventListener(e,t){var s;null===(s=this.listeners[e])||void 0===s||s.delete(t)}once(e,t){return this.on(e,t,{once:!0})}unAll(){this.listeners={}}emit(e,...t){this.listeners[e]&&this.listeners[e].forEach((e=>e(...t)))}}class t extends e{constructor(e){super(),this.subscriptions=[],this.options=e}onInit(){}init(e){this.wavesurfer=e,this.onInit()}destroy(){this.emit("destroy"),this.subscriptions.forEach((e=>e()))}}const s={scale:.5};class i extends t{constructor(e){super(e||{}),this.wrapper=void 0,this.container=null,this.onWheel=e=>{if(!this.wavesurfer||!this.container||Math.abs(e.deltaX)>=Math.abs(e.deltaY))return;e.preventDefault();const t=this.wavesurfer.getDuration(),s=this.wavesurfer.options.minPxPerSec,i=e.clientX,r=this.container.clientWidth,n=(this.wavesurfer.getScroll()+i)/s,o=this.calculateNewZoom(s,-e.deltaY),h=r/o*(i/r);o*t<r?(this.wavesurfer.zoom(r/t),this.container.scrollLeft=0):(this.wavesurfer.zoom(o),this.container.scrollLeft=(n-h)*o)},this.calculateNewZoom=(e,t)=>{const s=Math.max(0,e+t*this.options.scale);return void 0===this.options.maxZoom?s:Math.min(s,this.options.maxZoom)},this.options=Object.assign({},s,e)}static create(e){return new i(e)}onInit(){var e;this.wrapper=null===(e=this.wavesurfer)||void 0===e?void 0:e.getWrapper(),this.wrapper&&(this.container=this.wrapper.parentElement,this.wrapper.addEventListener("wheel",this.onWheel))}destroy(){this.wrapper&&this.wrapper.removeEventListener("wheel",this.onWheel),super.destroy()}}return i})); |
{ | ||
"name": "wavesurfer.js", | ||
"version": "7.5.0", | ||
"version": "7.5.1", | ||
"license": "BSD-3-Clause", | ||
@@ -5,0 +5,0 @@ "author": "katspaugh", |
@@ -5,10 +5,4 @@ # <img src="https://user-images.githubusercontent.com/381895/226091100-f5567a28-7736-4d37-8f84-e08f297b7e1a.png" alt="logo" height="60" valign="middle" /> wavesurfer.js | ||
## New TypeScript version | ||
**Wavesurfer.js** is an interactive waveform rendering and audio playback library, perfect for web applications. It leverages modern web technologies to provide a robust and visually engaging audio experience. | ||
wavesurfer.js v7 is a TypeScript rewrite of wavesurfer.js that brings several improvements: | ||
* Typed API for better development experience | ||
* Enhanced decoding and rendering performance | ||
* New and improved plugins | ||
<img width="626" alt="waveform screenshot" src="https://github.com/katspaugh/wavesurfer.js/assets/381895/05f03bed-800e-4fa1-b09a-82a39a1c62ce"> | ||
@@ -66,3 +60,3 @@ | ||
The "official" plugins have been completely rewritten and enhanced: | ||
We maintain a number of official plugins that add various extra features: | ||
@@ -95,4 +89,14 @@ * [Regions](https://wavesurfer.xyz/examples/?regions.js) – visual overlays and markers for regions of audio | ||
## Upgrading from v6 | ||
## v7 – a new TypeScript version | ||
Wavesurfer.js v7 is a TypeScript rewrite of wavesurfer.js that brings several improvements: | ||
* Typed API for better development experience | ||
* Enhanced decoding and rendering performance | ||
* New and improved plugins | ||
<img width="749" alt="Screenshot 2023-12-06 at 09 06 30" src="https://github.com/katspaugh/wavesurfer.js/assets/381895/21eca2d9-47c7-461f-82bb-f23993818458"> | ||
### Upgrading from v6 | ||
Most options, events, and methods are similar to those in previous versions. | ||
@@ -99,0 +103,0 @@ |
Sorry, the diff of this file is not supported yet
478364
4583
194