wavesurfer.js 6.5.0 → 7.0.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (132) hide show
  1. package/.eslintrc.json +24 -0
  2. package/.prettierrc +8 -0
  3. package/README.md +26 -117
  4. package/dist/base-plugin.d.ts +10 -0
  5. package/dist/base-plugin.js +13 -0
  6. package/dist/decoder.d.ts +10 -0
  7. package/dist/decoder.js +43 -0
  8. package/dist/event-emitter.d.ts +11 -0
  9. package/dist/event-emitter.js +21 -0
  10. package/dist/fetcher.d.ts +4 -0
  11. package/dist/fetcher.js +17 -0
  12. package/dist/index.d.ts +92 -0
  13. package/dist/index.js +166 -0
  14. package/dist/player-webaudio.d.ts +8 -0
  15. package/dist/player-webaudio.js +31 -0
  16. package/dist/player.d.ts +16 -0
  17. package/dist/player.js +40 -0
  18. package/dist/plugins/regions.d.ts +48 -0
  19. package/dist/plugins/regions.js +183 -0
  20. package/dist/renderer.d.ts +34 -0
  21. package/dist/renderer.js +193 -0
  22. package/dist/timer.d.ts +10 -0
  23. package/dist/timer.js +17 -0
  24. package/examples/audio.ogg +0 -0
  25. package/examples/bars.js +19 -0
  26. package/examples/basic.js +8 -0
  27. package/examples/gradient.js +28 -0
  28. package/examples/regions.js +63 -0
  29. package/examples/video.js +19 -0
  30. package/examples/webaudio.js +14 -0
  31. package/package.json +19 -99
  32. package/src/base-plugin.ts +20 -0
  33. package/src/decoder.ts +41 -0
  34. package/src/event-emitter.ts +35 -0
  35. package/src/fetcher.ts +7 -0
  36. package/src/index.ts +252 -0
  37. package/src/player-webaudio.ts +34 -0
  38. package/src/player.ts +50 -0
  39. package/src/plugins/regions.ts +240 -0
  40. package/src/renderer.ts +250 -0
  41. package/src/timer.ts +27 -0
  42. package/tsconfig.json +105 -0
  43. package/tutorial/index.html +47 -0
  44. package/tutorial/src/editor.js +70 -0
  45. package/tutorial/src/init.js +66 -0
  46. package/tutorial/src/url.js +25 -0
  47. package/tutorial/style.css +211 -0
  48. package/yarn-error.log +1049 -0
  49. package/LICENSE +0 -29
  50. package/dist/plugin/wavesurfer.cursor.js +0 -418
  51. package/dist/plugin/wavesurfer.cursor.js.map +0 -1
  52. package/dist/plugin/wavesurfer.cursor.min.js +0 -7
  53. package/dist/plugin/wavesurfer.cursor.min.js.map +0 -1
  54. package/dist/plugin/wavesurfer.elan.js +0 -381
  55. package/dist/plugin/wavesurfer.elan.js.map +0 -1
  56. package/dist/plugin/wavesurfer.elan.min.js +0 -7
  57. package/dist/plugin/wavesurfer.elan.min.js.map +0 -1
  58. package/dist/plugin/wavesurfer.markers.js +0 -520
  59. package/dist/plugin/wavesurfer.markers.js.map +0 -1
  60. package/dist/plugin/wavesurfer.markers.min.js +0 -7
  61. package/dist/plugin/wavesurfer.markers.min.js.map +0 -1
  62. package/dist/plugin/wavesurfer.mediasession.js +0 -181
  63. package/dist/plugin/wavesurfer.mediasession.js.map +0 -1
  64. package/dist/plugin/wavesurfer.mediasession.min.js +0 -7
  65. package/dist/plugin/wavesurfer.mediasession.min.js.map +0 -1
  66. package/dist/plugin/wavesurfer.microphone.js +0 -466
  67. package/dist/plugin/wavesurfer.microphone.js.map +0 -1
  68. package/dist/plugin/wavesurfer.microphone.min.js +0 -7
  69. package/dist/plugin/wavesurfer.microphone.min.js.map +0 -1
  70. package/dist/plugin/wavesurfer.minimap.js +0 -440
  71. package/dist/plugin/wavesurfer.minimap.js.map +0 -1
  72. package/dist/plugin/wavesurfer.minimap.min.js +0 -7
  73. package/dist/plugin/wavesurfer.minimap.min.js.map +0 -1
  74. package/dist/plugin/wavesurfer.playhead.js +0 -300
  75. package/dist/plugin/wavesurfer.playhead.js.map +0 -1
  76. package/dist/plugin/wavesurfer.playhead.min.js +0 -7
  77. package/dist/plugin/wavesurfer.playhead.min.js.map +0 -1
  78. package/dist/plugin/wavesurfer.regions.js +0 -1342
  79. package/dist/plugin/wavesurfer.regions.js.map +0 -1
  80. package/dist/plugin/wavesurfer.regions.min.js +0 -7
  81. package/dist/plugin/wavesurfer.regions.min.js.map +0 -1
  82. package/dist/plugin/wavesurfer.spectrogram.js +0 -736
  83. package/dist/plugin/wavesurfer.spectrogram.js.map +0 -1
  84. package/dist/plugin/wavesurfer.spectrogram.min.js +0 -7
  85. package/dist/plugin/wavesurfer.spectrogram.min.js.map +0 -1
  86. package/dist/plugin/wavesurfer.timeline.js +0 -649
  87. package/dist/plugin/wavesurfer.timeline.js.map +0 -1
  88. package/dist/plugin/wavesurfer.timeline.min.js +0 -7
  89. package/dist/plugin/wavesurfer.timeline.min.js.map +0 -1
  90. package/dist/wavesurfer-html-init.js +0 -381
  91. package/dist/wavesurfer-html-init.js.map +0 -1
  92. package/dist/wavesurfer-html-init.min.js +0 -7
  93. package/dist/wavesurfer-html-init.min.js.map +0 -1
  94. package/dist/wavesurfer.js +0 -6145
  95. package/dist/wavesurfer.js.map +0 -1
  96. package/dist/wavesurfer.min.js +0 -7
  97. package/dist/wavesurfer.min.js.map +0 -1
  98. package/src/drawer.canvasentry.js +0 -427
  99. package/src/drawer.js +0 -413
  100. package/src/drawer.multicanvas.js +0 -617
  101. package/src/html-init.js +0 -241
  102. package/src/mediaelement-webaudio.js +0 -77
  103. package/src/mediaelement.js +0 -443
  104. package/src/peakcache.js +0 -127
  105. package/src/plugin/cursor/index.js +0 -350
  106. package/src/plugin/elan/index.js +0 -307
  107. package/src/plugin/markers/index.js +0 -436
  108. package/src/plugin/mediasession/index.js +0 -94
  109. package/src/plugin/microphone/index.js +0 -415
  110. package/src/plugin/minimap/index.js +0 -403
  111. package/src/plugin/playhead/index.js +0 -226
  112. package/src/plugin/regions/index.js +0 -478
  113. package/src/plugin/regions/region.js +0 -883
  114. package/src/plugin/spectrogram/fft.js +0 -222
  115. package/src/plugin/spectrogram/index.js +0 -522
  116. package/src/plugin/timeline/index.js +0 -600
  117. package/src/util/absMax.js +0 -16
  118. package/src/util/clamp.js +0 -11
  119. package/src/util/fetch.js +0 -222
  120. package/src/util/frame.js +0 -13
  121. package/src/util/get-id.js +0 -22
  122. package/src/util/index.js +0 -14
  123. package/src/util/max.js +0 -16
  124. package/src/util/min.js +0 -16
  125. package/src/util/observer.js +0 -144
  126. package/src/util/orientation.js +0 -98
  127. package/src/util/prevent-click.js +0 -19
  128. package/src/util/request-animation-frame.js +0 -15
  129. package/src/util/silence-mode.js +0 -42
  130. package/src/util/style.js +0 -16
  131. package/src/wavesurfer.js +0 -1797
  132. package/src/webaudio.js +0 -779
package/LICENSE DELETED
@@ -1,29 +0,0 @@
1
- BSD 3-Clause License
2
-
3
- Copyright (c) 2012-2023, katspaugh and contributors
4
- All rights reserved.
5
-
6
- Redistribution and use in source and binary forms, with or without
7
- modification, are permitted provided that the following conditions are met:
8
-
9
- * Redistributions of source code must retain the above copyright notice, this
10
- list of conditions and the following disclaimer.
11
-
12
- * Redistributions in binary form must reproduce the above copyright notice,
13
- this list of conditions and the following disclaimer in the documentation
14
- and/or other materials provided with the distribution.
15
-
16
- * Neither the name of the copyright holder nor the names of its
17
- contributors may be used to endorse or promote products derived from
18
- this software without specific prior written permission.
19
-
20
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21
- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23
- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24
- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25
- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26
- SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27
- CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28
- OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -1,418 +0,0 @@
1
- /*!
2
- * wavesurfer.js cursor plugin 6.5.0 (2023-03-11)
3
- * https://wavesurfer-js.org
4
- * @license BSD-3-Clause
5
- */
6
- (function webpackUniversalModuleDefinition(root, factory) {
7
- if(typeof exports === 'object' && typeof module === 'object')
8
- module.exports = factory();
9
- else if(typeof define === 'function' && define.amd)
10
- define("WaveSurfer", [], factory);
11
- else if(typeof exports === 'object')
12
- exports["WaveSurfer"] = factory();
13
- else
14
- root["WaveSurfer"] = root["WaveSurfer"] || {}, root["WaveSurfer"]["cursor"] = factory();
15
- })(self, () => {
16
- return /******/ (() => { // webpackBootstrap
17
- /******/ "use strict";
18
- /******/ var __webpack_modules__ = ({
19
-
20
- /***/ "./src/plugin/cursor/index.js":
21
- /*!************************************!*\
22
- !*** ./src/plugin/cursor/index.js ***!
23
- \************************************/
24
- /***/ ((module, exports) => {
25
-
26
-
27
-
28
- Object.defineProperty(exports, "__esModule", ({
29
- value: true
30
- }));
31
- exports["default"] = void 0;
32
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
33
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
34
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
35
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
36
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
37
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
38
- function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
39
- /**
40
- * @typedef {Object} CursorPluginParams
41
- * @property {?boolean} deferInit Set to true to stop auto init in `addPlugin()`
42
- * @property {boolean} hideOnBlur=true Hide the cursor when the mouse leaves the
43
- * waveform
44
- * @property {string} width='1px' The width of the cursor
45
- * @property {string} color='black' The color of the cursor
46
- * @property {number|string} opacity='0.25' The opacity of the cursor
47
- * @property {string} style='solid' The border style of the cursor
48
- * @property {number} zIndex=3 The z-index of the cursor element
49
- * @property {object} customStyle An object with custom styles which are applied
50
- * to the cursor element
51
- * @property {boolean} showTime=false Show the time on the cursor.
52
- * @property {object} customShowTimeStyle An object with custom styles which are
53
- * applied to the cursor time element.
54
- * @property {boolean} followCursorY=false Use `true` to make the time on
55
- * the cursor follow the x and the y-position of the mouse. Use `false` to make the
56
- * it only follow the x-position of the mouse.
57
- * @property {function} formatTimeCallback Formats the timestamp on the cursor.
58
- * @property {boolean} isDestroyCalled true if called destroy before the ready event fired
59
- */
60
- /**
61
- * Displays a thin line at the position of the cursor on the waveform.
62
- *
63
- * @implements {PluginClass}
64
- * @extends {Observer}
65
- * @example
66
- * // es6
67
- * import CursorPlugin from 'wavesurfer.cursor.js';
68
- *
69
- * // commonjs
70
- * var CursorPlugin = require('wavesurfer.cursor.js');
71
- *
72
- * // if you are using <script> tags
73
- * var CursorPlugin = window.WaveSurfer.cursor;
74
- *
75
- * // ... initialising wavesurfer with the plugin
76
- * var wavesurfer = WaveSurfer.create({
77
- * // wavesurfer options ...
78
- * plugins: [
79
- * CursorPlugin.create({
80
- * // plugin options ...
81
- * })
82
- * ]
83
- * });
84
- */
85
- var CursorPlugin = /*#__PURE__*/function () {
86
- /**
87
- * Construct the plugin class. You probably want to use `CursorPlugin.create`
88
- * instead.
89
- *
90
- * @param {CursorPluginParams} params Plugin parameters
91
- * @param {object} ws Wavesurfer instance
92
- */
93
- function CursorPlugin(params, ws) {
94
- var _this = this;
95
- _classCallCheck(this, CursorPlugin);
96
- /**
97
- * @type {CursorPluginParams}
98
- */
99
- _defineProperty(this, "defaultParams", {
100
- hideOnBlur: true,
101
- width: '1px',
102
- color: 'black',
103
- opacity: '0.25',
104
- style: 'solid',
105
- zIndex: 4,
106
- customStyle: {},
107
- customShowTimeStyle: {},
108
- showTime: false,
109
- followCursorY: false,
110
- formatTimeCallback: null
111
- });
112
- /**
113
- * @param {object} e Mouse move event
114
- */
115
- _defineProperty(this, "_onMousemove", function (e) {
116
- var event = _this.util.withOrientation(e, _this.wavesurfer.params.vertical);
117
- var bbox = _this.wrapper.getBoundingClientRect();
118
- var y = 0;
119
- var x = _this.wrapper.scrollLeft + event.clientX - bbox.left;
120
- var displayTimeWidth = _this.displayTime ? _this.displayTime.getBoundingClientRect().width : 0;
121
- var flip = bbox.right < event.clientX + displayTimeWidth;
122
- if (_this.params.showTime && _this.params.followCursorY) {
123
- // follow y-position of the mouse
124
- y = event.clientY - (bbox.top + bbox.height / 2);
125
- }
126
- _this.updateCursorPosition(x, y, flip);
127
- });
128
- /**
129
- * @returns {void}
130
- */
131
- _defineProperty(this, "_onMouseenter", function () {
132
- return _this.showCursor();
133
- });
134
- /**
135
- * @returns {void}
136
- */
137
- _defineProperty(this, "_onMouseleave", function () {
138
- return _this.hideCursor();
139
- });
140
- this.wavesurfer = ws;
141
- this.style = ws.util.style;
142
- this.util = ws.util;
143
- /**
144
- * The cursor HTML element
145
- *
146
- * @type {?HTMLElement}
147
- */
148
- this.cursor = null;
149
- /**
150
- * displays the time next to the cursor
151
- *
152
- * @type {?HTMLElement}
153
- */
154
- this.showTime = null;
155
- /**
156
- * The html container that will display the time
157
- *
158
- * @type {?HTMLElement}
159
- */
160
- this.displayTime = null;
161
- /**
162
- * true when `destroy` was called before `ready` event
163
- * @type {boolean}
164
- */
165
- this.isDestroyCalled = false;
166
- this.params = Object.assign({}, this.defaultParams, params);
167
- }
168
- _createClass(CursorPlugin, [{
169
- key: "_onReady",
170
- value: function _onReady() {
171
- if (this.isDestroyCalled) {
172
- return;
173
- }
174
- this.wrapper = this.wavesurfer.drawer.wrapper;
175
- this.cursor = this.util.withOrientation(this.wrapper.appendChild(document.createElement('cursor')), this.wavesurfer.params.vertical);
176
- this.style(this.cursor, Object.assign({
177
- position: 'absolute',
178
- zIndex: this.params.zIndex,
179
- left: 0,
180
- top: 0,
181
- bottom: 0,
182
- width: '0',
183
- display: 'flex',
184
- borderRightStyle: this.params.style,
185
- borderRightWidth: this.params.width,
186
- borderRightColor: this.params.color,
187
- opacity: this.params.opacity,
188
- pointerEvents: 'none'
189
- }, this.params.customStyle));
190
- if (this.params.showTime) {
191
- this.showTime = this.util.withOrientation(this.wrapper.appendChild(document.createElement('showTitle')), this.wavesurfer.params.vertical);
192
- this.style(this.showTime, Object.assign({
193
- position: 'absolute',
194
- zIndex: this.params.zIndex,
195
- left: 0,
196
- top: 0,
197
- bottom: 0,
198
- width: 'auto',
199
- display: 'flex',
200
- opacity: this.params.opacity,
201
- pointerEvents: 'none',
202
- height: '100%'
203
- }, this.params.customStyle));
204
- this.displayTime = this.util.withOrientation(this.showTime.appendChild(document.createElement('div')), this.wavesurfer.params.vertical);
205
- this.style(this.displayTime, Object.assign({
206
- display: 'inline',
207
- pointerEvents: 'none',
208
- margin: 'auto',
209
- visibility: 'hidden' // initial value will be hidden just for measuring purpose
210
- }, this.params.customShowTimeStyle));
211
-
212
- // initial value to measure display width
213
- this.displayTime.innerHTML = this.formatTime(0);
214
- }
215
- this.wrapper.addEventListener('mousemove', this._onMousemove);
216
- if (this.params.hideOnBlur) {
217
- // ensure elements are hidden initially
218
- this.hideCursor();
219
- this.wrapper.addEventListener('mouseenter', this._onMouseenter);
220
- this.wrapper.addEventListener('mouseleave', this._onMouseleave);
221
- }
222
- }
223
-
224
- /**
225
- * Initialise the plugin (used by the Plugin API)
226
- */
227
- }, {
228
- key: "init",
229
- value: function init() {
230
- var _this2 = this;
231
- if (this.wavesurfer.isReady) {
232
- this._onReady();
233
- } else {
234
- this.wavesurfer.once('ready', function () {
235
- return _this2._onReady();
236
- });
237
- }
238
- }
239
-
240
- /**
241
- * Destroy the plugin (used by the Plugin API)
242
- */
243
- }, {
244
- key: "destroy",
245
- value: function destroy() {
246
- if (!this.cursorTime || !this.showTime) {
247
- this.isDestroyCalled = true;
248
- return;
249
- }
250
- if (this.params.showTime) {
251
- this.showTime && this.showTime.remove();
252
- }
253
- this.cursor && this.cursor.remove();
254
- this.wrapper.removeEventListener('mousemove', this._onMousemove);
255
- if (this.params.hideOnBlur) {
256
- this.wrapper.removeEventListener('mouseenter', this._onMouseenter);
257
- this.wrapper.removeEventListener('mouseleave', this._onMouseleave);
258
- }
259
- }
260
-
261
- /**
262
- * Update the cursor position
263
- *
264
- * @param {number} xpos The x offset of the cursor in pixels
265
- * @param {number} ypos The y offset of the cursor in pixels
266
- * @param {boolean} flip Flag to flip duration text from right to left
267
- */
268
- }, {
269
- key: "updateCursorPosition",
270
- value: function updateCursorPosition(xpos, ypos) {
271
- var flip = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
272
- this.style(this.cursor, {
273
- left: "".concat(xpos, "px")
274
- });
275
- if (this.params.showTime) {
276
- var duration = this.wavesurfer.getDuration();
277
- var elementWidth = this.wavesurfer.drawer.width / this.wavesurfer.params.pixelRatio;
278
- var scrollWidth = this.wavesurfer.drawer.getScrollX();
279
- var scrollTime = duration / this.wavesurfer.drawer.width * scrollWidth;
280
- var timeValue = Math.max(0, (xpos - this.wrapper.scrollLeft) / elementWidth * duration) + scrollTime;
281
- var formatValue = this.formatTime(timeValue);
282
- if (flip) {
283
- var textOffset = this.displayTime.getBoundingClientRect().width;
284
- xpos -= textOffset;
285
- }
286
- this.style(this.showTime, {
287
- left: "".concat(xpos, "px"),
288
- top: "".concat(ypos, "px")
289
- });
290
- this.style(this.displayTime, {
291
- visibility: 'visible'
292
- });
293
- this.displayTime.innerHTML = "".concat(formatValue);
294
- }
295
- }
296
-
297
- /**
298
- * Show the cursor
299
- */
300
- }, {
301
- key: "showCursor",
302
- value: function showCursor() {
303
- this.style(this.cursor, {
304
- display: 'flex'
305
- });
306
- if (this.params.showTime) {
307
- this.style(this.showTime, {
308
- display: 'flex'
309
- });
310
- }
311
- }
312
-
313
- /**
314
- * Hide the cursor
315
- */
316
- }, {
317
- key: "hideCursor",
318
- value: function hideCursor() {
319
- this.style(this.cursor, {
320
- display: 'none'
321
- });
322
- if (this.params.showTime) {
323
- this.style(this.showTime, {
324
- display: 'none'
325
- });
326
- }
327
- }
328
-
329
- /**
330
- * Format the timestamp for `cursorTime`.
331
- *
332
- * @param {number} cursorTime Time in seconds
333
- * @returns {string} Formatted timestamp
334
- */
335
- }, {
336
- key: "formatTime",
337
- value: function formatTime(cursorTime) {
338
- cursorTime = isNaN(cursorTime) ? 0 : cursorTime;
339
- if (this.params.formatTimeCallback) {
340
- return this.params.formatTimeCallback(cursorTime);
341
- }
342
- return [cursorTime].map(function (time) {
343
- return [Math.floor(time % 3600 / 60),
344
- // minutes
345
- ('00' + Math.floor(time % 60)).slice(-2),
346
- // seconds
347
- ('000' + Math.floor(time % 1 * 1000)).slice(-3) // milliseconds
348
- ].join(':');
349
- });
350
- }
351
- }], [{
352
- key: "create",
353
- value:
354
- /**
355
- * Cursor plugin definition factory
356
- *
357
- * This function must be used to create a plugin definition which can be
358
- * used by wavesurfer to correctly instantiate the plugin.
359
- *
360
- * @param {CursorPluginParams} params parameters use to initialise the
361
- * plugin
362
- * @return {PluginDefinition} an object representing the plugin
363
- */
364
- function create(params) {
365
- return {
366
- name: 'cursor',
367
- deferInit: params && params.deferInit ? params.deferInit : false,
368
- params: params,
369
- staticProps: {},
370
- instance: CursorPlugin
371
- };
372
- }
373
- }]);
374
- return CursorPlugin;
375
- }();
376
- exports["default"] = CursorPlugin;
377
- module.exports = exports.default;
378
-
379
- /***/ })
380
-
381
- /******/ });
382
- /************************************************************************/
383
- /******/ // The module cache
384
- /******/ var __webpack_module_cache__ = {};
385
- /******/
386
- /******/ // The require function
387
- /******/ function __webpack_require__(moduleId) {
388
- /******/ // Check if module is in cache
389
- /******/ var cachedModule = __webpack_module_cache__[moduleId];
390
- /******/ if (cachedModule !== undefined) {
391
- /******/ return cachedModule.exports;
392
- /******/ }
393
- /******/ // Create a new module (and put it into the cache)
394
- /******/ var module = __webpack_module_cache__[moduleId] = {
395
- /******/ // no module.id needed
396
- /******/ // no module.loaded needed
397
- /******/ exports: {}
398
- /******/ };
399
- /******/
400
- /******/ // Execute the module function
401
- /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
402
- /******/
403
- /******/ // Return the exports of the module
404
- /******/ return module.exports;
405
- /******/ }
406
- /******/
407
- /************************************************************************/
408
- /******/
409
- /******/ // startup
410
- /******/ // Load entry module and return exports
411
- /******/ // This entry module is referenced by other modules so it can't be inlined
412
- /******/ var __webpack_exports__ = __webpack_require__("./src/plugin/cursor/index.js");
413
- /******/
414
- /******/ return __webpack_exports__;
415
- /******/ })()
416
- ;
417
- });
418
- //# sourceMappingURL=wavesurfer.cursor.js.map
@@ -1 +0,0 @@
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;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CAAC,GAAI,IAAI,CAAC,EAAEE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QAAA,CACrD,CAACC,IAAI,CAAC,GAAG,CAAC;MAAA,EACd;IACL;EAAC;IAAArD,GAAA;IAAAC,KAAA;IA5SD;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;IACI,SAAAqD,OAAcpG,MAAM,EAAE;MAClB,OAAO;QACHqG,IAAI,EAAE,QAAQ;QACdC,SAAS,EAAEtG,MAAM,IAAIA,MAAM,CAACsG,SAAS,GAAGtG,MAAM,CAACsG,SAAS,GAAG,KAAK;QAChEtG,MAAM,EAAEA,MAAM;QACduG,WAAW,EAAE,CAAC,CAAC;QACfC,QAAQ,EAAEzG;MACd,CAAC;IACL;EAAC;EAAA,OAAAA,YAAA;AAAA;AAAA0G,kBAAA,GAAA1G,YAAA;AAAA4G,MAAA,CAAAF,OAAA,GAAAA,OAAA,CAAAC,OAAA;;;;;;UClEL;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 when `destroy` was called 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","_this","_classCallCheck","_defineProperty","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","_createClass","key","value","_onReady","drawer","appendChild","document","createElement","position","bottom","display","borderRightStyle","borderRightWidth","borderRightColor","pointerEvents","margin","visibility","innerHTML","formatTime","addEventListener","_onMousemove","_onMouseenter","_onMouseleave","init","_this2","isReady","once","destroy","cursorTime","remove","removeEventListener","xpos","ypos","arguments","length","undefined","concat","duration","getDuration","elementWidth","pixelRatio","scrollWidth","getScrollX","scrollTime","timeValue","Math","max","formatValue","textOffset","isNaN","map","time","floor","slice","join","create","name","deferInit","staticProps","instance","exports","default","module"],"sourceRoot":""}
@@ -1,7 +0,0 @@
1
- /*!
2
- * wavesurfer.js cursor plugin 6.5.0 (2023-03-11)
3
- * https://wavesurfer-js.org
4
- * @license BSD-3-Clause
5
- */
6
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("WaveSurfer",[],t):"object"==typeof exports?exports.WaveSurfer=t():(e.WaveSurfer=e.WaveSurfer||{},e.WaveSurfer.cursor=t())}(self,(()=>(()=>{"use strict";var e={178:(e,t)=>{function i(e){return i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i(e)}function r(e,t){for(var i=0;i<t.length;i++){var r=t[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,o(r.key),r)}}function s(e,t,i){return(t=o(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function o(e){var t=function(e,t){if("object"!==i(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var s=r.call(e,t||"default");if("object"!==i(s))return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"===i(t)?t:String(t)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var a=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,o=r.wrapper.scrollLeft+t.clientX-i.left,a=r.displayTime?r.displayTime.getBoundingClientRect().width:0,n=i.right<t.clientX+a;r.params.showTime&&r.params.followCursorY&&(s=t.clientY-(i.top+i.height/2)),r.updateCursorPosition(o,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,i,o;return t=e,i=[{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 r=this.wavesurfer.getDuration(),s=this.wavesurfer.drawer.width/this.wavesurfer.params.pixelRatio,o=this.wavesurfer.drawer.getScrollX(),a=r/this.wavesurfer.drawer.width*o,n=Math.max(0,(e-this.wrapper.scrollLeft)/s*r)+a,l=this.formatTime(n);i&&(e-=this.displayTime.getBoundingClientRect().width),this.style(this.showTime,{left:"".concat(e,"px"),top:"".concat(t,"px")}),this.style(this.displayTime,{visibility:"visible"}),this.displayTime.innerHTML="".concat(l)}}},{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(":")}))}}],o=[{key:"create",value:function(t){return{name:"cursor",deferInit:!(!t||!t.deferInit)&&t.deferInit,params:t,staticProps:{},instance:e}}}],i&&r(t.prototype,i),o&&r(t,o),Object.defineProperty(t,"prototype",{writable:!1}),e}();t.default=a,e.exports=t.default}},t={};var i=function i(r){var s=t[r];if(void 0!==s)return s.exports;var o=t[r]={exports:{}};return e[r](o,o.exports,i),o.exports}(178);return i})()));
7
- //# sourceMappingURL=wavesurfer.cursor.min.js.map
@@ -1 +0,0 @@
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,IACT,M,m7BCYA,IAyBqBC,EAAY,WA0E7B,SAAAA,EAAYC,EAAQC,GAAI,IAAAC,EAAA,M,4FAAAC,CAA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QAGrB,IAAIC,EAAS2G,EAAyBG,GAAY,CAGjD/G,QAAS,CAAC,GAOX,OAHAiH,EAAoBF,GAAU9G,EAAQA,EAAOD,QAAS8G,GAG/C7G,EAAOD,OACf,CCnB0B8G,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 * @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 when `destroy` was called 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","_this","_classCallCheck","_defineProperty","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","key","value","drawer","appendChild","document","createElement","position","bottom","display","borderRightStyle","borderRightWidth","borderRightColor","pointerEvents","margin","visibility","innerHTML","formatTime","addEventListener","_onMousemove","_onMouseenter","_onMouseleave","_this2","isReady","_onReady","once","cursorTime","remove","removeEventListener","xpos","ypos","arguments","length","undefined","concat","duration","getDuration","elementWidth","pixelRatio","scrollWidth","getScrollX","scrollTime","timeValue","Math","max","formatValue","isNaN","map","time","floor","slice","join","name","deferInit","staticProps","instance","default","__webpack_module_cache__","__webpack_exports__","__webpack_require__","moduleId","cachedModule","__webpack_modules__"],"sourceRoot":""}