wavesurfer.js 6.2.0 → 6.4.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 (58) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +1 -10
  3. package/dist/plugin/wavesurfer.cursor.js +29 -49
  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 +19 -49
  8. package/dist/plugin/wavesurfer.elan.js.map +1 -1
  9. package/dist/plugin/wavesurfer.elan.min.js +1 -1
  10. package/dist/plugin/wavesurfer.elan.min.js.map +1 -1
  11. package/dist/plugin/wavesurfer.markers.js +87 -67
  12. package/dist/plugin/wavesurfer.markers.js.map +1 -1
  13. package/dist/plugin/wavesurfer.markers.min.js +2 -2
  14. package/dist/plugin/wavesurfer.markers.min.js.map +1 -1
  15. package/dist/plugin/wavesurfer.mediasession.js +5 -15
  16. package/dist/plugin/wavesurfer.mediasession.js.map +1 -1
  17. package/dist/plugin/wavesurfer.mediasession.min.js +1 -1
  18. package/dist/plugin/wavesurfer.mediasession.min.js.map +1 -1
  19. package/dist/plugin/wavesurfer.microphone.js +44 -62
  20. package/dist/plugin/wavesurfer.microphone.js.map +1 -1
  21. package/dist/plugin/wavesurfer.microphone.min.js +1 -1
  22. package/dist/plugin/wavesurfer.microphone.min.js.map +1 -1
  23. package/dist/plugin/wavesurfer.minimap.js +16 -68
  24. package/dist/plugin/wavesurfer.minimap.js.map +1 -1
  25. package/dist/plugin/wavesurfer.minimap.min.js +1 -1
  26. package/dist/plugin/wavesurfer.minimap.min.js.map +1 -1
  27. package/dist/plugin/wavesurfer.playhead.js +2 -29
  28. package/dist/plugin/wavesurfer.playhead.js.map +1 -1
  29. package/dist/plugin/wavesurfer.playhead.min.js +1 -1
  30. package/dist/plugin/wavesurfer.playhead.min.js.map +1 -1
  31. package/dist/plugin/wavesurfer.regions.js +99 -253
  32. package/dist/plugin/wavesurfer.regions.js.map +1 -1
  33. package/dist/plugin/wavesurfer.regions.min.js +2 -2
  34. package/dist/plugin/wavesurfer.regions.min.js.map +1 -1
  35. package/dist/plugin/wavesurfer.spectrogram.js +52 -147
  36. package/dist/plugin/wavesurfer.spectrogram.js.map +1 -1
  37. package/dist/plugin/wavesurfer.spectrogram.min.js +2 -2
  38. package/dist/plugin/wavesurfer.spectrogram.min.js.map +1 -1
  39. package/dist/plugin/wavesurfer.timeline.js +42 -85
  40. package/dist/plugin/wavesurfer.timeline.js.map +1 -1
  41. package/dist/plugin/wavesurfer.timeline.min.js +1 -1
  42. package/dist/plugin/wavesurfer.timeline.min.js.map +1 -1
  43. package/dist/wavesurfer-html-init.js +31 -53
  44. package/dist/wavesurfer-html-init.js.map +1 -1
  45. package/dist/wavesurfer-html-init.min.js +1 -1
  46. package/dist/wavesurfer-html-init.min.js.map +1 -1
  47. package/dist/wavesurfer.js +448 -1008
  48. package/dist/wavesurfer.js.map +1 -1
  49. package/dist/wavesurfer.min.js +2 -2
  50. package/dist/wavesurfer.min.js.map +1 -1
  51. package/package.json +18 -19
  52. package/src/drawer.multicanvas.js +4 -4
  53. package/src/plugin/cursor/index.js +15 -3
  54. package/src/plugin/markers/index.js +70 -5
  55. package/src/plugin/regions/index.js +1 -1
  56. package/src/plugin/spectrogram/index.js +1 -1
  57. package/src/wavesurfer.js +12 -9
  58. package/CHANGES.md +0 -474
@@ -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;AAC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FM,MAEA,IAAIA,QAAQ,GAAG,EAAX,IAAiB,EAArB,EAAyB;QAC5B,OAAO,CAAP;MACH;;MACD,OAAO,CAAP;IACH;IAED;AACJ;AACA;AACA;AACA;AACA;;;;WACI,uCAA8BA,QAA9B,EAAwC;MACpC,IAAIA,QAAQ,IAAI,EAAhB,EAAoB;QAChB,OAAO,CAAP;MACH,CAFD,MAEO,IAAIA,QAAQ,GAAG,CAAX,IAAgB,EAApB,EAAwB;QAC3B,OAAO,CAAP;MACH,CAFM,MAEA,IAAIA,QAAQ,GAAG,EAAX,IAAiB,EAArB,EAAyB;QAC5B,OAAO,CAAP;MACH;;MACD,OAAO,CAAP;IACH;;;;IA1hBD;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;IACI,gBAAc1I,MAAd,EAAsB;MAClB,OAAO;QACH4I,IAAI,EAAE,UADH;QAEHC,SAAS,EAAE7I,MAAM,IAAIA,MAAM,CAAC6I,SAAjB,GAA6B7I,MAAM,CAAC6I,SAApC,GAAgD,KAFxD;QAGH7I,MAAM,EAAEA,MAHL;QAIH8I,QAAQ,EAAE/I;MAJP,CAAP;IAMH,EAED;;;;;;;;;;;;;;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/webpack/universalModuleDefinition","webpack://WaveSurfer/./src/plugin/timeline/index.js","webpack://WaveSurfer/webpack/bootstrap","webpack://WaveSurfer/webpack/before-startup","webpack://WaveSurfer/webpack/startup","webpack://WaveSurfer/webpack/after-startup"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"WaveSurfer\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"WaveSurfer\"] = factory();\n\telse\n\t\troot[\"WaveSurfer\"] = root[\"WaveSurfer\"] || {}, root[\"WaveSurfer\"][\"timeline\"] = factory();\n})(self, () => {\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
+ {"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;AAxBA,IAyBqBA,cAAc;EAyD/B;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;EACI,wBAAYC,MAAM,EAAEC,GAAE,EAAE;IAAA;IAAA;IAAA,mCA7CZ,YAAM;MACd,IAAI,KAAI,CAACC,OAAO,IAAI,KAAI,CAACC,MAAM,CAACD,OAAO,EAAE;QACrC,KAAI,CAACA,OAAO,CAACE,UAAU,GAAG,KAAI,CAACD,MAAM,CAACD,OAAO,CAACE,UAAU;MAC5D;IACJ,CAAC;IAAA,mCAKW;MAAA,OAAM,KAAI,CAACC,MAAM,EAAE;IAAA;IAAA,kCAEpB,YAAM;MACb,IAAMJ,EAAE,GAAG,KAAI,CAACK,UAAU;MAC1B,KAAI,CAACH,MAAM,GAAGF,EAAE,CAACE,MAAM;MACvB,KAAI,CAACI,UAAU,GAAGN,EAAE,CAACE,MAAM,CAACH,MAAM,CAACO,UAAU;MAC7C,KAAI,CAACC,cAAc,GAAGP,EAAE,CAACE,MAAM,CAACK,cAAc,IAAIP,EAAE,CAACE,MAAM,C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Z;;IAEA;AACJ;AACA;AACA;AACA;AACA;EALI;IAAA;IAAA,OAMA,uCAA8BA,QAAQ,EAAE;MACpC,IAAIA,QAAQ,IAAI,EAAE,EAAE;QAChB,OAAO,CAAC;MACZ,CAAC,MAAM,IAAIA,QAAQ,GAAG,CAAC,IAAI,EAAE,EAAE;QAC3B,OAAO,CAAC;MACZ,CAAC,MAAM,IAAIA,QAAQ,GAAG,EAAE,IAAI,EAAE,EAAE;QAC5B,OAAO,CAAC;MACZ;MACA,OAAO,CAAC;IACZ;EAAC;IAAA;IAAA;IA1hBD;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;IACI,gBAAc1I,MAAM,EAAE;MAClB,OAAO;QACH4I,IAAI,EAAE,UAAU;QAChBC,SAAS,EAAE7I,MAAM,IAAIA,MAAM,CAAC6I,SAAS,GAAG7I,MAAM,CAAC6I,SAAS,GAAG,KAAK;QAChE7I,MAAM,EAAEA,MAAM;QACd8I,QAAQ,EAAE/I;MACd,CAAC;IACL;;IAEA;EAAA;EAAA;AAAA;AAAA;AAAA;;;;;;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/webpack/universalModuleDefinition","webpack://WaveSurfer/./src/plugin/timeline/index.js","webpack://WaveSurfer/webpack/bootstrap","webpack://WaveSurfer/webpack/before-startup","webpack://WaveSurfer/webpack/startup","webpack://WaveSurfer/webpack/after-startup"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"WaveSurfer\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"WaveSurfer\"] = factory();\n\telse\n\t\troot[\"WaveSurfer\"] = root[\"WaveSurfer\"] || {}, root[\"WaveSurfer\"][\"timeline\"] = factory();\n})(self, () => {\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,5 +1,5 @@
1
1
  /*!
2
- * wavesurfer.js timeline plugin 6.2.0 (2022-05-16)
2
+ * wavesurfer.js timeline plugin 6.4.0 (2022-11-05)
3
3
  * https://wavesurfer-js.org
4
4
  * @license BSD-3-Clause
5
5
  */
@@ -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,IACT,M,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,iBACF,IAAMC,EAAO,YAAaF,EAAIA,EA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AASC,GAC/B,GAAID,EAAU,GAAK,EAAG,CAElB,IAAME,EAAUvC,SAASqC,EAAU,GAAI,IAIvC,OADAA,GAFAA,EAAUrC,SAASqC,EAAU,GAAI,KAEb,GAAK,IAAMA,EAAUA,EAClC,GAAP,OAAUE,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/webpack/universalModuleDefinition","webpack://WaveSurfer/./src/plugin/timeline/index.js","webpack://WaveSurfer/webpack/bootstrap","webpack://WaveSurfer/webpack/startup"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"WaveSurfer\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"WaveSurfer\"] = factory();\n\telse\n\t\troot[\"WaveSurfer\"] = root[\"WaveSurfer\"] || {}, root[\"WaveSurfer\"][\"timeline\"] = factory();\n})(self, () => {\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
+ {"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,CAAC,EAAGA,EAAiB,WAAY,SAAIC,IACjF,CATD,CASGK,MAAM,IACT,M,gYCwBA,IAyBqBC,EAAc,WAiE/B,WAAYC,EAAQC,GAAI,WAMpB,G,4FANoB,6BA7CZ,WACJ,EAAKC,SAAW,EAAKC,OAAOD,UAC5B,EAAKA,QAAQE,WAAa,EAAKD,OAAOD,QAAQE,WAEtD,IAAC,oBAKW,kBAAM,EAAKC,QAAQ,uBAEpB,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,QACT,IAAC,0BAKiB,SAAAa,GACdA,EAAEC,iBACF,IAAMC,EAAO,YAAaF,EAAIA,EAAEG,QAAUH,EAAEI,OAC5C,EAAKC,UAAU,QAASH,EAAO,EAAKlB,QAAQsB,aAAe,EAC/D,IAWIC,KAAKC,UACD,iBAAmB1B,EAAO0B,UACpBC,SAASC,cAAc5B,EAAO0B,WA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Bc,EAAYd,EAAQgB,YAAYH,GAAMhI,MACtCmH,EAAQF,SAASe,EAAMV,EAAIY,EAASX,IAGxCW,GAAWxC,CACf,CACJ,GACJ,GAEA,uCAOA,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,EAClC,GAAP,OAAUE,EAAO,YAAIF,EACzB,CACA,OAAOlI,KAAKC,MAAgB,IAAViI,GAAkB,GACxC,GAEA,iCAMA,SAAoBC,GAChB,OAAIA,GAAY,GACL,EACW,EAAXA,GAAgB,GAChB,EACW,GAAXA,GAAiB,GACjB,GAEwB,GAA5BnI,KAAKiF,KAAK,GAAMkD,EAC3B,GAEA,yCAMA,SAA4BA,GACxB,OAAIA,GAAY,GACL,GACW,EAAXA,GAAgB,GAChB,EAEA,CAGf,GAEA,2CAMA,SAA8BA,GAC1B,OAAIA,GAAY,GACL,EAEA,CAKf,M,8EAxgBA,EAnB+B,GAmB/B,+B,GC7EAE,EAA2B,CAAC,ECEhC,IAAIC,EDCJ,SAASC,EAAoBC,GAE5B,IAAIC,EAAeJ,EAAyBG,GAC5C,QAAqBE,IAAjBD,EACH,OAAOA,EAAa1J,QAGrB,IAAIC,EAASqJ,EAAyBG,GAAY,CAGjDzJ,QAAS,CAAC,GAOX,OAHA4J,EAAoBH,GAAUxJ,EAAQA,EAAOD,QAASwJ,GAG/CvJ,EAAOD,OACf,CCnB0BwJ,CAAoB,K,UHO9C","sources":["webpack://WaveSurfer/webpack/universalModuleDefinition","webpack://WaveSurfer/./src/plugin/timeline/index.js","webpack://WaveSurfer/webpack/bootstrap","webpack://WaveSurfer/webpack/startup"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"WaveSurfer\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"WaveSurfer\"] = factory();\n\telse\n\t\troot[\"WaveSurfer\"] = root[\"WaveSurfer\"] || {}, root[\"WaveSurfer\"][\"timeline\"] = factory();\n})(self, () => {\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.2.0 (2022-05-16)
2
+ * wavesurfer.js 6.4.0 (2022-11-05)
3
3
  * https://wavesurfer-js.org
4
4
  * @license BSD-3-Clause
5
5
  */
@@ -29,19 +29,12 @@ Object.defineProperty(exports, "__esModule", ({
29
29
  value: true
30
30
  }));
31
31
  exports["default"] = void 0;
32
-
33
32
  var _loadScript = _interopRequireDefault(__webpack_require__(/*! load-script */ "./node_modules/load-script/index.js"));
34
-
35
33
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
36
-
37
34
  function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
38
-
39
35
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
40
-
41
36
  function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
42
-
43
37
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
44
-
45
38
  /**
46
39
  * @typedef {Object} InitParams
47
40
  * @property {WavesurferParams} [defaults={backend: 'MediaElement,
@@ -54,7 +47,6 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
54
47
  * @property {function} loadPlugin If set overwrites the default request function,
55
48
  * can be used to inject plugins differently.
56
49
  */
57
-
58
50
  /**
59
51
  * The HTML initialisation API is not part of the main library bundle file and
60
52
  * must be additionally included.
@@ -103,24 +95,21 @@ var Init = /*#__PURE__*/function () {
103
95
  */
104
96
  function Init(WaveSurfer) {
105
97
  var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
106
-
107
98
  _classCallCheck(this, Init);
108
-
109
99
  if (!WaveSurfer) {
110
100
  throw new Error('WaveSurfer is not available!');
111
101
  }
102
+
112
103
  /**
113
104
  * cache WaveSurfer
114
105
  * @private
115
106
  */
116
-
117
-
118
107
  this.WaveSurfer = WaveSurfer;
108
+
119
109
  /**
120
110
  * build parameters, cache them in _params so minified builds are smaller
121
111
  * @private
122
112
  */
123
-
124
113
  var _params = this.params = Object.assign({}, {
125
114
  // wavesurfer parameter defaults so by default the audio player is
126
115
  // usable with native media element controls
@@ -137,7 +126,6 @@ var Init = /*#__PURE__*/function () {
137
126
  // and pass it to a callback
138
127
  loadPlugin: function loadPlugin(name, cb) {
139
128
  var src = _params.pluginCdnTemplate.replace('[name]', name);
140
-
141
129
  (0, _loadScript.default)(src, {
142
130
  async: false
143
131
  }, function (err, plugin) {
@@ -145,7 +133,6 @@ var Init = /*#__PURE__*/function () {
145
133
  // eslint-disable-next-line no-console
146
134
  return console.error("WaveSurfer plugin ".concat(name, " not found at ").concat(src));
147
135
  }
148
-
149
136
  cb(window.WaveSurfer[name]);
150
137
  });
151
138
  }
@@ -154,46 +141,40 @@ var Init = /*#__PURE__*/function () {
154
141
  * The nodes that should have instances attached to them
155
142
  * @type {NodeList}
156
143
  */
157
-
158
-
159
144
  this.containers = typeof _params.containers == 'string' ? document.querySelectorAll(_params.containers) : _params.containers;
160
145
  /** @private */
161
-
162
146
  this.pluginCache = {};
163
147
  /**
164
148
  * An array of wavesurfer instances
165
149
  * @type {Object[]}
166
150
  */
167
-
168
151
  this.instances = [];
169
152
  this.initAllEls();
170
153
  }
154
+
171
155
  /**
172
156
  * Initialize all container elements
173
157
  */
174
-
175
-
176
158
  _createClass(Init, [{
177
159
  key: "initAllEls",
178
160
  value: function initAllEls() {
179
161
  var _this = this;
180
-
181
162
  // iterate over all the container elements
182
163
  Array.prototype.forEach.call(this.containers, function (el) {
183
164
  // load the plugins as an array of plugin names
184
- var plugins = el.dataset.plugins ? el.dataset.plugins.split(',') : []; // no plugins to be loaded, just render
165
+ var plugins = el.dataset.plugins ? el.dataset.plugins.split(',') : [];
185
166
 
167
+ // no plugins to be loaded, just render
186
168
  if (!plugins.length) {
187
169
  return _this.initEl(el);
188
- } // … or: iterate over all the plugins
189
-
190
-
170
+ }
171
+ // … or: iterate over all the plugins
191
172
  plugins.forEach(function (name, i) {
192
173
  // plugin is not cached already, load it
193
174
  if (!_this.pluginCache[name]) {
194
175
  _this.params.loadPlugin(name, function (lib) {
195
- _this.pluginCache[name] = lib; // plugins were all loaded, render the element
196
-
176
+ _this.pluginCache[name] = lib;
177
+ // plugins were all loaded, render the element
197
178
  if (i + 1 === plugins.length) {
198
179
  _this.initEl(el, plugins);
199
180
  }
@@ -205,6 +186,7 @@ var Init = /*#__PURE__*/function () {
205
186
  });
206
187
  });
207
188
  }
189
+
208
190
  /**
209
191
  * Initialize a single container element and add to `this.instances`
210
192
  *
@@ -212,61 +194,57 @@ var Init = /*#__PURE__*/function () {
212
194
  * @param {PluginDefinition[]} plugins An Array of plugin names to initialize with
213
195
  * @return {Object} Wavesurfer instance
214
196
  */
215
-
216
197
  }, {
217
198
  key: "initEl",
218
199
  value: function initEl(el) {
219
200
  var _this2 = this;
220
-
221
201
  var plugins = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
222
- var jsonRegex = /^[[|{]/; // initialize plugins with the correct options
223
-
202
+ var jsonRegex = /^[[|{]/;
203
+ // initialize plugins with the correct options
224
204
  var initialisedPlugins = plugins.map(function (plugin) {
225
- var options = {}; // the regex to find this plugin attributes
226
-
205
+ var options = {};
206
+ // the regex to find this plugin attributes
227
207
  var attrNameRegex = new RegExp('^' + plugin);
228
- var attrName; // iterate over all the data attributes and find ones for this
208
+ var attrName;
209
+ // iterate over all the data attributes and find ones for this
229
210
  // plugin
230
-
231
211
  for (attrName in el.dataset) {
232
212
  var regexResult = attrNameRegex.exec(attrName);
233
-
234
213
  if (regexResult) {
235
- var attr = el.dataset[attrName]; // if the string begins with a [ or a { parse it as JSON
236
-
237
- var prop = jsonRegex.test(attr) ? JSON.parse(attr) : attr; // this removes the plugin prefix and changes the first letter
214
+ var attr = el.dataset[attrName];
215
+ // if the string begins with a [ or a { parse it as JSON
216
+ var prop = jsonRegex.test(attr) ? JSON.parse(attr) : attr;
217
+ // this removes the plugin prefix and changes the first letter
238
218
  // of the resulting string to lower case to follow the naming
239
219
  // convention of ws params
240
-
241
220
  var unprefixedOptionName = attrName.slice(plugin.length, plugin.length + 1).toLowerCase() + attrName.slice(plugin.length + 1);
242
221
  options[unprefixedOptionName] = prop;
243
222
  }
244
223
  }
245
-
246
224
  return _this2.pluginCache[plugin].create(options);
247
- }); // build parameter object for this container
248
-
225
+ });
226
+ // build parameter object for this container
249
227
  var params = Object.assign({
250
228
  container: el
251
229
  }, this.params.defaults, el.dataset, {
252
230
  plugins: initialisedPlugins
253
- }); // @TODO make nicer
231
+ });
254
232
 
255
- el.style.display = 'block'; // initialize wavesurfer, load audio (with peaks if provided)
233
+ // @TODO make nicer
234
+ el.style.display = 'block';
256
235
 
236
+ // initialize wavesurfer, load audio (with peaks if provided)
257
237
  var instance = this.WaveSurfer.create(params);
258
238
  var peaks = params.peaks ? JSON.parse(params.peaks) : undefined;
259
- instance.load(params.url, peaks); // push this instance into the instances cache
239
+ instance.load(params.url, peaks);
260
240
 
241
+ // push this instance into the instances cache
261
242
  this.instances.push(instance);
262
243
  return instance;
263
244
  }
264
245
  }]);
265
-
266
246
  return Init;
267
247
  }(); // if window object exists and window.WS_StopAutoInit is not true
268
-
269
-
270
248
  if ((typeof window === "undefined" ? "undefined" : _typeof(window)) === 'object' && !window.WS_StopAutoInit) {
271
249
  // call init when document is ready, apply any custom default settings
272
250
  // in window.WS_InitOptions
@@ -277,9 +255,9 @@ if ((typeof window === "undefined" ? "undefined" : _typeof(window)) === 'object'
277
255
  window.WaveSurferInit = new Init(window.WaveSurfer, window.WS_InitOptions);
278
256
  });
279
257
  }
280
- } // export init for manual usage
281
-
258
+ }
282
259
 
260
+ // export init for manual usage
283
261
  var _default = Init;
284
262
  exports["default"] = _default;
285
263
  module.exports = exports.default;