wavesurfer.js 4.5.0 → 5.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/CHANGES.md +36 -1
  2. package/README.md +6 -3
  3. package/dist/plugin/wavesurfer.cursor.js +39 -34
  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 +29 -27
  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 +381 -0
  12. package/dist/plugin/wavesurfer.markers.js.map +1 -0
  13. package/dist/plugin/wavesurfer.markers.min.js +7 -0
  14. package/dist/plugin/wavesurfer.markers.min.js.map +1 -0
  15. package/dist/plugin/wavesurfer.mediasession.js +29 -27
  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 +29 -27
  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 +30 -28
  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 +152 -126
  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 +97 -89
  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 +46 -32
  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 +9 -5
  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 +350 -166
  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 +282 -0
  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 +83 -70
  60. package/src/plugin/spectrogram/index.js +65 -61
  61. package/src/plugin/timeline/index.js +20 -11
  62. package/src/util/index.js +1 -0
  63. package/src/util/orientation.js +98 -0
  64. package/src/wavesurfer.js +18 -9
  65. package/src/webaudio.js +10 -9
@@ -1,7 +1,7 @@
1
1
  /*!
2
- * wavesurfer.js elan plugin 4.5.0 (2021-02-14)
2
+ * wavesurfer.js elan plugin 5.1.0 (2021-06-20)
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.elan=t())}(this,(function(){return(()=>{"use strict";var e={375:(e,t)=>{function n(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function r(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),e}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var a=function(){function e(t,n){if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.Types={ALIGNABLE_ANNOTATION:"ALIGNABLE_ANNOTATION",REF_ANNOTATION:"REF_ANNOTATION"},this.data=null,this.params=t,this.container="string"==typeof t.container?document.querySelector(t.container):t.container,!this.container)throw Error("No container for ELAN")}return r(e,null,[{key:"create",value:function(t){return{name:"elan",deferInit:!(!t||!t.deferInit)&&t.deferInit,params:t,instance:e}}}]),r(e,[{key:"init",value:function(){this.bindClick(),this.params.url&&this.load(this.params.url)}},{key:"destroy",value:function(){this.container.removeEventListener("click",this._onClick),this.container.removeChild(this.table)}},{key:"load",value:function(e){var t=this;this.loadXML(e,(function(e){t.data=t.parseElan(e),t.render(),t.fireEvent("ready",t.data)}))}},{key:"loadXML",value:function(e,t){var n=new XMLHttpRequest;n.open("GET",e,!0),n.responseType="document",n.send(),n.addEventListener("load",(function(e){t&&t(e.target.responseXML)}))}},{key:"parseElan",value:function(e){var t=this,n=Array.prototype.forEach,r=Array.prototype.map,a={media:{},timeOrder:{},tiers:[],annotations:{},alignableAnnotations:[]},i=e.querySelector("HEADER"),o="milliseconds"==i.getAttribute("TIME_UNITS"),s=i.querySelector("MEDIA_DESCRIPTOR");a.media.url=s.getAttribute("MEDIA_URL"),a.media.type=s.getAttribute("MIME_TYPE");var l=e.querySelectorAll("TIME_ORDER TIME_SLOT"),u={};return n.call(l,(function(e){var t=parseFloat(e.getAttribute("TIME_VALUE"));o&&(t=Math.round(100*t)/1e5),u[e.getAttribute("TIME_SLOT_ID")]=t})),a.tiers=r.call(e.querySelectorAll("TIER"),(function(e){return{id:e.getAttribute("TIER_ID"),linguisticTypeRef:e.getAttribute("LINGUISTIC_TYPE_REF"),defaultLocale:e.getAttribute("DEFAULT_LOCALE"),annotations:r.call(e.querySelectorAll("REF_ANNOTATION, ALIGNABLE_ANNOTATION"),(function(e){var n={type:e.nodeName,id:e.getAttribute("ANNOTATION_ID"),ref:e.getAttribute("ANNOTATION_REF"),value:e.querySelector("ANNOTATION_VALUE").textContent.trim()};return t.Types.ALIGNABLE_ANNOTATION==n.type&&(n.start=u[e.getAttribute("TIME_SLOT_REF1")],n.end=u[e.getAttribute("TIME_SLOT_REF2")],a.alignableAnnotations.push(n)),a.annotations[n.id]=n,n}))}})),a.tiers.forEach((function(e){e.annotations.forEach((function(e){null!=e.ref&&(e.reference=a.annotations[e.ref])}))})),a.alignableAnnotations.sort((function(e,t){var n=e.start-t.start;return 0==n&&(n=t.end-e.end),n})),a.length=a.alignableAnnotations.length,a}},{key:"render",value:function(){var e=this,t=this.data.tiers;this.params.tiers&&(t=t.filter((function(t){return t.id in e.params.tiers})));var n={},r={};t.forEach((function(t,a){t.annotations.forEach((function(t){t.reference&&t.reference.type==e.Types.ALIGNABLE_ANNOTATION&&(t.reference.id in n||(n[t.ref]={}),n[t.ref][a]=t,r[a]=!0)}))})),r=Object.keys(r).sort(),this.renderedAlignable=this.data.alignableAnnotations.filter((function(e){return n[e.id]}));var a=this.table=document.createElement("table");a.className="wavesurfer-annotations";var i=document.createElement("thead"),o=document.createElement("tr");i.appendChild(o),a.appendChild(i);var s=document.createElement("th");s.textContent="Time",s.className="wavesurfer-time",o.appendChild(s),r.forEach((function(n){var r=t[n],a=document.createElement("th");a.className="wavesurfer-tier-"+r.id,a.textContent=r.id,e.params.tiers&&(a.style.width=e.params.tiers[r.id]),o.appendChild(a)}));var l=document.createElement("tbody");a.appendChild(l),this.renderedAlignable.forEach((function(e){var a=document.createElement("tr");a.id="wavesurfer-alignable-"+e.id,l.appendChild(a);var i=document.createElement("td");i.className="wavesurfer-time",i.textContent=e.start.toFixed(1)+"–"+e.end.toFixed(1),a.appendChild(i);var o=n[e.id];r.forEach((function(n){var r=t[n],i=document.createElement("td"),s=o[n];s&&(i.id="wavesurfer-annotation-"+s.id,i.dataset.ref=e.id,i.dataset.start=e.start,i.dataset.end=e.end,i.textContent=s.value),i.className="wavesurfer-tier-"+r.id,a.appendChild(i)}))})),this.container.innerHTML="",this.container.appendChild(a)}},{key:"bindClick",value:function(){var e=this;this._onClick=function(t){var n=t.target.dataset.ref;if(null!=n){var r=e.data.annotations[n];r&&e.fireEvent("select",r.start,r.end)}},this.container.addEventListener("click",this._onClick)}},{key:"getRenderedAnnotation",value:function(e){var t;return this.renderedAlignable.some((function(n){return n.start<=e&&n.end>=e&&(t=n,!0)})),t}},{key:"getAnnotationNode",value:function(e){return document.getElementById("wavesurfer-alignable-"+e.id)}}]),e}();t.default=a,e.exports=t.default}},t={};return function n(r){if(t[r])return t[r].exports;var a=t[r]={exports:{}};return e[r](a,a.exports,n),a.exports}(375)})()}));
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.elan=t())}(this,(function(){return(()=>{"use strict";var e={375:(e,t)=>{function n(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r=function(){function e(t,n){if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.Types={ALIGNABLE_ANNOTATION:"ALIGNABLE_ANNOTATION",REF_ANNOTATION:"REF_ANNOTATION"},this.data=null,this.params=t,this.container="string"==typeof t.container?document.querySelector(t.container):t.container,!this.container)throw Error("No container for ELAN")}var t,r,a;return t=e,a=[{key:"create",value:function(t){return{name:"elan",deferInit:!(!t||!t.deferInit)&&t.deferInit,params:t,instance:e}}}],(r=[{key:"init",value:function(){this.bindClick(),this.params.url&&this.load(this.params.url)}},{key:"destroy",value:function(){this.container.removeEventListener("click",this._onClick),this.container.removeChild(this.table)}},{key:"load",value:function(e){var t=this;this.loadXML(e,(function(e){t.data=t.parseElan(e),t.render(),t.fireEvent("ready",t.data)}))}},{key:"loadXML",value:function(e,t){var n=new XMLHttpRequest;n.open("GET",e,!0),n.responseType="document",n.send(),n.addEventListener("load",(function(e){t&&t(e.target.responseXML)}))}},{key:"parseElan",value:function(e){var t=this,n=Array.prototype.forEach,r=Array.prototype.map,a={media:{},timeOrder:{},tiers:[],annotations:{},alignableAnnotations:[]},i=e.querySelector("HEADER"),o="milliseconds"==i.getAttribute("TIME_UNITS"),s=i.querySelector("MEDIA_DESCRIPTOR");a.media.url=s.getAttribute("MEDIA_URL"),a.media.type=s.getAttribute("MIME_TYPE");var l=e.querySelectorAll("TIME_ORDER TIME_SLOT"),u={};return n.call(l,(function(e){var t=parseFloat(e.getAttribute("TIME_VALUE"));o&&(t=Math.round(100*t)/1e5),u[e.getAttribute("TIME_SLOT_ID")]=t})),a.tiers=r.call(e.querySelectorAll("TIER"),(function(e){return{id:e.getAttribute("TIER_ID"),linguisticTypeRef:e.getAttribute("LINGUISTIC_TYPE_REF"),defaultLocale:e.getAttribute("DEFAULT_LOCALE"),annotations:r.call(e.querySelectorAll("REF_ANNOTATION, ALIGNABLE_ANNOTATION"),(function(e){var n={type:e.nodeName,id:e.getAttribute("ANNOTATION_ID"),ref:e.getAttribute("ANNOTATION_REF"),value:e.querySelector("ANNOTATION_VALUE").textContent.trim()};return t.Types.ALIGNABLE_ANNOTATION==n.type&&(n.start=u[e.getAttribute("TIME_SLOT_REF1")],n.end=u[e.getAttribute("TIME_SLOT_REF2")],a.alignableAnnotations.push(n)),a.annotations[n.id]=n,n}))}})),a.tiers.forEach((function(e){e.annotations.forEach((function(e){null!=e.ref&&(e.reference=a.annotations[e.ref])}))})),a.alignableAnnotations.sort((function(e,t){var n=e.start-t.start;return 0==n&&(n=t.end-e.end),n})),a.length=a.alignableAnnotations.length,a}},{key:"render",value:function(){var e=this,t=this.data.tiers;this.params.tiers&&(t=t.filter((function(t){return t.id in e.params.tiers})));var n={},r={};t.forEach((function(t,a){t.annotations.forEach((function(t){t.reference&&t.reference.type==e.Types.ALIGNABLE_ANNOTATION&&(t.reference.id in n||(n[t.ref]={}),n[t.ref][a]=t,r[a]=!0)}))})),r=Object.keys(r).sort(),this.renderedAlignable=this.data.alignableAnnotations.filter((function(e){return n[e.id]}));var a=this.table=document.createElement("table");a.className="wavesurfer-annotations";var i=document.createElement("thead"),o=document.createElement("tr");i.appendChild(o),a.appendChild(i);var s=document.createElement("th");s.textContent="Time",s.className="wavesurfer-time",o.appendChild(s),r.forEach((function(n){var r=t[n],a=document.createElement("th");a.className="wavesurfer-tier-"+r.id,a.textContent=r.id,e.params.tiers&&(a.style.width=e.params.tiers[r.id]),o.appendChild(a)}));var l=document.createElement("tbody");a.appendChild(l),this.renderedAlignable.forEach((function(e){var a=document.createElement("tr");a.id="wavesurfer-alignable-"+e.id,l.appendChild(a);var i=document.createElement("td");i.className="wavesurfer-time",i.textContent=e.start.toFixed(1)+"–"+e.end.toFixed(1),a.appendChild(i);var o=n[e.id];r.forEach((function(n){var r=t[n],i=document.createElement("td"),s=o[n];s&&(i.id="wavesurfer-annotation-"+s.id,i.dataset.ref=e.id,i.dataset.start=e.start,i.dataset.end=e.end,i.textContent=s.value),i.className="wavesurfer-tier-"+r.id,a.appendChild(i)}))})),this.container.innerHTML="",this.container.appendChild(a)}},{key:"bindClick",value:function(){var e=this;this._onClick=function(t){var n=t.target.dataset.ref;if(null!=n){var r=e.data.annotations[n];r&&e.fireEvent("select",r.start,r.end)}},this.container.addEventListener("click",this._onClick)}},{key:"getRenderedAnnotation",value:function(e){var t;return this.renderedAlignable.some((function(n){return n.start<=e&&n.end>=e&&(t=n,!0)})),t}},{key:"getAnnotationNode",value:function(e){return document.getElementById("wavesurfer-alignable-"+e.id)}}])&&n(t.prototype,r),a&&n(t,a),e}();t.default=r,e.exports=t.default}},t={};return function n(r){var a=t[r];if(void 0!==a)return a.exports;var i=t[r]={exports:{}};return e[r](i,i.exports,n),i.exports}(375)})()}));
7
7
  //# sourceMappingURL=wavesurfer.elan.min.js.map
@@ -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,IAC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AC9CC,EAASJ,GACF,MAIRI,I,wCAGOJ,GACd,OAAO3F,SAASiG,eAAe,wBAA0BN,EAAWvC,Q,uCC/SxE8C,EAA2B,GCE/B,ODCA,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,QCjBRgH,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","// module exports must be returned from runtime so entry inlining is disabled\n// startup\n// Load entry module and return exports\nreturn __webpack_require__(375);\n"],"sourceRoot":""}
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","cachedModule","undefined","__webpack_modules__"],"mappings":";;;;;CAAA,SAA2CA,EAAMC,GA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C,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,IAAIC,EAAeH,EAAyBE,GAC5C,QAAqBE,IAAjBD,EACH,OAAOA,EAAalH,QAGrB,IAAIC,EAAS8G,EAAyBE,GAAY,CAGjDjH,QAAS,IAOV,OAHAoH,EAAoBH,GAAUhH,EAAQA,EAAOD,QAASgH,GAG/C/G,EAAOD,QClBWgH,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\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"],"sourceRoot":""}
@@ -0,0 +1,381 @@
1
+ /*!
2
+ * wavesurfer.js markers plugin 5.1.0 (2021-06-20)
3
+ * https://wavesurfer-js.org
4
+ * @license BSD-3-Clause
5
+ */
6
+ (function webpackUniversalModuleDefinition(root, factory) {
7
+ if(typeof exports === 'object' && typeof module === 'object')
8
+ module.exports = factory();
9
+ else if(typeof define === 'function' && define.amd)
10
+ define("WaveSurfer", [], factory);
11
+ else if(typeof exports === 'object')
12
+ exports["WaveSurfer"] = factory();
13
+ else
14
+ root["WaveSurfer"] = root["WaveSurfer"] || {}, root["WaveSurfer"]["markers"] = factory();
15
+ })(this, function() {
16
+ return /******/ (() => { // webpackBootstrap
17
+ /******/ "use strict";
18
+ /******/ var __webpack_modules__ = ({
19
+
20
+ /***/ "./src/plugin/markers/index.js":
21
+ /*!*************************************!*\
22
+ !*** ./src/plugin/markers/index.js ***!
23
+ \*************************************/
24
+ /***/ ((module, exports) => {
25
+
26
+
27
+
28
+ Object.defineProperty(exports, "__esModule", ({
29
+ value: true
30
+ }));
31
+ exports.default = void 0;
32
+
33
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
34
+
35
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
36
+
37
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
38
+
39
+ /**
40
+ * @typedef {Object} MarkerParams
41
+ * @desc The parameters used to describe a marker.
42
+ * @example wavesurfer.addMarker(regionParams);
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
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
48
+ */
49
+
50
+ /**
51
+ * Markers are points in time in the audio that can be jumped to.
52
+ *
53
+ * @implements {PluginClass}
54
+ *
55
+ * @example
56
+ * import MarkersPlugin from 'wavesurfer.markers.js';
57
+ *
58
+ * // if you are using <script> tags
59
+ * var MarkerPlugin = window.WaveSurfer.markers;
60
+ *
61
+ * // ... initialising wavesurfer with the plugin
62
+ * var wavesurfer = WaveSurfer.create({
63
+ * // wavesurfer options ...
64
+ * plugins: [
65
+ * MarkersPlugin.create({
66
+ * // plugin options ...
67
+ * })
68
+ * ]
69
+ * });
70
+ */
71
+ var DEFAULT_FILL_COLOR = "#D8D8D8";
72
+ var DEFAULT_POSITION = "bottom";
73
+
74
+ var MarkersPlugin = /*#__PURE__*/function () {
75
+ function MarkersPlugin(params, ws) {
76
+ var _this = this;
77
+
78
+ _classCallCheck(this, MarkersPlugin);
79
+
80
+ this.params = params;
81
+ this.wavesurfer = ws;
82
+ this.util = ws.util;
83
+ this.style = this.util.style;
84
+ this.markerWidth = 11;
85
+ this.markerHeight = 22;
86
+
87
+ this._onResize = function () {
88
+ _this._updateMarkerPositions();
89
+ };
90
+
91
+ this._onBackendCreated = function () {
92
+ _this.wrapper = _this.wavesurfer.drawer.wrapper;
93
+
94
+ if (_this.params.markers) {
95
+ _this.params.markers.forEach(function (marker) {
96
+ return _this.add(marker);
97
+ });
98
+ }
99
+
100
+ window.addEventListener('resize', _this._onResize, true);
101
+ window.addEventListener('orientationchange', _this._onResize, true);
102
+
103
+ _this.wavesurfer.on('zoom', _this._onResize);
104
+ };
105
+
106
+ this.markers = [];
107
+
108
+ this._onReady = function () {
109
+ _this.wrapper = _this.wavesurfer.drawer.wrapper;
110
+
111
+ _this._updateMarkerPositions();
112
+ };
113
+ }
114
+
115
+ _createClass(MarkersPlugin, [{
116
+ key: "init",
117
+ value: function init() {
118
+ // Check if ws is ready
119
+ if (this.wavesurfer.isReady) {
120
+ this._onBackendCreated();
121
+
122
+ this._onReady();
123
+ } else {
124
+ this.wavesurfer.once('ready', this._onReady);
125
+ this.wavesurfer.once('backend-created', this._onBackendCreated);
126
+ }
127
+ }
128
+ }, {
129
+ key: "destroy",
130
+ value: function destroy() {
131
+ this.wavesurfer.un('ready', this._onReady);
132
+ this.wavesurfer.un('backend-created', this._onBackendCreated);
133
+ this.wavesurfer.un('zoom', this._onResize);
134
+ window.removeEventListener('resize', this._onResize, true);
135
+ window.removeEventListener('orientationchange', this._onResize, true);
136
+ this.clear();
137
+ }
138
+ /**
139
+ * Add a marker
140
+ *
141
+ * @param {MarkerParams} params Marker definition
142
+ * @return {object} The created marker
143
+ */
144
+
145
+ }, {
146
+ key: "add",
147
+ value: function add(params) {
148
+ var marker = {
149
+ time: params.time,
150
+ label: params.label,
151
+ color: params.color || DEFAULT_FILL_COLOR,
152
+ position: params.position || DEFAULT_POSITION
153
+ };
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);
161
+ this.wrapper.appendChild(marker.el);
162
+ this.markers.push(marker);
163
+
164
+ this._updateMarkerPositions();
165
+
166
+ return marker;
167
+ }
168
+ /**
169
+ * Remove a marker
170
+ *
171
+ * @param {number} index Index of the marker to remove
172
+ */
173
+
174
+ }, {
175
+ key: "remove",
176
+ value: function remove(index) {
177
+ var marker = this.markers[index];
178
+
179
+ if (!marker) {
180
+ return;
181
+ }
182
+
183
+ this.wrapper.removeChild(marker.el);
184
+ this.markers.splice(index, 1);
185
+ }
186
+ }, {
187
+ key: "_createPointerSVG",
188
+ value: function _createPointerSVG(color, position) {
189
+ var svgNS = "http://www.w3.org/2000/svg";
190
+ var el = document.createElementNS(svgNS, "svg");
191
+ var polygon = document.createElementNS(svgNS, "polygon");
192
+ el.setAttribute("viewBox", "0 0 40 80");
193
+ polygon.setAttribute("id", "polygon");
194
+ polygon.setAttribute("stroke", "#979797");
195
+ polygon.setAttribute("fill", color);
196
+ polygon.setAttribute("points", "20 0 40 30 40 80 0 80 0 30");
197
+
198
+ if (position == "top") {
199
+ polygon.setAttribute("transform", "rotate(180, 20 40)");
200
+ }
201
+
202
+ el.appendChild(polygon);
203
+ this.style(el, {
204
+ width: this.markerWidth + "px",
205
+ height: this.markerHeight + "px",
206
+ "min-width": this.markerWidth + "px",
207
+ "margin-right": "5px",
208
+ "z-index": 4
209
+ });
210
+ return el;
211
+ }
212
+ }, {
213
+ key: "_createMarkerElement",
214
+ value: function _createMarkerElement(marker, markerElement) {
215
+ var _this2 = this;
216
+
217
+ var label = marker.label;
218
+ var time = marker.time;
219
+ var el = document.createElement('marker');
220
+ el.className = "wavesurfer-marker";
221
+ this.style(el, {
222
+ position: "absolute",
223
+ height: "100%",
224
+ display: "flex",
225
+ overflow: "hidden",
226
+ "flex-direction": marker.position == "top" ? "column-reverse" : "column"
227
+ });
228
+ var line = document.createElement('div');
229
+ this.style(line, {
230
+ "flex-grow": 1,
231
+ "margin-left": this.markerWidth / 2 - 0.5 + "px",
232
+ background: "black",
233
+ width: "1px",
234
+ opacity: 0.1
235
+ });
236
+ el.appendChild(line);
237
+ var labelDiv = document.createElement('div');
238
+
239
+ var point = markerElement || this._createPointerSVG(marker.color, marker.position);
240
+
241
+ labelDiv.appendChild(point);
242
+
243
+ if (label) {
244
+ var labelEl = document.createElement('span');
245
+ labelEl.innerText = label;
246
+ this.style(labelEl, {
247
+ "font-family": "monospace",
248
+ "font-size": "90%"
249
+ });
250
+ labelDiv.appendChild(labelEl);
251
+ }
252
+
253
+ this.style(labelDiv, {
254
+ display: "flex",
255
+ "align-items": "center",
256
+ cursor: "pointer"
257
+ });
258
+ el.appendChild(labelDiv);
259
+ labelDiv.addEventListener("click", function (e) {
260
+ e.stopPropagation();
261
+
262
+ _this2.wavesurfer.setCurrentTime(time);
263
+
264
+ _this2.wavesurfer.fireEvent("marker-click", marker, e);
265
+ });
266
+ return el;
267
+ }
268
+ }, {
269
+ key: "_updateMarkerPositions",
270
+ value: function _updateMarkerPositions() {
271
+ var duration = this.wavesurfer.getDuration();
272
+
273
+ for (var i = 0; i < this.markers.length; i++) {
274
+ var marker = this.markers[i];
275
+ var elementWidth = this.wavesurfer.drawer.width / this.wavesurfer.params.pixelRatio;
276
+ var positionPct = Math.min(marker.time / duration, 1);
277
+ var leftPx = elementWidth * positionPct - this.markerWidth / 2;
278
+ this.style(marker.el, {
279
+ "left": leftPx + "px",
280
+ "max-width": elementWidth - leftPx + "px"
281
+ });
282
+ }
283
+ }
284
+ /**
285
+ * Remove all markers
286
+ */
287
+
288
+ }, {
289
+ key: "clear",
290
+ value: function clear() {
291
+ while (this.markers.length > 0) {
292
+ this.remove(0);
293
+ }
294
+ }
295
+ }], [{
296
+ key: "create",
297
+ value:
298
+ /**
299
+ * @typedef {Object} MarkersPluginParams
300
+ * @property {?MarkerParams[]} markers Initial set of markers
301
+ * @fires MarkersPlugin#marker-click
302
+ */
303
+
304
+ /**
305
+ * Markers plugin definition factory
306
+ *
307
+ * This function must be used to create a plugin definition which can be
308
+ * used by wavesurfer to correctly instantiate the plugin.
309
+ *
310
+ * @param {MarkersPluginParams} params parameters use to initialise the plugin
311
+ * @since 4.6.0
312
+ * @return {PluginDefinition} an object representing the plugin
313
+ */
314
+ function create(params) {
315
+ return {
316
+ name: 'markers',
317
+ deferInit: params && params.deferInit ? params.deferInit : false,
318
+ params: params,
319
+ staticProps: {
320
+ addMarker: function addMarker(options) {
321
+ if (!this.initialisedPluginList.markers) {
322
+ this.initPlugin('markers');
323
+ }
324
+
325
+ return this.markers.add(options);
326
+ },
327
+ clearMarkers: function clearMarkers() {
328
+ this.markers && this.markers.clear();
329
+ }
330
+ },
331
+ instance: MarkersPlugin
332
+ };
333
+ }
334
+ }]);
335
+
336
+ return MarkersPlugin;
337
+ }();
338
+
339
+ exports.default = MarkersPlugin;
340
+ module.exports = exports.default;
341
+
342
+ /***/ })
343
+
344
+ /******/ });
345
+ /************************************************************************/
346
+ /******/ // The module cache
347
+ /******/ var __webpack_module_cache__ = {};
348
+ /******/
349
+ /******/ // The require function
350
+ /******/ function __webpack_require__(moduleId) {
351
+ /******/ // Check if module is in cache
352
+ /******/ var cachedModule = __webpack_module_cache__[moduleId];
353
+ /******/ if (cachedModule !== undefined) {
354
+ /******/ return cachedModule.exports;
355
+ /******/ }
356
+ /******/ // Create a new module (and put it into the cache)
357
+ /******/ var module = __webpack_module_cache__[moduleId] = {
358
+ /******/ // no module.id needed
359
+ /******/ // no module.loaded needed
360
+ /******/ exports: {}
361
+ /******/ };
362
+ /******/
363
+ /******/ // Execute the module function
364
+ /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
365
+ /******/
366
+ /******/ // Return the exports of the module
367
+ /******/ return module.exports;
368
+ /******/ }
369
+ /******/
370
+ /************************************************************************/
371
+ /******/
372
+ /******/ // startup
373
+ /******/ // Load entry module and return exports
374
+ /******/ // This entry module is referenced by other modules so it can't be inlined
375
+ /******/ var __webpack_exports__ = __webpack_require__("./src/plugin/markers/index.js");
376
+ /******/
377
+ /******/ return __webpack_exports__;
378
+ /******/ })()
379
+ ;
380
+ });
381
+ //# sourceMappingURL=wavesurfer.markers.js.map
@@ -0,0 +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","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"],"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;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;AAqCjB,yBAAYC,MAAZ,EAAoBC,EAApB,EAAwB;AAAA;;AAAA;;AACpB,SAAKD,MAAL,GAAcA,MAAd;AACA,SAAKE,UAAL,GAAkBD,EAAlB;AACA,SAAKE,IAAL,GAAYF,EAAE,CA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;;AAjPD;AACJ;AACA;AACA;AACA;;AAEI;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACI,oBAAcvE,MAAd,EAAsB;AAClB,aAAO;AACHwE,YAAI,EAAE,SADH;AAEHC,iBAAS,EAAEzE,MAAM,IAAIA,MAAM,CAACyE,SAAjB,GAA6BzE,MAAM,CAACyE,SAApC,GAAgD,KAFxD;AAGHzE,cAAM,EAAEA,MAHL;AAIH0E,mBAAW,EAAE;AACTC,mBADS,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,sBAPS,0BAOM;AACX,iBAAKnE,OAAL,IAAgB,KAAKA,OAAL,CAAaY,KAAb,EAAhB;AACH;AATQ,SAJV;AAeHwD,gBAAQ,EAAEjF;AAfP,OAAP;AAiBH;;;;;;;;;;;;;UCzEL;UACA;;UAEA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;;UAEA;UACA;;UAEA;UACA;UACA;;;;UCtBA;UACA;UACA;UACA","file":"wavesurfer.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 * @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"],"sourceRoot":""}
@@ -0,0 +1,7 @@
1
+ /*!
2
+ * wavesurfer.js markers plugin 5.1.0 (2021-06-20)
3
+ * https://wavesurfer-js.org
4
+ * @license BSD-3-Clause
5
+ */
6
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("WaveSurfer",[],t):"object"==typeof exports?exports.WaveSurfer=t():(e.WaveSurfer=e.WaveSurfer||{},e.WaveSurfer.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 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
+ //# sourceMappingURL=wavesurfer.markers.min.js.map
@@ -0,0 +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","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__"],"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,8QCyBA,IAGqBC,E,WAqCjB,WAAYC,EAAQC,GAAI,Y,4FAAA,SACpBH,KAAKE,OAASA,EACdF,KAAKI,WAAaD,EAClBH,KAAKK,KAAOF,EAAGE,KACfL,KAAKM,MAAQN,KAAKK,KAAKC,MACvBN,KAAKO,YAAc,GACnBP,KAAKQ,aAAe,GAGpBR,KAAKS,UAAY,WACb,EAAKC,0BAGTV,KAAKW,kBAAoB,WACrB,EAAKC,QAAU,EAAKR,WAAWS,OAAOD,QAClC,EAAKV,OAAOY,SACZ,EAAKZ,OAAOY,QAAQC,SAAQ,SAAAC,GAAM,OAAI,EAAKC,IAAID,MAEnDE,OAAOC,iBAAiB,SAAU,EAAKV,WAAW,GAClDS,OAAOC,iBAAiB,oBAAqB,EAAKV,WAAW,GAC7D,EAAKL,WAAWgB,GAAG,OAAQ,EAAKX,YAGpCT,KAAKc,QAAU,GACfd,KAAKqB,SAAW,WACZ,EAAKT,QAAU,EAAKR,WAAWS,OAAOD,QACtC,EAAKF,0B,4CA9Cb,SAAcR,GACV,MAAO,CACHoB,KAAM,UACNC,aAAWrB,IAAUA,EAAOqB,YAAYrB,EAA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EAAGE,YAAYiB,GAEfA,EAAS3C,iBAAiB,SAAS,SAAAiD,GAC/BA,EAAEC,kBACF,EAAKjE,WAAWkE,eAAelC,GAC/B,EAAKhC,WAAWmE,UAAU,eAAgBvD,EAAQoD,MAG/CzB,I,oCAGX,WAGI,IAFA,IAAM6B,EAAWxE,KAAKI,WAAWqE,cAEvBC,EAAI,EAAIA,EAAI1E,KAAKc,QAAQ6D,OAAQD,IAAM,CAC7C,IAAI1D,EAAShB,KAAKc,QAAQ4D,GACpBE,EACF5E,KAAKI,WAAWS,OAAO4B,MACvBzC,KAAKI,WAAWF,OAAO2E,WAGrBC,EAAWF,EADGG,KAAKC,IAAIhE,EAAOoB,KAAOoC,EAAU,GACLxE,KAAKO,YAAc,EACnEP,KAAKM,MAAMU,EAAO2B,GAAI,CAClB,KAASmC,EAAS,KAClB,YAAcF,EAAeE,EAAU,U,mBAQnD,WACI,KAAQ9E,KAAKc,QAAQ6D,OAAS,GAC1B3E,KAAKiF,OAAO,Q,kECrRpBC,EAA2B,G,OAG/B,SAASC,EAAoBC,GAE5B,IAAIC,EAAeH,EAAyBE,GAC5C,QAAqBE,IAAjBD,EACH,OAAOA,EAAazF,QAGrB,IAAIC,EAASqF,EAAyBE,GAAY,CAGjDxF,QAAS,IAOV,OAHA2F,EAAoBH,GAAUvF,EAAQA,EAAOD,QAASuF,GAG/CtF,EAAOD,QClBWuF,CAAoB,M","file":"wavesurfer.markers.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\"][\"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 * @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"],"sourceRoot":""}