@vidispine/vdt-js 23.1.0-pre.1 → 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.es.js +222 -2410
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +241 -2429
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
package/dist/index.es.js
CHANGED
|
@@ -7,25 +7,7 @@ import _classCallCheck from '@babel/runtime/helpers/classCallCheck';
|
|
|
7
7
|
import _createClass from '@babel/runtime/helpers/createClass';
|
|
8
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
|
-
};
|
|
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'};
|
|
161
25
|
|
|
162
26
|
/**
|
|
163
27
|
* Array with all available VidiCore system/default field group names
|
|
164
28
|
*
|
|
165
29
|
* @category Metadata
|
|
166
|
-
*/
|
|
167
|
-
var SYSTEM_FIELDGROUPS = ['stl_subtitle', 'stl_tti', 'stl_gsi', 'mrk_marker', 'pho_validation', 'pho_resource', 'pho_error', 'facedetect_rect', 'facedetect_face', 'originalTrackFilename', 'stl_gsiHeader'];
|
|
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'];
|
|
168
31
|
|
|
169
32
|
/**
|
|
170
33
|
* Array with all available VidiCore system/default field names (including transient)
|
|
171
34
|
*
|
|
172
35
|
* @category Metadata
|
|
173
|
-
*/
|
|
174
|
-
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'];
|
|
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'];
|
|
175
37
|
|
|
176
|
-
var SHARED_ATTRIBUTE_KEYS
|
|
177
|
-
var SHARED_FIELD_AND_GROUP_ATTRIBUTE_KEYS = ['name', 'id', 'referenced', 'data', 'inheritance'];
|
|
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(_toConsumableArray(SHARED_ATTRIBUTE_KEYS), ['value', 'lang']);
|
|
44
|
+
*/var FIELD_VALUE_ATTRIBUTE_KEYS=[].concat(_toConsumableArray(SHARED_ATTRIBUTE_KEYS),['value','lang']);
|
|
185
45
|
|
|
186
46
|
/**
|
|
187
47
|
* Array with all available metadata field attributes
|
|
188
48
|
*
|
|
189
49
|
* @category Metadata
|
|
190
|
-
*/
|
|
191
|
-
var FIELD_ATTRIBUTE_KEYS = [].concat(_toConsumableArray(SHARED_ATTRIBUTE_KEYS), _toConsumableArray(SHARED_FIELD_AND_GROUP_ATTRIBUTE_KEYS), ['value', 'reference', 'type', 'track']);
|
|
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
53
|
* Array with all available metadata group attributes
|
|
195
54
|
*
|
|
196
55
|
* @category Metadata
|
|
197
|
-
*/
|
|
198
|
-
var GROUP_ATTRIBUTE_KEYS = [].concat(_toConsumableArray(SHARED_ATTRIBUTE_KEYS), _toConsumableArray(SHARED_FIELD_AND_GROUP_ATTRIBUTE_KEYS), ['cycle', 'field', 'group']);
|
|
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
|
-
}
|
|
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});}
|
|
472
111
|
|
|
473
|
-
var _excluded$c
|
|
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
|
-
});
|
|
480
|
-
|
|
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
|
-
}
|
|
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;}
|
|
500
119
|
|
|
501
|
-
var _excluded$b
|
|
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);
|
|
508
|
-
|
|
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
|
-
};
|
|
653
|
-
|
|
654
|
-
var _excluded$9 = ["field", "group"];
|
|
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
|
-
});
|
|
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;};
|
|
665
170
|
|
|
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
|
-
};
|
|
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;};
|
|
797
200
|
|
|
798
|
-
var _excluded$7
|
|
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
|
-
});
|
|
805
|
-
|
|
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,148 +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
|
-
}
|
|
985
|
-
if (options !== null && options !== void 0 && options.fraction || this.numerator > 1) {
|
|
986
|
-
var _timeBaseText2 = [this.denominator, this.numerator].join(':');
|
|
987
|
-
return _timeBaseText2;
|
|
988
|
-
}
|
|
989
|
-
var timeBaseText = String(this.denominator);
|
|
990
|
-
return timeBaseText;
|
|
991
|
-
}
|
|
992
|
-
|
|
993
|
-
/**
|
|
994
|
-
* Output TimeBase as frame rate (by default max 16 decimal places)
|
|
995
|
-
*
|
|
996
|
-
* @remarks
|
|
997
|
-
* For `options.fixed`:
|
|
998
|
-
* - `true` gives two decimal places
|
|
999
|
-
* - `false` gives max amount of decimal places
|
|
1000
|
-
* - `number` gives that amount of decimal places
|
|
1001
|
-
*
|
|
1002
|
-
* Default format: rate with two decimals if needed (i.e. decimals are > 0)
|
|
1003
|
-
*
|
|
1004
|
-
* Option precedence (when all true): `constant` > `rounded` > `fixed`
|
|
1005
|
-
*
|
|
1006
|
-
* @param options For how to display it as rate
|
|
1007
|
-
*
|
|
1008
|
-
* @return Rate of the TimeBase
|
|
1009
|
-
*
|
|
1010
|
-
* @category Time
|
|
1011
|
-
*/
|
|
1012
|
-
}, {
|
|
1013
|
-
key: "toRate",
|
|
1014
|
-
value: function toRate(options) {
|
|
1015
|
-
var rate = this.denominator / this.numerator;
|
|
1016
|
-
if (Number.isInteger(rate)) {
|
|
1017
|
-
return rate;
|
|
1018
|
-
}
|
|
1019
|
-
if (options !== null && options !== void 0 && options.rounded) {
|
|
1020
|
-
return Math.round(rate);
|
|
1021
|
-
}
|
|
1022
|
-
var _ref2 = options || {},
|
|
1023
|
-
_ref2$fixed = _ref2.fixed,
|
|
1024
|
-
fixed = _ref2$fixed === void 0 ? true : _ref2$fixed;
|
|
1025
|
-
if (fixed === true || typeof fixed === 'number') {
|
|
1026
|
-
return Number(rate.toFixed(typeof fixed === 'boolean' ? 2 : fixed));
|
|
1027
|
-
}
|
|
1028
|
-
return rate;
|
|
1029
|
-
}
|
|
1030
|
-
|
|
1031
|
-
/**
|
|
1032
|
-
* Get TimeBase in a object representation
|
|
1033
|
-
*
|
|
1034
|
-
* @returns TimeBase as `{denominator, numerator}` object
|
|
1035
|
-
*/
|
|
1036
|
-
}, {
|
|
1037
|
-
key: "toObject",
|
|
1038
|
-
value: function toObject() {
|
|
1039
|
-
return {
|
|
1040
|
-
denominator: this.denominator,
|
|
1041
|
-
numerator: this.numerator
|
|
1042
|
-
};
|
|
1043
|
-
}
|
|
1044
|
-
|
|
1045
|
-
/**
|
|
1046
|
-
* @deprecated Use {@link TimeBase#toObject | toObject} instead
|
|
1047
|
-
*
|
|
1048
|
-
* @returns TimeBase as `{denominator, numerator}` object
|
|
1049
|
-
*/
|
|
1050
|
-
}, {
|
|
1051
|
-
key: "toJson",
|
|
1052
|
-
value: function toJson() {
|
|
1053
|
-
// eslint-disable-next-line no-console
|
|
1054
|
-
console.warn('Deprecated - use toObject instead');
|
|
1055
|
-
return this.toObject();
|
|
1056
|
-
}
|
|
1057
|
-
}]);
|
|
1058
|
-
return TimeBase;
|
|
1059
|
-
}();
|
|
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;}();
|
|
1060
285
|
|
|
1061
286
|
/**
|
|
1062
287
|
* Format a string representation of a time base to a TimeBase Instance
|
|
@@ -1065,36 +290,7 @@ var TimeBase = /*#__PURE__*/function () {
|
|
|
1065
290
|
* @returns A TimeBase Instance
|
|
1066
291
|
*
|
|
1067
292
|
* @category Time
|
|
1068
|
-
*/
|
|
1069
|
-
var formatTimeBaseText = function formatTimeBaseText(timeBaseText) {
|
|
1070
|
-
if (timeBaseText === undefined) {
|
|
1071
|
-
return new TimeBase();
|
|
1072
|
-
}
|
|
1073
|
-
if (typeof timeBaseText === 'number') {
|
|
1074
|
-
return new TimeBase({
|
|
1075
|
-
denominator: timeBaseText
|
|
1076
|
-
});
|
|
1077
|
-
}
|
|
1078
|
-
if (typeof timeBaseText === 'string' && timeBaseText.includes(':')) {
|
|
1079
|
-
var _timeBaseText$split = timeBaseText.split(':'),
|
|
1080
|
-
_timeBaseText$split2 = _slicedToArray(_timeBaseText$split, 2),
|
|
1081
|
-
denominator = _timeBaseText$split2[0],
|
|
1082
|
-
numerator = _timeBaseText$split2[1];
|
|
1083
|
-
return new TimeBase({
|
|
1084
|
-
denominator: denominator,
|
|
1085
|
-
numerator: numerator
|
|
1086
|
-
});
|
|
1087
|
-
}
|
|
1088
|
-
if (TIME_BASE_CONSTANTS.includes(timeBaseText)) {
|
|
1089
|
-
return new TimeBase(MAP_CONSTANT_TO_DEN_NUM[timeBaseText]);
|
|
1090
|
-
}
|
|
1091
|
-
if (!['string', 'number'].includes(_typeof(timeBaseText)) || Number.isNaN(Number(timeBaseText))) {
|
|
1092
|
-
throw new Error("timeBaseText must be a number or ".concat(TIME_BASE_CONSTANTS.join(','), " - is ").concat(JSON.stringify(timeBaseText)));
|
|
1093
|
-
}
|
|
1094
|
-
return new TimeBase({
|
|
1095
|
-
denominator: Number(timeBaseText)
|
|
1096
|
-
});
|
|
1097
|
-
};
|
|
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)});};
|
|
1098
294
|
|
|
1099
295
|
/**
|
|
1100
296
|
* Create a TimeBase instance of an object
|
|
@@ -1103,10 +299,7 @@ var formatTimeBaseText = function formatTimeBaseText(timeBaseText) {
|
|
|
1103
299
|
* @returns A TimeBase instance
|
|
1104
300
|
*
|
|
1105
301
|
* @category Time
|
|
1106
|
-
*/
|
|
1107
|
-
var formatTimeBaseType = function formatTimeBaseType(timeBase) {
|
|
1108
|
-
return new TimeBase(timeBase);
|
|
1109
|
-
};
|
|
302
|
+
*/var formatTimeBaseType=function formatTimeBaseType(timeBase){return new TimeBase(timeBase);};
|
|
1110
303
|
|
|
1111
304
|
/**
|
|
1112
305
|
* Create a TimeBase Instance from a number, string or object representation of a time base
|
|
@@ -1115,13 +308,7 @@ var formatTimeBaseType = function formatTimeBaseType(timeBase) {
|
|
|
1115
308
|
* @returns A TimeBase instance
|
|
1116
309
|
*
|
|
1117
310
|
* @category Time
|
|
1118
|
-
*/
|
|
1119
|
-
var createTimeBase = function createTimeBase(timeBase) {
|
|
1120
|
-
if (typeof timeBase === 'string' || typeof timeBase === 'number') {
|
|
1121
|
-
return formatTimeBaseText(timeBase);
|
|
1122
|
-
}
|
|
1123
|
-
return formatTimeBaseType(timeBase);
|
|
1124
|
-
};
|
|
311
|
+
*/var createTimeBase=function createTimeBase(timeBase){if(typeof timeBase==='string'||typeof timeBase==='number'){return formatTimeBaseText(timeBase);}return formatTimeBaseType(timeBase);};
|
|
1125
312
|
|
|
1126
313
|
/**
|
|
1127
314
|
* @private
|
|
@@ -1130,11 +317,7 @@ var createTimeBase = function createTimeBase(timeBase) {
|
|
|
1130
317
|
*
|
|
1131
318
|
* @param timeBase Time base to get amount of frames to drop for
|
|
1132
319
|
* @returns Amount of frame drops for specified time base, false if no frame drops
|
|
1133
|
-
*/
|
|
1134
|
-
var getAmountOfFrameDrops = function getAmountOfFrameDrops(timeBase) {
|
|
1135
|
-
var timeBaseConstant = timeBase.toConstant();
|
|
1136
|
-
return timeBaseConstant === '59.94' && 4 || ['NTSC', '29.97'].includes(timeBaseConstant) && 2 || false;
|
|
1137
|
-
};
|
|
320
|
+
*/var getAmountOfFrameDrops=function getAmountOfFrameDrops(timeBase){var timeBaseConstant=timeBase.toConstant();return timeBaseConstant==='59.94'&&4||['NTSC','29.97'].includes(timeBaseConstant)&&2||false;};
|
|
1138
321
|
|
|
1139
322
|
/**
|
|
1140
323
|
* @private
|
|
@@ -1143,89 +326,24 @@ var getAmountOfFrameDrops = function getAmountOfFrameDrops(timeBase) {
|
|
|
1143
326
|
*
|
|
1144
327
|
* @param timeBase TimeBase Instance to check
|
|
1145
328
|
* @returns true if time base drops frames, false otherwise
|
|
1146
|
-
*/
|
|
1147
|
-
var isDropFrameTimeBase = function isDropFrameTimeBase(timeBase) {
|
|
1148
|
-
return getAmountOfFrameDrops(timeBase) > 0;
|
|
1149
|
-
};
|
|
329
|
+
*/var isDropFrameTimeBase=function isDropFrameTimeBase(timeBase){return getAmountOfFrameDrops(timeBase)>0;};
|
|
1150
330
|
|
|
1151
|
-
var _excluded$6
|
|
1152
|
-
var getDroppedFramesFromSamples = function getDroppedFramesFromSamples(timeCode) {
|
|
1153
|
-
var samples = timeCode.samples,
|
|
1154
|
-
timeBase = timeCode.timeBase;
|
|
1155
|
-
var amountOfFrameDrops = getAmountOfFrameDrops(timeBase);
|
|
1156
|
-
if (!amountOfFrameDrops) return 0;
|
|
1157
|
-
var roundedFrameRate = timeBase.toRate({
|
|
1158
|
-
rounded: true
|
|
1159
|
-
});
|
|
1160
|
-
var oneMinuteNotDroppedFrames = 60 * roundedFrameRate;
|
|
1161
|
-
var amountOfFramesToDropPerMinute = 60 * roundedFrameRate - amountOfFrameDrops;
|
|
1162
|
-
var tenMinuteFrames = 10 * (oneMinuteNotDroppedFrames - amountOfFrameDrops) + amountOfFrameDrops;
|
|
1163
|
-
var amountOfTenMinuteChunks = Math.floor((samples + 1) / tenMinuteFrames);
|
|
1164
|
-
var minuteRemainder = Math.max(0, (samples + 1) % tenMinuteFrames - oneMinuteNotDroppedFrames);
|
|
1165
|
-
var amountOfOneMinuteReminderChunks = Math.floor(minuteRemainder / amountOfFramesToDropPerMinute);
|
|
1166
|
-
var frameRemainder = minuteRemainder % amountOfFramesToDropPerMinute;
|
|
1167
|
-
var amountOfFrameRemainderChunks = frameRemainder > 0 ? amountOfFrameDrops : 0;
|
|
1168
|
-
return amountOfTenMinuteChunks * 9 * amountOfFrameDrops + amountOfOneMinuteReminderChunks * amountOfFrameDrops + amountOfFrameRemainderChunks;
|
|
1169
|
-
};
|
|
1170
|
-
/**
|
|
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;};/**
|
|
1171
332
|
* TimeCode class representing the TimeCodeType in VidiCore
|
|
1172
333
|
*
|
|
1173
334
|
* For more info, see the [Time Codes section of VidiCore API Docs](https://apidoc.vidispine.com/latest/time.html#time-codes)
|
|
1174
335
|
*
|
|
1175
336
|
* @category Time
|
|
1176
|
-
*/
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
// If time code is dropFrame or not (by default checks timeBase)
|
|
1183
|
-
|
|
1184
|
-
// Separator for frame in smpte output (default ":" for non-drop-frame and ";" for dropFrame)
|
|
1185
|
-
|
|
1186
|
-
/**
|
|
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
|
+
/**
|
|
1187
342
|
* Constructor for TimeCode
|
|
1188
343
|
*
|
|
1189
344
|
* @param timeCodeType Object to create TimeCode of
|
|
1190
345
|
* @param options Options for the timeCode
|
|
1191
|
-
*/
|
|
1192
|
-
function TimeCode(timeCodeType, options) {
|
|
1193
|
-
var _options$dropFrame, _options$frameSeparat;
|
|
1194
|
-
_classCallCheck(this, TimeCode);
|
|
1195
|
-
_defineProperty(this, "samples", 0);
|
|
1196
|
-
_defineProperty(this, "timeBase", new TimeBase());
|
|
1197
|
-
_defineProperty(this, "dropFrame", void 0);
|
|
1198
|
-
_defineProperty(this, "frameSeparator", void 0);
|
|
1199
|
-
var _ref = timeCodeType || {},
|
|
1200
|
-
samples = _ref.samples,
|
|
1201
|
-
timeBase = _ref.timeBase;
|
|
1202
|
-
if (samples !== undefined) {
|
|
1203
|
-
if (typeof samples === 'number') {
|
|
1204
|
-
this.samples = samples;
|
|
1205
|
-
} else if (typeof samples === 'string') {
|
|
1206
|
-
if (samples === '-INF') {
|
|
1207
|
-
this.samples = -Infinity;
|
|
1208
|
-
} else if (samples === '+INF') {
|
|
1209
|
-
this.samples = Infinity;
|
|
1210
|
-
} else {
|
|
1211
|
-
this.samples = Number(samples);
|
|
1212
|
-
}
|
|
1213
|
-
} else {
|
|
1214
|
-
throw new Error("samples is not number/string/-Inf/+Inf is: ".concat(samples));
|
|
1215
|
-
}
|
|
1216
|
-
}
|
|
1217
|
-
if (timeBase !== undefined) {
|
|
1218
|
-
if (timeBase instanceof TimeBase) {
|
|
1219
|
-
this.timeBase = timeBase;
|
|
1220
|
-
} else {
|
|
1221
|
-
this.timeBase = createTimeBase(timeBase);
|
|
1222
|
-
}
|
|
1223
|
-
}
|
|
1224
|
-
this.dropFrame = (_options$dropFrame = options === null || options === void 0 ? void 0 : options.dropFrame) !== null && _options$dropFrame !== void 0 ? _options$dropFrame : isDropFrameTimeBase(this.timeBase);
|
|
1225
|
-
this.frameSeparator = (_options$frameSeparat = options === null || options === void 0 ? void 0 : options.frameSeparator) !== null && _options$frameSeparat !== void 0 ? _options$frameSeparat : this.dropFrame ? ';' : ':';
|
|
1226
|
-
}
|
|
1227
|
-
|
|
1228
|
-
/**
|
|
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?';':':';}/**
|
|
1229
347
|
* Return this TimeCode added with the supplied timeCodeType
|
|
1230
348
|
* If time bases differ, it will retain the time base of this TimeCode instance
|
|
1231
349
|
* If supplied time code has a more granular time base - it will round down exceeding samples (hasn't reached that sample yet)
|
|
@@ -1236,351 +354,84 @@ var TimeCode = /*#__PURE__*/function () {
|
|
|
1236
354
|
*
|
|
1237
355
|
* @param timeCode A TimeCode instance you want to add with
|
|
1238
356
|
* @returns A new TimeCode instance with the addition applied
|
|
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
|
-
|
|
1314
|
-
|
|
1315
|
-
timeBase: conformToTimeBase
|
|
1316
|
-
};
|
|
1317
|
-
return new TimeCode(timeCode);
|
|
1318
|
-
}
|
|
1319
|
-
|
|
1320
|
-
/**
|
|
1321
|
-
* Get TimeCode as a text representation
|
|
1322
|
-
*
|
|
1323
|
-
* @remarks
|
|
1324
|
-
* Default format: samples@denominator(:numerator if > 1)
|
|
1325
|
-
*
|
|
1326
|
-
* `constant` has precedence over `fraction` if both are true
|
|
1327
|
-
*
|
|
1328
|
-
* @param options Options for how to format text
|
|
1329
|
-
* @returns Text representation of TimeCode
|
|
1330
|
-
*
|
|
1331
|
-
* @category Time
|
|
1332
|
-
*/
|
|
1333
|
-
}, {
|
|
1334
|
-
key: "toText",
|
|
1335
|
-
value: function toText(options) {
|
|
1336
|
-
var timeCodeText = "".concat(this.samples);
|
|
1337
|
-
var timeBaseText = this.timeBase.toText(options);
|
|
1338
|
-
if (options !== null && options !== void 0 && options.includeTimeBaseForSeconds || !['1', '1:1'].includes(timeBaseText)) {
|
|
1339
|
-
timeCodeText = [this.samples, timeBaseText].join('@');
|
|
1340
|
-
}
|
|
1341
|
-
return timeCodeText;
|
|
1342
|
-
}
|
|
1343
|
-
|
|
1344
|
-
/**
|
|
1345
|
-
* Get TimeCode in a units object representation
|
|
1346
|
-
*
|
|
1347
|
-
* @returns Units (time and frames) for the time code
|
|
1348
|
-
*/
|
|
1349
|
-
}, {
|
|
1350
|
-
key: "toUnits",
|
|
1351
|
-
value: function toUnits() {
|
|
1352
|
-
var totalSamples = this.samples + (this.dropFrame ? getDroppedFramesFromSamples(this) : 0);
|
|
1353
|
-
var roundedFrameRate = this.timeBase.toRate({
|
|
1354
|
-
rounded: true
|
|
1355
|
-
});
|
|
1356
|
-
|
|
1357
|
-
// Calculated without drop-frame but with 2 decimal places
|
|
1358
|
-
if (['23.976', '23.98'].includes(this.timeBase.toConstant())) {
|
|
1359
|
-
roundedFrameRate = this.timeBase.toRate({
|
|
1360
|
-
fixed: true
|
|
1361
|
-
});
|
|
1362
|
-
}
|
|
1363
|
-
var hours = Math.floor(totalSamples / (3600 * roundedFrameRate));
|
|
1364
|
-
var minutes = Math.floor(totalSamples / (60 * roundedFrameRate)) % 60;
|
|
1365
|
-
var seconds = Math.floor(totalSamples / roundedFrameRate) % 60;
|
|
1366
|
-
var frames = Math.floor(totalSamples % roundedFrameRate);
|
|
1367
|
-
return {
|
|
1368
|
-
hours: hours,
|
|
1369
|
-
minutes: minutes,
|
|
1370
|
-
seconds: seconds,
|
|
1371
|
-
frames: frames
|
|
1372
|
-
};
|
|
1373
|
-
}
|
|
1374
|
-
|
|
1375
|
-
/**
|
|
1376
|
-
* Get TimeCode in a time object representation
|
|
1377
|
-
* "milliseconds" is rounded down, if you want another representation use "partialSeconds"
|
|
1378
|
-
*
|
|
1379
|
-
* @returns Time for the time code
|
|
1380
|
-
*/
|
|
1381
|
-
}, {
|
|
1382
|
-
key: "toTime",
|
|
1383
|
-
value: function toTime() {
|
|
1384
|
-
var totalSamples = this.samples + getDroppedFramesFromSamples(this);
|
|
1385
|
-
var _this$toUnits = this.toUnits(),
|
|
1386
|
-
hours = _this$toUnits.hours,
|
|
1387
|
-
minutes = _this$toUnits.minutes,
|
|
1388
|
-
seconds = _this$toUnits.seconds;
|
|
1389
|
-
var roundedFrameRate = this.timeBase.toRate({
|
|
1390
|
-
rounded: true
|
|
1391
|
-
});
|
|
1392
|
-
var framesPrecise = totalSamples % roundedFrameRate;
|
|
1393
|
-
var milliseconds = Math.floor(1000 * framesPrecise / roundedFrameRate);
|
|
1394
|
-
var partialSeconds = framesPrecise / roundedFrameRate;
|
|
1395
|
-
return {
|
|
1396
|
-
hours: hours,
|
|
1397
|
-
minutes: minutes,
|
|
1398
|
-
seconds: seconds,
|
|
1399
|
-
milliseconds: milliseconds,
|
|
1400
|
-
partialSeconds: partialSeconds
|
|
1401
|
-
};
|
|
1402
|
-
}
|
|
1403
|
-
|
|
1404
|
-
/**
|
|
1405
|
-
* Get TimeCode in a seconds representation
|
|
1406
|
-
*
|
|
1407
|
-
* @returns Total seconds for the time code
|
|
1408
|
-
*/
|
|
1409
|
-
}, {
|
|
1410
|
-
key: "toSeconds",
|
|
1411
|
-
value: function toSeconds() {
|
|
1412
|
-
var _this$timeBase = this.timeBase,
|
|
1413
|
-
numerator = _this$timeBase.numerator,
|
|
1414
|
-
denominator = _this$timeBase.denominator;
|
|
1415
|
-
return Math.round(1000 * +(this.samples * numerator / denominator)) / 1000;
|
|
1416
|
-
}
|
|
1417
|
-
|
|
1418
|
-
/**
|
|
1419
|
-
* Get TimeCode in a duration representation
|
|
1420
|
-
* The time unit char keys for the format string are:
|
|
1421
|
-
* - "h" for hour
|
|
1422
|
-
* - "m" for minute
|
|
1423
|
-
* - "s" for seconds
|
|
1424
|
-
* - "S" for milliseconds
|
|
1425
|
-
* Any other char will be kept in the duration output string.
|
|
1426
|
-
*
|
|
1427
|
-
* Add consecutive chars for zero padding.
|
|
1428
|
-
*
|
|
1429
|
-
* By default it:
|
|
1430
|
-
* - uses colon delimiter (e.g. for format "hhmmss")
|
|
1431
|
-
* - shows "m:ss" or "h:mm:ss" if format is undefined
|
|
1432
|
-
*
|
|
1433
|
-
* @param options Options for how to display duration
|
|
1434
|
-
* @returns Duration representation of the TimeCode
|
|
1435
|
-
*/
|
|
1436
|
-
}, {
|
|
1437
|
-
key: "toDuration",
|
|
1438
|
-
value: function toDuration(options) {
|
|
1439
|
-
var _ref3 = options || {},
|
|
1440
|
-
format = _ref3.format;
|
|
1441
|
-
var _this$toTime = this.toTime(),
|
|
1442
|
-
hours = _this$toTime.hours,
|
|
1443
|
-
rest = _objectWithoutProperties(_this$toTime, _excluded$6);
|
|
1444
|
-
var minutes = rest.minutes,
|
|
1445
|
-
seconds = rest.seconds,
|
|
1446
|
-
milliseconds = rest.milliseconds;
|
|
1447
|
-
if (!!format && typeof format !== 'string') {
|
|
1448
|
-
throw Error('format has to be a string');
|
|
1449
|
-
}
|
|
1450
|
-
var isBefore = function isBefore(unit, units) {
|
|
1451
|
-
return !format.includes(unit) || !units.some(function (u) {
|
|
1452
|
-
return format.includes(u) && format.lastIndexOf(unit) > format.indexOf(u);
|
|
1453
|
-
});
|
|
1454
|
-
};
|
|
1455
|
-
if (!!format && !(isBefore('h', ['m', 's', 'S']) && isBefore('m', ['s', 'S']) && isBefore('s', ['S']))) {
|
|
1456
|
-
throw Error('format order is unsupported (has to be h, m, s then S)');
|
|
1457
|
-
}
|
|
1458
|
-
if (!format) {
|
|
1459
|
-
return "".concat(hours > 0 ? "".concat(hours, ":").concat("".concat(minutes).padStart(2, '0')) : minutes, ":").concat("".concat(seconds).padStart(2, '0'));
|
|
1460
|
-
}
|
|
1461
|
-
var countConsecutiveChars = function countConsecutiveChars(i, arr) {
|
|
1462
|
-
var j = i;
|
|
1463
|
-
while (arr[j] === arr[j + 1]) {
|
|
1464
|
-
j += 1;
|
|
1465
|
-
}
|
|
1466
|
-
return j - i + 1;
|
|
1467
|
-
};
|
|
1468
|
-
var timeUnitKeys = ['h', 'm', 's', 'S'];
|
|
1469
|
-
var output = [];
|
|
1470
|
-
_toConsumableArray(format).forEach(function (c, i, arr) {
|
|
1471
|
-
switch (c) {
|
|
1472
|
-
case 'h':
|
|
1473
|
-
{
|
|
1474
|
-
if (arr[i - 1] === 'h') {
|
|
1475
|
-
break;
|
|
1476
|
-
}
|
|
1477
|
-
var amount = countConsecutiveChars(i, arr);
|
|
1478
|
-
output.push("".concat(hours).padStart(amount, '0'));
|
|
1479
|
-
if (timeUnitKeys.includes(arr[i + amount])) {
|
|
1480
|
-
output.push(':');
|
|
1481
|
-
}
|
|
1482
|
-
break;
|
|
1483
|
-
}
|
|
1484
|
-
case 'm':
|
|
1485
|
-
{
|
|
1486
|
-
if (arr[i - 1] === 'm') {
|
|
1487
|
-
break;
|
|
1488
|
-
}
|
|
1489
|
-
var _amount = countConsecutiveChars(i, arr);
|
|
1490
|
-
if (!format.includes('h')) {
|
|
1491
|
-
minutes += hours * 60;
|
|
1492
|
-
}
|
|
1493
|
-
output.push("".concat(minutes).padStart(_amount, '0'));
|
|
1494
|
-
if (timeUnitKeys.includes(arr[i + _amount])) {
|
|
1495
|
-
output.push(':');
|
|
1496
|
-
}
|
|
1497
|
-
break;
|
|
1498
|
-
}
|
|
1499
|
-
case 's':
|
|
1500
|
-
{
|
|
1501
|
-
if (arr[i - 1] === 's') {
|
|
1502
|
-
break;
|
|
1503
|
-
}
|
|
1504
|
-
var _amount2 = countConsecutiveChars(i, arr);
|
|
1505
|
-
if (!format.includes('m')) {
|
|
1506
|
-
seconds += minutes * 60;
|
|
1507
|
-
}
|
|
1508
|
-
output.push("".concat(seconds).padStart(_amount2, '0'));
|
|
1509
|
-
if (timeUnitKeys.includes(arr[i + _amount2])) {
|
|
1510
|
-
output.push('.');
|
|
1511
|
-
}
|
|
1512
|
-
break;
|
|
1513
|
-
}
|
|
1514
|
-
case 'S':
|
|
1515
|
-
{
|
|
1516
|
-
if (arr[i - 1] === 'S') {
|
|
1517
|
-
break;
|
|
1518
|
-
}
|
|
1519
|
-
var _amount3 = countConsecutiveChars(i, arr);
|
|
1520
|
-
if (!format.includes('s')) {
|
|
1521
|
-
milliseconds += seconds * 1000;
|
|
1522
|
-
}
|
|
1523
|
-
output.push("".concat(Math.round(milliseconds / Math.pow(10, 3 - _amount3))).padStart(_amount3, '0'));
|
|
1524
|
-
break;
|
|
1525
|
-
}
|
|
1526
|
-
default:
|
|
1527
|
-
output.push(c);
|
|
1528
|
-
}
|
|
1529
|
-
});
|
|
1530
|
-
return output.join('');
|
|
1531
|
-
}
|
|
1532
|
-
|
|
1533
|
-
/**
|
|
1534
|
-
* Get TimeCode in a smpte representation
|
|
1535
|
-
*
|
|
1536
|
-
* @returns Smpte representation of the TimeCode
|
|
1537
|
-
*/
|
|
1538
|
-
}, {
|
|
1539
|
-
key: "toSmpte",
|
|
1540
|
-
value: function toSmpte() {
|
|
1541
|
-
if (this.samples === -Infinity) return '00:00:00:00';
|
|
1542
|
-
var _this$toUnits2 = this.toUnits(),
|
|
1543
|
-
hours = _this$toUnits2.hours,
|
|
1544
|
-
minutes = _this$toUnits2.minutes,
|
|
1545
|
-
seconds = _this$toUnits2.seconds,
|
|
1546
|
-
frames = _this$toUnits2.frames;
|
|
1547
|
-
var hhmmss = [hours.toFixed().padStart(2, '0'), minutes.toFixed().padStart(2, '0'), seconds.toFixed().padStart(2, '0')].join(':');
|
|
1548
|
-
return [hhmmss, "".concat(frames).padStart(2, '0')].join(this.frameSeparator);
|
|
1549
|
-
}
|
|
1550
|
-
|
|
1551
|
-
/**
|
|
1552
|
-
* Get TimeCode as a VidiCore TimeCodeType object
|
|
1553
|
-
*
|
|
1554
|
-
* @returns TimeCode as `{ samples, timeBase }`
|
|
1555
|
-
*/
|
|
1556
|
-
}, {
|
|
1557
|
-
key: "toObject",
|
|
1558
|
-
value: function toObject() {
|
|
1559
|
-
return {
|
|
1560
|
-
samples: this.samples,
|
|
1561
|
-
timeBase: this.timeBase.toObject()
|
|
1562
|
-
};
|
|
1563
|
-
}
|
|
1564
|
-
|
|
1565
|
-
/**
|
|
1566
|
-
* @deprecated Use {@link TimeCode#toObject | toObject} instead
|
|
1567
|
-
*
|
|
1568
|
-
* @returns TimeCode as `{ samples, timeBase }`
|
|
1569
|
-
*/
|
|
1570
|
-
}, {
|
|
1571
|
-
key: "toJson",
|
|
1572
|
-
value: function toJson() {
|
|
1573
|
-
// eslint-disable-next-line no-console
|
|
1574
|
-
console.warn('Deprecated - use toObject instead');
|
|
1575
|
-
return this.toObject();
|
|
1576
|
-
}
|
|
1577
|
-
}]);
|
|
1578
|
-
return TimeCode;
|
|
1579
|
-
}();
|
|
1580
|
-
|
|
1581
|
-
/* 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;}();
|
|
1582
433
|
|
|
1583
|
-
/**
|
|
434
|
+
/* eslint-disable no-self-assign */ /**
|
|
1584
435
|
* @private
|
|
1585
436
|
*
|
|
1586
437
|
* Using Euclid's algorithm
|
|
@@ -1588,26 +439,9 @@ var TimeCode = /*#__PURE__*/function () {
|
|
|
1588
439
|
* @param num1 a number
|
|
1589
440
|
* @param num2 another number
|
|
1590
441
|
* @returns The greatest common divisor of num1 and num2
|
|
1591
|
-
*/
|
|
1592
|
-
var getGreatestCommonDivisor = function getGreatestCommonDivisor(num1, num2) {
|
|
1593
|
-
var a = Math.abs(num1);
|
|
1594
|
-
var b = Math.abs(num2);
|
|
1595
|
-
while (a && b && a !== b) {
|
|
1596
|
-
if (a > b) {
|
|
1597
|
-
var _ref = [a - b, b];
|
|
1598
|
-
a = _ref[0];
|
|
1599
|
-
b = _ref[1];
|
|
1600
|
-
} else {
|
|
1601
|
-
var _ref2 = [a, b - a];
|
|
1602
|
-
a = _ref2[0];
|
|
1603
|
-
b = _ref2[1];
|
|
1604
|
-
}
|
|
1605
|
-
}
|
|
1606
|
-
return a || b;
|
|
1607
|
-
};
|
|
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;};
|
|
1608
443
|
|
|
1609
|
-
var _excluded$5
|
|
1610
|
-
/**
|
|
444
|
+
var _excluded$5=["timeBase","useGCD"];/**
|
|
1611
445
|
* Format seconds to TimeCode object
|
|
1612
446
|
*
|
|
1613
447
|
* @remarks
|
|
@@ -1623,117 +457,13 @@ var _excluded$5 = ["timeBase", "useGCD"];
|
|
|
1623
457
|
* @returns A TimeCode instance
|
|
1624
458
|
*
|
|
1625
459
|
* @category Time
|
|
1626
|
-
*/
|
|
1627
|
-
var formatTimeCodeSeconds = function formatTimeCodeSeconds(seconds, options) {
|
|
1628
|
-
var _ref = options || {},
|
|
1629
|
-
timeBase = _ref.timeBase,
|
|
1630
|
-
_ref$useGCD = _ref.useGCD,
|
|
1631
|
-
useGCD = _ref$useGCD === void 0 ? false : _ref$useGCD,
|
|
1632
|
-
timeCodeOptions = _objectWithoutProperties(_ref, _excluded$5);
|
|
1633
|
-
var secondsWithDot = "".concat(seconds).replace(/,/g, '.');
|
|
1634
|
-
if (Number.isNaN(+secondsWithDot)) {
|
|
1635
|
-
throw new Error("seconds must be digits, is ".concat(seconds));
|
|
1636
|
-
}
|
|
1637
|
-
var denominator = 1;
|
|
1638
|
-
var samples;
|
|
1639
|
-
if (Number.isInteger(+secondsWithDot)) {
|
|
1640
|
-
samples = +secondsWithDot * denominator;
|
|
1641
|
-
} else {
|
|
1642
|
-
var _ms$length;
|
|
1643
|
-
var _secondsWithDot$split = secondsWithDot.split('.'),
|
|
1644
|
-
_secondsWithDot$split2 = _slicedToArray(_secondsWithDot$split, 2),
|
|
1645
|
-
ms = _secondsWithDot$split2[1];
|
|
1646
|
-
var decimalPlaces = Math.min((_ms$length = ms === null || ms === void 0 ? void 0 : ms.length) !== null && _ms$length !== void 0 ? _ms$length : 0, 16);
|
|
1647
|
-
denominator *= Math.pow(10, decimalPlaces);
|
|
1648
|
-
samples = Math.round(Number(secondsWithDot) * denominator);
|
|
1649
|
-
}
|
|
1650
|
-
if (timeBase === undefined && useGCD) {
|
|
1651
|
-
var gcd = getGreatestCommonDivisor(denominator, samples);
|
|
1652
|
-
samples /= gcd;
|
|
1653
|
-
denominator /= gcd;
|
|
1654
|
-
}
|
|
1655
|
-
var timeCode = new TimeCode({
|
|
1656
|
-
samples: samples,
|
|
1657
|
-
timeBase: {
|
|
1658
|
-
denominator: denominator,
|
|
1659
|
-
numerator: 1
|
|
1660
|
-
}
|
|
1661
|
-
}, timeCodeOptions);
|
|
1662
|
-
return timeBase !== undefined ? timeCode.conformTimeBase(createTimeBase(timeBase)) : timeCode;
|
|
1663
|
-
};
|
|
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;};
|
|
1664
461
|
|
|
1665
|
-
var getDroppedFramesFromSmpte
|
|
1666
|
-
var _ref2 = _slicedToArray(_ref, 4),
|
|
1667
|
-
hh = _ref2[0],
|
|
1668
|
-
mm = _ref2[1],
|
|
1669
|
-
ss = _ref2[2],
|
|
1670
|
-
ff = _ref2[3];
|
|
1671
|
-
var roundedFrameRate = timeBase.toRate({
|
|
1672
|
-
rounded: true
|
|
1673
|
-
});
|
|
1674
|
-
var dropFrames = getAmountOfFrameDrops(timeBase);
|
|
1675
|
-
if (samples === 0 || !dropFrames) {
|
|
1676
|
-
return 0;
|
|
1677
|
-
}
|
|
1678
|
-
var shouldDropMinute = mm % 10 !== 0;
|
|
1679
|
-
var shouldDropSecond = shouldDropMinute && ss === 0;
|
|
1680
|
-
var hourFrames = hh * (3600 * roundedFrameRate - 54 * dropFrames);
|
|
1681
|
-
var minuteFrames = mm * 60 * roundedFrameRate - (mm - Math.ceil(mm / 10)) * dropFrames;
|
|
1682
|
-
var secondFrames = ss * roundedFrameRate - (shouldDropMinute && ss > 1 ? dropFrames : 0);
|
|
1683
|
-
if (shouldDropSecond && ff < dropFrames) {
|
|
1684
|
-
throw new Error("Frame does not exist for ".concat(timeBase.toConstant() || timeBase.toRate(), " drop-frame"));
|
|
1685
|
-
}
|
|
1686
|
-
var frameFrames = shouldDropSecond ? ff - dropFrames : ff;
|
|
1687
|
-
var samplesWithoutDroppedFrames = hourFrames + minuteFrames + secondFrames + frameFrames;
|
|
1688
|
-
return samples - samplesWithoutDroppedFrames;
|
|
1689
|
-
};
|
|
1690
|
-
var getSamplesFromSmpte = function getSamplesFromSmpte(smpteValues, timeBase, dropFrame) {
|
|
1691
|
-
var _smpteValues = _slicedToArray(smpteValues, 4),
|
|
1692
|
-
hh = _smpteValues[0],
|
|
1693
|
-
mm = _smpteValues[1],
|
|
1694
|
-
ss = _smpteValues[2],
|
|
1695
|
-
ff = _smpteValues[3];
|
|
1696
|
-
var roundedFrameRate = timeBase.toRate({
|
|
1697
|
-
rounded: true
|
|
1698
|
-
});
|
|
1699
|
-
var samples = hh * 3600 * roundedFrameRate + mm * 60 * roundedFrameRate + ss * roundedFrameRate + ff;
|
|
1700
|
-
return samples - (dropFrame ? getDroppedFramesFromSmpte(smpteValues, samples, timeBase) : 0);
|
|
1701
|
-
};
|
|
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);};
|
|
1702
463
|
|
|
1703
|
-
var splitSmpte
|
|
1704
|
-
var _ref = (smpte === null || smpte === void 0 ? void 0 : smpte.match(/[^0-9:\-_]/)) || [],
|
|
1705
|
-
_ref2 = _slicedToArray(_ref, 1),
|
|
1706
|
-
nonColonFrameSeparator = _ref2[0];
|
|
1707
|
-
var smpteValues = [];
|
|
1708
|
-
if (nonColonFrameSeparator) {
|
|
1709
|
-
var _smpte$split = smpte.split(nonColonFrameSeparator),
|
|
1710
|
-
_smpte$split2 = _slicedToArray(_smpte$split, 2),
|
|
1711
|
-
hhmmss = _smpte$split2[0],
|
|
1712
|
-
ff = _smpte$split2[1];
|
|
1713
|
-
smpteValues = [].concat(_toConsumableArray(hhmmss.split(':')), [ff]);
|
|
1714
|
-
} else {
|
|
1715
|
-
smpteValues = smpte.split(':');
|
|
1716
|
-
}
|
|
1717
|
-
if (smpteValues.length !== 4) {
|
|
1718
|
-
throw new Error('Invalid format, must be "##:##:##:##');
|
|
1719
|
-
}
|
|
1720
|
-
if (smpteValues.some(function (n) {
|
|
1721
|
-
return Number.isNaN(n);
|
|
1722
|
-
})) {
|
|
1723
|
-
throw new Error('Invalid format, values must be numbers');
|
|
1724
|
-
}
|
|
1725
|
-
var smpteFrameSeparator = nonColonFrameSeparator || ':';
|
|
1726
|
-
return {
|
|
1727
|
-
smpteValues: smpteValues.map(Number),
|
|
1728
|
-
smpteFrameSeparator: smpteFrameSeparator
|
|
1729
|
-
};
|
|
1730
|
-
};
|
|
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};};
|
|
1731
465
|
|
|
1732
|
-
var _excluded$4
|
|
1733
|
-
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; }
|
|
1734
|
-
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; }
|
|
1735
|
-
var EXCEEDING_OPTIONS = ['error', 'add', 'ignore'];
|
|
1736
|
-
/**
|
|
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'];/**
|
|
1737
467
|
* Format smpte text to a TimeCode Instance
|
|
1738
468
|
*
|
|
1739
469
|
* exceedingMode:
|
|
@@ -1746,139 +476,15 @@ var EXCEEDING_OPTIONS = ['error', 'add', 'ignore'];
|
|
|
1746
476
|
* @returns TimeCode instance created from smpte string
|
|
1747
477
|
*
|
|
1748
478
|
* @category Time
|
|
1749
|
-
*/
|
|
1750
|
-
var formatTimeCodeSmpte = function formatTimeCodeSmpte(smpte, options) {
|
|
1751
|
-
var _ref = options || {},
|
|
1752
|
-
_ref$exceedingMode = _ref.exceedingMode,
|
|
1753
|
-
exceedingMode = _ref$exceedingMode === void 0 ? 'error' : _ref$exceedingMode,
|
|
1754
|
-
timeBase = _ref.timeBase,
|
|
1755
|
-
timeCodeOptions = _objectWithoutProperties(_ref, _excluded$4);
|
|
1756
|
-
if ([null, undefined].includes(smpte)) {
|
|
1757
|
-
throw new Error("smpte cannot be undefined or null");
|
|
1758
|
-
}
|
|
1759
|
-
if (typeof smpte !== 'string') {
|
|
1760
|
-
throw new Error("smpte must be a string, is ".concat(JSON.stringify(smpte)));
|
|
1761
|
-
}
|
|
1762
|
-
var _splitSmpte = splitSmpte(smpte),
|
|
1763
|
-
smpteValues = _splitSmpte.smpteValues,
|
|
1764
|
-
smpteFrameSeparator = _splitSmpte.smpteFrameSeparator;
|
|
1765
|
-
var timeBaseInstance = createTimeBase(timeBase);
|
|
1766
|
-
var mergedOptions = _objectSpread$9(_objectSpread$9({}, timeCodeOptions), {}, {
|
|
1767
|
-
frameSeparator: (timeCodeOptions === null || timeCodeOptions === void 0 ? void 0 : timeCodeOptions.frameSeparator) || smpteFrameSeparator
|
|
1768
|
-
}, (timeCodeOptions === null || timeCodeOptions === void 0 ? void 0 : timeCodeOptions.dropFrame) === undefined ? {
|
|
1769
|
-
dropFrame: timeBase !== undefined ? isDropFrameTimeBase(timeBaseInstance) : [';', ','].includes(smpteFrameSeparator)
|
|
1770
|
-
} : {});
|
|
1771
|
-
var roundedFrameRate = timeBaseInstance.toRate({
|
|
1772
|
-
rounded: true
|
|
1773
|
-
});
|
|
1774
|
-
var maxFrame = Math.max(0, roundedFrameRate - 1);
|
|
1775
|
-
if (smpteValues.some(function (v) {
|
|
1776
|
-
return v < 0;
|
|
1777
|
-
})) {
|
|
1778
|
-
throw new Error('Negative values are not supported');
|
|
1779
|
-
}
|
|
1780
|
-
var samples;
|
|
1781
|
-
switch (exceedingMode) {
|
|
1782
|
-
case 'error':
|
|
1783
|
-
{
|
|
1784
|
-
var _smpteValues = _slicedToArray(smpteValues, 4),
|
|
1785
|
-
hours = _smpteValues[0],
|
|
1786
|
-
minutes = _smpteValues[1],
|
|
1787
|
-
seconds = _smpteValues[2],
|
|
1788
|
-
frames = _smpteValues[3];
|
|
1789
|
-
if (hours >= 100) {
|
|
1790
|
-
throw Error('Minutes has to be less than 60');
|
|
1791
|
-
}
|
|
1792
|
-
if (minutes >= 60) {
|
|
1793
|
-
throw Error('Minutes has to be less than 60');
|
|
1794
|
-
}
|
|
1795
|
-
if (seconds >= 60) {
|
|
1796
|
-
throw Error('Seconds has to be less than 60');
|
|
1797
|
-
}
|
|
1798
|
-
if (frames > maxFrame) {
|
|
1799
|
-
throw Error("Frames has to be less or equal to ".concat(maxFrame));
|
|
1800
|
-
}
|
|
1801
|
-
samples = getSamplesFromSmpte(smpteValues, timeBaseInstance, mergedOptions === null || mergedOptions === void 0 ? void 0 : mergedOptions.dropFrame);
|
|
1802
|
-
break;
|
|
1803
|
-
}
|
|
1804
|
-
case 'ignore':
|
|
1805
|
-
{
|
|
1806
|
-
var _smpteValues2 = _slicedToArray(smpteValues, 4),
|
|
1807
|
-
_hours = _smpteValues2[0],
|
|
1808
|
-
_minutes = _smpteValues2[1],
|
|
1809
|
-
_seconds = _smpteValues2[2],
|
|
1810
|
-
_frames = _smpteValues2[3];
|
|
1811
|
-
var truncatedSmpteValues = [Math.min(100, _hours), Math.min(59, _minutes), Math.min(59, _seconds), Math.min(maxFrame, _frames)];
|
|
1812
|
-
samples = getSamplesFromSmpte(truncatedSmpteValues, timeBaseInstance, mergedOptions === null || mergedOptions === void 0 ? void 0 : mergedOptions.dropFrame);
|
|
1813
|
-
break;
|
|
1814
|
-
}
|
|
1815
|
-
case 'add':
|
|
1816
|
-
{
|
|
1817
|
-
samples = getSamplesFromSmpte(smpteValues, timeBaseInstance, mergedOptions === null || mergedOptions === void 0 ? void 0 : mergedOptions.dropFrame);
|
|
1818
|
-
break;
|
|
1819
|
-
}
|
|
1820
|
-
default:
|
|
1821
|
-
{
|
|
1822
|
-
throw new Error("Invalid exceedingMode, options are ".concat(JSON.stringify(EXCEEDING_OPTIONS)));
|
|
1823
|
-
}
|
|
1824
|
-
}
|
|
1825
|
-
return new TimeCode({
|
|
1826
|
-
samples: samples,
|
|
1827
|
-
timeBase: timeBaseInstance
|
|
1828
|
-
}, mergedOptions);
|
|
1829
|
-
};
|
|
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);};
|
|
1830
480
|
|
|
1831
|
-
var _excluded$3
|
|
1832
|
-
/**
|
|
481
|
+
var _excluded$3=["timeBase"];/**
|
|
1833
482
|
* Format text to a TimeCode instance
|
|
1834
483
|
*
|
|
1835
484
|
* @returns A TimeCode instance
|
|
1836
485
|
*
|
|
1837
486
|
* @category Time
|
|
1838
|
-
*/
|
|
1839
|
-
var formatTimeCodeText = function formatTimeCodeText(timeCodeText, options) {
|
|
1840
|
-
var _timeCodeObject;
|
|
1841
|
-
var _ref = options || {},
|
|
1842
|
-
timeBase = _ref.timeBase,
|
|
1843
|
-
timeCodeOptions = _objectWithoutProperties(_ref, _excluded$3);
|
|
1844
|
-
var timeCodeObject;
|
|
1845
|
-
if (timeCodeText === undefined) {
|
|
1846
|
-
timeCodeObject = {
|
|
1847
|
-
samples: 0
|
|
1848
|
-
};
|
|
1849
|
-
} else if (typeof timeCodeText === 'number') {
|
|
1850
|
-
timeCodeObject = {
|
|
1851
|
-
samples: timeCodeText
|
|
1852
|
-
};
|
|
1853
|
-
} else if (timeCodeText.includes('@')) {
|
|
1854
|
-
var _timeCodeText$split = timeCodeText.split('@'),
|
|
1855
|
-
_timeCodeText$split2 = _slicedToArray(_timeCodeText$split, 2),
|
|
1856
|
-
samplesString = _timeCodeText$split2[0],
|
|
1857
|
-
timeBaseText = _timeCodeText$split2[1];
|
|
1858
|
-
var samples = Number(samplesString);
|
|
1859
|
-
timeCodeObject = {
|
|
1860
|
-
samples: samples,
|
|
1861
|
-
timeBase: formatTimeBaseText(timeBaseText)
|
|
1862
|
-
};
|
|
1863
|
-
} else if (timeCodeText === '-INF') {
|
|
1864
|
-
timeCodeObject = {
|
|
1865
|
-
samples: -Infinity
|
|
1866
|
-
};
|
|
1867
|
-
} else if (timeCodeText === '+INF') {
|
|
1868
|
-
timeCodeObject = {
|
|
1869
|
-
samples: Infinity
|
|
1870
|
-
};
|
|
1871
|
-
} else {
|
|
1872
|
-
timeCodeObject = {
|
|
1873
|
-
samples: Number(timeCodeText)
|
|
1874
|
-
};
|
|
1875
|
-
}
|
|
1876
|
-
if (Number.isNaN((_timeCodeObject = timeCodeObject) === null || _timeCodeObject === void 0 ? void 0 : _timeCodeObject.samples) || timeCodeObject.timeBase && !(timeCodeObject.timeBase instanceof TimeBase)) {
|
|
1877
|
-
throw new Error("timeCodeText must be a number or sample@timeBase - is ".concat(timeCodeText));
|
|
1878
|
-
}
|
|
1879
|
-
var timeCode = new TimeCode(timeCodeObject, timeCodeOptions);
|
|
1880
|
-
return timeBase ? timeCode.conformTimeBase(createTimeBase(timeBase)) : timeCode;
|
|
1881
|
-
};
|
|
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;};
|
|
1882
488
|
|
|
1883
489
|
/**
|
|
1884
490
|
* Format an object to a TimeCode instance
|
|
@@ -1888,18 +494,9 @@ var formatTimeCodeText = function formatTimeCodeText(timeCodeText, options) {
|
|
|
1888
494
|
* @returns A TimeCode instance
|
|
1889
495
|
*
|
|
1890
496
|
* @category Time
|
|
1891
|
-
*/
|
|
1892
|
-
var formatTimeCodeType = function formatTimeCodeType(timeCode, options) {
|
|
1893
|
-
return new TimeCode(timeCode, options);
|
|
1894
|
-
};
|
|
497
|
+
*/var formatTimeCodeType=function formatTimeCodeType(timeCode,options){return new TimeCode(timeCode,options);};
|
|
1895
498
|
|
|
1896
|
-
var hasSmpteFormat
|
|
1897
|
-
return !!s.match(/^(\d\d+):(\d\d+):(\d\d+)(:|;|\.|,)(\d\d+)$/);
|
|
1898
|
-
};
|
|
1899
|
-
var isNumber = function isNumber(s) {
|
|
1900
|
-
return !Number.isNaN(Number(s));
|
|
1901
|
-
};
|
|
1902
|
-
/**
|
|
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));};/**
|
|
1903
500
|
* Create a TimeCode instance from smpte, seconds/samples, timeCode object or string
|
|
1904
501
|
*
|
|
1905
502
|
* @param timeCode Smpte, seconds/samples, timeCode object or string
|
|
@@ -1907,42 +504,11 @@ var isNumber = function isNumber(s) {
|
|
|
1907
504
|
* @returns A TimeCode instance
|
|
1908
505
|
*
|
|
1909
506
|
* @category Time
|
|
1910
|
-
*/
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
if (typeof timeCode !== 'string' && typeof timeCode !== 'number') return formatTimeCodeType(timeCode, options);
|
|
1914
|
-
// SMPTE
|
|
1915
|
-
if (typeof timeCode === 'string' && hasSmpteFormat(timeCode)) return formatTimeCodeSmpte(timeCode, options);
|
|
1916
|
-
if (['string', 'number'].includes(_typeof(timeCode)) && isNumber(timeCode)) return formatTimeCodeSeconds(timeCode, options);
|
|
1917
|
-
if (typeof timeCode === 'string') {
|
|
1918
|
-
return formatTimeCodeText(timeCode, options);
|
|
1919
|
-
}
|
|
1920
|
-
return undefined;
|
|
1921
|
-
};
|
|
1922
|
-
|
|
1923
|
-
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; }
|
|
1924
|
-
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; }
|
|
1925
|
-
function timeToCueTime(_ref) {
|
|
1926
|
-
var _ref$hours = _ref.hours,
|
|
1927
|
-
hours = _ref$hours === void 0 ? 0 : _ref$hours,
|
|
1928
|
-
_ref$minutes = _ref.minutes,
|
|
1929
|
-
minutes = _ref$minutes === void 0 ? 0 : _ref$minutes,
|
|
1930
|
-
_ref$seconds = _ref.seconds,
|
|
1931
|
-
seconds = _ref$seconds === void 0 ? 0 : _ref$seconds,
|
|
1932
|
-
_ref$partialSeconds = _ref.partialSeconds,
|
|
1933
|
-
partialSeconds = _ref$partialSeconds === void 0 ? 0 : _ref$partialSeconds;
|
|
1934
|
-
var hourStr = hours.toFixed().padStart(2, '0');
|
|
1935
|
-
var minStr = minutes.toFixed().padStart(2, '0');
|
|
1936
|
-
var secondsStr = seconds.toFixed().padStart(2, '0');
|
|
1937
|
-
var partialStr = (partialSeconds * 10).toFixed().padStart(3, '0');
|
|
1938
|
-
return "".concat(hourStr, ":").concat(minStr, ":").concat(secondsStr, ".").concat(partialStr);
|
|
1939
|
-
}
|
|
1940
|
-
var defaultOptions$2 = {
|
|
1941
|
-
subtitleGroup: 'stl_subtitle',
|
|
1942
|
-
subtitleField: 'stl_text'
|
|
1943
|
-
};
|
|
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;};
|
|
1944
510
|
|
|
1945
|
-
|
|
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'};/**
|
|
1946
512
|
* Convert metadata subtitle groups to WebVtt subtitles
|
|
1947
513
|
*
|
|
1948
514
|
* @param metadataType - Vidicore metadata object (should include subtitleGroup and subtitleField)
|
|
@@ -1950,36 +516,7 @@ var defaultOptions$2 = {
|
|
|
1950
516
|
* @returns WebVtt subtitles
|
|
1951
517
|
*
|
|
1952
518
|
* @category Metadata
|
|
1953
|
-
*/
|
|
1954
|
-
var metadataTypeToWebVtt = function metadataTypeToWebVtt(metadataType, options) {
|
|
1955
|
-
var _defaultOptions = _objectSpread$8(_objectSpread$8({}, defaultOptions$2), options || {}),
|
|
1956
|
-
subtitleGroup = _defaultOptions.subtitleGroup,
|
|
1957
|
-
subtitleField = _defaultOptions.subtitleField;
|
|
1958
|
-
var _ref2 = metadataType || {},
|
|
1959
|
-
_ref2$timespan = _ref2.timespan,
|
|
1960
|
-
timespanList = _ref2$timespan === void 0 ? [] : _ref2$timespan;
|
|
1961
|
-
if (timespanList.length === 0) return '';
|
|
1962
|
-
var parsedTimespans = parseTimespanList(timespanList, {
|
|
1963
|
-
includeTimespanAttributes: true,
|
|
1964
|
-
sortTimespan: true,
|
|
1965
|
-
timespanAsList: true,
|
|
1966
|
-
overrideGroup: true,
|
|
1967
|
-
joinValue: ','
|
|
1968
|
-
});
|
|
1969
|
-
var vttCues = parsedTimespans.map(function (timespan) {
|
|
1970
|
-
var _ref3 = (Array.isArray(timespan) ? timespan[0] : timespan) || {},
|
|
1971
|
-
startText = _ref3.start,
|
|
1972
|
-
endText = _ref3.end,
|
|
1973
|
-
_ref3$subtitleGroup = _ref3[subtitleGroup];
|
|
1974
|
-
_ref3$subtitleGroup = _ref3$subtitleGroup === void 0 ? {} : _ref3$subtitleGroup;
|
|
1975
|
-
var text = _ref3$subtitleGroup[subtitleField];
|
|
1976
|
-
if (!text) return '';
|
|
1977
|
-
var start = timeToCueTime(formatTimeCodeText(startText).toTime());
|
|
1978
|
-
var end = timeToCueTime(formatTimeCodeText(endText).toTime());
|
|
1979
|
-
return "".concat(start, " --> ").concat(end, " line:0%\r").concat(text, "\r");
|
|
1980
|
-
});
|
|
1981
|
-
return "WEBVTT\n\n\n".concat(vttCues.join('\n'));
|
|
1982
|
-
};
|
|
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'));};
|
|
1983
520
|
|
|
1984
521
|
/**
|
|
1985
522
|
* Create a Vidicore facet list
|
|
@@ -1989,109 +526,27 @@ var metadataTypeToWebVtt = function metadataTypeToWebVtt(metadataType, options)
|
|
|
1989
526
|
* @returns A VidiCore facet list
|
|
1990
527
|
*
|
|
1991
528
|
* @category Search
|
|
1992
|
-
*/
|
|
1993
|
-
var createFacetType = function createFacetType() {
|
|
1994
|
-
var fieldList = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
1995
|
-
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
|
|
1996
|
-
count: true
|
|
1997
|
-
};
|
|
1998
|
-
return fieldList.map(function (field) {
|
|
1999
|
-
return {
|
|
2000
|
-
field: field,
|
|
2001
|
-
name: field,
|
|
2002
|
-
count: options.count !== undefined ? options === null || options === void 0 ? void 0 : options.count : true,
|
|
2003
|
-
exclude: fieldList
|
|
2004
|
-
};
|
|
2005
|
-
});
|
|
2006
|
-
};
|
|
2007
|
-
|
|
2008
|
-
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; }
|
|
2009
|
-
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; }
|
|
2010
|
-
/** 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};});};
|
|
2011
530
|
|
|
2012
|
-
/**
|
|
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 */ /**
|
|
2013
532
|
* Parse a VidiCore facet type list
|
|
2014
533
|
*
|
|
2015
534
|
* @param facetType A facet type list to parse
|
|
2016
535
|
* @returns A parsed facet type list
|
|
2017
536
|
*
|
|
2018
537
|
* @category Search
|
|
2019
|
-
*/
|
|
2020
|
-
var parseFacetType = function parseFacetType() {
|
|
2021
|
-
var facetType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
2022
|
-
var output = {};
|
|
2023
|
-
facetType.forEach(function (_ref) {
|
|
2024
|
-
var name = _ref.name,
|
|
2025
|
-
field = _ref.field,
|
|
2026
|
-
count = _ref.count;
|
|
2027
|
-
output[name || field] = count.reduce(function (acc, _ref2) {
|
|
2028
|
-
var fieldValue = _ref2.fieldValue,
|
|
2029
|
-
value = _ref2.value;
|
|
2030
|
-
return _objectSpread$7(_objectSpread$7({}, acc), {}, _defineProperty({}, fieldValue, value));
|
|
2031
|
-
}, {});
|
|
2032
|
-
});
|
|
2033
|
-
return output;
|
|
2034
|
-
};
|
|
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;};
|
|
2035
539
|
|
|
2036
|
-
function ownKeys$6(object,
|
|
2037
|
-
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; }
|
|
2038
|
-
var defaultOptions$1 = {
|
|
2039
|
-
arrayOnSingle: true,
|
|
2040
|
-
joinValue: undefined,
|
|
2041
|
-
timespanAsList: false
|
|
2042
|
-
};
|
|
2043
|
-
|
|
2044
|
-
/**
|
|
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};/**
|
|
2045
541
|
* Parses highlight timespan in VidiCore into key/value object.
|
|
2046
542
|
* The attributes can be targeted for each sub-type.
|
|
2047
543
|
* @param timespan - A VidiCore search timespan
|
|
2048
544
|
* @param options - Options which change how the timespans are parsed
|
|
2049
545
|
*
|
|
2050
546
|
* @category Search
|
|
2051
|
-
*/
|
|
2052
|
-
var parseHighlightTimespan = function parseHighlightTimespan(timespan, options) {
|
|
2053
|
-
var _defaultOptions = _objectSpread$6(_objectSpread$6({}, defaultOptions$1), options || {}),
|
|
2054
|
-
_defaultOptions$array = _defaultOptions.arrayOnSingle,
|
|
2055
|
-
arrayOnSingle = _defaultOptions$array === void 0 ? true : _defaultOptions$array,
|
|
2056
|
-
_defaultOptions$joinV = _defaultOptions.joinValue,
|
|
2057
|
-
joinValue = _defaultOptions$joinV === void 0 ? undefined : _defaultOptions$joinV,
|
|
2058
|
-
_defaultOptions$times = _defaultOptions.timespanAsList,
|
|
2059
|
-
timespanAsList = _defaultOptions$times === void 0 ? false : _defaultOptions$times;
|
|
2060
|
-
var _ref = timespan || {},
|
|
2061
|
-
_ref$field = _ref.field,
|
|
2062
|
-
field = _ref$field === void 0 ? [] : _ref$field,
|
|
2063
|
-
start = _ref.start,
|
|
2064
|
-
end = _ref.end;
|
|
2065
|
-
var initialValue = timespanAsList ? {
|
|
2066
|
-
start: start,
|
|
2067
|
-
end: end
|
|
2068
|
-
} : {};
|
|
2069
|
-
var fieldList = field.reduce(function (acc, curr) {
|
|
2070
|
-
var name = curr.name,
|
|
2071
|
-
_curr$value = curr.value,
|
|
2072
|
-
valueList = _curr$value === void 0 ? [] : _curr$value;
|
|
2073
|
-
if (valueList.length === 0) return acc;
|
|
2074
|
-
var fieldValue;
|
|
2075
|
-
if (arrayOnSingle === false && valueList.length === 1) {
|
|
2076
|
-
var _valueList = _slicedToArray(valueList, 1);
|
|
2077
|
-
fieldValue = _valueList[0];
|
|
2078
|
-
} else if (joinValue) fieldValue = valueList.join(joinValue);else fieldValue = valueList;
|
|
2079
|
-
return _objectSpread$6(_objectSpread$6({}, acc), {}, _defineProperty({}, name, fieldValue));
|
|
2080
|
-
}, initialValue);
|
|
2081
|
-
return fieldList;
|
|
2082
|
-
};
|
|
2083
|
-
|
|
2084
|
-
var _excluded$2 = ["timespanAsList", "joinTimespan", "flat", "flatTimespan"];
|
|
2085
|
-
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; }
|
|
2086
|
-
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; }
|
|
2087
|
-
var defaultOptions = _objectSpread$5(_objectSpread$5({}, defaultOptions$1), {}, {
|
|
2088
|
-
timespanAsList: false,
|
|
2089
|
-
joinTimespan: '_',
|
|
2090
|
-
flat: false,
|
|
2091
|
-
flatTimespan: false
|
|
2092
|
-
});
|
|
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;};
|
|
2093
548
|
|
|
2094
|
-
|
|
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});/**
|
|
2095
550
|
* Parses highlight timespans from VidiCore into key/value object.
|
|
2096
551
|
* The attributes can be targeted for each sub-type.
|
|
2097
552
|
*
|
|
@@ -2099,29 +554,7 @@ var defaultOptions = _objectSpread$5(_objectSpread$5({}, defaultOptions$1), {},
|
|
|
2099
554
|
* @param options - Options to change how the timespans are parsed
|
|
2100
555
|
*
|
|
2101
556
|
* @category Search
|
|
2102
|
-
*/
|
|
2103
|
-
var parseHighlightTimespanList = function parseHighlightTimespanList() {
|
|
2104
|
-
var highlightTimespanList = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
2105
|
-
var options = arguments.length > 1 ? arguments[1] : undefined;
|
|
2106
|
-
var _defaultOptions = _objectSpread$5(_objectSpread$5({}, defaultOptions), options || {}),
|
|
2107
|
-
timespanAsList = _defaultOptions.timespanAsList,
|
|
2108
|
-
_defaultOptions$joinT = _defaultOptions.joinTimespan,
|
|
2109
|
-
joinTimespan = _defaultOptions$joinT === void 0 ? '_' : _defaultOptions$joinT,
|
|
2110
|
-
flat = _defaultOptions.flat,
|
|
2111
|
-
flatTimespan = _defaultOptions.flatTimespan,
|
|
2112
|
-
parseHighlightTimespanOptions = _objectWithoutProperties(_defaultOptions, _excluded$2);
|
|
2113
|
-
if (timespanAsList === true) return highlightTimespanList.map(function (timespan) {
|
|
2114
|
-
return parseHighlightTimespan(timespan, _objectSpread$5(_objectSpread$5({}, parseHighlightTimespanOptions), {}, {
|
|
2115
|
-
timespanAsList: timespanAsList
|
|
2116
|
-
}));
|
|
2117
|
-
});
|
|
2118
|
-
if (flat === true || flatTimespan === true) return highlightTimespanList.reduce(function (a, timespan) {
|
|
2119
|
-
return _objectSpread$5(_objectSpread$5({}, a), parseHighlightTimespan(timespan, options));
|
|
2120
|
-
}, {});
|
|
2121
|
-
return highlightTimespanList.reduce(function (a, timespan) {
|
|
2122
|
-
return _objectSpread$5(_objectSpread$5({}, a), {}, _defineProperty({}, [timespan.start, timespan.end].join(joinTimespan), parseHighlightTimespan(timespan, options)));
|
|
2123
|
-
}, {});
|
|
2124
|
-
};
|
|
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)));},{});};
|
|
2125
558
|
|
|
2126
559
|
/**
|
|
2127
560
|
* Parse Vidicore "NOW" constants to a date object
|
|
@@ -2135,153 +568,24 @@ var parseHighlightTimespanList = function parseHighlightTimespanList() {
|
|
|
2135
568
|
* @returns A date from the NOW constant
|
|
2136
569
|
*
|
|
2137
570
|
* @category Search
|
|
2138
|
-
*/
|
|
2139
|
-
var parseNowDate = function parseNowDate() {
|
|
2140
|
-
var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'NOW';
|
|
2141
|
-
if (value.startsWith('NOW')) {
|
|
2142
|
-
if (value === 'NOW') return new Date();
|
|
2143
|
-
var sign = value[3];
|
|
2144
|
-
var number = Number(value.match(/(\d+)/)[0]);
|
|
2145
|
-
var unit = value.match(/(\d.*)/)[0].replace(/\d/g, '');
|
|
2146
|
-
var nowDiff = new Date();
|
|
2147
|
-
switch (unit) {
|
|
2148
|
-
case 'HOUR':
|
|
2149
|
-
case 'HOURS':
|
|
2150
|
-
if (sign === '+') nowDiff.setHours(nowDiff.getHours() + number);
|
|
2151
|
-
if (sign === '-') nowDiff.setHours(nowDiff.getHours() - number);
|
|
2152
|
-
break;
|
|
2153
|
-
case 'DAY':
|
|
2154
|
-
case 'DAYS':
|
|
2155
|
-
if (sign === '+') nowDiff.setDate(nowDiff.getDate() + number);
|
|
2156
|
-
if (sign === '-') nowDiff.setDate(nowDiff.getDate() - number);
|
|
2157
|
-
break;
|
|
2158
|
-
case 'MONTH':
|
|
2159
|
-
case 'MONTHS':
|
|
2160
|
-
if (sign === '+') nowDiff.setMonth(nowDiff.getMonth() + number);
|
|
2161
|
-
if (sign === '-') nowDiff.setMonth(nowDiff.getMonth() - number);
|
|
2162
|
-
break;
|
|
2163
|
-
case 'YEAR':
|
|
2164
|
-
case 'YEARS':
|
|
2165
|
-
if (sign === '+') nowDiff.setFullYear(nowDiff.getFullYear() + number);
|
|
2166
|
-
if (sign === '-') nowDiff.setFullYear(nowDiff.getFullYear() - number);
|
|
2167
|
-
break;
|
|
2168
|
-
}
|
|
2169
|
-
return nowDiff;
|
|
2170
|
-
}
|
|
2171
|
-
return new Date(value);
|
|
2172
|
-
};
|
|
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);};
|
|
2173
572
|
|
|
2174
|
-
var _excluded$1
|
|
2175
|
-
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; }
|
|
2176
|
-
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; }
|
|
2177
|
-
var parseBaseMediaInfoType = function parseBaseMediaInfoType(baseMediaInfoType) {
|
|
2178
|
-
var _ref = baseMediaInfoType || {},
|
|
2179
|
-
_ref$property = _ref.property,
|
|
2180
|
-
keyValuePairTypes = _ref$property === void 0 ? [] : _ref$property,
|
|
2181
|
-
props = _objectWithoutProperties(_ref, _excluded$1);
|
|
2182
|
-
var parsedKeyValuePairType = parseKeyValuePairTypes(keyValuePairTypes);
|
|
2183
|
-
return _objectSpread$4(_objectSpread$4({}, parsedKeyValuePairType), props);
|
|
2184
|
-
};
|
|
2185
|
-
var parseAudioMediaInfoType = function parseAudioMediaInfoType(mediaInfoType) {
|
|
2186
|
-
return parseBaseMediaInfoType(mediaInfoType);
|
|
2187
|
-
};
|
|
2188
|
-
var parseVideoMediaInfoType = function parseVideoMediaInfoType(mediaInfoType) {
|
|
2189
|
-
return parseBaseMediaInfoType(mediaInfoType);
|
|
2190
|
-
};
|
|
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);};
|
|
2191
574
|
|
|
2192
|
-
var sampleRateSymbols =
|
|
2193
|
-
kB: 'kHz',
|
|
2194
|
-
B: 'Hz',
|
|
2195
|
-
mB: 'mHz'
|
|
2196
|
-
};
|
|
2197
|
-
var bitRateSymbols$1 = {
|
|
2198
|
-
kB: 'kbps',
|
|
2199
|
-
B: 'bps',
|
|
2200
|
-
MB: 'mbps'
|
|
2201
|
-
};
|
|
2202
|
-
/**
|
|
575
|
+
var sampleRateSymbols={kB:'kHz',B:'Hz',mB:'mHz'};var bitRateSymbols$1={kB:'kbps',B:'bps',MB:'mbps'};/**
|
|
2203
576
|
* Parses the technical information of a AudioComponentType.
|
|
2204
577
|
* @param audioComponentType - A AudioComponentType from VidiCore.
|
|
2205
578
|
* @returns Parsed component object.
|
|
2206
579
|
*
|
|
2207
580
|
* @category Shape
|
|
2208
|
-
*/
|
|
2209
|
-
var parseAudioComponent = function parseAudioComponent(audioComponentType) {
|
|
2210
|
-
var timeBase = audioComponentType.timeBase,
|
|
2211
|
-
audioChannels = audioComponentType.channelCount,
|
|
2212
|
-
audioCodec = audioComponentType.codec,
|
|
2213
|
-
mediaInfo = audioComponentType.mediaInfo,
|
|
2214
|
-
bitrate = audioComponentType.bitrate,
|
|
2215
|
-
metadata = audioComponentType.metadata;
|
|
2216
|
-
var audioMediaInfo = parseAudioMediaInfoType(mediaInfo);
|
|
2217
|
-
var audioFormat = audioMediaInfo.Format,
|
|
2218
|
-
audioBitDepth = audioMediaInfo.Resolution,
|
|
2219
|
-
audioBitRateMode = audioMediaInfo.Bit_rate_mode;
|
|
2220
|
-
var audioMetadata = parseKeyValuePairTypes(metadata || []);
|
|
2221
|
-
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;
|
|
2222
|
-
var audioSamplerate = audioSamplerateSamples !== undefined ? filesize(audioSamplerateSamples, {
|
|
2223
|
-
base: 10,
|
|
2224
|
-
round: 1,
|
|
2225
|
-
symbols: sampleRateSymbols
|
|
2226
|
-
}) : undefined;
|
|
2227
|
-
var audioBitrate;
|
|
2228
|
-
var audioBitrateKbps;
|
|
2229
|
-
if (bitrate !== undefined) {
|
|
2230
|
-
var _split;
|
|
2231
|
-
audioBitrate = filesize(bitrate, {
|
|
2232
|
-
round: 2,
|
|
2233
|
-
symbols: bitRateSymbols$1
|
|
2234
|
-
});
|
|
2235
|
-
audioBitrateKbps = Number((_split = filesize(bitrate, {
|
|
2236
|
-
exponent: 1,
|
|
2237
|
-
symbols: bitRateSymbols$1
|
|
2238
|
-
}).split(' kbps')) === null || _split === void 0 ? void 0 : _split[0]);
|
|
2239
|
-
}
|
|
2240
|
-
return {
|
|
2241
|
-
audioFormat: audioFormat,
|
|
2242
|
-
audioCodec: audioCodec,
|
|
2243
|
-
audioSamplerate: audioSamplerate,
|
|
2244
|
-
audioSamplerateSamples: audioSamplerateSamples,
|
|
2245
|
-
audioBitDepth: audioBitDepth,
|
|
2246
|
-
audioBitrate: audioBitrate,
|
|
2247
|
-
audioBitrateKbps: audioBitrateKbps,
|
|
2248
|
-
audioBitRateMode: audioBitRateMode,
|
|
2249
|
-
audioChannels: audioChannels,
|
|
2250
|
-
audioMediaInfo: audioMediaInfo,
|
|
2251
|
-
audioMetadata: audioMetadata
|
|
2252
|
-
};
|
|
2253
|
-
};
|
|
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};};
|
|
2254
582
|
|
|
2255
583
|
/**
|
|
2256
584
|
* Const object with all file states in VidiCore
|
|
2257
585
|
* (see https://apidoc.vidispine.com/latest/storage/storage.html#file-states for more info)
|
|
2258
586
|
*
|
|
2259
587
|
* @category File
|
|
2260
|
-
*/
|
|
2261
|
-
var FILE_STATES = {
|
|
2262
|
-
/** Just created, not used. */
|
|
2263
|
-
NONE: 'NONE',
|
|
2264
|
-
/** Discovered or created, not yet marked as finished. */
|
|
2265
|
-
OPEN: 'OPEN',
|
|
2266
|
-
/** File does no longer grow. */
|
|
2267
|
-
CLOSED: 'CLOSED',
|
|
2268
|
-
/** The current state is not known. */
|
|
2269
|
-
UNKNOWN: 'UNKNOWN',
|
|
2270
|
-
/** File is missing from the file system/storage. */
|
|
2271
|
-
MISSING: 'MISSING',
|
|
2272
|
-
/** File has been missing for a longer period. Candidate for restoration from archive. */
|
|
2273
|
-
LOST: 'LOST',
|
|
2274
|
-
/** File will appear on file system/storage, transfer subsystem or transcoder will create it. */
|
|
2275
|
-
TO_APPEAR: 'TO_APPEAR',
|
|
2276
|
-
/** The file is no longer in use, and will be deleted at the next clean-up sweep. */
|
|
2277
|
-
TO_BE_DELETED: 'TO_BE_DELETED',
|
|
2278
|
-
/** File is in use by transfer subsystem or transcoder. */
|
|
2279
|
-
BEING_READ: 'BEING_READ',
|
|
2280
|
-
/** File is archived. */
|
|
2281
|
-
ARCHIVED: 'ARCHIVED',
|
|
2282
|
-
/** File will be synchronized by multi-site agent. */
|
|
2283
|
-
AWAITING_SYNC: 'AWAITING_SYNC'
|
|
2284
|
-
};
|
|
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'};
|
|
2285
589
|
|
|
2286
590
|
/**
|
|
2287
591
|
* Parses a VidiCore file object
|
|
@@ -2293,236 +597,35 @@ var FILE_STATES = {
|
|
|
2293
597
|
* @returns A parsed file object
|
|
2294
598
|
*
|
|
2295
599
|
* @category File
|
|
2296
|
-
*/
|
|
2297
|
-
var parseFileType = function parseFileType(fileType) {
|
|
2298
|
-
var _fileType$uri = fileType.uri,
|
|
2299
|
-
uriList = _fileType$uri === void 0 ? [] : _fileType$uri,
|
|
2300
|
-
fileSizeBytes = fileType.size,
|
|
2301
|
-
hash = fileType.hash,
|
|
2302
|
-
path = fileType.path,
|
|
2303
|
-
fileId = fileType.id;
|
|
2304
|
-
var _uriList = _slicedToArray(uriList, 1),
|
|
2305
|
-
uri = _uriList[0];
|
|
2306
|
-
var fileSize = fileSizeBytes !== undefined ? filesize(fileSizeBytes, {
|
|
2307
|
-
base: 2,
|
|
2308
|
-
standard: 'jedec'
|
|
2309
|
-
}) : '';
|
|
2310
|
-
var fileName = path ? path.split('/').pop() : undefined;
|
|
2311
|
-
return {
|
|
2312
|
-
uri: uri,
|
|
2313
|
-
hash: hash,
|
|
2314
|
-
fileSize: fileSize,
|
|
2315
|
-
fileSizeBytes: fileSizeBytes,
|
|
2316
|
-
path: path,
|
|
2317
|
-
fileName: fileName,
|
|
2318
|
-
fileId: fileId
|
|
2319
|
-
};
|
|
2320
|
-
};
|
|
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};};
|
|
2321
601
|
|
|
2322
|
-
function ownKeys$3(object,
|
|
2323
|
-
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; }
|
|
2324
|
-
/**
|
|
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;}/**
|
|
2325
603
|
* Parses the technical information of a BinaryComponentType.
|
|
2326
604
|
* @param binaryComponentType - A BinaryComponentType from VidiCore.
|
|
2327
605
|
* @returns Parsed component object.
|
|
2328
606
|
*
|
|
2329
607
|
* @category Shape
|
|
2330
|
-
*/
|
|
2331
|
-
var parseBinaryComponent = function parseBinaryComponent() {
|
|
2332
|
-
var binaryComponentType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
2333
|
-
var fileList = binaryComponentType.file,
|
|
2334
|
-
mediaInfo = binaryComponentType.mediaInfo,
|
|
2335
|
-
_binaryComponentType$ = binaryComponentType.metadata,
|
|
2336
|
-
metadata = _binaryComponentType$ === void 0 ? [] : _binaryComponentType$;
|
|
2337
|
-
var binaryMetadata = parseKeyValuePairTypes(metadata);
|
|
2338
|
-
var binaryMediaInfo = parseBaseMediaInfoType(mediaInfo);
|
|
2339
|
-
var parsedBinaryComponent = {
|
|
2340
|
-
binaryMetadata: binaryMetadata,
|
|
2341
|
-
binaryMediaInfo: binaryMediaInfo
|
|
2342
|
-
};
|
|
2343
|
-
if (fileList) {
|
|
2344
|
-
var _fileList = _slicedToArray(fileList, 1),
|
|
2345
|
-
fileType = _fileList[0];
|
|
2346
|
-
var parsedFileType = parseFileType(fileType);
|
|
2347
|
-
parsedBinaryComponent = _objectSpread$3(_objectSpread$3({}, parsedBinaryComponent), parsedFileType);
|
|
2348
|
-
}
|
|
2349
|
-
return parsedBinaryComponent;
|
|
2350
|
-
};
|
|
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;};
|
|
2351
609
|
|
|
2352
|
-
function ownKeys$2(object,
|
|
2353
|
-
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; }
|
|
2354
|
-
|
|
2355
|
-
/**
|
|
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;}/**
|
|
2356
611
|
* Parsed container component
|
|
2357
|
-
*/
|
|
2358
|
-
|
|
2359
|
-
/**
|
|
612
|
+
*/ /**
|
|
2360
613
|
* Parses the technical information of a ContainerComponentType.
|
|
2361
614
|
* @param containerComponentType - A ContainerComponentType from VidiCore.
|
|
2362
615
|
* @returns Parsed component object.
|
|
2363
616
|
*
|
|
2364
617
|
* @category Shape
|
|
2365
|
-
*/
|
|
2366
|
-
var parseContainerComponent = function parseContainerComponent() {
|
|
2367
|
-
var containerComponentType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
2368
|
-
var mediaInfo = containerComponentType.mediaInfo,
|
|
2369
|
-
metadata = containerComponentType.metadata,
|
|
2370
|
-
fileList = containerComponentType.file,
|
|
2371
|
-
durationTimeCode = containerComponentType.duration,
|
|
2372
|
-
startTimestamp = containerComponentType.startTimestamp,
|
|
2373
|
-
startTimecode = containerComponentType.startTimecode,
|
|
2374
|
-
timeCodeTimeBase = containerComponentType.timeCodeTimeBase;
|
|
2375
|
-
var containerMetadata = parseKeyValuePairTypes(metadata || []);
|
|
2376
|
-
var containerMediaInfo = parseBaseMediaInfoType(mediaInfo);
|
|
2377
|
-
var containerFormat = containerMediaInfo.Format;
|
|
2378
|
-
var videoFormat = containerMediaInfo.Video_Format_List,
|
|
2379
|
-
audioFormat = containerMediaInfo.Audio_Format_List,
|
|
2380
|
-
textFormat = containerMediaInfo.Text_Format_List;
|
|
2381
|
-
if (containerFormat === undefined) {
|
|
2382
|
-
var format = containerComponentType.format;
|
|
2383
|
-
containerFormat = format;
|
|
2384
|
-
if (format && format.includes(',')) {
|
|
2385
|
-
var formatList = format.split(',');
|
|
2386
|
-
var _formatList = _slicedToArray(formatList, 1);
|
|
2387
|
-
containerFormat = _formatList[0];
|
|
2388
|
-
}
|
|
2389
|
-
}
|
|
2390
|
-
var parsedContainerComponentType = {
|
|
2391
|
-
containerFormat: containerFormat,
|
|
2392
|
-
videoFormat: videoFormat,
|
|
2393
|
-
audioFormat: audioFormat,
|
|
2394
|
-
textFormat: textFormat,
|
|
2395
|
-
containerMetadata: containerMetadata,
|
|
2396
|
-
containerMediaInfo: containerMediaInfo
|
|
2397
|
-
};
|
|
2398
|
-
if (containerMetadata.componentOriginalFilename) {
|
|
2399
|
-
parsedContainerComponentType.originalFilename = containerMetadata.componentOriginalFilename;
|
|
2400
|
-
}
|
|
2401
|
-
if (durationTimeCode !== undefined && durationTimeCode.samples !== 0) {
|
|
2402
|
-
var timeCode = formatTimeCodeType(durationTimeCode);
|
|
2403
|
-
parsedContainerComponentType.durationTimeCode = timeCode.toObject();
|
|
2404
|
-
parsedContainerComponentType.duration = timeCode.toDuration();
|
|
2405
|
-
}
|
|
2406
|
-
if (startTimestamp) {
|
|
2407
|
-
parsedContainerComponentType.startTimestamp = formatTimeCodeType(startTimestamp).toObject();
|
|
2408
|
-
}
|
|
2409
|
-
if (startTimecode !== undefined && timeCodeTimeBase) {
|
|
2410
|
-
parsedContainerComponentType.startTimecode = formatTimeCodeType({
|
|
2411
|
-
samples: startTimecode,
|
|
2412
|
-
timeBase: timeCodeTimeBase
|
|
2413
|
-
});
|
|
2414
|
-
}
|
|
2415
|
-
if (fileList) {
|
|
2416
|
-
var _fileList = _slicedToArray(fileList, 1),
|
|
2417
|
-
fileType = _fileList[0];
|
|
2418
|
-
var parsedFileType = parseFileType(fileType);
|
|
2419
|
-
parsedContainerComponentType = _objectSpread$2(_objectSpread$2({}, parsedContainerComponentType), parsedFileType);
|
|
2420
|
-
}
|
|
2421
|
-
return parsedContainerComponentType;
|
|
2422
|
-
};
|
|
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;};
|
|
2423
619
|
|
|
2424
|
-
var bitRateSymbols
|
|
2425
|
-
kB: 'kbps',
|
|
2426
|
-
B: 'bps',
|
|
2427
|
-
MB: 'mbps'
|
|
2428
|
-
};
|
|
2429
|
-
/**
|
|
620
|
+
var bitRateSymbols={kB:'kbps',B:'bps',MB:'mbps'};/**
|
|
2430
621
|
* Parses the technical information of a VideoComponentType.
|
|
2431
622
|
* @param {Object} videoComponentType - A VideoComponentType from VidiCore.
|
|
2432
623
|
* @returns {Object} Parsed component object.
|
|
2433
624
|
*
|
|
2434
625
|
* @category Shape
|
|
2435
|
-
*/
|
|
2436
|
-
var parseVideoComponent = function parseVideoComponent() {
|
|
2437
|
-
var videoComponentType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
2438
|
-
var videoCodec = videoComponentType.codec,
|
|
2439
|
-
bitrate = videoComponentType.bitrate,
|
|
2440
|
-
fieldOrder = videoComponentType.fieldOrder,
|
|
2441
|
-
resolution = videoComponentType.resolution,
|
|
2442
|
-
mediaInfo = videoComponentType.mediaInfo,
|
|
2443
|
-
_videoComponentType$m = videoComponentType.metadata,
|
|
2444
|
-
metadata = _videoComponentType$m === void 0 ? [] : _videoComponentType$m;
|
|
2445
|
-
var videoMediaInfo = parseVideoMediaInfoType(mediaInfo);
|
|
2446
|
-
var videoMetadata = parseKeyValuePairTypes(metadata);
|
|
2447
|
-
var videoFormat = videoMediaInfo.Format,
|
|
2448
|
-
timeBaseText = videoMediaInfo['Frame rate'],
|
|
2449
|
-
colorSpace = videoMediaInfo['Color space'],
|
|
2450
|
-
colorPrimaries = videoMediaInfo['Color primaries'],
|
|
2451
|
-
chromaSubsampling = videoMediaInfo.Colorimetry;
|
|
2452
|
-
var timeBase;
|
|
2453
|
-
var averageFrameRate = videoComponentType.averageFrameRate,
|
|
2454
|
-
realBaseFrameRate = videoComponentType.realBaseFrameRate;
|
|
2455
|
-
if (realBaseFrameRate !== undefined) {
|
|
2456
|
-
timeBase = formatTimeBaseType({
|
|
2457
|
-
numerator: realBaseFrameRate.denominator,
|
|
2458
|
-
denominator: realBaseFrameRate.numerator
|
|
2459
|
-
});
|
|
2460
|
-
} else if (timeBaseText !== undefined) {
|
|
2461
|
-
timeBase = formatTimeBaseText(timeBaseText);
|
|
2462
|
-
} else if (averageFrameRate !== undefined) {
|
|
2463
|
-
timeBase = formatTimeBaseType({
|
|
2464
|
-
numerator: averageFrameRate.denominator,
|
|
2465
|
-
denominator: averageFrameRate.numerator
|
|
2466
|
-
});
|
|
2467
|
-
}
|
|
2468
|
-
var samples = videoMediaInfo['Frame count'];
|
|
2469
|
-
if (samples === undefined) {
|
|
2470
|
-
var numberOfPackets = videoComponentType.numberOfPackets;
|
|
2471
|
-
if (numberOfPackets !== undefined) samples = numberOfPackets.toString();
|
|
2472
|
-
}
|
|
2473
|
-
var timeCode;
|
|
2474
|
-
var frameRate;
|
|
2475
|
-
var smpte;
|
|
2476
|
-
if (samples && timeBase) {
|
|
2477
|
-
timeCode = formatTimeCodeType({
|
|
2478
|
-
samples: samples,
|
|
2479
|
-
timeBase: timeBase
|
|
2480
|
-
});
|
|
2481
|
-
frameRate = timeCode.timeBase.toConstant() || timeCode.timeBase.toRate();
|
|
2482
|
-
smpte = timeCode.toSmpte();
|
|
2483
|
-
}
|
|
2484
|
-
var _ref = resolution || {},
|
|
2485
|
-
height = _ref.height,
|
|
2486
|
-
width = _ref.width;
|
|
2487
|
-
var aspectRatio = parseAspectRatio(resolution);
|
|
2488
|
-
var dimension = "".concat(width, "x").concat(height);
|
|
2489
|
-
var videoBitrate;
|
|
2490
|
-
var videoBitrateMbps;
|
|
2491
|
-
if (bitrate !== undefined) {
|
|
2492
|
-
var _split;
|
|
2493
|
-
videoBitrate = filesize(bitrate, {
|
|
2494
|
-
round: 2,
|
|
2495
|
-
symbols: bitRateSymbols
|
|
2496
|
-
});
|
|
2497
|
-
videoBitrateMbps = Number((_split = filesize(bitrate, {
|
|
2498
|
-
exponent: 2,
|
|
2499
|
-
symbols: bitRateSymbols
|
|
2500
|
-
}).split(' mbps')) === null || _split === void 0 ? void 0 : _split[0]);
|
|
2501
|
-
}
|
|
2502
|
-
return {
|
|
2503
|
-
videoFormat: videoFormat,
|
|
2504
|
-
dimension: dimension,
|
|
2505
|
-
frameRate: frameRate,
|
|
2506
|
-
height: height,
|
|
2507
|
-
width: width,
|
|
2508
|
-
timeBase: timeBase,
|
|
2509
|
-
timeCode: timeCode,
|
|
2510
|
-
videoCodec: videoCodec,
|
|
2511
|
-
smpte: smpte,
|
|
2512
|
-
videoBitrate: videoBitrate,
|
|
2513
|
-
videoBitrateMbps: videoBitrateMbps,
|
|
2514
|
-
fieldOrder: fieldOrder,
|
|
2515
|
-
colorSpace: colorSpace,
|
|
2516
|
-
chromaSubsampling: chromaSubsampling,
|
|
2517
|
-
aspectRatio: aspectRatio,
|
|
2518
|
-
colorPrimaries: colorPrimaries,
|
|
2519
|
-
videoMetadata: videoMetadata,
|
|
2520
|
-
videoMediaInfo: videoMediaInfo
|
|
2521
|
-
};
|
|
2522
|
-
};
|
|
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};};
|
|
2523
627
|
|
|
2524
|
-
function ownKeys$1(object,
|
|
2525
|
-
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
|
|
2526
629
|
/**
|
|
2527
630
|
* Parses the technical information of a ShapeType and its various components.
|
|
2528
631
|
*
|
|
@@ -2536,72 +639,19 @@ function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) {
|
|
|
2536
639
|
* @returns Parsed shape object.
|
|
2537
640
|
*
|
|
2538
641
|
* @category Shape
|
|
2539
|
-
*/
|
|
2540
|
-
var parseShapeType = function parseShapeType() {
|
|
2541
|
-
var shapeType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
2542
|
-
var parsedShape = {};
|
|
2543
|
-
var containerComponent = shapeType.containerComponent,
|
|
2544
|
-
videoComponentList = shapeType.videoComponent,
|
|
2545
|
-
audioComponentList = shapeType.audioComponent,
|
|
2546
|
-
binaryComponentList = shapeType.binaryComponent,
|
|
2547
|
-
_shapeType$mimeType = shapeType.mimeType,
|
|
2548
|
-
mimeTypeList = _shapeType$mimeType === void 0 ? [] : _shapeType$mimeType,
|
|
2549
|
-
_shapeType$tag = shapeType.tag,
|
|
2550
|
-
tagList = _shapeType$tag === void 0 ? [] : _shapeType$tag;
|
|
2551
|
-
var _tagList = _slicedToArray(tagList, 1);
|
|
2552
|
-
parsedShape.tag = _tagList[0];
|
|
2553
|
-
var _mimeTypeList = _slicedToArray(mimeTypeList, 1);
|
|
2554
|
-
parsedShape.mimeType = _mimeTypeList[0];
|
|
2555
|
-
if (containerComponent) {
|
|
2556
|
-
var parsedContainerComponent = parseContainerComponent(containerComponent);
|
|
2557
|
-
parsedShape = _objectSpread$1(_objectSpread$1({}, parsedShape), parsedContainerComponent);
|
|
2558
|
-
}
|
|
2559
|
-
if (videoComponentList) {
|
|
2560
|
-
var _videoComponentList = _slicedToArray(videoComponentList, 1),
|
|
2561
|
-
videoComponent = _videoComponentList[0];
|
|
2562
|
-
var parsedVideoComponent = parseVideoComponent(videoComponent);
|
|
2563
|
-
parsedShape = _objectSpread$1(_objectSpread$1({}, parsedShape), parsedVideoComponent);
|
|
2564
|
-
}
|
|
2565
|
-
if (audioComponentList) {
|
|
2566
|
-
var _audioComponentList = _slicedToArray(audioComponentList, 1),
|
|
2567
|
-
audioComponent = _audioComponentList[0];
|
|
2568
|
-
var parsedAudioComponent = parseAudioComponent(audioComponent);
|
|
2569
|
-
parsedShape = _objectSpread$1(_objectSpread$1({}, parsedShape), parsedAudioComponent);
|
|
2570
|
-
}
|
|
2571
|
-
if (binaryComponentList) {
|
|
2572
|
-
var _binaryComponentList = _slicedToArray(binaryComponentList, 1),
|
|
2573
|
-
binaryComponent = _binaryComponentList[0];
|
|
2574
|
-
var parsedBinaryComponent = parseBinaryComponent(binaryComponent);
|
|
2575
|
-
parsedShape = _objectSpread$1(_objectSpread$1({}, parsedShape), parsedBinaryComponent);
|
|
2576
|
-
}
|
|
2577
|
-
return parsedShape;
|
|
2578
|
-
};
|
|
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;};
|
|
2579
643
|
|
|
2580
644
|
/**
|
|
2581
645
|
* Const object with document types
|
|
2582
646
|
*
|
|
2583
647
|
* @category Shape
|
|
2584
|
-
*/
|
|
2585
|
-
var DOCUMENT_TYPES = {
|
|
2586
|
-
PDF: 'PDF',
|
|
2587
|
-
TEXT: 'TEXT',
|
|
2588
|
-
MSWORD: 'MSWORD',
|
|
2589
|
-
JSON: 'JSON',
|
|
2590
|
-
XML: 'XML'
|
|
2591
|
-
};
|
|
648
|
+
*/var DOCUMENT_TYPES={PDF:'PDF',TEXT:'TEXT',MSWORD:'MSWORD',JSON:'JSON',XML:'XML'};
|
|
2592
649
|
|
|
2593
650
|
/**
|
|
2594
651
|
* Const object with media types
|
|
2595
652
|
*
|
|
2596
653
|
* @category Shape
|
|
2597
|
-
*/
|
|
2598
|
-
var SHAPE_MEDIA_TYPES = {
|
|
2599
|
-
IMAGE: 'IMAGE',
|
|
2600
|
-
AUDIO: 'AUDIO',
|
|
2601
|
-
VIDEO: 'VIDEO',
|
|
2602
|
-
DOCUMENT: 'DOCUMENT',
|
|
2603
|
-
BINARY: 'BINARY'
|
|
2604
|
-
};
|
|
654
|
+
*/var SHAPE_MEDIA_TYPES={IMAGE:'IMAGE',AUDIO:'AUDIO',VIDEO:'VIDEO',DOCUMENT:'DOCUMENT',BINARY:'BINARY'};
|
|
2605
655
|
|
|
2606
656
|
// eslint-disable-next-line import/no-cycle
|
|
2607
657
|
/**
|
|
@@ -2611,47 +661,13 @@ var SHAPE_MEDIA_TYPES = {
|
|
|
2611
661
|
* @returns The document type for a shape
|
|
2612
662
|
*
|
|
2613
663
|
* @category Shape
|
|
2614
|
-
*/
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
// shapeType.mimeType is always a string array,
|
|
2618
|
-
// but accepts passing in { mimeType: string } for backwards compatibility
|
|
2619
|
-
var mimeTypeArrayOrString = shape.mimeType;
|
|
2620
|
-
var mimeType = Array.isArray(mimeTypeArrayOrString) ? mimeTypeArrayOrString[0] : mimeTypeArrayOrString;
|
|
2621
|
-
if (!mimeType) return undefined;
|
|
2622
|
-
if (mimeType.endsWith('/pdf')) return DOCUMENT_TYPES.PDF;
|
|
2623
|
-
if (mimeType.startsWith('text/')) return DOCUMENT_TYPES.TEXT;
|
|
2624
|
-
if (mimeType.endsWith('/msword')) return DOCUMENT_TYPES.MSWORD;
|
|
2625
|
-
if (mimeType.endsWith('/json')) return DOCUMENT_TYPES.JSON;
|
|
2626
|
-
if (mimeType.endsWith('/xml')) return DOCUMENT_TYPES.XML;
|
|
2627
|
-
return undefined;
|
|
2628
|
-
};
|
|
2629
|
-
|
|
2630
|
-
var IMAGE_MIME_TYPES = ['image/apng', 'image/bmp', 'image/gif', 'image/jpeg', 'image/x-icon', 'image/png', 'image/svg+xml'];
|
|
2631
|
-
var VIDEO_MIME_TYPES = ['video/mp4'];
|
|
2632
|
-
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'];
|
|
2633
|
-
var DEFAULT_ALLOWED_MIME_TYPES = [].concat(VIDEO_MIME_TYPES, IMAGE_MIME_TYPES, AUDIO_MIME_TYPES);
|
|
2634
|
-
var DEFAULT_ALLOWED_METHODS = ['http', 'https'];
|
|
2635
|
-
var MP4_MIMETYPE = 'video/mp4';
|
|
2636
|
-
var QUICKTIME_MIMETYPE = 'video/quicktime';
|
|
2637
|
-
var M4V_MIMETYPE = 'video/x-m4v';
|
|
2638
|
-
var MP4_CONTAINER = 'MPEG-4';
|
|
2639
|
-
var MOV_CONTAINER = 'mov';
|
|
2640
|
-
var H264_CODEC = 'h264';
|
|
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;};
|
|
2641
667
|
|
|
2642
|
-
|
|
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.
|
|
2643
669
|
// using reverse() so the first has highest index
|
|
2644
|
-
var PREVIEW_SHAPE_ORDER
|
|
2645
|
-
var defaultSortPriority = function defaultSortPriority(_ref, _ref2) {
|
|
2646
|
-
var firstEl = _ref.parsedShape.tag;
|
|
2647
|
-
var secondEl = _ref2.parsedShape.tag;
|
|
2648
|
-
if (PREVIEW_SHAPE_ORDER.includes(firstEl) || PREVIEW_SHAPE_ORDER.includes(secondEl)) {
|
|
2649
|
-
return PREVIEW_SHAPE_ORDER.indexOf(secondEl) - PREVIEW_SHAPE_ORDER.indexOf(firstEl);
|
|
2650
|
-
}
|
|
2651
|
-
return firstEl.toLowerCase().localeCompare(secondEl.toLowerCase());
|
|
2652
|
-
};
|
|
2653
|
-
|
|
2654
|
-
/**
|
|
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());};/**
|
|
2655
671
|
* Filter a shape type list to get shapes that are playable in a browser
|
|
2656
672
|
*
|
|
2657
673
|
* @param itemType
|
|
@@ -2659,57 +675,7 @@ var defaultSortPriority = function defaultSortPriority(_ref, _ref2) {
|
|
|
2659
675
|
* @returns
|
|
2660
676
|
*
|
|
2661
677
|
* @category Shape
|
|
2662
|
-
*/
|
|
2663
|
-
var filterShapeSource = function filterShapeSource(itemType, options) {
|
|
2664
|
-
var _ref3 = options || {},
|
|
2665
|
-
_ref3$allowedMimeType = _ref3.allowedMimeTypes,
|
|
2666
|
-
allowedMimeTypes = _ref3$allowedMimeType === void 0 ? DEFAULT_ALLOWED_MIME_TYPES : _ref3$allowedMimeType,
|
|
2667
|
-
_ref3$allowedMethods = _ref3.allowedMethods,
|
|
2668
|
-
allowedMethods = _ref3$allowedMethods === void 0 ? DEFAULT_ALLOWED_METHODS : _ref3$allowedMethods,
|
|
2669
|
-
_ref3$sortPriority = _ref3.sortPriority,
|
|
2670
|
-
sortPriority = _ref3$sortPriority === void 0 ? defaultSortPriority : _ref3$sortPriority,
|
|
2671
|
-
_ref3$sourceKey = _ref3.sourceKey,
|
|
2672
|
-
sourceKey = _ref3$sourceKey === void 0 ? 'src' : _ref3$sourceKey,
|
|
2673
|
-
_ref3$mimeTypeKey = _ref3.mimeTypeKey,
|
|
2674
|
-
mimeTypeKey = _ref3$mimeTypeKey === void 0 ? 'type' : _ref3$mimeTypeKey,
|
|
2675
|
-
_ref3$shapeKey = _ref3.shapeKey,
|
|
2676
|
-
shapeKey = _ref3$shapeKey === void 0 ? 'shape' : _ref3$shapeKey,
|
|
2677
|
-
_ref3$parsedShapeKey = _ref3.parsedShapeKey,
|
|
2678
|
-
parsedShapeKey = _ref3$parsedShapeKey === void 0 ? 'parsedShape' : _ref3$parsedShapeKey;
|
|
2679
|
-
var _ref4 = itemType || {},
|
|
2680
|
-
_ref4$shape = _ref4.shape,
|
|
2681
|
-
shapeList = _ref4$shape === void 0 ? [] : _ref4$shape;
|
|
2682
|
-
var filteredShapeList = shapeList.reduce(function (acc, shapeType) {
|
|
2683
|
-
var type;
|
|
2684
|
-
var src;
|
|
2685
|
-
var parsedShape = parseShapeType(shapeType);
|
|
2686
|
-
var uri = parsedShape.uri,
|
|
2687
|
-
mimeType = parsedShape.mimeType,
|
|
2688
|
-
containerFormat = parsedShape.containerFormat,
|
|
2689
|
-
videoCodec = parsedShape.videoCodec;
|
|
2690
|
-
if (mimeType) {
|
|
2691
|
-
type = mimeType;
|
|
2692
|
-
if ((mimeType === QUICKTIME_MIMETYPE || mimeType === M4V_MIMETYPE) && (containerFormat === MP4_CONTAINER || containerFormat === MOV_CONTAINER) && videoCodec === H264_CODEC) type = MP4_MIMETYPE;
|
|
2693
|
-
}
|
|
2694
|
-
if (uri) {
|
|
2695
|
-
if (allowedMethods) {
|
|
2696
|
-
var _uri$split = uri.split('://'),
|
|
2697
|
-
_uri$split2 = _slicedToArray(_uri$split, 1),
|
|
2698
|
-
thisMethod = _uri$split2[0];
|
|
2699
|
-
if (allowedMethods.includes(thisMethod)) src = uri;
|
|
2700
|
-
} else {
|
|
2701
|
-
src = uri;
|
|
2702
|
-
}
|
|
2703
|
-
}
|
|
2704
|
-
if (src && allowedMimeTypes.includes(type)) {
|
|
2705
|
-
var _acc$push;
|
|
2706
|
-
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));
|
|
2707
|
-
}
|
|
2708
|
-
return acc;
|
|
2709
|
-
}, []);
|
|
2710
|
-
if (typeof sortPriority === 'function') filteredShapeList.sort(defaultSortPriority);
|
|
2711
|
-
return filteredShapeList;
|
|
2712
|
-
};
|
|
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;};
|
|
2713
679
|
|
|
2714
680
|
/**
|
|
2715
681
|
* Returns a const for which media type a shape has
|
|
@@ -2718,29 +684,7 @@ var filterShapeSource = function filterShapeSource(itemType, options) {
|
|
|
2718
684
|
* @returns
|
|
2719
685
|
*
|
|
2720
686
|
* @category Shape
|
|
2721
|
-
*/
|
|
2722
|
-
var getShapeMediaType = function getShapeMediaType(shape) {
|
|
2723
|
-
var parsedShape = parseShapeType(shape);
|
|
2724
|
-
var mimeType = parsedShape.mimeType,
|
|
2725
|
-
videoCodec = parsedShape.videoCodec,
|
|
2726
|
-
audioCodec = parsedShape.audioCodec;
|
|
2727
|
-
if (!mimeType) return undefined;
|
|
2728
|
-
if (mimeType.startsWith('audio/')) {
|
|
2729
|
-
if (audioCodec !== undefined) return SHAPE_MEDIA_TYPES.AUDIO;
|
|
2730
|
-
}
|
|
2731
|
-
if (mimeType.startsWith('video/')) {
|
|
2732
|
-
if (videoCodec !== undefined) return SHAPE_MEDIA_TYPES.VIDEO;
|
|
2733
|
-
if (audioCodec !== undefined) return SHAPE_MEDIA_TYPES.AUDIO;
|
|
2734
|
-
}
|
|
2735
|
-
if (mimeType.startsWith('image/')) return SHAPE_MEDIA_TYPES.IMAGE;
|
|
2736
|
-
if (mimeType.endsWith('/pdf')) return SHAPE_MEDIA_TYPES.DOCUMENT;
|
|
2737
|
-
if (mimeType.startsWith('text/')) return SHAPE_MEDIA_TYPES.DOCUMENT;
|
|
2738
|
-
if (mimeType.endsWith('/msword')) return SHAPE_MEDIA_TYPES.DOCUMENT;
|
|
2739
|
-
if (mimeType.endsWith('/json')) return SHAPE_MEDIA_TYPES.DOCUMENT;
|
|
2740
|
-
if (mimeType.endsWith('/xml')) return SHAPE_MEDIA_TYPES.DOCUMENT;
|
|
2741
|
-
if (mimeType.endsWith('/octet-stream')) return SHAPE_MEDIA_TYPES.BINARY;
|
|
2742
|
-
return undefined;
|
|
2743
|
-
};
|
|
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;};
|
|
2744
688
|
|
|
2745
689
|
/**
|
|
2746
690
|
* Find the thumbnail uri in a VidiCore item object that's nearest a timeCode
|
|
@@ -2753,160 +697,28 @@ var getShapeMediaType = function getShapeMediaType(shape) {
|
|
|
2753
697
|
* @returns A URI of a thumbnail, `undefined` if item has no thumbnails
|
|
2754
698
|
*
|
|
2755
699
|
* @category Thumbnail
|
|
2756
|
-
*/
|
|
2757
|
-
var findNearestThumbnail = function findNearestThumbnail(itemType, timeCode) {
|
|
2758
|
-
var tcSeconds = createTimeCode(timeCode).toSeconds();
|
|
2759
|
-
var _ref = itemType || {},
|
|
2760
|
-
_ref$thumbnails = _ref.thumbnails,
|
|
2761
|
-
thumbnails = _ref$thumbnails === void 0 ? {} : _ref$thumbnails;
|
|
2762
|
-
var _thumbnails$uri = thumbnails.uri,
|
|
2763
|
-
srcList = _thumbnails$uri === void 0 ? [] : _thumbnails$uri;
|
|
2764
|
-
var srcTcSeconds = srcList.map(function (url) {
|
|
2765
|
-
var tc = new URL(url).pathname.split('/').pop();
|
|
2766
|
-
return formatTimeCodeText(tc).toSeconds();
|
|
2767
|
-
});
|
|
2768
|
-
var nearestSrcIndex = srcTcSeconds.reduce(function (nearestIndex, curr, currIndex) {
|
|
2769
|
-
return Math.abs(curr - tcSeconds) < Math.abs(srcTcSeconds[nearestIndex] - tcSeconds) ? currIndex : nearestIndex;
|
|
2770
|
-
}, 0);
|
|
2771
|
-
return srcList[nearestSrcIndex];
|
|
2772
|
-
};
|
|
2773
|
-
|
|
2774
|
-
var _excluded = ["Codec"],
|
|
2775
|
-
_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];};
|
|
2776
701
|
|
|
2777
|
-
|
|
702
|
+
var _excluded=["Codec"],_excluded2=["Codec"];/**
|
|
2778
703
|
* TODO
|
|
2779
|
-
*/
|
|
2780
|
-
|
|
2781
|
-
/**
|
|
704
|
+
*/ /**
|
|
2782
705
|
* TODO
|
|
2783
706
|
*
|
|
2784
707
|
* @param mediaconvert
|
|
2785
708
|
* @returns
|
|
2786
709
|
*
|
|
2787
710
|
* @category Transcode
|
|
2788
|
-
*/
|
|
2789
|
-
var
|
|
2790
|
-
var output = {};
|
|
2791
|
-
var _ref = mediaconvert || {},
|
|
2792
|
-
_ref$outputSetting = _ref.outputSetting,
|
|
2793
|
-
outputSetting = _ref$outputSetting === void 0 ? [] : _ref$outputSetting;
|
|
2794
|
-
if (outputSetting.length === 0) return output;
|
|
2795
|
-
var mc = JSON.parse(outputSetting[0]);
|
|
2796
|
-
var _mc$Settings = mc.Settings;
|
|
2797
|
-
_mc$Settings = _mc$Settings === void 0 ? {} : _mc$Settings;
|
|
2798
|
-
var ContainerSettings = _mc$Settings.ContainerSettings,
|
|
2799
|
-
VideoDescription = _mc$Settings.VideoDescription,
|
|
2800
|
-
AudioDescriptions = _mc$Settings.AudioDescriptions;
|
|
2801
|
-
if (ContainerSettings) {
|
|
2802
|
-
output.containerFormat = ContainerSettings.Container;
|
|
2803
|
-
}
|
|
2804
|
-
if (VideoDescription) {
|
|
2805
|
-
var _VideoDescription$Cod = VideoDescription.CodecSettings,
|
|
2806
|
-
CodecSettings = _VideoDescription$Cod === void 0 ? {} : _VideoDescription$Cod;
|
|
2807
|
-
var Codec = CodecSettings.Codec,
|
|
2808
|
-
otherSettings = _objectWithoutProperties(CodecSettings, _excluded);
|
|
2809
|
-
output.videoFormat = Codec;
|
|
2810
|
-
var height = VideoDescription.Height,
|
|
2811
|
-
width = VideoDescription.Width;
|
|
2812
|
-
output.height = height;
|
|
2813
|
-
output.width = width;
|
|
2814
|
-
if (height && width) {
|
|
2815
|
-
output.dimension = "".concat(width, "x").concat(height);
|
|
2816
|
-
output.aspectRatio = parseAspectRatio({
|
|
2817
|
-
height: height,
|
|
2818
|
-
width: width
|
|
2819
|
-
});
|
|
2820
|
-
}
|
|
2821
|
-
var _Object$values = Object.values(otherSettings),
|
|
2822
|
-
_Object$values2 = _slicedToArray(_Object$values, 1),
|
|
2823
|
-
codecSpecs = _Object$values2[0];
|
|
2824
|
-
if (codecSpecs) {
|
|
2825
|
-
output.fieldOrder = codecSpecs.InterlaceMode;
|
|
2826
|
-
if (output.fieldOrder && output.fieldOrder.includes('TOP')) output.fieldOrder = 'interlaced';
|
|
2827
|
-
output.videoBitrate = codecSpecs.Bitrate;
|
|
2828
|
-
var numerator = codecSpecs.FramerateDenominator; // other way round to vs ¯\_(ツ)_/¯
|
|
2829
|
-
var denominator = codecSpecs.FramerateNumerator;
|
|
2830
|
-
var timeBase = formatTimeBaseType({
|
|
2831
|
-
denominator: denominator,
|
|
2832
|
-
numerator: numerator
|
|
2833
|
-
});
|
|
2834
|
-
output.timeBase = timeBase;
|
|
2835
|
-
output.frameRate = timeBase.toConstant() || timeBase.toRate();
|
|
2836
|
-
}
|
|
2837
|
-
}
|
|
2838
|
-
if (AudioDescriptions && AudioDescriptions.length > 0) {
|
|
2839
|
-
var _AudioDescriptions$0$ = AudioDescriptions[0].CodecSettings,
|
|
2840
|
-
_CodecSettings = _AudioDescriptions$0$ === void 0 ? {} : _AudioDescriptions$0$;
|
|
2841
|
-
var _Codec = _CodecSettings.Codec,
|
|
2842
|
-
_otherSettings = _objectWithoutProperties(_CodecSettings, _excluded2);
|
|
2843
|
-
output.audioFormat = _Codec;
|
|
2844
|
-
var _Object$values3 = Object.values(_otherSettings),
|
|
2845
|
-
_Object$values4 = _slicedToArray(_Object$values3, 1),
|
|
2846
|
-
_codecSpecs = _Object$values4[0];
|
|
2847
|
-
if (_codecSpecs) {
|
|
2848
|
-
output.audioSamplerate = _codecSpecs.SampleRate;
|
|
2849
|
-
output.audioBitrate = _codecSpecs.Bitrate;
|
|
2850
|
-
output.audioBitRateMode = _codecSpecs.RateControlMode;
|
|
2851
|
-
}
|
|
2852
|
-
}
|
|
2853
|
-
return output;
|
|
2854
|
-
};
|
|
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;};
|
|
2855
713
|
|
|
2856
|
-
function ownKeys(object,
|
|
2857
|
-
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; }
|
|
2858
|
-
/**
|
|
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;}/**
|
|
2859
715
|
* Parse a VidiCore transcode preset
|
|
2860
716
|
*
|
|
2861
717
|
* @param transcodePresetType a VidiCore transcode preset
|
|
2862
718
|
* @returns A parsed transcode preset
|
|
2863
719
|
*
|
|
2864
720
|
* @category Transcode
|
|
2865
|
-
*/
|
|
2866
|
-
var parseTranscodePreset = function parseTranscodePreset(transcodePresetType) {
|
|
2867
|
-
var output = {};
|
|
2868
|
-
var _ref = transcodePresetType || {},
|
|
2869
|
-
description = _ref.description,
|
|
2870
|
-
format = _ref.format,
|
|
2871
|
-
audio = _ref.audio,
|
|
2872
|
-
video = _ref.video,
|
|
2873
|
-
mediaconvert = _ref.mediaconvert;
|
|
2874
|
-
if (mediaconvert) return _objectSpread({
|
|
2875
|
-
description: description
|
|
2876
|
-
}, parseMediaConvertPreset(mediaconvert));
|
|
2877
|
-
output.description = description;
|
|
2878
|
-
output.containerFormat = format;
|
|
2879
|
-
if (video) {
|
|
2880
|
-
output.videoFormat = video.codec;
|
|
2881
|
-
output.videoBitrate = video.bitrate;
|
|
2882
|
-
if (video.framerate) {
|
|
2883
|
-
var timeBase = formatTimeBaseType(video.framerate);
|
|
2884
|
-
output.timeBase = timeBase;
|
|
2885
|
-
output.frameRate = timeBase.toConstant() || timeBase.toRate();
|
|
2886
|
-
}
|
|
2887
|
-
if (video.scaling) {
|
|
2888
|
-
var _video$scaling = video.scaling,
|
|
2889
|
-
height = _video$scaling.height,
|
|
2890
|
-
width = _video$scaling.width;
|
|
2891
|
-
output.height = height;
|
|
2892
|
-
output.width = width;
|
|
2893
|
-
if (height && width) {
|
|
2894
|
-
output.dimension = "".concat(width, "x").concat(height);
|
|
2895
|
-
output.aspectRatio = parseAspectRatio({
|
|
2896
|
-
height: height,
|
|
2897
|
-
width: width
|
|
2898
|
-
});
|
|
2899
|
-
}
|
|
2900
|
-
}
|
|
2901
|
-
}
|
|
2902
|
-
if (audio) {
|
|
2903
|
-
var audioFormat = audio.codec,
|
|
2904
|
-
channel = audio.channel;
|
|
2905
|
-
output.audioFormat = audioFormat;
|
|
2906
|
-
if (channel) output.audioChannels = channel.length;
|
|
2907
|
-
}
|
|
2908
|
-
return output;
|
|
2909
|
-
};
|
|
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;};
|
|
2910
722
|
|
|
2911
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 };
|
|
2912
724
|
//# sourceMappingURL=index.es.js.map
|