@vidispine/vdt-js 22.3.0-pre.5 → 22.3.1-pre.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/dist/index.js CHANGED
@@ -22,9 +22,28 @@ var _classCallCheck__default = /*#__PURE__*/_interopDefaultLegacy(_classCallChec
22
22
  var _createClass__default = /*#__PURE__*/_interopDefaultLegacy(_createClass);
23
23
  var parseFileSize__default = /*#__PURE__*/_interopDefaultLegacy(parseFileSize);
24
24
 
25
- function ownKeys$8(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
25
+ var gcd = function gcd(a, b) {
26
+ return b ? gcd(b, a % b) : a;
27
+ };
26
28
 
27
- function _objectSpread$8(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$8(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$8(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
29
+ var parseAspectRatio = function parseAspectRatio(_ref) {
30
+ var width = _ref.width,
31
+ height = _ref.height;
32
+ var denominator = gcd(width, height);
33
+ var widthRatio = width / denominator;
34
+ var heightRatio = height / denominator;
35
+
36
+ if (widthRatio > 21) {
37
+ heightRatio = 1;
38
+ widthRatio = (width / height).toFixed(2);
39
+ }
40
+
41
+ return [widthRatio, heightRatio].join(':');
42
+ };
43
+
44
+ function ownKeys$b(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
45
+
46
+ function _objectSpread$b(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$b(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$b(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
28
47
 
29
48
  var parseKeyValuePairType = function parseKeyValuePairType() {
30
49
  var keyValuePairType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
@@ -32,7 +51,7 @@ var parseKeyValuePairType = function parseKeyValuePairType() {
32
51
  var keyValuePairTypeReducer = function keyValuePairTypeReducer(a, _ref) {
33
52
  var key = _ref.key,
34
53
  value = _ref.value;
35
- return _objectSpread$8(_objectSpread$8({}, a), {}, _defineProperty__default["default"]({}, key, value));
54
+ return _objectSpread$b(_objectSpread$b({}, a), {}, _defineProperty__default["default"]({}, key, value));
36
55
  };
37
56
 
38
57
  return keyValuePairType.reduce(keyValuePairTypeReducer, {});
@@ -259,19 +278,19 @@ var roles = /*#__PURE__*/Object.freeze({
259
278
  VXA_READ: VXA_READ
260
279
  });
261
280
 
262
- var _excluded$4 = ["value"],
281
+ var _excluded$8 = ["value"],
263
282
  _excluded2$2 = ["start", "end"];
264
283
 
265
- function ownKeys$7(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
284
+ function ownKeys$a(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
266
285
 
267
- function _objectSpread$7(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$7(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$7(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
286
+ function _objectSpread$a(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$a(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$a(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
268
287
 
269
288
  var COMBINED_PROPERTY_KEYS = ['uuid', 'user', 'timestamp', 'change', 'conflict', 'mode', 'name', 'id', 'referenced', 'data', 'inheritance'];
270
289
  var GROUP_PROPERTY_KEYS = [].concat(COMBINED_PROPERTY_KEYS, ['cycle']);
271
290
  var FIELD_PROPERTY_KEYS = [].concat(COMBINED_PROPERTY_KEYS, ['value', 'reference', 'type', 'track']);
272
291
  var FIELD_VALUE_PROPERTY_KEYS = [].concat(COMBINED_PROPERTY_KEYS, ['value', 'lang']);
273
292
 
274
- var isObject = function isObject(o) {
293
+ var isObject$1 = function isObject(o) {
275
294
  return Object.prototype.toString.call(o) === '[object Object]';
276
295
  };
277
296
 
@@ -287,7 +306,7 @@ var isField = function isField(value) {
287
306
  };
288
307
 
289
308
  var isFieldObject = function isFieldObject(v) {
290
- return isObject(v) && (v.value === null || isObject(v.value) || isFieldType(v.value));
309
+ return isObject$1(v) && (v.value === null || isObject$1(v.value) || isFieldType(v.value));
291
310
  };
292
311
 
293
312
  if (value === null) {
@@ -303,7 +322,7 @@ var isField = function isField(value) {
303
322
 
304
323
  var isGroup = function isGroup(value) {
305
324
  var isGroupObject = function isGroupObject(v) {
306
- return isObject(v) && v.value === undefined && Object.entries(value);
325
+ return isObject$1(v) && v.value === undefined && Object.entries(value);
307
326
  };
308
327
 
309
328
  if (Array.isArray(value)) {
@@ -349,13 +368,13 @@ var parseValueObject = function parseValueObject(valueObject) {
349
368
  }
350
369
 
351
370
  var parsedValue = parseValue(valueObject === null || valueObject === void 0 ? void 0 : valueObject.value);
352
- return _objectSpread$7(_objectSpread$7({}, valueObject), parsedValue !== undefined ? parsedValue : {});
371
+ return _objectSpread$a(_objectSpread$a({}, valueObject), parsedValue !== undefined ? parsedValue : {});
353
372
  };
354
373
 
355
374
  var parseFieldValue = function parseFieldValue(value) {
356
375
  if ([undefined, null].includes(value)) return undefined;
357
376
  if (Array.isArray(value)) return value.map(parseFieldValue);
358
- if (isObject(value)) return parseValueObject(value);
377
+ if (isObject$1(value)) return parseValueObject(value);
359
378
  return parseValue(value);
360
379
  };
361
380
 
@@ -365,18 +384,18 @@ var parseFieldObject = function parseFieldObject(fieldObject) {
365
384
 
366
385
  if (parsedFieldValue === undefined) {
367
386
  fieldObject.value;
368
- var fieldObjectWithoutValue = _objectWithoutProperties__default["default"](fieldObject, _excluded$4);
387
+ var fieldObjectWithoutValue = _objectWithoutProperties__default["default"](fieldObject, _excluded$8);
369
388
 
370
389
  return fieldObjectWithoutValue;
371
390
  }
372
391
 
373
- return _objectSpread$7(_objectSpread$7({}, fieldObject), {}, {
392
+ return _objectSpread$a(_objectSpread$a({}, fieldObject), {}, {
374
393
  value: _toConsumableArray__default["default"](Array.isArray(parsedFieldValue) ? parsedFieldValue : [parsedFieldValue])
375
394
  });
376
395
  };
377
396
 
378
397
  var parseField$1 = function parseField(field) {
379
- if (isObject(field)) {
398
+ if (isObject$1(field)) {
380
399
  return parseFieldObject(field);
381
400
  }
382
401
 
@@ -401,10 +420,10 @@ var parseGroupsAndFields = function parseGroupsAndFields(groupOrField) {
401
420
  value = _ref2[1];
402
421
 
403
422
  if (GROUP_PROPERTY_KEYS.includes(name)) {
404
- groupAttributes = _objectSpread$7(_objectSpread$7({}, groupAttributes), {}, _defineProperty__default["default"]({}, name, value));
423
+ groupAttributes = _objectSpread$a(_objectSpread$a({}, groupAttributes), {}, _defineProperty__default["default"]({}, name, value));
405
424
  } else if (isField(value)) {
406
425
  try {
407
- field.push(_objectSpread$7({
426
+ field.push(_objectSpread$a({
408
427
  name: name
409
428
  }, parseField$1(value)));
410
429
  } catch (error) {
@@ -412,7 +431,7 @@ var parseGroupsAndFields = function parseGroupsAndFields(groupOrField) {
412
431
  }
413
432
  } else if (isGroup(value)) {
414
433
  (Array.isArray(value) ? value : [value]).forEach(function (v) {
415
- group.push(_objectSpread$7({
434
+ group.push(_objectSpread$a({
416
435
  name: name
417
436
  }, parseGroupsAndFields(v)));
418
437
  });
@@ -420,7 +439,7 @@ var parseGroupsAndFields = function parseGroupsAndFields(groupOrField) {
420
439
  throw Error("Unhandled value for \"".concat(name, "\""));
421
440
  }
422
441
  });
423
- return _objectSpread$7(_objectSpread$7(_objectSpread$7({}, groupAttributes), group.length > 0 ? {
442
+ return _objectSpread$a(_objectSpread$a(_objectSpread$a({}, groupAttributes), group.length > 0 ? {
424
443
  group: group
425
444
  } : {}), field.length > 0 ? {
426
445
  field: field
@@ -441,7 +460,7 @@ var parseTimespan$1 = function parseTimespan() {
441
460
  group = _parseGroupsAndFields.group,
442
461
  field = _parseGroupsAndFields.field;
443
462
 
444
- return _objectSpread$7(_objectSpread$7(_objectSpread$7({}, group ? {
463
+ return _objectSpread$a(_objectSpread$a(_objectSpread$a({}, group ? {
445
464
  group: group
446
465
  } : {}), field ? {
447
466
  field: field
@@ -451,10 +470,10 @@ var parseTimespan$1 = function parseTimespan() {
451
470
  });
452
471
  };
453
472
  /**
454
- * Create a MetadataType object from a metadata object
473
+ * Create a VidiCore MetadataType from a simplified object structure
455
474
  *
456
- * @param {Object} metadata - object with metadata to create MetadataType object of
457
- * @returns {Object} MetadataType
475
+ * @param {object} metadata - object to create MetadataType from
476
+ * @returns {object} a MetadataType object
458
477
  */
459
478
 
460
479
 
@@ -490,13 +509,13 @@ var sortTimespanList = function sortTimespanList(timespan1, timespan2) {
490
509
  return 0;
491
510
  };
492
511
 
493
- var _excluded$3 = ["value"],
512
+ var _excluded$7 = ["value"],
494
513
  _excluded2$1 = ["field", "group"],
495
514
  _excluded3 = ["field", "group"];
496
515
 
497
- function ownKeys$6(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
516
+ function ownKeys$9(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
498
517
 
499
- function _objectSpread$6(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$6(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$6(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
518
+ function _objectSpread$9(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$9(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$9(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
500
519
 
501
520
  var parseValueList = function parseValueList() {
502
521
  var valueList = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
@@ -535,10 +554,10 @@ var parseField = function parseField() {
535
554
 
536
555
  var _field$value = field.value,
537
556
  value = _field$value === void 0 ? [] : _field$value,
538
- attributes = _objectWithoutProperties__default["default"](field, _excluded$3);
557
+ attributes = _objectWithoutProperties__default["default"](field, _excluded$7);
539
558
 
540
559
  var parsedValueList = parseValueList(value, options);
541
- if (includeAttributes || includeFieldAttributes) return _objectSpread$6(_objectSpread$6({}, attributes), {}, {
560
+ if (includeAttributes || includeFieldAttributes) return _objectSpread$9(_objectSpread$9({}, attributes), {}, {
542
561
  value: parsedValueList
543
562
  });
544
563
  return parsedValueList;
@@ -673,8 +692,8 @@ var parseGroupList = function parseGroupList() {
673
692
  currentGroup = _output$key.group;
674
693
  var parsedField = parsedGroup.field,
675
694
  parsedGroupList = parsedGroup.group;
676
- output[key].field = _objectSpread$6(_objectSpread$6({}, currentField), parsedField);
677
- output[key].group = _objectSpread$6(_objectSpread$6({}, currentGroup), parsedGroupList);
695
+ output[key].field = _objectSpread$9(_objectSpread$9({}, currentField), parsedField);
696
+ output[key].group = _objectSpread$9(_objectSpread$9({}, currentGroup), parsedGroupList);
678
697
  } else {
679
698
  output[key] = parsedGroup;
680
699
  }
@@ -684,21 +703,21 @@ var parseGroupList = function parseGroupList() {
684
703
  /**
685
704
  * Parses timespan according to specified options.
686
705
  * The attributes can be targeted for each sub-type.
687
- * @param {Object} timespan={} - The timespan response from the API.
688
- * @param {Object} options={} - Options which change how the metadataType is parsed.
689
- * @param {string} options.joinValue=undefined - String to join the values, eg ','.
690
- * @param {boolean} options.includeAttributes=false - Include attributes on all objects.
691
- * @param {boolean} options.includeTimespanAttributes=false - Include attributes on timespans.
692
- * @param {boolean} options.includeGroupAttributes=false - Include attributes on groups.
693
- * @param {boolean} options.includeFieldAttributes=false - Include attributes on fields.
694
- * @param {boolean} options.includeValueAttributes=false - Include attributes on values.
695
- * @param {boolean} options.flat=false - Flatten to key/value (Note: keys may be overwritten).
696
- * @param {boolean} options.flatTimespan=false - Flatten timespan.
697
- * @param {boolean} options.flatGroup=false - Flatten group.
698
- * @param {boolean} options.groupAsList=false - Return groups as list.
699
- * @param {boolean} options.fieldAsList=false - Return fields as list.
700
- * @param {boolean} options.arrayOnSingle=true - Return fields as array even if single field.
701
- * @param {boolean} options.arrayOnSingleValue=true - Return fields as array even if single field value.
706
+ * @param {Object} [timespan={}] - A timespan from VidiCore.
707
+ * @param {Object} [options={}] - Options which change how the metadataType is parsed.
708
+ * @param {string} [options.joinValue=undefined] - String to join the values, eg ','.
709
+ * @param {boolean} [options.includeAttributes=false] - Include attributes on all objects.
710
+ * @param {boolean} [options.includeTimespanAttributes=false] - Include attributes on timespans.
711
+ * @param {boolean} [options.includeGroupAttributes=false] - Include attributes on groups.
712
+ * @param {boolean} [options.includeFieldAttributes=false] - Include attributes on fields.
713
+ * @param {boolean} [options.includeValueAttributes=false] - Include attributes on values.
714
+ * @param {boolean} [options.flat=false] - Flatten to key/value (Note: keys may be overwritten).
715
+ * @param {boolean} [options.flatTimespan=false] - Flatten timespan.
716
+ * @param {boolean} [options.flatGroup=false] - Flatten group.
717
+ * @param {boolean} [options.groupAsList=false] - Return groups as list.
718
+ * @param {boolean} [options.fieldAsList=false] - Return fields as list.
719
+ * @param {boolean} [options.arrayOnSingle=true] - Return fields as array even if single field.
720
+ * @param {boolean} [options.arrayOnSingleValue=true] - Return fields as array even if single field value.
702
721
  * @returns {Object} Metadata object parsed according to options.
703
722
  */
704
723
 
@@ -757,13 +776,14 @@ var parseTimespan = function parseTimespan() {
757
776
  return output;
758
777
  };
759
778
 
760
- function ownKeys$5(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
779
+ function ownKeys$8(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
761
780
 
762
- function _objectSpread$5(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$5(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$5(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
781
+ function _objectSpread$8(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$8(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$8(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
763
782
  /**
764
783
  * Parses timespanList according to specified options.
765
784
  * The attributes can be targeted for each sub-type.
766
- * @param {Object[]} timespanList - The timespanList response from the API.
785
+ *
786
+ * @param {Object[]} timespanList - A timespanList from VidiCore.
767
787
  * @param {Object} options - Options which change how the metadataType is parsed.
768
788
  * @param {string} options.joinValue - String to join the values, eg ','.
769
789
  * @param {boolean} options.includeAttributes - Include attributes on all objects.
@@ -779,8 +799,8 @@ function _objectSpread$5(target) { for (var i = 1; i < arguments.length; i++) {
779
799
  * @param {boolean} options.timespanAsList - Return timespans as list.
780
800
  * @param {boolean} options.groupAsList - Return groups as list.
781
801
  * @param {boolean} options.fieldAsList - Return fields as list.
782
- * @param {boolean} options.arrayOnSingle=true - Return fields as array even if single field.
783
- * @param {boolean} options.arrayOnSingleValue=true - Return fields as array even if single field value.
802
+ * @param {boolean} [options.arrayOnSingle=true] - Return fields as array even if single field.
803
+ * @param {boolean} [options.arrayOnSingleValue=true] - Return fields as array even if single field value.
784
804
  * @returns {Object} Metadata object parsed according to options.
785
805
  */
786
806
 
@@ -807,15 +827,15 @@ var parseTimespanList = function parseTimespanList() {
807
827
  var parsedTimespan = parseTimespan(thisTimespan, options);
808
828
 
809
829
  if (flat) {
810
- output = _objectSpread$5(_objectSpread$5({}, output), parsedTimespan);
830
+ output = _objectSpread$8(_objectSpread$8({}, output), parsedTimespan);
811
831
  } else if (output[key]) {
812
832
  var _output$key = output[key],
813
833
  currentField = _output$key.field,
814
834
  currentGroup = _output$key.group;
815
835
  var parsedField = parsedTimespan.field,
816
836
  parsedGroup = parsedTimespan.group;
817
- output[key].field = _objectSpread$5(_objectSpread$5({}, currentField), parsedField);
818
- output[key].group = _objectSpread$5(_objectSpread$5({}, currentGroup), parsedGroup);
837
+ output[key].field = _objectSpread$8(_objectSpread$8({}, currentField), parsedField);
838
+ output[key].group = _objectSpread$8(_objectSpread$8({}, currentGroup), parsedGroup);
819
839
  } else {
820
840
  output[key] = parsedTimespan;
821
841
  }
@@ -823,11 +843,11 @@ var parseTimespanList = function parseTimespanList() {
823
843
  return output;
824
844
  };
825
845
 
826
- var _excluded$2 = ["timespan"];
846
+ var _excluded$6 = ["timespan"];
827
847
  /**
828
848
  * Parses MetadataType according to specified options.
829
849
  * The attributes can be targeted for each sub-type.
830
- * @param {Object} metadataType - The MetadataType response from the API.
850
+ * @param {Object} metadataType - A MetadataType from VidiCore.
831
851
  * @param {Object} options - Options which change how the metadataType is parsed.
832
852
  * @param {string} options.joinValue - String to join the values, eg ','.
833
853
  * @param {boolean} options.includeAttributes - Include attributes on all objects.
@@ -843,8 +863,8 @@ var _excluded$2 = ["timespan"];
843
863
  * @param {boolean} options.timespanAsList - Return timespans as list.
844
864
  * @param {boolean} options.groupAsList - Return groups as list.
845
865
  * @param {boolean} options.fieldAsList - Return fields as list.
846
- * @param {boolean} options.arrayOnSingle=true - Return fields as array even if single field.
847
- * @param {boolean} options.arrayOnSingleValue=true - Return fields as array even if single field value.
866
+ * @param {boolean} [options.arrayOnSingle=true] - Return fields as array even if single field.
867
+ * @param {boolean} [options.arrayOnSingleValue=true] - Return fields as array even if single field value.
848
868
  * @returns {Object} Metadata object parsed according to options.
849
869
  */
850
870
 
@@ -860,7 +880,7 @@ var parseMetadataType = function parseMetadataType() {
860
880
  var _ref2 = metadataType || {},
861
881
  _ref2$timespan = _ref2.timespan,
862
882
  timespanList = _ref2$timespan === void 0 ? [] : _ref2$timespan,
863
- attributes = _objectWithoutProperties__default["default"](_ref2, _excluded$2);
883
+ attributes = _objectWithoutProperties__default["default"](_ref2, _excluded$6);
864
884
 
865
885
  if (sortTimespan) timespanList.sort(sortTimespanList);
866
886
  var timespan = parseTimespanList(timespanList, options);
@@ -880,91 +900,7 @@ var parseSimpleMetadataType = function parseSimpleMetadataType() {
880
900
  return parseKeyValuePairType(field);
881
901
  };
882
902
 
883
- function ownKeys$4(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
884
-
885
- function _objectSpread$4(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$4(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$4(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
886
-
887
- /**
888
- * Parses highlight timespan responses from the api into key/value object.
889
- * The attributes can be targeted for each sub-type.
890
- * @param {Object[]} highlightTimespan - A timespan object from the api response.
891
- * @param {Object} options - Options which change how the timespans are parsed.
892
- * @param {boolean} options.arrayOnSingle=true - Return an array if there is a single value.
893
- * @param {boolean} options.timespanAsList=false - Return timespans as list.
894
- * @param {string} options.joinValue - String to join the values, eg ','.
895
- */
896
- var parseHighlightTimespan = function parseHighlightTimespan() {
897
- var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
898
- _ref$field = _ref.field,
899
- field = _ref$field === void 0 ? [] : _ref$field,
900
- start = _ref.start,
901
- end = _ref.end;
902
-
903
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
904
- var _options$arrayOnSingl = options.arrayOnSingle,
905
- arrayOnSingle = _options$arrayOnSingl === void 0 ? true : _options$arrayOnSingl,
906
- _options$joinValue = options.joinValue,
907
- joinValue = _options$joinValue === void 0 ? undefined : _options$joinValue,
908
- _options$timespanAsLi = options.timespanAsList,
909
- timespanAsList = _options$timespanAsLi === void 0 ? undefined : _options$timespanAsLi;
910
- var initialValue = timespanAsList ? {
911
- start: start,
912
- end: end
913
- } : {};
914
- var fieldList = field.reduce(function (a, _ref2) {
915
- var name = _ref2.name,
916
- _ref2$value = _ref2.value,
917
- valueList = _ref2$value === void 0 ? [] : _ref2$value;
918
- if (valueList.length === 0) return a;
919
- var fieldValue;
920
-
921
- if (arrayOnSingle === false && valueList.length === 1) {
922
- var _valueList = _slicedToArray__default["default"](valueList, 1);
923
-
924
- fieldValue = _valueList[0];
925
- } else if (joinValue) fieldValue = valueList.join(joinValue);else fieldValue = valueList;
926
-
927
- return _objectSpread$4(_objectSpread$4({}, a), {}, _defineProperty__default["default"]({}, name, fieldValue));
928
- }, initialValue);
929
- return fieldList;
930
- };
931
-
932
- function ownKeys$3(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
933
-
934
- function _objectSpread$3(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$3(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$3(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
935
- /**
936
- * Parses highlight timespans responses from the api into key/value object.
937
- * The attributes can be targeted for each sub-type.
938
- * @param {Object} highlightTimespanList - A list of timespans from the api response.
939
- * @param {Object} options - Options which change how the timespans are parsed.
940
- * @param {boolean} options.arrayOnSingle=true - Return an array if there is a single value.
941
- * @param {string} options.joinValue - String to join the values, eg ','.
942
- * @param {boolean} options.timespanAsList=false - Return timespans as list.
943
- * @param {boolean} options.flat=false - Flatten to field-name/field-value (Note: field-values may be overwritten).
944
- * @param {boolean} options.flatTimespan=false - Flatten timespan to object with start/end as key.
945
- * @param {string} options.joinTimespan=_ - Character to join the start/end timecodes.
946
- */
947
-
948
- var parseHighlightTimespanList = function parseHighlightTimespanList() {
949
- var highlightTimespanList = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
950
- var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
951
- var flat = opts.flat,
952
- timespanAsList = opts.timespanAsList,
953
- _opts$joinTimespan = opts.joinTimespan,
954
- joinTimespan = _opts$joinTimespan === void 0 ? '_' : _opts$joinTimespan,
955
- flatTimespan = opts.flatTimespan;
956
- if (timespanAsList === true) return highlightTimespanList.map(function (timespan) {
957
- return parseHighlightTimespan(timespan, opts);
958
- });
959
- if (flat === true || flatTimespan === true) return highlightTimespanList.reduce(function (a, timespan) {
960
- return _objectSpread$3(_objectSpread$3({}, a), parseHighlightTimespan(timespan, opts));
961
- }, {});
962
- return highlightTimespanList.reduce(function (a, timespan) {
963
- return _objectSpread$3(_objectSpread$3({}, a), {}, _defineProperty__default["default"]({}, [timespan.start, timespan.end].join(joinTimespan), parseHighlightTimespan(timespan, opts)));
964
- }, {});
965
- };
966
-
967
- var CONSTANT_TIMEBASES = {
903
+ var MAP_CONSTANT_TO_DEN_NUM = {
968
904
  PAL: {
969
905
  denominator: 25,
970
906
  numerator: 1
@@ -984,59 +920,61 @@ var CONSTANT_TIMEBASES = {
984
920
  59.94: {
985
921
  denominator: 60000,
986
922
  numerator: 1001
987
- }
988
- };
989
- var FRAME_SEPARATORS = {
990
- ':': {
991
- dropFrame: false,
992
- field: 2
993
- },
994
- ';': {
995
- dropFrame: true,
996
- field: 2
997
923
  },
998
- '.': {
999
- dropFrame: false,
1000
- field: 1
924
+ 23.976: {
925
+ denominator: 48000,
926
+ numerator: 2002
1001
927
  },
1002
- ',': {
1003
- dropFrame: true,
1004
- field: 1
928
+ 23.98: {
929
+ denominator: 48000,
930
+ numerator: 2002
1005
931
  }
1006
932
  };
933
+ var TIME_BASE_CONSTANTS = Object.keys(MAP_CONSTANT_TO_DEN_NUM);
934
+
935
+ /**
936
+ * TimeBase class representing the TimeBaseType in VidiCore
937
+ *
938
+ * For more info, see the [Time bases section in VidiCore API Docs](https://apidoc.vidispine.com/latest/time.html#time-bases)
939
+ */
1007
940
 
1008
941
  var TimeBase = /*#__PURE__*/function () {
1009
- function TimeBase() {
1010
- var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
942
+ /**
943
+ * Constructor for TimeBase
944
+ *
945
+ * @param {object} [timeCodeType={}] A time base type object
946
+ * @param {number} [timeCodeType.numerator=1] The numerator for the TimeBase
947
+ * @param {number} [timeCodeType.denominator=1] The denominator for the TimeBase
948
+ */
949
+ function TimeBase(timeCodeType) {
950
+ _classCallCheck__default["default"](this, TimeBase);
951
+
952
+ var _ref = timeCodeType || {},
1011
953
  _ref$numerator = _ref.numerator,
1012
954
  numerator = _ref$numerator === void 0 ? 1 : _ref$numerator,
1013
955
  _ref$denominator = _ref.denominator,
1014
956
  denominator = _ref$denominator === void 0 ? 1 : _ref$denominator;
1015
957
 
1016
- _classCallCheck__default["default"](this, TimeBase);
1017
-
1018
958
  this.numerator = Number(numerator);
1019
959
  this.denominator = Number(denominator);
1020
960
  }
961
+ /**
962
+ * Get TimeBase in a constant representation (e.g. "PAL") if possible, otherwise undefined
963
+ * @returns {string} Constant representation of the TimeBase
964
+ */
965
+
1021
966
 
1022
967
  _createClass__default["default"](TimeBase, [{
1023
- key: "toJSON",
1024
- value: function toJSON() {
1025
- return {
1026
- denominator: this.denominator,
1027
- numerator: this.numerator
1028
- };
1029
- }
1030
- }, {
1031
968
  key: "toConstant",
1032
969
  value: function toConstant() {
1033
970
  var _this = this;
1034
971
 
1035
- var constant;
1036
- Object.entries(CONSTANT_TIMEBASES).find(function (thisTimeBase) {
1037
- var _thisTimeBase = _slicedToArray__default["default"](thisTimeBase, 2),
1038
- thisTimeBaseText = _thisTimeBase[0],
1039
- thisTimeBaseType = _thisTimeBase[1];
972
+ var constant; // If multiple equal den/num, it selects first in MAP_CONSTANT_TO_DEN_NUM
973
+
974
+ Object.entries(MAP_CONSTANT_TO_DEN_NUM).find(function (timeBaseConstant) {
975
+ var _timeBaseConstant = _slicedToArray__default["default"](timeBaseConstant, 2),
976
+ thisTimeBaseText = _timeBaseConstant[0],
977
+ thisTimeBaseType = _timeBaseConstant[1];
1040
978
 
1041
979
  var numerator = thisTimeBaseType.numerator,
1042
980
  denominator = thisTimeBaseType.denominator;
@@ -1050,18 +988,36 @@ var TimeBase = /*#__PURE__*/function () {
1050
988
  });
1051
989
  return constant;
1052
990
  }
991
+ /**
992
+ * Get TimeBase as a VidiCore TimeBaseType string
993
+ *
994
+ * Default format: denominator(:numerator if > 1)
995
+ * `constant` has precedence over `fraction` if both are true (e.g. NTSC > 30000:1001)
996
+ *
997
+ * @param {object} [options={}] For how to display it as text
998
+ * @param {boolean} [options.constant=false] Show time base as constant (e.g. PAL)
999
+ * @param {boolean} [options.fraction=false] Show time base as fraction (25:1) even when numerator is 1
1000
+ * @returns {string} Text representation of the TimeBase
1001
+ */
1002
+
1053
1003
  }, {
1054
1004
  key: "toText",
1055
1005
  value: function toText() {
1056
- var useConstant = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
1006
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1057
1007
 
1058
- if (useConstant) {
1008
+ var _ref2 = options || {},
1009
+ _ref2$constant = _ref2.constant,
1010
+ constant = _ref2$constant === void 0 ? false : _ref2$constant,
1011
+ _ref2$fraction = _ref2.fraction,
1012
+ fraction = _ref2$fraction === void 0 ? false : _ref2$fraction;
1013
+
1014
+ if (constant) {
1059
1015
  var _timeBaseText = this.toConstant();
1060
1016
 
1061
1017
  if (_timeBaseText) return _timeBaseText;
1062
1018
  }
1063
1019
 
1064
- if (this.numerator > 1) {
1020
+ if (fraction || this.numerator > 1) {
1065
1021
  var _timeBaseText2 = [this.denominator, this.numerator].join(':');
1066
1022
 
1067
1023
  return _timeBaseText2;
@@ -1070,13 +1026,40 @@ var TimeBase = /*#__PURE__*/function () {
1070
1026
  var timeBaseText = String(this.denominator);
1071
1027
  return timeBaseText;
1072
1028
  }
1029
+ /**
1030
+ * Output TimeBase as frame rate (by default max 16 decimal places)
1031
+ *
1032
+ *
1033
+ * For `options.fixed`:
1034
+ * - `true` gives two decimal places
1035
+ * - `false` gives max amount of decimal places
1036
+ * - `number` gives that amount of decimal places
1037
+ *
1038
+ * Default format: rate with two decimals if needed (i.e. decimals are > 0)
1039
+ * Option precedence (when all true): `constant` > `rounded` > `fixed`
1040
+ *
1041
+ * @param {object} [options={}] For how to display it as rate
1042
+ * @param {boolean|number} [options.fixed=true] Amount of decimal places (true gives 2 decimal places)
1043
+ * @param {boolean} [options.constant=false] Use constant representation (if applicable)
1044
+ * @param {boolean} [options.rounded=false] Rounded to nearest integer
1045
+ *
1046
+ * @returns {number} Rate of the TimeBase
1047
+ */
1048
+
1073
1049
  }, {
1074
1050
  key: "toRate",
1075
1051
  value: function toRate() {
1076
- var useConstant = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
1077
- var round = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
1052
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1078
1053
 
1079
- if (useConstant) {
1054
+ var _ref3 = options || {},
1055
+ _ref3$constant = _ref3.constant,
1056
+ constant = _ref3$constant === void 0 ? false : _ref3$constant,
1057
+ _ref3$rounded = _ref3.rounded,
1058
+ rounded = _ref3$rounded === void 0 ? false : _ref3$rounded,
1059
+ _ref3$fixed = _ref3.fixed,
1060
+ fixed = _ref3$fixed === void 0 ? true : _ref3$fixed;
1061
+
1062
+ if (constant) {
1080
1063
  var _rate = this.toConstant();
1081
1064
 
1082
1065
  if (_rate) return _rate;
@@ -1088,56 +1071,110 @@ var TimeBase = /*#__PURE__*/function () {
1088
1071
  return rate;
1089
1072
  }
1090
1073
 
1091
- return round ? rate.toFixed(2) : rate;
1074
+ if (rounded) {
1075
+ return Math.round(rate);
1076
+ }
1077
+
1078
+ if (fixed === true || typeof fixed === 'number') {
1079
+ return Number(rate.toFixed(fixed === true ? 2 : fixed));
1080
+ }
1081
+
1082
+ return rate;
1083
+ }
1084
+ /**
1085
+ * Get TimeBase in a object representation
1086
+ *
1087
+ * @returns {object} TimeBase as `{denominator, numerator}` object
1088
+ */
1089
+
1090
+ }, {
1091
+ key: "toObject",
1092
+ value: function toObject() {
1093
+ return {
1094
+ denominator: this.denominator,
1095
+ numerator: this.numerator
1096
+ };
1097
+ }
1098
+ /**
1099
+ * @deprecated Use {@link TimeBase#toObject|toObject} instead
1100
+ *
1101
+ * @returns {object} TimeBase as `{denominator, numerator}` object
1102
+ */
1103
+
1104
+ }, {
1105
+ key: "toJson",
1106
+ value: function toJson() {
1107
+ // eslint-disable-next-line no-console
1108
+ console.warn('Deprecated - use toObject instead');
1109
+ return this.toObject();
1092
1110
  }
1093
1111
  }]);
1094
1112
 
1095
1113
  return TimeBase;
1096
1114
  }();
1097
1115
 
1098
- var formatTimeBaseType = function formatTimeBaseType(timeBase) {
1099
- return new TimeBase(timeBase);
1100
- };
1116
+ /**
1117
+ * Format a string representation of a time base to a TimeBase Instance
1118
+ *
1119
+ * @param {string} timeBaseText The string to format to a TimeBase instance
1120
+ * @returns {TimeBase} A TimeBase Instance
1121
+ */
1101
1122
 
1102
1123
  var formatTimeBaseText = function formatTimeBaseText(timeBaseText) {
1103
1124
  if (timeBaseText === undefined) {
1104
- return formatTimeBaseType();
1125
+ return new TimeBase();
1105
1126
  }
1106
1127
 
1107
1128
  if (typeof timeBaseText === 'number') {
1108
- return formatTimeBaseType({
1129
+ return new TimeBase({
1109
1130
  denominator: timeBaseText
1110
1131
  });
1111
1132
  }
1112
1133
 
1113
- if (timeBaseText.includes(':')) {
1134
+ if (typeof timeBaseText === 'string' && timeBaseText.includes(':')) {
1114
1135
  var _timeBaseText$split = timeBaseText.split(':'),
1115
1136
  _timeBaseText$split2 = _slicedToArray__default["default"](_timeBaseText$split, 2),
1116
- _denominator = _timeBaseText$split2[0],
1137
+ denominator = _timeBaseText$split2[0],
1117
1138
  numerator = _timeBaseText$split2[1];
1118
1139
 
1119
- return formatTimeBaseType({
1120
- denominator: _denominator,
1140
+ return new TimeBase({
1141
+ denominator: denominator,
1121
1142
  numerator: numerator
1122
1143
  });
1123
1144
  }
1124
1145
 
1125
- if (Object.keys(CONSTANT_TIMEBASES).includes(timeBaseText)) {
1126
- return formatTimeBaseType(CONSTANT_TIMEBASES[timeBaseText]);
1146
+ if (TIME_BASE_CONSTANTS.includes(timeBaseText)) {
1147
+ return new TimeBase(MAP_CONSTANT_TO_DEN_NUM[timeBaseText]);
1127
1148
  }
1128
1149
 
1129
- var denominator = Number(timeBaseText);
1130
-
1131
- if (Number.isNaN(denominator)) {
1132
- throw new Error("timeBaseText must be a number or ".concat(Object.keys(CONSTANT_TIMEBASES).join(','), " - is ").concat(timeBaseText));
1150
+ if (!['string', 'number'].includes(_typeof__default["default"](timeBaseText)) || Number.isNaN(Number(timeBaseText))) {
1151
+ throw new Error("timeBaseText must be a number or ".concat(TIME_BASE_CONSTANTS.join(','), " - is ").concat(JSON.stringify(timeBaseText)));
1133
1152
  }
1134
1153
 
1135
- return formatTimeBaseType({
1136
- denominator: denominator
1154
+ return new TimeBase({
1155
+ denominator: Number(timeBaseText)
1137
1156
  });
1138
1157
  };
1139
1158
 
1140
- var formatTimeBase = function formatTimeBase(timeBase) {
1159
+ /**
1160
+ * Create a TimeBase instance of an object
1161
+ *
1162
+ * @param {object} timeBase A TimeBase object ({ numerator, denominator })
1163
+ * @returns {TimeBase} A TimeBase instance
1164
+ */
1165
+
1166
+ var formatTimeBaseType = function formatTimeBaseType(timeBase) {
1167
+ return new TimeBase(timeBase);
1168
+ };
1169
+
1170
+ /**
1171
+ * Create a TimeBase Instance from a string or object representation of a time base
1172
+ *
1173
+ * @param {string|object} timeBase Expressed as "denominator:numerator" or { numerator, denominator }
1174
+ * @returns {TimeBase} A TimeBase instance
1175
+ */
1176
+
1177
+ var createTimeBase = function createTimeBase(timeBase) {
1141
1178
  if (_typeof__default["default"](timeBase) === 'object') {
1142
1179
  return formatTimeBaseType(timeBase);
1143
1180
  }
@@ -1145,47 +1182,86 @@ var formatTimeBase = function formatTimeBase(timeBase) {
1145
1182
  return formatTimeBaseText(timeBase);
1146
1183
  };
1147
1184
 
1148
- var getDropFrames$1 = function getDropFrames(roundedFrameRate) {
1149
- return roundedFrameRate === 60 ? 4 : 2;
1185
+ /**
1186
+ * @private
1187
+ *
1188
+ * Drops 4 frames (0-3) for 59.97 and 2 frames (0-1) for 29.97/NTSC
1189
+ *
1190
+ * @param {TimeBase} timeBase to check
1191
+ * @returns {number} amount of frame drops for specified timeBase
1192
+ */
1193
+ var getAmountOfFrameDrops = function getAmountOfFrameDrops(timeBase) {
1194
+ var timeBaseConstant = timeBase.toRate({
1195
+ constant: true
1196
+ });
1197
+ return timeBaseConstant === '59.94' && 4 || ['NTSC', '29.97'].includes(timeBaseConstant) && 2 || 0;
1150
1198
  };
1151
1199
 
1152
- var getRoundedFrameRate$1 = function getRoundedFrameRate(timeBase) {
1153
- return Math.round(timeBase.denominator / timeBase.numerator);
1200
+ /**
1201
+ * @private
1202
+ *
1203
+ * Check if TimeBase drops frames
1204
+ *
1205
+ * @param {object} timeBase TimeBase Instance to check
1206
+ * @returns {boolean} true if time base drops frames, false otherwise
1207
+ */
1208
+
1209
+ var isDropFrameTimeBase = function isDropFrameTimeBase(timeBase) {
1210
+ return getAmountOfFrameDrops(timeBase) > 0;
1154
1211
  };
1155
1212
 
1156
- function countDroppedFrames(frames, roundedFrameRate) {
1157
- var dropFrames = getDropFrames$1(roundedFrameRate);
1158
- var oneMinuteUndroppedFrames = 60 * roundedFrameRate;
1159
- var oneMinuteDroppedFrames = 60 * roundedFrameRate - dropFrames;
1160
- var tenMinuteFrames = 10 * (oneMinuteUndroppedFrames - dropFrames) + dropFrames;
1161
- var tenMinuteChunks = Math.floor(frames / tenMinuteFrames);
1162
- var minuteRemainder = Math.max(0, frames % tenMinuteFrames - oneMinuteUndroppedFrames);
1163
- var oneMinuteChunks = Math.floor(minuteRemainder / oneMinuteDroppedFrames);
1164
- var frameRemainder = minuteRemainder % oneMinuteDroppedFrames;
1165
- var frameChunks = frameRemainder > 0 ? dropFrames : 0;
1166
- return tenMinuteChunks * 9 * dropFrames + oneMinuteChunks * dropFrames + frameChunks;
1167
- }
1213
+ var _excluded$5 = ["hours"];
1168
1214
 
1169
- var isDropFrameTimeBase = function isDropFrameTimeBase(_ref) {
1170
- var numerator = _ref.numerator,
1171
- denominator = _ref.denominator;
1172
- return numerator === 1001 && (denominator === 60000 || denominator === 30000);
1215
+ var getDroppedFramesFromSamples = function getDroppedFramesFromSamples(_ref) {
1216
+ var samples = _ref.samples,
1217
+ timeBase = _ref.timeBase;
1218
+ var amountOfFrameDrops = getAmountOfFrameDrops(timeBase);
1219
+ if (amountOfFrameDrops === 0) return 0;
1220
+ var roundedFrameRate = timeBase.toRate({
1221
+ rounded: true
1222
+ });
1223
+ var oneMinuteNotDroppedFrames = 60 * roundedFrameRate;
1224
+ var amountOfFramesToDropPerMinute = 60 * roundedFrameRate - amountOfFrameDrops;
1225
+ var tenMinuteFrames = 10 * (oneMinuteNotDroppedFrames - amountOfFrameDrops) + amountOfFrameDrops;
1226
+ var amountOfTenMinuteChunks = Math.floor((samples + 1) / tenMinuteFrames);
1227
+ var minuteRemainder = Math.max(0, (samples + 1) % tenMinuteFrames - oneMinuteNotDroppedFrames);
1228
+ var amountOfOneMinuteReminderChunks = Math.floor(minuteRemainder / amountOfFramesToDropPerMinute);
1229
+ var frameRemainder = minuteRemainder % amountOfFramesToDropPerMinute;
1230
+ var amountOfFrameRemainderChunks = frameRemainder > 0 ? amountOfFrameDrops : 0;
1231
+ return amountOfTenMinuteChunks * 9 * amountOfFrameDrops + amountOfOneMinuteReminderChunks * amountOfFrameDrops + amountOfFrameRemainderChunks;
1173
1232
  };
1233
+ /**
1234
+ * TimeCode class representing the TimeCodeType in VidiCore
1235
+ *
1236
+ * For more info, see the [Time Codes section of VidiCore API Docs](https://apidoc.vidispine.com/latest/time.html#time-codes)
1237
+ */
1238
+
1174
1239
 
1175
1240
  var TimeCode = /*#__PURE__*/function () {
1241
+ /**
1242
+ * Constructor for TimeCode
1243
+ *
1244
+ * @param {object} [timeCodeType={}] Object to create TimeCode of
1245
+ * @param {number} [timeCodeType.samples=0] Amount of samples for the time code
1246
+ * @param {object|string|number} [timeCodeType.timeBase={numerator: 1, denominator: 1}] The time base it should have
1247
+ * @param {object} [options={}] Options for the timeCode
1248
+ * @param {boolean} options.dropFrame If time code should be dropFrame or not (by default checks timeBase)
1249
+ * @param {string} options.frameSeparator Separator to use for frame smpte output (default ":" for non-drop-frame and ";" for dropFrame)
1250
+ */
1176
1251
  function TimeCode() {
1177
- var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
1178
- _ref2$samples = _ref2.samples,
1179
- samples = _ref2$samples === void 0 ? 0 : _ref2$samples,
1180
- timeBase = _ref2.timeBase;
1252
+ var _options$dropFrame, _options$frameSeparat;
1181
1253
 
1182
- var _ref3 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
1183
- dropFrame = _ref3.dropFrame,
1184
- _ref3$field = _ref3.field,
1185
- field = _ref3$field === void 0 ? 2 : _ref3$field;
1254
+ var timeCodeType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1255
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1186
1256
 
1187
1257
  _classCallCheck__default["default"](this, TimeCode);
1188
1258
 
1259
+ var _ref2 = timeCodeType || {},
1260
+ _ref2$samples = _ref2.samples,
1261
+ samples = _ref2$samples === void 0 ? 0 : _ref2$samples,
1262
+ _ref2$timeBase = _ref2.timeBase,
1263
+ timeBase = _ref2$timeBase === void 0 ? new TimeBase() : _ref2$timeBase;
1264
+
1189
1265
  if (typeof samples === 'number') {
1190
1266
  this.samples = samples;
1191
1267
  } else if (typeof samples === 'string') {
@@ -1200,21 +1276,39 @@ var TimeCode = /*#__PURE__*/function () {
1200
1276
  throw new Error("samples is not number/string/-Inf/+Inf is: ".concat(samples));
1201
1277
  }
1202
1278
 
1203
- this.timeBase = new TimeBase(timeBase);
1204
- this.dropFrame = dropFrame === undefined ? isDropFrameTimeBase(this.timeBase) : dropFrame;
1205
- this.field = field;
1279
+ this.timeBase = createTimeBase(timeBase);
1280
+ this.dropFrame = (_options$dropFrame = options === null || options === void 0 ? void 0 : options.dropFrame) !== null && _options$dropFrame !== void 0 ? _options$dropFrame : isDropFrameTimeBase(this.timeBase);
1281
+ this.frameSeparator = (_options$frameSeparat = options === null || options === void 0 ? void 0 : options.frameSeparator) !== null && _options$frameSeparat !== void 0 ? _options$frameSeparat : this.dropFrame ? ';' : ':';
1206
1282
  }
1283
+ /**
1284
+ * Return this TimeCode added with the supplied timeCodeType
1285
+ * If time bases differ, it will retain the time base of this TimeCode instance
1286
+ * If supplied time code has a more granular time base - it will round down exceeding samples (hasn't reached that sample yet)
1287
+ *
1288
+ * Note: This might make you "lose" frames depending on granularity of time bases, e.g.
1289
+ * "51@50".add("25@25") => "101@50"
1290
+ * while "25@25".add("51@50") => "50@25" (not "101@50")
1291
+ *
1292
+ * @param {TimeCode} timeCodeType A TimeCode instance you want to add with
1293
+ * @returns A new TimeCode instance with the addition applied
1294
+ */
1295
+
1207
1296
 
1208
1297
  _createClass__default["default"](TimeCode, [{
1209
1298
  key: "add",
1210
- value: function add(val) {
1211
- var _val$timeBase = val.timeBase,
1212
- numerator = _val$timeBase.numerator,
1213
- denominator = _val$timeBase.denominator;
1214
- var conformedTimeCode = val;
1299
+ value: function add(timeCodeType) {
1300
+ if (!(timeCodeType !== null && timeCodeType !== void 0 && timeCodeType.timeBase) || (timeCodeType === null || timeCodeType === void 0 ? void 0 : timeCodeType.samples) === undefined) {
1301
+ throw Error('Invalid timeCodeType, cannot be added');
1302
+ }
1303
+
1304
+ var _timeCodeType$timeBas = timeCodeType.timeBase;
1305
+ _timeCodeType$timeBas = _timeCodeType$timeBas === void 0 ? {} : _timeCodeType$timeBas;
1306
+ var numerator = _timeCodeType$timeBas.numerator,
1307
+ denominator = _timeCodeType$timeBas.denominator;
1308
+ var conformedTimeCode = timeCodeType;
1215
1309
 
1216
1310
  if (numerator !== this.timeBase.numerator || denominator !== this.timeBase.denominator) {
1217
- conformedTimeCode = val.conformTimeBase(this.timeBase);
1311
+ conformedTimeCode = timeCodeType.conformTimeBase(this.timeBase);
1218
1312
  }
1219
1313
 
1220
1314
  var _conformedTimeCode = conformedTimeCode,
@@ -1224,16 +1318,34 @@ var TimeCode = /*#__PURE__*/function () {
1224
1318
  timeBase: this.timeBase
1225
1319
  });
1226
1320
  }
1321
+ /**
1322
+ * Return this TimeCode subtracted with the supplied timeCodeType
1323
+ * If time bases differ, it will retain the time base of the instance time code
1324
+ * If supplied time code has a more granular time base - it will round down exceeding samples (hasn't reached that sample yet)
1325
+ *
1326
+ * Note: This might make you "lose" frames depending on granularity of time bases, e.g.
1327
+ * "101@50".subtract("25@25") => "51@50"
1328
+ * while "50@25".subtract("51@50") => "25@25" (not "49@50")
1329
+ *
1330
+ * @param {TimeCode} timeCodeType A TimeCode instance you want to subtract with
1331
+ * @returns A new TimeCode instance with the subtraction applied
1332
+ */
1333
+
1227
1334
  }, {
1228
1335
  key: "subtract",
1229
- value: function subtract(val) {
1230
- var _val$timeBase2 = val.timeBase,
1231
- numerator = _val$timeBase2.numerator,
1232
- denominator = _val$timeBase2.denominator;
1233
- var conformedTimeCode = val;
1336
+ value: function subtract(timeCodeType) {
1337
+ if (!(timeCodeType !== null && timeCodeType !== void 0 && timeCodeType.timeBase) || (timeCodeType === null || timeCodeType === void 0 ? void 0 : timeCodeType.samples) === undefined) {
1338
+ throw Error('Invalid timeCodeType, cannot be subtracted');
1339
+ }
1340
+
1341
+ var _timeCodeType$timeBas2 = timeCodeType.timeBase;
1342
+ _timeCodeType$timeBas2 = _timeCodeType$timeBas2 === void 0 ? {} : _timeCodeType$timeBas2;
1343
+ var numerator = _timeCodeType$timeBas2.numerator,
1344
+ denominator = _timeCodeType$timeBas2.denominator;
1345
+ var conformedTimeCode = timeCodeType;
1234
1346
 
1235
1347
  if (numerator !== this.timeBase.numerator || denominator !== this.timeBase.denominator) {
1236
- conformedTimeCode = val.conformTimeBase(this.timeBase);
1348
+ conformedTimeCode = timeCodeType.conformTimeBase(this.timeBase);
1237
1349
  }
1238
1350
 
1239
1351
  var _conformedTimeCode2 = conformedTimeCode,
@@ -1243,361 +1355,760 @@ var TimeCode = /*#__PURE__*/function () {
1243
1355
  timeBase: this.timeBase
1244
1356
  });
1245
1357
  }
1358
+ /**
1359
+ * Creates a new TimeCode instance with specified timeBase and samples adjusted to that.
1360
+ *
1361
+ * If it conforms to a less granular time base - it will floor samples (hasn't reached that sample yet)
1362
+ * - e.g. "51@50".conformTo("PAL") => "25@PAL" (not "26@PAL")
1363
+ *
1364
+ * @param {string|object} conformTo The TimeBase it should conform the TimeCode to
1365
+ * @returns A new TimeCode instance with the conformTo timeBase applied
1366
+ */
1367
+
1246
1368
  }, {
1247
1369
  key: "conformTimeBase",
1248
1370
  value: function conformTimeBase(conformTo) {
1249
- var timeBase = conformTo;
1371
+ var conformToTimeBase = conformTo;
1250
1372
 
1251
- if (conformTo instanceof TimeCode === false) {
1252
- timeBase = new TimeBase(conformTo);
1373
+ if (!(conformTo instanceof TimeBase)) {
1374
+ conformToTimeBase = createTimeBase(conformTo);
1253
1375
  }
1254
1376
 
1255
- var samples = Math.round(this.samples / (this.timeBase.toRate(false, false) / timeBase.toRate(false, false)));
1377
+ var samples = Math.floor(this.samples / (this.timeBase.toRate({
1378
+ fixed: false
1379
+ }) / conformToTimeBase.toRate({
1380
+ fixed: false
1381
+ })));
1256
1382
  var timeCode = {
1257
1383
  samples: samples,
1258
- timeBase: timeBase
1384
+ timeBase: conformToTimeBase
1259
1385
  };
1260
1386
  return new TimeCode(timeCode);
1261
1387
  }
1262
- }, {
1263
- key: "toJSON",
1264
- value: function toJSON() {
1265
- return {
1266
- samples: this.samples,
1267
- timeBase: this.timeBase
1268
- };
1269
- }
1388
+ /**
1389
+ * Get TimeCode as a text representation
1390
+ *
1391
+ * Default format: samples@denominator(:numerator if > 1)
1392
+ * `constant` has precedence over `fraction` if both are true
1393
+ *
1394
+ * @param {object} [options={}] TimeBase toText options
1395
+ * @param {boolean} [options.includeTimeBaseForSeconds=false] include time base even if seconds
1396
+ * @param {boolean} [options.constant=false] show as constant (e.g. @PAL)
1397
+ * @param {boolean} [options.fraction=false] show as fraction (@25:1)
1398
+ * @returns Text representation of TimeCode
1399
+ */
1400
+
1270
1401
  }, {
1271
1402
  key: "toText",
1272
1403
  value: function toText() {
1273
- var timeCodeText = String(this.samples);
1274
- var timeBaseText = this.timeBase.toText();
1404
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1405
+ var timeCodeText = "".concat(this.samples);
1406
+ var timeBaseText = this.timeBase.toText(options);
1275
1407
 
1276
- if (timeBaseText !== '1') {
1408
+ if (options !== null && options !== void 0 && options.includeTimeBaseForSeconds || !['1', '1:1'].includes(timeBaseText)) {
1277
1409
  timeCodeText = [this.samples, timeBaseText].join('@');
1278
1410
  }
1279
1411
 
1280
1412
  return timeCodeText;
1281
1413
  }
1414
+ /**
1415
+ * Get TimeCode in a units object representation
1416
+ *
1417
+ * @returns {object} in the format { hours, minutes, seconds, frames }
1418
+ */
1419
+
1282
1420
  }, {
1283
- key: "toSeconds",
1284
- value: function toSeconds() {
1285
- var _this$timeBase = this.timeBase,
1286
- numerator = _this$timeBase.numerator,
1287
- denominator = _this$timeBase.denominator;
1288
- return this.samples * (numerator / denominator);
1421
+ key: "toUnits",
1422
+ value: function toUnits() {
1423
+ var totalSamples = this.samples + (this.dropFrame ? getDroppedFramesFromSamples(this) : 0);
1424
+ var roundedFrameRate = this.timeBase.toRate({
1425
+ rounded: true
1426
+ }); // Calculated without drop-frame but with 2 decimal places
1427
+
1428
+ if (['23.976', '23.98'].includes(this.timeBase.toConstant())) {
1429
+ roundedFrameRate = this.timeBase.toRate({
1430
+ fixed: true
1431
+ });
1432
+ }
1433
+
1434
+ var hours = Math.floor(totalSamples / (3600 * roundedFrameRate));
1435
+ var minutes = Math.floor(totalSamples / (60 * roundedFrameRate)) % 60;
1436
+ var seconds = Math.floor(totalSamples / roundedFrameRate) % 60;
1437
+ var frames = Math.floor(totalSamples % roundedFrameRate);
1438
+ return {
1439
+ hours: hours,
1440
+ minutes: minutes,
1441
+ seconds: seconds,
1442
+ frames: frames
1443
+ };
1289
1444
  }
1445
+ /**
1446
+ * Get TimeCode in a time object representation
1447
+ * "milliseconds" is rounded down, if you want another representation use "partialSeconds"
1448
+ *
1449
+ * @returns {object} in the format { hours, minutes, seconds, milliseconds, partialSeconds }
1450
+ */
1451
+
1290
1452
  }, {
1291
1453
  key: "toTime",
1292
1454
  value: function toTime() {
1293
- var roundedFrameRate = getRoundedFrameRate$1(this.timeBase);
1294
- var totalSamples = this.samples + (this.dropFrame ? countDroppedFrames(this.samples + 1, roundedFrameRate) : 0);
1295
- var hours = Math.floor(totalSamples / (3600 * roundedFrameRate));
1296
- var minutes = Math.floor(totalSamples / (60 * roundedFrameRate)) % 60;
1297
- var seconds = Math.floor(totalSamples / roundedFrameRate) % 60;
1298
- var frames = totalSamples % roundedFrameRate;
1299
- var partialSeconds = frames / roundedFrameRate;
1455
+ var totalSamples = this.samples + getDroppedFramesFromSamples(this);
1456
+
1457
+ var _this$toUnits = this.toUnits(),
1458
+ hours = _this$toUnits.hours,
1459
+ minutes = _this$toUnits.minutes,
1460
+ seconds = _this$toUnits.seconds;
1461
+
1462
+ var roundedFrameRate = this.timeBase.toRate({
1463
+ rounded: true
1464
+ });
1465
+ var framesPrecise = totalSamples % roundedFrameRate;
1466
+ var milliseconds = Math.floor(1000 * framesPrecise / roundedFrameRate);
1467
+ var partialSeconds = framesPrecise / roundedFrameRate;
1300
1468
  return {
1301
1469
  hours: hours,
1302
1470
  minutes: minutes,
1303
1471
  seconds: seconds,
1304
- frames: frames,
1472
+ milliseconds: milliseconds,
1305
1473
  partialSeconds: partialSeconds
1306
1474
  };
1307
1475
  }
1476
+ /**
1477
+ * Get TimeCode in a seconds representation
1478
+ *
1479
+ * @returns {number} the seconds
1480
+ */
1481
+
1482
+ }, {
1483
+ key: "toSeconds",
1484
+ value: function toSeconds() {
1485
+ var _this$timeBase = this.timeBase,
1486
+ numerator = _this$timeBase.numerator,
1487
+ denominator = _this$timeBase.denominator;
1488
+ return Math.round(1000 * +(this.samples * numerator / denominator)) / 1000;
1489
+ }
1490
+ /**
1491
+ * Get TimeCode in a duration representation
1492
+ * The time unit char keys for the format string are:
1493
+ * - "h" for hour
1494
+ * - "m" for minute
1495
+ * - "s" for seconds
1496
+ * - "S" for milliseconds
1497
+ * Any other char will be kept in the duration output string.
1498
+ *
1499
+ * Add consecutive chars for zero padding.
1500
+ *
1501
+ * By default it:
1502
+ * - uses colon delimiter (e.g. for format "hhmmss")
1503
+ * - shows "m:ss" or "h:mm:ss" if format is undefined
1504
+ *
1505
+ * @param {object} [options={}]
1506
+ * @param {string} options.format specify format of duration string, e.g. hh:mm:ss.S for 01:23:04.5
1507
+ * @returns {string} Duration representation of the TimeCode
1508
+ */
1509
+
1308
1510
  }, {
1309
1511
  key: "toDuration",
1310
1512
  value: function toDuration() {
1311
- var _ref4 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
1312
- format = _ref4.format;
1513
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1514
+ var format = options.format;
1313
1515
 
1314
1516
  var _this$toTime = this.toTime(),
1315
1517
  hours = _this$toTime.hours,
1316
- minutes = _this$toTime.minutes,
1317
- seconds = _this$toTime.seconds;
1518
+ rest = _objectWithoutProperties__default["default"](_this$toTime, _excluded$5);
1318
1519
 
1319
- if (typeof format === 'string') {
1320
- if (format.toLowerCase() === 'hhmmss') {
1321
- return [hours.toFixed().padStart(2, '0'), minutes.toFixed().padStart(2, '0'), seconds.toFixed().padStart(2, '0')].join(':');
1322
- }
1520
+ var minutes = rest.minutes,
1521
+ seconds = rest.seconds,
1522
+ milliseconds = rest.milliseconds;
1523
+
1524
+ if (!!format && typeof format !== 'string') {
1525
+ throw Error('format has to be a string');
1323
1526
  }
1324
1527
 
1325
- if (hours) {
1326
- return [hours.toFixed(), minutes.toFixed().padStart(2, '0'), seconds.toFixed().padStart(2, '0')].join(':');
1528
+ var isBefore = function isBefore(unit, units) {
1529
+ return !format.includes(unit) || !units.some(function (u) {
1530
+ return format.includes(u) && format.lastIndexOf(unit) > format.indexOf(u);
1531
+ });
1532
+ };
1533
+
1534
+ if (!!format && !(isBefore('h', ['m', 's', 'S']) && isBefore('m', ['s', 'S']) && isBefore('s', ['S']))) {
1535
+ throw Error('format order is unsupported (has to be h, m, s then S)');
1327
1536
  }
1328
1537
 
1329
- if (minutes >= 10) {
1330
- return [minutes.toFixed().padStart(2, '0'), seconds.toFixed().padStart(2, '0')].join(':');
1538
+ if (!format) {
1539
+ return "".concat(hours > 0 ? "".concat(hours, ":").concat("".concat(minutes).padStart(2, '0')) : minutes, ":").concat("".concat(seconds).padStart(2, '0'));
1331
1540
  }
1332
1541
 
1333
- return [minutes.toFixed(), seconds.toFixed().padStart(2, '0')].join(':');
1334
- }
1335
- }, {
1336
- key: "toSmpte",
1337
- value: function toSmpte() {
1338
- var _this = this;
1542
+ var countConsecutiveChars = function countConsecutiveChars(i, arr) {
1543
+ var j = i;
1339
1544
 
1340
- if (this.samples === -Infinity) return '00:00:00:00';
1545
+ while (arr[j] === arr[j + 1]) {
1546
+ j += 1;
1547
+ }
1341
1548
 
1342
- var _this$toTime2 = this.toTime(),
1343
- hours = _this$toTime2.hours,
1344
- minutes = _this$toTime2.minutes,
1345
- seconds = _this$toTime2.seconds,
1346
- frames = _this$toTime2.frames;
1549
+ return j - i + 1;
1550
+ };
1347
1551
 
1348
- var hhmmss = [hours.toFixed().padStart(2, '0'), minutes.toFixed().padStart(2, '0'), seconds.toFixed().padStart(2, '0')].join(':');
1552
+ var timeUnitKeys = ['h', 'm', 's', 'S'];
1553
+ var output = [];
1349
1554
 
1350
- var _Object$entries$find = Object.entries(FRAME_SEPARATORS).find(function (thisSeparator) {
1351
- var _thisSeparator = _slicedToArray__default["default"](thisSeparator, 2),
1352
- _thisSeparator$ = _thisSeparator[1],
1353
- dropFrame = _thisSeparator$.dropFrame,
1354
- field = _thisSeparator$.field;
1555
+ _toConsumableArray__default["default"](format).forEach(function (c, i, arr) {
1556
+ switch (c) {
1557
+ case 'h':
1558
+ {
1559
+ if (arr[i - 1] === 'h') {
1560
+ break;
1561
+ }
1355
1562
 
1356
- return dropFrame === _this.dropFrame && field === _this.field;
1357
- }),
1358
- _Object$entries$find2 = _slicedToArray__default["default"](_Object$entries$find, 1),
1359
- _Object$entries$find3 = _Object$entries$find2[0],
1360
- frameSeparator = _Object$entries$find3 === void 0 ? ':' : _Object$entries$find3;
1563
+ var amount = countConsecutiveChars(i, arr);
1564
+ output.push("".concat(hours).padStart(amount, '0'));
1361
1565
 
1362
- return [hhmmss, frames.toFixed().padStart(2, '0')].join(frameSeparator);
1363
- }
1364
- }, {
1365
- key: "toFraction",
1366
- value: function toFraction() {
1367
- return "".concat(this.samples, "@").concat(this.timeBase.denominator, ":").concat(this.timeBase.numerator);
1368
- }
1369
- }]);
1566
+ if (timeUnitKeys.includes(arr[i + amount])) {
1567
+ output.push(':');
1568
+ }
1370
1569
 
1371
- return TimeCode;
1372
- }();
1570
+ break;
1571
+ }
1373
1572
 
1374
- var formatTimeCodeType = function formatTimeCodeType(timeCode, options) {
1375
- return new TimeCode(timeCode, options);
1376
- };
1573
+ case 'm':
1574
+ {
1575
+ if (arr[i - 1] === 'm') {
1576
+ break;
1577
+ }
1377
1578
 
1378
- var formatTimeCodeText = function formatTimeCodeText(timeCodeText, options) {
1379
- if (timeCodeText === undefined) {
1380
- var _timeCode = {
1381
- samples: 0
1382
- };
1383
- return formatTimeCodeType(_timeCode, options);
1384
- }
1579
+ var _amount = countConsecutiveChars(i, arr);
1385
1580
 
1386
- if (typeof timeCodeText === 'number') {
1387
- var _timeCode2 = {
1388
- samples: timeCodeText
1389
- };
1390
- return formatTimeCodeType(_timeCode2, options);
1391
- }
1581
+ if (!format.includes('h')) {
1582
+ minutes *= hours * 60;
1583
+ }
1392
1584
 
1393
- if (timeCodeText.includes('@')) {
1394
- var _timeCodeText$split = timeCodeText.split('@'),
1395
- _timeCodeText$split2 = _slicedToArray__default["default"](_timeCodeText$split, 2),
1396
- samplesString = _timeCodeText$split2[0],
1397
- timeBaseText = _timeCodeText$split2[1];
1585
+ output.push("".concat(minutes).padStart(_amount, '0'));
1398
1586
 
1399
- var _samples = Number(samplesString);
1587
+ if (timeUnitKeys.includes(arr[i + _amount])) {
1588
+ output.push(':');
1589
+ }
1400
1590
 
1401
- var timeBase = formatTimeBaseText(timeBaseText);
1402
- var _timeCode3 = {
1403
- samples: _samples,
1404
- timeBase: timeBase
1405
- };
1406
- return formatTimeCodeType(_timeCode3, options);
1407
- }
1591
+ break;
1592
+ }
1408
1593
 
1409
- if (timeCodeText === '-INF') {
1410
- var _samples2 = -Infinity;
1594
+ case 's':
1595
+ {
1596
+ if (arr[i - 1] === 's') {
1597
+ break;
1598
+ }
1411
1599
 
1412
- var _timeCode4 = {
1413
- samples: _samples2
1414
- };
1415
- return formatTimeCodeType(_timeCode4, options);
1416
- }
1600
+ var _amount2 = countConsecutiveChars(i, arr);
1417
1601
 
1418
- if (timeCodeText === '+INF') {
1419
- var _samples3 = Infinity;
1420
- var _timeCode5 = {
1421
- samples: _samples3
1422
- };
1423
- return formatTimeCodeType(_timeCode5, options);
1424
- }
1602
+ if (!format.includes('m')) {
1603
+ seconds *= minutes * 60;
1604
+ }
1605
+
1606
+ output.push("".concat(seconds).padStart(_amount2, '0'));
1607
+
1608
+ if (timeUnitKeys.includes(arr[i + _amount2])) {
1609
+ output.push('.');
1610
+ }
1611
+
1612
+ break;
1613
+ }
1614
+
1615
+ case 'S':
1616
+ {
1617
+ if (arr[i - 1] === 'S') {
1618
+ break;
1619
+ }
1620
+
1621
+ var _amount3 = countConsecutiveChars(i, arr);
1622
+
1623
+ if (!format.includes('s')) {
1624
+ milliseconds *= seconds * 1000;
1625
+ }
1626
+
1627
+ output.push("".concat(Math.round(milliseconds / Math.pow(10, 3 - _amount3))).padStart(_amount3, '0'));
1628
+ break;
1629
+ }
1630
+
1631
+ default:
1632
+ output.push(c);
1633
+ }
1634
+ });
1635
+
1636
+ return output.join('');
1637
+ }
1638
+ /**
1639
+ * Get TimeCode in a smpte representation
1640
+ *
1641
+ * @returns {string} Smpte representation of the TimeCode
1642
+ */
1643
+
1644
+ }, {
1645
+ key: "toSmpte",
1646
+ value: function toSmpte() {
1647
+ if (this.samples === -Infinity) return '00:00:00:00';
1648
+
1649
+ var _this$toUnits2 = this.toUnits(),
1650
+ hours = _this$toUnits2.hours,
1651
+ minutes = _this$toUnits2.minutes,
1652
+ seconds = _this$toUnits2.seconds,
1653
+ frames = _this$toUnits2.frames;
1654
+
1655
+ var hhmmss = [hours.toFixed().padStart(2, '0'), minutes.toFixed().padStart(2, '0'), seconds.toFixed().padStart(2, '0')].join(':');
1656
+ return [hhmmss, "".concat(frames).padStart(2, '0')].join(this.frameSeparator);
1657
+ }
1658
+ /**
1659
+ * Get TimeCode as a VidiCore TimeCodeType object
1660
+ *
1661
+ * @returns {object} TimeCode as `{ samples, timeBase }`
1662
+ */
1663
+
1664
+ }, {
1665
+ key: "toObject",
1666
+ value: function toObject() {
1667
+ return {
1668
+ samples: this.samples,
1669
+ timeBase: this.timeBase.toObject()
1670
+ };
1671
+ }
1672
+ /**
1673
+ * @deprecated Use {@link TimeCode#toObject|toObject} instead
1674
+ *
1675
+ * @returns {object} TimeCode as `{ samples, timeBase }`
1676
+ */
1677
+
1678
+ }, {
1679
+ key: "toJson",
1680
+ value: function toJson() {
1681
+ // eslint-disable-next-line no-console
1682
+ console.warn('Deprecated - use toObject instead');
1683
+ return this.toObject();
1684
+ }
1685
+ }]);
1425
1686
 
1426
- var samples = Number(timeCodeText);
1687
+ return TimeCode;
1688
+ }();
1427
1689
 
1428
- if (Number.isNaN(samples)) {
1429
- throw new Error("timeBaseText must be a number or sample@timeBase - is ".concat(timeCodeText));
1690
+ /* eslint-disable no-self-assign */
1691
+
1692
+ /**
1693
+ * @private
1694
+ *
1695
+ * Using Euclid's algorithm
1696
+ *
1697
+ * @param {number} num1 a number
1698
+ * @param {number} num2 another number
1699
+ * @returns {number} the greatest common divisor as a number
1700
+ */
1701
+ var getGreatestCommonDivisor = function getGreatestCommonDivisor(num1, num2) {
1702
+ var a = Math.abs(num1);
1703
+ var b = Math.abs(num2);
1704
+
1705
+ while (a && b && a !== b) {
1706
+ if (a > b) {
1707
+ var _ref = [a - b, b];
1708
+ a = _ref[0];
1709
+ b = _ref[1];
1710
+ } else {
1711
+ var _ref2 = [a, b - a];
1712
+ a = _ref2[0];
1713
+ b = _ref2[1];
1714
+ }
1430
1715
  }
1431
1716
 
1432
- var timeCode = {
1433
- samples: samples
1434
- };
1435
- return formatTimeCodeType(timeCode, options);
1717
+ return a || b;
1436
1718
  };
1437
1719
 
1438
- var formatSeconds = function formatSeconds(seconds, timeBase, options) {
1439
- if (Number.isNaN(Number(seconds))) {
1440
- throw new Error("seconds must be digits, is ".concat(seconds));
1441
- }
1720
+ var _excluded$4 = ["timeBase", "useGCD"];
1721
+ /**
1722
+ * Format seconds to TimeCode object
1723
+ * Input time base is always 1:1 since it expects seconds as input
1724
+ *
1725
+ * Note: Max 15 digits accuracy (double precision float64), e.g.
1726
+ * - 10^6 seconds can have 10^9 decimals (nanosecond) precision
1727
+ * - 10^9 seconds can have 10^6 decimals (microsecond) precision
1728
+ * - 10^12 seconds can have 10^3 decimals (millisecond) precision
1729
+ *
1730
+ * @param {string|number} seconds With or without decimals ("." and "," are both interpreted as decimal)
1731
+ * @param {object} [options={}] Options for how to format the seconds to a TimeCode
1732
+ * @param {object|string} options.timeBase What TimeBase the resulting TimeCode should have (if unset and useGCD=false, denominator will be 10^<amount-of-decimals>)
1733
+ * @param {boolean} [options.useGCD=false] Samples and denominator are divided with GCD (ignored if timeBase is set) (e.g. 1.04 => 104@100 => 26@25)
1734
+ * @returns {TimeCode} A TimeCode instance
1735
+ */
1442
1736
 
1443
- var _ref = timeBase || {},
1444
- _ref$denominator = _ref.denominator,
1445
- denominator = _ref$denominator === void 0 ? 1 : _ref$denominator,
1446
- _ref$numerator = _ref.numerator,
1447
- numerator = _ref$numerator === void 0 ? 1 : _ref$numerator;
1737
+ var formatTimeCodeSeconds = function formatTimeCodeSeconds(seconds) {
1738
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1448
1739
 
1449
- var samples = seconds * (denominator / numerator);
1450
- var timeCode = {
1451
- samples: samples,
1452
- timeBase: timeBase || {}
1453
- };
1454
- return new TimeCode(timeCode, options);
1455
- };
1740
+ var timeBase = options.timeBase,
1741
+ _options$useGCD = options.useGCD,
1742
+ useGCD = _options$useGCD === void 0 ? false : _options$useGCD,
1743
+ timeCodeOptions = _objectWithoutProperties__default["default"](options, _excluded$4);
1456
1744
 
1457
- var formatSecondsPrecise = function formatSecondsPrecise(seconds, timeBase, options) {
1458
- if (Number.isNaN(Number(seconds))) {
1745
+ var secondsWithDot = "".concat(seconds).replace(/,/g, '.');
1746
+
1747
+ if (Number.isNaN(+secondsWithDot)) {
1459
1748
  throw new Error("seconds must be digits, is ".concat(seconds));
1460
1749
  }
1461
1750
 
1462
- var _ref = timeBase || {},
1463
- _ref$numerator = _ref.numerator,
1464
- numerator = _ref$numerator === void 0 ? 1 : _ref$numerator;
1751
+ var denominator = 1;
1752
+ var samples;
1465
1753
 
1466
- var _ref2 = timeBase || {},
1467
- _ref2$denominator = _ref2.denominator,
1468
- denominator = _ref2$denominator === void 0 ? 1 : _ref2$denominator;
1754
+ if (Number.isInteger(+secondsWithDot)) {
1755
+ samples = +secondsWithDot * denominator;
1756
+ } else {
1757
+ var _ms$length;
1469
1758
 
1470
- if (!Number.isInteger(seconds)) {
1471
- var decimalPlaces = String(seconds).split('.')[1].length;
1759
+ var _secondsWithDot$split = secondsWithDot.split('.'),
1760
+ _secondsWithDot$split2 = _slicedToArray__default["default"](_secondsWithDot$split, 2),
1761
+ ms = _secondsWithDot$split2[1];
1762
+
1763
+ var decimalPlaces = Math.min((_ms$length = ms === null || ms === void 0 ? void 0 : ms.length) !== null && _ms$length !== void 0 ? _ms$length : 0, 16);
1472
1764
  denominator *= Math.pow(10, decimalPlaces);
1765
+ samples = Math.round(secondsWithDot * denominator);
1766
+ }
1767
+
1768
+ if (!timeBase && useGCD) {
1769
+ var gcd = getGreatestCommonDivisor(denominator, samples);
1770
+ samples /= gcd;
1771
+ denominator /= gcd;
1473
1772
  }
1474
1773
 
1475
- var samples = (seconds * (denominator / numerator)).toFixed();
1476
- var timeCode = {
1774
+ var timeCode = new TimeCode({
1477
1775
  samples: samples,
1478
1776
  timeBase: {
1479
1777
  denominator: denominator,
1480
- numerator: numerator
1778
+ numerator: 1
1481
1779
  }
1482
- };
1483
- return new TimeCode(timeCode, options);
1780
+ }, timeCodeOptions);
1781
+ return timeBase ? timeCode.conformTimeBase(createTimeBase(timeBase === true ? 1 : timeBase)) : timeCode;
1484
1782
  };
1485
1783
 
1486
- function ownKeys$2(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
1784
+ var _excluded$3 = ["exceedingMode", "timeBase"];
1487
1785
 
1488
- function _objectSpread$2(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$2(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$2(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
1786
+ function ownKeys$7(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
1489
1787
 
1490
- var getDropFrames = function getDropFrames(roundedFrameRate) {
1491
- return roundedFrameRate === 60 ? 4 : 2;
1788
+ function _objectSpread$7(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$7(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$7(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
1789
+ var MAP_SEPARATOR_TO_OPTIONS = {
1790
+ ':': {
1791
+ dropFrame: false,
1792
+ frameSeparator: ':'
1793
+ },
1794
+ '.': {
1795
+ dropFrame: false,
1796
+ frameSeparator: '.'
1797
+ },
1798
+ ';': {
1799
+ dropFrame: true,
1800
+ frameSeparator: ';'
1801
+ },
1802
+ ',': {
1803
+ dropFrame: true,
1804
+ frameSeparator: ','
1805
+ }
1492
1806
  };
1807
+ var getDroppedFramesFromSmpte = function getDroppedFramesFromSmpte(_ref, samples, timeBase) {
1808
+ var _ref2 = _slicedToArray__default["default"](_ref, 4),
1809
+ hh = _ref2[0],
1810
+ mm = _ref2[1],
1811
+ ss = _ref2[2],
1812
+ ff = _ref2[3];
1813
+
1814
+ var roundedFrameRate = timeBase.toRate({
1815
+ rounded: true
1816
+ });
1817
+ var dropFrames = getAmountOfFrameDrops(timeBase);
1818
+
1819
+ if (samples === 0 || dropFrames === 0) {
1820
+ return 0;
1821
+ }
1822
+
1823
+ var shouldDropMinute = mm % 10 !== 0;
1824
+ var shouldDropSecond = shouldDropMinute && ss === 0;
1825
+ var hourFrames = hh * (3600 * roundedFrameRate - 54 * dropFrames);
1826
+ var minuteFrames = mm * 60 * roundedFrameRate - (mm - Math.ceil(mm / 10)) * dropFrames;
1827
+ var secondFrames = ss * roundedFrameRate - (shouldDropMinute && ss > 1 ? dropFrames : 0);
1828
+
1829
+ if (shouldDropSecond && ff < dropFrames) {
1830
+ throw new Error("Frame does not exist for ".concat(timeBase.toRate({
1831
+ constant: true
1832
+ }), " drop-frame"));
1833
+ }
1493
1834
 
1494
- var getRoundedFrameRate = function getRoundedFrameRate(timeBase) {
1495
- return Math.round(timeBase.denominator / timeBase.numerator);
1835
+ var frameFrames = shouldDropSecond ? ff - dropFrames : ff;
1836
+ var samplesWithoutDroppedFrames = hourFrames + minuteFrames + secondFrames + frameFrames;
1837
+ return samples - samplesWithoutDroppedFrames;
1496
1838
  };
1497
1839
 
1498
- var splitSmpte = function splitSmpte(smpteText) {
1499
- var hasDropFrameSeparator = smpteText.match(/[^0-9:\-_]/);
1500
- var hhmmssff;
1501
- var frameOptions = {};
1840
+ var splitSmpte = function splitSmpte(smpte) {
1841
+ var _ref3 = (smpte === null || smpte === void 0 ? void 0 : smpte.match(/[^0-9:\-_]/)) || [],
1842
+ _ref4 = _slicedToArray__default["default"](_ref3, 1),
1843
+ nonColonFrameSeparator = _ref4[0];
1502
1844
 
1503
- if (hasDropFrameSeparator) {
1504
- var _hasDropFrameSeparato = _slicedToArray__default["default"](hasDropFrameSeparator, 1),
1505
- frameSeparator = _hasDropFrameSeparato[0];
1845
+ var smpteValues = [];
1846
+ var options = {
1847
+ frameSeparator: ':',
1848
+ dropFrame: false
1849
+ };
1506
1850
 
1507
- var _smpteText$split = smpteText.split(frameSeparator),
1508
- _smpteText$split2 = _slicedToArray__default["default"](_smpteText$split, 2),
1509
- hhmmss = _smpteText$split2[0],
1510
- splitFrames = _smpteText$split2[1];
1851
+ if (nonColonFrameSeparator) {
1852
+ var _smpte$split = smpte.split(nonColonFrameSeparator),
1853
+ _smpte$split2 = _slicedToArray__default["default"](_smpte$split, 2),
1854
+ hhmmss = _smpte$split2[0],
1855
+ ff = _smpte$split2[1];
1511
1856
 
1512
- hhmmssff = [].concat(_toConsumableArray__default["default"](hhmmss.split(':')), [splitFrames]);
1513
- frameOptions = FRAME_SEPARATORS[frameSeparator] || {};
1857
+ smpteValues = [].concat(_toConsumableArray__default["default"](hhmmss.split(':')), [ff]);
1858
+ options = MAP_SEPARATOR_TO_OPTIONS[nonColonFrameSeparator] || {};
1514
1859
  } else {
1515
- hhmmssff = smpteText.split(':');
1860
+ smpteValues = smpte.split(':');
1516
1861
  }
1517
1862
 
1518
- hhmmssff = hhmmssff.map(Number);
1863
+ smpteValues = smpteValues.map(Number);
1864
+
1865
+ if (smpteValues.length !== 4) {
1866
+ throw new Error('Invalid format, must be "##:##:##:##');
1867
+ }
1519
1868
 
1520
- if (hhmmssff.length > 4 || hhmmssff.some(function (n) {
1869
+ if (smpteValues.some(function (n) {
1521
1870
  return Number.isNaN(n);
1522
1871
  })) {
1523
- throw new Error('Invalid SMPTE timecode');
1872
+ throw new Error('Invalid format, values must be numbers');
1524
1873
  }
1525
1874
 
1526
- return [hhmmssff, frameOptions];
1875
+ return [smpteValues, options];
1527
1876
  };
1528
1877
 
1529
- var countSamples = function countSamples(hh, mm, ss, ff, _ref) {
1530
- var dropFrame = _ref.dropFrame,
1531
- roundedFrameRate = _ref.roundedFrameRate;
1878
+ var getSamplesFromSmpte = function getSamplesFromSmpte(smpteValues, timeBase, dropFrame) {
1879
+ var _smpteValues = _slicedToArray__default["default"](smpteValues, 4),
1880
+ hh = _smpteValues[0],
1881
+ mm = _smpteValues[1],
1882
+ ss = _smpteValues[2],
1883
+ ff = _smpteValues[3];
1884
+
1885
+ var roundedFrameRate = timeBase.toRate({
1886
+ rounded: true
1887
+ });
1888
+ var samples = hh * 3600 * roundedFrameRate + mm * 60 * roundedFrameRate + ss * roundedFrameRate + ff;
1889
+ return samples - (dropFrame ? getDroppedFramesFromSmpte(smpteValues, samples, timeBase) : 0);
1890
+ }; // Better naming than "useValueExcess" and "useValueTruncate" must exist
1891
+
1532
1892
 
1533
- if (!dropFrame) {
1534
- return hh * 3600 * roundedFrameRate + mm * 60 * roundedFrameRate + ss * roundedFrameRate + ff;
1893
+ var EXCEEDING_OPTIONS = ['error', 'add', 'ignore'];
1894
+ /**
1895
+ * Format smpte text to a TimeCode Instance
1896
+ *
1897
+ * exceedingMode:
1898
+ * - "overflow" exceeding values will be kept (e.g. PAL and 00:00:00:25 => 00:00:01:00)
1899
+ * - "truncate" exceeding values will be truncated (e.g. PAL and 00:00:00:25 => 00:00:00:24)
1900
+ * - "error" exceeding values will throw error (e.g. PAL and 00:00:00:25 => Error)
1901
+ *
1902
+ * @param {string} smpte String representation of smpte
1903
+ * @param {object} [options={}] What options to use for creating the time code from smpte (all not specified below are passed to the TimeCode constructor)
1904
+ * @param {object|string|number} options.timeBase TimeBase of smpte (and consequently TimeBase of output TimeCode)
1905
+ * @param {string} [options.exceedingMode=error] How to handle exceeding values (`overflow|truncate|error`)
1906
+ * @param {boolean} options.dropFrame If it should parse and create time code using dropFrame
1907
+ * @param {string} options.frameSeparator What frame separator the TimeCode should store (defaults to what the smpte has)
1908
+ * @returns {TimeCode} A TimeCode instance
1909
+ */
1910
+
1911
+ var formatTimeCodeSmpte = function formatTimeCodeSmpte(smpte) {
1912
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1913
+
1914
+ var _options$exceedingMod = options.exceedingMode,
1915
+ exceedingMode = _options$exceedingMod === void 0 ? 'error' : _options$exceedingMod,
1916
+ timeBase = options.timeBase,
1917
+ timeCodeOptions = _objectWithoutProperties__default["default"](options, _excluded$3);
1918
+
1919
+ if ([null, undefined].includes(smpte)) {
1920
+ throw new Error("smpte cannot be undefined or null");
1535
1921
  }
1536
1922
 
1537
- if (![30, 60].includes(roundedFrameRate)) {
1538
- throw new Error('Cannot use dropframe with non NTSC timebase');
1923
+ if (typeof smpte !== 'string') {
1924
+ throw new Error("smpte must be a string, is ".concat(JSON.stringify(smpte)));
1539
1925
  }
1540
1926
 
1541
- var dropFrames = getDropFrames(roundedFrameRate);
1542
- var shouldDropMinute = mm % 10 !== 0;
1543
- var shouldDropSecond = shouldDropMinute && ss === 0;
1544
- var hourFrames = hh * (3600 * roundedFrameRate - 54 * dropFrames);
1545
- var minuteFrames = mm * 60 * roundedFrameRate - (mm - Math.ceil(mm / 10)) * dropFrames;
1546
- var secondFrames = ss * roundedFrameRate - (shouldDropMinute && ss > 1 ? dropFrames : 0);
1927
+ var _splitSmpte = splitSmpte(smpte),
1928
+ _splitSmpte2 = _slicedToArray__default["default"](_splitSmpte, 2),
1929
+ smpteValues = _splitSmpte2[0],
1930
+ timeCodeOptionsFromSmpte = _splitSmpte2[1];
1547
1931
 
1548
- if (shouldDropSecond && ff < dropFrames) {
1549
- throw new Error('Invalid ff');
1932
+ var timeBaseInstance = createTimeBase(timeBase);
1933
+
1934
+ var mergedOptions = _objectSpread$7(_objectSpread$7({}, timeCodeOptionsFromSmpte), {}, {
1935
+ dropFrame: isDropFrameTimeBase(timeBaseInstance)
1936
+ }, timeCodeOptions);
1937
+
1938
+ var roundedFrameRate = timeBaseInstance.toRate({
1939
+ rounded: true
1940
+ });
1941
+ var maxFrame = Math.max(0, roundedFrameRate - 1);
1942
+
1943
+ if (smpteValues.some(function (v) {
1944
+ return v < 0;
1945
+ })) {
1946
+ throw new Error('Negative values are not supported');
1550
1947
  }
1551
1948
 
1552
- var frameFrames = shouldDropSecond ? ff - dropFrames : ff;
1553
- return hourFrames + minuteFrames + secondFrames + frameFrames;
1949
+ var samples;
1950
+
1951
+ switch (exceedingMode) {
1952
+ case 'error':
1953
+ {
1954
+ var _smpteValues2 = _slicedToArray__default["default"](smpteValues, 4),
1955
+ hours = _smpteValues2[0],
1956
+ minutes = _smpteValues2[1],
1957
+ seconds = _smpteValues2[2],
1958
+ frames = _smpteValues2[3];
1959
+
1960
+ if (hours >= 100) {
1961
+ throw Error('Minutes has to be less than 60');
1962
+ }
1963
+
1964
+ if (minutes >= 60) {
1965
+ throw Error('Minutes has to be less than 60');
1966
+ }
1967
+
1968
+ if (seconds >= 60) {
1969
+ throw Error('Seconds has to be less than 60');
1970
+ }
1971
+
1972
+ if (frames > maxFrame) {
1973
+ throw Error("Frames has to be less or equal to ".concat(maxFrame));
1974
+ }
1975
+
1976
+ samples = getSamplesFromSmpte(smpteValues, timeBaseInstance, mergedOptions === null || mergedOptions === void 0 ? void 0 : mergedOptions.dropFrame);
1977
+ break;
1978
+ }
1979
+
1980
+ case 'ignore':
1981
+ {
1982
+ var _smpteValues3 = _slicedToArray__default["default"](smpteValues, 4),
1983
+ _hours = _smpteValues3[0],
1984
+ _minutes = _smpteValues3[1],
1985
+ _seconds = _smpteValues3[2],
1986
+ _frames = _smpteValues3[3];
1987
+
1988
+ var truncatedSmpteValues = [Math.min(100, _hours), Math.min(59, _minutes), Math.min(59, _seconds), Math.min(maxFrame, _frames)];
1989
+ samples = getSamplesFromSmpte(truncatedSmpteValues, timeBaseInstance, mergedOptions === null || mergedOptions === void 0 ? void 0 : mergedOptions.dropFrame);
1990
+ break;
1991
+ }
1992
+
1993
+ case 'add':
1994
+ {
1995
+ samples = getSamplesFromSmpte(smpteValues, timeBaseInstance, mergedOptions === null || mergedOptions === void 0 ? void 0 : mergedOptions.dropFrame);
1996
+ break;
1997
+ }
1998
+
1999
+ default:
2000
+ {
2001
+ throw new Error("Invalid exceedingMode, options are ".concat(JSON.stringify(EXCEEDING_OPTIONS)));
2002
+ }
2003
+ }
2004
+
2005
+ return new TimeCode({
2006
+ samples: samples,
2007
+ timeBase: timeBaseInstance
2008
+ }, mergedOptions);
1554
2009
  };
1555
2010
 
1556
- var formatSmpte = function formatSmpte(smpteText, timeBaseText) {
1557
- var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
2011
+ var _excluded$2 = ["timeBase"];
2012
+ /**
2013
+ * Format text to a TimeCode instance
2014
+ *
2015
+ * @param {string} timeCodeText A time code text (e.g. "25@PAL")
2016
+ * @param {object} [options={}] Options for how to format
2017
+ * @param {object|string} options.timeBase The time base the returned TimeCode should have
2018
+ * @returns {TimeCode} A TimeCode instance
2019
+ */
2020
+
2021
+ var formatTimeCodeText = function formatTimeCodeText(timeCodeText, options) {
2022
+ var _timeCodeObject;
2023
+
2024
+ var _ref = options || {},
2025
+ timeBase = _ref.timeBase,
2026
+ timeCodeOptions = _objectWithoutProperties__default["default"](_ref, _excluded$2);
1558
2027
 
1559
- if (smpteText === undefined) {
1560
- var _timeBase = formatTimeBase(timeBaseText);
2028
+ var timeCodeObject;
1561
2029
 
1562
- var _timeCode = {
1563
- samples: 0,
1564
- timeBase: _timeBase
2030
+ if (timeCodeText === undefined) {
2031
+ timeCodeObject = {
2032
+ samples: 0
2033
+ };
2034
+ } else if (typeof timeCodeText === 'number') {
2035
+ timeCodeObject = {
2036
+ samples: timeCodeText
2037
+ };
2038
+ } else if (timeCodeText.includes('@')) {
2039
+ var _timeCodeText$split = timeCodeText.split('@'),
2040
+ _timeCodeText$split2 = _slicedToArray__default["default"](_timeCodeText$split, 2),
2041
+ samplesString = _timeCodeText$split2[0],
2042
+ timeBaseText = _timeCodeText$split2[1];
2043
+
2044
+ var samples = Number(samplesString);
2045
+ timeCodeObject = {
2046
+ samples: samples,
2047
+ timeBase: formatTimeBaseText(timeBaseText)
2048
+ };
2049
+ } else if (timeCodeText === '-INF') {
2050
+ timeCodeObject = {
2051
+ samples: -Infinity
2052
+ };
2053
+ } else if (timeCodeText === '+INF') {
2054
+ timeCodeObject = {
2055
+ samples: Infinity
2056
+ };
2057
+ } else {
2058
+ timeCodeObject = {
2059
+ samples: Number(timeCodeText)
1565
2060
  };
1566
- return formatTimeCodeType(_timeCode);
1567
2061
  }
1568
2062
 
1569
- if (typeof smpteText !== 'string') {
1570
- throw new Error("smpteText must be a string, is ".concat(smpteText));
2063
+ if (Number.isNaN((_timeCodeObject = timeCodeObject) === null || _timeCodeObject === void 0 ? void 0 : _timeCodeObject.samples) || timeCodeObject.timeBase && !(timeCodeObject.timeBase instanceof TimeBase)) {
2064
+ throw new Error("timeCodeText must be a number or sample@timeBase - is ".concat(timeCodeText));
1571
2065
  }
1572
2066
 
1573
- var _splitSmpte = splitSmpte(smpteText),
1574
- _splitSmpte2 = _slicedToArray__default["default"](_splitSmpte, 2),
1575
- _splitSmpte2$ = _slicedToArray__default["default"](_splitSmpte2[0], 4),
1576
- hh = _splitSmpte2$[0],
1577
- mm = _splitSmpte2$[1],
1578
- ss = _splitSmpte2$[2],
1579
- _splitSmpte2$$ = _splitSmpte2$[3],
1580
- ff = _splitSmpte2$$ === void 0 ? 0 : _splitSmpte2$$,
1581
- frameOptions = _splitSmpte2[1];
1582
-
1583
- var _frameOptions$dropFra = frameOptions.dropFrame,
1584
- dropFrame = _frameOptions$dropFra === void 0 ? false : _frameOptions$dropFra;
1585
- var timeBase = formatTimeBase(timeBaseText);
1586
- var roundedFrameRate = getRoundedFrameRate(timeBase);
1587
-
1588
- if (mm >= 60 || mm < 0 || ss >= 60 || ss < 0 || ff >= roundedFrameRate || ff < 0) {
1589
- throw new Error('Invalid mm, ss or ff');
1590
- }
1591
-
1592
- var samples = countSamples(hh, mm, ss, ff, {
1593
- dropFrame: dropFrame,
1594
- roundedFrameRate: roundedFrameRate
1595
- });
1596
- var timeCode = {
1597
- samples: samples,
1598
- timeBase: timeBase
1599
- };
1600
- return formatTimeCodeType(timeCode, _objectSpread$2(_objectSpread$2({}, frameOptions), options));
2067
+ var timeCode = new TimeCode(timeCodeObject, timeCodeOptions);
2068
+ return timeBase ? timeCode.conformTimeBase(createTimeBase(timeBase)) : timeCode;
2069
+ };
2070
+
2071
+ /**
2072
+ * Format an object to a TimeCode instance
2073
+ *
2074
+ * @param {object} timeCode To create TimeCode instance of
2075
+ * @param {object} options For the TimeCode constructor
2076
+ * @returns {TimeCode} A TimeCode instance
2077
+ */
2078
+
2079
+ var formatTimeCodeType = function formatTimeCodeType(timeCode, options) {
2080
+ return new TimeCode(timeCode, options);
2081
+ };
2082
+
2083
+ var isObject = function isObject(o) {
2084
+ return Object.prototype.toString.call(o) === '[object Object]';
2085
+ };
2086
+
2087
+ var isString = function isString(s) {
2088
+ return typeof s === 'string';
2089
+ };
2090
+
2091
+ var hasSmpteFormat = function hasSmpteFormat(s) {
2092
+ return isString(s) && !!s.match(/^(\d\d+):(\d\d+):(\d\d+)(:|;|\.|,)(\d\d+)$/);
2093
+ };
2094
+
2095
+ var isNumber = function isNumber(s) {
2096
+ return !Number.isNaN(Number(s));
2097
+ };
2098
+ /**
2099
+ * Create a TimeCode instance from smpte, seconds/samples, timeCode object or string
2100
+ *
2101
+ * @param {object|string|number} timeCode Smpte, seconds/samples, timeCode object or string
2102
+ * @param {object} [options={}] For the format functions
2103
+ * @returns {TimeCode} A TimeCode instance
2104
+ */
2105
+
2106
+
2107
+ var createTimeCode = function createTimeCode(timeCode, options) {
2108
+ if (isObject(timeCode)) return formatTimeCodeType(timeCode, options);
2109
+ if (hasSmpteFormat(timeCode)) return formatTimeCodeSmpte(timeCode, options);
2110
+ if (isNumber(timeCode)) return formatTimeCodeSeconds(timeCode, options);
2111
+ return formatTimeCodeText(timeCode, options);
1601
2112
  };
1602
2113
 
1603
2114
  function timeToCueTime(_ref) {
@@ -1617,10 +2128,10 @@ function timeToCueTime(_ref) {
1617
2128
  }
1618
2129
  /**
1619
2130
  * Convert subtitle groups to WebVtt subtitle format
1620
- * @param {Object} input={}
2131
+ * @param {Object} [input={}]
1621
2132
  * @param {Object} input.metadataType - MetadataType response from API.
1622
- * @param {string} input.subtitleGroup=stl_subtitle - Name of group containing subtitle field/text.
1623
- * @param {string} input.subtitleField=stl_text - Name of field (text) to use for the subtitles.
2133
+ * @param {string} [input.subtitleGroup=stl_subtitle] - Name of group containing subtitle field/text.
2134
+ * @param {string} [input.subtitleField=stl_text] - Name of field (text) to use for the subtitles.
1624
2135
  * @returns {string} WebVtt subtitles
1625
2136
  */
1626
2137
 
@@ -1679,9 +2190,9 @@ var createFacetType = function createFacetType() {
1679
2190
  });
1680
2191
  };
1681
2192
 
1682
- function ownKeys$1(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2193
+ function ownKeys$6(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
1683
2194
 
1684
- function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$1(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$1(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
2195
+ function _objectSpread$6(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$6(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$6(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
1685
2196
 
1686
2197
  var parseFacetType = function parseFacetType() {
1687
2198
  var facetType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
@@ -1690,7 +2201,7 @@ var parseFacetType = function parseFacetType() {
1690
2201
  var facetFieldReducer = function facetFieldReducer(a, _ref) {
1691
2202
  var fieldValue = _ref.fieldValue,
1692
2203
  value = _ref.value;
1693
- return _objectSpread$1(_objectSpread$1({}, a), {}, _defineProperty__default["default"]({}, fieldValue, value));
2204
+ return _objectSpread$6(_objectSpread$6({}, a), {}, _defineProperty__default["default"]({}, fieldValue, value));
1694
2205
  };
1695
2206
 
1696
2207
  facetType.forEach(function (_ref2) {
@@ -1702,41 +2213,95 @@ var parseFacetType = function parseFacetType() {
1702
2213
  return output;
1703
2214
  };
1704
2215
 
1705
- var _excluded$1 = ["property"];
2216
+ function ownKeys$5(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
1706
2217
 
1707
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2218
+ function _objectSpread$5(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$5(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$5(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
1708
2219
 
1709
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
1710
- var sampleRateSymbols = {
1711
- kB: 'kHz',
1712
- B: 'Hz',
1713
- mB: 'mHz'
1714
- };
1715
- var bitRateSymbols = {
1716
- kB: 'kbps',
1717
- B: 'bps',
1718
- MB: 'mbps'
1719
- };
2220
+ /**
2221
+ * Parses highlight timespan in VidiCore into key/value object.
2222
+ * The attributes can be targeted for each sub-type.
2223
+ * @param {Object[]} highlightTimespan - A VidiCore timespan object.
2224
+ * @param {Object} options - Options which change how the timespans are parsed.
2225
+ * @param {boolean} [options.arrayOnSingle=true] - Return an array if there is a single value.
2226
+ * @param {boolean} [options.timespanAsList=false] - Return timespans as list.
2227
+ * @param {string} options.joinValue - String to join the values, eg ','.
2228
+ */
2229
+ var parseHighlightTimespan = function parseHighlightTimespan() {
2230
+ var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
2231
+ _ref$field = _ref.field,
2232
+ field = _ref$field === void 0 ? [] : _ref$field,
2233
+ start = _ref.start,
2234
+ end = _ref.end;
1720
2235
 
1721
- var gcd = function gcd(a, b) {
1722
- return b ? gcd(b, a % b) : a;
2236
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2237
+ var _options$arrayOnSingl = options.arrayOnSingle,
2238
+ arrayOnSingle = _options$arrayOnSingl === void 0 ? true : _options$arrayOnSingl,
2239
+ _options$joinValue = options.joinValue,
2240
+ joinValue = _options$joinValue === void 0 ? undefined : _options$joinValue,
2241
+ _options$timespanAsLi = options.timespanAsList,
2242
+ timespanAsList = _options$timespanAsLi === void 0 ? undefined : _options$timespanAsLi;
2243
+ var initialValue = timespanAsList ? {
2244
+ start: start,
2245
+ end: end
2246
+ } : {};
2247
+ var fieldList = field.reduce(function (a, _ref2) {
2248
+ var name = _ref2.name,
2249
+ _ref2$value = _ref2.value,
2250
+ valueList = _ref2$value === void 0 ? [] : _ref2$value;
2251
+ if (valueList.length === 0) return a;
2252
+ var fieldValue;
2253
+
2254
+ if (arrayOnSingle === false && valueList.length === 1) {
2255
+ var _valueList = _slicedToArray__default["default"](valueList, 1);
2256
+
2257
+ fieldValue = _valueList[0];
2258
+ } else if (joinValue) fieldValue = valueList.join(joinValue);else fieldValue = valueList;
2259
+
2260
+ return _objectSpread$5(_objectSpread$5({}, a), {}, _defineProperty__default["default"]({}, name, fieldValue));
2261
+ }, initialValue);
2262
+ return fieldList;
1723
2263
  };
1724
2264
 
1725
- var parseAspectRatio = function parseAspectRatio(_ref) {
1726
- var width = _ref.width,
1727
- height = _ref.height;
1728
- var denominator = gcd(width, height);
1729
- var widthRatio = width / denominator;
1730
- var heightRatio = height / denominator;
2265
+ function ownKeys$4(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
1731
2266
 
1732
- if (widthRatio > 21) {
1733
- heightRatio = 1;
1734
- widthRatio = (width / height).toFixed(2);
1735
- }
2267
+ function _objectSpread$4(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$4(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$4(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
2268
+ /**
2269
+ * Parses highlight timespans from VidiCore into key/value object.
2270
+ * The attributes can be targeted for each sub-type.
2271
+ * @param {Object} highlightTimespanList - A list of timespans from VidiCore.
2272
+ * @param {Object} options - Options which change how the timespans are parsed.
2273
+ * @param {boolean} [options.arrayOnSingle=true] - Return an array if there is a single value.
2274
+ * @param {string} options.joinValue - String to join the values, eg ','.
2275
+ * @param {boolean} [options.timespanAsList=false] - Return timespans as list.
2276
+ * @param {boolean} [options.flat=false] - Flatten to field-name/field-value (Note: field-values may be overwritten).
2277
+ * @param {boolean} [options.flatTimespan=false] - Flatten timespan to object with start/end as key.
2278
+ * @param {string} [options.joinTimespan=_] - Character to join the start/end timecodes.
2279
+ */
1736
2280
 
1737
- return [widthRatio, heightRatio].join(':');
2281
+ var parseHighlightTimespanList = function parseHighlightTimespanList() {
2282
+ var highlightTimespanList = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
2283
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2284
+ var flat = options.flat,
2285
+ timespanAsList = options.timespanAsList,
2286
+ _options$joinTimespan = options.joinTimespan,
2287
+ joinTimespan = _options$joinTimespan === void 0 ? '_' : _options$joinTimespan,
2288
+ flatTimespan = options.flatTimespan;
2289
+ if (timespanAsList === true) return highlightTimespanList.map(function (timespan) {
2290
+ return parseHighlightTimespan(timespan, options);
2291
+ });
2292
+ if (flat === true || flatTimespan === true) return highlightTimespanList.reduce(function (a, timespan) {
2293
+ return _objectSpread$4(_objectSpread$4({}, a), parseHighlightTimespan(timespan, options));
2294
+ }, {});
2295
+ return highlightTimespanList.reduce(function (a, timespan) {
2296
+ return _objectSpread$4(_objectSpread$4({}, a), {}, _defineProperty__default["default"]({}, [timespan.start, timespan.end].join(joinTimespan), parseHighlightTimespan(timespan, options)));
2297
+ }, {});
1738
2298
  };
1739
2299
 
2300
+ var _excluded$1 = ["property"];
2301
+
2302
+ function ownKeys$3(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2303
+
2304
+ function _objectSpread$3(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$3(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$3(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
1740
2305
  var parseBaseMediaInfoType = function parseBaseMediaInfoType() {
1741
2306
  var baseMediaInfoType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1742
2307
 
@@ -1744,7 +2309,64 @@ var parseBaseMediaInfoType = function parseBaseMediaInfoType() {
1744
2309
  props = _objectWithoutProperties__default["default"](baseMediaInfoType, _excluded$1);
1745
2310
 
1746
2311
  var parsedKeyValuePairType = parseKeyValuePairType(keyValuePairType);
1747
- return _objectSpread(_objectSpread({}, parsedKeyValuePairType), props);
2312
+ return _objectSpread$3(_objectSpread$3({}, parsedKeyValuePairType), props);
2313
+ };
2314
+
2315
+ var sampleRateSymbols = {
2316
+ kB: 'kHz',
2317
+ B: 'Hz',
2318
+ mB: 'mHz'
2319
+ };
2320
+ var bitRateSymbols = {
2321
+ kB: 'kbps',
2322
+ B: 'bps',
2323
+ MB: 'mbps'
2324
+ };
2325
+ /**
2326
+ * Parses the technical information of a AudioComponentType.
2327
+ * @param {Object} audioComponentType - A AudioComponentType from VidiCore.
2328
+ * @returns {Object} Parsed component object.
2329
+ */
2330
+
2331
+ var parseAudioComponentType = function parseAudioComponentType() {
2332
+ var audioComponentType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2333
+ var _audioComponentType$t = audioComponentType.timeBase,
2334
+ timeBase = _audioComponentType$t === void 0 ? {} : _audioComponentType$t,
2335
+ audioChannels = audioComponentType.channelCount,
2336
+ audioCodec = audioComponentType.codec,
2337
+ _audioComponentType$m = audioComponentType.mediaInfo,
2338
+ mediaInfo = _audioComponentType$m === void 0 ? {} : _audioComponentType$m,
2339
+ bitrate = audioComponentType.bitrate,
2340
+ _audioComponentType$m2 = audioComponentType.metadata,
2341
+ metadata = _audioComponentType$m2 === void 0 ? [] : _audioComponentType$m2;
2342
+ var audioMediaInfo = parseBaseMediaInfoType(mediaInfo);
2343
+ var audioMetadata = parseKeyValuePairType(metadata);
2344
+ var audioFormat = audioMediaInfo.Format,
2345
+ audioBitDepth = audioMediaInfo.Resolution,
2346
+ audioBitRateMode = audioMediaInfo.Bit_rate_mode;
2347
+ var audioSamplerateSamples = timeBase.denominator ? timeBase.denominator / timeBase.numerator : undefined;
2348
+ var audioSamplerate = audioSamplerateSamples ? parseFileSize__default["default"](audioSamplerateSamples, {
2349
+ base: 10,
2350
+ round: 1,
2351
+ symbols: sampleRateSymbols
2352
+ }) : undefined;
2353
+ var audioBitrate = bitrate ? parseFileSize__default["default"](bitrate, {
2354
+ base: 10,
2355
+ round: 2,
2356
+ symbols: bitRateSymbols
2357
+ }) : undefined;
2358
+ return {
2359
+ audioFormat: audioFormat,
2360
+ audioCodec: audioCodec,
2361
+ audioSamplerate: audioSamplerate,
2362
+ audioSamplerateSamples: audioSamplerateSamples,
2363
+ audioBitDepth: audioBitDepth,
2364
+ audioBitrate: audioBitrate,
2365
+ audioBitRateMode: audioBitRateMode,
2366
+ audioChannels: audioChannels,
2367
+ audioMediaInfo: audioMediaInfo,
2368
+ audioMetadata: audioMetadata
2369
+ };
1748
2370
  };
1749
2371
 
1750
2372
  var parseFileType = function parseFileType(fileType) {
@@ -1771,16 +2393,60 @@ var parseFileType = function parseFileType(fileType) {
1771
2393
  };
1772
2394
  };
1773
2395
 
1774
- var parseContainerComponent = function parseContainerComponent(containerComponent) {
1775
- var _containerComponent$m = containerComponent.mediaInfo,
1776
- mediaInfo = _containerComponent$m === void 0 ? {} : _containerComponent$m,
1777
- _containerComponent$m2 = containerComponent.metadata,
1778
- metadata = _containerComponent$m2 === void 0 ? [] : _containerComponent$m2,
1779
- fileList = containerComponent.file,
1780
- durationTimeCode = containerComponent.duration,
1781
- startTimestamp = containerComponent.startTimestamp,
1782
- startTimecode = containerComponent.startTimecode,
1783
- timeCodeTimeBase = containerComponent.timeCodeTimeBase;
2396
+ function ownKeys$2(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2397
+
2398
+ function _objectSpread$2(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$2(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$2(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
2399
+ /**
2400
+ * Parses the technical information of a BinaryComponentType.
2401
+ * @param {Object} binaryComponentType - A BinaryComponentType from VidiCore.
2402
+ * @returns {Object} Parsed component object.
2403
+ */
2404
+
2405
+ var parseBinaryComponentType = function parseBinaryComponentType() {
2406
+ var binaryComponentType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2407
+ var fileList = binaryComponentType.file,
2408
+ _binaryComponentType$ = binaryComponentType.mediaInfo,
2409
+ mediaInfo = _binaryComponentType$ === void 0 ? {} : _binaryComponentType$,
2410
+ _binaryComponentType$2 = binaryComponentType.metadata,
2411
+ metadata = _binaryComponentType$2 === void 0 ? [] : _binaryComponentType$2;
2412
+ var binaryMetadata = parseKeyValuePairType(metadata);
2413
+ var binaryMediaInfo = parseBaseMediaInfoType(mediaInfo);
2414
+ var parsedBinaryComponent = {
2415
+ binaryMetadata: binaryMetadata,
2416
+ binaryMediaInfo: binaryMediaInfo
2417
+ };
2418
+
2419
+ if (fileList) {
2420
+ var _fileList = _slicedToArray__default["default"](fileList, 1),
2421
+ fileType = _fileList[0];
2422
+
2423
+ var parsedFileType = parseFileType(fileType);
2424
+ parsedBinaryComponent = _objectSpread$2(_objectSpread$2({}, parsedBinaryComponent), parsedFileType);
2425
+ }
2426
+
2427
+ return parsedBinaryComponent;
2428
+ };
2429
+
2430
+ function ownKeys$1(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2431
+
2432
+ function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$1(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$1(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
2433
+ /**
2434
+ * Parses the technical information of a ContainerComponentType.
2435
+ * @param {Object} containerComponentType - A ContainerComponentType from VidiCore.
2436
+ * @returns {Object} Parsed component object.
2437
+ */
2438
+
2439
+ var parseContainerComponentType = function parseContainerComponentType() {
2440
+ var containerComponentType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2441
+ var _containerComponentTy = containerComponentType.mediaInfo,
2442
+ mediaInfo = _containerComponentTy === void 0 ? {} : _containerComponentTy,
2443
+ _containerComponentTy2 = containerComponentType.metadata,
2444
+ metadata = _containerComponentTy2 === void 0 ? [] : _containerComponentTy2,
2445
+ fileList = containerComponentType.file,
2446
+ durationTimeCode = containerComponentType.duration,
2447
+ startTimestamp = containerComponentType.startTimestamp,
2448
+ startTimecode = containerComponentType.startTimecode,
2449
+ timeCodeTimeBase = containerComponentType.timeCodeTimeBase;
1784
2450
  var containerMetadata = parseKeyValuePairType(metadata);
1785
2451
  var containerMediaInfo = parseBaseMediaInfoType(mediaInfo);
1786
2452
  var containerFormat = containerMediaInfo.Format;
@@ -1789,7 +2455,7 @@ var parseContainerComponent = function parseContainerComponent(containerComponen
1789
2455
  textFormat = containerMediaInfo.Text_Format_List;
1790
2456
 
1791
2457
  if (containerFormat === undefined) {
1792
- var format = containerComponent.format;
2458
+ var format = containerComponentType.format;
1793
2459
  containerFormat = format;
1794
2460
 
1795
2461
  if (format && format.includes(',')) {
@@ -1801,7 +2467,7 @@ var parseContainerComponent = function parseContainerComponent(containerComponen
1801
2467
  }
1802
2468
  }
1803
2469
 
1804
- var parsedContainerComponent = {
2470
+ var parsedContainerComponentType = {
1805
2471
  containerFormat: containerFormat,
1806
2472
  videoFormat: videoFormat,
1807
2473
  audioFormat: audioFormat,
@@ -1811,20 +2477,21 @@ var parseContainerComponent = function parseContainerComponent(containerComponen
1811
2477
  };
1812
2478
 
1813
2479
  if (containerMetadata.componentOriginalFilename) {
1814
- parsedContainerComponent.originalFilename = containerMetadata.componentOriginalFilename;
2480
+ parsedContainerComponentType.originalFilename = containerMetadata.componentOriginalFilename;
1815
2481
  }
1816
2482
 
1817
2483
  if (durationTimeCode !== undefined && durationTimeCode.samples !== 0) {
1818
- parsedContainerComponent.durationTimeCode = formatTimeCodeType(durationTimeCode);
1819
- parsedContainerComponent.duration = parsedContainerComponent.durationTimeCode.toDuration();
2484
+ var timeCode = formatTimeCodeType(durationTimeCode);
2485
+ parsedContainerComponentType.durationTimeCode = timeCode.toObject();
2486
+ parsedContainerComponentType.duration = timeCode.toDuration();
1820
2487
  }
1821
2488
 
1822
2489
  if (startTimestamp) {
1823
- parsedContainerComponent.startTimestamp = formatTimeCodeType(startTimestamp);
2490
+ parsedContainerComponentType.startTimestamp = formatTimeCodeType(startTimestamp).toObject();
1824
2491
  }
1825
2492
 
1826
2493
  if (startTimecode !== undefined && timeCodeTimeBase) {
1827
- parsedContainerComponent.startTimecode = formatTimeCodeType({
2494
+ parsedContainerComponentType.startTimecode = formatTimeCodeType({
1828
2495
  samples: startTimecode,
1829
2496
  timeBase: timeCodeTimeBase
1830
2497
  });
@@ -1835,22 +2502,29 @@ var parseContainerComponent = function parseContainerComponent(containerComponen
1835
2502
  fileType = _fileList[0];
1836
2503
 
1837
2504
  var parsedFileType = parseFileType(fileType);
1838
- parsedContainerComponent = _objectSpread(_objectSpread({}, parsedContainerComponent), parsedFileType);
2505
+ parsedContainerComponentType = _objectSpread$1(_objectSpread$1({}, parsedContainerComponentType), parsedFileType);
1839
2506
  }
1840
2507
 
1841
- return parsedContainerComponent;
2508
+ return parsedContainerComponentType;
1842
2509
  };
1843
2510
 
1844
- var parseVideoComponent = function parseVideoComponent(videoComponent) {
1845
- var videoCodec = videoComponent.codec,
1846
- bitrate = videoComponent.bitrate,
1847
- fieldOrder = videoComponent.fieldOrder,
1848
- _videoComponent$resol = videoComponent.resolution,
1849
- resolution = _videoComponent$resol === void 0 ? {} : _videoComponent$resol,
1850
- _videoComponent$media = videoComponent.mediaInfo,
1851
- mediaInfo = _videoComponent$media === void 0 ? {} : _videoComponent$media,
1852
- _videoComponent$metad = videoComponent.metadata,
1853
- metadata = _videoComponent$metad === void 0 ? [] : _videoComponent$metad;
2511
+ /**
2512
+ * Parses the technical information of a VideoComponentType.
2513
+ * @param {Object} videoComponentType - A VideoComponentType from VidiCore.
2514
+ * @returns {Object} Parsed component object.
2515
+ */
2516
+
2517
+ var parseVideoComponentType = function parseVideoComponentType() {
2518
+ var videoComponentType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2519
+ var videoCodec = videoComponentType.codec,
2520
+ bitrate = videoComponentType.bitrate,
2521
+ fieldOrder = videoComponentType.fieldOrder,
2522
+ _videoComponentType$r = videoComponentType.resolution,
2523
+ resolution = _videoComponentType$r === void 0 ? {} : _videoComponentType$r,
2524
+ _videoComponentType$m = videoComponentType.mediaInfo,
2525
+ mediaInfo = _videoComponentType$m === void 0 ? {} : _videoComponentType$m,
2526
+ _videoComponentType$m2 = videoComponentType.metadata,
2527
+ metadata = _videoComponentType$m2 === void 0 ? [] : _videoComponentType$m2;
1854
2528
  var videoMediaInfo = parseBaseMediaInfoType(mediaInfo);
1855
2529
  var videoMetadata = parseKeyValuePairType(metadata);
1856
2530
  var videoFormat = videoMediaInfo.Format,
@@ -1859,8 +2533,8 @@ var parseVideoComponent = function parseVideoComponent(videoComponent) {
1859
2533
  colorPrimaries = videoMediaInfo['Color primaries'],
1860
2534
  chromaSubsampling = videoMediaInfo.Colorimetry;
1861
2535
  var timeBase;
1862
- var averageFrameRate = videoComponent.averageFrameRate,
1863
- realBaseFrameRate = videoComponent.realBaseFrameRate;
2536
+ var averageFrameRate = videoComponentType.averageFrameRate,
2537
+ realBaseFrameRate = videoComponentType.realBaseFrameRate;
1864
2538
 
1865
2539
  if (realBaseFrameRate !== undefined) {
1866
2540
  timeBase = {
@@ -1879,7 +2553,7 @@ var parseVideoComponent = function parseVideoComponent(videoComponent) {
1879
2553
  var samples = videoMediaInfo['Frame count'];
1880
2554
 
1881
2555
  if (samples === undefined) {
1882
- var numberOfPackets = videoComponent.numberOfPackets;
2556
+ var numberOfPackets = videoComponentType.numberOfPackets;
1883
2557
  if (numberOfPackets !== undefined) samples = numberOfPackets;
1884
2558
  }
1885
2559
 
@@ -1892,8 +2566,10 @@ var parseVideoComponent = function parseVideoComponent(videoComponent) {
1892
2566
  samples: samples,
1893
2567
  timeBase: timeBase
1894
2568
  });
1895
- frameRate = timeCode.timeBase.toRate(true);
1896
- smpte = timeCode.toSmpte(true);
2569
+ frameRate = timeCode.timeBase.toRate({
2570
+ constant: true
2571
+ });
2572
+ smpte = timeCode.toSmpte();
1897
2573
  }
1898
2574
 
1899
2575
  var height = resolution.height,
@@ -1924,69 +2600,21 @@ var parseVideoComponent = function parseVideoComponent(videoComponent) {
1924
2600
  };
1925
2601
  };
1926
2602
 
1927
- var parseAudioComponent = function parseAudioComponent(audioComponent) {
1928
- var _audioComponent$timeB = audioComponent.timeBase,
1929
- timeBase = _audioComponent$timeB === void 0 ? {} : _audioComponent$timeB,
1930
- audioChannels = audioComponent.channelCount,
1931
- audioCodec = audioComponent.codec,
1932
- _audioComponent$media = audioComponent.mediaInfo,
1933
- mediaInfo = _audioComponent$media === void 0 ? {} : _audioComponent$media,
1934
- bitrate = audioComponent.bitrate,
1935
- _audioComponent$metad = audioComponent.metadata,
1936
- metadata = _audioComponent$metad === void 0 ? [] : _audioComponent$metad;
1937
- var audioMediaInfo = parseBaseMediaInfoType(mediaInfo);
1938
- var audioMetadata = parseKeyValuePairType(metadata);
1939
- var audioFormat = audioMediaInfo.Format,
1940
- audioBitDepth = audioMediaInfo.Resolution,
1941
- audioBitRateMode = audioMediaInfo.Bit_rate_mode;
1942
- var audioSamplerateSamples = timeBase.denominator ? timeBase.denominator / timeBase.numerator : undefined;
1943
- var audioSamplerate = audioSamplerateSamples ? parseFileSize__default["default"](audioSamplerateSamples, {
1944
- base: 10,
1945
- round: 1,
1946
- symbols: sampleRateSymbols
1947
- }) : undefined;
1948
- var audioBitrate = bitrate ? parseFileSize__default["default"](bitrate, {
1949
- base: 10,
1950
- round: 2,
1951
- symbols: bitRateSymbols
1952
- }) : undefined;
1953
- return {
1954
- audioFormat: audioFormat,
1955
- audioCodec: audioCodec,
1956
- audioSamplerate: audioSamplerate,
1957
- audioSamplerateSamples: audioSamplerateSamples,
1958
- audioBitDepth: audioBitDepth,
1959
- audioBitrate: audioBitrate,
1960
- audioBitRateMode: audioBitRateMode,
1961
- audioChannels: audioChannels,
1962
- audioMediaInfo: audioMediaInfo,
1963
- audioMetadata: audioMetadata
1964
- };
1965
- };
1966
-
1967
- var parseBinaryComponent = function parseBinaryComponent(binaryComponent) {
1968
- var fileList = binaryComponent.file,
1969
- _binaryComponent$medi = binaryComponent.mediaInfo,
1970
- mediaInfo = _binaryComponent$medi === void 0 ? {} : _binaryComponent$medi,
1971
- _binaryComponent$meta = binaryComponent.metadata,
1972
- metadata = _binaryComponent$meta === void 0 ? [] : _binaryComponent$meta;
1973
- var binaryMetadata = parseKeyValuePairType(metadata);
1974
- var binaryMediaInfo = parseBaseMediaInfoType(mediaInfo);
1975
- var parsedBinaryComponent = {
1976
- binaryMetadata: binaryMetadata,
1977
- binaryMediaInfo: binaryMediaInfo
1978
- };
1979
-
1980
- if (fileList) {
1981
- var _fileList2 = _slicedToArray__default["default"](fileList, 1),
1982
- fileType = _fileList2[0];
1983
-
1984
- var parsedFileType = parseFileType(fileType);
1985
- parsedBinaryComponent = _objectSpread(_objectSpread({}, parsedBinaryComponent), parsedFileType);
1986
- }
2603
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
1987
2604
 
1988
- return parsedBinaryComponent;
1989
- };
2605
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
2606
+ /**
2607
+ * Parses the technical information of a ShapeType and its various components.
2608
+ *
2609
+ * Will only parse the first videoComponent, audioComponent, binaryComponent in the corresponding array.
2610
+ * To parse a selected component see:
2611
+ * - {@link parseContainerComponentType}
2612
+ * - {@link parseVideoComponentType}
2613
+ * - {@link parseAudioComponentType}
2614
+ * - {@link parseBinaryComponentType}
2615
+ * @param {Object} shapeType - A ShapeType from VidiCore.
2616
+ * @returns {Object} Parsed shape object.
2617
+ */
1990
2618
 
1991
2619
  var parseShapeType = function parseShapeType() {
1992
2620
  var shapeType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
@@ -2009,7 +2637,7 @@ var parseShapeType = function parseShapeType() {
2009
2637
  parsedShape.mimeType = _mimeTypeList[0];
2010
2638
 
2011
2639
  if (containerComponent) {
2012
- var parsedContainerComponent = parseContainerComponent(containerComponent);
2640
+ var parsedContainerComponent = parseContainerComponentType(containerComponent, shapeType);
2013
2641
  parsedShape = _objectSpread(_objectSpread({}, parsedShape), parsedContainerComponent);
2014
2642
  }
2015
2643
 
@@ -2017,7 +2645,7 @@ var parseShapeType = function parseShapeType() {
2017
2645
  var _videoComponentList = _slicedToArray__default["default"](videoComponentList, 1),
2018
2646
  videoComponent = _videoComponentList[0];
2019
2647
 
2020
- var parsedVideoComponent = parseVideoComponent(videoComponent);
2648
+ var parsedVideoComponent = parseVideoComponentType(videoComponent, shapeType);
2021
2649
  parsedShape = _objectSpread(_objectSpread({}, parsedShape), parsedVideoComponent);
2022
2650
  }
2023
2651
 
@@ -2025,7 +2653,7 @@ var parseShapeType = function parseShapeType() {
2025
2653
  var _audioComponentList = _slicedToArray__default["default"](audioComponentList, 1),
2026
2654
  audioComponent = _audioComponentList[0];
2027
2655
 
2028
- var parsedAudioComponent = parseAudioComponent(audioComponent);
2656
+ var parsedAudioComponent = parseAudioComponentType(audioComponent, shapeType);
2029
2657
  parsedShape = _objectSpread(_objectSpread({}, parsedShape), parsedAudioComponent);
2030
2658
  }
2031
2659
 
@@ -2033,13 +2661,47 @@ var parseShapeType = function parseShapeType() {
2033
2661
  var _binaryComponentList = _slicedToArray__default["default"](binaryComponentList, 1),
2034
2662
  binaryComponent = _binaryComponentList[0];
2035
2663
 
2036
- var parsedBinaryComponent = parseBinaryComponent(binaryComponent);
2664
+ var parsedBinaryComponent = parseBinaryComponentType(binaryComponent, shapeType);
2037
2665
  parsedShape = _objectSpread(_objectSpread({}, parsedShape), parsedBinaryComponent);
2038
2666
  }
2039
2667
 
2040
2668
  return parsedShape;
2041
2669
  };
2042
2670
 
2671
+ /* eslint-disable no-console */
2672
+ /**
2673
+ * @deprecated please use {@link parseAudioComponentType}
2674
+ */
2675
+
2676
+ var parseAudioComponent = function parseAudioComponent(audioComponent) {
2677
+ console.warn('parseAudioComponent is deprecated, please use parseAudioComponentType');
2678
+ return parseAudioComponentType(audioComponent);
2679
+ };
2680
+ /**
2681
+ * @deprecated please use {@link parseBinaryComponentType}
2682
+ */
2683
+
2684
+ var parseBinaryComponent = function parseBinaryComponent(binaryComponent) {
2685
+ console.warn('parseBinaryComponent is deprecated, please use parseBinaryComponentType');
2686
+ return parseBinaryComponentType(binaryComponent);
2687
+ };
2688
+ /**
2689
+ * @deprecated please use {@link parseContainerComponentType}
2690
+ */
2691
+
2692
+ var parseContainerComponent = function parseContainerComponent(containerComponent) {
2693
+ console.warn('parseContainerComponent is deprecated, please use parseContainerComponentType');
2694
+ return parseContainerComponentType(containerComponent);
2695
+ };
2696
+ /**
2697
+ * @deprecated please use {@link parseVideoComponentType}
2698
+ */
2699
+
2700
+ var parseVideoComponent = function parseVideoComponent(videoComponent) {
2701
+ console.warn('parseVideoComponent is deprecated, please use parseVideoComponentType');
2702
+ return parseVideoComponentType(videoComponent);
2703
+ };
2704
+
2043
2705
  var IMAGE_MIME_TYPES = ['image/apng', 'image/bmp', 'image/gif', 'image/jpeg', 'image/x-icon', 'image/png', 'image/svg+xml'];
2044
2706
  var VIDEO_MIME_TYPES = ['video/mp4'];
2045
2707
  var AUDIO_MIME_TYPES = ['audio/mp4', 'audio/mpeg', 'audio/x-aac', 'audio/aac', 'audio/x-wav', 'audio/wav', 'audio/accp', 'audio/ogg', 'audio/webm', 'audio/x-flac'];
@@ -2274,7 +2936,9 @@ var parseMediaConvertPreset = function parseMediaConvertPreset(transcodePresetTy
2274
2936
  numerator: numerator
2275
2937
  });
2276
2938
  output.timeBase = timeBase;
2277
- output.frameRate = timeBase.toRate(true);
2939
+ output.frameRate = timeBase.toRate({
2940
+ constant: true
2941
+ });
2278
2942
  }
2279
2943
  }
2280
2944
 
@@ -2319,7 +2983,9 @@ var parseTranscodePreset = function parseTranscodePreset(transcodePresetType) {
2319
2983
  if (video.framerate) {
2320
2984
  var timeBase = formatTimeBaseType(video.framerate);
2321
2985
  output.timeBase = timeBase;
2322
- output.frameRate = timeBase.toRate(true);
2986
+ output.frameRate = timeBase.toRate({
2987
+ constant: true
2988
+ });
2323
2989
  }
2324
2990
 
2325
2991
  if (video.scaling) {
@@ -2372,24 +3038,25 @@ exports.TimeBase = TimeBase;
2372
3038
  exports.TimeCode = TimeCode;
2373
3039
  exports.createFacetType = createFacetType;
2374
3040
  exports.createMetadataType = createMetadataType;
3041
+ exports.createTimeBase = createTimeBase;
3042
+ exports.createTimeCode = createTimeCode;
2375
3043
  exports.filterShapeSource = filterShapeSource;
2376
3044
  exports.findNearestThumbnail = findNearestThumbnail;
2377
- exports.formatSeconds = formatSeconds;
2378
- exports.formatSecondsPrecise = formatSecondsPrecise;
2379
- exports.formatSmpte = formatSmpte;
2380
- exports.formatTimeBase = formatTimeBase;
2381
3045
  exports.formatTimeBaseText = formatTimeBaseText;
2382
3046
  exports.formatTimeBaseType = formatTimeBaseType;
3047
+ exports.formatTimeCodeSeconds = formatTimeCodeSeconds;
3048
+ exports.formatTimeCodeSmpte = formatTimeCodeSmpte;
2383
3049
  exports.formatTimeCodeText = formatTimeCodeText;
2384
3050
  exports.formatTimeCodeType = formatTimeCodeType;
2385
3051
  exports.getDocumentType = getDocumentType;
2386
3052
  exports.getShapeMediaType = getShapeMediaType;
2387
3053
  exports.metadataTypeToWebVtt = metadataTypeToWebVtt;
2388
- exports.parseAspectRatio = parseAspectRatio;
2389
3054
  exports.parseAudioComponent = parseAudioComponent;
2390
- exports.parseBaseMediaInfoType = parseBaseMediaInfoType;
3055
+ exports.parseAudioComponentType = parseAudioComponentType;
2391
3056
  exports.parseBinaryComponent = parseBinaryComponent;
3057
+ exports.parseBinaryComponentType = parseBinaryComponentType;
2392
3058
  exports.parseContainerComponent = parseContainerComponent;
3059
+ exports.parseContainerComponentType = parseContainerComponentType;
2393
3060
  exports.parseFacetType = parseFacetType;
2394
3061
  exports.parseFileType = parseFileType;
2395
3062
  exports.parseHighlightTimespan = parseHighlightTimespan;
@@ -2404,5 +3071,6 @@ exports.parseTimespan = parseTimespan;
2404
3071
  exports.parseTimespanList = parseTimespanList;
2405
3072
  exports.parseTranscodePreset = parseTranscodePreset;
2406
3073
  exports.parseVideoComponent = parseVideoComponent;
3074
+ exports.parseVideoComponentType = parseVideoComponentType;
2407
3075
  exports.roles = roles;
2408
3076
  //# sourceMappingURL=index.js.map