@vidispine/vdt-js 22.4.0 → 23.1.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 +91 -20
- package/dist/index.es.js +264 -2363
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +285 -2382
- package/dist/index.js.map +1 -1
- package/package.json +8 -8
package/dist/index.es.js
CHANGED
|
@@ -5,27 +5,9 @@ import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
|
5
5
|
import _typeof from '@babel/runtime/helpers/typeof';
|
|
6
6
|
import _classCallCheck from '@babel/runtime/helpers/classCallCheck';
|
|
7
7
|
import _createClass from '@babel/runtime/helpers/createClass';
|
|
8
|
-
import
|
|
8
|
+
import { filesize } from 'filesize';
|
|
9
9
|
|
|
10
|
-
var gcd
|
|
11
|
-
return b ? gcd(b, a % b) : a;
|
|
12
|
-
};
|
|
13
|
-
var parseAspectRatio = function parseAspectRatio(aspectRatio) {
|
|
14
|
-
var _ref = aspectRatio || {},
|
|
15
|
-
width = _ref.width,
|
|
16
|
-
height = _ref.height;
|
|
17
|
-
if (width === undefined || height === undefined) {
|
|
18
|
-
return undefined;
|
|
19
|
-
}
|
|
20
|
-
var denominator = gcd(width, height);
|
|
21
|
-
var widthRatio = width / denominator;
|
|
22
|
-
var heightRatio = height / denominator;
|
|
23
|
-
if (widthRatio > 21) {
|
|
24
|
-
heightRatio = 1;
|
|
25
|
-
widthRatio = (width / height).toFixed(2);
|
|
26
|
-
}
|
|
27
|
-
return [widthRatio, heightRatio].join(':');
|
|
28
|
-
};
|
|
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(':');};
|
|
29
11
|
|
|
30
12
|
/**
|
|
31
13
|
*
|
|
@@ -33,342 +15,54 @@ var parseAspectRatio = function parseAspectRatio(aspectRatio) {
|
|
|
33
15
|
* @returns
|
|
34
16
|
*
|
|
35
17
|
* @category Other
|
|
36
|
-
*/
|
|
37
|
-
var parseKeyValuePairTypes = function parseKeyValuePairTypes(keyValuePairTypes) {
|
|
38
|
-
return Object.fromEntries(keyValuePairTypes.map(function (_ref) {
|
|
39
|
-
var key = _ref.key,
|
|
40
|
-
value = _ref.value;
|
|
41
|
-
return [key, value];
|
|
42
|
-
}));
|
|
43
|
-
};
|
|
18
|
+
*/var parseKeyValuePairTypes=function parseKeyValuePairTypes(keyValuePairTypes){return Object.fromEntries(keyValuePairTypes.map(function(_ref){var key=_ref.key,value=_ref.value;return [key,value];}));};
|
|
44
19
|
|
|
45
20
|
/**
|
|
46
|
-
*
|
|
21
|
+
* Const object with VidiCore role names
|
|
47
22
|
*
|
|
48
23
|
* @category Auth
|
|
49
|
-
*/
|
|
50
|
-
var ROLE_NAMES = {
|
|
51
|
-
ACCESSCONTROL_READ: '_accesscontrol_read',
|
|
52
|
-
ACCESSCONTROL_WRITE: '_accesscontrol_write',
|
|
53
|
-
ADMINISTRATOR: '_administrator',
|
|
54
|
-
AUTO_PROJECTION_READ: '_auto_projection_read',
|
|
55
|
-
AUTO_PROJECTION_WRITE: '_auto_projection_write',
|
|
56
|
-
COLLECTION_NOTIFICATION_READ: '_collection_notification_read',
|
|
57
|
-
COLLECTION_NOTIFICATION_WRITE: '_collection_notification_write',
|
|
58
|
-
COLLECTION_READ: '_collection_read',
|
|
59
|
-
COLLECTION_WRITE: '_collection_write',
|
|
60
|
-
CONFIGURATION_READ: '_configuration_read',
|
|
61
|
-
DELETION_LOCK_NOTIFICATION_READ: '_deletion_lock_notification_read',
|
|
62
|
-
DELETION_LOCK_NOTIFICATION_WRITE: '_deletion_lock_notification_write',
|
|
63
|
-
DELETION_LOCK_READ: '_deletion_lock_read',
|
|
64
|
-
DELETION_LOCK_WRITE: '_deletion_lock_write',
|
|
65
|
-
DOCUMENT_NOTIFICATION_READ: '_document_notification_read',
|
|
66
|
-
DOCUMENT_NOTIFICATION_WRITE: '_document_notification_write',
|
|
67
|
-
DOCUMENT_READ: '_document_read',
|
|
68
|
-
DOCUMENT_WRITE: '_document_write',
|
|
69
|
-
ERROR_READ: '_error_read',
|
|
70
|
-
ERROR_WRITE: '_error_write',
|
|
71
|
-
EXPORT: '_export',
|
|
72
|
-
EXPORT_TEMPLATE_READ: '_export_template_read',
|
|
73
|
-
EXPORT_TEMPLATE_WRITE: '_export_template_write',
|
|
74
|
-
EXTERNAL_ID_READ: '_external_id_read',
|
|
75
|
-
EXTERNAL_ID_WRITE: '_external_id_write',
|
|
76
|
-
FILE_NOTIFICATION_READ: '_file_notification_read',
|
|
77
|
-
FILE_NOTIFICATION_WRITE: '_file_notification_write',
|
|
78
|
-
FILE_READ: '_file_read',
|
|
79
|
-
FILE_WRITE: '_file_write',
|
|
80
|
-
GROUP_READ: '_group_read',
|
|
81
|
-
GROUP_WRITE: '_group_write',
|
|
82
|
-
IMPORT_WRITE: '_import',
|
|
83
|
-
ITEM_ID_READ: '_item_id_read',
|
|
84
|
-
ITEM_ID_WRITE: '_item_id_write',
|
|
85
|
-
ITEM_NOTIFICATION_READ: '_item_notification_read',
|
|
86
|
-
ITEM_NOTIFICATION_WRITE: '_item_notification_write',
|
|
87
|
-
ITEM_WRITE: '_item_write',
|
|
88
|
-
ITEM_SEARCH: '_item_search',
|
|
89
|
-
ITEM_SHAPE_READ: '_item_shape_read',
|
|
90
|
-
ITEM_SHAPE_WRITE: '_item_shape_write',
|
|
91
|
-
ITEM_TIMELINE_READ: '_item_timeline_read',
|
|
92
|
-
ITEM_TIMELINE_WRITE: '_item_timeline_write',
|
|
93
|
-
ITEM_URI: '_item_uri',
|
|
94
|
-
JOB_NOTIFICATION_READ: '_job_notification_read',
|
|
95
|
-
JOB_NOTIFICATION_WRITE: '_job_notification_write',
|
|
96
|
-
JOB_READ: '_job_read',
|
|
97
|
-
JOB_WRITE: '_job_write',
|
|
98
|
-
LIBRARY_READ: '_library_read',
|
|
99
|
-
LIBRARY_WRITE: '_library_write',
|
|
100
|
-
LOCK_READ: '_lock_read',
|
|
101
|
-
LOCK_WRITE: '_lock_write',
|
|
102
|
-
LOG_READ: '_log_read',
|
|
103
|
-
METADATA_DATASET_READ: '_metadata_dataset_read',
|
|
104
|
-
METADATA_DATASET_WRITE: '_metadata_dataset_write',
|
|
105
|
-
METADATA_FIELD_GROUP_READ: '_metadata_field_group_read',
|
|
106
|
-
METADATA_FIELD_GROUP_WRITE: '_metadata_field_group_write',
|
|
107
|
-
METADATA_FIELD_READ: '_metadata_field_read',
|
|
108
|
-
METADATA_FIELD_WRITE: '_metadata_field_write',
|
|
109
|
-
METADATA_GLOBAL_READ: '_metadata_global_read',
|
|
110
|
-
METADATA_GLOBAL_WRITE: '_metadata_global_write',
|
|
111
|
-
METADATA_LOCK_READ: '_metadata_lock_read',
|
|
112
|
-
METADATA_LOCK_WRITE: '_metadata_lock_write',
|
|
113
|
-
METADATA_READ: '_metadata_read',
|
|
114
|
-
METADATA_SCHEMA_READ: '_metadata_schema_read',
|
|
115
|
-
METADATA_SCHEMA_WRITE: '_metadata_schema_write',
|
|
116
|
-
METADATA_WRITE: '_metadata_write',
|
|
117
|
-
OTIF_ANALYZE: '_otif_analyze',
|
|
118
|
-
OTIF_READ: '_otif_read',
|
|
119
|
-
OTIF_WRITE: '_otif_write',
|
|
120
|
-
PLACEHOLDER_NOTIFICATION_READ: '_placeholder_notification_read',
|
|
121
|
-
PLACEHOLDER_NOTIFICATION_WRITE: '_placeholder_notification_write',
|
|
122
|
-
PROJECTION_READ: '_projection_read',
|
|
123
|
-
PROJECTION_WRITE: '_projection_write',
|
|
124
|
-
QUOTA_NOTIFICATION_READ: '_quota_notification_read',
|
|
125
|
-
QUOTA_NOTIFICATION_WRITE: '_quota_notification_write',
|
|
126
|
-
QUOTA_READ: '_quota_read',
|
|
127
|
-
QUOTA_WRITE: '_quota_write',
|
|
128
|
-
RELATION_READ: '_relation_read',
|
|
129
|
-
RELATION_WRITE: '_relation_write',
|
|
130
|
-
RESOURCE_READ: '_resource_read',
|
|
131
|
-
RESOURCE_WRITE: '_resource_write',
|
|
132
|
-
RUN_AS: '_run_as',
|
|
133
|
-
SEARCH: '_search',
|
|
134
|
-
SEQUENCE_READ: '_sequence_read',
|
|
135
|
-
SEQUENCE_WRITE: '_sequence_write',
|
|
136
|
-
SHAPE_TAG_READ: '_shape_tag_read',
|
|
137
|
-
SHAPE_TAG_WRITE: '_shape_tag_write',
|
|
138
|
-
SITE_MANAGER: '_site_manager',
|
|
139
|
-
SITE_RULE_READ: '_site_rule_read',
|
|
140
|
-
SITE_RULE_WRITE: '_site_rule_write',
|
|
141
|
-
STORAGE_GROUP_READ: '_storage_group_read',
|
|
142
|
-
STORAGE_GROUP_WRITE: '_storage_group_write',
|
|
143
|
-
STORAGE_NOTIFICATION_READ: '_storage_notification_read',
|
|
144
|
-
STORAGE_NOTIFICATION_WRITE: '_storage_notification_write',
|
|
145
|
-
STORAGE_READ: '_storage_read',
|
|
146
|
-
STORAGE_RULE_READ: '_storage_rule_read',
|
|
147
|
-
STORAGE_RULE_WRITE: '_storage_rule_write',
|
|
148
|
-
STORAGE_WRITE: '_storage_write',
|
|
149
|
-
SUPER_ACCESS_USER: '_super_access_user',
|
|
150
|
-
TASKDEFINITION_READ: '_taskdefinition_read',
|
|
151
|
-
TASKDEFINITION_WRITE: '_taskdefinition_write',
|
|
152
|
-
THUMBNAIL_READ: '_thumbnail_read',
|
|
153
|
-
THUMBNAIL_WRITE: '_thumbnail_write',
|
|
154
|
-
TRANSCODER: '_transcoder',
|
|
155
|
-
TRANSFER_READ: '_transfer_read',
|
|
156
|
-
TRANSFER_WRITE: '_transfer_write',
|
|
157
|
-
USER: '_user',
|
|
158
|
-
VXA: '_vxa',
|
|
159
|
-
VXA_READ: '_vxa_read'
|
|
160
|
-
};
|
|
161
|
-
|
|
162
|
-
var SHARED_ATTRIBUTE_KEYS = ['uuid', 'user', 'timestamp', 'change', 'conflict', 'mode'];
|
|
163
|
-
var SHARED_FIELD_AND_GROUP_ATTRIBUTE_KEYS = ['name', 'id', 'referenced', 'data', 'inheritance'];
|
|
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'};
|
|
164
25
|
|
|
165
26
|
/**
|
|
166
|
-
* Array with all available
|
|
27
|
+
* Array with all available VidiCore system/default field group names
|
|
167
28
|
*
|
|
168
29
|
* @category Metadata
|
|
169
|
-
*/
|
|
170
|
-
var GROUP_ATTRIBUTE_KEYS = [].concat(SHARED_ATTRIBUTE_KEYS, SHARED_FIELD_AND_GROUP_ATTRIBUTE_KEYS, ['cycle', 'field', 'group']);
|
|
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'];
|
|
171
31
|
|
|
172
32
|
/**
|
|
173
|
-
* Array with all available
|
|
33
|
+
* Array with all available VidiCore system/default field names (including transient)
|
|
174
34
|
*
|
|
175
35
|
* @category Metadata
|
|
176
|
-
*/
|
|
177
|
-
|
|
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'];
|
|
178
39
|
|
|
179
40
|
/**
|
|
180
41
|
* Array with all available metadata field value attributes
|
|
181
42
|
*
|
|
182
43
|
* @category Metadata
|
|
183
|
-
*/
|
|
184
|
-
var FIELD_VALUE_ATTRIBUTE_KEYS = [].concat(SHARED_ATTRIBUTE_KEYS, ['value', 'lang']);
|
|
44
|
+
*/var FIELD_VALUE_ATTRIBUTE_KEYS=[].concat(_toConsumableArray(SHARED_ATTRIBUTE_KEYS),['value','lang']);
|
|
185
45
|
|
|
186
46
|
/**
|
|
187
|
-
* Array with all available
|
|
47
|
+
* Array with all available metadata field attributes
|
|
188
48
|
*
|
|
189
49
|
* @category Metadata
|
|
190
|
-
*/
|
|
191
|
-
var SYSTEM_FIELDGROUPS = ['stl_subtitle', 'stl_tti', 'stl_gsi', 'mrk_marker', 'pho_validation', 'pho_resource', 'pho_error', 'facedetect_rect', 'facedetect_face', 'originalTrackFilename', 'stl_gsiHeader'];
|
|
50
|
+
*/var FIELD_ATTRIBUTE_KEYS=[].concat(_toConsumableArray(SHARED_ATTRIBUTE_KEYS),_toConsumableArray(SHARED_FIELD_AND_GROUP_ATTRIBUTE_KEYS),['value','reference','type','track']);
|
|
192
51
|
|
|
193
52
|
/**
|
|
194
|
-
* Array with all available
|
|
53
|
+
* Array with all available metadata group attributes
|
|
195
54
|
*
|
|
196
55
|
* @category Metadata
|
|
197
|
-
*/
|
|
198
|
-
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'];
|
|
56
|
+
*/var GROUP_ATTRIBUTE_KEYS=[].concat(_toConsumableArray(SHARED_ATTRIBUTE_KEYS),_toConsumableArray(SHARED_FIELD_AND_GROUP_ATTRIBUTE_KEYS),['cycle','field','group']);
|
|
199
57
|
|
|
200
|
-
var _excluded$e = ["value"],
|
|
201
|
-
_excluded2$2 = ["start", "end", "base"];
|
|
202
|
-
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; }
|
|
203
|
-
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; }
|
|
204
|
-
var isValueObject = function isValueObject(o) {
|
|
205
|
-
return Object.prototype.toString.call(o) === '[object Object]' && o.value !== undefined;
|
|
206
|
-
};
|
|
207
|
-
var isFieldType = function isFieldType(v) {
|
|
208
|
-
return ['string', 'boolean', 'number'].includes(_typeof(v));
|
|
209
|
-
};
|
|
210
|
-
var isFieldObject = function isFieldObject(o) {
|
|
211
|
-
return isValueObject(o) && ((o === null || o === void 0 ? void 0 : o.value) === null || isValueObject(o.value) || isFieldType(o.value));
|
|
212
|
-
};
|
|
213
|
-
var isObject = function isObject(o) {
|
|
214
|
-
return Object.prototype.toString.call(o) === '[object Object]';
|
|
215
|
-
};
|
|
216
|
-
var isDate = function isDate(o) {
|
|
217
|
-
return Object.prototype.toString.call(o) === '[object Date]';
|
|
218
|
-
};
|
|
219
|
-
var isField = function isField(value) {
|
|
220
|
-
if (value === null) {
|
|
221
|
-
return true;
|
|
222
|
-
}
|
|
223
|
-
if (Array.isArray(value)) {
|
|
224
|
-
return value.some(isField);
|
|
225
|
-
}
|
|
226
|
-
return isFieldType(value) || isFieldObject(value) || isDate(value);
|
|
227
|
-
};
|
|
228
|
-
var isGroup = function isGroup(value) {
|
|
229
|
-
var isGroupObject = function isGroupObject(v) {
|
|
230
|
-
return isObject(v) && v.value === undefined && !!Object.entries(value);
|
|
231
|
-
};
|
|
232
|
-
if (Array.isArray(value)) {
|
|
233
|
-
return value.every(isGroup);
|
|
234
|
-
}
|
|
235
|
-
return isGroupObject(value);
|
|
236
|
-
};
|
|
237
|
-
var tryPluralize = function tryPluralize(str, arr) {
|
|
238
|
-
return str + (arr.length > 1 ? 's' : '');
|
|
239
|
-
};
|
|
240
|
-
var ensureKeysAreValid = function ensureKeysAreValid(keysToCheck, keysToMatch) {
|
|
241
|
-
var unsupportedKeys = keysToCheck.filter(function (k) {
|
|
242
|
-
return !keysToMatch.includes(k);
|
|
243
|
-
});
|
|
244
|
-
if (unsupportedKeys.length) {
|
|
245
|
-
throw Error("Unsupported ".concat(tryPluralize('key', unsupportedKeys), " (").concat(unsupportedKeys.join(', '), ")"));
|
|
246
|
-
}
|
|
247
|
-
};
|
|
248
|
-
var parseValue$1 = function parseValue(value) {
|
|
249
|
-
if (Array.isArray(value)) {
|
|
250
|
-
throw Error('Invalid value inside value object, cannot be array');
|
|
251
|
-
}
|
|
252
|
-
if ([undefined, null].includes(value)) return {};
|
|
253
|
-
if (isDate(value)) return {
|
|
254
|
-
value: value.toISOString()
|
|
255
|
-
};
|
|
256
|
-
return {
|
|
257
|
-
value: value.toString()
|
|
258
|
-
};
|
|
259
|
-
};
|
|
260
|
-
var parseValueObject = function parseValueObject(valueObject) {
|
|
261
|
-
ensureKeysAreValid(Object.keys(valueObject), FIELD_VALUE_ATTRIBUTE_KEYS);
|
|
262
|
-
if (Object.keys(valueObject).length === 0) {
|
|
263
|
-
throw Error('Invalid value object, cannot be empty object');
|
|
264
|
-
}
|
|
265
|
-
if (typeof (valueObject === null || valueObject === void 0 ? void 0 : valueObject.value) === 'string') {
|
|
266
|
-
return valueObject;
|
|
267
|
-
}
|
|
268
|
-
var parsedValue = parseValue$1(valueObject === null || valueObject === void 0 ? void 0 : valueObject.value);
|
|
269
|
-
return _objectSpread$i(_objectSpread$i({}, valueObject), parsedValue !== undefined ? parsedValue : {});
|
|
270
|
-
};
|
|
271
|
-
var parseFieldValue = function parseFieldValue(value) {
|
|
272
|
-
if ([undefined, null].includes(value)) return undefined;
|
|
273
|
-
if (Array.isArray(value)) return value.flatMap(parseFieldValue);
|
|
274
|
-
if (isValueObject(value)) return parseValueObject(value);
|
|
275
|
-
return parseValue$1(value);
|
|
276
|
-
};
|
|
277
|
-
var parseFieldObject = function parseFieldObject(fieldObject) {
|
|
278
|
-
ensureKeysAreValid(Object.keys(fieldObject), FIELD_ATTRIBUTE_KEYS);
|
|
279
|
-
var parsedFieldValue = parseFieldValue(fieldObject === null || fieldObject === void 0 ? void 0 : fieldObject.value);
|
|
280
|
-
if (parsedFieldValue === undefined) {
|
|
281
|
-
fieldObject.value;
|
|
282
|
-
var fieldObjectWithoutValue = _objectWithoutProperties(fieldObject, _excluded$e);
|
|
283
|
-
return fieldObjectWithoutValue;
|
|
284
|
-
}
|
|
285
|
-
return _objectSpread$i(_objectSpread$i({}, fieldObject), {}, {
|
|
286
|
-
value: _toConsumableArray(Array.isArray(parsedFieldValue) ? parsedFieldValue : [parsedFieldValue])
|
|
287
|
-
});
|
|
288
|
-
};
|
|
289
|
-
var parseField$1 = function parseField(field) {
|
|
290
|
-
if (isFieldObject(field)) {
|
|
291
|
-
return parseFieldObject(field);
|
|
292
|
-
}
|
|
293
|
-
var parsedFieldValue = parseFieldValue(field);
|
|
294
|
-
if (parsedFieldValue === undefined) {
|
|
295
|
-
return undefined;
|
|
296
|
-
}
|
|
297
|
-
return {
|
|
298
|
-
value: _toConsumableArray(Array.isArray(parsedFieldValue) ? parsedFieldValue : [parsedFieldValue])
|
|
299
|
-
};
|
|
300
|
-
};
|
|
301
|
-
var parseGroupsAndFields = function parseGroupsAndFields(groupOrField) {
|
|
302
|
-
var group = [];
|
|
303
|
-
var field = [];
|
|
304
|
-
var groupAttributes = {};
|
|
305
|
-
Object.entries(groupOrField || {}).forEach(function (_ref) {
|
|
306
|
-
var _ref2 = _slicedToArray(_ref, 2),
|
|
307
|
-
name = _ref2[0],
|
|
308
|
-
value = _ref2[1];
|
|
309
|
-
if (GROUP_ATTRIBUTE_KEYS.includes(name)) {
|
|
310
|
-
groupAttributes = _objectSpread$i(_objectSpread$i({}, groupAttributes), {}, _defineProperty({}, name, value));
|
|
311
|
-
} else if (isField(value)) {
|
|
312
|
-
try {
|
|
313
|
-
field.push(_objectSpread$i({
|
|
314
|
-
name: name
|
|
315
|
-
}, parseField$1(value)));
|
|
316
|
-
} catch (error) {
|
|
317
|
-
throw Error(error.message + (name ? " for field \"".concat(name, "\"") : ''));
|
|
318
|
-
}
|
|
319
|
-
} else if (isGroup(value)) {
|
|
320
|
-
(Array.isArray(value) ? value : [value]).forEach(function (childGroup) {
|
|
321
|
-
group.push(_objectSpread$i({
|
|
322
|
-
name: name
|
|
323
|
-
}, parseGroupsAndFields(childGroup)));
|
|
324
|
-
});
|
|
325
|
-
} else {
|
|
326
|
-
throw Error("Unhandled value for \"".concat(name, "\""));
|
|
327
|
-
}
|
|
328
|
-
});
|
|
329
|
-
return _objectSpread$i(_objectSpread$i(_objectSpread$i({}, groupAttributes), group.length > 0 ? {
|
|
330
|
-
group: group
|
|
331
|
-
} : {}), field.length > 0 ? {
|
|
332
|
-
field: field
|
|
333
|
-
} : {});
|
|
334
|
-
};
|
|
335
|
-
var parseTimespan$1 = function parseTimespan(timespan) {
|
|
336
|
-
var _timespan$start = timespan.start,
|
|
337
|
-
start = _timespan$start === void 0 ? '-INF' : _timespan$start,
|
|
338
|
-
_timespan$end = timespan.end,
|
|
339
|
-
end = _timespan$end === void 0 ? '+INF' : _timespan$end,
|
|
340
|
-
_timespan$base = timespan.base,
|
|
341
|
-
base = _timespan$base === void 0 ? undefined : _timespan$base,
|
|
342
|
-
groupsAndFields = _objectWithoutProperties(timespan, _excluded2$2);
|
|
343
|
-
var _parseGroupsAndFields = parseGroupsAndFields(groupsAndFields),
|
|
344
|
-
group = _parseGroupsAndFields.group,
|
|
345
|
-
field = _parseGroupsAndFields.field;
|
|
346
|
-
return _objectSpread$i(_objectSpread$i(_objectSpread$i({}, group ? {
|
|
347
|
-
group: group
|
|
348
|
-
} : {}), field ? {
|
|
349
|
-
field: field
|
|
350
|
-
} : {}), {}, {
|
|
351
|
-
start: start.toString(),
|
|
352
|
-
end: end.toString()
|
|
353
|
-
}, base ? {
|
|
354
|
-
base: base
|
|
355
|
-
} : {});
|
|
356
|
-
};
|
|
357
|
-
/**
|
|
58
|
+
var _excluded$e=["value"],_excluded2$2=["start","end","base"];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 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$i(_objectSpread$i({},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$i(_objectSpread$i({},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$i(_objectSpread$i({},groupAttributes),{},_defineProperty({},name,value));}else if(isField(value)){try{field.push(_objectSpread$i({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$i({name:name},parseGroupsAndFields(childGroup)));});}else {throw Error("Unhandled value for \"".concat(name,"\""));}});return _objectSpread$i(_objectSpread$i(_objectSpread$i({},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$i(_objectSpread$i(_objectSpread$i({},group?{group:group}:{}),field?{field:field}:{}),{},{start:start.toString(),end:end.toString()},base?{base:base}:{});};/**
|
|
358
59
|
* Create a VidiCore metadata object from a more dense/simplified structure
|
|
359
60
|
*
|
|
360
61
|
* @param input To create VidiCore metadata object of
|
|
361
62
|
* @returns A VidiCore metadata object
|
|
362
63
|
*
|
|
363
64
|
* @category Metadata
|
|
364
|
-
*/
|
|
365
|
-
var createMetadataType = function createMetadataType(input) {
|
|
366
|
-
return {
|
|
367
|
-
timespan: (Array.isArray(input) ? input : [input || {}]).map(function (t) {
|
|
368
|
-
return parseTimespan$1(t);
|
|
369
|
-
})
|
|
370
|
-
};
|
|
371
|
-
};
|
|
65
|
+
*/var createMetadataType=function createMetadataType(input){return {timespan:(Array.isArray(input)?input:[input||{}]).map(function(t){return parseTimespan$1(t);})};};
|
|
372
66
|
|
|
373
67
|
/**
|
|
374
68
|
* @private
|
|
@@ -382,23 +76,7 @@ var createMetadataType = function createMetadataType(input) {
|
|
|
382
76
|
* @param timespan1 first timespan to compare
|
|
383
77
|
* @param timespan2 second timespan to compare
|
|
384
78
|
* @returns -1 if first is before second, 1 if first is after second, 0 if same start
|
|
385
|
-
*/
|
|
386
|
-
var sortTimespanList = function sortTimespanList(timespan1, timespan2) {
|
|
387
|
-
var _timespan1$start, _timespan2$start;
|
|
388
|
-
var _ref = (timespan1 === null || timespan1 === void 0 ? void 0 : (_timespan1$start = timespan1.start) === null || _timespan1$start === void 0 ? void 0 : _timespan1$start.split('@')) || [],
|
|
389
|
-
_ref2 = _slicedToArray(_ref, 1),
|
|
390
|
-
firstStart = _ref2[0];
|
|
391
|
-
var _ref3 = (timespan2 === null || timespan2 === void 0 ? void 0 : (_timespan2$start = timespan2.start) === null || _timespan2$start === void 0 ? void 0 : _timespan2$start.split('@')) || [],
|
|
392
|
-
_ref4 = _slicedToArray(_ref3, 1),
|
|
393
|
-
secondStart = _ref4[0];
|
|
394
|
-
if (Number(firstStart) < Number(secondStart)) {
|
|
395
|
-
return -1;
|
|
396
|
-
}
|
|
397
|
-
if (Number(firstStart) > Number(secondStart)) {
|
|
398
|
-
return 1;
|
|
399
|
-
}
|
|
400
|
-
return 0;
|
|
401
|
-
};
|
|
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;};
|
|
402
80
|
|
|
403
81
|
/**
|
|
404
82
|
* @private
|
|
@@ -407,137 +85,47 @@ var sortTimespanList = function sortTimespanList(timespan1, timespan2) {
|
|
|
407
85
|
*
|
|
408
86
|
* @param v value to return as array
|
|
409
87
|
* @returns input value wrapped as array
|
|
410
|
-
*/
|
|
411
|
-
var asArray = function asArray(v) {
|
|
412
|
-
return Array.isArray(v) ? v : v && [v] || [];
|
|
413
|
-
};
|
|
414
|
-
|
|
415
|
-
/**
|
|
88
|
+
*/var asArray=function asArray(v){return Array.isArray(v)?v:v&&[v]||[];};/**
|
|
416
89
|
* @private
|
|
417
90
|
*
|
|
418
91
|
* Wrap in array if not already an array, and return empty array if v is undefined
|
|
419
92
|
*
|
|
420
93
|
* @param v value to return as array
|
|
421
94
|
* @returns input value wrapped as array
|
|
422
|
-
*/
|
|
423
|
-
var asSingle = function asSingle(v) {
|
|
424
|
-
return Array.isArray(v) ? v.pop() : v;
|
|
425
|
-
};
|
|
426
|
-
|
|
427
|
-
/**
|
|
95
|
+
*/var asSingle=function asSingle(v){return Array.isArray(v)?v.pop():v;};/**
|
|
428
96
|
* @private
|
|
429
97
|
* Check if array is string array (+ type guard)
|
|
430
98
|
*
|
|
431
99
|
* @param arr Array to check if string array
|
|
432
100
|
* @returns true if string array
|
|
433
|
-
*/
|
|
434
|
-
var isStringArray = function isStringArray(arr) {
|
|
435
|
-
return (arr === null || arr === void 0 ? void 0 : arr.every(function (v) {
|
|
436
|
-
return typeof v === 'string';
|
|
437
|
-
})) || false;
|
|
438
|
-
};
|
|
439
|
-
|
|
440
|
-
var _excluded$d = ["value"];
|
|
441
|
-
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; }
|
|
442
|
-
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; }
|
|
443
|
-
var defaultOptions$a = {
|
|
444
|
-
includeValueAttributes: false
|
|
445
|
-
};
|
|
101
|
+
*/var isStringArray=function isStringArray(arr){return (arr===null||arr===void 0?void 0:arr.every(function(v){return typeof v==='string';}))||false;};
|
|
446
102
|
|
|
447
|
-
|
|
103
|
+
var _excluded$d=["value"];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 defaultOptions$a={includeValueAttributes:false};/**
|
|
448
104
|
* @internal
|
|
449
105
|
* Parse the value object inside a field value list
|
|
450
106
|
*
|
|
451
107
|
* @param value The Vidicore metadata value type
|
|
452
108
|
* @param options For how to parse the value object
|
|
453
109
|
* @returns The parsed value
|
|
454
|
-
*/
|
|
455
|
-
function parseValue(value, options) {
|
|
456
|
-
var _defaultOptions = _objectSpread$h(_objectSpread$h({}, defaultOptions$a), options || {}),
|
|
457
|
-
includeValueAttributes = _defaultOptions.includeValueAttributes;
|
|
458
|
-
if (includeValueAttributes === false) {
|
|
459
|
-
return value === null || value === void 0 ? void 0 : value.value;
|
|
460
|
-
}
|
|
461
|
-
var stringValue = value.value,
|
|
462
|
-
attributes = _objectWithoutProperties(value, _excluded$d);
|
|
463
|
-
var valueAttributes = includeValueAttributes === true && attributes || Array.isArray(includeValueAttributes) && Object.fromEntries(Object.entries(attributes).filter(function (_ref) {
|
|
464
|
-
var _ref2 = _slicedToArray(_ref, 1),
|
|
465
|
-
key = _ref2[0];
|
|
466
|
-
return includeValueAttributes.includes(key);
|
|
467
|
-
})) || {};
|
|
468
|
-
return _objectSpread$h(_objectSpread$h({}, valueAttributes), {}, {
|
|
469
|
-
value: stringValue
|
|
470
|
-
});
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
var _excluded$c = ["joinValue", "arrayOnSingleValue"];
|
|
474
|
-
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; }
|
|
475
|
-
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; }
|
|
476
|
-
var defaultOptions$9 = _objectSpread$g(_objectSpread$g({}, defaultOptions$a), {}, {
|
|
477
|
-
joinValue: undefined,
|
|
478
|
-
arrayOnSingleValue: true
|
|
479
|
-
});
|
|
110
|
+
*/function parseValue(value,options){var _defaultOptions=_objectSpread$h(_objectSpread$h({},defaultOptions$a),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$h(_objectSpread$h({},valueAttributes),{},{value:stringValue});}
|
|
480
111
|
|
|
481
|
-
|
|
112
|
+
var _excluded$c=["joinValue","arrayOnSingleValue"];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$9=_objectSpread$g(_objectSpread$g({},defaultOptions$a),{},{joinValue:undefined,arrayOnSingleValue:true});/**
|
|
482
113
|
* @internal
|
|
483
114
|
*
|
|
484
115
|
* @param valueList
|
|
485
116
|
* @param options
|
|
486
117
|
* @returns
|
|
487
|
-
*/
|
|
488
|
-
function parseValueList(valueList, options) {
|
|
489
|
-
var _defaultOptions = _objectSpread$g(_objectSpread$g({}, defaultOptions$9), options || {}),
|
|
490
|
-
joinValue = _defaultOptions.joinValue,
|
|
491
|
-
arrayOnSingleValue = _defaultOptions.arrayOnSingleValue,
|
|
492
|
-
parseValueOptions = _objectWithoutProperties(_defaultOptions, _excluded$c);
|
|
493
|
-
var parsedValueList = valueList === null || valueList === void 0 ? void 0 : valueList.map(function (v) {
|
|
494
|
-
return parseValue(v, parseValueOptions);
|
|
495
|
-
});
|
|
496
|
-
if (isStringArray(parsedValueList) && joinValue) return parsedValueList === null || parsedValueList === void 0 ? void 0 : parsedValueList.join(joinValue);
|
|
497
|
-
if (arrayOnSingleValue !== true && (parsedValueList === null || parsedValueList === void 0 ? void 0 : parsedValueList.length) <= 1) return parsedValueList === null || parsedValueList === void 0 ? void 0 : parsedValueList[0];
|
|
498
|
-
return parsedValueList;
|
|
499
|
-
}
|
|
500
|
-
|
|
501
|
-
var _excluded$b = ["includeFieldAttributes"],
|
|
502
|
-
_excluded2$1 = ["value"];
|
|
503
|
-
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; }
|
|
504
|
-
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; }
|
|
505
|
-
var defaultOptions$8 = _objectSpread$f({
|
|
506
|
-
includeFieldAttributes: false
|
|
507
|
-
}, defaultOptions$9);
|
|
118
|
+
*/function parseValueList(valueList,options){var _defaultOptions=_objectSpread$g(_objectSpread$g({},defaultOptions$9),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;}
|
|
508
119
|
|
|
509
|
-
|
|
120
|
+
var _excluded$b=["includeFieldAttributes"],_excluded2$1=["value"];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$8=_objectSpread$f({includeFieldAttributes:false},defaultOptions$9);/**
|
|
510
121
|
* @internal
|
|
511
122
|
*
|
|
512
123
|
* @param field
|
|
513
124
|
* @param options
|
|
514
125
|
* @returns
|
|
515
|
-
*/
|
|
516
|
-
var parseField = function parseField(field, options) {
|
|
517
|
-
var _defaultOptions = _objectSpread$f(_objectSpread$f({}, defaultOptions$8), options || {}),
|
|
518
|
-
includeFieldAttributes = _defaultOptions.includeFieldAttributes,
|
|
519
|
-
parseValueListOptions = _objectWithoutProperties(_defaultOptions, _excluded$b);
|
|
520
|
-
var value = field.value,
|
|
521
|
-
attributes = _objectWithoutProperties(field, _excluded2$1);
|
|
522
|
-
var parsedValueList = parseValueList(value, parseValueListOptions);
|
|
523
|
-
var fieldAttributes = includeFieldAttributes === true && attributes || Array.isArray(includeFieldAttributes) && Object.fromEntries(Object.entries(attributes).filter(function (_ref) {
|
|
524
|
-
var _ref2 = _slicedToArray(_ref, 1),
|
|
525
|
-
key = _ref2[0];
|
|
526
|
-
return includeFieldAttributes.includes(key);
|
|
527
|
-
})) || {};
|
|
528
|
-
return includeFieldAttributes ? _objectSpread$f(_objectSpread$f({}, fieldAttributes), {}, {
|
|
529
|
-
value: parsedValueList
|
|
530
|
-
}) : parsedValueList;
|
|
531
|
-
};
|
|
126
|
+
*/var parseField=function parseField(field,options){var _defaultOptions=_objectSpread$f(_objectSpread$f({},defaultOptions$8),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$f(_objectSpread$f({},fieldAttributes),{},{value:parsedValueList}):parsedValueList;};
|
|
532
127
|
|
|
533
|
-
function ownKeys$e(object,
|
|
534
|
-
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; }
|
|
535
|
-
var defaultOptions$7 = _objectSpread$e(_objectSpread$e({}, defaultOptions$8), {}, {
|
|
536
|
-
fieldAsList: false,
|
|
537
|
-
arrayOnSingleField: false,
|
|
538
|
-
overrideField: undefined
|
|
539
|
-
});
|
|
540
|
-
/**
|
|
128
|
+
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$7=_objectSpread$e(_objectSpread$e({},defaultOptions$8),{},{fieldAsList:false,arrayOnSingleField:false,overrideField:undefined});/**
|
|
541
129
|
* Parse a metadata field list according to selected options
|
|
542
130
|
*
|
|
543
131
|
* @remarks
|
|
@@ -553,34 +141,9 @@ var defaultOptions$7 = _objectSpread$e(_objectSpread$e({}, defaultOptions$8), {}
|
|
|
553
141
|
* @returns A parsed field list
|
|
554
142
|
*
|
|
555
143
|
* @category Metadata
|
|
556
|
-
*/
|
|
557
|
-
var parseFieldList = function parseFieldList(fieldList, options) {
|
|
558
|
-
var parseFieldListOptions = _objectSpread$e(_objectSpread$e({}, defaultOptions$7), options || {});
|
|
559
|
-
var fieldAsList = parseFieldListOptions.fieldAsList,
|
|
560
|
-
arrayOnSingleField = parseFieldListOptions.arrayOnSingleField,
|
|
561
|
-
overrideField = parseFieldListOptions.overrideField;
|
|
562
|
-
var shouldOverride = overrideField === true && fieldAsList === false;
|
|
563
|
-
var output = {};
|
|
564
|
-
fieldList === null || fieldList === void 0 ? void 0 : fieldList.forEach(function (field) {
|
|
565
|
-
var name = field.name;
|
|
566
|
-
var parsedField = parseField(field, parseFieldListOptions);
|
|
567
|
-
var parsedFieldOutput = arrayOnSingleField === true ? asArray(parsedField) : parsedField;
|
|
568
|
-
var existingParsedFields = output[name];
|
|
569
|
-
if (!existingParsedFields) output[name] = parsedFieldOutput;else if (shouldOverride) output[name] = parsedField;else output[name] = [asArray(existingParsedFields), asArray(parsedField)].flat();
|
|
570
|
-
});
|
|
571
|
-
return fieldAsList === true ? Object.values(output).flat() : output;
|
|
572
|
-
};
|
|
144
|
+
*/var parseFieldList=function parseFieldList(fieldList,options){var parseFieldListOptions=_objectSpread$e(_objectSpread$e({},defaultOptions$7),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;};
|
|
573
145
|
|
|
574
|
-
var _excluded$a
|
|
575
|
-
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; }
|
|
576
|
-
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; }
|
|
577
|
-
var defaultParseGroupOptions = _objectSpread$d(_objectSpread$d({}, defaultOptions$7), {}, {
|
|
578
|
-
includeGroupAttributes: false,
|
|
579
|
-
groupAsList: false,
|
|
580
|
-
arrayOnSingleGroup: false,
|
|
581
|
-
overrideGroup: undefined
|
|
582
|
-
});
|
|
583
|
-
/**
|
|
146
|
+
var _excluded$a=["field","group"];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 defaultParseGroupOptions=_objectSpread$d(_objectSpread$d({},defaultOptions$7),{},{includeGroupAttributes:false,groupAsList:false,arrayOnSingleGroup:false,overrideGroup:undefined});/**
|
|
584
147
|
* @internal
|
|
585
148
|
*
|
|
586
149
|
* (Kept here due to circular dependency otherwise)
|
|
@@ -588,35 +151,8 @@ var defaultParseGroupOptions = _objectSpread$d(_objectSpread$d({}, defaultOption
|
|
|
588
151
|
* @param group
|
|
589
152
|
* @param options
|
|
590
153
|
* @returns
|
|
591
|
-
*/
|
|
592
|
-
var
|
|
593
|
-
var parseGroupOptions = _objectSpread$d(_objectSpread$d({}, defaultParseGroupOptions), options || {});
|
|
594
|
-
var includeGroupAttributes = parseGroupOptions.includeGroupAttributes;
|
|
595
|
-
var parseFieldListOptions = Object.fromEntries(Object.entries(parseGroupOptions).filter(function (_ref) {
|
|
596
|
-
var _ref2 = _slicedToArray(_ref, 1),
|
|
597
|
-
key = _ref2[0];
|
|
598
|
-
return Object.keys(defaultOptions$7).includes(key);
|
|
599
|
-
}));
|
|
600
|
-
var fieldList = group.field,
|
|
601
|
-
groupList = group.group,
|
|
602
|
-
attributes = _objectWithoutProperties(group, _excluded$a);
|
|
603
|
-
var parsedFieldList = fieldList && parseFieldList(fieldList, parseFieldListOptions);
|
|
604
|
-
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
605
|
-
var parsedGroupList = groupList && parseGroupList(groupList, parseGroupOptions);
|
|
606
|
-
var groupAttributes = includeGroupAttributes === true && attributes || Array.isArray(includeGroupAttributes) && Object.fromEntries(Object.entries(attributes).filter(function (_ref3) {
|
|
607
|
-
var _ref4 = _slicedToArray(_ref3, 1),
|
|
608
|
-
key = _ref4[0];
|
|
609
|
-
return includeGroupAttributes.includes(key);
|
|
610
|
-
})) || {};
|
|
611
|
-
return _objectSpread$d(_objectSpread$d(_objectSpread$d({}, groupAttributes), parseFieldListOptions !== null && parseFieldListOptions !== void 0 && parseFieldListOptions.fieldAsList ? parsedFieldList && {
|
|
612
|
-
field: parsedFieldList
|
|
613
|
-
} || {} : parsedFieldList), parseGroupOptions !== null && parseGroupOptions !== void 0 && parseGroupOptions.groupAsList ? parsedGroupList && {
|
|
614
|
-
group: parsedGroupList
|
|
615
|
-
} || {} : parsedGroupList);
|
|
616
|
-
};
|
|
617
|
-
var defaultOptions$6 = defaultParseGroupOptions;
|
|
618
|
-
|
|
619
|
-
/**
|
|
154
|
+
*/var parseGroup=function parseGroup(group,options){var parseGroupOptions=_objectSpread$d(_objectSpread$d({},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$7).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$d(_objectSpread$d(_objectSpread$d({},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$6=defaultParseGroupOptions;/**
|
|
620
156
|
* Parse a metadata group list according to selected options
|
|
621
157
|
*
|
|
622
158
|
* @remarks
|
|
@@ -630,40 +166,9 @@ var defaultOptions$6 = defaultParseGroupOptions;
|
|
|
630
166
|
* @returns A parsed group list
|
|
631
167
|
*
|
|
632
168
|
* @category Metadata
|
|
633
|
-
*/
|
|
634
|
-
var parseGroupList = function parseGroupList(groupList, options) {
|
|
635
|
-
var parseGroupOptions = _objectSpread$d(_objectSpread$d({}, defaultOptions$6), options || {});
|
|
636
|
-
var groupAsList = parseGroupOptions.groupAsList,
|
|
637
|
-
arrayOnSingleGroup = parseGroupOptions.arrayOnSingleGroup,
|
|
638
|
-
overrideGroup = parseGroupOptions.overrideGroup;
|
|
639
|
-
var shouldOverride = overrideGroup === true && groupAsList === false;
|
|
640
|
-
var output = {};
|
|
641
|
-
groupList === null || groupList === void 0 ? void 0 : groupList.forEach(function (group) {
|
|
642
|
-
var name = group.name;
|
|
643
|
-
var parsedGroup = parseGroup(group, parseGroupOptions);
|
|
644
|
-
var parsedGroupOutput = arrayOnSingleGroup === true ? asArray(parsedGroup) : parsedGroup;
|
|
645
|
-
var existingParsedGroups = output[name];
|
|
646
|
-
if (!existingParsedGroups) output[name] = parsedGroupOutput;else if (shouldOverride) output[name] = parsedGroup;else output[name] = [asArray(existingParsedGroups), asArray(parsedGroup)].flat();
|
|
647
|
-
});
|
|
648
|
-
if (groupAsList) {
|
|
649
|
-
return Object.values(output).flat();
|
|
650
|
-
}
|
|
651
|
-
return output;
|
|
652
|
-
};
|
|
169
|
+
*/var parseGroupList=function parseGroupList(groupList,options){var parseGroupOptions=_objectSpread$d(_objectSpread$d({},defaultOptions$6),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;};
|
|
653
170
|
|
|
654
|
-
var _excluded$9
|
|
655
|
-
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; }
|
|
656
|
-
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; }
|
|
657
|
-
var defaultOptions$5 = _objectSpread$c(_objectSpread$c({}, defaultOptions$6), {}, {
|
|
658
|
-
includeTimespanAttributes: false,
|
|
659
|
-
flat: false,
|
|
660
|
-
arrayOnSingle: false,
|
|
661
|
-
arrayOnSingleValue: true,
|
|
662
|
-
arrayOnSingleGroup: undefined,
|
|
663
|
-
arrayOnSingleField: undefined
|
|
664
|
-
});
|
|
665
|
-
|
|
666
|
-
/**
|
|
171
|
+
var _excluded$9=["field","group"];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 defaultOptions$5=_objectSpread$c(_objectSpread$c({},defaultOptions$6),{},{includeTimespanAttributes:false,flat:false,arrayOnSingle:false,arrayOnSingleValue:true,arrayOnSingleGroup:undefined,arrayOnSingleField:undefined});/**
|
|
667
172
|
*
|
|
668
173
|
* Parses timespan according to specified options
|
|
669
174
|
*
|
|
@@ -677,76 +182,10 @@ var defaultOptions$5 = _objectSpread$c(_objectSpread$c({}, defaultOptions$6), {}
|
|
|
677
182
|
* @see {@link parseGroupList} and {@link parseFieldList} for more info
|
|
678
183
|
*
|
|
679
184
|
* @category Metadata
|
|
680
|
-
*/
|
|
681
|
-
var
|
|
682
|
-
var parseTimespanOptions = _objectSpread$c(_objectSpread$c({}, defaultOptions$5), options || {});
|
|
683
|
-
var includeTimespanAttributes = parseTimespanOptions.includeTimespanAttributes,
|
|
684
|
-
arrayOnSingle = parseTimespanOptions.arrayOnSingle,
|
|
685
|
-
flat = parseTimespanOptions.flat;
|
|
686
|
-
var parseGroupListOptions = Object.fromEntries(Object.entries(options).map(function (_ref) {
|
|
687
|
-
var _ref2 = _slicedToArray(_ref, 2),
|
|
688
|
-
key = _ref2[0],
|
|
689
|
-
value = _ref2[1];
|
|
690
|
-
if (Object.keys(defaultOptions$6).includes(key)) {
|
|
691
|
-
if (['arrayOnSingleGroup', 'arrayOnSingleField', 'arrayOnSingleValue'].includes(key) && (value !== undefined ? value : arrayOnSingle === true)) {
|
|
692
|
-
return [key, true];
|
|
693
|
-
}
|
|
694
|
-
if (['overrideGroup', 'overrideField'].includes(key) && (value !== undefined ? value : flat === true)) {
|
|
695
|
-
return [key, true];
|
|
696
|
-
}
|
|
697
|
-
return [key, value];
|
|
698
|
-
}
|
|
699
|
-
return undefined;
|
|
700
|
-
}).filter(function (e) {
|
|
701
|
-
return !!e;
|
|
702
|
-
}));
|
|
703
|
-
var parseFieldListOptions = Object.fromEntries(Object.entries(options).map(function (_ref3) {
|
|
704
|
-
var _ref4 = _slicedToArray(_ref3, 2),
|
|
705
|
-
key = _ref4[0],
|
|
706
|
-
value = _ref4[1];
|
|
707
|
-
if (Object.keys(defaultOptions$7).includes(key)) {
|
|
708
|
-
if (['arrayOnSingleField', 'arrayOnSingleValue'].includes(key) && (value !== undefined ? value : arrayOnSingle === true)) {
|
|
709
|
-
return [key, true];
|
|
710
|
-
}
|
|
711
|
-
if (['overrideField'].includes(key) && (value !== undefined ? value : flat === true)) {
|
|
712
|
-
return [key, true];
|
|
713
|
-
}
|
|
714
|
-
return [key, value];
|
|
715
|
-
}
|
|
716
|
-
return undefined;
|
|
717
|
-
}).filter(function (e) {
|
|
718
|
-
return !!e;
|
|
719
|
-
}));
|
|
720
|
-
var _ref5 = timespan || {},
|
|
721
|
-
fieldList = _ref5.field,
|
|
722
|
-
groupList = _ref5.group,
|
|
723
|
-
attributes = _objectWithoutProperties(_ref5, _excluded$9);
|
|
724
|
-
var parsedFieldList = fieldList && parseFieldList(fieldList, parseFieldListOptions);
|
|
725
|
-
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
726
|
-
var parsedGroupList = groupList && parseGroupList(groupList, parseGroupListOptions);
|
|
727
|
-
var timespanAttributes = includeTimespanAttributes === true && attributes || Array.isArray(includeTimespanAttributes) && Object.fromEntries(Object.entries(attributes).filter(function (_ref6) {
|
|
728
|
-
var _ref7 = _slicedToArray(_ref6, 1),
|
|
729
|
-
key = _ref7[0];
|
|
730
|
-
return includeTimespanAttributes.includes(key);
|
|
731
|
-
})) || {};
|
|
732
|
-
return _objectSpread$c(_objectSpread$c(_objectSpread$c({}, timespanAttributes), parseFieldListOptions !== null && parseFieldListOptions !== void 0 && parseFieldListOptions.fieldAsList ? {
|
|
733
|
-
field: parsedFieldList
|
|
734
|
-
} : parsedFieldList), parseGroupListOptions !== null && parseGroupListOptions !== void 0 && parseGroupListOptions.groupAsList ? {
|
|
735
|
-
group: parsedGroupList
|
|
736
|
-
} : parsedGroupList);
|
|
737
|
-
};
|
|
185
|
+
*/var parseTimespan=function parseTimespan(timespan,options){var parseTimespanOptions=_objectSpread$c(_objectSpread$c({},defaultOptions$5),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$6).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$7).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$c(_objectSpread$c(_objectSpread$c({},timespanAttributes),parseFieldListOptions!==null&&parseFieldListOptions!==void 0&&parseFieldListOptions.fieldAsList?{field:parsedFieldList}:parsedFieldList),parseGroupListOptions!==null&&parseGroupListOptions!==void 0&&parseGroupListOptions.groupAsList?{group:parsedGroupList}:parsedGroupList);};
|
|
738
187
|
|
|
739
|
-
var _excluded$8
|
|
740
|
-
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; }
|
|
741
|
-
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; }
|
|
742
|
-
var defaultOptions$4 = _objectSpread$b(_objectSpread$b({}, defaultOptions$5), {}, {
|
|
743
|
-
timespanAsList: false,
|
|
744
|
-
joinTimespan: '_',
|
|
745
|
-
sortTimespan: false,
|
|
746
|
-
flat: false,
|
|
747
|
-
flatTimespan: undefined
|
|
748
|
-
});
|
|
749
|
-
/**
|
|
188
|
+
var _excluded$8=["timespanAsList","joinTimespan","sortTimespan","flat","flatTimespan"];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 defaultOptions$4=_objectSpread$b(_objectSpread$b({},defaultOptions$5),{},{timespanAsList:false,joinTimespan:'_',sortTimespan:false,flat:false,flatTimespan:undefined});/**
|
|
750
189
|
* Parses timespanList according to specified options.
|
|
751
190
|
* The attributes can be targeted for each sub-type.
|
|
752
191
|
*
|
|
@@ -757,53 +196,9 @@ var defaultOptions$4 = _objectSpread$b(_objectSpread$b({}, defaultOptions$5), {}
|
|
|
757
196
|
* @see {@link parseTimespan} for more info
|
|
758
197
|
*
|
|
759
198
|
* @category Metadata
|
|
760
|
-
*/
|
|
761
|
-
var parseTimespanList = function parseTimespanList(timespanList, options) {
|
|
762
|
-
var parseTimespanListOptions = _objectSpread$b(_objectSpread$b({}, defaultOptions$4), options || {});
|
|
763
|
-
var timespanAsList = parseTimespanListOptions.timespanAsList,
|
|
764
|
-
joinTimespan = parseTimespanListOptions.joinTimespan,
|
|
765
|
-
sortTimespan = parseTimespanListOptions.sortTimespan,
|
|
766
|
-
flat = parseTimespanListOptions.flat,
|
|
767
|
-
flatTimespan = parseTimespanListOptions.flatTimespan,
|
|
768
|
-
otherOptions = _objectWithoutProperties(parseTimespanListOptions, _excluded$8);
|
|
769
|
-
var parseTimespanOptions = _objectSpread$b({
|
|
770
|
-
flat: flat
|
|
771
|
-
}, otherOptions);
|
|
772
|
-
if (sortTimespan) timespanList.sort(sortTimespanList);
|
|
773
|
-
var shouldFlatten = (flatTimespan !== undefined ? flatTimespan === true : flat === true) && timespanAsList === false;
|
|
774
|
-
var output = {};
|
|
775
|
-
timespanList === null || timespanList === void 0 ? void 0 : timespanList.forEach(function (timespan) {
|
|
776
|
-
var start = timespan.start,
|
|
777
|
-
end = timespan.end;
|
|
778
|
-
var key = shouldFlatten ? 'flat' : [start, end].join(joinTimespan);
|
|
779
|
-
var parsedTimespan = parseTimespan(timespan, parseTimespanOptions);
|
|
780
|
-
var existingParsedTimespans = output[key];
|
|
781
|
-
if (!existingParsedTimespans) output[key] = parsedTimespan;else if (shouldFlatten) {
|
|
782
|
-
if (start === '-INF' && end === '+INF') {
|
|
783
|
-
output[key] = _objectSpread$b(_objectSpread$b({}, asSingle(existingParsedTimespans)), parsedTimespan);
|
|
784
|
-
} else {
|
|
785
|
-
output[key] = _objectSpread$b(_objectSpread$b({}, parsedTimespan), asSingle(existingParsedTimespans));
|
|
786
|
-
}
|
|
787
|
-
} else output[key] = [].concat(_toConsumableArray(asArray(existingParsedTimespans)), [parsedTimespan]);
|
|
788
|
-
});
|
|
789
|
-
if (timespanAsList === true) {
|
|
790
|
-
return Object.values(output);
|
|
791
|
-
}
|
|
792
|
-
if (shouldFlatten) {
|
|
793
|
-
return Object.values(output).pop();
|
|
794
|
-
}
|
|
795
|
-
return output;
|
|
796
|
-
};
|
|
797
|
-
|
|
798
|
-
var _excluded$7 = ["timespan"];
|
|
799
|
-
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; }
|
|
800
|
-
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; }
|
|
801
|
-
var defaultOptions$3 = _objectSpread$a(_objectSpread$a({}, defaultOptions$4), {}, {
|
|
802
|
-
includeMetadataAttributes: false,
|
|
803
|
-
flat: false
|
|
804
|
-
});
|
|
199
|
+
*/var parseTimespanList=function parseTimespanList(timespanList,options){var parseTimespanListOptions=_objectSpread$b(_objectSpread$b({},defaultOptions$4),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$b({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$b(_objectSpread$b({},asSingle(existingParsedTimespans)),parsedTimespan);}else {output[key]=_objectSpread$b(_objectSpread$b({},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;};
|
|
805
200
|
|
|
806
|
-
|
|
201
|
+
var _excluded$7=["timespan"];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$3=_objectSpread$a(_objectSpread$a({},defaultOptions$4),{},{includeMetadataAttributes:false,flat:false});/**
|
|
807
202
|
* Parses MetadataType according to specified options
|
|
808
203
|
*
|
|
809
204
|
* @remarks
|
|
@@ -818,47 +213,7 @@ var defaultOptions$3 = _objectSpread$a(_objectSpread$a({}, defaultOptions$4), {}
|
|
|
818
213
|
* @see {@link parseTimespanList} for more info
|
|
819
214
|
*
|
|
820
215
|
* @category Metadata
|
|
821
|
-
*/
|
|
822
|
-
function parseMetadataType(metadataType, options) {
|
|
823
|
-
var parseMetadataTypeOptions = _objectSpread$a(_objectSpread$a({}, defaultOptions$3), options || {});
|
|
824
|
-
var includeMetadataAttributes = parseMetadataTypeOptions.includeMetadataAttributes,
|
|
825
|
-
flat = parseMetadataTypeOptions.flat;
|
|
826
|
-
var _ref = metadataType || {},
|
|
827
|
-
_ref$timespan = _ref.timespan,
|
|
828
|
-
timespanList = _ref$timespan === void 0 ? [] : _ref$timespan,
|
|
829
|
-
attributes = _objectWithoutProperties(_ref, _excluded$7);
|
|
830
|
-
var parseTimespanListOptions = Object.fromEntries(Object.entries(options).map(function (_ref2) {
|
|
831
|
-
var _ref3 = _slicedToArray(_ref2, 2),
|
|
832
|
-
key = _ref3[0],
|
|
833
|
-
value = _ref3[1];
|
|
834
|
-
if (Object.keys(defaultOptions$4).includes(key)) {
|
|
835
|
-
if (['onlyGeneric', 'overrideGroup', 'overrideField'].includes(key) && (value !== undefined ? value : flat === true)) {
|
|
836
|
-
return [key, true];
|
|
837
|
-
}
|
|
838
|
-
return [key, value];
|
|
839
|
-
}
|
|
840
|
-
return undefined;
|
|
841
|
-
}).filter(function (e) {
|
|
842
|
-
return !!e;
|
|
843
|
-
}));
|
|
844
|
-
var parsedTimespanList = parseTimespanList(timespanList, parseTimespanListOptions);
|
|
845
|
-
var metadataAttributes = includeMetadataAttributes === true && _objectSpread$a(_objectSpread$a({}, attributes), attributes.revision ? {
|
|
846
|
-
revision: attributes.revision.split(',')
|
|
847
|
-
} : {}) || Array.isArray(includeMetadataAttributes) && Object.fromEntries(Object.entries(attributes).map(function (_ref4) {
|
|
848
|
-
var _ref5 = _slicedToArray(_ref4, 2),
|
|
849
|
-
key = _ref5[0],
|
|
850
|
-
value = _ref5[1];
|
|
851
|
-
if (includeMetadataAttributes.includes(key)) {
|
|
852
|
-
return [key, key === 'revision' && typeof value === 'string' ? value.split(',') : value];
|
|
853
|
-
}
|
|
854
|
-
return undefined;
|
|
855
|
-
}).filter(function (o) {
|
|
856
|
-
return !!o;
|
|
857
|
-
})) || {};
|
|
858
|
-
return _objectSpread$a(_objectSpread$a({}, metadataAttributes), parseTimespanListOptions !== null && parseTimespanListOptions !== void 0 && parseTimespanListOptions.timespanAsList ? {
|
|
859
|
-
timespan: parsedTimespanList
|
|
860
|
-
} : parsedTimespanList);
|
|
861
|
-
}
|
|
216
|
+
*/function parseMetadataType(metadataType,options){var parseMetadataTypeOptions=_objectSpread$a(_objectSpread$a({},defaultOptions$3),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$4).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$a(_objectSpread$a({},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$a(_objectSpread$a({},metadataAttributes),parseTimespanListOptions!==null&&parseTimespanListOptions!==void 0&&parseTimespanListOptions.timespanAsList?{timespan:parsedTimespanList}:parsedTimespanList);}
|
|
862
217
|
|
|
863
218
|
/**
|
|
864
219
|
* Parse simple (key/value) metadata
|
|
@@ -869,45 +224,9 @@ function parseMetadataType(metadataType, options) {
|
|
|
869
224
|
* @returns A parsed simple metadata object
|
|
870
225
|
*
|
|
871
226
|
* @category Metadata
|
|
872
|
-
*/
|
|
873
|
-
var parseSimpleMetadataType = function parseSimpleMetadataType(simpleMetadataType) {
|
|
874
|
-
var _ref = simpleMetadataType || {},
|
|
875
|
-
_ref$field = _ref.field,
|
|
876
|
-
field = _ref$field === void 0 ? [] : _ref$field;
|
|
877
|
-
return parseKeyValuePairTypes(field);
|
|
878
|
-
};
|
|
227
|
+
*/var parseSimpleMetadataType=function parseSimpleMetadataType(simpleMetadataType){var _ref=simpleMetadataType||{},_ref$field=_ref.field,field=_ref$field===void 0?[]:_ref$field;return parseKeyValuePairTypes(field);};
|
|
879
228
|
|
|
880
|
-
var MAP_CONSTANT_TO_DEN_NUM =
|
|
881
|
-
PAL: {
|
|
882
|
-
denominator: 25,
|
|
883
|
-
numerator: 1
|
|
884
|
-
},
|
|
885
|
-
NTSC: {
|
|
886
|
-
denominator: 30000,
|
|
887
|
-
numerator: 1001
|
|
888
|
-
},
|
|
889
|
-
NTSC30: {
|
|
890
|
-
denominator: 30,
|
|
891
|
-
numerator: 1
|
|
892
|
-
},
|
|
893
|
-
29.97: {
|
|
894
|
-
denominator: 30000,
|
|
895
|
-
numerator: 1001
|
|
896
|
-
},
|
|
897
|
-
59.94: {
|
|
898
|
-
denominator: 60000,
|
|
899
|
-
numerator: 1001
|
|
900
|
-
},
|
|
901
|
-
23.976: {
|
|
902
|
-
denominator: 48000,
|
|
903
|
-
numerator: 2002
|
|
904
|
-
},
|
|
905
|
-
23.98: {
|
|
906
|
-
denominator: 48000,
|
|
907
|
-
numerator: 2002
|
|
908
|
-
}
|
|
909
|
-
};
|
|
910
|
-
var TIME_BASE_CONSTANTS = Object.keys(MAP_CONSTANT_TO_DEN_NUM);
|
|
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);
|
|
911
230
|
|
|
912
231
|
/**
|
|
913
232
|
* TimeBase class representing the TimeBaseType in VidiCore
|
|
@@ -915,146 +234,54 @@ var TIME_BASE_CONSTANTS = Object.keys(MAP_CONSTANT_TO_DEN_NUM);
|
|
|
915
234
|
* For more info, see the [Time bases section in VidiCore API Docs](https://apidoc.vidispine.com/latest/time.html#time-bases)
|
|
916
235
|
*
|
|
917
236
|
* @category Time
|
|
918
|
-
*/
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
// The denominator for the TimeBase
|
|
923
|
-
|
|
924
|
-
/**
|
|
237
|
+
*/var TimeBase=/*#__PURE__*/function(){// The numerator for the TimeBase
|
|
238
|
+
// The denominator for the TimeBase
|
|
239
|
+
/**
|
|
925
240
|
* Constructor for TimeBase
|
|
926
241
|
*
|
|
927
242
|
* @param timeBaseType A TimeBaseType object
|
|
928
|
-
*/
|
|
929
|
-
function TimeBase(timeBaseType) {
|
|
930
|
-
_classCallCheck(this, TimeBase);
|
|
931
|
-
_defineProperty(this, "numerator", 1);
|
|
932
|
-
_defineProperty(this, "denominator", 1);
|
|
933
|
-
var _ref = timeBaseType || {},
|
|
934
|
-
_ref$numerator = _ref.numerator,
|
|
935
|
-
numerator = _ref$numerator === void 0 ? 1 : _ref$numerator,
|
|
936
|
-
_ref$denominator = _ref.denominator,
|
|
937
|
-
denominator = _ref$denominator === void 0 ? 1 : _ref$denominator;
|
|
938
|
-
this.numerator = Number(numerator);
|
|
939
|
-
this.denominator = Number(denominator);
|
|
940
|
-
}
|
|
941
|
-
|
|
942
|
-
/**
|
|
243
|
+
*/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);}/**
|
|
943
244
|
* Get TimeBase in a constant representation (e.g. "PAL") if possible, otherwise undefined
|
|
944
245
|
* @returns Constant representation of the TimeBase
|
|
945
|
-
*/
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
if (options !== null && options !== void 0 && options.fraction || this.numerator > 1) {
|
|
985
|
-
var _timeBaseText2 = [this.denominator, this.numerator].join(':');
|
|
986
|
-
return _timeBaseText2;
|
|
987
|
-
}
|
|
988
|
-
var timeBaseText = String(this.denominator);
|
|
989
|
-
return timeBaseText;
|
|
990
|
-
}
|
|
991
|
-
|
|
992
|
-
/**
|
|
993
|
-
* Output TimeBase as frame rate (by default max 16 decimal places)
|
|
994
|
-
*
|
|
995
|
-
* @remarks
|
|
996
|
-
* For `options.fixed`:
|
|
997
|
-
* - `true` gives two decimal places
|
|
998
|
-
* - `false` gives max amount of decimal places
|
|
999
|
-
* - `number` gives that amount of decimal places
|
|
1000
|
-
*
|
|
1001
|
-
* Default format: rate with two decimals if needed (i.e. decimals are > 0)
|
|
1002
|
-
* Option precedence (when all true): `constant` > `rounded` > `fixed`
|
|
1003
|
-
*
|
|
1004
|
-
* @param options For how to display it as rate
|
|
1005
|
-
*
|
|
1006
|
-
* @return Rate of the TimeBase
|
|
1007
|
-
*
|
|
1008
|
-
* @category Time
|
|
1009
|
-
*/
|
|
1010
|
-
}, {
|
|
1011
|
-
key: "toRate",
|
|
1012
|
-
value: function toRate(options) {
|
|
1013
|
-
var rate = this.denominator / this.numerator;
|
|
1014
|
-
if (Number.isInteger(rate)) {
|
|
1015
|
-
return rate;
|
|
1016
|
-
}
|
|
1017
|
-
if (options !== null && options !== void 0 && options.rounded) {
|
|
1018
|
-
return Math.round(rate);
|
|
1019
|
-
}
|
|
1020
|
-
var _ref2 = options || {},
|
|
1021
|
-
_ref2$fixed = _ref2.fixed,
|
|
1022
|
-
fixed = _ref2$fixed === void 0 ? true : _ref2$fixed;
|
|
1023
|
-
if (fixed === true || typeof fixed === 'number') {
|
|
1024
|
-
return Number(rate.toFixed(typeof fixed === 'boolean' ? 2 : fixed));
|
|
1025
|
-
}
|
|
1026
|
-
return rate;
|
|
1027
|
-
}
|
|
1028
|
-
|
|
1029
|
-
/**
|
|
1030
|
-
* Get TimeBase in a object representation
|
|
1031
|
-
*
|
|
1032
|
-
* @returns TimeBase as `{denominator, numerator}` object
|
|
1033
|
-
*/
|
|
1034
|
-
}, {
|
|
1035
|
-
key: "toObject",
|
|
1036
|
-
value: function toObject() {
|
|
1037
|
-
return {
|
|
1038
|
-
denominator: this.denominator,
|
|
1039
|
-
numerator: this.numerator
|
|
1040
|
-
};
|
|
1041
|
-
}
|
|
1042
|
-
|
|
1043
|
-
/**
|
|
1044
|
-
* @deprecated Use {@link TimeBase#toObject | toObject} instead
|
|
1045
|
-
*
|
|
1046
|
-
* @returns TimeBase as `{denominator, numerator}` object
|
|
1047
|
-
*/
|
|
1048
|
-
}, {
|
|
1049
|
-
key: "toJson",
|
|
1050
|
-
value: function toJson() {
|
|
1051
|
-
// eslint-disable-next-line no-console
|
|
1052
|
-
console.warn('Deprecated - use toObject instead');
|
|
1053
|
-
return this.toObject();
|
|
1054
|
-
}
|
|
1055
|
-
}]);
|
|
1056
|
-
return TimeBase;
|
|
1057
|
-
}();
|
|
246
|
+
*/_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
|
|
247
|
+
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;}/**
|
|
248
|
+
* Get TimeBase as a VidiCore TimeBaseType string
|
|
249
|
+
*
|
|
250
|
+
* @remarks
|
|
251
|
+
* Default format: denominator(:numerator if > 1)
|
|
252
|
+
*
|
|
253
|
+
* `constant` has precedence over `fraction` if both are true (e.g. NTSC > 30000:1001)
|
|
254
|
+
*
|
|
255
|
+
* @param options For how to display it as text
|
|
256
|
+
* @returns Text representation of the TimeBase
|
|
257
|
+
*/},{key:"toText",value:function toText(options){if(options!==null&&options!==void 0&&options.constant){var _timeBaseText=this.toConstant();if(_timeBaseText)return _timeBaseText;}if(options!==null&&options!==void 0&&options.fraction||this.numerator>1){var _timeBaseText2=[this.denominator,this.numerator].join(':');return _timeBaseText2;}var timeBaseText=String(this.denominator);return timeBaseText;}/**
|
|
258
|
+
* Output TimeBase as frame rate (by default max 16 decimal places)
|
|
259
|
+
*
|
|
260
|
+
* @remarks
|
|
261
|
+
* For `options.fixed`:
|
|
262
|
+
* - `true` gives two decimal places
|
|
263
|
+
* - `false` gives max amount of decimal places
|
|
264
|
+
* - `number` gives that amount of decimal places
|
|
265
|
+
*
|
|
266
|
+
* Default format: rate with two decimals if needed (i.e. decimals are > 0)
|
|
267
|
+
*
|
|
268
|
+
* Option precedence (when all true): `constant` > `rounded` > `fixed`
|
|
269
|
+
*
|
|
270
|
+
* @param options For how to display it as rate
|
|
271
|
+
*
|
|
272
|
+
* @return Rate of the TimeBase
|
|
273
|
+
*
|
|
274
|
+
* @category Time
|
|
275
|
+
*/},{key:"toRate",value:function toRate(options){var rate=this.denominator/this.numerator;if(Number.isInteger(rate)){return rate;}if(options!==null&&options!==void 0&&options.rounded){return Math.round(rate);}var _ref2=options||{},_ref2$fixed=_ref2.fixed,fixed=_ref2$fixed===void 0?true:_ref2$fixed;if(fixed===true||typeof fixed==='number'){return Number(rate.toFixed(typeof fixed==='boolean'?2:fixed));}return rate;}/**
|
|
276
|
+
* Get TimeBase in a object representation
|
|
277
|
+
*
|
|
278
|
+
* @returns TimeBase as `{denominator, numerator}` object
|
|
279
|
+
*/},{key:"toObject",value:function toObject(){return {denominator:this.denominator,numerator:this.numerator};}/**
|
|
280
|
+
* @deprecated Use {@link TimeBase#toObject | toObject} instead
|
|
281
|
+
*
|
|
282
|
+
* @returns TimeBase as `{denominator, numerator}` object
|
|
283
|
+
*/},{key:"toJson",value:function toJson(){// eslint-disable-next-line no-console
|
|
284
|
+
console.warn('Deprecated - use toObject instead');return this.toObject();}}]);return TimeBase;}();
|
|
1058
285
|
|
|
1059
286
|
/**
|
|
1060
287
|
* Format a string representation of a time base to a TimeBase Instance
|
|
@@ -1063,36 +290,7 @@ var TimeBase = /*#__PURE__*/function () {
|
|
|
1063
290
|
* @returns A TimeBase Instance
|
|
1064
291
|
*
|
|
1065
292
|
* @category Time
|
|
1066
|
-
*/
|
|
1067
|
-
var formatTimeBaseText = function formatTimeBaseText(timeBaseText) {
|
|
1068
|
-
if (timeBaseText === undefined) {
|
|
1069
|
-
return new TimeBase();
|
|
1070
|
-
}
|
|
1071
|
-
if (typeof timeBaseText === 'number') {
|
|
1072
|
-
return new TimeBase({
|
|
1073
|
-
denominator: timeBaseText
|
|
1074
|
-
});
|
|
1075
|
-
}
|
|
1076
|
-
if (typeof timeBaseText === 'string' && timeBaseText.includes(':')) {
|
|
1077
|
-
var _timeBaseText$split = timeBaseText.split(':'),
|
|
1078
|
-
_timeBaseText$split2 = _slicedToArray(_timeBaseText$split, 2),
|
|
1079
|
-
denominator = _timeBaseText$split2[0],
|
|
1080
|
-
numerator = _timeBaseText$split2[1];
|
|
1081
|
-
return new TimeBase({
|
|
1082
|
-
denominator: denominator,
|
|
1083
|
-
numerator: numerator
|
|
1084
|
-
});
|
|
1085
|
-
}
|
|
1086
|
-
if (TIME_BASE_CONSTANTS.includes(timeBaseText)) {
|
|
1087
|
-
return new TimeBase(MAP_CONSTANT_TO_DEN_NUM[timeBaseText]);
|
|
1088
|
-
}
|
|
1089
|
-
if (!['string', 'number'].includes(_typeof(timeBaseText)) || Number.isNaN(Number(timeBaseText))) {
|
|
1090
|
-
throw new Error("timeBaseText must be a number or ".concat(TIME_BASE_CONSTANTS.join(','), " - is ").concat(JSON.stringify(timeBaseText)));
|
|
1091
|
-
}
|
|
1092
|
-
return new TimeBase({
|
|
1093
|
-
denominator: Number(timeBaseText)
|
|
1094
|
-
});
|
|
1095
|
-
};
|
|
293
|
+
*/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)});};
|
|
1096
294
|
|
|
1097
295
|
/**
|
|
1098
296
|
* Create a TimeBase instance of an object
|
|
@@ -1101,10 +299,7 @@ var formatTimeBaseText = function formatTimeBaseText(timeBaseText) {
|
|
|
1101
299
|
* @returns A TimeBase instance
|
|
1102
300
|
*
|
|
1103
301
|
* @category Time
|
|
1104
|
-
*/
|
|
1105
|
-
var formatTimeBaseType = function formatTimeBaseType(timeBase) {
|
|
1106
|
-
return new TimeBase(timeBase);
|
|
1107
|
-
};
|
|
302
|
+
*/var formatTimeBaseType=function formatTimeBaseType(timeBase){return new TimeBase(timeBase);};
|
|
1108
303
|
|
|
1109
304
|
/**
|
|
1110
305
|
* Create a TimeBase Instance from a number, string or object representation of a time base
|
|
@@ -1113,13 +308,7 @@ var formatTimeBaseType = function formatTimeBaseType(timeBase) {
|
|
|
1113
308
|
* @returns A TimeBase instance
|
|
1114
309
|
*
|
|
1115
310
|
* @category Time
|
|
1116
|
-
*/
|
|
1117
|
-
var createTimeBase = function createTimeBase(timeBase) {
|
|
1118
|
-
if (typeof timeBase === 'string' || typeof timeBase === 'number') {
|
|
1119
|
-
return formatTimeBaseText(timeBase);
|
|
1120
|
-
}
|
|
1121
|
-
return formatTimeBaseType(timeBase);
|
|
1122
|
-
};
|
|
311
|
+
*/var createTimeBase=function createTimeBase(timeBase){if(typeof timeBase==='string'||typeof timeBase==='number'){return formatTimeBaseText(timeBase);}return formatTimeBaseType(timeBase);};
|
|
1123
312
|
|
|
1124
313
|
/**
|
|
1125
314
|
* @private
|
|
@@ -1128,11 +317,7 @@ var createTimeBase = function createTimeBase(timeBase) {
|
|
|
1128
317
|
*
|
|
1129
318
|
* @param timeBase Time base to get amount of frames to drop for
|
|
1130
319
|
* @returns Amount of frame drops for specified time base, false if no frame drops
|
|
1131
|
-
*/
|
|
1132
|
-
var getAmountOfFrameDrops = function getAmountOfFrameDrops(timeBase) {
|
|
1133
|
-
var timeBaseConstant = timeBase.toConstant();
|
|
1134
|
-
return timeBaseConstant === '59.94' && 4 || ['NTSC', '29.97'].includes(timeBaseConstant) && 2 || false;
|
|
1135
|
-
};
|
|
320
|
+
*/var getAmountOfFrameDrops=function getAmountOfFrameDrops(timeBase){var timeBaseConstant=timeBase.toConstant();return timeBaseConstant==='59.94'&&4||['NTSC','29.97'].includes(timeBaseConstant)&&2||false;};
|
|
1136
321
|
|
|
1137
322
|
/**
|
|
1138
323
|
* @private
|
|
@@ -1141,89 +326,24 @@ var getAmountOfFrameDrops = function getAmountOfFrameDrops(timeBase) {
|
|
|
1141
326
|
*
|
|
1142
327
|
* @param timeBase TimeBase Instance to check
|
|
1143
328
|
* @returns true if time base drops frames, false otherwise
|
|
1144
|
-
*/
|
|
1145
|
-
var isDropFrameTimeBase = function isDropFrameTimeBase(timeBase) {
|
|
1146
|
-
return getAmountOfFrameDrops(timeBase) > 0;
|
|
1147
|
-
};
|
|
329
|
+
*/var isDropFrameTimeBase=function isDropFrameTimeBase(timeBase){return getAmountOfFrameDrops(timeBase)>0;};
|
|
1148
330
|
|
|
1149
|
-
var _excluded$6
|
|
1150
|
-
var getDroppedFramesFromSamples = function getDroppedFramesFromSamples(timeCode) {
|
|
1151
|
-
var samples = timeCode.samples,
|
|
1152
|
-
timeBase = timeCode.timeBase;
|
|
1153
|
-
var amountOfFrameDrops = getAmountOfFrameDrops(timeBase);
|
|
1154
|
-
if (!amountOfFrameDrops) return 0;
|
|
1155
|
-
var roundedFrameRate = timeBase.toRate({
|
|
1156
|
-
rounded: true
|
|
1157
|
-
});
|
|
1158
|
-
var oneMinuteNotDroppedFrames = 60 * roundedFrameRate;
|
|
1159
|
-
var amountOfFramesToDropPerMinute = 60 * roundedFrameRate - amountOfFrameDrops;
|
|
1160
|
-
var tenMinuteFrames = 10 * (oneMinuteNotDroppedFrames - amountOfFrameDrops) + amountOfFrameDrops;
|
|
1161
|
-
var amountOfTenMinuteChunks = Math.floor((samples + 1) / tenMinuteFrames);
|
|
1162
|
-
var minuteRemainder = Math.max(0, (samples + 1) % tenMinuteFrames - oneMinuteNotDroppedFrames);
|
|
1163
|
-
var amountOfOneMinuteReminderChunks = Math.floor(minuteRemainder / amountOfFramesToDropPerMinute);
|
|
1164
|
-
var frameRemainder = minuteRemainder % amountOfFramesToDropPerMinute;
|
|
1165
|
-
var amountOfFrameRemainderChunks = frameRemainder > 0 ? amountOfFrameDrops : 0;
|
|
1166
|
-
return amountOfTenMinuteChunks * 9 * amountOfFrameDrops + amountOfOneMinuteReminderChunks * amountOfFrameDrops + amountOfFrameRemainderChunks;
|
|
1167
|
-
};
|
|
1168
|
-
/**
|
|
331
|
+
var _excluded$6=["hours"];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;};/**
|
|
1169
332
|
* TimeCode class representing the TimeCodeType in VidiCore
|
|
1170
333
|
*
|
|
1171
334
|
* For more info, see the [Time Codes section of VidiCore API Docs](https://apidoc.vidispine.com/latest/time.html#time-codes)
|
|
1172
335
|
*
|
|
1173
336
|
* @category Time
|
|
1174
|
-
*/
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
// If time code is dropFrame or not (by default checks timeBase)
|
|
1181
|
-
|
|
1182
|
-
// Separator for frame in smpte output (default ":" for non-drop-frame and ";" for dropFrame)
|
|
1183
|
-
|
|
1184
|
-
/**
|
|
337
|
+
*/var TimeCode=/*#__PURE__*/function(){// Amount of samples for the time code
|
|
338
|
+
// The time base for the time code
|
|
339
|
+
// If time code is dropFrame or not (by default checks timeBase)
|
|
340
|
+
// Separator for frame in smpte output (default ":" for non-drop-frame and ";" for dropFrame)
|
|
341
|
+
/**
|
|
1185
342
|
* Constructor for TimeCode
|
|
1186
343
|
*
|
|
1187
344
|
* @param timeCodeType Object to create TimeCode of
|
|
1188
345
|
* @param options Options for the timeCode
|
|
1189
|
-
*/
|
|
1190
|
-
function TimeCode(timeCodeType, options) {
|
|
1191
|
-
var _options$dropFrame, _options$frameSeparat;
|
|
1192
|
-
_classCallCheck(this, TimeCode);
|
|
1193
|
-
_defineProperty(this, "samples", 0);
|
|
1194
|
-
_defineProperty(this, "timeBase", new TimeBase());
|
|
1195
|
-
_defineProperty(this, "dropFrame", void 0);
|
|
1196
|
-
_defineProperty(this, "frameSeparator", void 0);
|
|
1197
|
-
var _ref = timeCodeType || {},
|
|
1198
|
-
samples = _ref.samples,
|
|
1199
|
-
timeBase = _ref.timeBase;
|
|
1200
|
-
if (samples !== undefined) {
|
|
1201
|
-
if (typeof samples === 'number') {
|
|
1202
|
-
this.samples = samples;
|
|
1203
|
-
} else if (typeof samples === 'string') {
|
|
1204
|
-
if (samples === '-INF') {
|
|
1205
|
-
this.samples = -Infinity;
|
|
1206
|
-
} else if (samples === '+INF') {
|
|
1207
|
-
this.samples = Infinity;
|
|
1208
|
-
} else {
|
|
1209
|
-
this.samples = Number(samples);
|
|
1210
|
-
}
|
|
1211
|
-
} else {
|
|
1212
|
-
throw new Error("samples is not number/string/-Inf/+Inf is: ".concat(samples));
|
|
1213
|
-
}
|
|
1214
|
-
}
|
|
1215
|
-
if (timeBase !== undefined) {
|
|
1216
|
-
if (timeBase instanceof TimeBase) {
|
|
1217
|
-
this.timeBase = timeBase;
|
|
1218
|
-
} else {
|
|
1219
|
-
this.timeBase = createTimeBase(timeBase);
|
|
1220
|
-
}
|
|
1221
|
-
}
|
|
1222
|
-
this.dropFrame = (_options$dropFrame = options === null || options === void 0 ? void 0 : options.dropFrame) !== null && _options$dropFrame !== void 0 ? _options$dropFrame : isDropFrameTimeBase(this.timeBase);
|
|
1223
|
-
this.frameSeparator = (_options$frameSeparat = options === null || options === void 0 ? void 0 : options.frameSeparator) !== null && _options$frameSeparat !== void 0 ? _options$frameSeparat : this.dropFrame ? ';' : ':';
|
|
1224
|
-
}
|
|
1225
|
-
|
|
1226
|
-
/**
|
|
346
|
+
*/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?';':':';}/**
|
|
1227
347
|
* Return this TimeCode added with the supplied timeCodeType
|
|
1228
348
|
* If time bases differ, it will retain the time base of this TimeCode instance
|
|
1229
349
|
* If supplied time code has a more granular time base - it will round down exceeding samples (hasn't reached that sample yet)
|
|
@@ -1234,350 +354,84 @@ var TimeCode = /*#__PURE__*/function () {
|
|
|
1234
354
|
*
|
|
1235
355
|
* @param timeCode A TimeCode instance you want to add with
|
|
1236
356
|
* @returns A new TimeCode instance with the addition applied
|
|
1237
|
-
*/
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
timeBase: conformToTimeBase
|
|
1314
|
-
};
|
|
1315
|
-
return new TimeCode(timeCode);
|
|
1316
|
-
}
|
|
1317
|
-
|
|
1318
|
-
/**
|
|
1319
|
-
* Get TimeCode as a text representation
|
|
1320
|
-
*
|
|
1321
|
-
* @remarks
|
|
1322
|
-
* Default format: samples@denominator(:numerator if > 1)
|
|
1323
|
-
* `constant` has precedence over `fraction` if both are true
|
|
1324
|
-
*
|
|
1325
|
-
* @param options Options for how to format text
|
|
1326
|
-
* @returns Text representation of TimeCode
|
|
1327
|
-
*
|
|
1328
|
-
* @category Time
|
|
1329
|
-
*/
|
|
1330
|
-
}, {
|
|
1331
|
-
key: "toText",
|
|
1332
|
-
value: function toText(options) {
|
|
1333
|
-
var timeCodeText = "".concat(this.samples);
|
|
1334
|
-
var timeBaseText = this.timeBase.toText(options);
|
|
1335
|
-
if (options !== null && options !== void 0 && options.includeTimeBaseForSeconds || !['1', '1:1'].includes(timeBaseText)) {
|
|
1336
|
-
timeCodeText = [this.samples, timeBaseText].join('@');
|
|
1337
|
-
}
|
|
1338
|
-
return timeCodeText;
|
|
1339
|
-
}
|
|
1340
|
-
|
|
1341
|
-
/**
|
|
1342
|
-
* Get TimeCode in a units object representation
|
|
1343
|
-
*
|
|
1344
|
-
* @returns Units (time and frames) for the time code
|
|
1345
|
-
*/
|
|
1346
|
-
}, {
|
|
1347
|
-
key: "toUnits",
|
|
1348
|
-
value: function toUnits() {
|
|
1349
|
-
var totalSamples = this.samples + (this.dropFrame ? getDroppedFramesFromSamples(this) : 0);
|
|
1350
|
-
var roundedFrameRate = this.timeBase.toRate({
|
|
1351
|
-
rounded: true
|
|
1352
|
-
});
|
|
1353
|
-
|
|
1354
|
-
// Calculated without drop-frame but with 2 decimal places
|
|
1355
|
-
if (['23.976', '23.98'].includes(this.timeBase.toConstant())) {
|
|
1356
|
-
roundedFrameRate = this.timeBase.toRate({
|
|
1357
|
-
fixed: true
|
|
1358
|
-
});
|
|
1359
|
-
}
|
|
1360
|
-
var hours = Math.floor(totalSamples / (3600 * roundedFrameRate));
|
|
1361
|
-
var minutes = Math.floor(totalSamples / (60 * roundedFrameRate)) % 60;
|
|
1362
|
-
var seconds = Math.floor(totalSamples / roundedFrameRate) % 60;
|
|
1363
|
-
var frames = Math.floor(totalSamples % roundedFrameRate);
|
|
1364
|
-
return {
|
|
1365
|
-
hours: hours,
|
|
1366
|
-
minutes: minutes,
|
|
1367
|
-
seconds: seconds,
|
|
1368
|
-
frames: frames
|
|
1369
|
-
};
|
|
1370
|
-
}
|
|
1371
|
-
|
|
1372
|
-
/**
|
|
1373
|
-
* Get TimeCode in a time object representation
|
|
1374
|
-
* "milliseconds" is rounded down, if you want another representation use "partialSeconds"
|
|
1375
|
-
*
|
|
1376
|
-
* @returns Time for the time code
|
|
1377
|
-
*/
|
|
1378
|
-
}, {
|
|
1379
|
-
key: "toTime",
|
|
1380
|
-
value: function toTime() {
|
|
1381
|
-
var totalSamples = this.samples + getDroppedFramesFromSamples(this);
|
|
1382
|
-
var _this$toUnits = this.toUnits(),
|
|
1383
|
-
hours = _this$toUnits.hours,
|
|
1384
|
-
minutes = _this$toUnits.minutes,
|
|
1385
|
-
seconds = _this$toUnits.seconds;
|
|
1386
|
-
var roundedFrameRate = this.timeBase.toRate({
|
|
1387
|
-
rounded: true
|
|
1388
|
-
});
|
|
1389
|
-
var framesPrecise = totalSamples % roundedFrameRate;
|
|
1390
|
-
var milliseconds = Math.floor(1000 * framesPrecise / roundedFrameRate);
|
|
1391
|
-
var partialSeconds = framesPrecise / roundedFrameRate;
|
|
1392
|
-
return {
|
|
1393
|
-
hours: hours,
|
|
1394
|
-
minutes: minutes,
|
|
1395
|
-
seconds: seconds,
|
|
1396
|
-
milliseconds: milliseconds,
|
|
1397
|
-
partialSeconds: partialSeconds
|
|
1398
|
-
};
|
|
1399
|
-
}
|
|
1400
|
-
|
|
1401
|
-
/**
|
|
1402
|
-
* Get TimeCode in a seconds representation
|
|
1403
|
-
*
|
|
1404
|
-
* @returns Total seconds for the time code
|
|
1405
|
-
*/
|
|
1406
|
-
}, {
|
|
1407
|
-
key: "toSeconds",
|
|
1408
|
-
value: function toSeconds() {
|
|
1409
|
-
var _this$timeBase = this.timeBase,
|
|
1410
|
-
numerator = _this$timeBase.numerator,
|
|
1411
|
-
denominator = _this$timeBase.denominator;
|
|
1412
|
-
return Math.round(1000 * +(this.samples * numerator / denominator)) / 1000;
|
|
1413
|
-
}
|
|
1414
|
-
|
|
1415
|
-
/**
|
|
1416
|
-
* Get TimeCode in a duration representation
|
|
1417
|
-
* The time unit char keys for the format string are:
|
|
1418
|
-
* - "h" for hour
|
|
1419
|
-
* - "m" for minute
|
|
1420
|
-
* - "s" for seconds
|
|
1421
|
-
* - "S" for milliseconds
|
|
1422
|
-
* Any other char will be kept in the duration output string.
|
|
1423
|
-
*
|
|
1424
|
-
* Add consecutive chars for zero padding.
|
|
1425
|
-
*
|
|
1426
|
-
* By default it:
|
|
1427
|
-
* - uses colon delimiter (e.g. for format "hhmmss")
|
|
1428
|
-
* - shows "m:ss" or "h:mm:ss" if format is undefined
|
|
1429
|
-
*
|
|
1430
|
-
* @param options Options for how to display duration
|
|
1431
|
-
* @returns Duration representation of the TimeCode
|
|
1432
|
-
*/
|
|
1433
|
-
}, {
|
|
1434
|
-
key: "toDuration",
|
|
1435
|
-
value: function toDuration(options) {
|
|
1436
|
-
var _ref3 = options || {},
|
|
1437
|
-
format = _ref3.format;
|
|
1438
|
-
var _this$toTime = this.toTime(),
|
|
1439
|
-
hours = _this$toTime.hours,
|
|
1440
|
-
rest = _objectWithoutProperties(_this$toTime, _excluded$6);
|
|
1441
|
-
var minutes = rest.minutes,
|
|
1442
|
-
seconds = rest.seconds,
|
|
1443
|
-
milliseconds = rest.milliseconds;
|
|
1444
|
-
if (!!format && typeof format !== 'string') {
|
|
1445
|
-
throw Error('format has to be a string');
|
|
1446
|
-
}
|
|
1447
|
-
var isBefore = function isBefore(unit, units) {
|
|
1448
|
-
return !format.includes(unit) || !units.some(function (u) {
|
|
1449
|
-
return format.includes(u) && format.lastIndexOf(unit) > format.indexOf(u);
|
|
1450
|
-
});
|
|
1451
|
-
};
|
|
1452
|
-
if (!!format && !(isBefore('h', ['m', 's', 'S']) && isBefore('m', ['s', 'S']) && isBefore('s', ['S']))) {
|
|
1453
|
-
throw Error('format order is unsupported (has to be h, m, s then S)');
|
|
1454
|
-
}
|
|
1455
|
-
if (!format) {
|
|
1456
|
-
return "".concat(hours > 0 ? "".concat(hours, ":").concat("".concat(minutes).padStart(2, '0')) : minutes, ":").concat("".concat(seconds).padStart(2, '0'));
|
|
1457
|
-
}
|
|
1458
|
-
var countConsecutiveChars = function countConsecutiveChars(i, arr) {
|
|
1459
|
-
var j = i;
|
|
1460
|
-
while (arr[j] === arr[j + 1]) {
|
|
1461
|
-
j += 1;
|
|
1462
|
-
}
|
|
1463
|
-
return j - i + 1;
|
|
1464
|
-
};
|
|
1465
|
-
var timeUnitKeys = ['h', 'm', 's', 'S'];
|
|
1466
|
-
var output = [];
|
|
1467
|
-
_toConsumableArray(format).forEach(function (c, i, arr) {
|
|
1468
|
-
switch (c) {
|
|
1469
|
-
case 'h':
|
|
1470
|
-
{
|
|
1471
|
-
if (arr[i - 1] === 'h') {
|
|
1472
|
-
break;
|
|
1473
|
-
}
|
|
1474
|
-
var amount = countConsecutiveChars(i, arr);
|
|
1475
|
-
output.push("".concat(hours).padStart(amount, '0'));
|
|
1476
|
-
if (timeUnitKeys.includes(arr[i + amount])) {
|
|
1477
|
-
output.push(':');
|
|
1478
|
-
}
|
|
1479
|
-
break;
|
|
1480
|
-
}
|
|
1481
|
-
case 'm':
|
|
1482
|
-
{
|
|
1483
|
-
if (arr[i - 1] === 'm') {
|
|
1484
|
-
break;
|
|
1485
|
-
}
|
|
1486
|
-
var _amount = countConsecutiveChars(i, arr);
|
|
1487
|
-
if (!format.includes('h')) {
|
|
1488
|
-
minutes += hours * 60;
|
|
1489
|
-
}
|
|
1490
|
-
output.push("".concat(minutes).padStart(_amount, '0'));
|
|
1491
|
-
if (timeUnitKeys.includes(arr[i + _amount])) {
|
|
1492
|
-
output.push(':');
|
|
1493
|
-
}
|
|
1494
|
-
break;
|
|
1495
|
-
}
|
|
1496
|
-
case 's':
|
|
1497
|
-
{
|
|
1498
|
-
if (arr[i - 1] === 's') {
|
|
1499
|
-
break;
|
|
1500
|
-
}
|
|
1501
|
-
var _amount2 = countConsecutiveChars(i, arr);
|
|
1502
|
-
if (!format.includes('m')) {
|
|
1503
|
-
seconds += minutes * 60;
|
|
1504
|
-
}
|
|
1505
|
-
output.push("".concat(seconds).padStart(_amount2, '0'));
|
|
1506
|
-
if (timeUnitKeys.includes(arr[i + _amount2])) {
|
|
1507
|
-
output.push('.');
|
|
1508
|
-
}
|
|
1509
|
-
break;
|
|
1510
|
-
}
|
|
1511
|
-
case 'S':
|
|
1512
|
-
{
|
|
1513
|
-
if (arr[i - 1] === 'S') {
|
|
1514
|
-
break;
|
|
1515
|
-
}
|
|
1516
|
-
var _amount3 = countConsecutiveChars(i, arr);
|
|
1517
|
-
if (!format.includes('s')) {
|
|
1518
|
-
milliseconds += seconds * 1000;
|
|
1519
|
-
}
|
|
1520
|
-
output.push("".concat(Math.round(milliseconds / Math.pow(10, 3 - _amount3))).padStart(_amount3, '0'));
|
|
1521
|
-
break;
|
|
1522
|
-
}
|
|
1523
|
-
default:
|
|
1524
|
-
output.push(c);
|
|
1525
|
-
}
|
|
1526
|
-
});
|
|
1527
|
-
return output.join('');
|
|
1528
|
-
}
|
|
1529
|
-
|
|
1530
|
-
/**
|
|
1531
|
-
* Get TimeCode in a smpte representation
|
|
1532
|
-
*
|
|
1533
|
-
* @returns Smpte representation of the TimeCode
|
|
1534
|
-
*/
|
|
1535
|
-
}, {
|
|
1536
|
-
key: "toSmpte",
|
|
1537
|
-
value: function toSmpte() {
|
|
1538
|
-
if (this.samples === -Infinity) return '00:00:00:00';
|
|
1539
|
-
var _this$toUnits2 = this.toUnits(),
|
|
1540
|
-
hours = _this$toUnits2.hours,
|
|
1541
|
-
minutes = _this$toUnits2.minutes,
|
|
1542
|
-
seconds = _this$toUnits2.seconds,
|
|
1543
|
-
frames = _this$toUnits2.frames;
|
|
1544
|
-
var hhmmss = [hours.toFixed().padStart(2, '0'), minutes.toFixed().padStart(2, '0'), seconds.toFixed().padStart(2, '0')].join(':');
|
|
1545
|
-
return [hhmmss, "".concat(frames).padStart(2, '0')].join(this.frameSeparator);
|
|
1546
|
-
}
|
|
1547
|
-
|
|
1548
|
-
/**
|
|
1549
|
-
* Get TimeCode as a VidiCore TimeCodeType object
|
|
1550
|
-
*
|
|
1551
|
-
* @returns TimeCode as `{ samples, timeBase }`
|
|
1552
|
-
*/
|
|
1553
|
-
}, {
|
|
1554
|
-
key: "toObject",
|
|
1555
|
-
value: function toObject() {
|
|
1556
|
-
return {
|
|
1557
|
-
samples: this.samples,
|
|
1558
|
-
timeBase: this.timeBase.toObject()
|
|
1559
|
-
};
|
|
1560
|
-
}
|
|
1561
|
-
|
|
1562
|
-
/**
|
|
1563
|
-
* @deprecated Use {@link TimeCode#toObject | toObject} instead
|
|
1564
|
-
*
|
|
1565
|
-
* @returns TimeCode as `{ samples, timeBase }`
|
|
1566
|
-
*/
|
|
1567
|
-
}, {
|
|
1568
|
-
key: "toJson",
|
|
1569
|
-
value: function toJson() {
|
|
1570
|
-
// eslint-disable-next-line no-console
|
|
1571
|
-
console.warn('Deprecated - use toObject instead');
|
|
1572
|
-
return this.toObject();
|
|
1573
|
-
}
|
|
1574
|
-
}]);
|
|
1575
|
-
return TimeCode;
|
|
1576
|
-
}();
|
|
1577
|
-
|
|
1578
|
-
/* eslint-disable no-self-assign */
|
|
357
|
+
*/_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});}/**
|
|
358
|
+
* Return this TimeCode subtracted with the supplied timeCodeType
|
|
359
|
+
* If time bases differ, it will retain the time base of the instance time code
|
|
360
|
+
* If supplied time code has a more granular time base - it will round down exceeding samples (hasn't reached that sample yet)
|
|
361
|
+
*
|
|
362
|
+
* Note: This might make you "lose" frames depending on granularity of time bases, e.g.
|
|
363
|
+
* "101@50".subtract("25@25") => "51@50"
|
|
364
|
+
* while "50@25".subtract("51@50") => "25@25" (not "49@50")
|
|
365
|
+
*
|
|
366
|
+
* @param timeCode A TimeCode instance you want to subtract with
|
|
367
|
+
* @returns A new TimeCode instance with the subtraction applied
|
|
368
|
+
*/},{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});}/**
|
|
369
|
+
* Creates a new TimeCode instance with specified timeBase and samples adjusted to that.
|
|
370
|
+
*
|
|
371
|
+
* If it conforms to a less granular time base - it will floor samples (hasn't reached that sample yet)
|
|
372
|
+
* - e.g. "51@50".conformTo("PAL") => "25@PAL" (not "26@PAL")
|
|
373
|
+
*
|
|
374
|
+
* @param timeBase The TimeBase it should conform the TimeCode to
|
|
375
|
+
* @returns A new TimeCode instance with the conformTo timeBase applied
|
|
376
|
+
*/},{key:"conformTimeBase",value:function conformTimeBase(timeBase){var conformToTimeBase=timeBase instanceof TimeBase?timeBase:createTimeBase(timeBase);var samples=Math.floor(this.samples/(this.timeBase.toRate({fixed:false})/conformToTimeBase.toRate({fixed:false})));var timeCode={samples:samples,timeBase:conformToTimeBase};return new TimeCode(timeCode);}/**
|
|
377
|
+
* Get TimeCode as a text representation
|
|
378
|
+
*
|
|
379
|
+
* @remarks
|
|
380
|
+
* Default format: samples@denominator(:numerator if > 1)
|
|
381
|
+
*
|
|
382
|
+
* `constant` has precedence over `fraction` if both are true
|
|
383
|
+
*
|
|
384
|
+
* @param options Options for how to format text
|
|
385
|
+
* @returns Text representation of TimeCode
|
|
386
|
+
*
|
|
387
|
+
* @category Time
|
|
388
|
+
*/},{key:"toText",value:function toText(options){var timeCodeText="".concat(this.samples);var timeBaseText=this.timeBase.toText(options);if(options!==null&&options!==void 0&&options.includeTimeBaseForSeconds||!['1','1:1'].includes(timeBaseText)){timeCodeText=[this.samples,timeBaseText].join('@');}return timeCodeText;}/**
|
|
389
|
+
* Get TimeCode in a units object representation
|
|
390
|
+
*
|
|
391
|
+
* @returns Units (time and frames) for the time code
|
|
392
|
+
*/},{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
|
|
393
|
+
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};}/**
|
|
394
|
+
* Get TimeCode in a time object representation
|
|
395
|
+
* "milliseconds" is rounded down, if you want another representation use "partialSeconds"
|
|
396
|
+
*
|
|
397
|
+
* @returns Time for the time code
|
|
398
|
+
*/},{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};}/**
|
|
399
|
+
* Get TimeCode in a seconds representation
|
|
400
|
+
*
|
|
401
|
+
* @returns Total seconds for the time code
|
|
402
|
+
*/},{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;}/**
|
|
403
|
+
* Get TimeCode in a duration representation
|
|
404
|
+
* The time unit char keys for the format string are:
|
|
405
|
+
* - "h" for hour
|
|
406
|
+
* - "m" for minute
|
|
407
|
+
* - "s" for seconds
|
|
408
|
+
* - "S" for milliseconds
|
|
409
|
+
* Any other char will be kept in the duration output string.
|
|
410
|
+
*
|
|
411
|
+
* Add consecutive chars for zero padding.
|
|
412
|
+
*
|
|
413
|
+
* By default it:
|
|
414
|
+
* - uses colon delimiter (e.g. for format "hhmmss")
|
|
415
|
+
* - shows "m:ss" or "h:mm:ss" if format is undefined
|
|
416
|
+
*
|
|
417
|
+
* @param options Options for how to display duration
|
|
418
|
+
* @returns Duration representation of the TimeCode
|
|
419
|
+
*/},{key:"toDuration",value:function toDuration(options){var _ref3=options||{},format=_ref3.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('');}/**
|
|
420
|
+
* Get TimeCode in a smpte representation
|
|
421
|
+
*
|
|
422
|
+
* @returns Smpte representation of the TimeCode
|
|
423
|
+
*/},{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(':');return [hhmmss,"".concat(frames).padStart(2,'0')].join(this.frameSeparator);}/**
|
|
424
|
+
* Get TimeCode as a VidiCore TimeCodeType object
|
|
425
|
+
*
|
|
426
|
+
* @returns TimeCode as `{ samples, timeBase }`
|
|
427
|
+
*/},{key:"toObject",value:function toObject(){return {samples:this.samples,timeBase:this.timeBase.toObject()};}/**
|
|
428
|
+
* @deprecated Use {@link TimeCode#toObject | toObject} instead
|
|
429
|
+
*
|
|
430
|
+
* @returns TimeCode as `{ samples, timeBase }`
|
|
431
|
+
*/},{key:"toJson",value:function toJson(){// eslint-disable-next-line no-console
|
|
432
|
+
console.warn('Deprecated - use toObject instead');return this.toObject();}}]);return TimeCode;}();
|
|
1579
433
|
|
|
1580
|
-
/**
|
|
434
|
+
/* eslint-disable no-self-assign */ /**
|
|
1581
435
|
* @private
|
|
1582
436
|
*
|
|
1583
437
|
* Using Euclid's algorithm
|
|
@@ -1585,28 +439,13 @@ var TimeCode = /*#__PURE__*/function () {
|
|
|
1585
439
|
* @param num1 a number
|
|
1586
440
|
* @param num2 another number
|
|
1587
441
|
* @returns The greatest common divisor of num1 and num2
|
|
1588
|
-
*/
|
|
1589
|
-
var getGreatestCommonDivisor = function getGreatestCommonDivisor(num1, num2) {
|
|
1590
|
-
var a = Math.abs(num1);
|
|
1591
|
-
var b = Math.abs(num2);
|
|
1592
|
-
while (a && b && a !== b) {
|
|
1593
|
-
if (a > b) {
|
|
1594
|
-
var _ref = [a - b, b];
|
|
1595
|
-
a = _ref[0];
|
|
1596
|
-
b = _ref[1];
|
|
1597
|
-
} else {
|
|
1598
|
-
var _ref2 = [a, b - a];
|
|
1599
|
-
a = _ref2[0];
|
|
1600
|
-
b = _ref2[1];
|
|
1601
|
-
}
|
|
1602
|
-
}
|
|
1603
|
-
return a || b;
|
|
1604
|
-
};
|
|
442
|
+
*/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;};
|
|
1605
443
|
|
|
1606
|
-
var _excluded$5
|
|
1607
|
-
/**
|
|
444
|
+
var _excluded$5=["timeBase","useGCD"];/**
|
|
1608
445
|
* Format seconds to TimeCode object
|
|
1609
|
-
*
|
|
446
|
+
*
|
|
447
|
+
* @remarks
|
|
448
|
+
* Input time base is always considered as 1:1 since it expects seconds as input
|
|
1610
449
|
*
|
|
1611
450
|
* Note: Max 15 digits accuracy (double precision float64), e.g.
|
|
1612
451
|
* - 10^6 seconds can have 10^9 decimals (nanosecond) precision
|
|
@@ -1618,117 +457,13 @@ var _excluded$5 = ["timeBase", "useGCD"];
|
|
|
1618
457
|
* @returns A TimeCode instance
|
|
1619
458
|
*
|
|
1620
459
|
* @category Time
|
|
1621
|
-
*/
|
|
1622
|
-
var formatTimeCodeSeconds = function formatTimeCodeSeconds(seconds, options) {
|
|
1623
|
-
var _ref = options || {},
|
|
1624
|
-
timeBase = _ref.timeBase,
|
|
1625
|
-
_ref$useGCD = _ref.useGCD,
|
|
1626
|
-
useGCD = _ref$useGCD === void 0 ? false : _ref$useGCD,
|
|
1627
|
-
timeCodeOptions = _objectWithoutProperties(_ref, _excluded$5);
|
|
1628
|
-
var secondsWithDot = "".concat(seconds).replace(/,/g, '.');
|
|
1629
|
-
if (Number.isNaN(+secondsWithDot)) {
|
|
1630
|
-
throw new Error("seconds must be digits, is ".concat(seconds));
|
|
1631
|
-
}
|
|
1632
|
-
var denominator = 1;
|
|
1633
|
-
var samples;
|
|
1634
|
-
if (Number.isInteger(+secondsWithDot)) {
|
|
1635
|
-
samples = +secondsWithDot * denominator;
|
|
1636
|
-
} else {
|
|
1637
|
-
var _ms$length;
|
|
1638
|
-
var _secondsWithDot$split = secondsWithDot.split('.'),
|
|
1639
|
-
_secondsWithDot$split2 = _slicedToArray(_secondsWithDot$split, 2),
|
|
1640
|
-
ms = _secondsWithDot$split2[1];
|
|
1641
|
-
var decimalPlaces = Math.min((_ms$length = ms === null || ms === void 0 ? void 0 : ms.length) !== null && _ms$length !== void 0 ? _ms$length : 0, 16);
|
|
1642
|
-
denominator *= Math.pow(10, decimalPlaces);
|
|
1643
|
-
samples = Math.round(Number(secondsWithDot) * denominator);
|
|
1644
|
-
}
|
|
1645
|
-
if (timeBase === undefined && useGCD) {
|
|
1646
|
-
var gcd = getGreatestCommonDivisor(denominator, samples);
|
|
1647
|
-
samples /= gcd;
|
|
1648
|
-
denominator /= gcd;
|
|
1649
|
-
}
|
|
1650
|
-
var timeCode = new TimeCode({
|
|
1651
|
-
samples: samples,
|
|
1652
|
-
timeBase: {
|
|
1653
|
-
denominator: denominator,
|
|
1654
|
-
numerator: 1
|
|
1655
|
-
}
|
|
1656
|
-
}, timeCodeOptions);
|
|
1657
|
-
return timeBase !== undefined ? timeCode.conformTimeBase(createTimeBase(timeBase)) : timeCode;
|
|
1658
|
-
};
|
|
460
|
+
*/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)):timeCode;};
|
|
1659
461
|
|
|
1660
|
-
var getDroppedFramesFromSmpte
|
|
1661
|
-
var _ref2 = _slicedToArray(_ref, 4),
|
|
1662
|
-
hh = _ref2[0],
|
|
1663
|
-
mm = _ref2[1],
|
|
1664
|
-
ss = _ref2[2],
|
|
1665
|
-
ff = _ref2[3];
|
|
1666
|
-
var roundedFrameRate = timeBase.toRate({
|
|
1667
|
-
rounded: true
|
|
1668
|
-
});
|
|
1669
|
-
var dropFrames = getAmountOfFrameDrops(timeBase);
|
|
1670
|
-
if (samples === 0 || !dropFrames) {
|
|
1671
|
-
return 0;
|
|
1672
|
-
}
|
|
1673
|
-
var shouldDropMinute = mm % 10 !== 0;
|
|
1674
|
-
var shouldDropSecond = shouldDropMinute && ss === 0;
|
|
1675
|
-
var hourFrames = hh * (3600 * roundedFrameRate - 54 * dropFrames);
|
|
1676
|
-
var minuteFrames = mm * 60 * roundedFrameRate - (mm - Math.ceil(mm / 10)) * dropFrames;
|
|
1677
|
-
var secondFrames = ss * roundedFrameRate - (shouldDropMinute && ss > 1 ? dropFrames : 0);
|
|
1678
|
-
if (shouldDropSecond && ff < dropFrames) {
|
|
1679
|
-
throw new Error("Frame does not exist for ".concat(timeBase.toConstant() || timeBase.toRate(), " drop-frame"));
|
|
1680
|
-
}
|
|
1681
|
-
var frameFrames = shouldDropSecond ? ff - dropFrames : ff;
|
|
1682
|
-
var samplesWithoutDroppedFrames = hourFrames + minuteFrames + secondFrames + frameFrames;
|
|
1683
|
-
return samples - samplesWithoutDroppedFrames;
|
|
1684
|
-
};
|
|
1685
|
-
var getSamplesFromSmpte = function getSamplesFromSmpte(smpteValues, timeBase, dropFrame) {
|
|
1686
|
-
var _smpteValues = _slicedToArray(smpteValues, 4),
|
|
1687
|
-
hh = _smpteValues[0],
|
|
1688
|
-
mm = _smpteValues[1],
|
|
1689
|
-
ss = _smpteValues[2],
|
|
1690
|
-
ff = _smpteValues[3];
|
|
1691
|
-
var roundedFrameRate = timeBase.toRate({
|
|
1692
|
-
rounded: true
|
|
1693
|
-
});
|
|
1694
|
-
var samples = hh * 3600 * roundedFrameRate + mm * 60 * roundedFrameRate + ss * roundedFrameRate + ff;
|
|
1695
|
-
return samples - (dropFrame ? getDroppedFramesFromSmpte(smpteValues, samples, timeBase) : 0);
|
|
1696
|
-
};
|
|
462
|
+
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);};
|
|
1697
463
|
|
|
1698
|
-
var splitSmpte
|
|
1699
|
-
var _ref = (smpte === null || smpte === void 0 ? void 0 : smpte.match(/[^0-9:\-_]/)) || [],
|
|
1700
|
-
_ref2 = _slicedToArray(_ref, 1),
|
|
1701
|
-
nonColonFrameSeparator = _ref2[0];
|
|
1702
|
-
var smpteValues = [];
|
|
1703
|
-
if (nonColonFrameSeparator) {
|
|
1704
|
-
var _smpte$split = smpte.split(nonColonFrameSeparator),
|
|
1705
|
-
_smpte$split2 = _slicedToArray(_smpte$split, 2),
|
|
1706
|
-
hhmmss = _smpte$split2[0],
|
|
1707
|
-
ff = _smpte$split2[1];
|
|
1708
|
-
smpteValues = [].concat(_toConsumableArray(hhmmss.split(':')), [ff]);
|
|
1709
|
-
} else {
|
|
1710
|
-
smpteValues = smpte.split(':');
|
|
1711
|
-
}
|
|
1712
|
-
if (smpteValues.length !== 4) {
|
|
1713
|
-
throw new Error('Invalid format, must be "##:##:##:##');
|
|
1714
|
-
}
|
|
1715
|
-
if (smpteValues.some(function (n) {
|
|
1716
|
-
return Number.isNaN(n);
|
|
1717
|
-
})) {
|
|
1718
|
-
throw new Error('Invalid format, values must be numbers');
|
|
1719
|
-
}
|
|
1720
|
-
var smpteFrameSeparator = nonColonFrameSeparator || ':';
|
|
1721
|
-
return {
|
|
1722
|
-
smpteValues: smpteValues.map(Number),
|
|
1723
|
-
smpteFrameSeparator: smpteFrameSeparator
|
|
1724
|
-
};
|
|
1725
|
-
};
|
|
464
|
+
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};};
|
|
1726
465
|
|
|
1727
|
-
var _excluded$4
|
|
1728
|
-
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; }
|
|
1729
|
-
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; }
|
|
1730
|
-
var EXCEEDING_OPTIONS = ['error', 'add', 'ignore'];
|
|
1731
|
-
/**
|
|
466
|
+
var _excluded$4=["exceedingMode","timeBase"];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 EXCEEDING_OPTIONS=['error','add','ignore'];/**
|
|
1732
467
|
* Format smpte text to a TimeCode Instance
|
|
1733
468
|
*
|
|
1734
469
|
* exceedingMode:
|
|
@@ -1741,139 +476,15 @@ var EXCEEDING_OPTIONS = ['error', 'add', 'ignore'];
|
|
|
1741
476
|
* @returns TimeCode instance created from smpte string
|
|
1742
477
|
*
|
|
1743
478
|
* @category Time
|
|
1744
|
-
*/
|
|
1745
|
-
var formatTimeCodeSmpte = function formatTimeCodeSmpte(smpte, options) {
|
|
1746
|
-
var _ref = options || {},
|
|
1747
|
-
_ref$exceedingMode = _ref.exceedingMode,
|
|
1748
|
-
exceedingMode = _ref$exceedingMode === void 0 ? 'error' : _ref$exceedingMode,
|
|
1749
|
-
timeBase = _ref.timeBase,
|
|
1750
|
-
timeCodeOptions = _objectWithoutProperties(_ref, _excluded$4);
|
|
1751
|
-
if ([null, undefined].includes(smpte)) {
|
|
1752
|
-
throw new Error("smpte cannot be undefined or null");
|
|
1753
|
-
}
|
|
1754
|
-
if (typeof smpte !== 'string') {
|
|
1755
|
-
throw new Error("smpte must be a string, is ".concat(JSON.stringify(smpte)));
|
|
1756
|
-
}
|
|
1757
|
-
var _splitSmpte = splitSmpte(smpte),
|
|
1758
|
-
smpteValues = _splitSmpte.smpteValues,
|
|
1759
|
-
smpteFrameSeparator = _splitSmpte.smpteFrameSeparator;
|
|
1760
|
-
var timeBaseInstance = createTimeBase(timeBase);
|
|
1761
|
-
var mergedOptions = _objectSpread$9(_objectSpread$9({}, timeCodeOptions), {}, {
|
|
1762
|
-
frameSeparator: (timeCodeOptions === null || timeCodeOptions === void 0 ? void 0 : timeCodeOptions.frameSeparator) || smpteFrameSeparator
|
|
1763
|
-
}, (timeCodeOptions === null || timeCodeOptions === void 0 ? void 0 : timeCodeOptions.dropFrame) === undefined ? {
|
|
1764
|
-
dropFrame: timeBase !== undefined ? isDropFrameTimeBase(timeBaseInstance) : [';', ','].includes(smpteFrameSeparator)
|
|
1765
|
-
} : {});
|
|
1766
|
-
var roundedFrameRate = timeBaseInstance.toRate({
|
|
1767
|
-
rounded: true
|
|
1768
|
-
});
|
|
1769
|
-
var maxFrame = Math.max(0, roundedFrameRate - 1);
|
|
1770
|
-
if (smpteValues.some(function (v) {
|
|
1771
|
-
return v < 0;
|
|
1772
|
-
})) {
|
|
1773
|
-
throw new Error('Negative values are not supported');
|
|
1774
|
-
}
|
|
1775
|
-
var samples;
|
|
1776
|
-
switch (exceedingMode) {
|
|
1777
|
-
case 'error':
|
|
1778
|
-
{
|
|
1779
|
-
var _smpteValues = _slicedToArray(smpteValues, 4),
|
|
1780
|
-
hours = _smpteValues[0],
|
|
1781
|
-
minutes = _smpteValues[1],
|
|
1782
|
-
seconds = _smpteValues[2],
|
|
1783
|
-
frames = _smpteValues[3];
|
|
1784
|
-
if (hours >= 100) {
|
|
1785
|
-
throw Error('Minutes has to be less than 60');
|
|
1786
|
-
}
|
|
1787
|
-
if (minutes >= 60) {
|
|
1788
|
-
throw Error('Minutes has to be less than 60');
|
|
1789
|
-
}
|
|
1790
|
-
if (seconds >= 60) {
|
|
1791
|
-
throw Error('Seconds has to be less than 60');
|
|
1792
|
-
}
|
|
1793
|
-
if (frames > maxFrame) {
|
|
1794
|
-
throw Error("Frames has to be less or equal to ".concat(maxFrame));
|
|
1795
|
-
}
|
|
1796
|
-
samples = getSamplesFromSmpte(smpteValues, timeBaseInstance, mergedOptions === null || mergedOptions === void 0 ? void 0 : mergedOptions.dropFrame);
|
|
1797
|
-
break;
|
|
1798
|
-
}
|
|
1799
|
-
case 'ignore':
|
|
1800
|
-
{
|
|
1801
|
-
var _smpteValues2 = _slicedToArray(smpteValues, 4),
|
|
1802
|
-
_hours = _smpteValues2[0],
|
|
1803
|
-
_minutes = _smpteValues2[1],
|
|
1804
|
-
_seconds = _smpteValues2[2],
|
|
1805
|
-
_frames = _smpteValues2[3];
|
|
1806
|
-
var truncatedSmpteValues = [Math.min(100, _hours), Math.min(59, _minutes), Math.min(59, _seconds), Math.min(maxFrame, _frames)];
|
|
1807
|
-
samples = getSamplesFromSmpte(truncatedSmpteValues, timeBaseInstance, mergedOptions === null || mergedOptions === void 0 ? void 0 : mergedOptions.dropFrame);
|
|
1808
|
-
break;
|
|
1809
|
-
}
|
|
1810
|
-
case 'add':
|
|
1811
|
-
{
|
|
1812
|
-
samples = getSamplesFromSmpte(smpteValues, timeBaseInstance, mergedOptions === null || mergedOptions === void 0 ? void 0 : mergedOptions.dropFrame);
|
|
1813
|
-
break;
|
|
1814
|
-
}
|
|
1815
|
-
default:
|
|
1816
|
-
{
|
|
1817
|
-
throw new Error("Invalid exceedingMode, options are ".concat(JSON.stringify(EXCEEDING_OPTIONS)));
|
|
1818
|
-
}
|
|
1819
|
-
}
|
|
1820
|
-
return new TimeCode({
|
|
1821
|
-
samples: samples,
|
|
1822
|
-
timeBase: timeBaseInstance
|
|
1823
|
-
}, mergedOptions);
|
|
1824
|
-
};
|
|
479
|
+
*/var formatTimeCodeSmpte=function formatTimeCodeSmpte(smpte,options){var _ref=options||{},_ref$exceedingMode=_ref.exceedingMode,exceedingMode=_ref$exceedingMode===void 0?'error':_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$9(_objectSpread$9({},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);};
|
|
1825
480
|
|
|
1826
|
-
var _excluded$3
|
|
1827
|
-
/**
|
|
481
|
+
var _excluded$3=["timeBase"];/**
|
|
1828
482
|
* Format text to a TimeCode instance
|
|
1829
483
|
*
|
|
1830
484
|
* @returns A TimeCode instance
|
|
1831
485
|
*
|
|
1832
486
|
* @category Time
|
|
1833
|
-
*/
|
|
1834
|
-
var formatTimeCodeText = function formatTimeCodeText(timeCodeText, options) {
|
|
1835
|
-
var _timeCodeObject;
|
|
1836
|
-
var _ref = options || {},
|
|
1837
|
-
timeBase = _ref.timeBase,
|
|
1838
|
-
timeCodeOptions = _objectWithoutProperties(_ref, _excluded$3);
|
|
1839
|
-
var timeCodeObject;
|
|
1840
|
-
if (timeCodeText === undefined) {
|
|
1841
|
-
timeCodeObject = {
|
|
1842
|
-
samples: 0
|
|
1843
|
-
};
|
|
1844
|
-
} else if (typeof timeCodeText === 'number') {
|
|
1845
|
-
timeCodeObject = {
|
|
1846
|
-
samples: timeCodeText
|
|
1847
|
-
};
|
|
1848
|
-
} else if (timeCodeText.includes('@')) {
|
|
1849
|
-
var _timeCodeText$split = timeCodeText.split('@'),
|
|
1850
|
-
_timeCodeText$split2 = _slicedToArray(_timeCodeText$split, 2),
|
|
1851
|
-
samplesString = _timeCodeText$split2[0],
|
|
1852
|
-
timeBaseText = _timeCodeText$split2[1];
|
|
1853
|
-
var samples = Number(samplesString);
|
|
1854
|
-
timeCodeObject = {
|
|
1855
|
-
samples: samples,
|
|
1856
|
-
timeBase: formatTimeBaseText(timeBaseText)
|
|
1857
|
-
};
|
|
1858
|
-
} else if (timeCodeText === '-INF') {
|
|
1859
|
-
timeCodeObject = {
|
|
1860
|
-
samples: -Infinity
|
|
1861
|
-
};
|
|
1862
|
-
} else if (timeCodeText === '+INF') {
|
|
1863
|
-
timeCodeObject = {
|
|
1864
|
-
samples: Infinity
|
|
1865
|
-
};
|
|
1866
|
-
} else {
|
|
1867
|
-
timeCodeObject = {
|
|
1868
|
-
samples: Number(timeCodeText)
|
|
1869
|
-
};
|
|
1870
|
-
}
|
|
1871
|
-
if (Number.isNaN((_timeCodeObject = timeCodeObject) === null || _timeCodeObject === void 0 ? void 0 : _timeCodeObject.samples) || timeCodeObject.timeBase && !(timeCodeObject.timeBase instanceof TimeBase)) {
|
|
1872
|
-
throw new Error("timeCodeText must be a number or sample@timeBase - is ".concat(timeCodeText));
|
|
1873
|
-
}
|
|
1874
|
-
var timeCode = new TimeCode(timeCodeObject, timeCodeOptions);
|
|
1875
|
-
return timeBase ? timeCode.conformTimeBase(createTimeBase(timeBase)) : timeCode;
|
|
1876
|
-
};
|
|
487
|
+
*/var formatTimeCodeText=function formatTimeCodeText(timeCodeText,options){var _timeCodeObject;var _ref=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)):timeCode;};
|
|
1877
488
|
|
|
1878
489
|
/**
|
|
1879
490
|
* Format an object to a TimeCode instance
|
|
@@ -1883,18 +494,9 @@ var formatTimeCodeText = function formatTimeCodeText(timeCodeText, options) {
|
|
|
1883
494
|
* @returns A TimeCode instance
|
|
1884
495
|
*
|
|
1885
496
|
* @category Time
|
|
1886
|
-
*/
|
|
1887
|
-
var formatTimeCodeType = function formatTimeCodeType(timeCode, options) {
|
|
1888
|
-
return new TimeCode(timeCode, options);
|
|
1889
|
-
};
|
|
497
|
+
*/var formatTimeCodeType=function formatTimeCodeType(timeCode,options){return new TimeCode(timeCode,options);};
|
|
1890
498
|
|
|
1891
|
-
var hasSmpteFormat
|
|
1892
|
-
return !!s.match(/^(\d\d+):(\d\d+):(\d\d+)(:|;|\.|,)(\d\d+)$/);
|
|
1893
|
-
};
|
|
1894
|
-
var isNumber = function isNumber(s) {
|
|
1895
|
-
return !Number.isNaN(Number(s));
|
|
1896
|
-
};
|
|
1897
|
-
/**
|
|
499
|
+
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));};/**
|
|
1898
500
|
* Create a TimeCode instance from smpte, seconds/samples, timeCode object or string
|
|
1899
501
|
*
|
|
1900
502
|
* @param timeCode Smpte, seconds/samples, timeCode object or string
|
|
@@ -1902,42 +504,11 @@ var isNumber = function isNumber(s) {
|
|
|
1902
504
|
* @returns A TimeCode instance
|
|
1903
505
|
*
|
|
1904
506
|
* @category Time
|
|
1905
|
-
*/
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
if (typeof timeCode !== 'string' && typeof timeCode !== 'number') return formatTimeCodeType(timeCode, options);
|
|
1909
|
-
// SMPTE
|
|
1910
|
-
if (typeof timeCode === 'string' && hasSmpteFormat(timeCode)) return formatTimeCodeSmpte(timeCode, options);
|
|
1911
|
-
if (['string', 'number'].includes(_typeof(timeCode)) && isNumber(timeCode)) return formatTimeCodeSeconds(timeCode, options);
|
|
1912
|
-
if (typeof timeCode === 'string') {
|
|
1913
|
-
return formatTimeCodeText(timeCode, options);
|
|
1914
|
-
}
|
|
1915
|
-
return undefined;
|
|
1916
|
-
};
|
|
1917
|
-
|
|
1918
|
-
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; }
|
|
1919
|
-
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; }
|
|
1920
|
-
function timeToCueTime(_ref) {
|
|
1921
|
-
var _ref$hours = _ref.hours,
|
|
1922
|
-
hours = _ref$hours === void 0 ? 0 : _ref$hours,
|
|
1923
|
-
_ref$minutes = _ref.minutes,
|
|
1924
|
-
minutes = _ref$minutes === void 0 ? 0 : _ref$minutes,
|
|
1925
|
-
_ref$seconds = _ref.seconds,
|
|
1926
|
-
seconds = _ref$seconds === void 0 ? 0 : _ref$seconds,
|
|
1927
|
-
_ref$partialSeconds = _ref.partialSeconds,
|
|
1928
|
-
partialSeconds = _ref$partialSeconds === void 0 ? 0 : _ref$partialSeconds;
|
|
1929
|
-
var hourStr = hours.toFixed().padStart(2, '0');
|
|
1930
|
-
var minStr = minutes.toFixed().padStart(2, '0');
|
|
1931
|
-
var secondsStr = seconds.toFixed().padStart(2, '0');
|
|
1932
|
-
var partialStr = (partialSeconds * 10).toFixed().padStart(3, '0');
|
|
1933
|
-
return "".concat(hourStr, ":").concat(minStr, ":").concat(secondsStr, ".").concat(partialStr);
|
|
1934
|
-
}
|
|
1935
|
-
var defaultOptions$2 = {
|
|
1936
|
-
subtitleGroup: 'stl_subtitle',
|
|
1937
|
-
subtitleField: 'stl_text'
|
|
1938
|
-
};
|
|
507
|
+
*/var createTimeCode=function createTimeCode(timeCode,options){// TimeCode
|
|
508
|
+
if(typeof timeCode!=='string'&&typeof timeCode!=='number')return formatTimeCodeType(timeCode,options);// SMPTE
|
|
509
|
+
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;};
|
|
1939
510
|
|
|
1940
|
-
|
|
511
|
+
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'};/**
|
|
1941
512
|
* Convert metadata subtitle groups to WebVtt subtitles
|
|
1942
513
|
*
|
|
1943
514
|
* @param metadataType - Vidicore metadata object (should include subtitleGroup and subtitleField)
|
|
@@ -1945,36 +516,7 @@ var defaultOptions$2 = {
|
|
|
1945
516
|
* @returns WebVtt subtitles
|
|
1946
517
|
*
|
|
1947
518
|
* @category Metadata
|
|
1948
|
-
*/
|
|
1949
|
-
var metadataTypeToWebVtt = function metadataTypeToWebVtt(metadataType, options) {
|
|
1950
|
-
var _defaultOptions = _objectSpread$8(_objectSpread$8({}, defaultOptions$2), options || {}),
|
|
1951
|
-
subtitleGroup = _defaultOptions.subtitleGroup,
|
|
1952
|
-
subtitleField = _defaultOptions.subtitleField;
|
|
1953
|
-
var _ref2 = metadataType || {},
|
|
1954
|
-
_ref2$timespan = _ref2.timespan,
|
|
1955
|
-
timespanList = _ref2$timespan === void 0 ? [] : _ref2$timespan;
|
|
1956
|
-
if (timespanList.length === 0) return '';
|
|
1957
|
-
var parsedTimespans = parseTimespanList(timespanList, {
|
|
1958
|
-
includeTimespanAttributes: true,
|
|
1959
|
-
sortTimespan: true,
|
|
1960
|
-
timespanAsList: true,
|
|
1961
|
-
overrideGroup: true,
|
|
1962
|
-
joinValue: ','
|
|
1963
|
-
});
|
|
1964
|
-
var vttCues = parsedTimespans.map(function (timespan) {
|
|
1965
|
-
var _ref3 = (Array.isArray(timespan) ? timespan[0] : timespan) || {},
|
|
1966
|
-
startText = _ref3.start,
|
|
1967
|
-
endText = _ref3.end,
|
|
1968
|
-
_ref3$subtitleGroup = _ref3[subtitleGroup];
|
|
1969
|
-
_ref3$subtitleGroup = _ref3$subtitleGroup === void 0 ? {} : _ref3$subtitleGroup;
|
|
1970
|
-
var text = _ref3$subtitleGroup[subtitleField];
|
|
1971
|
-
if (!text) return '';
|
|
1972
|
-
var start = timeToCueTime(formatTimeCodeText(startText).toTime());
|
|
1973
|
-
var end = timeToCueTime(formatTimeCodeText(endText).toTime());
|
|
1974
|
-
return "".concat(start, " --> ").concat(end, " line:0%\r").concat(text, "\r");
|
|
1975
|
-
});
|
|
1976
|
-
return "WEBVTT\n\n\n".concat(vttCues.join('\n'));
|
|
1977
|
-
};
|
|
519
|
+
*/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'));};
|
|
1978
520
|
|
|
1979
521
|
/**
|
|
1980
522
|
* Create a Vidicore facet list
|
|
@@ -1984,109 +526,27 @@ var metadataTypeToWebVtt = function metadataTypeToWebVtt(metadataType, options)
|
|
|
1984
526
|
* @returns A VidiCore facet list
|
|
1985
527
|
*
|
|
1986
528
|
* @category Search
|
|
1987
|
-
*/
|
|
1988
|
-
var createFacetType = function createFacetType() {
|
|
1989
|
-
var fieldList = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
1990
|
-
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
|
|
1991
|
-
count: true
|
|
1992
|
-
};
|
|
1993
|
-
return fieldList.map(function (field) {
|
|
1994
|
-
return {
|
|
1995
|
-
field: field,
|
|
1996
|
-
name: field,
|
|
1997
|
-
count: options.count !== undefined ? options === null || options === void 0 ? void 0 : options.count : true,
|
|
1998
|
-
exclude: fieldList
|
|
1999
|
-
};
|
|
2000
|
-
});
|
|
2001
|
-
};
|
|
2002
|
-
|
|
2003
|
-
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; }
|
|
2004
|
-
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; }
|
|
2005
|
-
/** Parsed facet type */
|
|
529
|
+
*/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};});};
|
|
2006
530
|
|
|
2007
|
-
/**
|
|
531
|
+
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 */ /**
|
|
2008
532
|
* Parse a VidiCore facet type list
|
|
2009
533
|
*
|
|
2010
534
|
* @param facetType A facet type list to parse
|
|
2011
535
|
* @returns A parsed facet type list
|
|
2012
536
|
*
|
|
2013
537
|
* @category Search
|
|
2014
|
-
*/
|
|
2015
|
-
var parseFacetType = function parseFacetType() {
|
|
2016
|
-
var facetType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
2017
|
-
var output = {};
|
|
2018
|
-
facetType.forEach(function (_ref) {
|
|
2019
|
-
var name = _ref.name,
|
|
2020
|
-
field = _ref.field,
|
|
2021
|
-
count = _ref.count;
|
|
2022
|
-
output[name || field] = count.reduce(function (acc, _ref2) {
|
|
2023
|
-
var fieldValue = _ref2.fieldValue,
|
|
2024
|
-
value = _ref2.value;
|
|
2025
|
-
return _objectSpread$7(_objectSpread$7({}, acc), {}, _defineProperty({}, fieldValue, value));
|
|
2026
|
-
}, {});
|
|
2027
|
-
});
|
|
2028
|
-
return output;
|
|
2029
|
-
};
|
|
2030
|
-
|
|
2031
|
-
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; }
|
|
2032
|
-
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; }
|
|
2033
|
-
var defaultOptions$1 = {
|
|
2034
|
-
arrayOnSingle: true,
|
|
2035
|
-
joinValue: undefined,
|
|
2036
|
-
timespanAsList: false
|
|
2037
|
-
};
|
|
538
|
+
*/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;};
|
|
2038
539
|
|
|
2039
|
-
|
|
540
|
+
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};/**
|
|
2040
541
|
* Parses highlight timespan in VidiCore into key/value object.
|
|
2041
542
|
* The attributes can be targeted for each sub-type.
|
|
2042
543
|
* @param timespan - A VidiCore search timespan
|
|
2043
544
|
* @param options - Options which change how the timespans are parsed
|
|
2044
545
|
*
|
|
2045
546
|
* @category Search
|
|
2046
|
-
*/
|
|
2047
|
-
var parseHighlightTimespan = function parseHighlightTimespan(timespan, options) {
|
|
2048
|
-
var _defaultOptions = _objectSpread$6(_objectSpread$6({}, defaultOptions$1), options || {}),
|
|
2049
|
-
_defaultOptions$array = _defaultOptions.arrayOnSingle,
|
|
2050
|
-
arrayOnSingle = _defaultOptions$array === void 0 ? true : _defaultOptions$array,
|
|
2051
|
-
_defaultOptions$joinV = _defaultOptions.joinValue,
|
|
2052
|
-
joinValue = _defaultOptions$joinV === void 0 ? undefined : _defaultOptions$joinV,
|
|
2053
|
-
_defaultOptions$times = _defaultOptions.timespanAsList,
|
|
2054
|
-
timespanAsList = _defaultOptions$times === void 0 ? false : _defaultOptions$times;
|
|
2055
|
-
var _ref = timespan || {},
|
|
2056
|
-
_ref$field = _ref.field,
|
|
2057
|
-
field = _ref$field === void 0 ? [] : _ref$field,
|
|
2058
|
-
start = _ref.start,
|
|
2059
|
-
end = _ref.end;
|
|
2060
|
-
var initialValue = timespanAsList ? {
|
|
2061
|
-
start: start,
|
|
2062
|
-
end: end
|
|
2063
|
-
} : {};
|
|
2064
|
-
var fieldList = field.reduce(function (acc, curr) {
|
|
2065
|
-
var name = curr.name,
|
|
2066
|
-
_curr$value = curr.value,
|
|
2067
|
-
valueList = _curr$value === void 0 ? [] : _curr$value;
|
|
2068
|
-
if (valueList.length === 0) return acc;
|
|
2069
|
-
var fieldValue;
|
|
2070
|
-
if (arrayOnSingle === false && valueList.length === 1) {
|
|
2071
|
-
var _valueList = _slicedToArray(valueList, 1);
|
|
2072
|
-
fieldValue = _valueList[0];
|
|
2073
|
-
} else if (joinValue) fieldValue = valueList.join(joinValue);else fieldValue = valueList;
|
|
2074
|
-
return _objectSpread$6(_objectSpread$6({}, acc), {}, _defineProperty({}, name, fieldValue));
|
|
2075
|
-
}, initialValue);
|
|
2076
|
-
return fieldList;
|
|
2077
|
-
};
|
|
2078
|
-
|
|
2079
|
-
var _excluded$2 = ["timespanAsList", "joinTimespan", "flat", "flatTimespan"];
|
|
2080
|
-
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; }
|
|
2081
|
-
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; }
|
|
2082
|
-
var defaultOptions = _objectSpread$5(_objectSpread$5({}, defaultOptions$1), {}, {
|
|
2083
|
-
timespanAsList: false,
|
|
2084
|
-
joinTimespan: '_',
|
|
2085
|
-
flat: false,
|
|
2086
|
-
flatTimespan: false
|
|
2087
|
-
});
|
|
547
|
+
*/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;};
|
|
2088
548
|
|
|
2089
|
-
|
|
549
|
+
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});/**
|
|
2090
550
|
* Parses highlight timespans from VidiCore into key/value object.
|
|
2091
551
|
* The attributes can be targeted for each sub-type.
|
|
2092
552
|
*
|
|
@@ -2094,355 +554,78 @@ var defaultOptions = _objectSpread$5(_objectSpread$5({}, defaultOptions$1), {},
|
|
|
2094
554
|
* @param options - Options to change how the timespans are parsed
|
|
2095
555
|
*
|
|
2096
556
|
* @category Search
|
|
2097
|
-
*/
|
|
2098
|
-
var parseHighlightTimespanList = function parseHighlightTimespanList() {
|
|
2099
|
-
var highlightTimespanList = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
2100
|
-
var options = arguments.length > 1 ? arguments[1] : undefined;
|
|
2101
|
-
var _defaultOptions = _objectSpread$5(_objectSpread$5({}, defaultOptions), options || {}),
|
|
2102
|
-
timespanAsList = _defaultOptions.timespanAsList,
|
|
2103
|
-
_defaultOptions$joinT = _defaultOptions.joinTimespan,
|
|
2104
|
-
joinTimespan = _defaultOptions$joinT === void 0 ? '_' : _defaultOptions$joinT,
|
|
2105
|
-
flat = _defaultOptions.flat,
|
|
2106
|
-
flatTimespan = _defaultOptions.flatTimespan,
|
|
2107
|
-
parseHighlightTimespanOptions = _objectWithoutProperties(_defaultOptions, _excluded$2);
|
|
2108
|
-
if (timespanAsList === true) return highlightTimespanList.map(function (timespan) {
|
|
2109
|
-
return parseHighlightTimespan(timespan, _objectSpread$5(_objectSpread$5({}, parseHighlightTimespanOptions), {}, {
|
|
2110
|
-
timespanAsList: timespanAsList
|
|
2111
|
-
}));
|
|
2112
|
-
});
|
|
2113
|
-
if (flat === true || flatTimespan === true) return highlightTimespanList.reduce(function (a, timespan) {
|
|
2114
|
-
return _objectSpread$5(_objectSpread$5({}, a), parseHighlightTimespan(timespan, options));
|
|
2115
|
-
}, {});
|
|
2116
|
-
return highlightTimespanList.reduce(function (a, timespan) {
|
|
2117
|
-
return _objectSpread$5(_objectSpread$5({}, a), {}, _defineProperty({}, [timespan.start, timespan.end].join(joinTimespan), parseHighlightTimespan(timespan, options)));
|
|
2118
|
-
}, {});
|
|
2119
|
-
};
|
|
557
|
+
*/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)));},{});};
|
|
2120
558
|
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
break;
|
|
2135
|
-
case 'DAY':
|
|
2136
|
-
case 'DAYS':
|
|
2137
|
-
if (sign === '+') nowDiff.setDate(nowDiff.getDate() + number);
|
|
2138
|
-
if (sign === '-') nowDiff.setDate(nowDiff.getDate() - number);
|
|
2139
|
-
break;
|
|
2140
|
-
case 'MONTH':
|
|
2141
|
-
case 'MONTHS':
|
|
2142
|
-
if (sign === '+') nowDiff.setMonth(nowDiff.getMonth() + number);
|
|
2143
|
-
if (sign === '-') nowDiff.setMonth(nowDiff.getMonth() - number);
|
|
2144
|
-
break;
|
|
2145
|
-
case 'YEAR':
|
|
2146
|
-
case 'YEARS':
|
|
2147
|
-
if (sign === '+') nowDiff.setFullYear(nowDiff.getFullYear() + number);
|
|
2148
|
-
if (sign === '-') nowDiff.setFullYear(nowDiff.getFullYear() - number);
|
|
2149
|
-
break;
|
|
2150
|
-
}
|
|
2151
|
-
return nowDiff;
|
|
2152
|
-
}
|
|
2153
|
-
return new Date(value);
|
|
2154
|
-
};
|
|
559
|
+
/**
|
|
560
|
+
* Parse Vidicore "NOW" constants to a date object
|
|
561
|
+
*
|
|
562
|
+
* Format: `NOW[+/-][number][HOUR/DAY/MONTH/YEAR(s)]` (e.g. "NOW-2HOURS")
|
|
563
|
+
*
|
|
564
|
+
* @remarks
|
|
565
|
+
* Returns an approximate date since it's created client side
|
|
566
|
+
*
|
|
567
|
+
* @param value A "NOW" constant
|
|
568
|
+
* @returns A date from the NOW constant
|
|
569
|
+
*
|
|
570
|
+
* @category Search
|
|
571
|
+
*/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);};
|
|
2155
572
|
|
|
2156
|
-
var _excluded$1
|
|
2157
|
-
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; }
|
|
2158
|
-
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; }
|
|
2159
|
-
var parseBaseMediaInfoType = function parseBaseMediaInfoType(baseMediaInfoType) {
|
|
2160
|
-
var _ref = baseMediaInfoType || {},
|
|
2161
|
-
_ref$property = _ref.property,
|
|
2162
|
-
keyValuePairTypes = _ref$property === void 0 ? [] : _ref$property,
|
|
2163
|
-
props = _objectWithoutProperties(_ref, _excluded$1);
|
|
2164
|
-
var parsedKeyValuePairType = parseKeyValuePairTypes(keyValuePairTypes);
|
|
2165
|
-
return _objectSpread$4(_objectSpread$4({}, parsedKeyValuePairType), props);
|
|
2166
|
-
};
|
|
2167
|
-
var parseAudioMediaInfoType = function parseAudioMediaInfoType(mediaInfoType) {
|
|
2168
|
-
return parseBaseMediaInfoType(mediaInfoType);
|
|
2169
|
-
};
|
|
2170
|
-
var parseVideoMediaInfoType = function parseVideoMediaInfoType(mediaInfoType) {
|
|
2171
|
-
return parseBaseMediaInfoType(mediaInfoType);
|
|
2172
|
-
};
|
|
573
|
+
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);};
|
|
2173
574
|
|
|
2174
|
-
var sampleRateSymbols =
|
|
2175
|
-
kB: 'kHz',
|
|
2176
|
-
B: 'Hz',
|
|
2177
|
-
mB: 'mHz'
|
|
2178
|
-
};
|
|
2179
|
-
var bitRateSymbols = {
|
|
2180
|
-
kB: 'kbps',
|
|
2181
|
-
B: 'bps',
|
|
2182
|
-
MB: 'mbps'
|
|
2183
|
-
};
|
|
2184
|
-
/**
|
|
575
|
+
var sampleRateSymbols={kB:'kHz',B:'Hz',mB:'mHz'};var bitRateSymbols$1={kB:'kbps',B:'bps',MB:'mbps'};/**
|
|
2185
576
|
* Parses the technical information of a AudioComponentType.
|
|
2186
577
|
* @param audioComponentType - A AudioComponentType from VidiCore.
|
|
2187
578
|
* @returns Parsed component object.
|
|
2188
579
|
*
|
|
2189
580
|
* @category Shape
|
|
2190
|
-
*/
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
var audioMediaInfo = parseAudioMediaInfoType(mediaInfo);
|
|
2199
|
-
var audioFormat = audioMediaInfo.Format,
|
|
2200
|
-
audioBitDepth = audioMediaInfo.Resolution,
|
|
2201
|
-
audioBitRateMode = audioMediaInfo.Bit_rate_mode;
|
|
2202
|
-
var audioMetadata = parseKeyValuePairTypes(metadata || []);
|
|
2203
|
-
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;
|
|
2204
|
-
var audioSamplerate = audioSamplerateSamples !== undefined ? parseFileSize(audioSamplerateSamples, {
|
|
2205
|
-
base: 10,
|
|
2206
|
-
round: 1,
|
|
2207
|
-
symbols: sampleRateSymbols
|
|
2208
|
-
}) : undefined;
|
|
2209
|
-
var audioBitrate = bitrate !== undefined ? parseFileSize(bitrate, {
|
|
2210
|
-
base: 10,
|
|
2211
|
-
round: 2,
|
|
2212
|
-
symbols: bitRateSymbols
|
|
2213
|
-
}) : undefined;
|
|
2214
|
-
return {
|
|
2215
|
-
audioFormat: audioFormat,
|
|
2216
|
-
audioCodec: audioCodec,
|
|
2217
|
-
audioSamplerate: audioSamplerate,
|
|
2218
|
-
audioSamplerateSamples: audioSamplerateSamples,
|
|
2219
|
-
audioBitDepth: audioBitDepth,
|
|
2220
|
-
audioBitrate: audioBitrate,
|
|
2221
|
-
audioBitRateMode: audioBitRateMode,
|
|
2222
|
-
audioChannels: audioChannels,
|
|
2223
|
-
audioMediaInfo: audioMediaInfo,
|
|
2224
|
-
audioMetadata: audioMetadata
|
|
2225
|
-
};
|
|
2226
|
-
};
|
|
581
|
+
*/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};};
|
|
582
|
+
|
|
583
|
+
/**
|
|
584
|
+
* Const object with all file states in VidiCore
|
|
585
|
+
* (see https://apidoc.vidispine.com/latest/storage/storage.html#file-states for more info)
|
|
586
|
+
*
|
|
587
|
+
* @category File
|
|
588
|
+
*/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'};
|
|
2227
589
|
|
|
2228
590
|
/**
|
|
2229
591
|
* Parses a VidiCore file object
|
|
2230
592
|
*
|
|
593
|
+
* @remarks
|
|
594
|
+
* File sizes are parsed with JEDEC standard (base 2)
|
|
595
|
+
*
|
|
2231
596
|
* @param fileType VidiCore file object
|
|
2232
597
|
* @returns A parsed file object
|
|
2233
598
|
*
|
|
2234
599
|
* @category File
|
|
2235
|
-
*/
|
|
2236
|
-
var parseFileType = function parseFileType(fileType) {
|
|
2237
|
-
var _fileType$uri = fileType.uri,
|
|
2238
|
-
uriList = _fileType$uri === void 0 ? [] : _fileType$uri,
|
|
2239
|
-
fileSizeBytes = fileType.size,
|
|
2240
|
-
hash = fileType.hash,
|
|
2241
|
-
path = fileType.path,
|
|
2242
|
-
fileId = fileType.id;
|
|
2243
|
-
var _uriList = _slicedToArray(uriList, 1),
|
|
2244
|
-
uri = _uriList[0];
|
|
2245
|
-
var fileSize = fileSizeBytes !== undefined ? parseFileSize(fileSizeBytes) : '';
|
|
2246
|
-
var fileName = path ? path.split('/').pop() : undefined;
|
|
2247
|
-
return {
|
|
2248
|
-
uri: uri,
|
|
2249
|
-
hash: hash,
|
|
2250
|
-
fileSize: fileSize,
|
|
2251
|
-
fileSizeBytes: fileSizeBytes,
|
|
2252
|
-
path: path,
|
|
2253
|
-
fileName: fileName,
|
|
2254
|
-
fileId: fileId
|
|
2255
|
-
};
|
|
2256
|
-
};
|
|
600
|
+
*/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};};
|
|
2257
601
|
|
|
2258
|
-
function ownKeys$3(object,
|
|
2259
|
-
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; }
|
|
2260
|
-
/**
|
|
602
|
+
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;}/**
|
|
2261
603
|
* Parses the technical information of a BinaryComponentType.
|
|
2262
604
|
* @param binaryComponentType - A BinaryComponentType from VidiCore.
|
|
2263
605
|
* @returns Parsed component object.
|
|
2264
606
|
*
|
|
2265
607
|
* @category Shape
|
|
2266
|
-
*/
|
|
2267
|
-
var parseBinaryComponent = function parseBinaryComponent() {
|
|
2268
|
-
var binaryComponentType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
2269
|
-
var fileList = binaryComponentType.file,
|
|
2270
|
-
mediaInfo = binaryComponentType.mediaInfo,
|
|
2271
|
-
_binaryComponentType$ = binaryComponentType.metadata,
|
|
2272
|
-
metadata = _binaryComponentType$ === void 0 ? [] : _binaryComponentType$;
|
|
2273
|
-
var binaryMetadata = parseKeyValuePairTypes(metadata);
|
|
2274
|
-
var binaryMediaInfo = parseBaseMediaInfoType(mediaInfo);
|
|
2275
|
-
var parsedBinaryComponent = {
|
|
2276
|
-
binaryMetadata: binaryMetadata,
|
|
2277
|
-
binaryMediaInfo: binaryMediaInfo
|
|
2278
|
-
};
|
|
2279
|
-
if (fileList) {
|
|
2280
|
-
var _fileList = _slicedToArray(fileList, 1),
|
|
2281
|
-
fileType = _fileList[0];
|
|
2282
|
-
var parsedFileType = parseFileType(fileType);
|
|
2283
|
-
parsedBinaryComponent = _objectSpread$3(_objectSpread$3({}, parsedBinaryComponent), parsedFileType);
|
|
2284
|
-
}
|
|
2285
|
-
return parsedBinaryComponent;
|
|
2286
|
-
};
|
|
2287
|
-
|
|
2288
|
-
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; }
|
|
2289
|
-
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; }
|
|
608
|
+
*/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;};
|
|
2290
609
|
|
|
2291
|
-
/**
|
|
610
|
+
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;}/**
|
|
2292
611
|
* Parsed container component
|
|
2293
|
-
*/
|
|
2294
|
-
|
|
2295
|
-
/**
|
|
612
|
+
*/ /**
|
|
2296
613
|
* Parses the technical information of a ContainerComponentType.
|
|
2297
614
|
* @param containerComponentType - A ContainerComponentType from VidiCore.
|
|
2298
615
|
* @returns Parsed component object.
|
|
2299
616
|
*
|
|
2300
617
|
* @category Shape
|
|
2301
|
-
*/
|
|
2302
|
-
var parseContainerComponent = function parseContainerComponent() {
|
|
2303
|
-
var containerComponentType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
2304
|
-
var mediaInfo = containerComponentType.mediaInfo,
|
|
2305
|
-
metadata = containerComponentType.metadata,
|
|
2306
|
-
fileList = containerComponentType.file,
|
|
2307
|
-
durationTimeCode = containerComponentType.duration,
|
|
2308
|
-
startTimestamp = containerComponentType.startTimestamp,
|
|
2309
|
-
startTimecode = containerComponentType.startTimecode,
|
|
2310
|
-
timeCodeTimeBase = containerComponentType.timeCodeTimeBase;
|
|
2311
|
-
var containerMetadata = parseKeyValuePairTypes(metadata || []);
|
|
2312
|
-
var containerMediaInfo = parseBaseMediaInfoType(mediaInfo);
|
|
2313
|
-
var containerFormat = containerMediaInfo.Format;
|
|
2314
|
-
var videoFormat = containerMediaInfo.Video_Format_List,
|
|
2315
|
-
audioFormat = containerMediaInfo.Audio_Format_List,
|
|
2316
|
-
textFormat = containerMediaInfo.Text_Format_List;
|
|
2317
|
-
if (containerFormat === undefined) {
|
|
2318
|
-
var format = containerComponentType.format;
|
|
2319
|
-
containerFormat = format;
|
|
2320
|
-
if (format && format.includes(',')) {
|
|
2321
|
-
var formatList = format.split(',');
|
|
2322
|
-
var _formatList = _slicedToArray(formatList, 1);
|
|
2323
|
-
containerFormat = _formatList[0];
|
|
2324
|
-
}
|
|
2325
|
-
}
|
|
2326
|
-
var parsedContainerComponentType = {
|
|
2327
|
-
containerFormat: containerFormat,
|
|
2328
|
-
videoFormat: videoFormat,
|
|
2329
|
-
audioFormat: audioFormat,
|
|
2330
|
-
textFormat: textFormat,
|
|
2331
|
-
containerMetadata: containerMetadata,
|
|
2332
|
-
containerMediaInfo: containerMediaInfo
|
|
2333
|
-
};
|
|
2334
|
-
if (containerMetadata.componentOriginalFilename) {
|
|
2335
|
-
parsedContainerComponentType.originalFilename = containerMetadata.componentOriginalFilename;
|
|
2336
|
-
}
|
|
2337
|
-
if (durationTimeCode !== undefined && durationTimeCode.samples !== 0) {
|
|
2338
|
-
var timeCode = formatTimeCodeType(durationTimeCode);
|
|
2339
|
-
parsedContainerComponentType.durationTimeCode = timeCode.toObject();
|
|
2340
|
-
parsedContainerComponentType.duration = timeCode.toDuration();
|
|
2341
|
-
}
|
|
2342
|
-
if (startTimestamp) {
|
|
2343
|
-
parsedContainerComponentType.startTimestamp = formatTimeCodeType(startTimestamp).toObject();
|
|
2344
|
-
}
|
|
2345
|
-
if (startTimecode !== undefined && timeCodeTimeBase) {
|
|
2346
|
-
parsedContainerComponentType.startTimecode = formatTimeCodeType({
|
|
2347
|
-
samples: startTimecode,
|
|
2348
|
-
timeBase: timeCodeTimeBase
|
|
2349
|
-
});
|
|
2350
|
-
}
|
|
2351
|
-
if (fileList) {
|
|
2352
|
-
var _fileList = _slicedToArray(fileList, 1),
|
|
2353
|
-
fileType = _fileList[0];
|
|
2354
|
-
var parsedFileType = parseFileType(fileType);
|
|
2355
|
-
parsedContainerComponentType = _objectSpread$2(_objectSpread$2({}, parsedContainerComponentType), parsedFileType);
|
|
2356
|
-
}
|
|
2357
|
-
return parsedContainerComponentType;
|
|
2358
|
-
};
|
|
618
|
+
*/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;};
|
|
2359
619
|
|
|
2360
|
-
|
|
620
|
+
var bitRateSymbols={kB:'kbps',B:'bps',MB:'mbps'};/**
|
|
2361
621
|
* Parses the technical information of a VideoComponentType.
|
|
2362
622
|
* @param {Object} videoComponentType - A VideoComponentType from VidiCore.
|
|
2363
623
|
* @returns {Object} Parsed component object.
|
|
2364
624
|
*
|
|
2365
625
|
* @category Shape
|
|
2366
|
-
*/
|
|
2367
|
-
var parseVideoComponent = function parseVideoComponent() {
|
|
2368
|
-
var videoComponentType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
2369
|
-
var videoCodec = videoComponentType.codec,
|
|
2370
|
-
bitrate = videoComponentType.bitrate,
|
|
2371
|
-
fieldOrder = videoComponentType.fieldOrder,
|
|
2372
|
-
resolution = videoComponentType.resolution,
|
|
2373
|
-
mediaInfo = videoComponentType.mediaInfo,
|
|
2374
|
-
_videoComponentType$m = videoComponentType.metadata,
|
|
2375
|
-
metadata = _videoComponentType$m === void 0 ? [] : _videoComponentType$m;
|
|
2376
|
-
var videoMediaInfo = parseVideoMediaInfoType(mediaInfo);
|
|
2377
|
-
var videoMetadata = parseKeyValuePairTypes(metadata);
|
|
2378
|
-
var videoFormat = videoMediaInfo.Format,
|
|
2379
|
-
timeBaseText = videoMediaInfo['Frame rate'],
|
|
2380
|
-
colorSpace = videoMediaInfo['Color space'],
|
|
2381
|
-
colorPrimaries = videoMediaInfo['Color primaries'],
|
|
2382
|
-
chromaSubsampling = videoMediaInfo.Colorimetry;
|
|
2383
|
-
var timeBase;
|
|
2384
|
-
var averageFrameRate = videoComponentType.averageFrameRate,
|
|
2385
|
-
realBaseFrameRate = videoComponentType.realBaseFrameRate;
|
|
2386
|
-
if (realBaseFrameRate !== undefined) {
|
|
2387
|
-
timeBase = formatTimeBaseType({
|
|
2388
|
-
numerator: realBaseFrameRate.denominator,
|
|
2389
|
-
denominator: realBaseFrameRate.numerator
|
|
2390
|
-
});
|
|
2391
|
-
} else if (timeBaseText !== undefined) {
|
|
2392
|
-
timeBase = formatTimeBaseText(timeBaseText);
|
|
2393
|
-
} else if (averageFrameRate !== undefined) {
|
|
2394
|
-
timeBase = formatTimeBaseType({
|
|
2395
|
-
numerator: averageFrameRate.denominator,
|
|
2396
|
-
denominator: averageFrameRate.numerator
|
|
2397
|
-
});
|
|
2398
|
-
}
|
|
2399
|
-
var samples = videoMediaInfo['Frame count'];
|
|
2400
|
-
if (samples === undefined) {
|
|
2401
|
-
var numberOfPackets = videoComponentType.numberOfPackets;
|
|
2402
|
-
if (numberOfPackets !== undefined) samples = numberOfPackets.toString();
|
|
2403
|
-
}
|
|
2404
|
-
var timeCode;
|
|
2405
|
-
var frameRate;
|
|
2406
|
-
var smpte;
|
|
2407
|
-
if (samples && timeBase) {
|
|
2408
|
-
timeCode = formatTimeCodeType({
|
|
2409
|
-
samples: samples,
|
|
2410
|
-
timeBase: timeBase
|
|
2411
|
-
});
|
|
2412
|
-
frameRate = timeCode.timeBase.toConstant() || timeCode.timeBase.toRate();
|
|
2413
|
-
smpte = timeCode.toSmpte();
|
|
2414
|
-
}
|
|
2415
|
-
var _ref = resolution || {},
|
|
2416
|
-
height = _ref.height,
|
|
2417
|
-
width = _ref.width;
|
|
2418
|
-
var aspectRatio = parseAspectRatio(resolution);
|
|
2419
|
-
var dimension = "".concat(width, "x").concat(height);
|
|
2420
|
-
var videoBitrate = bitrate ? parseFileSize(bitrate, {
|
|
2421
|
-
bits: true
|
|
2422
|
-
}) : undefined;
|
|
2423
|
-
return {
|
|
2424
|
-
videoFormat: videoFormat,
|
|
2425
|
-
dimension: dimension,
|
|
2426
|
-
frameRate: frameRate,
|
|
2427
|
-
height: height,
|
|
2428
|
-
width: width,
|
|
2429
|
-
timeBase: timeBase,
|
|
2430
|
-
timeCode: timeCode,
|
|
2431
|
-
videoCodec: videoCodec,
|
|
2432
|
-
smpte: smpte,
|
|
2433
|
-
videoBitrate: videoBitrate,
|
|
2434
|
-
fieldOrder: fieldOrder,
|
|
2435
|
-
colorSpace: colorSpace,
|
|
2436
|
-
chromaSubsampling: chromaSubsampling,
|
|
2437
|
-
aspectRatio: aspectRatio,
|
|
2438
|
-
colorPrimaries: colorPrimaries,
|
|
2439
|
-
videoMetadata: videoMetadata,
|
|
2440
|
-
videoMediaInfo: videoMediaInfo
|
|
2441
|
-
};
|
|
2442
|
-
};
|
|
626
|
+
*/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};};
|
|
2443
627
|
|
|
2444
|
-
function ownKeys$1(object,
|
|
2445
|
-
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; }
|
|
628
|
+
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
|
|
2446
629
|
/**
|
|
2447
630
|
* Parses the technical information of a ShapeType and its various components.
|
|
2448
631
|
*
|
|
@@ -2456,56 +639,21 @@ function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) {
|
|
|
2456
639
|
* @returns Parsed shape object.
|
|
2457
640
|
*
|
|
2458
641
|
* @category Shape
|
|
2459
|
-
*/
|
|
2460
|
-
var parseShapeType = function parseShapeType() {
|
|
2461
|
-
var shapeType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
2462
|
-
var parsedShape = {};
|
|
2463
|
-
var containerComponent = shapeType.containerComponent,
|
|
2464
|
-
videoComponentList = shapeType.videoComponent,
|
|
2465
|
-
audioComponentList = shapeType.audioComponent,
|
|
2466
|
-
binaryComponentList = shapeType.binaryComponent,
|
|
2467
|
-
_shapeType$mimeType = shapeType.mimeType,
|
|
2468
|
-
mimeTypeList = _shapeType$mimeType === void 0 ? [] : _shapeType$mimeType,
|
|
2469
|
-
_shapeType$tag = shapeType.tag,
|
|
2470
|
-
tagList = _shapeType$tag === void 0 ? [] : _shapeType$tag;
|
|
2471
|
-
var _tagList = _slicedToArray(tagList, 1);
|
|
2472
|
-
parsedShape.tag = _tagList[0];
|
|
2473
|
-
var _mimeTypeList = _slicedToArray(mimeTypeList, 1);
|
|
2474
|
-
parsedShape.mimeType = _mimeTypeList[0];
|
|
2475
|
-
if (containerComponent) {
|
|
2476
|
-
var parsedContainerComponent = parseContainerComponent(containerComponent);
|
|
2477
|
-
parsedShape = _objectSpread$1(_objectSpread$1({}, parsedShape), parsedContainerComponent);
|
|
2478
|
-
}
|
|
2479
|
-
if (videoComponentList) {
|
|
2480
|
-
var _videoComponentList = _slicedToArray(videoComponentList, 1),
|
|
2481
|
-
videoComponent = _videoComponentList[0];
|
|
2482
|
-
var parsedVideoComponent = parseVideoComponent(videoComponent);
|
|
2483
|
-
parsedShape = _objectSpread$1(_objectSpread$1({}, parsedShape), parsedVideoComponent);
|
|
2484
|
-
}
|
|
2485
|
-
if (audioComponentList) {
|
|
2486
|
-
var _audioComponentList = _slicedToArray(audioComponentList, 1),
|
|
2487
|
-
audioComponent = _audioComponentList[0];
|
|
2488
|
-
var parsedAudioComponent = parseAudioComponent(audioComponent);
|
|
2489
|
-
parsedShape = _objectSpread$1(_objectSpread$1({}, parsedShape), parsedAudioComponent);
|
|
2490
|
-
}
|
|
2491
|
-
if (binaryComponentList) {
|
|
2492
|
-
var _binaryComponentList = _slicedToArray(binaryComponentList, 1),
|
|
2493
|
-
binaryComponent = _binaryComponentList[0];
|
|
2494
|
-
var parsedBinaryComponent = parseBinaryComponent(binaryComponent);
|
|
2495
|
-
parsedShape = _objectSpread$1(_objectSpread$1({}, parsedShape), parsedBinaryComponent);
|
|
2496
|
-
}
|
|
2497
|
-
return parsedShape;
|
|
2498
|
-
};
|
|
642
|
+
*/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;};
|
|
2499
643
|
|
|
2500
|
-
|
|
644
|
+
/**
|
|
645
|
+
* Const object with document types
|
|
646
|
+
*
|
|
647
|
+
* @category Shape
|
|
648
|
+
*/var DOCUMENT_TYPES={PDF:'PDF',TEXT:'TEXT',MSWORD:'MSWORD',JSON:'JSON',XML:'XML'};
|
|
2501
649
|
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
650
|
+
/**
|
|
651
|
+
* Const object with media types
|
|
652
|
+
*
|
|
653
|
+
* @category Shape
|
|
654
|
+
*/var SHAPE_MEDIA_TYPES={IMAGE:'IMAGE',AUDIO:'AUDIO',VIDEO:'VIDEO',DOCUMENT:'DOCUMENT',BINARY:'BINARY'};
|
|
655
|
+
|
|
656
|
+
// eslint-disable-next-line import/no-cycle
|
|
2509
657
|
/**
|
|
2510
658
|
* Return a const for the document type of a shape (looks at mimeType)
|
|
2511
659
|
*
|
|
@@ -2513,47 +661,13 @@ var DOCUMENT_TYPES = {
|
|
|
2513
661
|
* @returns The document type for a shape
|
|
2514
662
|
*
|
|
2515
663
|
* @category Shape
|
|
2516
|
-
*/
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
// shapeType.mimeType is always a string array,
|
|
2520
|
-
// but accepts passing in { mimeType: string } for backwards compatibility
|
|
2521
|
-
var mimeTypeArrayOrString = shape.mimeType;
|
|
2522
|
-
var mimeType = Array.isArray(mimeTypeArrayOrString) ? mimeTypeArrayOrString[0] : mimeTypeArrayOrString;
|
|
2523
|
-
if (!mimeType) return undefined;
|
|
2524
|
-
if (mimeType.endsWith('/pdf')) return DOCUMENT_TYPES.PDF;
|
|
2525
|
-
if (mimeType.startsWith('text/')) return DOCUMENT_TYPES.TEXT;
|
|
2526
|
-
if (mimeType.endsWith('/msword')) return DOCUMENT_TYPES.MSWORD;
|
|
2527
|
-
if (mimeType.endsWith('/json')) return DOCUMENT_TYPES.JSON;
|
|
2528
|
-
if (mimeType.endsWith('/xml')) return DOCUMENT_TYPES.XML;
|
|
2529
|
-
return undefined;
|
|
2530
|
-
};
|
|
664
|
+
*/var getShapeDocumentType=function getShapeDocumentType(){var shape=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};// shapeType.mimeType is always a string array,
|
|
665
|
+
// but accepts passing in { mimeType: string } for backwards compatibility
|
|
666
|
+
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;};
|
|
2531
667
|
|
|
2532
|
-
var IMAGE_MIME_TYPES
|
|
2533
|
-
var VIDEO_MIME_TYPES = ['video/mp4'];
|
|
2534
|
-
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'];
|
|
2535
|
-
var DEFAULT_ALLOWED_MIME_TYPES = [].concat(VIDEO_MIME_TYPES, IMAGE_MIME_TYPES, AUDIO_MIME_TYPES);
|
|
2536
|
-
var DEFAULT_ALLOWED_METHODS = ['http', 'https'];
|
|
2537
|
-
var MP4_MIMETYPE = 'video/mp4';
|
|
2538
|
-
var QUICKTIME_MIMETYPE = 'video/quicktime';
|
|
2539
|
-
var M4V_MIMETYPE = 'video/x-m4v';
|
|
2540
|
-
var MP4_CONTAINER = 'MPEG-4';
|
|
2541
|
-
var MOV_CONTAINER = 'mov';
|
|
2542
|
-
var H264_CODEC = 'h264';
|
|
2543
|
-
|
|
2544
|
-
// Sort by tags in the order of previewShapeOrder, secondary alphabetical.
|
|
668
|
+
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.
|
|
2545
669
|
// using reverse() so the first has highest index
|
|
2546
|
-
var PREVIEW_SHAPE_ORDER
|
|
2547
|
-
var defaultSortPriority = function defaultSortPriority(_ref, _ref2) {
|
|
2548
|
-
var firstEl = _ref.parsedShape.tag;
|
|
2549
|
-
var secondEl = _ref2.parsedShape.tag;
|
|
2550
|
-
if (PREVIEW_SHAPE_ORDER.includes(firstEl) || PREVIEW_SHAPE_ORDER.includes(secondEl)) {
|
|
2551
|
-
return PREVIEW_SHAPE_ORDER.indexOf(secondEl) - PREVIEW_SHAPE_ORDER.indexOf(firstEl);
|
|
2552
|
-
}
|
|
2553
|
-
return firstEl.toLowerCase().localeCompare(secondEl.toLowerCase());
|
|
2554
|
-
};
|
|
2555
|
-
|
|
2556
|
-
/**
|
|
670
|
+
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());};/**
|
|
2557
671
|
* Filter a shape type list to get shapes that are playable in a browser
|
|
2558
672
|
*
|
|
2559
673
|
* @param itemType
|
|
@@ -2561,67 +675,8 @@ var defaultSortPriority = function defaultSortPriority(_ref, _ref2) {
|
|
|
2561
675
|
* @returns
|
|
2562
676
|
*
|
|
2563
677
|
* @category Shape
|
|
2564
|
-
*/
|
|
2565
|
-
var filterShapeSource = function filterShapeSource(itemType, options) {
|
|
2566
|
-
var _ref3 = options || {},
|
|
2567
|
-
_ref3$allowedMimeType = _ref3.allowedMimeTypes,
|
|
2568
|
-
allowedMimeTypes = _ref3$allowedMimeType === void 0 ? DEFAULT_ALLOWED_MIME_TYPES : _ref3$allowedMimeType,
|
|
2569
|
-
_ref3$allowedMethods = _ref3.allowedMethods,
|
|
2570
|
-
allowedMethods = _ref3$allowedMethods === void 0 ? DEFAULT_ALLOWED_METHODS : _ref3$allowedMethods,
|
|
2571
|
-
_ref3$sortPriority = _ref3.sortPriority,
|
|
2572
|
-
sortPriority = _ref3$sortPriority === void 0 ? defaultSortPriority : _ref3$sortPriority,
|
|
2573
|
-
_ref3$sourceKey = _ref3.sourceKey,
|
|
2574
|
-
sourceKey = _ref3$sourceKey === void 0 ? 'src' : _ref3$sourceKey,
|
|
2575
|
-
_ref3$mimeTypeKey = _ref3.mimeTypeKey,
|
|
2576
|
-
mimeTypeKey = _ref3$mimeTypeKey === void 0 ? 'type' : _ref3$mimeTypeKey,
|
|
2577
|
-
_ref3$shapeKey = _ref3.shapeKey,
|
|
2578
|
-
shapeKey = _ref3$shapeKey === void 0 ? 'shape' : _ref3$shapeKey,
|
|
2579
|
-
_ref3$parsedShapeKey = _ref3.parsedShapeKey,
|
|
2580
|
-
parsedShapeKey = _ref3$parsedShapeKey === void 0 ? 'parsedShape' : _ref3$parsedShapeKey;
|
|
2581
|
-
var _ref4 = itemType || {},
|
|
2582
|
-
_ref4$shape = _ref4.shape,
|
|
2583
|
-
shapeList = _ref4$shape === void 0 ? [] : _ref4$shape;
|
|
2584
|
-
var filteredShapeList = shapeList.reduce(function (acc, shapeType) {
|
|
2585
|
-
var type;
|
|
2586
|
-
var src;
|
|
2587
|
-
var parsedShape = parseShapeType(shapeType);
|
|
2588
|
-
var uri = parsedShape.uri,
|
|
2589
|
-
mimeType = parsedShape.mimeType,
|
|
2590
|
-
containerFormat = parsedShape.containerFormat,
|
|
2591
|
-
videoCodec = parsedShape.videoCodec;
|
|
2592
|
-
if (mimeType) {
|
|
2593
|
-
type = mimeType;
|
|
2594
|
-
if ((mimeType === QUICKTIME_MIMETYPE || mimeType === M4V_MIMETYPE) && (containerFormat === MP4_CONTAINER || containerFormat === MOV_CONTAINER) && videoCodec === H264_CODEC) type = MP4_MIMETYPE;
|
|
2595
|
-
}
|
|
2596
|
-
if (uri) {
|
|
2597
|
-
if (allowedMethods) {
|
|
2598
|
-
var _uri$split = uri.split('://'),
|
|
2599
|
-
_uri$split2 = _slicedToArray(_uri$split, 1),
|
|
2600
|
-
thisMethod = _uri$split2[0];
|
|
2601
|
-
if (allowedMethods.includes(thisMethod)) src = uri;
|
|
2602
|
-
} else {
|
|
2603
|
-
src = uri;
|
|
2604
|
-
}
|
|
2605
|
-
}
|
|
2606
|
-
if (src && allowedMimeTypes.includes(type)) {
|
|
2607
|
-
var _acc$push;
|
|
2608
|
-
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));
|
|
2609
|
-
}
|
|
2610
|
-
return acc;
|
|
2611
|
-
}, []);
|
|
2612
|
-
if (typeof sortPriority === 'function') filteredShapeList.sort(defaultSortPriority);
|
|
2613
|
-
return filteredShapeList;
|
|
2614
|
-
};
|
|
2615
|
-
|
|
2616
|
-
// eslint-disable-next-line import/no-cycle
|
|
678
|
+
*/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;};
|
|
2617
679
|
|
|
2618
|
-
var SHAPE_MEDIA_TYPES = {
|
|
2619
|
-
IMAGE: 'IMAGE',
|
|
2620
|
-
AUDIO: 'AUDIO',
|
|
2621
|
-
VIDEO: 'VIDEO',
|
|
2622
|
-
DOCUMENT: 'DOCUMENT',
|
|
2623
|
-
BINARY: 'BINARY'
|
|
2624
|
-
};
|
|
2625
680
|
/**
|
|
2626
681
|
* Returns a const for which media type a shape has
|
|
2627
682
|
*
|
|
@@ -2629,29 +684,7 @@ var SHAPE_MEDIA_TYPES = {
|
|
|
2629
684
|
* @returns
|
|
2630
685
|
*
|
|
2631
686
|
* @category Shape
|
|
2632
|
-
*/
|
|
2633
|
-
var getShapeMediaType = function getShapeMediaType(shape) {
|
|
2634
|
-
var parsedShape = parseShapeType(shape);
|
|
2635
|
-
var mimeType = parsedShape.mimeType,
|
|
2636
|
-
videoCodec = parsedShape.videoCodec,
|
|
2637
|
-
audioCodec = parsedShape.audioCodec;
|
|
2638
|
-
if (!mimeType) return undefined;
|
|
2639
|
-
if (mimeType.startsWith('audio/')) {
|
|
2640
|
-
if (audioCodec !== undefined) return SHAPE_MEDIA_TYPES.AUDIO;
|
|
2641
|
-
}
|
|
2642
|
-
if (mimeType.startsWith('video/')) {
|
|
2643
|
-
if (videoCodec !== undefined) return SHAPE_MEDIA_TYPES.VIDEO;
|
|
2644
|
-
if (audioCodec !== undefined) return SHAPE_MEDIA_TYPES.AUDIO;
|
|
2645
|
-
}
|
|
2646
|
-
if (mimeType.startsWith('image/')) return SHAPE_MEDIA_TYPES.IMAGE;
|
|
2647
|
-
if (mimeType.endsWith('/pdf')) return SHAPE_MEDIA_TYPES.DOCUMENT;
|
|
2648
|
-
if (mimeType.startsWith('text/')) return SHAPE_MEDIA_TYPES.DOCUMENT;
|
|
2649
|
-
if (mimeType.endsWith('/msword')) return SHAPE_MEDIA_TYPES.DOCUMENT;
|
|
2650
|
-
if (mimeType.endsWith('/json')) return SHAPE_MEDIA_TYPES.DOCUMENT;
|
|
2651
|
-
if (mimeType.endsWith('/xml')) return SHAPE_MEDIA_TYPES.DOCUMENT;
|
|
2652
|
-
if (mimeType.endsWith('/octet-stream')) return SHAPE_MEDIA_TYPES.BINARY;
|
|
2653
|
-
return undefined;
|
|
2654
|
-
};
|
|
687
|
+
*/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;};
|
|
2655
688
|
|
|
2656
689
|
/**
|
|
2657
690
|
* Find the thumbnail uri in a VidiCore item object that's nearest a timeCode
|
|
@@ -2664,160 +697,28 @@ var getShapeMediaType = function getShapeMediaType(shape) {
|
|
|
2664
697
|
* @returns A URI of a thumbnail, `undefined` if item has no thumbnails
|
|
2665
698
|
*
|
|
2666
699
|
* @category Thumbnail
|
|
2667
|
-
*/
|
|
2668
|
-
var findNearestThumbnail = function findNearestThumbnail(itemType, timeCode) {
|
|
2669
|
-
var tcSeconds = createTimeCode(timeCode).toSeconds();
|
|
2670
|
-
var _ref = itemType || {},
|
|
2671
|
-
_ref$thumbnails = _ref.thumbnails,
|
|
2672
|
-
thumbnails = _ref$thumbnails === void 0 ? {} : _ref$thumbnails;
|
|
2673
|
-
var _thumbnails$uri = thumbnails.uri,
|
|
2674
|
-
srcList = _thumbnails$uri === void 0 ? [] : _thumbnails$uri;
|
|
2675
|
-
var srcTcSeconds = srcList.map(function (url) {
|
|
2676
|
-
var tc = new URL(url).pathname.split('/').pop();
|
|
2677
|
-
return formatTimeCodeText(tc).toSeconds();
|
|
2678
|
-
});
|
|
2679
|
-
var nearestSrcIndex = srcTcSeconds.reduce(function (nearestIndex, curr, currIndex) {
|
|
2680
|
-
return Math.abs(curr - tcSeconds) < Math.abs(srcTcSeconds[nearestIndex] - tcSeconds) ? currIndex : nearestIndex;
|
|
2681
|
-
}, 0);
|
|
2682
|
-
return srcList[nearestSrcIndex];
|
|
2683
|
-
};
|
|
2684
|
-
|
|
2685
|
-
var _excluded = ["Codec"],
|
|
2686
|
-
_excluded2 = ["Codec"];
|
|
700
|
+
*/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];};
|
|
2687
701
|
|
|
2688
|
-
|
|
702
|
+
var _excluded=["Codec"],_excluded2=["Codec"];/**
|
|
2689
703
|
* TODO
|
|
2690
|
-
*/
|
|
2691
|
-
|
|
2692
|
-
/**
|
|
704
|
+
*/ /**
|
|
2693
705
|
* TODO
|
|
2694
706
|
*
|
|
2695
707
|
* @param mediaconvert
|
|
2696
708
|
* @returns
|
|
2697
709
|
*
|
|
2698
710
|
* @category Transcode
|
|
2699
|
-
*/
|
|
2700
|
-
var
|
|
2701
|
-
var output = {};
|
|
2702
|
-
var _ref = mediaconvert || {},
|
|
2703
|
-
_ref$outputSetting = _ref.outputSetting,
|
|
2704
|
-
outputSetting = _ref$outputSetting === void 0 ? [] : _ref$outputSetting;
|
|
2705
|
-
if (outputSetting.length === 0) return output;
|
|
2706
|
-
var mc = JSON.parse(outputSetting[0]);
|
|
2707
|
-
var _mc$Settings = mc.Settings;
|
|
2708
|
-
_mc$Settings = _mc$Settings === void 0 ? {} : _mc$Settings;
|
|
2709
|
-
var ContainerSettings = _mc$Settings.ContainerSettings,
|
|
2710
|
-
VideoDescription = _mc$Settings.VideoDescription,
|
|
2711
|
-
AudioDescriptions = _mc$Settings.AudioDescriptions;
|
|
2712
|
-
if (ContainerSettings) {
|
|
2713
|
-
output.containerFormat = ContainerSettings.Container;
|
|
2714
|
-
}
|
|
2715
|
-
if (VideoDescription) {
|
|
2716
|
-
var _VideoDescription$Cod = VideoDescription.CodecSettings,
|
|
2717
|
-
CodecSettings = _VideoDescription$Cod === void 0 ? {} : _VideoDescription$Cod;
|
|
2718
|
-
var Codec = CodecSettings.Codec,
|
|
2719
|
-
otherSettings = _objectWithoutProperties(CodecSettings, _excluded);
|
|
2720
|
-
output.videoFormat = Codec;
|
|
2721
|
-
var height = VideoDescription.Height,
|
|
2722
|
-
width = VideoDescription.Width;
|
|
2723
|
-
output.height = height;
|
|
2724
|
-
output.width = width;
|
|
2725
|
-
if (height && width) {
|
|
2726
|
-
output.dimension = "".concat(width, "x").concat(height);
|
|
2727
|
-
output.aspectRatio = parseAspectRatio({
|
|
2728
|
-
height: height,
|
|
2729
|
-
width: width
|
|
2730
|
-
});
|
|
2731
|
-
}
|
|
2732
|
-
var _Object$values = Object.values(otherSettings),
|
|
2733
|
-
_Object$values2 = _slicedToArray(_Object$values, 1),
|
|
2734
|
-
codecSpecs = _Object$values2[0];
|
|
2735
|
-
if (codecSpecs) {
|
|
2736
|
-
output.fieldOrder = codecSpecs.InterlaceMode;
|
|
2737
|
-
if (output.fieldOrder && output.fieldOrder.includes('TOP')) output.fieldOrder = 'interlaced';
|
|
2738
|
-
output.videoBitrate = codecSpecs.Bitrate;
|
|
2739
|
-
var numerator = codecSpecs.FramerateDenominator; // other way round to vs ¯\_(ツ)_/¯
|
|
2740
|
-
var denominator = codecSpecs.FramerateNumerator;
|
|
2741
|
-
var timeBase = formatTimeBaseType({
|
|
2742
|
-
denominator: denominator,
|
|
2743
|
-
numerator: numerator
|
|
2744
|
-
});
|
|
2745
|
-
output.timeBase = timeBase;
|
|
2746
|
-
output.frameRate = timeBase.toConstant() || timeBase.toRate();
|
|
2747
|
-
}
|
|
2748
|
-
}
|
|
2749
|
-
if (AudioDescriptions && AudioDescriptions.length > 0) {
|
|
2750
|
-
var _AudioDescriptions$0$ = AudioDescriptions[0].CodecSettings,
|
|
2751
|
-
_CodecSettings = _AudioDescriptions$0$ === void 0 ? {} : _AudioDescriptions$0$;
|
|
2752
|
-
var _Codec = _CodecSettings.Codec,
|
|
2753
|
-
_otherSettings = _objectWithoutProperties(_CodecSettings, _excluded2);
|
|
2754
|
-
output.audioFormat = _Codec;
|
|
2755
|
-
var _Object$values3 = Object.values(_otherSettings),
|
|
2756
|
-
_Object$values4 = _slicedToArray(_Object$values3, 1),
|
|
2757
|
-
_codecSpecs = _Object$values4[0];
|
|
2758
|
-
if (_codecSpecs) {
|
|
2759
|
-
output.audioSamplerate = _codecSpecs.SampleRate;
|
|
2760
|
-
output.audioBitrate = _codecSpecs.Bitrate;
|
|
2761
|
-
output.audioBitRateMode = _codecSpecs.RateControlMode;
|
|
2762
|
-
}
|
|
2763
|
-
}
|
|
2764
|
-
return output;
|
|
2765
|
-
};
|
|
711
|
+
*/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 ¯\_(ツ)_/¯
|
|
712
|
+
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;};
|
|
2766
713
|
|
|
2767
|
-
function ownKeys(object,
|
|
2768
|
-
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; }
|
|
2769
|
-
/**
|
|
714
|
+
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;}/**
|
|
2770
715
|
* Parse a VidiCore transcode preset
|
|
2771
716
|
*
|
|
2772
717
|
* @param transcodePresetType a VidiCore transcode preset
|
|
2773
718
|
* @returns A parsed transcode preset
|
|
2774
719
|
*
|
|
2775
720
|
* @category Transcode
|
|
2776
|
-
*/
|
|
2777
|
-
var parseTranscodePreset = function parseTranscodePreset(transcodePresetType) {
|
|
2778
|
-
var output = {};
|
|
2779
|
-
var _ref = transcodePresetType || {},
|
|
2780
|
-
description = _ref.description,
|
|
2781
|
-
format = _ref.format,
|
|
2782
|
-
audio = _ref.audio,
|
|
2783
|
-
video = _ref.video,
|
|
2784
|
-
mediaconvert = _ref.mediaconvert;
|
|
2785
|
-
if (mediaconvert) return _objectSpread({
|
|
2786
|
-
description: description
|
|
2787
|
-
}, parseMediaConvertPreset(mediaconvert));
|
|
2788
|
-
output.description = description;
|
|
2789
|
-
output.containerFormat = format;
|
|
2790
|
-
if (video) {
|
|
2791
|
-
output.videoFormat = video.codec;
|
|
2792
|
-
output.videoBitrate = video.bitrate;
|
|
2793
|
-
if (video.framerate) {
|
|
2794
|
-
var timeBase = formatTimeBaseType(video.framerate);
|
|
2795
|
-
output.timeBase = timeBase;
|
|
2796
|
-
output.frameRate = timeBase.toConstant() || timeBase.toRate();
|
|
2797
|
-
}
|
|
2798
|
-
if (video.scaling) {
|
|
2799
|
-
var _video$scaling = video.scaling,
|
|
2800
|
-
height = _video$scaling.height,
|
|
2801
|
-
width = _video$scaling.width;
|
|
2802
|
-
output.height = height;
|
|
2803
|
-
output.width = width;
|
|
2804
|
-
if (height && width) {
|
|
2805
|
-
output.dimension = "".concat(width, "x").concat(height);
|
|
2806
|
-
output.aspectRatio = parseAspectRatio({
|
|
2807
|
-
height: height,
|
|
2808
|
-
width: width
|
|
2809
|
-
});
|
|
2810
|
-
}
|
|
2811
|
-
}
|
|
2812
|
-
}
|
|
2813
|
-
if (audio) {
|
|
2814
|
-
var audioFormat = audio.codec,
|
|
2815
|
-
channel = audio.channel;
|
|
2816
|
-
output.audioFormat = audioFormat;
|
|
2817
|
-
if (channel) output.audioChannels = channel.length;
|
|
2818
|
-
}
|
|
2819
|
-
return output;
|
|
2820
|
-
};
|
|
721
|
+
*/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;};
|
|
2821
722
|
|
|
2822
|
-
export { FIELD_ATTRIBUTE_KEYS, FIELD_VALUE_ATTRIBUTE_KEYS, GROUP_ATTRIBUTE_KEYS, ROLE_NAMES, 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 };
|
|
723
|
+
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 };
|
|
2823
724
|
//# sourceMappingURL=index.es.js.map
|