@vidispine/vdt-js 22.4.0-pre.5 → 22.4.0-pre.7

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
@@ -2417,11 +2417,6 @@ var parseNowDate = function parseNowDate() {
2417
2417
  var nowDiff = new Date();
2418
2418
 
2419
2419
  switch (unit) {
2420
- case 'TODAY':
2421
- if (sign === '+') nowDiff.setHours(23, 59, 59, 999);
2422
- if (sign === '-') nowDiff.setHours(0, 0, 0, 0);
2423
- break;
2424
-
2425
2420
  case 'HOUR':
2426
2421
  case 'HOURS':
2427
2422
  if (sign === '+') nowDiff.setHours(nowDiff.getHours() + number);
@@ -2841,6 +2836,7 @@ var parseShapeType = function parseShapeType() {
2841
2836
  return parsedShape;
2842
2837
  };
2843
2838
 
2839
+ // eslint-disable-next-line import/no-cycle
2844
2840
  var DOCUMENT_TYPES = {
2845
2841
  PDF: 'PDF',
2846
2842
  TEXT: 'TEXT',
@@ -2852,15 +2848,16 @@ var DOCUMENT_TYPES = {
2852
2848
  /**
2853
2849
  * Return a const for the document type of a shape (looks at mimeType)
2854
2850
  *
2855
- * @param shape
2851
+ * @param shape A VidiCore shape
2856
2852
  * @returns The document type for a shape
2857
2853
  *
2858
2854
  * @category Shape
2859
2855
  */
2860
- var getDocumentType = function getDocumentType(shape) {
2861
- var _ref = shape || {},
2862
- mimeTypeArrayOrString = _ref.mimeType;
2863
-
2856
+ var getShapeDocumentType = function getShapeDocumentType() {
2857
+ var shape = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2858
+ // shapeType.mimeType is always a string array,
2859
+ // but accepts passing in { mimeType: string } for backwards compatibility
2860
+ var mimeTypeArrayOrString = shape.mimeType;
2864
2861
  var mimeType = Array.isArray(mimeTypeArrayOrString) ? mimeTypeArrayOrString[0] : mimeTypeArrayOrString;
2865
2862
  if (!mimeType) return undefined;
2866
2863
  if (mimeType.endsWith('/pdf')) return DOCUMENT_TYPES.PDF;
@@ -2887,8 +2884,8 @@ var H264_CODEC = 'h264'; // Sort by tags in the order of previewShapeOrder, seco
2887
2884
  var PREVIEW_SHAPE_ORDER = ['__mp4', '__mp3_160k', '__png', '__jpeg', '__gif', 'original'].reverse();
2888
2885
 
2889
2886
  var defaultSortPriority = function defaultSortPriority(_ref, _ref2) {
2890
- var firstEl = _ref.shape.tag;
2891
- var secondEl = _ref2.shape.tag;
2887
+ var firstEl = _ref.parsedShape.tag;
2888
+ var secondEl = _ref2.parsedShape.tag;
2892
2889
 
2893
2890
  if (PREVIEW_SHAPE_ORDER.includes(firstEl) || PREVIEW_SHAPE_ORDER.includes(secondEl)) {
2894
2891
  return PREVIEW_SHAPE_ORDER.indexOf(secondEl) - PREVIEW_SHAPE_ORDER.indexOf(firstEl);
@@ -2911,29 +2908,31 @@ var filterShapeSource = function filterShapeSource(itemType, options) {
2911
2908
  var _ref3 = options || {},
2912
2909
  _ref3$allowedMimeType = _ref3.allowedMimeTypes,
2913
2910
  allowedMimeTypes = _ref3$allowedMimeType === void 0 ? DEFAULT_ALLOWED_MIME_TYPES : _ref3$allowedMimeType,
2914
- _ref3$sortPriority = _ref3.sortPriority,
2915
- sortPriority = _ref3$sortPriority === void 0 ? defaultSortPriority : _ref3$sortPriority,
2916
2911
  _ref3$allowedMethods = _ref3.allowedMethods,
2917
2912
  allowedMethods = _ref3$allowedMethods === void 0 ? DEFAULT_ALLOWED_METHODS : _ref3$allowedMethods,
2913
+ _ref3$sortPriority = _ref3.sortPriority,
2914
+ sortPriority = _ref3$sortPriority === void 0 ? defaultSortPriority : _ref3$sortPriority,
2918
2915
  _ref3$sourceKey = _ref3.sourceKey,
2919
2916
  sourceKey = _ref3$sourceKey === void 0 ? 'src' : _ref3$sourceKey,
2920
2917
  _ref3$mimeTypeKey = _ref3.mimeTypeKey,
2921
2918
  mimeTypeKey = _ref3$mimeTypeKey === void 0 ? 'type' : _ref3$mimeTypeKey,
2922
2919
  _ref3$shapeKey = _ref3.shapeKey,
2923
- shapeKey = _ref3$shapeKey === void 0 ? 'shape' : _ref3$shapeKey;
2920
+ shapeKey = _ref3$shapeKey === void 0 ? 'shape' : _ref3$shapeKey,
2921
+ _ref3$parsedShapeKey = _ref3.parsedShapeKey,
2922
+ parsedShapeKey = _ref3$parsedShapeKey === void 0 ? 'parsedShapeKey' : _ref3$parsedShapeKey;
2924
2923
 
2925
2924
  var _ref4 = itemType || {},
2926
2925
  _ref4$shape = _ref4.shape,
2927
2926
  shapeList = _ref4$shape === void 0 ? [] : _ref4$shape;
2928
2927
 
2929
- var parsedShapeList = shapeList.reduce(function (acc, shapeType) {
2928
+ var filteredShapeList = shapeList.reduce(function (acc, shapeType) {
2930
2929
  var type;
2931
2930
  var src;
2932
- var shape = parseShapeType(shapeType);
2933
- var uri = shape.uri,
2934
- mimeType = shape.mimeType,
2935
- containerFormat = shape.containerFormat,
2936
- videoCodec = shape.videoCodec;
2931
+ var parsedShape = parseShapeType(shapeType);
2932
+ var uri = parsedShape.uri,
2933
+ mimeType = parsedShape.mimeType,
2934
+ containerFormat = parsedShape.containerFormat,
2935
+ videoCodec = parsedShape.videoCodec;
2937
2936
 
2938
2937
  if (mimeType) {
2939
2938
  type = mimeType;
@@ -2955,13 +2954,13 @@ var filterShapeSource = function filterShapeSource(itemType, options) {
2955
2954
  if (src && allowedMimeTypes.includes(type)) {
2956
2955
  var _acc$push;
2957
2956
 
2958
- acc.push((_acc$push = {}, _defineProperty__default["default"](_acc$push, sourceKey, src), _defineProperty__default["default"](_acc$push, mimeTypeKey, type), _defineProperty__default["default"](_acc$push, shapeKey, shape), _acc$push));
2957
+ acc.push((_acc$push = {}, _defineProperty__default["default"](_acc$push, sourceKey, src), _defineProperty__default["default"](_acc$push, mimeTypeKey, type), _defineProperty__default["default"](_acc$push, shapeKey, shapeType), _defineProperty__default["default"](_acc$push, parsedShapeKey, parsedShape), _acc$push));
2959
2958
  }
2960
2959
 
2961
2960
  return acc;
2962
2961
  }, []);
2963
- if (typeof sortPriority === 'function') parsedShapeList.sort(defaultSortPriority);
2964
- return parsedShapeList;
2962
+ if (typeof sortPriority === 'function') filteredShapeList.sort(defaultSortPriority);
2963
+ return filteredShapeList;
2965
2964
  };
2966
2965
 
2967
2966
  var SHAPE_MEDIA_TYPES = {
@@ -2971,23 +2970,20 @@ var SHAPE_MEDIA_TYPES = {
2971
2970
  DOCUMENT: 'DOCUMENT',
2972
2971
  BINARY: 'BINARY'
2973
2972
  };
2974
- // TODO: For consistency, replace input with an actual ShapeType not a parsed shape
2975
- // (parse it internally if needed)
2976
2973
 
2977
2974
  /**
2978
2975
  * Returns a const for which media type a shape has
2979
2976
  *
2980
- * @param parsedShape
2977
+ * @param shape
2981
2978
  * @returns
2982
2979
  *
2983
2980
  * @category Shape
2984
2981
  */
2985
- var getShapeMediaType = function getShapeMediaType(parsedShape) {
2986
- var _ref = parsedShape || {},
2987
- mimeType = _ref.mimeType,
2988
- videoCodec = _ref.videoCodec,
2989
- audioCodec = _ref.audioCodec;
2990
-
2982
+ var getShapeMediaType = function getShapeMediaType(shape) {
2983
+ var parsedShape = parseShapeType(shape);
2984
+ var mimeType = parsedShape.mimeType,
2985
+ videoCodec = parsedShape.videoCodec,
2986
+ audioCodec = parsedShape.audioCodec;
2991
2987
  if (!mimeType) return undefined;
2992
2988
 
2993
2989
  if (mimeType.startsWith('audio/')) {
@@ -3225,7 +3221,7 @@ exports.formatTimeCodeSeconds = formatTimeCodeSeconds;
3225
3221
  exports.formatTimeCodeSmpte = formatTimeCodeSmpte;
3226
3222
  exports.formatTimeCodeText = formatTimeCodeText;
3227
3223
  exports.formatTimeCodeType = formatTimeCodeType;
3228
- exports.getDocumentType = getDocumentType;
3224
+ exports.getShapeDocumentType = getShapeDocumentType;
3229
3225
  exports.getShapeMediaType = getShapeMediaType;
3230
3226
  exports.metadataTypeToWebVtt = metadataTypeToWebVtt;
3231
3227
  exports.parseAudioComponent = parseAudioComponent;