@vidispine/vdt-js 21.4.0-pre.1 → 22.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/README.md +1 -1
- package/dist/index.es.js +1895 -2204
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +1915 -2215
- package/dist/index.js.map +1 -1
- package/package.json +26 -20
package/dist/index.js
CHANGED
|
@@ -2,2504 +2,1980 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
6
|
+
var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
|
|
7
|
+
var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
|
|
8
|
+
var parseFileSize = require('filesize');
|
|
9
|
+
var _typeof = require('@babel/runtime/helpers/typeof');
|
|
10
|
+
var _classCallCheck = require('@babel/runtime/helpers/classCallCheck');
|
|
11
|
+
var _createClass = require('@babel/runtime/helpers/createClass');
|
|
12
|
+
var _toConsumableArray = require('@babel/runtime/helpers/toConsumableArray');
|
|
13
|
+
|
|
14
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
15
|
+
|
|
16
|
+
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
|
|
17
|
+
var _slicedToArray__default = /*#__PURE__*/_interopDefaultLegacy(_slicedToArray);
|
|
18
|
+
var _objectWithoutProperties__default = /*#__PURE__*/_interopDefaultLegacy(_objectWithoutProperties);
|
|
19
|
+
var parseFileSize__default = /*#__PURE__*/_interopDefaultLegacy(parseFileSize);
|
|
20
|
+
var _typeof__default = /*#__PURE__*/_interopDefaultLegacy(_typeof);
|
|
21
|
+
var _classCallCheck__default = /*#__PURE__*/_interopDefaultLegacy(_classCallCheck);
|
|
22
|
+
var _createClass__default = /*#__PURE__*/_interopDefaultLegacy(_createClass);
|
|
23
|
+
var _toConsumableArray__default = /*#__PURE__*/_interopDefaultLegacy(_toConsumableArray);
|
|
24
|
+
|
|
25
|
+
function ownKeys$8(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
26
|
+
|
|
27
|
+
function _objectSpread$8(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$8(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$8(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
7
28
|
|
|
8
|
-
|
|
9
|
-
|
|
29
|
+
var parseKeyValuePairType = function parseKeyValuePairType() {
|
|
30
|
+
var keyValuePairType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
10
31
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
32
|
+
var keyValuePairTypeReducer = function keyValuePairTypeReducer(a, _ref) {
|
|
33
|
+
var key = _ref.key,
|
|
34
|
+
value = _ref.value;
|
|
35
|
+
return _objectSpread$8(_objectSpread$8({}, a), {}, _defineProperty__default["default"]({}, key, value));
|
|
36
|
+
};
|
|
16
37
|
|
|
17
|
-
|
|
18
|
-
|
|
38
|
+
return keyValuePairType.reduce(keyValuePairTypeReducer, {});
|
|
39
|
+
};
|
|
19
40
|
|
|
20
|
-
|
|
21
|
-
|
|
41
|
+
var parseNowDate = function parseNowDate() {
|
|
42
|
+
var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'NOW';
|
|
43
|
+
|
|
44
|
+
if (value.startsWith('NOW')) {
|
|
45
|
+
if (value === 'NOW') return new Date();
|
|
46
|
+
var sign = value[3];
|
|
47
|
+
var number = Number(value.match(/(\d+)/)[0]);
|
|
48
|
+
var unit = value.match(/(\d.*)/)[0].replace(/\d/g, '');
|
|
49
|
+
var nowDiff = new Date();
|
|
22
50
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
51
|
+
switch (unit) {
|
|
52
|
+
case 'HOUR':
|
|
53
|
+
case 'HOURS':
|
|
54
|
+
if (sign === '+') nowDiff.setHours(nowDiff.getHours() + number);
|
|
55
|
+
if (sign === '-') nowDiff.setHours(nowDiff.getHours() - number);
|
|
56
|
+
break;
|
|
26
57
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
58
|
+
case 'DAY':
|
|
59
|
+
case 'DAYS':
|
|
60
|
+
if (sign === '+') nowDiff.setDate(nowDiff.getDate() + number);
|
|
61
|
+
if (sign === '-') nowDiff.setDate(nowDiff.getDate() - number);
|
|
62
|
+
break;
|
|
63
|
+
|
|
64
|
+
case 'MONTH':
|
|
65
|
+
case 'MONTHS':
|
|
66
|
+
if (sign === '+') nowDiff.setMonth(nowDiff.getMonth() + number);
|
|
67
|
+
if (sign === '-') nowDiff.setMonth(nowDiff.getMonth() - number);
|
|
68
|
+
break;
|
|
69
|
+
|
|
70
|
+
case 'YEAR':
|
|
71
|
+
case 'YEARS':
|
|
72
|
+
if (sign === '+') nowDiff.setFullYear(nowDiff.getFullYear() + number);
|
|
73
|
+
if (sign === '-') nowDiff.setFullYear(nowDiff.getFullYear() - number);
|
|
74
|
+
break;
|
|
37
75
|
}
|
|
76
|
+
|
|
77
|
+
return nowDiff;
|
|
38
78
|
}
|
|
39
79
|
|
|
40
|
-
return
|
|
41
|
-
}
|
|
80
|
+
return new Date(value);
|
|
81
|
+
};
|
|
42
82
|
|
|
43
|
-
|
|
44
|
-
"@babel/helpers - typeof";
|
|
83
|
+
var _CONSTANT_TIMEBASES;
|
|
45
84
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
85
|
+
var PAL = 'PAL';
|
|
86
|
+
var NTSC = 'NTSC';
|
|
87
|
+
var NTSC30 = 'NTSC30';
|
|
88
|
+
var CONSTANT_TIMEBASES = (_CONSTANT_TIMEBASES = {}, _defineProperty__default["default"](_CONSTANT_TIMEBASES, PAL, {
|
|
89
|
+
denominator: 25,
|
|
90
|
+
numerator: 1
|
|
91
|
+
}), _defineProperty__default["default"](_CONSTANT_TIMEBASES, NTSC, {
|
|
92
|
+
denominator: 30000,
|
|
93
|
+
numerator: 1001
|
|
94
|
+
}), _defineProperty__default["default"](_CONSTANT_TIMEBASES, NTSC30, {
|
|
95
|
+
denominator: 30,
|
|
96
|
+
numerator: 1
|
|
97
|
+
}), _defineProperty__default["default"](_CONSTANT_TIMEBASES, 29.97, {
|
|
98
|
+
denominator: 30000,
|
|
99
|
+
numerator: 1001
|
|
100
|
+
}), _defineProperty__default["default"](_CONSTANT_TIMEBASES, 59.94, {
|
|
101
|
+
denominator: 60000,
|
|
102
|
+
numerator: 1001
|
|
103
|
+
}), _CONSTANT_TIMEBASES);
|
|
104
|
+
var FRAME_SEPARATORS = {
|
|
105
|
+
':': {
|
|
106
|
+
dropFrame: false,
|
|
107
|
+
field: 2
|
|
108
|
+
},
|
|
109
|
+
';': {
|
|
110
|
+
dropFrame: true,
|
|
111
|
+
field: 2
|
|
112
|
+
},
|
|
113
|
+
'.': {
|
|
114
|
+
dropFrame: false,
|
|
115
|
+
field: 1
|
|
116
|
+
},
|
|
117
|
+
',': {
|
|
118
|
+
dropFrame: true,
|
|
119
|
+
field: 1
|
|
54
120
|
}
|
|
121
|
+
};
|
|
55
122
|
|
|
56
|
-
|
|
57
|
-
}
|
|
123
|
+
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; }
|
|
58
124
|
|
|
59
|
-
function
|
|
60
|
-
if (!(instance instanceof Constructor)) {
|
|
61
|
-
throw new TypeError("Cannot call a class as a function");
|
|
62
|
-
}
|
|
63
|
-
}
|
|
125
|
+
function _objectSpread$7(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$7(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$7(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
64
126
|
|
|
65
|
-
function
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
descriptor.configurable = true;
|
|
70
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
71
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
127
|
+
var splitSmpte = function splitSmpte(smpteText) {
|
|
128
|
+
var hasDropFrameSeparator = smpteText.match(/[^0-9:\-_]/);
|
|
129
|
+
var hhmmssff;
|
|
130
|
+
var frameOptions = {};
|
|
74
131
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
return Constructor;
|
|
79
|
-
}
|
|
132
|
+
if (hasDropFrameSeparator) {
|
|
133
|
+
var _hasDropFrameSeparato = _slicedToArray__default["default"](hasDropFrameSeparator, 1),
|
|
134
|
+
frameSeparator = _hasDropFrameSeparato[0];
|
|
80
135
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
});
|
|
136
|
+
var _smpteText$split = smpteText.split(frameSeparator),
|
|
137
|
+
_smpteText$split2 = _slicedToArray__default["default"](_smpteText$split, 2),
|
|
138
|
+
hhmmss = _smpteText$split2[0],
|
|
139
|
+
splitFrames = _smpteText$split2[1];
|
|
140
|
+
|
|
141
|
+
hhmmssff = [].concat(_toConsumableArray__default["default"](hhmmss.split(':')), [splitFrames]);
|
|
142
|
+
frameOptions = FRAME_SEPARATORS[frameSeparator] || {};
|
|
89
143
|
} else {
|
|
90
|
-
|
|
144
|
+
hhmmssff = smpteText.split(':');
|
|
91
145
|
}
|
|
92
146
|
|
|
93
|
-
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
97
|
-
if (source == null) return {};
|
|
98
|
-
var target = {};
|
|
99
|
-
var sourceKeys = Object.keys(source);
|
|
100
|
-
var key, i;
|
|
147
|
+
hhmmssff = hhmmssff.map(Number);
|
|
101
148
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
149
|
+
if (hhmmssff.length > 4 || hhmmssff.some(function (n) {
|
|
150
|
+
return Number.isNaN(n);
|
|
151
|
+
})) {
|
|
152
|
+
throw new Error('Invalid SMPTE timecode');
|
|
106
153
|
}
|
|
107
154
|
|
|
108
|
-
return
|
|
109
|
-
}
|
|
155
|
+
return [hhmmssff, frameOptions];
|
|
156
|
+
};
|
|
110
157
|
|
|
111
|
-
function
|
|
112
|
-
|
|
158
|
+
var getDropFrames = function getDropFrames(roundedFrameRate) {
|
|
159
|
+
return roundedFrameRate === 60 ? 4 : 2;
|
|
160
|
+
};
|
|
113
161
|
|
|
114
|
-
|
|
162
|
+
var getRoundedFrameRate = function getRoundedFrameRate(timeBase) {
|
|
163
|
+
return Math.round(timeBase.denominator / timeBase.numerator);
|
|
164
|
+
};
|
|
115
165
|
|
|
116
|
-
|
|
166
|
+
var countSamples = function countSamples(hh, mm, ss, ff, _ref) {
|
|
167
|
+
var dropFrame = _ref.dropFrame,
|
|
168
|
+
roundedFrameRate = _ref.roundedFrameRate;
|
|
117
169
|
|
|
118
|
-
if (
|
|
119
|
-
|
|
170
|
+
if (!dropFrame) {
|
|
171
|
+
return hh * 3600 * roundedFrameRate + mm * 60 * roundedFrameRate + ss * roundedFrameRate + ff;
|
|
172
|
+
}
|
|
120
173
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
124
|
-
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
125
|
-
target[key] = source[key];
|
|
126
|
-
}
|
|
174
|
+
if (![30, 60].includes(roundedFrameRate)) {
|
|
175
|
+
throw new Error('Cannot use dropframe with non NTSC timebase');
|
|
127
176
|
}
|
|
128
177
|
|
|
129
|
-
|
|
130
|
-
|
|
178
|
+
var dropFrames = getDropFrames(roundedFrameRate);
|
|
179
|
+
var shouldDropMinute = mm % 10 !== 0;
|
|
180
|
+
var shouldDropSecond = shouldDropMinute && ss === 0;
|
|
181
|
+
var hourFrames = hh * (3600 * roundedFrameRate - 54 * dropFrames);
|
|
182
|
+
var minuteFrames = mm * 60 * roundedFrameRate - (mm - Math.ceil(mm / 10)) * dropFrames;
|
|
183
|
+
var secondFrames = ss * roundedFrameRate - (shouldDropMinute && ss > 1 ? dropFrames : 0);
|
|
131
184
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
}
|
|
185
|
+
if (shouldDropSecond && ff < dropFrames) {
|
|
186
|
+
throw new Error('Invalid ff');
|
|
187
|
+
}
|
|
135
188
|
|
|
136
|
-
|
|
137
|
-
return
|
|
138
|
-
}
|
|
189
|
+
var frameFrames = shouldDropSecond ? ff - dropFrames : ff;
|
|
190
|
+
return hourFrames + minuteFrames + secondFrames + frameFrames;
|
|
191
|
+
};
|
|
139
192
|
|
|
140
|
-
function
|
|
141
|
-
|
|
193
|
+
function countDroppedFrames(frames, roundedFrameRate) {
|
|
194
|
+
var dropFrames = getDropFrames(roundedFrameRate);
|
|
195
|
+
var oneMinuteUndroppedFrames = 60 * roundedFrameRate;
|
|
196
|
+
var oneMinuteDroppedFrames = 60 * roundedFrameRate - dropFrames;
|
|
197
|
+
var tenMinuteFrames = 10 * (oneMinuteUndroppedFrames - dropFrames) + dropFrames;
|
|
198
|
+
var tenMinuteChunks = Math.floor(frames / tenMinuteFrames);
|
|
199
|
+
var minuteRemainder = Math.max(0, frames % tenMinuteFrames - oneMinuteUndroppedFrames);
|
|
200
|
+
var oneMinuteChunks = Math.floor(minuteRemainder / oneMinuteDroppedFrames);
|
|
201
|
+
var frameRemainder = minuteRemainder % oneMinuteDroppedFrames;
|
|
202
|
+
var frameChunks = frameRemainder > 0 ? dropFrames : 0;
|
|
203
|
+
return tenMinuteChunks * 9 * dropFrames + oneMinuteChunks * dropFrames + frameChunks;
|
|
142
204
|
}
|
|
205
|
+
/**
|
|
206
|
+
* @class TimeBase
|
|
207
|
+
* @constructs formatTimeBaseText(timeBaseText: string)
|
|
208
|
+
*/
|
|
143
209
|
|
|
144
|
-
function _arrayWithHoles(arr) {
|
|
145
|
-
if (Array.isArray(arr)) return arr;
|
|
146
|
-
}
|
|
147
210
|
|
|
148
|
-
function
|
|
149
|
-
|
|
150
|
-
}
|
|
211
|
+
var TimeBase = /*#__PURE__*/function () {
|
|
212
|
+
function TimeBase() {
|
|
213
|
+
var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
214
|
+
_ref2$numerator = _ref2.numerator,
|
|
215
|
+
numerator = _ref2$numerator === void 0 ? 1 : _ref2$numerator,
|
|
216
|
+
_ref2$denominator = _ref2.denominator,
|
|
217
|
+
denominator = _ref2$denominator === void 0 ? 1 : _ref2$denominator;
|
|
151
218
|
|
|
152
|
-
|
|
153
|
-
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
219
|
+
_classCallCheck__default["default"](this, TimeBase);
|
|
154
220
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
var _d = false;
|
|
221
|
+
this.numerator = Number(numerator);
|
|
222
|
+
this.denominator = Number(denominator);
|
|
223
|
+
}
|
|
159
224
|
|
|
160
|
-
|
|
225
|
+
_createClass__default["default"](TimeBase, [{
|
|
226
|
+
key: "toJSON",
|
|
227
|
+
value: function toJSON() {
|
|
228
|
+
return {
|
|
229
|
+
denominator: this.denominator,
|
|
230
|
+
numerator: this.numerator
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
}, {
|
|
234
|
+
key: "toConstant",
|
|
235
|
+
value: function toConstant() {
|
|
236
|
+
var _this = this;
|
|
161
237
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
238
|
+
var constant;
|
|
239
|
+
Object.entries(CONSTANT_TIMEBASES).find(function (thisTimeBase) {
|
|
240
|
+
var _thisTimeBase = _slicedToArray__default["default"](thisTimeBase, 2),
|
|
241
|
+
thisTimeBaseText = _thisTimeBase[0],
|
|
242
|
+
thisTimeBaseType = _thisTimeBase[1];
|
|
165
243
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
} catch (err) {
|
|
169
|
-
_d = true;
|
|
170
|
-
_e = err;
|
|
171
|
-
} finally {
|
|
172
|
-
try {
|
|
173
|
-
if (!_n && _i["return"] != null) _i["return"]();
|
|
174
|
-
} finally {
|
|
175
|
-
if (_d) throw _e;
|
|
176
|
-
}
|
|
177
|
-
}
|
|
244
|
+
var numerator = thisTimeBaseType.numerator,
|
|
245
|
+
denominator = thisTimeBaseType.denominator;
|
|
178
246
|
|
|
179
|
-
|
|
180
|
-
|
|
247
|
+
if (numerator === _this.numerator && denominator === _this.denominator) {
|
|
248
|
+
constant = thisTimeBaseText;
|
|
249
|
+
return true;
|
|
250
|
+
}
|
|
181
251
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
252
|
+
return false;
|
|
253
|
+
});
|
|
254
|
+
return constant;
|
|
255
|
+
}
|
|
256
|
+
}, {
|
|
257
|
+
key: "toText",
|
|
258
|
+
value: function toText() {
|
|
259
|
+
var useConstant = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
190
260
|
|
|
191
|
-
|
|
192
|
-
|
|
261
|
+
if (useConstant) {
|
|
262
|
+
var _timeBaseText = this.toConstant();
|
|
193
263
|
|
|
194
|
-
|
|
264
|
+
if (_timeBaseText) return _timeBaseText;
|
|
265
|
+
}
|
|
195
266
|
|
|
196
|
-
|
|
197
|
-
|
|
267
|
+
if (this.numerator > 1) {
|
|
268
|
+
var _timeBaseText2 = [this.denominator, this.numerator].join(':');
|
|
198
269
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
}
|
|
270
|
+
return _timeBaseText2;
|
|
271
|
+
}
|
|
202
272
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
}
|
|
273
|
+
var timeBaseText = String(this.denominator);
|
|
274
|
+
return timeBaseText;
|
|
275
|
+
}
|
|
276
|
+
}, {
|
|
277
|
+
key: "toRate",
|
|
278
|
+
value: function toRate() {
|
|
279
|
+
var useConstant = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
280
|
+
var round = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
206
281
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
_excluded3 = ["field", "group"],
|
|
210
|
-
_excluded4 = ["timespan"];
|
|
282
|
+
if (useConstant) {
|
|
283
|
+
var _rate = this.toConstant();
|
|
211
284
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
var secondStart = _ref2.start;
|
|
285
|
+
if (_rate) return _rate;
|
|
286
|
+
}
|
|
215
287
|
|
|
216
|
-
|
|
217
|
-
_firstStart$split2 = _slicedToArray(_firstStart$split, 1),
|
|
218
|
-
first = _firstStart$split2[0];
|
|
288
|
+
var rate = this.denominator / this.numerator;
|
|
219
289
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
290
|
+
if (Number.isInteger(rate)) {
|
|
291
|
+
return rate;
|
|
292
|
+
}
|
|
223
293
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
}
|
|
294
|
+
return round ? rate.toFixed(2) : rate;
|
|
295
|
+
}
|
|
296
|
+
}]);
|
|
227
297
|
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
}
|
|
298
|
+
return TimeBase;
|
|
299
|
+
}();
|
|
231
300
|
|
|
232
|
-
|
|
301
|
+
var isDropFrameTimeBase = function isDropFrameTimeBase(_ref3) {
|
|
302
|
+
var numerator = _ref3.numerator,
|
|
303
|
+
denominator = _ref3.denominator;
|
|
304
|
+
return numerator === 1001 && (denominator === 60000 || denominator === 30000);
|
|
233
305
|
};
|
|
234
306
|
|
|
235
|
-
var
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
return timespanList.find(function (timespan) {
|
|
242
|
-
return timespan.start === start && timespan.end === end;
|
|
243
|
-
});
|
|
244
|
-
};
|
|
307
|
+
var TimeCode = /*#__PURE__*/function () {
|
|
308
|
+
function TimeCode() {
|
|
309
|
+
var _ref4 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
310
|
+
_ref4$samples = _ref4.samples,
|
|
311
|
+
samples = _ref4$samples === void 0 ? 0 : _ref4$samples,
|
|
312
|
+
timeBase = _ref4.timeBase;
|
|
245
313
|
|
|
246
|
-
var
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
arrayOnSingle = _options$arrayOnSingl === void 0 ? true : _options$arrayOnSingl,
|
|
251
|
-
_options$arrayOnSingl2 = options.arrayOnSingleValue,
|
|
252
|
-
arrayOnSingleValue = _options$arrayOnSingl2 === void 0 ? true : _options$arrayOnSingl2,
|
|
253
|
-
joinValue = options.joinValue,
|
|
254
|
-
includeAttributes = options.includeAttributes,
|
|
255
|
-
includeValueAttributes = options.includeValueAttributes;
|
|
256
|
-
if (includeAttributes || includeValueAttributes) return valueList;
|
|
257
|
-
var valueArray = [];
|
|
258
|
-
valueList.forEach(function (thisValue) {
|
|
259
|
-
if (thisValue.value) valueArray.push(thisValue.value);
|
|
260
|
-
});
|
|
261
|
-
if (joinValue) return valueArray.join(joinValue);
|
|
314
|
+
var _ref5 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
|
315
|
+
dropFrame = _ref5.dropFrame,
|
|
316
|
+
_ref5$field = _ref5.field,
|
|
317
|
+
field = _ref5$field === void 0 ? 2 : _ref5$field;
|
|
262
318
|
|
|
263
|
-
|
|
264
|
-
|
|
319
|
+
_classCallCheck__default["default"](this, TimeCode);
|
|
320
|
+
|
|
321
|
+
if (typeof samples === 'number') {
|
|
322
|
+
this.samples = samples;
|
|
323
|
+
} else if (typeof samples === 'string') {
|
|
324
|
+
if (samples === '-INF') {
|
|
325
|
+
this.samples = -Infinity;
|
|
326
|
+
} else if (samples === '+INF') {
|
|
327
|
+
this.samples = Infinity;
|
|
328
|
+
} else {
|
|
329
|
+
this.samples = Number(samples);
|
|
330
|
+
}
|
|
331
|
+
} else {
|
|
332
|
+
throw new Error("samples is not number/string/-Inf/+Inf is: ".concat(samples));
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
this.timeBase = new TimeBase(timeBase);
|
|
336
|
+
this.dropFrame = dropFrame === undefined ? isDropFrameTimeBase(this.timeBase) : dropFrame;
|
|
337
|
+
this.field = field;
|
|
265
338
|
}
|
|
266
339
|
|
|
267
|
-
|
|
268
|
-
|
|
340
|
+
_createClass__default["default"](TimeCode, [{
|
|
341
|
+
key: "add",
|
|
342
|
+
value: function add(val) {
|
|
343
|
+
var _val$timeBase = val.timeBase,
|
|
344
|
+
numerator = _val$timeBase.numerator,
|
|
345
|
+
denominator = _val$timeBase.denominator;
|
|
346
|
+
var conformedTimeCode = val;
|
|
269
347
|
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
var includeAttributes = options.includeAttributes,
|
|
274
|
-
includeFieldAttributes = options.includeFieldAttributes;
|
|
348
|
+
if (numerator !== this.timeBase.numerator || denominator !== this.timeBase.denominator) {
|
|
349
|
+
conformedTimeCode = val.conformTimeBase(this.timeBase);
|
|
350
|
+
}
|
|
275
351
|
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
352
|
+
var _conformedTimeCode = conformedTimeCode,
|
|
353
|
+
samples = _conformedTimeCode.samples;
|
|
354
|
+
return new TimeCode({
|
|
355
|
+
samples: this.samples + samples,
|
|
356
|
+
timeBase: this.timeBase
|
|
357
|
+
});
|
|
358
|
+
}
|
|
359
|
+
}, {
|
|
360
|
+
key: "subtract",
|
|
361
|
+
value: function subtract(val) {
|
|
362
|
+
var _val$timeBase2 = val.timeBase,
|
|
363
|
+
numerator = _val$timeBase2.numerator,
|
|
364
|
+
denominator = _val$timeBase2.denominator;
|
|
365
|
+
var conformedTimeCode = val;
|
|
279
366
|
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
});
|
|
284
|
-
return parsedValueList;
|
|
285
|
-
};
|
|
367
|
+
if (numerator !== this.timeBase.numerator || denominator !== this.timeBase.denominator) {
|
|
368
|
+
conformedTimeCode = val.conformTimeBase(this.timeBase);
|
|
369
|
+
}
|
|
286
370
|
|
|
287
|
-
var
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
371
|
+
var _conformedTimeCode2 = conformedTimeCode,
|
|
372
|
+
samples = _conformedTimeCode2.samples;
|
|
373
|
+
return new TimeCode({
|
|
374
|
+
samples: this.samples - samples,
|
|
375
|
+
timeBase: this.timeBase
|
|
376
|
+
});
|
|
377
|
+
}
|
|
378
|
+
}, {
|
|
379
|
+
key: "conformTimeBase",
|
|
380
|
+
value: function conformTimeBase(conformTo) {
|
|
381
|
+
var timeBase = conformTo;
|
|
296
382
|
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
});
|
|
301
|
-
}
|
|
383
|
+
if (conformTo instanceof TimeCode === false) {
|
|
384
|
+
timeBase = new TimeBase(conformTo);
|
|
385
|
+
}
|
|
302
386
|
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
387
|
+
var samples = Math.round(this.samples / (this.timeBase.toRate(false, false) / timeBase.toRate(false, false)));
|
|
388
|
+
var timeCode = {
|
|
389
|
+
samples: samples,
|
|
390
|
+
timeBase: timeBase
|
|
391
|
+
};
|
|
392
|
+
return new TimeCode(timeCode);
|
|
393
|
+
}
|
|
394
|
+
}, {
|
|
395
|
+
key: "toJSON",
|
|
396
|
+
value: function toJSON() {
|
|
397
|
+
return {
|
|
398
|
+
samples: this.samples,
|
|
399
|
+
timeBase: this.timeBase
|
|
400
|
+
};
|
|
401
|
+
}
|
|
402
|
+
}, {
|
|
403
|
+
key: "toText",
|
|
404
|
+
value: function toText() {
|
|
405
|
+
var timeCodeText = String(this.samples);
|
|
406
|
+
var timeBaseText = this.timeBase.toText();
|
|
306
407
|
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
var parsedValue = parsedField.value;
|
|
408
|
+
if (timeBaseText !== '1') {
|
|
409
|
+
timeCodeText = [this.samples, timeBaseText].join('@');
|
|
410
|
+
}
|
|
311
411
|
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
412
|
+
return timeCodeText;
|
|
413
|
+
}
|
|
414
|
+
}, {
|
|
415
|
+
key: "toSeconds",
|
|
416
|
+
value: function toSeconds() {
|
|
417
|
+
var _this$timeBase = this.timeBase,
|
|
418
|
+
numerator = _this$timeBase.numerator,
|
|
419
|
+
denominator = _this$timeBase.denominator;
|
|
420
|
+
return this.samples * (numerator / denominator);
|
|
421
|
+
}
|
|
422
|
+
}, {
|
|
423
|
+
key: "toTime",
|
|
424
|
+
value: function toTime() {
|
|
425
|
+
var roundedFrameRate = getRoundedFrameRate(this.timeBase);
|
|
426
|
+
var totalSamples = this.samples + (this.dropFrame ? countDroppedFrames(this.samples + 1, roundedFrameRate) : 0);
|
|
427
|
+
var hours = Math.floor(totalSamples / (3600 * roundedFrameRate));
|
|
428
|
+
var minutes = Math.floor(totalSamples / (60 * roundedFrameRate)) % 60;
|
|
429
|
+
var seconds = Math.floor(totalSamples / roundedFrameRate) % 60;
|
|
430
|
+
var frames = totalSamples % roundedFrameRate;
|
|
431
|
+
var partialSeconds = frames / roundedFrameRate;
|
|
432
|
+
return {
|
|
433
|
+
hours: hours,
|
|
434
|
+
minutes: minutes,
|
|
435
|
+
seconds: seconds,
|
|
436
|
+
frames: frames,
|
|
437
|
+
partialSeconds: partialSeconds
|
|
438
|
+
};
|
|
439
|
+
}
|
|
440
|
+
}, {
|
|
441
|
+
key: "toDuration",
|
|
442
|
+
value: function toDuration() {
|
|
443
|
+
var _ref6 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
444
|
+
format = _ref6.format;
|
|
320
445
|
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
446
|
+
var _this$toTime = this.toTime(),
|
|
447
|
+
hours = _this$toTime.hours,
|
|
448
|
+
minutes = _this$toTime.minutes,
|
|
449
|
+
seconds = _this$toTime.seconds;
|
|
450
|
+
|
|
451
|
+
if (typeof format === 'string') {
|
|
452
|
+
if (format.toLowerCase() === 'hhmmss') {
|
|
453
|
+
return [hours.toFixed().padStart(2, '0'), minutes.toFixed().padStart(2, '0'), seconds.toFixed().padStart(2, '0')].join(':');
|
|
325
454
|
}
|
|
326
455
|
}
|
|
327
|
-
|
|
328
|
-
|
|
456
|
+
|
|
457
|
+
if (hours) {
|
|
458
|
+
return [hours.toFixed(), minutes.toFixed().padStart(2, '0'), seconds.toFixed().padStart(2, '0')].join(':');
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
if (minutes >= 10) {
|
|
462
|
+
return [minutes.toFixed().padStart(2, '0'), seconds.toFixed().padStart(2, '0')].join(':');
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
return [minutes.toFixed(), seconds.toFixed().padStart(2, '0')].join(':');
|
|
329
466
|
}
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
|
|
467
|
+
}, {
|
|
468
|
+
key: "toSmpte",
|
|
469
|
+
value: function toSmpte() {
|
|
470
|
+
var _this2 = this;
|
|
333
471
|
|
|
334
|
-
|
|
335
|
-
var group = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
336
|
-
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
337
|
-
var includeAttributes = options.includeAttributes,
|
|
338
|
-
includeGroupAttributes = options.includeGroupAttributes,
|
|
339
|
-
flat = options.flat,
|
|
340
|
-
flatGroup = options.flatGroup,
|
|
341
|
-
groupAsList = options.groupAsList,
|
|
342
|
-
fieldAsList = options.fieldAsList;
|
|
472
|
+
if (this.samples === -Infinity) return '00:00:00:00';
|
|
343
473
|
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
474
|
+
var _this$toTime2 = this.toTime(),
|
|
475
|
+
hours = _this$toTime2.hours,
|
|
476
|
+
minutes = _this$toTime2.minutes,
|
|
477
|
+
seconds = _this$toTime2.seconds,
|
|
478
|
+
frames = _this$toTime2.frames;
|
|
349
479
|
|
|
350
|
-
|
|
351
|
-
var parsedGroupList = parseGroupList(groupList, options); // eslint-disable-line no-use-before-define,max-len
|
|
480
|
+
var hhmmss = [hours.toFixed().padStart(2, '0'), minutes.toFixed().padStart(2, '0'), seconds.toFixed().padStart(2, '0')].join(':');
|
|
352
481
|
|
|
353
|
-
|
|
482
|
+
var _Object$entries$find = Object.entries(FRAME_SEPARATORS).find(function (thisSeparator) {
|
|
483
|
+
var _thisSeparator = _slicedToArray__default["default"](thisSeparator, 2),
|
|
484
|
+
_thisSeparator$ = _thisSeparator[1],
|
|
485
|
+
dropFrame = _thisSeparator$.dropFrame,
|
|
486
|
+
field = _thisSeparator$.field;
|
|
354
487
|
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
488
|
+
return dropFrame === _this2.dropFrame && field === _this2.field;
|
|
489
|
+
}),
|
|
490
|
+
_Object$entries$find2 = _slicedToArray__default["default"](_Object$entries$find, 1),
|
|
491
|
+
_Object$entries$find3 = _Object$entries$find2[0],
|
|
492
|
+
frameSeparator = _Object$entries$find3 === void 0 ? ':' : _Object$entries$find3;
|
|
358
493
|
|
|
359
|
-
|
|
360
|
-
if (groupAsList) {
|
|
361
|
-
Object.assign(output, {
|
|
362
|
-
group: parsedGroupList
|
|
363
|
-
});
|
|
364
|
-
} else {
|
|
365
|
-
Object.assign(output, parsedGroupList);
|
|
494
|
+
return [hhmmss, frames.toFixed().padStart(2, '0')].join(frameSeparator);
|
|
366
495
|
}
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
});
|
|
372
|
-
} else {
|
|
373
|
-
Object.assign(output, parsedFieldList);
|
|
496
|
+
}, {
|
|
497
|
+
key: "toFraction",
|
|
498
|
+
value: function toFraction() {
|
|
499
|
+
return "".concat(this.samples, "@").concat(this.timeBase.denominator, ":").concat(this.timeBase.numerator);
|
|
374
500
|
}
|
|
375
|
-
}
|
|
376
|
-
Object.assign(output, {
|
|
377
|
-
field: parsedFieldList
|
|
378
|
-
});
|
|
379
|
-
Object.assign(output, {
|
|
380
|
-
group: parsedGroupList
|
|
381
|
-
});
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
return output;
|
|
385
|
-
};
|
|
386
|
-
|
|
387
|
-
var parseGroupList = function parseGroupList() {
|
|
388
|
-
var groupList = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
389
|
-
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
390
|
-
var groupAsList = options.groupAsList;
|
|
391
|
-
|
|
392
|
-
if (groupAsList) {
|
|
393
|
-
return groupList.map(function (thisGroup) {
|
|
394
|
-
return parseGroup(thisGroup, options);
|
|
395
|
-
});
|
|
396
|
-
}
|
|
501
|
+
}]);
|
|
397
502
|
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
var key = thisGroup.name;
|
|
401
|
-
var parsedGroup = parseGroup(thisGroup, options);
|
|
503
|
+
return TimeCode;
|
|
504
|
+
}();
|
|
402
505
|
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
currentField = _output$key.field,
|
|
406
|
-
currentGroup = _output$key.group;
|
|
407
|
-
var parsedField = parsedGroup.field,
|
|
408
|
-
parsedGroupList = parsedGroup.group;
|
|
409
|
-
output[key].field = _objectSpread2(_objectSpread2({}, currentField), parsedField);
|
|
410
|
-
output[key].group = _objectSpread2(_objectSpread2({}, currentGroup), parsedGroupList);
|
|
411
|
-
} else {
|
|
412
|
-
output[key] = parsedGroup;
|
|
413
|
-
}
|
|
414
|
-
});
|
|
415
|
-
return output;
|
|
506
|
+
var formatTimeBaseType = function formatTimeBaseType(timeBase) {
|
|
507
|
+
return new TimeBase(timeBase);
|
|
416
508
|
};
|
|
417
509
|
|
|
418
|
-
var
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
includeTimespanAttributes = options.includeTimespanAttributes,
|
|
423
|
-
flat = options.flat,
|
|
424
|
-
flatTimespan = options.flatTimespan,
|
|
425
|
-
groupAsList = options.groupAsList,
|
|
426
|
-
fieldAsList = options.fieldAsList;
|
|
427
|
-
|
|
428
|
-
var _timespan$field = timespan.field,
|
|
429
|
-
fieldList = _timespan$field === void 0 ? [] : _timespan$field,
|
|
430
|
-
_timespan$group = timespan.group,
|
|
431
|
-
groupList = _timespan$group === void 0 ? [] : _timespan$group,
|
|
432
|
-
attributes = _objectWithoutProperties(timespan, _excluded3);
|
|
433
|
-
|
|
434
|
-
var field = parseFieldList(fieldList, options);
|
|
435
|
-
var group = parseGroupList(groupList, options);
|
|
436
|
-
var output = {};
|
|
510
|
+
var formatTimeBaseText = function formatTimeBaseText(timeBaseText) {
|
|
511
|
+
if (timeBaseText === undefined) {
|
|
512
|
+
return formatTimeBaseType();
|
|
513
|
+
}
|
|
437
514
|
|
|
438
|
-
if (
|
|
439
|
-
|
|
515
|
+
if (typeof timeBaseText === 'number') {
|
|
516
|
+
return formatTimeBaseType({
|
|
517
|
+
denominator: timeBaseText
|
|
518
|
+
});
|
|
440
519
|
}
|
|
441
520
|
|
|
442
|
-
if (
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
} else {
|
|
448
|
-
Object.assign(output, group);
|
|
449
|
-
}
|
|
521
|
+
if (timeBaseText.includes(':')) {
|
|
522
|
+
var _timeBaseText$split = timeBaseText.split(':'),
|
|
523
|
+
_timeBaseText$split2 = _slicedToArray__default["default"](_timeBaseText$split, 2),
|
|
524
|
+
_denominator = _timeBaseText$split2[0],
|
|
525
|
+
numerator = _timeBaseText$split2[1];
|
|
450
526
|
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
});
|
|
455
|
-
} else {
|
|
456
|
-
Object.assign(output, field);
|
|
457
|
-
}
|
|
458
|
-
} else {
|
|
459
|
-
Object.assign(output, {
|
|
460
|
-
field: field
|
|
461
|
-
});
|
|
462
|
-
Object.assign(output, {
|
|
463
|
-
group: group
|
|
527
|
+
return formatTimeBaseType({
|
|
528
|
+
denominator: _denominator,
|
|
529
|
+
numerator: numerator
|
|
464
530
|
});
|
|
465
531
|
}
|
|
466
532
|
|
|
467
|
-
|
|
468
|
-
|
|
533
|
+
if (Object.keys(CONSTANT_TIMEBASES).includes(timeBaseText)) {
|
|
534
|
+
return formatTimeBaseType(CONSTANT_TIMEBASES[timeBaseText]);
|
|
535
|
+
}
|
|
469
536
|
|
|
470
|
-
var
|
|
471
|
-
var timespanList = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
472
|
-
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
473
|
-
var joinTimespan = options.joinTimespan,
|
|
474
|
-
flat = options.flat;
|
|
475
|
-
var timespanAsList = options.timespanAsList;
|
|
537
|
+
var denominator = Number(timeBaseText);
|
|
476
538
|
|
|
477
|
-
if (
|
|
478
|
-
|
|
479
|
-
return parseTimespan(thisTimespan, options);
|
|
480
|
-
});
|
|
539
|
+
if (Number.isNaN(denominator)) {
|
|
540
|
+
throw new Error("timeBaseText must be a number or ".concat(Object.keys(CONSTANT_TIMEBASES).join(','), " - is ").concat(timeBaseText));
|
|
481
541
|
}
|
|
482
542
|
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
var start = thisTimespan.start,
|
|
486
|
-
end = thisTimespan.end;
|
|
487
|
-
var key = [start, end].join(joinTimespan || '_');
|
|
488
|
-
var parsedTimespan = parseTimespan(thisTimespan, options);
|
|
489
|
-
|
|
490
|
-
if (flat) {
|
|
491
|
-
output = _objectSpread2(_objectSpread2({}, output), parsedTimespan);
|
|
492
|
-
} else if (output[key]) {
|
|
493
|
-
var _output$key2 = output[key],
|
|
494
|
-
currentField = _output$key2.field,
|
|
495
|
-
currentGroup = _output$key2.group;
|
|
496
|
-
var parsedField = parsedTimespan.field,
|
|
497
|
-
parsedGroup = parsedTimespan.group;
|
|
498
|
-
output[key].field = _objectSpread2(_objectSpread2({}, currentField), parsedField);
|
|
499
|
-
output[key].group = _objectSpread2(_objectSpread2({}, currentGroup), parsedGroup);
|
|
500
|
-
} else {
|
|
501
|
-
output[key] = parsedTimespan;
|
|
502
|
-
}
|
|
543
|
+
return formatTimeBaseType({
|
|
544
|
+
denominator: denominator
|
|
503
545
|
});
|
|
504
|
-
return output;
|
|
505
546
|
};
|
|
506
|
-
/**
|
|
507
|
-
* Parses MetadataType into key/value object.
|
|
508
|
-
* The attributes can be targeted for each sub-type.
|
|
509
|
-
* @param {Object} metadataType - The response from the API.
|
|
510
|
-
* @param {Object} options - Options which change how the metadataType is parsed.
|
|
511
|
-
* @param {Object} options.joinValue - String to join the values, eg ','.
|
|
512
|
-
* @param {Object} options.includeAttributes - include attributes on all objects.
|
|
513
|
-
* @param {Object} options.includeMetadataAttributes - include attributes on root.
|
|
514
|
-
* @param {Object} options.includeTimespanAttributes - include attributes on timespans.
|
|
515
|
-
* @param {Object} options.includeGroupAttributes - include attributes on groups.
|
|
516
|
-
* @param {Object} options.includeFieldAttributes - include attributes on fields.
|
|
517
|
-
* @param {Object} options.includeValueAttributes - include attributes on values.
|
|
518
|
-
* @param {Object} options.flat - Flatten to key/value (Note: keys may be overwritten).
|
|
519
|
-
* @param {Object} options.flatTimespan - Flatten timespan.
|
|
520
|
-
* @param {Object} options.flatGroup - Flatten group.
|
|
521
|
-
* @param {Object} options.sortTimespan - Sort timespan by start time.
|
|
522
|
-
* @param {Object} options.timespanAsList -Return timespans as list.
|
|
523
|
-
* @param {Object} options.groupAsList -Return groups as list.
|
|
524
|
-
* @param {Object} options.fieldAsList -Return fields as list.
|
|
525
|
-
*/
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
var parseMetadataType = function parseMetadataType() {
|
|
529
|
-
var metadataType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
530
|
-
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
531
|
-
var includeAttributes = options.includeAttributes,
|
|
532
|
-
includeMetadataAttributes = options.includeMetadataAttributes,
|
|
533
|
-
sortTimespan = options.sortTimespan;
|
|
534
|
-
|
|
535
|
-
var _metadataType$timespa2 = metadataType.timespan,
|
|
536
|
-
timespanList = _metadataType$timespa2 === void 0 ? [] : _metadataType$timespa2,
|
|
537
|
-
attributes = _objectWithoutProperties(metadataType, _excluded4);
|
|
538
|
-
|
|
539
|
-
if (sortTimespan) timespanList.sort(sortTimespanList);
|
|
540
|
-
var timespan = parseTimespanList(timespanList, options);
|
|
541
547
|
|
|
542
|
-
|
|
543
|
-
|
|
548
|
+
var formatTimeBase = function formatTimeBase(timeBase) {
|
|
549
|
+
if (_typeof__default["default"](timeBase) === 'object') {
|
|
550
|
+
return formatTimeBaseType(timeBase);
|
|
544
551
|
}
|
|
545
552
|
|
|
546
|
-
return
|
|
553
|
+
return formatTimeBaseText(timeBase);
|
|
547
554
|
};
|
|
548
555
|
|
|
549
|
-
var
|
|
556
|
+
var formatTimeCodeType = function formatTimeCodeType(timeCode, options) {
|
|
557
|
+
return new TimeCode(timeCode, options);
|
|
558
|
+
};
|
|
550
559
|
|
|
551
|
-
function
|
|
552
|
-
|
|
553
|
-
|
|
560
|
+
var formatTimeCodeText = function formatTimeCodeText(timeCodeText, options) {
|
|
561
|
+
if (timeCodeText === undefined) {
|
|
562
|
+
var _timeCode = {
|
|
563
|
+
samples: 0
|
|
564
|
+
};
|
|
565
|
+
return formatTimeCodeType(_timeCode, options);
|
|
566
|
+
}
|
|
554
567
|
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
*
|
|
559
|
-
* @copyright 2021 Jason Mulligan <jason.mulligan@avoidwork.com>
|
|
560
|
-
* @license BSD-3-Clause
|
|
561
|
-
* @version 6.4.0
|
|
562
|
-
*/
|
|
563
|
-
(function (global, factory) {
|
|
564
|
-
module.exports = factory() ;
|
|
565
|
-
})(commonjsGlobal, function () {
|
|
566
|
-
|
|
567
|
-
var b = /^(b|B)$/,
|
|
568
|
-
symbol = {
|
|
569
|
-
iec: {
|
|
570
|
-
bits: ["b", "Kib", "Mib", "Gib", "Tib", "Pib", "Eib", "Zib", "Yib"],
|
|
571
|
-
bytes: ["B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"]
|
|
572
|
-
},
|
|
573
|
-
jedec: {
|
|
574
|
-
bits: ["b", "Kb", "Mb", "Gb", "Tb", "Pb", "Eb", "Zb", "Yb"],
|
|
575
|
-
bytes: ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"]
|
|
576
|
-
}
|
|
577
|
-
},
|
|
578
|
-
fullform = {
|
|
579
|
-
iec: ["", "kibi", "mebi", "gibi", "tebi", "pebi", "exbi", "zebi", "yobi"],
|
|
580
|
-
jedec: ["", "kilo", "mega", "giga", "tera", "peta", "exa", "zetta", "yotta"]
|
|
581
|
-
},
|
|
582
|
-
roundingFuncs = {
|
|
583
|
-
floor: Math.floor,
|
|
584
|
-
ceil: Math.ceil
|
|
568
|
+
if (typeof timeCodeText === 'number') {
|
|
569
|
+
var _timeCode2 = {
|
|
570
|
+
samples: timeCodeText
|
|
585
571
|
};
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
*
|
|
589
|
-
* @method filesize
|
|
590
|
-
* @param {Mixed} arg String, Int or Float to transform
|
|
591
|
-
* @param {Object} descriptor [Optional] Flags
|
|
592
|
-
* @return {String} Readable file size String
|
|
593
|
-
*/
|
|
594
|
-
|
|
595
|
-
function filesize(arg) {
|
|
596
|
-
var descriptor = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
597
|
-
var result = [],
|
|
598
|
-
val = 0,
|
|
599
|
-
e,
|
|
600
|
-
base,
|
|
601
|
-
bits,
|
|
602
|
-
ceil,
|
|
603
|
-
full,
|
|
604
|
-
fullforms,
|
|
605
|
-
locale,
|
|
606
|
-
localeOptions,
|
|
607
|
-
neg,
|
|
608
|
-
num,
|
|
609
|
-
output,
|
|
610
|
-
pad,
|
|
611
|
-
round,
|
|
612
|
-
u,
|
|
613
|
-
unix,
|
|
614
|
-
separator,
|
|
615
|
-
spacer,
|
|
616
|
-
standard,
|
|
617
|
-
symbols,
|
|
618
|
-
roundingFunc,
|
|
619
|
-
precision;
|
|
620
|
-
|
|
621
|
-
if (isNaN(arg)) {
|
|
622
|
-
throw new TypeError("Invalid number");
|
|
623
|
-
}
|
|
572
|
+
return formatTimeCodeType(_timeCode2, options);
|
|
573
|
+
}
|
|
624
574
|
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
locale = descriptor.locale !== void 0 ? descriptor.locale : "";
|
|
631
|
-
localeOptions = descriptor.localeOptions || {};
|
|
632
|
-
separator = descriptor.separator !== void 0 ? descriptor.separator : "";
|
|
633
|
-
spacer = descriptor.spacer !== void 0 ? descriptor.spacer : unix ? "" : " ";
|
|
634
|
-
symbols = descriptor.symbols || {};
|
|
635
|
-
standard = base === 2 ? descriptor.standard || "jedec" : "jedec";
|
|
636
|
-
output = descriptor.output || "string";
|
|
637
|
-
full = descriptor.fullform === true;
|
|
638
|
-
fullforms = descriptor.fullforms instanceof Array ? descriptor.fullforms : [];
|
|
639
|
-
e = descriptor.exponent !== void 0 ? descriptor.exponent : -1;
|
|
640
|
-
roundingFunc = roundingFuncs[descriptor.roundingMethod] || Math.round;
|
|
641
|
-
num = Number(arg);
|
|
642
|
-
neg = num < 0;
|
|
643
|
-
ceil = base > 2 ? 1000 : 1024;
|
|
644
|
-
precision = isNaN(descriptor.precision) === false ? parseInt(descriptor.precision, 10) : 0; // Flipping a negative number to determine the size
|
|
645
|
-
|
|
646
|
-
if (neg) {
|
|
647
|
-
num = -num;
|
|
648
|
-
} // Determining the exponent
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
if (e === -1 || isNaN(e)) {
|
|
652
|
-
e = Math.floor(Math.log(num) / Math.log(ceil));
|
|
653
|
-
|
|
654
|
-
if (e < 0) {
|
|
655
|
-
e = 0;
|
|
656
|
-
}
|
|
657
|
-
} // Exceeding supported length, time to reduce & multiply
|
|
575
|
+
if (timeCodeText.includes('@')) {
|
|
576
|
+
var _timeCodeText$split = timeCodeText.split('@'),
|
|
577
|
+
_timeCodeText$split2 = _slicedToArray__default["default"](_timeCodeText$split, 2),
|
|
578
|
+
samplesString = _timeCodeText$split2[0],
|
|
579
|
+
timeBaseText = _timeCodeText$split2[1];
|
|
658
580
|
|
|
581
|
+
var _samples = Number(samplesString);
|
|
659
582
|
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
583
|
+
var timeBase = formatTimeBaseText(timeBaseText);
|
|
584
|
+
var _timeCode3 = {
|
|
585
|
+
samples: _samples,
|
|
586
|
+
timeBase: timeBase
|
|
587
|
+
};
|
|
588
|
+
return formatTimeCodeType(_timeCode3, options);
|
|
589
|
+
}
|
|
664
590
|
|
|
665
|
-
|
|
666
|
-
|
|
591
|
+
if (timeCodeText === '-INF') {
|
|
592
|
+
var _samples2 = -Infinity;
|
|
667
593
|
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
594
|
+
var _timeCode4 = {
|
|
595
|
+
samples: _samples2
|
|
596
|
+
};
|
|
597
|
+
return formatTimeCodeType(_timeCode4, options);
|
|
598
|
+
}
|
|
671
599
|
|
|
600
|
+
if (timeCodeText === '+INF') {
|
|
601
|
+
var _samples3 = Infinity;
|
|
602
|
+
var _timeCode5 = {
|
|
603
|
+
samples: _samples3
|
|
604
|
+
};
|
|
605
|
+
return formatTimeCodeType(_timeCode5, options);
|
|
606
|
+
}
|
|
672
607
|
|
|
673
|
-
|
|
674
|
-
result[0] = 0;
|
|
675
|
-
u = result[1] = unix ? "" : symbol[standard][bits ? "bits" : "bytes"][e];
|
|
676
|
-
} else {
|
|
677
|
-
val = num / (base === 2 ? Math.pow(2, e * 10) : Math.pow(1000, e));
|
|
608
|
+
var samples = Number(timeCodeText);
|
|
678
609
|
|
|
679
|
-
|
|
680
|
-
|
|
610
|
+
if (Number.isNaN(samples)) {
|
|
611
|
+
throw new Error("timeBaseText must be a number or sample@timeBase - is ".concat(timeCodeText));
|
|
612
|
+
}
|
|
681
613
|
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
614
|
+
var timeCode = {
|
|
615
|
+
samples: samples
|
|
616
|
+
};
|
|
617
|
+
return formatTimeCodeType(timeCode, options);
|
|
618
|
+
};
|
|
687
619
|
|
|
688
|
-
|
|
689
|
-
|
|
620
|
+
var formatSeconds = function formatSeconds(seconds, timeBase, options) {
|
|
621
|
+
if (Number.isNaN(Number(seconds))) {
|
|
622
|
+
throw new Error("seconds must be digits, is ".concat(seconds));
|
|
623
|
+
}
|
|
690
624
|
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
625
|
+
var _ref7 = timeBase || {},
|
|
626
|
+
_ref7$denominator = _ref7.denominator,
|
|
627
|
+
denominator = _ref7$denominator === void 0 ? 1 : _ref7$denominator,
|
|
628
|
+
_ref7$numerator = _ref7.numerator,
|
|
629
|
+
numerator = _ref7$numerator === void 0 ? 1 : _ref7$numerator;
|
|
695
630
|
|
|
696
|
-
|
|
631
|
+
var samples = seconds * (denominator / numerator);
|
|
632
|
+
var timeCode = {
|
|
633
|
+
samples: samples,
|
|
634
|
+
timeBase: timeBase || {}
|
|
635
|
+
};
|
|
636
|
+
return new TimeCode(timeCode, options);
|
|
637
|
+
};
|
|
697
638
|
|
|
698
|
-
|
|
699
|
-
|
|
639
|
+
var formatSecondsPrecise = function formatSecondsPrecise(seconds, timeBase, options) {
|
|
640
|
+
if (Number.isNaN(Number(seconds))) {
|
|
641
|
+
throw new Error("seconds must be digits, is ".concat(seconds));
|
|
642
|
+
}
|
|
700
643
|
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
}
|
|
705
|
-
}
|
|
706
|
-
} // Decorating a 'diff'
|
|
644
|
+
var _ref8 = timeBase || {},
|
|
645
|
+
_ref8$numerator = _ref8.numerator,
|
|
646
|
+
numerator = _ref8$numerator === void 0 ? 1 : _ref8$numerator;
|
|
707
647
|
|
|
648
|
+
var _ref9 = timeBase || {},
|
|
649
|
+
_ref9$denominator = _ref9.denominator,
|
|
650
|
+
denominator = _ref9$denominator === void 0 ? 1 : _ref9$denominator;
|
|
708
651
|
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
652
|
+
if (!Number.isInteger(seconds)) {
|
|
653
|
+
var decimalPlaces = String(seconds).split('.')[1].length;
|
|
654
|
+
denominator *= Math.pow(10, decimalPlaces);
|
|
655
|
+
}
|
|
712
656
|
|
|
657
|
+
var samples = (seconds * (denominator / numerator)).toFixed();
|
|
658
|
+
var timeCode = {
|
|
659
|
+
samples: samples,
|
|
660
|
+
timeBase: {
|
|
661
|
+
denominator: denominator,
|
|
662
|
+
numerator: numerator
|
|
663
|
+
}
|
|
664
|
+
};
|
|
665
|
+
return new TimeCode(timeCode, options);
|
|
666
|
+
};
|
|
713
667
|
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
} // Applying custom symbol
|
|
668
|
+
var formatSmpte = function formatSmpte(smpteText, timeBaseText) {
|
|
669
|
+
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
717
670
|
|
|
671
|
+
if (smpteText === undefined) {
|
|
672
|
+
var _timeBase = formatTimeBase(timeBaseText);
|
|
718
673
|
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
} else if (separator.length > 0) {
|
|
726
|
-
result[0] = result[0].toString().replace(".", separator);
|
|
727
|
-
}
|
|
728
|
-
|
|
729
|
-
if (pad && Number.isInteger(result[0]) === false && round > 0) {
|
|
730
|
-
var x = separator || ".",
|
|
731
|
-
tmp = result[0].toString().split(x),
|
|
732
|
-
s = tmp[1] || "",
|
|
733
|
-
l = s.length,
|
|
734
|
-
n = round - l;
|
|
735
|
-
result[0] = "".concat(tmp[0]).concat(x).concat(s.padEnd(l + n, "0"));
|
|
736
|
-
}
|
|
737
|
-
|
|
738
|
-
if (full) {
|
|
739
|
-
result[1] = fullforms[e] ? fullforms[e] : fullform[standard][e] + (bits ? "bit" : "byte") + (result[0] === 1 ? "" : "s");
|
|
740
|
-
} // Returning Array, Object, or String (default)
|
|
674
|
+
var _timeCode6 = {
|
|
675
|
+
samples: 0,
|
|
676
|
+
timeBase: _timeBase
|
|
677
|
+
};
|
|
678
|
+
return formatTimeCodeType(_timeCode6);
|
|
679
|
+
}
|
|
741
680
|
|
|
681
|
+
if (typeof smpteText !== 'string') {
|
|
682
|
+
throw new Error("smpteText must be a string, is ".concat(smpteText));
|
|
683
|
+
}
|
|
742
684
|
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
685
|
+
var _splitSmpte = splitSmpte(smpteText),
|
|
686
|
+
_splitSmpte2 = _slicedToArray__default["default"](_splitSmpte, 2),
|
|
687
|
+
_splitSmpte2$ = _slicedToArray__default["default"](_splitSmpte2[0], 4),
|
|
688
|
+
hh = _splitSmpte2$[0],
|
|
689
|
+
mm = _splitSmpte2$[1],
|
|
690
|
+
ss = _splitSmpte2$[2],
|
|
691
|
+
_splitSmpte2$$ = _splitSmpte2$[3],
|
|
692
|
+
ff = _splitSmpte2$$ === void 0 ? 0 : _splitSmpte2$$,
|
|
693
|
+
frameOptions = _splitSmpte2[1];
|
|
750
694
|
|
|
695
|
+
var _frameOptions$dropFra = frameOptions.dropFrame,
|
|
696
|
+
dropFrame = _frameOptions$dropFra === void 0 ? false : _frameOptions$dropFra;
|
|
697
|
+
var timeBase = formatTimeBase(timeBaseText);
|
|
698
|
+
var roundedFrameRate = getRoundedFrameRate(timeBase);
|
|
751
699
|
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
};
|
|
756
|
-
};
|
|
700
|
+
if (mm >= 60 || mm < 0 || ss >= 60 || ss < 0 || ff >= roundedFrameRate || ff < 0) {
|
|
701
|
+
throw new Error('Invalid mm, ss or ff');
|
|
702
|
+
}
|
|
757
703
|
|
|
758
|
-
|
|
704
|
+
var samples = countSamples(hh, mm, ss, ff, {
|
|
705
|
+
dropFrame: dropFrame,
|
|
706
|
+
roundedFrameRate: roundedFrameRate
|
|
759
707
|
});
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
var NTSC = 'NTSC';
|
|
766
|
-
var NTSC30 = 'NTSC30';
|
|
767
|
-
var CONSTANT_TIMEBASES = (_CONSTANT_TIMEBASES = {}, _defineProperty(_CONSTANT_TIMEBASES, PAL, {
|
|
768
|
-
denominator: 25,
|
|
769
|
-
numerator: 1
|
|
770
|
-
}), _defineProperty(_CONSTANT_TIMEBASES, NTSC, {
|
|
771
|
-
denominator: 30000,
|
|
772
|
-
numerator: 1001
|
|
773
|
-
}), _defineProperty(_CONSTANT_TIMEBASES, NTSC30, {
|
|
774
|
-
denominator: 30,
|
|
775
|
-
numerator: 1
|
|
776
|
-
}), _defineProperty(_CONSTANT_TIMEBASES, 29.97, {
|
|
777
|
-
denominator: 30000,
|
|
778
|
-
numerator: 1001
|
|
779
|
-
}), _defineProperty(_CONSTANT_TIMEBASES, 59.94, {
|
|
780
|
-
denominator: 60000,
|
|
781
|
-
numerator: 1001
|
|
782
|
-
}), _CONSTANT_TIMEBASES);
|
|
783
|
-
var FRAME_SEPARATORS = {
|
|
784
|
-
':': {
|
|
785
|
-
dropFrame: false,
|
|
786
|
-
field: 2
|
|
787
|
-
},
|
|
788
|
-
';': {
|
|
789
|
-
dropFrame: true,
|
|
790
|
-
field: 2
|
|
791
|
-
},
|
|
792
|
-
'.': {
|
|
793
|
-
dropFrame: false,
|
|
794
|
-
field: 1
|
|
795
|
-
},
|
|
796
|
-
',': {
|
|
797
|
-
dropFrame: true,
|
|
798
|
-
field: 1
|
|
799
|
-
}
|
|
708
|
+
var timeCode = {
|
|
709
|
+
samples: samples,
|
|
710
|
+
timeBase: timeBase
|
|
711
|
+
};
|
|
712
|
+
return formatTimeCodeType(timeCode, _objectSpread$7(_objectSpread$7({}, frameOptions), options));
|
|
800
713
|
};
|
|
801
714
|
|
|
802
|
-
var
|
|
803
|
-
var hasDropFrameSeparator = smpteText.match(/[^0-9:\-_]/);
|
|
804
|
-
var hhmmssff;
|
|
805
|
-
var frameOptions = {};
|
|
715
|
+
var _excluded$4 = ["property"];
|
|
806
716
|
|
|
807
|
-
|
|
808
|
-
var _hasDropFrameSeparato = _slicedToArray(hasDropFrameSeparator, 1),
|
|
809
|
-
frameSeparator = _hasDropFrameSeparato[0];
|
|
717
|
+
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; }
|
|
810
718
|
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
719
|
+
function _objectSpread$6(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$6(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$6(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
720
|
+
var sampleRateSymbols = {
|
|
721
|
+
kB: 'kHz',
|
|
722
|
+
B: 'Hz',
|
|
723
|
+
mB: 'mHz'
|
|
724
|
+
};
|
|
725
|
+
var bitRateSymbols = {
|
|
726
|
+
kB: 'kbps',
|
|
727
|
+
B: 'bps',
|
|
728
|
+
MB: 'mbps'
|
|
729
|
+
};
|
|
815
730
|
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
hhmmssff = smpteText.split(':');
|
|
820
|
-
}
|
|
731
|
+
var gcd = function gcd(a, b) {
|
|
732
|
+
return b ? gcd(b, a % b) : a;
|
|
733
|
+
};
|
|
821
734
|
|
|
822
|
-
|
|
735
|
+
var parseAspectRatio = function parseAspectRatio(_ref) {
|
|
736
|
+
var width = _ref.width,
|
|
737
|
+
height = _ref.height;
|
|
738
|
+
var denominator = gcd(width, height);
|
|
739
|
+
var widthRatio = width / denominator;
|
|
740
|
+
var heightRatio = height / denominator;
|
|
823
741
|
|
|
824
|
-
if (
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
throw new Error('Invalid SMPTE timecode');
|
|
742
|
+
if (widthRatio > 21) {
|
|
743
|
+
heightRatio = 1;
|
|
744
|
+
widthRatio = (width / height).toFixed(2);
|
|
828
745
|
}
|
|
829
746
|
|
|
830
|
-
return [
|
|
747
|
+
return [widthRatio, heightRatio].join(':');
|
|
831
748
|
};
|
|
832
749
|
|
|
833
|
-
var
|
|
834
|
-
|
|
750
|
+
var parseBaseMediaInfoType = function parseBaseMediaInfoType() {
|
|
751
|
+
var baseMediaInfoType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
752
|
+
|
|
753
|
+
var keyValuePairType = baseMediaInfoType.property,
|
|
754
|
+
props = _objectWithoutProperties__default["default"](baseMediaInfoType, _excluded$4);
|
|
755
|
+
|
|
756
|
+
var parsedKeyValuePairType = parseKeyValuePairType(keyValuePairType);
|
|
757
|
+
return _objectSpread$6(_objectSpread$6({}, parsedKeyValuePairType), props);
|
|
835
758
|
};
|
|
836
759
|
|
|
837
|
-
var
|
|
838
|
-
|
|
760
|
+
var parseFileType = function parseFileType(fileType) {
|
|
761
|
+
var _fileType$uri = fileType.uri,
|
|
762
|
+
uriList = _fileType$uri === void 0 ? [] : _fileType$uri,
|
|
763
|
+
fileSizeBytes = fileType.size,
|
|
764
|
+
hash = fileType.hash,
|
|
765
|
+
path = fileType.path,
|
|
766
|
+
fileId = fileType.id;
|
|
767
|
+
|
|
768
|
+
var _uriList = _slicedToArray__default["default"](uriList, 1),
|
|
769
|
+
uri = _uriList[0];
|
|
770
|
+
|
|
771
|
+
var fileSize = fileSizeBytes !== undefined ? parseFileSize__default["default"](fileSizeBytes) : '';
|
|
772
|
+
var fileName = path ? path.split('/').pop() : undefined;
|
|
773
|
+
return {
|
|
774
|
+
uri: uri,
|
|
775
|
+
hash: hash,
|
|
776
|
+
fileSize: fileSize,
|
|
777
|
+
fileSizeBytes: fileSizeBytes,
|
|
778
|
+
path: path,
|
|
779
|
+
fileName: fileName,
|
|
780
|
+
fileId: fileId
|
|
781
|
+
};
|
|
839
782
|
};
|
|
840
783
|
|
|
841
|
-
var
|
|
842
|
-
var
|
|
843
|
-
|
|
784
|
+
var parseContainerComponent = function parseContainerComponent(containerComponent) {
|
|
785
|
+
var _containerComponent$m = containerComponent.mediaInfo,
|
|
786
|
+
mediaInfo = _containerComponent$m === void 0 ? {} : _containerComponent$m,
|
|
787
|
+
_containerComponent$m2 = containerComponent.metadata,
|
|
788
|
+
metadata = _containerComponent$m2 === void 0 ? [] : _containerComponent$m2,
|
|
789
|
+
fileList = containerComponent.file,
|
|
790
|
+
durationTimeCode = containerComponent.duration,
|
|
791
|
+
startTimestamp = containerComponent.startTimestamp,
|
|
792
|
+
startTimecode = containerComponent.startTimecode,
|
|
793
|
+
timeCodeTimeBase = containerComponent.timeCodeTimeBase;
|
|
794
|
+
var containerMetadata = parseKeyValuePairType(metadata);
|
|
795
|
+
var containerMediaInfo = parseBaseMediaInfoType(mediaInfo);
|
|
796
|
+
var containerFormat = containerMediaInfo.Format;
|
|
797
|
+
var videoFormat = containerMediaInfo.Video_Format_List,
|
|
798
|
+
audioFormat = containerMediaInfo.Audio_Format_List,
|
|
799
|
+
textFormat = containerMediaInfo.Text_Format_List;
|
|
844
800
|
|
|
845
|
-
if (
|
|
846
|
-
|
|
847
|
-
|
|
801
|
+
if (containerFormat === undefined) {
|
|
802
|
+
var format = containerComponent.format;
|
|
803
|
+
containerFormat = format;
|
|
848
804
|
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
}
|
|
805
|
+
if (format && format.includes(',')) {
|
|
806
|
+
var formatList = format.split(',');
|
|
852
807
|
|
|
853
|
-
|
|
854
|
-
var shouldDropMinute = mm % 10 !== 0;
|
|
855
|
-
var shouldDropSecond = shouldDropMinute && ss === 0;
|
|
856
|
-
var hourFrames = hh * (3600 * roundedFrameRate - 54 * dropFrames);
|
|
857
|
-
var minuteFrames = mm * 60 * roundedFrameRate - (mm - Math.ceil(mm / 10)) * dropFrames;
|
|
858
|
-
var secondFrames = ss * roundedFrameRate - (shouldDropMinute && ss > 1 ? dropFrames : 0);
|
|
808
|
+
var _formatList = _slicedToArray__default["default"](formatList, 1);
|
|
859
809
|
|
|
860
|
-
|
|
861
|
-
|
|
810
|
+
containerFormat = _formatList[0];
|
|
811
|
+
}
|
|
862
812
|
}
|
|
863
813
|
|
|
864
|
-
var
|
|
865
|
-
|
|
866
|
-
|
|
814
|
+
var parsedContainerComponent = {
|
|
815
|
+
containerFormat: containerFormat,
|
|
816
|
+
videoFormat: videoFormat,
|
|
817
|
+
audioFormat: audioFormat,
|
|
818
|
+
textFormat: textFormat,
|
|
819
|
+
containerMetadata: containerMetadata,
|
|
820
|
+
containerMediaInfo: containerMediaInfo
|
|
821
|
+
};
|
|
867
822
|
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
var oneMinuteDroppedFrames = 60 * roundedFrameRate - dropFrames;
|
|
872
|
-
var tenMinuteFrames = 10 * (oneMinuteUndroppedFrames - dropFrames) + dropFrames;
|
|
873
|
-
var tenMinuteChunks = Math.floor(frames / tenMinuteFrames);
|
|
874
|
-
var minuteRemainder = Math.max(0, frames % tenMinuteFrames - oneMinuteUndroppedFrames);
|
|
875
|
-
var oneMinuteChunks = Math.floor(minuteRemainder / oneMinuteDroppedFrames);
|
|
876
|
-
var frameRemainder = minuteRemainder % oneMinuteDroppedFrames;
|
|
877
|
-
var frameChunks = frameRemainder > 0 ? dropFrames : 0;
|
|
878
|
-
return tenMinuteChunks * 9 * dropFrames + oneMinuteChunks * dropFrames + frameChunks;
|
|
879
|
-
}
|
|
823
|
+
if (containerMetadata.componentOriginalFilename) {
|
|
824
|
+
parsedContainerComponent.originalFilename = containerMetadata.componentOriginalFilename;
|
|
825
|
+
}
|
|
880
826
|
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
numerator = _ref2$numerator === void 0 ? 1 : _ref2$numerator,
|
|
886
|
-
_ref2$denominator = _ref2.denominator,
|
|
887
|
-
denominator = _ref2$denominator === void 0 ? 1 : _ref2$denominator;
|
|
827
|
+
if (durationTimeCode !== undefined && durationTimeCode.samples !== 0) {
|
|
828
|
+
parsedContainerComponent.durationTimeCode = formatTimeCodeType(durationTimeCode);
|
|
829
|
+
parsedContainerComponent.duration = parsedContainerComponent.durationTimeCode.toDuration();
|
|
830
|
+
}
|
|
888
831
|
|
|
889
|
-
|
|
832
|
+
if (startTimestamp) {
|
|
833
|
+
parsedContainerComponent.startTimestamp = formatTimeCodeType(startTimestamp);
|
|
834
|
+
}
|
|
890
835
|
|
|
891
|
-
|
|
892
|
-
|
|
836
|
+
if (startTimecode !== undefined && timeCodeTimeBase) {
|
|
837
|
+
parsedContainerComponent.startTimecode = formatTimeCodeType({
|
|
838
|
+
samples: startTimecode,
|
|
839
|
+
timeBase: timeCodeTimeBase
|
|
840
|
+
});
|
|
893
841
|
}
|
|
894
842
|
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
return {
|
|
899
|
-
denominator: this.denominator,
|
|
900
|
-
numerator: this.numerator
|
|
901
|
-
};
|
|
902
|
-
}
|
|
903
|
-
}, {
|
|
904
|
-
key: "toConstant",
|
|
905
|
-
value: function toConstant() {
|
|
906
|
-
var _this = this;
|
|
843
|
+
if (fileList) {
|
|
844
|
+
var _fileList = _slicedToArray__default["default"](fileList, 1),
|
|
845
|
+
fileType = _fileList[0];
|
|
907
846
|
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
thisTimeBaseText = _thisTimeBase[0],
|
|
912
|
-
thisTimeBaseType = _thisTimeBase[1];
|
|
847
|
+
var parsedFileType = parseFileType(fileType);
|
|
848
|
+
parsedContainerComponent = _objectSpread$6(_objectSpread$6({}, parsedContainerComponent), parsedFileType);
|
|
849
|
+
}
|
|
913
850
|
|
|
914
|
-
|
|
915
|
-
|
|
851
|
+
return parsedContainerComponent;
|
|
852
|
+
};
|
|
916
853
|
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
854
|
+
var parseVideoComponent = function parseVideoComponent(videoComponent) {
|
|
855
|
+
var videoCodec = videoComponent.codec,
|
|
856
|
+
bitrate = videoComponent.bitrate,
|
|
857
|
+
fieldOrder = videoComponent.fieldOrder,
|
|
858
|
+
_videoComponent$resol = videoComponent.resolution,
|
|
859
|
+
resolution = _videoComponent$resol === void 0 ? {} : _videoComponent$resol,
|
|
860
|
+
_videoComponent$media = videoComponent.mediaInfo,
|
|
861
|
+
mediaInfo = _videoComponent$media === void 0 ? {} : _videoComponent$media,
|
|
862
|
+
_videoComponent$metad = videoComponent.metadata,
|
|
863
|
+
metadata = _videoComponent$metad === void 0 ? [] : _videoComponent$metad;
|
|
864
|
+
var videoMediaInfo = parseBaseMediaInfoType(mediaInfo);
|
|
865
|
+
var videoMetadata = parseKeyValuePairType(metadata);
|
|
866
|
+
var videoFormat = videoMediaInfo.Format,
|
|
867
|
+
timeBaseText = videoMediaInfo['Frame rate'],
|
|
868
|
+
colorSpace = videoMediaInfo['Color space'],
|
|
869
|
+
colorPrimaries = videoMediaInfo['Color primaries'],
|
|
870
|
+
chromaSubsampling = videoMediaInfo.Colorimetry;
|
|
871
|
+
var timeBase;
|
|
872
|
+
var averageFrameRate = videoComponent.averageFrameRate,
|
|
873
|
+
realBaseFrameRate = videoComponent.realBaseFrameRate;
|
|
921
874
|
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
875
|
+
if (realBaseFrameRate !== undefined) {
|
|
876
|
+
timeBase = {
|
|
877
|
+
numerator: realBaseFrameRate.denominator,
|
|
878
|
+
denominator: realBaseFrameRate.numerator
|
|
879
|
+
};
|
|
880
|
+
} else if (timeBaseText !== undefined) {
|
|
881
|
+
timeBase = formatTimeBaseText(timeBaseText);
|
|
882
|
+
} else if (averageFrameRate !== undefined) {
|
|
883
|
+
timeBase = {
|
|
884
|
+
numerator: averageFrameRate.denominator,
|
|
885
|
+
denominator: averageFrameRate.numerator
|
|
886
|
+
};
|
|
887
|
+
}
|
|
930
888
|
|
|
931
|
-
|
|
932
|
-
var _timeBaseText = this.toConstant();
|
|
889
|
+
var samples = videoMediaInfo['Frame count'];
|
|
933
890
|
|
|
934
|
-
|
|
935
|
-
|
|
891
|
+
if (samples === undefined) {
|
|
892
|
+
var numberOfPackets = videoComponent.numberOfPackets;
|
|
893
|
+
if (numberOfPackets !== undefined) samples = numberOfPackets;
|
|
894
|
+
}
|
|
936
895
|
|
|
937
|
-
|
|
938
|
-
|
|
896
|
+
var timeCode;
|
|
897
|
+
var frameRate;
|
|
898
|
+
var smpte;
|
|
939
899
|
|
|
940
|
-
|
|
941
|
-
|
|
900
|
+
if (samples && timeBase) {
|
|
901
|
+
timeCode = formatTimeCodeType({
|
|
902
|
+
samples: samples,
|
|
903
|
+
timeBase: timeBase
|
|
904
|
+
});
|
|
905
|
+
frameRate = timeCode.timeBase.toRate(true);
|
|
906
|
+
smpte = timeCode.toSmpte(true);
|
|
907
|
+
}
|
|
942
908
|
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
909
|
+
var height = resolution.height,
|
|
910
|
+
width = resolution.width;
|
|
911
|
+
var aspectRatio = parseAspectRatio(resolution);
|
|
912
|
+
var dimension = "".concat(width, "x").concat(height);
|
|
913
|
+
var videoBitrate = bitrate ? parseFileSize__default["default"](bitrate, {
|
|
914
|
+
bits: true
|
|
915
|
+
}) : undefined;
|
|
916
|
+
return {
|
|
917
|
+
videoFormat: videoFormat,
|
|
918
|
+
dimension: dimension,
|
|
919
|
+
frameRate: frameRate,
|
|
920
|
+
height: height,
|
|
921
|
+
width: width,
|
|
922
|
+
timeBase: timeBase,
|
|
923
|
+
timeCode: timeCode,
|
|
924
|
+
videoCodec: videoCodec,
|
|
925
|
+
smpte: smpte,
|
|
926
|
+
videoBitrate: videoBitrate,
|
|
927
|
+
fieldOrder: fieldOrder,
|
|
928
|
+
colorSpace: colorSpace,
|
|
929
|
+
chromaSubsampling: chromaSubsampling,
|
|
930
|
+
aspectRatio: aspectRatio,
|
|
931
|
+
colorPrimaries: colorPrimaries,
|
|
932
|
+
videoMetadata: videoMetadata,
|
|
933
|
+
videoMediaInfo: videoMediaInfo
|
|
934
|
+
};
|
|
935
|
+
};
|
|
951
936
|
|
|
952
|
-
|
|
953
|
-
|
|
937
|
+
var parseAudioComponent = function parseAudioComponent(audioComponent) {
|
|
938
|
+
var _audioComponent$timeB = audioComponent.timeBase,
|
|
939
|
+
timeBase = _audioComponent$timeB === void 0 ? {} : _audioComponent$timeB,
|
|
940
|
+
audioChannels = audioComponent.channelCount,
|
|
941
|
+
audioCodec = audioComponent.codec,
|
|
942
|
+
_audioComponent$media = audioComponent.mediaInfo,
|
|
943
|
+
mediaInfo = _audioComponent$media === void 0 ? {} : _audioComponent$media,
|
|
944
|
+
bitrate = audioComponent.bitrate,
|
|
945
|
+
_audioComponent$metad = audioComponent.metadata,
|
|
946
|
+
metadata = _audioComponent$metad === void 0 ? [] : _audioComponent$metad;
|
|
947
|
+
var audioMediaInfo = parseBaseMediaInfoType(mediaInfo);
|
|
948
|
+
var audioMetadata = parseKeyValuePairType(metadata);
|
|
949
|
+
var audioFormat = audioMediaInfo.Format,
|
|
950
|
+
audioBitDepth = audioMediaInfo.Resolution,
|
|
951
|
+
audioBitRateMode = audioMediaInfo.Bit_rate_mode;
|
|
952
|
+
var audioSamplerateSamples = timeBase.denominator ? timeBase.denominator / timeBase.numerator : undefined;
|
|
953
|
+
var audioSamplerate = audioSamplerateSamples ? parseFileSize__default["default"](audioSamplerateSamples, {
|
|
954
|
+
base: 10,
|
|
955
|
+
round: 1,
|
|
956
|
+
symbols: sampleRateSymbols
|
|
957
|
+
}) : undefined;
|
|
958
|
+
var audioBitrate = bitrate ? parseFileSize__default["default"](bitrate, {
|
|
959
|
+
base: 10,
|
|
960
|
+
round: 2,
|
|
961
|
+
symbols: bitRateSymbols
|
|
962
|
+
}) : undefined;
|
|
963
|
+
return {
|
|
964
|
+
audioFormat: audioFormat,
|
|
965
|
+
audioCodec: audioCodec,
|
|
966
|
+
audioSamplerate: audioSamplerate,
|
|
967
|
+
audioSamplerateSamples: audioSamplerateSamples,
|
|
968
|
+
audioBitDepth: audioBitDepth,
|
|
969
|
+
audioBitrate: audioBitrate,
|
|
970
|
+
audioBitRateMode: audioBitRateMode,
|
|
971
|
+
audioChannels: audioChannels,
|
|
972
|
+
audioMediaInfo: audioMediaInfo,
|
|
973
|
+
audioMetadata: audioMetadata
|
|
974
|
+
};
|
|
975
|
+
};
|
|
954
976
|
|
|
955
|
-
|
|
956
|
-
|
|
977
|
+
var parseBinaryComponent = function parseBinaryComponent(binaryComponent) {
|
|
978
|
+
var fileList = binaryComponent.file,
|
|
979
|
+
_binaryComponent$medi = binaryComponent.mediaInfo,
|
|
980
|
+
mediaInfo = _binaryComponent$medi === void 0 ? {} : _binaryComponent$medi,
|
|
981
|
+
_binaryComponent$meta = binaryComponent.metadata,
|
|
982
|
+
metadata = _binaryComponent$meta === void 0 ? [] : _binaryComponent$meta;
|
|
983
|
+
var binaryMetadata = parseKeyValuePairType(metadata);
|
|
984
|
+
var binaryMediaInfo = parseBaseMediaInfoType(mediaInfo);
|
|
985
|
+
var parsedBinaryComponent = {
|
|
986
|
+
binaryMetadata: binaryMetadata,
|
|
987
|
+
binaryMediaInfo: binaryMediaInfo
|
|
988
|
+
};
|
|
957
989
|
|
|
958
|
-
|
|
990
|
+
if (fileList) {
|
|
991
|
+
var _fileList2 = _slicedToArray__default["default"](fileList, 1),
|
|
992
|
+
fileType = _fileList2[0];
|
|
959
993
|
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
994
|
+
var parsedFileType = parseFileType(fileType);
|
|
995
|
+
parsedBinaryComponent = _objectSpread$6(_objectSpread$6({}, parsedBinaryComponent), parsedFileType);
|
|
996
|
+
}
|
|
963
997
|
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
}]);
|
|
998
|
+
return parsedBinaryComponent;
|
|
999
|
+
};
|
|
967
1000
|
|
|
968
|
-
|
|
969
|
-
}
|
|
1001
|
+
var parseShapeType = function parseShapeType() {
|
|
1002
|
+
var shapeType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1003
|
+
var parsedShape = {};
|
|
1004
|
+
var containerComponent = shapeType.containerComponent,
|
|
1005
|
+
videoComponentList = shapeType.videoComponent,
|
|
1006
|
+
audioComponentList = shapeType.audioComponent,
|
|
1007
|
+
binaryComponentList = shapeType.binaryComponent,
|
|
1008
|
+
_shapeType$mimeType = shapeType.mimeType,
|
|
1009
|
+
mimeTypeList = _shapeType$mimeType === void 0 ? [] : _shapeType$mimeType,
|
|
1010
|
+
_shapeType$tag = shapeType.tag,
|
|
1011
|
+
tagList = _shapeType$tag === void 0 ? [] : _shapeType$tag;
|
|
970
1012
|
|
|
971
|
-
var
|
|
972
|
-
var numerator = _ref3.numerator,
|
|
973
|
-
denominator = _ref3.denominator;
|
|
974
|
-
return numerator === 1001 && (denominator === 60000 || denominator === 30000);
|
|
975
|
-
};
|
|
1013
|
+
var _tagList = _slicedToArray__default["default"](tagList, 1);
|
|
976
1014
|
|
|
977
|
-
|
|
978
|
-
function TimeCode() {
|
|
979
|
-
var _ref4 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
980
|
-
_ref4$samples = _ref4.samples,
|
|
981
|
-
samples = _ref4$samples === void 0 ? 0 : _ref4$samples,
|
|
982
|
-
timeBase = _ref4.timeBase;
|
|
1015
|
+
parsedShape.tag = _tagList[0];
|
|
983
1016
|
|
|
984
|
-
|
|
985
|
-
dropFrame = _ref5.dropFrame,
|
|
986
|
-
_ref5$field = _ref5.field,
|
|
987
|
-
field = _ref5$field === void 0 ? 2 : _ref5$field;
|
|
1017
|
+
var _mimeTypeList = _slicedToArray__default["default"](mimeTypeList, 1);
|
|
988
1018
|
|
|
989
|
-
|
|
1019
|
+
parsedShape.mimeType = _mimeTypeList[0];
|
|
990
1020
|
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
this.samples = -Infinity;
|
|
996
|
-
} else if (samples === '+INF') {
|
|
997
|
-
this.samples = Infinity;
|
|
998
|
-
} else {
|
|
999
|
-
this.samples = Number(samples);
|
|
1000
|
-
}
|
|
1001
|
-
} else {
|
|
1002
|
-
throw new Error("samples is not number/string/-Inf/+Inf is: ".concat(samples));
|
|
1003
|
-
}
|
|
1021
|
+
if (containerComponent) {
|
|
1022
|
+
var parsedContainerComponent = parseContainerComponent(containerComponent);
|
|
1023
|
+
parsedShape = _objectSpread$6(_objectSpread$6({}, parsedShape), parsedContainerComponent);
|
|
1024
|
+
}
|
|
1004
1025
|
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1026
|
+
if (videoComponentList) {
|
|
1027
|
+
var _videoComponentList = _slicedToArray__default["default"](videoComponentList, 1),
|
|
1028
|
+
videoComponent = _videoComponentList[0];
|
|
1029
|
+
|
|
1030
|
+
var parsedVideoComponent = parseVideoComponent(videoComponent);
|
|
1031
|
+
parsedShape = _objectSpread$6(_objectSpread$6({}, parsedShape), parsedVideoComponent);
|
|
1008
1032
|
}
|
|
1009
1033
|
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
var _val$timeBase = val.timeBase,
|
|
1014
|
-
numerator = _val$timeBase.numerator,
|
|
1015
|
-
denominator = _val$timeBase.denominator;
|
|
1016
|
-
var conformedTimeCode = val;
|
|
1034
|
+
if (audioComponentList) {
|
|
1035
|
+
var _audioComponentList = _slicedToArray__default["default"](audioComponentList, 1),
|
|
1036
|
+
audioComponent = _audioComponentList[0];
|
|
1017
1037
|
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1038
|
+
var parsedAudioComponent = parseAudioComponent(audioComponent);
|
|
1039
|
+
parsedShape = _objectSpread$6(_objectSpread$6({}, parsedShape), parsedAudioComponent);
|
|
1040
|
+
}
|
|
1021
1041
|
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
samples: this.samples + samples,
|
|
1026
|
-
timeBase: this.timeBase
|
|
1027
|
-
});
|
|
1028
|
-
}
|
|
1029
|
-
}, {
|
|
1030
|
-
key: "subtract",
|
|
1031
|
-
value: function subtract(val) {
|
|
1032
|
-
var _val$timeBase2 = val.timeBase,
|
|
1033
|
-
numerator = _val$timeBase2.numerator,
|
|
1034
|
-
denominator = _val$timeBase2.denominator;
|
|
1035
|
-
var conformedTimeCode = val;
|
|
1042
|
+
if (binaryComponentList) {
|
|
1043
|
+
var _binaryComponentList = _slicedToArray__default["default"](binaryComponentList, 1),
|
|
1044
|
+
binaryComponent = _binaryComponentList[0];
|
|
1036
1045
|
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1046
|
+
var parsedBinaryComponent = parseBinaryComponent(binaryComponent);
|
|
1047
|
+
parsedShape = _objectSpread$6(_objectSpread$6({}, parsedShape), parsedBinaryComponent);
|
|
1048
|
+
}
|
|
1040
1049
|
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
return new TimeCode({
|
|
1044
|
-
samples: this.samples - samples,
|
|
1045
|
-
timeBase: this.timeBase
|
|
1046
|
-
});
|
|
1047
|
-
}
|
|
1048
|
-
}, {
|
|
1049
|
-
key: "conformTimeBase",
|
|
1050
|
-
value: function conformTimeBase(conformTo) {
|
|
1051
|
-
var timeBase = conformTo;
|
|
1052
|
-
|
|
1053
|
-
if (conformTo instanceof TimeCode === false) {
|
|
1054
|
-
timeBase = new TimeBase(conformTo);
|
|
1055
|
-
}
|
|
1056
|
-
|
|
1057
|
-
var samples = Math.round(this.samples / (this.timeBase.toRate(false, false) / timeBase.toRate(false, false)));
|
|
1058
|
-
var timeCode = {
|
|
1059
|
-
samples: samples,
|
|
1060
|
-
timeBase: timeBase
|
|
1061
|
-
};
|
|
1062
|
-
return new TimeCode(timeCode);
|
|
1063
|
-
}
|
|
1064
|
-
}, {
|
|
1065
|
-
key: "toJSON",
|
|
1066
|
-
value: function toJSON() {
|
|
1067
|
-
return {
|
|
1068
|
-
samples: this.samples,
|
|
1069
|
-
timeBase: this.timeBase
|
|
1070
|
-
};
|
|
1071
|
-
}
|
|
1072
|
-
}, {
|
|
1073
|
-
key: "toText",
|
|
1074
|
-
value: function toText() {
|
|
1075
|
-
var timeCodeText = String(this.samples);
|
|
1076
|
-
var timeBaseText = this.timeBase.toText();
|
|
1050
|
+
return parsedShape;
|
|
1051
|
+
};
|
|
1077
1052
|
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
}
|
|
1053
|
+
var _excluded$3 = ["Codec"],
|
|
1054
|
+
_excluded2$2 = ["Codec"];
|
|
1081
1055
|
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
var minutes = Math.floor(totalSamples / (60 * roundedFrameRate)) % 60;
|
|
1099
|
-
var seconds = Math.floor(totalSamples / roundedFrameRate) % 60;
|
|
1100
|
-
var frames = totalSamples % roundedFrameRate;
|
|
1101
|
-
var partialSeconds = frames / roundedFrameRate;
|
|
1102
|
-
return {
|
|
1103
|
-
hours: hours,
|
|
1104
|
-
minutes: minutes,
|
|
1105
|
-
seconds: seconds,
|
|
1106
|
-
frames: frames,
|
|
1107
|
-
partialSeconds: partialSeconds
|
|
1108
|
-
};
|
|
1109
|
-
}
|
|
1110
|
-
}, {
|
|
1111
|
-
key: "toDuration",
|
|
1112
|
-
value: function toDuration() {
|
|
1113
|
-
var _ref6 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
1114
|
-
format = _ref6.format;
|
|
1056
|
+
var parseMediaConvertPreset = function parseMediaConvertPreset(transcodePresetType) {
|
|
1057
|
+
var output = {};
|
|
1058
|
+
var description = transcodePresetType.description,
|
|
1059
|
+
_transcodePresetType$ = transcodePresetType.mediaconvert;
|
|
1060
|
+
_transcodePresetType$ = _transcodePresetType$ === void 0 ? {} : _transcodePresetType$;
|
|
1061
|
+
var _transcodePresetType$2 = _transcodePresetType$.outputSetting,
|
|
1062
|
+
outputSetting = _transcodePresetType$2 === void 0 ? [] : _transcodePresetType$2;
|
|
1063
|
+
output.description = description;
|
|
1064
|
+
if (outputSetting.length === 0) return output;
|
|
1065
|
+
var mc = JSON.parse(outputSetting[0]);
|
|
1066
|
+
var _mc$Settings = mc.Settings;
|
|
1067
|
+
_mc$Settings = _mc$Settings === void 0 ? {} : _mc$Settings;
|
|
1068
|
+
var ContainerSettings = _mc$Settings.ContainerSettings,
|
|
1069
|
+
VideoDescription = _mc$Settings.VideoDescription,
|
|
1070
|
+
AudioDescriptions = _mc$Settings.AudioDescriptions;
|
|
1071
|
+
output.containerFormat = ContainerSettings.Container;
|
|
1115
1072
|
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
seconds = _this$toTime.seconds;
|
|
1073
|
+
if (ContainerSettings) {
|
|
1074
|
+
output.containerFormat = ContainerSettings.Container;
|
|
1075
|
+
}
|
|
1120
1076
|
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
}
|
|
1125
|
-
}
|
|
1077
|
+
if (VideoDescription) {
|
|
1078
|
+
var _VideoDescription$Cod = VideoDescription.CodecSettings,
|
|
1079
|
+
CodecSettings = _VideoDescription$Cod === void 0 ? {} : _VideoDescription$Cod;
|
|
1126
1080
|
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
}
|
|
1081
|
+
var Codec = CodecSettings.Codec,
|
|
1082
|
+
otherSettings = _objectWithoutProperties__default["default"](CodecSettings, _excluded$3);
|
|
1130
1083
|
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1084
|
+
output.videoFormat = Codec;
|
|
1085
|
+
var height = VideoDescription.Height,
|
|
1086
|
+
width = VideoDescription.Width;
|
|
1087
|
+
output.height = height;
|
|
1088
|
+
output.width = width;
|
|
1134
1089
|
|
|
1135
|
-
|
|
1090
|
+
if (height && width) {
|
|
1091
|
+
output.dimension = "".concat(width, "x").concat(height);
|
|
1092
|
+
output.aspectRatio = parseAspectRatio({
|
|
1093
|
+
height: height,
|
|
1094
|
+
width: width
|
|
1095
|
+
});
|
|
1136
1096
|
}
|
|
1137
|
-
}, {
|
|
1138
|
-
key: "toSmpte",
|
|
1139
|
-
value: function toSmpte() {
|
|
1140
|
-
var _this2 = this;
|
|
1141
|
-
|
|
1142
|
-
if (this.samples === -Infinity) return '00:00:00:00';
|
|
1143
1097
|
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
seconds = _this$toTime2.seconds,
|
|
1148
|
-
frames = _this$toTime2.frames;
|
|
1098
|
+
var _Object$values = Object.values(otherSettings),
|
|
1099
|
+
_Object$values2 = _slicedToArray__default["default"](_Object$values, 1),
|
|
1100
|
+
codecSpecs = _Object$values2[0];
|
|
1149
1101
|
|
|
1150
|
-
|
|
1102
|
+
if (codecSpecs) {
|
|
1103
|
+
output.fieldOrder = codecSpecs.InterlaceMode;
|
|
1104
|
+
if (output.fieldOrder && output.fieldOrder.includes('TOP')) output.fieldOrder = 'interlaced';
|
|
1105
|
+
output.videoBitrate = codecSpecs.Bitrate;
|
|
1106
|
+
var numerator = codecSpecs.FramerateDenominator; // other way round to vs ¯\_(ツ)_/¯
|
|
1151
1107
|
|
|
1152
|
-
var
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1108
|
+
var denominator = codecSpecs.FramerateNumerator;
|
|
1109
|
+
var timeBase = formatTimeBaseType({
|
|
1110
|
+
denominator: denominator,
|
|
1111
|
+
numerator: numerator
|
|
1112
|
+
});
|
|
1113
|
+
output.timeBase = timeBase;
|
|
1114
|
+
output.frameRate = timeBase.toRate(true);
|
|
1115
|
+
}
|
|
1116
|
+
}
|
|
1157
1117
|
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
_Object$entries$find3 = _Object$entries$find2[0],
|
|
1162
|
-
frameSeparator = _Object$entries$find3 === void 0 ? ':' : _Object$entries$find3;
|
|
1118
|
+
if (AudioDescriptions && AudioDescriptions.length > 0) {
|
|
1119
|
+
var _AudioDescriptions$0$ = AudioDescriptions[0].CodecSettings,
|
|
1120
|
+
_CodecSettings = _AudioDescriptions$0$ === void 0 ? {} : _AudioDescriptions$0$;
|
|
1163
1121
|
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
}, {
|
|
1167
|
-
key: "toFraction",
|
|
1168
|
-
value: function toFraction() {
|
|
1169
|
-
return "".concat(this.samples, "@").concat(this.timeBase.denominator, ":").concat(this.timeBase.numerator);
|
|
1170
|
-
}
|
|
1171
|
-
}]);
|
|
1122
|
+
var _Codec = _CodecSettings.Codec,
|
|
1123
|
+
_otherSettings = _objectWithoutProperties__default["default"](_CodecSettings, _excluded2$2);
|
|
1172
1124
|
|
|
1173
|
-
|
|
1174
|
-
}();
|
|
1125
|
+
output.audioFormat = _Codec;
|
|
1175
1126
|
|
|
1176
|
-
var
|
|
1177
|
-
|
|
1178
|
-
|
|
1127
|
+
var _Object$values3 = Object.values(_otherSettings),
|
|
1128
|
+
_Object$values4 = _slicedToArray__default["default"](_Object$values3, 1),
|
|
1129
|
+
_codecSpecs = _Object$values4[0];
|
|
1179
1130
|
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1131
|
+
if (_codecSpecs) {
|
|
1132
|
+
output.audioSamplerate = _codecSpecs.SampleRate;
|
|
1133
|
+
output.audioBitrate = _codecSpecs.Bitrate;
|
|
1134
|
+
output.audioBitRateMode = _codecSpecs.RateControlMode;
|
|
1135
|
+
}
|
|
1183
1136
|
}
|
|
1184
1137
|
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
denominator: timeBaseText
|
|
1188
|
-
});
|
|
1189
|
-
}
|
|
1138
|
+
return output;
|
|
1139
|
+
};
|
|
1190
1140
|
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1141
|
+
var parseTranscodePreset = function parseTranscodePreset(transcodePresetType) {
|
|
1142
|
+
var output = {};
|
|
1143
|
+
var description = transcodePresetType.description,
|
|
1144
|
+
format = transcodePresetType.format,
|
|
1145
|
+
audio = transcodePresetType.audio,
|
|
1146
|
+
video = transcodePresetType.video,
|
|
1147
|
+
mediaconvert = transcodePresetType.mediaconvert;
|
|
1148
|
+
if (mediaconvert) return parseMediaConvertPreset(transcodePresetType);
|
|
1149
|
+
output.description = description;
|
|
1150
|
+
output.containerFormat = format;
|
|
1196
1151
|
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
});
|
|
1201
|
-
}
|
|
1152
|
+
if (video) {
|
|
1153
|
+
output.videoFormat = video.codec;
|
|
1154
|
+
output.videoBitrate = video.bitrate;
|
|
1202
1155
|
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1156
|
+
if (video.framerate) {
|
|
1157
|
+
var timeBase = formatTimeBaseType(video.framerate);
|
|
1158
|
+
output.timeBase = timeBase;
|
|
1159
|
+
output.frameRate = timeBase.toRate(true);
|
|
1160
|
+
}
|
|
1206
1161
|
|
|
1207
|
-
|
|
1162
|
+
if (video.scaling) {
|
|
1163
|
+
var _video$scaling = video.scaling,
|
|
1164
|
+
height = _video$scaling.height,
|
|
1165
|
+
width = _video$scaling.width;
|
|
1166
|
+
output.height = height;
|
|
1167
|
+
output.width = width;
|
|
1208
1168
|
|
|
1209
|
-
|
|
1210
|
-
|
|
1169
|
+
if (height && width) {
|
|
1170
|
+
output.dimension = "".concat(width, "x").concat(height);
|
|
1171
|
+
output.aspectRatio = parseAspectRatio({
|
|
1172
|
+
height: height,
|
|
1173
|
+
width: width
|
|
1174
|
+
});
|
|
1175
|
+
}
|
|
1176
|
+
}
|
|
1211
1177
|
}
|
|
1212
1178
|
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
var formatTimeBase = function formatTimeBase(timeBase) {
|
|
1219
|
-
if (_typeof(timeBase) === 'object') {
|
|
1220
|
-
return formatTimeBaseType(timeBase);
|
|
1179
|
+
if (audio) {
|
|
1180
|
+
var audioFormat = audio.codec,
|
|
1181
|
+
channel = audio.channel;
|
|
1182
|
+
output.audioFormat = audioFormat;
|
|
1183
|
+
if (channel) output.audioChannels = channel.length;
|
|
1221
1184
|
}
|
|
1222
1185
|
|
|
1223
|
-
return
|
|
1186
|
+
return output;
|
|
1224
1187
|
};
|
|
1225
1188
|
|
|
1226
|
-
var
|
|
1227
|
-
|
|
1189
|
+
var PDF = 'PDF';
|
|
1190
|
+
var TEXT = 'TEXT';
|
|
1191
|
+
var MSWORD = 'MSWORD';
|
|
1192
|
+
var JSON$1 = 'JSON';
|
|
1193
|
+
var XML = 'XML';
|
|
1194
|
+
var getDocumentType = function getDocumentType() {
|
|
1195
|
+
var shape = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1196
|
+
var mimeType = shape.mimeType;
|
|
1197
|
+
if (!mimeType) return undefined;
|
|
1198
|
+
if (mimeType.endsWith('/pdf')) return PDF;
|
|
1199
|
+
if (mimeType.startsWith('text/')) return TEXT;
|
|
1200
|
+
if (mimeType.endsWith('/msword')) return MSWORD;
|
|
1201
|
+
if (mimeType.endsWith('/json')) return JSON$1;
|
|
1202
|
+
if (mimeType.endsWith('/xml')) return XML;
|
|
1203
|
+
return undefined;
|
|
1228
1204
|
};
|
|
1229
1205
|
|
|
1230
|
-
var
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1206
|
+
var ACCESSCONTROL_READ = '_accesscontrol_read';
|
|
1207
|
+
var ACCESSCONTROL_WRITE = '_accesscontrol_write';
|
|
1208
|
+
var ADMINISTRATOR = '_administrator';
|
|
1209
|
+
var AUTO_PROJECTION_READ = '_auto_projection_read';
|
|
1210
|
+
var AUTO_PROJECTION_WRITE = '_auto_projection_write';
|
|
1211
|
+
var COLLECTION_NOTIFICATION_READ = '_collection_notification_read';
|
|
1212
|
+
var COLLECTION_NOTIFICATION_WRITE = '_collection_notification_write';
|
|
1213
|
+
var COLLECTION_READ = '_collection_read';
|
|
1214
|
+
var COLLECTION_WRITE = '_collection_write';
|
|
1215
|
+
var DELETION_LOCK_NOTIFICATION_READ = '_deletion_lock_notification_read';
|
|
1216
|
+
var DELETION_LOCK_NOTIFICATION_WRITE = '_deletion_lock_notification_write';
|
|
1217
|
+
var DELETION_LOCK_READ = '_deletion_lock_read';
|
|
1218
|
+
var DELETION_LOCK_WRITE = '_deletion_lock_write';
|
|
1219
|
+
var DOCUMENT_NOTIFICATION_READ = '_document_notification_read';
|
|
1220
|
+
var DOCUMENT_NOTIFICATION_WRITE = '_document_notification_write';
|
|
1221
|
+
var DOCUMENT_READ = '_document_read';
|
|
1222
|
+
var DOCUMENT_WRITE = '_document_write';
|
|
1223
|
+
var ERROR_READ = '_error_read';
|
|
1224
|
+
var ERROR_WRITE = '_error_write';
|
|
1225
|
+
var EXPORT = '_export';
|
|
1226
|
+
var EXPORT_TEMPLATE_READ = '_export_template_read';
|
|
1227
|
+
var EXPORT_TEMPLATE_WRITE = '_export_template_write';
|
|
1228
|
+
var EXTERNAL_ID_READ = '_external_id_read';
|
|
1229
|
+
var EXTERNAL_ID_WRITE = '_external_id_write';
|
|
1230
|
+
var FILE_NOTIFICATION_READ = '_file_notification_read';
|
|
1231
|
+
var FILE_NOTIFICATION_WRITE = '_file_notification_write';
|
|
1232
|
+
var FILE_READ = '_file_read';
|
|
1233
|
+
var FILE_WRITE = '_file_write';
|
|
1234
|
+
var GROUP_READ = '_group_read';
|
|
1235
|
+
var GROUP_WRITE = '_group_write';
|
|
1236
|
+
var IMPORT_WRITE = '_import';
|
|
1237
|
+
var ITEM_ID_READ = '_item_id_read';
|
|
1238
|
+
var ITEM_ID_WRITE = '_item_id_write';
|
|
1239
|
+
var ITEM_NOTIFICATION_READ = '_item_notification_read';
|
|
1240
|
+
var ITEM_NOTIFICATION_WRITE = '_item_notification_write';
|
|
1241
|
+
var ITEM_WRITE = '_item_write';
|
|
1242
|
+
var ITEM_SEARCH = '_item_search';
|
|
1243
|
+
var ITEM_SHAPE_READ = '_item_shape_read';
|
|
1244
|
+
var ITEM_SHAPE_WRITE = '_item_shape_write';
|
|
1245
|
+
var ITEM_TIMELINE_READ = '_item_timeline_read';
|
|
1246
|
+
var ITEM_TIMELINE_WRITE = '_item_timeline_write';
|
|
1247
|
+
var ITEM_URI = '_item_uri';
|
|
1248
|
+
var JOB_NOTIFICATION_READ = '_job_notification_read';
|
|
1249
|
+
var JOB_NOTIFICATION_WRITE = '_job_notification_write';
|
|
1250
|
+
var JOB_READ = '_job_read';
|
|
1251
|
+
var JOB_WRITE = '_job_write';
|
|
1252
|
+
var LIBRARY_READ = '_library_read';
|
|
1253
|
+
var LIBRARY_WRITE = '_library_write';
|
|
1254
|
+
var LOCK_READ = '_lock_read';
|
|
1255
|
+
var LOCK_WRITE = '_lock_write';
|
|
1256
|
+
var LOG_READ = '_log_read';
|
|
1257
|
+
var METADATA_DATASET_READ = '_metadata_dataset_read';
|
|
1258
|
+
var METADATA_DATASET_WRITE = '_metadata_dataset_write';
|
|
1259
|
+
var METADATA_FIELD_GROUP_READ = '_metadata_field_group_read';
|
|
1260
|
+
var METADATA_FIELD_GROUP_WRITE = '_metadata_field_group_write';
|
|
1261
|
+
var METADATA_FIELD_READ = '_metadata_field_read';
|
|
1262
|
+
var METADATA_FIELD_WRITE = '_metadata_field_write';
|
|
1263
|
+
var METADATA_GLOBAL_READ = '_metadata_global_read';
|
|
1264
|
+
var METADATA_GLOBAL_WRITE = '_metadata_global_write';
|
|
1265
|
+
var METADATA_LOCK_READ = '_metadata_lock_read';
|
|
1266
|
+
var METADATA_LOCK_WRITE = '_metadata_lock_write';
|
|
1267
|
+
var METADATA_READ = '_metadata_read';
|
|
1268
|
+
var METADATA_SCHEMA_READ = '_metadata_schema_read';
|
|
1269
|
+
var METADATA_SCHEMA_WRITE = '_metadata_schema_write';
|
|
1270
|
+
var METADATA_WRITE = '_metadata_write';
|
|
1271
|
+
var OTIF_ANALYZE = '_otif_analyze';
|
|
1272
|
+
var OTIF_READ = '_otif_read';
|
|
1273
|
+
var OTIF_WRITE = '_otif_write';
|
|
1274
|
+
var PLACEHOLDER_NOTIFICATION_READ = '_placeholder_notification_read';
|
|
1275
|
+
var PLACEHOLDER_NOTIFICATION_WRITE = '_placeholder_notification_write';
|
|
1276
|
+
var PROJECTION_READ = '_projection_read';
|
|
1277
|
+
var PROJECTION_WRITE = '_projection_write';
|
|
1278
|
+
var QUOTA_NOTIFICATION_READ = '_quota_notification_read';
|
|
1279
|
+
var QUOTA_NOTIFICATION_WRITE = '_quota_notification_write';
|
|
1280
|
+
var QUOTA_READ = '_quota_read';
|
|
1281
|
+
var QUOTA_WRITE = '_quota_write';
|
|
1282
|
+
var RELATION_READ = '_relation_read';
|
|
1283
|
+
var RELATION_WRITE = '_relation_write';
|
|
1284
|
+
var RESOURCE_READ = '_resource_read';
|
|
1285
|
+
var RESOURCE_WRITE = '_resource_write';
|
|
1286
|
+
var RUN_AS = '_run_as';
|
|
1287
|
+
var SEARCH = '_search';
|
|
1288
|
+
var SEQUENCE_READ = '_sequence_read';
|
|
1289
|
+
var SEQUENCE_WRITE = '_sequence_write';
|
|
1290
|
+
var SHAPE_TAG_READ = '_shape_tag_read';
|
|
1291
|
+
var SHAPE_TAG_WRITE = '_shape_tag_write';
|
|
1292
|
+
var SITE_MANAGER = '_site_manager';
|
|
1293
|
+
var SITE_RULE_READ = '_site_rule_read';
|
|
1294
|
+
var SITE_RULE_WRITE = '_site_rule_write';
|
|
1295
|
+
var STORAGE_GROUP_READ = '_storage_group_read';
|
|
1296
|
+
var STORAGE_GROUP_WRITE = '_storage_group_write';
|
|
1297
|
+
var STORAGE_NOTIFICATION_READ = '_storage_notification_read';
|
|
1298
|
+
var STORAGE_NOTIFICATION_WRITE = '_storage_notification_write';
|
|
1299
|
+
var STORAGE_READ = '_storage_read';
|
|
1300
|
+
var STORAGE_RULE_READ = '_storage_rule_read';
|
|
1301
|
+
var STORAGE_RULE_WRITE = '_storage_rule_write';
|
|
1302
|
+
var STORAGE_WRITE = '_storage_write';
|
|
1303
|
+
var SUPER_ACCESS_USER = '_super_access_user';
|
|
1304
|
+
var TASKDEFINITION_READ = '_taskdefinition_read';
|
|
1305
|
+
var TASKDEFINITION_WRITE = '_taskdefinition_write';
|
|
1306
|
+
var THUMBNAIL_READ = '_thumbnail_read';
|
|
1307
|
+
var THUMBNAIL_WRITE = '_thumbnail_write';
|
|
1308
|
+
var TRANSCODER = '_transcoder';
|
|
1309
|
+
var TRANSFER_READ = '_transfer_read';
|
|
1310
|
+
var TRANSFER_WRITE = '_transfer_write';
|
|
1311
|
+
var USER = '_user';
|
|
1312
|
+
var VXA = '_vxa';
|
|
1313
|
+
var VXA_READ = '_vxa_read';
|
|
1237
1314
|
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1315
|
+
var roles = /*#__PURE__*/Object.freeze({
|
|
1316
|
+
__proto__: null,
|
|
1317
|
+
ACCESSCONTROL_READ: ACCESSCONTROL_READ,
|
|
1318
|
+
ACCESSCONTROL_WRITE: ACCESSCONTROL_WRITE,
|
|
1319
|
+
ADMINISTRATOR: ADMINISTRATOR,
|
|
1320
|
+
AUTO_PROJECTION_READ: AUTO_PROJECTION_READ,
|
|
1321
|
+
AUTO_PROJECTION_WRITE: AUTO_PROJECTION_WRITE,
|
|
1322
|
+
COLLECTION_NOTIFICATION_READ: COLLECTION_NOTIFICATION_READ,
|
|
1323
|
+
COLLECTION_NOTIFICATION_WRITE: COLLECTION_NOTIFICATION_WRITE,
|
|
1324
|
+
COLLECTION_READ: COLLECTION_READ,
|
|
1325
|
+
COLLECTION_WRITE: COLLECTION_WRITE,
|
|
1326
|
+
DELETION_LOCK_NOTIFICATION_READ: DELETION_LOCK_NOTIFICATION_READ,
|
|
1327
|
+
DELETION_LOCK_NOTIFICATION_WRITE: DELETION_LOCK_NOTIFICATION_WRITE,
|
|
1328
|
+
DELETION_LOCK_READ: DELETION_LOCK_READ,
|
|
1329
|
+
DELETION_LOCK_WRITE: DELETION_LOCK_WRITE,
|
|
1330
|
+
DOCUMENT_NOTIFICATION_READ: DOCUMENT_NOTIFICATION_READ,
|
|
1331
|
+
DOCUMENT_NOTIFICATION_WRITE: DOCUMENT_NOTIFICATION_WRITE,
|
|
1332
|
+
DOCUMENT_READ: DOCUMENT_READ,
|
|
1333
|
+
DOCUMENT_WRITE: DOCUMENT_WRITE,
|
|
1334
|
+
ERROR_READ: ERROR_READ,
|
|
1335
|
+
ERROR_WRITE: ERROR_WRITE,
|
|
1336
|
+
EXPORT: EXPORT,
|
|
1337
|
+
EXPORT_TEMPLATE_READ: EXPORT_TEMPLATE_READ,
|
|
1338
|
+
EXPORT_TEMPLATE_WRITE: EXPORT_TEMPLATE_WRITE,
|
|
1339
|
+
EXTERNAL_ID_READ: EXTERNAL_ID_READ,
|
|
1340
|
+
EXTERNAL_ID_WRITE: EXTERNAL_ID_WRITE,
|
|
1341
|
+
FILE_NOTIFICATION_READ: FILE_NOTIFICATION_READ,
|
|
1342
|
+
FILE_NOTIFICATION_WRITE: FILE_NOTIFICATION_WRITE,
|
|
1343
|
+
FILE_READ: FILE_READ,
|
|
1344
|
+
FILE_WRITE: FILE_WRITE,
|
|
1345
|
+
GROUP_READ: GROUP_READ,
|
|
1346
|
+
GROUP_WRITE: GROUP_WRITE,
|
|
1347
|
+
IMPORT_WRITE: IMPORT_WRITE,
|
|
1348
|
+
ITEM_ID_READ: ITEM_ID_READ,
|
|
1349
|
+
ITEM_ID_WRITE: ITEM_ID_WRITE,
|
|
1350
|
+
ITEM_NOTIFICATION_READ: ITEM_NOTIFICATION_READ,
|
|
1351
|
+
ITEM_NOTIFICATION_WRITE: ITEM_NOTIFICATION_WRITE,
|
|
1352
|
+
ITEM_WRITE: ITEM_WRITE,
|
|
1353
|
+
ITEM_SEARCH: ITEM_SEARCH,
|
|
1354
|
+
ITEM_SHAPE_READ: ITEM_SHAPE_READ,
|
|
1355
|
+
ITEM_SHAPE_WRITE: ITEM_SHAPE_WRITE,
|
|
1356
|
+
ITEM_TIMELINE_READ: ITEM_TIMELINE_READ,
|
|
1357
|
+
ITEM_TIMELINE_WRITE: ITEM_TIMELINE_WRITE,
|
|
1358
|
+
ITEM_URI: ITEM_URI,
|
|
1359
|
+
JOB_NOTIFICATION_READ: JOB_NOTIFICATION_READ,
|
|
1360
|
+
JOB_NOTIFICATION_WRITE: JOB_NOTIFICATION_WRITE,
|
|
1361
|
+
JOB_READ: JOB_READ,
|
|
1362
|
+
JOB_WRITE: JOB_WRITE,
|
|
1363
|
+
LIBRARY_READ: LIBRARY_READ,
|
|
1364
|
+
LIBRARY_WRITE: LIBRARY_WRITE,
|
|
1365
|
+
LOCK_READ: LOCK_READ,
|
|
1366
|
+
LOCK_WRITE: LOCK_WRITE,
|
|
1367
|
+
LOG_READ: LOG_READ,
|
|
1368
|
+
METADATA_DATASET_READ: METADATA_DATASET_READ,
|
|
1369
|
+
METADATA_DATASET_WRITE: METADATA_DATASET_WRITE,
|
|
1370
|
+
METADATA_FIELD_GROUP_READ: METADATA_FIELD_GROUP_READ,
|
|
1371
|
+
METADATA_FIELD_GROUP_WRITE: METADATA_FIELD_GROUP_WRITE,
|
|
1372
|
+
METADATA_FIELD_READ: METADATA_FIELD_READ,
|
|
1373
|
+
METADATA_FIELD_WRITE: METADATA_FIELD_WRITE,
|
|
1374
|
+
METADATA_GLOBAL_READ: METADATA_GLOBAL_READ,
|
|
1375
|
+
METADATA_GLOBAL_WRITE: METADATA_GLOBAL_WRITE,
|
|
1376
|
+
METADATA_LOCK_READ: METADATA_LOCK_READ,
|
|
1377
|
+
METADATA_LOCK_WRITE: METADATA_LOCK_WRITE,
|
|
1378
|
+
METADATA_READ: METADATA_READ,
|
|
1379
|
+
METADATA_SCHEMA_READ: METADATA_SCHEMA_READ,
|
|
1380
|
+
METADATA_SCHEMA_WRITE: METADATA_SCHEMA_WRITE,
|
|
1381
|
+
METADATA_WRITE: METADATA_WRITE,
|
|
1382
|
+
OTIF_ANALYZE: OTIF_ANALYZE,
|
|
1383
|
+
OTIF_READ: OTIF_READ,
|
|
1384
|
+
OTIF_WRITE: OTIF_WRITE,
|
|
1385
|
+
PLACEHOLDER_NOTIFICATION_READ: PLACEHOLDER_NOTIFICATION_READ,
|
|
1386
|
+
PLACEHOLDER_NOTIFICATION_WRITE: PLACEHOLDER_NOTIFICATION_WRITE,
|
|
1387
|
+
PROJECTION_READ: PROJECTION_READ,
|
|
1388
|
+
PROJECTION_WRITE: PROJECTION_WRITE,
|
|
1389
|
+
QUOTA_NOTIFICATION_READ: QUOTA_NOTIFICATION_READ,
|
|
1390
|
+
QUOTA_NOTIFICATION_WRITE: QUOTA_NOTIFICATION_WRITE,
|
|
1391
|
+
QUOTA_READ: QUOTA_READ,
|
|
1392
|
+
QUOTA_WRITE: QUOTA_WRITE,
|
|
1393
|
+
RELATION_READ: RELATION_READ,
|
|
1394
|
+
RELATION_WRITE: RELATION_WRITE,
|
|
1395
|
+
RESOURCE_READ: RESOURCE_READ,
|
|
1396
|
+
RESOURCE_WRITE: RESOURCE_WRITE,
|
|
1397
|
+
RUN_AS: RUN_AS,
|
|
1398
|
+
SEARCH: SEARCH,
|
|
1399
|
+
SEQUENCE_READ: SEQUENCE_READ,
|
|
1400
|
+
SEQUENCE_WRITE: SEQUENCE_WRITE,
|
|
1401
|
+
SHAPE_TAG_READ: SHAPE_TAG_READ,
|
|
1402
|
+
SHAPE_TAG_WRITE: SHAPE_TAG_WRITE,
|
|
1403
|
+
SITE_MANAGER: SITE_MANAGER,
|
|
1404
|
+
SITE_RULE_READ: SITE_RULE_READ,
|
|
1405
|
+
SITE_RULE_WRITE: SITE_RULE_WRITE,
|
|
1406
|
+
STORAGE_GROUP_READ: STORAGE_GROUP_READ,
|
|
1407
|
+
STORAGE_GROUP_WRITE: STORAGE_GROUP_WRITE,
|
|
1408
|
+
STORAGE_NOTIFICATION_READ: STORAGE_NOTIFICATION_READ,
|
|
1409
|
+
STORAGE_NOTIFICATION_WRITE: STORAGE_NOTIFICATION_WRITE,
|
|
1410
|
+
STORAGE_READ: STORAGE_READ,
|
|
1411
|
+
STORAGE_RULE_READ: STORAGE_RULE_READ,
|
|
1412
|
+
STORAGE_RULE_WRITE: STORAGE_RULE_WRITE,
|
|
1413
|
+
STORAGE_WRITE: STORAGE_WRITE,
|
|
1414
|
+
SUPER_ACCESS_USER: SUPER_ACCESS_USER,
|
|
1415
|
+
TASKDEFINITION_READ: TASKDEFINITION_READ,
|
|
1416
|
+
TASKDEFINITION_WRITE: TASKDEFINITION_WRITE,
|
|
1417
|
+
THUMBNAIL_READ: THUMBNAIL_READ,
|
|
1418
|
+
THUMBNAIL_WRITE: THUMBNAIL_WRITE,
|
|
1419
|
+
TRANSCODER: TRANSCODER,
|
|
1420
|
+
TRANSFER_READ: TRANSFER_READ,
|
|
1421
|
+
TRANSFER_WRITE: TRANSFER_WRITE,
|
|
1422
|
+
USER: USER,
|
|
1423
|
+
VXA: VXA,
|
|
1424
|
+
VXA_READ: VXA_READ
|
|
1425
|
+
});
|
|
1244
1426
|
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
_timeCodeText$split2 = _slicedToArray(_timeCodeText$split, 2),
|
|
1248
|
-
samplesString = _timeCodeText$split2[0],
|
|
1249
|
-
timeBaseText = _timeCodeText$split2[1];
|
|
1427
|
+
var _excluded$2 = ["groupName"],
|
|
1428
|
+
_excluded2$1 = ["start", "end"];
|
|
1250
1429
|
|
|
1251
|
-
|
|
1430
|
+
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; }
|
|
1252
1431
|
|
|
1253
|
-
|
|
1254
|
-
var _timeCode3 = {
|
|
1255
|
-
samples: _samples,
|
|
1256
|
-
timeBase: timeBase
|
|
1257
|
-
};
|
|
1258
|
-
return formatTimeCodeType(_timeCode3, options);
|
|
1259
|
-
}
|
|
1432
|
+
function _objectSpread$5(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$5(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$5(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
1260
1433
|
|
|
1261
|
-
|
|
1262
|
-
|
|
1434
|
+
var parseValueList$1 = function parseValueList(value) {
|
|
1435
|
+
if (value === undefined) return [];
|
|
1436
|
+
if (value === null) return [{
|
|
1437
|
+
value: ''
|
|
1438
|
+
}];
|
|
1263
1439
|
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1440
|
+
if (Array.isArray(value)) {
|
|
1441
|
+
return value.map(function (valueOrObject) {
|
|
1442
|
+
if (_typeof__default["default"](valueOrObject) === 'object') {
|
|
1443
|
+
return _objectSpread$5({
|
|
1444
|
+
value: valueOrObject.value || ''
|
|
1445
|
+
}, valueOrObject);
|
|
1446
|
+
}
|
|
1269
1447
|
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
};
|
|
1275
|
-
return formatTimeCodeType(_timeCode5, options);
|
|
1448
|
+
return {
|
|
1449
|
+
value: valueOrObject
|
|
1450
|
+
};
|
|
1451
|
+
});
|
|
1276
1452
|
}
|
|
1277
1453
|
|
|
1278
|
-
|
|
1454
|
+
if (value.value) return [value];
|
|
1455
|
+
return [{
|
|
1456
|
+
value: value
|
|
1457
|
+
}];
|
|
1458
|
+
};
|
|
1279
1459
|
|
|
1280
|
-
|
|
1281
|
-
|
|
1460
|
+
var parseValue = function parseValue() {
|
|
1461
|
+
var fieldValue = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1462
|
+
|
|
1463
|
+
if (fieldValue && (fieldValue.value || fieldValue.name)) {
|
|
1464
|
+
var valueList = fieldValue.value,
|
|
1465
|
+
uuid = fieldValue.uuid;
|
|
1466
|
+
var value = parseValueList$1(valueList);
|
|
1467
|
+
return {
|
|
1468
|
+
value: value,
|
|
1469
|
+
uuid: uuid
|
|
1470
|
+
};
|
|
1282
1471
|
}
|
|
1283
1472
|
|
|
1284
|
-
|
|
1285
|
-
|
|
1473
|
+
return {
|
|
1474
|
+
value: parseValueList$1(fieldValue)
|
|
1286
1475
|
};
|
|
1287
|
-
return formatTimeCodeType(timeCode, options);
|
|
1288
1476
|
};
|
|
1289
1477
|
|
|
1290
|
-
var
|
|
1291
|
-
var
|
|
1292
|
-
var
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1478
|
+
var parseField$1 = function parseField() {
|
|
1479
|
+
var field = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1480
|
+
var name = field.name,
|
|
1481
|
+
value = field.value;
|
|
1482
|
+
var parsedValue = parseValue(value);
|
|
1483
|
+
return _objectSpread$5({
|
|
1484
|
+
name: name
|
|
1485
|
+
}, parsedValue);
|
|
1486
|
+
};
|
|
1297
1487
|
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
var samples = seconds * (denominator / numerator);
|
|
1303
|
-
var timeCode = {
|
|
1304
|
-
samples: samples,
|
|
1305
|
-
timeBase: timeBase
|
|
1306
|
-
};
|
|
1307
|
-
return new TimeCode(timeCode, options);
|
|
1488
|
+
var shouldBeField = function shouldBeField(_ref) {
|
|
1489
|
+
var name = _ref.name,
|
|
1490
|
+
value = _ref.value;
|
|
1491
|
+
return ['string', 'boolean', 'number'].includes(_typeof__default["default"](value)) || name !== 'group' && Array.isArray(value) || value === null;
|
|
1308
1492
|
};
|
|
1309
1493
|
|
|
1310
|
-
var
|
|
1311
|
-
var
|
|
1312
|
-
var
|
|
1494
|
+
var parseGroup$1 = function parseGroup() {
|
|
1495
|
+
var thisGroup = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1496
|
+
var groupName = thisGroup.name,
|
|
1497
|
+
_thisGroup$value = thisGroup.value,
|
|
1498
|
+
groupsOrFields = _thisGroup$value === void 0 ? {} : _thisGroup$value; // eslint-disable-next-line no-use-before-define
|
|
1313
1499
|
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1500
|
+
var _parseGroupsOrFields = parseGroupsOrFields(groupsOrFields),
|
|
1501
|
+
field = _parseGroupsOrFields.field,
|
|
1502
|
+
group = _parseGroupsOrFields.group;
|
|
1317
1503
|
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1504
|
+
return {
|
|
1505
|
+
name: groupName,
|
|
1506
|
+
group: group,
|
|
1507
|
+
field: field
|
|
1508
|
+
};
|
|
1509
|
+
};
|
|
1322
1510
|
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1511
|
+
var parseGroupsOrFields = function parseGroupsOrFields(groupsOrFields) {
|
|
1512
|
+
var group = [];
|
|
1513
|
+
var field = [];
|
|
1514
|
+
Object.entries(groupsOrFields).forEach(function (_ref2) {
|
|
1515
|
+
var _ref3 = _slicedToArray__default["default"](_ref2, 2),
|
|
1516
|
+
name = _ref3[0],
|
|
1517
|
+
value = _ref3[1];
|
|
1327
1518
|
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1519
|
+
if (shouldBeField({
|
|
1520
|
+
name: name,
|
|
1521
|
+
value: value
|
|
1522
|
+
})) {
|
|
1523
|
+
field.push(parseField$1({
|
|
1524
|
+
name: name,
|
|
1525
|
+
value: value
|
|
1526
|
+
}));
|
|
1527
|
+
} else if (Array.isArray(value)) {
|
|
1528
|
+
value.forEach(function (_ref4) {
|
|
1529
|
+
var groupName = _ref4.groupName,
|
|
1530
|
+
groupValue = _objectWithoutProperties__default["default"](_ref4, _excluded$2);
|
|
1531
|
+
|
|
1532
|
+
group.push(parseGroup$1({
|
|
1533
|
+
name: groupName,
|
|
1534
|
+
value: groupValue
|
|
1535
|
+
}));
|
|
1536
|
+
});
|
|
1537
|
+
} else {
|
|
1538
|
+
group.push(parseGroup$1({
|
|
1539
|
+
name: name,
|
|
1540
|
+
value: value
|
|
1541
|
+
}));
|
|
1334
1542
|
}
|
|
1543
|
+
});
|
|
1544
|
+
return {
|
|
1545
|
+
group: group,
|
|
1546
|
+
field: field
|
|
1335
1547
|
};
|
|
1336
|
-
return new TimeCode(timeCode, options);
|
|
1337
1548
|
};
|
|
1338
1549
|
|
|
1339
|
-
var
|
|
1340
|
-
var
|
|
1550
|
+
var parseTimespan$1 = function parseTimespan() {
|
|
1551
|
+
var timespan = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1341
1552
|
|
|
1342
|
-
|
|
1343
|
-
|
|
1553
|
+
var _ref5 = timespan || {},
|
|
1554
|
+
_ref5$start = _ref5.start,
|
|
1555
|
+
start = _ref5$start === void 0 ? '-INF' : _ref5$start,
|
|
1556
|
+
_ref5$end = _ref5.end,
|
|
1557
|
+
end = _ref5$end === void 0 ? '+INF' : _ref5$end,
|
|
1558
|
+
groupsOrFields = _objectWithoutProperties__default["default"](_ref5, _excluded2$1);
|
|
1344
1559
|
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
};
|
|
1349
|
-
return formatTimeCodeType(_timeCode6);
|
|
1350
|
-
}
|
|
1560
|
+
var _parseGroupsOrFields2 = parseGroupsOrFields(groupsOrFields),
|
|
1561
|
+
group = _parseGroupsOrFields2.group,
|
|
1562
|
+
field = _parseGroupsOrFields2.field;
|
|
1351
1563
|
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1564
|
+
return {
|
|
1565
|
+
start: start,
|
|
1566
|
+
end: end,
|
|
1567
|
+
field: field,
|
|
1568
|
+
group: group
|
|
1569
|
+
};
|
|
1570
|
+
};
|
|
1571
|
+
/**
|
|
1572
|
+
* Create a MetadataType object from a metadata object
|
|
1573
|
+
* @param {Object} metadata={} - object with metadata to create MetadataType object of
|
|
1574
|
+
* @returns {Object} MetadataType
|
|
1575
|
+
*/
|
|
1355
1576
|
|
|
1356
|
-
var _splitSmpte = splitSmpte(smpteText),
|
|
1357
|
-
_splitSmpte2 = _slicedToArray(_splitSmpte, 2),
|
|
1358
|
-
_splitSmpte2$ = _slicedToArray(_splitSmpte2[0], 4),
|
|
1359
|
-
hh = _splitSmpte2$[0],
|
|
1360
|
-
mm = _splitSmpte2$[1],
|
|
1361
|
-
ss = _splitSmpte2$[2],
|
|
1362
|
-
_splitSmpte2$$ = _splitSmpte2$[3],
|
|
1363
|
-
ff = _splitSmpte2$$ === void 0 ? 0 : _splitSmpte2$$,
|
|
1364
|
-
frameOptions = _splitSmpte2[1];
|
|
1365
1577
|
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
var
|
|
1369
|
-
var roundedFrameRate = getRoundedFrameRate(timeBase);
|
|
1578
|
+
var createMetadataType = function createMetadataType() {
|
|
1579
|
+
var metadata = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1580
|
+
var metadataType = {};
|
|
1370
1581
|
|
|
1371
|
-
if (
|
|
1372
|
-
|
|
1582
|
+
if (Array.isArray(metadata)) {
|
|
1583
|
+
metadataType.timespan = metadata.map(function (thisTimeSpan) {
|
|
1584
|
+
return parseTimespan$1(thisTimeSpan);
|
|
1585
|
+
});
|
|
1586
|
+
} else {
|
|
1587
|
+
var genericTimespan = parseTimespan$1(metadata);
|
|
1588
|
+
metadataType.timespan = [genericTimespan];
|
|
1373
1589
|
}
|
|
1374
1590
|
|
|
1375
|
-
|
|
1376
|
-
dropFrame: dropFrame,
|
|
1377
|
-
roundedFrameRate: roundedFrameRate
|
|
1378
|
-
});
|
|
1379
|
-
var timeCode = {
|
|
1380
|
-
samples: samples,
|
|
1381
|
-
timeBase: timeBase
|
|
1382
|
-
};
|
|
1383
|
-
return formatTimeCodeType(timeCode, _objectSpread2(_objectSpread2({}, frameOptions), options));
|
|
1591
|
+
return metadataType;
|
|
1384
1592
|
};
|
|
1385
1593
|
|
|
1386
|
-
var
|
|
1387
|
-
var
|
|
1594
|
+
var sortTimespanList = function sortTimespanList(timespan1, timespan2) {
|
|
1595
|
+
var firstStart = timespan1.start;
|
|
1596
|
+
var secondStart = timespan2.start;
|
|
1388
1597
|
|
|
1389
|
-
var
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
return _objectSpread2(_objectSpread2({}, a), {}, _defineProperty({}, key, value));
|
|
1393
|
-
};
|
|
1598
|
+
var _firstStart$split = firstStart.split('@'),
|
|
1599
|
+
_firstStart$split2 = _slicedToArray__default["default"](_firstStart$split, 1),
|
|
1600
|
+
first = _firstStart$split2[0];
|
|
1394
1601
|
|
|
1395
|
-
|
|
1396
|
-
|
|
1602
|
+
var _secondStart$split = secondStart.split('@'),
|
|
1603
|
+
_secondStart$split2 = _slicedToArray__default["default"](_secondStart$split, 1),
|
|
1604
|
+
second = _secondStart$split2[0];
|
|
1397
1605
|
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
B: 'Hz',
|
|
1402
|
-
mB: 'mHz'
|
|
1403
|
-
};
|
|
1404
|
-
var bitRateSymbols = {
|
|
1405
|
-
kB: 'kbps',
|
|
1406
|
-
B: 'bps',
|
|
1407
|
-
MB: 'mbps'
|
|
1408
|
-
};
|
|
1606
|
+
if (Number(first) < Number(second)) {
|
|
1607
|
+
return -1;
|
|
1608
|
+
}
|
|
1409
1609
|
|
|
1410
|
-
|
|
1411
|
-
|
|
1610
|
+
if (Number(first) > Number(second)) {
|
|
1611
|
+
return 1;
|
|
1612
|
+
}
|
|
1613
|
+
|
|
1614
|
+
return 0;
|
|
1412
1615
|
};
|
|
1413
1616
|
|
|
1414
|
-
var
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
var denominator = gcd(width, height);
|
|
1418
|
-
var widthRatio = width / denominator;
|
|
1419
|
-
var heightRatio = height / denominator;
|
|
1617
|
+
var _excluded$1 = ["value"],
|
|
1618
|
+
_excluded2 = ["field", "group"],
|
|
1619
|
+
_excluded3 = ["field", "group"];
|
|
1420
1620
|
|
|
1421
|
-
|
|
1422
|
-
heightRatio = 1;
|
|
1423
|
-
widthRatio = (width / height).toFixed(2);
|
|
1424
|
-
}
|
|
1621
|
+
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; }
|
|
1425
1622
|
|
|
1426
|
-
|
|
1427
|
-
};
|
|
1623
|
+
function _objectSpread$4(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$4(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$4(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
1428
1624
|
|
|
1429
|
-
var
|
|
1430
|
-
var
|
|
1625
|
+
var parseValueList = function parseValueList() {
|
|
1626
|
+
var valueList = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
1627
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1628
|
+
var _options$arrayOnSingl = options.arrayOnSingle,
|
|
1629
|
+
arrayOnSingle = _options$arrayOnSingl === void 0 ? true : _options$arrayOnSingl,
|
|
1630
|
+
_options$arrayOnSingl2 = options.arrayOnSingleValue,
|
|
1631
|
+
arrayOnSingleValue = _options$arrayOnSingl2 === void 0 ? true : _options$arrayOnSingl2,
|
|
1632
|
+
joinValue = options.joinValue,
|
|
1633
|
+
includeAttributes = options.includeAttributes,
|
|
1634
|
+
includeValueAttributes = options.includeValueAttributes;
|
|
1635
|
+
if (includeAttributes || includeValueAttributes) return valueList;
|
|
1636
|
+
var valueArray = [];
|
|
1637
|
+
valueList.forEach(function (thisValue) {
|
|
1638
|
+
if (thisValue.value) valueArray.push(thisValue.value);
|
|
1639
|
+
});
|
|
1640
|
+
if (joinValue) return valueArray.join(joinValue);
|
|
1431
1641
|
|
|
1432
|
-
|
|
1433
|
-
|
|
1642
|
+
if (arrayOnSingle === false || arrayOnSingleValue === false && valueArray.length === 1) {
|
|
1643
|
+
return valueArray[0];
|
|
1644
|
+
}
|
|
1434
1645
|
|
|
1435
|
-
|
|
1436
|
-
return _objectSpread2(_objectSpread2({}, parsedKeyValuePairType), props);
|
|
1646
|
+
return valueArray;
|
|
1437
1647
|
};
|
|
1438
1648
|
|
|
1439
|
-
var
|
|
1440
|
-
var
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
path = fileType.path,
|
|
1445
|
-
fileId = fileType.id;
|
|
1649
|
+
var parseField = function parseField() {
|
|
1650
|
+
var field = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1651
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1652
|
+
var includeAttributes = options.includeAttributes,
|
|
1653
|
+
includeFieldAttributes = options.includeFieldAttributes;
|
|
1446
1654
|
|
|
1447
|
-
var
|
|
1448
|
-
|
|
1655
|
+
var _field$value = field.value,
|
|
1656
|
+
value = _field$value === void 0 ? [] : _field$value,
|
|
1657
|
+
attributes = _objectWithoutProperties__default["default"](field, _excluded$1);
|
|
1449
1658
|
|
|
1450
|
-
var
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
fileSize: fileSize,
|
|
1456
|
-
fileSizeBytes: fileSizeBytes,
|
|
1457
|
-
path: path,
|
|
1458
|
-
fileName: fileName,
|
|
1459
|
-
fileId: fileId
|
|
1460
|
-
};
|
|
1659
|
+
var parsedValueList = parseValueList(value, options);
|
|
1660
|
+
if (includeAttributes || includeFieldAttributes) return _objectSpread$4(_objectSpread$4({}, attributes), {}, {
|
|
1661
|
+
value: parsedValueList
|
|
1662
|
+
});
|
|
1663
|
+
return parsedValueList;
|
|
1461
1664
|
};
|
|
1462
1665
|
|
|
1463
|
-
var
|
|
1464
|
-
var
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
timeCodeTimeBase = containerComponent.timeCodeTimeBase;
|
|
1473
|
-
var containerMetadata = parseKeyValuePairType(metadata);
|
|
1474
|
-
var containerMediaInfo = parseBaseMediaInfoType(mediaInfo);
|
|
1475
|
-
var containerFormat = containerMediaInfo.Format;
|
|
1476
|
-
var videoFormat = containerMediaInfo.Video_Format_List,
|
|
1477
|
-
audioFormat = containerMediaInfo.Audio_Format_List,
|
|
1478
|
-
textFormat = containerMediaInfo.Text_Format_List;
|
|
1666
|
+
var parseFieldList = function parseFieldList() {
|
|
1667
|
+
var fieldList = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
1668
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1669
|
+
var joinValue = options.joinValue,
|
|
1670
|
+
includeAttributes = options.includeAttributes,
|
|
1671
|
+
includeFieldAttributes = options.includeFieldAttributes,
|
|
1672
|
+
includeValueAttributes = options.includeValueAttributes;
|
|
1673
|
+
var output = {};
|
|
1674
|
+
var fieldAsList = options.fieldAsList;
|
|
1479
1675
|
|
|
1480
|
-
if (
|
|
1481
|
-
|
|
1482
|
-
|
|
1676
|
+
if (fieldAsList) {
|
|
1677
|
+
return fieldList.map(function (thisField) {
|
|
1678
|
+
return parseField(thisField, options);
|
|
1679
|
+
});
|
|
1680
|
+
}
|
|
1483
1681
|
|
|
1484
|
-
|
|
1485
|
-
|
|
1682
|
+
fieldList.forEach(function (thisField) {
|
|
1683
|
+
var key = thisField.name;
|
|
1684
|
+
var parsedField = parseField(thisField, options);
|
|
1486
1685
|
|
|
1487
|
-
|
|
1686
|
+
if (output[key]) {
|
|
1687
|
+
if (includeAttributes || includeFieldAttributes) {
|
|
1688
|
+
var currentValue = output[key].value;
|
|
1689
|
+
var parsedValue = parsedField.value;
|
|
1488
1690
|
|
|
1489
|
-
|
|
1691
|
+
if (joinValue && !includeAttributes && !includeValueAttributes) {
|
|
1692
|
+
output[key].value = [currentValue, parsedValue].join(joinValue);
|
|
1693
|
+
} else {
|
|
1694
|
+
output[key].value = parsedValue.concat(currentValue);
|
|
1695
|
+
}
|
|
1696
|
+
} else {
|
|
1697
|
+
var _currentValue = output[key];
|
|
1698
|
+
var _parsedValue = parsedField;
|
|
1699
|
+
|
|
1700
|
+
if (joinValue) {
|
|
1701
|
+
output[key] = [_currentValue, _parsedValue].join(joinValue);
|
|
1702
|
+
} else {
|
|
1703
|
+
output[key] = _parsedValue.concat(_currentValue);
|
|
1704
|
+
}
|
|
1705
|
+
}
|
|
1706
|
+
} else {
|
|
1707
|
+
output[key] = parsedField;
|
|
1490
1708
|
}
|
|
1491
|
-
}
|
|
1709
|
+
});
|
|
1710
|
+
return output;
|
|
1711
|
+
};
|
|
1492
1712
|
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1713
|
+
var parseGroup = function parseGroup() {
|
|
1714
|
+
var group = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1715
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1716
|
+
var includeAttributes = options.includeAttributes,
|
|
1717
|
+
includeGroupAttributes = options.includeGroupAttributes,
|
|
1718
|
+
flat = options.flat,
|
|
1719
|
+
flatGroup = options.flatGroup,
|
|
1720
|
+
groupAsList = options.groupAsList,
|
|
1721
|
+
fieldAsList = options.fieldAsList;
|
|
1501
1722
|
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1723
|
+
var _group$field = group.field,
|
|
1724
|
+
fieldList = _group$field === void 0 ? [] : _group$field,
|
|
1725
|
+
_group$group = group.group,
|
|
1726
|
+
groupList = _group$group === void 0 ? [] : _group$group,
|
|
1727
|
+
attributes = _objectWithoutProperties__default["default"](group, _excluded2);
|
|
1505
1728
|
|
|
1506
|
-
|
|
1507
|
-
parsedContainerComponent.durationTimeCode = formatTimeCodeType(durationTimeCode);
|
|
1508
|
-
parsedContainerComponent.duration = parsedContainerComponent.durationTimeCode.toDuration();
|
|
1509
|
-
}
|
|
1729
|
+
var parsedFieldList = parseFieldList(fieldList, options); // eslint-disable-next-line no-use-before-define
|
|
1510
1730
|
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
}
|
|
1731
|
+
var parsedGroupList = parseGroupList(groupList, options);
|
|
1732
|
+
var output = {};
|
|
1514
1733
|
|
|
1515
|
-
if (
|
|
1516
|
-
|
|
1517
|
-
samples: startTimecode,
|
|
1518
|
-
timeBase: timeCodeTimeBase
|
|
1519
|
-
});
|
|
1734
|
+
if (includeAttributes || includeGroupAttributes) {
|
|
1735
|
+
Object.assign(output, attributes);
|
|
1520
1736
|
}
|
|
1521
1737
|
|
|
1522
|
-
if (
|
|
1523
|
-
|
|
1524
|
-
|
|
1738
|
+
if (flat || flatGroup) {
|
|
1739
|
+
if (groupAsList) {
|
|
1740
|
+
Object.assign(output, {
|
|
1741
|
+
group: parsedGroupList
|
|
1742
|
+
});
|
|
1743
|
+
} else {
|
|
1744
|
+
Object.assign(output, parsedGroupList);
|
|
1745
|
+
}
|
|
1525
1746
|
|
|
1526
|
-
|
|
1527
|
-
|
|
1747
|
+
if (fieldAsList) {
|
|
1748
|
+
Object.assign(output, {
|
|
1749
|
+
field: parsedFieldList
|
|
1750
|
+
});
|
|
1751
|
+
} else {
|
|
1752
|
+
Object.assign(output, parsedFieldList);
|
|
1753
|
+
}
|
|
1754
|
+
} else {
|
|
1755
|
+
Object.assign(output, {
|
|
1756
|
+
field: parsedFieldList
|
|
1757
|
+
});
|
|
1758
|
+
Object.assign(output, {
|
|
1759
|
+
group: parsedGroupList
|
|
1760
|
+
});
|
|
1528
1761
|
}
|
|
1529
1762
|
|
|
1530
|
-
return
|
|
1763
|
+
return output;
|
|
1531
1764
|
};
|
|
1532
1765
|
|
|
1533
|
-
var
|
|
1534
|
-
var
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
_videoComponent$resol = videoComponent.resolution,
|
|
1538
|
-
resolution = _videoComponent$resol === void 0 ? {} : _videoComponent$resol,
|
|
1539
|
-
_videoComponent$media = videoComponent.mediaInfo,
|
|
1540
|
-
mediaInfo = _videoComponent$media === void 0 ? {} : _videoComponent$media,
|
|
1541
|
-
_videoComponent$metad = videoComponent.metadata,
|
|
1542
|
-
metadata = _videoComponent$metad === void 0 ? [] : _videoComponent$metad;
|
|
1543
|
-
var videoMediaInfo = parseBaseMediaInfoType(mediaInfo);
|
|
1544
|
-
var videoMetadata = parseKeyValuePairType(metadata);
|
|
1545
|
-
var videoFormat = videoMediaInfo.Format,
|
|
1546
|
-
timeBaseText = videoMediaInfo['Frame rate'],
|
|
1547
|
-
colorSpace = videoMediaInfo['Color space'],
|
|
1548
|
-
colorPrimaries = videoMediaInfo['Color primaries'],
|
|
1549
|
-
chromaSubsampling = videoMediaInfo.Colorimetry;
|
|
1550
|
-
var timeBase;
|
|
1551
|
-
var averageFrameRate = videoComponent.averageFrameRate,
|
|
1552
|
-
realBaseFrameRate = videoComponent.realBaseFrameRate;
|
|
1766
|
+
var parseGroupList = function parseGroupList() {
|
|
1767
|
+
var groupList = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
1768
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1769
|
+
var groupAsList = options.groupAsList;
|
|
1553
1770
|
|
|
1554
|
-
if (
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
};
|
|
1559
|
-
} else if (timeBaseText !== undefined) {
|
|
1560
|
-
timeBase = formatTimeBaseText(timeBaseText);
|
|
1561
|
-
} else if (averageFrameRate !== undefined) {
|
|
1562
|
-
timeBase = {
|
|
1563
|
-
numerator: averageFrameRate.denominator,
|
|
1564
|
-
denominator: averageFrameRate.numerator
|
|
1565
|
-
};
|
|
1771
|
+
if (groupAsList) {
|
|
1772
|
+
return groupList.map(function (thisGroup) {
|
|
1773
|
+
return parseGroup(thisGroup, options);
|
|
1774
|
+
});
|
|
1566
1775
|
}
|
|
1567
1776
|
|
|
1568
|
-
var
|
|
1777
|
+
var output = {};
|
|
1778
|
+
groupList.forEach(function (thisGroup) {
|
|
1779
|
+
var key = thisGroup.name;
|
|
1780
|
+
var parsedGroup = parseGroup(thisGroup, options);
|
|
1569
1781
|
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1782
|
+
if (output[key]) {
|
|
1783
|
+
var _output$key = output[key],
|
|
1784
|
+
currentField = _output$key.field,
|
|
1785
|
+
currentGroup = _output$key.group;
|
|
1786
|
+
var parsedField = parsedGroup.field,
|
|
1787
|
+
parsedGroupList = parsedGroup.group;
|
|
1788
|
+
output[key].field = _objectSpread$4(_objectSpread$4({}, currentField), parsedField);
|
|
1789
|
+
output[key].group = _objectSpread$4(_objectSpread$4({}, currentGroup), parsedGroupList);
|
|
1790
|
+
} else {
|
|
1791
|
+
output[key] = parsedGroup;
|
|
1792
|
+
}
|
|
1793
|
+
});
|
|
1794
|
+
return output;
|
|
1795
|
+
};
|
|
1796
|
+
/**
|
|
1797
|
+
* Parses timespan according to specified options.
|
|
1798
|
+
* The attributes can be targeted for each sub-type.
|
|
1799
|
+
* @param {Object} timespan={} - The timespan response from the API.
|
|
1800
|
+
* @param {Object} options={} - Options which change how the metadataType is parsed.
|
|
1801
|
+
* @param {string} options.joinValue=undefined - String to join the values, eg ','.
|
|
1802
|
+
* @param {boolean} options.includeAttributes=false - Include attributes on all objects.
|
|
1803
|
+
* @param {boolean} options.includeTimespanAttributes=false - Include attributes on timespans.
|
|
1804
|
+
* @param {boolean} options.includeGroupAttributes=false - Include attributes on groups.
|
|
1805
|
+
* @param {boolean} options.includeFieldAttributes=false - Include attributes on fields.
|
|
1806
|
+
* @param {boolean} options.includeValueAttributes=false - Include attributes on values.
|
|
1807
|
+
* @param {boolean} options.flat=false - Flatten to key/value (Note: keys may be overwritten).
|
|
1808
|
+
* @param {boolean} options.flatTimespan=false - Flatten timespan.
|
|
1809
|
+
* @param {boolean} options.flatGroup=false - Flatten group.
|
|
1810
|
+
* @param {boolean} options.groupAsList=false - Return groups as list.
|
|
1811
|
+
* @param {boolean} options.fieldAsList=false - Return fields as list.
|
|
1812
|
+
* @param {boolean} options.arrayOnSingle=true - Return fields as array even if single field.
|
|
1813
|
+
* @param {boolean} options.arrayOnSingleValue=true - Return fields as array even if single field value.
|
|
1814
|
+
* @returns {Object} Metadata object parsed according to options.
|
|
1815
|
+
*/
|
|
1574
1816
|
|
|
1575
|
-
var timeCode;
|
|
1576
|
-
var frameRate;
|
|
1577
|
-
var smpte;
|
|
1578
1817
|
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1818
|
+
var parseTimespan = function parseTimespan() {
|
|
1819
|
+
var timespan = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1820
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1821
|
+
var includeAttributes = options.includeAttributes,
|
|
1822
|
+
includeTimespanAttributes = options.includeTimespanAttributes,
|
|
1823
|
+
flat = options.flat,
|
|
1824
|
+
flatTimespan = options.flatTimespan,
|
|
1825
|
+
groupAsList = options.groupAsList,
|
|
1826
|
+
fieldAsList = options.fieldAsList;
|
|
1827
|
+
|
|
1828
|
+
var _timespan$field = timespan.field,
|
|
1829
|
+
fieldList = _timespan$field === void 0 ? [] : _timespan$field,
|
|
1830
|
+
_timespan$group = timespan.group,
|
|
1831
|
+
groupList = _timespan$group === void 0 ? [] : _timespan$group,
|
|
1832
|
+
attributes = _objectWithoutProperties__default["default"](timespan, _excluded3);
|
|
1833
|
+
|
|
1834
|
+
var field = parseFieldList(fieldList, options);
|
|
1835
|
+
var group = parseGroupList(groupList, options);
|
|
1836
|
+
var output = {};
|
|
1837
|
+
|
|
1838
|
+
if (includeAttributes || includeTimespanAttributes) {
|
|
1839
|
+
Object.assign(output, attributes);
|
|
1586
1840
|
}
|
|
1587
1841
|
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
var videoBitrate = bitrate ? filesize(bitrate, {
|
|
1593
|
-
bits: true
|
|
1594
|
-
}) : undefined;
|
|
1595
|
-
return {
|
|
1596
|
-
videoFormat: videoFormat,
|
|
1597
|
-
dimension: dimension,
|
|
1598
|
-
frameRate: frameRate,
|
|
1599
|
-
height: height,
|
|
1600
|
-
width: width,
|
|
1601
|
-
timeBase: timeBase,
|
|
1602
|
-
timeCode: timeCode,
|
|
1603
|
-
videoCodec: videoCodec,
|
|
1604
|
-
smpte: smpte,
|
|
1605
|
-
videoBitrate: videoBitrate,
|
|
1606
|
-
fieldOrder: fieldOrder,
|
|
1607
|
-
colorSpace: colorSpace,
|
|
1608
|
-
chromaSubsampling: chromaSubsampling,
|
|
1609
|
-
aspectRatio: aspectRatio,
|
|
1610
|
-
colorPrimaries: colorPrimaries,
|
|
1611
|
-
videoMetadata: videoMetadata,
|
|
1612
|
-
videoMediaInfo: videoMediaInfo
|
|
1613
|
-
};
|
|
1614
|
-
};
|
|
1615
|
-
|
|
1616
|
-
var parseAudioComponent = function parseAudioComponent(audioComponent) {
|
|
1617
|
-
var _audioComponent$timeB = audioComponent.timeBase,
|
|
1618
|
-
timeBase = _audioComponent$timeB === void 0 ? {} : _audioComponent$timeB,
|
|
1619
|
-
audioChannels = audioComponent.channelCount,
|
|
1620
|
-
audioCodec = audioComponent.codec,
|
|
1621
|
-
_audioComponent$media = audioComponent.mediaInfo,
|
|
1622
|
-
mediaInfo = _audioComponent$media === void 0 ? {} : _audioComponent$media,
|
|
1623
|
-
bitrate = audioComponent.bitrate,
|
|
1624
|
-
_audioComponent$metad = audioComponent.metadata,
|
|
1625
|
-
metadata = _audioComponent$metad === void 0 ? [] : _audioComponent$metad;
|
|
1626
|
-
var audioMediaInfo = parseBaseMediaInfoType(mediaInfo);
|
|
1627
|
-
var audioMetadata = parseKeyValuePairType(metadata);
|
|
1628
|
-
var audioFormat = audioMediaInfo.Format,
|
|
1629
|
-
audioBitDepth = audioMediaInfo.Resolution,
|
|
1630
|
-
audioBitRateMode = audioMediaInfo.Bit_rate_mode;
|
|
1631
|
-
var audioSamplerateSamples = timeBase.denominator ? timeBase.denominator / timeBase.numerator : undefined;
|
|
1632
|
-
var audioSamplerate = audioSamplerateSamples ? filesize(audioSamplerateSamples, {
|
|
1633
|
-
base: 10,
|
|
1634
|
-
round: 1,
|
|
1635
|
-
symbols: sampleRateSymbols
|
|
1636
|
-
}) : undefined;
|
|
1637
|
-
var audioBitrate = bitrate ? filesize(bitrate, {
|
|
1638
|
-
base: 10,
|
|
1639
|
-
round: 2,
|
|
1640
|
-
symbols: bitRateSymbols
|
|
1641
|
-
}) : undefined;
|
|
1642
|
-
return {
|
|
1643
|
-
audioFormat: audioFormat,
|
|
1644
|
-
audioCodec: audioCodec,
|
|
1645
|
-
audioSamplerate: audioSamplerate,
|
|
1646
|
-
audioSamplerateSamples: audioSamplerateSamples,
|
|
1647
|
-
audioBitDepth: audioBitDepth,
|
|
1648
|
-
audioBitrate: audioBitrate,
|
|
1649
|
-
audioBitRateMode: audioBitRateMode,
|
|
1650
|
-
audioChannels: audioChannels,
|
|
1651
|
-
audioMediaInfo: audioMediaInfo,
|
|
1652
|
-
audioMetadata: audioMetadata
|
|
1653
|
-
};
|
|
1654
|
-
};
|
|
1655
|
-
|
|
1656
|
-
var parseBinaryComponent = function parseBinaryComponent(binaryComponent) {
|
|
1657
|
-
var fileList = binaryComponent.file,
|
|
1658
|
-
_binaryComponent$medi = binaryComponent.mediaInfo,
|
|
1659
|
-
mediaInfo = _binaryComponent$medi === void 0 ? {} : _binaryComponent$medi,
|
|
1660
|
-
_binaryComponent$meta = binaryComponent.metadata,
|
|
1661
|
-
metadata = _binaryComponent$meta === void 0 ? [] : _binaryComponent$meta;
|
|
1662
|
-
var binaryMetadata = parseKeyValuePairType(metadata);
|
|
1663
|
-
var binaryMediaInfo = parseBaseMediaInfoType(mediaInfo);
|
|
1664
|
-
var parsedBinaryComponent = {
|
|
1665
|
-
binaryMetadata: binaryMetadata,
|
|
1666
|
-
binaryMediaInfo: binaryMediaInfo
|
|
1667
|
-
};
|
|
1668
|
-
|
|
1669
|
-
if (fileList) {
|
|
1670
|
-
var _fileList2 = _slicedToArray(fileList, 1),
|
|
1671
|
-
fileType = _fileList2[0];
|
|
1672
|
-
|
|
1673
|
-
var parsedFileType = parseFileType(fileType);
|
|
1674
|
-
parsedBinaryComponent = _objectSpread2(_objectSpread2({}, parsedBinaryComponent), parsedFileType);
|
|
1675
|
-
}
|
|
1676
|
-
|
|
1677
|
-
return parsedBinaryComponent;
|
|
1678
|
-
};
|
|
1679
|
-
|
|
1680
|
-
var parseShapeType = function parseShapeType() {
|
|
1681
|
-
var shapeType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1682
|
-
var parsedShape = {};
|
|
1683
|
-
var containerComponent = shapeType.containerComponent,
|
|
1684
|
-
videoComponentList = shapeType.videoComponent,
|
|
1685
|
-
audioComponentList = shapeType.audioComponent,
|
|
1686
|
-
binaryComponentList = shapeType.binaryComponent,
|
|
1687
|
-
_shapeType$mimeType = shapeType.mimeType,
|
|
1688
|
-
mimeTypeList = _shapeType$mimeType === void 0 ? [] : _shapeType$mimeType,
|
|
1689
|
-
_shapeType$tag = shapeType.tag,
|
|
1690
|
-
tagList = _shapeType$tag === void 0 ? [] : _shapeType$tag;
|
|
1691
|
-
|
|
1692
|
-
var _tagList = _slicedToArray(tagList, 1);
|
|
1693
|
-
|
|
1694
|
-
parsedShape.tag = _tagList[0];
|
|
1695
|
-
|
|
1696
|
-
var _mimeTypeList = _slicedToArray(mimeTypeList, 1);
|
|
1697
|
-
|
|
1698
|
-
parsedShape.mimeType = _mimeTypeList[0];
|
|
1699
|
-
|
|
1700
|
-
if (containerComponent) {
|
|
1701
|
-
var parsedContainerComponent = parseContainerComponent(containerComponent);
|
|
1702
|
-
parsedShape = _objectSpread2(_objectSpread2({}, parsedShape), parsedContainerComponent);
|
|
1703
|
-
}
|
|
1704
|
-
|
|
1705
|
-
if (videoComponentList) {
|
|
1706
|
-
var _videoComponentList = _slicedToArray(videoComponentList, 1),
|
|
1707
|
-
videoComponent = _videoComponentList[0];
|
|
1708
|
-
|
|
1709
|
-
var parsedVideoComponent = parseVideoComponent(videoComponent);
|
|
1710
|
-
parsedShape = _objectSpread2(_objectSpread2({}, parsedShape), parsedVideoComponent);
|
|
1711
|
-
}
|
|
1712
|
-
|
|
1713
|
-
if (audioComponentList) {
|
|
1714
|
-
var _audioComponentList = _slicedToArray(audioComponentList, 1),
|
|
1715
|
-
audioComponent = _audioComponentList[0];
|
|
1716
|
-
|
|
1717
|
-
var parsedAudioComponent = parseAudioComponent(audioComponent);
|
|
1718
|
-
parsedShape = _objectSpread2(_objectSpread2({}, parsedShape), parsedAudioComponent);
|
|
1719
|
-
}
|
|
1720
|
-
|
|
1721
|
-
if (binaryComponentList) {
|
|
1722
|
-
var _binaryComponentList = _slicedToArray(binaryComponentList, 1),
|
|
1723
|
-
binaryComponent = _binaryComponentList[0];
|
|
1724
|
-
|
|
1725
|
-
var parsedBinaryComponent = parseBinaryComponent(binaryComponent);
|
|
1726
|
-
parsedShape = _objectSpread2(_objectSpread2({}, parsedShape), parsedBinaryComponent);
|
|
1727
|
-
}
|
|
1728
|
-
|
|
1729
|
-
return parsedShape;
|
|
1730
|
-
};
|
|
1731
|
-
|
|
1732
|
-
var _excluded$2 = ["Codec"],
|
|
1733
|
-
_excluded2$1 = ["Codec"];
|
|
1734
|
-
|
|
1735
|
-
var parseMediaConvertPreset = function parseMediaConvertPreset(transcodePresetType) {
|
|
1736
|
-
var output = {};
|
|
1737
|
-
var description = transcodePresetType.description,
|
|
1738
|
-
_transcodePresetType$ = transcodePresetType.mediaconvert;
|
|
1739
|
-
_transcodePresetType$ = _transcodePresetType$ === void 0 ? {} : _transcodePresetType$;
|
|
1740
|
-
var _transcodePresetType$2 = _transcodePresetType$.outputSetting,
|
|
1741
|
-
outputSetting = _transcodePresetType$2 === void 0 ? [] : _transcodePresetType$2;
|
|
1742
|
-
output.description = description;
|
|
1743
|
-
if (outputSetting.length === 0) return output;
|
|
1744
|
-
var mc = JSON.parse(outputSetting[0]);
|
|
1745
|
-
var _mc$Settings = mc.Settings;
|
|
1746
|
-
_mc$Settings = _mc$Settings === void 0 ? {} : _mc$Settings;
|
|
1747
|
-
var ContainerSettings = _mc$Settings.ContainerSettings,
|
|
1748
|
-
VideoDescription = _mc$Settings.VideoDescription,
|
|
1749
|
-
AudioDescriptions = _mc$Settings.AudioDescriptions;
|
|
1750
|
-
output.containerFormat = ContainerSettings.Container;
|
|
1751
|
-
|
|
1752
|
-
if (ContainerSettings) {
|
|
1753
|
-
output.containerFormat = ContainerSettings.Container;
|
|
1754
|
-
}
|
|
1755
|
-
|
|
1756
|
-
if (VideoDescription) {
|
|
1757
|
-
var _VideoDescription$Cod = VideoDescription.CodecSettings,
|
|
1758
|
-
CodecSettings = _VideoDescription$Cod === void 0 ? {} : _VideoDescription$Cod;
|
|
1759
|
-
|
|
1760
|
-
var Codec = CodecSettings.Codec,
|
|
1761
|
-
otherSettings = _objectWithoutProperties(CodecSettings, _excluded$2);
|
|
1762
|
-
|
|
1763
|
-
output.videoFormat = Codec;
|
|
1764
|
-
var height = VideoDescription.Height,
|
|
1765
|
-
width = VideoDescription.Width;
|
|
1766
|
-
output.height = height;
|
|
1767
|
-
output.width = width;
|
|
1768
|
-
|
|
1769
|
-
if (height && width) {
|
|
1770
|
-
output.dimension = "".concat(width, "x").concat(height);
|
|
1771
|
-
output.aspectRatio = parseAspectRatio({
|
|
1772
|
-
height: height,
|
|
1773
|
-
width: width
|
|
1842
|
+
if (flat || flatTimespan) {
|
|
1843
|
+
if (groupAsList) {
|
|
1844
|
+
Object.assign(output, {
|
|
1845
|
+
group: group
|
|
1774
1846
|
});
|
|
1847
|
+
} else {
|
|
1848
|
+
Object.assign(output, group);
|
|
1775
1849
|
}
|
|
1776
1850
|
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
if (codecSpecs) {
|
|
1782
|
-
output.fieldOrder = codecSpecs.InterlaceMode;
|
|
1783
|
-
if (output.fieldOrder && output.fieldOrder.includes('TOP')) output.fieldOrder = 'interlaced';
|
|
1784
|
-
output.videoBitrate = codecSpecs.Bitrate;
|
|
1785
|
-
var numerator = codecSpecs.FramerateDenominator; // other way round to vs ¯\_(ツ)_/¯
|
|
1786
|
-
|
|
1787
|
-
var denominator = codecSpecs.FramerateNumerator;
|
|
1788
|
-
var timeBase = formatTimeBaseType({
|
|
1789
|
-
denominator: denominator,
|
|
1790
|
-
numerator: numerator
|
|
1851
|
+
if (fieldAsList) {
|
|
1852
|
+
Object.assign(output, {
|
|
1853
|
+
field: field
|
|
1791
1854
|
});
|
|
1792
|
-
|
|
1793
|
-
output
|
|
1855
|
+
} else {
|
|
1856
|
+
Object.assign(output, field);
|
|
1794
1857
|
}
|
|
1858
|
+
} else {
|
|
1859
|
+
Object.assign(output, {
|
|
1860
|
+
field: field
|
|
1861
|
+
});
|
|
1862
|
+
Object.assign(output, {
|
|
1863
|
+
group: group
|
|
1864
|
+
});
|
|
1795
1865
|
}
|
|
1796
1866
|
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
_CodecSettings = _AudioDescriptions$0$ === void 0 ? {} : _AudioDescriptions$0$;
|
|
1867
|
+
return output;
|
|
1868
|
+
};
|
|
1800
1869
|
|
|
1801
|
-
|
|
1802
|
-
_otherSettings = _objectWithoutProperties(_CodecSettings, _excluded2$1);
|
|
1870
|
+
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; }
|
|
1803
1871
|
|
|
1804
|
-
|
|
1872
|
+
function _objectSpread$3(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$3(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$3(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
1873
|
+
/**
|
|
1874
|
+
* Parses timespanList according to specified options.
|
|
1875
|
+
* The attributes can be targeted for each sub-type.
|
|
1876
|
+
* @param {Object[]} timespanList - The timespanList response from the API.
|
|
1877
|
+
* @param {Object} options - Options which change how the metadataType is parsed.
|
|
1878
|
+
* @param {string} options.joinValue - String to join the values, eg ','.
|
|
1879
|
+
* @param {boolean} options.includeAttributes - Include attributes on all objects.
|
|
1880
|
+
* @param {boolean} options.includeMetadataAttributes - Include attributes on root.
|
|
1881
|
+
* @param {boolean} options.includeTimespanAttributes - Include attributes on timespans.
|
|
1882
|
+
* @param {boolean} options.includeGroupAttributes - Include attributes on groups.
|
|
1883
|
+
* @param {boolean} options.includeFieldAttributes - Include attributes on fields.
|
|
1884
|
+
* @param {boolean} options.includeValueAttributes - Include attributes on values.
|
|
1885
|
+
* @param {boolean} options.flat - Flatten to key/value (Note: keys may be overwritten).
|
|
1886
|
+
* @param {boolean} options.flatTimespan - Flatten timespan.
|
|
1887
|
+
* @param {boolean} options.flatGroup - Flatten group.
|
|
1888
|
+
* @param {boolean} options.sortTimespan - Sort timespan by start time.
|
|
1889
|
+
* @param {boolean} options.timespanAsList - Return timespans as list.
|
|
1890
|
+
* @param {boolean} options.groupAsList - Return groups as list.
|
|
1891
|
+
* @param {boolean} options.fieldAsList - Return fields as list.
|
|
1892
|
+
* @param {boolean} options.arrayOnSingle=true - Return fields as array even if single field.
|
|
1893
|
+
* @param {boolean} options.arrayOnSingleValue=true - Return fields as array even if single field value.
|
|
1894
|
+
* @returns {Object} Metadata object parsed according to options.
|
|
1895
|
+
*/
|
|
1805
1896
|
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1897
|
+
var parseTimespanList = function parseTimespanList() {
|
|
1898
|
+
var timespanList = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
1899
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1900
|
+
var joinTimespan = options.joinTimespan,
|
|
1901
|
+
flat = options.flat;
|
|
1902
|
+
var timespanAsList = options.timespanAsList;
|
|
1809
1903
|
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
}
|
|
1904
|
+
if (timespanAsList) {
|
|
1905
|
+
return timespanList.map(function (thisTimespan) {
|
|
1906
|
+
return parseTimespan(thisTimespan, options);
|
|
1907
|
+
});
|
|
1815
1908
|
}
|
|
1816
1909
|
|
|
1817
|
-
return output;
|
|
1818
|
-
};
|
|
1819
|
-
|
|
1820
|
-
var parseTranscodePreset = function parseTranscodePreset(transcodePresetType) {
|
|
1821
1910
|
var output = {};
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
if (mediaconvert) return parseMediaConvertPreset(transcodePresetType);
|
|
1828
|
-
output.description = description;
|
|
1829
|
-
output.containerFormat = format;
|
|
1830
|
-
|
|
1831
|
-
if (video) {
|
|
1832
|
-
output.videoFormat = video.codec;
|
|
1833
|
-
output.videoBitrate = video.bitrate;
|
|
1834
|
-
|
|
1835
|
-
if (video.framerate) {
|
|
1836
|
-
var timeBase = formatTimeBaseType(video.framerate);
|
|
1837
|
-
output.timeBase = timeBase;
|
|
1838
|
-
output.frameRate = timeBase.toRate(true);
|
|
1839
|
-
}
|
|
1911
|
+
timespanList.forEach(function (thisTimespan) {
|
|
1912
|
+
var start = thisTimespan.start,
|
|
1913
|
+
end = thisTimespan.end;
|
|
1914
|
+
var key = [start, end].join(joinTimespan || '_');
|
|
1915
|
+
var parsedTimespan = parseTimespan(thisTimespan, options);
|
|
1840
1916
|
|
|
1841
|
-
if (
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
height: height,
|
|
1852
|
-
width: width
|
|
1853
|
-
});
|
|
1854
|
-
}
|
|
1855
|
-
}
|
|
1856
|
-
}
|
|
1857
|
-
|
|
1858
|
-
if (audio) {
|
|
1859
|
-
var audioFormat = audio.codec,
|
|
1860
|
-
channel = audio.channel;
|
|
1861
|
-
output.audioFormat = audioFormat;
|
|
1862
|
-
if (channel) output.audioChannels = channel.length;
|
|
1863
|
-
}
|
|
1864
|
-
|
|
1865
|
-
return output;
|
|
1866
|
-
};
|
|
1867
|
-
|
|
1868
|
-
var parseFacetType = function parseFacetType() {
|
|
1869
|
-
var facetType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
1870
|
-
var output = {};
|
|
1871
|
-
|
|
1872
|
-
var facetFieldReducer = function facetFieldReducer(a, _ref) {
|
|
1873
|
-
var fieldValue = _ref.fieldValue,
|
|
1874
|
-
value = _ref.value;
|
|
1875
|
-
return _objectSpread2(_objectSpread2({}, a), {}, _defineProperty({}, fieldValue, value));
|
|
1876
|
-
};
|
|
1877
|
-
|
|
1878
|
-
facetType.forEach(function (_ref2) {
|
|
1879
|
-
var name = _ref2.name,
|
|
1880
|
-
field = _ref2.field,
|
|
1881
|
-
count = _ref2.count;
|
|
1882
|
-
output[name || field] = count.reduce(facetFieldReducer, {});
|
|
1883
|
-
});
|
|
1884
|
-
return output;
|
|
1885
|
-
}; // eslint-disable-next-line import/prefer-default-export
|
|
1886
|
-
|
|
1887
|
-
/* Note that VS may calculate +/- unit in another way */
|
|
1888
|
-
var parseNowDate = function parseNowDate() {
|
|
1889
|
-
var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'NOW';
|
|
1890
|
-
|
|
1891
|
-
if (value.startsWith('NOW')) {
|
|
1892
|
-
if (value === 'NOW') return new Date();
|
|
1893
|
-
var sign = value[3];
|
|
1894
|
-
var number = Number(value.match(/(\d+)/)[0]);
|
|
1895
|
-
var unit = value.match(/(\d.*)/)[0].replace(/\d/g, '');
|
|
1896
|
-
var nowDiff = new Date(); // eslint-disable-next-line default-case
|
|
1897
|
-
|
|
1898
|
-
switch (unit) {
|
|
1899
|
-
case 'HOUR':
|
|
1900
|
-
case 'HOURS':
|
|
1901
|
-
if (sign === '+') nowDiff.setHours(nowDiff.getHours() + number);
|
|
1902
|
-
if (sign === '-') nowDiff.setHours(nowDiff.getHours() - number);
|
|
1903
|
-
break;
|
|
1904
|
-
|
|
1905
|
-
case 'DAY':
|
|
1906
|
-
case 'DAYS':
|
|
1907
|
-
if (sign === '+') nowDiff.setDate(nowDiff.getDate() + number);
|
|
1908
|
-
if (sign === '-') nowDiff.setDate(nowDiff.getDate() - number);
|
|
1909
|
-
break;
|
|
1910
|
-
|
|
1911
|
-
case 'MONTH':
|
|
1912
|
-
case 'MONTHS':
|
|
1913
|
-
if (sign === '+') nowDiff.setMonth(nowDiff.getMonth() + number);
|
|
1914
|
-
if (sign === '-') nowDiff.setMonth(nowDiff.getMonth() - number);
|
|
1915
|
-
break;
|
|
1916
|
-
|
|
1917
|
-
case 'YEAR':
|
|
1918
|
-
case 'YEARS':
|
|
1919
|
-
if (sign === '+') nowDiff.setFullYear(nowDiff.getFullYear() + number);
|
|
1920
|
-
if (sign === '-') nowDiff.setFullYear(nowDiff.getFullYear() - number);
|
|
1921
|
-
break;
|
|
1922
|
-
}
|
|
1923
|
-
|
|
1924
|
-
return nowDiff;
|
|
1925
|
-
}
|
|
1926
|
-
|
|
1927
|
-
return new Date(value);
|
|
1928
|
-
};
|
|
1929
|
-
|
|
1930
|
-
var createFacetType = function createFacetType() {
|
|
1931
|
-
var fieldList = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
1932
|
-
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1933
|
-
return fieldList.map(function (field) {
|
|
1934
|
-
return {
|
|
1935
|
-
field: field,
|
|
1936
|
-
name: field,
|
|
1937
|
-
count: options.count || true,
|
|
1938
|
-
exclude: fieldList
|
|
1939
|
-
};
|
|
1940
|
-
});
|
|
1941
|
-
}; // eslint-disable-next-line import/prefer-default-export
|
|
1942
|
-
|
|
1943
|
-
var _excluded$3 = ["groupName"],
|
|
1944
|
-
_excluded2$2 = ["start", "end"];
|
|
1945
|
-
|
|
1946
|
-
/* eslint-disable import/prefer-default-export */
|
|
1947
|
-
var parseValueList$1 = function parseValueList(value) {
|
|
1948
|
-
if (value === undefined) return [];
|
|
1949
|
-
if (value === null) return [{
|
|
1950
|
-
value: ''
|
|
1951
|
-
}];
|
|
1952
|
-
|
|
1953
|
-
if (Array.isArray(value)) {
|
|
1954
|
-
return value.map(function (valueOrObject) {
|
|
1955
|
-
if (_typeof(valueOrObject) === 'object') {
|
|
1956
|
-
return _objectSpread2({
|
|
1957
|
-
value: valueOrObject.value || ''
|
|
1958
|
-
}, valueOrObject);
|
|
1959
|
-
}
|
|
1960
|
-
|
|
1961
|
-
return {
|
|
1962
|
-
value: valueOrObject
|
|
1963
|
-
};
|
|
1964
|
-
});
|
|
1965
|
-
}
|
|
1966
|
-
|
|
1967
|
-
if (value.value) return [value];
|
|
1968
|
-
return [{
|
|
1969
|
-
value: value
|
|
1970
|
-
}];
|
|
1971
|
-
};
|
|
1972
|
-
|
|
1973
|
-
var parseValue = function parseValue() {
|
|
1974
|
-
var fieldValue = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1975
|
-
|
|
1976
|
-
if (fieldValue && (fieldValue.value || fieldValue.name)) {
|
|
1977
|
-
var valueList = fieldValue.value,
|
|
1978
|
-
uuid = fieldValue.uuid;
|
|
1979
|
-
var value = parseValueList$1(valueList);
|
|
1980
|
-
return {
|
|
1981
|
-
value: value,
|
|
1982
|
-
uuid: uuid
|
|
1983
|
-
};
|
|
1984
|
-
}
|
|
1985
|
-
|
|
1986
|
-
return {
|
|
1987
|
-
value: parseValueList$1(fieldValue)
|
|
1988
|
-
};
|
|
1989
|
-
};
|
|
1990
|
-
|
|
1991
|
-
var parseField$1 = function parseField() {
|
|
1992
|
-
var field = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1993
|
-
var name = field.name,
|
|
1994
|
-
value = field.value;
|
|
1995
|
-
var parsedValue = parseValue(value);
|
|
1996
|
-
return _objectSpread2({
|
|
1997
|
-
name: name
|
|
1998
|
-
}, parsedValue);
|
|
1999
|
-
};
|
|
2000
|
-
|
|
2001
|
-
var shouldBeField = function shouldBeField(_ref) {
|
|
2002
|
-
var name = _ref.name,
|
|
2003
|
-
value = _ref.value;
|
|
2004
|
-
return ['string', 'boolean', 'number'].includes(_typeof(value)) || name !== 'group' && Array.isArray(value) || value === null;
|
|
2005
|
-
};
|
|
2006
|
-
|
|
2007
|
-
var parseGroup$1 = function parseGroup() {
|
|
2008
|
-
var thisGroup = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
2009
|
-
var groupName = thisGroup.name,
|
|
2010
|
-
_thisGroup$value = thisGroup.value,
|
|
2011
|
-
groupsOrFields = _thisGroup$value === void 0 ? {} : _thisGroup$value; // eslint-disable-next-line no-use-before-define
|
|
2012
|
-
|
|
2013
|
-
var _parseGroupsOrFields = parseGroupsOrFields(groupsOrFields),
|
|
2014
|
-
field = _parseGroupsOrFields.field,
|
|
2015
|
-
group = _parseGroupsOrFields.group;
|
|
2016
|
-
|
|
2017
|
-
return {
|
|
2018
|
-
name: groupName,
|
|
2019
|
-
group: group,
|
|
2020
|
-
field: field
|
|
2021
|
-
};
|
|
2022
|
-
};
|
|
2023
|
-
|
|
2024
|
-
var parseGroupsOrFields = function parseGroupsOrFields(groupsOrFields) {
|
|
2025
|
-
var group = [];
|
|
2026
|
-
var field = [];
|
|
2027
|
-
Object.entries(groupsOrFields).forEach(function (_ref2) {
|
|
2028
|
-
var _ref3 = _slicedToArray(_ref2, 2),
|
|
2029
|
-
name = _ref3[0],
|
|
2030
|
-
value = _ref3[1];
|
|
2031
|
-
|
|
2032
|
-
if (shouldBeField({
|
|
2033
|
-
name: name,
|
|
2034
|
-
value: value
|
|
2035
|
-
})) {
|
|
2036
|
-
field.push(parseField$1({
|
|
2037
|
-
name: name,
|
|
2038
|
-
value: value
|
|
2039
|
-
}));
|
|
2040
|
-
} else if (Array.isArray(value)) {
|
|
2041
|
-
value.forEach(function (_ref4) {
|
|
2042
|
-
var groupName = _ref4.groupName,
|
|
2043
|
-
groupValue = _objectWithoutProperties(_ref4, _excluded$3);
|
|
2044
|
-
|
|
2045
|
-
// eslint-disable-next-line no-use-before-define
|
|
2046
|
-
group.push(parseGroup$1({
|
|
2047
|
-
name: groupName,
|
|
2048
|
-
value: groupValue
|
|
2049
|
-
}));
|
|
2050
|
-
});
|
|
1917
|
+
if (flat) {
|
|
1918
|
+
output = _objectSpread$3(_objectSpread$3({}, output), parsedTimespan);
|
|
1919
|
+
} else if (output[key]) {
|
|
1920
|
+
var _output$key = output[key],
|
|
1921
|
+
currentField = _output$key.field,
|
|
1922
|
+
currentGroup = _output$key.group;
|
|
1923
|
+
var parsedField = parsedTimespan.field,
|
|
1924
|
+
parsedGroup = parsedTimespan.group;
|
|
1925
|
+
output[key].field = _objectSpread$3(_objectSpread$3({}, currentField), parsedField);
|
|
1926
|
+
output[key].group = _objectSpread$3(_objectSpread$3({}, currentGroup), parsedGroup);
|
|
2051
1927
|
} else {
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
}
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
var
|
|
2085
|
-
var
|
|
2086
|
-
var
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
_ref$minutes = _ref.minutes,
|
|
2104
|
-
minutes = _ref$minutes === void 0 ? 0 : _ref$minutes,
|
|
2105
|
-
_ref$seconds = _ref.seconds,
|
|
2106
|
-
seconds = _ref$seconds === void 0 ? 0 : _ref$seconds,
|
|
2107
|
-
_ref$partialSeconds = _ref.partialSeconds,
|
|
2108
|
-
partialSeconds = _ref$partialSeconds === void 0 ? 0 : _ref$partialSeconds;
|
|
2109
|
-
var hourStr = hours.toFixed().padStart(2, '0');
|
|
2110
|
-
var minStr = minutes.toFixed().padStart(2, '0');
|
|
2111
|
-
var secondsStr = seconds.toFixed().padStart(2, '0');
|
|
2112
|
-
var partialStr = (partialSeconds * 10).toFixed().padStart(3, '0');
|
|
2113
|
-
return "".concat(hourStr, ":").concat(minStr, ":").concat(secondsStr, ".").concat(partialStr);
|
|
2114
|
-
}
|
|
2115
|
-
|
|
2116
|
-
function metadataTypeToWebVtt(_ref2) {
|
|
2117
|
-
var metadataType = _ref2.metadataType,
|
|
2118
|
-
_ref2$subtitleGroup = _ref2.subtitleGroup,
|
|
2119
|
-
subtitleGroup = _ref2$subtitleGroup === void 0 ? 'stl_subtitle' : _ref2$subtitleGroup,
|
|
2120
|
-
_ref2$subtitleField = _ref2.subtitleField,
|
|
2121
|
-
subtitleField = _ref2$subtitleField === void 0 ? 'stl_text' : _ref2$subtitleField;
|
|
2122
|
-
var parseOptions = {
|
|
2123
|
-
includeTimespanAttributes: true,
|
|
2124
|
-
flatTimespan: true,
|
|
2125
|
-
flatGroup: true,
|
|
2126
|
-
joinValue: ','
|
|
2127
|
-
};
|
|
2128
|
-
|
|
2129
|
-
var _ref3 = metadataType || {},
|
|
2130
|
-
_ref3$timespan = _ref3.timespan,
|
|
2131
|
-
timespanList = _ref3$timespan === void 0 ? [] : _ref3$timespan;
|
|
2132
|
-
|
|
2133
|
-
if (timespanList.length === 0) return '';
|
|
2134
|
-
var sortedTimespans = timespanList.sort(sortTimespanList);
|
|
2135
|
-
var parsedTimespans = sortedTimespans.map(function (timespanType) {
|
|
2136
|
-
return parseTimespan(timespanType, parseOptions);
|
|
2137
|
-
});
|
|
2138
|
-
var vttCues = parsedTimespans.map(function (thisTimespan) {
|
|
2139
|
-
var startText = thisTimespan.start,
|
|
2140
|
-
endText = thisTimespan.end,
|
|
2141
|
-
_thisTimespan$subtitl = thisTimespan[subtitleGroup];
|
|
2142
|
-
_thisTimespan$subtitl = _thisTimespan$subtitl === void 0 ? {} : _thisTimespan$subtitl;
|
|
2143
|
-
var text = _thisTimespan$subtitl[subtitleField];
|
|
2144
|
-
if (!text) return '';
|
|
2145
|
-
var startTime = formatTimeCodeText(startText).toTime();
|
|
2146
|
-
var start = timeToCueTime(startTime);
|
|
2147
|
-
var endTime = formatTimeCodeText(endText).toTime();
|
|
2148
|
-
var end = timeToCueTime(endTime);
|
|
2149
|
-
return "".concat(start, " --> ").concat(end, " line:0%\r").concat(text, "\r");
|
|
2150
|
-
});
|
|
2151
|
-
return "WEBVTT\n\n\n".concat(vttCues.join('\n'));
|
|
2152
|
-
}
|
|
2153
|
-
|
|
2154
|
-
var IMAGE_MIME_TYPES = ['image/apng', 'image/bmp', 'image/gif', 'image/jpeg', 'image/x-icon', 'image/png', 'image/svg+xml'];
|
|
2155
|
-
var VIDEO_MIME_TYPES = ['video/mp4'];
|
|
2156
|
-
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'];
|
|
2157
|
-
var DEFAULT_ALLOWED_MIME_TYPES = [].concat(VIDEO_MIME_TYPES, IMAGE_MIME_TYPES, AUDIO_MIME_TYPES);
|
|
2158
|
-
var DEFAULT_ALLOWED_METHODS = ['http', 'https'];
|
|
2159
|
-
var MP4_MIMETYPE = 'video/mp4';
|
|
2160
|
-
var QUICKTIME_MIMETYPE = 'video/quicktime';
|
|
2161
|
-
var M4V_MIMETYPE = 'video/x-m4v';
|
|
2162
|
-
var MP4_CONTAINER = 'MPEG-4';
|
|
2163
|
-
var MOV_CONTAINER = 'mov';
|
|
2164
|
-
var H264_CODEC = 'h264'; // Sort by tags in the order of previewShapeOrder, secondary alphabetical.
|
|
2165
|
-
// using reverse() so the first has highest index
|
|
2166
|
-
|
|
2167
|
-
var PREVIEW_SHAPE_ORDER = ['__mp4', '__mp3_160k', '__png', '__jpeg', '__gif', 'original'].reverse();
|
|
2168
|
-
|
|
2169
|
-
var defaultSortPriority = function defaultSortPriority(_ref, _ref2) {
|
|
2170
|
-
var firstEl = _ref.shape.tag;
|
|
2171
|
-
var secondEl = _ref2.shape.tag;
|
|
2172
|
-
|
|
2173
|
-
if (PREVIEW_SHAPE_ORDER.includes(firstEl) || PREVIEW_SHAPE_ORDER.includes(secondEl)) {
|
|
2174
|
-
return PREVIEW_SHAPE_ORDER.indexOf(secondEl) - PREVIEW_SHAPE_ORDER.indexOf(firstEl);
|
|
2175
|
-
}
|
|
2176
|
-
|
|
2177
|
-
return firstEl.toLowerCase().localeCompare(secondEl.toLowerCase());
|
|
2178
|
-
};
|
|
2179
|
-
|
|
2180
|
-
var filterShapeSource = function filterShapeSource() {
|
|
2181
|
-
var itemType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
2182
|
-
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
2183
|
-
var _options$allowedMimeT = options.allowedMimeTypes,
|
|
2184
|
-
allowedMimeTypes = _options$allowedMimeT === void 0 ? DEFAULT_ALLOWED_MIME_TYPES : _options$allowedMimeT,
|
|
2185
|
-
_options$sortPriority = options.sortPriority,
|
|
2186
|
-
sortPriority = _options$sortPriority === void 0 ? defaultSortPriority : _options$sortPriority,
|
|
2187
|
-
_options$allowedMetho = options.allowedMethods,
|
|
2188
|
-
allowedMethods = _options$allowedMetho === void 0 ? DEFAULT_ALLOWED_METHODS : _options$allowedMetho,
|
|
2189
|
-
_options$sourceKey = options.sourceKey,
|
|
2190
|
-
sourceKey = _options$sourceKey === void 0 ? 'src' : _options$sourceKey,
|
|
2191
|
-
_options$mimeTypeKey = options.mimeTypeKey,
|
|
2192
|
-
mimeTypeKey = _options$mimeTypeKey === void 0 ? 'type' : _options$mimeTypeKey,
|
|
2193
|
-
_options$shapeKey = options.shapeKey,
|
|
2194
|
-
shapeKey = _options$shapeKey === void 0 ? 'shape' : _options$shapeKey;
|
|
2195
|
-
var _itemType$shape = itemType.shape,
|
|
2196
|
-
shapeList = _itemType$shape === void 0 ? [] : _itemType$shape;
|
|
2197
|
-
var parsedShapeList = shapeList.reduce(function (acc, shapeType) {
|
|
2198
|
-
var type;
|
|
2199
|
-
var src;
|
|
2200
|
-
var shape = parseShapeType(shapeType);
|
|
2201
|
-
var uri = shape.uri,
|
|
2202
|
-
mimeType = shape.mimeType,
|
|
2203
|
-
containerFormat = shape.containerFormat,
|
|
2204
|
-
videoCodec = shape.videoCodec;
|
|
2205
|
-
|
|
2206
|
-
if (mimeType) {
|
|
2207
|
-
type = mimeType;
|
|
2208
|
-
if ((mimeType === QUICKTIME_MIMETYPE || mimeType === M4V_MIMETYPE) && (containerFormat === MP4_CONTAINER || containerFormat === MOV_CONTAINER) && videoCodec === H264_CODEC) type = MP4_MIMETYPE;
|
|
2209
|
-
}
|
|
2210
|
-
|
|
2211
|
-
if (uri) {
|
|
2212
|
-
if (allowedMethods) {
|
|
2213
|
-
var _uri$split = uri.split('://'),
|
|
2214
|
-
_uri$split2 = _slicedToArray(_uri$split, 1),
|
|
2215
|
-
thisMethod = _uri$split2[0];
|
|
2216
|
-
|
|
2217
|
-
if (allowedMethods.includes(thisMethod)) src = uri;
|
|
2218
|
-
} else {
|
|
2219
|
-
src = uri;
|
|
2220
|
-
}
|
|
2221
|
-
}
|
|
2222
|
-
|
|
2223
|
-
if (src && allowedMimeTypes.includes(type)) {
|
|
2224
|
-
var _acc$push;
|
|
2225
|
-
|
|
2226
|
-
acc.push((_acc$push = {}, _defineProperty(_acc$push, sourceKey, src), _defineProperty(_acc$push, mimeTypeKey, type), _defineProperty(_acc$push, shapeKey, shape), _acc$push));
|
|
2227
|
-
}
|
|
2228
|
-
|
|
2229
|
-
return acc;
|
|
2230
|
-
}, []);
|
|
2231
|
-
if (typeof sortPriority === 'function') parsedShapeList.sort(defaultSortPriority);
|
|
2232
|
-
return parsedShapeList;
|
|
2233
|
-
};
|
|
2234
|
-
|
|
2235
|
-
var IMAGE = 'IMAGE';
|
|
2236
|
-
var AUDIO = 'AUDIO';
|
|
2237
|
-
var VIDEO = 'VIDEO';
|
|
2238
|
-
var DOCUMENT = 'DOCUMENT';
|
|
2239
|
-
|
|
2240
|
-
var getShapeMediaType = function getShapeMediaType() {
|
|
2241
|
-
var shape = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
2242
|
-
var mimeType = shape.mimeType,
|
|
2243
|
-
videoCodec = shape.videoCodec,
|
|
2244
|
-
audioCodec = shape.audioCodec;
|
|
2245
|
-
if (!mimeType) return undefined;
|
|
2246
|
-
|
|
2247
|
-
if (mimeType.startsWith('audio/')) {
|
|
2248
|
-
if (audioCodec !== undefined) return AUDIO;
|
|
2249
|
-
}
|
|
2250
|
-
|
|
2251
|
-
if (mimeType.startsWith('video/')) {
|
|
2252
|
-
if (videoCodec !== undefined) return VIDEO;
|
|
2253
|
-
if (audioCodec !== undefined) return AUDIO;
|
|
2254
|
-
}
|
|
2255
|
-
|
|
2256
|
-
if (mimeType.startsWith('image/')) return IMAGE;
|
|
2257
|
-
if (mimeType.endsWith('/pdf')) return DOCUMENT;
|
|
2258
|
-
if (mimeType.startsWith('text/')) return DOCUMENT;
|
|
2259
|
-
if (mimeType.endsWith('/msword')) return DOCUMENT;
|
|
2260
|
-
if (mimeType.endsWith('/json')) return DOCUMENT;
|
|
2261
|
-
if (mimeType.endsWith('/xml')) return DOCUMENT;
|
|
2262
|
-
return undefined;
|
|
2263
|
-
};
|
|
2264
|
-
|
|
2265
|
-
var findNearestThumbnail = function findNearestThumbnail() {
|
|
2266
|
-
var itemType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
2267
|
-
var timeCodeText = arguments.length > 1 ? arguments[1] : undefined;
|
|
2268
|
-
var tcSeconds = formatTimeCodeText(timeCodeText).toSeconds();
|
|
2269
|
-
var _itemType$thumbnails = itemType.thumbnails,
|
|
2270
|
-
thumbnails = _itemType$thumbnails === void 0 ? {} : _itemType$thumbnails;
|
|
2271
|
-
var _thumbnails$uri = thumbnails.uri,
|
|
2272
|
-
srcList = _thumbnails$uri === void 0 ? [] : _thumbnails$uri;
|
|
2273
|
-
var srcTcSeconds = srcList.map(function (url) {
|
|
2274
|
-
var tc = new URL(url).pathname.split('/').pop();
|
|
2275
|
-
return formatTimeCodeText(tc).toSeconds();
|
|
2276
|
-
});
|
|
2277
|
-
var nearestSrcIndex = srcTcSeconds.reduce(function (nearestIndex, curr, currIndex) {
|
|
2278
|
-
return Math.abs(curr - tcSeconds) < Math.abs(srcTcSeconds[nearestIndex] - tcSeconds) ? currIndex : nearestIndex;
|
|
2279
|
-
}, 0);
|
|
2280
|
-
return srcList[nearestSrcIndex];
|
|
2281
|
-
};
|
|
2282
|
-
|
|
2283
|
-
var ACCESSCONTROL_READ = '_accesscontrol_read';
|
|
2284
|
-
var ACCESSCONTROL_WRITE = '_accesscontrol_write';
|
|
2285
|
-
var ADMINISTRATOR = '_administrator';
|
|
2286
|
-
var AUTO_PROJECTION_READ = '_auto_projection_read';
|
|
2287
|
-
var AUTO_PROJECTION_WRITE = '_auto_projection_write';
|
|
2288
|
-
var COLLECTION_NOTIFICATION_READ = '_collection_notification_read';
|
|
2289
|
-
var COLLECTION_NOTIFICATION_WRITE = '_collection_notification_write';
|
|
2290
|
-
var COLLECTION_READ = '_collection_read';
|
|
2291
|
-
var COLLECTION_WRITE = '_collection_write';
|
|
2292
|
-
var DELETION_LOCK_NOTIFICATION_READ = '_deletion_lock_notification_read';
|
|
2293
|
-
var DELETION_LOCK_NOTIFICATION_WRITE = '_deletion_lock_notification_write';
|
|
2294
|
-
var DELETION_LOCK_READ = '_deletion_lock_read';
|
|
2295
|
-
var DELETION_LOCK_WRITE = '_deletion_lock_write';
|
|
2296
|
-
var DOCUMENT_NOTIFICATION_READ = '_document_notification_read';
|
|
2297
|
-
var DOCUMENT_NOTIFICATION_WRITE = '_document_notification_write';
|
|
2298
|
-
var DOCUMENT_READ = '_document_read';
|
|
2299
|
-
var DOCUMENT_WRITE = '_document_write';
|
|
2300
|
-
var ERROR_READ = '_error_read';
|
|
2301
|
-
var ERROR_WRITE = '_error_write';
|
|
2302
|
-
var EXPORT = '_export';
|
|
2303
|
-
var EXPORT_TEMPLATE_READ = '_export_template_read';
|
|
2304
|
-
var EXPORT_TEMPLATE_WRITE = '_export_template_write';
|
|
2305
|
-
var EXTERNAL_ID_READ = '_external_id_read';
|
|
2306
|
-
var EXTERNAL_ID_WRITE = '_external_id_write';
|
|
2307
|
-
var FILE_NOTIFICATION_READ = '_file_notification_read';
|
|
2308
|
-
var FILE_NOTIFICATION_WRITE = '_file_notification_write';
|
|
2309
|
-
var FILE_READ = '_file_read';
|
|
2310
|
-
var FILE_WRITE = '_file_write';
|
|
2311
|
-
var GROUP_READ = '_group_read';
|
|
2312
|
-
var GROUP_WRITE = '_group_write';
|
|
2313
|
-
var IMPORT_WRITE = '_import';
|
|
2314
|
-
var ITEM_ID_READ = '_item_id_read';
|
|
2315
|
-
var ITEM_ID_WRITE = '_item_id_write';
|
|
2316
|
-
var ITEM_NOTIFICATION_READ = '_item_notification_read';
|
|
2317
|
-
var ITEM_NOTIFICATION_WRITE = '_item_notification_write';
|
|
2318
|
-
var ITEM_WRITE = '_item_write';
|
|
2319
|
-
var ITEM_SEARCH = '_item_search';
|
|
2320
|
-
var ITEM_SHAPE_READ = '_item_shape_read';
|
|
2321
|
-
var ITEM_SHAPE_WRITE = '_item_shape_write';
|
|
2322
|
-
var ITEM_TIMELINE_READ = '_item_timeline_read';
|
|
2323
|
-
var ITEM_TIMELINE_WRITE = '_item_timeline_write';
|
|
2324
|
-
var ITEM_URI = '_item_uri';
|
|
2325
|
-
var JOB_NOTIFICATION_READ = '_job_notification_read';
|
|
2326
|
-
var JOB_NOTIFICATION_WRITE = '_job_notification_write';
|
|
2327
|
-
var JOB_READ = '_job_read';
|
|
2328
|
-
var JOB_WRITE = '_job_write';
|
|
2329
|
-
var LIBRARY_READ = '_library_read';
|
|
2330
|
-
var LIBRARY_WRITE = '_library_write';
|
|
2331
|
-
var LOCK_READ = '_lock_read';
|
|
2332
|
-
var LOCK_WRITE = '_lock_write';
|
|
2333
|
-
var LOG_READ = '_log_read';
|
|
2334
|
-
var METADATA_DATASET_READ = '_metadata_dataset_read';
|
|
2335
|
-
var METADATA_DATASET_WRITE = '_metadata_dataset_write';
|
|
2336
|
-
var METADATA_FIELD_GROUP_READ = '_metadata_field_group_read';
|
|
2337
|
-
var METADATA_FIELD_GROUP_WRITE = '_metadata_field_group_write';
|
|
2338
|
-
var METADATA_FIELD_READ = '_metadata_field_read';
|
|
2339
|
-
var METADATA_FIELD_WRITE = '_metadata_field_write';
|
|
2340
|
-
var METADATA_GLOBAL_READ = '_metadata_global_read';
|
|
2341
|
-
var METADATA_GLOBAL_WRITE = '_metadata_global_write';
|
|
2342
|
-
var METADATA_LOCK_READ = '_metadata_lock_read';
|
|
2343
|
-
var METADATA_LOCK_WRITE = '_metadata_lock_write';
|
|
2344
|
-
var METADATA_READ = '_metadata_read';
|
|
2345
|
-
var METADATA_SCHEMA_READ = '_metadata_schema_read';
|
|
2346
|
-
var METADATA_SCHEMA_WRITE = '_metadata_schema_write';
|
|
2347
|
-
var METADATA_WRITE = '_metadata_write';
|
|
2348
|
-
var OTIF_ANALYZE = '_otif_analyze';
|
|
2349
|
-
var OTIF_READ = '_otif_read';
|
|
2350
|
-
var OTIF_WRITE = '_otif_write';
|
|
2351
|
-
var PLACEHOLDER_NOTIFICATION_READ = '_placeholder_notification_read';
|
|
2352
|
-
var PLACEHOLDER_NOTIFICATION_WRITE = '_placeholder_notification_write';
|
|
2353
|
-
var PROJECTION_READ = '_projection_read';
|
|
2354
|
-
var PROJECTION_WRITE = '_projection_write';
|
|
2355
|
-
var QUOTA_NOTIFICATION_READ = '_quota_notification_read';
|
|
2356
|
-
var QUOTA_NOTIFICATION_WRITE = '_quota_notification_write';
|
|
2357
|
-
var QUOTA_READ = '_quota_read';
|
|
2358
|
-
var QUOTA_WRITE = '_quota_write';
|
|
2359
|
-
var RELATION_READ = '_relation_read';
|
|
2360
|
-
var RELATION_WRITE = '_relation_write';
|
|
2361
|
-
var RESOURCE_READ = '_resource_read';
|
|
2362
|
-
var RESOURCE_WRITE = '_resource_write';
|
|
2363
|
-
var RUN_AS = '_run_as';
|
|
2364
|
-
var SEARCH = '_search';
|
|
2365
|
-
var SEQUENCE_READ = '_sequence_read';
|
|
2366
|
-
var SEQUENCE_WRITE = '_sequence_write';
|
|
2367
|
-
var SHAPE_TAG_READ = '_shape_tag_read';
|
|
2368
|
-
var SHAPE_TAG_WRITE = '_shape_tag_write';
|
|
2369
|
-
var SITE_MANAGER = '_site_manager';
|
|
2370
|
-
var SITE_RULE_READ = '_site_rule_read';
|
|
2371
|
-
var SITE_RULE_WRITE = '_site_rule_write';
|
|
2372
|
-
var STORAGE_GROUP_READ = '_storage_group_read';
|
|
2373
|
-
var STORAGE_GROUP_WRITE = '_storage_group_write';
|
|
2374
|
-
var STORAGE_NOTIFICATION_READ = '_storage_notification_read';
|
|
2375
|
-
var STORAGE_NOTIFICATION_WRITE = '_storage_notification_write';
|
|
2376
|
-
var STORAGE_READ = '_storage_read';
|
|
2377
|
-
var STORAGE_RULE_READ = '_storage_rule_read';
|
|
2378
|
-
var STORAGE_RULE_WRITE = '_storage_rule_write';
|
|
2379
|
-
var STORAGE_WRITE = '_storage_write';
|
|
2380
|
-
var SUPER_ACCESS_USER = '_super_access_user';
|
|
2381
|
-
var TASKDEFINITION_READ = '_taskdefinition_read';
|
|
2382
|
-
var TASKDEFINITION_WRITE = '_taskdefinition_write';
|
|
2383
|
-
var THUMBNAIL_READ = '_thumbnail_read';
|
|
2384
|
-
var THUMBNAIL_WRITE = '_thumbnail_write';
|
|
2385
|
-
var TRANSCODER = '_transcoder';
|
|
2386
|
-
var TRANSFER_READ = '_transfer_read';
|
|
2387
|
-
var TRANSFER_WRITE = '_transfer_write';
|
|
2388
|
-
var USER = '_user';
|
|
2389
|
-
var VXA = '_vxa';
|
|
2390
|
-
var VXA_READ = '_vxa_read';
|
|
2391
|
-
|
|
2392
|
-
var roles = /*#__PURE__*/Object.freeze({
|
|
2393
|
-
__proto__: null,
|
|
2394
|
-
ACCESSCONTROL_READ: ACCESSCONTROL_READ,
|
|
2395
|
-
ACCESSCONTROL_WRITE: ACCESSCONTROL_WRITE,
|
|
2396
|
-
ADMINISTRATOR: ADMINISTRATOR,
|
|
2397
|
-
AUTO_PROJECTION_READ: AUTO_PROJECTION_READ,
|
|
2398
|
-
AUTO_PROJECTION_WRITE: AUTO_PROJECTION_WRITE,
|
|
2399
|
-
COLLECTION_NOTIFICATION_READ: COLLECTION_NOTIFICATION_READ,
|
|
2400
|
-
COLLECTION_NOTIFICATION_WRITE: COLLECTION_NOTIFICATION_WRITE,
|
|
2401
|
-
COLLECTION_READ: COLLECTION_READ,
|
|
2402
|
-
COLLECTION_WRITE: COLLECTION_WRITE,
|
|
2403
|
-
DELETION_LOCK_NOTIFICATION_READ: DELETION_LOCK_NOTIFICATION_READ,
|
|
2404
|
-
DELETION_LOCK_NOTIFICATION_WRITE: DELETION_LOCK_NOTIFICATION_WRITE,
|
|
2405
|
-
DELETION_LOCK_READ: DELETION_LOCK_READ,
|
|
2406
|
-
DELETION_LOCK_WRITE: DELETION_LOCK_WRITE,
|
|
2407
|
-
DOCUMENT_NOTIFICATION_READ: DOCUMENT_NOTIFICATION_READ,
|
|
2408
|
-
DOCUMENT_NOTIFICATION_WRITE: DOCUMENT_NOTIFICATION_WRITE,
|
|
2409
|
-
DOCUMENT_READ: DOCUMENT_READ,
|
|
2410
|
-
DOCUMENT_WRITE: DOCUMENT_WRITE,
|
|
2411
|
-
ERROR_READ: ERROR_READ,
|
|
2412
|
-
ERROR_WRITE: ERROR_WRITE,
|
|
2413
|
-
EXPORT: EXPORT,
|
|
2414
|
-
EXPORT_TEMPLATE_READ: EXPORT_TEMPLATE_READ,
|
|
2415
|
-
EXPORT_TEMPLATE_WRITE: EXPORT_TEMPLATE_WRITE,
|
|
2416
|
-
EXTERNAL_ID_READ: EXTERNAL_ID_READ,
|
|
2417
|
-
EXTERNAL_ID_WRITE: EXTERNAL_ID_WRITE,
|
|
2418
|
-
FILE_NOTIFICATION_READ: FILE_NOTIFICATION_READ,
|
|
2419
|
-
FILE_NOTIFICATION_WRITE: FILE_NOTIFICATION_WRITE,
|
|
2420
|
-
FILE_READ: FILE_READ,
|
|
2421
|
-
FILE_WRITE: FILE_WRITE,
|
|
2422
|
-
GROUP_READ: GROUP_READ,
|
|
2423
|
-
GROUP_WRITE: GROUP_WRITE,
|
|
2424
|
-
IMPORT_WRITE: IMPORT_WRITE,
|
|
2425
|
-
ITEM_ID_READ: ITEM_ID_READ,
|
|
2426
|
-
ITEM_ID_WRITE: ITEM_ID_WRITE,
|
|
2427
|
-
ITEM_NOTIFICATION_READ: ITEM_NOTIFICATION_READ,
|
|
2428
|
-
ITEM_NOTIFICATION_WRITE: ITEM_NOTIFICATION_WRITE,
|
|
2429
|
-
ITEM_WRITE: ITEM_WRITE,
|
|
2430
|
-
ITEM_SEARCH: ITEM_SEARCH,
|
|
2431
|
-
ITEM_SHAPE_READ: ITEM_SHAPE_READ,
|
|
2432
|
-
ITEM_SHAPE_WRITE: ITEM_SHAPE_WRITE,
|
|
2433
|
-
ITEM_TIMELINE_READ: ITEM_TIMELINE_READ,
|
|
2434
|
-
ITEM_TIMELINE_WRITE: ITEM_TIMELINE_WRITE,
|
|
2435
|
-
ITEM_URI: ITEM_URI,
|
|
2436
|
-
JOB_NOTIFICATION_READ: JOB_NOTIFICATION_READ,
|
|
2437
|
-
JOB_NOTIFICATION_WRITE: JOB_NOTIFICATION_WRITE,
|
|
2438
|
-
JOB_READ: JOB_READ,
|
|
2439
|
-
JOB_WRITE: JOB_WRITE,
|
|
2440
|
-
LIBRARY_READ: LIBRARY_READ,
|
|
2441
|
-
LIBRARY_WRITE: LIBRARY_WRITE,
|
|
2442
|
-
LOCK_READ: LOCK_READ,
|
|
2443
|
-
LOCK_WRITE: LOCK_WRITE,
|
|
2444
|
-
LOG_READ: LOG_READ,
|
|
2445
|
-
METADATA_DATASET_READ: METADATA_DATASET_READ,
|
|
2446
|
-
METADATA_DATASET_WRITE: METADATA_DATASET_WRITE,
|
|
2447
|
-
METADATA_FIELD_GROUP_READ: METADATA_FIELD_GROUP_READ,
|
|
2448
|
-
METADATA_FIELD_GROUP_WRITE: METADATA_FIELD_GROUP_WRITE,
|
|
2449
|
-
METADATA_FIELD_READ: METADATA_FIELD_READ,
|
|
2450
|
-
METADATA_FIELD_WRITE: METADATA_FIELD_WRITE,
|
|
2451
|
-
METADATA_GLOBAL_READ: METADATA_GLOBAL_READ,
|
|
2452
|
-
METADATA_GLOBAL_WRITE: METADATA_GLOBAL_WRITE,
|
|
2453
|
-
METADATA_LOCK_READ: METADATA_LOCK_READ,
|
|
2454
|
-
METADATA_LOCK_WRITE: METADATA_LOCK_WRITE,
|
|
2455
|
-
METADATA_READ: METADATA_READ,
|
|
2456
|
-
METADATA_SCHEMA_READ: METADATA_SCHEMA_READ,
|
|
2457
|
-
METADATA_SCHEMA_WRITE: METADATA_SCHEMA_WRITE,
|
|
2458
|
-
METADATA_WRITE: METADATA_WRITE,
|
|
2459
|
-
OTIF_ANALYZE: OTIF_ANALYZE,
|
|
2460
|
-
OTIF_READ: OTIF_READ,
|
|
2461
|
-
OTIF_WRITE: OTIF_WRITE,
|
|
2462
|
-
PLACEHOLDER_NOTIFICATION_READ: PLACEHOLDER_NOTIFICATION_READ,
|
|
2463
|
-
PLACEHOLDER_NOTIFICATION_WRITE: PLACEHOLDER_NOTIFICATION_WRITE,
|
|
2464
|
-
PROJECTION_READ: PROJECTION_READ,
|
|
2465
|
-
PROJECTION_WRITE: PROJECTION_WRITE,
|
|
2466
|
-
QUOTA_NOTIFICATION_READ: QUOTA_NOTIFICATION_READ,
|
|
2467
|
-
QUOTA_NOTIFICATION_WRITE: QUOTA_NOTIFICATION_WRITE,
|
|
2468
|
-
QUOTA_READ: QUOTA_READ,
|
|
2469
|
-
QUOTA_WRITE: QUOTA_WRITE,
|
|
2470
|
-
RELATION_READ: RELATION_READ,
|
|
2471
|
-
RELATION_WRITE: RELATION_WRITE,
|
|
2472
|
-
RESOURCE_READ: RESOURCE_READ,
|
|
2473
|
-
RESOURCE_WRITE: RESOURCE_WRITE,
|
|
2474
|
-
RUN_AS: RUN_AS,
|
|
2475
|
-
SEARCH: SEARCH,
|
|
2476
|
-
SEQUENCE_READ: SEQUENCE_READ,
|
|
2477
|
-
SEQUENCE_WRITE: SEQUENCE_WRITE,
|
|
2478
|
-
SHAPE_TAG_READ: SHAPE_TAG_READ,
|
|
2479
|
-
SHAPE_TAG_WRITE: SHAPE_TAG_WRITE,
|
|
2480
|
-
SITE_MANAGER: SITE_MANAGER,
|
|
2481
|
-
SITE_RULE_READ: SITE_RULE_READ,
|
|
2482
|
-
SITE_RULE_WRITE: SITE_RULE_WRITE,
|
|
2483
|
-
STORAGE_GROUP_READ: STORAGE_GROUP_READ,
|
|
2484
|
-
STORAGE_GROUP_WRITE: STORAGE_GROUP_WRITE,
|
|
2485
|
-
STORAGE_NOTIFICATION_READ: STORAGE_NOTIFICATION_READ,
|
|
2486
|
-
STORAGE_NOTIFICATION_WRITE: STORAGE_NOTIFICATION_WRITE,
|
|
2487
|
-
STORAGE_READ: STORAGE_READ,
|
|
2488
|
-
STORAGE_RULE_READ: STORAGE_RULE_READ,
|
|
2489
|
-
STORAGE_RULE_WRITE: STORAGE_RULE_WRITE,
|
|
2490
|
-
STORAGE_WRITE: STORAGE_WRITE,
|
|
2491
|
-
SUPER_ACCESS_USER: SUPER_ACCESS_USER,
|
|
2492
|
-
TASKDEFINITION_READ: TASKDEFINITION_READ,
|
|
2493
|
-
TASKDEFINITION_WRITE: TASKDEFINITION_WRITE,
|
|
2494
|
-
THUMBNAIL_READ: THUMBNAIL_READ,
|
|
2495
|
-
THUMBNAIL_WRITE: THUMBNAIL_WRITE,
|
|
2496
|
-
TRANSCODER: TRANSCODER,
|
|
2497
|
-
TRANSFER_READ: TRANSFER_READ,
|
|
2498
|
-
TRANSFER_WRITE: TRANSFER_WRITE,
|
|
2499
|
-
USER: USER,
|
|
2500
|
-
VXA: VXA,
|
|
2501
|
-
VXA_READ: VXA_READ
|
|
2502
|
-
});
|
|
1928
|
+
output[key] = parsedTimespan;
|
|
1929
|
+
}
|
|
1930
|
+
});
|
|
1931
|
+
return output;
|
|
1932
|
+
};
|
|
1933
|
+
|
|
1934
|
+
var _excluded = ["timespan"];
|
|
1935
|
+
/**
|
|
1936
|
+
* Parses MetadataType according to specified options.
|
|
1937
|
+
* The attributes can be targeted for each sub-type.
|
|
1938
|
+
* @param {Object} metadataType - The MetadataType response from the API.
|
|
1939
|
+
* @param {Object} options - Options which change how the metadataType is parsed.
|
|
1940
|
+
* @param {string} options.joinValue - String to join the values, eg ','.
|
|
1941
|
+
* @param {boolean} options.includeAttributes - Include attributes on all objects.
|
|
1942
|
+
* @param {boolean} options.includeMetadataAttributes - Include attributes on root.
|
|
1943
|
+
* @param {boolean} options.includeTimespanAttributes - Include attributes on timespans.
|
|
1944
|
+
* @param {boolean} options.includeGroupAttributes - Include attributes on groups.
|
|
1945
|
+
* @param {boolean} options.includeFieldAttributes - Include attributes on fields.
|
|
1946
|
+
* @param {boolean} options.includeValueAttributes - Include attributes on values.
|
|
1947
|
+
* @param {boolean} options.flat - Flatten to key/value (Note: keys may be overwritten).
|
|
1948
|
+
* @param {boolean} options.flatTimespan - Flatten timespan.
|
|
1949
|
+
* @param {boolean} options.flatGroup - Flatten group.
|
|
1950
|
+
* @param {boolean} options.sortTimespan - Sort timespan by start time.
|
|
1951
|
+
* @param {boolean} options.timespanAsList - Return timespans as list.
|
|
1952
|
+
* @param {boolean} options.groupAsList - Return groups as list.
|
|
1953
|
+
* @param {boolean} options.fieldAsList - Return fields as list.
|
|
1954
|
+
* @param {boolean} options.arrayOnSingle=true - Return fields as array even if single field.
|
|
1955
|
+
* @param {boolean} options.arrayOnSingleValue=true - Return fields as array even if single field value.
|
|
1956
|
+
* @returns {Object} Metadata object parsed according to options.
|
|
1957
|
+
*/
|
|
1958
|
+
|
|
1959
|
+
var parseMetadataType = function parseMetadataType() {
|
|
1960
|
+
var metadataType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1961
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1962
|
+
var includeAttributes = options.includeAttributes,
|
|
1963
|
+
includeMetadataAttributes = options.includeMetadataAttributes,
|
|
1964
|
+
sortTimespan = options.sortTimespan;
|
|
1965
|
+
|
|
1966
|
+
var _metadataType$timespa = metadataType.timespan,
|
|
1967
|
+
timespanList = _metadataType$timespa === void 0 ? [] : _metadataType$timespa,
|
|
1968
|
+
attributes = _objectWithoutProperties__default["default"](metadataType, _excluded);
|
|
1969
|
+
|
|
1970
|
+
if (sortTimespan) timespanList.sort(sortTimespanList);
|
|
1971
|
+
var timespan = parseTimespanList(timespanList, options);
|
|
1972
|
+
|
|
1973
|
+
if (includeAttributes || includeMetadataAttributes) {
|
|
1974
|
+
Object.assign(timespan, attributes);
|
|
1975
|
+
}
|
|
1976
|
+
|
|
1977
|
+
return timespan;
|
|
1978
|
+
};
|
|
2503
1979
|
|
|
2504
1980
|
var parseSimpleMetadataType = function parseSimpleMetadataType() {
|
|
2505
1981
|
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
@@ -2509,6 +1985,19 @@ var parseSimpleMetadataType = function parseSimpleMetadataType() {
|
|
|
2509
1985
|
return parseKeyValuePairType(field);
|
|
2510
1986
|
};
|
|
2511
1987
|
|
|
1988
|
+
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; }
|
|
1989
|
+
|
|
1990
|
+
function _objectSpread$2(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$2(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$2(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
1991
|
+
|
|
1992
|
+
/**
|
|
1993
|
+
* Parses highlight timespan responses from the api into key/value object.
|
|
1994
|
+
* The attributes can be targeted for each sub-type.
|
|
1995
|
+
* @param {Object[]} highlightTimespan - A timespan object from the api response.
|
|
1996
|
+
* @param {Object} options - Options which change how the timespans are parsed.
|
|
1997
|
+
* @param {boolean} options.arrayOnSingle=true - Return an array if there is a single value.
|
|
1998
|
+
* @param {boolean} options.timespanAsList=false - Return timespans as list.
|
|
1999
|
+
* @param {string} options.joinValue - String to join the values, eg ','.
|
|
2000
|
+
*/
|
|
2512
2001
|
var parseHighlightTimespan = function parseHighlightTimespan() {
|
|
2513
2002
|
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
2514
2003
|
_ref$field = _ref.field,
|
|
@@ -2535,29 +2024,32 @@ var parseHighlightTimespan = function parseHighlightTimespan() {
|
|
|
2535
2024
|
var fieldValue;
|
|
2536
2025
|
|
|
2537
2026
|
if (arrayOnSingle === false && valueList.length === 1) {
|
|
2538
|
-
var _valueList =
|
|
2027
|
+
var _valueList = _slicedToArray__default["default"](valueList, 1);
|
|
2539
2028
|
|
|
2540
2029
|
fieldValue = _valueList[0];
|
|
2541
2030
|
} else if (joinValue) fieldValue = valueList.join(joinValue);else fieldValue = valueList;
|
|
2542
2031
|
|
|
2543
|
-
return
|
|
2032
|
+
return _objectSpread$2(_objectSpread$2({}, a), {}, _defineProperty__default["default"]({}, name, fieldValue));
|
|
2544
2033
|
}, initialValue);
|
|
2545
2034
|
return fieldList;
|
|
2546
2035
|
};
|
|
2036
|
+
|
|
2037
|
+
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; }
|
|
2038
|
+
|
|
2039
|
+
function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$1(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$1(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
2547
2040
|
/**
|
|
2548
|
-
* Parses
|
|
2041
|
+
* Parses highlight timespans responses from the api into key/value object.
|
|
2549
2042
|
* The attributes can be targeted for each sub-type.
|
|
2550
|
-
* @param {Object} highlightTimespanList - A list of timespans.
|
|
2043
|
+
* @param {Object} highlightTimespanList - A list of timespans from the api response.
|
|
2551
2044
|
* @param {Object} options - Options which change how the timespans are parsed.
|
|
2552
|
-
* @param {
|
|
2553
|
-
* @param {
|
|
2554
|
-
* @param {
|
|
2555
|
-
* @param {
|
|
2556
|
-
* @param {
|
|
2557
|
-
* @param {
|
|
2045
|
+
* @param {boolean} options.arrayOnSingle=true - Return an array if there is a single value.
|
|
2046
|
+
* @param {string} options.joinValue - String to join the values, eg ','.
|
|
2047
|
+
* @param {boolean} options.timespanAsList=false - Return timespans as list.
|
|
2048
|
+
* @param {boolean} options.flat=false - Flatten to field-name/field-value (Note: field-values may be overwritten).
|
|
2049
|
+
* @param {boolean} options.flatTimespan=false - Flatten timespan to object with start/end as key.
|
|
2050
|
+
* @param {string} options.joinTimespan=_ - Character to join the start/end timecodes.
|
|
2558
2051
|
*/
|
|
2559
2052
|
|
|
2560
|
-
|
|
2561
2053
|
var parseHighlightTimespanList = function parseHighlightTimespanList() {
|
|
2562
2054
|
var highlightTimespanList = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
2563
2055
|
var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
@@ -2570,38 +2062,247 @@ var parseHighlightTimespanList = function parseHighlightTimespanList() {
|
|
|
2570
2062
|
return parseHighlightTimespan(timespan, opts);
|
|
2571
2063
|
});
|
|
2572
2064
|
if (flat === true || flatTimespan === true) return highlightTimespanList.reduce(function (a, timespan) {
|
|
2573
|
-
return
|
|
2065
|
+
return _objectSpread$1(_objectSpread$1({}, a), parseHighlightTimespan(timespan, opts));
|
|
2574
2066
|
}, {});
|
|
2575
2067
|
return highlightTimespanList.reduce(function (a, timespan) {
|
|
2576
|
-
return
|
|
2068
|
+
return _objectSpread$1(_objectSpread$1({}, a), {}, _defineProperty__default["default"]({}, [timespan.start, timespan.end].join(joinTimespan), parseHighlightTimespan(timespan, opts)));
|
|
2577
2069
|
}, {});
|
|
2578
2070
|
};
|
|
2579
2071
|
|
|
2580
|
-
|
|
2581
|
-
var
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2072
|
+
function timeToCueTime(_ref) {
|
|
2073
|
+
var _ref$hours = _ref.hours,
|
|
2074
|
+
hours = _ref$hours === void 0 ? 0 : _ref$hours,
|
|
2075
|
+
_ref$minutes = _ref.minutes,
|
|
2076
|
+
minutes = _ref$minutes === void 0 ? 0 : _ref$minutes,
|
|
2077
|
+
_ref$seconds = _ref.seconds,
|
|
2078
|
+
seconds = _ref$seconds === void 0 ? 0 : _ref$seconds,
|
|
2079
|
+
_ref$partialSeconds = _ref.partialSeconds,
|
|
2080
|
+
partialSeconds = _ref$partialSeconds === void 0 ? 0 : _ref$partialSeconds;
|
|
2081
|
+
var hourStr = hours.toFixed().padStart(2, '0');
|
|
2082
|
+
var minStr = minutes.toFixed().padStart(2, '0');
|
|
2083
|
+
var secondsStr = seconds.toFixed().padStart(2, '0');
|
|
2084
|
+
var partialStr = (partialSeconds * 10).toFixed().padStart(3, '0');
|
|
2085
|
+
return "".concat(hourStr, ":").concat(minStr, ":").concat(secondsStr, ".").concat(partialStr);
|
|
2086
|
+
}
|
|
2087
|
+
/**
|
|
2088
|
+
* Convert subtitle groups to WebVtt subtitle format
|
|
2089
|
+
* @param {Object} input={}
|
|
2090
|
+
* @param {Object} input.metadataType - MetadataType response from API.
|
|
2091
|
+
* @param {string} input.subtitleGroup=stl_subtitle - Name of group containing subtitle field/text.
|
|
2092
|
+
* @param {string} input.subtitleField=stl_text - Name of field (text) to use for the subtitles.
|
|
2093
|
+
* @returns {string} WebVtt subtitles
|
|
2094
|
+
*/
|
|
2585
2095
|
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
var
|
|
2096
|
+
|
|
2097
|
+
function metadataTypeToWebVtt(_ref2) {
|
|
2098
|
+
var metadataType = _ref2.metadataType,
|
|
2099
|
+
_ref2$subtitleGroup = _ref2.subtitleGroup,
|
|
2100
|
+
subtitleGroup = _ref2$subtitleGroup === void 0 ? 'stl_subtitle' : _ref2$subtitleGroup,
|
|
2101
|
+
_ref2$subtitleField = _ref2.subtitleField,
|
|
2102
|
+
subtitleField = _ref2$subtitleField === void 0 ? 'stl_text' : _ref2$subtitleField;
|
|
2103
|
+
var parseOptions = {
|
|
2104
|
+
includeTimespanAttributes: true,
|
|
2105
|
+
flatTimespan: true,
|
|
2106
|
+
flatGroup: true,
|
|
2107
|
+
joinValue: ','
|
|
2108
|
+
};
|
|
2109
|
+
|
|
2110
|
+
var _ref3 = metadataType || {},
|
|
2111
|
+
_ref3$timespan = _ref3.timespan,
|
|
2112
|
+
timespanList = _ref3$timespan === void 0 ? [] : _ref3$timespan;
|
|
2113
|
+
|
|
2114
|
+
if (timespanList.length === 0) return '';
|
|
2115
|
+
var sortedTimespans = timespanList.sort(sortTimespanList);
|
|
2116
|
+
var parsedTimespans = sortedTimespans.map(function (timespanType) {
|
|
2117
|
+
return parseTimespan(timespanType, parseOptions);
|
|
2118
|
+
});
|
|
2119
|
+
var vttCues = parsedTimespans.map(function (thisTimespan) {
|
|
2120
|
+
var startText = thisTimespan.start,
|
|
2121
|
+
endText = thisTimespan.end,
|
|
2122
|
+
_thisTimespan$subtitl = thisTimespan[subtitleGroup];
|
|
2123
|
+
_thisTimespan$subtitl = _thisTimespan$subtitl === void 0 ? {} : _thisTimespan$subtitl;
|
|
2124
|
+
var text = _thisTimespan$subtitl[subtitleField];
|
|
2125
|
+
if (!text) return '';
|
|
2126
|
+
var startTime = formatTimeCodeText(startText).toTime();
|
|
2127
|
+
var start = timeToCueTime(startTime);
|
|
2128
|
+
var endTime = formatTimeCodeText(endText).toTime();
|
|
2129
|
+
var end = timeToCueTime(endTime);
|
|
2130
|
+
return "".concat(start, " --> ").concat(end, " line:0%\r").concat(text, "\r");
|
|
2131
|
+
});
|
|
2132
|
+
return "WEBVTT\n\n\n".concat(vttCues.join('\n'));
|
|
2133
|
+
}
|
|
2134
|
+
|
|
2135
|
+
var createFacetType = function createFacetType() {
|
|
2136
|
+
var fieldList = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
2137
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
2138
|
+
return fieldList.map(function (field) {
|
|
2139
|
+
return {
|
|
2140
|
+
field: field,
|
|
2141
|
+
name: field,
|
|
2142
|
+
count: options.count || true,
|
|
2143
|
+
exclude: fieldList
|
|
2144
|
+
};
|
|
2145
|
+
});
|
|
2146
|
+
};
|
|
2147
|
+
|
|
2148
|
+
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; }
|
|
2149
|
+
|
|
2150
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
2151
|
+
|
|
2152
|
+
var parseFacetType = function parseFacetType() {
|
|
2153
|
+
var facetType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
2154
|
+
var output = {};
|
|
2155
|
+
|
|
2156
|
+
var facetFieldReducer = function facetFieldReducer(a, _ref) {
|
|
2157
|
+
var fieldValue = _ref.fieldValue,
|
|
2158
|
+
value = _ref.value;
|
|
2159
|
+
return _objectSpread(_objectSpread({}, a), {}, _defineProperty__default["default"]({}, fieldValue, value));
|
|
2160
|
+
};
|
|
2161
|
+
|
|
2162
|
+
facetType.forEach(function (_ref2) {
|
|
2163
|
+
var name = _ref2.name,
|
|
2164
|
+
field = _ref2.field,
|
|
2165
|
+
count = _ref2.count;
|
|
2166
|
+
output[name || field] = count.reduce(facetFieldReducer, {});
|
|
2167
|
+
});
|
|
2168
|
+
return output;
|
|
2169
|
+
};
|
|
2170
|
+
|
|
2171
|
+
var IMAGE_MIME_TYPES = ['image/apng', 'image/bmp', 'image/gif', 'image/jpeg', 'image/x-icon', 'image/png', 'image/svg+xml'];
|
|
2172
|
+
var VIDEO_MIME_TYPES = ['video/mp4'];
|
|
2173
|
+
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'];
|
|
2174
|
+
var DEFAULT_ALLOWED_MIME_TYPES = [].concat(VIDEO_MIME_TYPES, IMAGE_MIME_TYPES, AUDIO_MIME_TYPES);
|
|
2175
|
+
var DEFAULT_ALLOWED_METHODS = ['http', 'https'];
|
|
2176
|
+
var MP4_MIMETYPE = 'video/mp4';
|
|
2177
|
+
var QUICKTIME_MIMETYPE = 'video/quicktime';
|
|
2178
|
+
var M4V_MIMETYPE = 'video/x-m4v';
|
|
2179
|
+
var MP4_CONTAINER = 'MPEG-4';
|
|
2180
|
+
var MOV_CONTAINER = 'mov';
|
|
2181
|
+
var H264_CODEC = 'h264'; // Sort by tags in the order of previewShapeOrder, secondary alphabetical.
|
|
2182
|
+
// using reverse() so the first has highest index
|
|
2183
|
+
|
|
2184
|
+
var PREVIEW_SHAPE_ORDER = ['__mp4', '__mp3_160k', '__png', '__jpeg', '__gif', 'original'].reverse();
|
|
2185
|
+
|
|
2186
|
+
var defaultSortPriority = function defaultSortPriority(_ref, _ref2) {
|
|
2187
|
+
var firstEl = _ref.shape.tag;
|
|
2188
|
+
var secondEl = _ref2.shape.tag;
|
|
2189
|
+
|
|
2190
|
+
if (PREVIEW_SHAPE_ORDER.includes(firstEl) || PREVIEW_SHAPE_ORDER.includes(secondEl)) {
|
|
2191
|
+
return PREVIEW_SHAPE_ORDER.indexOf(secondEl) - PREVIEW_SHAPE_ORDER.indexOf(firstEl);
|
|
2192
|
+
}
|
|
2193
|
+
|
|
2194
|
+
return firstEl.toLowerCase().localeCompare(secondEl.toLowerCase());
|
|
2195
|
+
};
|
|
2196
|
+
|
|
2197
|
+
var filterShapeSource = function filterShapeSource() {
|
|
2198
|
+
var itemType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
2199
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
2200
|
+
var _options$allowedMimeT = options.allowedMimeTypes,
|
|
2201
|
+
allowedMimeTypes = _options$allowedMimeT === void 0 ? DEFAULT_ALLOWED_MIME_TYPES : _options$allowedMimeT,
|
|
2202
|
+
_options$sortPriority = options.sortPriority,
|
|
2203
|
+
sortPriority = _options$sortPriority === void 0 ? defaultSortPriority : _options$sortPriority,
|
|
2204
|
+
_options$allowedMetho = options.allowedMethods,
|
|
2205
|
+
allowedMethods = _options$allowedMetho === void 0 ? DEFAULT_ALLOWED_METHODS : _options$allowedMetho,
|
|
2206
|
+
_options$sourceKey = options.sourceKey,
|
|
2207
|
+
sourceKey = _options$sourceKey === void 0 ? 'src' : _options$sourceKey,
|
|
2208
|
+
_options$mimeTypeKey = options.mimeTypeKey,
|
|
2209
|
+
mimeTypeKey = _options$mimeTypeKey === void 0 ? 'type' : _options$mimeTypeKey,
|
|
2210
|
+
_options$shapeKey = options.shapeKey,
|
|
2211
|
+
shapeKey = _options$shapeKey === void 0 ? 'shape' : _options$shapeKey;
|
|
2212
|
+
var _itemType$shape = itemType.shape,
|
|
2213
|
+
shapeList = _itemType$shape === void 0 ? [] : _itemType$shape;
|
|
2214
|
+
var parsedShapeList = shapeList.reduce(function (acc, shapeType) {
|
|
2215
|
+
var type;
|
|
2216
|
+
var src;
|
|
2217
|
+
var shape = parseShapeType(shapeType);
|
|
2218
|
+
var uri = shape.uri,
|
|
2219
|
+
mimeType = shape.mimeType,
|
|
2220
|
+
containerFormat = shape.containerFormat,
|
|
2221
|
+
videoCodec = shape.videoCodec;
|
|
2222
|
+
|
|
2223
|
+
if (mimeType) {
|
|
2224
|
+
type = mimeType;
|
|
2225
|
+
if ((mimeType === QUICKTIME_MIMETYPE || mimeType === M4V_MIMETYPE) && (containerFormat === MP4_CONTAINER || containerFormat === MOV_CONTAINER) && videoCodec === H264_CODEC) type = MP4_MIMETYPE;
|
|
2226
|
+
}
|
|
2227
|
+
|
|
2228
|
+
if (uri) {
|
|
2229
|
+
if (allowedMethods) {
|
|
2230
|
+
var _uri$split = uri.split('://'),
|
|
2231
|
+
_uri$split2 = _slicedToArray__default["default"](_uri$split, 1),
|
|
2232
|
+
thisMethod = _uri$split2[0];
|
|
2233
|
+
|
|
2234
|
+
if (allowedMethods.includes(thisMethod)) src = uri;
|
|
2235
|
+
} else {
|
|
2236
|
+
src = uri;
|
|
2237
|
+
}
|
|
2238
|
+
}
|
|
2239
|
+
|
|
2240
|
+
if (src && allowedMimeTypes.includes(type)) {
|
|
2241
|
+
var _acc$push;
|
|
2242
|
+
|
|
2243
|
+
acc.push((_acc$push = {}, _defineProperty__default["default"](_acc$push, sourceKey, src), _defineProperty__default["default"](_acc$push, mimeTypeKey, type), _defineProperty__default["default"](_acc$push, shapeKey, shape), _acc$push));
|
|
2244
|
+
}
|
|
2245
|
+
|
|
2246
|
+
return acc;
|
|
2247
|
+
}, []);
|
|
2248
|
+
if (typeof sortPriority === 'function') parsedShapeList.sort(defaultSortPriority);
|
|
2249
|
+
return parsedShapeList;
|
|
2250
|
+
};
|
|
2251
|
+
|
|
2252
|
+
var IMAGE = 'IMAGE';
|
|
2253
|
+
var AUDIO = 'AUDIO';
|
|
2254
|
+
var VIDEO = 'VIDEO';
|
|
2255
|
+
var DOCUMENT = 'DOCUMENT';
|
|
2256
|
+
var getShapeMediaType = function getShapeMediaType() {
|
|
2257
|
+
var shapeType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
2258
|
+
var mimeType = shapeType.mimeType,
|
|
2259
|
+
videoCodec = shapeType.videoCodec,
|
|
2260
|
+
audioCodec = shapeType.audioCodec;
|
|
2589
2261
|
if (!mimeType) return undefined;
|
|
2590
|
-
|
|
2591
|
-
if (mimeType.startsWith('
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2262
|
+
|
|
2263
|
+
if (mimeType.startsWith('audio/')) {
|
|
2264
|
+
if (audioCodec !== undefined) return AUDIO;
|
|
2265
|
+
}
|
|
2266
|
+
|
|
2267
|
+
if (mimeType.startsWith('video/')) {
|
|
2268
|
+
if (videoCodec !== undefined) return VIDEO;
|
|
2269
|
+
if (audioCodec !== undefined) return AUDIO;
|
|
2270
|
+
}
|
|
2271
|
+
|
|
2272
|
+
if (mimeType.startsWith('image/')) return IMAGE;
|
|
2273
|
+
if (mimeType.endsWith('/pdf')) return DOCUMENT;
|
|
2274
|
+
if (mimeType.startsWith('text/')) return DOCUMENT;
|
|
2275
|
+
if (mimeType.endsWith('/msword')) return DOCUMENT;
|
|
2276
|
+
if (mimeType.endsWith('/json')) return DOCUMENT;
|
|
2277
|
+
if (mimeType.endsWith('/xml')) return DOCUMENT;
|
|
2595
2278
|
return undefined;
|
|
2596
2279
|
};
|
|
2597
2280
|
|
|
2281
|
+
var findNearestThumbnail = function findNearestThumbnail(itemType, timeCodeText) {
|
|
2282
|
+
var tcSeconds = formatTimeCodeText(timeCodeText).toSeconds();
|
|
2283
|
+
|
|
2284
|
+
var _ref = itemType || {},
|
|
2285
|
+
_ref$thumbnails = _ref.thumbnails,
|
|
2286
|
+
thumbnails = _ref$thumbnails === void 0 ? {} : _ref$thumbnails;
|
|
2287
|
+
|
|
2288
|
+
var _thumbnails$uri = thumbnails.uri,
|
|
2289
|
+
srcList = _thumbnails$uri === void 0 ? [] : _thumbnails$uri;
|
|
2290
|
+
var srcTcSeconds = srcList.map(function (url) {
|
|
2291
|
+
var tc = new URL(url).pathname.split('/').pop();
|
|
2292
|
+
return formatTimeCodeText(tc).toSeconds();
|
|
2293
|
+
});
|
|
2294
|
+
var nearestSrcIndex = srcTcSeconds.reduce(function (nearestIndex, curr, currIndex) {
|
|
2295
|
+
return Math.abs(curr - tcSeconds) < Math.abs(srcTcSeconds[nearestIndex] - tcSeconds) ? currIndex : nearestIndex;
|
|
2296
|
+
}, 0);
|
|
2297
|
+
return srcList[nearestSrcIndex];
|
|
2298
|
+
};
|
|
2299
|
+
|
|
2598
2300
|
exports.TimeBase = TimeBase;
|
|
2599
2301
|
exports.TimeCode = TimeCode;
|
|
2600
2302
|
exports.createFacetType = createFacetType;
|
|
2601
2303
|
exports.createMetadataType = createMetadataType;
|
|
2602
2304
|
exports.filterShapeSource = filterShapeSource;
|
|
2603
2305
|
exports.findNearestThumbnail = findNearestThumbnail;
|
|
2604
|
-
exports.findTimespan = findTimespan;
|
|
2605
2306
|
exports.formatSeconds = formatSeconds;
|
|
2606
2307
|
exports.formatSecondsPrecise = formatSecondsPrecise;
|
|
2607
2308
|
exports.formatSmpte = formatSmpte;
|
|
@@ -2633,5 +2334,4 @@ exports.parseTimespanList = parseTimespanList;
|
|
|
2633
2334
|
exports.parseTranscodePreset = parseTranscodePreset;
|
|
2634
2335
|
exports.parseVideoComponent = parseVideoComponent;
|
|
2635
2336
|
exports.roles = roles;
|
|
2636
|
-
exports.sortTimespanList = sortTimespanList;
|
|
2637
2337
|
//# sourceMappingURL=index.js.map
|