wavesurfer.js 6.0.0 → 6.0.3

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 (36) hide show
  1. package/CHANGES.md +24 -4
  2. package/dist/plugin/wavesurfer.cursor.js +5 -5
  3. package/dist/plugin/wavesurfer.cursor.js.map +1 -1
  4. package/dist/plugin/wavesurfer.cursor.min.js +2 -2
  5. package/dist/plugin/wavesurfer.cursor.min.js.map +1 -1
  6. package/dist/plugin/wavesurfer.elan.js +1 -1
  7. package/dist/plugin/wavesurfer.elan.min.js +1 -1
  8. package/dist/plugin/wavesurfer.markers.js +1 -1
  9. package/dist/plugin/wavesurfer.markers.min.js +1 -1
  10. package/dist/plugin/wavesurfer.mediasession.js +1 -1
  11. package/dist/plugin/wavesurfer.mediasession.min.js +1 -1
  12. package/dist/plugin/wavesurfer.microphone.js +1 -1
  13. package/dist/plugin/wavesurfer.microphone.min.js +1 -1
  14. package/dist/plugin/wavesurfer.minimap.js +1 -1
  15. package/dist/plugin/wavesurfer.minimap.min.js +1 -1
  16. package/dist/plugin/wavesurfer.playhead.js +1 -1
  17. package/dist/plugin/wavesurfer.playhead.min.js +1 -1
  18. package/dist/plugin/wavesurfer.regions.js +1 -1
  19. package/dist/plugin/wavesurfer.regions.js.map +1 -1
  20. package/dist/plugin/wavesurfer.regions.min.js +1 -1
  21. package/dist/plugin/wavesurfer.regions.min.js.map +1 -1
  22. package/dist/plugin/wavesurfer.spectrogram.js +1 -1
  23. package/dist/plugin/wavesurfer.spectrogram.min.js +1 -1
  24. package/dist/plugin/wavesurfer.timeline.js +1 -1
  25. package/dist/plugin/wavesurfer.timeline.min.js +1 -1
  26. package/dist/wavesurfer-html-init.js +1 -1
  27. package/dist/wavesurfer-html-init.min.js +1 -1
  28. package/dist/wavesurfer.js +13 -10
  29. package/dist/wavesurfer.js.map +1 -1
  30. package/dist/wavesurfer.min.js +2 -2
  31. package/dist/wavesurfer.min.js.map +1 -1
  32. package/package.json +8 -8
  33. package/src/drawer.canvasentry.js +10 -7
  34. package/src/drawer.multicanvas.js +1 -1
  35. package/src/plugin/cursor/index.js +4 -4
  36. package/src/plugin/regions/index.js +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wavesurfer.js",
3
- "version": "6.0.0",
3
+ "version": "6.0.3",
4
4
  "description": "Interactive navigable audio visualization using Web Audio and Canvas",
5
5
  "main": "dist/wavesurfer.js",
6
6
  "directories": {
@@ -55,7 +55,7 @@
55
55
  "visualization"
56
56
  ],
57
57
  "devDependencies": {
58
- "@babel/core": "^7.17.0",
58
+ "@babel/core": "^7.17.5",
59
59
  "@babel/eslint-parser": "^7.17.0",
60
60
  "@babel/plugin-proposal-class-properties": "^7.16.7",
61
61
  "@babel/preset-env": "^7.16.11",
@@ -74,22 +74,22 @@
74
74
  "esdoc-ecmascript-proposal-plugin": "^1.0.0",
75
75
  "esdoc-integrate-test-plugin": "^1.0.0",
76
76
  "esdoc-standard-plugin": "^1.0.0",
77
- "eslint": "^8.8.0",
77
+ "eslint": "^8.10.0",
78
78
  "htmlhint": "^1.1.2",
79
79
  "in-publish": "^2.0.1",
80
- "jasmine-core": "^4.0.0",
81
- "karma": "^6.3.15",
80
+ "jasmine-core": "^4.0.1",
81
+ "karma": "^6.3.17",
82
82
  "karma-chrome-launcher": "3.1.0",
83
- "karma-coverage": "^2.1.1",
83
+ "karma-coverage": "^2.2.0",
84
84
  "karma-firefox-launcher": "^2.1.2",
85
85
  "karma-jasmine": "4.0.1",
86
86
  "karma-jasmine-matchers": "5.0.0",
87
87
  "karma-verbose-reporter": "0.0.8",
88
88
  "karma-webpack": "^5.0.0",
89
- "lint-staged": "^12.3.3",
89
+ "lint-staged": "^12.3.4",
90
90
  "load-script": "^2.0.0",
91
91
  "pre-commit": "^1.2.2",
92
- "webpack": "^5.68.0",
92
+ "webpack": "^5.69.1",
93
93
  "webpack-cli": "^4.9.2",
94
94
  "webpack-dev-server": "^4.7.4",
95
95
  "webpack-merge": "^5.8.0"
@@ -161,17 +161,20 @@ export default class CanvasEntry {
161
161
  /**
162
162
  * Utility function to handle wave color arguments
163
163
  *
164
- * When the color argument type is a string, it will be returned as is.
165
- * Otherwise, it will be treated as an array, and a canvas gradient will
166
- * be returned
164
+ * When the color argument type is a string or CanvasGradient instance,
165
+ * it will be returned as is. Otherwise, it will be treated as an array,
166
+ * and a new CanvasGradient will be returned
167
167
  *
168
- * @since 5.3.0
168
+ * @since 6.0.0
169
169
  * @param {CanvasRenderingContext2D} ctx Rendering context of target canvas
170
- * @param {string|string[]} color Fill color for the wave canvas, or an array of colors to apply as a gradient
171
- * @returns {string|CanvasGradient} Returns a string fillstyle value, or a canvas gradient
170
+ * @param {string|string[]|CanvasGradient} color Either a single fill color
171
+ * for the wave canvas, an existing CanvasGradient instance, or an array
172
+ * of colors to apply as a gradient
173
+ * @returns {string|CanvasGradient} Returns a string fillstyle value, or a
174
+ * canvas gradient
172
175
  */
173
176
  getFillStyle(ctx, color) {
174
- if (typeof color == 'string') {
177
+ if (typeof color == 'string' || color instanceof CanvasGradient) {
175
178
  return color;
176
179
  }
177
180
 
@@ -313,7 +313,7 @@ export default class MultiCanvas extends Drawer {
313
313
  let peakIndexRange = Math.floor(peakIndex * scale) * peakIndexScale; // start index
314
314
  const peakIndexEnd = Math.floor((peakIndex + step) * scale) * peakIndexScale;
315
315
  do { // do..while makes sure at least one peak is always evaluated
316
- const newPeak = peaks[peakIndexRange];
316
+ const newPeak = Math.abs(peaks[peakIndexRange]); // for arrays starting with negative values
317
317
  if (newPeak > peak) {
318
318
  peak = newPeak; // higher
319
319
  }
@@ -5,7 +5,7 @@
5
5
  * waveform
6
6
  * @property {string} width='1px' The width of the cursor
7
7
  * @property {string} color='black' The color of the cursor
8
- * @property {string} opacity='0.25' The opacity of the cursor
8
+ * @property {number|string} opacity='0.25' The opacity of the cursor
9
9
  * @property {string} style='solid' The border style of the cursor
10
10
  * @property {number} zIndex=3 The z-index of the cursor element
11
11
  * @property {object} customStyle An object with custom styles which are applied
@@ -13,7 +13,7 @@
13
13
  * @property {boolean} showTime=false Show the time on the cursor.
14
14
  * @property {object} customShowTimeStyle An object with custom styles which are
15
15
  * applied to the cursor time element.
16
- * @property {string} followCursorY=false Use `true` to make the time on
16
+ * @property {boolean} followCursorY=false Use `true` to make the time on
17
17
  * the cursor follow the x and the y-position of the mouse. Use `false` to make the
18
18
  * it only follow the x-position of the mouse.
19
19
  * @property {function} formatTimeCallback Formats the timestamp on the cursor.
@@ -237,9 +237,9 @@ export default class CursorPlugin {
237
237
  */
238
238
  destroy() {
239
239
  if (this.params.showTime) {
240
- this.cursor.parentNode.removeChild(this.showTime);
240
+ this.showTime.remove();
241
241
  }
242
- this.cursor.parentNode.removeChild(this.cursor);
242
+ this.cursor.remove();
243
243
  this.wrapper.removeEventListener('mousemove', this._onMousemove);
244
244
  if (this.params.hideOnBlur) {
245
245
  this.wrapper.removeEventListener('mouseenter', this._onMouseenter);
@@ -10,7 +10,7 @@
10
10
  * @property {?number} snapToGridInterval Snap the regions to a grid of the specified multiples in seconds
11
11
  * @property {?number} snapToGridOffset Shift the snap-to-grid by the specified seconds. May also be negative.
12
12
  * @property {?boolean} deferInit Set to true to manually call
13
- * @property {number[]} maxRegions Maximum number of regions that may be created by the user at one time.
13
+ * @property {number} maxRegions Maximum number of regions that may be created by the user at one time.
14
14
  * `initPlugin('regions')`
15
15
  * @property {function} formatTimeCallback Allows custom formating for region tooltip.
16
16
  * @property {?number} edgeScrollWidth='5% from container edges' Optional width for edgeScroll to start