wavesurfer.js 6.1.0 → 6.3.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.
- package/CHANGES.md +20 -0
- package/LICENSE +1 -1
- package/README.md +0 -10
- package/dist/plugin/wavesurfer.cursor.js +4 -4
- package/dist/plugin/wavesurfer.cursor.js.map +1 -1
- package/dist/plugin/wavesurfer.cursor.min.js +2 -2
- package/dist/plugin/wavesurfer.cursor.min.js.map +1 -1
- package/dist/plugin/wavesurfer.elan.js +2 -2
- package/dist/plugin/wavesurfer.elan.js.map +1 -1
- package/dist/plugin/wavesurfer.elan.min.js +2 -2
- package/dist/plugin/wavesurfer.elan.min.js.map +1 -1
- package/dist/plugin/wavesurfer.markers.js +42 -7
- package/dist/plugin/wavesurfer.markers.js.map +1 -1
- package/dist/plugin/wavesurfer.markers.min.js +2 -2
- package/dist/plugin/wavesurfer.markers.min.js.map +1 -1
- package/dist/plugin/wavesurfer.mediasession.js +2 -2
- package/dist/plugin/wavesurfer.mediasession.js.map +1 -1
- package/dist/plugin/wavesurfer.mediasession.min.js +2 -2
- package/dist/plugin/wavesurfer.mediasession.min.js.map +1 -1
- package/dist/plugin/wavesurfer.microphone.js +2 -2
- package/dist/plugin/wavesurfer.microphone.js.map +1 -1
- package/dist/plugin/wavesurfer.microphone.min.js +2 -2
- package/dist/plugin/wavesurfer.microphone.min.js.map +1 -1
- package/dist/plugin/wavesurfer.minimap.js +2 -2
- package/dist/plugin/wavesurfer.minimap.js.map +1 -1
- package/dist/plugin/wavesurfer.minimap.min.js +2 -2
- package/dist/plugin/wavesurfer.minimap.min.js.map +1 -1
- package/dist/plugin/wavesurfer.playhead.js +2 -2
- package/dist/plugin/wavesurfer.playhead.js.map +1 -1
- package/dist/plugin/wavesurfer.playhead.min.js +2 -2
- package/dist/plugin/wavesurfer.playhead.min.js.map +1 -1
- package/dist/plugin/wavesurfer.regions.js +3 -3
- package/dist/plugin/wavesurfer.regions.js.map +1 -1
- package/dist/plugin/wavesurfer.regions.min.js +2 -2
- package/dist/plugin/wavesurfer.regions.min.js.map +1 -1
- package/dist/plugin/wavesurfer.spectrogram.js +15 -11
- package/dist/plugin/wavesurfer.spectrogram.js.map +1 -1
- package/dist/plugin/wavesurfer.spectrogram.min.js +2 -2
- package/dist/plugin/wavesurfer.spectrogram.min.js.map +1 -1
- package/dist/plugin/wavesurfer.timeline.js +2 -2
- package/dist/plugin/wavesurfer.timeline.js.map +1 -1
- package/dist/plugin/wavesurfer.timeline.min.js +2 -2
- package/dist/plugin/wavesurfer.timeline.min.js.map +1 -1
- package/dist/wavesurfer-html-init.js +2 -2
- package/dist/wavesurfer-html-init.js.map +1 -1
- package/dist/wavesurfer-html-init.min.js +2 -2
- package/dist/wavesurfer-html-init.min.js.map +1 -1
- package/dist/wavesurfer.js +34 -31
- package/dist/wavesurfer.js.map +1 -1
- package/dist/wavesurfer.min.js +2 -2
- package/dist/wavesurfer.min.js.map +1 -1
- package/package.json +18 -19
- package/src/drawer.multicanvas.js +4 -4
- package/src/plugin/cursor/index.js +2 -1
- package/src/plugin/markers/index.js +31 -5
- package/src/plugin/regions/index.js +1 -1
- package/src/plugin/spectrogram/index.js +13 -9
- package/src/wavesurfer.js +13 -9
package/CHANGES.md
CHANGED
|
@@ -1,6 +1,26 @@
|
|
|
1
1
|
wavesurfer.js changelog
|
|
2
2
|
=======================
|
|
3
3
|
|
|
4
|
+
6.3.0 (03.10.2022)
|
|
5
|
+
------------------
|
|
6
|
+
- Fix `barMinHeight` option not setting the minimum bar height properly (#2522)
|
|
7
|
+
- Regions plugin: restore support for one drag selection for all channels (#2529)
|
|
8
|
+
- Markers plugin:
|
|
9
|
+
- Add support for a context menu event on a marker (#2546)
|
|
10
|
+
- Spectrogram plugin: Make labels have position: absolute instead of fixed (#2542)
|
|
11
|
+
|
|
12
|
+
6.2.0 (16.05.2022)
|
|
13
|
+
------------------
|
|
14
|
+
- Fix `clientWidth` error in responsive mode (#2498)
|
|
15
|
+
- Cursor plugin:
|
|
16
|
+
- Fix `TypeError` when `showTime: undefined` (#2501)
|
|
17
|
+
- Spectrogram plugin:
|
|
18
|
+
- Fix to have consistent CSS height regardless of device pixel ratio (#2507)
|
|
19
|
+
- Added `height` configuration option to control CSS height of the view,
|
|
20
|
+
which will scale to fill
|
|
21
|
+
- Frequency label display is `fixed` instead of `absolute` to enable
|
|
22
|
+
consistent size on hi-dpi displays
|
|
23
|
+
|
|
4
24
|
6.1.0 (31.03.2022)
|
|
5
25
|
------------------
|
|
6
26
|
- Fix many calls to `setSinkId` resulting in no sound (#2481)
|
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -9,16 +9,6 @@ Interactive navigable audio visualization using Web Audio and Canvas.
|
|
|
9
9
|
|
|
10
10
|
See a [tutorial](https://wavesurfer-js.org/docs) and [examples](https://wavesurfer-js.org/examples) on [wavesurfer-js.org](https://wavesurfer-js.org).
|
|
11
11
|
|
|
12
|
-
## 10 years of wavesufer.js 🎉
|
|
13
|
-
Wavesufer.js was started in March 2012. To celebrate the 10-year anniversary of wavesufer.js, we created an NFT representing the initial commit to this repository.
|
|
14
|
-
|
|
15
|
-
If you're a company, or an individual, wishing to support the project, please consider buying this memorable commit.
|
|
16
|
-
|
|
17
|
-
|[<img alt="wavesufer.js NFT" src="https://lh3.googleusercontent.com/82rx4HORLYEodBBt13X6nZ2pdR-Ij25iRInmYuzCjjKU1uZ8NQmhaS-wB5u74qZlDShJlbEVTxUu8OodD8JdN79N7za4-AZfipT3=w600" width="300" />](https://opensea.io/assets/matic/0xE7ea2E2bE12C257d376400cB231D8eE51e972BD6/41246820351435245535444587687799096392219692760736652072803901002414398825025)|[Buy the first commit NFT 🎁](https://opensea.io/assets/matic/0xE7ea2E2bE12C257d376400cB231D8eE51e972BD6/41246820351435245535444587687799096392219692760736652072803901002414398825025)|
|
|
18
|
-
---|---|
|
|
19
|
-
|
|
20
|
-
The proceeds will go to the author and the current maintainer.
|
|
21
|
-
|
|
22
12
|
## Browser support
|
|
23
13
|
wavesurfer.js works only in [modern browsers supporting Web Audio](http://caniuse.com/audio-api).
|
|
24
14
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* wavesurfer.js cursor plugin 6.
|
|
2
|
+
* wavesurfer.js cursor plugin 6.3.0 (2022-10-03)
|
|
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"]["cursor"] = factory();
|
|
15
|
-
})(self,
|
|
15
|
+
})(self, () => {
|
|
16
16
|
return /******/ (() => { // webpackBootstrap
|
|
17
17
|
/******/ "use strict";
|
|
18
18
|
/******/ var __webpack_modules__ = ({
|
|
@@ -118,8 +118,8 @@ var CursorPlugin = /*#__PURE__*/function () {
|
|
|
118
118
|
|
|
119
119
|
var y = 0;
|
|
120
120
|
var x = _this.wrapper.scrollLeft + event.clientX - bbox.left;
|
|
121
|
-
|
|
122
|
-
var flip = bbox.right < event.clientX +
|
|
121
|
+
var displayTimeWidth = _this.displayTime ? _this.displayTime.getBoundingClientRect().width : 0;
|
|
122
|
+
var flip = bbox.right < event.clientX + displayTimeWidth;
|
|
123
123
|
|
|
124
124
|
if (_this.params.showTime && _this.params.followCursorY) {
|
|
125
125
|
// follow y-position of the mouse
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wavesurfer.cursor.js","mappings":";;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,+CAA+C;AAC/C,CAAC;AACD;;;;;;;;;;;;;;;;;;;;;;;;;ACVA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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GAAG,EAAlB,CAAR,EAA+BE,KAA/B,CAAqC,CAAC,CAAtC,CAFJ,EAE8C;AAC1C,SAAC,QAAQT,IAAI,CAACQ,KAAL,CAAYD,IAAI,GAAG,CAAR,GAAa,IAAxB,CAAT,EAAwCE,KAAxC,CAA8C,CAAC,CAA/C,CAHJ,CAGsD;AAHtD,UAIEC,IAJF,CAIO,GAJP,CADwB;AAAA,OAArB,CAAP;AAOH;;;;AAhSD;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACI,oBAAcpF,MAAd,EAAsB;AAClB,aAAO;AACHqF,QAAAA,IAAI,EAAE,QADH;AAEHC,QAAAA,SAAS,EAAEtF,MAAM,IAAIA,MAAM,CAACsF,SAAjB,GAA6BtF,MAAM,CAACsF,SAApC,GAAgD,KAFxD;AAGHtF,QAAAA,MAAM,EAAEA,MAHL;AAIHuF,QAAAA,WAAW,EAAE,EAJV;AAKHC,QAAAA,QAAQ,EAAEzF;AALP,OAAP;AAOH;AAED;AACJ;AACA;;;;;;;;;;;;;;UCrEA;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/cursor/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\"][\"cursor\"] = factory();\n})(self, function() {\nreturn ","/**\n * @typedef {Object} CursorPluginParams\n * @property {?boolean} deferInit Set to true to stop auto init in `addPlugin()`\n * @property {boolean} hideOnBlur=true Hide the cursor when the mouse leaves the\n * waveform\n * @property {string} width='1px' The width of the cursor\n * @property {string} color='black' The color of the cursor\n * @property {number|string} opacity='0.25' The opacity of the cursor\n * @property {string} style='solid' The border style of the cursor\n * @property {number} zIndex=3 The z-index of the cursor element\n * @property {object} customStyle An object with custom styles which are applied\n * to the cursor element\n * @property {boolean} showTime=false Show the time on the cursor.\n * @property {object} customShowTimeStyle An object with custom styles which are\n * applied to the cursor time element.\n * @property {boolean} followCursorY=false Use `true` to make the time on\n * the cursor follow the x and the y-position of the mouse. Use `false` to make the\n * it only follow the x-position of the mouse.\n * @property {function} formatTimeCallback Formats the timestamp on the cursor.\n */\n\n/**\n * Displays a thin line at the position of the cursor on the waveform.\n *\n * @implements {PluginClass}\n * @extends {Observer}\n * @example\n * // es6\n * import CursorPlugin from 'wavesurfer.cursor.js';\n *\n * // commonjs\n * var CursorPlugin = require('wavesurfer.cursor.js');\n *\n * // if you are using <script> tags\n * var CursorPlugin = window.WaveSurfer.cursor;\n *\n * // ... initialising wavesurfer with the plugin\n * var wavesurfer = WaveSurfer.create({\n * // wavesurfer options ...\n * plugins: [\n * CursorPlugin.create({\n * // plugin options ...\n * })\n * ]\n * });\n */\nexport default class CursorPlugin {\n /**\n * Cursor 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 {CursorPluginParams} params parameters use to initialise the\n * plugin\n * @return {PluginDefinition} an object representing the plugin\n */\n static create(params) {\n return {\n name: 'cursor',\n deferInit: params && params.deferInit ? params.deferInit : false,\n params: params,\n staticProps: {},\n instance: CursorPlugin\n };\n }\n\n /**\n * @type {CursorPluginParams}\n */\n defaultParams = {\n hideOnBlur: true,\n width: '1px',\n color: 'black',\n opacity: '0.25',\n style: 'solid',\n zIndex: 4,\n customStyle: {},\n customShowTimeStyle: {},\n showTime: false,\n followCursorY: false,\n formatTimeCallback: null\n };\n\n /**\n * @param {object} e Mouse move event\n */\n _onMousemove = e => {\n const event = this.util.withOrientation(e, this.wavesurfer.params.vertical);\n const bbox = this.wrapper.getBoundingClientRect();\n let y = 0;\n let x = this.wrapper.scrollLeft + event.clientX - bbox.left;\n let flip = bbox.right < event.clientX + this.displayTime.getBoundingClientRect().width;\n\n if (this.params.showTime && this.params.followCursorY) {\n // follow y-position of the mouse\n y = event.clientY - (bbox.top + bbox.height / 2);\n }\n\n this.updateCursorPosition(x, y, flip);\n };\n\n /**\n * @returns {void}\n */\n _onMouseenter = () => this.showCursor();\n\n /**\n * @returns {void}\n */\n _onMouseleave = () => this.hideCursor();\n\n /**\n * Construct the plugin class. You probably want to use `CursorPlugin.create`\n * instead.\n *\n * @param {CursorPluginParams} params Plugin parameters\n * @param {object} ws Wavesurfer instance\n */\n constructor(params, ws) {\n this.wavesurfer = ws;\n this.style = ws.util.style;\n this.util = ws.util;\n /**\n * The cursor HTML element\n *\n * @type {?HTMLElement}\n */\n this.cursor = null;\n /**\n * displays the time next to the cursor\n *\n * @type {?HTMLElement}\n */\n this.showTime = null;\n /**\n * The html container that will display the time\n *\n * @type {?HTMLElement}\n */\n this.displayTime = null;\n\n this.params = Object.assign({}, this.defaultParams, params);\n }\n\n _onReady() {\n this.wrapper = this.wavesurfer.drawer.wrapper;\n this.cursor = this.util.withOrientation(this.wrapper.appendChild(\n document.createElement('cursor'),\n ), this.wavesurfer.params.vertical);\n\n this.style(this.cursor,\n Object.assign(\n {\n position: 'absolute',\n zIndex: this.params.zIndex,\n left: 0,\n top: 0,\n bottom: 0,\n width: '0',\n display: 'flex',\n borderRightStyle: this.params.style,\n borderRightWidth: this.params.width,\n borderRightColor: this.params.color,\n opacity: this.params.opacity,\n pointerEvents: 'none'\n },\n this.params.customStyle\n )\n );\n\n if (this.params.showTime) {\n this.showTime = this.util.withOrientation(this.wrapper.appendChild(\n document.createElement('showTitle')\n ), this.wavesurfer.params.vertical);\n this.style(\n this.showTime,\n Object.assign(\n {\n position: 'absolute',\n zIndex: this.params.zIndex,\n left: 0,\n top: 0,\n bottom: 0,\n width: 'auto',\n display: 'flex',\n opacity: this.params.opacity,\n pointerEvents: 'none',\n height: '100%'\n },\n this.params.customStyle\n )\n );\n\n this.displayTime = this.util.withOrientation(this.showTime.appendChild(\n document.createElement('div'),\n ), this.wavesurfer.params.vertical);\n\n this.style(this.displayTime,\n Object.assign(\n {\n display: 'inline',\n pointerEvents: 'none',\n margin: 'auto',\n visibility: 'hidden' // initial value will be hidden just for measuring purpose\n },\n this.params.customShowTimeStyle\n )\n );\n\n // initial value to measure display width\n this.displayTime.innerHTML = this.formatTime(0);\n }\n\n this.wrapper.addEventListener('mousemove', this._onMousemove);\n if (this.params.hideOnBlur) {\n // ensure elements are hidden initially\n this.hideCursor();\n this.wrapper.addEventListener('mouseenter', this._onMouseenter);\n this.wrapper.addEventListener('mouseleave', this._onMouseleave);\n }\n }\n\n /**\n * Initialise the plugin (used by the Plugin API)\n */\n init() {\n if (this.wavesurfer.isReady) {\n this._onReady();\n } else {\n this.wavesurfer.once('ready', () => this._onReady());\n }\n }\n\n /**\n * Destroy the plugin (used by the Plugin API)\n */\n destroy() {\n if (this.params.showTime) {\n this.showTime.remove();\n }\n this.cursor.remove();\n this.wrapper.removeEventListener('mousemove', this._onMousemove);\n if (this.params.hideOnBlur) {\n this.wrapper.removeEventListener('mouseenter', this._onMouseenter);\n this.wrapper.removeEventListener('mouseleave', this._onMouseleave);\n }\n }\n\n /**\n * Update the cursor position\n *\n * @param {number} xpos The x offset of the cursor in pixels\n * @param {number} ypos The y offset of the cursor in pixels\n * @param {boolean} flip Flag to flip duration text from right to left\n */\n updateCursorPosition(xpos, ypos, flip = false) {\n this.style(this.cursor, {\n left: `${xpos}px`\n });\n if (this.params.showTime) {\n const duration = this.wavesurfer.getDuration();\n const elementWidth =\n this.wavesurfer.drawer.width /\n this.wavesurfer.params.pixelRatio;\n const scrollWidth = this.wavesurfer.drawer.getScrollX();\n\n const scrollTime =\n (duration / this.wavesurfer.drawer.width) * scrollWidth;\n\n const timeValue =\n Math.max(0, ((xpos - this.wrapper.scrollLeft) / elementWidth) * duration) + scrollTime;\n const formatValue = this.formatTime(timeValue);\n if (flip) {\n const textOffset = this.displayTime.getBoundingClientRect().width;\n xpos -= textOffset;\n }\n this.style(this.showTime, {\n left: `${xpos}px`,\n top: `${ypos}px`\n });\n this.style(this.displayTime, {\n visibility: 'visible'\n });\n this.displayTime.innerHTML = `${formatValue}`;\n }\n }\n\n /**\n * Show the cursor\n */\n showCursor() {\n this.style(this.cursor, {\n display: 'flex'\n });\n if (this.params.showTime) {\n this.style(this.showTime, {\n display: 'flex'\n });\n }\n }\n\n /**\n * Hide the cursor\n */\n hideCursor() {\n this.style(this.cursor, {\n display: 'none'\n });\n if (this.params.showTime) {\n this.style(this.showTime, {\n display: 'none'\n });\n }\n }\n\n /**\n * Format the timestamp for `cursorTime`.\n *\n * @param {number} cursorTime Time in seconds\n * @returns {string} Formatted timestamp\n */\n formatTime(cursorTime) {\n cursorTime = isNaN(cursorTime) ? 0 : cursorTime;\n\n if (this.params.formatTimeCallback) {\n return this.params.formatTimeCallback(cursorTime);\n }\n return [cursorTime].map(time =>\n [\n Math.floor((time % 3600) / 60), // minutes\n ('00' + Math.floor(time % 60)).slice(-2), // seconds\n ('000' + Math.floor((time % 1) * 1000)).slice(-3) // milliseconds\n ].join(':')\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/cursor/index.js\");\n",""],"names":["CursorPlugin","params","ws","hideOnBlur","width","color","opacity","style","zIndex","customStyle","customShowTimeStyle","showTime","followCursorY","formatTimeCallback","e","event","util","withOrientation","wavesurfer","vertical","bbox","wrapper","getBoundingClientRect","y","x","scrollLeft","clientX","left","flip","right","displayTime","clientY","top","height","updateCursorPosition","showCursor","hideCursor","cursor","Object","assign","defaultParams","drawer","appendChild","document","createElement","position","bottom","display","borderRightStyle","borderRightWidth","borderRightColor","pointerEvents","margin","visibility","innerHTML","formatTime","addEventListener","_onMousemove","_onMouseenter","_onMouseleave","isReady","_onReady","once","remove","removeEventListener","xpos","ypos","duration","getDuration","elementWidth","pixelRatio","scrollWidth","getScrollX","scrollTime","timeValue","Math","max","formatValue","textOffset","cursorTime","isNaN","map","time","floor","slice","join","name","deferInit","staticProps","instance"],"sourceRoot":""}
|
|
1
|
+
{"version":3,"file":"wavesurfer.cursor.js","mappings":";;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,+CAA+C;AAC/C,CAAC;AACD;;;;;;;;;;;;;;;;;;;;;;;;;ACVA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;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;EAmEjB;AACJ;AACA;AACA;AACA;AACA;AACA;EACI,sBAAYC,MAAZ,EAAoBC,EAApB,EAAwB;IAAA;;IAAA;;IAAA,uCAlDR;MACZC,UAAU,EAAE,IADA;MAEZC,KAAK,EAAE,KAFK;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wF,WAAW,EAAE,EAJV;QAKHC,QAAQ,EAAE1F;MALP,CAAP;IAOH;IAED;AACJ;AACA;;;;;;;;;;;;;;UCrEA;UACA;;UAEA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;;UAEA;UACA;;UAEA;UACA;UACA;;;;UEtBA;UACA;UACA;UACA","sources":["webpack://WaveSurfer/webpack/universalModuleDefinition","webpack://WaveSurfer/./src/plugin/cursor/index.js","webpack://WaveSurfer/webpack/bootstrap","webpack://WaveSurfer/webpack/before-startup","webpack://WaveSurfer/webpack/startup","webpack://WaveSurfer/webpack/after-startup"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"WaveSurfer\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"WaveSurfer\"] = factory();\n\telse\n\t\troot[\"WaveSurfer\"] = root[\"WaveSurfer\"] || {}, root[\"WaveSurfer\"][\"cursor\"] = factory();\n})(self, () => {\nreturn ","/**\n * @typedef {Object} CursorPluginParams\n * @property {?boolean} deferInit Set to true to stop auto init in `addPlugin()`\n * @property {boolean} hideOnBlur=true Hide the cursor when the mouse leaves the\n * waveform\n * @property {string} width='1px' The width of the cursor\n * @property {string} color='black' The color of the cursor\n * @property {number|string} opacity='0.25' The opacity of the cursor\n * @property {string} style='solid' The border style of the cursor\n * @property {number} zIndex=3 The z-index of the cursor element\n * @property {object} customStyle An object with custom styles which are applied\n * to the cursor element\n * @property {boolean} showTime=false Show the time on the cursor.\n * @property {object} customShowTimeStyle An object with custom styles which are\n * applied to the cursor time element.\n * @property {boolean} followCursorY=false Use `true` to make the time on\n * the cursor follow the x and the y-position of the mouse. Use `false` to make the\n * it only follow the x-position of the mouse.\n * @property {function} formatTimeCallback Formats the timestamp on the cursor.\n */\n\n/**\n * Displays a thin line at the position of the cursor on the waveform.\n *\n * @implements {PluginClass}\n * @extends {Observer}\n * @example\n * // es6\n * import CursorPlugin from 'wavesurfer.cursor.js';\n *\n * // commonjs\n * var CursorPlugin = require('wavesurfer.cursor.js');\n *\n * // if you are using <script> tags\n * var CursorPlugin = window.WaveSurfer.cursor;\n *\n * // ... initialising wavesurfer with the plugin\n * var wavesurfer = WaveSurfer.create({\n * // wavesurfer options ...\n * plugins: [\n * CursorPlugin.create({\n * // plugin options ...\n * })\n * ]\n * });\n */\nexport default class CursorPlugin {\n /**\n * Cursor 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 {CursorPluginParams} params parameters use to initialise the\n * plugin\n * @return {PluginDefinition} an object representing the plugin\n */\n static create(params) {\n return {\n name: 'cursor',\n deferInit: params && params.deferInit ? params.deferInit : false,\n params: params,\n staticProps: {},\n instance: CursorPlugin\n };\n }\n\n /**\n * @type {CursorPluginParams}\n */\n defaultParams = {\n hideOnBlur: true,\n width: '1px',\n color: 'black',\n opacity: '0.25',\n style: 'solid',\n zIndex: 4,\n customStyle: {},\n customShowTimeStyle: {},\n showTime: false,\n followCursorY: false,\n formatTimeCallback: null\n };\n\n /**\n * @param {object} e Mouse move event\n */\n _onMousemove = e => {\n const event = this.util.withOrientation(e, this.wavesurfer.params.vertical);\n const bbox = this.wrapper.getBoundingClientRect();\n let y = 0;\n let x = this.wrapper.scrollLeft + event.clientX - bbox.left;\n const displayTimeWidth = this.displayTime ? this.displayTime.getBoundingClientRect().width : 0;\n let flip = bbox.right < event.clientX + displayTimeWidth;\n\n if (this.params.showTime && this.params.followCursorY) {\n // follow y-position of the mouse\n y = event.clientY - (bbox.top + bbox.height / 2);\n }\n\n this.updateCursorPosition(x, y, flip);\n };\n\n /**\n * @returns {void}\n */\n _onMouseenter = () => this.showCursor();\n\n /**\n * @returns {void}\n */\n _onMouseleave = () => this.hideCursor();\n\n /**\n * Construct the plugin class. You probably want to use `CursorPlugin.create`\n * instead.\n *\n * @param {CursorPluginParams} params Plugin parameters\n * @param {object} ws Wavesurfer instance\n */\n constructor(params, ws) {\n this.wavesurfer = ws;\n this.style = ws.util.style;\n this.util = ws.util;\n /**\n * The cursor HTML element\n *\n * @type {?HTMLElement}\n */\n this.cursor = null;\n /**\n * displays the time next to the cursor\n *\n * @type {?HTMLElement}\n */\n this.showTime = null;\n /**\n * The html container that will display the time\n *\n * @type {?HTMLElement}\n */\n this.displayTime = null;\n\n this.params = Object.assign({}, this.defaultParams, params);\n }\n\n _onReady() {\n this.wrapper = this.wavesurfer.drawer.wrapper;\n this.cursor = this.util.withOrientation(this.wrapper.appendChild(\n document.createElement('cursor'),\n ), this.wavesurfer.params.vertical);\n\n this.style(this.cursor,\n Object.assign(\n {\n position: 'absolute',\n zIndex: this.params.zIndex,\n left: 0,\n top: 0,\n bottom: 0,\n width: '0',\n display: 'flex',\n borderRightStyle: this.params.style,\n borderRightWidth: this.params.width,\n borderRightColor: this.params.color,\n opacity: this.params.opacity,\n pointerEvents: 'none'\n },\n this.params.customStyle\n )\n );\n\n if (this.params.showTime) {\n this.showTime = this.util.withOrientation(this.wrapper.appendChild(\n document.createElement('showTitle')\n ), this.wavesurfer.params.vertical);\n this.style(\n this.showTime,\n Object.assign(\n {\n position: 'absolute',\n zIndex: this.params.zIndex,\n left: 0,\n top: 0,\n bottom: 0,\n width: 'auto',\n display: 'flex',\n opacity: this.params.opacity,\n pointerEvents: 'none',\n height: '100%'\n },\n this.params.customStyle\n )\n );\n\n this.displayTime = this.util.withOrientation(this.showTime.appendChild(\n document.createElement('div'),\n ), this.wavesurfer.params.vertical);\n\n this.style(this.displayTime,\n Object.assign(\n {\n display: 'inline',\n pointerEvents: 'none',\n margin: 'auto',\n visibility: 'hidden' // initial value will be hidden just for measuring purpose\n },\n this.params.customShowTimeStyle\n )\n );\n\n // initial value to measure display width\n this.displayTime.innerHTML = this.formatTime(0);\n }\n\n this.wrapper.addEventListener('mousemove', this._onMousemove);\n if (this.params.hideOnBlur) {\n // ensure elements are hidden initially\n this.hideCursor();\n this.wrapper.addEventListener('mouseenter', this._onMouseenter);\n this.wrapper.addEventListener('mouseleave', this._onMouseleave);\n }\n }\n\n /**\n * Initialise the plugin (used by the Plugin API)\n */\n init() {\n if (this.wavesurfer.isReady) {\n this._onReady();\n } else {\n this.wavesurfer.once('ready', () => this._onReady());\n }\n }\n\n /**\n * Destroy the plugin (used by the Plugin API)\n */\n destroy() {\n if (this.params.showTime) {\n this.showTime.remove();\n }\n this.cursor.remove();\n this.wrapper.removeEventListener('mousemove', this._onMousemove);\n if (this.params.hideOnBlur) {\n this.wrapper.removeEventListener('mouseenter', this._onMouseenter);\n this.wrapper.removeEventListener('mouseleave', this._onMouseleave);\n }\n }\n\n /**\n * Update the cursor position\n *\n * @param {number} xpos The x offset of the cursor in pixels\n * @param {number} ypos The y offset of the cursor in pixels\n * @param {boolean} flip Flag to flip duration text from right to left\n */\n updateCursorPosition(xpos, ypos, flip = false) {\n this.style(this.cursor, {\n left: `${xpos}px`\n });\n if (this.params.showTime) {\n const duration = this.wavesurfer.getDuration();\n const elementWidth =\n this.wavesurfer.drawer.width /\n this.wavesurfer.params.pixelRatio;\n const scrollWidth = this.wavesurfer.drawer.getScrollX();\n\n const scrollTime =\n (duration / this.wavesurfer.drawer.width) * scrollWidth;\n\n const timeValue =\n Math.max(0, ((xpos - this.wrapper.scrollLeft) / elementWidth) * duration) + scrollTime;\n const formatValue = this.formatTime(timeValue);\n if (flip) {\n const textOffset = this.displayTime.getBoundingClientRect().width;\n xpos -= textOffset;\n }\n this.style(this.showTime, {\n left: `${xpos}px`,\n top: `${ypos}px`\n });\n this.style(this.displayTime, {\n visibility: 'visible'\n });\n this.displayTime.innerHTML = `${formatValue}`;\n }\n }\n\n /**\n * Show the cursor\n */\n showCursor() {\n this.style(this.cursor, {\n display: 'flex'\n });\n if (this.params.showTime) {\n this.style(this.showTime, {\n display: 'flex'\n });\n }\n }\n\n /**\n * Hide the cursor\n */\n hideCursor() {\n this.style(this.cursor, {\n display: 'none'\n });\n if (this.params.showTime) {\n this.style(this.showTime, {\n display: 'none'\n });\n }\n }\n\n /**\n * Format the timestamp for `cursorTime`.\n *\n * @param {number} cursorTime Time in seconds\n * @returns {string} Formatted timestamp\n */\n formatTime(cursorTime) {\n cursorTime = isNaN(cursorTime) ? 0 : cursorTime;\n\n if (this.params.formatTimeCallback) {\n return this.params.formatTimeCallback(cursorTime);\n }\n return [cursorTime].map(time =>\n [\n Math.floor((time % 3600) / 60), // minutes\n ('00' + Math.floor(time % 60)).slice(-2), // seconds\n ('000' + Math.floor((time % 1) * 1000)).slice(-3) // milliseconds\n ].join(':')\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/cursor/index.js\");\n",""],"names":["CursorPlugin","params","ws","hideOnBlur","width","color","opacity","style","zIndex","customStyle","customShowTimeStyle","showTime","followCursorY","formatTimeCallback","e","event","util","withOrientation","wavesurfer","vertical","bbox","wrapper","getBoundingClientRect","y","x","scrollLeft","clientX","left","displayTimeWidth","displayTime","flip","right","clientY","top","height","updateCursorPosition","showCursor","hideCursor","cursor","Object","assign","defaultParams","drawer","appendChild","document","createElement","position","bottom","display","borderRightStyle","borderRightWidth","borderRightColor","pointerEvents","margin","visibility","innerHTML","formatTime","addEventListener","_onMousemove","_onMouseenter","_onMouseleave","isReady","_onReady","once","remove","removeEventListener","xpos","ypos","duration","getDuration","elementWidth","pixelRatio","scrollWidth","getScrollX","scrollTime","timeValue","Math","max","formatValue","textOffset","cursorTime","isNaN","map","time","floor","slice","join","name","deferInit","staticProps","instance"],"sourceRoot":""}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* wavesurfer.js cursor plugin 6.
|
|
2
|
+
* wavesurfer.js cursor plugin 6.3.0 (2022-10-03)
|
|
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.cursor=t())}(self,(
|
|
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.cursor=t())}(self,(()=>(()=>{"use strict";var e={178:(e,t)=>{function i(e,t){for(var i=0;i<t.length;i++){var s=t[i];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,s.key,s)}}function s(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r=function(){function e(t,i){var r=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),s(this,"defaultParams",{hideOnBlur:!0,width:"1px",color:"black",opacity:"0.25",style:"solid",zIndex:4,customStyle:{},customShowTimeStyle:{},showTime:!1,followCursorY:!1,formatTimeCallback:null}),s(this,"_onMousemove",(function(e){var t=r.util.withOrientation(e,r.wavesurfer.params.vertical),i=r.wrapper.getBoundingClientRect(),s=0,a=r.wrapper.scrollLeft+t.clientX-i.left,o=r.displayTime?r.displayTime.getBoundingClientRect().width:0,n=i.right<t.clientX+o;r.params.showTime&&r.params.followCursorY&&(s=t.clientY-(i.top+i.height/2)),r.updateCursorPosition(a,s,n)})),s(this,"_onMouseenter",(function(){return r.showCursor()})),s(this,"_onMouseleave",(function(){return r.hideCursor()})),this.wavesurfer=i,this.style=i.util.style,this.util=i.util,this.cursor=null,this.showTime=null,this.displayTime=null,this.params=Object.assign({},this.defaultParams,t)}var t,r,a;return t=e,r=[{key:"_onReady",value:function(){this.wrapper=this.wavesurfer.drawer.wrapper,this.cursor=this.util.withOrientation(this.wrapper.appendChild(document.createElement("cursor")),this.wavesurfer.params.vertical),this.style(this.cursor,Object.assign({position:"absolute",zIndex:this.params.zIndex,left:0,top:0,bottom:0,width:"0",display:"flex",borderRightStyle:this.params.style,borderRightWidth:this.params.width,borderRightColor:this.params.color,opacity:this.params.opacity,pointerEvents:"none"},this.params.customStyle)),this.params.showTime&&(this.showTime=this.util.withOrientation(this.wrapper.appendChild(document.createElement("showTitle")),this.wavesurfer.params.vertical),this.style(this.showTime,Object.assign({position:"absolute",zIndex:this.params.zIndex,left:0,top:0,bottom:0,width:"auto",display:"flex",opacity:this.params.opacity,pointerEvents:"none",height:"100%"},this.params.customStyle)),this.displayTime=this.util.withOrientation(this.showTime.appendChild(document.createElement("div")),this.wavesurfer.params.vertical),this.style(this.displayTime,Object.assign({display:"inline",pointerEvents:"none",margin:"auto",visibility:"hidden"},this.params.customShowTimeStyle)),this.displayTime.innerHTML=this.formatTime(0)),this.wrapper.addEventListener("mousemove",this._onMousemove),this.params.hideOnBlur&&(this.hideCursor(),this.wrapper.addEventListener("mouseenter",this._onMouseenter),this.wrapper.addEventListener("mouseleave",this._onMouseleave))}},{key:"init",value:function(){var e=this;this.wavesurfer.isReady?this._onReady():this.wavesurfer.once("ready",(function(){return e._onReady()}))}},{key:"destroy",value:function(){this.params.showTime&&this.showTime.remove(),this.cursor.remove(),this.wrapper.removeEventListener("mousemove",this._onMousemove),this.params.hideOnBlur&&(this.wrapper.removeEventListener("mouseenter",this._onMouseenter),this.wrapper.removeEventListener("mouseleave",this._onMouseleave))}},{key:"updateCursorPosition",value:function(e,t){var i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(this.style(this.cursor,{left:"".concat(e,"px")}),this.params.showTime){var s=this.wavesurfer.getDuration(),r=this.wavesurfer.drawer.width/this.wavesurfer.params.pixelRatio,a=this.wavesurfer.drawer.getScrollX(),o=s/this.wavesurfer.drawer.width*a,n=Math.max(0,(e-this.wrapper.scrollLeft)/r*s)+o,h=this.formatTime(n);if(i){var l=this.displayTime.getBoundingClientRect().width;e-=l}this.style(this.showTime,{left:"".concat(e,"px"),top:"".concat(t,"px")}),this.style(this.displayTime,{visibility:"visible"}),this.displayTime.innerHTML="".concat(h)}}},{key:"showCursor",value:function(){this.style(this.cursor,{display:"flex"}),this.params.showTime&&this.style(this.showTime,{display:"flex"})}},{key:"hideCursor",value:function(){this.style(this.cursor,{display:"none"}),this.params.showTime&&this.style(this.showTime,{display:"none"})}},{key:"formatTime",value:function(e){return e=isNaN(e)?0:e,this.params.formatTimeCallback?this.params.formatTimeCallback(e):[e].map((function(e){return[Math.floor(e%3600/60),("00"+Math.floor(e%60)).slice(-2),("000"+Math.floor(e%1*1e3)).slice(-3)].join(":")}))}}],a=[{key:"create",value:function(t){return{name:"cursor",deferInit:!(!t||!t.deferInit)&&t.deferInit,params:t,staticProps:{},instance:e}}}],r&&i(t.prototype,r),a&&i(t,a),Object.defineProperty(t,"prototype",{writable:!1}),e}();t.default=r,e.exports=t.default}},t={};var i=function i(s){var r=t[s];if(void 0!==r)return r.exports;var a=t[s]={exports:{}};return e[s](a,a.exports,i),a.exports}(178);return i})()));
|
|
7
7
|
//# sourceMappingURL=wavesurfer.cursor.min.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wavesurfer.cursor.min.js","mappings":";;;;;CAAA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AK9B,MAAM8B,KAAKC,OAAQ,CACpBU,QAAS,SAETX,KAAKpC,OAAOU,UACZ0B,KAAK9B,MAAM8B,KAAK1B,SAAU,CACtBqC,QAAS,W,wBAQrB,WACIX,KAAK9B,MAAM8B,KAAKC,OAAQ,CACpBU,QAAS,SAETX,KAAKpC,OAAOU,UACZ0B,KAAK9B,MAAM8B,KAAK1B,SAAU,CACtBqC,QAAS,W,wBAWrB,SAAWgC,GAGP,OAFAA,EAAaC,MAAMD,GAAc,EAAIA,EAEjC3C,KAAKpC,OAAOY,mBACLwB,KAAKpC,OAAOY,mBAAmBmE,GAEnC,CAACA,GAAYE,KAAI,SAAAC,GAAI,MACxB,CACIP,KAAKQ,MAAOD,EAAO,KAAQ,KAC1B,KAAOP,KAAKQ,MAAMD,EAAO,KAAKE,OAAO,IACrC,MAAQT,KAAKQ,MAAOD,EAAO,EAAK,MAAOE,OAAO,IACjDC,KAAK,W,uBApRf,SAAcrF,GACV,MAAO,CACHsF,KAAM,SACNC,aAAWvF,IAAUA,EAAOuF,YAAYvF,EAAOuF,UAC/CvF,OAAQA,EACRwF,YAAa,GACbC,SAAU1F,M,mFAjBDA,G,kCC7CjB2F,EAA2B,GCE/B,IAAIC,EDCJ,SAASC,EAAoBC,GAE5B,IAAIC,EAAeJ,EAAyBG,GAC5C,QAAqBE,IAAjBD,EACH,OAAOA,EAAapG,QAGrB,IAAIC,EAAS+F,EAAyBG,GAAY,CAGjDnG,QAAS,IAOV,OAHAsG,EAAoBH,GAAUlG,EAAQA,EAAOD,QAASkG,GAG/CjG,EAAOD,QClBWkG,CAAoB,K,UHO9C","sources":["webpack://WaveSurfer.[name]/webpack/universalModuleDefinition","webpack://WaveSurfer.[name]/./src/plugin/cursor/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\"][\"cursor\"] = factory();\n})(self, function() {\nreturn ","/**\n * @typedef {Object} CursorPluginParams\n * @property {?boolean} deferInit Set to true to stop auto init in `addPlugin()`\n * @property {boolean} hideOnBlur=true Hide the cursor when the mouse leaves the\n * waveform\n * @property {string} width='1px' The width of the cursor\n * @property {string} color='black' The color of the cursor\n * @property {number|string} opacity='0.25' The opacity of the cursor\n * @property {string} style='solid' The border style of the cursor\n * @property {number} zIndex=3 The z-index of the cursor element\n * @property {object} customStyle An object with custom styles which are applied\n * to the cursor element\n * @property {boolean} showTime=false Show the time on the cursor.\n * @property {object} customShowTimeStyle An object with custom styles which are\n * applied to the cursor time element.\n * @property {boolean} followCursorY=false Use `true` to make the time on\n * the cursor follow the x and the y-position of the mouse. Use `false` to make the\n * it only follow the x-position of the mouse.\n * @property {function} formatTimeCallback Formats the timestamp on the cursor.\n */\n\n/**\n * Displays a thin line at the position of the cursor on the waveform.\n *\n * @implements {PluginClass}\n * @extends {Observer}\n * @example\n * // es6\n * import CursorPlugin from 'wavesurfer.cursor.js';\n *\n * // commonjs\n * var CursorPlugin = require('wavesurfer.cursor.js');\n *\n * // if you are using <script> tags\n * var CursorPlugin = window.WaveSurfer.cursor;\n *\n * // ... initialising wavesurfer with the plugin\n * var wavesurfer = WaveSurfer.create({\n * // wavesurfer options ...\n * plugins: [\n * CursorPlugin.create({\n * // plugin options ...\n * })\n * ]\n * });\n */\nexport default class CursorPlugin {\n /**\n * Cursor 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 {CursorPluginParams} params parameters use to initialise the\n * plugin\n * @return {PluginDefinition} an object representing the plugin\n */\n static create(params) {\n return {\n name: 'cursor',\n deferInit: params && params.deferInit ? params.deferInit : false,\n params: params,\n staticProps: {},\n instance: CursorPlugin\n };\n }\n\n /**\n * @type {CursorPluginParams}\n */\n defaultParams = {\n hideOnBlur: true,\n width: '1px',\n color: 'black',\n opacity: '0.25',\n style: 'solid',\n zIndex: 4,\n customStyle: {},\n customShowTimeStyle: {},\n showTime: false,\n followCursorY: false,\n formatTimeCallback: null\n };\n\n /**\n * @param {object} e Mouse move event\n */\n _onMousemove = e => {\n const event = this.util.withOrientation(e, this.wavesurfer.params.vertical);\n const bbox = this.wrapper.getBoundingClientRect();\n let y = 0;\n let x = this.wrapper.scrollLeft + event.clientX - bbox.left;\n let flip = bbox.right < event.clientX + this.displayTime.getBoundingClientRect().width;\n\n if (this.params.showTime && this.params.followCursorY) {\n // follow y-position of the mouse\n y = event.clientY - (bbox.top + bbox.height / 2);\n }\n\n this.updateCursorPosition(x, y, flip);\n };\n\n /**\n * @returns {void}\n */\n _onMouseenter = () => this.showCursor();\n\n /**\n * @returns {void}\n */\n _onMouseleave = () => this.hideCursor();\n\n /**\n * Construct the plugin class. You probably want to use `CursorPlugin.create`\n * instead.\n *\n * @param {CursorPluginParams} params Plugin parameters\n * @param {object} ws Wavesurfer instance\n */\n constructor(params, ws) {\n this.wavesurfer = ws;\n this.style = ws.util.style;\n this.util = ws.util;\n /**\n * The cursor HTML element\n *\n * @type {?HTMLElement}\n */\n this.cursor = null;\n /**\n * displays the time next to the cursor\n *\n * @type {?HTMLElement}\n */\n this.showTime = null;\n /**\n * The html container that will display the time\n *\n * @type {?HTMLElement}\n */\n this.displayTime = null;\n\n this.params = Object.assign({}, this.defaultParams, params);\n }\n\n _onReady() {\n this.wrapper = this.wavesurfer.drawer.wrapper;\n this.cursor = this.util.withOrientation(this.wrapper.appendChild(\n document.createElement('cursor'),\n ), this.wavesurfer.params.vertical);\n\n this.style(this.cursor,\n Object.assign(\n {\n position: 'absolute',\n zIndex: this.params.zIndex,\n left: 0,\n top: 0,\n bottom: 0,\n width: '0',\n display: 'flex',\n borderRightStyle: this.params.style,\n borderRightWidth: this.params.width,\n borderRightColor: this.params.color,\n opacity: this.params.opacity,\n pointerEvents: 'none'\n },\n this.params.customStyle\n )\n );\n\n if (this.params.showTime) {\n this.showTime = this.util.withOrientation(this.wrapper.appendChild(\n document.createElement('showTitle')\n ), this.wavesurfer.params.vertical);\n this.style(\n this.showTime,\n Object.assign(\n {\n position: 'absolute',\n zIndex: this.params.zIndex,\n left: 0,\n top: 0,\n bottom: 0,\n width: 'auto',\n display: 'flex',\n opacity: this.params.opacity,\n pointerEvents: 'none',\n height: '100%'\n },\n this.params.customStyle\n )\n );\n\n this.displayTime = this.util.withOrientation(this.showTime.appendChild(\n document.createElement('div'),\n ), this.wavesurfer.params.vertical);\n\n this.style(this.displayTime,\n Object.assign(\n {\n display: 'inline',\n pointerEvents: 'none',\n margin: 'auto',\n visibility: 'hidden' // initial value will be hidden just for measuring purpose\n },\n this.params.customShowTimeStyle\n )\n );\n\n // initial value to measure display width\n this.displayTime.innerHTML = this.formatTime(0);\n }\n\n this.wrapper.addEventListener('mousemove', this._onMousemove);\n if (this.params.hideOnBlur) {\n // ensure elements are hidden initially\n this.hideCursor();\n this.wrapper.addEventListener('mouseenter', this._onMouseenter);\n this.wrapper.addEventListener('mouseleave', this._onMouseleave);\n }\n }\n\n /**\n * Initialise the plugin (used by the Plugin API)\n */\n init() {\n if (this.wavesurfer.isReady) {\n this._onReady();\n } else {\n this.wavesurfer.once('ready', () => this._onReady());\n }\n }\n\n /**\n * Destroy the plugin (used by the Plugin API)\n */\n destroy() {\n if (this.params.showTime) {\n this.showTime.remove();\n }\n this.cursor.remove();\n this.wrapper.removeEventListener('mousemove', this._onMousemove);\n if (this.params.hideOnBlur) {\n this.wrapper.removeEventListener('mouseenter', this._onMouseenter);\n this.wrapper.removeEventListener('mouseleave', this._onMouseleave);\n }\n }\n\n /**\n * Update the cursor position\n *\n * @param {number} xpos The x offset of the cursor in pixels\n * @param {number} ypos The y offset of the cursor in pixels\n * @param {boolean} flip Flag to flip duration text from right to left\n */\n updateCursorPosition(xpos, ypos, flip = false) {\n this.style(this.cursor, {\n left: `${xpos}px`\n });\n if (this.params.showTime) {\n const duration = this.wavesurfer.getDuration();\n const elementWidth =\n this.wavesurfer.drawer.width /\n this.wavesurfer.params.pixelRatio;\n const scrollWidth = this.wavesurfer.drawer.getScrollX();\n\n const scrollTime =\n (duration / this.wavesurfer.drawer.width) * scrollWidth;\n\n const timeValue =\n Math.max(0, ((xpos - this.wrapper.scrollLeft) / elementWidth) * duration) + scrollTime;\n const formatValue = this.formatTime(timeValue);\n if (flip) {\n const textOffset = this.displayTime.getBoundingClientRect().width;\n xpos -= textOffset;\n }\n this.style(this.showTime, {\n left: `${xpos}px`,\n top: `${ypos}px`\n });\n this.style(this.displayTime, {\n visibility: 'visible'\n });\n this.displayTime.innerHTML = `${formatValue}`;\n }\n }\n\n /**\n * Show the cursor\n */\n showCursor() {\n this.style(this.cursor, {\n display: 'flex'\n });\n if (this.params.showTime) {\n this.style(this.showTime, {\n display: 'flex'\n });\n }\n }\n\n /**\n * Hide the cursor\n */\n hideCursor() {\n this.style(this.cursor, {\n display: 'none'\n });\n if (this.params.showTime) {\n this.style(this.showTime, {\n display: 'none'\n });\n }\n }\n\n /**\n * Format the timestamp for `cursorTime`.\n *\n * @param {number} cursorTime Time in seconds\n * @returns {string} Formatted timestamp\n */\n formatTime(cursorTime) {\n cursorTime = isNaN(cursorTime) ? 0 : cursorTime;\n\n if (this.params.formatTimeCallback) {\n return this.params.formatTimeCallback(cursorTime);\n }\n return [cursorTime].map(time =>\n [\n Math.floor((time % 3600) / 60), // minutes\n ('00' + Math.floor(time % 60)).slice(-2), // seconds\n ('000' + Math.floor((time % 1) * 1000)).slice(-3) // milliseconds\n ].join(':')\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__(178);\n"],"names":["root","factory","exports","module","define","amd","self","CursorPlugin","params","ws","hideOnBlur","width","color","opacity","style","zIndex","customStyle","customShowTimeStyle","showTime","followCursorY","formatTimeCallback","e","event","util","withOrientation","wavesurfer","vertical","bbox","wrapper","getBoundingClientRect","y","x","scrollLeft","clientX","left","flip","right","displayTime","clientY","top","height","updateCursorPosition","showCursor","hideCursor","this","cursor","Object","assign","defaultParams","drawer","appendChild","document","createElement","position","bottom","display","borderRightStyle","borderRightWidth","borderRightColor","pointerEvents","margin","visibility","innerHTML","formatTime","addEventListener","_onMousemove","_onMouseenter","_onMouseleave","isReady","_onReady","once","remove","removeEventListener","xpos","ypos","duration","getDuration","elementWidth","pixelRatio","scrollWidth","getScrollX","scrollTime","timeValue","Math","max","formatValue","textOffset","cursorTime","isNaN","map","time","floor","slice","join","name","deferInit","staticProps","instance","__webpack_module_cache__","__webpack_exports__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__"],"sourceRoot":""}
|
|
1
|
+
{"version":3,"file":"wavesurfer.cursor.min.js","mappings":";;;;;CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,aAAc,GAAIH,GACC,iBAAZC,QACdA,QAAoB,WAAID,KAExBD,EAAiB,WAAIA,EAAiB,YAAK,CAAC,EAAGA,EAAiB,WAAU,OAAIC,IAC/E,CATD,CASGK,MAAM,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WACIX,KAAK/B,MAAM+B,KAAKC,OAAQ,CACpBU,QAAS,SAETX,KAAKrC,OAAOU,UACZ2B,KAAK/B,MAAM+B,KAAK3B,SAAU,CACtBsC,QAAS,QAGpB,G,wBAQD,SAAWgC,GAGP,OAFAA,EAAaC,MAAMD,GAAc,EAAIA,EAEjC3C,KAAKrC,OAAOY,mBACLyB,KAAKrC,OAAOY,mBAAmBoE,GAEnC,CAACA,GAAYE,KAAI,SAAAC,GAAI,MACxB,CACIP,KAAKQ,MAAOD,EAAO,KAAQ,KAC1B,KAAOP,KAAKQ,MAAMD,EAAO,KAAKE,OAAO,IACrC,MAAQT,KAAKQ,MAAOD,EAAO,EAAK,MAAOE,OAAO,IACjDC,KAAK,IALiB,GAO/B,I,uBAvRD,SAActF,GACV,MAAO,CACHuF,KAAM,SACNC,aAAWxF,IAAUA,EAAOwF,YAAYxF,EAAOwF,UAC/CxF,OAAQA,EACRyF,YAAa,CAAC,EACdC,SAAU3F,EAEjB,I,mFAnBgBA,G,kCC7CjB4F,EAA2B,CAAC,ECEhC,IAAIC,EDCJ,SAASC,EAAoBC,GAE5B,IAAIC,EAAeJ,EAAyBG,GAC5C,QAAqBE,IAAjBD,EACH,OAAOA,EAAarG,QAGrB,IAAIC,EAASgG,EAAyBG,GAAY,CAGjDpG,QAAS,CAAC,GAOX,OAHAuG,EAAoBH,GAAUnG,EAAQA,EAAOD,QAASmG,GAG/ClG,EAAOD,OACf,CCnB0BmG,CAAoB,K,UHO9C","sources":["webpack://WaveSurfer/webpack/universalModuleDefinition","webpack://WaveSurfer/./src/plugin/cursor/index.js","webpack://WaveSurfer/webpack/bootstrap","webpack://WaveSurfer/webpack/startup"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"WaveSurfer\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"WaveSurfer\"] = factory();\n\telse\n\t\troot[\"WaveSurfer\"] = root[\"WaveSurfer\"] || {}, root[\"WaveSurfer\"][\"cursor\"] = factory();\n})(self, () => {\nreturn ","/**\n * @typedef {Object} CursorPluginParams\n * @property {?boolean} deferInit Set to true to stop auto init in `addPlugin()`\n * @property {boolean} hideOnBlur=true Hide the cursor when the mouse leaves the\n * waveform\n * @property {string} width='1px' The width of the cursor\n * @property {string} color='black' The color of the cursor\n * @property {number|string} opacity='0.25' The opacity of the cursor\n * @property {string} style='solid' The border style of the cursor\n * @property {number} zIndex=3 The z-index of the cursor element\n * @property {object} customStyle An object with custom styles which are applied\n * to the cursor element\n * @property {boolean} showTime=false Show the time on the cursor.\n * @property {object} customShowTimeStyle An object with custom styles which are\n * applied to the cursor time element.\n * @property {boolean} followCursorY=false Use `true` to make the time on\n * the cursor follow the x and the y-position of the mouse. Use `false` to make the\n * it only follow the x-position of the mouse.\n * @property {function} formatTimeCallback Formats the timestamp on the cursor.\n */\n\n/**\n * Displays a thin line at the position of the cursor on the waveform.\n *\n * @implements {PluginClass}\n * @extends {Observer}\n * @example\n * // es6\n * import CursorPlugin from 'wavesurfer.cursor.js';\n *\n * // commonjs\n * var CursorPlugin = require('wavesurfer.cursor.js');\n *\n * // if you are using <script> tags\n * var CursorPlugin = window.WaveSurfer.cursor;\n *\n * // ... initialising wavesurfer with the plugin\n * var wavesurfer = WaveSurfer.create({\n * // wavesurfer options ...\n * plugins: [\n * CursorPlugin.create({\n * // plugin options ...\n * })\n * ]\n * });\n */\nexport default class CursorPlugin {\n /**\n * Cursor 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 {CursorPluginParams} params parameters use to initialise the\n * plugin\n * @return {PluginDefinition} an object representing the plugin\n */\n static create(params) {\n return {\n name: 'cursor',\n deferInit: params && params.deferInit ? params.deferInit : false,\n params: params,\n staticProps: {},\n instance: CursorPlugin\n };\n }\n\n /**\n * @type {CursorPluginParams}\n */\n defaultParams = {\n hideOnBlur: true,\n width: '1px',\n color: 'black',\n opacity: '0.25',\n style: 'solid',\n zIndex: 4,\n customStyle: {},\n customShowTimeStyle: {},\n showTime: false,\n followCursorY: false,\n formatTimeCallback: null\n };\n\n /**\n * @param {object} e Mouse move event\n */\n _onMousemove = e => {\n const event = this.util.withOrientation(e, this.wavesurfer.params.vertical);\n const bbox = this.wrapper.getBoundingClientRect();\n let y = 0;\n let x = this.wrapper.scrollLeft + event.clientX - bbox.left;\n const displayTimeWidth = this.displayTime ? this.displayTime.getBoundingClientRect().width : 0;\n let flip = bbox.right < event.clientX + displayTimeWidth;\n\n if (this.params.showTime && this.params.followCursorY) {\n // follow y-position of the mouse\n y = event.clientY - (bbox.top + bbox.height / 2);\n }\n\n this.updateCursorPosition(x, y, flip);\n };\n\n /**\n * @returns {void}\n */\n _onMouseenter = () => this.showCursor();\n\n /**\n * @returns {void}\n */\n _onMouseleave = () => this.hideCursor();\n\n /**\n * Construct the plugin class. You probably want to use `CursorPlugin.create`\n * instead.\n *\n * @param {CursorPluginParams} params Plugin parameters\n * @param {object} ws Wavesurfer instance\n */\n constructor(params, ws) {\n this.wavesurfer = ws;\n this.style = ws.util.style;\n this.util = ws.util;\n /**\n * The cursor HTML element\n *\n * @type {?HTMLElement}\n */\n this.cursor = null;\n /**\n * displays the time next to the cursor\n *\n * @type {?HTMLElement}\n */\n this.showTime = null;\n /**\n * The html container that will display the time\n *\n * @type {?HTMLElement}\n */\n this.displayTime = null;\n\n this.params = Object.assign({}, this.defaultParams, params);\n }\n\n _onReady() {\n this.wrapper = this.wavesurfer.drawer.wrapper;\n this.cursor = this.util.withOrientation(this.wrapper.appendChild(\n document.createElement('cursor'),\n ), this.wavesurfer.params.vertical);\n\n this.style(this.cursor,\n Object.assign(\n {\n position: 'absolute',\n zIndex: this.params.zIndex,\n left: 0,\n top: 0,\n bottom: 0,\n width: '0',\n display: 'flex',\n borderRightStyle: this.params.style,\n borderRightWidth: this.params.width,\n borderRightColor: this.params.color,\n opacity: this.params.opacity,\n pointerEvents: 'none'\n },\n this.params.customStyle\n )\n );\n\n if (this.params.showTime) {\n this.showTime = this.util.withOrientation(this.wrapper.appendChild(\n document.createElement('showTitle')\n ), this.wavesurfer.params.vertical);\n this.style(\n this.showTime,\n Object.assign(\n {\n position: 'absolute',\n zIndex: this.params.zIndex,\n left: 0,\n top: 0,\n bottom: 0,\n width: 'auto',\n display: 'flex',\n opacity: this.params.opacity,\n pointerEvents: 'none',\n height: '100%'\n },\n this.params.customStyle\n )\n );\n\n this.displayTime = this.util.withOrientation(this.showTime.appendChild(\n document.createElement('div'),\n ), this.wavesurfer.params.vertical);\n\n this.style(this.displayTime,\n Object.assign(\n {\n display: 'inline',\n pointerEvents: 'none',\n margin: 'auto',\n visibility: 'hidden' // initial value will be hidden just for measuring purpose\n },\n this.params.customShowTimeStyle\n )\n );\n\n // initial value to measure display width\n this.displayTime.innerHTML = this.formatTime(0);\n }\n\n this.wrapper.addEventListener('mousemove', this._onMousemove);\n if (this.params.hideOnBlur) {\n // ensure elements are hidden initially\n this.hideCursor();\n this.wrapper.addEventListener('mouseenter', this._onMouseenter);\n this.wrapper.addEventListener('mouseleave', this._onMouseleave);\n }\n }\n\n /**\n * Initialise the plugin (used by the Plugin API)\n */\n init() {\n if (this.wavesurfer.isReady) {\n this._onReady();\n } else {\n this.wavesurfer.once('ready', () => this._onReady());\n }\n }\n\n /**\n * Destroy the plugin (used by the Plugin API)\n */\n destroy() {\n if (this.params.showTime) {\n this.showTime.remove();\n }\n this.cursor.remove();\n this.wrapper.removeEventListener('mousemove', this._onMousemove);\n if (this.params.hideOnBlur) {\n this.wrapper.removeEventListener('mouseenter', this._onMouseenter);\n this.wrapper.removeEventListener('mouseleave', this._onMouseleave);\n }\n }\n\n /**\n * Update the cursor position\n *\n * @param {number} xpos The x offset of the cursor in pixels\n * @param {number} ypos The y offset of the cursor in pixels\n * @param {boolean} flip Flag to flip duration text from right to left\n */\n updateCursorPosition(xpos, ypos, flip = false) {\n this.style(this.cursor, {\n left: `${xpos}px`\n });\n if (this.params.showTime) {\n const duration = this.wavesurfer.getDuration();\n const elementWidth =\n this.wavesurfer.drawer.width /\n this.wavesurfer.params.pixelRatio;\n const scrollWidth = this.wavesurfer.drawer.getScrollX();\n\n const scrollTime =\n (duration / this.wavesurfer.drawer.width) * scrollWidth;\n\n const timeValue =\n Math.max(0, ((xpos - this.wrapper.scrollLeft) / elementWidth) * duration) + scrollTime;\n const formatValue = this.formatTime(timeValue);\n if (flip) {\n const textOffset = this.displayTime.getBoundingClientRect().width;\n xpos -= textOffset;\n }\n this.style(this.showTime, {\n left: `${xpos}px`,\n top: `${ypos}px`\n });\n this.style(this.displayTime, {\n visibility: 'visible'\n });\n this.displayTime.innerHTML = `${formatValue}`;\n }\n }\n\n /**\n * Show the cursor\n */\n showCursor() {\n this.style(this.cursor, {\n display: 'flex'\n });\n if (this.params.showTime) {\n this.style(this.showTime, {\n display: 'flex'\n });\n }\n }\n\n /**\n * Hide the cursor\n */\n hideCursor() {\n this.style(this.cursor, {\n display: 'none'\n });\n if (this.params.showTime) {\n this.style(this.showTime, {\n display: 'none'\n });\n }\n }\n\n /**\n * Format the timestamp for `cursorTime`.\n *\n * @param {number} cursorTime Time in seconds\n * @returns {string} Formatted timestamp\n */\n formatTime(cursorTime) {\n cursorTime = isNaN(cursorTime) ? 0 : cursorTime;\n\n if (this.params.formatTimeCallback) {\n return this.params.formatTimeCallback(cursorTime);\n }\n return [cursorTime].map(time =>\n [\n Math.floor((time % 3600) / 60), // minutes\n ('00' + Math.floor(time % 60)).slice(-2), // seconds\n ('000' + Math.floor((time % 1) * 1000)).slice(-3) // milliseconds\n ].join(':')\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__(178);\n"],"names":["root","factory","exports","module","define","amd","self","CursorPlugin","params","ws","hideOnBlur","width","color","opacity","style","zIndex","customStyle","customShowTimeStyle","showTime","followCursorY","formatTimeCallback","e","event","util","withOrientation","wavesurfer","vertical","bbox","wrapper","getBoundingClientRect","y","x","scrollLeft","clientX","left","displayTimeWidth","displayTime","flip","right","clientY","top","height","updateCursorPosition","showCursor","hideCursor","this","cursor","Object","assign","defaultParams","drawer","appendChild","document","createElement","position","bottom","display","borderRightStyle","borderRightWidth","borderRightColor","pointerEvents","margin","visibility","innerHTML","formatTime","addEventListener","_onMousemove","_onMouseenter","_onMouseleave","isReady","_onReady","once","remove","removeEventListener","xpos","ypos","duration","getDuration","elementWidth","pixelRatio","scrollWidth","getScrollX","scrollTime","timeValue","Math","max","formatValue","textOffset","cursorTime","isNaN","map","time","floor","slice","join","name","deferInit","staticProps","instance","__webpack_module_cache__","__webpack_exports__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__"],"sourceRoot":""}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* wavesurfer.js elan plugin 6.
|
|
2
|
+
* wavesurfer.js elan plugin 6.3.0 (2022-10-03)
|
|
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"]["elan"] = factory();
|
|
15
|
-
})(self,
|
|
15
|
+
})(self, () => {
|
|
16
16
|
return /******/ (() => { // webpackBootstrap
|
|
17
17
|
/******/ "use strict";
|
|
18
18
|
/******/ var __webpack_modules__ = ({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wavesurfer.elan.js","mappings":";;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,+CAA+C;AAC/C,CAAC;AACD;;;;;;;;;;;;;;;;;;;;;;;;;ACVA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;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;AACA;IACqBA;AAwBjB,sBAAYC,MAAZ,EAAoBC,EAApB,EAAwB;AAAA;;AAAA,mCALhB;AACJC,MAAAA,oBAAoB,EAAE,sBADlB;AAEJC,MAAAA,cAAc,EAAE;AAFZ,KAKgB;;AACpB,SAAKC,IAAL,GAAY,IAAZ;AACA,SAAKJ,MAAL,GAAcA,MAAd;AACA,SAAKK,SAAL,GACI,YAAY,OAAOL,MAAM,CAACK,SAA1B,GACMC,QAAQ,CAACC,aAAT,CAAuBP,MAAM,CAACK,SAA9B,CADN,GAEML,MAAM,CAACK,SAHjB;;AAKA,QAAI,CAAC,KAAKA,SAAV,EAAqB;AACjB,YAAMG,KAAK,CAAC,uBAAD,CAAX;AACH;AACJ;;;;WAED,gBAAO;AACH,WAAKC,SAAL;;AAEA,UAAI,KAAKT,MAAL,CAAYU,GAAhB,EAAqB;AACjB,aAAKC,IAAL,CAAU,KAAKX,MAAL,CAAYU,GAAtB;AACH;AACJ;;;WAED,mBAAU;AACN,WAAKL,SAAL,CAAeO,mBAAf,CAAmC,OAAnC,EAA4C,KAAKC,QAAjD;AACA,WAAKR,SAAL,CAAeS,WAAf,CAA2B,KAAKC,KAAhC;AACH;;;WAED,cAAKL,GAAL,EAAU;AAAA;;AACN,WAAKM,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X,IAAoBiC,IAApB,IAA4BH,UAAU,CAAC7B,GAAX,IAAkBgC,IAAlD,EAAwD;AACpDC,UAAAA,MAAM,GAAGJ,UAAT;AACA,iBAAO,IAAP;AACH;;AACD,eAAO,KAAP;AACH,OAND;AAOA,aAAOI,MAAP;AACH;;;WAED,2BAAkBJ,UAAlB,EAA8B;AAC1B,aAAOzF,QAAQ,CAAC+F,cAAT,CAAwB,0BAA0BN,UAAU,CAACxC,EAA7D,CAAP;AACH;;;;AA5QD;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACI,oBAAcvD,MAAd,EAAsB;AAClB,aAAO;AACHsG,QAAAA,IAAI,EAAE,MADH;AAEHC,QAAAA,SAAS,EAAEvG,MAAM,IAAIA,MAAM,CAACuG,SAAjB,GAA6BvG,MAAM,CAACuG,SAApC,GAAgD,KAFxD;AAGHvG,QAAAA,MAAM,EAAEA,MAHL;AAIHwG,QAAAA,QAAQ,EAAEzG;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/elan/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\"][\"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__(\"./src/plugin/elan/index.js\");\n",""],"names":["ElanPlugin","params","ws","ALIGNABLE_ANNOTATION","REF_ANNOTATION","data","container","document","querySelector","Error","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","Types","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","name","deferInit","instance"],"sourceRoot":""}
|
|
1
|
+
{"version":3,"file":"wavesurfer.elan.js","mappings":";;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,+CAA+C;AAC/C,CAAC;AACD;;;;;;;;;;;;;;;;;;;;;;;;;ACVA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;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;AACA;IACqBA;EAwBjB,oBAAYC,MAAZ,EAAoBC,EAApB,EAAwB;IAAA;;IAAA,+BALhB;MACJC,oBAAoB,EAAE,sBADlB;MAEJC,cAAc,EAAE;IAFZ,CAKgB;;IACpB,KAAKC,IAAL,GAAY,IAAZ;IACA,KAAKJ,MAAL,GAAcA,MAAd;IACA,KAAKK,SAAL,GACI,YAAY,OAAOL,MAAM,CAACK,SAA1B,GACMC,QAAQ,CAACC,aAAT,CAAuBP,MAAM,CAACK,SAA9B,CADN,GAEML,MAAM,CAACK,SAHjB;;IAKA,IAAI,CAAC,KAAKA,SAAV,EAAqB;MACjB,MAAMG,KAAK,CAAC,uBAAD,CAAX;IACH;EACJ;;;;WAED,gBAAO;MACH,KAAKC,SAAL;;MAEA,IAAI,KAAKT,MAAL,CAAYU,GAAhB,EAAqB;QACjB,KAAK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AwB,0BAA0BN,UAAU,CAACxC,EAA7D,CAAP;IACH;;;;IA5QD;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;IACI,gBAAcvD,MAAd,EAAsB;MAClB,OAAO;QACHsG,IAAI,EAAE,MADH;QAEHC,SAAS,EAAEvG,MAAM,IAAIA,MAAM,CAACuG,SAAjB,GAA6BvG,MAAM,CAACuG,SAApC,GAAgD,KAFxD;QAGHvG,MAAM,EAAEA,MAHL;QAIHwG,QAAQ,EAAEzG;MAJP,CAAP;IAMH;;;;;;;;;;;;;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/webpack/universalModuleDefinition","webpack://WaveSurfer/./src/plugin/elan/index.js","webpack://WaveSurfer/webpack/bootstrap","webpack://WaveSurfer/webpack/before-startup","webpack://WaveSurfer/webpack/startup","webpack://WaveSurfer/webpack/after-startup"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"WaveSurfer\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"WaveSurfer\"] = factory();\n\telse\n\t\troot[\"WaveSurfer\"] = root[\"WaveSurfer\"] || {}, root[\"WaveSurfer\"][\"elan\"] = factory();\n})(self, () => {\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__(\"./src/plugin/elan/index.js\");\n",""],"names":["ElanPlugin","params","ws","ALIGNABLE_ANNOTATION","REF_ANNOTATION","data","container","document","querySelector","Error","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","Types","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","name","deferInit","instance"],"sourceRoot":""}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* wavesurfer.js elan plugin 6.
|
|
2
|
+
* wavesurfer.js elan plugin 6.3.0 (2022-10-03)
|
|
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())}(self,(
|
|
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())}(self,(()=>(()=>{"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){var r,a,i;if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),i={ALIGNABLE_ANNOTATION:"ALIGNABLE_ANNOTATION",REF_ANNOTATION:"REF_ANNOTATION"},(a="Types")in(r=this)?Object.defineProperty(r,a,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[a]=i,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"),l=i.querySelector("MEDIA_DESCRIPTOR");a.media.url=l.getAttribute("MEDIA_URL"),a.media.type=l.getAttribute("MIME_TYPE");var s=e.querySelectorAll("TIME_ORDER TIME_SLOT"),u={};return n.call(s,(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 l=document.createElement("th");l.textContent="Time",l.className="wavesurfer-time",o.appendChild(l),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 s=document.createElement("tbody");a.appendChild(s),this.renderedAlignable.forEach((function(e){var a=document.createElement("tr");a.id="wavesurfer-alignable-"+e.id,s.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"),l=o[n];l&&(i.id="wavesurfer-annotation-"+l.id,i.dataset.ref=e.id,i.dataset.start=e.start,i.dataset.end=e.end,i.textContent=l.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),Object.defineProperty(t,"prototype",{writable:!1}),e}();t.default=r,e.exports=t.default}},t={};var n=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);return n})()));
|
|
7
7
|
//# sourceMappingURL=wavesurfer.elan.min.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wavesurfer.elan.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,WAAQ,KAAIC,KAR9E,CASGK,MAAM,WACT,Y,4QC0BqBC,EAAAA,WAwBjB,WAAYC,EAAQC,G,UAQhB,G,4FARoB,S,EALhB,CACJC,qBAAsB,uBACtBC,eAAgB,mB,EAGI,W,EAAA,M,sFACpBC,KAAKC,KAAO,KACZD,KAAKJ,OAASA,EACdI,KAAKE,UACD,iBAAmBN,EAAOM,UACpBC,SAASC,cAAcR,EAAOM,WAC9BN,EAAOM,WAEZF,KAAKE,UACN,MAAMG,MAAM,yB,4CAvBpB,SAAcT,GACV,MAAO,CACHU,KAAM,OACNC,aAAWX,IAAUA,EAAOW,YAAYX,EAAOW,UAC/CX,OAAQA,EACRY,SAAUb,O,qBAsBlB,WACIK,KAAKS,YAEDT,KAAKJ,OAAOc,KACZV,KAAKW,KAAKX,KAAKJ,OAAOc,O,qBAI9B,WACIV,KAAKE,UAAUU,oBAAoB,QAASZ,KAAKa,UACjDb,KAAKE,UAAUY,YAAYd,KAAKe,S,kBAGpC,SAAKL,GAAK,WACNV,KAAKgB,QAAQN,GAAK,SAAAO,GACd,EAAKhB,KAAO,EAAKiB,UAAUD,GAC3B,EAAKE,SACL,EAAKC,UAAU,QAAS,EAAKnB,W,qBAIrC,SAAQS,EAAKW,GACT,IAAMC,EAAM,I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GACZ,IAAMiC,EAAMjC,EAAEC,OAAOmE,QAAQnC,IAC7B,GAAI,MAAQA,EAAK,CACb,IAAMF,EAAQ,EAAK1D,KAAKuC,YAAYqB,GAChCF,GACA,EAAKvC,UAAU,SAAUuC,EAAMM,MAAON,EAAMO,OAIxDlE,KAAKE,UAAUyB,iBAAiB,QAAS3B,KAAKa,Y,mCAGlD,SAAsBqF,GAClB,IAAIC,EAQJ,OAPAnG,KAAKgF,kBAAkBoB,MAAK,SAAAL,GACxB,OAAIA,EAAW9B,OAASiC,GAAQH,EAAW7B,KAAOgC,IAC9CC,EAASJ,GACF,MAIRI,I,+BAGX,SAAkBJ,GACd,OAAO5F,SAASkG,eAAe,wBAA0BN,EAAWxC,S,gFA5QvD5D,G,kCCnCjB2G,EAA2B,GCE/B,IAAIC,EDCJ,SAASC,EAAoBC,GAE5B,IAAIC,EAAeJ,EAAyBG,GAC5C,QAAqBE,IAAjBD,EACH,OAAOA,EAAapH,QAGrB,IAAIC,EAAS+G,EAAyBG,GAAY,CAGjDnH,QAAS,IAOV,OAHAsH,EAAoBH,GAAUlH,EAAQA,EAAOD,QAASkH,GAG/CjH,EAAOD,QClBWkH,CAAoB,K,UHO9C","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","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","Types","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_exports__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__"],"sourceRoot":""}
|
|
1
|
+
{"version":3,"file":"wavesurfer.elan.min.js","mappings":";;;;;CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,aAAc,GAAIH,GACC,iBAAZC,QACdA,QAAoB,WAAID,KAExBD,EAAiB,WAAIA,EAAiB,YAAK,CAAC,EAAGA,EAAiB,WAAQ,KAAIC,IAC7E,CATD,CASGK,MAAM,IACT,M,4QC0BqBC,EAAAA,WAwBjB,WAAYC,EAAQC,G,UAQhB,G,4FARoB,S,EALhB,CACJC,qBAAsB,uBACtBC,eAAgB,mB,EAGI,W,EAAA,M,sFACpBC,KAAKC,KAAO,KACZD,KAAKJ,OAASA,EACdI,KAAKE,UACD,iBAAmBN,EAAOM,UACpBC,SAASC,cAAcR,EAAOM,WAC9BN,EAAOM,WAEZF,KAAKE,UACN,MAAMG,MAAM,wBAEnB,C,4CAzBD,SAAcT,GACV,MAAO,CACHU,KAAM,OACNC,aAAWX,IAAUA,EAAOW,YAAYX,EAAOW,UAC/CX,OAAQA,EACRY,SAAUb,EAEjB,K,qBAoBD,WACIK,KAAKS,YAEDT,KAAKJ,OAAOc,KACZV,KAAKW,KAAKX,KAAKJ,OAAOc,IAE7B,G,qBAED,WACIV,KAAKE,UAAUU,oBAAoB,QAAS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an/index.js","webpack://WaveSurfer/webpack/bootstrap","webpack://WaveSurfer/webpack/startup"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"WaveSurfer\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"WaveSurfer\"] = factory();\n\telse\n\t\troot[\"WaveSurfer\"] = root[\"WaveSurfer\"] || {}, root[\"WaveSurfer\"][\"elan\"] = factory();\n})(self, () => {\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","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","Types","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_exports__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__"],"sourceRoot":""}
|