wavesurfer.js 6.3.0 → 6.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +36 -47
  3. package/dist/plugin/wavesurfer.cursor.js +45 -54
  4. package/dist/plugin/wavesurfer.cursor.js.map +1 -1
  5. package/dist/plugin/wavesurfer.cursor.min.js +2 -2
  6. package/dist/plugin/wavesurfer.cursor.min.js.map +1 -1
  7. package/dist/plugin/wavesurfer.elan.js +24 -51
  8. package/dist/plugin/wavesurfer.elan.js.map +1 -1
  9. package/dist/plugin/wavesurfer.elan.min.js +2 -2
  10. package/dist/plugin/wavesurfer.elan.min.js.map +1 -1
  11. package/dist/plugin/wavesurfer.markers.js +62 -74
  12. package/dist/plugin/wavesurfer.markers.js.map +1 -1
  13. package/dist/plugin/wavesurfer.markers.min.js +2 -2
  14. package/dist/plugin/wavesurfer.markers.min.js.map +1 -1
  15. package/dist/plugin/wavesurfer.mediasession.js +8 -16
  16. package/dist/plugin/wavesurfer.mediasession.js.map +1 -1
  17. package/dist/plugin/wavesurfer.mediasession.min.js +2 -2
  18. package/dist/plugin/wavesurfer.mediasession.min.js.map +1 -1
  19. package/dist/plugin/wavesurfer.microphone.js +48 -63
  20. package/dist/plugin/wavesurfer.microphone.js.map +1 -1
  21. package/dist/plugin/wavesurfer.microphone.min.js +2 -2
  22. package/dist/plugin/wavesurfer.microphone.min.js.map +1 -1
  23. package/dist/plugin/wavesurfer.minimap.js +20 -69
  24. package/dist/plugin/wavesurfer.minimap.js.map +1 -1
  25. package/dist/plugin/wavesurfer.minimap.min.js +2 -2
  26. package/dist/plugin/wavesurfer.minimap.min.js.map +1 -1
  27. package/dist/plugin/wavesurfer.playhead.js +6 -30
  28. package/dist/plugin/wavesurfer.playhead.js.map +1 -1
  29. package/dist/plugin/wavesurfer.playhead.min.js +2 -2
  30. package/dist/plugin/wavesurfer.playhead.min.js.map +1 -1
  31. package/dist/plugin/wavesurfer.regions.js +203 -260
  32. package/dist/plugin/wavesurfer.regions.js.map +1 -1
  33. package/dist/plugin/wavesurfer.regions.min.js +2 -2
  34. package/dist/plugin/wavesurfer.regions.min.js.map +1 -1
  35. package/dist/plugin/wavesurfer.spectrogram.js +55 -147
  36. package/dist/plugin/wavesurfer.spectrogram.js.map +1 -1
  37. package/dist/plugin/wavesurfer.spectrogram.min.js +2 -2
  38. package/dist/plugin/wavesurfer.spectrogram.min.js.map +1 -1
  39. package/dist/plugin/wavesurfer.timeline.js +53 -88
  40. package/dist/plugin/wavesurfer.timeline.js.map +1 -1
  41. package/dist/plugin/wavesurfer.timeline.min.js +2 -2
  42. package/dist/plugin/wavesurfer.timeline.min.js.map +1 -1
  43. package/dist/wavesurfer-html-init.js +34 -54
  44. package/dist/wavesurfer-html-init.js.map +1 -1
  45. package/dist/wavesurfer-html-init.min.js +2 -2
  46. package/dist/wavesurfer-html-init.min.js.map +1 -1
  47. package/dist/wavesurfer.js +490 -1003
  48. package/dist/wavesurfer.js.map +1 -1
  49. package/dist/wavesurfer.min.js +2 -2
  50. package/dist/wavesurfer.min.js.map +1 -1
  51. package/package.json +11 -11
  52. package/src/mediaelement.js +3 -0
  53. package/src/plugin/cursor/index.js +15 -3
  54. package/src/plugin/markers/index.js +40 -1
  55. package/src/plugin/regions/index.js +4 -0
  56. package/src/plugin/regions/region.js +76 -1
  57. package/src/util/silence-mode.js +7 -0
  58. package/src/wavesurfer.js +4 -0
  59. package/CHANGES.md +0 -482
@@ -1 +1 @@
1
- {"version":3,"file":"wavesurfer.microphone.min.js","mappings":";;;;;CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,aAAc,GAAIH,GACC,iBAAZC,QACdA,QAAoB,WAAID,KAExBD,EAAiB,WAAIA,EAAiB,YAAK,CAAC,EAAGA,EAAiB,WAAc,W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QAAUlF,KAAKmF,eAClBzE,UAAU0E,UACV,qBACA,GAEJJ,EAAOK,WAAa,MACbL,GAEPC,OAAOK,mBACP5E,UAAU0E,UAAUP,MAAM,yBAG1BG,EAAO5E,QAAU,SACjB4E,EAAOK,WAAa,GACpBL,EAAOE,QAAUlF,KAAKmF,eAClBzE,UAAU0E,UACV,uBACA,GAEGJ,IAIXA,EAAO5E,QAAU,2BACV4E,IAtDHA,EAAO5E,QAAU,2BACV4E,EAsDd,M,gFApXgBnF,G,kCCxCjB0F,EAA2B,CAAC,ECEhC,IAAIC,EDCJ,SAASC,EAAoBC,GAE5B,IAAIC,EAAeJ,EAAyBG,GAC5C,QAAqBjF,IAAjBkF,EACH,OAAOA,EAAanG,QAGrB,IAAIC,EAAS8F,EAAyBG,GAAY,CAGjDlG,QAAS,CAAC,GAOX,OAHAoG,EAAoBF,GAAUjG,EAAQA,EAAOD,QAASiG,GAG/ChG,EAAOD,OACf,CCnB0BiG,CAAoB,K,UHO9C","sources":["webpack://WaveSurfer/webpack/universalModuleDefinition","webpack://WaveSurfer/./src/plugin/microphone/index.js","webpack://WaveSurfer/webpack/bootstrap","webpack://WaveSurfer/webpack/startup"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"WaveSurfer\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"WaveSurfer\"] = factory();\n\telse\n\t\troot[\"WaveSurfer\"] = root[\"WaveSurfer\"] || {}, root[\"WaveSurfer\"][\"microphone\"] = factory();\n})(self, () => {\nreturn ","/**\n * @typedef {Object} MicrophonePluginParams\n * @property {MediaStreamConstraints} constraints The constraints parameter is a\n * MediaStreamConstaints object with two members: video and audio, describing\n * the media types requested. Either or both must be specified.\n * @property {number} bufferSize=4096 The buffer size in units of sample-frames.\n * If specified, the bufferSize must be one of the following values: `256`,\n * `512`, `1024`, `2048`, `4096`, `8192`, `16384`\n * @property {number} numberOfInputChannels=1 Integer specifying the number of\n * channels for this node's input. Values of up to 32 are supported.\n * @property {number} numberOfOutputChannels=1 Integer specifying the number of\n * channels for this node's output.\n * @property {?boolean} deferInit Set to true to manually call\n * `initPlugin('microphone')`\n */\n\n/**\n * Visualize microphone input in a wavesurfer instance.\n *\n * @implements {PluginClass}\n * @extends {Observer}\n * @example\n * // es6\n * import MicrophonePlugin from 'wavesurfer.microphone.js';\n *\n * // commonjs\n * var MicrophonePlugin = require('wavesurfer.microphone.js');\n *\n * // if you are using <script> tags\n * var MicrophonePlugin = window.WaveSurfer.microphone;\n *\n * // ... initialising wavesurfer with the plugin\n * var wavesurfer = WaveSurfer.create({\n * // wavesurfer options ...\n * plugins: [\n * MicrophonePlugin.create({\n * // plugin options ...\n * })\n * ]\n * });\n */\nexport default class MicrophonePlugin {\n /**\n * Microphone plugin definition factory\n *\n * This function must be used to create a plugin definition which can be\n * used by wavesurfer to correctly instantiate the plugin.\n *\n * @param {MicrophonePluginParams} params parameters use to initialise the plugin\n * @return {PluginDefinition} an object representing the plugin\n */\n static create(params) {\n return {\n name: 'microphone',\n deferInit: params && params.deferInit ? params.deferInit : false,\n params: params,\n instance: MicrophonePlugin\n };\n }\n\n constructor(params, ws) {\n this.params = params;\n this.wavesurfer = ws;\n\n this.active = false;\n this.paused = false;\n this.browser = this.detectBrowser();\n this.reloadBufferFunction = e => this.reloadBuffer(e);\n\n // cross-browser getUserMedia\n const promisifiedOldGUM = (\n constraints,\n successCallback,\n errorCallback\n ) => {\n // get a hold of getUserMedia, if present\n const getUserMedia =\n navigator.getUserMedia ||\n navigator.webkitGetUserMedia ||\n navigator.mozGetUserMedia ||\n navigator.msGetUserMedia;\n // Some browsers just don't implement it - return a rejected\n // promise with an error to keep a consistent interface\n if (!getUserMedia) {\n return Promise.reject(\n new Error('getUserMedia is not implemented in this browser')\n );\n }\n // otherwise, wrap the call to the old navigator.getUserMedia with\n // a Promise\n return new Promise((successCallback, errorCallback) => {\n getUserMedia.call(\n navigator,\n constraints,\n successCallback,\n errorCallback\n );\n });\n };\n // Older browsers might not implement mediaDevices at all, so we set an\n // empty object first\n if (navigator.mediaDevices === undefined) {\n navigator.mediaDevices = {};\n }\n // Some browsers partially implement mediaDevices. We can't just assign\n // an object with getUserMedia as it would overwrite existing\n // properties. Here, we will just add the getUserMedia property if it's\n // missing.\n if (navigator.mediaDevices.getUserMedia === undefined) {\n navigator.mediaDevices.getUserMedia = promisifiedOldGUM;\n }\n this.constraints = this.params.constraints || {\n video: false,\n audio: true\n };\n this.bufferSize = this.params.bufferSize || 4096;\n this.numberOfInputChannels = this.params.numberOfInputChannels || 1;\n this.numberOfOutputChannels = this.params.numberOfOutputChannels || 1;\n\n this._onBackendCreated = () => {\n // wavesurfer's AudioContext where we'll route the mic signal to\n this.micContext = this.wavesurfer.backend.getAudioContext();\n };\n }\n\n init() {\n this.wavesurfer.on('backend-created', this._onBackendCreated);\n if (this.wavesurfer.backend) {\n this._onBackendCreated();\n }\n }\n\n /**\n * Destroy the microphone plugin.\n */\n destroy() {\n // make sure the buffer is not redrawn during\n // cleanup and demolition of this plugin.\n this.paused = true;\n\n this.wavesurfer.un('backend-created', this._onBackendCreated);\n this.stop();\n }\n\n /**\n * Allow user to select audio input device, e.g. microphone, and\n * start the visualization.\n */\n start() {\n navigator.mediaDevices\n .getUserMedia(this.constraints)\n .then(data => this.gotStream(data))\n .catch(data => this.deviceError(data));\n }\n\n /**\n * Pause/resume visualization.\n */\n togglePlay() {\n if (!this.active) {\n // start it first\n this.start();\n } else {\n // toggle paused\n this.paused = !this.paused;\n\n if (this.paused) {\n this.pause();\n } else {\n this.play();\n }\n }\n }\n\n /**\n * Play visualization.\n */\n play() {\n this.paused = false;\n\n this.connect();\n }\n\n /**\n * Pause visualization.\n */\n pause() {\n this.paused = true;\n\n // disconnect sources so they can be used elsewhere\n // (eg. during audio playback)\n this.disconnect();\n }\n\n /**\n * Stop the device stream and remove any remaining waveform drawing from\n * the wavesurfer canvas.\n */\n stop() {\n if (this.active) {\n // stop visualization and device\n this.stopDevice();\n\n // empty last frame\n this.wavesurfer.empty();\n }\n }\n\n /**\n * Stop the device and the visualization.\n */\n stopDevice() {\n this.active = false;\n\n // stop visualization\n this.disconnect();\n\n // stop stream from device\n if (this.stream && this.stream.getTracks) {\n this.stream.getTracks().forEach(stream => stream.stop());\n }\n }\n\n /**\n * Connect the media sources that feed the visualization.\n */\n connect() {\n if (this.stream !== undefined) {\n // Create a local buffer for data to be copied to the Wavesurfer buffer for Edge\n if (this.browser.browser === 'edge') {\n this.localAudioBuffer = this.micContext.createBuffer(\n this.numberOfInputChannels,\n this.bufferSize,\n this.micContext.sampleRate\n );\n }\n\n // Create an AudioNode from the stream.\n this.mediaStreamSource = this.micContext.createMediaStreamSource(\n this.stream\n );\n\n this.levelChecker = this.micContext.createScriptProcessor(\n this.bufferSize,\n this.numberOfInputChannels,\n this.numberOfOutputChannels\n );\n this.mediaStreamSource.connect(this.levelChecker);\n\n this.levelChecker.connect(this.micContext.destination);\n this.levelChecker.onaudioprocess = this.reloadBufferFunction;\n }\n }\n\n /**\n * Disconnect the media sources that feed the visualization.\n */\n disconnect() {\n if (this.mediaStreamSource !== undefined) {\n this.mediaStreamSource.disconnect();\n }\n\n if (this.levelChecker !== undefined) {\n this.levelChecker.disconnect();\n this.levelChecker.onaudioprocess = undefined;\n }\n\n if (this.localAudioBuffer !== undefined) {\n this.localAudioBuffer = undefined;\n }\n }\n\n /**\n * Redraw the waveform.\n *\n * @param {object} event Audioprocess event\n */\n reloadBuffer(event) {\n if (!this.paused) {\n this.wavesurfer.empty();\n\n if (this.browser.browser === 'edge') {\n // copy audio data to a local audio buffer,\n // from https://github.com/audiojs/audio-buffer-utils\n let channel, l;\n for (\n channel = 0,\n l = Math.min(\n this.localAudioBuffer.numberOfChannels,\n event.inputBuffer.numberOfChannels\n );\n channel < l;\n channel++\n ) {\n this.localAudioBuffer\n .getChannelData(channel)\n .set(event.inputBuffer.getChannelData(channel));\n }\n\n this.wavesurfer.loadDecodedBuffer(this.localAudioBuffer);\n } else {\n this.wavesurfer.loadDecodedBuffer(event.inputBuffer);\n }\n }\n }\n\n /**\n * Audio input device is ready.\n *\n * @param {MediaStream} stream The microphone's media stream.\n */\n gotStream(stream) {\n this.stream = stream;\n this.active = true;\n\n // start visualization\n this.play();\n\n // notify listeners\n this.fireEvent('deviceReady', stream);\n }\n\n /**\n * Device error callback.\n *\n * @param {string} code Error message\n */\n deviceError(code) {\n // notify listeners\n this.fireEvent('deviceError', code);\n }\n\n /**\n * Extract browser version out of the provided user agent string.\n * @param {!string} uastring userAgent string.\n * @param {!string} expr Regular expression used as match criteria.\n * @param {!number} pos position in the version string to be returned.\n * @return {!number} browser version.\n */\n extractVersion(uastring, expr, pos) {\n const match = uastring.match(expr);\n return match && match.length >= pos && parseInt(match[pos], 10);\n }\n\n /**\n * Browser detector.\n * @return {object} result containing browser, version and minVersion\n * properties.\n */\n detectBrowser() {\n // Returned result object.\n const result = {};\n result.browser = null;\n result.version = null;\n result.minVersion = null;\n\n // Non supported browser.\n if (typeof window === 'undefined' || !window.navigator) {\n result.browser = 'Not a supported browser.';\n return result;\n }\n\n if (navigator.mozGetUserMedia) {\n // Firefox\n result.browser = 'firefox';\n result.version = this.extractVersion(\n navigator.userAgent,\n /Firefox\\/(\\d+)\\./,\n 1\n );\n result.minVersion = 31;\n return result;\n } else if (navigator.webkitGetUserMedia) {\n // Chrome/Chromium/Webview/Opera\n result.browser = 'chrome';\n result.version = this.extractVersion(\n navigator.userAgent,\n /Chrom(e|ium)\\/(\\d+)\\./,\n 2\n );\n result.minVersion = 38;\n return result;\n } else if (\n navigator.mediaDevices &&\n navigator.userAgent.match(/Edge\\/(\\d+).(\\d+)$/)\n ) {\n // Edge\n result.browser = 'edge';\n result.version = this.extractVersion(\n navigator.userAgent,\n /Edge\\/(\\d+).(\\d+)$/,\n 2\n );\n result.minVersion = 10547;\n return result;\n } else if (\n window.RTCPeerConnection &&\n navigator.userAgent.match(/AppleWebKit\\/(\\d+)\\./)\n ) {\n // Safari\n result.browser = 'safari';\n result.minVersion = 11;\n result.version = this.extractVersion(\n navigator.userAgent,\n /AppleWebKit\\/(\\d+)\\./,\n 1\n );\n return result;\n }\n\n // Non supported browser default.\n result.browser = 'Not a supported browser.';\n return result;\n }\n}\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// startup\n// Load entry module and return exports\n// This entry module is referenced by other modules so it can't be inlined\nvar __webpack_exports__ = __webpack_require__(872);\n"],"names":["root","factory","exports","module","define","amd","self","MicrophonePlugin","params","ws","this","wavesurfer","active","paused","browser","detectBrowser","reloadBufferFunction","e","reloadBuffer","undefined","navigator","mediaDevices","getUserMedia","constraints","successCallback","errorCallback","webkitGetUserMedia","mozGetUserMedia","msGetUserMedia","Promise","call","reject","Error","video","audio","bufferSize","numberOfInputChannels","numberOfOutputChannels","_onBackendCreated","micContext","backend","getAudioContext","name","deferInit","instance","on","un","stop","then","data","gotStream","catch","deviceError","pause","play","start","connect","disconnect","stopDevice","empty","stream","getTracks","forEach","localAudioBuffer","createBuffer","sampleRate","mediaStreamSource","createMediaStreamSource","levelChecker","createScriptProcessor","destination","onaudioprocess","event","channel","l","Math","min","numberOfChannels","inputBuffer","getChannelData","set","loadDecodedBuffer","fireEvent","code","uastring","expr","pos","match","length","parseInt","result","window","version","extractVersion","userAgent","minVersion","RTCPeerConnection","__webpack_module_cache__","__webpack_exports__","__webpack_require__","moduleId","cachedModule","__webpack_modules__"],"sourceRoot":""}
1
+ {"version":3,"file":"wavesurfer.microphone.min.js","mappings":";;;;;CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,aAAc,GAAIH,GACC,iBAAZC,QACdA,QAAoB,WAAID,KAExBD,EAAiB,WAAIA,EAAiB,YAAK,CAAC,EAAGA,EAAiB,WAAc,WAAIC,IACnF,CATD,CASGK,MAAM,IACT,M,+yBCMA,IAyBqBC,EAAgB,WAmBjC,SAAAA,EAAYC,EAAQC,GAAI,IAAAC,EAAA,M,4FAAAC,CAAA,KAAAJ,GACpBK,KAAKJ,OAASA,EACdI,KAAKC,WAAaJ,EAElBG,KAAKE,QAAS,EACdF,KAAKG,QAAS,EACdH,KAAKI,QAAUJ,KAAKK,gBACpBL,KAAKM,qBAAuB,SAAAC,GAAC,OAAIT,EAAKU,aAAaD,EAAE,OAkCtBE,IAA3BC,UAAUC,eACVD,UAAUC,aAAe,CAAC,QAMcF,IAAxCC,UAAUC,aAAaC,eACvBF,UAAUC,aAAaC,aAvCD,SACtBC,EACAC,EACAC,GAGA,IAAMH,EACFF,UAAUE,cACVF,UAAUM,oBACVN,UAAUO,iBACVP,UAAUQ,eAGd,OAAKN,EAOE,IAAIO,SAAQ,SAACL,EAAiBC,GACjCH,EAAaQ,KACTV,UACAG,EACAC,EACAC,EAER,IAbWI,QAAQE,OACX,IAAIC,MAAM,mDAatB,GAaAtB,KAAKa,YAAcb,KAAKJ,OAAOiB,aAAe,CAC1CU,OAAO,EACPC,OAAO,GAEXxB,KAAKyB,WAAazB,KAAKJ,OAAO6B,YAAc,KAC5CzB,KAAK0B,sBAAwB1B,KAAKJ,OAAO8B,uBAAyB,EAClE1B,KAAK2B,uBAAyB3B,KAAKJ,OAAO+B,wBAA0B,EAEpE3B,KAAK4B,kBAAoB,WAErB9B,EAAK+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AAoBC,GAE5B,IAAIC,EAAeJ,EAAyBG,GAC5C,QAAqBrF,IAAjBsF,EACH,OAAOA,EAAazG,QAGrB,IAAIC,EAASoG,EAAyBG,GAAY,CAGjDxG,QAAS,CAAC,GAOX,OAHA0G,EAAoBF,GAAUvG,EAAQA,EAAOD,QAASuG,GAG/CtG,EAAOD,OACf,CCnB0BuG,CAAoB,K,UHO9C","sources":["webpack://WaveSurfer/webpack/universalModuleDefinition","webpack://WaveSurfer/./src/plugin/microphone/index.js","webpack://WaveSurfer/webpack/bootstrap","webpack://WaveSurfer/webpack/startup"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"WaveSurfer\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"WaveSurfer\"] = factory();\n\telse\n\t\troot[\"WaveSurfer\"] = root[\"WaveSurfer\"] || {}, root[\"WaveSurfer\"][\"microphone\"] = factory();\n})(self, () => {\nreturn ","/**\n * @typedef {Object} MicrophonePluginParams\n * @property {MediaStreamConstraints} constraints The constraints parameter is a\n * MediaStreamConstaints object with two members: video and audio, describing\n * the media types requested. Either or both must be specified.\n * @property {number} bufferSize=4096 The buffer size in units of sample-frames.\n * If specified, the bufferSize must be one of the following values: `256`,\n * `512`, `1024`, `2048`, `4096`, `8192`, `16384`\n * @property {number} numberOfInputChannels=1 Integer specifying the number of\n * channels for this node's input. Values of up to 32 are supported.\n * @property {number} numberOfOutputChannels=1 Integer specifying the number of\n * channels for this node's output.\n * @property {?boolean} deferInit Set to true to manually call\n * `initPlugin('microphone')`\n */\n\n/**\n * Visualize microphone input in a wavesurfer instance.\n *\n * @implements {PluginClass}\n * @extends {Observer}\n * @example\n * // es6\n * import MicrophonePlugin from 'wavesurfer.microphone.js';\n *\n * // commonjs\n * var MicrophonePlugin = require('wavesurfer.microphone.js');\n *\n * // if you are using <script> tags\n * var MicrophonePlugin = window.WaveSurfer.microphone;\n *\n * // ... initialising wavesurfer with the plugin\n * var wavesurfer = WaveSurfer.create({\n * // wavesurfer options ...\n * plugins: [\n * MicrophonePlugin.create({\n * // plugin options ...\n * })\n * ]\n * });\n */\nexport default class MicrophonePlugin {\n /**\n * Microphone plugin definition factory\n *\n * This function must be used to create a plugin definition which can be\n * used by wavesurfer to correctly instantiate the plugin.\n *\n * @param {MicrophonePluginParams} params parameters use to initialise the plugin\n * @return {PluginDefinition} an object representing the plugin\n */\n static create(params) {\n return {\n name: 'microphone',\n deferInit: params && params.deferInit ? params.deferInit : false,\n params: params,\n instance: MicrophonePlugin\n };\n }\n\n constructor(params, ws) {\n this.params = params;\n this.wavesurfer = ws;\n\n this.active = false;\n this.paused = false;\n this.browser = this.detectBrowser();\n this.reloadBufferFunction = e => this.reloadBuffer(e);\n\n // cross-browser getUserMedia\n const promisifiedOldGUM = (\n constraints,\n successCallback,\n errorCallback\n ) => {\n // get a hold of getUserMedia, if present\n const getUserMedia =\n navigator.getUserMedia ||\n navigator.webkitGetUserMedia ||\n navigator.mozGetUserMedia ||\n navigator.msGetUserMedia;\n // Some browsers just don't implement it - return a rejected\n // promise with an error to keep a consistent interface\n if (!getUserMedia) {\n return Promise.reject(\n new Error('getUserMedia is not implemented in this browser')\n );\n }\n // otherwise, wrap the call to the old navigator.getUserMedia with\n // a Promise\n return new Promise((successCallback, errorCallback) => {\n getUserMedia.call(\n navigator,\n constraints,\n successCallback,\n errorCallback\n );\n });\n };\n // Older browsers might not implement mediaDevices at all, so we set an\n // empty object first\n if (navigator.mediaDevices === undefined) {\n navigator.mediaDevices = {};\n }\n // Some browsers partially implement mediaDevices. We can't just assign\n // an object with getUserMedia as it would overwrite existing\n // properties. Here, we will just add the getUserMedia property if it's\n // missing.\n if (navigator.mediaDevices.getUserMedia === undefined) {\n navigator.mediaDevices.getUserMedia = promisifiedOldGUM;\n }\n this.constraints = this.params.constraints || {\n video: false,\n audio: true\n };\n this.bufferSize = this.params.bufferSize || 4096;\n this.numberOfInputChannels = this.params.numberOfInputChannels || 1;\n this.numberOfOutputChannels = this.params.numberOfOutputChannels || 1;\n\n this._onBackendCreated = () => {\n // wavesurfer's AudioContext where we'll route the mic signal to\n this.micContext = this.wavesurfer.backend.getAudioContext();\n };\n }\n\n init() {\n this.wavesurfer.on('backend-created', this._onBackendCreated);\n if (this.wavesurfer.backend) {\n this._onBackendCreated();\n }\n }\n\n /**\n * Destroy the microphone plugin.\n */\n destroy() {\n // make sure the buffer is not redrawn during\n // cleanup and demolition of this plugin.\n this.paused = true;\n\n this.wavesurfer.un('backend-created', this._onBackendCreated);\n this.stop();\n }\n\n /**\n * Allow user to select audio input device, e.g. microphone, and\n * start the visualization.\n */\n start() {\n navigator.mediaDevices\n .getUserMedia(this.constraints)\n .then(data => this.gotStream(data))\n .catch(data => this.deviceError(data));\n }\n\n /**\n * Pause/resume visualization.\n */\n togglePlay() {\n if (!this.active) {\n // start it first\n this.start();\n } else {\n // toggle paused\n this.paused = !this.paused;\n\n if (this.paused) {\n this.pause();\n } else {\n this.play();\n }\n }\n }\n\n /**\n * Play visualization.\n */\n play() {\n this.paused = false;\n\n this.connect();\n }\n\n /**\n * Pause visualization.\n */\n pause() {\n this.paused = true;\n\n // disconnect sources so they can be used elsewhere\n // (eg. during audio playback)\n this.disconnect();\n }\n\n /**\n * Stop the device stream and remove any remaining waveform drawing from\n * the wavesurfer canvas.\n */\n stop() {\n if (this.active) {\n // stop visualization and device\n this.stopDevice();\n\n // empty last frame\n this.wavesurfer.empty();\n }\n }\n\n /**\n * Stop the device and the visualization.\n */\n stopDevice() {\n this.active = false;\n\n // stop visualization\n this.disconnect();\n\n // stop stream from device\n if (this.stream && this.stream.getTracks) {\n this.stream.getTracks().forEach(stream => stream.stop());\n }\n }\n\n /**\n * Connect the media sources that feed the visualization.\n */\n connect() {\n if (this.stream !== undefined) {\n // Create a local buffer for data to be copied to the Wavesurfer buffer for Edge\n if (this.browser.browser === 'edge') {\n this.localAudioBuffer = this.micContext.createBuffer(\n this.numberOfInputChannels,\n this.bufferSize,\n this.micContext.sampleRate\n );\n }\n\n // Create an AudioNode from the stream.\n this.mediaStreamSource = this.micContext.createMediaStreamSource(\n this.stream\n );\n\n this.levelChecker = this.micContext.createScriptProcessor(\n this.bufferSize,\n this.numberOfInputChannels,\n this.numberOfOutputChannels\n );\n this.mediaStreamSource.connect(this.levelChecker);\n\n this.levelChecker.connect(this.micContext.destination);\n this.levelChecker.onaudioprocess = this.reloadBufferFunction;\n }\n }\n\n /**\n * Disconnect the media sources that feed the visualization.\n */\n disconnect() {\n if (this.mediaStreamSource !== undefined) {\n this.mediaStreamSource.disconnect();\n }\n\n if (this.levelChecker !== undefined) {\n this.levelChecker.disconnect();\n this.levelChecker.onaudioprocess = undefined;\n }\n\n if (this.localAudioBuffer !== undefined) {\n this.localAudioBuffer = undefined;\n }\n }\n\n /**\n * Redraw the waveform.\n *\n * @param {object} event Audioprocess event\n */\n reloadBuffer(event) {\n if (!this.paused) {\n this.wavesurfer.empty();\n\n if (this.browser.browser === 'edge') {\n // copy audio data to a local audio buffer,\n // from https://github.com/audiojs/audio-buffer-utils\n let channel, l;\n for (\n channel = 0,\n l = Math.min(\n this.localAudioBuffer.numberOfChannels,\n event.inputBuffer.numberOfChannels\n );\n channel < l;\n channel++\n ) {\n this.localAudioBuffer\n .getChannelData(channel)\n .set(event.inputBuffer.getChannelData(channel));\n }\n\n this.wavesurfer.loadDecodedBuffer(this.localAudioBuffer);\n } else {\n this.wavesurfer.loadDecodedBuffer(event.inputBuffer);\n }\n }\n }\n\n /**\n * Audio input device is ready.\n *\n * @param {MediaStream} stream The microphone's media stream.\n */\n gotStream(stream) {\n this.stream = stream;\n this.active = true;\n\n // start visualization\n this.play();\n\n // notify listeners\n this.fireEvent('deviceReady', stream);\n }\n\n /**\n * Device error callback.\n *\n * @param {string} code Error message\n */\n deviceError(code) {\n // notify listeners\n this.fireEvent('deviceError', code);\n }\n\n /**\n * Extract browser version out of the provided user agent string.\n * @param {!string} uastring userAgent string.\n * @param {!string} expr Regular expression used as match criteria.\n * @param {!number} pos position in the version string to be returned.\n * @return {!number} browser version.\n */\n extractVersion(uastring, expr, pos) {\n const match = uastring.match(expr);\n return match && match.length >= pos && parseInt(match[pos], 10);\n }\n\n /**\n * Browser detector.\n * @return {object} result containing browser, version and minVersion\n * properties.\n */\n detectBrowser() {\n // Returned result object.\n const result = {};\n result.browser = null;\n result.version = null;\n result.minVersion = null;\n\n // Non supported browser.\n if (typeof window === 'undefined' || !window.navigator) {\n result.browser = 'Not a supported browser.';\n return result;\n }\n\n if (navigator.mozGetUserMedia) {\n // Firefox\n result.browser = 'firefox';\n result.version = this.extractVersion(\n navigator.userAgent,\n /Firefox\\/(\\d+)\\./,\n 1\n );\n result.minVersion = 31;\n return result;\n } else if (navigator.webkitGetUserMedia) {\n // Chrome/Chromium/Webview/Opera\n result.browser = 'chrome';\n result.version = this.extractVersion(\n navigator.userAgent,\n /Chrom(e|ium)\\/(\\d+)\\./,\n 2\n );\n result.minVersion = 38;\n return result;\n } else if (\n navigator.mediaDevices &&\n navigator.userAgent.match(/Edge\\/(\\d+).(\\d+)$/)\n ) {\n // Edge\n result.browser = 'edge';\n result.version = this.extractVersion(\n navigator.userAgent,\n /Edge\\/(\\d+).(\\d+)$/,\n 2\n );\n result.minVersion = 10547;\n return result;\n } else if (\n window.RTCPeerConnection &&\n navigator.userAgent.match(/AppleWebKit\\/(\\d+)\\./)\n ) {\n // Safari\n result.browser = 'safari';\n result.minVersion = 11;\n result.version = this.extractVersion(\n navigator.userAgent,\n /AppleWebKit\\/(\\d+)\\./,\n 1\n );\n return result;\n }\n\n // Non supported browser default.\n result.browser = 'Not a supported browser.';\n return result;\n }\n}\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// startup\n// Load entry module and return exports\n// This entry module is referenced by other modules so it can't be inlined\nvar __webpack_exports__ = __webpack_require__(872);\n"],"names":["root","factory","exports","module","define","amd","self","MicrophonePlugin","params","ws","_this","_classCallCheck","this","wavesurfer","active","paused","browser","detectBrowser","reloadBufferFunction","e","reloadBuffer","undefined","navigator","mediaDevices","getUserMedia","constraints","successCallback","errorCallback","webkitGetUserMedia","mozGetUserMedia","msGetUserMedia","Promise","call","reject","Error","video","audio","bufferSize","numberOfInputChannels","numberOfOutputChannels","_onBackendCreated","micContext","backend","getAudioContext","key","value","name","deferInit","instance","on","un","stop","_this2","then","data","gotStream","catch","deviceError","pause","play","start","connect","disconnect","stopDevice","empty","stream","getTracks","forEach","localAudioBuffer","createBuffer","sampleRate","mediaStreamSource","createMediaStreamSource","levelChecker","createScriptProcessor","destination","onaudioprocess","event","channel","l","Math","min","numberOfChannels","inputBuffer","getChannelData","set","loadDecodedBuffer","fireEvent","code","uastring","expr","pos","match","length","parseInt","result","window","version","extractVersion","userAgent","minVersion","RTCPeerConnection","default","__webpack_module_cache__","__webpack_exports__","__webpack_require__","moduleId","cachedModule","__webpack_modules__"],"sourceRoot":""}
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * wavesurfer.js minimap plugin 6.3.0 (2022-10-03)
2
+ * wavesurfer.js minimap plugin 6.5.0 (2023-03-11)
3
3
  * https://wavesurfer-js.org
4
4
  * @license BSD-3-Clause
5
5
  */
@@ -29,15 +29,13 @@ Object.defineProperty(exports, "__esModule", ({
29
29
  value: true
30
30
  }));
31
31
  exports["default"] = void 0;
32
-
32
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
33
33
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
34
-
35
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
36
-
34
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
37
35
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
38
-
36
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
37
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
39
38
  /*eslint no-console: ["error", { allow: ["warn"] }] */
40
-
41
39
  /**
42
40
  * @typedef {Object} MinimapPluginParams
43
41
  * @desc Extends the `WavesurferParams` wavesurfer was initialised with
@@ -47,7 +45,6 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
47
45
  * @property {?boolean} deferInit Set to true to manually call
48
46
  * `initPlugin('minimap')`
49
47
  */
50
-
51
48
  /**
52
49
  * Renders a smaller version waveform as a minimap of the main waveform.
53
50
  *
@@ -76,9 +73,7 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
76
73
  var MinimapPlugin = /*#__PURE__*/function () {
77
74
  function MinimapPlugin(params, ws) {
78
75
  var _this = this;
79
-
80
76
  _classCallCheck(this, MinimapPlugin);
81
-
82
77
  this.params = Object.assign({}, ws.params, {
83
78
  showRegions: false,
84
79
  regionsPluginName: params.regionsPluginName || 'regions',
@@ -91,25 +86,21 @@ var MinimapPlugin = /*#__PURE__*/function () {
91
86
  }, params, {
92
87
  scrollParent: false,
93
88
  fillParent: true
94
- }); // if container is a selector, get the element
95
-
89
+ });
90
+ // if container is a selector, get the element
96
91
  if (typeof params.container === 'string') {
97
92
  var el = document.querySelector(params.container);
98
-
99
93
  if (!el) {
100
94
  console.warn("Wavesurfer minimap container ".concat(params.container, " was not found! The minimap will be automatically appended below the waveform."));
101
95
  }
102
-
103
96
  this.params.container = el;
104
- } // if no container is specified add a new element and insert it
105
-
106
-
97
+ }
98
+ // if no container is specified add a new element and insert it
107
99
  if (!params.container) {
108
100
  this.params.container = ws.util.style(document.createElement('minimap'), {
109
101
  display: 'block'
110
102
  });
111
103
  }
112
-
113
104
  this.drawer = new ws.Drawer(this.params.container, this.params);
114
105
  this.wavesurfer = ws;
115
106
  this.util = ws.util;
@@ -119,97 +110,78 @@ var MinimapPlugin = /*#__PURE__*/function () {
119
110
  this.regionsPlugin = this.wavesurfer[this.params.regionsPluginName];
120
111
  this.drawer.createWrapper();
121
112
  this.createElements();
122
- var isInitialised = false; // ws ready event listener
113
+ var isInitialised = false;
123
114
 
115
+ // ws ready event listener
124
116
  this._onShouldRender = function () {
125
117
  // only bind the events in the first run
126
118
  if (!isInitialised) {
127
119
  _this.bindWavesurferEvents();
128
-
129
120
  _this.bindMinimapEvents();
130
-
131
121
  isInitialised = true;
132
- } // if there is no such element, append it to the container (below
122
+ }
123
+ // if there is no such element, append it to the container (below
133
124
  // the waveform)
134
-
135
-
136
125
  if (!document.body.contains(_this.params.container)) {
137
126
  ws.container.insertBefore(_this.params.container, null);
138
127
  }
139
-
140
128
  if (_this.regionsPlugin && _this.params.showRegions) {
141
129
  _this.drawRegions();
142
130
  }
143
-
144
131
  _this.render();
145
132
  };
146
-
147
133
  this._onAudioprocess = function (currentTime) {
148
134
  _this.drawer.progress(_this.wavesurfer.backend.getPlayedPercents());
149
- }; // ws seek event listener
150
-
135
+ };
151
136
 
137
+ // ws seek event listener
152
138
  this._onSeek = function () {
153
139
  return _this.drawer.progress(ws.backend.getPlayedPercents());
154
- }; // event listeners for the overview region
155
-
140
+ };
156
141
 
142
+ // event listeners for the overview region
157
143
  this._onScroll = function (e) {
158
144
  if (!_this.draggingOverview) {
159
145
  var orientedTarget = _this.util.withOrientation(e.target, _this.wavesurfer.params.vertical);
160
-
161
146
  _this.moveOverviewRegion(orientedTarget.scrollLeft / _this.ratio);
162
147
  }
163
148
  };
164
-
165
149
  this._onMouseover = function (e) {
166
150
  if (_this.draggingOverview) {
167
151
  _this.draggingOverview = false;
168
152
  }
169
153
  };
170
-
171
154
  var prevWidth = 0;
172
155
  this._onResize = ws.util.debounce(function () {
173
156
  if (prevWidth != _this.drawer.wrapper.clientWidth) {
174
157
  prevWidth = _this.drawer.wrapper.clientWidth;
175
-
176
158
  _this.render();
177
-
178
159
  _this.drawer.progress(_this.wavesurfer.backend.getPlayedPercents());
179
160
  }
180
161
  });
181
-
182
162
  this._onLoading = function (percent) {
183
163
  if (percent >= 100) {
184
164
  _this.cleared = false;
185
165
  return;
186
166
  }
187
-
188
167
  if (_this.cleared === true) {
189
168
  return;
190
169
  }
191
-
192
170
  var len = _this.drawer.getWidth();
193
-
194
171
  _this.drawer.drawPeaks([0], len, 0, len);
195
-
196
172
  _this.cleared = true;
197
173
  };
198
-
199
174
  this._onZoom = function (e) {
200
175
  _this.render();
201
176
  };
202
-
203
177
  this.wavesurfer.on('zoom', this._onZoom);
204
178
  }
205
-
206
179
  _createClass(MinimapPlugin, [{
207
180
  key: "init",
208
181
  value: function init() {
209
182
  if (this.wavesurfer.isReady) {
210
183
  this._onShouldRender();
211
184
  }
212
-
213
185
  this.wavesurfer.on(this.renderEvent, this._onShouldRender);
214
186
  }
215
187
  }, {
@@ -232,7 +204,6 @@ var MinimapPlugin = /*#__PURE__*/function () {
232
204
  key: "drawRegions",
233
205
  value: function drawRegions() {
234
206
  var _this2 = this;
235
-
236
207
  this.regions = {};
237
208
  this.wavesurfer.on('region-created', function (region) {
238
209
  _this2.regions[region.id] = region;
@@ -251,21 +222,15 @@ var MinimapPlugin = /*#__PURE__*/function () {
251
222
  key: "renderRegions",
252
223
  value: function renderRegions() {
253
224
  var _this3 = this;
254
-
255
225
  var regionElements = this.drawer.wrapper.querySelectorAll('region');
256
226
  var i;
257
-
258
227
  for (i = 0; i < regionElements.length; ++i) {
259
228
  this.drawer.wrapper.removeChild(regionElements[i]);
260
229
  }
261
-
262
230
  Object.keys(this.regions).forEach(function (id) {
263
231
  var region = _this3.regions[id];
264
-
265
232
  var width = _this3.getWidth() * ((region.end - region.start) / _this3.wavesurfer.getDuration());
266
-
267
233
  var left = _this3.getWidth() * (region.start / _this3.wavesurfer.getDuration());
268
-
269
234
  var regionElement = _this3.util.style(document.createElement('region'), {
270
235
  height: 'inherit',
271
236
  backgroundColor: region.color,
@@ -274,9 +239,7 @@ var MinimapPlugin = /*#__PURE__*/function () {
274
239
  display: 'block',
275
240
  position: 'absolute'
276
241
  });
277
-
278
242
  regionElement.classList.add(id);
279
-
280
243
  _this3.drawer.wrapper.appendChild(regionElement);
281
244
  });
282
245
  }
@@ -284,7 +247,6 @@ var MinimapPlugin = /*#__PURE__*/function () {
284
247
  key: "createElements",
285
248
  value: function createElements() {
286
249
  this.drawer.createElements();
287
-
288
250
  if (this.params.showOverview) {
289
251
  this.overviewRegion = this.util.withOrientation(this.drawer.wrapper.appendChild(document.createElement('overview')), this.wavesurfer.params.vertical);
290
252
  this.util.style(this.overviewRegion, {
@@ -308,7 +270,6 @@ var MinimapPlugin = /*#__PURE__*/function () {
308
270
  this.wavesurfer.on('audioprocess', this._onAudioprocess);
309
271
  this.wavesurfer.on('seek', this._onSeek);
310
272
  this.wavesurfer.on('loading', this._onLoading);
311
-
312
273
  if (this.params.showOverview) {
313
274
  this.wavesurfer.on('scroll', this._onScroll);
314
275
  this.wavesurfer.drawer.wrapper.addEventListener('mouseover', this._onMouseover);
@@ -318,16 +279,16 @@ var MinimapPlugin = /*#__PURE__*/function () {
318
279
  key: "bindMinimapEvents",
319
280
  value: function bindMinimapEvents() {
320
281
  var _this4 = this;
321
-
322
282
  var positionMouseDown = {
323
283
  clientX: 0,
324
284
  clientY: 0
325
285
  };
326
286
  var relativePositionX = 0;
327
- var seek = true; // the following event listeners will be destroyed by using
287
+ var seek = true;
288
+
289
+ // the following event listeners will be destroyed by using
328
290
  // this.unAll() and nullifying the DOM node references after
329
291
  // removing them
330
-
331
292
  if (this.params.interact) {
332
293
  this.drawer.wrapper.addEventListener('click', function (event) {
333
294
  _this4.fireEvent('click', event, _this4.drawer.handleEvent(event));
@@ -335,18 +296,15 @@ var MinimapPlugin = /*#__PURE__*/function () {
335
296
  this.on('click', function (event, position) {
336
297
  if (seek) {
337
298
  _this4.drawer.progress(position);
338
-
339
299
  _this4.wavesurfer.seekAndCenter(position);
340
300
  } else {
341
301
  seek = true;
342
302
  }
343
303
  });
344
304
  }
345
-
346
305
  if (this.params.showOverview) {
347
306
  this.overviewRegion.domElement.addEventListener('mousedown', function (e) {
348
307
  var event = _this4.util.withOrientation(e, _this4.wavesurfer.params.vertical);
349
-
350
308
  _this4.draggingOverview = true;
351
309
  relativePositionX = event.layerX;
352
310
  positionMouseDown.clientX = event.clientX;
@@ -355,13 +313,11 @@ var MinimapPlugin = /*#__PURE__*/function () {
355
313
  this.drawer.wrapper.addEventListener('mousemove', function (e) {
356
314
  if (_this4.draggingOverview) {
357
315
  var event = _this4.util.withOrientation(e, _this4.wavesurfer.params.vertical);
358
-
359
316
  _this4.moveOverviewRegion(event.clientX - _this4.drawer.container.getBoundingClientRect().left - relativePositionX);
360
317
  }
361
318
  });
362
319
  this.drawer.wrapper.addEventListener('mouseup', function (e) {
363
320
  var event = _this4.util.withOrientation(e, _this4.wavesurfer.params.vertical);
364
-
365
321
  if (positionMouseDown.clientX - event.clientX === 0 && positionMouseDown.clientX - event.clientX === 0) {
366
322
  seek = true;
367
323
  _this4.draggingOverview = false;
@@ -379,7 +335,6 @@ var MinimapPlugin = /*#__PURE__*/function () {
379
335
  var peaks = this.wavesurfer.backend.getPeaks(len, 0, len);
380
336
  this.drawer.drawPeaks(peaks, len, 0, len);
381
337
  this.drawer.progress(this.wavesurfer.backend.getPlayedPercents());
382
-
383
338
  if (this.params.showOverview) {
384
339
  //get proportional width of overview region considering the respective
385
340
  //width of the drawers
@@ -404,11 +359,9 @@ var MinimapPlugin = /*#__PURE__*/function () {
404
359
  } else {
405
360
  this.overviewPosition = this.drawer.container.offsetWidth - this.overviewWidth;
406
361
  }
407
-
408
362
  this.util.style(this.overviewRegion, {
409
363
  left: this.overviewPosition + 'px'
410
364
  });
411
-
412
365
  if (this.draggingOverview) {
413
366
  this.wavesurfer.drawer.wrapper.scrollLeft = this.overviewPosition * this.ratio;
414
367
  }
@@ -440,10 +393,8 @@ var MinimapPlugin = /*#__PURE__*/function () {
440
393
  };
441
394
  }
442
395
  }]);
443
-
444
396
  return MinimapPlugin;
445
397
  }();
446
-
447
398
  exports["default"] = MinimapPlugin;
448
399
  module.exports = exports.default;
449
400
 
@@ -1 +1 @@
1
- {"version":3,"file":"wavesurfer.minimap.js","mappings":";;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,+CAA+C;AAC/C,CAAC;AACD;;;;;;;;;;;;;;;;;;;;;;;ACVA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAC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AZ,GAAoB,KAAKzF,MAAL,CAAYkI,UAAvC;IACH;;;;IA5WD;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;IACI,gBAAclI,MAAd,EAAsB;MAClB,OAAO;QACHmI,IAAI,EAAE,SADH;QAEHC,SAAS,EAAEpI,MAAM,IAAIA,MAAM,CAACoI,SAAjB,GAA6BpI,MAAM,CAACoI,SAApC,GAAgD,KAFxD;QAGHpI,MAAM,EAAEA,MAHL;QAIHqI,WAAW,EAAE,EAJV;QAKHC,QAAQ,EAAEvI;MALP,CAAP;IAOH;;;;;;;;;;;;;UCtDL;UACA;;UAEA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;;UAEA;UACA;;UAEA;UACA;UACA;;;;UEtBA;UACA;UACA;UACA","sources":["webpack://WaveSurfer/webpack/universalModuleDefinition","webpack://WaveSurfer/./src/plugin/minimap/index.js","webpack://WaveSurfer/webpack/bootstrap","webpack://WaveSurfer/webpack/before-startup","webpack://WaveSurfer/webpack/startup","webpack://WaveSurfer/webpack/after-startup"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"WaveSurfer\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"WaveSurfer\"] = factory();\n\telse\n\t\troot[\"WaveSurfer\"] = root[\"WaveSurfer\"] || {}, root[\"WaveSurfer\"][\"minimap\"] = factory();\n})(self, () => {\nreturn ","/*eslint no-console: [\"error\", { allow: [\"warn\"] }] */\n/**\n * @typedef {Object} MinimapPluginParams\n * @desc Extends the `WavesurferParams` wavesurfer was initialised with\n * @property {?string|HTMLElement} container CSS selector or HTML element where\n * the map should be rendered. By default it is simply appended\n * after the waveform.\n * @property {?boolean} deferInit Set to true to manually call\n * `initPlugin('minimap')`\n */\n\n/**\n * Renders a smaller version waveform as a minimap of the main waveform.\n *\n * @implements {PluginClass}\n * @extends {Observer}\n * @example\n * // es6\n * import MinimapPlugin from 'wavesurfer.minimap.js';\n *\n * // commonjs\n * var MinimapPlugin = require('wavesurfer.minimap.js');\n *\n * // if you are using <script> tags\n * var MinimapPlugin = window.WaveSurfer.minimap;\n *\n * // ... initialising wavesurfer with the plugin\n * var wavesurfer = WaveSurfer.create({\n * // wavesurfer options ...\n * plugins: [\n * MinimapPlugin.create({\n * // plugin options ...\n * })\n * ]\n * });\n */\nexport default class MinimapPlugin {\n /**\n * Minimap plugin definition factory\n *\n * This function must be used to create a plugin definition which can be\n * used by wavesurfer to correctly instantiate the plugin.\n *\n * @param {MinimapPluginParams} params parameters use to initialise the plugin\n * @return {PluginDefinition} an object representing the plugin\n */\n static create(params) {\n return {\n name: 'minimap',\n deferInit: params && params.deferInit ? params.deferInit : false,\n params: params,\n staticProps: {},\n instance: MinimapPlugin\n };\n }\n\n constructor(params, ws) {\n this.params = Object.assign(\n {},\n ws.params,\n {\n showRegions: false,\n regionsPluginName: params.regionsPluginName || 'regions',\n showOverview: false,\n overviewBorderColor: 'green',\n overviewBorderSize: 2,\n // the container should be different\n container: false,\n height: Math.max(Math.round(ws.params.height / 4), 20)\n },\n params,\n {\n scrollParent: false,\n fillParent: true\n }\n );\n // if container is a selector, get the element\n if (typeof params.container === 'string') {\n const el = document.querySelector(params.container);\n if (!el) {\n console.warn(\n `Wavesurfer minimap container ${params.container} was not found! The minimap will be automatically appended below the waveform.`\n );\n }\n this.params.container = el;\n }\n // if no container is specified add a new element and insert it\n if (!params.container) {\n this.params.container = ws.util.style(\n document.createElement('minimap'),\n {\n display: 'block'\n }\n );\n }\n this.drawer = new ws.Drawer(this.params.container, this.params);\n this.wavesurfer = ws;\n this.util = ws.util;\n this.cleared = false;\n this.renderEvent = 'redraw';\n this.overviewRegion = null;\n this.regionsPlugin = this.wavesurfer[this.params.regionsPluginName];\n\n this.drawer.createWrapper();\n this.createElements();\n let isInitialised = false;\n\n // ws ready event listener\n this._onShouldRender = () => {\n // only bind the events in the first run\n if (!isInitialised) {\n this.bindWavesurferEvents();\n this.bindMinimapEvents();\n isInitialised = true;\n }\n // if there is no such element, append it to the container (below\n // the waveform)\n if (!document.body.contains(this.params.container)) {\n ws.container.insertBefore(this.params.container, null);\n }\n\n if (this.regionsPlugin && this.params.showRegions) {\n this.drawRegions();\n }\n this.render();\n };\n\n this._onAudioprocess = currentTime => {\n this.drawer.progress(this.wavesurfer.backend.getPlayedPercents());\n };\n\n // ws seek event listener\n this._onSeek = () =>\n this.drawer.progress(ws.backend.getPlayedPercents());\n\n // event listeners for the overview region\n this._onScroll = e => {\n if (!this.draggingOverview) {\n const orientedTarget = this.util.withOrientation(e.target, this.wavesurfer.params.vertical);\n this.moveOverviewRegion(orientedTarget.scrollLeft / this.ratio);\n }\n };\n this._onMouseover = e => {\n if (this.draggingOverview) {\n this.draggingOverview = false;\n }\n };\n let prevWidth = 0;\n this._onResize = ws.util.debounce(() => {\n if (prevWidth != this.drawer.wrapper.clientWidth) {\n prevWidth = this.drawer.wrapper.clientWidth;\n this.render();\n this.drawer.progress(\n this.wavesurfer.backend.getPlayedPercents()\n );\n }\n });\n this._onLoading = percent => {\n if (percent >= 100) {\n this.cleared = false;\n return;\n }\n if (this.cleared === true) {\n return;\n }\n const len = this.drawer.getWidth();\n this.drawer.drawPeaks([0], len, 0, len);\n this.cleared = true;\n };\n this._onZoom = e => {\n this.render();\n };\n this.wavesurfer.on('zoom', this._onZoom);\n }\n\n init() {\n if (this.wavesurfer.isReady) {\n this._onShouldRender();\n }\n this.wavesurfer.on(this.renderEvent, this._onShouldRender);\n }\n\n destroy() {\n window.removeEventListener('resize', this._onResize, true);\n window.removeEventListener('orientationchange', this._onResize, true);\n this.wavesurfer.drawer.wrapper.removeEventListener(\n 'mouseover',\n this._onMouseover\n );\n this.wavesurfer.un(this.renderEvent, this._onShouldRender);\n this.wavesurfer.un('seek', this._onSeek);\n this.wavesurfer.un('scroll', this._onScroll);\n this.wavesurfer.un('audioprocess', this._onAudioprocess);\n this.wavesurfer.un('zoom', this._onZoom);\n this.wavesurfer.un('loading', this._onLoading);\n this.drawer.destroy();\n this.overviewRegion = null;\n this.unAll();\n }\n\n drawRegions() {\n this.regions = {};\n\n this.wavesurfer.on('region-created', region => {\n this.regions[region.id] = region;\n this.drawer.wrapper && this.renderRegions();\n });\n\n this.wavesurfer.on('region-updated', region => {\n this.regions[region.id] = region;\n this.drawer.wrapper && this.renderRegions();\n });\n\n this.wavesurfer.on('region-removed', region => {\n delete this.regions[region.id];\n this.drawer.wrapper && this.renderRegions();\n });\n }\n\n renderRegions() {\n const regionElements = this.drawer.wrapper.querySelectorAll('region');\n let i;\n for (i = 0; i < regionElements.length; ++i) {\n this.drawer.wrapper.removeChild(regionElements[i]);\n }\n\n Object.keys(this.regions).forEach(id => {\n const region = this.regions[id];\n const width =\n this.getWidth() *\n ((region.end - region.start) / this.wavesurfer.getDuration());\n const left =\n this.getWidth() *\n (region.start / this.wavesurfer.getDuration());\n const regionElement = this.util.style(\n document.createElement('region'),\n {\n height: 'inherit',\n backgroundColor: region.color,\n width: width + 'px',\n left: left + 'px',\n display: 'block',\n position: 'absolute'\n }\n );\n regionElement.classList.add(id);\n this.drawer.wrapper.appendChild(regionElement);\n });\n }\n\n createElements() {\n this.drawer.createElements();\n if (this.params.showOverview) {\n this.overviewRegion = this.util.withOrientation(\n this.drawer.wrapper.appendChild(document.createElement('overview')),\n this.wavesurfer.params.vertical\n );\n\n this.util.style(\n this.overviewRegion,\n {\n top: 0,\n bottom: 0,\n width: '0px',\n display: 'block',\n position: 'absolute',\n cursor: 'move',\n border:\n this.params.overviewBorderSize +\n 'px solid ' +\n this.params.overviewBorderColor,\n zIndex: 2,\n opacity: this.params.overviewOpacity\n }\n );\n }\n }\n\n bindWavesurferEvents() {\n window.addEventListener('resize', this._onResize, true);\n window.addEventListener('orientationchange', this._onResize, true);\n this.wavesurfer.on('audioprocess', this._onAudioprocess);\n this.wavesurfer.on('seek', this._onSeek);\n this.wavesurfer.on('loading', this._onLoading);\n if (this.params.showOverview) {\n this.wavesurfer.on('scroll', this._onScroll);\n this.wavesurfer.drawer.wrapper.addEventListener(\n 'mouseover',\n this._onMouseover\n );\n }\n }\n\n bindMinimapEvents() {\n const positionMouseDown = {\n clientX: 0,\n clientY: 0\n };\n let relativePositionX = 0;\n let seek = true;\n\n // the following event listeners will be destroyed by using\n // this.unAll() and nullifying the DOM node references after\n // removing them\n if (this.params.interact) {\n this.drawer.wrapper.addEventListener('click', event => {\n this.fireEvent('click', event, this.drawer.handleEvent(event));\n });\n\n this.on('click', (event, position) => {\n if (seek) {\n this.drawer.progress(position);\n this.wavesurfer.seekAndCenter(position);\n } else {\n seek = true;\n }\n });\n }\n\n if (this.params.showOverview) {\n this.overviewRegion.domElement.addEventListener('mousedown', e => {\n const event = this.util.withOrientation(e, this.wavesurfer.params.vertical);\n this.draggingOverview = true;\n relativePositionX = event.layerX;\n positionMouseDown.clientX = event.clientX;\n positionMouseDown.clientY = event.clientY;\n });\n\n this.drawer.wrapper.addEventListener('mousemove', e => {\n if (this.draggingOverview) {\n const event = this.util.withOrientation(e, this.wavesurfer.params.vertical);\n this.moveOverviewRegion(\n event.clientX -\n this.drawer.container.getBoundingClientRect().left -\n relativePositionX\n );\n }\n });\n\n this.drawer.wrapper.addEventListener('mouseup', e => {\n const event = this.util.withOrientation(e, this.wavesurfer.params.vertical);\n if (\n positionMouseDown.clientX - event.clientX === 0 &&\n positionMouseDown.clientX - event.clientX === 0\n ) {\n seek = true;\n this.draggingOverview = false;\n } else if (this.draggingOverview) {\n seek = false;\n this.draggingOverview = false;\n }\n });\n }\n }\n\n render() {\n const len = this.drawer.getWidth();\n const peaks = this.wavesurfer.backend.getPeaks(len, 0, len);\n this.drawer.drawPeaks(peaks, len, 0, len);\n this.drawer.progress(this.wavesurfer.backend.getPlayedPercents());\n\n if (this.params.showOverview) {\n //get proportional width of overview region considering the respective\n //width of the drawers\n this.ratio = this.wavesurfer.drawer.width / this.drawer.width;\n this.waveShowedWidth = this.wavesurfer.drawer.width / this.ratio;\n this.waveWidth = this.wavesurfer.drawer.width;\n this.overviewWidth = this.drawer.container.offsetWidth / this.ratio;\n this.overviewPosition = 0;\n this.moveOverviewRegion(\n this.wavesurfer.drawer.wrapper.scrollLeft / this.ratio\n );\n this.util.style(this.overviewRegion, {\n width: this.overviewWidth + 'px'\n });\n }\n }\n\n moveOverviewRegion(pixels) {\n if (pixels < 0) {\n this.overviewPosition = 0;\n } else if (\n pixels + this.overviewWidth <\n this.drawer.container.offsetWidth\n ) {\n this.overviewPosition = pixels;\n } else {\n this.overviewPosition =\n this.drawer.container.offsetWidth - this.overviewWidth;\n }\n this.util.style(this.overviewRegion, {\n left: this.overviewPosition + 'px'\n });\n if (this.draggingOverview) {\n this.wavesurfer.drawer.wrapper.scrollLeft =\n this.overviewPosition * this.ratio;\n }\n }\n\n getWidth() {\n return this.drawer.width / this.params.pixelRatio;\n }\n}\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","","// startup\n// Load entry module and return exports\n// This entry module is referenced by other modules so it can't be inlined\nvar __webpack_exports__ = __webpack_require__(\"./src/plugin/minimap/index.js\");\n",""],"names":["MinimapPlugin","params","ws","Object","assign","showRegions","regionsPluginName","showOverview","overviewBorderColor","overviewBorderSize","container","height","Math","max","round","scrollParent","fillParent","el","document","querySelector","console","warn","util","style","createElement","display","drawer","Drawer","wavesurfer","cleared","renderEvent","overviewRegion","regionsPlugin","createWrapper","createElements","isInitialised","_onShouldRender","bindWavesurferEvents","bindMinimapEvents","body","contains","insertBefore","drawRegions","render","_onAudioprocess","currentTime","progress","backend","getPlayedPercents","_onSeek","_onScroll","e","draggingOverview","orientedTarget","withOrientation","target","vertical","moveOverviewRegion","scrollLeft","ratio","_onMouseover","prevWidth","_onResize","debounce","wrapper","clientWidth","_onLoading","percent","len","getWidth","drawPeaks","_onZoom","on","isReady","window","removeEventListener","un","destroy","unAll","regions","region","id","renderRegions","regionElements","querySelectorAll","i","length","removeChild","keys","forEach","width","end","start","getDuration","left","regionElement","backgroundColor","color","position","classList","add","appendChild","top","bottom","cursor","border","zIndex","opacity","overviewOpacity","addEventListener","positionMouseDown","clientX","clientY","relativePositionX","seek","interact","event","fireEvent","handleEvent","seekAndCenter","domElement","layerX","getBoundingClientRect","peaks","getPeaks","waveShowedWidth","waveWidth","overviewWidth","offsetWidth","overviewPosition","pixels","pixelRatio","name","deferInit","staticProps","instance"],"sourceRoot":""}
1
+ {"version":3,"file":"wavesurfer.minimap.js","mappings":";;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,+CAA+C;AAC/C,CAAC;AACD;;;;;;;;;;;;;;;;;;;;;;ACVA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAxBA,IAyBqBA,aAAa;EAoB9B,SAAAA,cAAYC,MAAM,EAAEC,EAAE,EAAE;IAAA,IAAAC,KAAA;IAAAC,eAAA,OAAAJ,aAAA;IACpB,IAAI,CAACC,MAAM,GAAGI,MAAM,CAACC,MAAM,CACvB,CAAC,CAAC,EACFJ,EAAE,CAACD,MAAM,EACT;MACIM,WAAW,EAAE,KAAK;MAClBC,iBAAiB,EAAEP,MAAM,CAACO,iBAAiB,IAAI,SAAS;MACxDC,YAA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AA,OAAAA,aAAA;AAAA;AAAAmJ,kBAAA,GAAAnJ,aAAA;AAAAqJ,MAAA,CAAAF,OAAA,GAAAA,OAAA,CAAAC,OAAA;;;;;;UCtDL;UACA;;UAEA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;;UAEA;UACA;;UAEA;UACA;UACA;;;;UEtBA;UACA;UACA;UACA","sources":["webpack://WaveSurfer/webpack/universalModuleDefinition","webpack://WaveSurfer/./src/plugin/minimap/index.js","webpack://WaveSurfer/webpack/bootstrap","webpack://WaveSurfer/webpack/before-startup","webpack://WaveSurfer/webpack/startup","webpack://WaveSurfer/webpack/after-startup"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"WaveSurfer\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"WaveSurfer\"] = factory();\n\telse\n\t\troot[\"WaveSurfer\"] = root[\"WaveSurfer\"] || {}, root[\"WaveSurfer\"][\"minimap\"] = factory();\n})(self, () => {\nreturn ","/*eslint no-console: [\"error\", { allow: [\"warn\"] }] */\n/**\n * @typedef {Object} MinimapPluginParams\n * @desc Extends the `WavesurferParams` wavesurfer was initialised with\n * @property {?string|HTMLElement} container CSS selector or HTML element where\n * the map should be rendered. By default it is simply appended\n * after the waveform.\n * @property {?boolean} deferInit Set to true to manually call\n * `initPlugin('minimap')`\n */\n\n/**\n * Renders a smaller version waveform as a minimap of the main waveform.\n *\n * @implements {PluginClass}\n * @extends {Observer}\n * @example\n * // es6\n * import MinimapPlugin from 'wavesurfer.minimap.js';\n *\n * // commonjs\n * var MinimapPlugin = require('wavesurfer.minimap.js');\n *\n * // if you are using <script> tags\n * var MinimapPlugin = window.WaveSurfer.minimap;\n *\n * // ... initialising wavesurfer with the plugin\n * var wavesurfer = WaveSurfer.create({\n * // wavesurfer options ...\n * plugins: [\n * MinimapPlugin.create({\n * // plugin options ...\n * })\n * ]\n * });\n */\nexport default class MinimapPlugin {\n /**\n * Minimap plugin definition factory\n *\n * This function must be used to create a plugin definition which can be\n * used by wavesurfer to correctly instantiate the plugin.\n *\n * @param {MinimapPluginParams} params parameters use to initialise the plugin\n * @return {PluginDefinition} an object representing the plugin\n */\n static create(params) {\n return {\n name: 'minimap',\n deferInit: params && params.deferInit ? params.deferInit : false,\n params: params,\n staticProps: {},\n instance: MinimapPlugin\n };\n }\n\n constructor(params, ws) {\n this.params = Object.assign(\n {},\n ws.params,\n {\n showRegions: false,\n regionsPluginName: params.regionsPluginName || 'regions',\n showOverview: false,\n overviewBorderColor: 'green',\n overviewBorderSize: 2,\n // the container should be different\n container: false,\n height: Math.max(Math.round(ws.params.height / 4), 20)\n },\n params,\n {\n scrollParent: false,\n fillParent: true\n }\n );\n // if container is a selector, get the element\n if (typeof params.container === 'string') {\n const el = document.querySelector(params.container);\n if (!el) {\n console.warn(\n `Wavesurfer minimap container ${params.container} was not found! The minimap will be automatically appended below the waveform.`\n );\n }\n this.params.container = el;\n }\n // if no container is specified add a new element and insert it\n if (!params.container) {\n this.params.container = ws.util.style(\n document.createElement('minimap'),\n {\n display: 'block'\n }\n );\n }\n this.drawer = new ws.Drawer(this.params.container, this.params);\n this.wavesurfer = ws;\n this.util = ws.util;\n this.cleared = false;\n this.renderEvent = 'redraw';\n this.overviewRegion = null;\n this.regionsPlugin = this.wavesurfer[this.params.regionsPluginName];\n\n this.drawer.createWrapper();\n this.createElements();\n let isInitialised = false;\n\n // ws ready event listener\n this._onShouldRender = () => {\n // only bind the events in the first run\n if (!isInitialised) {\n this.bindWavesurferEvents();\n this.bindMinimapEvents();\n isInitialised = true;\n }\n // if there is no such element, append it to the container (below\n // the waveform)\n if (!document.body.contains(this.params.container)) {\n ws.container.insertBefore(this.params.container, null);\n }\n\n if (this.regionsPlugin && this.params.showRegions) {\n this.drawRegions();\n }\n this.render();\n };\n\n this._onAudioprocess = currentTime => {\n this.drawer.progress(this.wavesurfer.backend.getPlayedPercents());\n };\n\n // ws seek event listener\n this._onSeek = () =>\n this.drawer.progress(ws.backend.getPlayedPercents());\n\n // event listeners for the overview region\n this._onScroll = e => {\n if (!this.draggingOverview) {\n const orientedTarget = this.util.withOrientation(e.target, this.wavesurfer.params.vertical);\n this.moveOverviewRegion(orientedTarget.scrollLeft / this.ratio);\n }\n };\n this._onMouseover = e => {\n if (this.draggingOverview) {\n this.draggingOverview = false;\n }\n };\n let prevWidth = 0;\n this._onResize = ws.util.debounce(() => {\n if (prevWidth != this.drawer.wrapper.clientWidth) {\n prevWidth = this.drawer.wrapper.clientWidth;\n this.render();\n this.drawer.progress(\n this.wavesurfer.backend.getPlayedPercents()\n );\n }\n });\n this._onLoading = percent => {\n if (percent >= 100) {\n this.cleared = false;\n return;\n }\n if (this.cleared === true) {\n return;\n }\n const len = this.drawer.getWidth();\n this.drawer.drawPeaks([0], len, 0, len);\n this.cleared = true;\n };\n this._onZoom = e => {\n this.render();\n };\n this.wavesurfer.on('zoom', this._onZoom);\n }\n\n init() {\n if (this.wavesurfer.isReady) {\n this._onShouldRender();\n }\n this.wavesurfer.on(this.renderEvent, this._onShouldRender);\n }\n\n destroy() {\n window.removeEventListener('resize', this._onResize, true);\n window.removeEventListener('orientationchange', this._onResize, true);\n this.wavesurfer.drawer.wrapper.removeEventListener(\n 'mouseover',\n this._onMouseover\n );\n this.wavesurfer.un(this.renderEvent, this._onShouldRender);\n this.wavesurfer.un('seek', this._onSeek);\n this.wavesurfer.un('scroll', this._onScroll);\n this.wavesurfer.un('audioprocess', this._onAudioprocess);\n this.wavesurfer.un('zoom', this._onZoom);\n this.wavesurfer.un('loading', this._onLoading);\n this.drawer.destroy();\n this.overviewRegion = null;\n this.unAll();\n }\n\n drawRegions() {\n this.regions = {};\n\n this.wavesurfer.on('region-created', region => {\n this.regions[region.id] = region;\n this.drawer.wrapper && this.renderRegions();\n });\n\n this.wavesurfer.on('region-updated', region => {\n this.regions[region.id] = region;\n this.drawer.wrapper && this.renderRegions();\n });\n\n this.wavesurfer.on('region-removed', region => {\n delete this.regions[region.id];\n this.drawer.wrapper && this.renderRegions();\n });\n }\n\n renderRegions() {\n const regionElements = this.drawer.wrapper.querySelectorAll('region');\n let i;\n for (i = 0; i < regionElements.length; ++i) {\n this.drawer.wrapper.removeChild(regionElements[i]);\n }\n\n Object.keys(this.regions).forEach(id => {\n const region = this.regions[id];\n const width =\n this.getWidth() *\n ((region.end - region.start) / this.wavesurfer.getDuration());\n const left =\n this.getWidth() *\n (region.start / this.wavesurfer.getDuration());\n const regionElement = this.util.style(\n document.createElement('region'),\n {\n height: 'inherit',\n backgroundColor: region.color,\n width: width + 'px',\n left: left + 'px',\n display: 'block',\n position: 'absolute'\n }\n );\n regionElement.classList.add(id);\n this.drawer.wrapper.appendChild(regionElement);\n });\n }\n\n createElements() {\n this.drawer.createElements();\n if (this.params.showOverview) {\n this.overviewRegion = this.util.withOrientation(\n this.drawer.wrapper.appendChild(document.createElement('overview')),\n this.wavesurfer.params.vertical\n );\n\n this.util.style(\n this.overviewRegion,\n {\n top: 0,\n bottom: 0,\n width: '0px',\n display: 'block',\n position: 'absolute',\n cursor: 'move',\n border:\n this.params.overviewBorderSize +\n 'px solid ' +\n this.params.overviewBorderColor,\n zIndex: 2,\n opacity: this.params.overviewOpacity\n }\n );\n }\n }\n\n bindWavesurferEvents() {\n window.addEventListener('resize', this._onResize, true);\n window.addEventListener('orientationchange', this._onResize, true);\n this.wavesurfer.on('audioprocess', this._onAudioprocess);\n this.wavesurfer.on('seek', this._onSeek);\n this.wavesurfer.on('loading', this._onLoading);\n if (this.params.showOverview) {\n this.wavesurfer.on('scroll', this._onScroll);\n this.wavesurfer.drawer.wrapper.addEventListener(\n 'mouseover',\n this._onMouseover\n );\n }\n }\n\n bindMinimapEvents() {\n const positionMouseDown = {\n clientX: 0,\n clientY: 0\n };\n let relativePositionX = 0;\n let seek = true;\n\n // the following event listeners will be destroyed by using\n // this.unAll() and nullifying the DOM node references after\n // removing them\n if (this.params.interact) {\n this.drawer.wrapper.addEventListener('click', event => {\n this.fireEvent('click', event, this.drawer.handleEvent(event));\n });\n\n this.on('click', (event, position) => {\n if (seek) {\n this.drawer.progress(position);\n this.wavesurfer.seekAndCenter(position);\n } else {\n seek = true;\n }\n });\n }\n\n if (this.params.showOverview) {\n this.overviewRegion.domElement.addEventListener('mousedown', e => {\n const event = this.util.withOrientation(e, this.wavesurfer.params.vertical);\n this.draggingOverview = true;\n relativePositionX = event.layerX;\n positionMouseDown.clientX = event.clientX;\n positionMouseDown.clientY = event.clientY;\n });\n\n this.drawer.wrapper.addEventListener('mousemove', e => {\n if (this.draggingOverview) {\n const event = this.util.withOrientation(e, this.wavesurfer.params.vertical);\n this.moveOverviewRegion(\n event.clientX -\n this.drawer.container.getBoundingClientRect().left -\n relativePositionX\n );\n }\n });\n\n this.drawer.wrapper.addEventListener('mouseup', e => {\n const event = this.util.withOrientation(e, this.wavesurfer.params.vertical);\n if (\n positionMouseDown.clientX - event.clientX === 0 &&\n positionMouseDown.clientX - event.clientX === 0\n ) {\n seek = true;\n this.draggingOverview = false;\n } else if (this.draggingOverview) {\n seek = false;\n this.draggingOverview = false;\n }\n });\n }\n }\n\n render() {\n const len = this.drawer.getWidth();\n const peaks = this.wavesurfer.backend.getPeaks(len, 0, len);\n this.drawer.drawPeaks(peaks, len, 0, len);\n this.drawer.progress(this.wavesurfer.backend.getPlayedPercents());\n\n if (this.params.showOverview) {\n //get proportional width of overview region considering the respective\n //width of the drawers\n this.ratio = this.wavesurfer.drawer.width / this.drawer.width;\n this.waveShowedWidth = this.wavesurfer.drawer.width / this.ratio;\n this.waveWidth = this.wavesurfer.drawer.width;\n this.overviewWidth = this.drawer.container.offsetWidth / this.ratio;\n this.overviewPosition = 0;\n this.moveOverviewRegion(\n this.wavesurfer.drawer.wrapper.scrollLeft / this.ratio\n );\n this.util.style(this.overviewRegion, {\n width: this.overviewWidth + 'px'\n });\n }\n }\n\n moveOverviewRegion(pixels) {\n if (pixels < 0) {\n this.overviewPosition = 0;\n } else if (\n pixels + this.overviewWidth <\n this.drawer.container.offsetWidth\n ) {\n this.overviewPosition = pixels;\n } else {\n this.overviewPosition =\n this.drawer.container.offsetWidth - this.overviewWidth;\n }\n this.util.style(this.overviewRegion, {\n left: this.overviewPosition + 'px'\n });\n if (this.draggingOverview) {\n this.wavesurfer.drawer.wrapper.scrollLeft =\n this.overviewPosition * this.ratio;\n }\n }\n\n getWidth() {\n return this.drawer.width / this.params.pixelRatio;\n }\n}\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","","// startup\n// Load entry module and return exports\n// This entry module is referenced by other modules so it can't be inlined\nvar __webpack_exports__ = __webpack_require__(\"./src/plugin/minimap/index.js\");\n",""],"names":["MinimapPlugin","params","ws","_this","_classCallCheck","Object","assign","showRegions","regionsPluginName","showOverview","overviewBorderColor","overviewBorderSize","container","height","Math","max","round","scrollParent","fillParent","el","document","querySelector","console","warn","concat","util","style","createElement","display","drawer","Drawer","wavesurfer","cleared","renderEvent","overviewRegion","regionsPlugin","createWrapper","createElements","isInitialised","_onShouldRender","bindWavesurferEvents","bindMinimapEvents","body","contains","insertBefore","drawRegions","render","_onAudioprocess","currentTime","progress","backend","getPlayedPercents","_onSeek","_onScroll","e","draggingOverview","orientedTarget","withOrientation","target","vertical","moveOverviewRegion","scrollLeft","ratio","_onMouseover","prevWidth","_onResize","debounce","wrapper","clientWidth","_onLoading","percent","len","getWidth","drawPeaks","_onZoom","on","_createClass","key","value","init","isReady","destroy","window","removeEventListener","un","unAll","_this2","regions","region","id","renderRegions","_this3","regionElements","querySelectorAll","i","length","removeChild","keys","forEach","width","end","start","getDuration","left","regionElement","backgroundColor","color","position","classList","add","appendChild","top","bottom","cursor","border","zIndex","opacity","overviewOpacity","addEventListener","_this4","positionMouseDown","clientX","clientY","relativePositionX","seek","interact","event","fireEvent","handleEvent","seekAndCenter","domElement","layerX","getBoundingClientRect","peaks","getPeaks","waveShowedWidth","waveWidth","overviewWidth","offsetWidth","overviewPosition","pixels","pixelRatio","create","name","deferInit","staticProps","instance","exports","default","module"],"sourceRoot":""}
@@ -1,7 +1,7 @@
1
1
  /*!
2
- * wavesurfer.js minimap plugin 6.3.0 (2022-10-03)
2
+ * wavesurfer.js minimap plugin 6.5.0 (2023-03-11)
3
3
  * https://wavesurfer-js.org
4
4
  * @license BSD-3-Clause
5
5
  */
6
- !function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define("WaveSurfer",[],r):"object"==typeof exports?exports.WaveSurfer=r():(e.WaveSurfer=e.WaveSurfer||{},e.WaveSurfer.minimap=r())}(self,(()=>(()=>{"use strict";var e={521:(e,r)=>{function i(e,r){for(var i=0;i<r.length;i++){var t=r[i];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(e,t.key,t)}}Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var t=function(){function e(r,i){var t=this;if(function(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}(this,e),this.params=Object.assign({},i.params,{showRegions:!1,regionsPluginName:r.regionsPluginName||"regions",showOverview:!1,overviewBorderColor:"green",overviewBorderSize:2,container:!1,height:Math.max(Math.round(i.params.height/4),20)},r,{scrollParent:!1,fillParent:!0}),"string"==typeof r.container){var n=document.querySelector(r.container);n||console.warn("Wavesurfer minimap container ".concat(r.container," was not found! The minimap will be automatically appended below the waveform.")),this.params.container=n}r.container||(this.params.container=i.util.style(document.createElement("minimap"),{display:"block"})),this.drawer=new i.Drawer(this.params.container,this.params),this.wavesurfer=i,this.util=i.util,this.cleared=!1,this.renderEvent="redraw",this.overviewRegion=null,this.regionsPlugin=this.wavesurfer[this.params.regionsPluginName],this.drawer.createWrapper(),this.createElements();var s=!1;this._onShouldRender=function(){s||(t.bindWavesurferEvents(),t.bindMinimapEvents(),s=!0),document.body.contains(t.params.container)||i.container.insertBefore(t.params.container,null),t.regionsPlugin&&t.params.showRegions&&t.drawRegions(),t.render()},this._onAudioprocess=function(e){t.drawer.progress(t.wavesurfer.backend.getPlayedPercents())},this._onSeek=function(){return t.drawer.progress(i.backend.getPlayedPercents())},this._onScroll=function(e){if(!t.draggingOverview){var r=t.util.withOrientation(e.target,t.wavesurfer.params.vertical);t.moveOverviewRegion(r.scrollLeft/t.ratio)}},this._onMouseover=function(e){t.draggingOverview&&(t.draggingOverview=!1)};var o=0;this._onResize=i.util.debounce((function(){o!=t.drawer.wrapper.clientWidth&&(o=t.drawer.wrapper.clientWidth,t.render(),t.drawer.progress(t.wavesurfer.backend.getPlayedPercents()))})),this._onLoading=function(e){if(e>=100)t.cleared=!1;else if(!0!==t.cleared){var r=t.drawer.getWidth();t.drawer.drawPeaks([0],r,0,r),t.cleared=!0}},this._onZoom=function(e){t.render()},this.wavesurfer.on("zoom",this._onZoom)}var r,t,n;return r=e,n=[{key:"create",value:function(r){return{name:"minimap",deferInit:!(!r||!r.deferInit)&&r.deferInit,params:r,staticProps:{},instance:e}}}],(t=[{key:"init",value:function(){this.wavesurfer.isReady&&this._onShouldRender(),this.wavesurfer.on(this.renderEvent,this._onShouldRender)}},{key:"destroy",value:function(){window.removeEventListener("resize",this._onResize,!0),window.removeEventListener("orientationchange",this._onResize,!0),this.wavesurfer.drawer.wrapper.removeEventListener("mouseover",this._onMouseover),this.wavesurfer.un(this.renderEvent,this._onShouldRender),this.wavesurfer.un("seek",this._onSeek),this.wavesurfer.un("scroll",this._onScroll),this.wavesurfer.un("audioprocess",this._onAudioprocess),this.wavesurfer.un("zoom",this._onZoom),this.wavesurfer.un("loading",this._onLoading),this.drawer.destroy(),this.overviewRegion=null,this.unAll()}},{key:"drawRegions",value:function(){var e=this;this.regions={},this.wavesurfer.on("region-created",(function(r){e.regions[r.id]=r,e.drawer.wrapper&&e.renderRegions()})),this.wavesurfer.on("region-updated",(function(r){e.regions[r.id]=r,e.drawer.wrapper&&e.renderRegions()})),this.wavesurfer.on("region-removed",(function(r){delete e.regions[r.id],e.drawer.wrapper&&e.renderRegions()}))}},{key:"renderRegions",value:function(){var e,r=this,i=this.drawer.wrapper.querySelectorAll("region");for(e=0;e<i.length;++e)this.drawer.wrapper.removeChild(i[e]);Object.keys(this.regions).forEach((function(e){var i=r.regions[e],t=r.getWidth()*((i.end-i.start)/r.wavesurfer.getDuration()),n=r.getWidth()*(i.start/r.wavesurfer.getDuration()),s=r.util.style(document.createElement("region"),{height:"inherit",backgroundColor:i.color,width:t+"px",left:n+"px",display:"block",position:"absolute"});s.classList.add(e),r.drawer.wrapper.appendChild(s)}))}},{key:"createElements",value:function(){this.drawer.createElements(),this.params.showOverview&&(this.overviewRegion=this.util.withOrientation(this.drawer.wrapper.appendChild(document.createElement("overview")),this.wavesurfer.params.vertical),this.util.style(this.overviewRegion,{top:0,bottom:0,width:"0px",display:"block",position:"absolute",cursor:"move",border:this.params.overviewBorderSize+"px solid "+this.params.overviewBorderColor,zIndex:2,opacity:this.params.overviewOpacity}))}},{key:"bindWavesurferEvents",value:function(){window.addEventListener("resize",this._onResize,!0),window.addEventListener("orientationchange",this._onResize,!0),this.wavesurfer.on("audioprocess",this._onAudioprocess),this.wavesurfer.on("seek",this._onSeek),this.wavesurfer.on("loading",this._onLoading),this.params.showOverview&&(this.wavesurfer.on("scroll",this._onScroll),this.wavesurfer.drawer.wrapper.addEventListener("mouseover",this._onMouseover))}},{key:"bindMinimapEvents",value:function(){var e=this,r={clientX:0,clientY:0},i=0,t=!0;this.params.interact&&(this.drawer.wrapper.addEventListener("click",(function(r){e.fireEvent("click",r,e.drawer.handleEvent(r))})),this.on("click",(function(r,i){t?(e.drawer.progress(i),e.wavesurfer.seekAndCenter(i)):t=!0}))),this.params.showOverview&&(this.overviewRegion.domElement.addEventListener("mousedown",(function(t){var n=e.util.withOrientation(t,e.wavesurfer.params.vertical);e.draggingOverview=!0,i=n.layerX,r.clientX=n.clientX,r.clientY=n.clientY})),this.drawer.wrapper.addEventListener("mousemove",(function(r){if(e.draggingOverview){var t=e.util.withOrientation(r,e.wavesurfer.params.vertical);e.moveOverviewRegion(t.clientX-e.drawer.container.getBoundingClientRect().left-i)}})),this.drawer.wrapper.addEventListener("mouseup",(function(i){var n=e.util.withOrientation(i,e.wavesurfer.params.vertical);r.clientX-n.clientX==0&&r.clientX-n.clientX==0?(t=!0,e.draggingOverview=!1):e.draggingOverview&&(t=!1,e.draggingOverview=!1)})))}},{key:"render",value:function(){var e=this.drawer.getWidth(),r=this.wavesurfer.backend.getPeaks(e,0,e);this.drawer.drawPeaks(r,e,0,e),this.drawer.progress(this.wavesurfer.backend.getPlayedPercents()),this.params.showOverview&&(this.ratio=this.wavesurfer.drawer.width/this.drawer.width,this.waveShowedWidth=this.wavesurfer.drawer.width/this.ratio,this.waveWidth=this.wavesurfer.drawer.width,this.overviewWidth=this.drawer.container.offsetWidth/this.ratio,this.overviewPosition=0,this.moveOverviewRegion(this.wavesurfer.drawer.wrapper.scrollLeft/this.ratio),this.util.style(this.overviewRegion,{width:this.overviewWidth+"px"}))}},{key:"moveOverviewRegion",value:function(e){e<0?this.overviewPosition=0:e+this.overviewWidth<this.drawer.container.offsetWidth?this.overviewPosition=e:this.overviewPosition=this.drawer.container.offsetWidth-this.overviewWidth,this.util.style(this.overviewRegion,{left:this.overviewPosition+"px"}),this.draggingOverview&&(this.wavesurfer.drawer.wrapper.scrollLeft=this.overviewPosition*this.ratio)}},{key:"getWidth",value:function(){return this.drawer.width/this.params.pixelRatio}}])&&i(r.prototype,t),n&&i(r,n),Object.defineProperty(r,"prototype",{writable:!1}),e}();r.default=t,e.exports=r.default}},r={};var i=function i(t){var n=r[t];if(void 0!==n)return n.exports;var s=r[t]={exports:{}};return e[t](s,s.exports,i),s.exports}(521);return i})()));
6
+ !function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define("WaveSurfer",[],r):"object"==typeof exports?exports.WaveSurfer=r():(e.WaveSurfer=e.WaveSurfer||{},e.WaveSurfer.minimap=r())}(self,(()=>(()=>{"use strict";var e={521:(e,r)=>{function i(e){return i="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},i(e)}function t(e,r){for(var t=0;t<r.length;t++){var n=r[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,(o=n.key,s=void 0,s=function(e,r){if("object"!==i(e)||null===e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,r||"default");if("object"!==i(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(e)}(o,"string"),"symbol"===i(s)?s:String(s)),n)}var o,s}Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var n=function(){function e(r,i){var t=this;if(function(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}(this,e),this.params=Object.assign({},i.params,{showRegions:!1,regionsPluginName:r.regionsPluginName||"regions",showOverview:!1,overviewBorderColor:"green",overviewBorderSize:2,container:!1,height:Math.max(Math.round(i.params.height/4),20)},r,{scrollParent:!1,fillParent:!0}),"string"==typeof r.container){var n=document.querySelector(r.container);n||console.warn("Wavesurfer minimap container ".concat(r.container," was not found! The minimap will be automatically appended below the waveform.")),this.params.container=n}r.container||(this.params.container=i.util.style(document.createElement("minimap"),{display:"block"})),this.drawer=new i.Drawer(this.params.container,this.params),this.wavesurfer=i,this.util=i.util,this.cleared=!1,this.renderEvent="redraw",this.overviewRegion=null,this.regionsPlugin=this.wavesurfer[this.params.regionsPluginName],this.drawer.createWrapper(),this.createElements();var o=!1;this._onShouldRender=function(){o||(t.bindWavesurferEvents(),t.bindMinimapEvents(),o=!0),document.body.contains(t.params.container)||i.container.insertBefore(t.params.container,null),t.regionsPlugin&&t.params.showRegions&&t.drawRegions(),t.render()},this._onAudioprocess=function(e){t.drawer.progress(t.wavesurfer.backend.getPlayedPercents())},this._onSeek=function(){return t.drawer.progress(i.backend.getPlayedPercents())},this._onScroll=function(e){if(!t.draggingOverview){var r=t.util.withOrientation(e.target,t.wavesurfer.params.vertical);t.moveOverviewRegion(r.scrollLeft/t.ratio)}},this._onMouseover=function(e){t.draggingOverview&&(t.draggingOverview=!1)};var s=0;this._onResize=i.util.debounce((function(){s!=t.drawer.wrapper.clientWidth&&(s=t.drawer.wrapper.clientWidth,t.render(),t.drawer.progress(t.wavesurfer.backend.getPlayedPercents()))})),this._onLoading=function(e){if(e>=100)t.cleared=!1;else if(!0!==t.cleared){var r=t.drawer.getWidth();t.drawer.drawPeaks([0],r,0,r),t.cleared=!0}},this._onZoom=function(e){t.render()},this.wavesurfer.on("zoom",this._onZoom)}var r,i,n;return r=e,n=[{key:"create",value:function(r){return{name:"minimap",deferInit:!(!r||!r.deferInit)&&r.deferInit,params:r,staticProps:{},instance:e}}}],(i=[{key:"init",value:function(){this.wavesurfer.isReady&&this._onShouldRender(),this.wavesurfer.on(this.renderEvent,this._onShouldRender)}},{key:"destroy",value:function(){window.removeEventListener("resize",this._onResize,!0),window.removeEventListener("orientationchange",this._onResize,!0),this.wavesurfer.drawer.wrapper.removeEventListener("mouseover",this._onMouseover),this.wavesurfer.un(this.renderEvent,this._onShouldRender),this.wavesurfer.un("seek",this._onSeek),this.wavesurfer.un("scroll",this._onScroll),this.wavesurfer.un("audioprocess",this._onAudioprocess),this.wavesurfer.un("zoom",this._onZoom),this.wavesurfer.un("loading",this._onLoading),this.drawer.destroy(),this.overviewRegion=null,this.unAll()}},{key:"drawRegions",value:function(){var e=this;this.regions={},this.wavesurfer.on("region-created",(function(r){e.regions[r.id]=r,e.drawer.wrapper&&e.renderRegions()})),this.wavesurfer.on("region-updated",(function(r){e.regions[r.id]=r,e.drawer.wrapper&&e.renderRegions()})),this.wavesurfer.on("region-removed",(function(r){delete e.regions[r.id],e.drawer.wrapper&&e.renderRegions()}))}},{key:"renderRegions",value:function(){var e,r=this,i=this.drawer.wrapper.querySelectorAll("region");for(e=0;e<i.length;++e)this.drawer.wrapper.removeChild(i[e]);Object.keys(this.regions).forEach((function(e){var i=r.regions[e],t=r.getWidth()*((i.end-i.start)/r.wavesurfer.getDuration()),n=r.getWidth()*(i.start/r.wavesurfer.getDuration()),o=r.util.style(document.createElement("region"),{height:"inherit",backgroundColor:i.color,width:t+"px",left:n+"px",display:"block",position:"absolute"});o.classList.add(e),r.drawer.wrapper.appendChild(o)}))}},{key:"createElements",value:function(){this.drawer.createElements(),this.params.showOverview&&(this.overviewRegion=this.util.withOrientation(this.drawer.wrapper.appendChild(document.createElement("overview")),this.wavesurfer.params.vertical),this.util.style(this.overviewRegion,{top:0,bottom:0,width:"0px",display:"block",position:"absolute",cursor:"move",border:this.params.overviewBorderSize+"px solid "+this.params.overviewBorderColor,zIndex:2,opacity:this.params.overviewOpacity}))}},{key:"bindWavesurferEvents",value:function(){window.addEventListener("resize",this._onResize,!0),window.addEventListener("orientationchange",this._onResize,!0),this.wavesurfer.on("audioprocess",this._onAudioprocess),this.wavesurfer.on("seek",this._onSeek),this.wavesurfer.on("loading",this._onLoading),this.params.showOverview&&(this.wavesurfer.on("scroll",this._onScroll),this.wavesurfer.drawer.wrapper.addEventListener("mouseover",this._onMouseover))}},{key:"bindMinimapEvents",value:function(){var e=this,r={clientX:0,clientY:0},i=0,t=!0;this.params.interact&&(this.drawer.wrapper.addEventListener("click",(function(r){e.fireEvent("click",r,e.drawer.handleEvent(r))})),this.on("click",(function(r,i){t?(e.drawer.progress(i),e.wavesurfer.seekAndCenter(i)):t=!0}))),this.params.showOverview&&(this.overviewRegion.domElement.addEventListener("mousedown",(function(t){var n=e.util.withOrientation(t,e.wavesurfer.params.vertical);e.draggingOverview=!0,i=n.layerX,r.clientX=n.clientX,r.clientY=n.clientY})),this.drawer.wrapper.addEventListener("mousemove",(function(r){if(e.draggingOverview){var t=e.util.withOrientation(r,e.wavesurfer.params.vertical);e.moveOverviewRegion(t.clientX-e.drawer.container.getBoundingClientRect().left-i)}})),this.drawer.wrapper.addEventListener("mouseup",(function(i){var n=e.util.withOrientation(i,e.wavesurfer.params.vertical);r.clientX-n.clientX==0&&r.clientX-n.clientX==0?(t=!0,e.draggingOverview=!1):e.draggingOverview&&(t=!1,e.draggingOverview=!1)})))}},{key:"render",value:function(){var e=this.drawer.getWidth(),r=this.wavesurfer.backend.getPeaks(e,0,e);this.drawer.drawPeaks(r,e,0,e),this.drawer.progress(this.wavesurfer.backend.getPlayedPercents()),this.params.showOverview&&(this.ratio=this.wavesurfer.drawer.width/this.drawer.width,this.waveShowedWidth=this.wavesurfer.drawer.width/this.ratio,this.waveWidth=this.wavesurfer.drawer.width,this.overviewWidth=this.drawer.container.offsetWidth/this.ratio,this.overviewPosition=0,this.moveOverviewRegion(this.wavesurfer.drawer.wrapper.scrollLeft/this.ratio),this.util.style(this.overviewRegion,{width:this.overviewWidth+"px"}))}},{key:"moveOverviewRegion",value:function(e){e<0?this.overviewPosition=0:e+this.overviewWidth<this.drawer.container.offsetWidth?this.overviewPosition=e:this.overviewPosition=this.drawer.container.offsetWidth-this.overviewWidth,this.util.style(this.overviewRegion,{left:this.overviewPosition+"px"}),this.draggingOverview&&(this.wavesurfer.drawer.wrapper.scrollLeft=this.overviewPosition*this.ratio)}},{key:"getWidth",value:function(){return this.drawer.width/this.params.pixelRatio}}])&&t(r.prototype,i),n&&t(r,n),Object.defineProperty(r,"prototype",{writable:!1}),e}();r.default=n,e.exports=r.default}},r={};var i=function i(t){var n=r[t];if(void 0!==n)return n.exports;var o=r[t]={exports:{}};return e[t](o,o.exports,i),o.exports}(521);return i})()));
7
7
  //# sourceMappingURL=wavesurfer.minimap.min.js.map