diff --git a/dist/wfplayer.js b/dist/wfplayer.js index 648e8e9..caad7fe 100644 --- a/dist/wfplayer.js +++ b/dist/wfplayer.js @@ -1,7 +1,7 @@ /*! - * wfplayer.js v2.2.6 + * wfplayer.js v2.2.7 * Github: https://github.com/zhw2590582/WFPlayer * (c) 2017-2023 Harvey Zack * Released under the MIT License. */ -!function(e,t,r,o,n){var i="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},s="function"==typeof i[o]&&i[o],a=s.cache||{},l="undefined"!=typeof module&&"function"==typeof module.require&&module.require.bind(module);function c(t,r){if(!a[t]){if(!e[t]){var n="function"==typeof i[o]&&i[o];if(!r&&n)return n(t,!0);if(s)return s(t,!0);if(l&&"string"==typeof t)return l(t);var u=new Error("Cannot find module '"+t+"'");throw u.code="MODULE_NOT_FOUND",u}h.resolve=function(r){var o=e[t][1][r];return null!=o?o:r},h.cache={};var f=a[t]=new c.Module(t);e[t][0].call(f.exports,h,f,f.exports,this)}return a[t].exports;function h(e){var t=h.resolve(e);return!1===t?{}:c(t)}}c.isParcelRequire=!0,c.Module=function(e){this.id=e,this.bundle=c,this.exports={}},c.modules=e,c.cache=a,c.parent=s,c.register=function(t,r){e[t]=[function(e,t){t.exports=r},{}]},Object.defineProperty(c,"root",{get:function(){return i[o]}}),i[o]=c;for(var u=0;uD));var n=e("option-validator"),i=o.interopDefault(n),s=e("./emitter"),a=o.interopDefault(s),l=e("./events"),c=o.interopDefault(l),u=e("./template"),f=o.interopDefault(u),h=e("./drawer"),d=o.interopDefault(h),p=e("./decoder"),m=o.interopDefault(p),g=e("./loader"),y=o.interopDefault(g),w=e("./controller"),b=o.interopDefault(w),v=e("bundle-text:./style.less"),x=o.interopDefault(v),T=e("./utils");let C=0;const j=[];class D extends a.default{static get instances(){return j}static get version(){return"2.2.6"}static get env(){return"production"}static get default(){return{container:"#waveform",mediaElement:null,useWorker:!0,wave:!0,waveColor:"rgba(255, 255, 255, 0.1)",backgroundColor:"rgb(28, 32, 34)",paddingColor:"rgba(255, 255, 255, 0.05)",cursor:!0,cursorColor:"#ff0000",progress:!0,progressColor:"rgba(255, 255, 255, 0.5)",grid:!0,gridColor:"rgba(255, 255, 255, 0.05)",ruler:!0,rulerColor:"rgba(255, 255, 255, 0.5)",scrollbar:!0,scrollbarColor:"rgba(255, 255, 255, 0.25)",rulerAtTop:!0,scrollable:!1,refreshDelay:50,channel:0,duration:10,padding:5,waveScale:.8,waveSize:1,pixelRatio:Math.ceil(window.devicePixelRatio)}}static get scheme(){return{container:"htmlelement|htmldivelement",mediaElement:"null|htmlvideoelement|htmlaudioelement",useWorker:"boolean",wave:"boolean",waveColor:"string",backgroundColor:"string",paddingColor:"string",cursor:"boolean",cursorColor:"string",progress:"boolean",progressColor:"string",grid:"boolean",gridColor:"string",ruler:"boolean",rulerColor:"string",scrollbar:"boolean",scrollbarColor:"string",rulerAtTop:"boolean",scrollable:"boolean",refreshDelay:"number",channel:"number",duration:"number",padding:"number",waveScale:"number",waveSize:"number",pixelRatio:"number"}}get currentTime(){return this.options.mediaElement?this.options.mediaElement.currentTime:this._currentTime}get duration(){return this.options.mediaElement?this.options.mediaElement.duration:1/0}get playing(){const{mediaElement:e}=this.options;return!!e&&!!(e.currentTime>0&&!e.paused&&!e.ended&&e.readyState>2)}get canvas(){return this.template.canvas}get config(){return this.drawer.config}get proxy(){return this.events.proxy}setOptions(e={}){return(0,T.errorHandle)("object"===i.default.kindOf(e),"setOptions expects to receive object as a parameter."),"string"==typeof e.container&&(e.container=document.querySelector(e.container)),"string"==typeof e.mediaElement&&(e.mediaElement=document.querySelector(e.mediaElement)),this.options=(0,i.default)({...D.default,...this.options,...e},D.scheme),this.options.channel=Math.abs(Math.floor(this.options.channel)),this.options.duration=Math.abs(Math.floor(this.options.duration)),this.options.padding=Math.abs(Math.floor(this.options.padding)),this.options.pixelRatio=Math.abs(Math.floor(this.options.pixelRatio)),this.options.waveSize=Math.abs(Math.floor(this.options.waveSize)),this.options.waveScale=Math.abs(this.options.waveScale),this.options.duration%2!=0&&(this.options.duration-=1),this.emit("options",this.options),this.options.scrollable?(0,T.addClass)(this.options.container,"wf-scrollable"):(0,T.removeClass)(this.options.container,"wf-scrollable"),this.update(),this}load(e){return e&&"function"==typeof e.getChannelData?(this.decoder.decodeSuccess(e),this.controller.init(),this):e&&e.buffer?(this.decoder.decodeAudioData(e),this.controller.init(),this):((e instanceof HTMLVideoElement||e instanceof HTMLAudioElement)&&(this.options.mediaElement=e,e=e.currentSrc||e.src),(0,T.errorHandle)("string"==typeof e&&e.trim(),"The load target is not a string. If you are loading a mediaElement, make sure the mediaElement.src is not empty."),this.loader.load(e),this.controller.init(),this)}getCurrentTimeFromEvent(e){const{container:t}=this.options,{padding:r,beginTime:o,gridGap:n,pixelRatio:i}=this.drawer.config,s=e.pageX-t.getBoundingClientRect().left-r*n/i;return this.getDurationFromWidth(s)+o}getDurationFromWidth(e){const{gridGap:t,pixelRatio:r}=this.drawer.config;return e/(t/r*10)}getWidthFromDuration(e){const{gridGap:t,pixelRatio:r}=this.drawer.config;return t/r*10*e}getLeftFromTime(e){const{gridGap:t,pixelRatio:r,beginTime:o,padding:n}=this.drawer.config;return this.getWidthFromDuration(e-o)+n*t/r}checkVisible(e,t){const{beginTime:r,duration:o}=this.drawer.config;return"number"==typeof e&&"number"==typeof t&&(!(e>=t)&&(!(tr+o)))}checkCurrent(e,t){return this.checkVisible(e,t)&&this.currentTime>=e&&this.currentTime<=t}seek(e){return(0,T.errorHandle)("number"==typeof e,"seek expects to receive number as a parameter."),cancelAnimationFrame(this._seekTimer),this._currentTime=(0,T.clamp)(e,0,this.duration),this.options.mediaElement&&this.options.mediaElement.currentTime!==this._currentTime&&(this.options.mediaElement.currentTime=this._currentTime),this.update(),this}smoothSeek(e,t=.2){return new Promise((r=>{(0,T.errorHandle)("number"==typeof e,"smoothSeek expects to receive number as a parameter."),cancelAnimationFrame(this._seekTimer);const o=(0,T.clamp)(e,0,this.duration),n=o-this.currentTime;if(0===n)return r(this);const i=n/t/100,{mediaElement:s}=this.options,{playing:a}=this;a&&s.pause(),function e(){this._seekTimer=requestAnimationFrame((()=>{n>0&&this.currentTimeo?(this.seek(this.currentTime+i),this.isDestroy||e.call(this)):(this.seek(o),a&&s.play(),r(this))}))}.call(this)}))}changeChannel(e){return this.decoder.changeChannel(e),this.setOptions({channel:e}),this.update(),this}exportImage(){return this.template.exportImage(),this}update(){return this.template&&this.drawer&&(this.template.update(),this.drawer.update()),this}reset(){return this.decoder.destroy(),this}destroy(){return this.isDestroy=!0,this.events.destroy(),this.template.destroy(),this.controller.destroy(),this.decoder.destroy(),this.loader.destroy(),this.drawer.destroy(),j.splice(j.indexOf(this),1),this}constructor(e={}){super(),this._seekTimer=null,this._currentTime=0,this.isDestroy=!1,this.grabbing=!1,this.options={},this.setOptions(e),this.events=new(0,c.default)(this),this.template=new(0,f.default)(this),this.decoder=new(0,m.default)(this),this.drawer=new(0,d.default)(this),this.controller=new(0,b.default)(this),this.loader=new(0,y.default)(this),this.update(),C+=1,this.id=C,j.push(this)}}if("undefined"!=typeof document&&!document.getElementById("wfplayer-style")){const e=document.createElement("style");e.id="wfplayer-style",e.textContent=x.default,document.head.appendChild(e)}"undefined"!=typeof window&&(window.WFPlayer=D)},{"option-validator":"e1J0t","./emitter":"eQX3k","./events":"giPUg","./template":"2OQDE","./drawer":"5ozk4","./decoder":"2xfV6","./loader":"kF7nB","./controller":"3y0fD","bundle-text:./style.less":"4okRS","./utils":"50e2b","@parcel/transformer-js/src/esmodule-helpers.js":"47PTV"}],e1J0t:[function(e,t,r){t.exports=function(){"use strict";function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}var t=Object.prototype.toString,r=function(r){if(void 0===r)return"undefined";if(null===r)return"null";var n=e(r);if("boolean"===n)return"boolean";if("string"===n)return"string";if("number"===n)return"number";if("symbol"===n)return"symbol";if("function"===n)return function(e){return"GeneratorFunction"===o(e)}(r)?"generatorfunction":"function";if(function(e){return Array.isArray?Array.isArray(e):e instanceof Array}(r))return"array";if(function(e){return!(!e.constructor||"function"!=typeof e.constructor.isBuffer)&&e.constructor.isBuffer(e)}(r))return"buffer";if(function(e){try{if("number"==typeof e.length&&"function"==typeof e.callee)return!0}catch(e){if(-1!==e.message.indexOf("callee"))return!0}return!1}(r))return"arguments";if(function(e){return e instanceof Date||"function"==typeof e.toDateString&&"function"==typeof e.getDate&&"function"==typeof e.setDate}(r))return"date";if(function(e){return e instanceof Error||"string"==typeof e.message&&e.constructor&&"number"==typeof e.constructor.stackTraceLimit}(r))return"error";if(function(e){return e instanceof RegExp||"string"==typeof e.flags&&"boolean"==typeof e.ignoreCase&&"boolean"==typeof e.multiline&&"boolean"==typeof e.global}(r))return"regexp";switch(o(r)){case"Symbol":return"symbol";case"Promise":return"promise";case"WeakMap":return"weakmap";case"WeakSet":return"weakset";case"Map":return"map";case"Set":return"set";case"Int8Array":return"int8array";case"Uint8Array":return"uint8array";case"Uint8ClampedArray":return"uint8clampedarray";case"Int16Array":return"int16array";case"Uint16Array":return"uint16array";case"Int32Array":return"int32array";case"Uint32Array":return"uint32array";case"Float32Array":return"float32array";case"Float64Array":return"float64array"}if(function(e){return"function"==typeof e.throw&&"function"==typeof e.return&&"function"==typeof e.next}(r))return"generator";switch(n=t.call(r)){case"[object Object]":return"object";case"[object Map Iterator]":return"mapiterator";case"[object Set Iterator]":return"setiterator";case"[object String Iterator]":return"stringiterator";case"[object Array Iterator]":return"arrayiterator"}return n.slice(8,-1).toLowerCase().replace(/\s/g,"")};function o(e){return e.constructor?e.constructor.name:null}function n(e,t){var o=2n));class n{on(e,t,r){const o=this.e||(this.e={});return(o[e]||(o[e]=[])).push({fn:t,ctx:r}),this}once(e,t,r){const o=this;function n(...i){o.off(e,n),t.apply(r,i)}return n._=t,this.on(e,n,r)}emit(e,...t){const r=((this.e||(this.e={}))[e]||[]).slice();for(let e=0;en));class n{proxy(e,t,r,o={}){if(Array.isArray(t))return t.map((t=>this.proxy(e,t,r,o)));e.addEventListener(t,r,o);const n=()=>e.removeEventListener(t,r,o);return this.destroyEvents.push(n),n}destroy(){this.destroyEvents.forEach((e=>e()))}constructor(){this.destroyEvents=[],this.proxy=this.proxy.bind(this)}}},{"@parcel/transformer-js/src/esmodule-helpers.js":"47PTV"}],"2OQDE":[function(e,t,r){var o=e("@parcel/transformer-js/src/esmodule-helpers.js");o.defineInteropFlag(r),o.export(r,"default",(()=>i));var n=e("./utils");class i{init(){const{container:e,pixelRatio:t}=this.wf.options,{clientWidth:r,clientHeight:o}=e,i=r*t,s=o*t;this.canvas?(this.canvas.width!==i&&(this.canvas.width=i),this.canvas.height!==s&&(this.canvas.height=s)):((0,n.errorHandle)(this.wf.constructor.instances.every((t=>t.options.container!==e)),"Cannot mount multiple instances on the same dom element, please destroy the previous instance first."),e.innerHTML="",(0,n.addClass)(e,"wf-player"),this.canvas=document.createElement("canvas"),this.canvas.width=i,this.canvas.height=s,this.canvas.style.width="100%",this.canvas.style.height="100%",e.appendChild(this.canvas))}exportImage(){const e=document.createElement("a");e.style.display="none",e.href=this.canvas.toDataURL("image/png"),e.download=`${Date.now()}.png`,document.body.appendChild(e),e.click(),document.body.removeChild(e)}destroy(){this.wf.options.container.innerHTML=""}constructor(e){this.wf=e,this.canvas=null;const{refreshDelay:t}=e.options;this.update=(0,n.throttle)(this.init,t,this),this.init()}}},{"./utils":"50e2b","@parcel/transformer-js/src/esmodule-helpers.js":"47PTV"}],"50e2b":[function(e,t,r){var o=e("@parcel/transformer-js/src/esmodule-helpers.js");o.defineInteropFlag(r),o.export(r,"WFPlayerError",(()=>n)),o.export(r,"errorHandle",(()=>i)),o.export(r,"mergeBuffer",(()=>s)),o.export(r,"clamp",(()=>a)),o.export(r,"throttle",(()=>l)),o.export(r,"addClass",(()=>c)),o.export(r,"removeClass",(()=>u));class n extends Error{constructor(e){super(e),this.name="WFPlayerError"}}function i(e,t){if(!e)throw new n(t);return e}function s(...e){const t=e[0].constructor;return e.reduce(((e,r)=>{const o=new t((0|e.byteLength)+(0|r.byteLength));return o.set(e,0),o.set(r,0|e.byteLength),o}),new t)}function a(e,t,r){return Math.max(Math.min(e,Math.max(t,r)),Math.min(t,r))}function l(e,t,r){let o=Date.now();return(...n)=>{Date.now()-o>=t&&(e.apply(r,n),o=Date.now())}}function c(e,t){return e.classList.add(t)}function u(e,t){return e.classList.remove(t)}},{"@parcel/transformer-js/src/esmodule-helpers.js":"47PTV"}],"5ozk4":[function(e,t,r){var o=e("@parcel/transformer-js/src/esmodule-helpers.js");o.defineInteropFlag(r),o.export(r,"default",(()=>l));var n=e("./utils"),i=e("bundle-text:./worker"),s=o.interopDefault(i),a=e("./worker");class l{update(){const{currentTime:e,duration:t,options:{container:r,mediaElement:o,...n}}=this.wf,{width:i,height:s}=this.canvas;this.worker.postMessage({type:"UPDATE",data:{...n,currentTime:e,width:i,height:s,totolDuration:t}})}destroy(){this.worker.terminate&&this.worker.terminate()}constructor(e){this.wf=e,this.canvas=e.template.canvas,this.config={};const{refreshDelay:t,useWorker:r}=e.options;this.update=(0,n.throttle)(this.update,t,this),r&&window.OffscreenCanvas&&window.Worker?(this.worker=new Worker(URL.createObjectURL(new Blob([s.default]))),this.ctx=this.canvas.getContext("bitmaprenderer"),this.wf.events.proxy(this.worker,"message",(t=>{const{type:r,data:o}=t.data;"UPFATE"!==r||e.isDestroy||(this.config=o.config,this.wf.emit("update",o.config),this.ctx.transferFromImageBitmap(o.imageBitmap))})),this.worker.postMessage({type:"INIT",data:{width:this.canvas.width,height:this.canvas.height}})):(this.worker={postMessage:a.postMessage},this.wf.on("update",(e=>{this.config=e})),this.worker.postMessage({type:"INIT",data:{canvas:this.canvas,wf:this.wf}})),e.on("decode",(({channelData:e,sampleRate:t})=>{this.worker.postMessage({type:"DECODE",data:{channelData:e,sampleRate:t}}),this.update()}))}}},{"./utils":"50e2b","bundle-text:./worker":"2nCk3","./worker":"iCc9f","@parcel/transformer-js/src/esmodule-helpers.js":"47PTV"}],"2nCk3":[function(e,t,r){t.exports='!function(e,t,o,n,r){var i="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},l="function"==typeof i[n]&&i[n],a=l.cache||{},f="undefined"!=typeof module&&"function"==typeof module.require&&module.require.bind(module);function c(t,o){if(!a[t]){if(!e[t]){var r="function"==typeof i[n]&&i[n];if(!o&&r)return r(t,!0);if(l)return l(t,!0);if(f&&"string"==typeof t)return f(t);var u=new Error("Cannot find module \'"+t+"\'");throw u.code="MODULE_NOT_FOUND",u}d.resolve=function(o){var n=e[t][1][o];return null!=n?n:o},d.cache={};var s=a[t]=new c.Module(t);e[t][0].call(s.exports,d,s,s.exports,this)}return a[t].exports;function d(e){var t=d.resolve(e);return!1===t?{}:c(t)}}c.isParcelRequire=!0,c.Module=function(e){this.id=e,this.bundle=c,this.exports={}},c.modules=e,c.cache=a,c.parent=l,c.register=function(t,o){e[t]=[function(e,t){t.exports=o},{}]},Object.defineProperty(c,"root",{get:function(){return i[n]}}),i[n]=c;for(var u=0;uy));const r=void 0===self.document;let i=null,l=null,a=null,f=0,c=0,u=0,s=1,d=44100,h=new Float32Array,p="";function g(e){const t=Math.floor(e/3600),o=Math.floor((e-3600*t)/60);return[t,o,Math.floor(e-3600*t-60*o)].map((e=>e<10?`0${e}`:String(e))).join(":")}function m(e){const{width:t,height:o,currentTime:n,progress:r,waveColor:i,progressColor:l,duration:f,padding:s,waveScale:p,waveSize:g,scrollable:m}=e,y=o/2,b=t-c*s*2,w=Math.floor(u*d),x=Math.floor((M=(u+f)*d,T=w,v=1/0,Math.max(Math.min(M,Math.max(T,v)),Math.min(T,v))));var M,T,v;const R=Math.floor((x-w)/b),C=m?t/2:s*c+(n-u)*c*10;let O=0,j=0,S=1,P=-1;for(let e=w;eP&&(P=t),O>=R&&j=e?l:i,a.fillRect(e,(1+S*p)*y,g,Math.max(1,(P-S)*y*p)),j+=g,O=0,S=1,P=-1}}}self.onmessage=function(e){const{type:t,data:o}=e.data;if("INIT"===t&&(r?l=new OffscreenCanvas(o.width,o.height):(i=o.wf,l=o.canvas),a=l.getContext("2d")),"DECODE"===t&&(d=o.sampleRate,h=o.channelData),"UPDATE"===t){const e=JSON.stringify(o);if(p===e)return p=e;l.width!==o.width&&(l.width=o.width),l.height!==o.height&&(l.height=o.height);const{byteLength:t}=h;f=10*o.duration+2*o.padding,c=o.width/f,s=function(e){a.font=11*e.pixelRatio+"px Arial";const t=a.measureText("99:99:99").width;return function e(o){return c*o/(1.5*t)>1?Math.floor(o/10):e(o+10)}(10)}(o),u=o.scrollable?o.currentTime-o.duration/2:Math.floor(o.currentTime/o.duration)*o.duration,function(e){const{width:t,height:o,backgroundColor:n,paddingColor:r,padding:i}=e;a.clearRect(0,0,t,o),a.fillStyle=n,a.fillRect(0,0,t,o),a.fillStyle=r,a.fillRect(0,0,i*c,o),a.fillRect(t-i*c,0,i*c,o)}(o),o.grid&&function(e){const{width:t,height:o,currentTime:n,gridColor:r,pixelRatio:i,scrollable:l}=e;a.fillStyle=r;for(let e=0;e=0&&a.fillText(g(e),n-11*r*2+r,l?30*r:t-30*r+11)}else(e-i)%5==0&&a.fillRect(n,l?0:t-7.5*r,r,7.5*r)}}(o),o.wave&&m(o),o.scrollbar&&function(e){const{width:t,height:o,currentTime:n,pixelRatio:r,rulerAtTop:i,totolDuration:l,scrollable:f,scrollbarColor:u}=e;if(!f||!l||l===1/0)return;const s=t/(c/r*10*l)*t,d=5*r,h=n/l*(t-s),p=i?o-d:0;a.fillStyle=u,a.fillRect(h,p,s,d)}(o),o.cursor&&function(e){const{height:t,width:o,currentTime:n,cursorColor:r,pixelRatio:i,padding:l,scrollable:f}=e;a.fillStyle=r;const s=f?o/2:l*c+(n-u)*c*10;a.fillRect(s,0,i,t)}(o);const n={gridNum:f,gridGap:c,beginTime:u,density:s,sampleRate:d,byteLength:t,...o};r?self.postMessage({type:"UPFATE",data:{config:n,imageBitmap:l.transferToImageBitmap()}}):i.emit("update",n)}};const y=e=>{self.onmessage({data:e})}},{"@parcel/transformer-js/src/esmodule-helpers.js":"47PTV"}],"47PTV":[function(e,t,o){o.interopDefault=function(e){return e&&e.__esModule?e:{default:e}},o.defineInteropFlag=function(e){Object.defineProperty(e,"__esModule",{value:!0})},o.exportAll=function(e,t){return Object.keys(e).forEach((function(o){"default"===o||"__esModule"===o||t.hasOwnProperty(o)||Object.defineProperty(t,o,{enumerable:!0,get:function(){return e[o]}})})),t},o.export=function(e,t,o){Object.defineProperty(e,t,{enumerable:!0,get:o})}},{}]},["04Ftm"],"04Ftm","parcelRequireb650");'},{}],iCc9f:[function(e,t,r){var o=e("@parcel/transformer-js/src/esmodule-helpers.js");o.defineInteropFlag(r),o.export(r,"postMessage",(()=>y));const n=void 0===self.document;let i=null,s=null,a=null,l=0,c=0,u=0,f=1,h=44100,d=new Float32Array,p="";function m(e){const t=Math.floor(e/3600),r=Math.floor((e-3600*t)/60);return[t,r,Math.floor(e-3600*t-60*r)].map((e=>e<10?`0${e}`:String(e))).join(":")}function g(e){const{width:t,height:r,currentTime:o,progress:n,waveColor:i,progressColor:s,duration:l,padding:f,waveScale:p,waveSize:m,scrollable:g}=e,y=r/2,w=t-c*f*2,b=Math.floor(u*h),v=Math.floor((x=(u+l)*h,T=b,C=1/0,Math.max(Math.min(x,Math.max(T,C)),Math.min(T,C))));var x,T,C;const j=Math.floor((v-b)/w),D=g?t/2:f*c+(o-u)*c*10;let M=0,S=0,k=1,E=-1;for(let e=b;eE&&(E=t),M>=j&&S=e?s:i,a.fillRect(e,(1+k*p)*y,m,Math.max(1,(E-k)*y*p)),S+=m,M=0,k=1,E=-1}}}self.onmessage=function(e){const{type:t,data:r}=e.data;if("INIT"===t&&(n?s=new OffscreenCanvas(r.width,r.height):(i=r.wf,s=r.canvas),a=s.getContext("2d")),"DECODE"===t&&(h=r.sampleRate,d=r.channelData),"UPDATE"===t){const e=JSON.stringify(r);if(p===e)return p=e;s.width!==r.width&&(s.width=r.width),s.height!==r.height&&(s.height=r.height);const{byteLength:t}=d;l=10*r.duration+2*r.padding,c=r.width/l,f=function(e){a.font=11*e.pixelRatio+"px Arial";const t=a.measureText("99:99:99").width;return function e(r){return c*r/(1.5*t)>1?Math.floor(r/10):e(r+10)}(10)}(r),u=r.scrollable?r.currentTime-r.duration/2:Math.floor(r.currentTime/r.duration)*r.duration,function(e){const{width:t,height:r,backgroundColor:o,paddingColor:n,padding:i}=e;a.clearRect(0,0,t,r),a.fillStyle=o,a.fillRect(0,0,t,r),a.fillStyle=n,a.fillRect(0,0,i*c,r),a.fillRect(t-i*c,0,i*c,r)}(r),r.grid&&function(e){const{width:t,height:r,currentTime:o,gridColor:n,pixelRatio:i,scrollable:s}=e;a.fillStyle=n;for(let e=0;e=0&&a.fillText(m(e),o-11*n*2+n,s?30*n:t-30*n+11)}else(e-i)%5==0&&a.fillRect(o,s?0:t-7.5*n,n,7.5*n)}}(r),r.wave&&g(r),r.scrollbar&&function(e){const{width:t,height:r,currentTime:o,pixelRatio:n,rulerAtTop:i,totolDuration:s,scrollable:l,scrollbarColor:u}=e;if(!l||!s||s===1/0)return;const f=t/(c/n*10*s)*t,h=5*n,d=o/s*(t-f),p=i?r-h:0;a.fillStyle=u,a.fillRect(d,p,f,h)}(r),r.cursor&&function(e){const{height:t,width:r,currentTime:o,cursorColor:n,pixelRatio:i,padding:s,scrollable:l}=e;a.fillStyle=n;const f=l?r/2:s*c+(o-u)*c*10;a.fillRect(f,0,i,t)}(r);const o={gridNum:l,gridGap:c,beginTime:u,density:f,sampleRate:h,byteLength:t,...r};n?self.postMessage({type:"UPFATE",data:{config:o,imageBitmap:s.transferToImageBitmap()}}):i.emit("update",o)}};const y=e=>{self.onmessage({data:e})}},{"@parcel/transformer-js/src/esmodule-helpers.js":"47PTV"}],"2xfV6":[function(e,t,r){var o=e("@parcel/transformer-js/src/esmodule-helpers.js");o.defineInteropFlag(r),o.export(r,"default",(()=>n));class n{decodeAudioData(e){return new Promise(((t,r)=>{this.wf.emit("decode:start",e),this.audioCtx.decodeAudioData(e.buffer,(e=>{this.wf.emit("decode:success",e),this.decodeSuccess(e),t(e)}),(e=>{this.wf.emit("decode:error",e),r(e)}))}))}decodeSuccess(e){this.audiobuffer=e,this.channelData=e.getChannelData(this.wf.options.channel),this.wf.emit("decode",{channelData:this.channelData,sampleRate:this.audiobuffer.sampleRate,duration:this.audiobuffer.duration}),this.wf.update()}changeChannel(e){this.channelData=this.audiobuffer.getChannelData(e)||new Float32Array,this.wf.emit("decode",{channelData:this.channelData,sampleRate:this.audiobuffer.sampleRate,duration:this.audiobuffer.duration}),this.wf.update()}destroy(){this.audiobuffer=this.audioCtx.createBuffer(1,2,44100),this.channelData=new Float32Array,this.wf.emit("decode",{channelData:this.channelData,sampleRate:this.audiobuffer.sampleRate,duration:this.audiobuffer.duration}),this.wf.update()}constructor(e){this.wf=e,this.audioCtx=new(window.OfflineAudioContext||window.webkitOfflineAudioContext)(1,2,44100),this.audiobuffer=this.audioCtx.createBuffer(1,2,44100),this.channelData=new Float32Array}}},{"@parcel/transformer-js/src/esmodule-helpers.js":"47PTV"}],kF7nB:[function(e,t,r){var o=e("@parcel/transformer-js/src/esmodule-helpers.js");o.defineInteropFlag(r),o.export(r,"default",(()=>i));var n=e("./utils");class i{load(e){return this.destroy(),fetch(e).then((e=>e.body&&"function"==typeof e.body.getReader?(this.fileSize=Number(e.headers.get("content-length")),this.reader=e.body.getReader(),function e(){return this.reader.read().then((({done:t,value:r})=>t?null:(this.loadSize+=r.byteLength,this.data=(0,n.mergeBuffer)(this.data,r),this.wf.decoder.decodeAudioData(this.data.slice()),this.wf.emit("load",{fileSize:this.fileSize,loadSize:this.loadSize,data:this.data}),e.call(this))))}.call(this)):e.arrayBuffer())).then((e=>(e&&e.byteLength&&(this.data=new Uint8Array(e),this.fileSize=this.data.byteLength,this.loadSize=this.data.byteLength,this.wf.decoder.decodeAudioData(this.data),this.wf.emit("load",{fileSize:this.fileSize,loadSize:this.loadSize,data:this.data})),e)))}destroy(){this.fileSize=0,this.loadSize=0,this.data=new Uint8Array,this.reader&&(this.reader.cancel(),this.reader=null)}constructor(e){this.wf=e,this.fileSize=0,this.loadSize=0,this.data=new Uint8Array,this.reader=null}}},{"./utils":"50e2b","@parcel/transformer-js/src/esmodule-helpers.js":"47PTV"}],"3y0fD":[function(e,t,r){var o=e("@parcel/transformer-js/src/esmodule-helpers.js");o.defineInteropFlag(r),o.export(r,"default",(()=>i));var n=e("./utils");class i{clickInit(){const{options:{container:e},events:{proxy:t}}=this.wf;t(e,["click","contextmenu"],(e=>{if(this.wf.grabbing)return;const t=this.wf.getCurrentTimeFromEvent(e);this.wf.emit(e.type,t,e)}))}resizeInit(){const{proxy:e}=this.wf.events,t=(0,n.throttle)((()=>{this.wf.update(),this.wf.emit("resize")}),200,this);e(window,["resize","orientationchange"],(()=>{t()}))}playInit(){const{events:{proxy:e},options:{mediaElement:t}}=this.wf;t&&(e(t,["seeked","seeking","canplay"],(()=>{this.wf.update()})),function e(){this.playTimer=requestAnimationFrame((()=>{this.wf.playing&&this.wf.update(),this.wf.isDestroy||e.call(this)}))}.call(this))}scrollInit(){const{events:{proxy:e},options:{container:t}}=this.wf;e(t,"wheel",(e=>{this.wf.emit("scroll",Math.sign(e.deltaY),e)}))}grabInit(){const{events:{proxy:e},options:{container:t}}=this.wf;let r=!1,o=0,i=0;e(t,"mousedown",(e=>{if(this.wf.emit("mousedown",e),0!==e.button)return;r=!0;const{scrollable:t}=this.wf.config;o=t?this.wf.currentTime:this.wf.getCurrentTimeFromEvent(e),i=e.pageX})),e(t,"mousemove",(e=>{if(this.wf.emit("mousemove",e),!r)return;this.wf.grabbing=!0,(0,n.addClass)(t,"wf-grabbing");const{scrollable:s}=this.wf.config,a=e.pageX-i,l=this.wf.getDurationFromWidth(a),c=o+(s?-l:l);this.wf.emit("grabbing",c,e)})),e(document,"mouseup",(e=>{this.wf.emit("mouseup",e),r&&(setTimeout((()=>this.wf.grabbing=!1)),(0,n.removeClass)(t,"wf-grabbing"),r=!1,o=0,i=0)}))}hoverInit(){const{events:{proxy:e},options:{container:t}}=this.wf,r=document.createElement("div");(0,n.addClass)(r,"wf-cursor"),t.appendChild(r),this.wf.template.cursor=r,this.wf.on("mousemove",(e=>{r.style.left=e.pageX-t.getBoundingClientRect().left+"px"})),e(t,"mouseenter",(e=>{this.wf.emit("mouseenter",e),r.style.display=null})),e(t,"mouseleave",(e=>{this.wf.emit("mouseleave",e),r.style.display="none"}))}destroy(){cancelAnimationFrame(this.playTimer)}constructor(e){this.wf=e,this.playTimer=null,this.isInit=!1,this.init=()=>{this.isInit||(this.isInit=!0,this.clickInit(),this.resizeInit(),this.playInit(),this.scrollInit(),this.grabInit(),this.hoverInit())}}}},{"./utils":"50e2b","@parcel/transformer-js/src/esmodule-helpers.js":"47PTV"}],"4okRS":[function(e,t,r){t.exports=".wf-player{position:relative;overflow:hidden}.wf-scrollable{cursor:grab}.wf-scrollable.wf-grabbing{cursor:grabbing}.wf-cursor{z-index:10;width:1px;height:100%;opacity:.25;-webkit-user-select:none;user-select:none;pointer-events:none;background-color:#fff;position:absolute;top:0;bottom:0;left:0}.wf-subtitle{z-index:20;height:100%;width:100%;-webkit-user-select:none;user-select:none;pointer-events:none;position:absolute;inset:0}.wf-subtitle-item{height:100%;cursor:default;pointer-events:all;background-color:#fff3;justify-content:center;align-items:center;transition:background-color .2s;display:flex;position:absolute;top:0;bottom:0}.wf-subtitle-item:hover{background-color:#ffffff4d}.wf-subtitle-current{background-color:#2196f380;border:1px solid #2196f380}.wf-subtitle-current:hover{background-color:#2196f399}"},{}]},["bqk8e"],"bqk8e","parcelRequireb650"); \ No newline at end of file +!function(e,t,r,i,n){var o="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},s="function"==typeof o[i]&&o[i],a=s.cache||{},l="undefined"!=typeof module&&"function"==typeof module.require&&module.require.bind(module);function u(t,r){if(!a[t]){if(!e[t]){var n="function"==typeof o[i]&&o[i];if(!r&&n)return n(t,!0);if(s)return s(t,!0);if(l&&"string"==typeof t)return l(t);var c=Error("Cannot find module '"+t+"'");throw c.code="MODULE_NOT_FOUND",c}h.resolve=function(r){var i=e[t][1][r];return null!=i?i:r},h.cache={};var f=a[t]=new u.Module(t);e[t][0].call(f.exports,h,f,f.exports,this)}return a[t].exports;function h(e){var t=h.resolve(e);return!1===t?{}:u(t)}}u.isParcelRequire=!0,u.Module=function(e){this.id=e,this.bundle=u,this.exports={}},u.modules=e,u.cache=a,u.parent=s,u.register=function(t,r){e[t]=[function(e,t){t.exports=r},{}]},Object.defineProperty(u,"root",{get:function(){return o[i]}}),o[i]=u;for(var c=0;c0&&!e.paused&&!e.ended&&e.readyState>2)}get canvas(){return this.template.canvas}get config(){return this.drawer.config}get proxy(){return this.events.proxy}setOptions(e={}){return(0,j.errorHandle)("object"===(0,o.default).kindOf(e),"setOptions expects to receive object as a parameter."),"string"==typeof e.container&&(e.container=document.querySelector(e.container)),"string"==typeof e.mediaElement&&(e.mediaElement=document.querySelector(e.mediaElement)),this.options=(0,o.default)({...C.default,...this.options,...e},C.scheme),this.options.channel=Math.abs(Math.floor(this.options.channel)),this.options.duration=Math.abs(Math.floor(this.options.duration)),this.options.padding=Math.abs(Math.floor(this.options.padding)),this.options.pixelRatio=Math.abs(Math.floor(this.options.pixelRatio)),this.options.waveSize=Math.abs(Math.floor(this.options.waveSize)),this.options.waveScale=Math.abs(this.options.waveScale),this.options.duration%2!=0&&(this.options.duration-=1),this.emit("options",this.options),this.options.scrollable?(0,j.addClass)(this.options.container,"wf-scrollable"):(0,j.removeClass)(this.options.container,"wf-scrollable"),this.update(),this}load(e){return e&&"function"==typeof e.getChannelData?this.decoder.decodeSuccess(e):e&&e.buffer?this.decoder.decodeAudioData(e):((e instanceof HTMLVideoElement||e instanceof HTMLAudioElement)&&(this.options.mediaElement=e,e=e.currentSrc||e.src),(0,j.errorHandle)("string"==typeof e&&e.trim(),"The load target is not a string. If you are loading a mediaElement, make sure the mediaElement.src is not empty."),this.loader.load(e)),this.controller.init(),this}getCurrentTimeFromEvent(e){let{container:t}=this.options,{padding:r,beginTime:i,gridGap:n,pixelRatio:o}=this.drawer.config,s=e.pageX-t.getBoundingClientRect().left,a=this.getDurationFromWidth(s-r*n/o);return a+i}getDurationFromWidth(e){let{gridGap:t,pixelRatio:r}=this.drawer.config;return e/(t/r*10)}getWidthFromDuration(e){let{gridGap:t,pixelRatio:r}=this.drawer.config;return t/r*10*e}getLeftFromTime(e){let{gridGap:t,pixelRatio:r,beginTime:i,padding:n}=this.drawer.config,o=this.getWidthFromDuration(e-i);return o+n*t/r}checkVisible(e,t){let{beginTime:r,duration:i}=this.drawer.config;return"number"==typeof e&&"number"==typeof t&&!(e>=t)&&!(tr+i)}checkCurrent(e,t){return this.checkVisible(e,t)&&this.currentTime>=e&&this.currentTime<=t}seek(e){return(0,j.errorHandle)("number"==typeof e,"seek expects to receive number as a parameter."),cancelAnimationFrame(this._seekTimer),this._currentTime=(0,j.clamp)(e,0,this.duration),this.options.mediaElement&&this.options.mediaElement.currentTime!==this._currentTime&&(this.options.mediaElement.currentTime=this._currentTime),this.update(),this}smoothSeek(e,t=.2){return new Promise(r=>{(0,j.errorHandle)("number"==typeof e,"smoothSeek expects to receive number as a parameter."),cancelAnimationFrame(this._seekTimer);let i=(0,j.clamp)(e,0,this.duration),n=i-this.currentTime;if(0===n)return r(this);let o=n/t/100,{mediaElement:s}=this.options,{playing:a}=this;a&&s.pause(),(function e(){this._seekTimer=requestAnimationFrame(()=>{n>0&&this.currentTimei?(this.seek(this.currentTime+o),this.isDestroy||e.call(this)):(this.seek(i),a&&s.play(),r(this))})}).call(this)})}changeChannel(e){return this.decoder.changeChannel(e),this.setOptions({channel:e}),this.update(),this}exportImage(){return this.template.exportImage(),this}update(){return this.template&&this.drawer&&(this.template.update(),this.drawer.update()),this}reset(){return this.decoder.destroy(),this}destroy(){return this.isDestroy=!0,this.events.destroy(),this.template.destroy(),this.controller.destroy(),this.decoder.destroy(),this.loader.destroy(),this.drawer.destroy(),M.splice(M.indexOf(this),1),this}}if(r.default=C,"undefined"!=typeof document&&!document.getElementById("wfplayer-style")){let e=document.createElement("style");e.id="wfplayer-style",e.textContent=x.default,document.head.appendChild(e)}"undefined"!=typeof window&&(window.WFPlayer=C)},{"option-validator":"jm7Z2","./emitter":"eQX3k","./events":"giPUg","./template":"2OQDE","./drawer":"5ozk4","./decoder":"2xfV6","./loader":"kF7nB","./controller":"3y0fD","bundle-text:./style.less":"bG3aw","./utils":"50e2b","@parcel/transformer-js/src/esmodule-helpers.js":"cjq69"}],jm7Z2:[function(e,t,r){t.exports=function(){function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}var t=Object.prototype.toString,r=function(r){if(void 0===r)return"undefined";if(null===r)return"null";var n=e(r);if("boolean"===n)return"boolean";if("string"===n)return"string";if("number"===n)return"number";if("symbol"===n)return"symbol";if("function"===n)return"GeneratorFunction"===i(r)?"generatorfunction":"function";if(Array.isArray?Array.isArray(r):r instanceof Array)return"array";if(r.constructor&&"function"==typeof r.constructor.isBuffer&&r.constructor.isBuffer(r))return"buffer";if(function(e){try{if("number"==typeof e.length&&"function"==typeof e.callee)return!0}catch(e){if(-1!==e.message.indexOf("callee"))return!0}return!1}(r))return"arguments";if(r instanceof Date||"function"==typeof r.toDateString&&"function"==typeof r.getDate&&"function"==typeof r.setDate)return"date";if(r instanceof Error||"string"==typeof r.message&&r.constructor&&"number"==typeof r.constructor.stackTraceLimit)return"error";if(r instanceof RegExp||"string"==typeof r.flags&&"boolean"==typeof r.ignoreCase&&"boolean"==typeof r.multiline&&"boolean"==typeof r.global)return"regexp";switch(i(r)){case"Symbol":return"symbol";case"Promise":return"promise";case"WeakMap":return"weakmap";case"WeakSet":return"weakset";case"Map":return"map";case"Set":return"set";case"Int8Array":return"int8array";case"Uint8Array":return"uint8array";case"Uint8ClampedArray":return"uint8clampedarray";case"Int16Array":return"int16array";case"Uint16Array":return"uint16array";case"Int32Array":return"int32array";case"Uint32Array":return"uint32array";case"Float32Array":return"float32array";case"Float64Array":return"float64array"}if("function"==typeof r.throw&&"function"==typeof r.return&&"function"==typeof r.next)return"generator";switch(n=t.call(r)){case"[object Object]":return"object";case"[object Map Iterator]":return"mapiterator";case"[object Set Iterator]":return"setiterator";case"[object String Iterator]":return"stringiterator";case"[object Array Iterator]":return"arrayiterator"}return n.slice(8,-1).toLowerCase().replace(/\s/g,"")};function i(e){return e.constructor?e.constructor.name:null}function n(e,t){var i=2this.proxy(e,t,r,i));e.addEventListener(t,r,i);let n=()=>e.removeEventListener(t,r,i);return this.destroyEvents.push(n),n}destroy(){this.destroyEvents.forEach(e=>e())}}},{"@parcel/transformer-js/src/esmodule-helpers.js":"cjq69"}],"2OQDE":[function(e,t,r){e("@parcel/transformer-js/src/esmodule-helpers.js").defineInteropFlag(r);var i=e("./utils");r.default=class{constructor(e){this.wf=e,this.canvas=null;let{refreshDelay:t}=e.options;this.update=(0,i.throttle)(this.init,t,this),this.init()}init(){let{container:e,pixelRatio:t}=this.wf.options,{clientWidth:r,clientHeight:n}=e,o=r*t,s=n*t;this.canvas?(this.canvas.width!==o&&(this.canvas.width=o),this.canvas.height!==s&&(this.canvas.height=s)):((0,i.errorHandle)(this.wf.constructor.instances.every(t=>t.options.container!==e),"Cannot mount multiple instances on the same dom element, please destroy the previous instance first."),e.innerHTML="",(0,i.addClass)(e,"wf-player"),this.canvas=document.createElement("canvas"),this.canvas.width=o,this.canvas.height=s,this.canvas.style.width="100%",this.canvas.style.height="100%",e.appendChild(this.canvas))}exportImage(){let e=document.createElement("a");e.style.display="none",e.href=this.canvas.toDataURL("image/png"),e.download=`${Date.now()}.png`,document.body.appendChild(e),e.click(),document.body.removeChild(e)}destroy(){this.wf.options.container.innerHTML=""}}},{"./utils":"50e2b","@parcel/transformer-js/src/esmodule-helpers.js":"cjq69"}],"50e2b":[function(e,t,r){var i=e("@parcel/transformer-js/src/esmodule-helpers.js");i.defineInteropFlag(r),i.export(r,"WFPlayerError",()=>n),i.export(r,"errorHandle",()=>o),i.export(r,"mergeBuffer",()=>s),i.export(r,"clamp",()=>a),i.export(r,"throttle",()=>l),i.export(r,"addClass",()=>u),i.export(r,"removeClass",()=>c);class n extends Error{constructor(e){super(e),this.name="WFPlayerError"}}function o(e,t){if(!e)throw new n(t);return e}function s(...e){let t=e[0].constructor;return e.reduce((e,r)=>{let i=new t((0|e.byteLength)+(0|r.byteLength));return i.set(e,0),i.set(r,0|e.byteLength),i},new t)}function a(e,t,r){return Math.max(Math.min(e,Math.max(t,r)),Math.min(t,r))}function l(e,t,r){let i=Date.now();return(...n)=>{let o=Date.now();o-i>=t&&(e.apply(r,n),i=Date.now())}}function u(e,t){return e.classList.add(t)}function c(e,t){return e.classList.remove(t)}},{"@parcel/transformer-js/src/esmodule-helpers.js":"cjq69"}],"5ozk4":[function(e,t,r){var i=e("@parcel/transformer-js/src/esmodule-helpers.js");i.defineInteropFlag(r);var n=e("./utils"),o=e("bundle-text:./worker"),s=i.interopDefault(o),a=e("./worker");r.default=class{constructor(e){this.wf=e,this.canvas=e.template.canvas,this.config={};let{refreshDelay:t,useWorker:r}=e.options;this.update=(0,n.throttle)(this.update,t,this),r&&window.OffscreenCanvas&&window.Worker?(this.worker=new Worker(URL.createObjectURL(new Blob([s.default]))),this.ctx=this.canvas.getContext("bitmaprenderer"),this.wf.events.proxy(this.worker,"message",t=>{let{type:r,data:i}=t.data;"UPFATE"!==r||e.isDestroy||(this.config=i.config,this.wf.emit("update",i.config),this.ctx.transferFromImageBitmap(i.imageBitmap))}),this.worker.postMessage({type:"INIT",data:{width:this.canvas.width,height:this.canvas.height}})):(this.worker={postMessage:a.postMessage},this.wf.on("update",e=>{this.config=e}),this.worker.postMessage({type:"INIT",data:{canvas:this.canvas,wf:this.wf}})),e.on("decode",({channelData:e,sampleRate:t})=>{this.worker.postMessage({type:"DECODE",data:{channelData:e,sampleRate:t}}),this.update()})}update(){let{currentTime:e,duration:t,options:{container:r,mediaElement:i,...n}}=this.wf,{width:o,height:s}=this.canvas;this.worker.postMessage({type:"UPDATE",data:{...n,currentTime:e,width:o,height:s,totolDuration:t}})}destroy(){this.worker.terminate&&this.worker.terminate()}}},{"./utils":"50e2b","bundle-text:./worker":"32kDY","./worker":"iCc9f","@parcel/transformer-js/src/esmodule-helpers.js":"cjq69"}],"32kDY":[function(e,t,r){t.exports='!function(e,t,l,n,r){var o="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},i="function"==typeof o[n]&&o[n],f=i.cache||{},a="undefined"!=typeof module&&"function"==typeof module.require&&module.require.bind(module);function u(t,l){if(!f[t]){if(!e[t]){var r="function"==typeof o[n]&&o[n];if(!l&&r)return r(t,!0);if(i)return i(t,!0);if(a&&"string"==typeof t)return a(t);var c=Error("Cannot find module \'"+t+"\'");throw c.code="MODULE_NOT_FOUND",c}s.resolve=function(l){var n=e[t][1][l];return null!=n?n:l},s.cache={};var d=f[t]=new u.Module(t);e[t][0].call(d.exports,s,d,d.exports,this)}return f[t].exports;function s(e){var t=s.resolve(e);return!1===t?{}:u(t)}}u.isParcelRequire=!0,u.Module=function(e){this.id=e,this.bundle=u,this.exports={}},u.modules=e,u.cache=f,u.parent=i,u.register=function(t,l){e[t]=[function(e,t){t.exports=l},{}]},Object.defineProperty(u,"root",{get:function(){return o[n]}}),o[n]=u;for(var c=0;cm);let r=void 0===self.document,o=null,i=null,f=null,a=0,u=0,c=0,d=1,s=44100,p=new Float32Array,h="";self.onmessage=function(e){let{type:t,data:l}=e.data;if("INIT"===t&&(r?i=new OffscreenCanvas(l.width,l.height):(o=l.wf,i=l.canvas),f=i.getContext("2d")),"DECODE"===t&&(s=l.sampleRate,p=l.channelData),"UPDATE"===t){let e=JSON.stringify(l);if(h===e)return h=e;i.width!==l.width&&(i.width=l.width),i.height!==l.height&&(i.height=l.height);let{byteLength:t}=p;a=10*l.duration+2*l.padding,u=l.width/a,d=function(e){if(0===u)return 1;f.font=`${11*e.pixelRatio}px Arial`;let t=f.measureText("99:99:99").width;return function e(l){let n=u*l/(1.5*t);return n>1?Math.floor(l/10):e(l+10)}(10)}(l),c=l.scrollable?l.currentTime-l.duration/2:Math.floor(l.currentTime/l.duration)*l.duration,function(e){let{width:t,height:l,backgroundColor:n,paddingColor:r,padding:o}=e;f.clearRect(0,0,t,l),f.fillStyle=n,f.fillRect(0,0,t,l),f.fillStyle=r,f.fillRect(0,0,o*u,l),f.fillRect(t-o*u,0,o*u,l)}(l),l.grid&&function(e){let{width:t,height:l,currentTime:n,gridColor:r,pixelRatio:o,scrollable:i}=e;f.fillStyle=r;for(let e=0;e=0&&f.fillText(function(e){let t=Math.floor(e/3600),l=Math.floor((e-3600*t)/60);return[t,l,Math.floor(e-3600*t-60*l)].map(e=>e<10?`0${e}`:String(e)).join(":")}(e),n-11*r*2+r,i?30*r:t-30*r+11)}else(e-o)%5==0&&f.fillRect(n,i?0:t-7.5*r,r,7.5*r)}}(l),l.wave&&function(e){var t;let{width:l,height:n,currentTime:r,progress:o,waveColor:i,progressColor:a,duration:d,padding:h,waveScale:m,waveSize:g,scrollable:y}=e,M=n/2,x=l-u*h*2,w=Math.floor(c*s),b=Math.floor(Math.max(Math.min((c+d)*s,Math.max(w,t=1/0)),Math.min(w,t))),v=Math.floor((b-w)/x),R=y?l/2:h*u+(r-c)*u*10,j=0,O=0,T=1,S=-1;for(let e=w;eS&&(S=t),j>=v&&O=e?a:i,f.fillRect(e,(1+T*m)*M,g,Math.max(1,(S-T)*M*m)),O+=g,j=0,T=1,S=-1}}}(l),l.scrollbar&&function(e){let{width:t,height:l,currentTime:n,pixelRatio:r,rulerAtTop:o,totolDuration:i,scrollable:a,scrollbarColor:c}=e;if(!a||!i||i===1/0)return;let d=u/r*10*i,s=t/d*t,p=5*r,h=n/i*(t-s),m=o?l-p:0;f.fillStyle=c,f.fillRect(h,m,s,p)}(l),l.cursor&&function(e){let{height:t,width:l,currentTime:n,cursorColor:r,pixelRatio:o,padding:i,scrollable:a}=e;f.fillStyle=r;let d=a?l/2:i*u+(n-c)*u*10;f.fillRect(d,0,o,t)}(l);let n={gridNum:a,gridGap:u,beginTime:c,density:d,sampleRate:s,byteLength:t,...l};r?self.postMessage({type:"UPFATE",data:{config:n,imageBitmap:i.transferToImageBitmap()}}):o.emit("update",n)}};let m=e=>{self.onmessage({data:e})}},{"@parcel/transformer-js/src/esmodule-helpers.js":"cjq69"}],cjq69:[function(e,t,l){l.interopDefault=function(e){return e&&e.__esModule?e:{default:e}},l.defineInteropFlag=function(e){Object.defineProperty(e,"__esModule",{value:!0})},l.exportAll=function(e,t){return Object.keys(e).forEach(function(l){"default"===l||"__esModule"===l||t.hasOwnProperty(l)||Object.defineProperty(t,l,{enumerable:!0,get:function(){return e[l]}})}),t},l.export=function(e,t,l){Object.defineProperty(e,t,{enumerable:!0,get:l})}},{}]},["04Ftm"],"04Ftm","parcelRequireb650");'},{}],iCc9f:[function(e,t,r){var i=e("@parcel/transformer-js/src/esmodule-helpers.js");i.defineInteropFlag(r),i.export(r,"postMessage",()=>m);let n=void 0===self.document,o=null,s=null,a=null,l=0,u=0,c=0,f=1,h=44100,d=new Float32Array,p="";self.onmessage=function(e){let{type:t,data:r}=e.data;if("INIT"===t&&(n?s=new OffscreenCanvas(r.width,r.height):(o=r.wf,s=r.canvas),a=s.getContext("2d")),"DECODE"===t&&(h=r.sampleRate,d=r.channelData),"UPDATE"===t){let e=JSON.stringify(r);if(p===e)return p=e;s.width!==r.width&&(s.width=r.width),s.height!==r.height&&(s.height=r.height);let{byteLength:t}=d;l=10*r.duration+2*r.padding,u=r.width/l,f=function(e){if(0===u)return 1;a.font=`${11*e.pixelRatio}px Arial`;let t=a.measureText("99:99:99").width;return function e(r){let i=u*r/(1.5*t);return i>1?Math.floor(r/10):e(r+10)}(10)}(r),c=r.scrollable?r.currentTime-r.duration/2:Math.floor(r.currentTime/r.duration)*r.duration,function(e){let{width:t,height:r,backgroundColor:i,paddingColor:n,padding:o}=e;a.clearRect(0,0,t,r),a.fillStyle=i,a.fillRect(0,0,t,r),a.fillStyle=n,a.fillRect(0,0,o*u,r),a.fillRect(t-o*u,0,o*u,r)}(r),r.grid&&function(e){let{width:t,height:r,currentTime:i,gridColor:n,pixelRatio:o,scrollable:s}=e;a.fillStyle=n;for(let e=0;e=0&&a.fillText(function(e){let t=Math.floor(e/3600),r=Math.floor((e-3600*t)/60);return[t,r,Math.floor(e-3600*t-60*r)].map(e=>e<10?`0${e}`:String(e)).join(":")}(e),i-11*n*2+n,s?30*n:t-30*n+11)}else(e-o)%5==0&&a.fillRect(i,s?0:t-7.5*n,n,7.5*n)}}(r),r.wave&&function(e){var t;let{width:r,height:i,currentTime:n,progress:o,waveColor:s,progressColor:l,duration:f,padding:p,waveScale:m,waveSize:g,scrollable:y}=e,w=i/2,b=r-u*p*2,v=Math.floor(c*h),x=Math.floor(Math.max(Math.min((c+f)*h,Math.max(v,t=1/0)),Math.min(v,t))),j=Math.floor((x-v)/b),T=y?r/2:p*u+(n-c)*u*10,M=0,C=0,D=1,S=-1;for(let e=v;eS&&(S=t),M>=j&&C=e?l:s,a.fillRect(e,(1+D*m)*w,g,Math.max(1,(S-D)*w*m)),C+=g,M=0,D=1,S=-1}}}(r),r.scrollbar&&function(e){let{width:t,height:r,currentTime:i,pixelRatio:n,rulerAtTop:o,totolDuration:s,scrollable:l,scrollbarColor:c}=e;if(!l||!s||s===1/0)return;let f=u/n*10*s,h=t/f*t,d=5*n,p=i/s*(t-h),m=o?r-d:0;a.fillStyle=c,a.fillRect(p,m,h,d)}(r),r.cursor&&function(e){let{height:t,width:r,currentTime:i,cursorColor:n,pixelRatio:o,padding:s,scrollable:l}=e;a.fillStyle=n;let f=l?r/2:s*u+(i-c)*u*10;a.fillRect(f,0,o,t)}(r);let i={gridNum:l,gridGap:u,beginTime:c,density:f,sampleRate:h,byteLength:t,...r};n?self.postMessage({type:"UPFATE",data:{config:i,imageBitmap:s.transferToImageBitmap()}}):o.emit("update",i)}};let m=e=>{self.onmessage({data:e})}},{"@parcel/transformer-js/src/esmodule-helpers.js":"cjq69"}],"2xfV6":[function(e,t,r){e("@parcel/transformer-js/src/esmodule-helpers.js").defineInteropFlag(r),r.default=class{constructor(e){this.wf=e,this.audioCtx=new(window.OfflineAudioContext||window.webkitOfflineAudioContext)(1,2,44100),this.audiobuffer=this.audioCtx.createBuffer(1,2,44100),this.channelData=new Float32Array}decodeAudioData(e){return new Promise((t,r)=>{this.wf.emit("decode:start",e),this.audioCtx.decodeAudioData(e.buffer,e=>{this.wf.emit("decode:success",e),this.decodeSuccess(e),t(e)},e=>{this.wf.emit("decode:error",e),r(e)})})}decodeSuccess(e){this.audiobuffer=e,this.channelData=e.getChannelData(this.wf.options.channel),this.wf.emit("decode",{channelData:this.channelData,sampleRate:this.audiobuffer.sampleRate,duration:this.audiobuffer.duration}),this.wf.update()}changeChannel(e){this.channelData=this.audiobuffer.getChannelData(e)||new Float32Array,this.wf.emit("decode",{channelData:this.channelData,sampleRate:this.audiobuffer.sampleRate,duration:this.audiobuffer.duration}),this.wf.update()}destroy(){this.audiobuffer=this.audioCtx.createBuffer(1,2,44100),this.channelData=new Float32Array,this.wf.emit("decode",{channelData:this.channelData,sampleRate:this.audiobuffer.sampleRate,duration:this.audiobuffer.duration}),this.wf.update()}}},{"@parcel/transformer-js/src/esmodule-helpers.js":"cjq69"}],kF7nB:[function(e,t,r){e("@parcel/transformer-js/src/esmodule-helpers.js").defineInteropFlag(r);var i=e("./utils");r.default=class{constructor(e){this.wf=e,this.fileSize=0,this.loadSize=0,this.data=new Uint8Array,this.reader=null}load(e){return this.destroy(),fetch(e).then(e=>e.body&&"function"==typeof e.body.getReader?(this.fileSize=Number(e.headers.get("content-length")),this.reader=e.body.getReader(),(function e(){return this.reader.read().then(({done:t,value:r})=>t?null:(this.loadSize+=r.byteLength,this.data=(0,i.mergeBuffer)(this.data,r),this.wf.decoder.decodeAudioData(this.data.slice()),this.wf.emit("load",{fileSize:this.fileSize,loadSize:this.loadSize,data:this.data}),e.call(this)))}).call(this)):e.arrayBuffer()).then(e=>(e&&e.byteLength&&(this.data=new Uint8Array(e),this.fileSize=this.data.byteLength,this.loadSize=this.data.byteLength,this.wf.decoder.decodeAudioData(this.data),this.wf.emit("load",{fileSize:this.fileSize,loadSize:this.loadSize,data:this.data})),e))}destroy(){this.fileSize=0,this.loadSize=0,this.data=new Uint8Array,this.reader&&(this.reader.cancel(),this.reader=null)}}},{"./utils":"50e2b","@parcel/transformer-js/src/esmodule-helpers.js":"cjq69"}],"3y0fD":[function(e,t,r){e("@parcel/transformer-js/src/esmodule-helpers.js").defineInteropFlag(r);var i=e("./utils");r.default=class{constructor(e){this.wf=e,this.playTimer=null,this.isInit=!1,this.init=()=>{this.isInit||(this.isInit=!0,this.clickInit(),this.resizeInit(),this.playInit(),this.scrollInit(),this.grabInit(),this.hoverInit())}}clickInit(){let{options:{container:e},events:{proxy:t}}=this.wf;t(e,["click","contextmenu"],e=>{if(this.wf.grabbing)return;let t=this.wf.getCurrentTimeFromEvent(e);this.wf.emit(e.type,t,e)})}resizeInit(){let{proxy:e}=this.wf.events,t=(0,i.throttle)(()=>{this.wf.update(),this.wf.emit("resize")},200,this);e(window,["resize","orientationchange"],()=>{t()})}playInit(){let{events:{proxy:e},options:{mediaElement:t}}=this.wf;t&&(e(t,["seeked","seeking","canplay"],()=>{this.wf.update()}),(function e(){this.playTimer=requestAnimationFrame(()=>{this.wf.playing&&this.wf.update(),this.wf.isDestroy||e.call(this)})}).call(this))}scrollInit(){let{events:{proxy:e},options:{container:t}}=this.wf;e(t,"wheel",e=>{this.wf.emit("scroll",Math.sign(e.deltaY),e)})}grabInit(){let{events:{proxy:e},options:{container:t}}=this.wf,r=!1,n=0,o=0;e(t,"mousedown",e=>{if(this.wf.emit("mousedown",e),0!==e.button)return;r=!0;let{scrollable:t}=this.wf.config;n=t?this.wf.currentTime:this.wf.getCurrentTimeFromEvent(e),o=e.pageX}),e(t,"mousemove",e=>{if(this.wf.emit("mousemove",e),!r)return;this.wf.grabbing=!0,(0,i.addClass)(t,"wf-grabbing");let{scrollable:s}=this.wf.config,a=e.pageX-o,l=this.wf.getDurationFromWidth(a),u=n+(s?-l:l);this.wf.emit("grabbing",u,e)}),e(document,"mouseup",e=>{this.wf.emit("mouseup",e),r&&(setTimeout(()=>this.wf.grabbing=!1),(0,i.removeClass)(t,"wf-grabbing"),r=!1,n=0,o=0)})}hoverInit(){let{events:{proxy:e},options:{container:t}}=this.wf,r=document.createElement("div");(0,i.addClass)(r,"wf-cursor"),t.appendChild(r),this.wf.template.cursor=r,this.wf.on("mousemove",e=>{r.style.left=e.pageX-t.getBoundingClientRect().left+"px"}),e(t,"mouseenter",e=>{this.wf.emit("mouseenter",e),r.style.display=null}),e(t,"mouseleave",e=>{this.wf.emit("mouseleave",e),r.style.display="none"})}destroy(){cancelAnimationFrame(this.playTimer)}}},{"./utils":"50e2b","@parcel/transformer-js/src/esmodule-helpers.js":"cjq69"}],bG3aw:[function(e,t,r){t.exports=".wf-player{position:relative;overflow:hidden}.wf-scrollable{cursor:grab}.wf-scrollable.wf-grabbing{cursor:grabbing}.wf-cursor{z-index:10;opacity:.25;-webkit-user-select:none;user-select:none;pointer-events:none;background-color:#fff;width:1px;height:100%;position:absolute;top:0;bottom:0;left:0}"},{}]},["bqk8e"],"bqk8e","parcelRequireb650"); \ No newline at end of file diff --git a/docs/uncompiled/index.js b/docs/uncompiled/index.js index 09cf30a..1766a92 100644 --- a/docs/uncompiled/index.js +++ b/docs/uncompiled/index.js @@ -171,7 +171,7 @@ class WFPlayer extends (0, _emitterDefault.default) { return instances; } static get version() { - return "2.2.5"; + return "2.2.7"; } static get env() { return "development"; @@ -262,7 +262,7 @@ class WFPlayer extends (0, _emitterDefault.default) { return this.options.mediaElement ? this.options.mediaElement.duration : Infinity; } get playing() { - const { mediaElement } = this.options; + const { mediaElement } = this.options; if (mediaElement) return !!(mediaElement.currentTime > 0 && !mediaElement.paused && !mediaElement.ended && mediaElement.readyState > 2); return false; } @@ -322,8 +322,8 @@ class WFPlayer extends (0, _emitterDefault.default) { return this; } getCurrentTimeFromEvent(event) { - const { container } = this.options; - const { padding , beginTime , gridGap , pixelRatio } = this.drawer.config; + const { container } = this.options; + const { padding, beginTime, gridGap, pixelRatio } = this.drawer.config; const left = event.pageX - container.getBoundingClientRect().left; const paddingWidth = padding * gridGap / pixelRatio; const offsetLeft = left - paddingWidth; @@ -331,20 +331,20 @@ class WFPlayer extends (0, _emitterDefault.default) { return duration + beginTime; } getDurationFromWidth(width) { - const { gridGap , pixelRatio } = this.drawer.config; + const { gridGap, pixelRatio } = this.drawer.config; return width / (gridGap / pixelRatio * 10); } getWidthFromDuration(duration) { - const { gridGap , pixelRatio } = this.drawer.config; + const { gridGap, pixelRatio } = this.drawer.config; return gridGap / pixelRatio * 10 * duration; } getLeftFromTime(time) { - const { gridGap , pixelRatio , beginTime , padding } = this.drawer.config; + const { gridGap, pixelRatio, beginTime, padding } = this.drawer.config; const width = this.getWidthFromDuration(time - beginTime); return width + padding * gridGap / pixelRatio; } checkVisible(start, end) { - const { beginTime , duration } = this.drawer.config; + const { beginTime, duration } = this.drawer.config; if (typeof start !== "number" || typeof end !== "number") return false; if (start >= end) return false; if (end < beginTime) return false; @@ -370,8 +370,8 @@ class WFPlayer extends (0, _emitterDefault.default) { const diff = clampSecond - this.currentTime; if (diff === 0) return resolve(this); const step = diff / duration / 100; - const { mediaElement } = this.options; - const { playing } = this; + const { mediaElement } = this.options; + const { playing } = this; if (playing) mediaElement.pause(); (function loop() { this._seekTimer = requestAnimationFrame(()=>{ @@ -433,7 +433,7 @@ if (typeof document !== "undefined") { } if (typeof window !== "undefined") window["WFPlayer"] = WFPlayer; -},{"option-validator":"2tbdu","./emitter":"2ZQK0","./events":"jVQIf","./template":"eG0JW","./drawer":"7NL0G","./decoder":"eDdom","./loader":"6Zr4E","./controller":"5fGZE","bundle-text:./style.less":"fVJDJ","./utils":"5vF3n","@parcel/transformer-js/src/esmodule-helpers.js":"5dUr6"}],"2tbdu":[function(require,module,exports) { +},{"option-validator":"lEoFj","./emitter":"2ZQK0","./events":"jVQIf","./template":"eG0JW","./drawer":"7NL0G","./decoder":"eDdom","./loader":"6Zr4E","./controller":"5fGZE","bundle-text:./style.less":"4SQ8Q","./utils":"5vF3n","@parcel/transformer-js/src/esmodule-helpers.js":"jPXxM"}],"lEoFj":[function(require,module,exports) { !function(r, t) { module.exports = t(); }(this, function() { @@ -466,8 +466,8 @@ if (typeof window !== "undefined") window["WFPlayer"] = WFPlayer; if (function(r) { try { if ("number" == typeof r.length && "function" == typeof r.callee) return !0; - } catch (r1) { - if (-1 !== r1.message.indexOf("callee")) return !0; + } catch (r) { + if (-1 !== r.message.indexOf("callee")) return !0; } return !1; }(r)) return "arguments"; @@ -616,7 +616,7 @@ class Emitter { } exports.default = Emitter; -},{"@parcel/transformer-js/src/esmodule-helpers.js":"5dUr6"}],"5dUr6":[function(require,module,exports) { +},{"@parcel/transformer-js/src/esmodule-helpers.js":"jPXxM"}],"jPXxM":[function(require,module,exports) { exports.interopDefault = function(a) { return a && a.__esModule ? a : { default: a @@ -667,7 +667,7 @@ class Events { } exports.default = Events; -},{"@parcel/transformer-js/src/esmodule-helpers.js":"5dUr6"}],"eG0JW":[function(require,module,exports) { +},{"@parcel/transformer-js/src/esmodule-helpers.js":"jPXxM"}],"eG0JW":[function(require,module,exports) { var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); var _utils = require("./utils"); @@ -675,13 +675,13 @@ class Template { constructor(wf){ this.wf = wf; this.canvas = null; - const { refreshDelay } = wf.options; + const { refreshDelay } = wf.options; this.update = (0, _utils.throttle)(this.init, refreshDelay, this); this.init(); } init() { - const { container , pixelRatio } = this.wf.options; - const { clientWidth , clientHeight } = container; + const { container, pixelRatio } = this.wf.options; + const { clientWidth, clientHeight } = container; const width = clientWidth * pixelRatio; const height = clientHeight * pixelRatio; if (this.canvas) { @@ -714,7 +714,7 @@ class Template { } exports.default = Template; -},{"./utils":"5vF3n","@parcel/transformer-js/src/esmodule-helpers.js":"5dUr6"}],"5vF3n":[function(require,module,exports) { +},{"./utils":"5vF3n","@parcel/transformer-js/src/esmodule-helpers.js":"jPXxM"}],"5vF3n":[function(require,module,exports) { var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); parcelHelpers.export(exports, "WFPlayerError", ()=>WFPlayerError); @@ -763,7 +763,7 @@ function removeClass(el, className) { return el.classList.remove(className); } -},{"@parcel/transformer-js/src/esmodule-helpers.js":"5dUr6"}],"7NL0G":[function(require,module,exports) { +},{"@parcel/transformer-js/src/esmodule-helpers.js":"jPXxM"}],"7NL0G":[function(require,module,exports) { var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); var _utils = require("./utils"); @@ -775,7 +775,7 @@ class Drawer { this.wf = wf; this.canvas = wf.template.canvas; this.config = {}; - const { refreshDelay , useWorker } = wf.options; + const { refreshDelay, useWorker } = wf.options; this.update = (0, _utils.throttle)(this.update, refreshDelay, this); if (useWorker && window.OffscreenCanvas && window.Worker) { this.worker = new Worker(URL.createObjectURL(new Blob([ @@ -783,7 +783,7 @@ class Drawer { ]))); this.ctx = this.canvas.getContext("bitmaprenderer"); this.wf.events.proxy(this.worker, "message", (event)=>{ - const { type , data } = event.data; + const { type, data } = event.data; if (type === "UPFATE" && !wf.isDestroy) { this.config = data.config; this.wf.emit("update", data.config); @@ -812,7 +812,7 @@ class Drawer { } }); } - wf.on("decode", ({ channelData , sampleRate })=>{ + wf.on("decode", ({ channelData, sampleRate })=>{ this.worker.postMessage({ type: "DECODE", data: { @@ -824,9 +824,9 @@ class Drawer { }); } update() { - const { currentTime , duration: totolDuration , // eslint-disable-next-line no-unused-vars - options: { container , mediaElement , ...options } } = this.wf; - const { width , height } = this.canvas; + const { currentTime, duration: totolDuration, // eslint-disable-next-line no-unused-vars + options: { container, mediaElement, ...options } } = this.wf; + const { width, height } = this.canvas; this.worker.postMessage({ type: "UPDATE", data: { @@ -844,8 +844,8 @@ class Drawer { } exports.default = Drawer; -},{"./utils":"5vF3n","bundle-text:./worker":"5gMmV","./worker":"lPZ5X","@parcel/transformer-js/src/esmodule-helpers.js":"5dUr6"}],"5gMmV":[function(require,module,exports) { -module.exports = "// modules are defined as an array\n// [ module function, map of requires ]\n//\n// map of requires is short require name -> numeric require\n//\n// anything defined in a previous bundle is accessed via the\n// orig method which is the require for previous bundles\n\n(function (modules, entry, mainEntry, parcelRequireName, globalName) {\n /* eslint-disable no-undef */\n var globalObject =\n typeof globalThis !== 'undefined'\n ? globalThis\n : typeof self !== 'undefined'\n ? self\n : typeof window !== 'undefined'\n ? window\n : typeof global !== 'undefined'\n ? global\n : {};\n /* eslint-enable no-undef */\n\n // Save the require from previous bundle to this closure if any\n var previousRequire =\n typeof globalObject[parcelRequireName] === 'function' &&\n globalObject[parcelRequireName];\n\n var cache = previousRequire.cache || {};\n // Do not use `require` to prevent Webpack from trying to bundle this call\n var nodeRequire =\n typeof module !== 'undefined' &&\n typeof module.require === 'function' &&\n module.require.bind(module);\n\n function newRequire(name, jumped) {\n if (!cache[name]) {\n if (!modules[name]) {\n // if we cannot find the module within our internal map or\n // cache jump to the current global require ie. the last bundle\n // that was added to the page.\n var currentRequire =\n typeof globalObject[parcelRequireName] === 'function' &&\n globalObject[parcelRequireName];\n if (!jumped && currentRequire) {\n return currentRequire(name, true);\n }\n\n // If there are other bundles on this page the require from the\n // previous one is saved to 'previousRequire'. Repeat this as\n // many times as there are bundles until the module is found or\n // we exhaust the require chain.\n if (previousRequire) {\n return previousRequire(name, true);\n }\n\n // Try the node require function if it exists.\n if (nodeRequire && typeof name === 'string') {\n return nodeRequire(name);\n }\n\n var err = new Error(\"Cannot find module '\" + name + \"'\");\n err.code = 'MODULE_NOT_FOUND';\n throw err;\n }\n\n localRequire.resolve = resolve;\n localRequire.cache = {};\n\n var module = (cache[name] = new newRequire.Module(name));\n\n modules[name][0].call(\n module.exports,\n localRequire,\n module,\n module.exports,\n this\n );\n }\n\n return cache[name].exports;\n\n function localRequire(x) {\n var res = localRequire.resolve(x);\n return res === false ? {} : newRequire(res);\n }\n\n function resolve(x) {\n var id = modules[name][1][x];\n return id != null ? id : x;\n }\n }\n\n function Module(moduleName) {\n this.id = moduleName;\n this.bundle = newRequire;\n this.exports = {};\n }\n\n newRequire.isParcelRequire = true;\n newRequire.Module = Module;\n newRequire.modules = modules;\n newRequire.cache = cache;\n newRequire.parent = previousRequire;\n newRequire.register = function (id, exports) {\n modules[id] = [\n function (require, module) {\n module.exports = exports;\n },\n {},\n ];\n };\n\n Object.defineProperty(newRequire, 'root', {\n get: function () {\n return globalObject[parcelRequireName];\n },\n });\n\n globalObject[parcelRequireName] = newRequire;\n\n for (var i = 0; i < entry.length; i++) {\n newRequire(entry[i]);\n }\n\n if (mainEntry) {\n // Expose entry point to Node, AMD or browser globals\n // Based on https://github.com/ForbesLindesay/umd/blob/master/template.js\n var mainExports = newRequire(mainEntry);\n\n // CommonJS\n if (typeof exports === 'object' && typeof module !== 'undefined') {\n module.exports = mainExports;\n\n // RequireJS\n } else if (typeof define === 'function' && define.amd) {\n define(function () {\n return mainExports;\n });\n\n //