@vonage/media-processor 1.0.0
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/LICENSE +201 -0
- package/README.md +9 -0
- package/dist/docs/.nojekyll +1 -0
- package/dist/docs/assets/highlight.css +85 -0
- package/dist/docs/assets/icons.css +1043 -0
- package/dist/docs/assets/icons.png +0 -0
- package/dist/docs/assets/icons@2x.png +0 -0
- package/dist/docs/assets/main.js +52 -0
- package/dist/docs/assets/search.js +1 -0
- package/dist/docs/assets/style.css +1413 -0
- package/dist/docs/assets/widgets.png +0 -0
- package/dist/docs/assets/widgets@2x.png +0 -0
- package/dist/docs/classes/MediaProcessor.html +17 -0
- package/dist/docs/classes/MediaProcessorConnector.html +12 -0
- package/dist/docs/index.html +15 -0
- package/dist/docs/interfaces/MediaProcessorConnectorInterface.html +10 -0
- package/dist/docs/interfaces/MediaProcessorInterface.html +11 -0
- package/dist/docs/modules.html +16 -0
- package/dist/media-processor.es.js +1602 -0
- package/dist/media-processor.umd.js +2 -0
- package/dist/types/main.d.ts +8 -0
- package/dist/types/src/core/InsertableStreamHelper.d.ts +10 -0
- package/dist/types/src/core/MediaProcessor.d.ts +58 -0
- package/dist/types/src/core/MediaProcessorConnector.d.ts +79 -0
- package/dist/types/src/core/MediaProcessorConnectorInterface.d.ts +17 -0
- package/dist/types/src/core/MediaProcessorInterface.d.ts +16 -0
- package/dist/types/src/core/pipeline.d.ts +26 -0
- package/dist/types/src/telemetry/Key.d.ts +8 -0
- package/dist/types/src/telemetry/Reporter.d.ts +67 -0
- package/dist/types/src/utils/package-json.d.ts +4 -0
- package/dist/types/src/utils/utils.d.ts +6 -0
- package/package.json +50 -0
|
@@ -0,0 +1,1602 @@
|
|
|
1
|
+
function isSupported() {
|
|
2
|
+
return new Promise((resolve, reject) => {
|
|
3
|
+
if (typeof MediaStreamTrackProcessor === "undefined" || typeof MediaStreamTrackGenerator === "undefined") {
|
|
4
|
+
reject("Your browser does not support the MediaStreamTrack API for Insertable Streams of Media.");
|
|
5
|
+
} else {
|
|
6
|
+
resolve();
|
|
7
|
+
}
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
class Key {
|
|
11
|
+
}
|
|
12
|
+
Key.updates = {
|
|
13
|
+
"transformer_new": "New transformer",
|
|
14
|
+
"transformer_null": "Null transformer"
|
|
15
|
+
};
|
|
16
|
+
Key.errors = {
|
|
17
|
+
"transformer_none": "No transformers provided",
|
|
18
|
+
"transformer_start": "Cannot start transformer",
|
|
19
|
+
"transformer_transform": "Cannot transform frame",
|
|
20
|
+
"transformer_flush": "Cannot flush transformer"
|
|
21
|
+
};
|
|
22
|
+
var axios$2 = { exports: {} };
|
|
23
|
+
var bind$2 = function bind(fn, thisArg) {
|
|
24
|
+
return function wrap() {
|
|
25
|
+
var args = new Array(arguments.length);
|
|
26
|
+
for (var i = 0; i < args.length; i++) {
|
|
27
|
+
args[i] = arguments[i];
|
|
28
|
+
}
|
|
29
|
+
return fn.apply(thisArg, args);
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
var bind$1 = bind$2;
|
|
33
|
+
var toString = Object.prototype.toString;
|
|
34
|
+
function isArray(val) {
|
|
35
|
+
return Array.isArray(val);
|
|
36
|
+
}
|
|
37
|
+
function isUndefined(val) {
|
|
38
|
+
return typeof val === "undefined";
|
|
39
|
+
}
|
|
40
|
+
function isBuffer(val) {
|
|
41
|
+
return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor) && typeof val.constructor.isBuffer === "function" && val.constructor.isBuffer(val);
|
|
42
|
+
}
|
|
43
|
+
function isArrayBuffer(val) {
|
|
44
|
+
return toString.call(val) === "[object ArrayBuffer]";
|
|
45
|
+
}
|
|
46
|
+
function isFormData(val) {
|
|
47
|
+
return toString.call(val) === "[object FormData]";
|
|
48
|
+
}
|
|
49
|
+
function isArrayBufferView(val) {
|
|
50
|
+
var result;
|
|
51
|
+
if (typeof ArrayBuffer !== "undefined" && ArrayBuffer.isView) {
|
|
52
|
+
result = ArrayBuffer.isView(val);
|
|
53
|
+
} else {
|
|
54
|
+
result = val && val.buffer && isArrayBuffer(val.buffer);
|
|
55
|
+
}
|
|
56
|
+
return result;
|
|
57
|
+
}
|
|
58
|
+
function isString(val) {
|
|
59
|
+
return typeof val === "string";
|
|
60
|
+
}
|
|
61
|
+
function isNumber(val) {
|
|
62
|
+
return typeof val === "number";
|
|
63
|
+
}
|
|
64
|
+
function isObject(val) {
|
|
65
|
+
return val !== null && typeof val === "object";
|
|
66
|
+
}
|
|
67
|
+
function isPlainObject(val) {
|
|
68
|
+
if (toString.call(val) !== "[object Object]") {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
var prototype = Object.getPrototypeOf(val);
|
|
72
|
+
return prototype === null || prototype === Object.prototype;
|
|
73
|
+
}
|
|
74
|
+
function isDate(val) {
|
|
75
|
+
return toString.call(val) === "[object Date]";
|
|
76
|
+
}
|
|
77
|
+
function isFile(val) {
|
|
78
|
+
return toString.call(val) === "[object File]";
|
|
79
|
+
}
|
|
80
|
+
function isBlob(val) {
|
|
81
|
+
return toString.call(val) === "[object Blob]";
|
|
82
|
+
}
|
|
83
|
+
function isFunction(val) {
|
|
84
|
+
return toString.call(val) === "[object Function]";
|
|
85
|
+
}
|
|
86
|
+
function isStream(val) {
|
|
87
|
+
return isObject(val) && isFunction(val.pipe);
|
|
88
|
+
}
|
|
89
|
+
function isURLSearchParams(val) {
|
|
90
|
+
return toString.call(val) === "[object URLSearchParams]";
|
|
91
|
+
}
|
|
92
|
+
function trim(str) {
|
|
93
|
+
return str.trim ? str.trim() : str.replace(/^\s+|\s+$/g, "");
|
|
94
|
+
}
|
|
95
|
+
function isStandardBrowserEnv() {
|
|
96
|
+
if (typeof navigator !== "undefined" && (navigator.product === "ReactNative" || navigator.product === "NativeScript" || navigator.product === "NS")) {
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
99
|
+
return typeof window !== "undefined" && typeof document !== "undefined";
|
|
100
|
+
}
|
|
101
|
+
function forEach(obj, fn) {
|
|
102
|
+
if (obj === null || typeof obj === "undefined") {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
if (typeof obj !== "object") {
|
|
106
|
+
obj = [obj];
|
|
107
|
+
}
|
|
108
|
+
if (isArray(obj)) {
|
|
109
|
+
for (var i = 0, l = obj.length; i < l; i++) {
|
|
110
|
+
fn.call(null, obj[i], i, obj);
|
|
111
|
+
}
|
|
112
|
+
} else {
|
|
113
|
+
for (var key in obj) {
|
|
114
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
115
|
+
fn.call(null, obj[key], key, obj);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
function merge() {
|
|
121
|
+
var result = {};
|
|
122
|
+
function assignValue(val, key) {
|
|
123
|
+
if (isPlainObject(result[key]) && isPlainObject(val)) {
|
|
124
|
+
result[key] = merge(result[key], val);
|
|
125
|
+
} else if (isPlainObject(val)) {
|
|
126
|
+
result[key] = merge({}, val);
|
|
127
|
+
} else if (isArray(val)) {
|
|
128
|
+
result[key] = val.slice();
|
|
129
|
+
} else {
|
|
130
|
+
result[key] = val;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
for (var i = 0, l = arguments.length; i < l; i++) {
|
|
134
|
+
forEach(arguments[i], assignValue);
|
|
135
|
+
}
|
|
136
|
+
return result;
|
|
137
|
+
}
|
|
138
|
+
function extend(a, b, thisArg) {
|
|
139
|
+
forEach(b, function assignValue(val, key) {
|
|
140
|
+
if (thisArg && typeof val === "function") {
|
|
141
|
+
a[key] = bind$1(val, thisArg);
|
|
142
|
+
} else {
|
|
143
|
+
a[key] = val;
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
return a;
|
|
147
|
+
}
|
|
148
|
+
function stripBOM(content) {
|
|
149
|
+
if (content.charCodeAt(0) === 65279) {
|
|
150
|
+
content = content.slice(1);
|
|
151
|
+
}
|
|
152
|
+
return content;
|
|
153
|
+
}
|
|
154
|
+
var utils$e = {
|
|
155
|
+
isArray,
|
|
156
|
+
isArrayBuffer,
|
|
157
|
+
isBuffer,
|
|
158
|
+
isFormData,
|
|
159
|
+
isArrayBufferView,
|
|
160
|
+
isString,
|
|
161
|
+
isNumber,
|
|
162
|
+
isObject,
|
|
163
|
+
isPlainObject,
|
|
164
|
+
isUndefined,
|
|
165
|
+
isDate,
|
|
166
|
+
isFile,
|
|
167
|
+
isBlob,
|
|
168
|
+
isFunction,
|
|
169
|
+
isStream,
|
|
170
|
+
isURLSearchParams,
|
|
171
|
+
isStandardBrowserEnv,
|
|
172
|
+
forEach,
|
|
173
|
+
merge,
|
|
174
|
+
extend,
|
|
175
|
+
trim,
|
|
176
|
+
stripBOM
|
|
177
|
+
};
|
|
178
|
+
var utils$d = utils$e;
|
|
179
|
+
function encode(val) {
|
|
180
|
+
return encodeURIComponent(val).replace(/%3A/gi, ":").replace(/%24/g, "$").replace(/%2C/gi, ",").replace(/%20/g, "+").replace(/%5B/gi, "[").replace(/%5D/gi, "]");
|
|
181
|
+
}
|
|
182
|
+
var buildURL$2 = function buildURL(url, params, paramsSerializer) {
|
|
183
|
+
if (!params) {
|
|
184
|
+
return url;
|
|
185
|
+
}
|
|
186
|
+
var serializedParams;
|
|
187
|
+
if (paramsSerializer) {
|
|
188
|
+
serializedParams = paramsSerializer(params);
|
|
189
|
+
} else if (utils$d.isURLSearchParams(params)) {
|
|
190
|
+
serializedParams = params.toString();
|
|
191
|
+
} else {
|
|
192
|
+
var parts = [];
|
|
193
|
+
utils$d.forEach(params, function serialize(val, key) {
|
|
194
|
+
if (val === null || typeof val === "undefined") {
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
if (utils$d.isArray(val)) {
|
|
198
|
+
key = key + "[]";
|
|
199
|
+
} else {
|
|
200
|
+
val = [val];
|
|
201
|
+
}
|
|
202
|
+
utils$d.forEach(val, function parseValue(v) {
|
|
203
|
+
if (utils$d.isDate(v)) {
|
|
204
|
+
v = v.toISOString();
|
|
205
|
+
} else if (utils$d.isObject(v)) {
|
|
206
|
+
v = JSON.stringify(v);
|
|
207
|
+
}
|
|
208
|
+
parts.push(encode(key) + "=" + encode(v));
|
|
209
|
+
});
|
|
210
|
+
});
|
|
211
|
+
serializedParams = parts.join("&");
|
|
212
|
+
}
|
|
213
|
+
if (serializedParams) {
|
|
214
|
+
var hashmarkIndex = url.indexOf("#");
|
|
215
|
+
if (hashmarkIndex !== -1) {
|
|
216
|
+
url = url.slice(0, hashmarkIndex);
|
|
217
|
+
}
|
|
218
|
+
url += (url.indexOf("?") === -1 ? "?" : "&") + serializedParams;
|
|
219
|
+
}
|
|
220
|
+
return url;
|
|
221
|
+
};
|
|
222
|
+
var utils$c = utils$e;
|
|
223
|
+
function InterceptorManager$1() {
|
|
224
|
+
this.handlers = [];
|
|
225
|
+
}
|
|
226
|
+
InterceptorManager$1.prototype.use = function use(fulfilled, rejected, options) {
|
|
227
|
+
this.handlers.push({
|
|
228
|
+
fulfilled,
|
|
229
|
+
rejected,
|
|
230
|
+
synchronous: options ? options.synchronous : false,
|
|
231
|
+
runWhen: options ? options.runWhen : null
|
|
232
|
+
});
|
|
233
|
+
return this.handlers.length - 1;
|
|
234
|
+
};
|
|
235
|
+
InterceptorManager$1.prototype.eject = function eject(id) {
|
|
236
|
+
if (this.handlers[id]) {
|
|
237
|
+
this.handlers[id] = null;
|
|
238
|
+
}
|
|
239
|
+
};
|
|
240
|
+
InterceptorManager$1.prototype.forEach = function forEach2(fn) {
|
|
241
|
+
utils$c.forEach(this.handlers, function forEachHandler(h) {
|
|
242
|
+
if (h !== null) {
|
|
243
|
+
fn(h);
|
|
244
|
+
}
|
|
245
|
+
});
|
|
246
|
+
};
|
|
247
|
+
var InterceptorManager_1 = InterceptorManager$1;
|
|
248
|
+
var utils$b = utils$e;
|
|
249
|
+
var normalizeHeaderName$1 = function normalizeHeaderName(headers, normalizedName) {
|
|
250
|
+
utils$b.forEach(headers, function processHeader(value, name) {
|
|
251
|
+
if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) {
|
|
252
|
+
headers[normalizedName] = value;
|
|
253
|
+
delete headers[name];
|
|
254
|
+
}
|
|
255
|
+
});
|
|
256
|
+
};
|
|
257
|
+
var enhanceError$2 = function enhanceError(error, config, code, request2, response) {
|
|
258
|
+
error.config = config;
|
|
259
|
+
if (code) {
|
|
260
|
+
error.code = code;
|
|
261
|
+
}
|
|
262
|
+
error.request = request2;
|
|
263
|
+
error.response = response;
|
|
264
|
+
error.isAxiosError = true;
|
|
265
|
+
error.toJSON = function toJSON() {
|
|
266
|
+
return {
|
|
267
|
+
message: this.message,
|
|
268
|
+
name: this.name,
|
|
269
|
+
description: this.description,
|
|
270
|
+
number: this.number,
|
|
271
|
+
fileName: this.fileName,
|
|
272
|
+
lineNumber: this.lineNumber,
|
|
273
|
+
columnNumber: this.columnNumber,
|
|
274
|
+
stack: this.stack,
|
|
275
|
+
config: this.config,
|
|
276
|
+
code: this.code,
|
|
277
|
+
status: this.response && this.response.status ? this.response.status : null
|
|
278
|
+
};
|
|
279
|
+
};
|
|
280
|
+
return error;
|
|
281
|
+
};
|
|
282
|
+
var enhanceError$1 = enhanceError$2;
|
|
283
|
+
var createError$2 = function createError(message, config, code, request2, response) {
|
|
284
|
+
var error = new Error(message);
|
|
285
|
+
return enhanceError$1(error, config, code, request2, response);
|
|
286
|
+
};
|
|
287
|
+
var createError$1 = createError$2;
|
|
288
|
+
var settle$1 = function settle(resolve, reject, response) {
|
|
289
|
+
var validateStatus2 = response.config.validateStatus;
|
|
290
|
+
if (!response.status || !validateStatus2 || validateStatus2(response.status)) {
|
|
291
|
+
resolve(response);
|
|
292
|
+
} else {
|
|
293
|
+
reject(createError$1("Request failed with status code " + response.status, response.config, null, response.request, response));
|
|
294
|
+
}
|
|
295
|
+
};
|
|
296
|
+
var utils$a = utils$e;
|
|
297
|
+
var cookies$1 = utils$a.isStandardBrowserEnv() ? function standardBrowserEnv() {
|
|
298
|
+
return {
|
|
299
|
+
write: function write(name, value, expires, path, domain, secure) {
|
|
300
|
+
var cookie = [];
|
|
301
|
+
cookie.push(name + "=" + encodeURIComponent(value));
|
|
302
|
+
if (utils$a.isNumber(expires)) {
|
|
303
|
+
cookie.push("expires=" + new Date(expires).toGMTString());
|
|
304
|
+
}
|
|
305
|
+
if (utils$a.isString(path)) {
|
|
306
|
+
cookie.push("path=" + path);
|
|
307
|
+
}
|
|
308
|
+
if (utils$a.isString(domain)) {
|
|
309
|
+
cookie.push("domain=" + domain);
|
|
310
|
+
}
|
|
311
|
+
if (secure === true) {
|
|
312
|
+
cookie.push("secure");
|
|
313
|
+
}
|
|
314
|
+
document.cookie = cookie.join("; ");
|
|
315
|
+
},
|
|
316
|
+
read: function read(name) {
|
|
317
|
+
var match = document.cookie.match(new RegExp("(^|;\\s*)(" + name + ")=([^;]*)"));
|
|
318
|
+
return match ? decodeURIComponent(match[3]) : null;
|
|
319
|
+
},
|
|
320
|
+
remove: function remove(name) {
|
|
321
|
+
this.write(name, "", Date.now() - 864e5);
|
|
322
|
+
}
|
|
323
|
+
};
|
|
324
|
+
}() : function nonStandardBrowserEnv() {
|
|
325
|
+
return {
|
|
326
|
+
write: function write() {
|
|
327
|
+
},
|
|
328
|
+
read: function read() {
|
|
329
|
+
return null;
|
|
330
|
+
},
|
|
331
|
+
remove: function remove() {
|
|
332
|
+
}
|
|
333
|
+
};
|
|
334
|
+
}();
|
|
335
|
+
var isAbsoluteURL$1 = function isAbsoluteURL(url) {
|
|
336
|
+
return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
|
|
337
|
+
};
|
|
338
|
+
var combineURLs$1 = function combineURLs(baseURL, relativeURL) {
|
|
339
|
+
return relativeURL ? baseURL.replace(/\/+$/, "") + "/" + relativeURL.replace(/^\/+/, "") : baseURL;
|
|
340
|
+
};
|
|
341
|
+
var isAbsoluteURL2 = isAbsoluteURL$1;
|
|
342
|
+
var combineURLs2 = combineURLs$1;
|
|
343
|
+
var buildFullPath$1 = function buildFullPath(baseURL, requestedURL) {
|
|
344
|
+
if (baseURL && !isAbsoluteURL2(requestedURL)) {
|
|
345
|
+
return combineURLs2(baseURL, requestedURL);
|
|
346
|
+
}
|
|
347
|
+
return requestedURL;
|
|
348
|
+
};
|
|
349
|
+
var utils$9 = utils$e;
|
|
350
|
+
var ignoreDuplicateOf = [
|
|
351
|
+
"age",
|
|
352
|
+
"authorization",
|
|
353
|
+
"content-length",
|
|
354
|
+
"content-type",
|
|
355
|
+
"etag",
|
|
356
|
+
"expires",
|
|
357
|
+
"from",
|
|
358
|
+
"host",
|
|
359
|
+
"if-modified-since",
|
|
360
|
+
"if-unmodified-since",
|
|
361
|
+
"last-modified",
|
|
362
|
+
"location",
|
|
363
|
+
"max-forwards",
|
|
364
|
+
"proxy-authorization",
|
|
365
|
+
"referer",
|
|
366
|
+
"retry-after",
|
|
367
|
+
"user-agent"
|
|
368
|
+
];
|
|
369
|
+
var parseHeaders$1 = function parseHeaders(headers) {
|
|
370
|
+
var parsed = {};
|
|
371
|
+
var key;
|
|
372
|
+
var val;
|
|
373
|
+
var i;
|
|
374
|
+
if (!headers) {
|
|
375
|
+
return parsed;
|
|
376
|
+
}
|
|
377
|
+
utils$9.forEach(headers.split("\n"), function parser(line) {
|
|
378
|
+
i = line.indexOf(":");
|
|
379
|
+
key = utils$9.trim(line.substr(0, i)).toLowerCase();
|
|
380
|
+
val = utils$9.trim(line.substr(i + 1));
|
|
381
|
+
if (key) {
|
|
382
|
+
if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) {
|
|
383
|
+
return;
|
|
384
|
+
}
|
|
385
|
+
if (key === "set-cookie") {
|
|
386
|
+
parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]);
|
|
387
|
+
} else {
|
|
388
|
+
parsed[key] = parsed[key] ? parsed[key] + ", " + val : val;
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
});
|
|
392
|
+
return parsed;
|
|
393
|
+
};
|
|
394
|
+
var utils$8 = utils$e;
|
|
395
|
+
var isURLSameOrigin$1 = utils$8.isStandardBrowserEnv() ? function standardBrowserEnv2() {
|
|
396
|
+
var msie = /(msie|trident)/i.test(navigator.userAgent);
|
|
397
|
+
var urlParsingNode = document.createElement("a");
|
|
398
|
+
var originURL;
|
|
399
|
+
function resolveURL(url) {
|
|
400
|
+
var href = url;
|
|
401
|
+
if (msie) {
|
|
402
|
+
urlParsingNode.setAttribute("href", href);
|
|
403
|
+
href = urlParsingNode.href;
|
|
404
|
+
}
|
|
405
|
+
urlParsingNode.setAttribute("href", href);
|
|
406
|
+
return {
|
|
407
|
+
href: urlParsingNode.href,
|
|
408
|
+
protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, "") : "",
|
|
409
|
+
host: urlParsingNode.host,
|
|
410
|
+
search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, "") : "",
|
|
411
|
+
hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, "") : "",
|
|
412
|
+
hostname: urlParsingNode.hostname,
|
|
413
|
+
port: urlParsingNode.port,
|
|
414
|
+
pathname: urlParsingNode.pathname.charAt(0) === "/" ? urlParsingNode.pathname : "/" + urlParsingNode.pathname
|
|
415
|
+
};
|
|
416
|
+
}
|
|
417
|
+
originURL = resolveURL(window.location.href);
|
|
418
|
+
return function isURLSameOrigin2(requestURL) {
|
|
419
|
+
var parsed = utils$8.isString(requestURL) ? resolveURL(requestURL) : requestURL;
|
|
420
|
+
return parsed.protocol === originURL.protocol && parsed.host === originURL.host;
|
|
421
|
+
};
|
|
422
|
+
}() : function nonStandardBrowserEnv2() {
|
|
423
|
+
return function isURLSameOrigin2() {
|
|
424
|
+
return true;
|
|
425
|
+
};
|
|
426
|
+
}();
|
|
427
|
+
function Cancel$3(message) {
|
|
428
|
+
this.message = message;
|
|
429
|
+
}
|
|
430
|
+
Cancel$3.prototype.toString = function toString2() {
|
|
431
|
+
return "Cancel" + (this.message ? ": " + this.message : "");
|
|
432
|
+
};
|
|
433
|
+
Cancel$3.prototype.__CANCEL__ = true;
|
|
434
|
+
var Cancel_1 = Cancel$3;
|
|
435
|
+
var utils$7 = utils$e;
|
|
436
|
+
var settle2 = settle$1;
|
|
437
|
+
var cookies = cookies$1;
|
|
438
|
+
var buildURL$1 = buildURL$2;
|
|
439
|
+
var buildFullPath2 = buildFullPath$1;
|
|
440
|
+
var parseHeaders2 = parseHeaders$1;
|
|
441
|
+
var isURLSameOrigin = isURLSameOrigin$1;
|
|
442
|
+
var createError2 = createError$2;
|
|
443
|
+
var defaults$4 = defaults_1;
|
|
444
|
+
var Cancel$2 = Cancel_1;
|
|
445
|
+
var xhr = function xhrAdapter(config) {
|
|
446
|
+
return new Promise(function dispatchXhrRequest(resolve, reject) {
|
|
447
|
+
var requestData = config.data;
|
|
448
|
+
var requestHeaders = config.headers;
|
|
449
|
+
var responseType = config.responseType;
|
|
450
|
+
var onCanceled;
|
|
451
|
+
function done() {
|
|
452
|
+
if (config.cancelToken) {
|
|
453
|
+
config.cancelToken.unsubscribe(onCanceled);
|
|
454
|
+
}
|
|
455
|
+
if (config.signal) {
|
|
456
|
+
config.signal.removeEventListener("abort", onCanceled);
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
if (utils$7.isFormData(requestData)) {
|
|
460
|
+
delete requestHeaders["Content-Type"];
|
|
461
|
+
}
|
|
462
|
+
var request2 = new XMLHttpRequest();
|
|
463
|
+
if (config.auth) {
|
|
464
|
+
var username = config.auth.username || "";
|
|
465
|
+
var password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : "";
|
|
466
|
+
requestHeaders.Authorization = "Basic " + btoa(username + ":" + password);
|
|
467
|
+
}
|
|
468
|
+
var fullPath = buildFullPath2(config.baseURL, config.url);
|
|
469
|
+
request2.open(config.method.toUpperCase(), buildURL$1(fullPath, config.params, config.paramsSerializer), true);
|
|
470
|
+
request2.timeout = config.timeout;
|
|
471
|
+
function onloadend() {
|
|
472
|
+
if (!request2) {
|
|
473
|
+
return;
|
|
474
|
+
}
|
|
475
|
+
var responseHeaders = "getAllResponseHeaders" in request2 ? parseHeaders2(request2.getAllResponseHeaders()) : null;
|
|
476
|
+
var responseData = !responseType || responseType === "text" || responseType === "json" ? request2.responseText : request2.response;
|
|
477
|
+
var response = {
|
|
478
|
+
data: responseData,
|
|
479
|
+
status: request2.status,
|
|
480
|
+
statusText: request2.statusText,
|
|
481
|
+
headers: responseHeaders,
|
|
482
|
+
config,
|
|
483
|
+
request: request2
|
|
484
|
+
};
|
|
485
|
+
settle2(function _resolve(value) {
|
|
486
|
+
resolve(value);
|
|
487
|
+
done();
|
|
488
|
+
}, function _reject(err) {
|
|
489
|
+
reject(err);
|
|
490
|
+
done();
|
|
491
|
+
}, response);
|
|
492
|
+
request2 = null;
|
|
493
|
+
}
|
|
494
|
+
if ("onloadend" in request2) {
|
|
495
|
+
request2.onloadend = onloadend;
|
|
496
|
+
} else {
|
|
497
|
+
request2.onreadystatechange = function handleLoad() {
|
|
498
|
+
if (!request2 || request2.readyState !== 4) {
|
|
499
|
+
return;
|
|
500
|
+
}
|
|
501
|
+
if (request2.status === 0 && !(request2.responseURL && request2.responseURL.indexOf("file:") === 0)) {
|
|
502
|
+
return;
|
|
503
|
+
}
|
|
504
|
+
setTimeout(onloadend);
|
|
505
|
+
};
|
|
506
|
+
}
|
|
507
|
+
request2.onabort = function handleAbort() {
|
|
508
|
+
if (!request2) {
|
|
509
|
+
return;
|
|
510
|
+
}
|
|
511
|
+
reject(createError2("Request aborted", config, "ECONNABORTED", request2));
|
|
512
|
+
request2 = null;
|
|
513
|
+
};
|
|
514
|
+
request2.onerror = function handleError() {
|
|
515
|
+
reject(createError2("Network Error", config, null, request2));
|
|
516
|
+
request2 = null;
|
|
517
|
+
};
|
|
518
|
+
request2.ontimeout = function handleTimeout() {
|
|
519
|
+
var timeoutErrorMessage = config.timeout ? "timeout of " + config.timeout + "ms exceeded" : "timeout exceeded";
|
|
520
|
+
var transitional2 = config.transitional || defaults$4.transitional;
|
|
521
|
+
if (config.timeoutErrorMessage) {
|
|
522
|
+
timeoutErrorMessage = config.timeoutErrorMessage;
|
|
523
|
+
}
|
|
524
|
+
reject(createError2(timeoutErrorMessage, config, transitional2.clarifyTimeoutError ? "ETIMEDOUT" : "ECONNABORTED", request2));
|
|
525
|
+
request2 = null;
|
|
526
|
+
};
|
|
527
|
+
if (utils$7.isStandardBrowserEnv()) {
|
|
528
|
+
var xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath)) && config.xsrfCookieName ? cookies.read(config.xsrfCookieName) : void 0;
|
|
529
|
+
if (xsrfValue) {
|
|
530
|
+
requestHeaders[config.xsrfHeaderName] = xsrfValue;
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
if ("setRequestHeader" in request2) {
|
|
534
|
+
utils$7.forEach(requestHeaders, function setRequestHeader(val, key) {
|
|
535
|
+
if (typeof requestData === "undefined" && key.toLowerCase() === "content-type") {
|
|
536
|
+
delete requestHeaders[key];
|
|
537
|
+
} else {
|
|
538
|
+
request2.setRequestHeader(key, val);
|
|
539
|
+
}
|
|
540
|
+
});
|
|
541
|
+
}
|
|
542
|
+
if (!utils$7.isUndefined(config.withCredentials)) {
|
|
543
|
+
request2.withCredentials = !!config.withCredentials;
|
|
544
|
+
}
|
|
545
|
+
if (responseType && responseType !== "json") {
|
|
546
|
+
request2.responseType = config.responseType;
|
|
547
|
+
}
|
|
548
|
+
if (typeof config.onDownloadProgress === "function") {
|
|
549
|
+
request2.addEventListener("progress", config.onDownloadProgress);
|
|
550
|
+
}
|
|
551
|
+
if (typeof config.onUploadProgress === "function" && request2.upload) {
|
|
552
|
+
request2.upload.addEventListener("progress", config.onUploadProgress);
|
|
553
|
+
}
|
|
554
|
+
if (config.cancelToken || config.signal) {
|
|
555
|
+
onCanceled = function(cancel) {
|
|
556
|
+
if (!request2) {
|
|
557
|
+
return;
|
|
558
|
+
}
|
|
559
|
+
reject(!cancel || cancel && cancel.type ? new Cancel$2("canceled") : cancel);
|
|
560
|
+
request2.abort();
|
|
561
|
+
request2 = null;
|
|
562
|
+
};
|
|
563
|
+
config.cancelToken && config.cancelToken.subscribe(onCanceled);
|
|
564
|
+
if (config.signal) {
|
|
565
|
+
config.signal.aborted ? onCanceled() : config.signal.addEventListener("abort", onCanceled);
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
if (!requestData) {
|
|
569
|
+
requestData = null;
|
|
570
|
+
}
|
|
571
|
+
request2.send(requestData);
|
|
572
|
+
});
|
|
573
|
+
};
|
|
574
|
+
var utils$6 = utils$e;
|
|
575
|
+
var normalizeHeaderName2 = normalizeHeaderName$1;
|
|
576
|
+
var enhanceError2 = enhanceError$2;
|
|
577
|
+
var DEFAULT_CONTENT_TYPE = {
|
|
578
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
579
|
+
};
|
|
580
|
+
function setContentTypeIfUnset(headers, value) {
|
|
581
|
+
if (!utils$6.isUndefined(headers) && utils$6.isUndefined(headers["Content-Type"])) {
|
|
582
|
+
headers["Content-Type"] = value;
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
function getDefaultAdapter() {
|
|
586
|
+
var adapter;
|
|
587
|
+
if (typeof XMLHttpRequest !== "undefined") {
|
|
588
|
+
adapter = xhr;
|
|
589
|
+
} else if (typeof process !== "undefined" && Object.prototype.toString.call(process) === "[object process]") {
|
|
590
|
+
adapter = xhr;
|
|
591
|
+
}
|
|
592
|
+
return adapter;
|
|
593
|
+
}
|
|
594
|
+
function stringifySafely(rawValue, parser, encoder) {
|
|
595
|
+
if (utils$6.isString(rawValue)) {
|
|
596
|
+
try {
|
|
597
|
+
(parser || JSON.parse)(rawValue);
|
|
598
|
+
return utils$6.trim(rawValue);
|
|
599
|
+
} catch (e) {
|
|
600
|
+
if (e.name !== "SyntaxError") {
|
|
601
|
+
throw e;
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
return (encoder || JSON.stringify)(rawValue);
|
|
606
|
+
}
|
|
607
|
+
var defaults$3 = {
|
|
608
|
+
transitional: {
|
|
609
|
+
silentJSONParsing: true,
|
|
610
|
+
forcedJSONParsing: true,
|
|
611
|
+
clarifyTimeoutError: false
|
|
612
|
+
},
|
|
613
|
+
adapter: getDefaultAdapter(),
|
|
614
|
+
transformRequest: [function transformRequest(data2, headers) {
|
|
615
|
+
normalizeHeaderName2(headers, "Accept");
|
|
616
|
+
normalizeHeaderName2(headers, "Content-Type");
|
|
617
|
+
if (utils$6.isFormData(data2) || utils$6.isArrayBuffer(data2) || utils$6.isBuffer(data2) || utils$6.isStream(data2) || utils$6.isFile(data2) || utils$6.isBlob(data2)) {
|
|
618
|
+
return data2;
|
|
619
|
+
}
|
|
620
|
+
if (utils$6.isArrayBufferView(data2)) {
|
|
621
|
+
return data2.buffer;
|
|
622
|
+
}
|
|
623
|
+
if (utils$6.isURLSearchParams(data2)) {
|
|
624
|
+
setContentTypeIfUnset(headers, "application/x-www-form-urlencoded;charset=utf-8");
|
|
625
|
+
return data2.toString();
|
|
626
|
+
}
|
|
627
|
+
if (utils$6.isObject(data2) || headers && headers["Content-Type"] === "application/json") {
|
|
628
|
+
setContentTypeIfUnset(headers, "application/json");
|
|
629
|
+
return stringifySafely(data2);
|
|
630
|
+
}
|
|
631
|
+
return data2;
|
|
632
|
+
}],
|
|
633
|
+
transformResponse: [function transformResponse(data2) {
|
|
634
|
+
var transitional2 = this.transitional || defaults$3.transitional;
|
|
635
|
+
var silentJSONParsing = transitional2 && transitional2.silentJSONParsing;
|
|
636
|
+
var forcedJSONParsing = transitional2 && transitional2.forcedJSONParsing;
|
|
637
|
+
var strictJSONParsing = !silentJSONParsing && this.responseType === "json";
|
|
638
|
+
if (strictJSONParsing || forcedJSONParsing && utils$6.isString(data2) && data2.length) {
|
|
639
|
+
try {
|
|
640
|
+
return JSON.parse(data2);
|
|
641
|
+
} catch (e) {
|
|
642
|
+
if (strictJSONParsing) {
|
|
643
|
+
if (e.name === "SyntaxError") {
|
|
644
|
+
throw enhanceError2(e, this, "E_JSON_PARSE");
|
|
645
|
+
}
|
|
646
|
+
throw e;
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
return data2;
|
|
651
|
+
}],
|
|
652
|
+
timeout: 0,
|
|
653
|
+
xsrfCookieName: "XSRF-TOKEN",
|
|
654
|
+
xsrfHeaderName: "X-XSRF-TOKEN",
|
|
655
|
+
maxContentLength: -1,
|
|
656
|
+
maxBodyLength: -1,
|
|
657
|
+
validateStatus: function validateStatus(status) {
|
|
658
|
+
return status >= 200 && status < 300;
|
|
659
|
+
},
|
|
660
|
+
headers: {
|
|
661
|
+
common: {
|
|
662
|
+
"Accept": "application/json, text/plain, */*"
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
};
|
|
666
|
+
utils$6.forEach(["delete", "get", "head"], function forEachMethodNoData(method) {
|
|
667
|
+
defaults$3.headers[method] = {};
|
|
668
|
+
});
|
|
669
|
+
utils$6.forEach(["post", "put", "patch"], function forEachMethodWithData(method) {
|
|
670
|
+
defaults$3.headers[method] = utils$6.merge(DEFAULT_CONTENT_TYPE);
|
|
671
|
+
});
|
|
672
|
+
var defaults_1 = defaults$3;
|
|
673
|
+
var utils$5 = utils$e;
|
|
674
|
+
var defaults$2 = defaults_1;
|
|
675
|
+
var transformData$1 = function transformData(data2, headers, fns) {
|
|
676
|
+
var context = this || defaults$2;
|
|
677
|
+
utils$5.forEach(fns, function transform(fn) {
|
|
678
|
+
data2 = fn.call(context, data2, headers);
|
|
679
|
+
});
|
|
680
|
+
return data2;
|
|
681
|
+
};
|
|
682
|
+
var isCancel$1 = function isCancel(value) {
|
|
683
|
+
return !!(value && value.__CANCEL__);
|
|
684
|
+
};
|
|
685
|
+
var utils$4 = utils$e;
|
|
686
|
+
var transformData2 = transformData$1;
|
|
687
|
+
var isCancel2 = isCancel$1;
|
|
688
|
+
var defaults$1 = defaults_1;
|
|
689
|
+
var Cancel$1 = Cancel_1;
|
|
690
|
+
function throwIfCancellationRequested(config) {
|
|
691
|
+
if (config.cancelToken) {
|
|
692
|
+
config.cancelToken.throwIfRequested();
|
|
693
|
+
}
|
|
694
|
+
if (config.signal && config.signal.aborted) {
|
|
695
|
+
throw new Cancel$1("canceled");
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
var dispatchRequest$1 = function dispatchRequest(config) {
|
|
699
|
+
throwIfCancellationRequested(config);
|
|
700
|
+
config.headers = config.headers || {};
|
|
701
|
+
config.data = transformData2.call(config, config.data, config.headers, config.transformRequest);
|
|
702
|
+
config.headers = utils$4.merge(config.headers.common || {}, config.headers[config.method] || {}, config.headers);
|
|
703
|
+
utils$4.forEach(["delete", "get", "head", "post", "put", "patch", "common"], function cleanHeaderConfig(method) {
|
|
704
|
+
delete config.headers[method];
|
|
705
|
+
});
|
|
706
|
+
var adapter = config.adapter || defaults$1.adapter;
|
|
707
|
+
return adapter(config).then(function onAdapterResolution(response) {
|
|
708
|
+
throwIfCancellationRequested(config);
|
|
709
|
+
response.data = transformData2.call(config, response.data, response.headers, config.transformResponse);
|
|
710
|
+
return response;
|
|
711
|
+
}, function onAdapterRejection(reason) {
|
|
712
|
+
if (!isCancel2(reason)) {
|
|
713
|
+
throwIfCancellationRequested(config);
|
|
714
|
+
if (reason && reason.response) {
|
|
715
|
+
reason.response.data = transformData2.call(config, reason.response.data, reason.response.headers, config.transformResponse);
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
return Promise.reject(reason);
|
|
719
|
+
});
|
|
720
|
+
};
|
|
721
|
+
var utils$3 = utils$e;
|
|
722
|
+
var mergeConfig$2 = function mergeConfig(config1, config2) {
|
|
723
|
+
config2 = config2 || {};
|
|
724
|
+
var config = {};
|
|
725
|
+
function getMergedValue(target, source2) {
|
|
726
|
+
if (utils$3.isPlainObject(target) && utils$3.isPlainObject(source2)) {
|
|
727
|
+
return utils$3.merge(target, source2);
|
|
728
|
+
} else if (utils$3.isPlainObject(source2)) {
|
|
729
|
+
return utils$3.merge({}, source2);
|
|
730
|
+
} else if (utils$3.isArray(source2)) {
|
|
731
|
+
return source2.slice();
|
|
732
|
+
}
|
|
733
|
+
return source2;
|
|
734
|
+
}
|
|
735
|
+
function mergeDeepProperties(prop) {
|
|
736
|
+
if (!utils$3.isUndefined(config2[prop])) {
|
|
737
|
+
return getMergedValue(config1[prop], config2[prop]);
|
|
738
|
+
} else if (!utils$3.isUndefined(config1[prop])) {
|
|
739
|
+
return getMergedValue(void 0, config1[prop]);
|
|
740
|
+
}
|
|
741
|
+
}
|
|
742
|
+
function valueFromConfig2(prop) {
|
|
743
|
+
if (!utils$3.isUndefined(config2[prop])) {
|
|
744
|
+
return getMergedValue(void 0, config2[prop]);
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
function defaultToConfig2(prop) {
|
|
748
|
+
if (!utils$3.isUndefined(config2[prop])) {
|
|
749
|
+
return getMergedValue(void 0, config2[prop]);
|
|
750
|
+
} else if (!utils$3.isUndefined(config1[prop])) {
|
|
751
|
+
return getMergedValue(void 0, config1[prop]);
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
function mergeDirectKeys(prop) {
|
|
755
|
+
if (prop in config2) {
|
|
756
|
+
return getMergedValue(config1[prop], config2[prop]);
|
|
757
|
+
} else if (prop in config1) {
|
|
758
|
+
return getMergedValue(void 0, config1[prop]);
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
var mergeMap = {
|
|
762
|
+
"url": valueFromConfig2,
|
|
763
|
+
"method": valueFromConfig2,
|
|
764
|
+
"data": valueFromConfig2,
|
|
765
|
+
"baseURL": defaultToConfig2,
|
|
766
|
+
"transformRequest": defaultToConfig2,
|
|
767
|
+
"transformResponse": defaultToConfig2,
|
|
768
|
+
"paramsSerializer": defaultToConfig2,
|
|
769
|
+
"timeout": defaultToConfig2,
|
|
770
|
+
"timeoutMessage": defaultToConfig2,
|
|
771
|
+
"withCredentials": defaultToConfig2,
|
|
772
|
+
"adapter": defaultToConfig2,
|
|
773
|
+
"responseType": defaultToConfig2,
|
|
774
|
+
"xsrfCookieName": defaultToConfig2,
|
|
775
|
+
"xsrfHeaderName": defaultToConfig2,
|
|
776
|
+
"onUploadProgress": defaultToConfig2,
|
|
777
|
+
"onDownloadProgress": defaultToConfig2,
|
|
778
|
+
"decompress": defaultToConfig2,
|
|
779
|
+
"maxContentLength": defaultToConfig2,
|
|
780
|
+
"maxBodyLength": defaultToConfig2,
|
|
781
|
+
"transport": defaultToConfig2,
|
|
782
|
+
"httpAgent": defaultToConfig2,
|
|
783
|
+
"httpsAgent": defaultToConfig2,
|
|
784
|
+
"cancelToken": defaultToConfig2,
|
|
785
|
+
"socketPath": defaultToConfig2,
|
|
786
|
+
"responseEncoding": defaultToConfig2,
|
|
787
|
+
"validateStatus": mergeDirectKeys
|
|
788
|
+
};
|
|
789
|
+
utils$3.forEach(Object.keys(config1).concat(Object.keys(config2)), function computeConfigValue(prop) {
|
|
790
|
+
var merge2 = mergeMap[prop] || mergeDeepProperties;
|
|
791
|
+
var configValue = merge2(prop);
|
|
792
|
+
utils$3.isUndefined(configValue) && merge2 !== mergeDirectKeys || (config[prop] = configValue);
|
|
793
|
+
});
|
|
794
|
+
return config;
|
|
795
|
+
};
|
|
796
|
+
var data = {
|
|
797
|
+
"version": "0.25.0"
|
|
798
|
+
};
|
|
799
|
+
var VERSION = data.version;
|
|
800
|
+
var validators$1 = {};
|
|
801
|
+
["object", "boolean", "number", "function", "string", "symbol"].forEach(function(type, i) {
|
|
802
|
+
validators$1[type] = function validator2(thing) {
|
|
803
|
+
return typeof thing === type || "a" + (i < 1 ? "n " : " ") + type;
|
|
804
|
+
};
|
|
805
|
+
});
|
|
806
|
+
var deprecatedWarnings = {};
|
|
807
|
+
validators$1.transitional = function transitional(validator2, version2, message) {
|
|
808
|
+
function formatMessage(opt, desc) {
|
|
809
|
+
return "[Axios v" + VERSION + "] Transitional option '" + opt + "'" + desc + (message ? ". " + message : "");
|
|
810
|
+
}
|
|
811
|
+
return function(value, opt, opts) {
|
|
812
|
+
if (validator2 === false) {
|
|
813
|
+
throw new Error(formatMessage(opt, " has been removed" + (version2 ? " in " + version2 : "")));
|
|
814
|
+
}
|
|
815
|
+
if (version2 && !deprecatedWarnings[opt]) {
|
|
816
|
+
deprecatedWarnings[opt] = true;
|
|
817
|
+
console.warn(formatMessage(opt, " has been deprecated since v" + version2 + " and will be removed in the near future"));
|
|
818
|
+
}
|
|
819
|
+
return validator2 ? validator2(value, opt, opts) : true;
|
|
820
|
+
};
|
|
821
|
+
};
|
|
822
|
+
function assertOptions(options, schema, allowUnknown) {
|
|
823
|
+
if (typeof options !== "object") {
|
|
824
|
+
throw new TypeError("options must be an object");
|
|
825
|
+
}
|
|
826
|
+
var keys = Object.keys(options);
|
|
827
|
+
var i = keys.length;
|
|
828
|
+
while (i-- > 0) {
|
|
829
|
+
var opt = keys[i];
|
|
830
|
+
var validator2 = schema[opt];
|
|
831
|
+
if (validator2) {
|
|
832
|
+
var value = options[opt];
|
|
833
|
+
var result = value === void 0 || validator2(value, opt, options);
|
|
834
|
+
if (result !== true) {
|
|
835
|
+
throw new TypeError("option " + opt + " must be " + result);
|
|
836
|
+
}
|
|
837
|
+
continue;
|
|
838
|
+
}
|
|
839
|
+
if (allowUnknown !== true) {
|
|
840
|
+
throw Error("Unknown option " + opt);
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
}
|
|
844
|
+
var validator$1 = {
|
|
845
|
+
assertOptions,
|
|
846
|
+
validators: validators$1
|
|
847
|
+
};
|
|
848
|
+
var utils$2 = utils$e;
|
|
849
|
+
var buildURL2 = buildURL$2;
|
|
850
|
+
var InterceptorManager = InterceptorManager_1;
|
|
851
|
+
var dispatchRequest2 = dispatchRequest$1;
|
|
852
|
+
var mergeConfig$1 = mergeConfig$2;
|
|
853
|
+
var validator = validator$1;
|
|
854
|
+
var validators = validator.validators;
|
|
855
|
+
function Axios$1(instanceConfig) {
|
|
856
|
+
this.defaults = instanceConfig;
|
|
857
|
+
this.interceptors = {
|
|
858
|
+
request: new InterceptorManager(),
|
|
859
|
+
response: new InterceptorManager()
|
|
860
|
+
};
|
|
861
|
+
}
|
|
862
|
+
Axios$1.prototype.request = function request(configOrUrl, config) {
|
|
863
|
+
if (typeof configOrUrl === "string") {
|
|
864
|
+
config = config || {};
|
|
865
|
+
config.url = configOrUrl;
|
|
866
|
+
} else {
|
|
867
|
+
config = configOrUrl || {};
|
|
868
|
+
}
|
|
869
|
+
if (!config.url) {
|
|
870
|
+
throw new Error("Provided config url is not valid");
|
|
871
|
+
}
|
|
872
|
+
config = mergeConfig$1(this.defaults, config);
|
|
873
|
+
if (config.method) {
|
|
874
|
+
config.method = config.method.toLowerCase();
|
|
875
|
+
} else if (this.defaults.method) {
|
|
876
|
+
config.method = this.defaults.method.toLowerCase();
|
|
877
|
+
} else {
|
|
878
|
+
config.method = "get";
|
|
879
|
+
}
|
|
880
|
+
var transitional2 = config.transitional;
|
|
881
|
+
if (transitional2 !== void 0) {
|
|
882
|
+
validator.assertOptions(transitional2, {
|
|
883
|
+
silentJSONParsing: validators.transitional(validators.boolean),
|
|
884
|
+
forcedJSONParsing: validators.transitional(validators.boolean),
|
|
885
|
+
clarifyTimeoutError: validators.transitional(validators.boolean)
|
|
886
|
+
}, false);
|
|
887
|
+
}
|
|
888
|
+
var requestInterceptorChain = [];
|
|
889
|
+
var synchronousRequestInterceptors = true;
|
|
890
|
+
this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
|
|
891
|
+
if (typeof interceptor.runWhen === "function" && interceptor.runWhen(config) === false) {
|
|
892
|
+
return;
|
|
893
|
+
}
|
|
894
|
+
synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
|
|
895
|
+
requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
|
|
896
|
+
});
|
|
897
|
+
var responseInterceptorChain = [];
|
|
898
|
+
this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
|
|
899
|
+
responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
|
|
900
|
+
});
|
|
901
|
+
var promise;
|
|
902
|
+
if (!synchronousRequestInterceptors) {
|
|
903
|
+
var chain = [dispatchRequest2, void 0];
|
|
904
|
+
Array.prototype.unshift.apply(chain, requestInterceptorChain);
|
|
905
|
+
chain = chain.concat(responseInterceptorChain);
|
|
906
|
+
promise = Promise.resolve(config);
|
|
907
|
+
while (chain.length) {
|
|
908
|
+
promise = promise.then(chain.shift(), chain.shift());
|
|
909
|
+
}
|
|
910
|
+
return promise;
|
|
911
|
+
}
|
|
912
|
+
var newConfig = config;
|
|
913
|
+
while (requestInterceptorChain.length) {
|
|
914
|
+
var onFulfilled = requestInterceptorChain.shift();
|
|
915
|
+
var onRejected = requestInterceptorChain.shift();
|
|
916
|
+
try {
|
|
917
|
+
newConfig = onFulfilled(newConfig);
|
|
918
|
+
} catch (error) {
|
|
919
|
+
onRejected(error);
|
|
920
|
+
break;
|
|
921
|
+
}
|
|
922
|
+
}
|
|
923
|
+
try {
|
|
924
|
+
promise = dispatchRequest2(newConfig);
|
|
925
|
+
} catch (error) {
|
|
926
|
+
return Promise.reject(error);
|
|
927
|
+
}
|
|
928
|
+
while (responseInterceptorChain.length) {
|
|
929
|
+
promise = promise.then(responseInterceptorChain.shift(), responseInterceptorChain.shift());
|
|
930
|
+
}
|
|
931
|
+
return promise;
|
|
932
|
+
};
|
|
933
|
+
Axios$1.prototype.getUri = function getUri(config) {
|
|
934
|
+
if (!config.url) {
|
|
935
|
+
throw new Error("Provided config url is not valid");
|
|
936
|
+
}
|
|
937
|
+
config = mergeConfig$1(this.defaults, config);
|
|
938
|
+
return buildURL2(config.url, config.params, config.paramsSerializer).replace(/^\?/, "");
|
|
939
|
+
};
|
|
940
|
+
utils$2.forEach(["delete", "get", "head", "options"], function forEachMethodNoData2(method) {
|
|
941
|
+
Axios$1.prototype[method] = function(url, config) {
|
|
942
|
+
return this.request(mergeConfig$1(config || {}, {
|
|
943
|
+
method,
|
|
944
|
+
url,
|
|
945
|
+
data: (config || {}).data
|
|
946
|
+
}));
|
|
947
|
+
};
|
|
948
|
+
});
|
|
949
|
+
utils$2.forEach(["post", "put", "patch"], function forEachMethodWithData2(method) {
|
|
950
|
+
Axios$1.prototype[method] = function(url, data2, config) {
|
|
951
|
+
return this.request(mergeConfig$1(config || {}, {
|
|
952
|
+
method,
|
|
953
|
+
url,
|
|
954
|
+
data: data2
|
|
955
|
+
}));
|
|
956
|
+
};
|
|
957
|
+
});
|
|
958
|
+
var Axios_1 = Axios$1;
|
|
959
|
+
var Cancel = Cancel_1;
|
|
960
|
+
function CancelToken(executor) {
|
|
961
|
+
if (typeof executor !== "function") {
|
|
962
|
+
throw new TypeError("executor must be a function.");
|
|
963
|
+
}
|
|
964
|
+
var resolvePromise;
|
|
965
|
+
this.promise = new Promise(function promiseExecutor(resolve) {
|
|
966
|
+
resolvePromise = resolve;
|
|
967
|
+
});
|
|
968
|
+
var token = this;
|
|
969
|
+
this.promise.then(function(cancel) {
|
|
970
|
+
if (!token._listeners)
|
|
971
|
+
return;
|
|
972
|
+
var i;
|
|
973
|
+
var l = token._listeners.length;
|
|
974
|
+
for (i = 0; i < l; i++) {
|
|
975
|
+
token._listeners[i](cancel);
|
|
976
|
+
}
|
|
977
|
+
token._listeners = null;
|
|
978
|
+
});
|
|
979
|
+
this.promise.then = function(onfulfilled) {
|
|
980
|
+
var _resolve;
|
|
981
|
+
var promise = new Promise(function(resolve) {
|
|
982
|
+
token.subscribe(resolve);
|
|
983
|
+
_resolve = resolve;
|
|
984
|
+
}).then(onfulfilled);
|
|
985
|
+
promise.cancel = function reject() {
|
|
986
|
+
token.unsubscribe(_resolve);
|
|
987
|
+
};
|
|
988
|
+
return promise;
|
|
989
|
+
};
|
|
990
|
+
executor(function cancel(message) {
|
|
991
|
+
if (token.reason) {
|
|
992
|
+
return;
|
|
993
|
+
}
|
|
994
|
+
token.reason = new Cancel(message);
|
|
995
|
+
resolvePromise(token.reason);
|
|
996
|
+
});
|
|
997
|
+
}
|
|
998
|
+
CancelToken.prototype.throwIfRequested = function throwIfRequested() {
|
|
999
|
+
if (this.reason) {
|
|
1000
|
+
throw this.reason;
|
|
1001
|
+
}
|
|
1002
|
+
};
|
|
1003
|
+
CancelToken.prototype.subscribe = function subscribe(listener) {
|
|
1004
|
+
if (this.reason) {
|
|
1005
|
+
listener(this.reason);
|
|
1006
|
+
return;
|
|
1007
|
+
}
|
|
1008
|
+
if (this._listeners) {
|
|
1009
|
+
this._listeners.push(listener);
|
|
1010
|
+
} else {
|
|
1011
|
+
this._listeners = [listener];
|
|
1012
|
+
}
|
|
1013
|
+
};
|
|
1014
|
+
CancelToken.prototype.unsubscribe = function unsubscribe(listener) {
|
|
1015
|
+
if (!this._listeners) {
|
|
1016
|
+
return;
|
|
1017
|
+
}
|
|
1018
|
+
var index = this._listeners.indexOf(listener);
|
|
1019
|
+
if (index !== -1) {
|
|
1020
|
+
this._listeners.splice(index, 1);
|
|
1021
|
+
}
|
|
1022
|
+
};
|
|
1023
|
+
CancelToken.source = function source() {
|
|
1024
|
+
var cancel;
|
|
1025
|
+
var token = new CancelToken(function executor(c) {
|
|
1026
|
+
cancel = c;
|
|
1027
|
+
});
|
|
1028
|
+
return {
|
|
1029
|
+
token,
|
|
1030
|
+
cancel
|
|
1031
|
+
};
|
|
1032
|
+
};
|
|
1033
|
+
var CancelToken_1 = CancelToken;
|
|
1034
|
+
var spread = function spread2(callback) {
|
|
1035
|
+
return function wrap(arr) {
|
|
1036
|
+
return callback.apply(null, arr);
|
|
1037
|
+
};
|
|
1038
|
+
};
|
|
1039
|
+
var utils$1 = utils$e;
|
|
1040
|
+
var isAxiosError = function isAxiosError2(payload) {
|
|
1041
|
+
return utils$1.isObject(payload) && payload.isAxiosError === true;
|
|
1042
|
+
};
|
|
1043
|
+
var utils = utils$e;
|
|
1044
|
+
var bind2 = bind$2;
|
|
1045
|
+
var Axios = Axios_1;
|
|
1046
|
+
var mergeConfig2 = mergeConfig$2;
|
|
1047
|
+
var defaults = defaults_1;
|
|
1048
|
+
function createInstance(defaultConfig) {
|
|
1049
|
+
var context = new Axios(defaultConfig);
|
|
1050
|
+
var instance = bind2(Axios.prototype.request, context);
|
|
1051
|
+
utils.extend(instance, Axios.prototype, context);
|
|
1052
|
+
utils.extend(instance, context);
|
|
1053
|
+
instance.create = function create(instanceConfig) {
|
|
1054
|
+
return createInstance(mergeConfig2(defaultConfig, instanceConfig));
|
|
1055
|
+
};
|
|
1056
|
+
return instance;
|
|
1057
|
+
}
|
|
1058
|
+
var axios$1 = createInstance(defaults);
|
|
1059
|
+
axios$1.Axios = Axios;
|
|
1060
|
+
axios$1.Cancel = Cancel_1;
|
|
1061
|
+
axios$1.CancelToken = CancelToken_1;
|
|
1062
|
+
axios$1.isCancel = isCancel$1;
|
|
1063
|
+
axios$1.VERSION = data.version;
|
|
1064
|
+
axios$1.all = function all(promises) {
|
|
1065
|
+
return Promise.all(promises);
|
|
1066
|
+
};
|
|
1067
|
+
axios$1.spread = spread;
|
|
1068
|
+
axios$1.isAxiosError = isAxiosError;
|
|
1069
|
+
axios$2.exports = axios$1;
|
|
1070
|
+
axios$2.exports.default = axios$1;
|
|
1071
|
+
var axios = axios$2.exports;
|
|
1072
|
+
class Optional {
|
|
1073
|
+
isEmpty() {
|
|
1074
|
+
return !this.isPresent();
|
|
1075
|
+
}
|
|
1076
|
+
static of(value) {
|
|
1077
|
+
if (value !== null && value !== void 0)
|
|
1078
|
+
return new PresentOptional(value);
|
|
1079
|
+
else
|
|
1080
|
+
throw new TypeError("The passed value was null or undefined.");
|
|
1081
|
+
}
|
|
1082
|
+
static ofNonNull(value) {
|
|
1083
|
+
return Optional.of(value);
|
|
1084
|
+
}
|
|
1085
|
+
static ofNullable(nullable) {
|
|
1086
|
+
if (nullable !== null && nullable !== void 0)
|
|
1087
|
+
return new PresentOptional(nullable);
|
|
1088
|
+
else
|
|
1089
|
+
return new EmptyOptional();
|
|
1090
|
+
}
|
|
1091
|
+
static empty() {
|
|
1092
|
+
return new EmptyOptional();
|
|
1093
|
+
}
|
|
1094
|
+
static from(option) {
|
|
1095
|
+
switch (option.kind) {
|
|
1096
|
+
case "present":
|
|
1097
|
+
return Optional.of(option.value);
|
|
1098
|
+
case "empty":
|
|
1099
|
+
return Optional.empty();
|
|
1100
|
+
default:
|
|
1101
|
+
throw new TypeError("The passed value was not an Option type.");
|
|
1102
|
+
}
|
|
1103
|
+
}
|
|
1104
|
+
}
|
|
1105
|
+
class PresentOptional extends Optional {
|
|
1106
|
+
constructor(value) {
|
|
1107
|
+
super();
|
|
1108
|
+
this.payload = value;
|
|
1109
|
+
}
|
|
1110
|
+
isPresent() {
|
|
1111
|
+
return true;
|
|
1112
|
+
}
|
|
1113
|
+
get() {
|
|
1114
|
+
return this.payload;
|
|
1115
|
+
}
|
|
1116
|
+
ifPresent(consumer) {
|
|
1117
|
+
consumer(this.payload);
|
|
1118
|
+
}
|
|
1119
|
+
ifPresentOrElse(consumer, emptyAction) {
|
|
1120
|
+
consumer(this.payload);
|
|
1121
|
+
}
|
|
1122
|
+
filter(predicate) {
|
|
1123
|
+
return predicate(this.payload) ? this : Optional.empty();
|
|
1124
|
+
}
|
|
1125
|
+
map(mapper) {
|
|
1126
|
+
const result = mapper(this.payload);
|
|
1127
|
+
return Optional.ofNullable(result);
|
|
1128
|
+
}
|
|
1129
|
+
flatMap(mapper) {
|
|
1130
|
+
return mapper(this.payload);
|
|
1131
|
+
}
|
|
1132
|
+
or(supplier) {
|
|
1133
|
+
return this;
|
|
1134
|
+
}
|
|
1135
|
+
orElse(another) {
|
|
1136
|
+
return this.payload;
|
|
1137
|
+
}
|
|
1138
|
+
orElseGet(another) {
|
|
1139
|
+
return this.payload;
|
|
1140
|
+
}
|
|
1141
|
+
orElseThrow(exception) {
|
|
1142
|
+
return this.payload;
|
|
1143
|
+
}
|
|
1144
|
+
orNull() {
|
|
1145
|
+
return this.payload;
|
|
1146
|
+
}
|
|
1147
|
+
orUndefined() {
|
|
1148
|
+
return this.payload;
|
|
1149
|
+
}
|
|
1150
|
+
toOption() {
|
|
1151
|
+
return { kind: "present", value: this.payload };
|
|
1152
|
+
}
|
|
1153
|
+
matches(cases) {
|
|
1154
|
+
return cases.present(this.payload);
|
|
1155
|
+
}
|
|
1156
|
+
toJSON(key) {
|
|
1157
|
+
return this.payload;
|
|
1158
|
+
}
|
|
1159
|
+
}
|
|
1160
|
+
class EmptyOptional extends Optional {
|
|
1161
|
+
isPresent() {
|
|
1162
|
+
return false;
|
|
1163
|
+
}
|
|
1164
|
+
constructor() {
|
|
1165
|
+
super();
|
|
1166
|
+
}
|
|
1167
|
+
get() {
|
|
1168
|
+
throw new TypeError("The optional is not present.");
|
|
1169
|
+
}
|
|
1170
|
+
ifPresent(consumer) {
|
|
1171
|
+
}
|
|
1172
|
+
ifPresentOrElse(consumer, emptyAction) {
|
|
1173
|
+
emptyAction();
|
|
1174
|
+
}
|
|
1175
|
+
filter(predicate) {
|
|
1176
|
+
return this;
|
|
1177
|
+
}
|
|
1178
|
+
map(mapper) {
|
|
1179
|
+
return Optional.empty();
|
|
1180
|
+
}
|
|
1181
|
+
flatMap(mapper) {
|
|
1182
|
+
return Optional.empty();
|
|
1183
|
+
}
|
|
1184
|
+
or(supplier) {
|
|
1185
|
+
return supplier();
|
|
1186
|
+
}
|
|
1187
|
+
orElse(another) {
|
|
1188
|
+
return another;
|
|
1189
|
+
}
|
|
1190
|
+
orElseGet(another) {
|
|
1191
|
+
return this.orElse(another());
|
|
1192
|
+
}
|
|
1193
|
+
orElseThrow(exception) {
|
|
1194
|
+
throw exception();
|
|
1195
|
+
}
|
|
1196
|
+
orNull() {
|
|
1197
|
+
return null;
|
|
1198
|
+
}
|
|
1199
|
+
orUndefined() {
|
|
1200
|
+
return void 0;
|
|
1201
|
+
}
|
|
1202
|
+
toOption() {
|
|
1203
|
+
return { kind: "empty" };
|
|
1204
|
+
}
|
|
1205
|
+
matches(cases) {
|
|
1206
|
+
return cases.empty();
|
|
1207
|
+
}
|
|
1208
|
+
toJSON(key) {
|
|
1209
|
+
return null;
|
|
1210
|
+
}
|
|
1211
|
+
}
|
|
1212
|
+
const version = "1.0.0";
|
|
1213
|
+
let _metadata;
|
|
1214
|
+
function setMetadata(metadata) {
|
|
1215
|
+
_metadata = metadata;
|
|
1216
|
+
}
|
|
1217
|
+
function getMetadata() {
|
|
1218
|
+
return _metadata;
|
|
1219
|
+
}
|
|
1220
|
+
class ReportBuilder {
|
|
1221
|
+
constructor() {
|
|
1222
|
+
const metadata = getMetadata();
|
|
1223
|
+
this._report = {
|
|
1224
|
+
action: Optional.empty(),
|
|
1225
|
+
applicationId: Optional.ofNullable(metadata !== void 0 ? metadata.appId : null),
|
|
1226
|
+
timestamp: Date.now(),
|
|
1227
|
+
fps: Optional.empty(),
|
|
1228
|
+
framesTransformed: Optional.empty(),
|
|
1229
|
+
guid: Optional.empty(),
|
|
1230
|
+
highestFrameTransformCpu: Optional.empty(),
|
|
1231
|
+
message: Optional.empty(),
|
|
1232
|
+
source: Optional.ofNullable(metadata !== void 0 ? metadata.sourceType : null),
|
|
1233
|
+
transformedFps: Optional.empty(),
|
|
1234
|
+
transformerType: Optional.empty(),
|
|
1235
|
+
variation: Optional.empty(),
|
|
1236
|
+
videoHeight: Optional.empty(),
|
|
1237
|
+
videoWidth: Optional.empty(),
|
|
1238
|
+
version
|
|
1239
|
+
};
|
|
1240
|
+
}
|
|
1241
|
+
action(action) {
|
|
1242
|
+
this._report.action = Optional.ofNullable(action);
|
|
1243
|
+
return this;
|
|
1244
|
+
}
|
|
1245
|
+
framesTransformed(framesTransformed) {
|
|
1246
|
+
this._report.framesTransformed = Optional.ofNullable(framesTransformed);
|
|
1247
|
+
return this;
|
|
1248
|
+
}
|
|
1249
|
+
fps(fps) {
|
|
1250
|
+
this._report.fps = Optional.ofNullable(fps);
|
|
1251
|
+
return this;
|
|
1252
|
+
}
|
|
1253
|
+
guid(guid) {
|
|
1254
|
+
this._report.guid = Optional.ofNullable(guid);
|
|
1255
|
+
return this;
|
|
1256
|
+
}
|
|
1257
|
+
message(message) {
|
|
1258
|
+
this._report.message = Optional.ofNullable(message);
|
|
1259
|
+
return this;
|
|
1260
|
+
}
|
|
1261
|
+
transformedFps(transformedFps) {
|
|
1262
|
+
this._report.transformedFps = Optional.ofNullable(transformedFps);
|
|
1263
|
+
return this;
|
|
1264
|
+
}
|
|
1265
|
+
transformerType(transformerType) {
|
|
1266
|
+
this._report.transformerType = Optional.ofNullable(transformerType);
|
|
1267
|
+
return this;
|
|
1268
|
+
}
|
|
1269
|
+
variation(variation) {
|
|
1270
|
+
this._report.variation = Optional.ofNullable(variation);
|
|
1271
|
+
return this;
|
|
1272
|
+
}
|
|
1273
|
+
videoHeight(videoHeight) {
|
|
1274
|
+
this._report.videoHeight = Optional.ofNullable(videoHeight);
|
|
1275
|
+
return this;
|
|
1276
|
+
}
|
|
1277
|
+
videoWidth(videoWidth) {
|
|
1278
|
+
this._report.videoWidth = Optional.ofNullable(videoWidth);
|
|
1279
|
+
return this;
|
|
1280
|
+
}
|
|
1281
|
+
build() {
|
|
1282
|
+
return this._report;
|
|
1283
|
+
}
|
|
1284
|
+
}
|
|
1285
|
+
const serializeReport = (report) => {
|
|
1286
|
+
return JSON.stringify(report, (key, value) => {
|
|
1287
|
+
if (value !== null)
|
|
1288
|
+
return value;
|
|
1289
|
+
});
|
|
1290
|
+
};
|
|
1291
|
+
class Reporter {
|
|
1292
|
+
static report(report) {
|
|
1293
|
+
return new Promise((resolve, reject) => {
|
|
1294
|
+
let axiosInstance = axios.create();
|
|
1295
|
+
let config = {
|
|
1296
|
+
timeout: 1e4,
|
|
1297
|
+
timeoutErrorMessage: "Request timeout",
|
|
1298
|
+
headers: {
|
|
1299
|
+
"Content-Type": "application/json"
|
|
1300
|
+
}
|
|
1301
|
+
};
|
|
1302
|
+
const telemetryServerUrl = "https://hlg.tokbox.com/prod/logging/vcp_webrtc";
|
|
1303
|
+
axiosInstance.post(telemetryServerUrl, serializeReport(report), config).then((res) => {
|
|
1304
|
+
console.log(res);
|
|
1305
|
+
resolve("success");
|
|
1306
|
+
}).catch((e) => {
|
|
1307
|
+
console.log(e);
|
|
1308
|
+
reject(e);
|
|
1309
|
+
});
|
|
1310
|
+
});
|
|
1311
|
+
}
|
|
1312
|
+
}
|
|
1313
|
+
var getRandomValues;
|
|
1314
|
+
var rnds8 = new Uint8Array(16);
|
|
1315
|
+
function rng() {
|
|
1316
|
+
if (!getRandomValues) {
|
|
1317
|
+
getRandomValues = typeof crypto !== "undefined" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || typeof msCrypto !== "undefined" && typeof msCrypto.getRandomValues === "function" && msCrypto.getRandomValues.bind(msCrypto);
|
|
1318
|
+
if (!getRandomValues) {
|
|
1319
|
+
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
1320
|
+
}
|
|
1321
|
+
}
|
|
1322
|
+
return getRandomValues(rnds8);
|
|
1323
|
+
}
|
|
1324
|
+
var REGEX = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;
|
|
1325
|
+
function validate(uuid) {
|
|
1326
|
+
return typeof uuid === "string" && REGEX.test(uuid);
|
|
1327
|
+
}
|
|
1328
|
+
var byteToHex = [];
|
|
1329
|
+
for (var i = 0; i < 256; ++i) {
|
|
1330
|
+
byteToHex.push((i + 256).toString(16).substr(1));
|
|
1331
|
+
}
|
|
1332
|
+
function stringify(arr) {
|
|
1333
|
+
var offset = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0;
|
|
1334
|
+
var uuid = (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase();
|
|
1335
|
+
if (!validate(uuid)) {
|
|
1336
|
+
throw TypeError("Stringified UUID is invalid");
|
|
1337
|
+
}
|
|
1338
|
+
return uuid;
|
|
1339
|
+
}
|
|
1340
|
+
function v4(options, buf, offset) {
|
|
1341
|
+
options = options || {};
|
|
1342
|
+
var rnds = options.random || (options.rng || rng)();
|
|
1343
|
+
rnds[6] = rnds[6] & 15 | 64;
|
|
1344
|
+
rnds[8] = rnds[8] & 63 | 128;
|
|
1345
|
+
if (buf) {
|
|
1346
|
+
offset = offset || 0;
|
|
1347
|
+
for (var i = 0; i < 16; ++i) {
|
|
1348
|
+
buf[offset + i] = rnds[i];
|
|
1349
|
+
}
|
|
1350
|
+
return buf;
|
|
1351
|
+
}
|
|
1352
|
+
return stringify(rnds);
|
|
1353
|
+
}
|
|
1354
|
+
const TELEMETRY_MEDIA_TRANSFORMER_QOS_REPORT_INTERVAL = 500;
|
|
1355
|
+
class InternalTransformer {
|
|
1356
|
+
constructor(transformer) {
|
|
1357
|
+
this.uuid_ = v4();
|
|
1358
|
+
this.framesTransformed_ = 0;
|
|
1359
|
+
this.transformer_ = transformer;
|
|
1360
|
+
this.shouldStop_ = false;
|
|
1361
|
+
this.isFlashed_ = false;
|
|
1362
|
+
this.framesFromSource_ = 0;
|
|
1363
|
+
this.fps_ = 0;
|
|
1364
|
+
this.mediaTransformerQosReportStartTimestamp_ = 0;
|
|
1365
|
+
this.videoHeight_ = 0;
|
|
1366
|
+
this.videoWidth_ = 0;
|
|
1367
|
+
this.transformerType_ = "Custom";
|
|
1368
|
+
if ("getTransformerType" in transformer) {
|
|
1369
|
+
this.transformerType_ = transformer.getTransformerType();
|
|
1370
|
+
}
|
|
1371
|
+
const report = new ReportBuilder().action("MediaTransformer").guid(this.uuid_).transformerType(this.transformerType_).variation("Create").build();
|
|
1372
|
+
Reporter.report(report);
|
|
1373
|
+
}
|
|
1374
|
+
async start(controller) {
|
|
1375
|
+
if (this.transformer_ && typeof this.transformer_.start === "function") {
|
|
1376
|
+
try {
|
|
1377
|
+
await this.transformer_.start(controller);
|
|
1378
|
+
} catch (e) {
|
|
1379
|
+
const report = new ReportBuilder().action("MediaTransformer").guid(this.uuid_).message(Key.errors["transformer_start"]).transformerType(this.transformerType_).variation("Error").build();
|
|
1380
|
+
Reporter.report(report);
|
|
1381
|
+
}
|
|
1382
|
+
}
|
|
1383
|
+
}
|
|
1384
|
+
async transform(frame, controller) {
|
|
1385
|
+
var _a, _b, _c, _d;
|
|
1386
|
+
if (this.mediaTransformerQosReportStartTimestamp_ === 0) {
|
|
1387
|
+
this.mediaTransformerQosReportStartTimestamp_ = Date.now();
|
|
1388
|
+
}
|
|
1389
|
+
this.videoHeight_ = (_a = frame == null ? void 0 : frame.displayHeight) != null ? _a : 0;
|
|
1390
|
+
this.videoWidth_ = (_b = frame == null ? void 0 : frame.displayWidth) != null ? _b : 0;
|
|
1391
|
+
++this.framesFromSource_;
|
|
1392
|
+
if (this.transformer_) {
|
|
1393
|
+
if (!this.shouldStop_) {
|
|
1394
|
+
try {
|
|
1395
|
+
await ((_d = (_c = this.transformer_).transform) == null ? void 0 : _d.call(_c, frame, controller));
|
|
1396
|
+
++this.framesTransformed_;
|
|
1397
|
+
if (this.framesTransformed_ === TELEMETRY_MEDIA_TRANSFORMER_QOS_REPORT_INTERVAL) {
|
|
1398
|
+
this.mediaTransformerQosReport();
|
|
1399
|
+
}
|
|
1400
|
+
} catch (e) {
|
|
1401
|
+
const report = new ReportBuilder().action("MediaTransformer").guid(this.uuid_).message(Key.errors["transformer_transform"]).transformerType(this.transformerType_).variation("Error").build();
|
|
1402
|
+
Reporter.report(report);
|
|
1403
|
+
}
|
|
1404
|
+
} else {
|
|
1405
|
+
frame.close();
|
|
1406
|
+
this.flush(controller);
|
|
1407
|
+
controller.terminate();
|
|
1408
|
+
}
|
|
1409
|
+
}
|
|
1410
|
+
}
|
|
1411
|
+
async flush(controller) {
|
|
1412
|
+
if (this.transformer_ && typeof this.transformer_.flush === "function" && !this.isFlashed_) {
|
|
1413
|
+
this.isFlashed_ = true;
|
|
1414
|
+
try {
|
|
1415
|
+
await this.transformer_.flush(controller);
|
|
1416
|
+
} catch (e) {
|
|
1417
|
+
const error = new ReportBuilder().action("MediaTransformer").guid(this.uuid_).message(Key.errors["transformer_transform"]).transformerType(this.transformerType_).variation("Error").build();
|
|
1418
|
+
Reporter.report(error);
|
|
1419
|
+
}
|
|
1420
|
+
}
|
|
1421
|
+
this.mediaTransformerQosReport();
|
|
1422
|
+
const deleteReport = new ReportBuilder().action("MediaTransformer").guid(this.uuid_).transformerType(this.transformerType_).variation("Delete").build();
|
|
1423
|
+
Reporter.report(deleteReport);
|
|
1424
|
+
}
|
|
1425
|
+
stop() {
|
|
1426
|
+
console.log("[Pipeline] Stop stream.");
|
|
1427
|
+
this.shouldStop_ = true;
|
|
1428
|
+
}
|
|
1429
|
+
mediaTransformerQosReport() {
|
|
1430
|
+
let timeElapsed_s = (Date.now() - this.mediaTransformerQosReportStartTimestamp_) / 1e3;
|
|
1431
|
+
let fps = this.framesFromSource_ / timeElapsed_s;
|
|
1432
|
+
let transformedFps = this.framesTransformed_ / timeElapsed_s;
|
|
1433
|
+
const qos = new ReportBuilder().action("MediaTransformer").fps(fps).transformedFps(transformedFps).framesTransformed(this.framesTransformed_).guid(this.uuid_).transformerType(this.transformerType_).videoHeight(this.videoHeight_).videoWidth(this.videoWidth_).variation("QoS").build();
|
|
1434
|
+
Reporter.report(qos);
|
|
1435
|
+
this.mediaTransformerQosReportStartTimestamp_ = 0;
|
|
1436
|
+
this.framesFromSource_ = 0;
|
|
1437
|
+
this.framesTransformed_ = 0;
|
|
1438
|
+
}
|
|
1439
|
+
}
|
|
1440
|
+
class Pipeline {
|
|
1441
|
+
constructor(transformers) {
|
|
1442
|
+
this.transformers_ = [];
|
|
1443
|
+
for (let transformer of transformers) {
|
|
1444
|
+
this.transformers_.push(new InternalTransformer(transformer));
|
|
1445
|
+
}
|
|
1446
|
+
}
|
|
1447
|
+
async start(readable, writeable) {
|
|
1448
|
+
if (!this.transformers_ || this.transformers_.length === 0) {
|
|
1449
|
+
console.log("[Pipeline] No transformers.");
|
|
1450
|
+
return;
|
|
1451
|
+
}
|
|
1452
|
+
try {
|
|
1453
|
+
let orgReader = readable;
|
|
1454
|
+
for (let transformer of this.transformers_) {
|
|
1455
|
+
readable = readable.pipeThrough(new TransformStream(transformer));
|
|
1456
|
+
}
|
|
1457
|
+
readable.pipeTo(writeable).then(async () => {
|
|
1458
|
+
console.log("[Pipeline] Setup.");
|
|
1459
|
+
await writeable.abort();
|
|
1460
|
+
await orgReader.cancel();
|
|
1461
|
+
}).catch(async (e) => {
|
|
1462
|
+
readable.cancel().then(() => {
|
|
1463
|
+
console.log("[Pipeline] Shutting down streams after abort.");
|
|
1464
|
+
}).catch((e2) => {
|
|
1465
|
+
console.error("[Pipeline] Error from stream transform:", e2);
|
|
1466
|
+
});
|
|
1467
|
+
await writeable.abort(e);
|
|
1468
|
+
await orgReader.cancel(e);
|
|
1469
|
+
});
|
|
1470
|
+
} catch (e) {
|
|
1471
|
+
this.destroy();
|
|
1472
|
+
return;
|
|
1473
|
+
}
|
|
1474
|
+
console.log("[Pipeline] Pipeline started.");
|
|
1475
|
+
}
|
|
1476
|
+
async destroy() {
|
|
1477
|
+
console.log("[Pipeline] Destroying Pipeline.");
|
|
1478
|
+
for (let transformer of this.transformers_) {
|
|
1479
|
+
transformer.stop();
|
|
1480
|
+
}
|
|
1481
|
+
}
|
|
1482
|
+
}
|
|
1483
|
+
class MediaProcessor {
|
|
1484
|
+
constructor() {
|
|
1485
|
+
this.uuid_ = v4();
|
|
1486
|
+
const report = new ReportBuilder().action("MediaProcessor").guid(this.uuid_).variation("Create").build();
|
|
1487
|
+
Reporter.report(report);
|
|
1488
|
+
}
|
|
1489
|
+
transform(readable, writable) {
|
|
1490
|
+
this.readable_ = readable;
|
|
1491
|
+
this.writable_ = writable;
|
|
1492
|
+
return this.transformInternal();
|
|
1493
|
+
}
|
|
1494
|
+
transformInternal() {
|
|
1495
|
+
return new Promise((resolve, reject) => {
|
|
1496
|
+
if (!this.transformers_ || this.transformers_.length === 0) {
|
|
1497
|
+
const report = new ReportBuilder().action("MediaProcessor").guid(this.uuid_).message(Key.errors["transformer_none"]).variation("Error").build();
|
|
1498
|
+
Reporter.report(report);
|
|
1499
|
+
reject("[MediaProcessor] Need to set transformers.");
|
|
1500
|
+
}
|
|
1501
|
+
if (this.pipeline_) {
|
|
1502
|
+
this.pipeline_.destroy();
|
|
1503
|
+
}
|
|
1504
|
+
this.pipeline_ = new Pipeline(this.transformers_);
|
|
1505
|
+
this.pipeline_.start(this.readable_, this.writable_).then(() => {
|
|
1506
|
+
resolve();
|
|
1507
|
+
}).catch((e) => {
|
|
1508
|
+
reject(e);
|
|
1509
|
+
});
|
|
1510
|
+
});
|
|
1511
|
+
}
|
|
1512
|
+
setTransformers(transformers) {
|
|
1513
|
+
const report = new ReportBuilder().action("MediaProcessor").guid(this.uuid_).message(Key.updates["transformer_new"]).variation("Update").build();
|
|
1514
|
+
Reporter.report(report);
|
|
1515
|
+
this.transformers_ = transformers;
|
|
1516
|
+
if (this.readable_ && this.writable_) {
|
|
1517
|
+
return this.transformInternal();
|
|
1518
|
+
}
|
|
1519
|
+
return Promise.resolve();
|
|
1520
|
+
}
|
|
1521
|
+
destroy() {
|
|
1522
|
+
return new Promise((resolve) => {
|
|
1523
|
+
if (this.pipeline_) {
|
|
1524
|
+
this.pipeline_.destroy();
|
|
1525
|
+
}
|
|
1526
|
+
const report = new ReportBuilder().action("MediaProcessor").guid(this.uuid_).variation("Delete").build();
|
|
1527
|
+
Reporter.report(report);
|
|
1528
|
+
resolve();
|
|
1529
|
+
});
|
|
1530
|
+
}
|
|
1531
|
+
}
|
|
1532
|
+
class InsertableStreamHelper {
|
|
1533
|
+
constructor() {
|
|
1534
|
+
this.processor_ = null;
|
|
1535
|
+
this.generator_ = null;
|
|
1536
|
+
}
|
|
1537
|
+
init(track) {
|
|
1538
|
+
return new Promise((resolve, reject) => {
|
|
1539
|
+
try {
|
|
1540
|
+
this.processor_ = new MediaStreamTrackProcessor(track);
|
|
1541
|
+
} catch (e) {
|
|
1542
|
+
console.log(`[InsertableStreamHelper] MediaStreamTrackProcessor failed: ${e}`);
|
|
1543
|
+
reject(e);
|
|
1544
|
+
}
|
|
1545
|
+
try {
|
|
1546
|
+
if (track.kind === "audio") {
|
|
1547
|
+
this.generator_ = new MediaStreamTrackGenerator({ kind: "audio" });
|
|
1548
|
+
} else if (track.kind === "video") {
|
|
1549
|
+
this.generator_ = new MediaStreamTrackGenerator({ kind: "video" });
|
|
1550
|
+
} else {
|
|
1551
|
+
reject("kind not supported");
|
|
1552
|
+
}
|
|
1553
|
+
} catch (e) {
|
|
1554
|
+
console.log(`[InsertableStreamHelper] MediaStreamTrackGenerator failed: ${e}`);
|
|
1555
|
+
reject(e);
|
|
1556
|
+
}
|
|
1557
|
+
resolve();
|
|
1558
|
+
});
|
|
1559
|
+
}
|
|
1560
|
+
getReadable() {
|
|
1561
|
+
return this.processor_.readable;
|
|
1562
|
+
}
|
|
1563
|
+
getWriteable() {
|
|
1564
|
+
return this.generator_.writable;
|
|
1565
|
+
}
|
|
1566
|
+
getProccesorTrack() {
|
|
1567
|
+
return this.generator_;
|
|
1568
|
+
}
|
|
1569
|
+
}
|
|
1570
|
+
class MediaProcessorConnector {
|
|
1571
|
+
constructor(vonageMediaProcessor) {
|
|
1572
|
+
this.insertableStreamHelper_ = new InsertableStreamHelper();
|
|
1573
|
+
this.mediaProcessor_ = vonageMediaProcessor;
|
|
1574
|
+
}
|
|
1575
|
+
setTrack(track) {
|
|
1576
|
+
return new Promise((resolve, reject) => {
|
|
1577
|
+
this.insertableStreamHelper_.init(track).then(() => {
|
|
1578
|
+
this.mediaProcessor_.transform(this.insertableStreamHelper_.getReadable(), this.insertableStreamHelper_.getWriteable()).then(() => {
|
|
1579
|
+
resolve(this.insertableStreamHelper_.getProccesorTrack());
|
|
1580
|
+
}).catch((e) => {
|
|
1581
|
+
reject(e);
|
|
1582
|
+
});
|
|
1583
|
+
}).catch((e) => {
|
|
1584
|
+
reject(e);
|
|
1585
|
+
});
|
|
1586
|
+
});
|
|
1587
|
+
}
|
|
1588
|
+
destroy() {
|
|
1589
|
+
return new Promise((resolve, reject) => {
|
|
1590
|
+
if (this.mediaProcessor_) {
|
|
1591
|
+
this.mediaProcessor_.destroy().then(() => {
|
|
1592
|
+
resolve();
|
|
1593
|
+
}).catch((e) => {
|
|
1594
|
+
reject(e);
|
|
1595
|
+
});
|
|
1596
|
+
} else {
|
|
1597
|
+
reject("no processor");
|
|
1598
|
+
}
|
|
1599
|
+
});
|
|
1600
|
+
}
|
|
1601
|
+
}
|
|
1602
|
+
export { MediaProcessor, MediaProcessorConnector, isSupported, setMetadata };
|