wavesurfer.js 6.0.2 → 6.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/CHANGES.md +22 -0
  2. package/README.md +1 -1
  3. package/dist/plugin/wavesurfer.cursor.js +5 -5
  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 +1 -1
  8. package/dist/plugin/wavesurfer.elan.min.js +1 -1
  9. package/dist/plugin/wavesurfer.markers.js +1 -1
  10. package/dist/plugin/wavesurfer.markers.min.js +1 -1
  11. package/dist/plugin/wavesurfer.mediasession.js +1 -3
  12. package/dist/plugin/wavesurfer.mediasession.js.map +1 -1
  13. package/dist/plugin/wavesurfer.mediasession.min.js +1 -1
  14. package/dist/plugin/wavesurfer.mediasession.min.js.map +1 -1
  15. package/dist/plugin/wavesurfer.microphone.js +1 -1
  16. package/dist/plugin/wavesurfer.microphone.min.js +1 -1
  17. package/dist/plugin/wavesurfer.minimap.js +24 -4
  18. package/dist/plugin/wavesurfer.minimap.js.map +1 -1
  19. package/dist/plugin/wavesurfer.minimap.min.js +2 -2
  20. package/dist/plugin/wavesurfer.minimap.min.js.map +1 -1
  21. package/dist/plugin/wavesurfer.playhead.js +1 -1
  22. package/dist/plugin/wavesurfer.playhead.min.js +1 -1
  23. package/dist/plugin/wavesurfer.regions.js +1 -1
  24. package/dist/plugin/wavesurfer.regions.min.js +1 -1
  25. package/dist/plugin/wavesurfer.spectrogram.js +28 -9
  26. package/dist/plugin/wavesurfer.spectrogram.js.map +1 -1
  27. package/dist/plugin/wavesurfer.spectrogram.min.js +2 -2
  28. package/dist/plugin/wavesurfer.spectrogram.min.js.map +1 -1
  29. package/dist/plugin/wavesurfer.timeline.js +5 -3
  30. package/dist/plugin/wavesurfer.timeline.js.map +1 -1
  31. package/dist/plugin/wavesurfer.timeline.min.js +2 -2
  32. package/dist/plugin/wavesurfer.timeline.min.js.map +1 -1
  33. package/dist/wavesurfer-html-init.js +1 -1
  34. package/dist/wavesurfer-html-init.min.js +1 -1
  35. package/dist/wavesurfer.js +33 -10
  36. package/dist/wavesurfer.js.map +1 -1
  37. package/dist/wavesurfer.min.js +2 -2
  38. package/dist/wavesurfer.min.js.map +1 -1
  39. package/package.json +10 -10
  40. package/src/plugin/cursor/index.js +4 -4
  41. package/src/plugin/mediasession/index.js +0 -2
  42. package/src/plugin/minimap/index.js +17 -2
  43. package/src/plugin/spectrogram/index.js +23 -10
  44. package/src/plugin/timeline/index.js +7 -1
  45. package/src/wavesurfer.js +4 -1
  46. package/src/webaudio.js +24 -7
@@ -1 +1 @@
1
- {"version":3,"file":"wavesurfer.timeline.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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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;AAyDjB;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACI,0BAAYC,MAAZ,EAAoBC,GAApB,EAAwB;AAAA;;AAAA;;AAAA,uCA7CZ,YAAM;AACd,UAAI,KAAI,CAACC,OAAL,IAAgB,KAAI,CAACC,MAAL,CAAYD,OAAhC,EAAyC;AACrC,aAAI,CAACA,OAAL,CAAaE,UAAb,GAA0B,KAAI,CAACD,MAAL,CAAYD,OAAZ,CAAoBE,UAA9C;AACH;AACJ,KAyCuB;;A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I,EAAhB,EAAoB;AAChB,eAAO,CAAP;AACH,OAFD,MAEO,IAAIA,QAAQ,GAAG,CAAX,IAAgB,EAApB,EAAwB;AAC3B,eAAO,CAAP;AACH,OAFM,MAEA,IAAIA,QAAQ,GAAG,EAAX,IAAiB,EAArB,EAAyB;AAC5B,eAAO,CAAP;AACH;;AACD,aAAO,CAAP;AACH;;;;AAphBD;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACI,oBAAczI,MAAd,EAAsB;AAClB,aAAO;AACH2I,QAAAA,IAAI,EAAE,UADH;AAEHC,QAAAA,SAAS,EAAE5I,MAAM,IAAIA,MAAM,CAAC4I,SAAjB,GAA6B5I,MAAM,CAAC4I,SAApC,GAAgD,KAFxD;AAGH5I,QAAAA,MAAM,EAAEA,MAHL;AAIH6I,QAAAA,QAAQ,EAAE9I;AAJP,OAAP;AAMH,MAED;;;;;;;;;;;;;;UC9EJ;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/timeline/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\"][\"timeline\"] = factory();\n})(self, function() {\nreturn ","/**\n * @typedef {Object} TimelinePluginParams\n * @desc Extends the `WavesurferParams` wavesurfer was initialised with\n * @property {!string|HTMLElement} container CSS selector or HTML element where\n * the timeline should be drawn. This is the only required parameter.\n * @property {number} notchPercentHeight=90 Height of notches in percent\n * @property {string} unlabeledNotchColor='#c0c0c0' The colour of the notches\n * that do not have labels\n * @property {string} primaryColor='#000' The colour of the main notches\n * @property {string} secondaryColor='#c0c0c0' The colour of the secondary\n * notches\n * @property {string} primaryFontColor='#000' The colour of the labels next to\n * the main notches\n * @property {string} secondaryFontColor='#000' The colour of the labels next to\n * the secondary notches\n * @property {number} labelPadding=5 The padding between the label and the notch\n * @property {?number} zoomDebounce A debounce timeout to increase rendering\n * performance for large files\n * @property {string} fontFamily='Arial'\n * @property {number} fontSize=10 Font size of labels in pixels\n * @property {?number} duration Length of the track in seconds. Overrides\n * getDuration() for setting length of timeline\n * @property {function} formatTimeCallback (sec, pxPerSec) -> label\n * @property {function} timeInterval (pxPerSec) -> seconds between notches\n * @property {function} primaryLabelInterval (pxPerSec) -> cadence between\n * labels in primary color\n * @property {function} secondaryLabelInterval (pxPerSec) -> cadence between\n * labels in secondary color\n * @property {?number} offset Offset for the timeline start in seconds. May also be\n * negative.\n * @property {?boolean} deferInit Set to true to manually call\n * `initPlugin('timeline')`\n */\n\n/**\n * Adds a timeline to the waveform.\n *\n * @implements {PluginClass}\n * @extends {Observer}\n * @example\n * // es6\n * import TimelinePlugin from 'wavesurfer.timeline.js';\n *\n * // commonjs\n * var TimelinePlugin = require('wavesurfer.timeline.js');\n *\n * // if you are using <script> tags\n * var TimelinePlugin = window.WaveSurfer.timeline;\n *\n * // ... initialising wavesurfer with the plugin\n * var wavesurfer = WaveSurfer.create({\n * // wavesurfer options ...\n * plugins: [\n * TimelinePlugin.create({\n * // plugin options ...\n * })\n * ]\n * });\n */\nexport default class TimelinePlugin {\n /**\n * Timeline 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 {TimelinePluginParams} params parameters use to initialise the plugin\n * @return {PluginDefinition} an object representing the plugin\n */\n static create(params) {\n return {\n name: 'timeline',\n deferInit: params && params.deferInit ? params.deferInit : false,\n params: params,\n instance: TimelinePlugin\n };\n }\n\n // event handlers\n _onScroll = () => {\n if (this.wrapper && this.drawer.wrapper) {\n this.wrapper.scrollLeft = this.drawer.wrapper.scrollLeft;\n }\n };\n\n /**\n * @returns {void}\n */\n _onRedraw = () => this.render();\n\n _onReady = () => {\n const ws = this.wavesurfer;\n this.drawer = ws.drawer;\n this.pixelRatio = ws.drawer.params.pixelRatio;\n this.maxCanvasWidth = ws.drawer.maxCanvasWidth || ws.drawer.width;\n this.maxCanvasElementWidth =\n ws.drawer.maxCanvasElementWidth ||\n Math.round(this.maxCanvasWidth / this.pixelRatio);\n\n // add listeners\n ws.drawer.wrapper.addEventListener('scroll', this._onScroll);\n ws.on('redraw', this._onRedraw);\n ws.on('zoom', this._onZoom);\n\n this.render();\n };\n\n /**\n * @param {object} e Click event\n */\n _onWrapperClick = e => {\n e.preventDefault();\n const relX = 'offsetX' in e ? e.offsetX : e.layerX;\n this.fireEvent('click', relX / this.wrapper.scrollWidth || 0);\n };\n\n /**\n * Creates an instance of TimelinePlugin.\n *\n * You probably want to use TimelinePlugin.create()\n *\n * @param {TimelinePluginParams} params Plugin parameters\n * @param {object} ws Wavesurfer instance\n */\n constructor(params, ws) {\n this.container =\n 'string' == typeof params.container\n ? document.querySelector(params.container)\n : params.container;\n\n if (!this.container) {\n throw new Error('No container for wavesurfer timeline');\n }\n\n this.wavesurfer = ws;\n this.util = ws.util;\n this.params = Object.assign(\n {},\n {\n height: 20,\n notchPercentHeight: 90,\n labelPadding: 5,\n unlabeledNotchColor: '#c0c0c0',\n primaryColor: '#000',\n secondaryColor: '#c0c0c0',\n primaryFontColor: '#000',\n secondaryFontColor: '#000',\n fontFamily: 'Arial',\n fontSize: 10,\n duration: null,\n zoomDebounce: false,\n formatTimeCallback: this.defaultFormatTimeCallback,\n timeInterval: this.defaultTimeInterval,\n primaryLabelInterval: this.defaultPrimaryLabelInterval,\n secondaryLabelInterval: this.defaultSecondaryLabelInterval,\n offset: 0\n },\n params\n );\n\n this.canvases = [];\n this.wrapper = null;\n this.drawer = null;\n this.pixelRatio = null;\n this.maxCanvasWidth = null;\n this.maxCanvasElementWidth = null;\n /**\n * This event handler has to be in the constructor function because it\n * relies on the debounce function which is only available after\n * instantiation\n *\n * Use a debounced function if `params.zoomDebounce` is defined\n *\n * @returns {void}\n */\n this._onZoom = this.params.zoomDebounce\n ? this.wavesurfer.util.debounce(\n () => this.render(),\n this.params.zoomDebounce\n )\n : () => this.render();\n }\n\n /**\n * Initialisation function used by the plugin API\n */\n init() {\n // Check if ws is ready\n if (this.wavesurfer.isReady) {\n this._onReady();\n } else {\n this.wavesurfer.once('ready', this._onReady);\n }\n }\n\n /**\n * Destroy function used by the plugin API\n */\n destroy() {\n this.unAll();\n this.wavesurfer.un('redraw', this._onRedraw);\n this.wavesurfer.un('zoom', this._onZoom);\n this.wavesurfer.un('ready', this._onReady);\n this.wavesurfer.drawer.wrapper.removeEventListener(\n 'scroll',\n this._onScroll\n );\n if (this.wrapper && this.wrapper.parentNode) {\n this.wrapper.removeEventListener('click', this._onWrapperClick);\n this.wrapper.parentNode.removeChild(this.wrapper);\n this.wrapper = null;\n }\n }\n\n /**\n * Create a timeline element to wrap the canvases drawn by this plugin\n *\n */\n createWrapper() {\n const wsParams = this.wavesurfer.params;\n this.container.innerHTML = '';\n this.wrapper = this.container.appendChild(\n document.createElement('timeline')\n );\n this.util.style(this.wrapper, {\n display: 'block',\n position: 'relative',\n userSelect: 'none',\n webkitUserSelect: 'none',\n height: `${this.params.height}px`\n });\n\n if (wsParams.fillParent || wsParams.scrollParent) {\n this.util.style(this.wrapper, {\n width: '100%',\n overflowX: 'hidden',\n overflowY: 'hidden'\n });\n }\n\n this.wrapper.addEventListener('click', this._onWrapperClick);\n }\n\n /**\n * Render the timeline (also updates the already rendered timeline)\n *\n */\n render() {\n if (!this.wrapper) {\n this.createWrapper();\n }\n this.updateCanvases();\n this.updateCanvasesPositioning();\n this.renderCanvases();\n }\n\n /**\n * Add new timeline canvas\n *\n */\n addCanvas() {\n const canvas = this.wrapper.appendChild(\n document.createElement('canvas')\n );\n this.canvases.push(canvas);\n this.util.style(canvas, {\n position: 'absolute',\n zIndex: 4\n });\n }\n\n /**\n * Remove timeline canvas\n *\n */\n removeCanvas() {\n const canvas = this.canvases.pop();\n canvas.parentElement.removeChild(canvas);\n }\n\n /**\n * Make sure the correct of timeline canvas elements exist and are cached in\n * this.canvases\n *\n */\n updateCanvases() {\n const totalWidth = Math.round(this.drawer.wrapper.scrollWidth);\n const requiredCanvases = Math.ceil(\n totalWidth / this.maxCanvasElementWidth\n );\n\n while (this.canvases.length < requiredCanvases) {\n this.addCanvas();\n }\n\n while (this.canvases.length > requiredCanvases) {\n this.removeCanvas();\n }\n }\n\n /**\n * Update the dimensions and positioning style for all the timeline canvases\n *\n */\n updateCanvasesPositioning() {\n // cache length for performance\n const canvasesLength = this.canvases.length;\n this.canvases.forEach((canvas, i) => {\n // canvas width is the max element width, or if it is the last the\n // required width\n const canvasWidth =\n i === canvasesLength - 1\n ? this.drawer.wrapper.scrollWidth -\n this.maxCanvasElementWidth * (canvasesLength - 1)\n : this.maxCanvasElementWidth;\n // set dimensions and style\n canvas.width = canvasWidth * this.pixelRatio;\n // on certain pixel ratios the canvas appears cut off at the bottom,\n // therefore leave 1px extra\n canvas.height = (this.params.height + 1) * this.pixelRatio;\n this.util.style(canvas, {\n width: `${canvasWidth}px`,\n height: `${this.params.height}px`,\n left: `${i * this.maxCanvasElementWidth}px`\n });\n });\n }\n\n /**\n * Render the timeline labels and notches\n *\n */\n renderCanvases() {\n const duration =\n this.params.duration ||\n this.wavesurfer.backend.getDuration();\n\n if (duration <= 0) {\n return;\n }\n const wsParams = this.wavesurfer.params;\n const fontSize = this.params.fontSize * wsParams.pixelRatio;\n const totalSeconds = parseInt(duration, 10) + 1;\n const width =\n wsParams.fillParent && !wsParams.scrollParent\n ? this.drawer.getWidth()\n : this.drawer.wrapper.scrollWidth * wsParams.pixelRatio;\n const height1 = this.params.height * this.pixelRatio;\n const height2 =\n this.params.height *\n (this.params.notchPercentHeight / 100) *\n this.pixelRatio;\n const pixelsPerSecond = width / duration;\n\n const formatTime = this.params.formatTimeCallback;\n // if parameter is function, call the function with\n // pixelsPerSecond, otherwise simply take the value as-is\n const intervalFnOrVal = option =>\n typeof option === 'function' ? option(pixelsPerSecond) : option;\n const timeInterval = intervalFnOrVal(this.params.timeInterval);\n const primaryLabelInterval = intervalFnOrVal(\n this.params.primaryLabelInterval\n );\n const secondaryLabelInterval = intervalFnOrVal(\n this.params.secondaryLabelInterval\n );\n\n let curPixel = pixelsPerSecond * this.params.offset;\n let curSeconds = 0;\n let i;\n // build an array of position data with index, second and pixel data,\n // this is then used multiple times below\n const positioning = [];\n for (i = 0; i < totalSeconds / timeInterval; i++) {\n positioning.push([i, curSeconds, curPixel]);\n curSeconds += timeInterval;\n curPixel += pixelsPerSecond * timeInterval;\n }\n\n // iterate over each position\n const renderPositions = cb => {\n positioning.forEach(pos => {\n cb(pos[0], pos[1], pos[2]);\n });\n };\n\n // render primary labels\n this.setFillStyles(this.params.primaryColor);\n this.setFonts(`${fontSize}px ${this.params.fontFamily}`);\n this.setFillStyles(this.params.primaryFontColor);\n renderPositions((i, curSeconds, curPixel) => {\n if (i % primaryLabelInterval === 0) {\n this.fillRect(curPixel, 0, 1, height1);\n this.fillText(\n formatTime(curSeconds, pixelsPerSecond),\n curPixel + this.params.labelPadding * this.pixelRatio,\n height1\n );\n }\n });\n\n // render secondary labels\n this.setFillStyles(this.params.secondaryColor);\n this.setFonts(`${fontSize}px ${this.params.fontFamily}`);\n this.setFillStyles(this.params.secondaryFontColor);\n renderPositions((i, curSeconds, curPixel) => {\n if (i % secondaryLabelInterval === 0) {\n this.fillRect(curPixel, 0, 1, height1);\n this.fillText(\n formatTime(curSeconds, pixelsPerSecond),\n curPixel + this.params.labelPadding * this.pixelRatio,\n height1\n );\n }\n });\n\n // render the actual notches (when no labels are used)\n this.setFillStyles(this.params.unlabeledNotchColor);\n renderPositions((i, curSeconds, curPixel) => {\n if (\n i % secondaryLabelInterval !== 0 &&\n i % primaryLabelInterval !== 0\n ) {\n this.fillRect(curPixel, 0, 1, height2);\n }\n });\n }\n\n /**\n * Set the canvas fill style\n *\n * @param {DOMString|CanvasGradient|CanvasPattern} fillStyle Fill style to\n * use\n */\n setFillStyles(fillStyle) {\n this.canvases.forEach(canvas => {\n const context = canvas.getContext('2d');\n if (context) {\n context.fillStyle = fillStyle;\n }\n });\n }\n\n /**\n * Set the canvas font\n *\n * @param {DOMString} font Font to use\n */\n setFonts(font) {\n this.canvases.forEach(canvas => {\n const context = canvas.getContext('2d');\n if (context) {\n context.font = font;\n }\n });\n }\n\n /**\n * Draw a rectangle on the canvases\n *\n * (it figures out the offset for each canvas)\n *\n * @param {number} x X-position\n * @param {number} y Y-position\n * @param {number} width Width\n * @param {number} height Height\n */\n fillRect(x, y, width, height) {\n this.canvases.forEach((canvas, i) => {\n const leftOffset = i * this.maxCanvasWidth;\n\n const intersection = {\n x1: Math.max(x, i * this.maxCanvasWidth),\n y1: y,\n x2: Math.min(x + width, i * this.maxCanvasWidth + canvas.width),\n y2: y + height\n };\n\n if (intersection.x1 < intersection.x2) {\n const context = canvas\n .getContext('2d');\n if (context) {\n context\n .fillRect(\n intersection.x1 - leftOffset,\n intersection.y1,\n intersection.x2 - intersection.x1,\n intersection.y2 - intersection.y1\n );\n }\n }\n });\n }\n\n /**\n * Fill a given text on the canvases\n *\n * @param {string} text Text to render\n * @param {number} x X-position\n * @param {number} y Y-position\n */\n fillText(text, x, y) {\n let textWidth;\n let xOffset = 0;\n\n this.canvases.forEach(canvas => {\n const context = canvas.getContext('2d');\n if (context) {\n const canvasWidth = context.canvas.width;\n\n if (xOffset > x + textWidth) {\n return;\n }\n\n if (xOffset + canvasWidth > x && context) {\n textWidth = context.measureText(text).width;\n context.fillText(text, x - xOffset, y);\n }\n\n xOffset += canvasWidth;\n }\n });\n }\n\n /**\n * Turn the time into a suitable label for the time.\n *\n * @param {number} seconds Seconds to format\n * @param {number} pxPerSec Pixels per second\n * @returns {number} Time\n */\n defaultFormatTimeCallback(seconds, pxPerSec) {\n if (seconds / 60 > 1) {\n // calculate minutes and seconds from seconds count\n const minutes = parseInt(seconds / 60, 10);\n seconds = parseInt(seconds % 60, 10);\n // fill up seconds with zeroes\n seconds = seconds < 10 ? '0' + seconds : seconds;\n return `${minutes}:${seconds}`;\n }\n return Math.round(seconds * 1000) / 1000;\n }\n\n /**\n * Return how many seconds should be between each notch\n *\n * @param {number} pxPerSec Pixels per second\n * @returns {number} Time\n */\n defaultTimeInterval(pxPerSec) {\n if (pxPerSec >= 25) {\n return 1;\n } else if (pxPerSec * 5 >= 25) {\n return 5;\n } else if (pxPerSec * 15 >= 25) {\n return 15;\n }\n return Math.ceil(0.5 / pxPerSec) * 60;\n }\n\n /**\n * Return the cadence of notches that get labels in the primary color.\n *\n * @param {number} pxPerSec Pixels per second\n * @returns {number} Cadence\n */\n defaultPrimaryLabelInterval(pxPerSec) {\n if (pxPerSec >= 25) {\n return 10;\n } else if (pxPerSec * 5 >= 25) {\n return 6;\n } else if (pxPerSec * 15 >= 25) {\n return 4;\n }\n return 4;\n }\n\n /**\n * Return the cadence of notches that get labels in the secondary color.\n *\n * @param {number} pxPerSec Pixels per second\n * @returns {number} Cadence\n */\n defaultSecondaryLabelInterval(pxPerSec) {\n if (pxPerSec >= 25) {\n return 5;\n } else if (pxPerSec * 5 >= 25) {\n return 2;\n } else if (pxPerSec * 15 >= 25) {\n return 2;\n }\n return 2;\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/timeline/index.js\");\n",""],"names":["TimelinePlugin","params","ws","wrapper","drawer","scrollLeft","render","wavesurfer","pixelRatio","maxCanvasWidth","width","maxCanvasElementWidth","Math","round","addEventListener","_onScroll","on","_onRedraw","_onZoom","e","preventDefault","relX","offsetX","layerX","fireEvent","scrollWidth","container","document","querySelector","Error","util","Object","assign","height","notchPercentHeight","labelPadding","unlabeledNotchColor","primaryColor","secondaryColor","primaryFontColor","secondaryFontColor","fontFamily","fontSize","duration","zoomDebounce","formatTimeCallback","defaultFormatTimeCallback","timeInterval","defaultTimeInterval","primaryLabelInterval","defaultPrimaryLabelInterval","secondaryLabelInterval","defaultSecondaryLabelInterval","offset","canvases","debounce","isReady","_onReady","once","unAll","un","removeEventListener","parentNode","_onWrapperClick","removeChild","wsParams","innerHTML","appendChild","createElement","style","display","position","userSelect","webkitUserSelect","fillParent","scrollParent","overflowX","overflowY","createWrapper","updateCanvases","updateCanvasesPositioning","renderCanvases","canvas","push","zIndex","pop","parentElement","totalWidth","requiredCanvases","ceil","length","addCanvas","removeCanvas","canvasesLength","forEach","i","canvasWidth","left","backend","getDuration","totalSeconds","parseInt","getWidth","height1","height2","pixelsPerSecond","formatTime","intervalFnOrVal","option","curPixel","curSeconds","positioning","renderPositions","cb","pos","setFillStyles","setFonts","fillRect","fillText","fillStyle","context","getContext","font","x","y","leftOffset","intersection","x1","max","y1","x2","min","y2","text","textWidth","xOffset","measureText","seconds","pxPerSec","minutes","name","deferInit","instance"],"sourceRoot":""}
1
+ {"version":3,"file":"wavesurfer.timeline.js","mappings":";;;;;AAAA;AACA;A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AIA,MAAM,CAAC6I,SAAjB,GAA6B7I,MAAM,CAAC6I,SAApC,GAAgD,KAFxD;AAGH7I,QAAAA,MAAM,EAAEA,MAHL;AAIH8I,QAAAA,QAAQ,EAAE/I;AAJP,OAAP;AAMH,MAED;;;;;;;;;;;;;;UC9EJ;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/timeline/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\"][\"timeline\"] = factory();\n})(self, function() {\nreturn ","/**\n * @typedef {Object} TimelinePluginParams\n * @desc Extends the `WavesurferParams` wavesurfer was initialised with\n * @property {!string|HTMLElement} container CSS selector or HTML element where\n * the timeline should be drawn. This is the only required parameter.\n * @property {number} notchPercentHeight=90 Height of notches in percent\n * @property {string} unlabeledNotchColor='#c0c0c0' The colour of the notches\n * that do not have labels\n * @property {string} primaryColor='#000' The colour of the main notches\n * @property {string} secondaryColor='#c0c0c0' The colour of the secondary\n * notches\n * @property {string} primaryFontColor='#000' The colour of the labels next to\n * the main notches\n * @property {string} secondaryFontColor='#000' The colour of the labels next to\n * the secondary notches\n * @property {number} labelPadding=5 The padding between the label and the notch\n * @property {?number} zoomDebounce A debounce timeout to increase rendering\n * performance for large files\n * @property {string} fontFamily='Arial'\n * @property {number} fontSize=10 Font size of labels in pixels\n * @property {?number} duration Length of the track in seconds. Overrides\n * getDuration() for setting length of timeline\n * @property {function} formatTimeCallback (sec, pxPerSec) -> label\n * @property {function} timeInterval (pxPerSec) -> seconds between notches\n * @property {function} primaryLabelInterval (pxPerSec) -> cadence between\n * labels in primary color\n * @property {function} secondaryLabelInterval (pxPerSec) -> cadence between\n * labels in secondary color\n * @property {?number} offset Offset for the timeline start in seconds. May also be\n * negative.\n * @property {?boolean} deferInit Set to true to manually call\n * `initPlugin('timeline')`\n */\n\n/**\n * Adds a timeline to the waveform.\n *\n * @implements {PluginClass}\n * @extends {Observer}\n * @example\n * // es6\n * import TimelinePlugin from 'wavesurfer.timeline.js';\n *\n * // commonjs\n * var TimelinePlugin = require('wavesurfer.timeline.js');\n *\n * // if you are using <script> tags\n * var TimelinePlugin = window.WaveSurfer.timeline;\n *\n * // ... initialising wavesurfer with the plugin\n * var wavesurfer = WaveSurfer.create({\n * // wavesurfer options ...\n * plugins: [\n * TimelinePlugin.create({\n * // plugin options ...\n * })\n * ]\n * });\n */\nexport default class TimelinePlugin {\n /**\n * Timeline 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 {TimelinePluginParams} params parameters use to initialise the plugin\n * @return {PluginDefinition} an object representing the plugin\n */\n static create(params) {\n return {\n name: 'timeline',\n deferInit: params && params.deferInit ? params.deferInit : false,\n params: params,\n instance: TimelinePlugin\n };\n }\n\n // event handlers\n _onScroll = () => {\n if (this.wrapper && this.drawer.wrapper) {\n this.wrapper.scrollLeft = this.drawer.wrapper.scrollLeft;\n }\n };\n\n /**\n * @returns {void}\n */\n _onRedraw = () => this.render();\n\n _onReady = () => {\n const ws = this.wavesurfer;\n this.drawer = ws.drawer;\n this.pixelRatio = ws.drawer.params.pixelRatio;\n this.maxCanvasWidth = ws.drawer.maxCanvasWidth || ws.drawer.width;\n this.maxCanvasElementWidth =\n ws.drawer.maxCanvasElementWidth ||\n Math.round(this.maxCanvasWidth / this.pixelRatio);\n\n // add listeners\n ws.drawer.wrapper.addEventListener('scroll', this._onScroll);\n ws.on('redraw', this._onRedraw);\n ws.on('zoom', this._onZoom);\n\n this.render();\n };\n\n /**\n * @param {object} e Click event\n */\n _onWrapperClick = e => {\n e.preventDefault();\n const relX = 'offsetX' in e ? e.offsetX : e.layerX;\n this.fireEvent('click', relX / this.wrapper.scrollWidth || 0);\n };\n\n /**\n * Creates an instance of TimelinePlugin.\n *\n * You probably want to use TimelinePlugin.create()\n *\n * @param {TimelinePluginParams} params Plugin parameters\n * @param {object} ws Wavesurfer instance\n */\n constructor(params, ws) {\n this.container =\n 'string' == typeof params.container\n ? document.querySelector(params.container)\n : params.container;\n\n if (!this.container) {\n throw new Error('No container for wavesurfer timeline');\n }\n\n this.wavesurfer = ws;\n this.util = ws.util;\n this.params = Object.assign(\n {},\n {\n height: 20,\n notchPercentHeight: 90,\n labelPadding: 5,\n unlabeledNotchColor: '#c0c0c0',\n primaryColor: '#000',\n secondaryColor: '#c0c0c0',\n primaryFontColor: '#000',\n secondaryFontColor: '#000',\n fontFamily: 'Arial',\n fontSize: 10,\n duration: null,\n zoomDebounce: false,\n formatTimeCallback: this.defaultFormatTimeCallback,\n timeInterval: this.defaultTimeInterval,\n primaryLabelInterval: this.defaultPrimaryLabelInterval,\n secondaryLabelInterval: this.defaultSecondaryLabelInterval,\n offset: 0\n },\n params\n );\n\n this.canvases = [];\n this.wrapper = null;\n this.drawer = null;\n this.pixelRatio = null;\n this.maxCanvasWidth = null;\n this.maxCanvasElementWidth = null;\n /**\n * This event handler has to be in the constructor function because it\n * relies on the debounce function which is only available after\n * instantiation\n *\n * Use a debounced function if `params.zoomDebounce` is defined\n *\n * @returns {void}\n */\n this._onZoom = this.params.zoomDebounce\n ? this.wavesurfer.util.debounce(\n () => this.render(),\n this.params.zoomDebounce\n )\n : () => this.render();\n }\n\n /**\n * Initialisation function used by the plugin API\n */\n init() {\n // Check if ws is ready\n if (this.wavesurfer.isReady) {\n this._onReady();\n } else {\n this.wavesurfer.once('ready', this._onReady);\n }\n }\n\n /**\n * Destroy function used by the plugin API\n */\n destroy() {\n this.unAll();\n this.wavesurfer.un('redraw', this._onRedraw);\n this.wavesurfer.un('zoom', this._onZoom);\n this.wavesurfer.un('ready', this._onReady);\n this.wavesurfer.drawer.wrapper.removeEventListener(\n 'scroll',\n this._onScroll\n );\n if (this.wrapper && this.wrapper.parentNode) {\n this.wrapper.removeEventListener('click', this._onWrapperClick);\n this.wrapper.parentNode.removeChild(this.wrapper);\n this.wrapper = null;\n }\n }\n\n /**\n * Create a timeline element to wrap the canvases drawn by this plugin\n *\n */\n createWrapper() {\n const wsParams = this.wavesurfer.params;\n this.container.innerHTML = '';\n this.wrapper = this.container.appendChild(\n document.createElement('timeline')\n );\n this.util.style(this.wrapper, {\n display: 'block',\n position: 'relative',\n userSelect: 'none',\n webkitUserSelect: 'none',\n height: `${this.params.height}px`\n });\n\n if (wsParams.fillParent || wsParams.scrollParent) {\n this.util.style(this.wrapper, {\n width: '100%',\n overflowX: 'hidden',\n overflowY: 'hidden'\n });\n }\n\n this.wrapper.addEventListener('click', this._onWrapperClick);\n }\n\n /**\n * Render the timeline (also updates the already rendered timeline)\n *\n */\n render() {\n if (!this.wrapper) {\n this.createWrapper();\n }\n this.updateCanvases();\n this.updateCanvasesPositioning();\n this.renderCanvases();\n }\n\n /**\n * Add new timeline canvas\n *\n */\n addCanvas() {\n const canvas = this.wrapper.appendChild(\n document.createElement('canvas')\n );\n this.canvases.push(canvas);\n this.util.style(canvas, {\n position: 'absolute',\n zIndex: 4\n });\n }\n\n /**\n * Remove timeline canvas\n *\n */\n removeCanvas() {\n const canvas = this.canvases.pop();\n canvas.parentElement.removeChild(canvas);\n }\n\n /**\n * Make sure the correct of timeline canvas elements exist and are cached in\n * this.canvases\n *\n */\n updateCanvases() {\n const totalWidth = Math.round(this.drawer.wrapper.scrollWidth);\n const requiredCanvases = Math.ceil(\n totalWidth / this.maxCanvasElementWidth\n );\n\n while (this.canvases.length < requiredCanvases) {\n this.addCanvas();\n }\n\n while (this.canvases.length > requiredCanvases) {\n this.removeCanvas();\n }\n }\n\n /**\n * Update the dimensions and positioning style for all the timeline canvases\n *\n */\n updateCanvasesPositioning() {\n // cache length for performance\n const canvasesLength = this.canvases.length;\n this.canvases.forEach((canvas, i) => {\n // canvas width is the max element width, or if it is the last the\n // required width\n const canvasWidth =\n i === canvasesLength - 1\n ? this.drawer.wrapper.scrollWidth -\n this.maxCanvasElementWidth * (canvasesLength - 1)\n : this.maxCanvasElementWidth;\n // set dimensions and style\n canvas.width = canvasWidth * this.pixelRatio;\n // on certain pixel ratios the canvas appears cut off at the bottom,\n // therefore leave 1px extra\n canvas.height = (this.params.height + 1) * this.pixelRatio;\n this.util.style(canvas, {\n width: `${canvasWidth}px`,\n height: `${this.params.height}px`,\n left: `${i * this.maxCanvasElementWidth}px`\n });\n });\n }\n\n /**\n * Render the timeline labels and notches\n *\n */\n renderCanvases() {\n const duration =\n this.params.duration ||\n this.wavesurfer.backend.getDuration();\n\n if (duration <= 0) {\n return;\n }\n const wsParams = this.wavesurfer.params;\n const fontSize = this.params.fontSize * wsParams.pixelRatio;\n const totalSeconds = parseInt(duration, 10) + 1;\n const width =\n wsParams.fillParent && !wsParams.scrollParent\n ? this.drawer.getWidth()\n : this.drawer.wrapper.scrollWidth * wsParams.pixelRatio;\n const height1 = this.params.height * this.pixelRatio;\n const height2 =\n this.params.height *\n (this.params.notchPercentHeight / 100) *\n this.pixelRatio;\n const pixelsPerSecond = width / duration;\n\n const formatTime = this.params.formatTimeCallback;\n // if parameter is function, call the function with\n // pixelsPerSecond, otherwise simply take the value as-is\n const intervalFnOrVal = option =>\n typeof option === 'function' ? option(pixelsPerSecond) : option;\n const timeInterval = intervalFnOrVal(this.params.timeInterval);\n const primaryLabelInterval = intervalFnOrVal(\n this.params.primaryLabelInterval\n );\n const secondaryLabelInterval = intervalFnOrVal(\n this.params.secondaryLabelInterval\n );\n\n let curPixel = pixelsPerSecond * this.params.offset;\n let curSeconds = 0;\n let i;\n // build an array of position data with index, second and pixel data,\n // this is then used multiple times below\n const positioning = [];\n\n // render until end in case we have a negative offset\n const renderSeconds = (this.params.offset < 0)\n ? totalSeconds - this.params.offset\n : totalSeconds;\n\n for (i = 0; i < renderSeconds / timeInterval; i++) {\n positioning.push([i, curSeconds, curPixel]);\n curSeconds += timeInterval;\n curPixel += pixelsPerSecond * timeInterval;\n }\n\n // iterate over each position\n const renderPositions = cb => {\n positioning.forEach(pos => {\n cb(pos[0], pos[1], pos[2]);\n });\n };\n\n // render primary labels\n this.setFillStyles(this.params.primaryColor);\n this.setFonts(`${fontSize}px ${this.params.fontFamily}`);\n this.setFillStyles(this.params.primaryFontColor);\n renderPositions((i, curSeconds, curPixel) => {\n if (i % primaryLabelInterval === 0) {\n this.fillRect(curPixel, 0, 1, height1);\n this.fillText(\n formatTime(curSeconds, pixelsPerSecond),\n curPixel + this.params.labelPadding * this.pixelRatio,\n height1\n );\n }\n });\n\n // render secondary labels\n this.setFillStyles(this.params.secondaryColor);\n this.setFonts(`${fontSize}px ${this.params.fontFamily}`);\n this.setFillStyles(this.params.secondaryFontColor);\n renderPositions((i, curSeconds, curPixel) => {\n if (i % secondaryLabelInterval === 0) {\n this.fillRect(curPixel, 0, 1, height1);\n this.fillText(\n formatTime(curSeconds, pixelsPerSecond),\n curPixel + this.params.labelPadding * this.pixelRatio,\n height1\n );\n }\n });\n\n // render the actual notches (when no labels are used)\n this.setFillStyles(this.params.unlabeledNotchColor);\n renderPositions((i, curSeconds, curPixel) => {\n if (\n i % secondaryLabelInterval !== 0 &&\n i % primaryLabelInterval !== 0\n ) {\n this.fillRect(curPixel, 0, 1, height2);\n }\n });\n }\n\n /**\n * Set the canvas fill style\n *\n * @param {DOMString|CanvasGradient|CanvasPattern} fillStyle Fill style to\n * use\n */\n setFillStyles(fillStyle) {\n this.canvases.forEach(canvas => {\n const context = canvas.getContext('2d');\n if (context) {\n context.fillStyle = fillStyle;\n }\n });\n }\n\n /**\n * Set the canvas font\n *\n * @param {DOMString} font Font to use\n */\n setFonts(font) {\n this.canvases.forEach(canvas => {\n const context = canvas.getContext('2d');\n if (context) {\n context.font = font;\n }\n });\n }\n\n /**\n * Draw a rectangle on the canvases\n *\n * (it figures out the offset for each canvas)\n *\n * @param {number} x X-position\n * @param {number} y Y-position\n * @param {number} width Width\n * @param {number} height Height\n */\n fillRect(x, y, width, height) {\n this.canvases.forEach((canvas, i) => {\n const leftOffset = i * this.maxCanvasWidth;\n\n const intersection = {\n x1: Math.max(x, i * this.maxCanvasWidth),\n y1: y,\n x2: Math.min(x + width, i * this.maxCanvasWidth + canvas.width),\n y2: y + height\n };\n\n if (intersection.x1 < intersection.x2) {\n const context = canvas\n .getContext('2d');\n if (context) {\n context\n .fillRect(\n intersection.x1 - leftOffset,\n intersection.y1,\n intersection.x2 - intersection.x1,\n intersection.y2 - intersection.y1\n );\n }\n }\n });\n }\n\n /**\n * Fill a given text on the canvases\n *\n * @param {string} text Text to render\n * @param {number} x X-position\n * @param {number} y Y-position\n */\n fillText(text, x, y) {\n let textWidth;\n let xOffset = 0;\n\n this.canvases.forEach(canvas => {\n const context = canvas.getContext('2d');\n if (context) {\n const canvasWidth = context.canvas.width;\n\n if (xOffset > x + textWidth) {\n return;\n }\n\n if (xOffset + canvasWidth > x && context) {\n textWidth = context.measureText(text).width;\n context.fillText(text, x - xOffset, y);\n }\n\n xOffset += canvasWidth;\n }\n });\n }\n\n /**\n * Turn the time into a suitable label for the time.\n *\n * @param {number} seconds Seconds to format\n * @param {number} pxPerSec Pixels per second\n * @returns {number} Time\n */\n defaultFormatTimeCallback(seconds, pxPerSec) {\n if (seconds / 60 > 1) {\n // calculate minutes and seconds from seconds count\n const minutes = parseInt(seconds / 60, 10);\n seconds = parseInt(seconds % 60, 10);\n // fill up seconds with zeroes\n seconds = seconds < 10 ? '0' + seconds : seconds;\n return `${minutes}:${seconds}`;\n }\n return Math.round(seconds * 1000) / 1000;\n }\n\n /**\n * Return how many seconds should be between each notch\n *\n * @param {number} pxPerSec Pixels per second\n * @returns {number} Time\n */\n defaultTimeInterval(pxPerSec) {\n if (pxPerSec >= 25) {\n return 1;\n } else if (pxPerSec * 5 >= 25) {\n return 5;\n } else if (pxPerSec * 15 >= 25) {\n return 15;\n }\n return Math.ceil(0.5 / pxPerSec) * 60;\n }\n\n /**\n * Return the cadence of notches that get labels in the primary color.\n *\n * @param {number} pxPerSec Pixels per second\n * @returns {number} Cadence\n */\n defaultPrimaryLabelInterval(pxPerSec) {\n if (pxPerSec >= 25) {\n return 10;\n } else if (pxPerSec * 5 >= 25) {\n return 6;\n } else if (pxPerSec * 15 >= 25) {\n return 4;\n }\n return 4;\n }\n\n /**\n * Return the cadence of notches that get labels in the secondary color.\n *\n * @param {number} pxPerSec Pixels per second\n * @returns {number} Cadence\n */\n defaultSecondaryLabelInterval(pxPerSec) {\n if (pxPerSec >= 25) {\n return 5;\n } else if (pxPerSec * 5 >= 25) {\n return 2;\n } else if (pxPerSec * 15 >= 25) {\n return 2;\n }\n return 2;\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/timeline/index.js\");\n",""],"names":["TimelinePlugin","params","ws","wrapper","drawer","scrollLeft","render","wavesurfer","pixelRatio","maxCanvasWidth","width","maxCanvasElementWidth","Math","round","addEventListener","_onScroll","on","_onRedraw","_onZoom","e","preventDefault","relX","offsetX","layerX","fireEvent","scrollWidth","container","document","querySelector","Error","util","Object","assign","height","notchPercentHeight","labelPadding","unlabeledNotchColor","primaryColor","secondaryColor","primaryFontColor","secondaryFontColor","fontFamily","fontSize","duration","zoomDebounce","formatTimeCallback","defaultFormatTimeCallback","timeInterval","defaultTimeInterval","primaryLabelInterval","defaultPrimaryLabelInterval","secondaryLabelInterval","defaultSecondaryLabelInterval","offset","canvases","debounce","isReady","_onReady","once","unAll","un","removeEventListener","parentNode","_onWrapperClick","removeChild","wsParams","innerHTML","appendChild","createElement","style","display","position","userSelect","webkitUserSelect","fillParent","scrollParent","overflowX","overflowY","createWrapper","updateCanvases","updateCanvasesPositioning","renderCanvases","canvas","push","zIndex","pop","parentElement","totalWidth","requiredCanvases","ceil","length","addCanvas","removeCanvas","canvasesLength","forEach","i","canvasWidth","left","backend","getDuration","totalSeconds","parseInt","getWidth","height1","height2","pixelsPerSecond","formatTime","intervalFnOrVal","option","curPixel","curSeconds","positioning","renderSeconds","renderPositions","cb","pos","setFillStyles","setFonts","fillRect","fillText","fillStyle","context","getContext","font","x","y","leftOffset","intersection","x1","max","y1","x2","min","y2","text","textWidth","xOffset","measureText","seconds","pxPerSec","minutes","name","deferInit","instance"],"sourceRoot":""}
@@ -1,7 +1,7 @@
1
1
  /*!
2
- * wavesurfer.js timeline plugin 6.0.2 (2022-02-20)
2
+ * wavesurfer.js timeline plugin 6.1.0 (2022-03-31)
3
3
  * https://wavesurfer-js.org
4
4
  * @license BSD-3-Clause
5
5
  */
6
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("WaveSurfer",[],t):"object"==typeof exports?exports.WaveSurfer=t():(e.WaveSurfer=e.WaveSurfer||{},e.WaveSurfer.timeline=t())}(self,(function(){return(()=>{"use strict";var e={171:(e,t)=>{function a(e,t){for(var a=0;a<t.length;a++){var r=t[a];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function r(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i=function(){function e(t,a){var i=this;if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),r(this,"_onScroll",(function(){i.wrapper&&i.drawer.wrapper&&(i.wrapper.scrollLeft=i.drawer.wrapper.scrollLeft)})),r(this,"_onRedraw",(function(){return i.render()})),r(this,"_onReady",(function(){var e=i.wavesurfer;i.drawer=e.drawer,i.pixelRatio=e.drawer.params.pixelRatio,i.maxCanvasWidth=e.drawer.maxCanvasWidth||e.drawer.width,i.maxCanvasElementWidth=e.drawer.maxCanvasElementWidth||Math.round(i.maxCanvasWidth/i.pixelRatio),e.drawer.wrapper.addEventListener("scroll",i._onScroll),e.on("redraw",i._onRedraw),e.on("zoom",i._onZoom),i.render()})),r(this,"_onWrapperClick",(function(e){e.preventDefault();var t="offsetX"in e?e.offsetX:e.layerX;i.fireEvent("click",t/i.wrapper.scrollWidth||0)})),this.container="string"==typeof t.container?document.querySelector(t.container):t.container,!this.container)throw new Error("No container for wavesurfer timeline");this.wavesurfer=a,this.util=a.util,this.params=Object.assign({},{height:20,notchPercentHeight:90,labelPadding:5,unlabeledNotchColor:"#c0c0c0",primaryColor:"#000",secondaryColor:"#c0c0c0",primaryFontColor:"#000",secondaryFontColor:"#000",fontFamily:"Arial",fontSize:10,duration:null,zoomDebounce:!1,formatTimeCallback:this.defaultFormatTimeCallback,timeInterval:this.defaultTimeInterval,primaryLabelInterval:this.defaultPrimaryLabelInterval,secondaryLabelInterval:this.defaultSecondaryLabelInterval,offset:0},t),this.canvases=[],this.wrapper=null,this.drawer=null,this.pixelRatio=null,this.maxCanvasWidth=null,this.maxCanvasElementWidth=null,this._onZoom=this.params.zoomDebounce?this.wavesurfer.util.debounce((function(){return i.render()}),this.params.zoomDebounce):function(){return i.render()}}var t,i,n;return t=e,n=[{key:"create",value:function(t){return{name:"timeline",deferInit:!(!t||!t.deferInit)&&t.deferInit,params:t,instance:e}}}],(i=[{key:"init",value:function(){this.wavesurfer.isReady?this._onReady():this.wavesurfer.once("ready",this._onReady)}},{key:"destroy",value:function(){this.unAll(),this.wavesurfer.un("redraw",this._onRedraw),this.wavesurfer.un("zoom",this._onZoom),this.wavesurfer.un("ready",this._onReady),this.wavesurfer.drawer.wrapper.removeEventListener("scroll",this._onScroll),this.wrapper&&this.wrapper.parentNode&&(this.wrapper.removeEventListener("click",this._onWrapperClick),this.wrapper.parentNode.removeChild(this.wrapper),this.wrapper=null)}},{key:"createWrapper",value:function(){var e=this.wavesurfer.params;this.container.innerHTML="",this.wrapper=this.container.appendChild(document.createElement("timeline")),this.util.style(this.wrapper,{display:"block",position:"relative",userSelect:"none",webkitUserSelect:"none",height:"".concat(this.params.height,"px")}),(e.fillParent||e.scrollParent)&&this.util.style(this.wrapper,{width:"100%",overflowX:"hidden",overflowY:"hidden"}),this.wrapper.addEventListener("click",this._onWrapperClick)}},{key:"render",value:function(){this.wrapper||this.createWrapper(),this.updateCanvases(),this.updateCanvasesPositioning(),this.renderCanvases()}},{key:"addCanvas",value:function(){var e=this.wrapper.appendChild(document.createElement("canvas"));this.canvases.push(e),this.util.style(e,{position:"absolute",zIndex:4})}},{key:"removeCanvas",value:function(){var e=this.canvases.pop();e.parentElement.removeChild(e)}},{key:"updateCanvases",value:function(){for(var e=Math.round(this.drawer.wrapper.scrollWidth),t=Math.ceil(e/this.maxCanvasElementWidth);this.canvases.length<t;)this.addCanvas();for(;this.canvases.length>t;)this.removeCanvas()}},{key:"updateCanvasesPositioning",value:function(){var e=this,t=this.canvases.length;this.canvases.forEach((function(a,r){var i=r===t-1?e.drawer.wrapper.scrollWidth-e.maxCanvasElementWidth*(t-1):e.maxCanvasElementWidth;a.width=i*e.pixelRatio,a.height=(e.params.height+1)*e.pixelRatio,e.util.style(a,{width:"".concat(i,"px"),height:"".concat(e.params.height,"px"),left:"".concat(r*e.maxCanvasElementWidth,"px")})}))}},{key:"renderCanvases",value:function(){var e=this,t=this.params.duration||this.wavesurfer.backend.getDuration();if(!(t<=0)){var a,r=this.wavesurfer.params,i=this.params.fontSize*r.pixelRatio,n=parseInt(t,10)+1,s=r.fillParent&&!r.scrollParent?this.drawer.getWidth():this.drawer.wrapper.scrollWidth*r.pixelRatio,o=this.params.height*this.pixelRatio,l=this.params.height*(this.params.notchPercentHeight/100)*this.pixelRatio,h=s/t,c=this.params.formatTimeCallback,u=function(e){return"function"==typeof e?e(h):e},p=u(this.params.timeInterval),f=u(this.params.primaryLabelInterval),d=u(this.params.secondaryLabelInterval),v=h*this.params.offset,m=0,y=[];for(a=0;a<n/p;a++)y.push([a,m,v]),m+=p,v+=h*p;var w=function(e){y.forEach((function(t){e(t[0],t[1],t[2])}))};this.setFillStyles(this.params.primaryColor),this.setFonts("".concat(i,"px ").concat(this.params.fontFamily)),this.setFillStyles(this.params.primaryFontColor),w((function(t,a,r){t%f==0&&(e.fillRect(r,0,1,o),e.fillText(c(a,h),r+e.params.labelPadding*e.pixelRatio,o))})),this.setFillStyles(this.params.secondaryColor),this.setFonts("".concat(i,"px ").concat(this.params.fontFamily)),this.setFillStyles(this.params.secondaryFontColor),w((function(t,a,r){t%d==0&&(e.fillRect(r,0,1,o),e.fillText(c(a,h),r+e.params.labelPadding*e.pixelRatio,o))})),this.setFillStyles(this.params.unlabeledNotchColor),w((function(t,a,r){t%d!=0&&t%f!=0&&e.fillRect(r,0,1,l)}))}}},{key:"setFillStyles",value:function(e){this.canvases.forEach((function(t){var a=t.getContext("2d");a&&(a.fillStyle=e)}))}},{key:"setFonts",value:function(e){this.canvases.forEach((function(t){var a=t.getContext("2d");a&&(a.font=e)}))}},{key:"fillRect",value:function(e,t,a,r){var i=this;this.canvases.forEach((function(n,s){var o=s*i.maxCanvasWidth,l={x1:Math.max(e,s*i.maxCanvasWidth),y1:t,x2:Math.min(e+a,s*i.maxCanvasWidth+n.width),y2:t+r};if(l.x1<l.x2){var h=n.getContext("2d");h&&h.fillRect(l.x1-o,l.y1,l.x2-l.x1,l.y2-l.y1)}}))}},{key:"fillText",value:function(e,t,a){var r,i=0;this.canvases.forEach((function(n){var s=n.getContext("2d");if(s){var o=s.canvas.width;if(i>t+r)return;i+o>t&&s&&(r=s.measureText(e).width,s.fillText(e,t-i,a)),i+=o}}))}},{key:"defaultFormatTimeCallback",value:function(e,t){if(e/60>1){var a=parseInt(e/60,10);return e=(e=parseInt(e%60,10))<10?"0"+e:e,"".concat(a,":").concat(e)}return Math.round(1e3*e)/1e3}},{key:"defaultTimeInterval",value:function(e){return e>=25?1:5*e>=25?5:15*e>=25?15:60*Math.ceil(.5/e)}},{key:"defaultPrimaryLabelInterval",value:function(e){return e>=25?10:5*e>=25?6:4}},{key:"defaultSecondaryLabelInterval",value:function(e){return e>=25?5:2}}])&&a(t.prototype,i),n&&a(t,n),Object.defineProperty(t,"prototype",{writable:!1}),e}();t.default=i,e.exports=t.default}},t={};var a=function a(r){var i=t[r];if(void 0!==i)return i.exports;var n=t[r]={exports:{}};return e[r](n,n.exports,a),n.exports}(171);return a})()}));
6
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("WaveSurfer",[],t):"object"==typeof exports?exports.WaveSurfer=t():(e.WaveSurfer=e.WaveSurfer||{},e.WaveSurfer.timeline=t())}(self,(function(){return(()=>{"use strict";var e={171:(e,t)=>{function a(e,t){for(var a=0;a<t.length;a++){var r=t[a];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function r(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i=function(){function e(t,a){var i=this;if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),r(this,"_onScroll",(function(){i.wrapper&&i.drawer.wrapper&&(i.wrapper.scrollLeft=i.drawer.wrapper.scrollLeft)})),r(this,"_onRedraw",(function(){return i.render()})),r(this,"_onReady",(function(){var e=i.wavesurfer;i.drawer=e.drawer,i.pixelRatio=e.drawer.params.pixelRatio,i.maxCanvasWidth=e.drawer.maxCanvasWidth||e.drawer.width,i.maxCanvasElementWidth=e.drawer.maxCanvasElementWidth||Math.round(i.maxCanvasWidth/i.pixelRatio),e.drawer.wrapper.addEventListener("scroll",i._onScroll),e.on("redraw",i._onRedraw),e.on("zoom",i._onZoom),i.render()})),r(this,"_onWrapperClick",(function(e){e.preventDefault();var t="offsetX"in e?e.offsetX:e.layerX;i.fireEvent("click",t/i.wrapper.scrollWidth||0)})),this.container="string"==typeof t.container?document.querySelector(t.container):t.container,!this.container)throw new Error("No container for wavesurfer timeline");this.wavesurfer=a,this.util=a.util,this.params=Object.assign({},{height:20,notchPercentHeight:90,labelPadding:5,unlabeledNotchColor:"#c0c0c0",primaryColor:"#000",secondaryColor:"#c0c0c0",primaryFontColor:"#000",secondaryFontColor:"#000",fontFamily:"Arial",fontSize:10,duration:null,zoomDebounce:!1,formatTimeCallback:this.defaultFormatTimeCallback,timeInterval:this.defaultTimeInterval,primaryLabelInterval:this.defaultPrimaryLabelInterval,secondaryLabelInterval:this.defaultSecondaryLabelInterval,offset:0},t),this.canvases=[],this.wrapper=null,this.drawer=null,this.pixelRatio=null,this.maxCanvasWidth=null,this.maxCanvasElementWidth=null,this._onZoom=this.params.zoomDebounce?this.wavesurfer.util.debounce((function(){return i.render()}),this.params.zoomDebounce):function(){return i.render()}}var t,i,n;return t=e,n=[{key:"create",value:function(t){return{name:"timeline",deferInit:!(!t||!t.deferInit)&&t.deferInit,params:t,instance:e}}}],(i=[{key:"init",value:function(){this.wavesurfer.isReady?this._onReady():this.wavesurfer.once("ready",this._onReady)}},{key:"destroy",value:function(){this.unAll(),this.wavesurfer.un("redraw",this._onRedraw),this.wavesurfer.un("zoom",this._onZoom),this.wavesurfer.un("ready",this._onReady),this.wavesurfer.drawer.wrapper.removeEventListener("scroll",this._onScroll),this.wrapper&&this.wrapper.parentNode&&(this.wrapper.removeEventListener("click",this._onWrapperClick),this.wrapper.parentNode.removeChild(this.wrapper),this.wrapper=null)}},{key:"createWrapper",value:function(){var e=this.wavesurfer.params;this.container.innerHTML="",this.wrapper=this.container.appendChild(document.createElement("timeline")),this.util.style(this.wrapper,{display:"block",position:"relative",userSelect:"none",webkitUserSelect:"none",height:"".concat(this.params.height,"px")}),(e.fillParent||e.scrollParent)&&this.util.style(this.wrapper,{width:"100%",overflowX:"hidden",overflowY:"hidden"}),this.wrapper.addEventListener("click",this._onWrapperClick)}},{key:"render",value:function(){this.wrapper||this.createWrapper(),this.updateCanvases(),this.updateCanvasesPositioning(),this.renderCanvases()}},{key:"addCanvas",value:function(){var e=this.wrapper.appendChild(document.createElement("canvas"));this.canvases.push(e),this.util.style(e,{position:"absolute",zIndex:4})}},{key:"removeCanvas",value:function(){var e=this.canvases.pop();e.parentElement.removeChild(e)}},{key:"updateCanvases",value:function(){for(var e=Math.round(this.drawer.wrapper.scrollWidth),t=Math.ceil(e/this.maxCanvasElementWidth);this.canvases.length<t;)this.addCanvas();for(;this.canvases.length>t;)this.removeCanvas()}},{key:"updateCanvasesPositioning",value:function(){var e=this,t=this.canvases.length;this.canvases.forEach((function(a,r){var i=r===t-1?e.drawer.wrapper.scrollWidth-e.maxCanvasElementWidth*(t-1):e.maxCanvasElementWidth;a.width=i*e.pixelRatio,a.height=(e.params.height+1)*e.pixelRatio,e.util.style(a,{width:"".concat(i,"px"),height:"".concat(e.params.height,"px"),left:"".concat(r*e.maxCanvasElementWidth,"px")})}))}},{key:"renderCanvases",value:function(){var e=this,t=this.params.duration||this.wavesurfer.backend.getDuration();if(!(t<=0)){var a,r=this.wavesurfer.params,i=this.params.fontSize*r.pixelRatio,n=parseInt(t,10)+1,s=r.fillParent&&!r.scrollParent?this.drawer.getWidth():this.drawer.wrapper.scrollWidth*r.pixelRatio,o=this.params.height*this.pixelRatio,l=this.params.height*(this.params.notchPercentHeight/100)*this.pixelRatio,h=s/t,c=this.params.formatTimeCallback,u=function(e){return"function"==typeof e?e(h):e},p=u(this.params.timeInterval),f=u(this.params.primaryLabelInterval),d=u(this.params.secondaryLabelInterval),v=h*this.params.offset,m=0,y=[],w=this.params.offset<0?n-this.params.offset:n;for(a=0;a<w/p;a++)y.push([a,m,v]),m+=p,v+=h*p;var x=function(e){y.forEach((function(t){e(t[0],t[1],t[2])}))};this.setFillStyles(this.params.primaryColor),this.setFonts("".concat(i,"px ").concat(this.params.fontFamily)),this.setFillStyles(this.params.primaryFontColor),x((function(t,a,r){t%f==0&&(e.fillRect(r,0,1,o),e.fillText(c(a,h),r+e.params.labelPadding*e.pixelRatio,o))})),this.setFillStyles(this.params.secondaryColor),this.setFonts("".concat(i,"px ").concat(this.params.fontFamily)),this.setFillStyles(this.params.secondaryFontColor),x((function(t,a,r){t%d==0&&(e.fillRect(r,0,1,o),e.fillText(c(a,h),r+e.params.labelPadding*e.pixelRatio,o))})),this.setFillStyles(this.params.unlabeledNotchColor),x((function(t,a,r){t%d!=0&&t%f!=0&&e.fillRect(r,0,1,l)}))}}},{key:"setFillStyles",value:function(e){this.canvases.forEach((function(t){var a=t.getContext("2d");a&&(a.fillStyle=e)}))}},{key:"setFonts",value:function(e){this.canvases.forEach((function(t){var a=t.getContext("2d");a&&(a.font=e)}))}},{key:"fillRect",value:function(e,t,a,r){var i=this;this.canvases.forEach((function(n,s){var o=s*i.maxCanvasWidth,l={x1:Math.max(e,s*i.maxCanvasWidth),y1:t,x2:Math.min(e+a,s*i.maxCanvasWidth+n.width),y2:t+r};if(l.x1<l.x2){var h=n.getContext("2d");h&&h.fillRect(l.x1-o,l.y1,l.x2-l.x1,l.y2-l.y1)}}))}},{key:"fillText",value:function(e,t,a){var r,i=0;this.canvases.forEach((function(n){var s=n.getContext("2d");if(s){var o=s.canvas.width;if(i>t+r)return;i+o>t&&s&&(r=s.measureText(e).width,s.fillText(e,t-i,a)),i+=o}}))}},{key:"defaultFormatTimeCallback",value:function(e,t){if(e/60>1){var a=parseInt(e/60,10);return e=(e=parseInt(e%60,10))<10?"0"+e:e,"".concat(a,":").concat(e)}return Math.round(1e3*e)/1e3}},{key:"defaultTimeInterval",value:function(e){return e>=25?1:5*e>=25?5:15*e>=25?15:60*Math.ceil(.5/e)}},{key:"defaultPrimaryLabelInterval",value:function(e){return e>=25?10:5*e>=25?6:4}},{key:"defaultSecondaryLabelInterval",value:function(e){return e>=25?5:2}}])&&a(t.prototype,i),n&&a(t,n),Object.defineProperty(t,"prototype",{writable:!1}),e}();t.default=i,e.exports=t.default}},t={};var a=function a(r){var i=t[r];if(void 0!==i)return i.exports;var n=t[r]={exports:{}};return e[r](n,n.exports,a),n.exports}(171);return a})()}));
7
7
  //# sourceMappingURL=wavesurfer.timeline.min.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"wavesurfer.timeline.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,WAAY,SAAIC,KARlF,CASGK,MAAM,WACT,Y,oYCiDqBC,EAAAA,WAiEjB,WAAYC,EAAQC,GAAI,WAMpB,G,4FANoB,6BA7CZ,WACJ,EAAKC,SAAW,EAAKC,OAAOD,UAC5B,EAAKA,QAAQE,WAAa,EAAKD,OAAOD,QAAQE,eA2C9B,oBApCZ,kBAAM,EAAKC,YAoCC,mBAlCb,WACP,IAAMJ,EAAK,EAAKK,WAChB,EAAKH,OAASF,EAAGE,OACjB,EAAKI,WAA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AClB,IAAMsC,EAAUtC,EAAOuC,WAAW,MAClC,GAAID,EAAS,CACT,IAAMxB,EAAcwB,EAAQtC,OAAO5E,MAEnC,GAAIiI,EAAUZ,EAAIW,EACd,OAGAC,EAAUvC,EAAc2B,GAAKH,IAC7Bc,EAAYd,EAAQgB,YAAYH,GAAM/H,MACtCkH,EAAQF,SAASe,EAAMV,EAAIY,EAASX,IAGxCW,GAAWvC,Q,uCAYvB,SAA0ByC,EAASC,GAC/B,GAAID,EAAU,GAAK,EAAG,CAElB,IAAME,EAAUtC,SAASoC,EAAU,GAAI,IAIvC,OADAA,GAFAA,EAAUpC,SAASoC,EAAU,GAAI,KAEb,GAAK,IAAMA,EAAUA,EACzC,UAAUE,EAAV,YAAqBF,GAEzB,OAAOjI,KAAKC,MAAgB,IAAVgI,GAAkB,M,iCASxC,SAAoBC,GAChB,OAAIA,GAAY,GACL,EACW,EAAXA,GAAgB,GAChB,EACW,GAAXA,GAAiB,GACjB,GAEwB,GAA5BlI,KAAKiF,KAAK,GAAMiD,K,yCAS3B,SAA4BA,GACxB,OAAIA,GAAY,GACL,GACW,EAAXA,GAAgB,GAChB,EAEA,I,2CAWf,SAA8BA,GAC1B,OAAIA,GAAY,GACL,EAEA,O,gFAhhBE9I,G,kCC1DjBgJ,EAA2B,GCE/B,IAAIC,EDCJ,SAASC,EAAoBC,GAE5B,IAAIC,EAAeJ,EAAyBG,GAC5C,QAAqBE,IAAjBD,EACH,OAAOA,EAAazJ,QAGrB,IAAIC,EAASoJ,EAAyBG,GAAY,CAGjDxJ,QAAS,IAOV,OAHA2J,EAAoBH,GAAUvJ,EAAQA,EAAOD,QAASuJ,GAG/CtJ,EAAOD,QClBWuJ,CAAoB,K,UHO9C","sources":["webpack://WaveSurfer.[name]/webpack/universalModuleDefinition","webpack://WaveSurfer.[name]/./src/plugin/timeline/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\"][\"timeline\"] = factory();\n})(self, function() {\nreturn ","/**\n * @typedef {Object} TimelinePluginParams\n * @desc Extends the `WavesurferParams` wavesurfer was initialised with\n * @property {!string|HTMLElement} container CSS selector or HTML element where\n * the timeline should be drawn. This is the only required parameter.\n * @property {number} notchPercentHeight=90 Height of notches in percent\n * @property {string} unlabeledNotchColor='#c0c0c0' The colour of the notches\n * that do not have labels\n * @property {string} primaryColor='#000' The colour of the main notches\n * @property {string} secondaryColor='#c0c0c0' The colour of the secondary\n * notches\n * @property {string} primaryFontColor='#000' The colour of the labels next to\n * the main notches\n * @property {string} secondaryFontColor='#000' The colour of the labels next to\n * the secondary notches\n * @property {number} labelPadding=5 The padding between the label and the notch\n * @property {?number} zoomDebounce A debounce timeout to increase rendering\n * performance for large files\n * @property {string} fontFamily='Arial'\n * @property {number} fontSize=10 Font size of labels in pixels\n * @property {?number} duration Length of the track in seconds. Overrides\n * getDuration() for setting length of timeline\n * @property {function} formatTimeCallback (sec, pxPerSec) -> label\n * @property {function} timeInterval (pxPerSec) -> seconds between notches\n * @property {function} primaryLabelInterval (pxPerSec) -> cadence between\n * labels in primary color\n * @property {function} secondaryLabelInterval (pxPerSec) -> cadence between\n * labels in secondary color\n * @property {?number} offset Offset for the timeline start in seconds. May also be\n * negative.\n * @property {?boolean} deferInit Set to true to manually call\n * `initPlugin('timeline')`\n */\n\n/**\n * Adds a timeline to the waveform.\n *\n * @implements {PluginClass}\n * @extends {Observer}\n * @example\n * // es6\n * import TimelinePlugin from 'wavesurfer.timeline.js';\n *\n * // commonjs\n * var TimelinePlugin = require('wavesurfer.timeline.js');\n *\n * // if you are using <script> tags\n * var TimelinePlugin = window.WaveSurfer.timeline;\n *\n * // ... initialising wavesurfer with the plugin\n * var wavesurfer = WaveSurfer.create({\n * // wavesurfer options ...\n * plugins: [\n * TimelinePlugin.create({\n * // plugin options ...\n * })\n * ]\n * });\n */\nexport default class TimelinePlugin {\n /**\n * Timeline 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 {TimelinePluginParams} params parameters use to initialise the plugin\n * @return {PluginDefinition} an object representing the plugin\n */\n static create(params) {\n return {\n name: 'timeline',\n deferInit: params && params.deferInit ? params.deferInit : false,\n params: params,\n instance: TimelinePlugin\n };\n }\n\n // event handlers\n _onScroll = () => {\n if (this.wrapper && this.drawer.wrapper) {\n this.wrapper.scrollLeft = this.drawer.wrapper.scrollLeft;\n }\n };\n\n /**\n * @returns {void}\n */\n _onRedraw = () => this.render();\n\n _onReady = () => {\n const ws = this.wavesurfer;\n this.drawer = ws.drawer;\n this.pixelRatio = ws.drawer.params.pixelRatio;\n this.maxCanvasWidth = ws.drawer.maxCanvasWidth || ws.drawer.width;\n this.maxCanvasElementWidth =\n ws.drawer.maxCanvasElementWidth ||\n Math.round(this.maxCanvasWidth / this.pixelRatio);\n\n // add listeners\n ws.drawer.wrapper.addEventListener('scroll', this._onScroll);\n ws.on('redraw', this._onRedraw);\n ws.on('zoom', this._onZoom);\n\n this.render();\n };\n\n /**\n * @param {object} e Click event\n */\n _onWrapperClick = e => {\n e.preventDefault();\n const relX = 'offsetX' in e ? e.offsetX : e.layerX;\n this.fireEvent('click', relX / this.wrapper.scrollWidth || 0);\n };\n\n /**\n * Creates an instance of TimelinePlugin.\n *\n * You probably want to use TimelinePlugin.create()\n *\n * @param {TimelinePluginParams} params Plugin parameters\n * @param {object} ws Wavesurfer instance\n */\n constructor(params, ws) {\n this.container =\n 'string' == typeof params.container\n ? document.querySelector(params.container)\n : params.container;\n\n if (!this.container) {\n throw new Error('No container for wavesurfer timeline');\n }\n\n this.wavesurfer = ws;\n this.util = ws.util;\n this.params = Object.assign(\n {},\n {\n height: 20,\n notchPercentHeight: 90,\n labelPadding: 5,\n unlabeledNotchColor: '#c0c0c0',\n primaryColor: '#000',\n secondaryColor: '#c0c0c0',\n primaryFontColor: '#000',\n secondaryFontColor: '#000',\n fontFamily: 'Arial',\n fontSize: 10,\n duration: null,\n zoomDebounce: false,\n formatTimeCallback: this.defaultFormatTimeCallback,\n timeInterval: this.defaultTimeInterval,\n primaryLabelInterval: this.defaultPrimaryLabelInterval,\n secondaryLabelInterval: this.defaultSecondaryLabelInterval,\n offset: 0\n },\n params\n );\n\n this.canvases = [];\n this.wrapper = null;\n this.drawer = null;\n this.pixelRatio = null;\n this.maxCanvasWidth = null;\n this.maxCanvasElementWidth = null;\n /**\n * This event handler has to be in the constructor function because it\n * relies on the debounce function which is only available after\n * instantiation\n *\n * Use a debounced function if `params.zoomDebounce` is defined\n *\n * @returns {void}\n */\n this._onZoom = this.params.zoomDebounce\n ? this.wavesurfer.util.debounce(\n () => this.render(),\n this.params.zoomDebounce\n )\n : () => this.render();\n }\n\n /**\n * Initialisation function used by the plugin API\n */\n init() {\n // Check if ws is ready\n if (this.wavesurfer.isReady) {\n this._onReady();\n } else {\n this.wavesurfer.once('ready', this._onReady);\n }\n }\n\n /**\n * Destroy function used by the plugin API\n */\n destroy() {\n this.unAll();\n this.wavesurfer.un('redraw', this._onRedraw);\n this.wavesurfer.un('zoom', this._onZoom);\n this.wavesurfer.un('ready', this._onReady);\n this.wavesurfer.drawer.wrapper.removeEventListener(\n 'scroll',\n this._onScroll\n );\n if (this.wrapper && this.wrapper.parentNode) {\n this.wrapper.removeEventListener('click', this._onWrapperClick);\n this.wrapper.parentNode.removeChild(this.wrapper);\n this.wrapper = null;\n }\n }\n\n /**\n * Create a timeline element to wrap the canvases drawn by this plugin\n *\n */\n createWrapper() {\n const wsParams = this.wavesurfer.params;\n this.container.innerHTML = '';\n this.wrapper = this.container.appendChild(\n document.createElement('timeline')\n );\n this.util.style(this.wrapper, {\n display: 'block',\n position: 'relative',\n userSelect: 'none',\n webkitUserSelect: 'none',\n height: `${this.params.height}px`\n });\n\n if (wsParams.fillParent || wsParams.scrollParent) {\n this.util.style(this.wrapper, {\n width: '100%',\n overflowX: 'hidden',\n overflowY: 'hidden'\n });\n }\n\n this.wrapper.addEventListener('click', this._onWrapperClick);\n }\n\n /**\n * Render the timeline (also updates the already rendered timeline)\n *\n */\n render() {\n if (!this.wrapper) {\n this.createWrapper();\n }\n this.updateCanvases();\n this.updateCanvasesPositioning();\n this.renderCanvases();\n }\n\n /**\n * Add new timeline canvas\n *\n */\n addCanvas() {\n const canvas = this.wrapper.appendChild(\n document.createElement('canvas')\n );\n this.canvases.push(canvas);\n this.util.style(canvas, {\n position: 'absolute',\n zIndex: 4\n });\n }\n\n /**\n * Remove timeline canvas\n *\n */\n removeCanvas() {\n const canvas = this.canvases.pop();\n canvas.parentElement.removeChild(canvas);\n }\n\n /**\n * Make sure the correct of timeline canvas elements exist and are cached in\n * this.canvases\n *\n */\n updateCanvases() {\n const totalWidth = Math.round(this.drawer.wrapper.scrollWidth);\n const requiredCanvases = Math.ceil(\n totalWidth / this.maxCanvasElementWidth\n );\n\n while (this.canvases.length < requiredCanvases) {\n this.addCanvas();\n }\n\n while (this.canvases.length > requiredCanvases) {\n this.removeCanvas();\n }\n }\n\n /**\n * Update the dimensions and positioning style for all the timeline canvases\n *\n */\n updateCanvasesPositioning() {\n // cache length for performance\n const canvasesLength = this.canvases.length;\n this.canvases.forEach((canvas, i) => {\n // canvas width is the max element width, or if it is the last the\n // required width\n const canvasWidth =\n i === canvasesLength - 1\n ? this.drawer.wrapper.scrollWidth -\n this.maxCanvasElementWidth * (canvasesLength - 1)\n : this.maxCanvasElementWidth;\n // set dimensions and style\n canvas.width = canvasWidth * this.pixelRatio;\n // on certain pixel ratios the canvas appears cut off at the bottom,\n // therefore leave 1px extra\n canvas.height = (this.params.height + 1) * this.pixelRatio;\n this.util.style(canvas, {\n width: `${canvasWidth}px`,\n height: `${this.params.height}px`,\n left: `${i * this.maxCanvasElementWidth}px`\n });\n });\n }\n\n /**\n * Render the timeline labels and notches\n *\n */\n renderCanvases() {\n const duration =\n this.params.duration ||\n this.wavesurfer.backend.getDuration();\n\n if (duration <= 0) {\n return;\n }\n const wsParams = this.wavesurfer.params;\n const fontSize = this.params.fontSize * wsParams.pixelRatio;\n const totalSeconds = parseInt(duration, 10) + 1;\n const width =\n wsParams.fillParent && !wsParams.scrollParent\n ? this.drawer.getWidth()\n : this.drawer.wrapper.scrollWidth * wsParams.pixelRatio;\n const height1 = this.params.height * this.pixelRatio;\n const height2 =\n this.params.height *\n (this.params.notchPercentHeight / 100) *\n this.pixelRatio;\n const pixelsPerSecond = width / duration;\n\n const formatTime = this.params.formatTimeCallback;\n // if parameter is function, call the function with\n // pixelsPerSecond, otherwise simply take the value as-is\n const intervalFnOrVal = option =>\n typeof option === 'function' ? option(pixelsPerSecond) : option;\n const timeInterval = intervalFnOrVal(this.params.timeInterval);\n const primaryLabelInterval = intervalFnOrVal(\n this.params.primaryLabelInterval\n );\n const secondaryLabelInterval = intervalFnOrVal(\n this.params.secondaryLabelInterval\n );\n\n let curPixel = pixelsPerSecond * this.params.offset;\n let curSeconds = 0;\n let i;\n // build an array of position data with index, second and pixel data,\n // this is then used multiple times below\n const positioning = [];\n for (i = 0; i < totalSeconds / timeInterval; i++) {\n positioning.push([i, curSeconds, curPixel]);\n curSeconds += timeInterval;\n curPixel += pixelsPerSecond * timeInterval;\n }\n\n // iterate over each position\n const renderPositions = cb => {\n positioning.forEach(pos => {\n cb(pos[0], pos[1], pos[2]);\n });\n };\n\n // render primary labels\n this.setFillStyles(this.params.primaryColor);\n this.setFonts(`${fontSize}px ${this.params.fontFamily}`);\n this.setFillStyles(this.params.primaryFontColor);\n renderPositions((i, curSeconds, curPixel) => {\n if (i % primaryLabelInterval === 0) {\n this.fillRect(curPixel, 0, 1, height1);\n this.fillText(\n formatTime(curSeconds, pixelsPerSecond),\n curPixel + this.params.labelPadding * this.pixelRatio,\n height1\n );\n }\n });\n\n // render secondary labels\n this.setFillStyles(this.params.secondaryColor);\n this.setFonts(`${fontSize}px ${this.params.fontFamily}`);\n this.setFillStyles(this.params.secondaryFontColor);\n renderPositions((i, curSeconds, curPixel) => {\n if (i % secondaryLabelInterval === 0) {\n this.fillRect(curPixel, 0, 1, height1);\n this.fillText(\n formatTime(curSeconds, pixelsPerSecond),\n curPixel + this.params.labelPadding * this.pixelRatio,\n height1\n );\n }\n });\n\n // render the actual notches (when no labels are used)\n this.setFillStyles(this.params.unlabeledNotchColor);\n renderPositions((i, curSeconds, curPixel) => {\n if (\n i % secondaryLabelInterval !== 0 &&\n i % primaryLabelInterval !== 0\n ) {\n this.fillRect(curPixel, 0, 1, height2);\n }\n });\n }\n\n /**\n * Set the canvas fill style\n *\n * @param {DOMString|CanvasGradient|CanvasPattern} fillStyle Fill style to\n * use\n */\n setFillStyles(fillStyle) {\n this.canvases.forEach(canvas => {\n const context = canvas.getContext('2d');\n if (context) {\n context.fillStyle = fillStyle;\n }\n });\n }\n\n /**\n * Set the canvas font\n *\n * @param {DOMString} font Font to use\n */\n setFonts(font) {\n this.canvases.forEach(canvas => {\n const context = canvas.getContext('2d');\n if (context) {\n context.font = font;\n }\n });\n }\n\n /**\n * Draw a rectangle on the canvases\n *\n * (it figures out the offset for each canvas)\n *\n * @param {number} x X-position\n * @param {number} y Y-position\n * @param {number} width Width\n * @param {number} height Height\n */\n fillRect(x, y, width, height) {\n this.canvases.forEach((canvas, i) => {\n const leftOffset = i * this.maxCanvasWidth;\n\n const intersection = {\n x1: Math.max(x, i * this.maxCanvasWidth),\n y1: y,\n x2: Math.min(x + width, i * this.maxCanvasWidth + canvas.width),\n y2: y + height\n };\n\n if (intersection.x1 < intersection.x2) {\n const context = canvas\n .getContext('2d');\n if (context) {\n context\n .fillRect(\n intersection.x1 - leftOffset,\n intersection.y1,\n intersection.x2 - intersection.x1,\n intersection.y2 - intersection.y1\n );\n }\n }\n });\n }\n\n /**\n * Fill a given text on the canvases\n *\n * @param {string} text Text to render\n * @param {number} x X-position\n * @param {number} y Y-position\n */\n fillText(text, x, y) {\n let textWidth;\n let xOffset = 0;\n\n this.canvases.forEach(canvas => {\n const context = canvas.getContext('2d');\n if (context) {\n const canvasWidth = context.canvas.width;\n\n if (xOffset > x + textWidth) {\n return;\n }\n\n if (xOffset + canvasWidth > x && context) {\n textWidth = context.measureText(text).width;\n context.fillText(text, x - xOffset, y);\n }\n\n xOffset += canvasWidth;\n }\n });\n }\n\n /**\n * Turn the time into a suitable label for the time.\n *\n * @param {number} seconds Seconds to format\n * @param {number} pxPerSec Pixels per second\n * @returns {number} Time\n */\n defaultFormatTimeCallback(seconds, pxPerSec) {\n if (seconds / 60 > 1) {\n // calculate minutes and seconds from seconds count\n const minutes = parseInt(seconds / 60, 10);\n seconds = parseInt(seconds % 60, 10);\n // fill up seconds with zeroes\n seconds = seconds < 10 ? '0' + seconds : seconds;\n return `${minutes}:${seconds}`;\n }\n return Math.round(seconds * 1000) / 1000;\n }\n\n /**\n * Return how many seconds should be between each notch\n *\n * @param {number} pxPerSec Pixels per second\n * @returns {number} Time\n */\n defaultTimeInterval(pxPerSec) {\n if (pxPerSec >= 25) {\n return 1;\n } else if (pxPerSec * 5 >= 25) {\n return 5;\n } else if (pxPerSec * 15 >= 25) {\n return 15;\n }\n return Math.ceil(0.5 / pxPerSec) * 60;\n }\n\n /**\n * Return the cadence of notches that get labels in the primary color.\n *\n * @param {number} pxPerSec Pixels per second\n * @returns {number} Cadence\n */\n defaultPrimaryLabelInterval(pxPerSec) {\n if (pxPerSec >= 25) {\n return 10;\n } else if (pxPerSec * 5 >= 25) {\n return 6;\n } else if (pxPerSec * 15 >= 25) {\n return 4;\n }\n return 4;\n }\n\n /**\n * Return the cadence of notches that get labels in the secondary color.\n *\n * @param {number} pxPerSec Pixels per second\n * @returns {number} Cadence\n */\n defaultSecondaryLabelInterval(pxPerSec) {\n if (pxPerSec >= 25) {\n return 5;\n } else if (pxPerSec * 5 >= 25) {\n return 2;\n } else if (pxPerSec * 15 >= 25) {\n return 2;\n }\n return 2;\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__(171);\n"],"names":["root","factory","exports","module","define","amd","self","TimelinePlugin","params","ws","wrapper","drawer","scrollLeft","render","wavesurfer","pixelRatio","maxCanvasWidth","width","maxCanvasElementWidth","Math","round","addEventListener","_onScroll","on","_onRedraw","_onZoom","e","preventDefault","relX","offsetX","layerX","fireEvent","scrollWidth","this","container","document","querySelector","Error","util","Object","assign","height","notchPercentHeight","labelPadding","unlabeledNotchColor","primaryColor","secondaryColor","primaryFontColor","secondaryFontColor","fontFamily","fontSize","duration","zoomDebounce","formatTimeCallback","defaultFormatTimeCallback","timeInterval","defaultTimeInterval","primaryLabelInterval","defaultPrimaryLabelInterval","secondaryLabelInterval","defaultSecondaryLabelInterval","offset","canvases","debounce","name","deferInit","instance","isReady","_onReady","once","unAll","un","removeEventListener","parentNode","_onWrapperClick","removeChild","wsParams","innerHTML","appendChild","createElement","style","display","position","userSelect","webkitUserSelect","fillParent","scrollParent","overflowX","overflowY","createWrapper","updateCanvases","updateCanvasesPositioning","renderCanvases","canvas","push","zIndex","pop","parentElement","totalWidth","requiredCanvases","ceil","length","addCanvas","removeCanvas","canvasesLength","forEach","i","canvasWidth","left","backend","getDuration","totalSeconds","parseInt","getWidth","height1","height2","pixelsPerSecond","formatTime","intervalFnOrVal","option","curPixel","curSeconds","positioning","renderPositions","cb","pos","setFillStyles","setFonts","fillRect","fillText","fillStyle","context","getContext","font","x","y","leftOffset","intersection","x1","max","y1","x2","min","y2","text","textWidth","xOffset","measureText","seconds","pxPerSec","minutes","__webpack_module_cache__","__webpack_exports__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__"],"sourceRoot":""}
1
+ {"version":3,"file":"wavesurfer.timeline.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,WAAY,SAAIC,KARlF,CASGK,MAAM,WACT,Y,oYCiDqBC,EAAAA,WAiEjB,WAAYC,EAAQC,GAAI,WAMpB,G,4FANoB,6BA7CZ,WACJ,EAAKC,SAAW,EAAKC,OAAOD,UAC5B,EAAKA,QAAQE,WAAa,EAAKD,OAAOD,QAAQE,eA2C9B,oBApCZ,kBAAM,EAAKC,YAoCC,mBAlCb,WACP,IAAMJ,EAAK,EAAKK,WAChB,EAAKH,OAASF,EAAGE,OACjB,EAAKI,WAAaN,EAAGE,OAAOH,OAAOO,WACnC,EAAKC,eAAiBP,EAAGE,OAAOK,gBAAkBP,EAAGE,OAAOM,MAC5D,EAAKC,sBACDT,EAAGE,OAAOO,uBACVC,KAAKC,MAAM,EAAKJ,eAAiB,EAAKD,YAG1CN,EAAGE,OAAOD,QAAQW,iBAAiB,SAAU,EAAKC,WAClDb,EAAGc,GAAG,SAAU,EAAKC,WACrBf,EAAGc,GAAG,OAAQ,EAAKE,SAEnB,EAAKZ,YAoBe,0BAdN,SAAAa,GACdA,EAAEC,iBAC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,GAAWxC,Q,uCAYvB,SAA0B0C,EAASC,GAC/B,GAAID,EAAU,GAAK,EAAG,CAElB,IAAME,EAAUvC,SAASqC,EAAU,GAAI,IAIvC,OADAA,GAFAA,EAAUrC,SAASqC,EAAU,GAAI,KAEb,GAAK,IAAMA,EAAUA,EACzC,UAAUE,EAAV,YAAqBF,GAEzB,OAAOlI,KAAKC,MAAgB,IAAViI,GAAkB,M,iCASxC,SAAoBC,GAChB,OAAIA,GAAY,GACL,EACW,EAAXA,GAAgB,GAChB,EACW,GAAXA,GAAiB,GACjB,GAEwB,GAA5BnI,KAAKiF,KAAK,GAAMkD,K,yCAS3B,SAA4BA,GACxB,OAAIA,GAAY,GACL,GACW,EAAXA,GAAgB,GAChB,EAEA,I,2CAWf,SAA8BA,GAC1B,OAAIA,GAAY,GACL,EAEA,O,gFAthBE/I,G,kCC1DjBiJ,EAA2B,GCE/B,IAAIC,EDCJ,SAASC,EAAoBC,GAE5B,IAAIC,EAAeJ,EAAyBG,GAC5C,QAAqBE,IAAjBD,EACH,OAAOA,EAAa1J,QAGrB,IAAIC,EAASqJ,EAAyBG,GAAY,CAGjDzJ,QAAS,IAOV,OAHA4J,EAAoBH,GAAUxJ,EAAQA,EAAOD,QAASwJ,GAG/CvJ,EAAOD,QClBWwJ,CAAoB,K,UHO9C","sources":["webpack://WaveSurfer.[name]/webpack/universalModuleDefinition","webpack://WaveSurfer.[name]/./src/plugin/timeline/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\"][\"timeline\"] = factory();\n})(self, function() {\nreturn ","/**\n * @typedef {Object} TimelinePluginParams\n * @desc Extends the `WavesurferParams` wavesurfer was initialised with\n * @property {!string|HTMLElement} container CSS selector or HTML element where\n * the timeline should be drawn. This is the only required parameter.\n * @property {number} notchPercentHeight=90 Height of notches in percent\n * @property {string} unlabeledNotchColor='#c0c0c0' The colour of the notches\n * that do not have labels\n * @property {string} primaryColor='#000' The colour of the main notches\n * @property {string} secondaryColor='#c0c0c0' The colour of the secondary\n * notches\n * @property {string} primaryFontColor='#000' The colour of the labels next to\n * the main notches\n * @property {string} secondaryFontColor='#000' The colour of the labels next to\n * the secondary notches\n * @property {number} labelPadding=5 The padding between the label and the notch\n * @property {?number} zoomDebounce A debounce timeout to increase rendering\n * performance for large files\n * @property {string} fontFamily='Arial'\n * @property {number} fontSize=10 Font size of labels in pixels\n * @property {?number} duration Length of the track in seconds. Overrides\n * getDuration() for setting length of timeline\n * @property {function} formatTimeCallback (sec, pxPerSec) -> label\n * @property {function} timeInterval (pxPerSec) -> seconds between notches\n * @property {function} primaryLabelInterval (pxPerSec) -> cadence between\n * labels in primary color\n * @property {function} secondaryLabelInterval (pxPerSec) -> cadence between\n * labels in secondary color\n * @property {?number} offset Offset for the timeline start in seconds. May also be\n * negative.\n * @property {?boolean} deferInit Set to true to manually call\n * `initPlugin('timeline')`\n */\n\n/**\n * Adds a timeline to the waveform.\n *\n * @implements {PluginClass}\n * @extends {Observer}\n * @example\n * // es6\n * import TimelinePlugin from 'wavesurfer.timeline.js';\n *\n * // commonjs\n * var TimelinePlugin = require('wavesurfer.timeline.js');\n *\n * // if you are using <script> tags\n * var TimelinePlugin = window.WaveSurfer.timeline;\n *\n * // ... initialising wavesurfer with the plugin\n * var wavesurfer = WaveSurfer.create({\n * // wavesurfer options ...\n * plugins: [\n * TimelinePlugin.create({\n * // plugin options ...\n * })\n * ]\n * });\n */\nexport default class TimelinePlugin {\n /**\n * Timeline 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 {TimelinePluginParams} params parameters use to initialise the plugin\n * @return {PluginDefinition} an object representing the plugin\n */\n static create(params) {\n return {\n name: 'timeline',\n deferInit: params && params.deferInit ? params.deferInit : false,\n params: params,\n instance: TimelinePlugin\n };\n }\n\n // event handlers\n _onScroll = () => {\n if (this.wrapper && this.drawer.wrapper) {\n this.wrapper.scrollLeft = this.drawer.wrapper.scrollLeft;\n }\n };\n\n /**\n * @returns {void}\n */\n _onRedraw = () => this.render();\n\n _onReady = () => {\n const ws = this.wavesurfer;\n this.drawer = ws.drawer;\n this.pixelRatio = ws.drawer.params.pixelRatio;\n this.maxCanvasWidth = ws.drawer.maxCanvasWidth || ws.drawer.width;\n this.maxCanvasElementWidth =\n ws.drawer.maxCanvasElementWidth ||\n Math.round(this.maxCanvasWidth / this.pixelRatio);\n\n // add listeners\n ws.drawer.wrapper.addEventListener('scroll', this._onScroll);\n ws.on('redraw', this._onRedraw);\n ws.on('zoom', this._onZoom);\n\n this.render();\n };\n\n /**\n * @param {object} e Click event\n */\n _onWrapperClick = e => {\n e.preventDefault();\n const relX = 'offsetX' in e ? e.offsetX : e.layerX;\n this.fireEvent('click', relX / this.wrapper.scrollWidth || 0);\n };\n\n /**\n * Creates an instance of TimelinePlugin.\n *\n * You probably want to use TimelinePlugin.create()\n *\n * @param {TimelinePluginParams} params Plugin parameters\n * @param {object} ws Wavesurfer instance\n */\n constructor(params, ws) {\n this.container =\n 'string' == typeof params.container\n ? document.querySelector(params.container)\n : params.container;\n\n if (!this.container) {\n throw new Error('No container for wavesurfer timeline');\n }\n\n this.wavesurfer = ws;\n this.util = ws.util;\n this.params = Object.assign(\n {},\n {\n height: 20,\n notchPercentHeight: 90,\n labelPadding: 5,\n unlabeledNotchColor: '#c0c0c0',\n primaryColor: '#000',\n secondaryColor: '#c0c0c0',\n primaryFontColor: '#000',\n secondaryFontColor: '#000',\n fontFamily: 'Arial',\n fontSize: 10,\n duration: null,\n zoomDebounce: false,\n formatTimeCallback: this.defaultFormatTimeCallback,\n timeInterval: this.defaultTimeInterval,\n primaryLabelInterval: this.defaultPrimaryLabelInterval,\n secondaryLabelInterval: this.defaultSecondaryLabelInterval,\n offset: 0\n },\n params\n );\n\n this.canvases = [];\n this.wrapper = null;\n this.drawer = null;\n this.pixelRatio = null;\n this.maxCanvasWidth = null;\n this.maxCanvasElementWidth = null;\n /**\n * This event handler has to be in the constructor function because it\n * relies on the debounce function which is only available after\n * instantiation\n *\n * Use a debounced function if `params.zoomDebounce` is defined\n *\n * @returns {void}\n */\n this._onZoom = this.params.zoomDebounce\n ? this.wavesurfer.util.debounce(\n () => this.render(),\n this.params.zoomDebounce\n )\n : () => this.render();\n }\n\n /**\n * Initialisation function used by the plugin API\n */\n init() {\n // Check if ws is ready\n if (this.wavesurfer.isReady) {\n this._onReady();\n } else {\n this.wavesurfer.once('ready', this._onReady);\n }\n }\n\n /**\n * Destroy function used by the plugin API\n */\n destroy() {\n this.unAll();\n this.wavesurfer.un('redraw', this._onRedraw);\n this.wavesurfer.un('zoom', this._onZoom);\n this.wavesurfer.un('ready', this._onReady);\n this.wavesurfer.drawer.wrapper.removeEventListener(\n 'scroll',\n this._onScroll\n );\n if (this.wrapper && this.wrapper.parentNode) {\n this.wrapper.removeEventListener('click', this._onWrapperClick);\n this.wrapper.parentNode.removeChild(this.wrapper);\n this.wrapper = null;\n }\n }\n\n /**\n * Create a timeline element to wrap the canvases drawn by this plugin\n *\n */\n createWrapper() {\n const wsParams = this.wavesurfer.params;\n this.container.innerHTML = '';\n this.wrapper = this.container.appendChild(\n document.createElement('timeline')\n );\n this.util.style(this.wrapper, {\n display: 'block',\n position: 'relative',\n userSelect: 'none',\n webkitUserSelect: 'none',\n height: `${this.params.height}px`\n });\n\n if (wsParams.fillParent || wsParams.scrollParent) {\n this.util.style(this.wrapper, {\n width: '100%',\n overflowX: 'hidden',\n overflowY: 'hidden'\n });\n }\n\n this.wrapper.addEventListener('click', this._onWrapperClick);\n }\n\n /**\n * Render the timeline (also updates the already rendered timeline)\n *\n */\n render() {\n if (!this.wrapper) {\n this.createWrapper();\n }\n this.updateCanvases();\n this.updateCanvasesPositioning();\n this.renderCanvases();\n }\n\n /**\n * Add new timeline canvas\n *\n */\n addCanvas() {\n const canvas = this.wrapper.appendChild(\n document.createElement('canvas')\n );\n this.canvases.push(canvas);\n this.util.style(canvas, {\n position: 'absolute',\n zIndex: 4\n });\n }\n\n /**\n * Remove timeline canvas\n *\n */\n removeCanvas() {\n const canvas = this.canvases.pop();\n canvas.parentElement.removeChild(canvas);\n }\n\n /**\n * Make sure the correct of timeline canvas elements exist and are cached in\n * this.canvases\n *\n */\n updateCanvases() {\n const totalWidth = Math.round(this.drawer.wrapper.scrollWidth);\n const requiredCanvases = Math.ceil(\n totalWidth / this.maxCanvasElementWidth\n );\n\n while (this.canvases.length < requiredCanvases) {\n this.addCanvas();\n }\n\n while (this.canvases.length > requiredCanvases) {\n this.removeCanvas();\n }\n }\n\n /**\n * Update the dimensions and positioning style for all the timeline canvases\n *\n */\n updateCanvasesPositioning() {\n // cache length for performance\n const canvasesLength = this.canvases.length;\n this.canvases.forEach((canvas, i) => {\n // canvas width is the max element width, or if it is the last the\n // required width\n const canvasWidth =\n i === canvasesLength - 1\n ? this.drawer.wrapper.scrollWidth -\n this.maxCanvasElementWidth * (canvasesLength - 1)\n : this.maxCanvasElementWidth;\n // set dimensions and style\n canvas.width = canvasWidth * this.pixelRatio;\n // on certain pixel ratios the canvas appears cut off at the bottom,\n // therefore leave 1px extra\n canvas.height = (this.params.height + 1) * this.pixelRatio;\n this.util.style(canvas, {\n width: `${canvasWidth}px`,\n height: `${this.params.height}px`,\n left: `${i * this.maxCanvasElementWidth}px`\n });\n });\n }\n\n /**\n * Render the timeline labels and notches\n *\n */\n renderCanvases() {\n const duration =\n this.params.duration ||\n this.wavesurfer.backend.getDuration();\n\n if (duration <= 0) {\n return;\n }\n const wsParams = this.wavesurfer.params;\n const fontSize = this.params.fontSize * wsParams.pixelRatio;\n const totalSeconds = parseInt(duration, 10) + 1;\n const width =\n wsParams.fillParent && !wsParams.scrollParent\n ? this.drawer.getWidth()\n : this.drawer.wrapper.scrollWidth * wsParams.pixelRatio;\n const height1 = this.params.height * this.pixelRatio;\n const height2 =\n this.params.height *\n (this.params.notchPercentHeight / 100) *\n this.pixelRatio;\n const pixelsPerSecond = width / duration;\n\n const formatTime = this.params.formatTimeCallback;\n // if parameter is function, call the function with\n // pixelsPerSecond, otherwise simply take the value as-is\n const intervalFnOrVal = option =>\n typeof option === 'function' ? option(pixelsPerSecond) : option;\n const timeInterval = intervalFnOrVal(this.params.timeInterval);\n const primaryLabelInterval = intervalFnOrVal(\n this.params.primaryLabelInterval\n );\n const secondaryLabelInterval = intervalFnOrVal(\n this.params.secondaryLabelInterval\n );\n\n let curPixel = pixelsPerSecond * this.params.offset;\n let curSeconds = 0;\n let i;\n // build an array of position data with index, second and pixel data,\n // this is then used multiple times below\n const positioning = [];\n\n // render until end in case we have a negative offset\n const renderSeconds = (this.params.offset < 0)\n ? totalSeconds - this.params.offset\n : totalSeconds;\n\n for (i = 0; i < renderSeconds / timeInterval; i++) {\n positioning.push([i, curSeconds, curPixel]);\n curSeconds += timeInterval;\n curPixel += pixelsPerSecond * timeInterval;\n }\n\n // iterate over each position\n const renderPositions = cb => {\n positioning.forEach(pos => {\n cb(pos[0], pos[1], pos[2]);\n });\n };\n\n // render primary labels\n this.setFillStyles(this.params.primaryColor);\n this.setFonts(`${fontSize}px ${this.params.fontFamily}`);\n this.setFillStyles(this.params.primaryFontColor);\n renderPositions((i, curSeconds, curPixel) => {\n if (i % primaryLabelInterval === 0) {\n this.fillRect(curPixel, 0, 1, height1);\n this.fillText(\n formatTime(curSeconds, pixelsPerSecond),\n curPixel + this.params.labelPadding * this.pixelRatio,\n height1\n );\n }\n });\n\n // render secondary labels\n this.setFillStyles(this.params.secondaryColor);\n this.setFonts(`${fontSize}px ${this.params.fontFamily}`);\n this.setFillStyles(this.params.secondaryFontColor);\n renderPositions((i, curSeconds, curPixel) => {\n if (i % secondaryLabelInterval === 0) {\n this.fillRect(curPixel, 0, 1, height1);\n this.fillText(\n formatTime(curSeconds, pixelsPerSecond),\n curPixel + this.params.labelPadding * this.pixelRatio,\n height1\n );\n }\n });\n\n // render the actual notches (when no labels are used)\n this.setFillStyles(this.params.unlabeledNotchColor);\n renderPositions((i, curSeconds, curPixel) => {\n if (\n i % secondaryLabelInterval !== 0 &&\n i % primaryLabelInterval !== 0\n ) {\n this.fillRect(curPixel, 0, 1, height2);\n }\n });\n }\n\n /**\n * Set the canvas fill style\n *\n * @param {DOMString|CanvasGradient|CanvasPattern} fillStyle Fill style to\n * use\n */\n setFillStyles(fillStyle) {\n this.canvases.forEach(canvas => {\n const context = canvas.getContext('2d');\n if (context) {\n context.fillStyle = fillStyle;\n }\n });\n }\n\n /**\n * Set the canvas font\n *\n * @param {DOMString} font Font to use\n */\n setFonts(font) {\n this.canvases.forEach(canvas => {\n const context = canvas.getContext('2d');\n if (context) {\n context.font = font;\n }\n });\n }\n\n /**\n * Draw a rectangle on the canvases\n *\n * (it figures out the offset for each canvas)\n *\n * @param {number} x X-position\n * @param {number} y Y-position\n * @param {number} width Width\n * @param {number} height Height\n */\n fillRect(x, y, width, height) {\n this.canvases.forEach((canvas, i) => {\n const leftOffset = i * this.maxCanvasWidth;\n\n const intersection = {\n x1: Math.max(x, i * this.maxCanvasWidth),\n y1: y,\n x2: Math.min(x + width, i * this.maxCanvasWidth + canvas.width),\n y2: y + height\n };\n\n if (intersection.x1 < intersection.x2) {\n const context = canvas\n .getContext('2d');\n if (context) {\n context\n .fillRect(\n intersection.x1 - leftOffset,\n intersection.y1,\n intersection.x2 - intersection.x1,\n intersection.y2 - intersection.y1\n );\n }\n }\n });\n }\n\n /**\n * Fill a given text on the canvases\n *\n * @param {string} text Text to render\n * @param {number} x X-position\n * @param {number} y Y-position\n */\n fillText(text, x, y) {\n let textWidth;\n let xOffset = 0;\n\n this.canvases.forEach(canvas => {\n const context = canvas.getContext('2d');\n if (context) {\n const canvasWidth = context.canvas.width;\n\n if (xOffset > x + textWidth) {\n return;\n }\n\n if (xOffset + canvasWidth > x && context) {\n textWidth = context.measureText(text).width;\n context.fillText(text, x - xOffset, y);\n }\n\n xOffset += canvasWidth;\n }\n });\n }\n\n /**\n * Turn the time into a suitable label for the time.\n *\n * @param {number} seconds Seconds to format\n * @param {number} pxPerSec Pixels per second\n * @returns {number} Time\n */\n defaultFormatTimeCallback(seconds, pxPerSec) {\n if (seconds / 60 > 1) {\n // calculate minutes and seconds from seconds count\n const minutes = parseInt(seconds / 60, 10);\n seconds = parseInt(seconds % 60, 10);\n // fill up seconds with zeroes\n seconds = seconds < 10 ? '0' + seconds : seconds;\n return `${minutes}:${seconds}`;\n }\n return Math.round(seconds * 1000) / 1000;\n }\n\n /**\n * Return how many seconds should be between each notch\n *\n * @param {number} pxPerSec Pixels per second\n * @returns {number} Time\n */\n defaultTimeInterval(pxPerSec) {\n if (pxPerSec >= 25) {\n return 1;\n } else if (pxPerSec * 5 >= 25) {\n return 5;\n } else if (pxPerSec * 15 >= 25) {\n return 15;\n }\n return Math.ceil(0.5 / pxPerSec) * 60;\n }\n\n /**\n * Return the cadence of notches that get labels in the primary color.\n *\n * @param {number} pxPerSec Pixels per second\n * @returns {number} Cadence\n */\n defaultPrimaryLabelInterval(pxPerSec) {\n if (pxPerSec >= 25) {\n return 10;\n } else if (pxPerSec * 5 >= 25) {\n return 6;\n } else if (pxPerSec * 15 >= 25) {\n return 4;\n }\n return 4;\n }\n\n /**\n * Return the cadence of notches that get labels in the secondary color.\n *\n * @param {number} pxPerSec Pixels per second\n * @returns {number} Cadence\n */\n defaultSecondaryLabelInterval(pxPerSec) {\n if (pxPerSec >= 25) {\n return 5;\n } else if (pxPerSec * 5 >= 25) {\n return 2;\n } else if (pxPerSec * 15 >= 25) {\n return 2;\n }\n return 2;\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__(171);\n"],"names":["root","factory","exports","module","define","amd","self","TimelinePlugin","params","ws","wrapper","drawer","scrollLeft","render","wavesurfer","pixelRatio","maxCanvasWidth","width","maxCanvasElementWidth","Math","round","addEventListener","_onScroll","on","_onRedraw","_onZoom","e","preventDefault","relX","offsetX","layerX","fireEvent","scrollWidth","this","container","document","querySelector","Error","util","Object","assign","height","notchPercentHeight","labelPadding","unlabeledNotchColor","primaryColor","secondaryColor","primaryFontColor","secondaryFontColor","fontFamily","fontSize","duration","zoomDebounce","formatTimeCallback","defaultFormatTimeCallback","timeInterval","defaultTimeInterval","primaryLabelInterval","defaultPrimaryLabelInterval","secondaryLabelInterval","defaultSecondaryLabelInterval","offset","canvases","debounce","name","deferInit","instance","isReady","_onReady","once","unAll","un","removeEventListener","parentNode","_onWrapperClick","removeChild","wsParams","innerHTML","appendChild","createElement","style","display","position","userSelect","webkitUserSelect","fillParent","scrollParent","overflowX","overflowY","createWrapper","updateCanvases","updateCanvasesPositioning","renderCanvases","canvas","push","zIndex","pop","parentElement","totalWidth","requiredCanvases","ceil","length","addCanvas","removeCanvas","canvasesLength","forEach","i","canvasWidth","left","backend","getDuration","totalSeconds","parseInt","getWidth","height1","height2","pixelsPerSecond","formatTime","intervalFnOrVal","option","curPixel","curSeconds","positioning","renderSeconds","renderPositions","cb","pos","setFillStyles","setFonts","fillRect","fillText","fillStyle","context","getContext","font","x","y","leftOffset","intersection","x1","max","y1","x2","min","y2","text","textWidth","xOffset","measureText","seconds","pxPerSec","minutes","__webpack_module_cache__","__webpack_exports__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__"],"sourceRoot":""}
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * wavesurfer.js 6.0.2 (2022-02-20)
2
+ * wavesurfer.js 6.1.0 (2022-03-31)
3
3
  * https://wavesurfer-js.org
4
4
  * @license BSD-3-Clause
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * wavesurfer.js 6.0.2 (2022-02-20)
2
+ * wavesurfer.js 6.1.0 (2022-03-31)
3
3
  * https://wavesurfer-js.org
4
4
  * @license BSD-3-Clause
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * wavesurfer.js 6.0.2 (2022-02-20)
2
+ * wavesurfer.js 6.1.0 (2022-03-31)
3
3
  * https://wavesurfer-js.org
4
4
  * @license BSD-3-Clause
5
5
  */
@@ -4149,7 +4149,10 @@ var WaveSurfer = /*#__PURE__*/function (_util$Observer) {
4149
4149
  if (prevWidth != _this.drawer.wrapper.clientWidth && !_this.params.scrollParent) {
4150
4150
  prevWidth = _this.drawer.wrapper.clientWidth;
4151
4151
 
4152
- _this.drawer.fireEvent('redraw');
4152
+ if (prevWidth) {
4153
+ // redraw only if waveform container is rendered and has a width
4154
+ _this.drawer.fireEvent('redraw');
4155
+ }
4153
4156
  }
4154
4157
  }, typeof _this.params.responsive === 'number' ? _this.params.responsive : 100);
4155
4158
  return _possibleConstructorReturn(_this, _assertThisInitialized(_this));
@@ -5597,7 +5600,7 @@ var WaveSurfer = /*#__PURE__*/function (_util$Observer) {
5597
5600
 
5598
5601
  exports["default"] = WaveSurfer;
5599
5602
 
5600
- _defineProperty(WaveSurfer, "VERSION", "6.0.2");
5603
+ _defineProperty(WaveSurfer, "VERSION", "6.1.0");
5601
5604
 
5602
5605
  _defineProperty(WaveSurfer, "util", util);
5603
5606
 
@@ -5773,6 +5776,12 @@ var WebAudio = /*#__PURE__*/function (_util$Observer) {
5773
5776
  /** @private */
5774
5777
 
5775
5778
  _this.explicitDuration = params.duration;
5779
+ /** @private */
5780
+
5781
+ _this.sinkStreamDestination = null;
5782
+ /** @private */
5783
+
5784
+ _this.sinkAudioElement = null;
5776
5785
  /**
5777
5786
  * Boolean indicating if the backend was destroyed.
5778
5787
  */
@@ -6003,18 +6012,24 @@ var WebAudio = /*#__PURE__*/function (_util$Observer) {
6003
6012
  * output. Here we create an HTMLAudioElement, connect the
6004
6013
  * webaudio stream to that element and setSinkId there.
6005
6014
  */
6006
- var audio = new window.Audio();
6015
+ if (!this.sinkAudioElement) {
6016
+ this.sinkAudioElement = new window.Audio(); // autoplay is necessary since we're not invoking .play()
6007
6017
 
6008
- if (!audio.setSinkId) {
6018
+ this.sinkAudioElement.autoplay = true;
6019
+ }
6020
+
6021
+ if (!this.sinkAudioElement.setSinkId) {
6009
6022
  return Promise.reject(new Error('setSinkId is not supported in your browser'));
6010
6023
  }
6011
6024
 
6012
- audio.autoplay = true;
6013
- var dest = this.ac.createMediaStreamDestination();
6025
+ if (!this.sinkStreamDestination) {
6026
+ this.sinkStreamDestination = this.ac.createMediaStreamDestination();
6027
+ }
6028
+
6014
6029
  this.gainNode.disconnect();
6015
- this.gainNode.connect(dest);
6016
- audio.srcObject = dest.stream;
6017
- return audio.setSinkId(deviceId);
6030
+ this.gainNode.connect(this.sinkStreamDestination);
6031
+ this.sinkAudioElement.srcObject = this.sinkStreamDestination.stream;
6032
+ return this.sinkAudioElement.setSinkId(deviceId);
6018
6033
  } else {
6019
6034
  return Promise.reject(new Error('Invalid deviceId: ' + deviceId));
6020
6035
  }
@@ -6261,6 +6276,14 @@ var WebAudio = /*#__PURE__*/function (_util$Observer) {
6261
6276
 
6262
6277
 
6263
6278
  window.WaveSurferOfflineAudioContext = null;
6279
+ } // disconnect resources used by setSinkId
6280
+
6281
+
6282
+ if (this.sinkStreamDestination) {
6283
+ this.sinkAudioElement.pause();
6284
+ this.sinkAudioElement.srcObject = null;
6285
+ this.sinkStreamDestination.disconnect();
6286
+ this.sinkStreamDestination = null;
6264
6287
  }
6265
6288
  }
6266
6289
  /**