@checksub_team/peaks_timeline 2.4.0-alpha.0 → 2.4.0-alpha.1

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": "2.4.0-alpha.0",
3
+ "version": "2.4.0-alpha.1",
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
@@ -14563,7 +14563,7 @@ module.exports = function (Utils, Invoker, Konva) {
14563
14563
  };
14564
14564
  return Axis;
14565
14565
  }(_dereq_('../utils'), _dereq_('./invoker'), _dereq_('konva'));
14566
- },{"../utils":116,"./invoker":90,"konva":43}],87:[function(_dereq_,module,exports){
14566
+ },{"../utils":117,"./invoker":90,"konva":43}],87:[function(_dereq_,module,exports){
14567
14567
  module.exports = function (Data, Utils) {
14568
14568
  'use strict';
14569
14569
  function DataRetriever(peaks) {
@@ -14639,7 +14639,7 @@ module.exports = function (Data, Utils) {
14639
14639
  };
14640
14640
  return DataRetriever;
14641
14641
  }(_dereq_('./data'), _dereq_('../utils'));
14642
- },{"../utils":116,"./data":88}],88:[function(_dereq_,module,exports){
14642
+ },{"../utils":117,"./data":88}],88:[function(_dereq_,module,exports){
14643
14643
  module.exports = function () {
14644
14644
  'use strict';
14645
14645
  function Data(type, content) {
@@ -14762,7 +14762,7 @@ module.exports = function (Utils, Konva) {
14762
14762
  };
14763
14763
  return DefaultSegmentMarker;
14764
14764
  }(_dereq_('../utils'), _dereq_('konva'));
14765
- },{"../utils":116,"konva":43}],90:[function(_dereq_,module,exports){
14765
+ },{"../utils":117,"konva":43}],90:[function(_dereq_,module,exports){
14766
14766
  module.exports = function () {
14767
14767
  'use strict';
14768
14768
  var raf = typeof window !== 'undefined' && window.requestAnimationFrame || function (fn) {
@@ -15494,7 +15494,7 @@ module.exports = function (SourceGroup, Utils, Konva) {
15494
15494
  };
15495
15495
  return LineGroup;
15496
15496
  }(_dereq_('./source-group'), _dereq_('../utils'), _dereq_('konva'));
15497
- },{"../utils":116,"./source-group":102,"konva":43}],92:[function(_dereq_,module,exports){
15497
+ },{"../utils":117,"./source-group":102,"konva":43}],92:[function(_dereq_,module,exports){
15498
15498
  module.exports = function (SegmentsGroup, LineGroup, LineIndicator, Utils) {
15499
15499
  'use strict';
15500
15500
  function LineGroups(peaks, view, layer) {
@@ -15966,7 +15966,7 @@ module.exports = function (SegmentsGroup, LineGroup, LineIndicator, Utils) {
15966
15966
  };
15967
15967
  return LineGroups;
15968
15968
  }(_dereq_('./segments-group'), _dereq_('./line-group'), _dereq_('./line-indicator'), _dereq_('../utils'));
15969
- },{"../utils":116,"./line-group":91,"./line-indicator":93,"./segments-group":101}],93:[function(_dereq_,module,exports){
15969
+ },{"../utils":117,"./line-group":91,"./line-indicator":93,"./segments-group":101}],93:[function(_dereq_,module,exports){
15970
15970
  module.exports = function (Konva, SVGs, Invoker, Utils) {
15971
15971
  'use strict';
15972
15972
  function LineIndicator(peaks, view, container) {
@@ -16346,7 +16346,7 @@ module.exports = function (Konva, SVGs, Invoker, Utils) {
16346
16346
  };
16347
16347
  return LineIndicator;
16348
16348
  }(_dereq_('konva'), _dereq_('./svgs'), _dereq_('./invoker'), _dereq_('../utils'));
16349
- },{"../utils":116,"./invoker":90,"./svgs":104,"konva":43}],94:[function(_dereq_,module,exports){
16349
+ },{"../utils":117,"./invoker":90,"./svgs":104,"konva":43}],94:[function(_dereq_,module,exports){
16350
16350
  module.exports = function (Konva) {
16351
16351
  'use strict';
16352
16352
  var RADIUS = 5;
@@ -16427,7 +16427,7 @@ module.exports = function (DefaultSegmentMarker, Utils, Konva) {
16427
16427
  createSegmentLabel: createSegmentLabel
16428
16428
  };
16429
16429
  }(_dereq_('./default-segment-marker'), _dereq_('../utils'), _dereq_('konva'));
16430
- },{"../utils":116,"./default-segment-marker":89,"konva":43}],96:[function(_dereq_,module,exports){
16430
+ },{"../utils":117,"./default-segment-marker":89,"konva":43}],96:[function(_dereq_,module,exports){
16431
16431
  module.exports = function (SourceGroup, Invoker, Source, Utils, Konva) {
16432
16432
  'use strict';
16433
16433
  var TIME_X_OFFSET = 20;
@@ -16814,7 +16814,7 @@ module.exports = function (SourceGroup, Invoker, Source, Utils, Konva) {
16814
16814
  };
16815
16815
  return ModeLayer;
16816
16816
  }(_dereq_('./source-group'), _dereq_('./invoker'), _dereq_('../models/source'), _dereq_('../utils'), _dereq_('konva'));
16817
- },{"../models/source":112,"../utils":116,"./invoker":90,"./source-group":102,"konva":43}],97:[function(_dereq_,module,exports){
16817
+ },{"../models/source":112,"../utils":117,"./invoker":90,"./source-group":102,"konva":43}],97:[function(_dereq_,module,exports){
16818
16818
  module.exports = function (Konva) {
16819
16819
  'use strict';
16820
16820
  function getMarkerObject(obj) {
@@ -17136,7 +17136,7 @@ module.exports = function (Utils, Invoker, Konva) {
17136
17136
  };
17137
17137
  return PlayheadLayer;
17138
17138
  }(_dereq_('../utils'), _dereq_('./invoker'), _dereq_('konva'));
17139
- },{"../utils":116,"./invoker":90,"konva":43}],99:[function(_dereq_,module,exports){
17139
+ },{"../utils":117,"./invoker":90,"konva":43}],99:[function(_dereq_,module,exports){
17140
17140
  module.exports = function (Konva) {
17141
17141
  'use strict';
17142
17142
  function SegmentMarker(options) {
@@ -17587,7 +17587,7 @@ module.exports = function (Konva, SegmentMarker, Utils) {
17587
17587
  };
17588
17588
  return SegmentShape;
17589
17589
  }(_dereq_('konva'), _dereq_('./segment-marker'), _dereq_('../utils'));
17590
- },{"../utils":116,"./segment-marker":99,"konva":43}],101:[function(_dereq_,module,exports){
17590
+ },{"../utils":117,"./segment-marker":99,"konva":43}],101:[function(_dereq_,module,exports){
17591
17591
  module.exports = function (SegmentShape, Utils, Konva) {
17592
17592
  'use strict';
17593
17593
  function SegmentsGroup(peaks, view, allowEditing) {
@@ -18127,7 +18127,7 @@ module.exports = function (SegmentShape, Utils, Konva) {
18127
18127
  };
18128
18128
  return SegmentsGroup;
18129
18129
  }(_dereq_('./segment-shape'), _dereq_('../utils'), _dereq_('konva'));
18130
- },{"../utils":116,"./segment-shape":100,"konva":43}],102:[function(_dereq_,module,exports){
18130
+ },{"../utils":117,"./segment-shape":100,"konva":43}],102:[function(_dereq_,module,exports){
18131
18131
  module.exports = function (WaveformBuilder, WaveformShape, Loader, Invoker, Utils, Konva) {
18132
18132
  'use strict';
18133
18133
  var SPACING_BETWEEN_PREVIEW_AND_BORDER_RATIO = 0.15;
@@ -19857,7 +19857,7 @@ module.exports = function (WaveformBuilder, WaveformShape, Loader, Invoker, Util
19857
19857
  };
19858
19858
  return SourceGroup;
19859
19859
  }(_dereq_('./waveform-builder'), _dereq_('./waveform-shape'), _dereq_('./loader'), _dereq_('./invoker'), _dereq_('../utils'), _dereq_('konva'));
19860
- },{"../utils":116,"./invoker":90,"./loader":94,"./waveform-builder":105,"./waveform-shape":106,"konva":43}],103:[function(_dereq_,module,exports){
19860
+ },{"../utils":117,"./invoker":90,"./loader":94,"./waveform-builder":105,"./waveform-shape":106,"konva":43}],103:[function(_dereq_,module,exports){
19861
19861
  module.exports = function (SourceGroup, LineGroups, DataRetriever, Invoker, Utils, Konva) {
19862
19862
  'use strict';
19863
19863
  function SourcesLayer(peaks, view, allowEditing) {
@@ -20584,7 +20584,7 @@ module.exports = function (SourceGroup, LineGroups, DataRetriever, Invoker, Util
20584
20584
  };
20585
20585
  return SourcesLayer;
20586
20586
  }(_dereq_('./source-group'), _dereq_('./line-groups'), _dereq_('./data-retriever'), _dereq_('./invoker'), _dereq_('../utils'), _dereq_('konva'));
20587
- },{"../utils":116,"./data-retriever":87,"./invoker":90,"./line-groups":92,"./source-group":102,"konva":43}],104:[function(_dereq_,module,exports){
20587
+ },{"../utils":117,"./data-retriever":87,"./invoker":90,"./line-groups":92,"./source-group":102,"konva":43}],104:[function(_dereq_,module,exports){
20588
20588
  module.exports = function () {
20589
20589
  'use strict';
20590
20590
  var SVGs = {
@@ -20824,7 +20824,7 @@ module.exports = function (WaveformData, Utils) {
20824
20824
  };
20825
20825
  return WaveformBuilder;
20826
20826
  }(_dereq_('waveform-data'), _dereq_('../utils'));
20827
- },{"../utils":116,"waveform-data":85}],106:[function(_dereq_,module,exports){
20827
+ },{"../utils":117,"waveform-data":85}],106:[function(_dereq_,module,exports){
20828
20828
  module.exports = function (Utils, Konva) {
20829
20829
  'use strict';
20830
20830
  function scaleY(amplitude, height, scale) {
@@ -20934,7 +20934,7 @@ module.exports = function (Utils, Konva) {
20934
20934
  };
20935
20935
  return WaveformShape;
20936
20936
  }(_dereq_('../utils'), _dereq_('konva'));
20937
- },{"../utils":116,"konva":43}],107:[function(_dereq_,module,exports){
20937
+ },{"../utils":117,"konva":43}],107:[function(_dereq_,module,exports){
20938
20938
  module.exports = function () {
20939
20939
  'use strict';
20940
20940
  var nodes = [
@@ -21077,7 +21077,7 @@ module.exports = function (Line, Utils) {
21077
21077
  };
21078
21078
  return LineHandler;
21079
21079
  }(_dereq_('./models/line'), _dereq_('./utils'));
21080
- },{"./models/line":110,"./utils":116}],109:[function(_dereq_,module,exports){
21080
+ },{"./models/line":110,"./utils":117}],109:[function(_dereq_,module,exports){
21081
21081
  module.exports = function (Colors, EventEmitter, SegmentHandler, SourceHandler, LineHandler, KeyboardHandler, Player, View, MarkerFactories, Utils) {
21082
21082
  'use strict';
21083
21083
  function Peaks() {
@@ -21369,7 +21369,7 @@ module.exports = function (Colors, EventEmitter, SegmentHandler, SourceHandler,
21369
21369
  };
21370
21370
  return Peaks;
21371
21371
  }(_dereq_('colors.css'), _dereq_('eventemitter2'), _dereq_('./segment-handler'), _dereq_('./source-handler'), _dereq_('./line-handler'), _dereq_('./keyboard-handler'), _dereq_('./player'), _dereq_('./view'), _dereq_('./components/marker-factories'), _dereq_('./utils'));
21372
- },{"./components/marker-factories":95,"./keyboard-handler":107,"./line-handler":108,"./player":113,"./segment-handler":114,"./source-handler":115,"./utils":116,"./view":117,"colors.css":1,"eventemitter2":2}],110:[function(_dereq_,module,exports){
21372
+ },{"./components/marker-factories":95,"./keyboard-handler":107,"./line-handler":108,"./player":113,"./segment-handler":114,"./source-handler":115,"./utils":117,"./view":118,"colors.css":1,"eventemitter2":2}],110:[function(_dereq_,module,exports){
21373
21373
  module.exports = function (Utils) {
21374
21374
  'use strict';
21375
21375
  function validateLine(options, context) {
@@ -21488,7 +21488,7 @@ module.exports = function (Utils) {
21488
21488
  };
21489
21489
  return Line;
21490
21490
  }(_dereq_('../utils'));
21491
- },{"../utils":116}],111:[function(_dereq_,module,exports){
21491
+ },{"../utils":117}],111:[function(_dereq_,module,exports){
21492
21492
  module.exports = function (Utils) {
21493
21493
  'use strict';
21494
21494
  function validateSegment(peaks, options, context) {
@@ -21804,9 +21804,10 @@ module.exports = function (Utils) {
21804
21804
  };
21805
21805
  return Segment;
21806
21806
  }(_dereq_('../utils'));
21807
- },{"../utils":116}],112:[function(_dereq_,module,exports){
21808
- module.exports = function (Utils) {
21807
+ },{"../utils":117}],112:[function(_dereq_,module,exports){
21808
+ module.exports = function (SourceKeys, Utils) {
21809
21809
  'use strict';
21810
+ var RESERVED_SOURCE_KEYS = SourceKeys;
21810
21811
  function validateSource(peaks, options, context) {
21811
21812
  if (!Utils.isValidTime(options.startTime)) {
21812
21813
  throw new TypeError('peaks.sources.' + context + ': startTime should be a valid number');
@@ -22176,7 +22177,7 @@ module.exports = function (Utils) {
22176
22177
  for (var i = 0; i < customParams.length; i += 2) {
22177
22178
  var key = customParams[i];
22178
22179
  var value = customParams[i + 1];
22179
- if (key && key.startsWith('custom_')) {
22180
+ if (key && typeof key === 'string' && !key.startsWith('_') && !RESERVED_SOURCE_KEYS.has(key)) {
22180
22181
  this[key] = value;
22181
22182
  }
22182
22183
  }
@@ -22800,7 +22801,7 @@ module.exports = function (Utils) {
22800
22801
  this._waveformData = opts.waveformData;
22801
22802
  if (options && typeof options === 'object') {
22802
22803
  for (var key in options) {
22803
- if (Object.prototype.hasOwnProperty.call(options, key) && key.startsWith('custom_')) {
22804
+ if (key && typeof key === 'string' && Object.prototype.hasOwnProperty.call(options, key) && !key.startsWith('_') && !RESERVED_SOURCE_KEYS.has(key)) {
22804
22805
  this[key] = options[key];
22805
22806
  }
22806
22807
  }
@@ -22838,7 +22839,7 @@ module.exports = function (Utils) {
22838
22839
  Source.prototype.toSerializable = function () {
22839
22840
  var serializable = {};
22840
22841
  for (var key in this) {
22841
- if (Object.prototype.hasOwnProperty.call(this, key) && key.startsWith('custom_')) {
22842
+ if (key && typeof key === 'string' && Object.prototype.hasOwnProperty.call(this, key) && !key.startsWith('_') && !RESERVED_SOURCE_KEYS.has(key)) {
22842
22843
  serializable[key] = this[key];
22843
22844
  }
22844
22845
  }
@@ -22855,8 +22856,8 @@ module.exports = function (Utils) {
22855
22856
  return serializable;
22856
22857
  };
22857
22858
  return Source;
22858
- }(_dereq_('../utils'));
22859
- },{"../utils":116}],113:[function(_dereq_,module,exports){
22859
+ }(_dereq_('../source-keys'), _dereq_('../utils'));
22860
+ },{"../source-keys":116,"../utils":117}],113:[function(_dereq_,module,exports){
22860
22861
  module.exports = function (Utils) {
22861
22862
  'use strict';
22862
22863
  function Player(peaks) {
@@ -22889,7 +22890,7 @@ module.exports = function (Utils) {
22889
22890
  };
22890
22891
  return Player;
22891
22892
  }(_dereq_('./utils'));
22892
- },{"./utils":116}],114:[function(_dereq_,module,exports){
22893
+ },{"./utils":117}],114:[function(_dereq_,module,exports){
22893
22894
  module.exports = function (Colors, Segment, Utils) {
22894
22895
  'use strict';
22895
22896
  function SegmentHandler(peaks) {
@@ -23051,9 +23052,10 @@ module.exports = function (Colors, Segment, Utils) {
23051
23052
  };
23052
23053
  return SegmentHandler;
23053
23054
  }(_dereq_('colors.css'), _dereq_('./models/segment'), _dereq_('./utils'));
23054
- },{"./models/segment":111,"./utils":116,"colors.css":1}],115:[function(_dereq_,module,exports){
23055
- module.exports = function (Source, Utils) {
23055
+ },{"./models/segment":111,"./utils":117,"colors.css":1}],115:[function(_dereq_,module,exports){
23056
+ module.exports = function (Source, SourceKeys, Utils) {
23056
23057
  'use strict';
23058
+ var SOURCE_OPTION_KEYS = SourceKeys;
23057
23059
  function SourceHandler(peaks) {
23058
23060
  this._peaks = peaks;
23059
23061
  this._sources = [];
@@ -23122,11 +23124,11 @@ module.exports = function (Source, Utils) {
23122
23124
  targetSpeed: sourceToCut.targetSpeed,
23123
23125
  waveformData: sourceToCut.waveformData
23124
23126
  };
23125
- for (var key in sourceToCut) {
23126
- if (key.startsWith('custom_')) {
23127
+ Object.keys(sourceToCut).forEach(function (key) {
23128
+ if (key && !key.startsWith('_') && !SOURCE_OPTION_KEYS.has(key)) {
23127
23129
  newSourceOptions[key] = sourceToCut[key];
23128
23130
  }
23129
- }
23131
+ });
23130
23132
  var newSource = this._add([newSourceOptions])[0];
23131
23133
  this._peaks.emit('sources.updated', [
23132
23134
  sourceToCut,
@@ -23144,13 +23146,13 @@ module.exports = function (Source, Utils) {
23144
23146
  if (!Utils.isObject(options)) {
23145
23147
  throw new TypeError('peaks.sources.add(): expected a Source object parameter');
23146
23148
  }
23147
- var customParams = [];
23149
+ var extraParams = [];
23148
23150
  Object.entries(options).forEach(function ([key, value]) {
23149
- if (key.startsWith('custom_')) {
23150
- customParams.push(key, value);
23151
+ if (key && typeof key === 'string' && !key.startsWith('_') && !SOURCE_OPTION_KEYS.has(key)) {
23152
+ extraParams.push(key, value);
23151
23153
  }
23152
23154
  });
23153
- var source = new Source(this._peaks, options.id || this._getNextSourceId(), options.lineId, options.originId, options.elementId, options.title, options.titleAlignments, options.url, options.previewUrl, options.binaryUrl, options.kind, options.subkind, options.duration, options.startTime, options.endTime, options.mediaStartTime, options.mediaEndTime, options.color, options.backgroundColor, options.hoverBackgroundColor, options.selectedBackgroundColor, options.borderColor, options.selectedBorderColor, options.warningColor, options.warningWidth, options.volumeSliderColor, options.volumeSliderWidth, options.volumeSliderDraggingWidth, options.textFont, options.textFontSize, options.textColor, options.textBackgroundColor, options.textPosition, options.textAutoScroll, options.borderWidth, options.borderRadius, options.wrapped, options.draggable, options.orderable, options.resizable, options.cuttable, options.deletable, options.wrapping, options.previewHeight, options.binaryHeight, options.indicators, options.markers, options.buttons, options.markerColor, options.markerWidth, options.volume, options.volumeRange, options.loading, options.targetSpeed, options.waveformData, ...customParams);
23155
+ var source = new Source(this._peaks, options.id || this._getNextSourceId(), options.lineId, options.originId, options.elementId, options.title, options.titleAlignments, options.url, options.previewUrl, options.binaryUrl, options.kind, options.subkind, options.duration, options.startTime, options.endTime, options.mediaStartTime, options.mediaEndTime, options.color, options.backgroundColor, options.hoverBackgroundColor, options.selectedBackgroundColor, options.borderColor, options.selectedBorderColor, options.warningColor, options.warningWidth, options.volumeSliderColor, options.volumeSliderWidth, options.volumeSliderDraggingWidth, options.textFont, options.textFontSize, options.textColor, options.textBackgroundColor, options.textPosition, options.textAutoScroll, options.borderWidth, options.borderRadius, options.wrapped, options.draggable, options.orderable, options.resizable, options.cuttable, options.deletable, options.wrapping, options.previewHeight, options.binaryHeight, options.indicators, options.markers, options.buttons, options.markerColor, options.markerWidth, options.volume, options.volumeRange, options.loading, options.targetSpeed, options.waveformData, ...extraParams);
23154
23156
  return source;
23155
23157
  };
23156
23158
  SourceHandler.prototype.getSources = function () {
@@ -23265,8 +23267,68 @@ module.exports = function (Source, Utils) {
23265
23267
  this._peaks.emit('handler.sources.hide', [this._sourcesById[sourceId]]);
23266
23268
  };
23267
23269
  return SourceHandler;
23268
- }(_dereq_('./models/source'), _dereq_('./utils'));
23269
- },{"./models/source":112,"./utils":116}],116:[function(_dereq_,module,exports){
23270
+ }(_dereq_('./models/source'), _dereq_('./source-keys'), _dereq_('./utils'));
23271
+ },{"./models/source":112,"./source-keys":116,"./utils":117}],116:[function(_dereq_,module,exports){
23272
+ module.exports = function () {
23273
+ 'use strict';
23274
+ return new Set([
23275
+ 'id',
23276
+ 'lineId',
23277
+ 'originId',
23278
+ 'elementId',
23279
+ 'title',
23280
+ 'titleAlignments',
23281
+ 'url',
23282
+ 'previewUrl',
23283
+ 'binaryUrl',
23284
+ 'kind',
23285
+ 'subkind',
23286
+ 'duration',
23287
+ 'startTime',
23288
+ 'endTime',
23289
+ 'mediaStartTime',
23290
+ 'mediaEndTime',
23291
+ 'color',
23292
+ 'backgroundColor',
23293
+ 'hoverBackgroundColor',
23294
+ 'selectedBackgroundColor',
23295
+ 'borderColor',
23296
+ 'selectedBorderColor',
23297
+ 'warningColor',
23298
+ 'warningWidth',
23299
+ 'volumeSliderColor',
23300
+ 'volumeSliderWidth',
23301
+ 'volumeSliderDraggingWidth',
23302
+ 'textFont',
23303
+ 'textFontSize',
23304
+ 'textColor',
23305
+ 'textBackgroundColor',
23306
+ 'textPosition',
23307
+ 'textAutoScroll',
23308
+ 'borderWidth',
23309
+ 'borderRadius',
23310
+ 'wrapped',
23311
+ 'draggable',
23312
+ 'orderable',
23313
+ 'resizable',
23314
+ 'cuttable',
23315
+ 'deletable',
23316
+ 'wrapping',
23317
+ 'previewHeight',
23318
+ 'binaryHeight',
23319
+ 'indicators',
23320
+ 'markers',
23321
+ 'buttons',
23322
+ 'markerColor',
23323
+ 'markerWidth',
23324
+ 'volume',
23325
+ 'volumeRange',
23326
+ 'loading',
23327
+ 'targetSpeed',
23328
+ 'waveformData'
23329
+ ]);
23330
+ }();
23331
+ },{}],117:[function(_dereq_,module,exports){
23270
23332
  module.exports = function (UUID) {
23271
23333
  'use strict';
23272
23334
  if (typeof Number.isFinite !== 'function') {
@@ -23496,7 +23558,7 @@ module.exports = function (UUID) {
23496
23558
  }
23497
23559
  };
23498
23560
  }(_dereq_('uuid'));
23499
- },{"uuid":62}],117:[function(_dereq_,module,exports){
23561
+ },{"uuid":62}],118:[function(_dereq_,module,exports){
23500
23562
  module.exports = function (MouseDragHandler, PlayheadLayer, SourcesLayer, ModeLayer, Axis, Utils, Konva) {
23501
23563
  'use strict';
23502
23564
  function View(container, peaks) {
@@ -24145,6 +24207,6 @@ module.exports = function (MouseDragHandler, PlayheadLayer, SourcesLayer, ModeLa
24145
24207
  };
24146
24208
  return View;
24147
24209
  }(_dereq_('./components/mouse-drag-handler'), _dereq_('./components/playhead-layer'), _dereq_('./components/sources-layer'), _dereq_('./components/mode-layer'), _dereq_('./components/axis'), _dereq_('./utils'), _dereq_('konva'));
24148
- },{"./components/axis":86,"./components/mode-layer":96,"./components/mouse-drag-handler":97,"./components/playhead-layer":98,"./components/sources-layer":103,"./utils":116,"konva":43}]},{},[109])(109)
24210
+ },{"./components/axis":86,"./components/mode-layer":96,"./components/mouse-drag-handler":97,"./components/playhead-layer":98,"./components/sources-layer":103,"./utils":117,"konva":43}]},{},[109])(109)
24149
24211
  });
24150
24212
  //# sourceMappingURL=peaks.js.map
@@ -7,10 +7,16 @@
7
7
  */
8
8
 
9
9
  define([
10
+ '../source-keys',
10
11
  '../utils'
11
- ], function(Utils) {
12
+ ], function(SourceKeys, Utils) {
12
13
  'use strict';
13
14
 
15
+ // Keys that belong to the Source API / options bag.
16
+ // Any other user-provided keys are treated as metadata fields and preserved
17
+ // as enumerable own-properties on the Source instance.
18
+ var RESERVED_SOURCE_KEYS = SourceKeys;
19
+
14
20
  function validateSource(peaks, options, context) {
15
21
  if (!Utils.isValidTime(options.startTime)) {
16
22
  throw new TypeError('peaks.sources.' + context + ': startTime should be a valid number');
@@ -572,7 +578,7 @@ define([
572
578
  var key = customParams[i];
573
579
  var value = customParams[i + 1];
574
580
 
575
- if (key && key.startsWith('custom_')) {
581
+ if (key && typeof key === 'string' && !key.startsWith('_') && !RESERVED_SOURCE_KEYS.has(key)) {
576
582
  this[key] = value;
577
583
  }
578
584
  }
@@ -1262,7 +1268,10 @@ define([
1262
1268
 
1263
1269
  if (options && typeof options === 'object') {
1264
1270
  for (var key in options) {
1265
- if (Object.prototype.hasOwnProperty.call(options, key) && key.startsWith('custom_')) {
1271
+ if (key && typeof key === 'string'
1272
+ && Object.prototype.hasOwnProperty.call(options, key)
1273
+ && !key.startsWith('_')
1274
+ && !RESERVED_SOURCE_KEYS.has(key)) {
1266
1275
  this[key] = options[key];
1267
1276
  }
1268
1277
  }
@@ -1334,9 +1343,12 @@ define([
1334
1343
  Source.prototype.toSerializable = function() {
1335
1344
  var serializable = {};
1336
1345
 
1337
- // Get all custom properties
1346
+ // Get all user-defined metadata properties
1338
1347
  for (var key in this) {
1339
- if (Object.prototype.hasOwnProperty.call(this, key) && key.startsWith('custom_')) {
1348
+ if (key && typeof key === 'string'
1349
+ && Object.prototype.hasOwnProperty.call(this, key)
1350
+ && !key.startsWith('_')
1351
+ && !RESERVED_SOURCE_KEYS.has(key)) {
1340
1352
  serializable[key] = this[key];
1341
1353
  }
1342
1354
  }
@@ -8,10 +8,13 @@
8
8
 
9
9
  define([
10
10
  './models/source',
11
+ './source-keys',
11
12
  './utils'
12
- ], function(Source, Utils) {
13
+ ], function(Source, SourceKeys, Utils) {
13
14
  'use strict';
14
15
 
16
+ var SOURCE_OPTION_KEYS = SourceKeys;
17
+
15
18
  /**
16
19
  * Source parameters.
17
20
  *
@@ -114,11 +117,12 @@ define([
114
117
  waveformData: sourceToCut.waveformData
115
118
  };
116
119
 
117
- for (var key in sourceToCut) {
118
- if (key.startsWith('custom_')) {
120
+ // Preserve user-defined metadata fields on the new (cut) source.
121
+ Object.keys(sourceToCut).forEach(function(key) {
122
+ if (key && !key.startsWith('_') && !SOURCE_OPTION_KEYS.has(key)) {
119
123
  newSourceOptions[key] = sourceToCut[key];
120
124
  }
121
- }
125
+ });
122
126
 
123
127
  var newSource = this._add([newSourceOptions])[0];
124
128
 
@@ -163,11 +167,11 @@ define([
163
167
  throw new TypeError('peaks.sources.add(): expected a Source object parameter');
164
168
  }
165
169
 
166
- var customParams = [];
170
+ var extraParams = [];
167
171
 
168
172
  Object.entries(options).forEach(function([key, value]) {
169
- if (key.startsWith('custom_')) {
170
- customParams.push(key, value);
173
+ if (key && typeof key === 'string' && !key.startsWith('_') && !SOURCE_OPTION_KEYS.has(key)) {
174
+ extraParams.push(key, value);
171
175
  }
172
176
  });
173
177
 
@@ -227,7 +231,7 @@ define([
227
231
  options.loading,
228
232
  options.targetSpeed,
229
233
  options.waveformData,
230
- ...customParams
234
+ ...extraParams
231
235
  );
232
236
 
233
237
  return source;
@@ -0,0 +1,68 @@
1
+ /**
2
+ * @file
3
+ *
4
+ * Defines the reserved Source option keys.
5
+ *
6
+ * @module source-keys
7
+ */
8
+
9
+ define(function() {
10
+ 'use strict';
11
+
12
+ return new Set([
13
+ 'id',
14
+ 'lineId',
15
+ 'originId',
16
+ 'elementId',
17
+ 'title',
18
+ 'titleAlignments',
19
+ 'url',
20
+ 'previewUrl',
21
+ 'binaryUrl',
22
+ 'kind',
23
+ 'subkind',
24
+ 'duration',
25
+ 'startTime',
26
+ 'endTime',
27
+ 'mediaStartTime',
28
+ 'mediaEndTime',
29
+ 'color',
30
+ 'backgroundColor',
31
+ 'hoverBackgroundColor',
32
+ 'selectedBackgroundColor',
33
+ 'borderColor',
34
+ 'selectedBorderColor',
35
+ 'warningColor',
36
+ 'warningWidth',
37
+ 'volumeSliderColor',
38
+ 'volumeSliderWidth',
39
+ 'volumeSliderDraggingWidth',
40
+ 'textFont',
41
+ 'textFontSize',
42
+ 'textColor',
43
+ 'textBackgroundColor',
44
+ 'textPosition',
45
+ 'textAutoScroll',
46
+ 'borderWidth',
47
+ 'borderRadius',
48
+ 'wrapped',
49
+ 'draggable',
50
+ 'orderable',
51
+ 'resizable',
52
+ 'cuttable',
53
+ 'deletable',
54
+ 'wrapping',
55
+ 'previewHeight',
56
+ 'binaryHeight',
57
+ 'indicators',
58
+ 'markers',
59
+ 'buttons',
60
+ 'markerColor',
61
+ 'markerWidth',
62
+ 'volume',
63
+ 'volumeRange',
64
+ 'loading',
65
+ 'targetSpeed',
66
+ 'waveformData'
67
+ ]);
68
+ });