wavesurfer.js 6.2.0 → 6.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/CHANGES.md +8 -0
  2. package/LICENSE +1 -1
  3. package/README.md +0 -10
  4. package/dist/plugin/wavesurfer.cursor.js +1 -1
  5. package/dist/plugin/wavesurfer.cursor.min.js +1 -1
  6. package/dist/plugin/wavesurfer.cursor.min.js.map +1 -1
  7. package/dist/plugin/wavesurfer.elan.js +1 -1
  8. package/dist/plugin/wavesurfer.elan.min.js +1 -1
  9. package/dist/plugin/wavesurfer.elan.min.js.map +1 -1
  10. package/dist/plugin/wavesurfer.markers.js +41 -6
  11. package/dist/plugin/wavesurfer.markers.js.map +1 -1
  12. package/dist/plugin/wavesurfer.markers.min.js +2 -2
  13. package/dist/plugin/wavesurfer.markers.min.js.map +1 -1
  14. package/dist/plugin/wavesurfer.mediasession.js +1 -1
  15. package/dist/plugin/wavesurfer.mediasession.min.js +1 -1
  16. package/dist/plugin/wavesurfer.mediasession.min.js.map +1 -1
  17. package/dist/plugin/wavesurfer.microphone.js +1 -1
  18. package/dist/plugin/wavesurfer.microphone.min.js +1 -1
  19. package/dist/plugin/wavesurfer.microphone.min.js.map +1 -1
  20. package/dist/plugin/wavesurfer.minimap.js +1 -1
  21. package/dist/plugin/wavesurfer.minimap.min.js +1 -1
  22. package/dist/plugin/wavesurfer.minimap.min.js.map +1 -1
  23. package/dist/plugin/wavesurfer.playhead.js +1 -1
  24. package/dist/plugin/wavesurfer.playhead.min.js +1 -1
  25. package/dist/plugin/wavesurfer.playhead.min.js.map +1 -1
  26. package/dist/plugin/wavesurfer.regions.js +2 -2
  27. package/dist/plugin/wavesurfer.regions.js.map +1 -1
  28. package/dist/plugin/wavesurfer.regions.min.js +2 -2
  29. package/dist/plugin/wavesurfer.regions.min.js.map +1 -1
  30. package/dist/plugin/wavesurfer.spectrogram.js +2 -2
  31. package/dist/plugin/wavesurfer.spectrogram.js.map +1 -1
  32. package/dist/plugin/wavesurfer.spectrogram.min.js +2 -2
  33. package/dist/plugin/wavesurfer.spectrogram.min.js.map +1 -1
  34. package/dist/plugin/wavesurfer.timeline.js +1 -1
  35. package/dist/plugin/wavesurfer.timeline.min.js +1 -1
  36. package/dist/plugin/wavesurfer.timeline.min.js.map +1 -1
  37. package/dist/wavesurfer-html-init.js +1 -1
  38. package/dist/wavesurfer-html-init.js.map +1 -1
  39. package/dist/wavesurfer-html-init.min.js +1 -1
  40. package/dist/wavesurfer-html-init.min.js.map +1 -1
  41. package/dist/wavesurfer.js +32 -29
  42. package/dist/wavesurfer.js.map +1 -1
  43. package/dist/wavesurfer.min.js +2 -2
  44. package/dist/wavesurfer.min.js.map +1 -1
  45. package/package.json +18 -19
  46. package/src/drawer.multicanvas.js +4 -4
  47. package/src/plugin/markers/index.js +31 -5
  48. package/src/plugin/regions/index.js +1 -1
  49. package/src/plugin/spectrogram/index.js +1 -1
  50. package/src/wavesurfer.js +12 -9
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wavesurfer.js",
3
- "version": "6.2.0",
3
+ "version": "6.3.0",
4
4
  "description": "Interactive navigable audio visualization using Web Audio and Canvas",
5
5
  "main": "dist/wavesurfer.js",
6
6
  "directories": {
@@ -55,17 +55,16 @@
55
55
  "visualization"
56
56
  ],
57
57
  "devDependencies": {
58
- "@babel/core": "^7.17.8",
59
- "@babel/eslint-parser": "^7.17.0",
60
- "@babel/plugin-proposal-class-properties": "^7.16.7",
61
- "@babel/preset-env": "^7.16.11",
62
- "@babel/register": "^7.17.7",
63
- "@chiragrupani/karma-chromium-edge-launcher": "^2.2.1",
64
- "babel-loader": "^8.2.4",
58
+ "@babel/core": "^7.19.3",
59
+ "@babel/eslint-parser": "^7.19.1",
60
+ "@babel/plugin-proposal-class-properties": "^7.18.6",
61
+ "@babel/preset-env": "^7.19.3",
62
+ "@babel/register": "^7.18.9",
63
+ "@chiragrupani/karma-chromium-edge-launcher": "^2.2.2",
64
+ "babel-loader": "^8.2.5",
65
65
  "babel-plugin-add-module-exports": "^1.0.4",
66
66
  "babel-plugin-istanbul": "^6.1.1",
67
- "babel-plugin-proxy": "^1.1.0",
68
- "date-fns": "^2.28.0",
67
+ "date-fns": "^2.29.3",
69
68
  "debounce": "^1.2.1",
70
69
  "esdoc": "^1.1.0",
71
70
  "esdoc-accessor-plugin": "^1.0.0",
@@ -74,24 +73,24 @@
74
73
  "esdoc-ecmascript-proposal-plugin": "^1.0.0",
75
74
  "esdoc-integrate-test-plugin": "^1.0.0",
76
75
  "esdoc-standard-plugin": "^1.0.0",
77
- "eslint": "^8.11.0",
78
- "htmlhint": "^1.1.2",
76
+ "eslint": "^8.24.0",
77
+ "htmlhint": "^1.1.4",
79
78
  "in-publish": "^2.0.1",
80
- "jasmine-core": "^4.0.1",
81
- "karma": "^6.3.17",
79
+ "jasmine-core": "^4.4.0",
80
+ "karma": "^6.4.1",
82
81
  "karma-chrome-launcher": "3.1.1",
83
82
  "karma-coverage": "^2.2.0",
84
83
  "karma-firefox-launcher": "^2.1.2",
85
- "karma-jasmine": "4.0.1",
84
+ "karma-jasmine": "5.1.0",
86
85
  "karma-jasmine-matchers": "5.0.0",
87
86
  "karma-verbose-reporter": "0.0.8",
88
87
  "karma-webpack": "^5.0.0",
89
- "lint-staged": "^12.3.7",
88
+ "lint-staged": "^13.0.3",
90
89
  "load-script": "^2.0.0",
91
90
  "pre-commit": "^1.2.2",
92
- "webpack": "^5.70.0",
93
- "webpack-cli": "^4.9.2",
94
- "webpack-dev-server": "^4.7.4",
91
+ "webpack": "^5.74.0",
92
+ "webpack-cli": "^4.10.0",
93
+ "webpack-dev-server": "^4.11.1",
95
94
  "webpack-merge": "^5.8.0"
96
95
  },
97
96
  "homepage": "https://wavesurfer-js.org",
@@ -323,10 +323,10 @@ export default class MultiCanvas extends Drawer {
323
323
  // calculate the height of this bar according to the highest peak found
324
324
  let h = Math.round((peak / absmax) * halfH);
325
325
 
326
- // in case of silences, allow the user to specify that we
327
- // always draw *something* (normally a 1px high bar)
328
- if (h == 0 && this.params.barMinHeight) {
329
- h = this.params.barMinHeight;
326
+ // raise the bar height to the specified minimum height
327
+ // Math.max is used to replace any value smaller than barMinHeight (not just 0) with barMinHeight
328
+ if (this.params.barMinHeight) {
329
+ h = Math.max(h, this.params.barMinHeight);
330
330
  }
331
331
 
332
332
  this.fillRect(
@@ -8,6 +8,8 @@
8
8
  * @property {?position} string "top" or "bottom", defaults to "bottom"
9
9
  * @property {?markerElement} element An HTML element to display instead of the default marker image
10
10
  * @property {?draggable} boolean Set marker as draggable, defaults to false
11
+ * @property {?boolean} preventContextMenu Determines whether the context menu
12
+ * is prevented from being opened, defaults to false
11
13
  */
12
14
 
13
15
 
@@ -159,7 +161,8 @@ export default class MarkersPlugin {
159
161
  label: params.label,
160
162
  color: params.color || DEFAULT_FILL_COLOR,
161
163
  position: params.position || DEFAULT_POSITION,
162
- draggable: !!params.draggable
164
+ draggable: !!params.draggable,
165
+ preventContextMenu: !!params.preventContextMenu
163
166
  };
164
167
 
165
168
  marker.el = this._createMarkerElement(marker, params.markerElement);
@@ -181,6 +184,18 @@ export default class MarkersPlugin {
181
184
  if (!marker) {
182
185
  return;
183
186
  }
187
+ let label = marker.el.getElementsByClassName("marker-label")[0];
188
+ if (label) {
189
+ if (label._onContextMenu) {
190
+ label.removeEventListener("contextmenu", label._onContextMenu);
191
+ }
192
+ if (label._onClick) {
193
+ label.removeEventListener("click", label._onClick);
194
+ }
195
+ if (label._onMouseDown) {
196
+ label.removeEventListener("mousedown", label._onMouseDown);
197
+ }
198
+ }
184
199
 
185
200
  this.wrapper.removeChild(marker.el);
186
201
  this.markers.splice(index, 1);
@@ -262,10 +277,11 @@ export default class MarkersPlugin {
262
277
  "align-items": "center",
263
278
  cursor: "pointer"
264
279
  });
280
+ labelDiv.classList.add("marker-label");
265
281
 
266
282
  el.appendChild(labelDiv);
267
283
 
268
- labelDiv.addEventListener("click", e => {
284
+ labelDiv._onClick = (e) => {
269
285
  e.stopPropagation();
270
286
  // Click event is caught when the marker-drop event was dispatched.
271
287
  // Drop event was dispatched at this moment, but this.dragging
@@ -275,12 +291,22 @@ export default class MarkersPlugin {
275
291
  }
276
292
  this.wavesurfer.setCurrentTime(marker.time);
277
293
  this.wavesurfer.fireEvent("marker-click", marker, e);
278
- });
294
+ };
295
+ labelDiv.addEventListener("click", labelDiv._onClick);
296
+
297
+ labelDiv._onContextMenu = (e) => {
298
+ if (marker.preventContextMenu) {
299
+ e.preventDefault();
300
+ }
301
+ this.wavesurfer.fireEvent("marker-contextmenu", marker, e);
302
+ };
303
+ labelDiv.addEventListener("contextmenu", labelDiv._onContextMenu);
279
304
 
280
305
  if (marker.draggable) {
281
- labelDiv.addEventListener("mousedown", e => {
306
+ labelDiv._onMouseDown = () => {
282
307
  this.selectedMarker = marker;
283
- });
308
+ };
309
+ labelDiv.addEventListener("mousedown", labelDiv._onMouseDown);
284
310
  }
285
311
  return el;
286
312
  }
@@ -299,7 +299,7 @@ export default class RegionsPlugin {
299
299
  );
300
300
 
301
301
  // set the region channel index based on the clicked area
302
- if (this.wavesurfer.params.splitChannels) {
302
+ if (this.wavesurfer.params.splitChannels && this.wavesurfer.params.splitChannelsOptions.splitDragSelection) {
303
303
  const y = (e.touches ? e.touches[0].clientY : e.clientY) - wrapperRect.top;
304
304
  const channelCount = this.wavesurfer.backend.buffer != null ? this.wavesurfer.backend.buffer.numberOfChannels : 1;
305
305
  const channelHeight = this.wrapper.clientHeight / channelCount;
@@ -187,7 +187,7 @@ export default class SpectrogramPlugin {
187
187
  const labelsEl = (this.labelsEl = document.createElement('canvas'));
188
188
  labelsEl.classList.add('spec-labels');
189
189
  this.drawer.style(labelsEl, {
190
- position: 'fixed',
190
+ position: 'absolute',
191
191
  zIndex: 9,
192
192
  height: `${this.height * this.channels}px`,
193
193
  width: `55px`
package/src/wavesurfer.js CHANGED
@@ -174,6 +174,8 @@ import MediaElementWebAudio from './mediaelement-webaudio';
174
174
  * @property {boolean} relativeNormalization=false determines whether
175
175
  * normalization is done per channel or maintains proportionality between
176
176
  * channels. Only applied when normalize and splitChannels are both true.
177
+ * @property {boolean} splitDragSelection=false determines if drag selection in regions
178
+ * plugin works separately on each channel or only one selection for all channels
177
179
  * @since 4.3.0
178
180
  */
179
181
 
@@ -298,7 +300,8 @@ export default class WaveSurfer extends util.Observer {
298
300
  overlay: false,
299
301
  channelColors: {},
300
302
  filterChannels: [],
301
- relativeNormalization: false
303
+ relativeNormalization: false,
304
+ splitDragSelection: false
302
305
  },
303
306
  vertical: false,
304
307
  waveColor: '#999',
@@ -1684,19 +1687,19 @@ export default class WaveSurfer extends util.Observer {
1684
1687
  /**
1685
1688
  * Save waveform image as data URI.
1686
1689
  *
1687
- * The default format is `'image/png'`. Other supported types are
1688
- * `'image/jpeg'` and `'image/webp'`.
1690
+ * The default format is `image/png`. Other supported types are
1691
+ * `image/jpeg` and `image/webp`.
1689
1692
  *
1690
1693
  * @param {string} format='image/png' A string indicating the image format.
1691
- * The default format type is `'image/png'`.
1694
+ * The default format type is `image/png`.
1692
1695
  * @param {number} quality=1 A number between 0 and 1 indicating the image
1693
1696
  * quality to use for image formats that use lossy compression such as
1694
- * `'image/jpeg'`` and `'image/webp'`.
1695
- * @param {string} type Image data type to return. Either 'dataURL' (default)
1696
- * or 'blob'.
1697
- * @return {string|string[]|Promise} When using `'dataURL'` type this returns
1697
+ * `image/jpeg` and `image/webp`.
1698
+ * @param {string} type Image data type to return. Either `dataURL` (default)
1699
+ * or `blob`.
1700
+ * @return {string|string[]|Promise} When using `dataURL` type this returns
1698
1701
  * a single data URL or an array of data URLs, one for each canvas. When using
1699
- * `'blob'` type this returns a `Promise` resolving with an array of `Blob`
1702
+ * `blob` type this returns a `Promise` resolving with an array of `Blob`
1700
1703
  * instances, one for each canvas.
1701
1704
  */
1702
1705
  exportImage(format, quality, type) {