@vidispine/vdt-js 23.1.0 → 23.2.0-pre.2
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.d.ts +1262 -1105
- package/dist/index.js +1602 -676
- package/dist/index.umd.cjs +5 -0
- package/package.json +28 -30
- package/dist/index.es.js +0 -719
- package/dist/index.es.js.map +0 -1
- package/dist/index.js.map +0 -1
package/dist/index.es.js
DELETED
|
@@ -1,719 +0,0 @@
|
|
|
1
|
-
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
2
|
-
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
3
|
-
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
4
|
-
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
5
|
-
import _typeof from '@babel/runtime/helpers/typeof';
|
|
6
|
-
import _classCallCheck from '@babel/runtime/helpers/classCallCheck';
|
|
7
|
-
import _createClass from '@babel/runtime/helpers/createClass';
|
|
8
|
-
import { filesize } from 'filesize';
|
|
9
|
-
|
|
10
|
-
var gcd=function gcd(a,b){return b?gcd(b,a%b):a;};var parseAspectRatio=function parseAspectRatio(aspectRatio){var _ref=aspectRatio||{},width=_ref.width,height=_ref.height;if(width===undefined||height===undefined){return undefined;}var denominator=gcd(width,height);var widthRatio=width/denominator;var heightRatio=height/denominator;if(widthRatio>21){heightRatio=1;widthRatio=(width/height).toFixed(2);}return [widthRatio,heightRatio].join(':');};
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
*
|
|
14
|
-
* @param keyValuePairTypes
|
|
15
|
-
* @returns
|
|
16
|
-
*
|
|
17
|
-
* @category Other
|
|
18
|
-
*/var parseKeyValuePairTypes=function parseKeyValuePairTypes(keyValuePairTypes){return Object.fromEntries(keyValuePairTypes.map(function(_ref){var key=_ref.key,value=_ref.value;return [key,value];}));};
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Const object with VidiCore role names
|
|
22
|
-
*
|
|
23
|
-
* @category Auth
|
|
24
|
-
*/var ROLE_NAMES={ACCESSCONTROL_READ:'_accesscontrol_read',ACCESSCONTROL_WRITE:'_accesscontrol_write',ADMINISTRATOR:'_administrator',AUTO_PROJECTION_READ:'_auto_projection_read',AUTO_PROJECTION_WRITE:'_auto_projection_write',COLLECTION_NOTIFICATION_READ:'_collection_notification_read',COLLECTION_NOTIFICATION_WRITE:'_collection_notification_write',COLLECTION_READ:'_collection_read',COLLECTION_WRITE:'_collection_write',CONFIGURATION_READ:'_configuration_read',DELETION_LOCK_NOTIFICATION_READ:'_deletion_lock_notification_read',DELETION_LOCK_NOTIFICATION_WRITE:'_deletion_lock_notification_write',DELETION_LOCK_READ:'_deletion_lock_read',DELETION_LOCK_WRITE:'_deletion_lock_write',DOCUMENT_NOTIFICATION_READ:'_document_notification_read',DOCUMENT_NOTIFICATION_WRITE:'_document_notification_write',DOCUMENT_READ:'_document_read',DOCUMENT_WRITE:'_document_write',ERROR_READ:'_error_read',ERROR_WRITE:'_error_write',EXPORT:'_export',EXPORT_TEMPLATE_READ:'_export_template_read',EXPORT_TEMPLATE_WRITE:'_export_template_write',EXTERNAL_ID_READ:'_external_id_read',EXTERNAL_ID_WRITE:'_external_id_write',FILE_NOTIFICATION_READ:'_file_notification_read',FILE_NOTIFICATION_WRITE:'_file_notification_write',FILE_READ:'_file_read',FILE_WRITE:'_file_write',GROUP_READ:'_group_read',GROUP_WRITE:'_group_write',IMPORT_WRITE:'_import',ITEM_ID_READ:'_item_id_read',ITEM_ID_WRITE:'_item_id_write',ITEM_NOTIFICATION_READ:'_item_notification_read',ITEM_NOTIFICATION_WRITE:'_item_notification_write',ITEM_WRITE:'_item_write',ITEM_SEARCH:'_item_search',ITEM_SHAPE_READ:'_item_shape_read',ITEM_SHAPE_WRITE:'_item_shape_write',ITEM_TIMELINE_READ:'_item_timeline_read',ITEM_TIMELINE_WRITE:'_item_timeline_write',ITEM_URI:'_item_uri',JOB_NOTIFICATION_READ:'_job_notification_read',JOB_NOTIFICATION_WRITE:'_job_notification_write',JOB_READ:'_job_read',JOB_WRITE:'_job_write',LIBRARY_READ:'_library_read',LIBRARY_WRITE:'_library_write',LOCK_READ:'_lock_read',LOCK_WRITE:'_lock_write',LOG_READ:'_log_read',METADATA_DATASET_READ:'_metadata_dataset_read',METADATA_DATASET_WRITE:'_metadata_dataset_write',METADATA_FIELD_GROUP_READ:'_metadata_field_group_read',METADATA_FIELD_GROUP_WRITE:'_metadata_field_group_write',METADATA_FIELD_READ:'_metadata_field_read',METADATA_FIELD_WRITE:'_metadata_field_write',METADATA_GLOBAL_READ:'_metadata_global_read',METADATA_GLOBAL_WRITE:'_metadata_global_write',METADATA_LOCK_READ:'_metadata_lock_read',METADATA_LOCK_WRITE:'_metadata_lock_write',METADATA_READ:'_metadata_read',METADATA_SCHEMA_READ:'_metadata_schema_read',METADATA_SCHEMA_WRITE:'_metadata_schema_write',METADATA_WRITE:'_metadata_write',OTIF_ANALYZE:'_otif_analyze',OTIF_READ:'_otif_read',OTIF_WRITE:'_otif_write',PLACEHOLDER_NOTIFICATION_READ:'_placeholder_notification_read',PLACEHOLDER_NOTIFICATION_WRITE:'_placeholder_notification_write',PROJECTION_READ:'_projection_read',PROJECTION_WRITE:'_projection_write',QUOTA_NOTIFICATION_READ:'_quota_notification_read',QUOTA_NOTIFICATION_WRITE:'_quota_notification_write',QUOTA_READ:'_quota_read',QUOTA_WRITE:'_quota_write',RELATION_READ:'_relation_read',RELATION_WRITE:'_relation_write',RESOURCE_READ:'_resource_read',RESOURCE_WRITE:'_resource_write',RUN_AS:'_run_as',SEARCH:'_search',SEQUENCE_READ:'_sequence_read',SEQUENCE_WRITE:'_sequence_write',SHAPE_TAG_READ:'_shape_tag_read',SHAPE_TAG_WRITE:'_shape_tag_write',SITE_MANAGER:'_site_manager',SITE_RULE_READ:'_site_rule_read',SITE_RULE_WRITE:'_site_rule_write',STORAGE_GROUP_READ:'_storage_group_read',STORAGE_GROUP_WRITE:'_storage_group_write',STORAGE_NOTIFICATION_READ:'_storage_notification_read',STORAGE_NOTIFICATION_WRITE:'_storage_notification_write',STORAGE_READ:'_storage_read',STORAGE_RULE_READ:'_storage_rule_read',STORAGE_RULE_WRITE:'_storage_rule_write',STORAGE_WRITE:'_storage_write',SUPER_ACCESS_USER:'_super_access_user',TASKDEFINITION_READ:'_taskdefinition_read',TASKDEFINITION_WRITE:'_taskdefinition_write',THUMBNAIL_READ:'_thumbnail_read',THUMBNAIL_WRITE:'_thumbnail_write',TRANSCODER:'_transcoder',TRANSFER_READ:'_transfer_read',TRANSFER_WRITE:'_transfer_write',USER:'_user',VXA:'_vxa',VXA_READ:'_vxa_read'};
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Array with all available VidiCore system/default field group names
|
|
28
|
-
*
|
|
29
|
-
* @category Metadata
|
|
30
|
-
*/var SYSTEM_FIELDGROUPS=['stl_subtitle','stl_tti','stl_gsi','mrk_marker','pho_validation','pho_resource','pho_error','facedetect_rect','facedetect_face','originalTrackFilename','stl_gsiHeader'];
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Array with all available VidiCore system/default field names (including transient)
|
|
34
|
-
*
|
|
35
|
-
* @category Metadata
|
|
36
|
-
*/var SYSTEM_FIELDS=['title','user','shapeTag','representativeThumbnail','representativeThumbnailNoAuth','representativeItems','itemId','collectionId','mediaType','mimeType','created','startTimeCode','startSeconds','fieldValidationError','schemaValidationError','originalFilename','originalUri','originalAudioCodec','originalVideoCodec','originalHeight','originalWidth','originalFormat','durationSeconds','durationTimeCode','solr-index','__user','__collection','__collection_size','__ancestor_collection','__ancestor_collection_size','__shape','__shape_size','__shape_last_added','__placeholder_shape_size','__version','__version_count','__storage','__storage_size','__shapetag_{tag}_hash_{hash}','__storage_{tag}','__storage_{tag}_size','__storagegroup','__storagegroup_size','__sequence','__sequence_size','__metadata_last_modified','__external_id','__deletion_lock_id','__deletion_lock_expiry','__child_collection','__child_collection_size','__parent_collection','__parent_collection_size','__items_size','stl_text','stl_justification','stl_xrelative','stl_yrelative','stl_vertical','stl_verticalbase','stl_horizontalbase','stl_sizerelative','stl_color','stl_outline','stl_outlinecolor','stl_outlinesize','stl_font','stl_service','stl_tti','stl_gsi','cct','tcd','tcf','oet','cd','mnc','cpn','dfc','tcp','tcs','tet','tnb','tnd','en','co','tng','rd','mnr','dsc','opt','lc','tpt','tn','slr','tns','rn','pub','dsn','ecd','mrk_zerolength','mrk_text','mrk_color','pho_resource_name','pho_error_level','pho_error_code','pho_error_description','facedetect_rect_width','facedetect_rect_height','facedetect_rect_y','facedetect_rect_x','facedetect_pid','facedetect_rect','trackId','eidr_actor','eidr_alternateId','eidr_countryOfOrigin','eidr_director','eidr_id','eidr_referentType','eidr_releaseDate','eidr_resourceName','eidr_status','eidr_sync','ttml_div','ttml_root','vxa_collection_id','vxaId','vxaLocalPath','tco','cs','ebn','tf','cf','sgn','tci','jc','vp','sn'];
|
|
37
|
-
|
|
38
|
-
var SHARED_ATTRIBUTE_KEYS=['uuid','user','timestamp','change','conflict','mode'];var SHARED_FIELD_AND_GROUP_ATTRIBUTE_KEYS=['name','id','referenced','data','inheritance'];
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Array with all available metadata field value attributes
|
|
42
|
-
*
|
|
43
|
-
* @category Metadata
|
|
44
|
-
*/var FIELD_VALUE_ATTRIBUTE_KEYS=[].concat(_toConsumableArray(SHARED_ATTRIBUTE_KEYS),['value','lang']);
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Array with all available metadata field attributes
|
|
48
|
-
*
|
|
49
|
-
* @category Metadata
|
|
50
|
-
*/var FIELD_ATTRIBUTE_KEYS=[].concat(_toConsumableArray(SHARED_ATTRIBUTE_KEYS),_toConsumableArray(SHARED_FIELD_AND_GROUP_ATTRIBUTE_KEYS),['value','reference','type','track']);
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Array with all available metadata group attributes
|
|
54
|
-
*
|
|
55
|
-
* @category Metadata
|
|
56
|
-
*/var GROUP_ATTRIBUTE_KEYS=[].concat(_toConsumableArray(SHARED_ATTRIBUTE_KEYS),_toConsumableArray(SHARED_FIELD_AND_GROUP_ATTRIBUTE_KEYS),['cycle','field','group']);
|
|
57
|
-
|
|
58
|
-
var _excluded$e=["value"],_excluded2$2=["start","end","base"];function ownKeys$m(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;}function _objectSpread$m(target){for(var i=1;i<arguments.length;i++){var source=null!=arguments[i]?arguments[i]:{};i%2?ownKeys$m(Object(source),!0).forEach(function(key){_defineProperty(target,key,source[key]);}):Object.getOwnPropertyDescriptors?Object.defineProperties(target,Object.getOwnPropertyDescriptors(source)):ownKeys$m(Object(source)).forEach(function(key){Object.defineProperty(target,key,Object.getOwnPropertyDescriptor(source,key));});}return target;}var isValueObject=function isValueObject(o){return Object.prototype.toString.call(o)==='[object Object]'&&o.value!==undefined;};var isFieldType=function isFieldType(v){return ['string','boolean','number'].includes(_typeof(v));};var isFieldObject=function isFieldObject(o){return isValueObject(o)&&((o===null||o===void 0?void 0:o.value)===null||isValueObject(o.value)||isFieldType(o.value));};var isObject=function isObject(o){return Object.prototype.toString.call(o)==='[object Object]';};var isDate=function isDate(o){return Object.prototype.toString.call(o)==='[object Date]';};var isField=function isField(value){if(value===null){return true;}if(Array.isArray(value)){return value.some(isField);}return isFieldType(value)||isFieldObject(value)||isDate(value);};var isGroup=function isGroup(value){var isGroupObject=function isGroupObject(v){return isObject(v)&&v.value===undefined&&!!Object.entries(value);};if(Array.isArray(value)){return value.every(isGroup);}return isGroupObject(value);};var tryPluralize=function tryPluralize(str,arr){return str+(arr.length>1?'s':'');};var ensureKeysAreValid=function ensureKeysAreValid(keysToCheck,keysToMatch){var unsupportedKeys=keysToCheck.filter(function(k){return !keysToMatch.includes(k);});if(unsupportedKeys.length){throw Error("Unsupported ".concat(tryPluralize('key',unsupportedKeys)," (").concat(unsupportedKeys.join(', '),")"));}};var parseValue$1=function parseValue(value){if(Array.isArray(value)){throw Error('Invalid value inside value object, cannot be array');}if([undefined,null].includes(value))return {};if(isDate(value))return {value:value.toISOString()};return {value:value.toString()};};var parseValueObject=function parseValueObject(valueObject){ensureKeysAreValid(Object.keys(valueObject),FIELD_VALUE_ATTRIBUTE_KEYS);if(Object.keys(valueObject).length===0){throw Error('Invalid value object, cannot be empty object');}if(typeof(valueObject===null||valueObject===void 0?void 0:valueObject.value)==='string'){return valueObject;}var parsedValue=parseValue$1(valueObject===null||valueObject===void 0?void 0:valueObject.value);return _objectSpread$m(_objectSpread$m({},valueObject),parsedValue!==undefined?parsedValue:{});};var parseFieldValue=function parseFieldValue(value){if([undefined,null].includes(value))return undefined;if(Array.isArray(value))return value.flatMap(parseFieldValue);if(isValueObject(value))return parseValueObject(value);return parseValue$1(value);};var parseFieldObject=function parseFieldObject(fieldObject){ensureKeysAreValid(Object.keys(fieldObject),FIELD_ATTRIBUTE_KEYS);var parsedFieldValue=parseFieldValue(fieldObject===null||fieldObject===void 0?void 0:fieldObject.value);if(parsedFieldValue===undefined){fieldObject.value;var fieldObjectWithoutValue=_objectWithoutProperties(fieldObject,_excluded$e);return fieldObjectWithoutValue;}return _objectSpread$m(_objectSpread$m({},fieldObject),{},{value:_toConsumableArray(Array.isArray(parsedFieldValue)?parsedFieldValue:[parsedFieldValue])});};var parseField$1=function parseField(field){if(isFieldObject(field)){return parseFieldObject(field);}var parsedFieldValue=parseFieldValue(field);if(parsedFieldValue===undefined){return undefined;}return {value:_toConsumableArray(Array.isArray(parsedFieldValue)?parsedFieldValue:[parsedFieldValue])};};var parseGroupsAndFields=function parseGroupsAndFields(groupOrField){var group=[];var field=[];var groupAttributes={};Object.entries(groupOrField||{}).forEach(function(_ref){var _ref2=_slicedToArray(_ref,2),name=_ref2[0],value=_ref2[1];if(GROUP_ATTRIBUTE_KEYS.includes(name)){groupAttributes=_objectSpread$m(_objectSpread$m({},groupAttributes),{},_defineProperty({},name,value));}else if(isField(value)){try{field.push(_objectSpread$m({name:name},parseField$1(value)));}catch(error){throw Error(error.message+(name?" for field \"".concat(name,"\""):''));}}else if(isGroup(value)){(Array.isArray(value)?value:[value]).forEach(function(childGroup){group.push(_objectSpread$m({name:name},parseGroupsAndFields(childGroup)));});}else {throw Error("Unhandled value for \"".concat(name,"\""));}});return _objectSpread$m(_objectSpread$m(_objectSpread$m({},groupAttributes),group.length>0?{group:group}:{}),field.length>0?{field:field}:{});};var parseTimespan$1=function parseTimespan(timespan){var _timespan$start=timespan.start,start=_timespan$start===void 0?'-INF':_timespan$start,_timespan$end=timespan.end,end=_timespan$end===void 0?'+INF':_timespan$end,_timespan$base=timespan.base,base=_timespan$base===void 0?undefined:_timespan$base,groupsAndFields=_objectWithoutProperties(timespan,_excluded2$2);var _parseGroupsAndFields=parseGroupsAndFields(groupsAndFields),group=_parseGroupsAndFields.group,field=_parseGroupsAndFields.field;return _objectSpread$m(_objectSpread$m(_objectSpread$m({},group?{group:group}:{}),field?{field:field}:{}),{},{start:start.toString(),end:end.toString()},base?{base:base}:{});};/**
|
|
59
|
-
* Create a VidiCore metadata object from a more dense/simplified structure
|
|
60
|
-
*
|
|
61
|
-
* @param input To create VidiCore metadata object of
|
|
62
|
-
* @returns A VidiCore metadata object
|
|
63
|
-
*
|
|
64
|
-
* @category Metadata
|
|
65
|
-
*/var createMetadataType=function createMetadataType(input){return {timespan:(Array.isArray(input)?input:[input||{}]).map(function(t){return parseTimespan$1(t);})};};
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* @private
|
|
69
|
-
*
|
|
70
|
-
* Function to sort timespan lists with
|
|
71
|
-
*
|
|
72
|
-
* TODO:
|
|
73
|
-
* - Take different time bases in account
|
|
74
|
-
* - Also compare end if start is same (lowest end first)
|
|
75
|
-
*
|
|
76
|
-
* @param timespan1 first timespan to compare
|
|
77
|
-
* @param timespan2 second timespan to compare
|
|
78
|
-
* @returns -1 if first is before second, 1 if first is after second, 0 if same start
|
|
79
|
-
*/var sortTimespanList=function sortTimespanList(timespan1,timespan2){var _timespan1$start,_timespan2$start;var _ref=(timespan1===null||timespan1===void 0?void 0:(_timespan1$start=timespan1.start)===null||_timespan1$start===void 0?void 0:_timespan1$start.split('@'))||[],_ref2=_slicedToArray(_ref,1),firstStart=_ref2[0];var _ref3=(timespan2===null||timespan2===void 0?void 0:(_timespan2$start=timespan2.start)===null||_timespan2$start===void 0?void 0:_timespan2$start.split('@'))||[],_ref4=_slicedToArray(_ref3,1),secondStart=_ref4[0];if(Number(firstStart)<Number(secondStart)){return -1;}if(Number(firstStart)>Number(secondStart)){return 1;}return 0;};
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* @private
|
|
83
|
-
*
|
|
84
|
-
* Wrap in array if not already an array, and return empty array if v is undefined
|
|
85
|
-
*
|
|
86
|
-
* @param v value to return as array
|
|
87
|
-
* @returns input value wrapped as array
|
|
88
|
-
*/var asArray=function asArray(v){return Array.isArray(v)?v:v&&[v]||[];};/**
|
|
89
|
-
* @private
|
|
90
|
-
*
|
|
91
|
-
* Wrap in array if not already an array, and return empty array if v is undefined
|
|
92
|
-
*
|
|
93
|
-
* @param v value to return as array
|
|
94
|
-
* @returns input value wrapped as array
|
|
95
|
-
*/var asSingle=function asSingle(v){return Array.isArray(v)?v.pop():v;};/**
|
|
96
|
-
* @private
|
|
97
|
-
* Check if array is string array (+ type guard)
|
|
98
|
-
*
|
|
99
|
-
* @param arr Array to check if string array
|
|
100
|
-
* @returns true if string array
|
|
101
|
-
*/var isStringArray=function isStringArray(arr){return (arr===null||arr===void 0?void 0:arr.every(function(v){return typeof v==='string';}))||false;};
|
|
102
|
-
|
|
103
|
-
var _excluded$d=["value"];function ownKeys$l(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;}function _objectSpread$l(target){for(var i=1;i<arguments.length;i++){var source=null!=arguments[i]?arguments[i]:{};i%2?ownKeys$l(Object(source),!0).forEach(function(key){_defineProperty(target,key,source[key]);}):Object.getOwnPropertyDescriptors?Object.defineProperties(target,Object.getOwnPropertyDescriptors(source)):ownKeys$l(Object(source)).forEach(function(key){Object.defineProperty(target,key,Object.getOwnPropertyDescriptor(source,key));});}return target;}var defaultOptions$f={includeValueAttributes:false};/**
|
|
104
|
-
* @internal
|
|
105
|
-
* Parse the value object inside a field value list
|
|
106
|
-
*
|
|
107
|
-
* @param value The Vidicore metadata value type
|
|
108
|
-
* @param options For how to parse the value object
|
|
109
|
-
* @returns The parsed value
|
|
110
|
-
*/function parseValue(value,options){var _defaultOptions=_objectSpread$l(_objectSpread$l({},defaultOptions$f),options||{}),includeValueAttributes=_defaultOptions.includeValueAttributes;if(includeValueAttributes===false){return value===null||value===void 0?void 0:value.value;}var stringValue=value.value,attributes=_objectWithoutProperties(value,_excluded$d);var valueAttributes=includeValueAttributes===true&&attributes||Array.isArray(includeValueAttributes)&&Object.fromEntries(Object.entries(attributes).filter(function(_ref){var _ref2=_slicedToArray(_ref,1),key=_ref2[0];return includeValueAttributes.includes(key);}))||{};return _objectSpread$l(_objectSpread$l({},valueAttributes),{},{value:stringValue});}
|
|
111
|
-
|
|
112
|
-
var _excluded$c=["joinValue","arrayOnSingleValue"];function ownKeys$k(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;}function _objectSpread$k(target){for(var i=1;i<arguments.length;i++){var source=null!=arguments[i]?arguments[i]:{};i%2?ownKeys$k(Object(source),!0).forEach(function(key){_defineProperty(target,key,source[key]);}):Object.getOwnPropertyDescriptors?Object.defineProperties(target,Object.getOwnPropertyDescriptors(source)):ownKeys$k(Object(source)).forEach(function(key){Object.defineProperty(target,key,Object.getOwnPropertyDescriptor(source,key));});}return target;}var defaultOptions$e=_objectSpread$k(_objectSpread$k({},defaultOptions$f),{},{joinValue:undefined,arrayOnSingleValue:true});/**
|
|
113
|
-
* @internal
|
|
114
|
-
*
|
|
115
|
-
* @param valueList
|
|
116
|
-
* @param options
|
|
117
|
-
* @returns
|
|
118
|
-
*/function parseValueList(valueList,options){var _defaultOptions=_objectSpread$k(_objectSpread$k({},defaultOptions$e),options||{}),joinValue=_defaultOptions.joinValue,arrayOnSingleValue=_defaultOptions.arrayOnSingleValue,parseValueOptions=_objectWithoutProperties(_defaultOptions,_excluded$c);var parsedValueList=valueList===null||valueList===void 0?void 0:valueList.map(function(v){return parseValue(v,parseValueOptions);});if(isStringArray(parsedValueList)&&joinValue)return parsedValueList===null||parsedValueList===void 0?void 0:parsedValueList.join(joinValue);if(arrayOnSingleValue!==true&&(parsedValueList===null||parsedValueList===void 0?void 0:parsedValueList.length)<=1)return parsedValueList===null||parsedValueList===void 0?void 0:parsedValueList[0];return parsedValueList;}
|
|
119
|
-
|
|
120
|
-
var _excluded$b=["includeFieldAttributes"],_excluded2$1=["value"];function ownKeys$j(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;}function _objectSpread$j(target){for(var i=1;i<arguments.length;i++){var source=null!=arguments[i]?arguments[i]:{};i%2?ownKeys$j(Object(source),!0).forEach(function(key){_defineProperty(target,key,source[key]);}):Object.getOwnPropertyDescriptors?Object.defineProperties(target,Object.getOwnPropertyDescriptors(source)):ownKeys$j(Object(source)).forEach(function(key){Object.defineProperty(target,key,Object.getOwnPropertyDescriptor(source,key));});}return target;}var defaultOptions$d=_objectSpread$j({includeFieldAttributes:false},defaultOptions$e);/**
|
|
121
|
-
* @internal
|
|
122
|
-
*
|
|
123
|
-
* @param field
|
|
124
|
-
* @param options
|
|
125
|
-
* @returns
|
|
126
|
-
*/var parseField=function parseField(field,options){var _defaultOptions=_objectSpread$j(_objectSpread$j({},defaultOptions$d),options||{}),includeFieldAttributes=_defaultOptions.includeFieldAttributes,parseValueListOptions=_objectWithoutProperties(_defaultOptions,_excluded$b);var value=field.value,attributes=_objectWithoutProperties(field,_excluded2$1);var parsedValueList=parseValueList(value,parseValueListOptions);var fieldAttributes=includeFieldAttributes===true&&attributes||Array.isArray(includeFieldAttributes)&&Object.fromEntries(Object.entries(attributes).filter(function(_ref){var _ref2=_slicedToArray(_ref,1),key=_ref2[0];return includeFieldAttributes.includes(key);}))||{};return includeFieldAttributes?_objectSpread$j(_objectSpread$j({},fieldAttributes),{},{value:parsedValueList}):parsedValueList;};
|
|
127
|
-
|
|
128
|
-
function ownKeys$i(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;}function _objectSpread$i(target){for(var i=1;i<arguments.length;i++){var source=null!=arguments[i]?arguments[i]:{};i%2?ownKeys$i(Object(source),!0).forEach(function(key){_defineProperty(target,key,source[key]);}):Object.getOwnPropertyDescriptors?Object.defineProperties(target,Object.getOwnPropertyDescriptors(source)):ownKeys$i(Object(source)).forEach(function(key){Object.defineProperty(target,key,Object.getOwnPropertyDescriptor(source,key));});}return target;}var defaultOptions$c=_objectSpread$i(_objectSpread$i({},defaultOptions$d),{},{fieldAsList:false,arrayOnSingleField:false,overrideField:undefined});/**
|
|
129
|
-
* Parse a metadata field list according to selected options
|
|
130
|
-
*
|
|
131
|
-
* @remarks
|
|
132
|
-
* When parsing duplicate fields (same field name in the same field list) it will:
|
|
133
|
-
* - with default options: combine field values to one array within the same field name key
|
|
134
|
-
* - with `joinValue` enabled: join values within each field (returns array with string for each field value)
|
|
135
|
-
* - with `fieldAsList` enabled: separate fields in the list/array (as usual, even if not duplicate)
|
|
136
|
-
* - with `includeFieldAttributes` enabled: return an array of field objects
|
|
137
|
-
* - with `overrideField` enabled: return the latest duplicated field it parses
|
|
138
|
-
*
|
|
139
|
-
* @param fieldList Field list to parse
|
|
140
|
-
* @param [options=defaultOptions] Options for how to parse the field list
|
|
141
|
-
* @returns A parsed field list
|
|
142
|
-
*
|
|
143
|
-
* @category Metadata
|
|
144
|
-
*/var parseFieldList=function parseFieldList(fieldList,options){var parseFieldListOptions=_objectSpread$i(_objectSpread$i({},defaultOptions$c),options||{});var fieldAsList=parseFieldListOptions.fieldAsList,arrayOnSingleField=parseFieldListOptions.arrayOnSingleField,overrideField=parseFieldListOptions.overrideField;var shouldOverride=overrideField===true&&fieldAsList===false;var output={};fieldList===null||fieldList===void 0?void 0:fieldList.forEach(function(field){var name=field.name;var parsedField=parseField(field,parseFieldListOptions);var parsedFieldOutput=arrayOnSingleField===true?asArray(parsedField):parsedField;var existingParsedFields=output[name];if(!existingParsedFields)output[name]=parsedFieldOutput;else if(shouldOverride)output[name]=parsedField;else output[name]=[asArray(existingParsedFields),asArray(parsedField)].flat();});return fieldAsList===true?Object.values(output).flat():output;};
|
|
145
|
-
|
|
146
|
-
var _excluded$a=["field","group"];function ownKeys$h(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;}function _objectSpread$h(target){for(var i=1;i<arguments.length;i++){var source=null!=arguments[i]?arguments[i]:{};i%2?ownKeys$h(Object(source),!0).forEach(function(key){_defineProperty(target,key,source[key]);}):Object.getOwnPropertyDescriptors?Object.defineProperties(target,Object.getOwnPropertyDescriptors(source)):ownKeys$h(Object(source)).forEach(function(key){Object.defineProperty(target,key,Object.getOwnPropertyDescriptor(source,key));});}return target;}var defaultParseGroupOptions=_objectSpread$h(_objectSpread$h({},defaultOptions$c),{},{includeGroupAttributes:false,groupAsList:false,arrayOnSingleGroup:false,overrideGroup:undefined});/**
|
|
147
|
-
* @internal
|
|
148
|
-
*
|
|
149
|
-
* (Kept here due to circular dependency otherwise)
|
|
150
|
-
*
|
|
151
|
-
* @param group
|
|
152
|
-
* @param options
|
|
153
|
-
* @returns
|
|
154
|
-
*/var parseGroup=function parseGroup(group,options){var parseGroupOptions=_objectSpread$h(_objectSpread$h({},defaultParseGroupOptions),options||{});var includeGroupAttributes=parseGroupOptions.includeGroupAttributes;var parseFieldListOptions=Object.fromEntries(Object.entries(parseGroupOptions).filter(function(_ref){var _ref2=_slicedToArray(_ref,1),key=_ref2[0];return Object.keys(defaultOptions$c).includes(key);}));var fieldList=group.field,groupList=group.group,attributes=_objectWithoutProperties(group,_excluded$a);var parsedFieldList=fieldList&&parseFieldList(fieldList,parseFieldListOptions);// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
155
|
-
var parsedGroupList=groupList&&parseGroupList(groupList,parseGroupOptions);var groupAttributes=includeGroupAttributes===true&&attributes||Array.isArray(includeGroupAttributes)&&Object.fromEntries(Object.entries(attributes).filter(function(_ref3){var _ref4=_slicedToArray(_ref3,1),key=_ref4[0];return includeGroupAttributes.includes(key);}))||{};return _objectSpread$h(_objectSpread$h(_objectSpread$h({},groupAttributes),parseFieldListOptions!==null&&parseFieldListOptions!==void 0&&parseFieldListOptions.fieldAsList?parsedFieldList&&{field:parsedFieldList}||{}:parsedFieldList),parseGroupOptions!==null&&parseGroupOptions!==void 0&&parseGroupOptions.groupAsList?parsedGroupList&&{group:parsedGroupList}||{}:parsedGroupList);};var defaultOptions$b=defaultParseGroupOptions;/**
|
|
156
|
-
* Parse a metadata group list according to selected options
|
|
157
|
-
*
|
|
158
|
-
* @remarks
|
|
159
|
-
* Parsing duplicate groups (same group name in the same group list) it will:
|
|
160
|
-
* - with default options: combine group objects to one array within the same group name key
|
|
161
|
-
* - with `groupAsList` enabled: return separate group objects in a list/array (as usual, even if not duplicate)
|
|
162
|
-
* - with `overrideGroup` enabled: return the latest duplicated group it parses
|
|
163
|
-
*
|
|
164
|
-
* @param groupList Group list to parse
|
|
165
|
-
* @param options options for how to parse list
|
|
166
|
-
* @returns A parsed group list
|
|
167
|
-
*
|
|
168
|
-
* @category Metadata
|
|
169
|
-
*/var parseGroupList=function parseGroupList(groupList,options){var parseGroupOptions=_objectSpread$h(_objectSpread$h({},defaultOptions$b),options||{});var groupAsList=parseGroupOptions.groupAsList,arrayOnSingleGroup=parseGroupOptions.arrayOnSingleGroup,overrideGroup=parseGroupOptions.overrideGroup;var shouldOverride=overrideGroup===true&&groupAsList===false;var output={};groupList===null||groupList===void 0?void 0:groupList.forEach(function(group){var name=group.name;var parsedGroup=parseGroup(group,parseGroupOptions);var parsedGroupOutput=arrayOnSingleGroup===true?asArray(parsedGroup):parsedGroup;var existingParsedGroups=output[name];if(!existingParsedGroups)output[name]=parsedGroupOutput;else if(shouldOverride)output[name]=parsedGroup;else output[name]=[asArray(existingParsedGroups),asArray(parsedGroup)].flat();});if(groupAsList){return Object.values(output).flat();}return output;};
|
|
170
|
-
|
|
171
|
-
var _excluded$9=["field","group"];function ownKeys$g(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;}function _objectSpread$g(target){for(var i=1;i<arguments.length;i++){var source=null!=arguments[i]?arguments[i]:{};i%2?ownKeys$g(Object(source),!0).forEach(function(key){_defineProperty(target,key,source[key]);}):Object.getOwnPropertyDescriptors?Object.defineProperties(target,Object.getOwnPropertyDescriptors(source)):ownKeys$g(Object(source)).forEach(function(key){Object.defineProperty(target,key,Object.getOwnPropertyDescriptor(source,key));});}return target;}var defaultOptions$a=_objectSpread$g(_objectSpread$g({},defaultOptions$b),{},{includeTimespanAttributes:false,flat:false,arrayOnSingle:false,arrayOnSingleValue:true,arrayOnSingleGroup:undefined,arrayOnSingleField:undefined});/**
|
|
172
|
-
*
|
|
173
|
-
* Parses timespan according to specified options
|
|
174
|
-
*
|
|
175
|
-
* @remarks
|
|
176
|
-
* To ensure a flat (no array) representation when using `flat: true`, the parser will also set `overrideGroup` and `overrideField` to true (unless those are explicitly set false)
|
|
177
|
-
*
|
|
178
|
-
* @param timespan - A VidiCore metadata timespan
|
|
179
|
-
* @param options - Options to change how it is parsed
|
|
180
|
-
* @returns Timespan parsed according to options
|
|
181
|
-
*
|
|
182
|
-
* @see {@link parseGroupList} and {@link parseFieldList} for more info
|
|
183
|
-
*
|
|
184
|
-
* @category Metadata
|
|
185
|
-
*/var parseTimespan=function parseTimespan(timespan,options){var parseTimespanOptions=_objectSpread$g(_objectSpread$g({},defaultOptions$a),options||{});var includeTimespanAttributes=parseTimespanOptions.includeTimespanAttributes,arrayOnSingle=parseTimespanOptions.arrayOnSingle,flat=parseTimespanOptions.flat;var parseGroupListOptions=Object.fromEntries(Object.entries(options).map(function(_ref){var _ref2=_slicedToArray(_ref,2),key=_ref2[0],value=_ref2[1];if(Object.keys(defaultOptions$b).includes(key)){if(['arrayOnSingleGroup','arrayOnSingleField','arrayOnSingleValue'].includes(key)&&(value!==undefined?value:arrayOnSingle===true)){return [key,true];}if(['overrideGroup','overrideField'].includes(key)&&(value!==undefined?value:flat===true)){return [key,true];}return [key,value];}return undefined;}).filter(function(e){return !!e;}));var parseFieldListOptions=Object.fromEntries(Object.entries(options).map(function(_ref3){var _ref4=_slicedToArray(_ref3,2),key=_ref4[0],value=_ref4[1];if(Object.keys(defaultOptions$c).includes(key)){if(['arrayOnSingleField','arrayOnSingleValue'].includes(key)&&(value!==undefined?value:arrayOnSingle===true)){return [key,true];}if(['overrideField'].includes(key)&&(value!==undefined?value:flat===true)){return [key,true];}return [key,value];}return undefined;}).filter(function(e){return !!e;}));var _ref5=timespan||{},fieldList=_ref5.field,groupList=_ref5.group,attributes=_objectWithoutProperties(_ref5,_excluded$9);var parsedFieldList=fieldList&&parseFieldList(fieldList,parseFieldListOptions);// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
186
|
-
var parsedGroupList=groupList&&parseGroupList(groupList,parseGroupListOptions);var timespanAttributes=includeTimespanAttributes===true&&attributes||Array.isArray(includeTimespanAttributes)&&Object.fromEntries(Object.entries(attributes).filter(function(_ref6){var _ref7=_slicedToArray(_ref6,1),key=_ref7[0];return includeTimespanAttributes.includes(key);}))||{};return _objectSpread$g(_objectSpread$g(_objectSpread$g({},timespanAttributes),parseFieldListOptions!==null&&parseFieldListOptions!==void 0&&parseFieldListOptions.fieldAsList?{field:parsedFieldList}:parsedFieldList),parseGroupListOptions!==null&&parseGroupListOptions!==void 0&&parseGroupListOptions.groupAsList?{group:parsedGroupList}:parsedGroupList);};
|
|
187
|
-
|
|
188
|
-
var _excluded$8=["timespanAsList","joinTimespan","sortTimespan","flat","flatTimespan"];function ownKeys$f(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;}function _objectSpread$f(target){for(var i=1;i<arguments.length;i++){var source=null!=arguments[i]?arguments[i]:{};i%2?ownKeys$f(Object(source),!0).forEach(function(key){_defineProperty(target,key,source[key]);}):Object.getOwnPropertyDescriptors?Object.defineProperties(target,Object.getOwnPropertyDescriptors(source)):ownKeys$f(Object(source)).forEach(function(key){Object.defineProperty(target,key,Object.getOwnPropertyDescriptor(source,key));});}return target;}var defaultOptions$9=_objectSpread$f(_objectSpread$f({},defaultOptions$a),{},{timespanAsList:false,joinTimespan:'_',sortTimespan:false,flat:false,flatTimespan:undefined});/**
|
|
189
|
-
* Parses timespanList according to specified options.
|
|
190
|
-
* The attributes can be targeted for each sub-type.
|
|
191
|
-
*
|
|
192
|
-
* @param timespanList - A Vidicore metadata timespan list
|
|
193
|
-
* @param options - Options which change how the metadataType is parsed.
|
|
194
|
-
* @returns Timespan list parsed according to options
|
|
195
|
-
*
|
|
196
|
-
* @see {@link parseTimespan} for more info
|
|
197
|
-
*
|
|
198
|
-
* @category Metadata
|
|
199
|
-
*/var parseTimespanList=function parseTimespanList(timespanList,options){var parseTimespanListOptions=_objectSpread$f(_objectSpread$f({},defaultOptions$9),options||{});var timespanAsList=parseTimespanListOptions.timespanAsList,joinTimespan=parseTimespanListOptions.joinTimespan,sortTimespan=parseTimespanListOptions.sortTimespan,flat=parseTimespanListOptions.flat,flatTimespan=parseTimespanListOptions.flatTimespan,otherOptions=_objectWithoutProperties(parseTimespanListOptions,_excluded$8);var parseTimespanOptions=_objectSpread$f({flat:flat},otherOptions);if(sortTimespan)timespanList.sort(sortTimespanList);var shouldFlatten=(flatTimespan!==undefined?flatTimespan===true:flat===true)&×panAsList===false;var output={};timespanList===null||timespanList===void 0?void 0:timespanList.forEach(function(timespan){var start=timespan.start,end=timespan.end;var key=shouldFlatten?'flat':[start,end].join(joinTimespan);var parsedTimespan=parseTimespan(timespan,parseTimespanOptions);var existingParsedTimespans=output[key];if(!existingParsedTimespans)output[key]=parsedTimespan;else if(shouldFlatten){if(start==='-INF'&&end==='+INF'){output[key]=_objectSpread$f(_objectSpread$f({},asSingle(existingParsedTimespans)),parsedTimespan);}else {output[key]=_objectSpread$f(_objectSpread$f({},parsedTimespan),asSingle(existingParsedTimespans));}}else output[key]=[].concat(_toConsumableArray(asArray(existingParsedTimespans)),[parsedTimespan]);});if(timespanAsList===true){return Object.values(output);}if(shouldFlatten){return Object.values(output).pop();}return output;};
|
|
200
|
-
|
|
201
|
-
var _excluded$7=["timespan"];function ownKeys$e(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;}function _objectSpread$e(target){for(var i=1;i<arguments.length;i++){var source=null!=arguments[i]?arguments[i]:{};i%2?ownKeys$e(Object(source),!0).forEach(function(key){_defineProperty(target,key,source[key]);}):Object.getOwnPropertyDescriptors?Object.defineProperties(target,Object.getOwnPropertyDescriptors(source)):ownKeys$e(Object(source)).forEach(function(key){Object.defineProperty(target,key,Object.getOwnPropertyDescriptor(source,key));});}return target;}var defaultOptions$8=_objectSpread$e(_objectSpread$e({},defaultOptions$9),{},{includeMetadataAttributes:false,flat:false});/**
|
|
202
|
-
* Parses MetadataType according to specified options
|
|
203
|
-
*
|
|
204
|
-
* @remarks
|
|
205
|
-
* Be aware that you need to take into account that the returned groups and fields can be an array if it has multiple values or groups/fields with same name.
|
|
206
|
-
* If you are certain your metadata type won't return multiple groups/fields/values with same name or don't mind that they _might_ be overridden:
|
|
207
|
-
* you can use the option `flat` along with `joinValue` or `arrayOnSingleValue: false`.
|
|
208
|
-
*
|
|
209
|
-
* @param metadataType - A MetadataType from VidiCore
|
|
210
|
-
* @param options - Options which change how the metadataType is parsed
|
|
211
|
-
* @returns Metadata object parsed according to options
|
|
212
|
-
*
|
|
213
|
-
* @see {@link parseTimespanList} for more info
|
|
214
|
-
*
|
|
215
|
-
* @category Metadata
|
|
216
|
-
*/function parseMetadataType(metadataType,options){var parseMetadataTypeOptions=_objectSpread$e(_objectSpread$e({},defaultOptions$8),options||{});var includeMetadataAttributes=parseMetadataTypeOptions.includeMetadataAttributes,flat=parseMetadataTypeOptions.flat;var _ref=metadataType||{},_ref$timespan=_ref.timespan,timespanList=_ref$timespan===void 0?[]:_ref$timespan,attributes=_objectWithoutProperties(_ref,_excluded$7);var parseTimespanListOptions=Object.fromEntries(Object.entries(options).map(function(_ref2){var _ref3=_slicedToArray(_ref2,2),key=_ref3[0],value=_ref3[1];if(Object.keys(defaultOptions$9).includes(key)){if(['onlyGeneric','overrideGroup','overrideField'].includes(key)&&(value!==undefined?value:flat===true)){return [key,true];}return [key,value];}return undefined;}).filter(function(e){return !!e;}));var parsedTimespanList=parseTimespanList(timespanList,parseTimespanListOptions);var metadataAttributes=includeMetadataAttributes===true&&_objectSpread$e(_objectSpread$e({},attributes),attributes.revision?{revision:attributes.revision.split(',')}:{})||Array.isArray(includeMetadataAttributes)&&Object.fromEntries(Object.entries(attributes).map(function(_ref4){var _ref5=_slicedToArray(_ref4,2),key=_ref5[0],value=_ref5[1];if(includeMetadataAttributes.includes(key)){return [key,key==='revision'&&typeof value==='string'?value.split(','):value];}return undefined;}).filter(function(o){return !!o;}))||{};return _objectSpread$e(_objectSpread$e({},metadataAttributes),parseTimespanListOptions!==null&&parseTimespanListOptions!==void 0&&parseTimespanListOptions.timespanAsList?{timespan:parsedTimespanList}:parsedTimespanList);}
|
|
217
|
-
|
|
218
|
-
/**
|
|
219
|
-
* Parse simple (key/value) metadata
|
|
220
|
-
*
|
|
221
|
-
* Not indexed metadata, available on almost all entities (storages, library, user, group, etc...)
|
|
222
|
-
*
|
|
223
|
-
* @param simpleMetadataType A VidiCore simple metadata object
|
|
224
|
-
* @returns A parsed simple metadata object
|
|
225
|
-
*
|
|
226
|
-
* @category Metadata
|
|
227
|
-
*/var parseSimpleMetadataType=function parseSimpleMetadataType(simpleMetadataType){var _ref=simpleMetadataType||{},_ref$field=_ref.field,field=_ref$field===void 0?[]:_ref$field;return parseKeyValuePairTypes(field);};
|
|
228
|
-
|
|
229
|
-
var MAP_CONSTANT_TO_DEN_NUM={PAL:{denominator:25,numerator:1},NTSC:{denominator:30000,numerator:1001},NTSC30:{denominator:30,numerator:1},29.97:{denominator:30000,numerator:1001},59.94:{denominator:60000,numerator:1001},23.976:{denominator:48000,numerator:2002},23.98:{denominator:48000,numerator:2002}};var TIME_BASE_CONSTANTS=Object.keys(MAP_CONSTANT_TO_DEN_NUM);
|
|
230
|
-
|
|
231
|
-
function ownKeys$d(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;}function _objectSpread$d(target){for(var i=1;i<arguments.length;i++){var source=null!=arguments[i]?arguments[i]:{};i%2?ownKeys$d(Object(source),!0).forEach(function(key){_defineProperty(target,key,source[key]);}):Object.getOwnPropertyDescriptors?Object.defineProperties(target,Object.getOwnPropertyDescriptors(source)):ownKeys$d(Object(source)).forEach(function(key){Object.defineProperty(target,key,Object.getOwnPropertyDescriptor(source,key));});}return target;}var defaultOptions$7={toText:{constant:false,fraction:false},toRate:{fixed:true,rounded:false}};/**
|
|
232
|
-
* TimeBase class representing the TimeBaseType in VidiCore
|
|
233
|
-
*
|
|
234
|
-
* For more info, see the [Time bases section in VidiCore API Docs](https://apidoc.vidispine.com/latest/time.html#time-bases)
|
|
235
|
-
*
|
|
236
|
-
* @category Time
|
|
237
|
-
*/var TimeBase=/*#__PURE__*/function(){/** The numerator for the TimeBase */ /** The denominator for the TimeBase */ /**
|
|
238
|
-
* Constructor for TimeBase
|
|
239
|
-
*
|
|
240
|
-
* @param timeBaseType A TimeBaseType object
|
|
241
|
-
*/function TimeBase(timeBaseType){_classCallCheck(this,TimeBase);_defineProperty(this,"numerator",1);_defineProperty(this,"denominator",1);var _ref=timeBaseType||{},_ref$numerator=_ref.numerator,numerator=_ref$numerator===void 0?1:_ref$numerator,_ref$denominator=_ref.denominator,denominator=_ref$denominator===void 0?1:_ref$denominator;this.numerator=Number(numerator);this.denominator=Number(denominator);}/**
|
|
242
|
-
* Get TimeBase in a constant representation (e.g. "PAL") if possible, otherwise undefined
|
|
243
|
-
* @returns Constant representation of the TimeBase
|
|
244
|
-
*/_createClass(TimeBase,[{key:"toConstant",value:function toConstant(){var _this=this;var constant;// If multiple equal den/num, it selects first in MAP_CONSTANT_TO_DEN_NUM
|
|
245
|
-
Object.entries(MAP_CONSTANT_TO_DEN_NUM).find(function(timeBaseConstant){var _timeBaseConstant=_slicedToArray(timeBaseConstant,2),thisTimeBaseText=_timeBaseConstant[0],thisTimeBaseType=_timeBaseConstant[1];var numerator=thisTimeBaseType.numerator,denominator=thisTimeBaseType.denominator;if(numerator===_this.numerator&&denominator===_this.denominator){constant=thisTimeBaseText;return true;}return false;});return constant;}/**
|
|
246
|
-
* Get TimeBase as a VidiCore TimeBaseType string
|
|
247
|
-
*
|
|
248
|
-
* @remarks
|
|
249
|
-
* Default format: denominator(:numerator if > 1)
|
|
250
|
-
*
|
|
251
|
-
* `constant` has precedence over `fraction` if both are true (e.g. NTSC > 30000:1001)
|
|
252
|
-
*
|
|
253
|
-
* @param options For how to display it as text
|
|
254
|
-
* @returns Text representation of the TimeBase
|
|
255
|
-
*/},{key:"toText",value:function toText(options){var _defaultOptions$toTex=_objectSpread$d(_objectSpread$d({},defaultOptions$7.toText),options),constant=_defaultOptions$toTex.constant,fraction=_defaultOptions$toTex.fraction;if(constant){var _timeBaseText=this.toConstant();if(_timeBaseText)return _timeBaseText;}if(fraction||this.numerator>1){var _timeBaseText2=[this.denominator,this.numerator].join(':');return _timeBaseText2;}var timeBaseText=String(this.denominator);return timeBaseText;}/**
|
|
256
|
-
* Output TimeBase as frame rate (by default max 16 decimal places)
|
|
257
|
-
*
|
|
258
|
-
* @remarks
|
|
259
|
-
* Default format: rate with two decimals if needed (i.e. decimals are > 0)
|
|
260
|
-
*
|
|
261
|
-
* `rounded` has precedence over `fixed`
|
|
262
|
-
*
|
|
263
|
-
* @param options On how to return the rate
|
|
264
|
-
*
|
|
265
|
-
* @return Rate of the TimeBase
|
|
266
|
-
*/},{key:"toRate",value:function toRate(options){var rate=this.denominator/this.numerator;if(Number.isInteger(rate)){return rate;}var _defaultOptions$toRat=_objectSpread$d(_objectSpread$d({},defaultOptions$7.toRate),options||{}),rounded=_defaultOptions$toRat.rounded,fixed=_defaultOptions$toRat.fixed;if(rounded){return Math.round(rate);}if(fixed===true||typeof fixed==='number'){return Number(rate.toFixed(typeof fixed==='boolean'?2:fixed));}return rate;}/**
|
|
267
|
-
* Get TimeBase in a object representation
|
|
268
|
-
*
|
|
269
|
-
* @returns TimeBase as `{denominator, numerator}` object
|
|
270
|
-
*/},{key:"toObject",value:function toObject(){return {denominator:this.denominator,numerator:this.numerator};}/**
|
|
271
|
-
* @deprecated Use {@link TimeBase#toObject | toObject} instead
|
|
272
|
-
*
|
|
273
|
-
* @returns TimeBase as `{denominator, numerator}` object
|
|
274
|
-
*/},{key:"toJson",value:function toJson(){// eslint-disable-next-line no-console
|
|
275
|
-
console.warn('Deprecated - use toObject instead');return this.toObject();}}]);return TimeBase;}();
|
|
276
|
-
|
|
277
|
-
/**
|
|
278
|
-
* Format a string representation of a time base to a TimeBase Instance
|
|
279
|
-
*
|
|
280
|
-
* @param timeBaseText The string to format to a TimeBase instance
|
|
281
|
-
* @returns A TimeBase Instance
|
|
282
|
-
*
|
|
283
|
-
* @category Time
|
|
284
|
-
*/var formatTimeBaseText=function formatTimeBaseText(timeBaseText){if(timeBaseText===undefined){return new TimeBase();}if(typeof timeBaseText==='number'){return new TimeBase({denominator:timeBaseText});}if(typeof timeBaseText==='string'&&timeBaseText.includes(':')){var _timeBaseText$split=timeBaseText.split(':'),_timeBaseText$split2=_slicedToArray(_timeBaseText$split,2),denominator=_timeBaseText$split2[0],numerator=_timeBaseText$split2[1];return new TimeBase({denominator:denominator,numerator:numerator});}if(TIME_BASE_CONSTANTS.includes(timeBaseText)){return new TimeBase(MAP_CONSTANT_TO_DEN_NUM[timeBaseText]);}if(!['string','number'].includes(_typeof(timeBaseText))||Number.isNaN(Number(timeBaseText))){throw new Error("timeBaseText must be a number or ".concat(TIME_BASE_CONSTANTS.join(',')," - is ").concat(JSON.stringify(timeBaseText)));}return new TimeBase({denominator:Number(timeBaseText)});};
|
|
285
|
-
|
|
286
|
-
/**
|
|
287
|
-
* Create a TimeBase instance of an object
|
|
288
|
-
*
|
|
289
|
-
* @param timeBase A TimeBase object
|
|
290
|
-
* @returns A TimeBase instance
|
|
291
|
-
*
|
|
292
|
-
* @category Time
|
|
293
|
-
*/var formatTimeBaseType=function formatTimeBaseType(timeBase){return new TimeBase(timeBase);};
|
|
294
|
-
|
|
295
|
-
/**
|
|
296
|
-
* Create a TimeBase Instance from a number, string or object representation of a time base
|
|
297
|
-
*
|
|
298
|
-
* @param timeBase Input to create time base from
|
|
299
|
-
* @returns A TimeBase instance
|
|
300
|
-
*
|
|
301
|
-
* @category Time
|
|
302
|
-
*/var createTimeBase=function createTimeBase(timeBase){if(timeBase instanceof TimeBase){return timeBase;}if(typeof timeBase==='string'||typeof timeBase==='number'){return formatTimeBaseText(timeBase);}return formatTimeBaseType(timeBase);};
|
|
303
|
-
|
|
304
|
-
/**
|
|
305
|
-
* @private
|
|
306
|
-
*
|
|
307
|
-
* Drops 4 frames (0-3) for 59.97 and 2 frames (0-1) for 29.97/NTSC
|
|
308
|
-
*
|
|
309
|
-
* @param timeBase Time base to get amount of frames to drop for
|
|
310
|
-
* @returns Amount of frame drops for specified time base, false if no frame drops
|
|
311
|
-
*/var getAmountOfFrameDrops=function getAmountOfFrameDrops(timeBase){var timeBaseConstant=timeBase.toConstant();return timeBaseConstant==='59.94'&&4||['NTSC','29.97'].includes(timeBaseConstant)&&2||false;};
|
|
312
|
-
|
|
313
|
-
/**
|
|
314
|
-
* @private
|
|
315
|
-
*
|
|
316
|
-
* Check if TimeBase drops frames
|
|
317
|
-
*
|
|
318
|
-
* @param timeBase TimeBase Instance to check
|
|
319
|
-
* @returns true if time base drops frames, false otherwise
|
|
320
|
-
*/var isDropFrameTimeBase=function isDropFrameTimeBase(timeBase){return getAmountOfFrameDrops(timeBase)>0;};
|
|
321
|
-
|
|
322
|
-
var _excluded$6=["hours"];function ownKeys$c(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;}function _objectSpread$c(target){for(var i=1;i<arguments.length;i++){var source=null!=arguments[i]?arguments[i]:{};i%2?ownKeys$c(Object(source),!0).forEach(function(key){_defineProperty(target,key,source[key]);}):Object.getOwnPropertyDescriptors?Object.defineProperties(target,Object.getOwnPropertyDescriptors(source)):ownKeys$c(Object(source)).forEach(function(key){Object.defineProperty(target,key,Object.getOwnPropertyDescriptor(source,key));});}return target;}var getDroppedFramesFromSamples=function getDroppedFramesFromSamples(timeCode){var samples=timeCode.samples,timeBase=timeCode.timeBase;var amountOfFrameDrops=getAmountOfFrameDrops(timeBase);if(!amountOfFrameDrops)return 0;var roundedFrameRate=timeBase.toRate({rounded:true});var oneMinuteNotDroppedFrames=60*roundedFrameRate;var amountOfFramesToDropPerMinute=60*roundedFrameRate-amountOfFrameDrops;var tenMinuteFrames=10*(oneMinuteNotDroppedFrames-amountOfFrameDrops)+amountOfFrameDrops;var amountOfTenMinuteChunks=Math.floor((samples+1)/tenMinuteFrames);var minuteRemainder=Math.max(0,(samples+1)%tenMinuteFrames-oneMinuteNotDroppedFrames);var amountOfOneMinuteReminderChunks=Math.floor(minuteRemainder/amountOfFramesToDropPerMinute);var frameRemainder=minuteRemainder%amountOfFramesToDropPerMinute;var amountOfFrameRemainderChunks=frameRemainder>0?amountOfFrameDrops:0;return amountOfTenMinuteChunks*9*amountOfFrameDrops+amountOfOneMinuteReminderChunks*amountOfFrameDrops+amountOfFrameRemainderChunks;};var defaultOptions$6={conformTimeBase:{dropFrame:undefined,frameSeparator:undefined},toText:{constant:false,fraction:false,includeTimeBaseForSeconds:false},toDuration:{format:undefined}};/**
|
|
323
|
-
* TimeCode class representing the TimeCodeType in VidiCore
|
|
324
|
-
*
|
|
325
|
-
* For more info, see the [Time Codes section of VidiCore API Docs](https://apidoc.vidispine.com/latest/time.html#time-codes)
|
|
326
|
-
*
|
|
327
|
-
* @category Time
|
|
328
|
-
*/var TimeCode=/*#__PURE__*/function(){/** Amount of samples for the time code */ /** The time base for the time code */ /** If time code is dropFrame or not (by default checks timeBase) */ /** Separator for frame in smpte output (default ":" for non-drop-frame and ";" for dropFrame) */ /**
|
|
329
|
-
* Constructor for TimeCode
|
|
330
|
-
*
|
|
331
|
-
* @param timeCodeType Object to create TimeCode of
|
|
332
|
-
* @param options Options for the timeCode
|
|
333
|
-
*/function TimeCode(timeCodeType,options){var _options$dropFrame,_options$frameSeparat;_classCallCheck(this,TimeCode);_defineProperty(this,"samples",0);_defineProperty(this,"timeBase",new TimeBase());_defineProperty(this,"dropFrame",void 0);_defineProperty(this,"frameSeparator",void 0);var _ref=timeCodeType||{},samples=_ref.samples,timeBase=_ref.timeBase;if(samples!==undefined){if(typeof samples==='number'){this.samples=samples;}else if(typeof samples==='string'){if(samples==='-INF'){this.samples=-Infinity;}else if(samples==='+INF'){this.samples=Infinity;}else {this.samples=Number(samples);}}else {throw new Error("samples is not number/string/-Inf/+Inf is: ".concat(samples));}}if(timeBase!==undefined){if(timeBase instanceof TimeBase){this.timeBase=timeBase;}else {this.timeBase=createTimeBase(timeBase);}}this.dropFrame=(_options$dropFrame=options===null||options===void 0?void 0:options.dropFrame)!==null&&_options$dropFrame!==void 0?_options$dropFrame:isDropFrameTimeBase(this.timeBase);this.frameSeparator=(_options$frameSeparat=options===null||options===void 0?void 0:options.frameSeparator)!==null&&_options$frameSeparat!==void 0?_options$frameSeparat:this.dropFrame?';':':';}/**
|
|
334
|
-
* Return this TimeCode added with the supplied timeCodeType
|
|
335
|
-
* - If time bases differ, it will retain the time base of this TimeCode instance
|
|
336
|
-
* - If supplied time code has a more granular time base, it will round down exceeding samples (hasn't reached that sample yet)
|
|
337
|
-
*
|
|
338
|
-
* @remarks
|
|
339
|
-
* If you don't want to "lose" frames in the manner described above, make sure time code you're operating on has higher time base granularity
|
|
340
|
-
*
|
|
341
|
-
* To exemplify:
|
|
342
|
-
* - "51@50".add("25@25") => "101@50"
|
|
343
|
-
* - while "25@25".add("51@50") => "50@25"
|
|
344
|
-
*
|
|
345
|
-
* @param timeCode A TimeCode instance you want to add with
|
|
346
|
-
* @returns A new TimeCode instance with the addition applied
|
|
347
|
-
*/_createClass(TimeCode,[{key:"add",value:function add(timeCode){if(!(timeCode!==null&&timeCode!==void 0&&timeCode.timeBase)||(timeCode===null||timeCode===void 0?void 0:timeCode.samples)===undefined){throw Error('Invalid timeCodeType, cannot be added');}var _ref2=(timeCode===null||timeCode===void 0?void 0:timeCode.timeBase)||{},numerator=_ref2.numerator,denominator=_ref2.denominator;var conformedTimeCode=timeCode;if(numerator!==this.timeBase.numerator||denominator!==this.timeBase.denominator){conformedTimeCode=timeCode.conformTimeBase(this.timeBase);}var _conformedTimeCode=conformedTimeCode,samples=_conformedTimeCode.samples;return new TimeCode({samples:this.samples+samples,timeBase:this.timeBase});}/**
|
|
348
|
-
* Return this TimeCode subtracted with the supplied timeCodeType
|
|
349
|
-
* - If time bases differ, it will retain the time base of the instance time code
|
|
350
|
-
* - If supplied time code has a more granular time base, it will round down exceeding samples (hasn't reached that sample yet)
|
|
351
|
-
*
|
|
352
|
-
* @remarks
|
|
353
|
-
* If you don't want to "lose" frames in the manner described above, make sure time code you're operating on has higher time base granularity
|
|
354
|
-
|
|
355
|
-
* To exemplify:
|
|
356
|
-
* - "101@50".subtract("25@25") => "51@50"
|
|
357
|
-
* - while "50@25".subtract("51@50") => "25@25"
|
|
358
|
-
*
|
|
359
|
-
* @param timeCode A TimeCode instance you want to subtract with
|
|
360
|
-
* @returns A new TimeCode instance with the subtraction applied
|
|
361
|
-
*/},{key:"subtract",value:function subtract(timeCode){if(!(timeCode!==null&&timeCode!==void 0&&timeCode.timeBase)||(timeCode===null||timeCode===void 0?void 0:timeCode.samples)===undefined){throw Error('Invalid timeCodeType, cannot be subtracted');}var _timeCode$timeBase=timeCode.timeBase;_timeCode$timeBase=_timeCode$timeBase===void 0?{}:_timeCode$timeBase;var numerator=_timeCode$timeBase.numerator,denominator=_timeCode$timeBase.denominator;var conformedTimeCode=timeCode;if(numerator!==this.timeBase.numerator||denominator!==this.timeBase.denominator){conformedTimeCode=timeCode.conformTimeBase(this.timeBase);}var _conformedTimeCode2=conformedTimeCode,samples=_conformedTimeCode2.samples;return new TimeCode({samples:this.samples-samples,timeBase:this.timeBase});}/**
|
|
362
|
-
* Creates a new TimeCode instance with specified timeBase and samples adjusted to that.
|
|
363
|
-
*
|
|
364
|
-
* @remarks
|
|
365
|
-
* If it conforms to a less granular time base - it will floor samples (hasn't reached that sample yet)
|
|
366
|
-
* - e.g. "51@50".conformTo("PAL") => "25@PAL" (not "26@PAL")
|
|
367
|
-
*
|
|
368
|
-
* @param timeBase The TimeBase it should conform the TimeCode to
|
|
369
|
-
* @param options Explicitly set TimeCode options, by default these are derived from `timeBase`
|
|
370
|
-
* @returns A new TimeCode instance with the conformTo timeBase applied
|
|
371
|
-
*/},{key:"conformTimeBase",value:function conformTimeBase(timeBase,options){var conformToTimeBase=timeBase instanceof TimeBase?timeBase:createTimeBase(timeBase);var samples=Math.floor(this.samples/(this.timeBase.toRate({fixed:false})/conformToTimeBase.toRate({fixed:false})));var mergedOptions=_objectSpread$c(_objectSpread$c({},defaultOptions$6.conformTimeBase),options||{});return new TimeCode({samples:samples,timeBase:conformToTimeBase},mergedOptions);}/**
|
|
372
|
-
* Get TimeCode as a text representation
|
|
373
|
-
*
|
|
374
|
-
* @remarks
|
|
375
|
-
* Default format: `samples@denominator[:numerator (if > 1)])`
|
|
376
|
-
*
|
|
377
|
-
* `constant` has precedence over `fraction` if both are true
|
|
378
|
-
*
|
|
379
|
-
* @param options Options for how to format text
|
|
380
|
-
* @returns Text representation of TimeCode
|
|
381
|
-
*/},{key:"toText",value:function toText(options){var timeCodeText="".concat(this.samples);var mergedOptions=_objectSpread$c(_objectSpread$c({},defaultOptions$6.toText),options||{});var timeBaseText=this.timeBase.toText(mergedOptions);if(options!==null&&options!==void 0&&options.includeTimeBaseForSeconds||!['1','1:1'].includes(timeBaseText)){timeCodeText=[this.samples,timeBaseText].join('@');}return timeCodeText;}/**
|
|
382
|
-
* Get TimeCode in a units object representation
|
|
383
|
-
*
|
|
384
|
-
* @returns Units (time and frames) for the time code
|
|
385
|
-
*/},{key:"toUnits",value:function toUnits(){var totalSamples=this.samples+(this.dropFrame?getDroppedFramesFromSamples(this):0);var roundedFrameRate=this.timeBase.toRate({rounded:true});// Calculated without drop-frame but with 2 decimal places
|
|
386
|
-
if(['23.976','23.98'].includes(this.timeBase.toConstant())){roundedFrameRate=this.timeBase.toRate({fixed:true});}var hours=Math.floor(totalSamples/(3600*roundedFrameRate));var minutes=Math.floor(totalSamples/(60*roundedFrameRate))%60;var seconds=Math.floor(totalSamples/roundedFrameRate)%60;var frames=Math.floor(totalSamples%roundedFrameRate);return {hours:hours,minutes:minutes,seconds:seconds,frames:frames};}/**
|
|
387
|
-
* Get TimeCode in a time object representation
|
|
388
|
-
*
|
|
389
|
-
* Note: "milliseconds" is rounded down - use "partialSeconds" for another representation
|
|
390
|
-
*
|
|
391
|
-
* @returns Time for the time code
|
|
392
|
-
*/},{key:"toTime",value:function toTime(){var totalSamples=this.samples+getDroppedFramesFromSamples(this);var _this$toUnits=this.toUnits(),hours=_this$toUnits.hours,minutes=_this$toUnits.minutes,seconds=_this$toUnits.seconds;var roundedFrameRate=this.timeBase.toRate({rounded:true});var framesPrecise=totalSamples%roundedFrameRate;var milliseconds=Math.floor(1000*framesPrecise/roundedFrameRate);var partialSeconds=framesPrecise/roundedFrameRate;return {hours:hours,minutes:minutes,seconds:seconds,milliseconds:milliseconds,partialSeconds:partialSeconds};}/**
|
|
393
|
-
* Get TimeCode in a seconds representation
|
|
394
|
-
*
|
|
395
|
-
* @returns Total seconds for the time code
|
|
396
|
-
*/},{key:"toSeconds",value:function toSeconds(){var _this$timeBase=this.timeBase,numerator=_this$timeBase.numerator,denominator=_this$timeBase.denominator;return Math.round(1000*+(this.samples*numerator/denominator))/1000;}/**
|
|
397
|
-
* Get TimeCode in a duration representation
|
|
398
|
-
*
|
|
399
|
-
* The time unit keys for the format string are:
|
|
400
|
-
* - `h` for hour
|
|
401
|
-
* - `m` for minute
|
|
402
|
-
* - `s` for seconds
|
|
403
|
-
* - `S` for milliseconds
|
|
404
|
-
* - Any other char will be kept in the duration output string
|
|
405
|
-
*
|
|
406
|
-
* Note: Add several consecutive chars for zero padding.
|
|
407
|
-
*
|
|
408
|
-
* By default it:
|
|
409
|
-
* - uses colon delimiter (e.g. for format "hhmmss")
|
|
410
|
-
* - shows "m:ss" or "h:mm:ss" if format is undefined
|
|
411
|
-
*
|
|
412
|
-
* @param options Options for how to display duration
|
|
413
|
-
* @returns Duration representation of the TimeCode
|
|
414
|
-
*/},{key:"toDuration",value:function toDuration(options){var _defaultOptions$toDur=_objectSpread$c(_objectSpread$c({},defaultOptions$6.toDuration),options||{}),format=_defaultOptions$toDur.format;var _this$toTime=this.toTime(),hours=_this$toTime.hours,rest=_objectWithoutProperties(_this$toTime,_excluded$6);var minutes=rest.minutes,seconds=rest.seconds,milliseconds=rest.milliseconds;if(!!format&&typeof format!=='string'){throw Error('format has to be a string');}var isBefore=function isBefore(unit,units){return !format.includes(unit)||!units.some(function(u){return format.includes(u)&&format.lastIndexOf(unit)>format.indexOf(u);});};if(!!format&&!(isBefore('h',['m','s','S'])&&isBefore('m',['s','S'])&&isBefore('s',['S']))){throw Error('format order is unsupported (has to be h, m, s then S)');}if(!format){return "".concat(hours>0?"".concat(hours,":").concat("".concat(minutes).padStart(2,'0')):minutes,":").concat("".concat(seconds).padStart(2,'0'));}var countConsecutiveChars=function countConsecutiveChars(i,arr){var j=i;while(arr[j]===arr[j+1]){j+=1;}return j-i+1;};var timeUnitKeys=['h','m','s','S'];var output=[];_toConsumableArray(format).forEach(function(c,i,arr){switch(c){case'h':{if(arr[i-1]==='h'){break;}var amount=countConsecutiveChars(i,arr);output.push("".concat(hours).padStart(amount,'0'));if(timeUnitKeys.includes(arr[i+amount])){output.push(':');}break;}case'm':{if(arr[i-1]==='m'){break;}var _amount=countConsecutiveChars(i,arr);if(!format.includes('h')){minutes+=hours*60;}output.push("".concat(minutes).padStart(_amount,'0'));if(timeUnitKeys.includes(arr[i+_amount])){output.push(':');}break;}case's':{if(arr[i-1]==='s'){break;}var _amount2=countConsecutiveChars(i,arr);if(!format.includes('m')){seconds+=minutes*60;}output.push("".concat(seconds).padStart(_amount2,'0'));if(timeUnitKeys.includes(arr[i+_amount2])){output.push('.');}break;}case'S':{if(arr[i-1]==='S'){break;}var _amount3=countConsecutiveChars(i,arr);if(!format.includes('s')){milliseconds+=seconds*1000;}output.push("".concat(Math.round(milliseconds/Math.pow(10,3-_amount3))).padStart(_amount3,'0'));break;}default:output.push(c);}});return output.join('');}/**
|
|
415
|
-
* Get TimeCode in a smpte representation
|
|
416
|
-
*
|
|
417
|
-
* @returns Smpte representation of the TimeCode
|
|
418
|
-
*/},{key:"toSmpte",value:function toSmpte(){if(this.samples===-Infinity)return '00:00:00:00';var _this$toUnits2=this.toUnits(),hours=_this$toUnits2.hours,minutes=_this$toUnits2.minutes,seconds=_this$toUnits2.seconds,frames=_this$toUnits2.frames;var hhmmss=[hours.toFixed().padStart(2,'0'),minutes.toFixed().padStart(2,'0'),seconds.toFixed().padStart(2,'0')].join(':');var framePadLength=Math.max(2,"".concat(this.timeBase.toRate({rounded:true})-1).length);return [hhmmss,"".concat(frames).padStart(framePadLength,'0')].join(this.frameSeparator);}/**
|
|
419
|
-
* Get TimeCode as a VidiCore TimeCodeType object
|
|
420
|
-
*
|
|
421
|
-
* @returns TimeCode as `{ samples, timeBase }`
|
|
422
|
-
*/},{key:"toObject",value:function toObject(){return {samples:this.samples,timeBase:this.timeBase.toObject()};}/**
|
|
423
|
-
* @deprecated Use {@link TimeCode#toObject | toObject} instead
|
|
424
|
-
*
|
|
425
|
-
* @returns TimeCode as `{ samples, timeBase }`
|
|
426
|
-
*/},{key:"toJson",value:function toJson(){// eslint-disable-next-line no-console
|
|
427
|
-
console.warn('Deprecated - use toObject instead');return this.toObject();}}]);return TimeCode;}();
|
|
428
|
-
|
|
429
|
-
/* eslint-disable no-self-assign */ /**
|
|
430
|
-
* @private
|
|
431
|
-
*
|
|
432
|
-
* Using Euclid's algorithm
|
|
433
|
-
*
|
|
434
|
-
* @param num1 a number
|
|
435
|
-
* @param num2 another number
|
|
436
|
-
* @returns The greatest common divisor of num1 and num2
|
|
437
|
-
*/var getGreatestCommonDivisor=function getGreatestCommonDivisor(num1,num2){var a=Math.abs(num1);var b=Math.abs(num2);while(a&&b&&a!==b){if(a>b){var _ref=[a-b,b];a=_ref[0];b=_ref[1];}else {var _ref2=[a,b-a];a=_ref2[0];b=_ref2[1];}}return a||b;};
|
|
438
|
-
|
|
439
|
-
var _excluded$5=["timeBase","useGCD"];/**
|
|
440
|
-
* Format seconds to TimeCode object
|
|
441
|
-
*
|
|
442
|
-
* @remarks
|
|
443
|
-
* Input time base is always considered as 1:1 since it expects seconds as input
|
|
444
|
-
*
|
|
445
|
-
* Note: Max 15 digits accuracy (double precision float64), e.g.
|
|
446
|
-
* - 10^6 seconds can have 10^9 decimals (nanosecond) precision
|
|
447
|
-
* - 10^9 seconds can have 10^6 decimals (microsecond) precision
|
|
448
|
-
* - 10^12 seconds can have 10^3 decimals (millisecond) precision
|
|
449
|
-
*
|
|
450
|
-
* @param seconds With or without decimals ("." and "," are both interpreted as decimal)
|
|
451
|
-
* @param options Options for how to format the seconds to a TimeCode
|
|
452
|
-
* @returns A TimeCode instance
|
|
453
|
-
*
|
|
454
|
-
* @category Time
|
|
455
|
-
*/var formatTimeCodeSeconds=function formatTimeCodeSeconds(seconds,options){var _ref=options||{},timeBase=_ref.timeBase,_ref$useGCD=_ref.useGCD,useGCD=_ref$useGCD===void 0?false:_ref$useGCD,timeCodeOptions=_objectWithoutProperties(_ref,_excluded$5);var secondsWithDot="".concat(seconds).replace(/,/g,'.');if(Number.isNaN(+secondsWithDot)){throw new Error("seconds must be digits, is ".concat(seconds));}var denominator=1;var samples;if(Number.isInteger(+secondsWithDot)){samples=+secondsWithDot*denominator;}else {var _ms$length;var _secondsWithDot$split=secondsWithDot.split('.'),_secondsWithDot$split2=_slicedToArray(_secondsWithDot$split,2),ms=_secondsWithDot$split2[1];var decimalPlaces=Math.min((_ms$length=ms===null||ms===void 0?void 0:ms.length)!==null&&_ms$length!==void 0?_ms$length:0,16);denominator*=Math.pow(10,decimalPlaces);samples=Math.round(Number(secondsWithDot)*denominator);}if(timeBase===undefined&&useGCD){var gcd=getGreatestCommonDivisor(denominator,samples);samples/=gcd;denominator/=gcd;}var timeCode=new TimeCode({samples:samples,timeBase:{denominator:denominator,numerator:1}},timeCodeOptions);return timeBase!==undefined?timeCode.conformTimeBase(createTimeBase(timeBase),timeCodeOptions):timeCode;};
|
|
456
|
-
|
|
457
|
-
var getDroppedFramesFromSmpte=function getDroppedFramesFromSmpte(_ref,samples,timeBase){var _ref2=_slicedToArray(_ref,4),hh=_ref2[0],mm=_ref2[1],ss=_ref2[2],ff=_ref2[3];var roundedFrameRate=timeBase.toRate({rounded:true});var dropFrames=getAmountOfFrameDrops(timeBase);if(samples===0||!dropFrames){return 0;}var shouldDropMinute=mm%10!==0;var shouldDropSecond=shouldDropMinute&&ss===0;var hourFrames=hh*(3600*roundedFrameRate-54*dropFrames);var minuteFrames=mm*60*roundedFrameRate-(mm-Math.ceil(mm/10))*dropFrames;var secondFrames=ss*roundedFrameRate-(shouldDropMinute&&ss>1?dropFrames:0);if(shouldDropSecond&&ff<dropFrames){throw new Error("Frame does not exist for ".concat(timeBase.toConstant()||timeBase.toRate()," drop-frame"));}var frameFrames=shouldDropSecond?ff-dropFrames:ff;var samplesWithoutDroppedFrames=hourFrames+minuteFrames+secondFrames+frameFrames;return samples-samplesWithoutDroppedFrames;};var getSamplesFromSmpte=function getSamplesFromSmpte(smpteValues,timeBase,dropFrame){var _smpteValues=_slicedToArray(smpteValues,4),hh=_smpteValues[0],mm=_smpteValues[1],ss=_smpteValues[2],ff=_smpteValues[3];var roundedFrameRate=timeBase.toRate({rounded:true});var samples=hh*3600*roundedFrameRate+mm*60*roundedFrameRate+ss*roundedFrameRate+ff;return samples-(dropFrame?getDroppedFramesFromSmpte(smpteValues,samples,timeBase):0);};
|
|
458
|
-
|
|
459
|
-
var splitSmpte=function splitSmpte(smpte){var _ref=(smpte===null||smpte===void 0?void 0:smpte.match(/[^0-9:\-_]/))||[],_ref2=_slicedToArray(_ref,1),nonColonFrameSeparator=_ref2[0];var smpteValues=[];if(nonColonFrameSeparator){var _smpte$split=smpte.split(nonColonFrameSeparator),_smpte$split2=_slicedToArray(_smpte$split,2),hhmmss=_smpte$split2[0],ff=_smpte$split2[1];smpteValues=[].concat(_toConsumableArray(hhmmss.split(':')),[ff]);}else {smpteValues=smpte.split(':');}if(smpteValues.length!==4){throw new Error('Invalid format, must be "##:##:##:##');}if(smpteValues.some(function(n){return Number.isNaN(n);})){throw new Error('Invalid format, values must be numbers');}var smpteFrameSeparator=nonColonFrameSeparator||':';return {smpteValues:smpteValues.map(Number),smpteFrameSeparator:smpteFrameSeparator};};
|
|
460
|
-
|
|
461
|
-
var _excluded$4=["exceedingMode","timeBase"];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;}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(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;}var EXCEEDING_OPTIONS=['error','add','ignore'];var defaultOptions$5={exceedingMode:'error',timeBase:undefined,dropFrame:undefined,frameSeparator:undefined};/**
|
|
462
|
-
* Format smpte text to a TimeCode Instance
|
|
463
|
-
*
|
|
464
|
-
* Options for `exceedingMode`:
|
|
465
|
-
* - `add` will be overflow to higher unit (e.g. PAL and 00:00:00:25 => 00:00:01:00)
|
|
466
|
-
* - `ignore` will be truncated (e.g. PAL and 00:00:00:25 => 00:00:00:24)
|
|
467
|
-
* - `error` will throw error (e.g. PAL and 00:00:00:25 => Error)
|
|
468
|
-
*
|
|
469
|
-
* @param smpte String representation of smpte
|
|
470
|
-
* @param options Options for creating the time code from smpte
|
|
471
|
-
* @returns TimeCode instance created from smpte string
|
|
472
|
-
*
|
|
473
|
-
* @category Time
|
|
474
|
-
*/var formatTimeCodeSmpte=function formatTimeCodeSmpte(smpte,options){var _ref=_objectSpread$b(_objectSpread$b({},defaultOptions$5),options)||{},exceedingMode=_ref.exceedingMode,timeBase=_ref.timeBase,timeCodeOptions=_objectWithoutProperties(_ref,_excluded$4);if([null,undefined].includes(smpte)){throw new Error("smpte cannot be undefined or null");}if(typeof smpte!=='string'){throw new Error("smpte must be a string, is ".concat(JSON.stringify(smpte)));}var _splitSmpte=splitSmpte(smpte),smpteValues=_splitSmpte.smpteValues,smpteFrameSeparator=_splitSmpte.smpteFrameSeparator;var timeBaseInstance=createTimeBase(timeBase);var mergedOptions=_objectSpread$b(_objectSpread$b({},timeCodeOptions),{},{frameSeparator:(timeCodeOptions===null||timeCodeOptions===void 0?void 0:timeCodeOptions.frameSeparator)||smpteFrameSeparator},(timeCodeOptions===null||timeCodeOptions===void 0?void 0:timeCodeOptions.dropFrame)===undefined?{dropFrame:timeBase!==undefined?isDropFrameTimeBase(timeBaseInstance):[';',','].includes(smpteFrameSeparator)}:{});var roundedFrameRate=timeBaseInstance.toRate({rounded:true});var maxFrame=Math.max(0,roundedFrameRate-1);if(smpteValues.some(function(v){return v<0;})){throw new Error('Negative values are not supported');}var samples;switch(exceedingMode){case'error':{var _smpteValues=_slicedToArray(smpteValues,4),hours=_smpteValues[0],minutes=_smpteValues[1],seconds=_smpteValues[2],frames=_smpteValues[3];if(hours>=100){throw Error('Minutes has to be less than 60');}if(minutes>=60){throw Error('Minutes has to be less than 60');}if(seconds>=60){throw Error('Seconds has to be less than 60');}if(frames>maxFrame){throw Error("Frames has to be less or equal to ".concat(maxFrame));}samples=getSamplesFromSmpte(smpteValues,timeBaseInstance,mergedOptions===null||mergedOptions===void 0?void 0:mergedOptions.dropFrame);break;}case'ignore':{var _smpteValues2=_slicedToArray(smpteValues,4),_hours=_smpteValues2[0],_minutes=_smpteValues2[1],_seconds=_smpteValues2[2],_frames=_smpteValues2[3];var truncatedSmpteValues=[Math.min(100,_hours),Math.min(59,_minutes),Math.min(59,_seconds),Math.min(maxFrame,_frames)];samples=getSamplesFromSmpte(truncatedSmpteValues,timeBaseInstance,mergedOptions===null||mergedOptions===void 0?void 0:mergedOptions.dropFrame);break;}case'add':{samples=getSamplesFromSmpte(smpteValues,timeBaseInstance,mergedOptions===null||mergedOptions===void 0?void 0:mergedOptions.dropFrame);break;}default:{throw new Error("Invalid exceedingMode, options are ".concat(JSON.stringify(EXCEEDING_OPTIONS)));}}return new TimeCode({samples:samples,timeBase:timeBaseInstance},mergedOptions);};
|
|
475
|
-
|
|
476
|
-
var _excluded$3=["timeBase"];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;}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(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;}var defaultOptions$4={timeBase:undefined,dropFrame:undefined,frameSeparator:undefined};/**
|
|
477
|
-
* Format text to a TimeCode instance
|
|
478
|
-
*
|
|
479
|
-
* @returns A TimeCode instance
|
|
480
|
-
*
|
|
481
|
-
* @category Time
|
|
482
|
-
*/var formatTimeCodeText=function formatTimeCodeText(timeCodeText,options){var _timeCodeObject;var _ref=_objectSpread$a(_objectSpread$a({},defaultOptions$4),options)||{},timeBase=_ref.timeBase,timeCodeOptions=_objectWithoutProperties(_ref,_excluded$3);var timeCodeObject;if(timeCodeText===undefined){timeCodeObject={samples:0};}else if(typeof timeCodeText==='number'){timeCodeObject={samples:timeCodeText};}else if(timeCodeText.includes('@')){var _timeCodeText$split=timeCodeText.split('@'),_timeCodeText$split2=_slicedToArray(_timeCodeText$split,2),samplesString=_timeCodeText$split2[0],timeBaseText=_timeCodeText$split2[1];var samples=Number(samplesString);timeCodeObject={samples:samples,timeBase:formatTimeBaseText(timeBaseText)};}else if(timeCodeText==='-INF'){timeCodeObject={samples:-Infinity};}else if(timeCodeText==='+INF'){timeCodeObject={samples:Infinity};}else {timeCodeObject={samples:Number(timeCodeText)};}if(Number.isNaN((_timeCodeObject=timeCodeObject)===null||_timeCodeObject===void 0?void 0:_timeCodeObject.samples)||timeCodeObject.timeBase&&!(timeCodeObject.timeBase instanceof TimeBase)){throw new Error("timeCodeText must be a number or sample@timeBase - is ".concat(timeCodeText));}var timeCode=new TimeCode(timeCodeObject,timeCodeOptions);return timeBase?timeCode.conformTimeBase(createTimeBase(timeBase),timeCodeOptions):timeCode;};
|
|
483
|
-
|
|
484
|
-
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;}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(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;}var defaultOptions$3={dropFrame:undefined,frameSeparator:undefined};/**
|
|
485
|
-
* Format an object to a TimeCode instance
|
|
486
|
-
*
|
|
487
|
-
* @param timeCode To create TimeCode instance of
|
|
488
|
-
* @param options For the TimeCode constructor
|
|
489
|
-
* @returns A TimeCode instance
|
|
490
|
-
*
|
|
491
|
-
* @category Time
|
|
492
|
-
*/var formatTimeCodeType=function formatTimeCodeType(timeCode,options){return new TimeCode(timeCode,_objectSpread$9(_objectSpread$9({},defaultOptions$3),options));};
|
|
493
|
-
|
|
494
|
-
var hasSmpteFormat=function hasSmpteFormat(s){return !!s.match(/^(\d\d+):(\d\d+):(\d\d+)(:|;|\.|,)(\d\d+)$/);};var isNumber=function isNumber(s){return !Number.isNaN(Number(s));};/**
|
|
495
|
-
* Create a TimeCode instance from smpte, seconds/samples, timeCode object or string
|
|
496
|
-
*
|
|
497
|
-
* @param timeCode Smpte, seconds/samples, timeCode object or string
|
|
498
|
-
* @param options For the format functions
|
|
499
|
-
* @returns A TimeCode instance
|
|
500
|
-
*
|
|
501
|
-
* @category Time
|
|
502
|
-
*/var createTimeCode=function createTimeCode(timeCode,options){if(timeCode instanceof TimeCode){return timeCode;}if(typeof timeCode!=='string'&&typeof timeCode!=='number')// TimeCode object
|
|
503
|
-
return formatTimeCodeType(timeCode,options);// SMPTE
|
|
504
|
-
if(typeof timeCode==='string'&&hasSmpteFormat(timeCode))return formatTimeCodeSmpte(timeCode,options);if(['string','number'].includes(_typeof(timeCode))&&isNumber(timeCode))return formatTimeCodeSeconds(timeCode,options);if(typeof timeCode==='string'){return formatTimeCodeText(timeCode,options);}return undefined;};
|
|
505
|
-
|
|
506
|
-
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;}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(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;}function timeToCueTime(_ref){var _ref$hours=_ref.hours,hours=_ref$hours===void 0?0:_ref$hours,_ref$minutes=_ref.minutes,minutes=_ref$minutes===void 0?0:_ref$minutes,_ref$seconds=_ref.seconds,seconds=_ref$seconds===void 0?0:_ref$seconds,_ref$partialSeconds=_ref.partialSeconds,partialSeconds=_ref$partialSeconds===void 0?0:_ref$partialSeconds;var hourStr=hours.toFixed().padStart(2,'0');var minStr=minutes.toFixed().padStart(2,'0');var secondsStr=seconds.toFixed().padStart(2,'0');var partialStr=(partialSeconds*10).toFixed().padStart(3,'0');return "".concat(hourStr,":").concat(minStr,":").concat(secondsStr,".").concat(partialStr);}var defaultOptions$2={subtitleGroup:'stl_subtitle',subtitleField:'stl_text'};/**
|
|
507
|
-
* Convert metadata subtitle groups to WebVtt subtitles
|
|
508
|
-
*
|
|
509
|
-
* @param metadataType - Vidicore metadata object (should include subtitleGroup and subtitleField)
|
|
510
|
-
* @param options - options for how to map subtitle group
|
|
511
|
-
* @returns WebVtt subtitles
|
|
512
|
-
*
|
|
513
|
-
* @category Metadata
|
|
514
|
-
*/var metadataTypeToWebVtt=function metadataTypeToWebVtt(metadataType,options){var _defaultOptions=_objectSpread$8(_objectSpread$8({},defaultOptions$2),options||{}),subtitleGroup=_defaultOptions.subtitleGroup,subtitleField=_defaultOptions.subtitleField;var _ref2=metadataType||{},_ref2$timespan=_ref2.timespan,timespanList=_ref2$timespan===void 0?[]:_ref2$timespan;if(timespanList.length===0)return '';var parsedTimespans=parseTimespanList(timespanList,{includeTimespanAttributes:true,sortTimespan:true,timespanAsList:true,overrideGroup:true,joinValue:','});var vttCues=parsedTimespans.map(function(timespan){var _ref3=(Array.isArray(timespan)?timespan[0]:timespan)||{},startText=_ref3.start,endText=_ref3.end,_ref3$subtitleGroup=_ref3[subtitleGroup];_ref3$subtitleGroup=_ref3$subtitleGroup===void 0?{}:_ref3$subtitleGroup;var text=_ref3$subtitleGroup[subtitleField];if(!text)return '';var start=timeToCueTime(formatTimeCodeText(startText).toTime());var end=timeToCueTime(formatTimeCodeText(endText).toTime());return "".concat(start," --> ").concat(end," line:0%\r").concat(text,"\r");});return "WEBVTT\n\n\n".concat(vttCues.join('\n'));};
|
|
515
|
-
|
|
516
|
-
/**
|
|
517
|
-
* Create a Vidicore facet list
|
|
518
|
-
*
|
|
519
|
-
* @param fieldList Input to create facet of
|
|
520
|
-
* @param options Options for creating the facet
|
|
521
|
-
* @returns A VidiCore facet list
|
|
522
|
-
*
|
|
523
|
-
* @category Search
|
|
524
|
-
*/var createFacetType=function createFacetType(){var fieldList=arguments.length>0&&arguments[0]!==undefined?arguments[0]:[];var options=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{count:true};return fieldList.map(function(field){return {field:field,name:field,count:options.count!==undefined?options===null||options===void 0?void 0:options.count:true,exclude:fieldList};});};
|
|
525
|
-
|
|
526
|
-
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;}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(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;}/** Parsed facet type */ /**
|
|
527
|
-
* Parse a VidiCore facet type list
|
|
528
|
-
*
|
|
529
|
-
* @param facetType A facet type list to parse
|
|
530
|
-
* @returns A parsed facet type list
|
|
531
|
-
*
|
|
532
|
-
* @category Search
|
|
533
|
-
*/var parseFacetType=function parseFacetType(){var facetType=arguments.length>0&&arguments[0]!==undefined?arguments[0]:[];var output={};facetType.forEach(function(_ref){var name=_ref.name,field=_ref.field,count=_ref.count;output[name||field]=count.reduce(function(acc,_ref2){var fieldValue=_ref2.fieldValue,value=_ref2.value;return _objectSpread$7(_objectSpread$7({},acc),{},_defineProperty({},fieldValue,value));},{});});return output;};
|
|
534
|
-
|
|
535
|
-
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;}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(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;}var defaultOptions$1={arrayOnSingle:true,joinValue:undefined,timespanAsList:false};/**
|
|
536
|
-
* Parses highlight timespan in VidiCore into key/value object.
|
|
537
|
-
* The attributes can be targeted for each sub-type.
|
|
538
|
-
* @param timespan - A VidiCore search timespan
|
|
539
|
-
* @param options - Options which change how the timespans are parsed
|
|
540
|
-
*
|
|
541
|
-
* @category Search
|
|
542
|
-
*/var parseHighlightTimespan=function parseHighlightTimespan(timespan,options){var _defaultOptions=_objectSpread$6(_objectSpread$6({},defaultOptions$1),options||{}),_defaultOptions$array=_defaultOptions.arrayOnSingle,arrayOnSingle=_defaultOptions$array===void 0?true:_defaultOptions$array,_defaultOptions$joinV=_defaultOptions.joinValue,joinValue=_defaultOptions$joinV===void 0?undefined:_defaultOptions$joinV,_defaultOptions$times=_defaultOptions.timespanAsList,timespanAsList=_defaultOptions$times===void 0?false:_defaultOptions$times;var _ref=timespan||{},_ref$field=_ref.field,field=_ref$field===void 0?[]:_ref$field,start=_ref.start,end=_ref.end;var initialValue=timespanAsList?{start:start,end:end}:{};var fieldList=field.reduce(function(acc,curr){var name=curr.name,_curr$value=curr.value,valueList=_curr$value===void 0?[]:_curr$value;if(valueList.length===0)return acc;var fieldValue;if(arrayOnSingle===false&&valueList.length===1){var _valueList=_slicedToArray(valueList,1);fieldValue=_valueList[0];}else if(joinValue)fieldValue=valueList.join(joinValue);else fieldValue=valueList;return _objectSpread$6(_objectSpread$6({},acc),{},_defineProperty({},name,fieldValue));},initialValue);return fieldList;};
|
|
543
|
-
|
|
544
|
-
var _excluded$2=["timespanAsList","joinTimespan","flat","flatTimespan"];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;}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(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;}var defaultOptions=_objectSpread$5(_objectSpread$5({},defaultOptions$1),{},{timespanAsList:false,joinTimespan:'_',flat:false,flatTimespan:false});/**
|
|
545
|
-
* Parses highlight timespans from VidiCore into key/value object.
|
|
546
|
-
* The attributes can be targeted for each sub-type.
|
|
547
|
-
*
|
|
548
|
-
* @param highlightTimespanList - A list of timespans from VidiCore.
|
|
549
|
-
* @param options - Options to change how the timespans are parsed
|
|
550
|
-
*
|
|
551
|
-
* @category Search
|
|
552
|
-
*/var parseHighlightTimespanList=function parseHighlightTimespanList(){var highlightTimespanList=arguments.length>0&&arguments[0]!==undefined?arguments[0]:[];var options=arguments.length>1?arguments[1]:undefined;var _defaultOptions=_objectSpread$5(_objectSpread$5({},defaultOptions),options||{}),timespanAsList=_defaultOptions.timespanAsList,_defaultOptions$joinT=_defaultOptions.joinTimespan,joinTimespan=_defaultOptions$joinT===void 0?'_':_defaultOptions$joinT,flat=_defaultOptions.flat,flatTimespan=_defaultOptions.flatTimespan,parseHighlightTimespanOptions=_objectWithoutProperties(_defaultOptions,_excluded$2);if(timespanAsList===true)return highlightTimespanList.map(function(timespan){return parseHighlightTimespan(timespan,_objectSpread$5(_objectSpread$5({},parseHighlightTimespanOptions),{},{timespanAsList:timespanAsList}));});if(flat===true||flatTimespan===true)return highlightTimespanList.reduce(function(a,timespan){return _objectSpread$5(_objectSpread$5({},a),parseHighlightTimespan(timespan,options));},{});return highlightTimespanList.reduce(function(a,timespan){return _objectSpread$5(_objectSpread$5({},a),{},_defineProperty({},[timespan.start,timespan.end].join(joinTimespan),parseHighlightTimespan(timespan,options)));},{});};
|
|
553
|
-
|
|
554
|
-
/**
|
|
555
|
-
* Parse Vidicore "NOW" constants to a date object
|
|
556
|
-
*
|
|
557
|
-
* Format: `NOW[+/-][number][HOUR/DAY/MONTH/YEAR(s)]` (e.g. "NOW-2HOURS")
|
|
558
|
-
*
|
|
559
|
-
* @remarks
|
|
560
|
-
* Returns an approximate date since it's created client side
|
|
561
|
-
*
|
|
562
|
-
* @param value A "NOW" constant
|
|
563
|
-
* @returns A date from the NOW constant
|
|
564
|
-
*
|
|
565
|
-
* @category Search
|
|
566
|
-
*/var parseNowDate=function parseNowDate(){var value=arguments.length>0&&arguments[0]!==undefined?arguments[0]:'NOW';if(value.startsWith('NOW')){if(value==='NOW')return new Date();var sign=value[3];var number=Number(value.match(/(\d+)/)[0]);var unit=value.match(/(\d.*)/)[0].replace(/\d/g,'');var nowDiff=new Date();switch(unit){case'HOUR':case'HOURS':if(sign==='+')nowDiff.setHours(nowDiff.getHours()+number);if(sign==='-')nowDiff.setHours(nowDiff.getHours()-number);break;case'DAY':case'DAYS':if(sign==='+')nowDiff.setDate(nowDiff.getDate()+number);if(sign==='-')nowDiff.setDate(nowDiff.getDate()-number);break;case'MONTH':case'MONTHS':if(sign==='+')nowDiff.setMonth(nowDiff.getMonth()+number);if(sign==='-')nowDiff.setMonth(nowDiff.getMonth()-number);break;case'YEAR':case'YEARS':if(sign==='+')nowDiff.setFullYear(nowDiff.getFullYear()+number);if(sign==='-')nowDiff.setFullYear(nowDiff.getFullYear()-number);break;}return nowDiff;}return new Date(value);};
|
|
567
|
-
|
|
568
|
-
var _excluded$1=["property"];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;}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(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;}var parseBaseMediaInfoType=function parseBaseMediaInfoType(baseMediaInfoType){var _ref=baseMediaInfoType||{},_ref$property=_ref.property,keyValuePairTypes=_ref$property===void 0?[]:_ref$property,props=_objectWithoutProperties(_ref,_excluded$1);var parsedKeyValuePairType=parseKeyValuePairTypes(keyValuePairTypes);return _objectSpread$4(_objectSpread$4({},parsedKeyValuePairType),props);};var parseAudioMediaInfoType=function parseAudioMediaInfoType(mediaInfoType){return parseBaseMediaInfoType(mediaInfoType);};var parseVideoMediaInfoType=function parseVideoMediaInfoType(mediaInfoType){return parseBaseMediaInfoType(mediaInfoType);};
|
|
569
|
-
|
|
570
|
-
var sampleRateSymbols={kB:'kHz',B:'Hz',mB:'mHz'};var bitRateSymbols$1={kB:'kbps',B:'bps',MB:'mbps'};/**
|
|
571
|
-
* Parses the technical information of a AudioComponentType.
|
|
572
|
-
* @param audioComponentType - A AudioComponentType from VidiCore.
|
|
573
|
-
* @returns Parsed component object.
|
|
574
|
-
*
|
|
575
|
-
* @category Shape
|
|
576
|
-
*/var parseAudioComponent=function parseAudioComponent(audioComponentType){var timeBase=audioComponentType.timeBase,audioChannels=audioComponentType.channelCount,audioCodec=audioComponentType.codec,mediaInfo=audioComponentType.mediaInfo,bitrate=audioComponentType.bitrate,metadata=audioComponentType.metadata;var audioMediaInfo=parseAudioMediaInfoType(mediaInfo);var audioFormat=audioMediaInfo.Format,audioBitDepth=audioMediaInfo.Resolution,audioBitRateMode=audioMediaInfo.Bit_rate_mode;var audioMetadata=parseKeyValuePairTypes(metadata||[]);var audioSamplerateSamples=timeBase!==null&&timeBase!==void 0&&timeBase.denominator?((timeBase===null||timeBase===void 0?void 0:timeBase.denominator)||1)/((timeBase===null||timeBase===void 0?void 0:timeBase.numerator)||1):undefined;var audioSamplerate=audioSamplerateSamples!==undefined?filesize(audioSamplerateSamples,{base:10,round:1,symbols:sampleRateSymbols}):undefined;var audioBitrate;var audioBitrateKbps;if(bitrate!==undefined){var _split;audioBitrate=filesize(bitrate,{round:2,symbols:bitRateSymbols$1});audioBitrateKbps=Number((_split=filesize(bitrate,{exponent:1,symbols:bitRateSymbols$1}).split(' kbps'))===null||_split===void 0?void 0:_split[0]);}return {audioFormat:audioFormat,audioCodec:audioCodec,audioSamplerate:audioSamplerate,audioSamplerateSamples:audioSamplerateSamples,audioBitDepth:audioBitDepth,audioBitrate:audioBitrate,audioBitrateKbps:audioBitrateKbps,audioBitRateMode:audioBitRateMode,audioChannels:audioChannels,audioMediaInfo:audioMediaInfo,audioMetadata:audioMetadata};};
|
|
577
|
-
|
|
578
|
-
/**
|
|
579
|
-
* Const object with all file states in VidiCore
|
|
580
|
-
* (see https://apidoc.vidispine.com/latest/storage/storage.html#file-states for more info)
|
|
581
|
-
*
|
|
582
|
-
* @category File
|
|
583
|
-
*/var FILE_STATES={/** Just created, not used. */NONE:'NONE',/** Discovered or created, not yet marked as finished. */OPEN:'OPEN',/** File does no longer grow. */CLOSED:'CLOSED',/** The current state is not known. */UNKNOWN:'UNKNOWN',/** File is missing from the file system/storage. */MISSING:'MISSING',/** File has been missing for a longer period. Candidate for restoration from archive. */LOST:'LOST',/** File will appear on file system/storage, transfer subsystem or transcoder will create it. */TO_APPEAR:'TO_APPEAR',/** The file is no longer in use, and will be deleted at the next clean-up sweep. */TO_BE_DELETED:'TO_BE_DELETED',/** File is in use by transfer subsystem or transcoder. */BEING_READ:'BEING_READ',/** File is archived. */ARCHIVED:'ARCHIVED',/** File will be synchronized by multi-site agent. */AWAITING_SYNC:'AWAITING_SYNC'};
|
|
584
|
-
|
|
585
|
-
/**
|
|
586
|
-
* Parses a VidiCore file object
|
|
587
|
-
*
|
|
588
|
-
* @remarks
|
|
589
|
-
* File sizes are parsed with JEDEC standard (base 2)
|
|
590
|
-
*
|
|
591
|
-
* @param fileType VidiCore file object
|
|
592
|
-
* @returns A parsed file object
|
|
593
|
-
*
|
|
594
|
-
* @category File
|
|
595
|
-
*/var parseFileType=function parseFileType(fileType){var _fileType$uri=fileType.uri,uriList=_fileType$uri===void 0?[]:_fileType$uri,fileSizeBytes=fileType.size,hash=fileType.hash,path=fileType.path,fileId=fileType.id;var _uriList=_slicedToArray(uriList,1),uri=_uriList[0];var fileSize=fileSizeBytes!==undefined?filesize(fileSizeBytes,{base:2,standard:'jedec'}):'';var fileName=path?path.split('/').pop():undefined;return {uri:uri,hash:hash,fileSize:fileSize,fileSizeBytes:fileSizeBytes,path:path,fileName:fileName,fileId:fileId};};
|
|
596
|
-
|
|
597
|
-
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;}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(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;}/**
|
|
598
|
-
* Parses the technical information of a BinaryComponentType.
|
|
599
|
-
* @param binaryComponentType - A BinaryComponentType from VidiCore.
|
|
600
|
-
* @returns Parsed component object.
|
|
601
|
-
*
|
|
602
|
-
* @category Shape
|
|
603
|
-
*/var parseBinaryComponent=function parseBinaryComponent(){var binaryComponentType=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var fileList=binaryComponentType.file,mediaInfo=binaryComponentType.mediaInfo,_binaryComponentType$=binaryComponentType.metadata,metadata=_binaryComponentType$===void 0?[]:_binaryComponentType$;var binaryMetadata=parseKeyValuePairTypes(metadata);var binaryMediaInfo=parseBaseMediaInfoType(mediaInfo);var parsedBinaryComponent={binaryMetadata:binaryMetadata,binaryMediaInfo:binaryMediaInfo};if(fileList){var _fileList=_slicedToArray(fileList,1),fileType=_fileList[0];var parsedFileType=parseFileType(fileType);parsedBinaryComponent=_objectSpread$3(_objectSpread$3({},parsedBinaryComponent),parsedFileType);}return parsedBinaryComponent;};
|
|
604
|
-
|
|
605
|
-
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;}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(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;}/**
|
|
606
|
-
* Parsed container component
|
|
607
|
-
*/ /**
|
|
608
|
-
* Parses the technical information of a ContainerComponentType.
|
|
609
|
-
* @param containerComponentType - A ContainerComponentType from VidiCore.
|
|
610
|
-
* @returns Parsed component object.
|
|
611
|
-
*
|
|
612
|
-
* @category Shape
|
|
613
|
-
*/var parseContainerComponent=function parseContainerComponent(){var containerComponentType=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var mediaInfo=containerComponentType.mediaInfo,metadata=containerComponentType.metadata,fileList=containerComponentType.file,durationTimeCode=containerComponentType.duration,startTimestamp=containerComponentType.startTimestamp,startTimecode=containerComponentType.startTimecode,timeCodeTimeBase=containerComponentType.timeCodeTimeBase;var containerMetadata=parseKeyValuePairTypes(metadata||[]);var containerMediaInfo=parseBaseMediaInfoType(mediaInfo);var containerFormat=containerMediaInfo.Format;var videoFormat=containerMediaInfo.Video_Format_List,audioFormat=containerMediaInfo.Audio_Format_List,textFormat=containerMediaInfo.Text_Format_List;if(containerFormat===undefined){var format=containerComponentType.format;containerFormat=format;if(format&&format.includes(',')){var formatList=format.split(',');var _formatList=_slicedToArray(formatList,1);containerFormat=_formatList[0];}}var parsedContainerComponentType={containerFormat:containerFormat,videoFormat:videoFormat,audioFormat:audioFormat,textFormat:textFormat,containerMetadata:containerMetadata,containerMediaInfo:containerMediaInfo};if(containerMetadata.componentOriginalFilename){parsedContainerComponentType.originalFilename=containerMetadata.componentOriginalFilename;}if(durationTimeCode!==undefined&&durationTimeCode.samples!==0){var timeCode=formatTimeCodeType(durationTimeCode);parsedContainerComponentType.durationTimeCode=timeCode.toObject();parsedContainerComponentType.duration=timeCode.toDuration();}if(startTimestamp){parsedContainerComponentType.startTimestamp=formatTimeCodeType(startTimestamp).toObject();}if(startTimecode!==undefined&&timeCodeTimeBase){parsedContainerComponentType.startTimecode=formatTimeCodeType({samples:startTimecode,timeBase:timeCodeTimeBase});}if(fileList){var _fileList=_slicedToArray(fileList,1),fileType=_fileList[0];var parsedFileType=parseFileType(fileType);parsedContainerComponentType=_objectSpread$2(_objectSpread$2({},parsedContainerComponentType),parsedFileType);}return parsedContainerComponentType;};
|
|
614
|
-
|
|
615
|
-
var bitRateSymbols={kB:'kbps',B:'bps',MB:'mbps'};/**
|
|
616
|
-
* Parses the technical information of a VideoComponentType.
|
|
617
|
-
* @param {Object} videoComponentType - A VideoComponentType from VidiCore.
|
|
618
|
-
* @returns {Object} Parsed component object.
|
|
619
|
-
*
|
|
620
|
-
* @category Shape
|
|
621
|
-
*/var parseVideoComponent=function parseVideoComponent(){var videoComponentType=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var videoCodec=videoComponentType.codec,bitrate=videoComponentType.bitrate,fieldOrder=videoComponentType.fieldOrder,resolution=videoComponentType.resolution,mediaInfo=videoComponentType.mediaInfo,_videoComponentType$m=videoComponentType.metadata,metadata=_videoComponentType$m===void 0?[]:_videoComponentType$m;var videoMediaInfo=parseVideoMediaInfoType(mediaInfo);var videoMetadata=parseKeyValuePairTypes(metadata);var videoFormat=videoMediaInfo.Format,timeBaseText=videoMediaInfo['Frame rate'],colorSpace=videoMediaInfo['Color space'],colorPrimaries=videoMediaInfo['Color primaries'],chromaSubsampling=videoMediaInfo.Colorimetry;var timeBase;var averageFrameRate=videoComponentType.averageFrameRate,realBaseFrameRate=videoComponentType.realBaseFrameRate;if(realBaseFrameRate!==undefined){timeBase=formatTimeBaseType({numerator:realBaseFrameRate.denominator,denominator:realBaseFrameRate.numerator});}else if(timeBaseText!==undefined){timeBase=formatTimeBaseText(timeBaseText);}else if(averageFrameRate!==undefined){timeBase=formatTimeBaseType({numerator:averageFrameRate.denominator,denominator:averageFrameRate.numerator});}var samples=videoMediaInfo['Frame count'];if(samples===undefined){var numberOfPackets=videoComponentType.numberOfPackets;if(numberOfPackets!==undefined)samples=numberOfPackets.toString();}var timeCode;var frameRate;var smpte;if(samples&&timeBase){timeCode=formatTimeCodeType({samples:samples,timeBase:timeBase});frameRate=timeCode.timeBase.toConstant()||timeCode.timeBase.toRate();smpte=timeCode.toSmpte();}var _ref=resolution||{},height=_ref.height,width=_ref.width;var aspectRatio=parseAspectRatio(resolution);var dimension="".concat(width,"x").concat(height);var videoBitrate;var videoBitrateMbps;if(bitrate!==undefined){var _split;videoBitrate=filesize(bitrate,{round:2,symbols:bitRateSymbols});videoBitrateMbps=Number((_split=filesize(bitrate,{exponent:2,symbols:bitRateSymbols}).split(' mbps'))===null||_split===void 0?void 0:_split[0]);}return {videoFormat:videoFormat,dimension:dimension,frameRate:frameRate,height:height,width:width,timeBase:timeBase,timeCode:timeCode,videoCodec:videoCodec,smpte:smpte,videoBitrate:videoBitrate,videoBitrateMbps:videoBitrateMbps,fieldOrder:fieldOrder,colorSpace:colorSpace,chromaSubsampling:chromaSubsampling,aspectRatio:aspectRatio,colorPrimaries:colorPrimaries,videoMetadata:videoMetadata,videoMediaInfo:videoMediaInfo};};
|
|
622
|
-
|
|
623
|
-
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;}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(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;}// eslint-disable-next-line import/no-cycle
|
|
624
|
-
/**
|
|
625
|
-
* Parses the technical information of a ShapeType and its various components.
|
|
626
|
-
*
|
|
627
|
-
* Will only parse the first videoComponent, audioComponent, binaryComponent in the corresponding array.
|
|
628
|
-
* To parse a selected component see:
|
|
629
|
-
* - {@link parseContainerComponent}
|
|
630
|
-
* - {@link parseVideoComponent}
|
|
631
|
-
* - {@link parseAudioComponent}
|
|
632
|
-
* - {@link parseBinaryComponent}
|
|
633
|
-
* @param shapeType - A ShapeType from VidiCore.
|
|
634
|
-
* @returns Parsed shape object.
|
|
635
|
-
*
|
|
636
|
-
* @category Shape
|
|
637
|
-
*/var parseShapeType=function parseShapeType(){var shapeType=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var parsedShape={};var containerComponent=shapeType.containerComponent,videoComponentList=shapeType.videoComponent,audioComponentList=shapeType.audioComponent,binaryComponentList=shapeType.binaryComponent,_shapeType$mimeType=shapeType.mimeType,mimeTypeList=_shapeType$mimeType===void 0?[]:_shapeType$mimeType,_shapeType$tag=shapeType.tag,tagList=_shapeType$tag===void 0?[]:_shapeType$tag;var _tagList=_slicedToArray(tagList,1);parsedShape.tag=_tagList[0];var _mimeTypeList=_slicedToArray(mimeTypeList,1);parsedShape.mimeType=_mimeTypeList[0];if(containerComponent){var parsedContainerComponent=parseContainerComponent(containerComponent);parsedShape=_objectSpread$1(_objectSpread$1({},parsedShape),parsedContainerComponent);}if(videoComponentList){var _videoComponentList=_slicedToArray(videoComponentList,1),videoComponent=_videoComponentList[0];var parsedVideoComponent=parseVideoComponent(videoComponent);parsedShape=_objectSpread$1(_objectSpread$1({},parsedShape),parsedVideoComponent);}if(audioComponentList){var _audioComponentList=_slicedToArray(audioComponentList,1),audioComponent=_audioComponentList[0];var parsedAudioComponent=parseAudioComponent(audioComponent);parsedShape=_objectSpread$1(_objectSpread$1({},parsedShape),parsedAudioComponent);}if(binaryComponentList){var _binaryComponentList=_slicedToArray(binaryComponentList,1),binaryComponent=_binaryComponentList[0];var parsedBinaryComponent=parseBinaryComponent(binaryComponent);parsedShape=_objectSpread$1(_objectSpread$1({},parsedShape),parsedBinaryComponent);}return parsedShape;};
|
|
638
|
-
|
|
639
|
-
/**
|
|
640
|
-
* Const object with document types
|
|
641
|
-
*
|
|
642
|
-
* @category Shape
|
|
643
|
-
*/var DOCUMENT_TYPES={PDF:'PDF',TEXT:'TEXT',MSWORD:'MSWORD',JSON:'JSON',XML:'XML'};
|
|
644
|
-
|
|
645
|
-
/**
|
|
646
|
-
* Const object with media types
|
|
647
|
-
*
|
|
648
|
-
* @category Shape
|
|
649
|
-
*/var SHAPE_MEDIA_TYPES={IMAGE:'IMAGE',AUDIO:'AUDIO',VIDEO:'VIDEO',DOCUMENT:'DOCUMENT',BINARY:'BINARY'};
|
|
650
|
-
|
|
651
|
-
// eslint-disable-next-line import/no-cycle
|
|
652
|
-
/**
|
|
653
|
-
* Return a const for the document type of a shape (looks at mimeType)
|
|
654
|
-
*
|
|
655
|
-
* @param shape A VidiCore shape
|
|
656
|
-
* @returns The document type for a shape
|
|
657
|
-
*
|
|
658
|
-
* @category Shape
|
|
659
|
-
*/var getShapeDocumentType=function getShapeDocumentType(){var shape=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};// shapeType.mimeType is always a string array,
|
|
660
|
-
// but accepts passing in { mimeType: string } for backwards compatibility
|
|
661
|
-
var mimeTypeArrayOrString=shape.mimeType;var mimeType=Array.isArray(mimeTypeArrayOrString)?mimeTypeArrayOrString[0]:mimeTypeArrayOrString;if(!mimeType)return undefined;if(mimeType.endsWith('/pdf'))return DOCUMENT_TYPES.PDF;if(mimeType.startsWith('text/'))return DOCUMENT_TYPES.TEXT;if(mimeType.endsWith('/msword'))return DOCUMENT_TYPES.MSWORD;if(mimeType.endsWith('/json'))return DOCUMENT_TYPES.JSON;if(mimeType.endsWith('/xml'))return DOCUMENT_TYPES.XML;return undefined;};
|
|
662
|
-
|
|
663
|
-
var IMAGE_MIME_TYPES=['image/apng','image/bmp','image/gif','image/jpeg','image/x-icon','image/png','image/svg+xml'];var VIDEO_MIME_TYPES=['video/mp4'];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'];var DEFAULT_ALLOWED_MIME_TYPES=[].concat(VIDEO_MIME_TYPES,IMAGE_MIME_TYPES,AUDIO_MIME_TYPES);var DEFAULT_ALLOWED_METHODS=['http','https'];var MP4_MIMETYPE='video/mp4';var QUICKTIME_MIMETYPE='video/quicktime';var M4V_MIMETYPE='video/x-m4v';var MP4_CONTAINER='MPEG-4';var MOV_CONTAINER='mov';var H264_CODEC='h264';// Sort by tags in the order of previewShapeOrder, secondary alphabetical.
|
|
664
|
-
// using reverse() so the first has highest index
|
|
665
|
-
var PREVIEW_SHAPE_ORDER=['__mp4','__mp3_160k','__png','__jpeg','__gif','original'].reverse();var defaultSortPriority=function defaultSortPriority(_ref,_ref2){var firstEl=_ref.parsedShape.tag;var secondEl=_ref2.parsedShape.tag;if(PREVIEW_SHAPE_ORDER.includes(firstEl)||PREVIEW_SHAPE_ORDER.includes(secondEl)){return PREVIEW_SHAPE_ORDER.indexOf(secondEl)-PREVIEW_SHAPE_ORDER.indexOf(firstEl);}return firstEl.toLowerCase().localeCompare(secondEl.toLowerCase());};/**
|
|
666
|
-
* Filter a shape type list to get shapes that are playable in a browser
|
|
667
|
-
*
|
|
668
|
-
* @param itemType
|
|
669
|
-
* @param options
|
|
670
|
-
* @returns
|
|
671
|
-
*
|
|
672
|
-
* @category Shape
|
|
673
|
-
*/var filterShapeSource=function filterShapeSource(itemType,options){var _ref3=options||{},_ref3$allowedMimeType=_ref3.allowedMimeTypes,allowedMimeTypes=_ref3$allowedMimeType===void 0?DEFAULT_ALLOWED_MIME_TYPES:_ref3$allowedMimeType,_ref3$allowedMethods=_ref3.allowedMethods,allowedMethods=_ref3$allowedMethods===void 0?DEFAULT_ALLOWED_METHODS:_ref3$allowedMethods,_ref3$sortPriority=_ref3.sortPriority,sortPriority=_ref3$sortPriority===void 0?defaultSortPriority:_ref3$sortPriority,_ref3$sourceKey=_ref3.sourceKey,sourceKey=_ref3$sourceKey===void 0?'src':_ref3$sourceKey,_ref3$mimeTypeKey=_ref3.mimeTypeKey,mimeTypeKey=_ref3$mimeTypeKey===void 0?'type':_ref3$mimeTypeKey,_ref3$shapeKey=_ref3.shapeKey,shapeKey=_ref3$shapeKey===void 0?'shape':_ref3$shapeKey,_ref3$parsedShapeKey=_ref3.parsedShapeKey,parsedShapeKey=_ref3$parsedShapeKey===void 0?'parsedShape':_ref3$parsedShapeKey;var _ref4=itemType||{},_ref4$shape=_ref4.shape,shapeList=_ref4$shape===void 0?[]:_ref4$shape;var filteredShapeList=shapeList.reduce(function(acc,shapeType){var type;var src;var parsedShape=parseShapeType(shapeType);var uri=parsedShape.uri,mimeType=parsedShape.mimeType,containerFormat=parsedShape.containerFormat,videoCodec=parsedShape.videoCodec;if(mimeType){type=mimeType;if((mimeType===QUICKTIME_MIMETYPE||mimeType===M4V_MIMETYPE)&&(containerFormat===MP4_CONTAINER||containerFormat===MOV_CONTAINER)&&videoCodec===H264_CODEC)type=MP4_MIMETYPE;}if(uri){if(allowedMethods){var _uri$split=uri.split('://'),_uri$split2=_slicedToArray(_uri$split,1),thisMethod=_uri$split2[0];if(allowedMethods.includes(thisMethod))src=uri;}else {src=uri;}}if(src&&allowedMimeTypes.includes(type)){var _acc$push;acc.push((_acc$push={},_defineProperty(_acc$push,sourceKey,src),_defineProperty(_acc$push,mimeTypeKey,type),_defineProperty(_acc$push,shapeKey,shapeType),_defineProperty(_acc$push,parsedShapeKey,parsedShape),_acc$push));}return acc;},[]);if(typeof sortPriority==='function')filteredShapeList.sort(defaultSortPriority);return filteredShapeList;};
|
|
674
|
-
|
|
675
|
-
/**
|
|
676
|
-
* Returns a const for which media type a shape has
|
|
677
|
-
*
|
|
678
|
-
* @param shape
|
|
679
|
-
* @returns
|
|
680
|
-
*
|
|
681
|
-
* @category Shape
|
|
682
|
-
*/var getShapeMediaType=function getShapeMediaType(shape){var parsedShape=parseShapeType(shape);var mimeType=parsedShape.mimeType,videoCodec=parsedShape.videoCodec,audioCodec=parsedShape.audioCodec;if(!mimeType)return undefined;if(mimeType.startsWith('audio/')){if(audioCodec!==undefined)return SHAPE_MEDIA_TYPES.AUDIO;}if(mimeType.startsWith('video/')){if(videoCodec!==undefined)return SHAPE_MEDIA_TYPES.VIDEO;if(audioCodec!==undefined)return SHAPE_MEDIA_TYPES.AUDIO;}if(mimeType.startsWith('image/'))return SHAPE_MEDIA_TYPES.IMAGE;if(mimeType.endsWith('/pdf'))return SHAPE_MEDIA_TYPES.DOCUMENT;if(mimeType.startsWith('text/'))return SHAPE_MEDIA_TYPES.DOCUMENT;if(mimeType.endsWith('/msword'))return SHAPE_MEDIA_TYPES.DOCUMENT;if(mimeType.endsWith('/json'))return SHAPE_MEDIA_TYPES.DOCUMENT;if(mimeType.endsWith('/xml'))return SHAPE_MEDIA_TYPES.DOCUMENT;if(mimeType.endsWith('/octet-stream'))return SHAPE_MEDIA_TYPES.BINARY;return undefined;};
|
|
683
|
-
|
|
684
|
-
/**
|
|
685
|
-
* Find the thumbnail uri in a VidiCore item object that's nearest a timeCode
|
|
686
|
-
*
|
|
687
|
-
* @remarks
|
|
688
|
-
* Time code is included in path of VidiCore thumbnail uris
|
|
689
|
-
*
|
|
690
|
-
* @param itemType A VidiCore item object
|
|
691
|
-
* @param timeCode A timeCode to find nearest thumbnail to
|
|
692
|
-
* @returns A URI of a thumbnail, `undefined` if item has no thumbnails
|
|
693
|
-
*
|
|
694
|
-
* @category Thumbnail
|
|
695
|
-
*/var findNearestThumbnail=function findNearestThumbnail(itemType,timeCode){var tcSeconds=createTimeCode(timeCode).toSeconds();var _ref=itemType||{},_ref$thumbnails=_ref.thumbnails,thumbnails=_ref$thumbnails===void 0?{}:_ref$thumbnails;var _thumbnails$uri=thumbnails.uri,srcList=_thumbnails$uri===void 0?[]:_thumbnails$uri;var srcTcSeconds=srcList.map(function(url){var tc=new URL(url).pathname.split('/').pop();return formatTimeCodeText(tc).toSeconds();});var nearestSrcIndex=srcTcSeconds.reduce(function(nearestIndex,curr,currIndex){return Math.abs(curr-tcSeconds)<Math.abs(srcTcSeconds[nearestIndex]-tcSeconds)?currIndex:nearestIndex;},0);return srcList[nearestSrcIndex];};
|
|
696
|
-
|
|
697
|
-
var _excluded=["Codec"],_excluded2=["Codec"];/**
|
|
698
|
-
* TODO
|
|
699
|
-
*/ /**
|
|
700
|
-
* TODO
|
|
701
|
-
*
|
|
702
|
-
* @param mediaconvert
|
|
703
|
-
* @returns
|
|
704
|
-
*
|
|
705
|
-
* @category Transcode
|
|
706
|
-
*/var parseMediaConvertPreset=function parseMediaConvertPreset(mediaconvert){var output={};var _ref=mediaconvert||{},_ref$outputSetting=_ref.outputSetting,outputSetting=_ref$outputSetting===void 0?[]:_ref$outputSetting;if(outputSetting.length===0)return output;var mc=JSON.parse(outputSetting[0]);var _mc$Settings=mc.Settings;_mc$Settings=_mc$Settings===void 0?{}:_mc$Settings;var ContainerSettings=_mc$Settings.ContainerSettings,VideoDescription=_mc$Settings.VideoDescription,AudioDescriptions=_mc$Settings.AudioDescriptions;if(ContainerSettings){output.containerFormat=ContainerSettings.Container;}if(VideoDescription){var _VideoDescription$Cod=VideoDescription.CodecSettings,CodecSettings=_VideoDescription$Cod===void 0?{}:_VideoDescription$Cod;var Codec=CodecSettings.Codec,otherSettings=_objectWithoutProperties(CodecSettings,_excluded);output.videoFormat=Codec;var height=VideoDescription.Height,width=VideoDescription.Width;output.height=height;output.width=width;if(height&&width){output.dimension="".concat(width,"x").concat(height);output.aspectRatio=parseAspectRatio({height:height,width:width});}var _Object$values=Object.values(otherSettings),_Object$values2=_slicedToArray(_Object$values,1),codecSpecs=_Object$values2[0];if(codecSpecs){output.fieldOrder=codecSpecs.InterlaceMode;if(output.fieldOrder&&output.fieldOrder.includes('TOP'))output.fieldOrder='interlaced';output.videoBitrate=codecSpecs.Bitrate;var numerator=codecSpecs.FramerateDenominator;// other way round to vs ¯\_(ツ)_/¯
|
|
707
|
-
var denominator=codecSpecs.FramerateNumerator;var timeBase=formatTimeBaseType({denominator:denominator,numerator:numerator});output.timeBase=timeBase;output.frameRate=timeBase.toConstant()||timeBase.toRate();}}if(AudioDescriptions&&AudioDescriptions.length>0){var _AudioDescriptions$0$=AudioDescriptions[0].CodecSettings,_CodecSettings=_AudioDescriptions$0$===void 0?{}:_AudioDescriptions$0$;var _Codec=_CodecSettings.Codec,_otherSettings=_objectWithoutProperties(_CodecSettings,_excluded2);output.audioFormat=_Codec;var _Object$values3=Object.values(_otherSettings),_Object$values4=_slicedToArray(_Object$values3,1),_codecSpecs=_Object$values4[0];if(_codecSpecs){output.audioSamplerate=_codecSpecs.SampleRate;output.audioBitrate=_codecSpecs.Bitrate;output.audioBitRateMode=_codecSpecs.RateControlMode;}}return output;};
|
|
708
|
-
|
|
709
|
-
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;}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(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;}/**
|
|
710
|
-
* Parse a VidiCore transcode preset
|
|
711
|
-
*
|
|
712
|
-
* @param transcodePresetType a VidiCore transcode preset
|
|
713
|
-
* @returns A parsed transcode preset
|
|
714
|
-
*
|
|
715
|
-
* @category Transcode
|
|
716
|
-
*/var parseTranscodePreset=function parseTranscodePreset(transcodePresetType){var output={};var _ref=transcodePresetType||{},description=_ref.description,format=_ref.format,audio=_ref.audio,video=_ref.video,mediaconvert=_ref.mediaconvert;if(mediaconvert)return _objectSpread({description:description},parseMediaConvertPreset(mediaconvert));output.description=description;output.containerFormat=format;if(video){output.videoFormat=video.codec;output.videoBitrate=video.bitrate;if(video.framerate){var timeBase=formatTimeBaseType(video.framerate);output.timeBase=timeBase;output.frameRate=timeBase.toConstant()||timeBase.toRate();}if(video.scaling){var _video$scaling=video.scaling,height=_video$scaling.height,width=_video$scaling.width;output.height=height;output.width=width;if(height&&width){output.dimension="".concat(width,"x").concat(height);output.aspectRatio=parseAspectRatio({height:height,width:width});}}}if(audio){var audioFormat=audio.codec,channel=audio.channel;output.audioFormat=audioFormat;if(channel)output.audioChannels=channel.length;}return output;};
|
|
717
|
-
|
|
718
|
-
export { DOCUMENT_TYPES, FIELD_ATTRIBUTE_KEYS, FIELD_VALUE_ATTRIBUTE_KEYS, FILE_STATES, GROUP_ATTRIBUTE_KEYS, ROLE_NAMES, SHAPE_MEDIA_TYPES, SYSTEM_FIELDGROUPS, SYSTEM_FIELDS, TimeBase, TimeCode, createFacetType, createMetadataType, createTimeBase, createTimeCode, filterShapeSource, findNearestThumbnail, formatTimeBaseText, formatTimeBaseType, formatTimeCodeSeconds, formatTimeCodeSmpte, formatTimeCodeText, formatTimeCodeType, getShapeDocumentType, getShapeMediaType, metadataTypeToWebVtt, parseAudioComponent, parseBinaryComponent, parseContainerComponent, parseFacetType, parseFieldList, parseFileType, parseGroupList, parseHighlightTimespan, parseHighlightTimespanList, parseKeyValuePairTypes as parseKeyValuePairType, parseMediaConvertPreset, parseMetadataType, parseNowDate, parseShapeType, parseSimpleMetadataType, parseTimespan, parseTimespanList, parseTranscodePreset, parseVideoComponent };
|
|
719
|
-
//# sourceMappingURL=index.es.js.map
|