@checksub_team/peaks_timeline 1.4.47 → 1.4.50

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@checksub_team/peaks_timeline",
3
- "version": "1.4.47",
3
+ "version": "1.4.50",
4
4
  "description": "JavaScript UI component for displaying audio waveforms",
5
5
  "main": "./peaks.js",
6
6
  "types": "./peaks.js.d.ts",
package/peaks.js CHANGED
@@ -16693,21 +16693,26 @@ module.exports = function (Konva, SegmentMarker, Utils) {
16693
16693
  module.exports = function (Utils) {
16694
16694
  'use strict';
16695
16695
  function validateSegment(peaks, options, context) {
16696
+ var shouldNotifyUpdate = false;
16696
16697
  if (!Utils.isValidTime(options.startTime)) {
16697
16698
  throw new TypeError('peaks.segments.' + context + ': startTime should be a valid number');
16698
16699
  }
16699
16700
  if (!Utils.isValidTime(options.endTime)) {
16700
16701
  options.endTime = options.startTime;
16702
+ shouldNotifyUpdate = true;
16701
16703
  }
16702
16704
  options.startTime = Utils.roundTime(options.startTime);
16703
16705
  options.endTime = Utils.roundTime(options.endTime);
16704
16706
  if (options.startTime < 0) {
16705
16707
  options.startTime = 0;
16708
+ shouldNotifyUpdate = true;
16706
16709
  }
16707
16710
  if (options.endTime < 0) {
16708
16711
  options.endTime = 0;
16712
+ shouldNotifyUpdate = true;
16709
16713
  } else if (options.endTime - options.startTime < peaks.options.minSegmentSize) {
16710
16714
  options.endTime = options.startTime + peaks.options.minSegmentSize;
16715
+ shouldNotifyUpdate = true;
16711
16716
  }
16712
16717
  options.startTime = Utils.roundTime(options.startTime);
16713
16718
  options.endTime = Utils.roundTime(options.endTime);
@@ -16732,6 +16737,7 @@ module.exports = function (Utils) {
16732
16737
  } else if (!Utils.isValidColor(options.hoverColor)) {
16733
16738
  throw new TypeError('peaks.segments.' + context + ': hoverColor must be a boolean');
16734
16739
  }
16740
+ return shouldNotifyUpdate;
16735
16741
  }
16736
16742
  function Segment(peaks, id, startTime, endTime, labelText, color, textColor, handleTextColor, hoverColor, opacity, editable, allowDeletion, line, indicators) {
16737
16743
  var opts = {
@@ -16748,7 +16754,7 @@ module.exports = function (Utils) {
16748
16754
  line: line,
16749
16755
  indicators: indicators
16750
16756
  };
16751
- validateSegment(peaks, opts, 'add()');
16757
+ var shouldNotifyUpdate = validateSegment(peaks, opts, 'add()');
16752
16758
  this._peaks = peaks;
16753
16759
  this._id = id;
16754
16760
  this._startTime = opts.startTime;
@@ -16764,6 +16770,9 @@ module.exports = function (Utils) {
16764
16770
  this._line = opts.line;
16765
16771
  this._indicators = opts.indicators;
16766
16772
  this._minSize = peaks.options.minSegmentSize;
16773
+ if (shouldNotifyUpdate) {
16774
+ peaks.emit('segments.updated', [this]);
16775
+ }
16767
16776
  }
16768
16777
  Object.defineProperties(Segment.prototype, {
16769
16778
  id: {
@@ -16873,7 +16882,7 @@ module.exports = function (Utils) {
16873
16882
  indicators: this.indicators
16874
16883
  };
16875
16884
  Utils.extend(opts, options);
16876
- validateSegment(this._peaks, opts, 'update()');
16885
+ var shouldNotifyUpdate = validateSegment(this._peaks, opts, 'update()');
16877
16886
  this._startTime = opts.startTime;
16878
16887
  this._endTime = opts.endTime;
16879
16888
  this._labelText = opts.labelText;
@@ -16887,6 +16896,9 @@ module.exports = function (Utils) {
16887
16896
  this._line = opts.line;
16888
16897
  this._indicators = opts.indicators;
16889
16898
  this._peaks.emit('segment.updated', this);
16899
+ if (shouldNotifyUpdate) {
16900
+ this._peaks.emit('segments.updated', [this]);
16901
+ }
16890
16902
  };
16891
16903
  Segment.prototype.isVisible = function (startTime, endTime) {
16892
16904
  return this.startTime < endTime && startTime < this.endTime;
@@ -17452,6 +17464,7 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Konva) {
17452
17464
  this._group.on('dragend', this._onSourceGroupDragEnd.bind(this));
17453
17465
  this._addWrap(true);
17454
17466
  this._addUnwrap(true);
17467
+ this._addTitle(true);
17455
17468
  this._addHandles(true);
17456
17469
  this.setWrapping(source.wrapped);
17457
17470
  }
@@ -17504,12 +17517,7 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Konva) {
17504
17517
  this._width = newWidth;
17505
17518
  this._rightHandle.x(newWidth - HANDLE_WIDTH);
17506
17519
  this.updatePreviews();
17507
- var title = this._wrap.getChildren(function (node) {
17508
- return node.getClassName() === 'Text';
17509
- });
17510
- if (title) {
17511
- title.width(newWidth - 10);
17512
- }
17520
+ this._title.width(newWidth - 10);
17513
17521
  }
17514
17522
  };
17515
17523
  SourceGroup.prototype.setWrapping = function (wrap) {
@@ -17736,10 +17744,20 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Konva) {
17736
17744
  }
17737
17745
  });
17738
17746
  }
17747
+ wrap.add(background);
17748
+ return wrap;
17749
+ };
17750
+ SourceGroup.prototype._addTitle = function (forceCreate) {
17751
+ if (!this._title || forceCreate) {
17752
+ this._title = this._createTitle();
17753
+ }
17754
+ this._group.add(this._title);
17755
+ };
17756
+ SourceGroup.prototype._createTitle = function () {
17739
17757
  var title = new Konva.Text({
17740
17758
  x: 5,
17759
+ y: 5,
17741
17760
  width: this._width - 10,
17742
- height: this._wrappedHeight,
17743
17761
  text: Utils.removeLineBreaks(this._source.title),
17744
17762
  textAlign: 'left',
17745
17763
  verticalAlign: 'middle',
@@ -17750,9 +17768,7 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Konva) {
17750
17768
  ellipsis: true,
17751
17769
  listening: false
17752
17770
  });
17753
- wrap.add(background);
17754
- wrap.add(title);
17755
- return wrap;
17771
+ return title;
17756
17772
  };
17757
17773
  SourceGroup.prototype.getWidth = function () {
17758
17774
  return this._width;
@@ -18244,13 +18260,14 @@ module.exports = function (Utils) {
18244
18260
  options.wrapped = false;
18245
18261
  }
18246
18262
  }
18247
- function Source(peaks, id, originId, elementId, title, url, previewUrl, binaryUrl, kind, duration, startTime, endTime, mediaStartTime, mediaEndTime, color, borderColor, selectedColor, textColor, borderWidth, wrapped, position, draggable, resizable, wrapping, previewHeight, binaryHeight) {
18263
+ function Source(peaks, id, originId, elementId, title, url, previewUrl, binaryUrl, kind, subkind, duration, startTime, endTime, mediaStartTime, mediaEndTime, color, borderColor, selectedColor, textColor, borderWidth, wrapped, position, draggable, resizable, wrapping, previewHeight, binaryHeight) {
18248
18264
  var opts = {
18249
18265
  title: title,
18250
18266
  url: url,
18251
18267
  previewUrl: previewUrl,
18252
18268
  binaryUrl: binaryUrl,
18253
18269
  kind: kind,
18270
+ subkind: subkind,
18254
18271
  duration: duration,
18255
18272
  startTime: startTime,
18256
18273
  endTime: endTime,
@@ -18279,6 +18296,7 @@ module.exports = function (Utils) {
18279
18296
  this._previewUrl = opts.previewUrl;
18280
18297
  this._binaryUrl = opts.binaryUrl;
18281
18298
  this._kind = opts.kind;
18299
+ this._subkind = opts.subkind;
18282
18300
  this._duration = opts.duration;
18283
18301
  this._startTime = opts.startTime;
18284
18302
  this._endTime = opts.endTime;
@@ -18353,6 +18371,15 @@ module.exports = function (Utils) {
18353
18371
  this._kind = kind;
18354
18372
  }
18355
18373
  },
18374
+ subkind: {
18375
+ enumerable: true,
18376
+ get: function () {
18377
+ return this._subkind;
18378
+ },
18379
+ set: function (subkind) {
18380
+ this._subkind = subkind;
18381
+ }
18382
+ },
18356
18383
  duration: {
18357
18384
  enumerable: true,
18358
18385
  get: function () {
@@ -18595,6 +18622,7 @@ module.exports = function (Utils) {
18595
18622
  previewUrl: this.previewUrl,
18596
18623
  binaryUrl: this.binaryUrl,
18597
18624
  kind: this.kind,
18625
+ subkind: this.subkind,
18598
18626
  duration: this.duration,
18599
18627
  startTime: this.startTime,
18600
18628
  endTime: this.endTime,
@@ -18620,6 +18648,7 @@ module.exports = function (Utils) {
18620
18648
  this._previewUrl = opts.previewUrl;
18621
18649
  this._binaryUrl = opts.binaryUrl;
18622
18650
  this._kind = opts.kind;
18651
+ this._subkind = opts.subkind;
18623
18652
  this._duration = opts.duration;
18624
18653
  this._startTime = opts.startTime;
18625
18654
  this._endTime = opts.endTime;
@@ -19313,6 +19342,7 @@ module.exports = function (Source, Utils) {
19313
19342
  previewUrl: sourceToCut.previewUrl,
19314
19343
  binaryUrl: sourceToCut.binaryUrl,
19315
19344
  kind: sourceToCut.kind,
19345
+ subkind: sourceToCut.subkind,
19316
19346
  duration: sourceToCut.duration,
19317
19347
  startTime: sourceToCut.endTime,
19318
19348
  endTime: originalEndTime,
@@ -19344,7 +19374,7 @@ module.exports = function (Source, Utils) {
19344
19374
  if (!Utils.isObject(options)) {
19345
19375
  throw new TypeError('peaks.sources.add(): expected a Source object parameter');
19346
19376
  }
19347
- var source = new Source(this._peaks, options.id || this._getNextSourceId(), options.originId, options.elementId, options.title, options.url, options.previewUrl, options.binaryUrl, options.kind, options.duration, options.startTime, options.endTime, options.mediaStartTime, options.mediaEndTime, options.color, options.borderColor, options.selectedColor, options.textColor, options.borderWidth, options.wrapped, options.position, options.draggable, options.resizable, options.wrapping, options.previewHeight, options.binaryHeight);
19377
+ var source = new Source(this._peaks, options.id || this._getNextSourceId(), options.originId, options.elementId, options.title, options.url, options.previewUrl, options.binaryUrl, options.kind, options.subkind, options.duration, options.startTime, options.endTime, options.mediaStartTime, options.mediaEndTime, options.color, options.borderColor, options.selectedColor, options.textColor, options.borderWidth, options.wrapped, options.position, options.draggable, options.resizable, options.wrapping, options.previewHeight, options.binaryHeight);
19348
19378
  return source;
19349
19379
  };
19350
19380
  TimelineSources.prototype.getSources = function () {
package/src/segment.js CHANGED
@@ -12,25 +12,31 @@ define([
12
12
  'use strict';
13
13
 
14
14
  function validateSegment(peaks, options, context) {
15
+ var shouldNotifyUpdate = false;
16
+
15
17
  if (!Utils.isValidTime(options.startTime)) {
16
18
  throw new TypeError('peaks.segments.' + context + ': startTime should be a valid number');
17
19
  }
18
20
 
19
21
  if (!Utils.isValidTime(options.endTime)) {
20
22
  options.endTime = options.startTime;
23
+ shouldNotifyUpdate = true;
21
24
  }
22
25
 
23
26
  options.startTime = Utils.roundTime(options.startTime);
24
27
  options.endTime = Utils.roundTime(options.endTime);
25
28
  if (options.startTime < 0) {
26
29
  options.startTime = 0;
30
+ shouldNotifyUpdate = true;
27
31
  }
28
32
 
29
33
  if (options.endTime < 0) {
30
34
  options.endTime = 0;
35
+ shouldNotifyUpdate = true;
31
36
  }
32
37
  else if (options.endTime - options.startTime < peaks.options.minSegmentSize) {
33
38
  options.endTime = options.startTime + peaks.options.minSegmentSize;
39
+ shouldNotifyUpdate = true;
34
40
  }
35
41
 
36
42
  options.startTime = Utils.roundTime(options.startTime);
@@ -64,6 +70,8 @@ define([
64
70
  else if (!Utils.isValidColor(options.hoverColor)) {
65
71
  throw new TypeError('peaks.segments.' + context + ': hoverColor must be a boolean');
66
72
  }
73
+
74
+ return shouldNotifyUpdate;
67
75
  }
68
76
 
69
77
  /**
@@ -106,7 +114,7 @@ define([
106
114
  indicators: indicators
107
115
  };
108
116
 
109
- validateSegment(peaks, opts, 'add()');
117
+ var shouldNotifyUpdate = validateSegment(peaks, opts, 'add()');
110
118
 
111
119
  this._peaks = peaks;
112
120
  this._id = id;
@@ -123,6 +131,10 @@ define([
123
131
  this._line = opts.line;
124
132
  this._indicators = opts.indicators;
125
133
  this._minSize = peaks.options.minSegmentSize;
134
+
135
+ if (shouldNotifyUpdate) {
136
+ peaks.emit('segments.updated', [this]);
137
+ }
126
138
  }
127
139
 
128
140
  Object.defineProperties(Segment.prototype, {
@@ -238,7 +250,7 @@ define([
238
250
 
239
251
  Utils.extend(opts, options);
240
252
 
241
- validateSegment(this._peaks, opts, 'update()');
253
+ var shouldNotifyUpdate = validateSegment(this._peaks, opts, 'update()');
242
254
 
243
255
  this._startTime = opts.startTime;
244
256
  this._endTime = opts.endTime;
@@ -254,6 +266,10 @@ define([
254
266
  this._indicators = opts.indicators;
255
267
 
256
268
  this._peaks.emit('segment.updated', this);
269
+
270
+ if (shouldNotifyUpdate) {
271
+ this._peaks.emit('segments.updated', [this]);
272
+ }
257
273
  };
258
274
 
259
275
  /**
@@ -86,6 +86,7 @@ define([
86
86
 
87
87
  this._addWrap(true);
88
88
  this._addUnwrap(true);
89
+ this._addTitle(true);
89
90
  this._addHandles(true);
90
91
 
91
92
  this.setWrapping(source.wrapped);
@@ -205,13 +206,7 @@ define([
205
206
  this.updatePreviews();
206
207
 
207
208
  // update wrap
208
- var title = this._wrap.getChildren(function(node) {
209
- return node.getClassName() === 'Text';
210
- });
211
-
212
- if (title) {
213
- title.width(newWidth - 10);
214
- }
209
+ this._title.width(newWidth - 10);
215
210
  }
216
211
  };
217
212
 
@@ -498,10 +493,24 @@ define([
498
493
  });
499
494
  }
500
495
 
496
+ wrap.add(background);
497
+
498
+ return wrap;
499
+ };
500
+
501
+ SourceGroup.prototype._addTitle = function(forceCreate) {
502
+ if (!this._title || forceCreate) {
503
+ this._title = this._createTitle();
504
+ }
505
+
506
+ this._group.add(this._title);
507
+ };
508
+
509
+ SourceGroup.prototype._createTitle = function() {
501
510
  var title = new Konva.Text({
502
511
  x: 5,
512
+ y: 5,
503
513
  width: this._width - 10,
504
- height: this._wrappedHeight,
505
514
  text: Utils.removeLineBreaks(this._source.title),
506
515
  textAlign: 'left',
507
516
  verticalAlign: 'middle',
@@ -513,10 +522,7 @@ define([
513
522
  listening: false
514
523
  });
515
524
 
516
- wrap.add(background);
517
- wrap.add(title);
518
-
519
- return wrap;
525
+ return title;
520
526
  };
521
527
 
522
528
  SourceGroup.prototype.getWidth = function() {
package/src/source.js CHANGED
@@ -220,7 +220,7 @@ define([
220
220
  */
221
221
 
222
222
  function Source(peaks, id, originId, elementId, title, url, previewUrl, binaryUrl, kind,
223
- duration, startTime, endTime, mediaStartTime, mediaEndTime, color, borderColor,
223
+ subkind, duration, startTime, endTime, mediaStartTime, mediaEndTime, color, borderColor,
224
224
  selectedColor, textColor, borderWidth, wrapped, position, draggable, resizable, wrapping,
225
225
  previewHeight, binaryHeight) {
226
226
  var opts = {
@@ -229,6 +229,7 @@ define([
229
229
  previewUrl: previewUrl,
230
230
  binaryUrl: binaryUrl,
231
231
  kind: kind,
232
+ subkind: subkind,
232
233
  duration: duration,
233
234
  startTime: startTime,
234
235
  endTime: endTime,
@@ -259,6 +260,7 @@ define([
259
260
  this._previewUrl = opts.previewUrl;
260
261
  this._binaryUrl = opts.binaryUrl;
261
262
  this._kind = opts.kind;
263
+ this._subkind = opts.subkind;
262
264
  this._duration = opts.duration;
263
265
  this._startTime = opts.startTime;
264
266
  this._endTime = opts.endTime;
@@ -336,6 +338,16 @@ define([
336
338
  this._kind = kind;
337
339
  }
338
340
  },
341
+ subkind: {
342
+ enumerable: true,
343
+ get: function() {
344
+ return this._subkind;
345
+ },
346
+
347
+ set: function(subkind) {
348
+ this._subkind = subkind;
349
+ }
350
+ },
339
351
  duration: {
340
352
  enumerable: true,
341
353
  get: function() {
@@ -622,6 +634,7 @@ define([
622
634
  previewUrl: this.previewUrl,
623
635
  binaryUrl: this.binaryUrl,
624
636
  kind: this.kind,
637
+ subkind: this.subkind,
625
638
  duration: this.duration,
626
639
  startTime: this.startTime,
627
640
  endTime: this.endTime,
@@ -650,6 +663,7 @@ define([
650
663
  this._previewUrl = opts.previewUrl;
651
664
  this._binaryUrl = opts.binaryUrl;
652
665
  this._kind = opts.kind;
666
+ this._subkind = opts.subkind;
653
667
  this._duration = opts.duration;
654
668
  this._startTime = opts.startTime;
655
669
  this._endTime = opts.endTime;
@@ -71,6 +71,7 @@ define([
71
71
  previewUrl: sourceToCut.previewUrl,
72
72
  binaryUrl: sourceToCut.binaryUrl,
73
73
  kind: sourceToCut.kind,
74
+ subkind: sourceToCut.subkind,
74
75
  duration: sourceToCut.duration,
75
76
  startTime: sourceToCut.endTime,
76
77
  endTime: originalEndTime,
@@ -143,6 +144,7 @@ define([
143
144
  options.previewUrl,
144
145
  options.binaryUrl,
145
146
  options.kind,
147
+ options.subkind,
146
148
  options.duration,
147
149
  options.startTime,
148
150
  options.endTime,