wavesurfer.js 4.6.0 → 5.2.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 (66) hide show
  1. package/CHANGES.md +41 -0
  2. package/README.md +6 -3
  3. package/dist/plugin/wavesurfer.cursor.js +9 -5
  4. package/dist/plugin/wavesurfer.cursor.js.map +1 -1
  5. package/dist/plugin/wavesurfer.cursor.min.js +2 -2
  6. package/dist/plugin/wavesurfer.cursor.min.js.map +1 -1
  7. package/dist/plugin/wavesurfer.elan.js +5 -4
  8. package/dist/plugin/wavesurfer.elan.js.map +1 -1
  9. package/dist/plugin/wavesurfer.elan.min.js +2 -2
  10. package/dist/plugin/wavesurfer.elan.min.js.map +1 -1
  11. package/dist/plugin/wavesurfer.markers.js +31 -12
  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 -4
  16. package/dist/plugin/wavesurfer.mediasession.js.map +1 -1
  17. package/dist/plugin/wavesurfer.mediasession.min.js +2 -2
  18. package/dist/plugin/wavesurfer.mediasession.min.js.map +1 -1
  19. package/dist/plugin/wavesurfer.microphone.js +5 -4
  20. package/dist/plugin/wavesurfer.microphone.js.map +1 -1
  21. package/dist/plugin/wavesurfer.microphone.min.js +2 -2
  22. package/dist/plugin/wavesurfer.microphone.min.js.map +1 -1
  23. package/dist/plugin/wavesurfer.minimap.js +5 -4
  24. package/dist/plugin/wavesurfer.minimap.js.map +1 -1
  25. package/dist/plugin/wavesurfer.minimap.min.js +2 -2
  26. package/dist/plugin/wavesurfer.minimap.min.js.map +1 -1
  27. package/dist/plugin/wavesurfer.playhead.js +324 -0
  28. package/dist/plugin/wavesurfer.playhead.js.map +1 -0
  29. package/dist/plugin/wavesurfer.playhead.min.js +7 -0
  30. package/dist/plugin/wavesurfer.playhead.min.js.map +1 -0
  31. package/dist/plugin/wavesurfer.regions.js +141 -86
  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 +70 -63
  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 +32 -16
  40. package/dist/plugin/wavesurfer.timeline.js.map +1 -1
  41. package/dist/plugin/wavesurfer.timeline.min.js +2 -2
  42. package/dist/plugin/wavesurfer.timeline.min.js.map +1 -1
  43. package/dist/wavesurfer-html-init.js +5 -4
  44. package/dist/wavesurfer-html-init.js.map +1 -1
  45. package/dist/wavesurfer-html-init.min.js +2 -2
  46. package/dist/wavesurfer-html-init.min.js.map +1 -1
  47. package/dist/wavesurfer.js +326 -60
  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 +19 -16
  52. package/src/drawer.canvasentry.js +16 -0
  53. package/src/drawer.js +30 -21
  54. package/src/drawer.multicanvas.js +63 -39
  55. package/src/plugin/cursor/index.js +3 -1
  56. package/src/plugin/markers/index.js +22 -8
  57. package/src/plugin/playhead/index.js +226 -0
  58. package/src/plugin/regions/index.js +28 -11
  59. package/src/plugin/regions/region.js +116 -75
  60. package/src/plugin/spectrogram/index.js +65 -61
  61. package/src/plugin/timeline/index.js +30 -19
  62. package/src/util/index.js +2 -0
  63. package/src/util/orientation.js +98 -0
  64. package/src/util/silence-mode.js +35 -0
  65. package/src/wavesurfer.js +41 -22
  66. package/src/webaudio.js +11 -2
@@ -1 +1 @@
1
- {"version":3,"sources":["webpack://WaveSurfer.[name]/webpack/universalModuleDefinition","webpack://WaveSurfer.[name]/./src/plugin/elan/index.js","webpack://WaveSurfer.[name]/webpack/bootstrap","webpack://WaveSurfer.[name]/webpack/startup"],"names":["root","factory","exports","module","define","amd","this","ElanPlugin","params","ws","Types","ALIGNABLE_ANNOTATION","REF_ANNOTATION","data","container","document","querySelector","Error","name","deferInit","instance","bindClick","url","load","removeEventListener","_onClick","removeChild","table","loadXML","xml","parseElan","render","fireEvent","callback","xhr","XMLHttpRequest","open","responseType","send","addEventListener","e","target","responseXML","_forEach","Array","prototype","forEach","_map","map","media","timeOrder","tiers","annotations","alignableAnnotations","header","inMilliseconds","getAttribute","type","timeSlots","querySelectorAll","call","slot","value","parseFloat","Math","round","tier","id","linguisticTypeRef","defaultLocale","node","annot","nodeName","ref","textContent","trim","start","end","push","reference","sort","a","b","d","length","filter","backRefs","indeces","index","Object","keys","renderedAlignable","alignable","createElement","className","thead","headRow","appendChild","th","style","width","tbody","row","td","toFixed","backRef","annotation","dataset","innerHTML","time","result","some","getElementById","__webpack_module_cache__","__webpack_require__","moduleId","__webpack_modules__"],"mappings":";;;;;CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,aAAc,GAAIH,GACC,iBAAZC,QACdA,QAAoB,WAAID,KAExBD,EAAiB,WAAIA,EAAiB,YAAK,GAAIA,EAAiB,WAAQ,KAAIC,KAR9E,CASGK,MAAM,WACT,M,kRC0BqBC,E,WAwBjB,WAAYC,EAAQC,GAQhB,G,4FARoB,cALxBC,MAAQ,CACJC,qBAAsB,uBACtBC,eAAgB,kBAIhBN,KAAKO,KAAO,KACZP,KAAKE,OAASA,EACdF,KAAKQ,UACD,iBAAmBN,EAAOM,UACpBC,SAASC,cAAcR,EAAOM,WAC9BN,EAAOM,WAEZR,KAAKQ,UACN,MAAMG,MAAM,yB,4CAvBpB,SAAcT,GACV,MAAO,CACHU,KAAM,OACNC,aAAWX,IAAUA,EAAOW,YAAYX,E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MAC5Ba,EAAaD,EAAQjB,GACvBkB,IACAH,EAAGpC,GAAK,yBAA2BuC,EAAWvC,GAC9CoC,EAAGI,QAAQlC,IAAMmB,EAAUzB,GAC3BoC,EAAGI,QAAQ/B,MAAQgB,EAAUhB,MAC7B2B,EAAGI,QAAQ9B,IAAMe,EAAUf,IAC3B0B,EAAG7B,YAAcgC,EAAW5C,OAEhCyC,EAAGT,UAAY,mBAAqB5B,EAAKC,GACzCmC,EAAIL,YAAYM,SAIxBjG,KAAKQ,UAAU8F,UAAY,GAC3BtG,KAAKQ,UAAUmF,YAAYtE,K,uBAG/B,WAAY,WACRrB,KAAKmB,SAAW,SAAAe,GACZ,IAAMiC,EAAMjC,EAAEC,OAAOkE,QAAQlC,IAC7B,GAAI,MAAQA,EAAK,CACb,IAAMF,EAAQ,EAAK1D,KAAKuC,YAAYqB,GAChCF,GACA,EAAKvC,UAAU,SAAUuC,EAAMK,MAAOL,EAAMM,OAIxDvE,KAAKQ,UAAUyB,iBAAiB,QAASjC,KAAKmB,Y,mCAGlD,SAAsBoF,GAClB,IAAIC,EAQJ,OAPAxG,KAAKqF,kBAAkBoB,MAAK,SAAAL,GACxB,OAAIA,EAAW9B,OAASiC,GAAQH,EAAW7B,KAAOgC,IAC9CC,EAASJ,GACF,MAIRI,I,+BAGX,SAAkBJ,GACd,OAAO3F,SAASiG,eAAe,wBAA0BN,EAAWvC,S,kEC/SxE8C,EAA2B,G,OAG/B,SAASC,EAAoBC,GAE5B,GAAGF,EAAyBE,GAC3B,OAAOF,EAAyBE,GAAUjH,QAG3C,IAAIC,EAAS8G,EAAyBE,GAAY,CAGjDjH,QAAS,IAOV,OAHAkH,EAAoBD,GAAUhH,EAAQA,EAAOD,QAASgH,GAG/C/G,EAAOD,QCjBWgH,CAAoB,M","file":"wavesurfer.elan.min.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"WaveSurfer\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"WaveSurfer\"] = factory();\n\telse\n\t\troot[\"WaveSurfer\"] = root[\"WaveSurfer\"] || {}, root[\"WaveSurfer\"][\"elan\"] = factory();\n})(this, function() {\nreturn ","/**\n * @typedef {Object} ElanPluginParams\n * @property {string|HTMLElement} container CSS selector or HTML element where\n * the ELAN information should be rendered.\n * @property {string} url The location of ELAN XML data\n * @property {?boolean} deferInit Set to true to manually call\n * @property {?Object} tiers If set only shows the data tiers with the `TIER_ID`\n * in this map.\n */\n\n/**\n * Downloads and renders ELAN audio transcription documents alongside the\n * waveform.\n *\n * @implements {PluginClass}\n * @extends {Observer}\n * @example\n * // es6\n * import ElanPlugin from 'wavesurfer.elan.js';\n *\n * // commonjs\n * var ElanPlugin = require('wavesurfer.elan.js');\n *\n * // if you are using <script> tags\n * var ElanPlugin = window.WaveSurfer.elan;\n *\n * // ... initialising wavesurfer with the plugin\n * var wavesurfer = WaveSurfer.create({\n * // wavesurfer options ...\n * plugins: [\n * ElanPlugin.create({\n * // plugin options ...\n * })\n * ]\n * });\n */\nexport default class ElanPlugin {\n /**\n * Elan 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 {ElanPluginParams} params parameters use to initialise the plugin\n * @return {PluginDefinition} an object representing the plugin\n */\n static create(params) {\n return {\n name: 'elan',\n deferInit: params && params.deferInit ? params.deferInit : false,\n params: params,\n instance: ElanPlugin\n };\n }\n\n Types = {\n ALIGNABLE_ANNOTATION: 'ALIGNABLE_ANNOTATION',\n REF_ANNOTATION: 'REF_ANNOTATION'\n };\n\n constructor(params, ws) {\n this.data = null;\n this.params = params;\n this.container =\n 'string' == typeof params.container\n ? document.querySelector(params.container)\n : params.container;\n\n if (!this.container) {\n throw Error('No container for ELAN');\n }\n }\n\n init() {\n this.bindClick();\n\n if (this.params.url) {\n this.load(this.params.url);\n }\n }\n\n destroy() {\n this.container.removeEventListener('click', this._onClick);\n this.container.removeChild(this.table);\n }\n\n load(url) {\n this.loadXML(url, xml => {\n this.data = this.parseElan(xml);\n this.render();\n this.fireEvent('ready', this.data);\n });\n }\n\n loadXML(url, callback) {\n const xhr = new XMLHttpRequest();\n xhr.open('GET', url, true);\n xhr.responseType = 'document';\n xhr.send();\n xhr.addEventListener('load', e => {\n callback && callback(e.target.responseXML);\n });\n }\n\n parseElan(xml) {\n const _forEach = Array.prototype.forEach;\n const _map = Array.prototype.map;\n\n const data = {\n media: {},\n timeOrder: {},\n tiers: [],\n annotations: {},\n alignableAnnotations: []\n };\n\n const header = xml.querySelector('HEADER');\n const inMilliseconds =\n header.getAttribute('TIME_UNITS') == 'milliseconds';\n const media = header.querySelector('MEDIA_DESCRIPTOR');\n data.media.url = media.getAttribute('MEDIA_URL');\n data.media.type = media.getAttribute('MIME_TYPE');\n\n const timeSlots = xml.querySelectorAll('TIME_ORDER TIME_SLOT');\n const timeOrder = {};\n _forEach.call(timeSlots, slot => {\n let value = parseFloat(slot.getAttribute('TIME_VALUE'));\n // If in milliseconds, convert to seconds with rounding\n if (inMilliseconds) {\n value = Math.round(value * 1e2) / 1e5;\n }\n timeOrder[slot.getAttribute('TIME_SLOT_ID')] = value;\n });\n\n data.tiers = _map.call(xml.querySelectorAll('TIER'), tier => ({\n id: tier.getAttribute('TIER_ID'),\n linguisticTypeRef: tier.getAttribute('LINGUISTIC_TYPE_REF'),\n defaultLocale: tier.getAttribute('DEFAULT_LOCALE'),\n annotations: _map.call(\n tier.querySelectorAll('REF_ANNOTATION, ALIGNABLE_ANNOTATION'),\n node => {\n const annot = {\n type: node.nodeName,\n id: node.getAttribute('ANNOTATION_ID'),\n ref: node.getAttribute('ANNOTATION_REF'),\n value: node\n .querySelector('ANNOTATION_VALUE')\n .textContent.trim()\n };\n\n if (this.Types.ALIGNABLE_ANNOTATION == annot.type) {\n // Add start & end to alignable annotation\n annot.start =\n timeOrder[node.getAttribute('TIME_SLOT_REF1')];\n annot.end =\n timeOrder[node.getAttribute('TIME_SLOT_REF2')];\n // Add to the list of alignable annotations\n data.alignableAnnotations.push(annot);\n }\n\n // Additionally, put into the flat map of all annotations\n data.annotations[annot.id] = annot;\n\n return annot;\n }\n )\n }));\n\n // Create JavaScript references between annotations\n data.tiers.forEach(tier => {\n tier.annotations.forEach(annot => {\n if (null != annot.ref) {\n annot.reference = data.annotations[annot.ref];\n }\n });\n });\n\n // Sort alignable annotations by start & end\n data.alignableAnnotations.sort((a, b) => {\n let d = a.start - b.start;\n if (d == 0) {\n d = b.end - a.end;\n }\n return d;\n });\n\n data.length = data.alignableAnnotations.length;\n\n return data;\n }\n\n render() {\n // apply tiers filter\n let tiers = this.data.tiers;\n if (this.params.tiers) {\n tiers = tiers.filter(tier => tier.id in this.params.tiers);\n }\n\n // denormalize references to alignable annotations\n const backRefs = {};\n let indeces = {};\n tiers.forEach((tier, index) => {\n tier.annotations.forEach(annot => {\n if (\n annot.reference &&\n annot.reference.type == this.Types.ALIGNABLE_ANNOTATION\n ) {\n if (!(annot.reference.id in backRefs)) {\n backRefs[annot.ref] = {};\n }\n backRefs[annot.ref][index] = annot;\n indeces[index] = true;\n }\n });\n });\n indeces = Object.keys(indeces).sort();\n\n this.renderedAlignable = this.data.alignableAnnotations.filter(\n alignable => backRefs[alignable.id]\n );\n\n // table\n const table = (this.table = document.createElement('table'));\n table.className = 'wavesurfer-annotations';\n\n // head\n const thead = document.createElement('thead');\n const headRow = document.createElement('tr');\n thead.appendChild(headRow);\n table.appendChild(thead);\n const th = document.createElement('th');\n th.textContent = 'Time';\n th.className = 'wavesurfer-time';\n headRow.appendChild(th);\n indeces.forEach(index => {\n const tier = tiers[index];\n const th = document.createElement('th');\n th.className = 'wavesurfer-tier-' + tier.id;\n th.textContent = tier.id;\n if (this.params.tiers) { th.style.width = this.params.tiers[tier.id]; }\n headRow.appendChild(th);\n });\n\n // body\n const tbody = document.createElement('tbody');\n table.appendChild(tbody);\n this.renderedAlignable.forEach(alignable => {\n const row = document.createElement('tr');\n row.id = 'wavesurfer-alignable-' + alignable.id;\n tbody.appendChild(row);\n\n const td = document.createElement('td');\n td.className = 'wavesurfer-time';\n td.textContent =\n alignable.start.toFixed(1) + '–' + alignable.end.toFixed(1);\n row.appendChild(td);\n\n const backRef = backRefs[alignable.id];\n indeces.forEach(index => {\n const tier = tiers[index];\n const td = document.createElement('td');\n const annotation = backRef[index];\n if (annotation) {\n td.id = 'wavesurfer-annotation-' + annotation.id;\n td.dataset.ref = alignable.id;\n td.dataset.start = alignable.start;\n td.dataset.end = alignable.end;\n td.textContent = annotation.value;\n }\n td.className = 'wavesurfer-tier-' + tier.id;\n row.appendChild(td);\n });\n });\n\n this.container.innerHTML = '';\n this.container.appendChild(table);\n }\n\n bindClick() {\n this._onClick = e => {\n const ref = e.target.dataset.ref;\n if (null != ref) {\n const annot = this.data.annotations[ref];\n if (annot) {\n this.fireEvent('select', annot.start, annot.end);\n }\n }\n };\n this.container.addEventListener('click', this._onClick);\n }\n\n getRenderedAnnotation(time) {\n let result;\n this.renderedAlignable.some(annotation => {\n if (annotation.start <= time && annotation.end >= time) {\n result = annotation;\n return true;\n }\n return false;\n });\n return result;\n }\n\n getAnnotationNode(annotation) {\n return document.getElementById('wavesurfer-alignable-' + annotation.id);\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\tif(__webpack_module_cache__[moduleId]) {\n\t\treturn __webpack_module_cache__[moduleId].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_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xDjE,KAAKE,UAAUyB,iBAAiB,QAAS3B,KAAKa,Y,mCAGlD,SAAsBoF,GAClB,IAAIC,EAQJ,OAPAlG,KAAK+E,kBAAkBoB,MAAK,SAAAL,GACxB,OAAIA,EAAW9B,OAASiC,GAAQH,EAAW7B,KAAOgC,IAC9CC,EAASJ,GACF,MAIRI,I,+BAGX,SAAkBJ,GACd,OAAO3F,SAASiG,eAAe,wBAA0BN,EAAWvC,S,6BA5QvD7D,G,kCCnCjB2G,EAA2B,G,OAG/B,SAASC,EAAoBC,GAE5B,IAAIC,EAAeH,EAAyBE,GAC5C,QAAqBE,IAAjBD,EACH,OAAOA,EAAanH,QAGrB,IAAIC,EAAS+G,EAAyBE,GAAY,CAGjDlH,QAAS,IAOV,OAHAqH,EAAoBH,GAAUjH,EAAQA,EAAOD,QAASiH,GAG/ChH,EAAOD,QClBWiH,CAAoB,MHO9C","sources":["webpack://WaveSurfer.[name]/webpack/universalModuleDefinition","webpack://WaveSurfer.[name]/./src/plugin/elan/index.js","webpack://WaveSurfer.[name]/webpack/bootstrap","webpack://WaveSurfer.[name]/webpack/startup"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"WaveSurfer\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"WaveSurfer\"] = factory();\n\telse\n\t\troot[\"WaveSurfer\"] = root[\"WaveSurfer\"] || {}, root[\"WaveSurfer\"][\"elan\"] = factory();\n})(self, function() {\nreturn ","/**\n * @typedef {Object} ElanPluginParams\n * @property {string|HTMLElement} container CSS selector or HTML element where\n * the ELAN information should be rendered.\n * @property {string} url The location of ELAN XML data\n * @property {?boolean} deferInit Set to true to manually call\n * @property {?Object} tiers If set only shows the data tiers with the `TIER_ID`\n * in this map.\n */\n\n/**\n * Downloads and renders ELAN audio transcription documents alongside the\n * waveform.\n *\n * @implements {PluginClass}\n * @extends {Observer}\n * @example\n * // es6\n * import ElanPlugin from 'wavesurfer.elan.js';\n *\n * // commonjs\n * var ElanPlugin = require('wavesurfer.elan.js');\n *\n * // if you are using <script> tags\n * var ElanPlugin = window.WaveSurfer.elan;\n *\n * // ... initialising wavesurfer with the plugin\n * var wavesurfer = WaveSurfer.create({\n * // wavesurfer options ...\n * plugins: [\n * ElanPlugin.create({\n * // plugin options ...\n * })\n * ]\n * });\n */\nexport default class ElanPlugin {\n /**\n * Elan 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 {ElanPluginParams} params parameters use to initialise the plugin\n * @return {PluginDefinition} an object representing the plugin\n */\n static create(params) {\n return {\n name: 'elan',\n deferInit: params && params.deferInit ? params.deferInit : false,\n params: params,\n instance: ElanPlugin\n };\n }\n\n Types = {\n ALIGNABLE_ANNOTATION: 'ALIGNABLE_ANNOTATION',\n REF_ANNOTATION: 'REF_ANNOTATION'\n };\n\n constructor(params, ws) {\n this.data = null;\n this.params = params;\n this.container =\n 'string' == typeof params.container\n ? document.querySelector(params.container)\n : params.container;\n\n if (!this.container) {\n throw Error('No container for ELAN');\n }\n }\n\n init() {\n this.bindClick();\n\n if (this.params.url) {\n this.load(this.params.url);\n }\n }\n\n destroy() {\n this.container.removeEventListener('click', this._onClick);\n this.container.removeChild(this.table);\n }\n\n load(url) {\n this.loadXML(url, xml => {\n this.data = this.parseElan(xml);\n this.render();\n this.fireEvent('ready', this.data);\n });\n }\n\n loadXML(url, callback) {\n const xhr = new XMLHttpRequest();\n xhr.open('GET', url, true);\n xhr.responseType = 'document';\n xhr.send();\n xhr.addEventListener('load', e => {\n callback && callback(e.target.responseXML);\n });\n }\n\n parseElan(xml) {\n const _forEach = Array.prototype.forEach;\n const _map = Array.prototype.map;\n\n const data = {\n media: {},\n timeOrder: {},\n tiers: [],\n annotations: {},\n alignableAnnotations: []\n };\n\n const header = xml.querySelector('HEADER');\n const inMilliseconds =\n header.getAttribute('TIME_UNITS') == 'milliseconds';\n const media = header.querySelector('MEDIA_DESCRIPTOR');\n data.media.url = media.getAttribute('MEDIA_URL');\n data.media.type = media.getAttribute('MIME_TYPE');\n\n const timeSlots = xml.querySelectorAll('TIME_ORDER TIME_SLOT');\n const timeOrder = {};\n _forEach.call(timeSlots, slot => {\n let value = parseFloat(slot.getAttribute('TIME_VALUE'));\n // If in milliseconds, convert to seconds with rounding\n if (inMilliseconds) {\n value = Math.round(value * 1e2) / 1e5;\n }\n timeOrder[slot.getAttribute('TIME_SLOT_ID')] = value;\n });\n\n data.tiers = _map.call(xml.querySelectorAll('TIER'), tier => ({\n id: tier.getAttribute('TIER_ID'),\n linguisticTypeRef: tier.getAttribute('LINGUISTIC_TYPE_REF'),\n defaultLocale: tier.getAttribute('DEFAULT_LOCALE'),\n annotations: _map.call(\n tier.querySelectorAll('REF_ANNOTATION, ALIGNABLE_ANNOTATION'),\n node => {\n const annot = {\n type: node.nodeName,\n id: node.getAttribute('ANNOTATION_ID'),\n ref: node.getAttribute('ANNOTATION_REF'),\n value: node\n .querySelector('ANNOTATION_VALUE')\n .textContent.trim()\n };\n\n if (this.Types.ALIGNABLE_ANNOTATION == annot.type) {\n // Add start & end to alignable annotation\n annot.start =\n timeOrder[node.getAttribute('TIME_SLOT_REF1')];\n annot.end =\n timeOrder[node.getAttribute('TIME_SLOT_REF2')];\n // Add to the list of alignable annotations\n data.alignableAnnotations.push(annot);\n }\n\n // Additionally, put into the flat map of all annotations\n data.annotations[annot.id] = annot;\n\n return annot;\n }\n )\n }));\n\n // Create JavaScript references between annotations\n data.tiers.forEach(tier => {\n tier.annotations.forEach(annot => {\n if (null != annot.ref) {\n annot.reference = data.annotations[annot.ref];\n }\n });\n });\n\n // Sort alignable annotations by start & end\n data.alignableAnnotations.sort((a, b) => {\n let d = a.start - b.start;\n if (d == 0) {\n d = b.end - a.end;\n }\n return d;\n });\n\n data.length = data.alignableAnnotations.length;\n\n return data;\n }\n\n render() {\n // apply tiers filter\n let tiers = this.data.tiers;\n if (this.params.tiers) {\n tiers = tiers.filter(tier => tier.id in this.params.tiers);\n }\n\n // denormalize references to alignable annotations\n const backRefs = {};\n let indeces = {};\n tiers.forEach((tier, index) => {\n tier.annotations.forEach(annot => {\n if (\n annot.reference &&\n annot.reference.type == this.Types.ALIGNABLE_ANNOTATION\n ) {\n if (!(annot.reference.id in backRefs)) {\n backRefs[annot.ref] = {};\n }\n backRefs[annot.ref][index] = annot;\n indeces[index] = true;\n }\n });\n });\n indeces = Object.keys(indeces).sort();\n\n this.renderedAlignable = this.data.alignableAnnotations.filter(\n alignable => backRefs[alignable.id]\n );\n\n // table\n const table = (this.table = document.createElement('table'));\n table.className = 'wavesurfer-annotations';\n\n // head\n const thead = document.createElement('thead');\n const headRow = document.createElement('tr');\n thead.appendChild(headRow);\n table.appendChild(thead);\n const th = document.createElement('th');\n th.textContent = 'Time';\n th.className = 'wavesurfer-time';\n headRow.appendChild(th);\n indeces.forEach(index => {\n const tier = tiers[index];\n const th = document.createElement('th');\n th.className = 'wavesurfer-tier-' + tier.id;\n th.textContent = tier.id;\n if (this.params.tiers) { th.style.width = this.params.tiers[tier.id]; }\n headRow.appendChild(th);\n });\n\n // body\n const tbody = document.createElement('tbody');\n table.appendChild(tbody);\n this.renderedAlignable.forEach(alignable => {\n const row = document.createElement('tr');\n row.id = 'wavesurfer-alignable-' + alignable.id;\n tbody.appendChild(row);\n\n const td = document.createElement('td');\n td.className = 'wavesurfer-time';\n td.textContent =\n alignable.start.toFixed(1) + '–' + alignable.end.toFixed(1);\n row.appendChild(td);\n\n const backRef = backRefs[alignable.id];\n indeces.forEach(index => {\n const tier = tiers[index];\n const td = document.createElement('td');\n const annotation = backRef[index];\n if (annotation) {\n td.id = 'wavesurfer-annotation-' + annotation.id;\n td.dataset.ref = alignable.id;\n td.dataset.start = alignable.start;\n td.dataset.end = alignable.end;\n td.textContent = annotation.value;\n }\n td.className = 'wavesurfer-tier-' + tier.id;\n row.appendChild(td);\n });\n });\n\n this.container.innerHTML = '';\n this.container.appendChild(table);\n }\n\n bindClick() {\n this._onClick = e => {\n const ref = e.target.dataset.ref;\n if (null != ref) {\n const annot = this.data.annotations[ref];\n if (annot) {\n this.fireEvent('select', annot.start, annot.end);\n }\n }\n };\n this.container.addEventListener('click', this._onClick);\n }\n\n getRenderedAnnotation(time) {\n let result;\n this.renderedAlignable.some(annotation => {\n if (annotation.start <= time && annotation.end >= time) {\n result = annotation;\n return true;\n }\n return false;\n });\n return result;\n }\n\n getAnnotationNode(annotation) {\n return document.getElementById('wavesurfer-alignable-' + annotation.id);\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__(375);\n"],"names":["root","factory","exports","module","define","amd","self","ElanPlugin","params","ws","Types","ALIGNABLE_ANNOTATION","REF_ANNOTATION","this","data","container","document","querySelector","Error","name","deferInit","instance","bindClick","url","load","removeEventListener","_onClick","removeChild","table","loadXML","xml","parseElan","render","fireEvent","callback","xhr","XMLHttpRequest","open","responseType","send","addEventListener","e","target","responseXML","_forEach","Array","prototype","forEach","_map","map","media","timeOrder","tiers","annotations","alignableAnnotations","header","inMilliseconds","getAttribute","type","timeSlots","querySelectorAll","call","slot","value","parseFloat","Math","round","tier","id","linguisticTypeRef","defaultLocale","node","annot","nodeName","ref","textContent","trim","start","end","push","reference","sort","a","b","d","length","filter","backRefs","indeces","index","Object","keys","renderedAlignable","alignable","createElement","className","thead","headRow","appendChild","th","style","width","tbody","row","td","toFixed","backRef","annotation","dataset","innerHTML","time","result","some","getElementById","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__"],"sourceRoot":""}
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * wavesurfer.js markers plugin 4.6.0 (2021-03-05)
2
+ * wavesurfer.js markers plugin 5.2.0 (2021-08-16)
3
3
  * https://wavesurfer-js.org
4
4
  * @license BSD-3-Clause
5
5
  */
@@ -12,7 +12,7 @@
12
12
  exports["WaveSurfer"] = factory();
13
13
  else
14
14
  root["WaveSurfer"] = root["WaveSurfer"] || {}, root["WaveSurfer"]["markers"] = factory();
15
- })(this, function() {
15
+ })(self, function() {
16
16
  return /******/ (() => { // webpackBootstrap
17
17
  /******/ "use strict";
18
18
  /******/ var __webpack_modules__ = ({
@@ -41,9 +41,10 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
41
41
  * @desc The parameters used to describe a marker.
42
42
  * @example wavesurfer.addMarker(regionParams);
43
43
  * @property {number} time The time to set the marker at
44
- * @property {?label} string an optional marker label
45
- * @property {?color} string background color for marker
44
+ * @property {?label} string An optional marker label
45
+ * @property {?color} string Background color for marker
46
46
  * @property {?position} string "top" or "bottom", defaults to "bottom"
47
+ * @property {?markerElement} element An HTML element to display instead of the default marker image
47
48
  */
48
49
 
49
50
  /**
@@ -150,7 +151,13 @@ var MarkersPlugin = /*#__PURE__*/function () {
150
151
  color: params.color || DEFAULT_FILL_COLOR,
151
152
  position: params.position || DEFAULT_POSITION
152
153
  };
153
- marker.el = this._createMarkerElement(marker);
154
+
155
+ if (params.markerElement) {
156
+ this.markerWidth = params.markerElement.width;
157
+ this.markerHeight = params.markerElement.height;
158
+ }
159
+
160
+ marker.el = this._createMarkerElement(marker, params.markerElement);
154
161
  this.wrapper.appendChild(marker.el);
155
162
  this.markers.push(marker);
156
163
 
@@ -168,7 +175,11 @@ var MarkersPlugin = /*#__PURE__*/function () {
168
175
  key: "remove",
169
176
  value: function remove(index) {
170
177
  var marker = this.markers[index];
171
- if (!marker) return;
178
+
179
+ if (!marker) {
180
+ return;
181
+ }
182
+
172
183
  this.wrapper.removeChild(marker.el);
173
184
  this.markers.splice(index, 1);
174
185
  }
@@ -192,6 +203,7 @@ var MarkersPlugin = /*#__PURE__*/function () {
192
203
  this.style(el, {
193
204
  width: this.markerWidth + "px",
194
205
  height: this.markerHeight + "px",
206
+ "min-width": this.markerWidth + "px",
195
207
  "margin-right": "5px",
196
208
  "z-index": 4
197
209
  });
@@ -199,7 +211,7 @@ var MarkersPlugin = /*#__PURE__*/function () {
199
211
  }
200
212
  }, {
201
213
  key: "_createMarkerElement",
202
- value: function _createMarkerElement(marker) {
214
+ value: function _createMarkerElement(marker, markerElement) {
203
215
  var _this2 = this;
204
216
 
205
217
  var label = marker.label;
@@ -210,6 +222,7 @@ var MarkersPlugin = /*#__PURE__*/function () {
210
222
  position: "absolute",
211
223
  height: "100%",
212
224
  display: "flex",
225
+ overflow: "hidden",
213
226
  "flex-direction": marker.position == "top" ? "column-reverse" : "column"
214
227
  });
215
228
  var line = document.createElement('div');
@@ -223,7 +236,7 @@ var MarkersPlugin = /*#__PURE__*/function () {
223
236
  el.appendChild(line);
224
237
  var labelDiv = document.createElement('div');
225
238
 
226
- var point = this._createPointerSVG(marker.color, marker.position);
239
+ var point = markerElement || this._createPointerSVG(marker.color, marker.position);
227
240
 
228
241
  labelDiv.appendChild(point);
229
242
 
@@ -247,6 +260,8 @@ var MarkersPlugin = /*#__PURE__*/function () {
247
260
  e.stopPropagation();
248
261
 
249
262
  _this2.wavesurfer.setCurrentTime(time);
263
+
264
+ _this2.wavesurfer.fireEvent("marker-click", marker, e);
250
265
  });
251
266
  return el;
252
267
  }
@@ -258,9 +273,11 @@ var MarkersPlugin = /*#__PURE__*/function () {
258
273
  for (var i = 0; i < this.markers.length; i++) {
259
274
  var marker = this.markers[i];
260
275
  var elementWidth = this.wavesurfer.drawer.width / this.wavesurfer.params.pixelRatio;
261
- var positionPct = marker.time / duration;
276
+ var positionPct = Math.min(marker.time / duration, 1);
277
+ var leftPx = elementWidth * positionPct - this.markerWidth / 2;
262
278
  this.style(marker.el, {
263
- left: elementWidth * positionPct - this.markerWidth / 2 + "px"
279
+ "left": leftPx + "px",
280
+ "max-width": elementWidth - leftPx + "px"
264
281
  });
265
282
  }
266
283
  }
@@ -281,6 +298,7 @@ var MarkersPlugin = /*#__PURE__*/function () {
281
298
  /**
282
299
  * @typedef {Object} MarkersPluginParams
283
300
  * @property {?MarkerParams[]} markers Initial set of markers
301
+ * @fires MarkersPlugin#marker-click
284
302
  */
285
303
 
286
304
  /**
@@ -331,8 +349,9 @@ module.exports = exports.default;
331
349
  /******/ // The require function
332
350
  /******/ function __webpack_require__(moduleId) {
333
351
  /******/ // Check if module is in cache
334
- /******/ if(__webpack_module_cache__[moduleId]) {
335
- /******/ return __webpack_module_cache__[moduleId].exports;
352
+ /******/ var cachedModule = __webpack_module_cache__[moduleId];
353
+ /******/ if (cachedModule !== undefined) {
354
+ /******/ return cachedModule.exports;
336
355
  /******/ }
337
356
  /******/ // Create a new module (and put it into the cache)
338
357
  /******/ var module = __webpack_module_cache__[moduleId] = {
@@ -1 +1 @@
1
- {"version":3,"sources":["webpack://WaveSurfer.[name]/webpack/universalModuleDefinition","webpack://WaveSurfer.[name]/./src/plugin/markers/index.js","webpack://WaveSurfer.[name]/webpack/bootstrap","webpack://WaveSurfer.[name]/webpack/startup"],"names":["DEFAULT_FILL_COLOR","DEFAULT_POSITION","MarkersPlugin","params","ws","wavesurfer","util","style","markerWidth","markerHeight","_onResize","_updateMarkerPositions","_onBackendCreated","wrapper","drawer","markers","forEach","marker","add","window","addEventListener","on","_onReady","isReady","once","un","removeEventListener","clear","time","label","color","position","el","_createMarkerElement","appendChild","push","index","removeChild","splice","svgNS","document","createElementNS","polygon","setAttribute","width","height","createElement","className","display","line","background","opacity","labelDiv","point","_createPointerSVG","labelEl","innerText","cursor","e","stopPropagation","setCurrentTime","duration","getDuration","i","length","elementWidth","pixelRatio","positionPct","left","remove","name","deferInit","staticProps","addMarker","options","initialisedPluginList","initPlugin","clearMarkers","instance"],"mappings":";;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,+CAA+C;AAC/C,CAAC;AACD,O;;;;;;;;;;;;;;;;;;;;;;;ACTA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA,IAAMA,kBAAkB,GAAG,SAA3B;AACA,IAAMC,gBAAgB,GAAG,QAAzB;;IAEqBC,a;AAoCjB,yBAAYC,MAAZ,EAAoBC,EAApB,EAAwB;AAAA;;AAAA;;AACpB,SAAKD,MAAL,GAAcA,MAAd;AACA,SAAKE,UAAL,GAAkBD,EAAlB;AACA,SAAKE,IAAL,GAAYF,EAAE,CAACE,IAAf;AACA,SAAKC,KAAL,GAAa,KAAKD,IAAL,CAAUC,KAAvB;AACA,SAAKC,WAAL,GAAmB,EAAnB;AACA,SAAKC,YAAL,GAAoB,EAApB;;AAGA,SAAKC,SAAL,GAAiB,YAAM;AACnB,WAAI,CAACC,sBAAL;AACH,KAFD;;AAIA,SAAKC,iBAAL,GAAyB,YAAM;AAC3B,WAAI,CAACC,OAAL,GAAe,KAAI,CAACR,UAAL,CAAgBS,MAAhB,CAAuBD,OAAtC;;AACA,UAAI,KAAI,CAACV,MAAL,CAAYY,OAAhB,EAAyB;AACrB,aAAI,CAACZ,MAAL,CAAYY,OAAZ,CAAoBC,OAApB,CAA4B,UAAAC,MAAM;AAAA,iBAAI,KAAI,CAACC,GAAL,CAASD,MAAT,CAAJ;AAAA,SAAlC;AACH;;AACDE,YAAM,CAACC,gBAAP,CAAwB,QAAxB,EAAkC,KAAI,CAACV,SAAvC,EAAkD,IAAlD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BAAQ;AACJ,aAAQ,KAAKO,OAAL,CAAaiD,MAAb,GAAsB,CAA9B,EAAkC;AAC9B,aAAKK,MAAL,CAAY,CAAZ;AACH;AACJ;;;;AApOD;AACJ;AACA;AACA;;AAEI;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACI,oBAAclE,MAAd,EAAsB;AAClB,aAAO;AACHmE,YAAI,EAAE,SADH;AAEHC,iBAAS,EAAEpE,MAAM,IAAIA,MAAM,CAACoE,SAAjB,GAA6BpE,MAAM,CAACoE,SAApC,GAAgD,KAFxD;AAGHpE,cAAM,EAAEA,MAHL;AAIHqE,mBAAW,EAAE;AACTC,mBADS,qBACCC,OADD,EACU;AACf,gBAAI,CAAC,KAAKC,qBAAL,CAA2B5D,OAAhC,EAAyC;AACrC,mBAAK6D,UAAL,CAAgB,SAAhB;AACH;;AACD,mBAAO,KAAK7D,OAAL,CAAaG,GAAb,CAAiBwD,OAAjB,CAAP;AACH,WANQ;AAOTG,sBAPS,0BAOM;AACX,iBAAK9D,OAAL,IAAgB,KAAKA,OAAL,CAAaY,KAAb,EAAhB;AACH;AATQ,SAJV;AAeHmD,gBAAQ,EAAE5E;AAfP,OAAP;AAiBH;;;;;;;;;;;;;UCvEL;UACA;;UAEA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;;UAEA;UACA;;UAEA;UACA;UACA;;;;UCrBA;UACA;UACA;UACA","file":"wavesurfer.markers.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"WaveSurfer\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"WaveSurfer\"] = factory();\n\telse\n\t\troot[\"WaveSurfer\"] = root[\"WaveSurfer\"] || {}, root[\"WaveSurfer\"][\"markers\"] = factory();\n})(this, function() {\nreturn ","\n/**\n * @typedef {Object} MarkerParams\n * @desc The parameters used to describe a marker.\n * @example wavesurfer.addMarker(regionParams);\n * @property {number} time The time to set the marker at\n * @property {?label} string an optional marker label\n * @property {?color} string background color for marker\n * @property {?position} string \"top\" or \"bottom\", defaults to \"bottom\"\n */\n\n\n/**\n * Markers are points in time in the audio that can be jumped to.\n *\n * @implements {PluginClass}\n *\n * @example\n * import MarkersPlugin from 'wavesurfer.markers.js';\n *\n * // if you are using <script> tags\n * var MarkerPlugin = window.WaveSurfer.markers;\n *\n * // ... initialising wavesurfer with the plugin\n * var wavesurfer = WaveSurfer.create({\n * // wavesurfer options ...\n * plugins: [\n * MarkersPlugin.create({\n * // plugin options ...\n * })\n * ]\n * });\n */\n\nconst DEFAULT_FILL_COLOR = \"#D8D8D8\";\nconst DEFAULT_POSITION = \"bottom\";\n\nexport default class MarkersPlugin {\n /**\n * @typedef {Object} MarkersPluginParams\n * @property {?MarkerParams[]} markers Initial set of markers\n */\n\n /**\n * Markers 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 {MarkersPluginParams} params parameters use to initialise the plugin\n * @since 4.6.0\n * @return {PluginDefinition} an object representing the plugin\n */\n static create(params) {\n return {\n name: 'markers',\n deferInit: params && params.deferInit ? params.deferInit : false,\n params: params,\n staticProps: {\n addMarker(options) {\n if (!this.initialisedPluginList.markers) {\n this.initPlugin('markers');\n }\n return this.markers.add(options);\n },\n clearMarkers() {\n this.markers && this.markers.clear();\n }\n },\n instance: MarkersPlugin\n };\n }\n\n constructor(params, ws) {\n this.params = params;\n this.wavesurfer = ws;\n this.util = ws.util;\n this.style = this.util.style;\n this.markerWidth = 11;\n this.markerHeight = 22;\n\n\n this._onResize = () => {\n this._updateMarkerPositions();\n };\n\n this._onBackendCreated = () => {\n this.wrapper = this.wavesurfer.drawer.wrapper;\n if (this.params.markers) {\n this.params.markers.forEach(marker => this.add(marker));\n }\n window.addEventListener('resize', this._onResize, true);\n window.addEventListener('orientationchange', this._onResize, true);\n this.wavesurfer.on('zoom', this._onResize);\n };\n\n this.markers = [];\n this._onReady = () => {\n this.wrapper = this.wavesurfer.drawer.wrapper;\n this._updateMarkerPositions();\n };\n }\n\n init() {\n // Check if ws is ready\n if (this.wavesurfer.isReady) {\n this._onBackendCreated();\n this._onReady();\n } else {\n this.wavesurfer.once('ready', this._onReady);\n this.wavesurfer.once('backend-created', this._onBackendCreated);\n }\n }\n\n destroy() {\n this.wavesurfer.un('ready', this._onReady);\n this.wavesurfer.un('backend-created', this._onBackendCreated);\n\n this.wavesurfer.un('zoom', this._onResize);\n\n window.removeEventListener('resize', this._onResize, true);\n window.removeEventListener('orientationchange', this._onResize, true);\n\n this.clear();\n }\n\n /**\n * Add a marker\n *\n * @param {MarkerParams} params Marker definition\n * @return {object} The created marker\n */\n add(params) {\n let marker = {\n time: params.time,\n label: params.label,\n color: params.color || DEFAULT_FILL_COLOR,\n position: params.position || DEFAULT_POSITION\n };\n\n marker.el = this._createMarkerElement(marker);\n\n this.wrapper.appendChild(marker.el);\n this.markers.push(marker);\n this._updateMarkerPositions();\n\n return marker;\n }\n\n /**\n * Remove a marker\n *\n * @param {number} index Index of the marker to remove\n */\n remove(index) {\n let marker = this.markers[index];\n if ( !marker ) return;\n\n this.wrapper.removeChild(marker.el);\n this.markers.splice(index, 1);\n }\n\n _createPointerSVG(color, position) {\n const svgNS = \"http://www.w3.org/2000/svg\";\n\n const el = document.createElementNS(svgNS, \"svg\");\n const polygon = document.createElementNS(svgNS, \"polygon\");\n\n el.setAttribute(\"viewBox\", \"0 0 40 80\");\n\n polygon.setAttribute(\"id\", \"polygon\");\n polygon.setAttribute(\"stroke\", \"#979797\");\n polygon.setAttribute(\"fill\", color);\n polygon.setAttribute(\"points\", \"20 0 40 30 40 80 0 80 0 30\");\n if ( position == \"top\" ) {\n polygon.setAttribute(\"transform\", \"rotate(180, 20 40)\");\n }\n\n el.appendChild(polygon);\n\n this.style(el, {\n width: this.markerWidth + \"px\",\n height: this.markerHeight + \"px\",\n \"margin-right\": \"5px\",\n \"z-index\": 4\n });\n return el;\n }\n\n _createMarkerElement(marker) {\n let label = marker.label;\n let time = marker.time;\n\n const el = document.createElement('marker');\n el.className = \"wavesurfer-marker\";\n\n this.style(el, {\n position: \"absolute\",\n height: \"100%\",\n display: \"flex\",\n \"flex-direction\": (marker.position == \"top\" ? \"column-reverse\" : \"column\")\n });\n\n const line = document.createElement('div');\n this.style(line, {\n \"flex-grow\": 1,\n \"margin-left\": (this.markerWidth / 2 - 0.5) + \"px\",\n background: \"black\",\n width: \"1px\",\n opacity: 0.1\n });\n el.appendChild(line);\n\n const labelDiv = document.createElement('div');\n const point = this._createPointerSVG(marker.color, marker.position);\n labelDiv.appendChild(point);\n\n if ( label ) {\n const labelEl = document.createElement('span');\n labelEl.innerText = label;\n this.style(labelEl, {\n \"font-family\": \"monospace\",\n \"font-size\": \"90%\"\n });\n labelDiv.appendChild(labelEl);\n }\n\n this.style(labelDiv, {\n display: \"flex\",\n \"align-items\": \"center\",\n cursor: \"pointer\"\n });\n\n el.appendChild(labelDiv);\n\n labelDiv.addEventListener(\"click\", e => {\n e.stopPropagation();\n this.wavesurfer.setCurrentTime(time);\n });\n\n return el;\n }\n\n _updateMarkerPositions() {\n const duration = this.wavesurfer.getDuration();\n\n for ( let i = 0 ; i < this.markers.length; i++ ) {\n let marker = this.markers[i];\n const elementWidth =\n this.wavesurfer.drawer.width /\n this.wavesurfer.params.pixelRatio;\n\n const positionPct = marker.time / duration;\n this.style(marker.el, {\n left: ((elementWidth * positionPct) - (this.markerWidth / 2)) + \"px\"\n });\n }\n }\n\n /**\n * Remove all markers\n */\n clear() {\n while ( this.markers.length > 0 ) {\n this.remove(0);\n }\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\tif(__webpack_module_cache__[moduleId]) {\n\t\treturn __webpack_module_cache__[moduleId].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/markers/index.js\");\n"],"sourceRoot":""}
1
+ {"version":3,"file":"wavesurfer.markers.js","mappings":";;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,+CAA+C;AAC/C,CAAC;AACD;;;;;;;;;;;;;;;;;;;;;;;ACTA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA,IAAMA,kBAAkB,GAAG,SAA3B;AACA,IAAMC,gBAAgB,GAAG,QAAzB;;IAEqBC;AAqCjB,yBAAYC,MAAZ,EAAoBC,EAApB,EAAwB;AAAA;;AAAA;;AACpB,SAAKD,MAAL,GAAcA,MAAd;AACA,SAAKE,UAAL,GAAkBD,EAAlB;AACA,SAAKE,IAAL,GAAYF,EAAE,CAACE,IAAf;AACA,SAAKC,KAAL,GAAa,KAAKD,IAAL,CAAUC,KAAvB;AACA,SAAKC,WAAL,GAAmB,EAAnB;AACA,SAAKC,YAAL,GAAoB,EAApB;;AAGA,SAAKC,SAAL,GAAiB,YAAM;AACnB,WAAI,CAACC,sBAAL;AACH,KAFD;;AAIA,SAAKC,iBAAL,GAAyB,YAAM;AAC3B,WAAI,CAACC,OAAL,GAAe,KAAI,CAACR,UAAL,CAAgBS,MAAhB,CAAuBD,OAAtC;;AACA,UAAI,KAAI,CAACV,MAAL,CAAYY,OAAhB,EAAyB;AACrB,aAAI,CAACZ,MAAL,CAAYY,OAAZ,CAAoBC,OAApB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AAS,EAAEzE,MAAM,IAAIA,MAAM,CAACyE,SAAjB,GAA6BzE,MAAM,CAACyE,SAApC,GAAgD,KAFxD;AAGHzE,QAAAA,MAAM,EAAEA,MAHL;AAIH0E,QAAAA,WAAW,EAAE;AACTC,UAAAA,SADS,qBACCC,OADD,EACU;AACf,gBAAI,CAAC,KAAKC,qBAAL,CAA2BjE,OAAhC,EAAyC;AACrC,mBAAKkE,UAAL,CAAgB,SAAhB;AACH;;AACD,mBAAO,KAAKlE,OAAL,CAAaG,GAAb,CAAiB6D,OAAjB,CAAP;AACH,WANQ;AAOTG,UAAAA,YAPS,0BAOM;AACX,iBAAKnE,OAAL,IAAgB,KAAKA,OAAL,CAAaY,KAAb,EAAhB;AACH;AATQ,SAJV;AAeHwD,QAAAA,QAAQ,EAAEjF;AAfP,OAAP;AAiBH;;;;;;;;;;;;;UCzEL;UACA;;UAEA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;;UAEA;UACA;;UAEA;UACA;UACA;;;;UEtBA;UACA;UACA;UACA","sources":["webpack://WaveSurfer.[name]/webpack/universalModuleDefinition","webpack://WaveSurfer.[name]/./src/plugin/markers/index.js","webpack://WaveSurfer.[name]/webpack/bootstrap","webpack://WaveSurfer.[name]/webpack/before-startup","webpack://WaveSurfer.[name]/webpack/startup","webpack://WaveSurfer.[name]/webpack/after-startup"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"WaveSurfer\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"WaveSurfer\"] = factory();\n\telse\n\t\troot[\"WaveSurfer\"] = root[\"WaveSurfer\"] || {}, root[\"WaveSurfer\"][\"markers\"] = factory();\n})(self, function() {\nreturn ","\n/**\n * @typedef {Object} MarkerParams\n * @desc The parameters used to describe a marker.\n * @example wavesurfer.addMarker(regionParams);\n * @property {number} time The time to set the marker at\n * @property {?label} string An optional marker label\n * @property {?color} string Background color for marker\n * @property {?position} string \"top\" or \"bottom\", defaults to \"bottom\"\n * @property {?markerElement} element An HTML element to display instead of the default marker image\n */\n\n\n/**\n * Markers are points in time in the audio that can be jumped to.\n *\n * @implements {PluginClass}\n *\n * @example\n * import MarkersPlugin from 'wavesurfer.markers.js';\n *\n * // if you are using <script> tags\n * var MarkerPlugin = window.WaveSurfer.markers;\n *\n * // ... initialising wavesurfer with the plugin\n * var wavesurfer = WaveSurfer.create({\n * // wavesurfer options ...\n * plugins: [\n * MarkersPlugin.create({\n * // plugin options ...\n * })\n * ]\n * });\n */\n\nconst DEFAULT_FILL_COLOR = \"#D8D8D8\";\nconst DEFAULT_POSITION = \"bottom\";\n\nexport default class MarkersPlugin {\n /**\n * @typedef {Object} MarkersPluginParams\n * @property {?MarkerParams[]} markers Initial set of markers\n * @fires MarkersPlugin#marker-click\n */\n\n /**\n * Markers 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 {MarkersPluginParams} params parameters use to initialise the plugin\n * @since 4.6.0\n * @return {PluginDefinition} an object representing the plugin\n */\n static create(params) {\n return {\n name: 'markers',\n deferInit: params && params.deferInit ? params.deferInit : false,\n params: params,\n staticProps: {\n addMarker(options) {\n if (!this.initialisedPluginList.markers) {\n this.initPlugin('markers');\n }\n return this.markers.add(options);\n },\n clearMarkers() {\n this.markers && this.markers.clear();\n }\n },\n instance: MarkersPlugin\n };\n }\n\n constructor(params, ws) {\n this.params = params;\n this.wavesurfer = ws;\n this.util = ws.util;\n this.style = this.util.style;\n this.markerWidth = 11;\n this.markerHeight = 22;\n\n\n this._onResize = () => {\n this._updateMarkerPositions();\n };\n\n this._onBackendCreated = () => {\n this.wrapper = this.wavesurfer.drawer.wrapper;\n if (this.params.markers) {\n this.params.markers.forEach(marker => this.add(marker));\n }\n window.addEventListener('resize', this._onResize, true);\n window.addEventListener('orientationchange', this._onResize, true);\n this.wavesurfer.on('zoom', this._onResize);\n };\n\n this.markers = [];\n this._onReady = () => {\n this.wrapper = this.wavesurfer.drawer.wrapper;\n this._updateMarkerPositions();\n };\n }\n\n init() {\n // Check if ws is ready\n if (this.wavesurfer.isReady) {\n this._onBackendCreated();\n this._onReady();\n } else {\n this.wavesurfer.once('ready', this._onReady);\n this.wavesurfer.once('backend-created', this._onBackendCreated);\n }\n }\n\n destroy() {\n this.wavesurfer.un('ready', this._onReady);\n this.wavesurfer.un('backend-created', this._onBackendCreated);\n\n this.wavesurfer.un('zoom', this._onResize);\n\n window.removeEventListener('resize', this._onResize, true);\n window.removeEventListener('orientationchange', this._onResize, true);\n\n this.clear();\n }\n\n /**\n * Add a marker\n *\n * @param {MarkerParams} params Marker definition\n * @return {object} The created marker\n */\n add(params) {\n let marker = {\n time: params.time,\n label: params.label,\n color: params.color || DEFAULT_FILL_COLOR,\n position: params.position || DEFAULT_POSITION\n };\n\n if (params.markerElement) {\n this.markerWidth = params.markerElement.width;\n this.markerHeight = params.markerElement.height;\n }\n\n marker.el = this._createMarkerElement(marker, params.markerElement);\n\n this.wrapper.appendChild(marker.el);\n this.markers.push(marker);\n this._updateMarkerPositions();\n\n return marker;\n }\n\n /**\n * Remove a marker\n *\n * @param {number} index Index of the marker to remove\n */\n remove(index) {\n let marker = this.markers[index];\n if (!marker) {\n return;\n }\n\n this.wrapper.removeChild(marker.el);\n this.markers.splice(index, 1);\n }\n\n _createPointerSVG(color, position) {\n const svgNS = \"http://www.w3.org/2000/svg\";\n\n const el = document.createElementNS(svgNS, \"svg\");\n const polygon = document.createElementNS(svgNS, \"polygon\");\n\n el.setAttribute(\"viewBox\", \"0 0 40 80\");\n\n polygon.setAttribute(\"id\", \"polygon\");\n polygon.setAttribute(\"stroke\", \"#979797\");\n polygon.setAttribute(\"fill\", color);\n polygon.setAttribute(\"points\", \"20 0 40 30 40 80 0 80 0 30\");\n if ( position == \"top\" ) {\n polygon.setAttribute(\"transform\", \"rotate(180, 20 40)\");\n }\n\n el.appendChild(polygon);\n\n this.style(el, {\n width: this.markerWidth + \"px\",\n height: this.markerHeight + \"px\",\n \"min-width\": this.markerWidth + \"px\",\n \"margin-right\": \"5px\",\n \"z-index\": 4\n });\n return el;\n }\n\n _createMarkerElement(marker, markerElement) {\n let label = marker.label;\n let time = marker.time;\n\n const el = document.createElement('marker');\n el.className = \"wavesurfer-marker\";\n\n this.style(el, {\n position: \"absolute\",\n height: \"100%\",\n display: \"flex\",\n overflow: \"hidden\",\n \"flex-direction\": (marker.position == \"top\" ? \"column-reverse\" : \"column\")\n });\n\n const line = document.createElement('div');\n this.style(line, {\n \"flex-grow\": 1,\n \"margin-left\": (this.markerWidth / 2 - 0.5) + \"px\",\n background: \"black\",\n width: \"1px\",\n opacity: 0.1\n });\n el.appendChild(line);\n\n const labelDiv = document.createElement('div');\n const point = markerElement || this._createPointerSVG(marker.color, marker.position);\n labelDiv.appendChild(point);\n\n if ( label ) {\n const labelEl = document.createElement('span');\n labelEl.innerText = label;\n this.style(labelEl, {\n \"font-family\": \"monospace\",\n \"font-size\": \"90%\"\n });\n labelDiv.appendChild(labelEl);\n }\n\n this.style(labelDiv, {\n display: \"flex\",\n \"align-items\": \"center\",\n cursor: \"pointer\"\n });\n\n el.appendChild(labelDiv);\n\n labelDiv.addEventListener(\"click\", e => {\n e.stopPropagation();\n this.wavesurfer.setCurrentTime(time);\n this.wavesurfer.fireEvent(\"marker-click\", marker, e);\n });\n\n return el;\n }\n\n _updateMarkerPositions() {\n const duration = this.wavesurfer.getDuration();\n\n for ( let i = 0 ; i < this.markers.length; i++ ) {\n let marker = this.markers[i];\n const elementWidth =\n this.wavesurfer.drawer.width /\n this.wavesurfer.params.pixelRatio;\n\n const positionPct = Math.min(marker.time / duration, 1);\n const leftPx = ((elementWidth * positionPct) - (this.markerWidth / 2));\n this.style(marker.el, {\n \"left\": leftPx + \"px\",\n \"max-width\": (elementWidth - leftPx) + \"px\"\n });\n }\n }\n\n /**\n * Remove all markers\n */\n clear() {\n while ( this.markers.length > 0 ) {\n this.remove(0);\n }\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/markers/index.js\");\n",""],"names":["DEFAULT_FILL_COLOR","DEFAULT_POSITION","MarkersPlugin","params","ws","wavesurfer","util","style","markerWidth","markerHeight","_onResize","_updateMarkerPositions","_onBackendCreated","wrapper","drawer","markers","forEach","marker","add","window","addEventListener","on","_onReady","isReady","once","un","removeEventListener","clear","time","label","color","position","markerElement","width","height","el","_createMarkerElement","appendChild","push","index","removeChild","splice","svgNS","document","createElementNS","polygon","setAttribute","createElement","className","display","overflow","line","background","opacity","labelDiv","point","_createPointerSVG","labelEl","innerText","cursor","e","stopPropagation","setCurrentTime","fireEvent","duration","getDuration","i","length","elementWidth","pixelRatio","positionPct","Math","min","leftPx","remove","name","deferInit","staticProps","addMarker","options","initialisedPluginList","initPlugin","clearMarkers","instance"],"sourceRoot":""}
@@ -1,7 +1,7 @@
1
1
  /*!
2
- * wavesurfer.js markers plugin 4.6.0 (2021-03-05)
2
+ * wavesurfer.js markers plugin 5.2.0 (2021-08-16)
3
3
  * https://wavesurfer-js.org
4
4
  * @license BSD-3-Clause
5
5
  */
6
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("WaveSurfer",[],t):"object"==typeof exports?exports.WaveSurfer=t():(e.WaveSurfer=e.WaveSurfer||{},e.WaveSurfer.markers=t())}(this,(function(){return(()=>{"use strict";var e={188:(e,t)=>{function r(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i=function(){function e(t,r){var i=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.params=t,this.wavesurfer=r,this.util=r.util,this.style=this.util.style,this.markerWidth=11,this.markerHeight=22,this._onResize=function(){i._updateMarkerPositions()},this._onBackendCreated=function(){i.wrapper=i.wavesurfer.drawer.wrapper,i.params.markers&&i.params.markers.forEach((function(e){return i.add(e)})),window.addEventListener("resize",i._onResize,!0),window.addEventListener("orientationchange",i._onResize,!0),i.wavesurfer.on("zoom",i._onResize)},this.markers=[],this._onReady=function(){i.wrapper=i.wavesurfer.drawer.wrapper,i._updateMarkerPositions()}}var t,i,a;return t=e,a=[{key:"create",value:function(t){return{name:"markers",deferInit:!(!t||!t.deferInit)&&t.deferInit,params:t,staticProps:{addMarker:function(e){return this.initialisedPluginList.markers||this.initPlugin("markers"),this.markers.add(e)},clearMarkers:function(){this.markers&&this.markers.clear()}},instance:e}}}],(i=[{key:"init",value:function(){this.wavesurfer.isReady?(this._onBackendCreated(),this._onReady()):(this.wavesurfer.once("ready",this._onReady),this.wavesurfer.once("backend-created",this._onBackendCreated))}},{key:"destroy",value:function(){this.wavesurfer.un("ready",this._onReady),this.wavesurfer.un("backend-created",this._onBackendCreated),this.wavesurfer.un("zoom",this._onResize),window.removeEventListener("resize",this._onResize,!0),window.removeEventListener("orientationchange",this._onResize,!0),this.clear()}},{key:"add",value:function(e){var t={time:e.time,label:e.label,color:e.color||"#D8D8D8",position:e.position||"bottom"};return t.el=this._createMarkerElement(t),this.wrapper.appendChild(t.el),this.markers.push(t),this._updateMarkerPositions(),t}},{key:"remove",value:function(e){var t=this.markers[e];t&&(this.wrapper.removeChild(t.el),this.markers.splice(e,1))}},{key:"_createPointerSVG",value:function(e,t){var r="http://www.w3.org/2000/svg",i=document.createElementNS(r,"svg"),a=document.createElementNS(r,"polygon");return i.setAttribute("viewBox","0 0 40 80"),a.setAttribute("id","polygon"),a.setAttribute("stroke","#979797"),a.setAttribute("fill",e),a.setAttribute("points","20 0 40 30 40 80 0 80 0 30"),"top"==t&&a.setAttribute("transform","rotate(180, 20 40)"),i.appendChild(a),this.style(i,{width:this.markerWidth+"px",height:this.markerHeight+"px","margin-right":"5px","z-index":4}),i}},{key:"_createMarkerElement",value:function(e){var t=this,r=e.label,i=e.time,a=document.createElement("marker");a.className="wavesurfer-marker",this.style(a,{position:"absolute",height:"100%",display:"flex","flex-direction":"top"==e.position?"column-reverse":"column"});var n=document.createElement("div");this.style(n,{"flex-grow":1,"margin-left":this.markerWidth/2-.5+"px",background:"black",width:"1px",opacity:.1}),a.appendChild(n);var s=document.createElement("div"),o=this._createPointerSVG(e.color,e.position);if(s.appendChild(o),r){var u=document.createElement("span");u.innerText=r,this.style(u,{"font-family":"monospace","font-size":"90%"}),s.appendChild(u)}return this.style(s,{display:"flex","align-items":"center",cursor:"pointer"}),a.appendChild(s),s.addEventListener("click",(function(e){e.stopPropagation(),t.wavesurfer.setCurrentTime(i)})),a}},{key:"_updateMarkerPositions",value:function(){for(var e=this.wavesurfer.getDuration(),t=0;t<this.markers.length;t++){var r=this.markers[t],i=this.wavesurfer.drawer.width/this.wavesurfer.params.pixelRatio,a=r.time/e;this.style(r.el,{left:i*a-this.markerWidth/2+"px"})}}},{key:"clear",value:function(){for(;this.markers.length>0;)this.remove(0)}}])&&r(t.prototype,i),a&&r(t,a),e}();t.default=i,e.exports=t.default}},t={};return function r(i){if(t[i])return t[i].exports;var a=t[i]={exports:{}};return e[i](a,a.exports,r),a.exports}(188)})()}));
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.markers=t())}(self,(function(){return(()=>{"use strict";var e={188:(e,t)=>{function r(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i=function(){function e(t,r){var i=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.params=t,this.wavesurfer=r,this.util=r.util,this.style=this.util.style,this.markerWidth=11,this.markerHeight=22,this._onResize=function(){i._updateMarkerPositions()},this._onBackendCreated=function(){i.wrapper=i.wavesurfer.drawer.wrapper,i.params.markers&&i.params.markers.forEach((function(e){return i.add(e)})),window.addEventListener("resize",i._onResize,!0),window.addEventListener("orientationchange",i._onResize,!0),i.wavesurfer.on("zoom",i._onResize)},this.markers=[],this._onReady=function(){i.wrapper=i.wavesurfer.drawer.wrapper,i._updateMarkerPositions()}}var t,i,a;return t=e,a=[{key:"create",value:function(t){return{name:"markers",deferInit:!(!t||!t.deferInit)&&t.deferInit,params:t,staticProps:{addMarker:function(e){return this.initialisedPluginList.markers||this.initPlugin("markers"),this.markers.add(e)},clearMarkers:function(){this.markers&&this.markers.clear()}},instance:e}}}],(i=[{key:"init",value:function(){this.wavesurfer.isReady?(this._onBackendCreated(),this._onReady()):(this.wavesurfer.once("ready",this._onReady),this.wavesurfer.once("backend-created",this._onBackendCreated))}},{key:"destroy",value:function(){this.wavesurfer.un("ready",this._onReady),this.wavesurfer.un("backend-created",this._onBackendCreated),this.wavesurfer.un("zoom",this._onResize),window.removeEventListener("resize",this._onResize,!0),window.removeEventListener("orientationchange",this._onResize,!0),this.clear()}},{key:"add",value:function(e){var t={time:e.time,label:e.label,color:e.color||"#D8D8D8",position:e.position||"bottom"};return e.markerElement&&(this.markerWidth=e.markerElement.width,this.markerHeight=e.markerElement.height),t.el=this._createMarkerElement(t,e.markerElement),this.wrapper.appendChild(t.el),this.markers.push(t),this._updateMarkerPositions(),t}},{key:"remove",value:function(e){var t=this.markers[e];t&&(this.wrapper.removeChild(t.el),this.markers.splice(e,1))}},{key:"_createPointerSVG",value:function(e,t){var r="http://www.w3.org/2000/svg",i=document.createElementNS(r,"svg"),a=document.createElementNS(r,"polygon");return i.setAttribute("viewBox","0 0 40 80"),a.setAttribute("id","polygon"),a.setAttribute("stroke","#979797"),a.setAttribute("fill",e),a.setAttribute("points","20 0 40 30 40 80 0 80 0 30"),"top"==t&&a.setAttribute("transform","rotate(180, 20 40)"),i.appendChild(a),this.style(i,{width:this.markerWidth+"px",height:this.markerHeight+"px","min-width":this.markerWidth+"px","margin-right":"5px","z-index":4}),i}},{key:"_createMarkerElement",value:function(e,t){var r=this,i=e.label,a=e.time,n=document.createElement("marker");n.className="wavesurfer-marker",this.style(n,{position:"absolute",height:"100%",display:"flex",overflow:"hidden","flex-direction":"top"==e.position?"column-reverse":"column"});var s=document.createElement("div");this.style(s,{"flex-grow":1,"margin-left":this.markerWidth/2-.5+"px",background:"black",width:"1px",opacity:.1}),n.appendChild(s);var o=document.createElement("div"),u=t||this._createPointerSVG(e.color,e.position);if(o.appendChild(u),i){var d=document.createElement("span");d.innerText=i,this.style(d,{"font-family":"monospace","font-size":"90%"}),o.appendChild(d)}return this.style(o,{display:"flex","align-items":"center",cursor:"pointer"}),n.appendChild(o),o.addEventListener("click",(function(t){t.stopPropagation(),r.wavesurfer.setCurrentTime(a),r.wavesurfer.fireEvent("marker-click",e,t)})),n}},{key:"_updateMarkerPositions",value:function(){for(var e=this.wavesurfer.getDuration(),t=0;t<this.markers.length;t++){var r=this.markers[t],i=this.wavesurfer.drawer.width/this.wavesurfer.params.pixelRatio,a=i*Math.min(r.time/e,1)-this.markerWidth/2;this.style(r.el,{left:a+"px","max-width":i-a+"px"})}}},{key:"clear",value:function(){for(;this.markers.length>0;)this.remove(0)}}])&&r(t.prototype,i),a&&r(t,a),e}();t.default=i,e.exports=t.default}},t={};return function r(i){var a=t[i];if(void 0!==a)return a.exports;var n=t[i]={exports:{}};return e[i](n,n.exports,r),n.exports}(188)})()}));
7
7
  //# sourceMappingURL=wavesurfer.markers.min.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["webpack://WaveSurfer.[name]/webpack/universalModuleDefinition","webpack://WaveSurfer.[name]/./src/plugin/markers/index.js","webpack://WaveSurfer.[name]/webpack/bootstrap","webpack://WaveSurfer.[name]/webpack/startup"],"names":["root","factory","exports","module","define","amd","this","MarkersPlugin","params","ws","wavesurfer","util","style","markerWidth","markerHeight","_onResize","_updateMarkerPositions","_onBackendCreated","wrapper","drawer","markers","forEach","marker","add","window","addEventListener","on","_onReady","name","deferInit","staticProps","addMarker","options","initialisedPluginList","initPlugin","clearMarkers","clear","instance","isReady","once","un","removeEventListener","time","label","color","position","el","_createMarkerElement","appendChild","push","index","removeChild","splice","svgNS","document","createElementNS","polygon","setAttribute","width","height","createElement","className","display","line","background","opacity","labelDiv","point","_createPointerSVG","labelEl","innerText","cursor","e","stopPropagation","setCurrentTime","duration","getDuration","i","length","elementWidth","pixelRatio","positionPct","left","remove","__webpack_module_cache__","__webpack_require__","moduleId","__webpack_modules__"],"mappings":";;;;;CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,aAAc,GAAIH,GACC,iBAAZC,QACdA,QAAoB,WAAID,KAExBD,EAAiB,WAAIA,EAAiB,YAAK,GAAIA,EAAiB,WAAW,QAAIC,KARjF,CASGK,MAAM,WACT,M,8QCwBA,IAGqBC,E,WAoCjB,WAAYC,EAAQC,GAAI,Y,4FAAA,SACpBH,KAAKE,OAASA,EACdF,KAAKI,WAAaD,EAClBH,KAAKK,KAAOF,EAAGE,KACfL,KAAKM,MA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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\"][\"markers\"] = factory();\n})(this, function() {\nreturn ","\n/**\n * @typedef {Object} MarkerParams\n * @desc The parameters used to describe a marker.\n * @example wavesurfer.addMarker(regionParams);\n * @property {number} time The time to set the marker at\n * @property {?label} string an optional marker label\n * @property {?color} string background color for marker\n * @property {?position} string \"top\" or \"bottom\", defaults to \"bottom\"\n */\n\n\n/**\n * Markers are points in time in the audio that can be jumped to.\n *\n * @implements {PluginClass}\n *\n * @example\n * import MarkersPlugin from 'wavesurfer.markers.js';\n *\n * // if you are using <script> tags\n * var MarkerPlugin = window.WaveSurfer.markers;\n *\n * // ... initialising wavesurfer with the plugin\n * var wavesurfer = WaveSurfer.create({\n * // wavesurfer options ...\n * plugins: [\n * MarkersPlugin.create({\n * // plugin options ...\n * })\n * ]\n * });\n */\n\nconst DEFAULT_FILL_COLOR = \"#D8D8D8\";\nconst DEFAULT_POSITION = \"bottom\";\n\nexport default class MarkersPlugin {\n /**\n * @typedef {Object} MarkersPluginParams\n * @property {?MarkerParams[]} markers Initial set of markers\n */\n\n /**\n * Markers 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 {MarkersPluginParams} params parameters use to initialise the plugin\n * @since 4.6.0\n * @return {PluginDefinition} an object representing the plugin\n */\n static create(params) {\n return {\n name: 'markers',\n deferInit: params && params.deferInit ? params.deferInit : false,\n params: params,\n staticProps: {\n addMarker(options) {\n if (!this.initialisedPluginList.markers) {\n this.initPlugin('markers');\n }\n return this.markers.add(options);\n },\n clearMarkers() {\n this.markers && this.markers.clear();\n }\n },\n instance: MarkersPlugin\n };\n }\n\n constructor(params, ws) {\n this.params = params;\n this.wavesurfer = ws;\n this.util = ws.util;\n this.style = this.util.style;\n this.markerWidth = 11;\n this.markerHeight = 22;\n\n\n this._onResize = () => {\n this._updateMarkerPositions();\n };\n\n this._onBackendCreated = () => {\n this.wrapper = this.wavesurfer.drawer.wrapper;\n if (this.params.markers) {\n this.params.markers.forEach(marker => this.add(marker));\n }\n window.addEventListener('resize', this._onResize, true);\n window.addEventListener('orientationchange', this._onResize, true);\n this.wavesurfer.on('zoom', this._onResize);\n };\n\n this.markers = [];\n this._onReady = () => {\n this.wrapper = this.wavesurfer.drawer.wrapper;\n this._updateMarkerPositions();\n };\n }\n\n init() {\n // Check if ws is ready\n if (this.wavesurfer.isReady) {\n this._onBackendCreated();\n this._onReady();\n } else {\n this.wavesurfer.once('ready', this._onReady);\n this.wavesurfer.once('backend-created', this._onBackendCreated);\n }\n }\n\n destroy() {\n this.wavesurfer.un('ready', this._onReady);\n this.wavesurfer.un('backend-created', this._onBackendCreated);\n\n this.wavesurfer.un('zoom', this._onResize);\n\n window.removeEventListener('resize', this._onResize, true);\n window.removeEventListener('orientationchange', this._onResize, true);\n\n this.clear();\n }\n\n /**\n * Add a marker\n *\n * @param {MarkerParams} params Marker definition\n * @return {object} The created marker\n */\n add(params) {\n let marker = {\n time: params.time,\n label: params.label,\n color: params.color || DEFAULT_FILL_COLOR,\n position: params.position || DEFAULT_POSITION\n };\n\n marker.el = this._createMarkerElement(marker);\n\n this.wrapper.appendChild(marker.el);\n this.markers.push(marker);\n this._updateMarkerPositions();\n\n return marker;\n }\n\n /**\n * Remove a marker\n *\n * @param {number} index Index of the marker to remove\n */\n remove(index) {\n let marker = this.markers[index];\n if ( !marker ) return;\n\n this.wrapper.removeChild(marker.el);\n this.markers.splice(index, 1);\n }\n\n _createPointerSVG(color, position) {\n const svgNS = \"http://www.w3.org/2000/svg\";\n\n const el = document.createElementNS(svgNS, \"svg\");\n const polygon = document.createElementNS(svgNS, \"polygon\");\n\n el.setAttribute(\"viewBox\", \"0 0 40 80\");\n\n polygon.setAttribute(\"id\", \"polygon\");\n polygon.setAttribute(\"stroke\", \"#979797\");\n polygon.setAttribute(\"fill\", color);\n polygon.setAttribute(\"points\", \"20 0 40 30 40 80 0 80 0 30\");\n if ( position == \"top\" ) {\n polygon.setAttribute(\"transform\", \"rotate(180, 20 40)\");\n }\n\n el.appendChild(polygon);\n\n this.style(el, {\n width: this.markerWidth + \"px\",\n height: this.markerHeight + \"px\",\n \"margin-right\": \"5px\",\n \"z-index\": 4\n });\n return el;\n }\n\n _createMarkerElement(marker) {\n let label = marker.label;\n let time = marker.time;\n\n const el = document.createElement('marker');\n el.className = \"wavesurfer-marker\";\n\n this.style(el, {\n position: \"absolute\",\n height: \"100%\",\n display: \"flex\",\n \"flex-direction\": (marker.position == \"top\" ? \"column-reverse\" : \"column\")\n });\n\n const line = document.createElement('div');\n this.style(line, {\n \"flex-grow\": 1,\n \"margin-left\": (this.markerWidth / 2 - 0.5) + \"px\",\n background: \"black\",\n width: \"1px\",\n opacity: 0.1\n });\n el.appendChild(line);\n\n const labelDiv = document.createElement('div');\n const point = this._createPointerSVG(marker.color, marker.position);\n labelDiv.appendChild(point);\n\n if ( label ) {\n const labelEl = document.createElement('span');\n labelEl.innerText = label;\n this.style(labelEl, {\n \"font-family\": \"monospace\",\n \"font-size\": \"90%\"\n });\n labelDiv.appendChild(labelEl);\n }\n\n this.style(labelDiv, {\n display: \"flex\",\n \"align-items\": \"center\",\n cursor: \"pointer\"\n });\n\n el.appendChild(labelDiv);\n\n labelDiv.addEventListener(\"click\", e => {\n e.stopPropagation();\n this.wavesurfer.setCurrentTime(time);\n });\n\n return el;\n }\n\n _updateMarkerPositions() {\n const duration = this.wavesurfer.getDuration();\n\n for ( let i = 0 ; i < this.markers.length; i++ ) {\n let marker = this.markers[i];\n const elementWidth =\n this.wavesurfer.drawer.width /\n this.wavesurfer.params.pixelRatio;\n\n const positionPct = marker.time / duration;\n this.style(marker.el, {\n left: ((elementWidth * positionPct) - (this.markerWidth / 2)) + \"px\"\n });\n }\n }\n\n /**\n * Remove all markers\n */\n clear() {\n while ( this.markers.length > 0 ) {\n this.remove(0);\n }\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\tif(__webpack_module_cache__[moduleId]) {\n\t\treturn __webpack_module_cache__[moduleId].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__(188);\n"],"sourceRoot":""}
1
+ {"version":3,"file":"wavesurfer.markers.min.js","mappings":";;;;;CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,aAAc,GAAIH,GACC,iBAAZC,QACdA,QAAoB,WAAID,KAExBD,EAAiB,WAAIA,EAAiB,YAAK,GAAIA,EAAiB,WAAW,QAAIC,KARjF,CASGK,MAAM,WACT,Y,wQCyBA,IAGqBC,EAAAA,WAqCjB,WAAYC,EAAQC,GAAI,Y,4FAAA,SACpBC,KAAKF,OAASA,EACdE,KAAKC,WAAaF,EAClBC,KAAKE,KAAOH,EAAGG,KACfF,KAAKG,MAAQH,KAAKE,KAAKC,MACvBH,KAAKI,YAAc,GACnBJ,KAAKK,aAAe,GAGpBL,KAAKM,UAAY,WACb,EAAKC,0BAGTP,KAAKQ,kBAAoB,WACrB,EAAKC,QAAU,EAAKR,WAAWS,OAAOD,QAClC,EAAKX,OAAOa,SACZ,EAAKb,OAAOa,QAAQC,SAAQ,SAAAC,GAAM,OAAI,EAAKC,IA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pack/universalModuleDefinition","webpack://WaveSurfer.[name]/./src/plugin/markers/index.js","webpack://WaveSurfer.[name]/webpack/bootstrap","webpack://WaveSurfer.[name]/webpack/startup"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"WaveSurfer\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"WaveSurfer\"] = factory();\n\telse\n\t\troot[\"WaveSurfer\"] = root[\"WaveSurfer\"] || {}, root[\"WaveSurfer\"][\"markers\"] = factory();\n})(self, function() {\nreturn ","\n/**\n * @typedef {Object} MarkerParams\n * @desc The parameters used to describe a marker.\n * @example wavesurfer.addMarker(regionParams);\n * @property {number} time The time to set the marker at\n * @property {?label} string An optional marker label\n * @property {?color} string Background color for marker\n * @property {?position} string \"top\" or \"bottom\", defaults to \"bottom\"\n * @property {?markerElement} element An HTML element to display instead of the default marker image\n */\n\n\n/**\n * Markers are points in time in the audio that can be jumped to.\n *\n * @implements {PluginClass}\n *\n * @example\n * import MarkersPlugin from 'wavesurfer.markers.js';\n *\n * // if you are using <script> tags\n * var MarkerPlugin = window.WaveSurfer.markers;\n *\n * // ... initialising wavesurfer with the plugin\n * var wavesurfer = WaveSurfer.create({\n * // wavesurfer options ...\n * plugins: [\n * MarkersPlugin.create({\n * // plugin options ...\n * })\n * ]\n * });\n */\n\nconst DEFAULT_FILL_COLOR = \"#D8D8D8\";\nconst DEFAULT_POSITION = \"bottom\";\n\nexport default class MarkersPlugin {\n /**\n * @typedef {Object} MarkersPluginParams\n * @property {?MarkerParams[]} markers Initial set of markers\n * @fires MarkersPlugin#marker-click\n */\n\n /**\n * Markers 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 {MarkersPluginParams} params parameters use to initialise the plugin\n * @since 4.6.0\n * @return {PluginDefinition} an object representing the plugin\n */\n static create(params) {\n return {\n name: 'markers',\n deferInit: params && params.deferInit ? params.deferInit : false,\n params: params,\n staticProps: {\n addMarker(options) {\n if (!this.initialisedPluginList.markers) {\n this.initPlugin('markers');\n }\n return this.markers.add(options);\n },\n clearMarkers() {\n this.markers && this.markers.clear();\n }\n },\n instance: MarkersPlugin\n };\n }\n\n constructor(params, ws) {\n this.params = params;\n this.wavesurfer = ws;\n this.util = ws.util;\n this.style = this.util.style;\n this.markerWidth = 11;\n this.markerHeight = 22;\n\n\n this._onResize = () => {\n this._updateMarkerPositions();\n };\n\n this._onBackendCreated = () => {\n this.wrapper = this.wavesurfer.drawer.wrapper;\n if (this.params.markers) {\n this.params.markers.forEach(marker => this.add(marker));\n }\n window.addEventListener('resize', this._onResize, true);\n window.addEventListener('orientationchange', this._onResize, true);\n this.wavesurfer.on('zoom', this._onResize);\n };\n\n this.markers = [];\n this._onReady = () => {\n this.wrapper = this.wavesurfer.drawer.wrapper;\n this._updateMarkerPositions();\n };\n }\n\n init() {\n // Check if ws is ready\n if (this.wavesurfer.isReady) {\n this._onBackendCreated();\n this._onReady();\n } else {\n this.wavesurfer.once('ready', this._onReady);\n this.wavesurfer.once('backend-created', this._onBackendCreated);\n }\n }\n\n destroy() {\n this.wavesurfer.un('ready', this._onReady);\n this.wavesurfer.un('backend-created', this._onBackendCreated);\n\n this.wavesurfer.un('zoom', this._onResize);\n\n window.removeEventListener('resize', this._onResize, true);\n window.removeEventListener('orientationchange', this._onResize, true);\n\n this.clear();\n }\n\n /**\n * Add a marker\n *\n * @param {MarkerParams} params Marker definition\n * @return {object} The created marker\n */\n add(params) {\n let marker = {\n time: params.time,\n label: params.label,\n color: params.color || DEFAULT_FILL_COLOR,\n position: params.position || DEFAULT_POSITION\n };\n\n if (params.markerElement) {\n this.markerWidth = params.markerElement.width;\n this.markerHeight = params.markerElement.height;\n }\n\n marker.el = this._createMarkerElement(marker, params.markerElement);\n\n this.wrapper.appendChild(marker.el);\n this.markers.push(marker);\n this._updateMarkerPositions();\n\n return marker;\n }\n\n /**\n * Remove a marker\n *\n * @param {number} index Index of the marker to remove\n */\n remove(index) {\n let marker = this.markers[index];\n if (!marker) {\n return;\n }\n\n this.wrapper.removeChild(marker.el);\n this.markers.splice(index, 1);\n }\n\n _createPointerSVG(color, position) {\n const svgNS = \"http://www.w3.org/2000/svg\";\n\n const el = document.createElementNS(svgNS, \"svg\");\n const polygon = document.createElementNS(svgNS, \"polygon\");\n\n el.setAttribute(\"viewBox\", \"0 0 40 80\");\n\n polygon.setAttribute(\"id\", \"polygon\");\n polygon.setAttribute(\"stroke\", \"#979797\");\n polygon.setAttribute(\"fill\", color);\n polygon.setAttribute(\"points\", \"20 0 40 30 40 80 0 80 0 30\");\n if ( position == \"top\" ) {\n polygon.setAttribute(\"transform\", \"rotate(180, 20 40)\");\n }\n\n el.appendChild(polygon);\n\n this.style(el, {\n width: this.markerWidth + \"px\",\n height: this.markerHeight + \"px\",\n \"min-width\": this.markerWidth + \"px\",\n \"margin-right\": \"5px\",\n \"z-index\": 4\n });\n return el;\n }\n\n _createMarkerElement(marker, markerElement) {\n let label = marker.label;\n let time = marker.time;\n\n const el = document.createElement('marker');\n el.className = \"wavesurfer-marker\";\n\n this.style(el, {\n position: \"absolute\",\n height: \"100%\",\n display: \"flex\",\n overflow: \"hidden\",\n \"flex-direction\": (marker.position == \"top\" ? \"column-reverse\" : \"column\")\n });\n\n const line = document.createElement('div');\n this.style(line, {\n \"flex-grow\": 1,\n \"margin-left\": (this.markerWidth / 2 - 0.5) + \"px\",\n background: \"black\",\n width: \"1px\",\n opacity: 0.1\n });\n el.appendChild(line);\n\n const labelDiv = document.createElement('div');\n const point = markerElement || this._createPointerSVG(marker.color, marker.position);\n labelDiv.appendChild(point);\n\n if ( label ) {\n const labelEl = document.createElement('span');\n labelEl.innerText = label;\n this.style(labelEl, {\n \"font-family\": \"monospace\",\n \"font-size\": \"90%\"\n });\n labelDiv.appendChild(labelEl);\n }\n\n this.style(labelDiv, {\n display: \"flex\",\n \"align-items\": \"center\",\n cursor: \"pointer\"\n });\n\n el.appendChild(labelDiv);\n\n labelDiv.addEventListener(\"click\", e => {\n e.stopPropagation();\n this.wavesurfer.setCurrentTime(time);\n this.wavesurfer.fireEvent(\"marker-click\", marker, e);\n });\n\n return el;\n }\n\n _updateMarkerPositions() {\n const duration = this.wavesurfer.getDuration();\n\n for ( let i = 0 ; i < this.markers.length; i++ ) {\n let marker = this.markers[i];\n const elementWidth =\n this.wavesurfer.drawer.width /\n this.wavesurfer.params.pixelRatio;\n\n const positionPct = Math.min(marker.time / duration, 1);\n const leftPx = ((elementWidth * positionPct) - (this.markerWidth / 2));\n this.style(marker.el, {\n \"left\": leftPx + \"px\",\n \"max-width\": (elementWidth - leftPx) + \"px\"\n });\n }\n }\n\n /**\n * Remove all markers\n */\n clear() {\n while ( this.markers.length > 0 ) {\n this.remove(0);\n }\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__(188);\n"],"names":["root","factory","exports","module","define","amd","self","MarkersPlugin","params","ws","this","wavesurfer","util","style","markerWidth","markerHeight","_onResize","_updateMarkerPositions","_onBackendCreated","wrapper","drawer","markers","forEach","marker","add","window","addEventListener","on","_onReady","name","deferInit","staticProps","addMarker","options","initialisedPluginList","initPlugin","clearMarkers","clear","instance","isReady","once","un","removeEventListener","time","label","color","position","markerElement","width","height","el","_createMarkerElement","appendChild","push","index","removeChild","splice","svgNS","document","createElementNS","polygon","setAttribute","createElement","className","display","overflow","line","background","opacity","labelDiv","point","_createPointerSVG","labelEl","innerText","cursor","e","stopPropagation","setCurrentTime","fireEvent","duration","getDuration","i","length","elementWidth","pixelRatio","leftPx","Math","min","remove","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__"],"sourceRoot":""}
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * wavesurfer.js mediasession plugin 4.6.0 (2021-03-05)
2
+ * wavesurfer.js mediasession plugin 5.2.0 (2021-08-16)
3
3
  * https://wavesurfer-js.org
4
4
  * @license BSD-3-Clause
5
5
  */
@@ -12,7 +12,7 @@
12
12
  exports["WaveSurfer"] = factory();
13
13
  else
14
14
  root["WaveSurfer"] = root["WaveSurfer"] || {}, root["WaveSurfer"]["mediasession"] = factory();
15
- })(this, function() {
15
+ })(self, function() {
16
16
  return /******/ (() => { // webpackBootstrap
17
17
  /******/ "use strict";
18
18
  /******/ var __webpack_modules__ = ({
@@ -159,8 +159,9 @@ module.exports = exports.default;
159
159
  /******/ // The require function
160
160
  /******/ function __webpack_require__(moduleId) {
161
161
  /******/ // Check if module is in cache
162
- /******/ if(__webpack_module_cache__[moduleId]) {
163
- /******/ return __webpack_module_cache__[moduleId].exports;
162
+ /******/ var cachedModule = __webpack_module_cache__[moduleId];
163
+ /******/ if (cachedModule !== undefined) {
164
+ /******/ return cachedModule.exports;
164
165
  /******/ }
165
166
  /******/ // Create a new module (and put it into the cache)
166
167
  /******/ var module = __webpack_module_cache__[moduleId] = {
@@ -1 +1 @@
1
- {"version":3,"sources":["webpack://WaveSurfer.[name]/webpack/universalModuleDefinition","webpack://WaveSurfer.[name]/./src/plugin/mediasession/index.js","webpack://WaveSurfer.[name]/webpack/bootstrap","webpack://WaveSurfer.[name]/webpack/startup"],"names":["MediaSessionPlugin","params","ws","wavesurfer","navigator","metadata","update","on","mediaSession","setActionHandler","play","playPause","skipBackward","skipForward","MediaMetadata","Function","name","deferInit","instance"],"mappings":";;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,+CAA+C;AAC/C,CAAC;AACD,O;;;;;;;;;;;;;;;;;;;;;;;;;ACVA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;IACqBA,kB;AAmBjB,8BAAYC,MAAZ,EAAoBC,EAApB,EAAwB;AAAA;;AAAA;;AACpB,SAAKD,MAAL,GAAcA,MAAd;AACA,SAAKE,UAAL,GAAkBD,EAAlB;;AAEA,QAAI,kBAAkBE,SAAtB,EAAiC;AAC7B;AACA,WAAKC,QAAL,GAAgB,KAAKJ,MAAL,CAAYI,QAA5B;AACA,WAAKC,MAAL,GAH6B,CAK7B;;AACA,WAAKH,UAAL,CAAgBI,EAAhB,CAAmB,MAAnB,EAA2B,YAAM;AAC7B,aAAI,CAACD,MAAL;AACH,OAFD,EAN6B,CAU7B;;AACAF,eAAS,CAACI,YAAV,CAAuBC,gBAAvB,CAAwC,MAAxC,EAAgD,YAAM;AAClD,aAAI,CAACN,UAAL,CAAgBO,IAAhB;AACH,OAFD;AAGAN,eAAS,CAACI,YAAV,CAAuBC,gBAAvB,CAAwC,OAAxC,EAAiD,YAAM;AACnD,aAAI,CAACN,UAAL,CAAgBQ,SAAhB;AACH,OAFD;AAGAP,eAAS,CAACI,YAAV,CAAuBC,gBAAvB,CAAwC,cAAxC,EAAwD,YAAM;AAC1D,aAAI,CAACN,UAAL,CAAgBS,YAAhB;AACH,OAFD;AAGAR,eAAS,CAACI,YAAV,CAAuBC,gBAAvB,CAAwC,aAAxC,EAAuD,YAAM;AACzD,aAAI,CAACN,UAAL,CAAgBU,WAAhB;AACH,OAFD;AAGH;AACJ;;;;WAED,gBAAO,CAAE;;;WAET,mBAAU,CAAE;;;WAEZ,kBAAS;AACL,UAAI,QAAOC,aAAP,yCAAOA,aAAP,eAAgCC,QAAhC,yCAAgCA,QAAhC,EAAJ,EAA8C;AAC1C;AACAX,iBAAS,CAACI,YAAV,CAAuBH,QAAvB,GAAkC,IAAIS,aAAJ,CAAkB,KAAKT,QAAvB,CAAlC;AACH;AACJ;;;;AAzDD;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACI,oBAAcJ,MAAd,EAAsB;AAClB,aAAO;AACHe,YAAI,EAAE,cADH;AAEHC,iBAAS,EAAEhB,MAAM,IAAIA,MAAM,CAACgB,SAAjB,GAA6BhB,MAAM,CAACgB,SAApC,GAAgD,KAFxD;AAGHhB,cAAM,EAAEA,MAHL;AAIHiB,gBAAQ,EAAElB;AAJP,OAAP;AAMH;;;;;;;;;;;;;UCrDL;UACA;;UAEA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;;UAEA;UACA;;UAEA;UACA;UACA;;;;UCrBA;UACA;UACA;UACA","file":"wavesurfer.mediasession.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"WaveSurfer\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"WaveSurfer\"] = factory();\n\telse\n\t\troot[\"WaveSurfer\"] = root[\"WaveSurfer\"] || {}, root[\"WaveSurfer\"][\"mediasession\"] = factory();\n})(this, function() {\nreturn ","/*global MediaMetadata*/\n\n/**\n * @typedef {Object} MediaSessionPluginParams\n * @property {MediaMetadata} metadata A MediaMetadata object: a representation\n * of the metadata associated with a MediaSession that can be used by user agents\n * to provide a customized user interface.\n * @property {?boolean} deferInit Set to true to manually call\n * `initPlugin('mediasession')`\n */\n\n/**\n * Visualize MediaSession information for a wavesurfer instance.\n *\n * @implements {PluginClass}\n * @extends {Observer}\n * @example\n * // es6\n * import MediaSessionPlugin from 'wavesurfer.mediasession.js';\n *\n * // commonjs\n * var MediaSessionPlugin = require('wavesurfer.mediasession.js');\n *\n * // if you are using <script> tags\n * var MediaSessionPlugin = window.WaveSurfer.mediasession;\n *\n * // ... initialising wavesurfer with the plugin\n * var wavesurfer = WaveSurfer.create({\n * // wavesurfer options ...\n * plugins: [\n * MediaSessionPlugin.create({\n * // plugin options ...\n * })\n * ]\n * });\n */\nexport default class MediaSessionPlugin {\n /**\n * MediaSession 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 {MediaSessionPluginParams} params parameters use to initialise the plugin\n * @return {PluginDefinition} an object representing the plugin\n */\n static create(params) {\n return {\n name: 'mediasession',\n deferInit: params && params.deferInit ? params.deferInit : false,\n params: params,\n instance: MediaSessionPlugin\n };\n }\n\n constructor(params, ws) {\n this.params = params;\n this.wavesurfer = ws;\n\n if ('mediaSession' in navigator) {\n // update metadata\n this.metadata = this.params.metadata;\n this.update();\n\n // update metadata when playback starts\n this.wavesurfer.on('play', () => {\n this.update();\n });\n\n // set playback action handlers\n navigator.mediaSession.setActionHandler('play', () => {\n this.wavesurfer.play();\n });\n navigator.mediaSession.setActionHandler('pause', () => {\n this.wavesurfer.playPause();\n });\n navigator.mediaSession.setActionHandler('seekbackward', () => {\n this.wavesurfer.skipBackward();\n });\n navigator.mediaSession.setActionHandler('seekforward', () => {\n this.wavesurfer.skipForward();\n });\n }\n }\n\n init() {}\n\n destroy() {}\n\n update() {\n if (typeof MediaMetadata === typeof Function) {\n // set metadata\n navigator.mediaSession.metadata = new MediaMetadata(this.metadata);\n }\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\tif(__webpack_module_cache__[moduleId]) {\n\t\treturn __webpack_module_cache__[moduleId].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/mediasession/index.js\");\n"],"sourceRoot":""}
1
+ {"version":3,"file":"wavesurfer.mediasession.js","mappings":";;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,+CAA+C;AAC/C,CAAC;AACD;;;;;;;;;;;;;;;;;;;;;;;;;ACVA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;IACqBA;AAmBjB,8BAAYC,MAAZ,EAAoBC,EAApB,EAAwB;AAAA;;AAAA;;AACpB,SAAKD,MAAL,GAAcA,MAAd;AACA,SAAKE,UAAL,GAAkBD,EAAlB;;AAEA,QAAI,kBAAkBE,SAAtB,EAAiC;AAC7B;AACA,WAAKC,QAAL,GAAgB,KAAKJ,MAAL,CAAYI,QAA5B;AACA,WAAKC,MAAL,GAH6B,CAK7B;;AACA,WAAKH,UAAL,CAAgBI,EAAhB,CAAmB,MAAnB,EAA2B,YAAM;AAC7B,aAAI,CAACD,MAAL;AACH,OAFD,EAN6B,CAU7B;;AACAF,MAAAA,SAAS,CAACI,YAAV,CAAuBC,gBAAvB,CAAwC,MAAxC,EAAgD,YAAM;AAClD,aAAI,CAACN,UAAL,CAAgBO,IAAhB;AACH,OAFD;AAGAN,MAAAA,SAAS,CAACI,YAAV,CAAuBC,gBAAvB,CAAwC,OAAxC,EAAiD,YAAM;AACnD,aAAI,CAACN,UAAL,CAAgBQ,SAAhB;AACH,OAFD;AAGAP,MAAAA,SAAS,CAACI,YAAV,CAAuBC,gBAAvB,CAAwC,cAAxC,EAAwD,YAAM;AAC1D,aAAI,CAACN,UAAL,CAAgBS,YAAhB;AACH,OAFD;AAGAR,MAAAA,SAAS,CAACI,YAAV,CAAuBC,gBAAvB,CAAwC,aAAxC,EAAuD,YAAM;AACzD,aAAI,CAACN,UAAL,CAAgBU,WAAhB;AACH,OAFD;AAGH;AACJ;;;;WAED,gBAAO,CAAE;;;WAET,mBAAU,CAAE;;;WAEZ,kBAAS;AACL,UAAI,QAAOC,aAAP,yCAAOA,aAAP,eAAgCC,QAAhC,yCAAgCA,QAAhC,EAAJ,EAA8C;AAC1C;AACAX,QAAAA,SAAS,CAACI,YAAV,CAAuBH,QAAvB,GAAkC,IAAIS,aAAJ,CAAkB,KAAKT,QAAvB,CAAlC;AACH;AACJ;;;;AAzDD;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACI,oBAAcJ,MAAd,EAAsB;AAClB,aAAO;AACHe,QAAAA,IAAI,EAAE,cADH;AAEHC,QAAAA,SAAS,EAAEhB,MAAM,IAAIA,MAAM,CAACgB,SAAjB,GAA6BhB,MAAM,CAACgB,SAApC,GAAgD,KAFxD;AAGHhB,QAAAA,MAAM,EAAEA,MAHL;AAIHiB,QAAAA,QAAQ,EAAElB;AAJP,OAAP;AAMH;;;;;;;;;;;;;UCrDL;UACA;;UAEA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;;UAEA;UACA;;UAEA;UACA;UACA;;;;UEtBA;UACA;UACA;UACA","sources":["webpack://WaveSurfer.[name]/webpack/universalModuleDefinition","webpack://WaveSurfer.[name]/./src/plugin/mediasession/index.js","webpack://WaveSurfer.[name]/webpack/bootstrap","webpack://WaveSurfer.[name]/webpack/before-startup","webpack://WaveSurfer.[name]/webpack/startup","webpack://WaveSurfer.[name]/webpack/after-startup"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"WaveSurfer\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"WaveSurfer\"] = factory();\n\telse\n\t\troot[\"WaveSurfer\"] = root[\"WaveSurfer\"] || {}, root[\"WaveSurfer\"][\"mediasession\"] = factory();\n})(self, function() {\nreturn ","/*global MediaMetadata*/\n\n/**\n * @typedef {Object} MediaSessionPluginParams\n * @property {MediaMetadata} metadata A MediaMetadata object: a representation\n * of the metadata associated with a MediaSession that can be used by user agents\n * to provide a customized user interface.\n * @property {?boolean} deferInit Set to true to manually call\n * `initPlugin('mediasession')`\n */\n\n/**\n * Visualize MediaSession information for a wavesurfer instance.\n *\n * @implements {PluginClass}\n * @extends {Observer}\n * @example\n * // es6\n * import MediaSessionPlugin from 'wavesurfer.mediasession.js';\n *\n * // commonjs\n * var MediaSessionPlugin = require('wavesurfer.mediasession.js');\n *\n * // if you are using <script> tags\n * var MediaSessionPlugin = window.WaveSurfer.mediasession;\n *\n * // ... initialising wavesurfer with the plugin\n * var wavesurfer = WaveSurfer.create({\n * // wavesurfer options ...\n * plugins: [\n * MediaSessionPlugin.create({\n * // plugin options ...\n * })\n * ]\n * });\n */\nexport default class MediaSessionPlugin {\n /**\n * MediaSession 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 {MediaSessionPluginParams} params parameters use to initialise the plugin\n * @return {PluginDefinition} an object representing the plugin\n */\n static create(params) {\n return {\n name: 'mediasession',\n deferInit: params && params.deferInit ? params.deferInit : false,\n params: params,\n instance: MediaSessionPlugin\n };\n }\n\n constructor(params, ws) {\n this.params = params;\n this.wavesurfer = ws;\n\n if ('mediaSession' in navigator) {\n // update metadata\n this.metadata = this.params.metadata;\n this.update();\n\n // update metadata when playback starts\n this.wavesurfer.on('play', () => {\n this.update();\n });\n\n // set playback action handlers\n navigator.mediaSession.setActionHandler('play', () => {\n this.wavesurfer.play();\n });\n navigator.mediaSession.setActionHandler('pause', () => {\n this.wavesurfer.playPause();\n });\n navigator.mediaSession.setActionHandler('seekbackward', () => {\n this.wavesurfer.skipBackward();\n });\n navigator.mediaSession.setActionHandler('seekforward', () => {\n this.wavesurfer.skipForward();\n });\n }\n }\n\n init() {}\n\n destroy() {}\n\n update() {\n if (typeof MediaMetadata === typeof Function) {\n // set metadata\n navigator.mediaSession.metadata = new MediaMetadata(this.metadata);\n }\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/mediasession/index.js\");\n",""],"names":["MediaSessionPlugin","params","ws","wavesurfer","navigator","metadata","update","on","mediaSession","setActionHandler","play","playPause","skipBackward","skipForward","MediaMetadata","Function","name","deferInit","instance"],"sourceRoot":""}
@@ -1,7 +1,7 @@
1
1
  /*!
2
- * wavesurfer.js mediasession plugin 4.6.0 (2021-03-05)
2
+ * wavesurfer.js mediasession plugin 5.2.0 (2021-08-16)
3
3
  * https://wavesurfer-js.org
4
4
  * @license BSD-3-Clause
5
5
  */
6
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("WaveSurfer",[],t):"object"==typeof exports?exports.WaveSurfer=t():(e.WaveSurfer=e.WaveSurfer||{},e.WaveSurfer.mediasession=t())}(this,(function(){return(()=>{"use strict";var e={511:(e,t)=>{function n(e){return(n="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})(e)}function a(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r=function(){function e(t,n){var a=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.params=t,this.wavesurfer=n,"mediaSession"in navigator&&(this.metadata=this.params.metadata,this.update(),this.wavesurfer.on("play",(function(){a.update()})),navigator.mediaSession.setActionHandler("play",(function(){a.wavesurfer.play()})),navigator.mediaSession.setActionHandler("pause",(function(){a.wavesurfer.playPause()})),navigator.mediaSession.setActionHandler("seekbackward",(function(){a.wavesurfer.skipBackward()})),navigator.mediaSession.setActionHandler("seekforward",(function(){a.wavesurfer.skipForward()})))}var t,r,o;return t=e,o=[{key:"create",value:function(t){return{name:"mediasession",deferInit:!(!t||!t.deferInit)&&t.deferInit,params:t,instance:e}}}],(r=[{key:"init",value:function(){}},{key:"destroy",value:function(){}},{key:"update",value:function(){("undefined"==typeof MediaMetadata?"undefined":n(MediaMetadata))===("undefined"==typeof Function?"undefined":n(Function))&&(navigator.mediaSession.metadata=new MediaMetadata(this.metadata))}}])&&a(t.prototype,r),o&&a(t,o),e}();t.default=r,e.exports=t.default}},t={};return function n(a){if(t[a])return t[a].exports;var r=t[a]={exports:{}};return e[a](r,r.exports,n),r.exports}(511)})()}));
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.mediasession=t())}(self,(function(){return(()=>{"use strict";var e={511:(e,t)=>{function n(e){return(n="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})(e)}function a(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r=function(){function e(t,n){var a=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.params=t,this.wavesurfer=n,"mediaSession"in navigator&&(this.metadata=this.params.metadata,this.update(),this.wavesurfer.on("play",(function(){a.update()})),navigator.mediaSession.setActionHandler("play",(function(){a.wavesurfer.play()})),navigator.mediaSession.setActionHandler("pause",(function(){a.wavesurfer.playPause()})),navigator.mediaSession.setActionHandler("seekbackward",(function(){a.wavesurfer.skipBackward()})),navigator.mediaSession.setActionHandler("seekforward",(function(){a.wavesurfer.skipForward()})))}var t,r,o;return t=e,o=[{key:"create",value:function(t){return{name:"mediasession",deferInit:!(!t||!t.deferInit)&&t.deferInit,params:t,instance:e}}}],(r=[{key:"init",value:function(){}},{key:"destroy",value:function(){}},{key:"update",value:function(){("undefined"==typeof MediaMetadata?"undefined":n(MediaMetadata))===("undefined"==typeof Function?"undefined":n(Function))&&(navigator.mediaSession.metadata=new MediaMetadata(this.metadata))}}])&&a(t.prototype,r),o&&a(t,o),e}();t.default=r,e.exports=t.default}},t={};return function n(a){var r=t[a];if(void 0!==r)return r.exports;var o=t[a]={exports:{}};return e[a](o,o.exports,n),o.exports}(511)})()}));
7
7
  //# sourceMappingURL=wavesurfer.mediasession.min.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["webpack://WaveSurfer.[name]/webpack/universalModuleDefinition","webpack://WaveSurfer.[name]/./src/plugin/mediasession/index.js","webpack://WaveSurfer.[name]/webpack/bootstrap","webpack://WaveSurfer.[name]/webpack/startup"],"names":["root","factory","exports","module","define","amd","this","MediaSessionPlugin","params","ws","wavesurfer","navigator","metadata","update","on","mediaSession","setActionHandler","play","playPause","skipBackward","skipForward","name","deferInit","instance","MediaMetadata","Function","__webpack_module_cache__","__webpack_require__","moduleId","__webpack_modules__"],"mappings":";;;;;CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,aAAc,GAAIH,GACC,iBAAZC,QACdA,QAAoB,WAAID,KAExBD,EAAiB,WAAIA,EAAiB,YAAK,GAAIA,EAAiB,WAAgB,aAAIC,KARtF,CASGK,MAAM,WACT,M,ufC0BqBC,E,WAmBjB,WAAYC,EAAQC,GAAI,Y,4FAAA,SACpBH,KAAKE,OAASA,EACdF,KAAKI,WAAaD,EAEd,iBAAkBE,YAElBL,KAAKM,SAAWN,KAAKE,OAAOI,SAC5BN,KAAKO,SAGLP,KAAKI,WAAWI,GAAG,QAAQ,WACvB,EAAKD,YAITF,UAAUI,aAAaC,iBAAiB,QAAQ,WAC5C,EAAKN,WAAWO,UAEpBN,UAAUI,aAAaC,iBAAiB,SAAS,WAC7C,EAAKN,WAAWQ,eAEpBP,UAAUI,aAAaC,iBAAiB,gBAAgB,WACpD,EAAKN,WAAWS,kBAEpBR,UAAUI,aAAaC,iBAAiB,eAAe,WACnD,EAAKN,WAAWU,kB,4CAlC5B,SAAcZ,GACV,MAAO,CACHa,KAAM,eACNC,aAAWd,IAAUA,EAAOc,YAAYd,EAAOc,UAC/Cd,OAAQA,EACRe,SAAUhB,O,qBAkClB,c,qBAEA,c,oBAEA,YACQ,oBAAOiB,cAAP,cAAOA,mBAAP,oBAAgCC,SAAhC,cAAgCA,aAEhCd,UAAUI,aAAaH,SAAW,IAAIY,cAAclB,KAAKM,gB,kEC3FjEc,EAA2B,G,OAG/B,SAASC,EAAoBC,GAE5B,GAAGF,EAAyBE,GAC3B,OAAOF,EAAyBE,GAAU1B,QAG3C,IAAIC,EAASuB,EAAyBE,GAAY,CAGjD1B,QAAS,IAOV,OAHA2B,EAAoBD,GAAUzB,EAAQA,EAAOD,QAASyB,GAG/CxB,EAAOD,QCjBWyB,CAAoB,M","file":"wavesurfer.mediasession.min.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"WaveSurfer\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"WaveSurfer\"] = factory();\n\telse\n\t\troot[\"WaveSurfer\"] = root[\"WaveSurfer\"] || {}, root[\"WaveSurfer\"][\"mediasession\"] = factory();\n})(this, function() {\nreturn ","/*global MediaMetadata*/\n\n/**\n * @typedef {Object} MediaSessionPluginParams\n * @property {MediaMetadata} metadata A MediaMetadata object: a representation\n * of the metadata associated with a MediaSession that can be used by user agents\n * to provide a customized user interface.\n * @property {?boolean} deferInit Set to true to manually call\n * `initPlugin('mediasession')`\n */\n\n/**\n * Visualize MediaSession information for a wavesurfer instance.\n *\n * @implements {PluginClass}\n * @extends {Observer}\n * @example\n * // es6\n * import MediaSessionPlugin from 'wavesurfer.mediasession.js';\n *\n * // commonjs\n * var MediaSessionPlugin = require('wavesurfer.mediasession.js');\n *\n * // if you are using <script> tags\n * var MediaSessionPlugin = window.WaveSurfer.mediasession;\n *\n * // ... initialising wavesurfer with the plugin\n * var wavesurfer = WaveSurfer.create({\n * // wavesurfer options ...\n * plugins: [\n * MediaSessionPlugin.create({\n * // plugin options ...\n * })\n * ]\n * });\n */\nexport default class MediaSessionPlugin {\n /**\n * MediaSession 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 {MediaSessionPluginParams} params parameters use to initialise the plugin\n * @return {PluginDefinition} an object representing the plugin\n */\n static create(params) {\n return {\n name: 'mediasession',\n deferInit: params && params.deferInit ? params.deferInit : false,\n params: params,\n instance: MediaSessionPlugin\n };\n }\n\n constructor(params, ws) {\n this.params = params;\n this.wavesurfer = ws;\n\n if ('mediaSession' in navigator) {\n // update metadata\n this.metadata = this.params.metadata;\n this.update();\n\n // update metadata when playback starts\n this.wavesurfer.on('play', () => {\n this.update();\n });\n\n // set playback action handlers\n navigator.mediaSession.setActionHandler('play', () => {\n this.wavesurfer.play();\n });\n navigator.mediaSession.setActionHandler('pause', () => {\n this.wavesurfer.playPause();\n });\n navigator.mediaSession.setActionHandler('seekbackward', () => {\n this.wavesurfer.skipBackward();\n });\n navigator.mediaSession.setActionHandler('seekforward', () => {\n this.wavesurfer.skipForward();\n });\n }\n }\n\n init() {}\n\n destroy() {}\n\n update() {\n if (typeof MediaMetadata === typeof Function) {\n // set metadata\n navigator.mediaSession.metadata = new MediaMetadata(this.metadata);\n }\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\tif(__webpack_module_cache__[moduleId]) {\n\t\treturn __webpack_module_cache__[moduleId].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__(511);\n"],"sourceRoot":""}
1
+ {"version":3,"file":"wavesurfer.mediasession.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,WAAgB,aAAIC,KARtF,CASGK,MAAM,WACT,Y,ifC0BqBC,EAAAA,WAmBjB,WAAYC,EAAQC,GAAI,Y,4FAAA,SACpBC,KAAKF,OAASA,EACdE,KAAKC,WAAaF,EAEd,iBAAkBG,YAElBF,KAAKG,SAAWH,KAAKF,OAAOK,SAC5BH,KAAKI,SAGLJ,KAAKC,WAAWI,GAAG,QAAQ,WACvB,EAAKD,YAITF,UAAUI,aAAaC,iBAAiB,QAAQ,WAC5C,EAAKN,WAAWO,UAEpBN,UAAUI,aAAaC,iBAAiB,SAAS,WAC7C,EAAKN,WAAWQ,eAEpBP,UAAUI,aAAaC,iBAAiB,gBAAgB,WACpD,EAAKN,WAAWS,kBAEpBR,UAAUI,aAAaC,iBAAiB,eAAe,WACnD,EAAKN,WAAWU,kB,4CAlC5B,SAAcb,GACV,MAAO,CACHc,KAAM,eACNC,aAAWf,IAAUA,EAAOe,YAAYf,EAAOe,UAC/Cf,OAAQA,EACRgB,SAAUjB,O,qBAkClB,c,qBAEA,c,oBAEA,YACQ,oBAAOkB,cAAP,cAAOA,mBAAP,oBAAgCC,SAAhC,cAAgCA,aAEhCd,UAAUI,aAAaH,SAAW,IAAIY,cAAcf,KAAKG,gB,6BAxDhDN,G,kCCnCjBoB,EAA2B,G,OAG/B,SAASC,EAAoBC,GAE5B,IAAIC,EAAeH,EAAyBE,GAC5C,QAAqBE,IAAjBD,EACH,OAAOA,EAAa5B,QAGrB,IAAIC,EAASwB,EAAyBE,GAAY,CAGjD3B,QAAS,IAOV,OAHA8B,EAAoBH,GAAU1B,EAAQA,EAAOD,QAAS0B,GAG/CzB,EAAOD,QClBW0B,CAAoB,MHO9C","sources":["webpack://WaveSurfer.[name]/webpack/universalModuleDefinition","webpack://WaveSurfer.[name]/./src/plugin/mediasession/index.js","webpack://WaveSurfer.[name]/webpack/bootstrap","webpack://WaveSurfer.[name]/webpack/startup"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"WaveSurfer\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"WaveSurfer\"] = factory();\n\telse\n\t\troot[\"WaveSurfer\"] = root[\"WaveSurfer\"] || {}, root[\"WaveSurfer\"][\"mediasession\"] = factory();\n})(self, function() {\nreturn ","/*global MediaMetadata*/\n\n/**\n * @typedef {Object} MediaSessionPluginParams\n * @property {MediaMetadata} metadata A MediaMetadata object: a representation\n * of the metadata associated with a MediaSession that can be used by user agents\n * to provide a customized user interface.\n * @property {?boolean} deferInit Set to true to manually call\n * `initPlugin('mediasession')`\n */\n\n/**\n * Visualize MediaSession information for a wavesurfer instance.\n *\n * @implements {PluginClass}\n * @extends {Observer}\n * @example\n * // es6\n * import MediaSessionPlugin from 'wavesurfer.mediasession.js';\n *\n * // commonjs\n * var MediaSessionPlugin = require('wavesurfer.mediasession.js');\n *\n * // if you are using <script> tags\n * var MediaSessionPlugin = window.WaveSurfer.mediasession;\n *\n * // ... initialising wavesurfer with the plugin\n * var wavesurfer = WaveSurfer.create({\n * // wavesurfer options ...\n * plugins: [\n * MediaSessionPlugin.create({\n * // plugin options ...\n * })\n * ]\n * });\n */\nexport default class MediaSessionPlugin {\n /**\n * MediaSession 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 {MediaSessionPluginParams} params parameters use to initialise the plugin\n * @return {PluginDefinition} an object representing the plugin\n */\n static create(params) {\n return {\n name: 'mediasession',\n deferInit: params && params.deferInit ? params.deferInit : false,\n params: params,\n instance: MediaSessionPlugin\n };\n }\n\n constructor(params, ws) {\n this.params = params;\n this.wavesurfer = ws;\n\n if ('mediaSession' in navigator) {\n // update metadata\n this.metadata = this.params.metadata;\n this.update();\n\n // update metadata when playback starts\n this.wavesurfer.on('play', () => {\n this.update();\n });\n\n // set playback action handlers\n navigator.mediaSession.setActionHandler('play', () => {\n this.wavesurfer.play();\n });\n navigator.mediaSession.setActionHandler('pause', () => {\n this.wavesurfer.playPause();\n });\n navigator.mediaSession.setActionHandler('seekbackward', () => {\n this.wavesurfer.skipBackward();\n });\n navigator.mediaSession.setActionHandler('seekforward', () => {\n this.wavesurfer.skipForward();\n });\n }\n }\n\n init() {}\n\n destroy() {}\n\n update() {\n if (typeof MediaMetadata === typeof Function) {\n // set metadata\n navigator.mediaSession.metadata = new MediaMetadata(this.metadata);\n }\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__(511);\n"],"names":["root","factory","exports","module","define","amd","self","MediaSessionPlugin","params","ws","this","wavesurfer","navigator","metadata","update","on","mediaSession","setActionHandler","play","playPause","skipBackward","skipForward","name","deferInit","instance","MediaMetadata","Function","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__"],"sourceRoot":""}
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * wavesurfer.js microphone plugin 4.6.0 (2021-03-05)
2
+ * wavesurfer.js microphone plugin 5.2.0 (2021-08-16)
3
3
  * https://wavesurfer-js.org
4
4
  * @license BSD-3-Clause
5
5
  */
@@ -12,7 +12,7 @@
12
12
  exports["WaveSurfer"] = factory();
13
13
  else
14
14
  root["WaveSurfer"] = root["WaveSurfer"] || {}, root["WaveSurfer"]["microphone"] = factory();
15
- })(this, function() {
15
+ })(self, function() {
16
16
  return /******/ (() => { // webpackBootstrap
17
17
  /******/ "use strict";
18
18
  /******/ var __webpack_modules__ = ({
@@ -449,8 +449,9 @@ module.exports = exports.default;
449
449
  /******/ // The require function
450
450
  /******/ function __webpack_require__(moduleId) {
451
451
  /******/ // Check if module is in cache
452
- /******/ if(__webpack_module_cache__[moduleId]) {
453
- /******/ return __webpack_module_cache__[moduleId].exports;
452
+ /******/ var cachedModule = __webpack_module_cache__[moduleId];
453
+ /******/ if (cachedModule !== undefined) {
454
+ /******/ return cachedModule.exports;
454
455
  /******/ }
455
456
  /******/ // Create a new module (and put it into the cache)
456
457
  /******/ var module = __webpack_module_cache__[moduleId] = {