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

wavesurfer.js

Package Overview
Dependencies
Maintainers
1
Versions
302
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wavesurfer.js - npm Package Compare versions

Comparing version 1.0.26 to 1.0.27

coverage/coverage.json

2

dist/plugin/wavesurfer.elan.min.js

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

/*! wavesurfer.js 1.0.26
/*! wavesurfer.js 1.0.27
* https://github.com/katspaugh/wavesurfer.js
* @license CC-BY 3.0 */"use strict";WaveSurfer.ELAN={Types:{ALIGNABLE_ANNOTATION:"ALIGNABLE_ANNOTATION",REF_ANNOTATION:"REF_ANNOTATION"},init:function(a){if(this.data=null,this.params=a,this.container="string"==typeof a.container?document.querySelector(a.container):a.container,!this.container)throw Error("No container for ELAN");this.bindClick(),a.url&&this.load(a.url)},load:function(a){var b=this;this.loadXML(a,function(a){b.data=b.parseElan(a),b.render(),b.fireEvent("ready",b.data)})},loadXML:function(a,b){var c=new XMLHttpRequest;c.open("GET",a,!0),c.responseType="document",c.send(),c.addEventListener("load",function(a){b&&b(a.target.responseXML)})},parseElan:function(a){var b=Array.prototype.forEach,c=Array.prototype.map,d={media:{},timeOrder:{},tiers:[],annotations:{},alignableAnnotations:[]},e=a.querySelector("HEADER"),f="milliseconds"==e.getAttribute("TIME_UNITS"),g=e.querySelector("MEDIA_DESCRIPTOR");d.media.url=g.getAttribute("MEDIA_URL"),d.media.type=g.getAttribute("MIME_TYPE");var h=a.querySelectorAll("TIME_ORDER TIME_SLOT"),i={};return b.call(h,function(a){var b=parseFloat(a.getAttribute("TIME_VALUE"));f&&(b=Math.round(100*b)/1e5),i[a.getAttribute("TIME_SLOT_ID")]=b}),d.tiers=c.call(a.querySelectorAll("TIER"),function(a){return{id:a.getAttribute("TIER_ID"),linguisticTypeRef:a.getAttribute("LINGUISTIC_TYPE_REF"),defaultLocale:a.getAttribute("DEFAULT_LOCALE"),annotations:c.call(a.querySelectorAll("REF_ANNOTATION, ALIGNABLE_ANNOTATION"),function(a){var b={type:a.nodeName,id:a.getAttribute("ANNOTATION_ID"),ref:a.getAttribute("ANNOTATION_REF"),value:a.querySelector("ANNOTATION_VALUE").textContent.trim()};return this.Types.ALIGNABLE_ANNOTATION==b.type&&(b.start=i[a.getAttribute("TIME_SLOT_REF1")],b.end=i[a.getAttribute("TIME_SLOT_REF2")],d.alignableAnnotations.push(b)),d.annotations[b.id]=b,b},this)}},this),d.tiers.forEach(function(a){a.annotations.forEach(function(a){null!=a.ref&&(a.reference=d.annotations[a.ref])},this)},this),d.alignableAnnotations.sort(function(a,b){var c=a.start-b.start;return 0==c&&(c=b.end-a.end),c}),d.length=d.alignableAnnotations.length,d},render:function(){var a=this.data.tiers;this.params.tiers&&(a=a.filter(function(a){return a.id in this.params.tiers},this));var b={},c={};a.forEach(function(a,d){a.annotations.forEach(function(a){a.reference&&a.reference.type==this.Types.ALIGNABLE_ANNOTATION&&(a.reference.id in b||(b[a.ref]={}),b[a.ref][d]=a,c[d]=!0)},this)},this),c=Object.keys(c).sort(),this.renderedAlignable=this.data.alignableAnnotations.filter(function(a){return b[a.id]});var d=document.createElement("table");d.className="wavesurfer-annotations";var e=document.createElement("thead"),f=document.createElement("tr");e.appendChild(f),d.appendChild(e);var g=document.createElement("th");g.textContent="Time",g.className="wavesurfer-time",f.appendChild(g),c.forEach(function(b){var c=a[b],d=document.createElement("th");d.className="wavesurfer-tier-"+c.id,d.textContent=c.id,d.style.width=this.params.tiers[c.id],f.appendChild(d)},this);var h=document.createElement("tbody");d.appendChild(h),this.renderedAlignable.forEach(function(d){var e=document.createElement("tr");e.id="wavesurfer-alignable-"+d.id,h.appendChild(e);var f=document.createElement("td");f.className="wavesurfer-time",f.textContent=d.start.toFixed(1)+"–"+d.end.toFixed(1),e.appendChild(f);var g=b[d.id];c.forEach(function(b){var c=a[b],f=document.createElement("td"),h=g[b];h&&(f.id="wavesurfer-annotation-"+h.id,f.dataset.ref=d.id,f.dataset.start=d.start,f.dataset.end=d.end,f.textContent=h.value),f.className="wavesurfer-tier-"+c.id,e.appendChild(f)},this)},this),this.container.innerHTML="",this.container.appendChild(d)},bindClick:function(){var a=this;this.container.addEventListener("click",function(b){var c=b.target.dataset.ref;if(null!=c){var d=a.data.annotations[c];d&&a.fireEvent("select",d.start,d.end)}})},getRenderedAnnotation:function(a){var b;return this.renderedAlignable.some(function(c){return c.start<=a&&c.end>=a?(b=c,!0):!1}),b},getAnnotationNode:function(a){return document.getElementById("wavesurfer-alignable-"+a.id)}},WaveSurfer.util.extend(WaveSurfer.ELAN,WaveSurfer.Observer);

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

/*! wavesurfer.js 1.0.26
/*! wavesurfer.js 1.0.27
* https://github.com/katspaugh/wavesurfer.js
* @license CC-BY 3.0 */!function(a,b){"function"==typeof define&&define.amd?define(["wavesurfer"],b):a.WaveSurfer.Microphone=b(a.WaveSurfer)}(this,function(a){"use strict";return a.Microphone={init:function(a){this.params=a;this.wavesurfer=a.wavesurfer;if(!this.wavesurfer)throw new Error("No WaveSurfer instance provided");this.active=!1,this.paused=!1,this.getUserMedia=(navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia).bind(navigator),this.bufferSize=this.params.bufferSize||4096,this.numberOfInputChannels=this.params.numberOfInputChannels||1,this.numberOfOutputChannels=this.params.numberOfOutputChannels||1,this.micContext=this.wavesurfer.backend.getAudioContext()},start:function(){this.getUserMedia({video:!1,audio:!0},this.gotStream.bind(this),this.deviceError.bind(this))},togglePlay:function(){this.active?(this.paused=!this.paused,this.paused?this.disconnect():this.connect()):this.start()},stop:function(){this.active&&(this.active=!1,this.stream&&this.stream.stop(),this.disconnect(),this.wavesurfer.empty())},connect:function(){void 0!==this.stream&&(this.mediaStreamSource=this.micContext.createMediaStreamSource(this.stream),this.levelChecker=this.micContext.createScriptProcessor(this.bufferSize,this.numberOfInputChannels,this.numberOfOutputChannels),this.mediaStreamSource.connect(this.levelChecker),this.levelChecker.connect(this.micContext.destination),this.levelChecker.onaudioprocess=this.reloadBuffer.bind(this))},disconnect:function(){void 0!==this.mediaStreamSource&&this.mediaStreamSource.disconnect(),void 0!==this.levelChecker&&this.levelChecker.disconnect()},reloadBuffer:function(a){this.paused||(this.wavesurfer.empty(),this.wavesurfer.loadDecodedBuffer(a.inputBuffer))},gotStream:function(a){this.stream=a,this.active=!0,this.connect(),this.fireEvent("deviceReady",a)},destroy:function(){this.stop()},deviceError:function(a){this.fireEvent("deviceError",a)}},a.util.extend(a.Microphone,a.Observer),a.Microphone});

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

/*! wavesurfer.js 1.0.26
/*! wavesurfer.js 1.0.27
* https://github.com/katspaugh/wavesurfer.js
* @license CC-BY 3.0 */"use strict";WaveSurfer.Minimap=WaveSurfer.util.extend({},WaveSurfer.Drawer,WaveSurfer.Drawer.Canvas,{init:function(a,b){this.wavesurfer=a,this.container=this.wavesurfer.drawer.container,this.lastPos=this.wavesurfer.drawer.lastPos,this.params=a.util.extend({},this.wavesurfer.drawer.params,{showRegions:!1,showOverview:!1,overviewBorderColor:"green",overviewBorderSize:2},b,{scrollParent:!1,fillParent:!0}),this.width=0,this.height=this.params.height*this.params.pixelRatio,this.createWrapper(),this.createElements(),WaveSurfer.Regions&&this.params.showRegions&&this.regions(),this.bindWaveSurferEvents(),this.bindMinimapEvents()},regions:function(){var a=this;this.regions={},this.wavesurfer.on("region-created",function(b){a.regions[b.id]=b,a.renderRegions()}),this.wavesurfer.on("region-updated",function(b){a.regions[b.id]=b,a.renderRegions()}),this.wavesurfer.on("region-removed",function(b){delete a.regions[b.id],a.renderRegions()})},renderRegions:function(){for(var a=this,b=this.wrapper.querySelectorAll("region"),c=0;c<b.length;++c)this.wrapper.removeChild(b[c]);Object.keys(this.regions).forEach(function(b){var c=a.regions[b],d=a.width*((c.end-c.start)/a.wavesurfer.getDuration()),e=a.width*(c.start/a.wavesurfer.getDuration()),f=a.style(document.createElement("region"),{height:"inherit",backgroundColor:c.color,width:d+"px",left:e+"px",display:"block",position:"absolute"});f.classList.add(b),a.wrapper.appendChild(f)})},createElements:function(){WaveSurfer.Drawer.Canvas.createElements.call(this),this.params.showOverview&&(this.overviewRegion=this.style(document.createElement("overview"),{height:this.wrapper.offsetHeight-2*this.params.overviewBorderSize+"px",width:"0px",display:"block",position:"absolute",cursor:"move",border:this.params.overviewBorderSize+"px solid "+this.params.overviewBorderColor,zIndex:2,opacity:this.params.overviewOpacity}),this.wrapper.appendChild(this.overviewRegion))},bindWaveSurferEvents:function(){var a=this;this.wavesurfer.on("ready",this.render.bind(this)),this.wavesurfer.on("audioprocess",function(){a.progress(a.wavesurfer.backend.getPlayedPercents())}),this.wavesurfer.on("seek",function(){a.progress(a.wavesurfer.backend.getPlayedPercents())}),this.params.showOverview&&(this.wavesurfer.on("scroll",function(b){a.draggingOverview||a.moveOverviewRegion(b.target.scrollLeft/a.ratio)}),this.wavesurfer.drawer.wrapper.addEventListener("mouseover",function(){a.draggingOverview&&(a.draggingOverview=!1)})),this.wavesurfer.on("destroy",this.destroy.bind(this))},bindMinimapEvents:function(){var a=this,b=0,c=!0,d={clientX:0,clientY:0};this.on("click",function(a,b){c?(this.progress(b),this.wavesurfer.seekAndCenter(b)):c=!0}.bind(this)),this.params.showOverview&&(this.overviewRegion.addEventListener("mousedown",function(c){a.draggingOverview=!0,b=c.layerX,d.clientX=c.clientX,d.clientY=c.clientY}),this.wrapper.addEventListener("mousemove",function(c){a.draggingOverview&&a.moveOverviewRegion(c.clientX-a.container.getBoundingClientRect().left-b)}),this.wrapper.addEventListener("mouseup",function(b){d.clientX-b.clientX===0&&d.clientX-b.clientX===0?(c=!0,a.draggingOverview=!1):a.draggingOverview&&(c=!1,a.draggingOverview=!1)}))},render:function(){var a=this.getWidth(),b=this.wavesurfer.backend.getPeaks(a);this.drawPeaks(b,a),this.params.showOverview&&(this.ratio=this.wavesurfer.drawer.width/this.width,this.waveShowedWidth=this.wavesurfer.drawer.width/this.ratio,this.waveWidth=this.wavesurfer.drawer.width,this.overviewWidth=this.width/this.ratio,this.overviewPosition=0,this.overviewRegion.style.width=this.overviewWidth-2*this.params.overviewBorderSize+"px")},moveOverviewRegion:function(a){this.overviewPosition=0>a?0:a+this.overviewWidth<this.width?a:this.width-this.overviewWidth,this.overviewRegion.style.left=this.overviewPosition+"px",this.wavesurfer.drawer.wrapper.scrollLeft=this.overviewPosition*this.ratio}}),WaveSurfer.initMinimap=function(a){var b=Object.create(WaveSurfer.Minimap);return b.init(this,a),b};

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

/*! wavesurfer.js 1.0.26
/*! wavesurfer.js 1.0.27
* https://github.com/katspaugh/wavesurfer.js
* @license CC-BY 3.0 */"use strict";WaveSurfer.Regions={init:function(a){this.wavesurfer=a,this.wrapper=this.wavesurfer.drawer.wrapper,this.list={}},add:function(a){var b=Object.create(WaveSurfer.Region);return b.init(a,this.wavesurfer),this.list[b.id]=b,b.on("remove",function(){delete this.list[b.id]}.bind(this)),b},clear:function(){Object.keys(this.list).forEach(function(a){this.list[a].remove()},this)},enableDragSelection:function(a){var b,c,d,e=this;this.wrapper.addEventListener("mousedown",function(a){b=!0,c=e.wavesurfer.drawer.handleEvent(a),d=null}),this.wrapper.addEventListener("mouseup",function(){b=!1,d=null}),this.wrapper.addEventListener("mousemove",function(f){if(b){d||(d=e.add(a||{}));var g=e.wavesurfer.getDuration(),h=e.wavesurfer.drawer.handleEvent(f);d.update({start:Math.min(h*g,c*g),end:Math.max(h*g,c*g)})}})}},WaveSurfer.Region={style:WaveSurfer.Drawer.style,init:function(a,b){this.wavesurfer=b,this.wrapper=b.drawer.wrapper,this.id=null==a.id?WaveSurfer.util.getId():a.id,this.start=Number(a.start)||0,this.end=null==a.end?this.start+4/this.wrapper.scrollWidth*this.wavesurfer.getDuration():Number(a.end),this.resize=void 0===a.resize?!0:Boolean(a.resize),this.drag=void 0===a.drag?!0:Boolean(a.drag),this.loop=Boolean(a.loop),this.color=a.color||"rgba(0, 0, 0, 0.1)",this.data=a.data||{},this.bindInOut(),this.render(),this.wavesurfer.fireEvent("region-created",this)},update:function(a){null!=a.start&&(this.start=Number(a.start)),null!=a.end&&(this.end=Number(a.end)),null!=a.loop&&(this.loop=Boolean(a.loop)),null!=a.color&&(this.color=a.color),null!=a.data&&(this.data=a.data),null!=a.resize&&(this.resize=Boolean(a.resize)),null!=a.drag&&(this.drag=Boolean(a.drag)),this.updateRender(),this.fireEvent("update"),this.wavesurfer.fireEvent("region-updated",this)},remove:function(){this.element&&(this.wrapper.removeChild(this.element),this.element=null,this.fireEvent("remove"),this.wavesurfer.fireEvent("region-removed",this))},play:function(){this.wavesurfer.play(this.start,this.end),this.fireEvent("play"),this.wavesurfer.fireEvent("region-play",this)},playLoop:function(){this.play(),this.once("out",this.playLoop.bind(this))},render:function(){var a=document.createElement("region");a.className="wavesurfer-region",a.title=this.formatTime(this.start,this.end);this.wrapper.scrollWidth;if(this.style(a,{position:"absolute",zIndex:2,height:"100%",top:"0px"}),this.resize){var b=a.appendChild(document.createElement("handle")),c=a.appendChild(document.createElement("handle"));b.className="wavesurfer-handle wavesurfer-handle-start",c.className="wavesurfer-handle wavesurfer-handle-end";var d={cursor:"col-resize",position:"absolute",left:"0px",top:"0px",width:"1%",maxWidth:"4px",height:"100%"};this.style(b,d),this.style(c,d),this.style(c,{left:"100%"})}this.element=this.wrapper.appendChild(a),this.updateRender(),this.bindEvents(a)},formatTime:function(a,b){return(a==b?[a]:[a,b]).map(function(a){return[Math.floor(a%3600/60),("00"+Math.floor(a%60)).slice(-2)].join(":")}).join("–")},updateRender:function(){var a=this.wavesurfer.getDuration(),b=this.wrapper.scrollWidth;this.start<0&&(this.start=0,this.end=this.end-this.start),this.end>a&&(this.end=a,this.start=a-(this.end-this.start)),this.style(this.element,{left:~~(this.start/a*b)+"px",width:~~((this.end-this.start)/a*b)+"px",backgroundColor:this.color,cursor:this.drag?"move":"default"}),this.element.title=this.formatTime(this.start,this.end)},bindInOut:function(){var a=this,b=function(){a.firedIn=!1,a.firedOut=!1},c=function(b){!a.firedIn&&a.start<=b&&a.end>b&&(a.firedIn=!0,a.fireEvent("in"),a.wavesurfer.fireEvent("region-in",a)),!a.firedOut&&a.firedIn&&a.end<=b&&(a.firedOut=!0,a.fireEvent("out"),a.wavesurfer.fireEvent("region-out",a))};this.wavesurfer.on("play",b),this.wavesurfer.backend.on("audioprocess",c),this.on("remove",function(){a.wavesurfer.un("play",b),a.wavesurfer.backend.un("audioprocess",c)}),this.on("out",function(){a.loop&&a.wavesurfer.play(a.start)})},bindEvents:function(){var a=this;this.element.addEventListener("mouseenter",function(b){a.fireEvent("mouseenter",b),a.wavesurfer.fireEvent("region-mouseenter",a,b)}),this.element.addEventListener("mouseleave",function(b){a.fireEvent("mouseleave",b),a.wavesurfer.fireEvent("region-mouseleave",a,b)}),this.element.addEventListener("click",function(b){b.preventDefault(),a.fireEvent("click",b),a.wavesurfer.fireEvent("region-click",a,b)}),this.element.addEventListener("dblclick",function(b){b.stopPropagation(),b.preventDefault(),a.fireEvent("dblclick",b),a.wavesurfer.fireEvent("region-dblclick",a,b)}),(this.drag||this.resize)&&function(){var b,c,d,e=a.wavesurfer.getDuration(),f=function(f){f.stopPropagation(),d=a.wavesurfer.drawer.handleEvent(f)*e,"handle"==f.target.tagName.toLowerCase()?c=f.target.classList.contains("wavesurfer-handle-start")?"start":"end":b=!0},g=function(d){(b||c)&&(b=!1,c=!1,d.stopPropagation(),d.preventDefault(),a.fireEvent("update-end"),a.wavesurfer.fireEvent("region-update-end"))},h=function(f){if(b||c){var g=a.wavesurfer.drawer.handleEvent(f)*e,h=g-d;d=g,a.drag&&b&&a.onDrag(h),a.resize&&c&&a.onResize(h,c)}};a.element.addEventListener("mousedown",f),a.wrapper.addEventListener("mousemove",h),document.body.addEventListener("mouseup",g),a.on("remove",function(){document.body.removeEventListener("mouseup",g),a.wrapper.removeEventListener("mousemove",h)}),a.wavesurfer.on("destroy",function(){document.body.removeEventListener("mouseup",g)})}()},onDrag:function(a){this.update({start:this.start+a,end:this.end+a})},onResize:function(a,b){this.update("start"==b?{start:Math.min(this.start+a,this.end),end:Math.max(this.start+a,this.end)}:{start:Math.min(this.end+a,this.start),end:Math.max(this.end+a,this.start)})}},WaveSurfer.util.extend(WaveSurfer.Region,WaveSurfer.Observer),WaveSurfer.initRegions=function(){this.regions||(this.regions=Object.create(WaveSurfer.Regions),this.regions.init(this))},WaveSurfer.addRegion=function(a){return this.initRegions(),this.regions.add(a)},WaveSurfer.clearRegions=function(){this.regions&&this.regions.clear()},WaveSurfer.enableDragSelection=function(a){this.initRegions(),this.regions.enableDragSelection(a)};

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

/*! wavesurfer.js 1.0.26
/*! wavesurfer.js 1.0.27
* https://github.com/katspaugh/wavesurfer.js
* @license CC-BY 3.0 */"use strict";WaveSurfer.Spectrogram={init:function(a){this.params=a;var b=this.wavesurfer=a.wavesurfer;if(!this.wavesurfer)throw Error("No WaveSurfer intance provided");this.frequenciesDataUrl=a.frequenciesDataUrl;var c=this.drawer=this.wavesurfer.drawer;if(this.buffer=this.wavesurfer.backend.buffer,this.container="string"==typeof a.container?document.querySelector(a.container):a.container,!this.container)throw Error("No container for WaveSurfer spectrogram");this.width=c.width,this.pixelRatio=this.params.pixelRatio||b.params.pixelRatio,this.fftSamples=this.params.fftSamples||b.params.fftSamples||512,this.height=this.fftSamples/2,this.createWrapper(),this.createCanvas(),this.render(),b.drawer.wrapper.onscroll=this.updateScroll.bind(this),b.on("redraw",this.render.bind(this))},createWrapper:function(){var a=this.wavesurfer.params;this.wrapper=this.container.appendChild(document.createElement("spectrogram")),this.drawer.style(this.wrapper,{display:"block",position:"relative",userSelect:"none",webkitUserSelect:"none",height:this.height+"px"}),(a.fillParent||a.scrollParent)&&this.drawer.style(this.wrapper,{width:"100%",overflowX:"hidden",overflowY:"hidden"});var b=this;this.wrapper.addEventListener("click",function(a){a.preventDefault();var c="offsetX"in a?a.offsetX:a.layerX;b.fireEvent("click",c/b.scrollWidth||0)})},createCanvas:function(){var a=this.canvas=this.wrapper.appendChild(document.createElement("canvas"));this.spectrCc=a.getContext("2d"),this.wavesurfer.drawer.style(a,{position:"absolute",zIndex:4})},render:function(){this.updateCanvasStyle(),this.frequenciesDataUrl?this.loadFrequenciesData(this.frequenciesDataUrl):this.getFrequencies(this.drawSpectrogram)},updateCanvasStyle:function(){var a=Math.round(this.width/this.pixelRatio)+"px";this.canvas.width=this.width,this.canvas.height=this.height,this.canvas.style.width=a},drawSpectrogram:function(a,b){for(var c=(b.spectrCc,b.wavesurfer.backend.getDuration(),b.height),d=b.resample(a),e=2/b.buffer.numberOfChannels,f=0;f<d.length;f++)for(var g=0;g<d[f].length;g++){var h=255-d[f][g];b.spectrCc.fillStyle="rgb("+h+", "+h+", "+h+")",b.spectrCc.fillRect(f,c-g*e,1,1*e)}},getFrequencies:function(a){var b=this.fftSamples,c=this.buffer,d=[],e=new window.OfflineAudioContext(1,c.length,c.sampleRate),f=e.createBufferSource(),g=e.createScriptProcessor(0,1,1),h=e.createAnalyser();h.fftSize=b,h.smoothingTimeConstant=this.width/c.duration<10?.75:.25,f.buffer=c,f.connect(h),h.connect(g),g.connect(e.destination),g.onaudioprocess=function(){var a=new Uint8Array(h.frequencyBinCount);h.getByteFrequencyData(a),d.push(a)},f.start(0),e.startRendering();var i=this;e.oncomplete=function(){a(d,i)}},loadFrequenciesData:function(a){var b=this,c=WaveSurfer.util.ajax({url:a});return c.on("success",function(a){b.drawSpectrogram(JSON.parse(a),b)}),c.on("error",function(a){b.fireEvent("error","XHR error: "+a.target.statusText)}),c},updateScroll:function(a){this.wrapper.scrollLeft=a.target.scrollLeft},resample:function(a,b){for(var b=this.width,c=[],d=1/a.length,e=1/b,f=0;b>f;f++){for(var g=new Array(a[0].length),h=0;h<a.length;h++){var i=h*d,j=i+d,k=f*e,l=k+e,m=k>=j||i>=l?0:Math.min(Math.max(j,k),Math.max(l,i))-Math.max(Math.min(j,k),Math.min(l,i));if(m>0)for(var n=0;n<a[0].length;n++)null==g[n]&&(g[n]=0),g[n]+=m/e*a[h][n]}for(var o=new Uint8Array(a[0].length),n=0;n<a[0].length;n++)o[n]=g[n];c.push(o)}return c}},WaveSurfer.util.extend(WaveSurfer.Spectrogram,WaveSurfer.Observer);

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

/*! wavesurfer.js 1.0.26
/*! wavesurfer.js 1.0.27
* https://github.com/katspaugh/wavesurfer.js
* @license CC-BY 3.0 */!function(a,b){"function"==typeof define&&define.amd?define(["wavesurfer"],b):a.WaveSurfer.Timeline=b(a.WaveSurfer)}(this,function(a){"use strict";return a.Timeline={init:function(a){this.params=a;var b=this.wavesurfer=a.wavesurfer;if(!this.wavesurfer)throw Error("No WaveSurfer intance provided");var c=this.drawer=this.wavesurfer.drawer;if(this.container="string"==typeof a.container?document.querySelector(a.container):a.container,!this.container)throw Error("No container for WaveSurfer timeline");this.width=c.width,this.height=this.params.height||20,this.notchPercentHeight=this.params.notchPercentHeight||90,this.primaryColor=this.params.primaryColor||"#000",this.secondaryColor=this.params.secondaryColor||"#c0c0c0",this.primaryFontColor=this.params.primaryFontColor||"#000",this.secondaryFontColor=this.params.secondaryFontColor||"#000",this.fontFamily=this.params.fontFamily||"Arial",this.fontSize=this.params.fontSize||10,this.createWrapper(),this.createCanvas(),this.render(),b.drawer.wrapper.onscroll=this.updateScroll.bind(this),b.on("redraw",this.render.bind(this)),b.on("destroy",this.destroy.bind(this))},destroy:function(){this.unAll(),this.wrapper&&(this.wrapper.parentNode.removeChild(this.wrapper),this.wrapper=null)},createWrapper:function(){var a=this.container.querySelector("timeline");a&&this.container.removeChild(a);var b=this.wavesurfer.params;this.wrapper=this.container.appendChild(document.createElement("timeline")),this.drawer.style(this.wrapper,{display:"block",position:"relative",userSelect:"none",webkitUserSelect:"none",height:this.height+"px"}),(b.fillParent||b.scrollParent)&&this.drawer.style(this.wrapper,{width:"100%",overflowX:"hidden",overflowY:"hidden"});var c=this;this.wrapper.addEventListener("click",function(a){a.preventDefault();var b="offsetX"in a?a.offsetX:a.layerX;c.fireEvent("click",b/c.wrapper.scrollWidth||0)})},createCanvas:function(){var a=this.canvas=this.wrapper.appendChild(document.createElement("canvas"));this.timeCc=a.getContext("2d"),this.wavesurfer.drawer.style(a,{position:"absolute",zIndex:4})},render:function(){this.updateCanvasStyle(),this.drawTimeCanvas()},updateCanvasStyle:function(){var a=this.drawer.wrapper.scrollWidth;this.canvas.width=a*this.wavesurfer.params.pixelRatio,this.canvas.height=this.height*this.wavesurfer.params.pixelRatio,this.canvas.style.width=a+"px",this.canvas.style.height=this.height+"px"},drawTimeCanvas:function(){var a=this.wavesurfer.backend,b=this.wavesurfer.params,c=a.getDuration();if(b.fillParent&&!b.scrollParent)var d=this.drawer.getWidth();else d=this.drawer.wrapper.scrollWidth*b.pixelRatio;var e=d/c;if(c>0){var f=0,g=0,h=parseInt(c,10)+1,i=function(a){if(a/60>1){var b=parseInt(a/60),a=parseInt(a%60);return a=10>a?"0"+a:a,""+b+":"+a}return a};if(1*e>=25)var j=1,k=10,l=5;else if(5*e>=25)var j=5,k=6,l=2;else if(15*e>=25)var j=15,k=4,l=2;else var j=60,k=4,l=2;for(var m=this.height-4,n=this.height*(this.notchPercentHeight/100)-4,o=this.fontSize*b.pixelRatio,p=0;h/j>p;p++)p%k==0?(this.timeCc.fillStyle=this.primaryColor,this.timeCc.fillRect(f,0,1,m),this.timeCc.font=o+"px "+this.fontFamily,this.timeCc.fillStyle=this.primaryFontColor,this.timeCc.fillText(i(g),f+5,m)):p%l==0?(this.timeCc.fillStyle=this.secondaryColor,this.timeCc.fillRect(f,0,1,m),this.timeCc.font=o+"px "+this.fontFamily,this.timeCc.fillStyle=this.secondaryFontColor,this.timeCc.fillText(i(g),f+5,m)):(this.timeCc.fillStyle=this.secondaryColor,this.timeCc.fillRect(f,0,1,n)),g+=j,f+=e*j}},updateScroll:function(){this.wrapper.scrollLeft=this.drawer.wrapper.scrollLeft}},a.util.extend(a.Timeline,a.Observer),a.Timeline});

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

/*! wavesurfer.js 1.0.26
/*! wavesurfer.js 1.0.27
* https://github.com/katspaugh/wavesurfer.js

@@ -613,7 +613,7 @@ * @license CC-BY 3.0 */

this.setState(this.PAUSED_STATE);
this.createVolumeNode();
this.createScriptNode();
this.createAnalyserNode();
this.setState(this.PAUSED_STATE);
this.setPlaybackRate(this.params.audioRate);

@@ -669,17 +669,20 @@ },

createScriptNode: function () {
var my = this;
var bufferSize = this.scriptBufferSize;
if (this.ac.createScriptProcessor) {
this.scriptNode = this.ac.createScriptProcessor(bufferSize);
this.scriptNode = this.ac.createScriptProcessor(this.scriptBufferSize);
} else {
this.scriptNode = this.ac.createJavaScriptNode(bufferSize);
this.scriptNode = this.ac.createJavaScriptNode(this.scriptBufferSize);
}
this.scriptNode.connect(this.ac.destination);
},
addOnAudioProcess: function () {
var my = this;
this.scriptNode.onaudioprocess = function () {
var time = my.getCurrentTime();
if (my.buffer && time >= my.getDuration()) {
if (time >= my.getDuration()) {
my.setState(my.FINISHED_STATE);
} else if (my.buffer && time >= my.scheduledPause) {
} else if (time >= my.scheduledPause) {
my.setState(my.PAUSED_STATE);

@@ -692,2 +695,6 @@ } else if (my.state === my.states[my.PLAYING_STATE]) {

removeOnAudioProcess: function () {
this.scriptNode.onaudioprocess = null;
},
createAnalyserNode: function () {

@@ -922,2 +929,3 @@ this.analyser = this.ac.createAnalyser();

init: function () {
this.addOnAudioProcess();
},

@@ -935,2 +943,3 @@ getPlayedPercents: function () {

init: function () {
this.removeOnAudioProcess();
},

@@ -948,2 +957,3 @@ getPlayedPercents: function () {

init: function () {
this.removeOnAudioProcess();
this.fireEvent('finish');

@@ -1326,2 +1336,3 @@ },

zIndex: 1,
left: 0,
top: 0,

@@ -1337,2 +1348,3 @@ bottom: 0

zIndex: 2,
left: 0,
top: 0,

@@ -1339,0 +1351,0 @@ bottom: 0,

@@ -14,2 +14,3 @@ /**

height: 100,
pixelRatio: 1,
scrollParent: true,

@@ -16,0 +17,0 @@ normalize: true,

@@ -96,5 +96,48 @@ /*global module:false*/

},
src: ['<%= concat.dist.src %>', 'plugin/*.js']
src: ['<%= concat.dist.src %>', 'plugin/*.js', 'spec/*.spec.js']
},
},
jasmine: {
core: {
src: '<%= concat.dist.src %>',
options: {
specs: ['spec/*.spec.js'],
vendor: [
'node_modules/jasmine-expect/dist/jasmine-matchers.js'
]
}
},
coverage: {
src: '<%= concat.dist.src %>',
options: {
specs: '<%= jasmine.core.options.specs %>',
vendor: '<%= jasmine.core.options.vendor %>',
template: require('grunt-template-jasmine-istanbul'),
templateOptions: {
coverage: 'coverage/coverage.json',
report: [
{
type: 'lcov',
options: {
dir: 'coverage/lcov'
}
},
{
type: 'html',
options: {
dir: 'coverage/html'
}
}]
}
}
}
},
coveralls: {
options: {
force: true
},
main_target: {
src: 'coverage/lcov/lcov.info'
}
}
});

@@ -131,9 +174,13 @@

grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-jasmine');
grunt.loadNpmTasks('grunt-coveralls');
// Default task.
grunt.registerTask('default', ['jshint', 'concat', 'commonjs', 'amd', 'uglify']);
grunt.registerTask('default', ['jshint', 'test', 'coverage', 'concat', 'commonjs',
'amd', 'uglify']);
// Dev
grunt.registerTask('dev', ['concat', 'uglify']);
grunt.registerTask('test', ['jasmine:core']);
grunt.registerTask('coverage', ['jasmine:coverage']);
};
{
"name": "wavesurfer.js",
"version": "1.0.26",
"version": "1.0.27",
"description": "Interactive navigable audio visualization using Web Audio and Canvas",

@@ -11,3 +11,3 @@ "main": "dist/wavesurfer.cjs.js",

"start": "grunt; ruby -run -e httpd . -p 8080",
"test": "echo No tests yet!"
"test": "grunt test"
},

@@ -27,5 +27,9 @@ "repository": {

"grunt-contrib-uglify": ">=0.5.0",
"grunt-contrib-jshint": ">=0.10.0"
"grunt-contrib-jshint": ">=0.10.0",
"grunt-contrib-jasmine": ">=0.8.2",
"grunt-template-jasmine-istanbul": ">=0.3.3",
"jasmine-expect": ">=1.22.3",
"grunt-coveralls": ">=1.0.0"
},
"homepage": "https://github.com/katspaugh/wavesurfer.js"
}

@@ -204,2 +204,3 @@ # wavesurfer.js

[![Build Status](https://travis-ci.org/katspaugh/wavesurfer.js.svg?branch=master)](https://travis-ci.org/katspaugh/wavesurfer.js)
[![Coverage Status](https://coveralls.io/repos/katspaugh/wavesurfer.js/badge.svg)](https://coveralls.io/r/katspaugh/wavesurfer.js)

@@ -219,3 +220,3 @@ Install `grunt-cli` using npm:

Build a minified version of the library and plugins. This command also checks
for code-style mistakes:
for code-style mistakes and runs the tests:

@@ -228,2 +229,16 @@ ```

Running tests only:
```
grunt test
```
Creating a coverage report:
```
grunt coverage
```
The HTML report can be found in `coverage/html/index.html`.
# Credits

@@ -230,0 +245,0 @@

@@ -11,2 +11,3 @@ 'use strict';

zIndex: 1,
left: 0,
top: 0,

@@ -22,2 +23,3 @@ bottom: 0

zIndex: 2,
left: 0,
top: 0,

@@ -24,0 +26,0 @@ bottom: 0,

@@ -45,7 +45,7 @@ 'use strict';

this.setState(this.PAUSED_STATE);
this.createVolumeNode();
this.createScriptNode();
this.createAnalyserNode();
this.setState(this.PAUSED_STATE);
this.setPlaybackRate(this.params.audioRate);

@@ -101,17 +101,20 @@ },

createScriptNode: function () {
var my = this;
var bufferSize = this.scriptBufferSize;
if (this.ac.createScriptProcessor) {
this.scriptNode = this.ac.createScriptProcessor(bufferSize);
this.scriptNode = this.ac.createScriptProcessor(this.scriptBufferSize);
} else {
this.scriptNode = this.ac.createJavaScriptNode(bufferSize);
this.scriptNode = this.ac.createJavaScriptNode(this.scriptBufferSize);
}
this.scriptNode.connect(this.ac.destination);
},
addOnAudioProcess: function () {
var my = this;
this.scriptNode.onaudioprocess = function () {
var time = my.getCurrentTime();
if (my.buffer && time >= my.getDuration()) {
if (time >= my.getDuration()) {
my.setState(my.FINISHED_STATE);
} else if (my.buffer && time >= my.scheduledPause) {
} else if (time >= my.scheduledPause) {
my.setState(my.PAUSED_STATE);

@@ -124,2 +127,6 @@ } else if (my.state === my.states[my.PLAYING_STATE]) {

removeOnAudioProcess: function () {
this.scriptNode.onaudioprocess = null;
},
createAnalyserNode: function () {

@@ -354,2 +361,3 @@ this.analyser = this.ac.createAnalyser();

init: function () {
this.addOnAudioProcess();
},

@@ -367,2 +375,3 @@ getPlayedPercents: function () {

init: function () {
this.removeOnAudioProcess();
},

@@ -380,2 +389,3 @@ getPlayedPercents: function () {

init: function () {
this.removeOnAudioProcess();
this.fireEvent('finish');

@@ -382,0 +392,0 @@ },

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