wavesurfer.js 6.5.1 → 7.0.0-alpha.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 (132) hide show
  1. package/.eslintrc.json +24 -0
  2. package/.prettierrc +8 -0
  3. package/README.md +26 -117
  4. package/dist/base-plugin.d.ts +10 -0
  5. package/dist/base-plugin.js +13 -0
  6. package/dist/decoder.d.ts +10 -0
  7. package/dist/decoder.js +43 -0
  8. package/dist/event-emitter.d.ts +11 -0
  9. package/dist/event-emitter.js +21 -0
  10. package/dist/fetcher.d.ts +4 -0
  11. package/dist/fetcher.js +17 -0
  12. package/dist/index.d.ts +92 -0
  13. package/dist/index.js +166 -0
  14. package/dist/player-webaudio.d.ts +8 -0
  15. package/dist/player-webaudio.js +31 -0
  16. package/dist/player.d.ts +16 -0
  17. package/dist/player.js +40 -0
  18. package/dist/plugins/regions.d.ts +48 -0
  19. package/dist/plugins/regions.js +183 -0
  20. package/dist/renderer.d.ts +34 -0
  21. package/dist/renderer.js +193 -0
  22. package/dist/timer.d.ts +10 -0
  23. package/dist/timer.js +17 -0
  24. package/examples/audio.ogg +0 -0
  25. package/examples/bars.js +19 -0
  26. package/examples/basic.js +8 -0
  27. package/examples/gradient.js +28 -0
  28. package/examples/regions.js +63 -0
  29. package/examples/video.js +19 -0
  30. package/examples/webaudio.js +14 -0
  31. package/package.json +19 -99
  32. package/src/base-plugin.ts +20 -0
  33. package/src/decoder.ts +41 -0
  34. package/src/event-emitter.ts +35 -0
  35. package/src/fetcher.ts +7 -0
  36. package/src/index.ts +252 -0
  37. package/src/player-webaudio.ts +34 -0
  38. package/src/player.ts +50 -0
  39. package/src/plugins/regions.ts +240 -0
  40. package/src/renderer.ts +250 -0
  41. package/src/timer.ts +27 -0
  42. package/tsconfig.json +105 -0
  43. package/tutorial/index.html +47 -0
  44. package/tutorial/src/editor.js +70 -0
  45. package/tutorial/src/init.js +66 -0
  46. package/tutorial/src/url.js +25 -0
  47. package/tutorial/style.css +211 -0
  48. package/yarn-error.log +1049 -0
  49. package/LICENSE +0 -29
  50. package/dist/plugin/wavesurfer.cursor.js +0 -418
  51. package/dist/plugin/wavesurfer.cursor.js.map +0 -1
  52. package/dist/plugin/wavesurfer.cursor.min.js +0 -7
  53. package/dist/plugin/wavesurfer.cursor.min.js.map +0 -1
  54. package/dist/plugin/wavesurfer.elan.js +0 -381
  55. package/dist/plugin/wavesurfer.elan.js.map +0 -1
  56. package/dist/plugin/wavesurfer.elan.min.js +0 -7
  57. package/dist/plugin/wavesurfer.elan.min.js.map +0 -1
  58. package/dist/plugin/wavesurfer.markers.js +0 -520
  59. package/dist/plugin/wavesurfer.markers.js.map +0 -1
  60. package/dist/plugin/wavesurfer.markers.min.js +0 -7
  61. package/dist/plugin/wavesurfer.markers.min.js.map +0 -1
  62. package/dist/plugin/wavesurfer.mediasession.js +0 -181
  63. package/dist/plugin/wavesurfer.mediasession.js.map +0 -1
  64. package/dist/plugin/wavesurfer.mediasession.min.js +0 -7
  65. package/dist/plugin/wavesurfer.mediasession.min.js.map +0 -1
  66. package/dist/plugin/wavesurfer.microphone.js +0 -466
  67. package/dist/plugin/wavesurfer.microphone.js.map +0 -1
  68. package/dist/plugin/wavesurfer.microphone.min.js +0 -7
  69. package/dist/plugin/wavesurfer.microphone.min.js.map +0 -1
  70. package/dist/plugin/wavesurfer.minimap.js +0 -440
  71. package/dist/plugin/wavesurfer.minimap.js.map +0 -1
  72. package/dist/plugin/wavesurfer.minimap.min.js +0 -7
  73. package/dist/plugin/wavesurfer.minimap.min.js.map +0 -1
  74. package/dist/plugin/wavesurfer.playhead.js +0 -300
  75. package/dist/plugin/wavesurfer.playhead.js.map +0 -1
  76. package/dist/plugin/wavesurfer.playhead.min.js +0 -7
  77. package/dist/plugin/wavesurfer.playhead.min.js.map +0 -1
  78. package/dist/plugin/wavesurfer.regions.js +0 -1335
  79. package/dist/plugin/wavesurfer.regions.js.map +0 -1
  80. package/dist/plugin/wavesurfer.regions.min.js +0 -7
  81. package/dist/plugin/wavesurfer.regions.min.js.map +0 -1
  82. package/dist/plugin/wavesurfer.spectrogram.js +0 -736
  83. package/dist/plugin/wavesurfer.spectrogram.js.map +0 -1
  84. package/dist/plugin/wavesurfer.spectrogram.min.js +0 -7
  85. package/dist/plugin/wavesurfer.spectrogram.min.js.map +0 -1
  86. package/dist/plugin/wavesurfer.timeline.js +0 -649
  87. package/dist/plugin/wavesurfer.timeline.js.map +0 -1
  88. package/dist/plugin/wavesurfer.timeline.min.js +0 -7
  89. package/dist/plugin/wavesurfer.timeline.min.js.map +0 -1
  90. package/dist/wavesurfer-html-init.js +0 -381
  91. package/dist/wavesurfer-html-init.js.map +0 -1
  92. package/dist/wavesurfer-html-init.min.js +0 -7
  93. package/dist/wavesurfer-html-init.min.js.map +0 -1
  94. package/dist/wavesurfer.js +0 -6145
  95. package/dist/wavesurfer.js.map +0 -1
  96. package/dist/wavesurfer.min.js +0 -7
  97. package/dist/wavesurfer.min.js.map +0 -1
  98. package/src/drawer.canvasentry.js +0 -427
  99. package/src/drawer.js +0 -413
  100. package/src/drawer.multicanvas.js +0 -617
  101. package/src/html-init.js +0 -241
  102. package/src/mediaelement-webaudio.js +0 -77
  103. package/src/mediaelement.js +0 -443
  104. package/src/peakcache.js +0 -127
  105. package/src/plugin/cursor/index.js +0 -350
  106. package/src/plugin/elan/index.js +0 -307
  107. package/src/plugin/markers/index.js +0 -436
  108. package/src/plugin/mediasession/index.js +0 -94
  109. package/src/plugin/microphone/index.js +0 -415
  110. package/src/plugin/minimap/index.js +0 -403
  111. package/src/plugin/playhead/index.js +0 -226
  112. package/src/plugin/regions/index.js +0 -478
  113. package/src/plugin/regions/region.js +0 -875
  114. package/src/plugin/spectrogram/fft.js +0 -222
  115. package/src/plugin/spectrogram/index.js +0 -522
  116. package/src/plugin/timeline/index.js +0 -600
  117. package/src/util/absMax.js +0 -16
  118. package/src/util/clamp.js +0 -11
  119. package/src/util/fetch.js +0 -222
  120. package/src/util/frame.js +0 -13
  121. package/src/util/get-id.js +0 -22
  122. package/src/util/index.js +0 -14
  123. package/src/util/max.js +0 -16
  124. package/src/util/min.js +0 -16
  125. package/src/util/observer.js +0 -144
  126. package/src/util/orientation.js +0 -98
  127. package/src/util/prevent-click.js +0 -19
  128. package/src/util/request-animation-frame.js +0 -15
  129. package/src/util/silence-mode.js +0 -42
  130. package/src/util/style.js +0 -16
  131. package/src/wavesurfer.js +0 -1797
  132. package/src/webaudio.js +0 -779
@@ -1 +0,0 @@
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,SAAAA,eAAYC,MAAM,EAAEC,GAAE,EAAE;IAAA,IAAAC,KAAA;IAAAC,eAAA,OAAAJ,cAAA;IA9CxB;IAAAK,eAAA,oBACY,YAAM;MACd,IAAIF,KAAI,CAACG,OAAO,IAAIH,KAAI,CAACI,MAAM,CAACD,OAAO,EAAE;QACrCH,KAAI,CAACG,OAAO,CAACE,UAAU,GAAGL,KAAI,CAACI,MAAM,CAACD,OAAO,CAACE,UAAU;MAC5D;IACJ,CAAC;IAED;AACJ;AACA;IAFIH,eAAA,oBAGY;MAAA,OAAMF,KAAI,CAACM,MAAM,EAAE;IAAA;IAAAJ,eAAA,mBAEpB,YAAM;MACb,IAAMH,E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;QAC3B,OAAO,CAAC;MACZ,CAAC,MAAM,IAAIA,QAAQ,GAAG,EAAE,IAAI,EAAE,EAAE;QAC5B,OAAO,CAAC;MACZ;MACA,OAAO,CAAC;IACZ;EAAC;IAAA3F,GAAA;IAAAC,KAAA;IA1hBD;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;IACI,SAAA4F,OAAcxJ,MAAM,EAAE;MAClB,OAAO;QACHyJ,IAAI,EAAE,UAAU;QAChBC,SAAS,EAAE1J,MAAM,IAAIA,MAAM,CAAC0J,SAAS,GAAG1J,MAAM,CAAC0J,SAAS,GAAG,KAAK;QAChE1J,MAAM,EAAEA,MAAM;QACd2J,QAAQ,EAAE5J;MACd,CAAC;IACL;EAAC;EAAA,OAAAA,cAAA;AAAA;AAAA6J,kBAAA,GAAA7J,cAAA;AAAA+J,MAAA,CAAAF,OAAA,GAAAA,OAAA,CAAAC,OAAA;;;;;;UC5EL;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","_this","_classCallCheck","_defineProperty","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","_createClass","key","value","init","isReady","_onReady","once","destroy","unAll","un","removeEventListener","parentNode","_onWrapperClick","removeChild","createWrapper","wsParams","innerHTML","appendChild","createElement","style","display","position","userSelect","webkitUserSelect","concat","fillParent","scrollParent","overflowX","overflowY","updateCanvases","updateCanvasesPositioning","renderCanvases","addCanvas","canvas","push","zIndex","removeCanvas","pop","parentElement","totalWidth","requiredCanvases","ceil","length","_this2","canvasesLength","forEach","i","canvasWidth","left","_this3","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","_this4","leftOffset","intersection","x1","max","y1","x2","min","y2","text","textWidth","xOffset","measureText","seconds","pxPerSec","minutes","create","name","deferInit","instance","exports","default","module"],"sourceRoot":""}
@@ -1,7 +0,0 @@
1
- /*!
2
- * wavesurfer.js timeline plugin 6.5.1 (2023-03-12)
3
- * https://wavesurfer-js.org
4
- * @license BSD-3-Clause
5
- */
6
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("WaveSurfer",[],t):"object"==typeof exports?exports.WaveSurfer=t():(e.WaveSurfer=e.WaveSurfer||{},e.WaveSurfer.timeline=t())}(self,(()=>(()=>{"use strict";var e={171:(e,t)=>{function a(e){return a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},a(e)}function r(e,t){for(var a=0;a<t.length;a++){var r=t[a];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,n(r.key),r)}}function i(e,t,a){return(t=n(t))in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}function n(e){var t=function(e,t){if("object"!==a(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!==a(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"===a(t)?t:String(t)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var o=function(){function e(t,a){var r=this;if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),i(this,"_onScroll",(function(){r.wrapper&&r.drawer.wrapper&&(r.wrapper.scrollLeft=r.drawer.wrapper.scrollLeft)})),i(this,"_onRedraw",(function(){return r.render()})),i(this,"_onReady",(function(){var e=r.wavesurfer;r.drawer=e.drawer,r.pixelRatio=e.drawer.params.pixelRatio,r.maxCanvasWidth=e.drawer.maxCanvasWidth||e.drawer.width,r.maxCanvasElementWidth=e.drawer.maxCanvasElementWidth||Math.round(r.maxCanvasWidth/r.pixelRatio),e.drawer.wrapper.addEventListener("scroll",r._onScroll),e.on("redraw",r._onRedraw),e.on("zoom",r._onZoom),r.render()})),i(this,"_onWrapperClick",(function(e){e.preventDefault();var t="offsetX"in e?e.offsetX:e.layerX;r.fireEvent("click",t/r.wrapper.scrollWidth||0)})),this.container="string"==typeof t.container?document.querySelector(t.container):t.container,!this.container)throw new Error("No container for wavesurfer timeline");this.wavesurfer=a,this.util=a.util,this.params=Object.assign({},{height:20,notchPercentHeight:90,labelPadding:5,unlabeledNotchColor:"#c0c0c0",primaryColor:"#000",secondaryColor:"#c0c0c0",primaryFontColor:"#000",secondaryFontColor:"#000",fontFamily:"Arial",fontSize:10,duration:null,zoomDebounce:!1,formatTimeCallback:this.defaultFormatTimeCallback,timeInterval:this.defaultTimeInterval,primaryLabelInterval:this.defaultPrimaryLabelInterval,secondaryLabelInterval:this.defaultSecondaryLabelInterval,offset:0},t),this.canvases=[],this.wrapper=null,this.drawer=null,this.pixelRatio=null,this.maxCanvasWidth=null,this.maxCanvasElementWidth=null,this._onZoom=this.params.zoomDebounce?this.wavesurfer.util.debounce((function(){return r.render()}),this.params.zoomDebounce):function(){return r.render()}}var t,a,n;return t=e,n=[{key:"create",value:function(t){return{name:"timeline",deferInit:!(!t||!t.deferInit)&&t.deferInit,params:t,instance:e}}}],(a=[{key:"init",value:function(){this.wavesurfer.isReady?this._onReady():this.wavesurfer.once("ready",this._onReady)}},{key:"destroy",value:function(){this.unAll(),this.wavesurfer.un("redraw",this._onRedraw),this.wavesurfer.un("zoom",this._onZoom),this.wavesurfer.un("ready",this._onReady),this.wavesurfer.drawer.wrapper.removeEventListener("scroll",this._onScroll),this.wrapper&&this.wrapper.parentNode&&(this.wrapper.removeEventListener("click",this._onWrapperClick),this.wrapper.parentNode.removeChild(this.wrapper),this.wrapper=null)}},{key:"createWrapper",value:function(){var e=this.wavesurfer.params;this.container.innerHTML="",this.wrapper=this.container.appendChild(document.createElement("timeline")),this.util.style(this.wrapper,{display:"block",position:"relative",userSelect:"none",webkitUserSelect:"none",height:"".concat(this.params.height,"px")}),(e.fillParent||e.scrollParent)&&this.util.style(this.wrapper,{width:"100%",overflowX:"hidden",overflowY:"hidden"}),this.wrapper.addEventListener("click",this._onWrapperClick)}},{key:"render",value:function(){this.wrapper||this.createWrapper(),this.updateCanvases(),this.updateCanvasesPositioning(),this.renderCanvases()}},{key:"addCanvas",value:function(){var e=this.wrapper.appendChild(document.createElement("canvas"));this.canvases.push(e),this.util.style(e,{position:"absolute",zIndex:4})}},{key:"removeCanvas",value:function(){var e=this.canvases.pop();e.parentElement.removeChild(e)}},{key:"updateCanvases",value:function(){for(var e=Math.round(this.drawer.wrapper.scrollWidth),t=Math.ceil(e/this.maxCanvasElementWidth);this.canvases.length<t;)this.addCanvas();for(;this.canvases.length>t;)this.removeCanvas()}},{key:"updateCanvasesPositioning",value:function(){var e=this,t=this.canvases.length;this.canvases.forEach((function(a,r){var i=r===t-1?e.drawer.wrapper.scrollWidth-e.maxCanvasElementWidth*(t-1):e.maxCanvasElementWidth;a.width=i*e.pixelRatio,a.height=(e.params.height+1)*e.pixelRatio,e.util.style(a,{width:"".concat(i,"px"),height:"".concat(e.params.height,"px"),left:"".concat(r*e.maxCanvasElementWidth,"px")})}))}},{key:"renderCanvases",value:function(){var e=this,t=this.params.duration||this.wavesurfer.backend.getDuration();if(!(t<=0)){var a,r=this.wavesurfer.params,i=this.params.fontSize*r.pixelRatio,n=parseInt(t,10)+1,o=r.fillParent&&!r.scrollParent?this.drawer.getWidth():this.drawer.wrapper.scrollWidth*r.pixelRatio,s=this.params.height*this.pixelRatio,l=this.params.height*(this.params.notchPercentHeight/100)*this.pixelRatio,c=o/t,h=this.params.formatTimeCallback,u=function(e){return"function"==typeof e?e(c):e},f=u(this.params.timeInterval),p=u(this.params.primaryLabelInterval),d=u(this.params.secondaryLabelInterval),v=c*this.params.offset,m=0,y=[],w=this.params.offset<0?n-this.params.offset:n;for(a=0;a<w/f;a++)y.push([a,m,v]),m+=f,v+=c*f;var x=function(e){y.forEach((function(t){e(t[0],t[1],t[2])}))};this.setFillStyles(this.params.primaryColor),this.setFonts("".concat(i,"px ").concat(this.params.fontFamily)),this.setFillStyles(this.params.primaryFontColor),x((function(t,a,r){t%p==0&&(e.fillRect(r,0,1,s),e.fillText(h(a,c),r+e.params.labelPadding*e.pixelRatio,s))})),this.setFillStyles(this.params.secondaryColor),this.setFonts("".concat(i,"px ").concat(this.params.fontFamily)),this.setFillStyles(this.params.secondaryFontColor),x((function(t,a,r){t%d==0&&(e.fillRect(r,0,1,s),e.fillText(h(a,c),r+e.params.labelPadding*e.pixelRatio,s))})),this.setFillStyles(this.params.unlabeledNotchColor),x((function(t,a,r){t%d!=0&&t%p!=0&&e.fillRect(r,0,1,l)}))}}},{key:"setFillStyles",value:function(e){this.canvases.forEach((function(t){var a=t.getContext("2d");a&&(a.fillStyle=e)}))}},{key:"setFonts",value:function(e){this.canvases.forEach((function(t){var a=t.getContext("2d");a&&(a.font=e)}))}},{key:"fillRect",value:function(e,t,a,r){var i=this;this.canvases.forEach((function(n,o){var s=o*i.maxCanvasWidth,l={x1:Math.max(e,o*i.maxCanvasWidth),y1:t,x2:Math.min(e+a,o*i.maxCanvasWidth+n.width),y2:t+r};if(l.x1<l.x2){var c=n.getContext("2d");c&&c.fillRect(l.x1-s,l.y1,l.x2-l.x1,l.y2-l.y1)}}))}},{key:"fillText",value:function(e,t,a){var r,i=0;this.canvases.forEach((function(n){var o=n.getContext("2d");if(o){var s=o.canvas.width;if(i>t+r)return;i+s>t&&o&&(r=o.measureText(e).width,o.fillText(e,t-i,a)),i+=s}}))}},{key:"defaultFormatTimeCallback",value:function(e,t){if(e/60>1){var a=parseInt(e/60,10);return e=(e=parseInt(e%60,10))<10?"0"+e:e,"".concat(a,":").concat(e)}return Math.round(1e3*e)/1e3}},{key:"defaultTimeInterval",value:function(e){return e>=25?1:5*e>=25?5:15*e>=25?15:60*Math.ceil(.5/e)}},{key:"defaultPrimaryLabelInterval",value:function(e){return e>=25?10:5*e>=25?6:4}},{key:"defaultSecondaryLabelInterval",value:function(e){return e>=25?5:2}}])&&r(t.prototype,a),n&&r(t,n),Object.defineProperty(t,"prototype",{writable:!1}),e}();t.default=o,e.exports=t.default}},t={};var a=function a(r){var i=t[r];if(void 0!==i)return i.exports;var n=t[r]={exports:{}};return e[r](n,n.exports,a),n.exports}(171);return a})()));
7
- //# sourceMappingURL=wavesurfer.timeline.min.js.map
@@ -1 +0,0 @@
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,m7BCwBA,IAyBqBC,EAAc,WAiE/B,SAAAA,EAAYC,EAAQC,GAAI,IAAAC,EAAA,KAMpB,G,4FANoBC,CAAA,KAAAJ,GA9CxBK,EAAA,kBACY,WACJF,EAAKG,SAAWH,EAAKI,OAAOD,UAC5BH,EAAKG,QAAQE,WAAaL,EAAKI,OAAOD,QAAQE,WAEtD,IAEAH,EAAA,kBAGY,kBAAMF,EAAKM,QAAQ,IAAAJ,EAAA,iBAEpB,WACP,IAAMH,EAAKC,EAAKO,WAChBP,EAAKI,OAASL,EAAGK,OACjBJ,EAAKQ,WAAaT,EAAGK,OAAON,OAAOU,WACnCR,EAAKS,eAAiBV,EAAGK,OAAOK,gBAAkBV,EAAGK,OAAOM,MAC5DV,EAAKW,sBACDZ,EAAGK,OAAOO,uBACVC,KAAKC,MAAMb,EAAKS,eAAiBT,EAAKQ,YAG1CT,EAAGK,OAAOD,QAAQ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oB2F,GAChB,OAAIA,GAAY,GACL,EACW,EAAXA,GAAgB,GAChB,EACW,GAAXA,GAAiB,GACjB,GAEwB,GAA5BzI,KAAKoF,KAAK,GAAMqD,EAC3B,GAEA,CAAA5F,IAAA,8BAAAC,MAMA,SAA4B2F,GACxB,OAAIA,GAAY,GACL,GACW,EAAXA,GAAgB,GAChB,EAEA,CAGf,GAEA,CAAA5F,IAAA,gCAAAC,MAMA,SAA8B2F,GAC1B,OAAIA,GAAY,GACL,EAEA,CAKf,M,8EA1gBCxJ,CAAA,CAjB8B,GAiB9BL,EAAAA,QAAAK,EAAAJ,EAAAD,QAAAA,EAAA+J,O,GC3EDC,EAA2B,CAAC,ECEhC,IAAIC,EDCJ,SAASC,EAAoBC,GAE5B,IAAIC,EAAeJ,EAAyBG,GAC5C,QAAqBE,IAAjBD,EACH,OAAOA,EAAapK,QAGrB,IAAIC,EAAS+J,EAAyBG,GAAY,CAGjDnK,QAAS,CAAC,GAOX,OAHAsK,EAAoBH,GAAUlK,EAAQA,EAAOD,QAASkK,GAG/CjK,EAAOD,OACf,CCnB0BkK,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","_this","_classCallCheck","_defineProperty","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","key","value","name","deferInit","instance","isReady","_onReady","once","unAll","un","removeEventListener","parentNode","_onWrapperClick","removeChild","wsParams","innerHTML","appendChild","createElement","style","display","position","userSelect","webkitUserSelect","concat","fillParent","scrollParent","overflowX","overflowY","createWrapper","updateCanvases","updateCanvasesPositioning","renderCanvases","canvas","push","zIndex","pop","parentElement","totalWidth","requiredCanvases","ceil","length","addCanvas","removeCanvas","_this2","canvasesLength","forEach","i","canvasWidth","left","_this3","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","_this4","leftOffset","intersection","x1","max","y1","x2","min","y2","text","textWidth","xOffset","measureText","seconds","pxPerSec","minutes","default","__webpack_module_cache__","__webpack_exports__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__"],"sourceRoot":""}
@@ -1,381 +0,0 @@
1
- /*!
2
- * wavesurfer.js 6.5.1 (2023-03-12)
3
- * https://wavesurfer-js.org
4
- * @license BSD-3-Clause
5
- */
6
- (function webpackUniversalModuleDefinition(root, factory) {
7
- if(typeof exports === 'object' && typeof module === 'object')
8
- module.exports = factory();
9
- else if(typeof define === 'function' && define.amd)
10
- define("WaveSurfer", [], factory);
11
- else if(typeof exports === 'object')
12
- exports["WaveSurfer"] = factory();
13
- else
14
- root["WaveSurfer"] = root["WaveSurfer"] || {}, root["WaveSurfer"]["html-init"] = factory();
15
- })(self, () => {
16
- return /******/ (() => { // webpackBootstrap
17
- /******/ var __webpack_modules__ = ({
18
-
19
- /***/ "./src/html-init.js":
20
- /*!**************************!*\
21
- !*** ./src/html-init.js ***!
22
- \**************************/
23
- /***/ ((module, exports, __webpack_require__) => {
24
-
25
- "use strict";
26
-
27
-
28
- Object.defineProperty(exports, "__esModule", ({
29
- value: true
30
- }));
31
- exports["default"] = void 0;
32
- var _loadScript = _interopRequireDefault(__webpack_require__(/*! load-script */ "./node_modules/load-script/index.js"));
33
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
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); }
35
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
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, _toPropertyKey(descriptor.key), descriptor); } }
37
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
38
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
39
- function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
40
- /**
41
- * @typedef {Object} InitParams
42
- * @property {WavesurferParams} [defaults={backend: 'MediaElement,
43
- * mediaControls: true}] The default wavesurfer initialisation parameters
44
- * @property {string|NodeList} containers='wavesurfer' Selector or NodeList of
45
- * elements to attach instances to
46
- * @property {string}
47
- * pluginCdnTemplate='//localhost:8080/dist/plugin/wavesurfer.[name].js' URL
48
- * template for the dynamic loading of plugins
49
- * @property {function} loadPlugin If set overwrites the default request function,
50
- * can be used to inject plugins differently.
51
- */
52
- /**
53
- * The HTML initialisation API is not part of the main library bundle file and
54
- * must be additionally included.
55
- *
56
- * The API attaches wavesurfer instances to all `<wavesurfer>` (can be
57
- * customised), parsing their `data-` attributes to construct an options object
58
- * for initialisation. Among other things it can dynamically load plugin code.
59
- *
60
- * The automatic initialisation can be prevented by setting the
61
- * `window.WS_StopAutoInit` flag to true. The `html-init[.min].js` file exports
62
- * the `Init` class, which can be called manually.
63
- *
64
- * Site-wide defaults can be added by setting `window.WS_InitOptions`.
65
- *
66
- * @example
67
- * <!-- with minimap and timeline plugin -->
68
- * <wavesurfer
69
- * data-url="../media/demo.wav"
70
- * data-plugins="minimap,timeline"
71
- * data-minimap-height="30"
72
- * data-minimap-wave-color="#ddd"
73
- * data-minimap-progress-color="#999"
74
- * data-timeline-font-size="13px"
75
- * data-timeline-container="#timeline"
76
- * >
77
- * </wavesurfer>
78
- * <div id="timeline"></div>
79
- *
80
- * <!-- with regions plugin -->
81
- * <wavesurfer
82
- * data-url="../media/demo.wav"
83
- * data-plugins="regions"
84
- * data-regions-regions='[{"start": 1,"end": 3,"color": "hsla(400, 100%, 30%, 0.5)"}]'
85
- * >
86
- * </wavesurfer>
87
- */
88
- var Init = /*#__PURE__*/function () {
89
- /**
90
- * Instantiate Init class and initialize elements
91
- *
92
- * This is done automatically if `window` is defined and
93
- * `window.WS_StopAutoInit` is not set to true
94
- *
95
- * @param {WaveSurfer} WaveSurfer The WaveSurfer library object
96
- * @param {InitParams} params initialisation options
97
- */
98
- function Init(WaveSurfer) {
99
- var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
100
- _classCallCheck(this, Init);
101
- if (!WaveSurfer) {
102
- throw new Error('WaveSurfer is not available!');
103
- }
104
-
105
- /**
106
- * cache WaveSurfer
107
- * @private
108
- */
109
- this.WaveSurfer = WaveSurfer;
110
-
111
- /**
112
- * build parameters, cache them in _params so minified builds are smaller
113
- * @private
114
- */
115
- var _params = this.params = Object.assign({}, {
116
- // wavesurfer parameter defaults so by default the audio player is
117
- // usable with native media element controls
118
- defaults: {
119
- backend: 'MediaElement',
120
- mediaControls: true
121
- },
122
- // containers to instantiate on, can be selector string or NodeList
123
- containers: 'wavesurfer',
124
- // @TODO insert plugin CDN URIs
125
- pluginCdnTemplate: '//localhost:8080/dist/plugin/wavesurfer.[name].js',
126
- // loadPlugin function can be overridden to inject plugin definition
127
- // objects, this default function uses load-script to load a plugin
128
- // and pass it to a callback
129
- loadPlugin: function loadPlugin(name, cb) {
130
- var src = _params.pluginCdnTemplate.replace('[name]', name);
131
- (0, _loadScript.default)(src, {
132
- async: false
133
- }, function (err, plugin) {
134
- if (err) {
135
- // eslint-disable-next-line no-console
136
- return console.error("WaveSurfer plugin ".concat(name, " not found at ").concat(src));
137
- }
138
- cb(window.WaveSurfer[name]);
139
- });
140
- }
141
- }, params);
142
- /**
143
- * The nodes that should have instances attached to them
144
- * @type {NodeList}
145
- */
146
- this.containers = typeof _params.containers == 'string' ? document.querySelectorAll(_params.containers) : _params.containers;
147
- /** @private */
148
- this.pluginCache = {};
149
- /**
150
- * An array of wavesurfer instances
151
- * @type {Object[]}
152
- */
153
- this.instances = [];
154
- this.initAllEls();
155
- }
156
-
157
- /**
158
- * Initialize all container elements
159
- */
160
- _createClass(Init, [{
161
- key: "initAllEls",
162
- value: function initAllEls() {
163
- var _this = this;
164
- // iterate over all the container elements
165
- Array.prototype.forEach.call(this.containers, function (el) {
166
- // load the plugins as an array of plugin names
167
- var plugins = el.dataset.plugins ? el.dataset.plugins.split(',') : [];
168
-
169
- // no plugins to be loaded, just render
170
- if (!plugins.length) {
171
- return _this.initEl(el);
172
- }
173
- // … or: iterate over all the plugins
174
- plugins.forEach(function (name, i) {
175
- // plugin is not cached already, load it
176
- if (!_this.pluginCache[name]) {
177
- _this.params.loadPlugin(name, function (lib) {
178
- _this.pluginCache[name] = lib;
179
- // plugins were all loaded, render the element
180
- if (i + 1 === plugins.length) {
181
- _this.initEl(el, plugins);
182
- }
183
- });
184
- } else if (i === plugins.length) {
185
- // plugin was cached and this plugin was the last
186
- _this.initEl(el, plugins);
187
- }
188
- });
189
- });
190
- }
191
-
192
- /**
193
- * Initialize a single container element and add to `this.instances`
194
- *
195
- * @param {HTMLElement} el The container to instantiate wavesurfer to
196
- * @param {PluginDefinition[]} plugins An Array of plugin names to initialize with
197
- * @return {Object} Wavesurfer instance
198
- */
199
- }, {
200
- key: "initEl",
201
- value: function initEl(el) {
202
- var _this2 = this;
203
- var plugins = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
204
- var jsonRegex = /^[[|{]/;
205
- // initialize plugins with the correct options
206
- var initialisedPlugins = plugins.map(function (plugin) {
207
- var options = {};
208
- // the regex to find this plugin attributes
209
- var attrNameRegex = new RegExp('^' + plugin);
210
- var attrName;
211
- // iterate over all the data attributes and find ones for this
212
- // plugin
213
- for (attrName in el.dataset) {
214
- var regexResult = attrNameRegex.exec(attrName);
215
- if (regexResult) {
216
- var attr = el.dataset[attrName];
217
- // if the string begins with a [ or a { parse it as JSON
218
- var prop = jsonRegex.test(attr) ? JSON.parse(attr) : attr;
219
- // this removes the plugin prefix and changes the first letter
220
- // of the resulting string to lower case to follow the naming
221
- // convention of ws params
222
- var unprefixedOptionName = attrName.slice(plugin.length, plugin.length + 1).toLowerCase() + attrName.slice(plugin.length + 1);
223
- options[unprefixedOptionName] = prop;
224
- }
225
- }
226
- return _this2.pluginCache[plugin].create(options);
227
- });
228
- // build parameter object for this container
229
- var params = Object.assign({
230
- container: el
231
- }, this.params.defaults, el.dataset, {
232
- plugins: initialisedPlugins
233
- });
234
-
235
- // @TODO make nicer
236
- el.style.display = 'block';
237
-
238
- // initialize wavesurfer, load audio (with peaks if provided)
239
- var instance = this.WaveSurfer.create(params);
240
- var peaks = params.peaks ? JSON.parse(params.peaks) : undefined;
241
- instance.load(params.url, peaks);
242
-
243
- // push this instance into the instances cache
244
- this.instances.push(instance);
245
- return instance;
246
- }
247
- }]);
248
- return Init;
249
- }(); // if window object exists and window.WS_StopAutoInit is not true
250
- if ((typeof window === "undefined" ? "undefined" : _typeof(window)) === 'object' && !window.WS_StopAutoInit) {
251
- // call init when document is ready, apply any custom default settings
252
- // in window.WS_InitOptions
253
- if (document.readyState === 'complete') {
254
- window.WaveSurferInit = new Init(window.WaveSurfer, window.WS_InitOptions);
255
- } else {
256
- window.addEventListener('load', function () {
257
- window.WaveSurferInit = new Init(window.WaveSurfer, window.WS_InitOptions);
258
- });
259
- }
260
- }
261
-
262
- // export init for manual usage
263
- var _default = Init;
264
- exports["default"] = _default;
265
- module.exports = exports.default;
266
-
267
- /***/ }),
268
-
269
- /***/ "./node_modules/load-script/index.js":
270
- /*!*******************************************!*\
271
- !*** ./node_modules/load-script/index.js ***!
272
- \*******************************************/
273
- /***/ ((module) => {
274
-
275
-
276
- module.exports = function load (src, opts, cb) {
277
- var head = document.head || document.getElementsByTagName('head')[0]
278
- var script = document.createElement('script')
279
-
280
- if (typeof opts === 'function') {
281
- cb = opts
282
- opts = {}
283
- }
284
-
285
- opts = opts || {}
286
- cb = cb || function() {}
287
-
288
- script.type = opts.type || 'text/javascript'
289
- script.charset = opts.charset || 'utf8';
290
- script.async = 'async' in opts ? !!opts.async : true
291
- script.src = src
292
-
293
- if (opts.attrs) {
294
- setAttributes(script, opts.attrs)
295
- }
296
-
297
- if (opts.text) {
298
- script.text = '' + opts.text
299
- }
300
-
301
- var onend = 'onload' in script ? stdOnEnd : ieOnEnd
302
- onend(script, cb)
303
-
304
- // some good legacy browsers (firefox) fail the 'in' detection above
305
- // so as a fallback we always set onload
306
- // old IE will ignore this and new IE will set onload
307
- if (!script.onload) {
308
- stdOnEnd(script, cb);
309
- }
310
-
311
- head.appendChild(script)
312
- }
313
-
314
- function setAttributes(script, attrs) {
315
- for (var attr in attrs) {
316
- script.setAttribute(attr, attrs[attr]);
317
- }
318
- }
319
-
320
- function stdOnEnd (script, cb) {
321
- script.onload = function () {
322
- this.onerror = this.onload = null
323
- cb(null, script)
324
- }
325
- script.onerror = function () {
326
- // this.onload = null here is necessary
327
- // because even IE9 works not like others
328
- this.onerror = this.onload = null
329
- cb(new Error('Failed to load ' + this.src), script)
330
- }
331
- }
332
-
333
- function ieOnEnd (script, cb) {
334
- script.onreadystatechange = function () {
335
- if (this.readyState != 'complete' && this.readyState != 'loaded') return
336
- this.onreadystatechange = null
337
- cb(null, script) // there is no way to catch loading errors in IE8
338
- }
339
- }
340
-
341
-
342
- /***/ })
343
-
344
- /******/ });
345
- /************************************************************************/
346
- /******/ // The module cache
347
- /******/ var __webpack_module_cache__ = {};
348
- /******/
349
- /******/ // The require function
350
- /******/ function __webpack_require__(moduleId) {
351
- /******/ // Check if module is in cache
352
- /******/ var cachedModule = __webpack_module_cache__[moduleId];
353
- /******/ if (cachedModule !== undefined) {
354
- /******/ return cachedModule.exports;
355
- /******/ }
356
- /******/ // Create a new module (and put it into the cache)
357
- /******/ var module = __webpack_module_cache__[moduleId] = {
358
- /******/ // no module.id needed
359
- /******/ // no module.loaded needed
360
- /******/ exports: {}
361
- /******/ };
362
- /******/
363
- /******/ // Execute the module function
364
- /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
365
- /******/
366
- /******/ // Return the exports of the module
367
- /******/ return module.exports;
368
- /******/ }
369
- /******/
370
- /************************************************************************/
371
- /******/
372
- /******/ // startup
373
- /******/ // Load entry module and return exports
374
- /******/ // This entry module is referenced by other modules so it can't be inlined
375
- /******/ var __webpack_exports__ = __webpack_require__("./src/html-init.js");
376
- /******/
377
- /******/ return __webpack_exports__;
378
- /******/ })()
379
- ;
380
- });
381
- //# sourceMappingURL=wavesurfer-html-init.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"wavesurfer-html-init.js","mappings":";;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,+CAA+C;AAC/C,CAAC;AACD;;;;;;;;;;;;;;;;ACVA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,mBAAA;AAAqC,SAAAD,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,SAAAG,QAAAH,GAAA,sCAAAG,OAAA,wBAAAC,MAAA,uBAAAA,MAAA,CAAAC,QAAA,aAAAL,GAAA,kBAAAA,GAAA,gBAAAA,GAAA,WAAAA,GAAA,yBAAAI,MAAA,IAAAJ,GAAA,CAAAM,WAAA,KAAAF,MAAA,IAAAJ,GAAA,KAAAI,MAAA,CAAAG,SAAA,qBAAAP,GAAA,KAAAG,OAAA,CAAAH,GAAA;AAAA,SAAAQ,gBAAAC,QAAA,EAAAC,WAAA,UAAAD,QAAA,YAAAC,WAAA,eAAAC,SAAA;AAAA,SAAAC,kBAAAC,MAAA,EAAAC,KAAA,aAAAC,CAAA,MAAAA,CAAA,GAAAD,KAAA,CAAAE,MAAA,EAAAD,CAAA,UAAAE,UAAA,GAAAH,KAAA,CAAAC,CA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E,IAAI;AAAAwE,kBAAA,GAAAD,QAAA;AAAAE,MAAA,CAAAD,OAAA,GAAAA,OAAA,CAAA7G,OAAA;;;;;;;;;;;AC/OnB;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;UChEA;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/html-init.js","webpack://WaveSurfer/./node_modules/load-script/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\"][\"html-init\"] = factory();\n})(self, () => {\nreturn ","import loadScript from 'load-script';\n\n/**\n * @typedef {Object} InitParams\n * @property {WavesurferParams} [defaults={backend: 'MediaElement,\n * mediaControls: true}] The default wavesurfer initialisation parameters\n * @property {string|NodeList} containers='wavesurfer' Selector or NodeList of\n * elements to attach instances to\n * @property {string}\n * pluginCdnTemplate='//localhost:8080/dist/plugin/wavesurfer.[name].js' URL\n * template for the dynamic loading of plugins\n * @property {function} loadPlugin If set overwrites the default request function,\n * can be used to inject plugins differently.\n */\n/**\n * The HTML initialisation API is not part of the main library bundle file and\n * must be additionally included.\n *\n * The API attaches wavesurfer instances to all `<wavesurfer>` (can be\n * customised), parsing their `data-` attributes to construct an options object\n * for initialisation. Among other things it can dynamically load plugin code.\n *\n * The automatic initialisation can be prevented by setting the\n * `window.WS_StopAutoInit` flag to true. The `html-init[.min].js` file exports\n * the `Init` class, which can be called manually.\n *\n * Site-wide defaults can be added by setting `window.WS_InitOptions`.\n *\n * @example\n * <!-- with minimap and timeline plugin -->\n * <wavesurfer\n * data-url=\"../media/demo.wav\"\n * data-plugins=\"minimap,timeline\"\n * data-minimap-height=\"30\"\n * data-minimap-wave-color=\"#ddd\"\n * data-minimap-progress-color=\"#999\"\n * data-timeline-font-size=\"13px\"\n * data-timeline-container=\"#timeline\"\n * >\n * </wavesurfer>\n * <div id=\"timeline\"></div>\n *\n * <!-- with regions plugin -->\n * <wavesurfer\n * data-url=\"../media/demo.wav\"\n * data-plugins=\"regions\"\n * data-regions-regions='[{\"start\": 1,\"end\": 3,\"color\": \"hsla(400, 100%, 30%, 0.5)\"}]'\n * >\n * </wavesurfer>\n */\nclass Init {\n /**\n * Instantiate Init class and initialize elements\n *\n * This is done automatically if `window` is defined and\n * `window.WS_StopAutoInit` is not set to true\n *\n * @param {WaveSurfer} WaveSurfer The WaveSurfer library object\n * @param {InitParams} params initialisation options\n */\n constructor(WaveSurfer, params = {}) {\n if (!WaveSurfer) {\n throw new Error('WaveSurfer is not available!');\n }\n\n /**\n * cache WaveSurfer\n * @private\n */\n this.WaveSurfer = WaveSurfer;\n\n /**\n * build parameters, cache them in _params so minified builds are smaller\n * @private\n */\n const _params = (this.params = Object.assign(\n {},\n {\n // wavesurfer parameter defaults so by default the audio player is\n // usable with native media element controls\n defaults: {\n backend: 'MediaElement',\n mediaControls: true\n },\n // containers to instantiate on, can be selector string or NodeList\n containers: 'wavesurfer',\n // @TODO insert plugin CDN URIs\n pluginCdnTemplate:\n '//localhost:8080/dist/plugin/wavesurfer.[name].js',\n // loadPlugin function can be overridden to inject plugin definition\n // objects, this default function uses load-script to load a plugin\n // and pass it to a callback\n loadPlugin(name, cb) {\n const src = _params.pluginCdnTemplate.replace(\n '[name]',\n name\n );\n loadScript(src, { async: false }, (err, plugin) => {\n if (err) {\n // eslint-disable-next-line no-console\n return console.error(\n `WaveSurfer plugin ${name} not found at ${src}`\n );\n }\n cb(window.WaveSurfer[name]);\n });\n }\n },\n params\n ));\n /**\n * The nodes that should have instances attached to them\n * @type {NodeList}\n */\n this.containers =\n typeof _params.containers == 'string'\n ? document.querySelectorAll(_params.containers)\n : _params.containers;\n /** @private */\n this.pluginCache = {};\n /**\n * An array of wavesurfer instances\n * @type {Object[]}\n */\n this.instances = [];\n\n this.initAllEls();\n }\n\n /**\n * Initialize all container elements\n */\n initAllEls() {\n // iterate over all the container elements\n Array.prototype.forEach.call(this.containers, el => {\n // load the plugins as an array of plugin names\n const plugins = el.dataset.plugins\n ? el.dataset.plugins.split(',')\n : [];\n\n // no plugins to be loaded, just render\n if (!plugins.length) {\n return this.initEl(el);\n }\n // … or: iterate over all the plugins\n plugins.forEach((name, i) => {\n // plugin is not cached already, load it\n if (!this.pluginCache[name]) {\n this.params.loadPlugin(name, lib => {\n this.pluginCache[name] = lib;\n // plugins were all loaded, render the element\n if (i + 1 === plugins.length) {\n this.initEl(el, plugins);\n }\n });\n } else if (i === plugins.length) {\n // plugin was cached and this plugin was the last\n this.initEl(el, plugins);\n }\n });\n });\n }\n\n /**\n * Initialize a single container element and add to `this.instances`\n *\n * @param {HTMLElement} el The container to instantiate wavesurfer to\n * @param {PluginDefinition[]} plugins An Array of plugin names to initialize with\n * @return {Object} Wavesurfer instance\n */\n initEl(el, plugins = []) {\n const jsonRegex = /^[[|{]/;\n // initialize plugins with the correct options\n const initialisedPlugins = plugins.map(plugin => {\n const options = {};\n // the regex to find this plugin attributes\n const attrNameRegex = new RegExp('^' + plugin);\n let attrName;\n // iterate over all the data attributes and find ones for this\n // plugin\n for (attrName in el.dataset) {\n const regexResult = attrNameRegex.exec(attrName);\n if (regexResult) {\n const attr = el.dataset[attrName];\n // if the string begins with a [ or a { parse it as JSON\n const prop = jsonRegex.test(attr) ? JSON.parse(attr) : attr;\n // this removes the plugin prefix and changes the first letter\n // of the resulting string to lower case to follow the naming\n // convention of ws params\n const unprefixedOptionName =\n attrName\n .slice(plugin.length, plugin.length + 1)\n .toLowerCase() + attrName.slice(plugin.length + 1);\n options[unprefixedOptionName] = prop;\n }\n }\n return this.pluginCache[plugin].create(options);\n });\n // build parameter object for this container\n const params = Object.assign(\n { container: el },\n this.params.defaults,\n el.dataset,\n { plugins: initialisedPlugins }\n );\n\n // @TODO make nicer\n el.style.display = 'block';\n\n // initialize wavesurfer, load audio (with peaks if provided)\n const instance = this.WaveSurfer.create(params);\n const peaks = params.peaks ? JSON.parse(params.peaks) : undefined;\n instance.load(params.url, peaks);\n\n // push this instance into the instances cache\n this.instances.push(instance);\n return instance;\n }\n}\n\n// if window object exists and window.WS_StopAutoInit is not true\nif (typeof window === 'object' && !window.WS_StopAutoInit) {\n // call init when document is ready, apply any custom default settings\n // in window.WS_InitOptions\n if (document.readyState === 'complete') {\n window.WaveSurferInit = new Init(\n window.WaveSurfer,\n window.WS_InitOptions\n );\n } else {\n window.addEventListener('load', () => {\n window.WaveSurferInit = new Init(\n window.WaveSurfer,\n window.WS_InitOptions\n );\n });\n }\n}\n\n// export init for manual usage\nexport default Init;\n","\nmodule.exports = function load (src, opts, cb) {\n var head = document.head || document.getElementsByTagName('head')[0]\n var script = document.createElement('script')\n\n if (typeof opts === 'function') {\n cb = opts\n opts = {}\n }\n\n opts = opts || {}\n cb = cb || function() {}\n\n script.type = opts.type || 'text/javascript'\n script.charset = opts.charset || 'utf8';\n script.async = 'async' in opts ? !!opts.async : true\n script.src = src\n\n if (opts.attrs) {\n setAttributes(script, opts.attrs)\n }\n\n if (opts.text) {\n script.text = '' + opts.text\n }\n\n var onend = 'onload' in script ? stdOnEnd : ieOnEnd\n onend(script, cb)\n\n // some good legacy browsers (firefox) fail the 'in' detection above\n // so as a fallback we always set onload\n // old IE will ignore this and new IE will set onload\n if (!script.onload) {\n stdOnEnd(script, cb);\n }\n\n head.appendChild(script)\n}\n\nfunction setAttributes(script, attrs) {\n for (var attr in attrs) {\n script.setAttribute(attr, attrs[attr]);\n }\n}\n\nfunction stdOnEnd (script, cb) {\n script.onload = function () {\n this.onerror = this.onload = null\n cb(null, script)\n }\n script.onerror = function () {\n // this.onload = null here is necessary\n // because even IE9 works not like others\n this.onerror = this.onload = null\n cb(new Error('Failed to load ' + this.src), script)\n }\n}\n\nfunction ieOnEnd (script, cb) {\n script.onreadystatechange = function () {\n if (this.readyState != 'complete' && this.readyState != 'loaded') return\n this.onreadystatechange = null\n cb(null, script) // there is no way to catch loading errors in IE8\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/html-init.js\");\n",""],"names":["_loadScript","_interopRequireDefault","require","obj","__esModule","default","_typeof","Symbol","iterator","constructor","prototype","_classCallCheck","instance","Constructor","TypeError","_defineProperties","target","props","i","length","descriptor","enumerable","configurable","writable","Object","defineProperty","_toPropertyKey","key","_createClass","protoProps","staticProps","arg","_toPrimitive","String","input","hint","prim","toPrimitive","undefined","res","call","Number","Init","WaveSurfer","params","arguments","Error","_params","assign","defaults","backend","mediaControls","containers","pluginCdnTemplate","loadPlugin","name","cb","src","replace","loadScript","async","err","plugin","console","error","concat","window","document","querySelectorAll","pluginCache","instances","initAllEls","value","_this","Array","forEach","el","plugins","dataset","split","initEl","lib","_this2","jsonRegex","initialisedPlugins","map","options","attrNameRegex","RegExp","attrName","regexResult","exec","attr","prop","test","JSON","parse","unprefixedOptionName","slice","toLowerCase","create","container","style","display","peaks","load","url","push","WS_StopAutoInit","readyState","WaveSurferInit","WS_InitOptions","addEventListener","_default","exports","module"],"sourceRoot":""}