wavesurfer.js 5.1.0 → 6.0.2

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 (66) hide show
  1. package/CHANGES.md +47 -0
  2. package/README.md +10 -0
  3. package/dist/plugin/wavesurfer.cursor.js +53 -51
  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 +10 -7
  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 +142 -26
  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 +6 -6
  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 +5 -5
  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 +26 -23
  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 +5 -5
  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 +88 -21
  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 +71 -58
  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 +52 -54
  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 +6 -6
  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 +302 -133
  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 +23 -23
  52. package/src/drawer.canvasentry.js +33 -6
  53. package/src/drawer.js +1 -0
  54. package/src/drawer.multicanvas.js +19 -8
  55. package/src/mediaelement.js +1 -1
  56. package/src/plugin/cursor/index.js +68 -70
  57. package/src/plugin/markers/index.js +112 -23
  58. package/src/plugin/minimap/index.js +24 -21
  59. package/src/plugin/regions/index.js +31 -4
  60. package/src/plugin/regions/region.js +45 -8
  61. package/src/plugin/spectrogram/index.js +65 -50
  62. package/src/plugin/timeline/index.js +11 -9
  63. package/src/util/index.js +1 -0
  64. package/src/util/silence-mode.js +35 -0
  65. package/src/wavesurfer.js +54 -23
  66. package/src/webaudio.js +10 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["webpack://WaveSurfer.[name]/webpack/universalModuleDefinition","webpack://WaveSurfer.[name]/./src/plugin/microphone/index.js","webpack://WaveSurfer.[name]/webpack/bootstrap","webpack://WaveSurfer.[name]/webpack/startup"],"names":["root","factory","exports","module","define","amd","this","MicrophonePlugin","params","ws","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_require__","moduleId","cachedModule","__webpack_modules__"],"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,GAAIA,EAAiB,WAAc,WAAIC,KARpF,CASGK,MAAM,WACT,M,kRC+BqBC,E,WAmBjB,WAAYC,EAAQC,GAAI,Y,4FAAA,SACpBH,KAAKE,OAASA,EACdF,KAAKI,WAAaD,EAElBH,KAAKK,QAAS,EACdL,KAAKM,QAAS,EACdN,KAAKO,QAAUP,KAAKQ,gBACpBR,KAAKS,qBAAuB,SAAAC,GAAC,OAAI,EAAKC,aAAaD,SAkCpBE,IAA3BC,UAAUC,eACVD,UAAUC,aAAe,SAMeF,IAAxCC,UAAUC,aAAaC,eACvBF,U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AoBF,GAAU/F,EAAQA,EAAOD,QAAS+F,GAG/C9F,EAAOD,QClBW+F,CAAoB,M","file":"wavesurfer.microphone.min.js","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})(this, function() {\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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AAOE,QAAUlF,KAAKmF,eAClBzE,UAAU0E,UACV,wBACA,GAEJJ,EAAOK,WAAa,GACbL,GAEPtE,UAAUC,cACVD,UAAU0E,UAAUP,MAAM,uBAG1BG,EAAO5E,QAAU,OACjB4E,EAAOE,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,Q,gFA9TEnF,G,kCCxCjB0F,EAA2B,GCE/B,IAAIC,EDCJ,SAASC,EAAoBC,GAE5B,IAAIC,EAAeJ,EAAyBG,GAC5C,QAAqBjF,IAAjBkF,EACH,OAAOA,EAAanG,QAGrB,IAAIC,EAAS8F,EAAyBG,GAAY,CAGjDlG,QAAS,IAOV,OAHAoG,EAAoBF,GAAUjG,EAAQA,EAAOD,QAASiG,GAG/ChG,EAAOD,QClBWiG,CAAoB,K,UHO9C","sources":["webpack://WaveSurfer.[name]/webpack/universalModuleDefinition","webpack://WaveSurfer.[name]/./src/plugin/microphone/index.js","webpack://WaveSurfer.[name]/webpack/bootstrap","webpack://WaveSurfer.[name]/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, function() {\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,5 +1,5 @@
1
1
  /*!
2
- * wavesurfer.js minimap plugin 5.1.0 (2021-06-20)
2
+ * wavesurfer.js minimap plugin 6.0.2 (2022-02-20)
3
3
  * https://wavesurfer-js.org
4
4
  * @license BSD-3-Clause
5
5
  */
@@ -12,7 +12,7 @@
12
12
  exports["WaveSurfer"] = factory();
13
13
  else
14
14
  root["WaveSurfer"] = root["WaveSurfer"] || {}, root["WaveSurfer"]["minimap"] = factory();
15
- })(this, function() {
15
+ })(self, function() {
16
16
  return /******/ (() => { // webpackBootstrap
17
17
  /******/ "use strict";
18
18
  /******/ var __webpack_modules__ = ({
@@ -28,13 +28,13 @@ return /******/ (() => { // webpackBootstrap
28
28
  Object.defineProperty(exports, "__esModule", ({
29
29
  value: true
30
30
  }));
31
- exports.default = void 0;
31
+ exports["default"] = void 0;
32
32
 
33
33
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
34
34
 
35
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
36
 
37
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
37
+ 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
38
 
39
39
  /*eslint no-console: ["error", { allow: ["warn"] }] */
40
40
 
@@ -113,16 +113,7 @@ var MinimapPlugin = /*#__PURE__*/function () {
113
113
  this.drawer = new ws.Drawer(this.params.container, this.params);
114
114
  this.wavesurfer = ws;
115
115
  this.util = ws.util;
116
- /**
117
- * Minimap needs to listen for the `ready` and `waveform-ready` events
118
- * to work with the `MediaElement` backend. The moment the `ready` event
119
- * is called is different (and peaks would not load).
120
- *
121
- * @type {string}
122
- * @see https://github.com/katspaugh/wavesurfer.js/issues/736
123
- */
124
-
125
- this.renderEvent = ws.params.backend === 'MediaElement' ? 'waveform-ready' : 'ready';
116
+ this.renderEvent = 'redraw';
126
117
  this.overviewRegion = null;
127
118
  this.regionsPlugin = this.wavesurfer[this.params.regionsPluginName];
128
119
  this.drawer.createWrapper();
@@ -164,7 +155,9 @@ var MinimapPlugin = /*#__PURE__*/function () {
164
155
 
165
156
  this._onScroll = function (e) {
166
157
  if (!_this.draggingOverview) {
167
- _this.moveOverviewRegion(e.target.scrollLeft / _this.ratio);
158
+ var orientedTarget = _this.util.withOrientation(e.target, _this.wavesurfer.params.vertical);
159
+
160
+ _this.moveOverviewRegion(orientedTarget.scrollLeft / _this.ratio);
168
161
  }
169
162
  };
170
163
 
@@ -274,7 +267,8 @@ var MinimapPlugin = /*#__PURE__*/function () {
274
267
  this.drawer.createElements();
275
268
 
276
269
  if (this.params.showOverview) {
277
- this.overviewRegion = this.util.style(document.createElement('overview'), {
270
+ this.overviewRegion = this.util.withOrientation(this.drawer.wrapper.appendChild(document.createElement('overview')), this.wavesurfer.params.vertical);
271
+ this.util.style(this.overviewRegion, {
278
272
  top: 0,
279
273
  bottom: 0,
280
274
  width: '0px',
@@ -285,7 +279,6 @@ var MinimapPlugin = /*#__PURE__*/function () {
285
279
  zIndex: 2,
286
280
  opacity: this.params.overviewOpacity
287
281
  });
288
- this.drawer.wrapper.appendChild(this.overviewRegion);
289
282
  }
290
283
  }
291
284
  }, {
@@ -331,18 +324,24 @@ var MinimapPlugin = /*#__PURE__*/function () {
331
324
  }
332
325
 
333
326
  if (this.params.showOverview) {
334
- this.overviewRegion.addEventListener('mousedown', function (event) {
327
+ this.overviewRegion.domElement.addEventListener('mousedown', function (e) {
328
+ var event = _this4.util.withOrientation(e, _this4.wavesurfer.params.vertical);
329
+
335
330
  _this4.draggingOverview = true;
336
331
  relativePositionX = event.layerX;
337
332
  positionMouseDown.clientX = event.clientX;
338
333
  positionMouseDown.clientY = event.clientY;
339
334
  });
340
- this.drawer.wrapper.addEventListener('mousemove', function (event) {
335
+ this.drawer.wrapper.addEventListener('mousemove', function (e) {
341
336
  if (_this4.draggingOverview) {
337
+ var event = _this4.util.withOrientation(e, _this4.wavesurfer.params.vertical);
338
+
342
339
  _this4.moveOverviewRegion(event.clientX - _this4.drawer.container.getBoundingClientRect().left - relativePositionX);
343
340
  }
344
341
  });
345
- this.drawer.wrapper.addEventListener('mouseup', function (event) {
342
+ this.drawer.wrapper.addEventListener('mouseup', function (e) {
343
+ var event = _this4.util.withOrientation(e, _this4.wavesurfer.params.vertical);
344
+
346
345
  if (positionMouseDown.clientX - event.clientX === 0 && positionMouseDown.clientX - event.clientX === 0) {
347
346
  seek = true;
348
347
  _this4.draggingOverview = false;
@@ -370,7 +369,9 @@ var MinimapPlugin = /*#__PURE__*/function () {
370
369
  this.overviewWidth = this.drawer.container.offsetWidth / this.ratio;
371
370
  this.overviewPosition = 0;
372
371
  this.moveOverviewRegion(this.wavesurfer.drawer.wrapper.scrollLeft / this.ratio);
373
- this.overviewRegion.style.width = this.overviewWidth + 'px';
372
+ this.util.style(this.overviewRegion, {
373
+ width: this.overviewWidth + 'px'
374
+ });
374
375
  }
375
376
  }
376
377
  }, {
@@ -384,7 +385,9 @@ var MinimapPlugin = /*#__PURE__*/function () {
384
385
  this.overviewPosition = this.drawer.container.offsetWidth - this.overviewWidth;
385
386
  }
386
387
 
387
- this.overviewRegion.style.left = this.overviewPosition + 'px';
388
+ this.util.style(this.overviewRegion, {
389
+ left: this.overviewPosition + 'px'
390
+ });
388
391
 
389
392
  if (this.draggingOverview) {
390
393
  this.wavesurfer.drawer.wrapper.scrollLeft = this.overviewPosition * this.ratio;
@@ -421,7 +424,7 @@ var MinimapPlugin = /*#__PURE__*/function () {
421
424
  return MinimapPlugin;
422
425
  }();
423
426
 
424
- exports.default = MinimapPlugin;
427
+ exports["default"] = MinimapPlugin;
425
428
  module.exports = exports.default;
426
429
 
427
430
  /***/ })
@@ -1 +1 @@
1
- {"version":3,"sources":["webpack://WaveSurfer.[name]/webpack/universalModuleDefinition","webpack://WaveSurfer.[name]/./src/plugin/minimap/index.js","webpack://WaveSurfer.[name]/webpack/bootstrap","webpack://WaveSurfer.[name]/webpack/startup"],"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","renderEvent","backend","overviewRegion","regionsPlugin","createWrapper","createElements","isInitialised","_onShouldRender","bindWavesurferEvents","bindMinimapEvents","body","contains","insertBefore","regions","render","_onAudioprocess","currentTime","progress","getPlayedPercents","_onSeek","_onScroll","e","draggingOverview","moveOverviewRegion","target","scrollLeft","ratio","_onMouseover","prevWidth","_onResize","debounce","wrapper","clientWidth","_onZoom","on","isReady","window","removeEventListener","un","destroy","unAll","region","id","renderRegions","regionElements","querySelectorAll","i","length","removeChild","keys","forEach","width","getWidth","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","layerX","getBoundingClientRect","len","peaks","getPeaks","drawPeaks","waveShowedWidth","waveWidth","overviewWidth","offsetWidth","overviewPosition","pixels","pixelRatio","name","deferInit","staticProps","instance"],"mappings":";;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,+CAA+C;AAC/C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1B,GAAiC,KAAKoC,gBAAL,GAAwB,IAAzD;;AACA,UAAI,KAAKtE,gBAAT,EAA2B;AACvB,aAAKvB,UAAL,CAAgBF,MAAhB,CAAuBkC,OAAvB,CAA+BN,UAA/B,GACI,KAAKmE,gBAAL,GAAwB,KAAKlE,KADjC;AAEH;AACJ;;;WAED,oBAAW;AACP,aAAO,KAAK7B,MAAL,CAAYsD,KAAZ,GAAoB,KAAK/E,MAAL,CAAY0H,UAAvC;AACH;;;;AA1VD;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACI,oBAAc1H,MAAd,EAAsB;AAClB,aAAO;AACH2H,YAAI,EAAE,SADH;AAEHC,iBAAS,EAAE5H,MAAM,IAAIA,MAAM,CAAC4H,SAAjB,GAA6B5H,MAAM,CAAC4H,SAApC,GAAgD,KAFxD;AAGH5H,cAAM,EAAEA,MAHL;AAIH6H,mBAAW,EAAE,EAJV;AAKHC,gBAAQ,EAAE/H;AALP,OAAP;AAOH;;;;;;;;;;;;;UCtDL;UACA;;UAEA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;;UAEA;UACA;;UAEA;UACA;UACA;;;;UCtBA;UACA;UACA;UACA","file":"wavesurfer.minimap.js","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})(this, function() {\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 /**\n * Minimap needs to listen for the `ready` and `waveform-ready` events\n * to work with the `MediaElement` backend. The moment the `ready` event\n * is called is different (and peaks would not load).\n *\n * @type {string}\n * @see https://github.com/katspaugh/wavesurfer.js/issues/736\n */\n this.renderEvent =\n ws.params.backend === 'MediaElement' ? 'waveform-ready' : 'ready';\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.regions();\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 this.moveOverviewRegion(e.target.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._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.drawer.destroy();\n this.overviewRegion = null;\n this.unAll();\n }\n\n regions() {\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.style(\n document.createElement('overview'),\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 this.drawer.wrapper.appendChild(this.overviewRegion);\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 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.addEventListener('mousedown', event => {\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', event => {\n if (this.draggingOverview) {\n this.moveOverviewRegion(\n event.clientX -\n this.drawer.container.getBoundingClientRect().left -\n relativePositionX\n );\n }\n });\n\n this.drawer.wrapper.addEventListener('mouseup', event => {\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.overviewRegion.style.width = this.overviewWidth + 'px';\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.overviewRegion.style.left = this.overviewPosition + 'px';\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"],"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;IACqBA;AAoBjB,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iI,QAAAA,WAAW,EAAE,EAJV;AAKHC,QAAAA,QAAQ,EAAEnI;AALP,OAAP;AAOH;;;;;;;;;;;;;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.[name]/webpack/universalModuleDefinition","webpack://WaveSurfer.[name]/./src/plugin/minimap/index.js","webpack://WaveSurfer.[name]/webpack/bootstrap","webpack://WaveSurfer.[name]/webpack/before-startup","webpack://WaveSurfer.[name]/webpack/startup","webpack://WaveSurfer.[name]/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, function() {\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.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.regions();\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._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.drawer.destroy();\n this.overviewRegion = null;\n this.unAll();\n }\n\n regions() {\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 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","renderEvent","overviewRegion","regionsPlugin","createWrapper","createElements","isInitialised","_onShouldRender","bindWavesurferEvents","bindMinimapEvents","body","contains","insertBefore","regions","render","_onAudioprocess","currentTime","progress","backend","getPlayedPercents","_onSeek","_onScroll","e","draggingOverview","orientedTarget","withOrientation","target","vertical","moveOverviewRegion","scrollLeft","ratio","_onMouseover","prevWidth","_onResize","debounce","wrapper","clientWidth","_onZoom","on","isReady","window","removeEventListener","un","destroy","unAll","region","id","renderRegions","regionElements","querySelectorAll","i","length","removeChild","keys","forEach","width","getWidth","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","len","peaks","getPeaks","drawPeaks","waveShowedWidth","waveWidth","overviewWidth","offsetWidth","overviewPosition","pixels","pixelRatio","name","deferInit","staticProps","instance"],"sourceRoot":""}
@@ -1,7 +1,7 @@
1
1
  /*!
2
- * wavesurfer.js minimap plugin 5.1.0 (2021-06-20)
2
+ * wavesurfer.js minimap plugin 6.0.2 (2022-02-20)
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())}(this,(function(){return(()=>{"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.renderEvent="MediaElement"===i.params.backend?"waveform-ready":"ready",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.regions(),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){t.draggingOverview||t.moveOverviewRegion(e.target.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._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.drawer.destroy(),this.overviewRegion=null,this.unAll()}},{key:"regions",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.style(document.createElement("overview"),{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}),this.drawer.wrapper.appendChild(this.overviewRegion))}},{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.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.addEventListener("mousedown",(function(t){e.draggingOverview=!0,i=t.layerX,r.clientX=t.clientX,r.clientY=t.clientY})),this.drawer.wrapper.addEventListener("mousemove",(function(r){e.draggingOverview&&e.moveOverviewRegion(r.clientX-e.drawer.container.getBoundingClientRect().left-i)})),this.drawer.wrapper.addEventListener("mouseup",(function(i){r.clientX-i.clientX==0&&r.clientX-i.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.overviewRegion.style.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.overviewRegion.style.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),e}();r.default=t,e.exports=r.default}},r={};return 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)})()}));
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,(function(){return(()=>{"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.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.regions(),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._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.drawer.destroy(),this.overviewRegion=null,this.unAll()}},{key:"regions",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.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})()}));
7
7
  //# sourceMappingURL=wavesurfer.minimap.min.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["webpack://WaveSurfer.[name]/webpack/universalModuleDefinition","webpack://WaveSurfer.[name]/./src/plugin/minimap/index.js","webpack://WaveSurfer.[name]/webpack/bootstrap","webpack://WaveSurfer.[name]/webpack/startup"],"names":["root","factory","exports","module","define","amd","this","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","renderEvent","backend","overviewRegion","regionsPlugin","createWrapper","createElements","isInitialised","_onShouldRender","bindWavesurferEvents","bindMinimapEvents","body","contains","insertBefore","regions","render","_onAudioprocess","currentTime","progress","getPlayedPercents","_onSeek","_onScroll","e","draggingOverview","moveOverviewRegion","target","scrollLeft","ratio","_onMouseover","prevWidth","_onResize","debounce","wrapper","clientWidth","_onZoom","on","name","deferInit","staticProps","instance","isReady","window","removeEventListener","un","destroy","unAll","region","id","renderRegions","i","regionElements","querySelectorAll","length","removeChild","keys","forEach","width","getWidth","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","layerX","getBoundingClientRect","len","peaks","getPeaks","drawPeaks","waveShowedWidth","waveWidth","overviewWidth","offsetWidth","overviewPosition","pixels","pixelRatio","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__"],"mappings":";;;;;CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OAC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D9H,KAAK2B,OAAOhB,UAAUkH,YAAc7H,KAAK4H,cAEjD5H,KAAKgC,eAAeR,MAAMkE,KAAO1F,KAAK8H,iBAAmB,KACrD9H,KAAKoD,mBACLpD,KAAK6B,WAAWF,OAAOkC,QAAQN,WAC3BvD,KAAK8H,iBAAmB9H,KAAKwD,S,sBAIzC,WACI,OAAOxD,KAAK2B,OAAO0D,MAAQrF,KAAKE,OAAO8H,gB,kEC7X3CC,EAA2B,G,OAG/B,SAASC,EAAoBC,GAE5B,IAAIC,EAAeH,EAAyBE,GAC5C,QAAqBE,IAAjBD,EACH,OAAOA,EAAaxI,QAGrB,IAAIC,EAASoI,EAAyBE,GAAY,CAGjDvI,QAAS,IAOV,OAHA0I,EAAoBH,GAAUtI,EAAQA,EAAOD,QAASsI,GAG/CrI,EAAOD,QClBWsI,CAAoB,M","file":"wavesurfer.minimap.min.js","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})(this, function() {\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 /**\n * Minimap needs to listen for the `ready` and `waveform-ready` events\n * to work with the `MediaElement` backend. The moment the `ready` event\n * is called is different (and peaks would not load).\n *\n * @type {string}\n * @see https://github.com/katspaugh/wavesurfer.js/issues/736\n */\n this.renderEvent =\n ws.params.backend === 'MediaElement' ? 'waveform-ready' : 'ready';\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.regions();\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 this.moveOverviewRegion(e.target.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._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.drawer.destroy();\n this.overviewRegion = null;\n this.unAll();\n }\n\n regions() {\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.style(\n document.createElement('overview'),\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 this.drawer.wrapper.appendChild(this.overviewRegion);\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 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.addEventListener('mousedown', event => {\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', event => {\n if (this.draggingOverview) {\n this.moveOverviewRegion(\n event.clientX -\n this.drawer.container.getBoundingClientRect().left -\n relativePositionX\n );\n }\n });\n\n this.drawer.wrapper.addEventListener('mouseup', event => {\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.overviewRegion.style.width = this.overviewWidth + 'px';\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.overviewRegion.style.left = this.overviewPosition + 'px';\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__(521);\n"],"sourceRoot":""}
1
+ {"version":3,"file":"wavesurfer.minimap.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,GAAIA,EAAiB,WAAW,QAAIC,KARjF,CASGK,MAAM,WACT,Y,4QC0BqBC,EAAAA,WAoBjB,WAAYC,EAAQC,GAAI,WAqBpB,G,4FArBoB,SACpBC,KAAKF,OAASG,OAAOC,OACjB,GACAH,EAAGD,OACH,CACIK,aAAa,EACbC,kBAAmBN,EAAOM,mBAAqB,UAC/CC,cAAc,EACdC,oBAAqB,QACrBC,mBAAoB,EAEpBC,WAAW,EACXC,OAAQC,KAAKC,IAAID,KAAKE,MAAMb,EAAGD,OAAOW,O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KAAKC,MAAMrB,KAAK4B,eAAgB,CACjC8D,KAAM1F,KAAK+H,iBAAmB,OAE9B/H,KAAKiD,mBACLjD,KAAK0B,WAAWF,OAAOqC,QAAQN,WAC3BvD,KAAK+H,iBAAmB/H,KAAKwD,S,sBAIzC,WACI,OAAOxD,KAAKwB,OAAO6D,MAAQrF,KAAKF,OAAOmI,gB,gFA7V1BpI,G,kCCnCjBqI,EAA2B,GCE/B,IAAIC,EDCJ,SAASC,EAAoBC,GAE5B,IAAIC,EAAeJ,EAAyBG,GAC5C,QAAqBE,IAAjBD,EACH,OAAOA,EAAa9I,QAGrB,IAAIC,EAASyI,EAAyBG,GAAY,CAGjD7I,QAAS,IAOV,OAHAgJ,EAAoBH,GAAU5I,EAAQA,EAAOD,QAAS4I,GAG/C3I,EAAOD,QClBW4I,CAAoB,K,UHO9C","sources":["webpack://WaveSurfer.[name]/webpack/universalModuleDefinition","webpack://WaveSurfer.[name]/./src/plugin/minimap/index.js","webpack://WaveSurfer.[name]/webpack/bootstrap","webpack://WaveSurfer.[name]/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\"][\"minimap\"] = factory();\n})(self, function() {\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.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.regions();\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._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.drawer.destroy();\n this.overviewRegion = null;\n this.unAll();\n }\n\n regions() {\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 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__(521);\n"],"names":["root","factory","exports","module","define","amd","self","MinimapPlugin","params","ws","this","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","renderEvent","overviewRegion","regionsPlugin","createWrapper","createElements","isInitialised","_onShouldRender","bindWavesurferEvents","bindMinimapEvents","body","contains","insertBefore","regions","render","_onAudioprocess","currentTime","progress","backend","getPlayedPercents","_onSeek","_onScroll","e","draggingOverview","orientedTarget","withOrientation","target","vertical","moveOverviewRegion","scrollLeft","ratio","_onMouseover","prevWidth","_onResize","debounce","wrapper","clientWidth","_onZoom","on","name","deferInit","staticProps","instance","isReady","window","removeEventListener","un","destroy","unAll","region","id","renderRegions","i","regionElements","querySelectorAll","length","removeChild","keys","forEach","width","getWidth","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","len","peaks","getPeaks","drawPeaks","waveShowedWidth","waveWidth","overviewWidth","offsetWidth","overviewPosition","pixels","pixelRatio","__webpack_module_cache__","__webpack_exports__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__"],"sourceRoot":""}
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * wavesurfer.js playhead plugin 5.1.0 (2021-06-20)
2
+ * wavesurfer.js playhead plugin 6.0.2 (2022-02-20)
3
3
  * https://wavesurfer-js.org
4
4
  * @license BSD-3-Clause
5
5
  */
@@ -12,7 +12,7 @@
12
12
  exports["WaveSurfer"] = factory();
13
13
  else
14
14
  root["WaveSurfer"] = root["WaveSurfer"] || {}, root["WaveSurfer"]["playhead"] = factory();
15
- })(this, function() {
15
+ })(self, function() {
16
16
  return /******/ (() => { // webpackBootstrap
17
17
  /******/ "use strict";
18
18
  /******/ var __webpack_modules__ = ({
@@ -28,13 +28,13 @@ return /******/ (() => { // webpackBootstrap
28
28
  Object.defineProperty(exports, "__esModule", ({
29
29
  value: true
30
30
  }));
31
- exports.default = void 0;
31
+ exports["default"] = void 0;
32
32
 
33
33
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
34
34
 
35
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
36
 
37
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
37
+ 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
38
 
39
39
  /**
40
40
  * The playhead plugin separates the notion of the currently playing position from
@@ -279,7 +279,7 @@ var PlayheadPlugin = /*#__PURE__*/function () {
279
279
  return PlayheadPlugin;
280
280
  }();
281
281
 
282
- exports.default = PlayheadPlugin;
282
+ exports["default"] = PlayheadPlugin;
283
283
  module.exports = exports.default;
284
284
 
285
285
  /***/ })