wavesurfer.js 6.2.0 → 6.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +1 -10
  3. package/dist/plugin/wavesurfer.cursor.js +29 -49
  4. package/dist/plugin/wavesurfer.cursor.js.map +1 -1
  5. package/dist/plugin/wavesurfer.cursor.min.js +2 -2
  6. package/dist/plugin/wavesurfer.cursor.min.js.map +1 -1
  7. package/dist/plugin/wavesurfer.elan.js +19 -49
  8. package/dist/plugin/wavesurfer.elan.js.map +1 -1
  9. package/dist/plugin/wavesurfer.elan.min.js +1 -1
  10. package/dist/plugin/wavesurfer.elan.min.js.map +1 -1
  11. package/dist/plugin/wavesurfer.markers.js +87 -67
  12. package/dist/plugin/wavesurfer.markers.js.map +1 -1
  13. package/dist/plugin/wavesurfer.markers.min.js +2 -2
  14. package/dist/plugin/wavesurfer.markers.min.js.map +1 -1
  15. package/dist/plugin/wavesurfer.mediasession.js +5 -15
  16. package/dist/plugin/wavesurfer.mediasession.js.map +1 -1
  17. package/dist/plugin/wavesurfer.mediasession.min.js +1 -1
  18. package/dist/plugin/wavesurfer.mediasession.min.js.map +1 -1
  19. package/dist/plugin/wavesurfer.microphone.js +44 -62
  20. package/dist/plugin/wavesurfer.microphone.js.map +1 -1
  21. package/dist/plugin/wavesurfer.microphone.min.js +1 -1
  22. package/dist/plugin/wavesurfer.microphone.min.js.map +1 -1
  23. package/dist/plugin/wavesurfer.minimap.js +16 -68
  24. package/dist/plugin/wavesurfer.minimap.js.map +1 -1
  25. package/dist/plugin/wavesurfer.minimap.min.js +1 -1
  26. package/dist/plugin/wavesurfer.minimap.min.js.map +1 -1
  27. package/dist/plugin/wavesurfer.playhead.js +2 -29
  28. package/dist/plugin/wavesurfer.playhead.js.map +1 -1
  29. package/dist/plugin/wavesurfer.playhead.min.js +1 -1
  30. package/dist/plugin/wavesurfer.playhead.min.js.map +1 -1
  31. package/dist/plugin/wavesurfer.regions.js +99 -253
  32. package/dist/plugin/wavesurfer.regions.js.map +1 -1
  33. package/dist/plugin/wavesurfer.regions.min.js +2 -2
  34. package/dist/plugin/wavesurfer.regions.min.js.map +1 -1
  35. package/dist/plugin/wavesurfer.spectrogram.js +52 -147
  36. package/dist/plugin/wavesurfer.spectrogram.js.map +1 -1
  37. package/dist/plugin/wavesurfer.spectrogram.min.js +2 -2
  38. package/dist/plugin/wavesurfer.spectrogram.min.js.map +1 -1
  39. package/dist/plugin/wavesurfer.timeline.js +42 -85
  40. package/dist/plugin/wavesurfer.timeline.js.map +1 -1
  41. package/dist/plugin/wavesurfer.timeline.min.js +1 -1
  42. package/dist/plugin/wavesurfer.timeline.min.js.map +1 -1
  43. package/dist/wavesurfer-html-init.js +31 -53
  44. package/dist/wavesurfer-html-init.js.map +1 -1
  45. package/dist/wavesurfer-html-init.min.js +1 -1
  46. package/dist/wavesurfer-html-init.min.js.map +1 -1
  47. package/dist/wavesurfer.js +448 -1008
  48. package/dist/wavesurfer.js.map +1 -1
  49. package/dist/wavesurfer.min.js +2 -2
  50. package/dist/wavesurfer.min.js.map +1 -1
  51. package/package.json +18 -19
  52. package/src/drawer.multicanvas.js +4 -4
  53. package/src/plugin/cursor/index.js +15 -3
  54. package/src/plugin/markers/index.js +70 -5
  55. package/src/plugin/regions/index.js +1 -1
  56. package/src/plugin/spectrogram/index.js +1 -1
  57. package/src/wavesurfer.js +12 -9
  58. package/CHANGES.md +0 -474
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  BSD 3-Clause License
2
2
 
3
- Copyright (c) 2012-2021, katspaugh and contributors
3
+ Copyright (c) 2012-2022, katspaugh and contributors
4
4
  All rights reserved.
5
5
 
6
6
  Redistribution and use in source and binary forms, with or without
package/README.md CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  [![npm version](https://img.shields.io/npm/v/wavesurfer.js.svg?style=flat)](https://www.npmjs.com/package/wavesurfer.js)
4
4
  ![npm](https://img.shields.io/npm/dm/wavesurfer.js.svg) [![Join the chat at https://gitter.im/katspaugh/wavesurfer.js](https://badges.gitter.im/katspaugh/wavesurfer.js.svg)](https://gitter.im/katspaugh/wavesurfer.js?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
5
+ [![GitPOAP Badge](https://public-api.gitpoap.io/v1/repo/katspaugh/wavesurfer.js/badge)](https://www.gitpoap.io/gh/katspaugh/wavesurfer.js)
5
6
 
6
7
  Interactive navigable audio visualization using Web Audio and Canvas.
7
8
 
@@ -9,16 +10,6 @@ Interactive navigable audio visualization using Web Audio and Canvas.
9
10
 
10
11
  See a [tutorial](https://wavesurfer-js.org/docs) and [examples](https://wavesurfer-js.org/examples) on [wavesurfer-js.org](https://wavesurfer-js.org).
11
12
 
12
- ## 10 years of wavesurfer.js 🎉
13
- Wavesurfer.js was started in March 2012. To celebrate the 10-year anniversary of wavesurfer.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
13
  ## Browser support
23
14
  wavesurfer.js works only in [modern browsers supporting Web Audio](http://caniuse.com/audio-api).
24
15
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * wavesurfer.js cursor plugin 6.2.0 (2022-05-16)
2
+ * wavesurfer.js cursor plugin 6.4.0 (2022-11-05)
3
3
  * https://wavesurfer-js.org
4
4
  * @license BSD-3-Clause
5
5
  */
@@ -29,15 +29,10 @@ Object.defineProperty(exports, "__esModule", ({
29
29
  value: true
30
30
  }));
31
31
  exports["default"] = void 0;
32
-
33
32
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
34
-
35
33
  function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
36
-
37
34
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
38
-
39
35
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
40
-
41
36
  /**
42
37
  * @typedef {Object} CursorPluginParams
43
38
  * @property {?boolean} deferInit Set to true to stop auto init in `addPlugin()`
@@ -57,8 +52,8 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
57
52
  * the cursor follow the x and the y-position of the mouse. Use `false` to make the
58
53
  * it only follow the x-position of the mouse.
59
54
  * @property {function} formatTimeCallback Formats the timestamp on the cursor.
55
+ * @property {boolean} isDestroyCalled true if called destroy before the ready event fired
60
56
  */
61
-
62
57
  /**
63
58
  * Displays a thin line at the position of the cursor on the waveform.
64
59
  *
@@ -94,9 +89,7 @@ var CursorPlugin = /*#__PURE__*/function () {
94
89
  */
95
90
  function CursorPlugin(params, ws) {
96
91
  var _this = this;
97
-
98
92
  _classCallCheck(this, CursorPlugin);
99
-
100
93
  _defineProperty(this, "defaultParams", {
101
94
  hideOnBlur: true,
102
95
  width: '1px',
@@ -110,33 +103,25 @@ var CursorPlugin = /*#__PURE__*/function () {
110
103
  followCursorY: false,
111
104
  formatTimeCallback: null
112
105
  });
113
-
114
106
  _defineProperty(this, "_onMousemove", function (e) {
115
107
  var event = _this.util.withOrientation(e, _this.wavesurfer.params.vertical);
116
-
117
108
  var bbox = _this.wrapper.getBoundingClientRect();
118
-
119
109
  var y = 0;
120
110
  var x = _this.wrapper.scrollLeft + event.clientX - bbox.left;
121
111
  var displayTimeWidth = _this.displayTime ? _this.displayTime.getBoundingClientRect().width : 0;
122
112
  var flip = bbox.right < event.clientX + displayTimeWidth;
123
-
124
113
  if (_this.params.showTime && _this.params.followCursorY) {
125
114
  // follow y-position of the mouse
126
115
  y = event.clientY - (bbox.top + bbox.height / 2);
127
116
  }
128
-
129
117
  _this.updateCursorPosition(x, y, flip);
130
118
  });
131
-
132
119
  _defineProperty(this, "_onMouseenter", function () {
133
120
  return _this.showCursor();
134
121
  });
135
-
136
122
  _defineProperty(this, "_onMouseleave", function () {
137
123
  return _this.hideCursor();
138
124
  });
139
-
140
125
  this.wavesurfer = ws;
141
126
  this.style = ws.util.style;
142
127
  this.util = ws.util;
@@ -145,28 +130,32 @@ var CursorPlugin = /*#__PURE__*/function () {
145
130
  *
146
131
  * @type {?HTMLElement}
147
132
  */
148
-
149
133
  this.cursor = null;
150
134
  /**
151
135
  * displays the time next to the cursor
152
136
  *
153
137
  * @type {?HTMLElement}
154
138
  */
155
-
156
139
  this.showTime = null;
157
140
  /**
158
141
  * The html container that will display the time
159
142
  *
160
143
  * @type {?HTMLElement}
161
144
  */
162
-
163
145
  this.displayTime = null;
146
+ /**
147
+ * true if call destory before ready event
148
+ * @type {boolean}
149
+ */
150
+ this.isDestroyCalled = false;
164
151
  this.params = Object.assign({}, this.defaultParams, params);
165
152
  }
166
-
167
153
  _createClass(CursorPlugin, [{
168
154
  key: "_onReady",
169
155
  value: function _onReady() {
156
+ if (this.isDestroyCalled) {
157
+ return;
158
+ }
170
159
  this.wrapper = this.wavesurfer.drawer.wrapper;
171
160
  this.cursor = this.util.withOrientation(this.wrapper.appendChild(document.createElement('cursor')), this.wavesurfer.params.vertical);
172
161
  this.style(this.cursor, Object.assign({
@@ -183,7 +172,6 @@ var CursorPlugin = /*#__PURE__*/function () {
183
172
  opacity: this.params.opacity,
184
173
  pointerEvents: 'none'
185
174
  }, this.params.customStyle));
186
-
187
175
  if (this.params.showTime) {
188
176
  this.showTime = this.util.withOrientation(this.wrapper.appendChild(document.createElement('showTitle')), this.wavesurfer.params.vertical);
189
177
  this.style(this.showTime, Object.assign({
@@ -204,14 +192,12 @@ var CursorPlugin = /*#__PURE__*/function () {
204
192
  pointerEvents: 'none',
205
193
  margin: 'auto',
206
194
  visibility: 'hidden' // initial value will be hidden just for measuring purpose
195
+ }, this.params.customShowTimeStyle));
207
196
 
208
- }, this.params.customShowTimeStyle)); // initial value to measure display width
209
-
197
+ // initial value to measure display width
210
198
  this.displayTime.innerHTML = this.formatTime(0);
211
199
  }
212
-
213
200
  this.wrapper.addEventListener('mousemove', this._onMousemove);
214
-
215
201
  if (this.params.hideOnBlur) {
216
202
  // ensure elements are hidden initially
217
203
  this.hideCursor();
@@ -219,15 +205,14 @@ var CursorPlugin = /*#__PURE__*/function () {
219
205
  this.wrapper.addEventListener('mouseleave', this._onMouseleave);
220
206
  }
221
207
  }
208
+
222
209
  /**
223
210
  * Initialise the plugin (used by the Plugin API)
224
211
  */
225
-
226
212
  }, {
227
213
  key: "init",
228
214
  value: function init() {
229
215
  var _this2 = this;
230
-
231
216
  if (this.wavesurfer.isReady) {
232
217
  this._onReady();
233
218
  } else {
@@ -236,25 +221,28 @@ var CursorPlugin = /*#__PURE__*/function () {
236
221
  });
237
222
  }
238
223
  }
224
+
239
225
  /**
240
226
  * Destroy the plugin (used by the Plugin API)
241
227
  */
242
-
243
228
  }, {
244
229
  key: "destroy",
245
230
  value: function destroy() {
231
+ if (!this.cursorTime || !this.showTime) {
232
+ this.isDestroyCalled = true;
233
+ return;
234
+ }
246
235
  if (this.params.showTime) {
247
- this.showTime.remove();
236
+ this.showTime && this.showTime.remove();
248
237
  }
249
-
250
- this.cursor.remove();
238
+ this.cursor && this.cursor.remove();
251
239
  this.wrapper.removeEventListener('mousemove', this._onMousemove);
252
-
253
240
  if (this.params.hideOnBlur) {
254
241
  this.wrapper.removeEventListener('mouseenter', this._onMouseenter);
255
242
  this.wrapper.removeEventListener('mouseleave', this._onMouseleave);
256
243
  }
257
244
  }
245
+
258
246
  /**
259
247
  * Update the cursor position
260
248
  *
@@ -262,7 +250,6 @@ var CursorPlugin = /*#__PURE__*/function () {
262
250
  * @param {number} ypos The y offset of the cursor in pixels
263
251
  * @param {boolean} flip Flag to flip duration text from right to left
264
252
  */
265
-
266
253
  }, {
267
254
  key: "updateCursorPosition",
268
255
  value: function updateCursorPosition(xpos, ypos) {
@@ -270,7 +257,6 @@ var CursorPlugin = /*#__PURE__*/function () {
270
257
  this.style(this.cursor, {
271
258
  left: "".concat(xpos, "px")
272
259
  });
273
-
274
260
  if (this.params.showTime) {
275
261
  var duration = this.wavesurfer.getDuration();
276
262
  var elementWidth = this.wavesurfer.drawer.width / this.wavesurfer.params.pixelRatio;
@@ -278,12 +264,10 @@ var CursorPlugin = /*#__PURE__*/function () {
278
264
  var scrollTime = duration / this.wavesurfer.drawer.width * scrollWidth;
279
265
  var timeValue = Math.max(0, (xpos - this.wrapper.scrollLeft) / elementWidth * duration) + scrollTime;
280
266
  var formatValue = this.formatTime(timeValue);
281
-
282
267
  if (flip) {
283
268
  var textOffset = this.displayTime.getBoundingClientRect().width;
284
269
  xpos -= textOffset;
285
270
  }
286
-
287
271
  this.style(this.showTime, {
288
272
  left: "".concat(xpos, "px"),
289
273
  top: "".concat(ypos, "px")
@@ -294,59 +278,57 @@ var CursorPlugin = /*#__PURE__*/function () {
294
278
  this.displayTime.innerHTML = "".concat(formatValue);
295
279
  }
296
280
  }
281
+
297
282
  /**
298
283
  * Show the cursor
299
284
  */
300
-
301
285
  }, {
302
286
  key: "showCursor",
303
287
  value: function showCursor() {
304
288
  this.style(this.cursor, {
305
289
  display: 'flex'
306
290
  });
307
-
308
291
  if (this.params.showTime) {
309
292
  this.style(this.showTime, {
310
293
  display: 'flex'
311
294
  });
312
295
  }
313
296
  }
297
+
314
298
  /**
315
299
  * Hide the cursor
316
300
  */
317
-
318
301
  }, {
319
302
  key: "hideCursor",
320
303
  value: function hideCursor() {
321
304
  this.style(this.cursor, {
322
305
  display: 'none'
323
306
  });
324
-
325
307
  if (this.params.showTime) {
326
308
  this.style(this.showTime, {
327
309
  display: 'none'
328
310
  });
329
311
  }
330
312
  }
313
+
331
314
  /**
332
315
  * Format the timestamp for `cursorTime`.
333
316
  *
334
317
  * @param {number} cursorTime Time in seconds
335
318
  * @returns {string} Formatted timestamp
336
319
  */
337
-
338
320
  }, {
339
321
  key: "formatTime",
340
322
  value: function formatTime(cursorTime) {
341
323
  cursorTime = isNaN(cursorTime) ? 0 : cursorTime;
342
-
343
324
  if (this.params.formatTimeCallback) {
344
325
  return this.params.formatTimeCallback(cursorTime);
345
326
  }
346
-
347
327
  return [cursorTime].map(function (time) {
348
- return [Math.floor(time % 3600 / 60), // minutes
349
- ('00' + Math.floor(time % 60)).slice(-2), // seconds
328
+ return [Math.floor(time % 3600 / 60),
329
+ // minutes
330
+ ('00' + Math.floor(time % 60)).slice(-2),
331
+ // seconds
350
332
  ('000' + Math.floor(time % 1 * 1000)).slice(-3) // milliseconds
351
333
  ].join(':');
352
334
  });
@@ -373,15 +355,13 @@ var CursorPlugin = /*#__PURE__*/function () {
373
355
  instance: CursorPlugin
374
356
  };
375
357
  }
358
+
376
359
  /**
377
360
  * @type {CursorPluginParams}
378
361
  */
379
-
380
362
  }]);
381
-
382
363
  return CursorPlugin;
383
364
  }();
384
-
385
365
  exports["default"] = CursorPlugin;
386
366
  module.exports = exports.default;
387
367
 
@@ -1 +1 @@
1
- {"version":3,"file":"wavesurfer.cursor.js","mappings":";;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,+CAA+C;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AQT,IAAI,CAACQ,KAAL,CAAYD,IAAI,GAAG,CAAR,GAAa,IAAxB,CAAT,EAAwCE,KAAxC,CAA8C,CAAC,CAA/C,CAHJ,CAGsD;QAHtD,EAIEC,IAJF,CAIO,GAJP,CADwB;MAAA,CAArB,CAAP;IAOH;;;;IAjSD;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;IACI,gBAAcrF,MAAd,EAAsB;MAClB,OAAO;QACHsF,IAAI,EAAE,QADH;QAEHC,SAAS,EAAEvF,MAAM,IAAIA,MAAM,CAACuF,SAAjB,GAA6BvF,MAAM,CAACuF,SAApC,GAAgD,KAFxD;QAGHvF,MAAM,EAAEA,MAHL;QAIHwF,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
+ {"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;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAxBA,IAyBqBA,YAAY;EAmE7B;AACJ;AACA;AACA;AACA;AACA;AACA;EACI,sBAAYC,MAAM,EAAEC,EAAE,EAAE;IAAA;IAAA;IAAA,uCAlDR;MACZC,UAAU,EAAE,IAAI;MAChBC,KAAK,EAAE,KAAK;MACZC,KAAK,EAAE,OAAO;MACdC,OAAO,EAAE,MAAM;MACfC,KAAK,EAAE,OAAO;MACdC,MAAM,EAAE,CAAC;MACT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QAAA,OACxB,CACIN,IAAI,CAACO,KAAK,CAAED,IAAI,GAAG,IAAI,GAAI,EAAE,CAAC;QAAE;QAChC,CAAC,IAAI,GAAGN,IAAI,CAACO,KAAK,CAACD,IAAI,GAAG,EAAE,CAAC,EAAEE,KAAK,CAAC,CAAC,CAAC,CAAC;QAAE;QAC1C,CAAC,KAAK,GAAGR,IAAI,CAACO,KAAK,CAAED,IAAI,GAAG,CAAC,GAAI,IAAI,CAAC,EAAEE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QAAA,CACrD,CAACC,IAAI,CAAC,GAAG,CAAC;MAAA,EACd;IACL;EAAC;IAAA;IAAA;IA5SD;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;IACI,gBAActF,MAAM,EAAE;MAClB,OAAO;QACHuF,IAAI,EAAE,QAAQ;QACdC,SAAS,EAAExF,MAAM,IAAIA,MAAM,CAACwF,SAAS,GAAGxF,MAAM,CAACwF,SAAS,GAAG,KAAK;QAChExF,MAAM,EAAEA,MAAM;QACdyF,WAAW,EAAE,CAAC,CAAC;QACfC,QAAQ,EAAE3F;MACd,CAAC;IACL;;IAEA;AACJ;AACA;EAFI;EAAA;AAAA;AAAA;AAAA;;;;;;UCpEJ;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 * @property {boolean} isDestroyCalled true if called destroy before the ready event fired\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 * true if call destory before ready event\n * @type {boolean}\n */\n this.isDestroyCalled = false;\n\n this.params = Object.assign({}, this.defaultParams, params);\n }\n\n _onReady() {\n if (this.isDestroyCalled) {\n return;\n }\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.cursorTime || !this.showTime){\n this.isDestroyCalled = true;\n return;\n }\n if (this.params.showTime) {\n this.showTime && this.showTime.remove();\n }\n this.cursor && 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 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","isDestroyCalled","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","cursorTime","remove","removeEventListener","xpos","ypos","duration","getDuration","elementWidth","pixelRatio","scrollWidth","getScrollX","scrollTime","timeValue","Math","max","formatValue","textOffset","isNaN","map","time","floor","slice","join","name","deferInit","staticProps","instance"],"sourceRoot":""}
@@ -1,7 +1,7 @@
1
1
  /*!
2
- * wavesurfer.js cursor plugin 6.2.0 (2022-05-16)
2
+ * wavesurfer.js cursor plugin 6.4.0 (2022-11-05)
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,(()=>(()=>{"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})()));
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.isDestroyCalled=!1,this.params=Object.assign({},this.defaultParams,t)}var t,r,a;return t=e,r=[{key:"_onReady",value:function(){this.isDestroyCalled||(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.cursorTime&&this.showTime?(this.params.showTime&&this.showTime&&this.showTime.remove(),this.cursor&&this.cursor.remove(),this.wrapper.removeEventListener("mousemove",this._onMousemove),this.params.hideOnBlur&&(this.wrapper.removeEventListener("mouseenter",this._onMouseenter),this.wrapper.removeEventListener("mouseleave",this._onMouseleave))):this.isDestroyCalled=!0}},{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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KT,YAAa,CACzB0B,WAAY,YAEhBjB,KAAKT,YAAY2B,UAAjB,UAAgCuB,M,wBAOxC,WACIzC,KAAK/B,MAAM+B,KAAKC,OAAQ,CACpBU,QAAS,SAETX,KAAKrC,OAAOU,UACZ2B,KAAK/B,MAAM+B,KAAK3B,SAAU,CACtBsC,QAAS,W,wBAQrB,WACIX,KAAK/B,MAAM+B,KAAKC,OAAQ,CACpBU,QAAS,SAETX,KAAKrC,OAAOU,UACZ2B,KAAK/B,MAAM+B,KAAK3B,SAAU,CACtBsC,QAAS,W,wBAWrB,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,W,uBArRf,SAActF,GACV,MAAO,CACHuF,KAAM,SACNC,aAAWxF,IAAUA,EAAOwF,YAAYxF,EAAOwF,UAC/CxF,OAAQA,EACRyF,YAAa,GACbC,SAAU3F,M,mFAjBDA,G,kCC7CjB4F,EAA2B,GCE/B,IAAIC,EDCJ,SAASC,EAAoBC,GAE5B,IAAIC,EAAeJ,EAAyBG,GAC5C,QAAqBE,IAAjBD,EACH,OAAOA,EAAarG,QAGrB,IAAIC,EAASgG,EAAyBG,GAAY,CAGjDpG,QAAS,IAOV,OAHAuG,EAAoBH,GAAUnG,EAAQA,EAAOD,QAASmG,GAG/ClG,EAAOD,QClBWmG,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
+ {"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,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AoB,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 * @property {boolean} isDestroyCalled true if called destroy before the ready event fired\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 * true if call destory before ready event\n * @type {boolean}\n */\n this.isDestroyCalled = false;\n\n this.params = Object.assign({}, this.defaultParams, params);\n }\n\n _onReady() {\n if (this.isDestroyCalled) {\n return;\n }\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.cursorTime || !this.showTime){\n this.isDestroyCalled = true;\n return;\n }\n if (this.params.showTime) {\n this.showTime && this.showTime.remove();\n }\n this.cursor && 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 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","isDestroyCalled","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","cursorTime","remove","removeEventListener","xpos","ypos","duration","getDuration","elementWidth","pixelRatio","scrollWidth","getScrollX","scrollTime","timeValue","Math","max","formatValue","textOffset","isNaN","map","time","floor","slice","join","name","deferInit","staticProps","instance","__webpack_module_cache__","__webpack_exports__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__"],"sourceRoot":""}