@bigbinary/neeto-media-recorder 1.0.1 → 1.0.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/core.js +1369 -0
- package/core.js.map +1 -0
- package/index.js +697 -979
- package/index.js.map +1 -1
- package/package.json +22 -3
- package/src/translations/en.json +33 -0
- package/src/translations/index.js +3 -0
- package/utils.js +11 -0
- package/utils.js.map +1 -0
package/core.js
ADDED
|
@@ -0,0 +1,1369 @@
|
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
import { isNot, existsBy, isNotEmpty } from '@bigbinary/neeto-cist';
|
|
3
|
+
import { identity, isNil, pick } from 'ramda';
|
|
4
|
+
import { RETRIABLE_ERRORS, UPLOAD_EVENT, UPLOAD_STATUS, SCREEN_RECORDER_STATUS, SCREEN_RECORDER_ERROR, SCREEN_RECORDER_EVENT, ONE_SECOND, ONE_SECOND_IN_MILLISECONDS } from '@bigbinary/neeto-media-recorder/constants';
|
|
5
|
+
import { sleep } from '@bigbinary/neeto-media-recorder/utils';
|
|
6
|
+
import { withImmutableActions } from '@bigbinary/neeto-commons-frontend/react-utils';
|
|
7
|
+
import { create as create$3 } from 'zustand';
|
|
8
|
+
|
|
9
|
+
function _arrayLikeToArray(arr, len) {
|
|
10
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
11
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
12
|
+
return arr2;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function _arrayWithoutHoles(arr) {
|
|
16
|
+
if (Array.isArray(arr)) return _arrayLikeToArray(arr);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function _iterableToArray(iter) {
|
|
20
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
24
|
+
if (!o) return;
|
|
25
|
+
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
26
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
27
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
28
|
+
if (n === "Map" || n === "Set") return Array.from(o);
|
|
29
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function _nonIterableSpread() {
|
|
33
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function _toConsumableArray(arr) {
|
|
37
|
+
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
41
|
+
try {
|
|
42
|
+
var info = gen[key](arg);
|
|
43
|
+
var value = info.value;
|
|
44
|
+
} catch (error) {
|
|
45
|
+
reject(error);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
if (info.done) {
|
|
49
|
+
resolve(value);
|
|
50
|
+
} else {
|
|
51
|
+
Promise.resolve(value).then(_next, _throw);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
function _asyncToGenerator(fn) {
|
|
55
|
+
return function () {
|
|
56
|
+
var self = this,
|
|
57
|
+
args = arguments;
|
|
58
|
+
return new Promise(function (resolve, reject) {
|
|
59
|
+
var gen = fn.apply(self, args);
|
|
60
|
+
function _next(value) {
|
|
61
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
62
|
+
}
|
|
63
|
+
function _throw(err) {
|
|
64
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
65
|
+
}
|
|
66
|
+
_next(undefined);
|
|
67
|
+
});
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function _classCallCheck(instance, Constructor) {
|
|
72
|
+
if (!(instance instanceof Constructor)) {
|
|
73
|
+
throw new TypeError("Cannot call a class as a function");
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function _typeof$1(obj) {
|
|
78
|
+
"@babel/helpers - typeof";
|
|
79
|
+
|
|
80
|
+
return _typeof$1 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
|
|
81
|
+
return typeof obj;
|
|
82
|
+
} : function (obj) {
|
|
83
|
+
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
84
|
+
}, _typeof$1(obj);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function _toPrimitive(input, hint) {
|
|
88
|
+
if (_typeof$1(input) !== "object" || input === null) return input;
|
|
89
|
+
var prim = input[Symbol.toPrimitive];
|
|
90
|
+
if (prim !== undefined) {
|
|
91
|
+
var res = prim.call(input, hint || "default");
|
|
92
|
+
if (_typeof$1(res) !== "object") return res;
|
|
93
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
94
|
+
}
|
|
95
|
+
return (hint === "string" ? String : Number)(input);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function _toPropertyKey(arg) {
|
|
99
|
+
var key = _toPrimitive(arg, "string");
|
|
100
|
+
return _typeof$1(key) === "symbol" ? key : String(key);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function _defineProperties(target, props) {
|
|
104
|
+
for (var i = 0; i < props.length; i++) {
|
|
105
|
+
var descriptor = props[i];
|
|
106
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
107
|
+
descriptor.configurable = true;
|
|
108
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
109
|
+
Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
function _createClass(Constructor, protoProps, staticProps) {
|
|
113
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
114
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
115
|
+
Object.defineProperty(Constructor, "prototype", {
|
|
116
|
+
writable: false
|
|
117
|
+
});
|
|
118
|
+
return Constructor;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function _defineProperty(obj, key, value) {
|
|
122
|
+
key = _toPropertyKey(key);
|
|
123
|
+
if (key in obj) {
|
|
124
|
+
Object.defineProperty(obj, key, {
|
|
125
|
+
value: value,
|
|
126
|
+
enumerable: true,
|
|
127
|
+
configurable: true,
|
|
128
|
+
writable: true
|
|
129
|
+
});
|
|
130
|
+
} else {
|
|
131
|
+
obj[key] = value;
|
|
132
|
+
}
|
|
133
|
+
return obj;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function _classApplyDescriptorGet(receiver, descriptor) {
|
|
137
|
+
if (descriptor.get) {
|
|
138
|
+
return descriptor.get.call(receiver);
|
|
139
|
+
}
|
|
140
|
+
return descriptor.value;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
function _classExtractFieldDescriptor(receiver, privateMap, action) {
|
|
144
|
+
if (!privateMap.has(receiver)) {
|
|
145
|
+
throw new TypeError("attempted to " + action + " private field on non-instance");
|
|
146
|
+
}
|
|
147
|
+
return privateMap.get(receiver);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function _classPrivateFieldGet(receiver, privateMap) {
|
|
151
|
+
var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get");
|
|
152
|
+
return _classApplyDescriptorGet(receiver, descriptor);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
function _classApplyDescriptorSet(receiver, descriptor, value) {
|
|
156
|
+
if (descriptor.set) {
|
|
157
|
+
descriptor.set.call(receiver, value);
|
|
158
|
+
} else {
|
|
159
|
+
if (!descriptor.writable) {
|
|
160
|
+
throw new TypeError("attempted to set read only private field");
|
|
161
|
+
}
|
|
162
|
+
descriptor.value = value;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
function _classPrivateFieldSet(receiver, privateMap, value) {
|
|
167
|
+
var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set");
|
|
168
|
+
_classApplyDescriptorSet(receiver, descriptor, value);
|
|
169
|
+
return value;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
function getDefaultExportFromCjs (x) {
|
|
173
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
var regeneratorRuntime$1 = {exports: {}};
|
|
177
|
+
|
|
178
|
+
var _typeof = {exports: {}};
|
|
179
|
+
|
|
180
|
+
_typeof.exports;
|
|
181
|
+
|
|
182
|
+
(function (module) {
|
|
183
|
+
function _typeof(obj) {
|
|
184
|
+
"@babel/helpers - typeof";
|
|
185
|
+
|
|
186
|
+
return (module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
|
|
187
|
+
return typeof obj;
|
|
188
|
+
} : function (obj) {
|
|
189
|
+
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
190
|
+
}, module.exports.__esModule = true, module.exports["default"] = module.exports), _typeof(obj);
|
|
191
|
+
}
|
|
192
|
+
module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
193
|
+
} (_typeof));
|
|
194
|
+
|
|
195
|
+
var _typeofExports = _typeof.exports;
|
|
196
|
+
|
|
197
|
+
regeneratorRuntime$1.exports;
|
|
198
|
+
|
|
199
|
+
(function (module) {
|
|
200
|
+
var _typeof = _typeofExports["default"];
|
|
201
|
+
function _regeneratorRuntime() {
|
|
202
|
+
module.exports = _regeneratorRuntime = function _regeneratorRuntime() {
|
|
203
|
+
return exports;
|
|
204
|
+
}, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
205
|
+
var exports = {},
|
|
206
|
+
Op = Object.prototype,
|
|
207
|
+
hasOwn = Op.hasOwnProperty,
|
|
208
|
+
defineProperty = Object.defineProperty || function (obj, key, desc) {
|
|
209
|
+
obj[key] = desc.value;
|
|
210
|
+
},
|
|
211
|
+
$Symbol = "function" == typeof Symbol ? Symbol : {},
|
|
212
|
+
iteratorSymbol = $Symbol.iterator || "@@iterator",
|
|
213
|
+
asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
|
|
214
|
+
toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
|
|
215
|
+
function define(obj, key, value) {
|
|
216
|
+
return Object.defineProperty(obj, key, {
|
|
217
|
+
value: value,
|
|
218
|
+
enumerable: !0,
|
|
219
|
+
configurable: !0,
|
|
220
|
+
writable: !0
|
|
221
|
+
}), obj[key];
|
|
222
|
+
}
|
|
223
|
+
try {
|
|
224
|
+
define({}, "");
|
|
225
|
+
} catch (err) {
|
|
226
|
+
define = function define(obj, key, value) {
|
|
227
|
+
return obj[key] = value;
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
function wrap(innerFn, outerFn, self, tryLocsList) {
|
|
231
|
+
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
|
|
232
|
+
generator = Object.create(protoGenerator.prototype),
|
|
233
|
+
context = new Context(tryLocsList || []);
|
|
234
|
+
return defineProperty(generator, "_invoke", {
|
|
235
|
+
value: makeInvokeMethod(innerFn, self, context)
|
|
236
|
+
}), generator;
|
|
237
|
+
}
|
|
238
|
+
function tryCatch(fn, obj, arg) {
|
|
239
|
+
try {
|
|
240
|
+
return {
|
|
241
|
+
type: "normal",
|
|
242
|
+
arg: fn.call(obj, arg)
|
|
243
|
+
};
|
|
244
|
+
} catch (err) {
|
|
245
|
+
return {
|
|
246
|
+
type: "throw",
|
|
247
|
+
arg: err
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
exports.wrap = wrap;
|
|
252
|
+
var ContinueSentinel = {};
|
|
253
|
+
function Generator() {}
|
|
254
|
+
function GeneratorFunction() {}
|
|
255
|
+
function GeneratorFunctionPrototype() {}
|
|
256
|
+
var IteratorPrototype = {};
|
|
257
|
+
define(IteratorPrototype, iteratorSymbol, function () {
|
|
258
|
+
return this;
|
|
259
|
+
});
|
|
260
|
+
var getProto = Object.getPrototypeOf,
|
|
261
|
+
NativeIteratorPrototype = getProto && getProto(getProto(values([])));
|
|
262
|
+
NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
|
|
263
|
+
var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
|
|
264
|
+
function defineIteratorMethods(prototype) {
|
|
265
|
+
["next", "throw", "return"].forEach(function (method) {
|
|
266
|
+
define(prototype, method, function (arg) {
|
|
267
|
+
return this._invoke(method, arg);
|
|
268
|
+
});
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
function AsyncIterator(generator, PromiseImpl) {
|
|
272
|
+
function invoke(method, arg, resolve, reject) {
|
|
273
|
+
var record = tryCatch(generator[method], generator, arg);
|
|
274
|
+
if ("throw" !== record.type) {
|
|
275
|
+
var result = record.arg,
|
|
276
|
+
value = result.value;
|
|
277
|
+
return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
|
|
278
|
+
invoke("next", value, resolve, reject);
|
|
279
|
+
}, function (err) {
|
|
280
|
+
invoke("throw", err, resolve, reject);
|
|
281
|
+
}) : PromiseImpl.resolve(value).then(function (unwrapped) {
|
|
282
|
+
result.value = unwrapped, resolve(result);
|
|
283
|
+
}, function (error) {
|
|
284
|
+
return invoke("throw", error, resolve, reject);
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
reject(record.arg);
|
|
288
|
+
}
|
|
289
|
+
var previousPromise;
|
|
290
|
+
defineProperty(this, "_invoke", {
|
|
291
|
+
value: function value(method, arg) {
|
|
292
|
+
function callInvokeWithMethodAndArg() {
|
|
293
|
+
return new PromiseImpl(function (resolve, reject) {
|
|
294
|
+
invoke(method, arg, resolve, reject);
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
|
298
|
+
}
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
function makeInvokeMethod(innerFn, self, context) {
|
|
302
|
+
var state = "suspendedStart";
|
|
303
|
+
return function (method, arg) {
|
|
304
|
+
if ("executing" === state) throw new Error("Generator is already running");
|
|
305
|
+
if ("completed" === state) {
|
|
306
|
+
if ("throw" === method) throw arg;
|
|
307
|
+
return doneResult();
|
|
308
|
+
}
|
|
309
|
+
for (context.method = method, context.arg = arg;;) {
|
|
310
|
+
var delegate = context.delegate;
|
|
311
|
+
if (delegate) {
|
|
312
|
+
var delegateResult = maybeInvokeDelegate(delegate, context);
|
|
313
|
+
if (delegateResult) {
|
|
314
|
+
if (delegateResult === ContinueSentinel) continue;
|
|
315
|
+
return delegateResult;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
|
|
319
|
+
if ("suspendedStart" === state) throw state = "completed", context.arg;
|
|
320
|
+
context.dispatchException(context.arg);
|
|
321
|
+
} else "return" === context.method && context.abrupt("return", context.arg);
|
|
322
|
+
state = "executing";
|
|
323
|
+
var record = tryCatch(innerFn, self, context);
|
|
324
|
+
if ("normal" === record.type) {
|
|
325
|
+
if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
|
|
326
|
+
return {
|
|
327
|
+
value: record.arg,
|
|
328
|
+
done: context.done
|
|
329
|
+
};
|
|
330
|
+
}
|
|
331
|
+
"throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
|
|
332
|
+
}
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
function maybeInvokeDelegate(delegate, context) {
|
|
336
|
+
var methodName = context.method,
|
|
337
|
+
method = delegate.iterator[methodName];
|
|
338
|
+
if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel;
|
|
339
|
+
var record = tryCatch(method, delegate.iterator, context.arg);
|
|
340
|
+
if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
|
|
341
|
+
var info = record.arg;
|
|
342
|
+
return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel);
|
|
343
|
+
}
|
|
344
|
+
function pushTryEntry(locs) {
|
|
345
|
+
var entry = {
|
|
346
|
+
tryLoc: locs[0]
|
|
347
|
+
};
|
|
348
|
+
1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
|
|
349
|
+
}
|
|
350
|
+
function resetTryEntry(entry) {
|
|
351
|
+
var record = entry.completion || {};
|
|
352
|
+
record.type = "normal", delete record.arg, entry.completion = record;
|
|
353
|
+
}
|
|
354
|
+
function Context(tryLocsList) {
|
|
355
|
+
this.tryEntries = [{
|
|
356
|
+
tryLoc: "root"
|
|
357
|
+
}], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
|
|
358
|
+
}
|
|
359
|
+
function values(iterable) {
|
|
360
|
+
if (iterable) {
|
|
361
|
+
var iteratorMethod = iterable[iteratorSymbol];
|
|
362
|
+
if (iteratorMethod) return iteratorMethod.call(iterable);
|
|
363
|
+
if ("function" == typeof iterable.next) return iterable;
|
|
364
|
+
if (!isNaN(iterable.length)) {
|
|
365
|
+
var i = -1,
|
|
366
|
+
next = function next() {
|
|
367
|
+
for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
|
|
368
|
+
return next.value = undefined, next.done = !0, next;
|
|
369
|
+
};
|
|
370
|
+
return next.next = next;
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
return {
|
|
374
|
+
next: doneResult
|
|
375
|
+
};
|
|
376
|
+
}
|
|
377
|
+
function doneResult() {
|
|
378
|
+
return {
|
|
379
|
+
value: undefined,
|
|
380
|
+
done: !0
|
|
381
|
+
};
|
|
382
|
+
}
|
|
383
|
+
return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", {
|
|
384
|
+
value: GeneratorFunctionPrototype,
|
|
385
|
+
configurable: !0
|
|
386
|
+
}), defineProperty(GeneratorFunctionPrototype, "constructor", {
|
|
387
|
+
value: GeneratorFunction,
|
|
388
|
+
configurable: !0
|
|
389
|
+
}), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
|
|
390
|
+
var ctor = "function" == typeof genFun && genFun.constructor;
|
|
391
|
+
return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
|
|
392
|
+
}, exports.mark = function (genFun) {
|
|
393
|
+
return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
|
|
394
|
+
}, exports.awrap = function (arg) {
|
|
395
|
+
return {
|
|
396
|
+
__await: arg
|
|
397
|
+
};
|
|
398
|
+
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
|
|
399
|
+
return this;
|
|
400
|
+
}), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
|
|
401
|
+
void 0 === PromiseImpl && (PromiseImpl = Promise);
|
|
402
|
+
var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
|
|
403
|
+
return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
|
|
404
|
+
return result.done ? result.value : iter.next();
|
|
405
|
+
});
|
|
406
|
+
}, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
|
|
407
|
+
return this;
|
|
408
|
+
}), define(Gp, "toString", function () {
|
|
409
|
+
return "[object Generator]";
|
|
410
|
+
}), exports.keys = function (val) {
|
|
411
|
+
var object = Object(val),
|
|
412
|
+
keys = [];
|
|
413
|
+
for (var key in object) keys.push(key);
|
|
414
|
+
return keys.reverse(), function next() {
|
|
415
|
+
for (; keys.length;) {
|
|
416
|
+
var key = keys.pop();
|
|
417
|
+
if (key in object) return next.value = key, next.done = !1, next;
|
|
418
|
+
}
|
|
419
|
+
return next.done = !0, next;
|
|
420
|
+
};
|
|
421
|
+
}, exports.values = values, Context.prototype = {
|
|
422
|
+
constructor: Context,
|
|
423
|
+
reset: function reset(skipTempReset) {
|
|
424
|
+
if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined);
|
|
425
|
+
},
|
|
426
|
+
stop: function stop() {
|
|
427
|
+
this.done = !0;
|
|
428
|
+
var rootRecord = this.tryEntries[0].completion;
|
|
429
|
+
if ("throw" === rootRecord.type) throw rootRecord.arg;
|
|
430
|
+
return this.rval;
|
|
431
|
+
},
|
|
432
|
+
dispatchException: function dispatchException(exception) {
|
|
433
|
+
if (this.done) throw exception;
|
|
434
|
+
var context = this;
|
|
435
|
+
function handle(loc, caught) {
|
|
436
|
+
return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
|
|
437
|
+
}
|
|
438
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
439
|
+
var entry = this.tryEntries[i],
|
|
440
|
+
record = entry.completion;
|
|
441
|
+
if ("root" === entry.tryLoc) return handle("end");
|
|
442
|
+
if (entry.tryLoc <= this.prev) {
|
|
443
|
+
var hasCatch = hasOwn.call(entry, "catchLoc"),
|
|
444
|
+
hasFinally = hasOwn.call(entry, "finallyLoc");
|
|
445
|
+
if (hasCatch && hasFinally) {
|
|
446
|
+
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
|
|
447
|
+
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
|
|
448
|
+
} else if (hasCatch) {
|
|
449
|
+
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
|
|
450
|
+
} else {
|
|
451
|
+
if (!hasFinally) throw new Error("try statement without catch or finally");
|
|
452
|
+
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
},
|
|
457
|
+
abrupt: function abrupt(type, arg) {
|
|
458
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
459
|
+
var entry = this.tryEntries[i];
|
|
460
|
+
if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
|
|
461
|
+
var finallyEntry = entry;
|
|
462
|
+
break;
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
|
|
466
|
+
var record = finallyEntry ? finallyEntry.completion : {};
|
|
467
|
+
return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
|
|
468
|
+
},
|
|
469
|
+
complete: function complete(record, afterLoc) {
|
|
470
|
+
if ("throw" === record.type) throw record.arg;
|
|
471
|
+
return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel;
|
|
472
|
+
},
|
|
473
|
+
finish: function finish(finallyLoc) {
|
|
474
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
475
|
+
var entry = this.tryEntries[i];
|
|
476
|
+
if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
|
|
477
|
+
}
|
|
478
|
+
},
|
|
479
|
+
"catch": function _catch(tryLoc) {
|
|
480
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
481
|
+
var entry = this.tryEntries[i];
|
|
482
|
+
if (entry.tryLoc === tryLoc) {
|
|
483
|
+
var record = entry.completion;
|
|
484
|
+
if ("throw" === record.type) {
|
|
485
|
+
var thrown = record.arg;
|
|
486
|
+
resetTryEntry(entry);
|
|
487
|
+
}
|
|
488
|
+
return thrown;
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
throw new Error("illegal catch attempt");
|
|
492
|
+
},
|
|
493
|
+
delegateYield: function delegateYield(iterable, resultName, nextLoc) {
|
|
494
|
+
return this.delegate = {
|
|
495
|
+
iterator: values(iterable),
|
|
496
|
+
resultName: resultName,
|
|
497
|
+
nextLoc: nextLoc
|
|
498
|
+
}, "next" === this.method && (this.arg = undefined), ContinueSentinel;
|
|
499
|
+
}
|
|
500
|
+
}, exports;
|
|
501
|
+
}
|
|
502
|
+
module.exports = _regeneratorRuntime, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
503
|
+
} (regeneratorRuntime$1));
|
|
504
|
+
|
|
505
|
+
var regeneratorRuntimeExports = regeneratorRuntime$1.exports;
|
|
506
|
+
|
|
507
|
+
// TODO(Babel 8): Remove this file.
|
|
508
|
+
|
|
509
|
+
var runtime = regeneratorRuntimeExports();
|
|
510
|
+
var regenerator = runtime;
|
|
511
|
+
|
|
512
|
+
// Copied from https://github.com/facebook/regenerator/blob/main/packages/runtime/runtime.js#L736=
|
|
513
|
+
try {
|
|
514
|
+
regeneratorRuntime = runtime;
|
|
515
|
+
} catch (accidentalStrictMode) {
|
|
516
|
+
if (typeof globalThis === "object") {
|
|
517
|
+
globalThis.regeneratorRuntime = runtime;
|
|
518
|
+
} else {
|
|
519
|
+
Function("r", "regeneratorRuntime = r")(runtime);
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
var _regeneratorRuntime = /*@__PURE__*/getDefaultExportFromCjs(regenerator);
|
|
524
|
+
|
|
525
|
+
var create$2 = function create(_ref) {
|
|
526
|
+
var recordingId = _ref.recordingId,
|
|
527
|
+
payload = _ref.payload;
|
|
528
|
+
return axios.post("/api/v1/recordings/".concat(recordingId, "/abort_upload"), {
|
|
529
|
+
abortUpload: payload
|
|
530
|
+
});
|
|
531
|
+
};
|
|
532
|
+
var abortUploadApi = {
|
|
533
|
+
create: create$2
|
|
534
|
+
};
|
|
535
|
+
|
|
536
|
+
var create$1 = function create(_ref) {
|
|
537
|
+
var recordingId = _ref.recordingId,
|
|
538
|
+
payload = _ref.payload;
|
|
539
|
+
return axios.post("/api/v1/recordings/".concat(recordingId, "/complete_upload"), {
|
|
540
|
+
completeUpload: payload
|
|
541
|
+
});
|
|
542
|
+
};
|
|
543
|
+
var completeUploadApi = {
|
|
544
|
+
create: create$1
|
|
545
|
+
};
|
|
546
|
+
|
|
547
|
+
var create = function create(_ref) {
|
|
548
|
+
var recordingId = _ref.recordingId,
|
|
549
|
+
payload = _ref.payload;
|
|
550
|
+
return axios.post("/api/v1/recordings/".concat(recordingId, "/part_presigned_url"), {
|
|
551
|
+
partPresignedUrl: payload
|
|
552
|
+
});
|
|
553
|
+
};
|
|
554
|
+
var partPresignedUrlApi = {
|
|
555
|
+
create: create
|
|
556
|
+
};
|
|
557
|
+
|
|
558
|
+
var s3AxiosInstance = axios.create({
|
|
559
|
+
headers: {
|
|
560
|
+
"Content-Type": 'video/webm;codecs="vp9"'
|
|
561
|
+
}
|
|
562
|
+
});
|
|
563
|
+
s3AxiosInstance.interceptors.response.use(identity, function (error) {
|
|
564
|
+
return !axios.isCancel(error) && Promise.reject(error);
|
|
565
|
+
});
|
|
566
|
+
var presignedUpload = /*#__PURE__*/function () {
|
|
567
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref) {
|
|
568
|
+
var presignedUrl, blob, config, _ref$retries, retries, _ref$retryDelay, retryDelay, remainingAttempts, _error$response;
|
|
569
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
570
|
+
while (1) switch (_context.prev = _context.next) {
|
|
571
|
+
case 0:
|
|
572
|
+
presignedUrl = _ref.presignedUrl, blob = _ref.blob, config = _ref.config, _ref$retries = _ref.retries, retries = _ref$retries === void 0 ? 3 : _ref$retries, _ref$retryDelay = _ref.retryDelay, retryDelay = _ref$retryDelay === void 0 ? 4000 : _ref$retryDelay;
|
|
573
|
+
remainingAttempts = retries + 1;
|
|
574
|
+
case 2:
|
|
575
|
+
if (!remainingAttempts--) {
|
|
576
|
+
_context.next = 20;
|
|
577
|
+
break;
|
|
578
|
+
}
|
|
579
|
+
_context.prev = 3;
|
|
580
|
+
_context.next = 6;
|
|
581
|
+
return s3AxiosInstance.put(presignedUrl, blob, config);
|
|
582
|
+
case 6:
|
|
583
|
+
return _context.abrupt("return", _context.sent);
|
|
584
|
+
case 9:
|
|
585
|
+
_context.prev = 9;
|
|
586
|
+
_context.t0 = _context["catch"](3);
|
|
587
|
+
if (!(RETRIABLE_ERRORS.includes((_error$response = _context.t0.response) === null || _error$response === void 0 ? void 0 : _error$response.status) && remainingAttempts > 0)) {
|
|
588
|
+
_context.next = 17;
|
|
589
|
+
break;
|
|
590
|
+
}
|
|
591
|
+
_context.next = 14;
|
|
592
|
+
return sleep(retryDelay);
|
|
593
|
+
case 14:
|
|
594
|
+
retryDelay *= 2;
|
|
595
|
+
_context.next = 18;
|
|
596
|
+
break;
|
|
597
|
+
case 17:
|
|
598
|
+
throw _context.t0;
|
|
599
|
+
case 18:
|
|
600
|
+
_context.next = 2;
|
|
601
|
+
break;
|
|
602
|
+
case 20:
|
|
603
|
+
return _context.abrupt("return", null);
|
|
604
|
+
case 21:
|
|
605
|
+
case "end":
|
|
606
|
+
return _context.stop();
|
|
607
|
+
}
|
|
608
|
+
}, _callee, null, [[3, 9]]);
|
|
609
|
+
}));
|
|
610
|
+
return function presignedUpload(_x) {
|
|
611
|
+
return _ref2.apply(this, arguments);
|
|
612
|
+
};
|
|
613
|
+
}();
|
|
614
|
+
var s3Api = {
|
|
615
|
+
presignedUpload: presignedUpload
|
|
616
|
+
};
|
|
617
|
+
|
|
618
|
+
var prepareStore$1 = function prepareStore() {
|
|
619
|
+
return create$3(withImmutableActions(function () {
|
|
620
|
+
return {
|
|
621
|
+
status: ""
|
|
622
|
+
};
|
|
623
|
+
}));
|
|
624
|
+
};
|
|
625
|
+
|
|
626
|
+
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; }
|
|
627
|
+
function _objectSpread$2(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$2(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$2(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
628
|
+
function _classPrivateFieldInitSpec$1(obj, privateMap, value) { _checkPrivateRedeclaration$1(obj, privateMap); privateMap.set(obj, value); }
|
|
629
|
+
function _checkPrivateRedeclaration$1(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
|
630
|
+
var _recordingId = /*#__PURE__*/new WeakMap();
|
|
631
|
+
var _uploadId = /*#__PURE__*/new WeakMap();
|
|
632
|
+
var _unUploadedChunks = /*#__PURE__*/new WeakMap();
|
|
633
|
+
var _partNumber = /*#__PURE__*/new WeakMap();
|
|
634
|
+
var _s3PartUploadPromises = /*#__PURE__*/new WeakMap();
|
|
635
|
+
var _callbacks$1 = /*#__PURE__*/new WeakMap();
|
|
636
|
+
var _store$1 = /*#__PURE__*/new WeakMap();
|
|
637
|
+
var _abortController = /*#__PURE__*/new WeakMap();
|
|
638
|
+
var _pendingS3ChunkUploads = /*#__PURE__*/new WeakMap();
|
|
639
|
+
var _fireCallbacks$1 = /*#__PURE__*/new WeakMap();
|
|
640
|
+
var _uploadChunkToS = /*#__PURE__*/new WeakMap();
|
|
641
|
+
var _getCurrentUnUploadedBlob = /*#__PURE__*/new WeakMap();
|
|
642
|
+
var MultipartS3Uploader = /*#__PURE__*/function () {
|
|
643
|
+
function MultipartS3Uploader() {
|
|
644
|
+
var _this = this;
|
|
645
|
+
_classCallCheck(this, MultipartS3Uploader);
|
|
646
|
+
_defineProperty(this, "MIN_UPLOAD_CHUNK_SIZE", 5 * 1024 * 1024);
|
|
647
|
+
_classPrivateFieldInitSpec$1(this, _recordingId, {
|
|
648
|
+
writable: true,
|
|
649
|
+
value: ""
|
|
650
|
+
});
|
|
651
|
+
_classPrivateFieldInitSpec$1(this, _uploadId, {
|
|
652
|
+
writable: true,
|
|
653
|
+
value: ""
|
|
654
|
+
});
|
|
655
|
+
_classPrivateFieldInitSpec$1(this, _unUploadedChunks, {
|
|
656
|
+
writable: true,
|
|
657
|
+
value: []
|
|
658
|
+
});
|
|
659
|
+
_classPrivateFieldInitSpec$1(this, _partNumber, {
|
|
660
|
+
writable: true,
|
|
661
|
+
value: 1
|
|
662
|
+
});
|
|
663
|
+
_classPrivateFieldInitSpec$1(this, _s3PartUploadPromises, {
|
|
664
|
+
writable: true,
|
|
665
|
+
value: []
|
|
666
|
+
});
|
|
667
|
+
_classPrivateFieldInitSpec$1(this, _callbacks$1, {
|
|
668
|
+
writable: true,
|
|
669
|
+
value: {}
|
|
670
|
+
});
|
|
671
|
+
_classPrivateFieldInitSpec$1(this, _store$1, {
|
|
672
|
+
writable: true,
|
|
673
|
+
value: void 0
|
|
674
|
+
});
|
|
675
|
+
_classPrivateFieldInitSpec$1(this, _abortController, {
|
|
676
|
+
writable: true,
|
|
677
|
+
value: void 0
|
|
678
|
+
});
|
|
679
|
+
_classPrivateFieldInitSpec$1(this, _pendingS3ChunkUploads, {
|
|
680
|
+
writable: true,
|
|
681
|
+
value: []
|
|
682
|
+
});
|
|
683
|
+
_defineProperty(this, "initialize", function (recordingId, uploadId) {
|
|
684
|
+
_classPrivateFieldSet(_this, _recordingId, recordingId);
|
|
685
|
+
_classPrivateFieldSet(_this, _uploadId, uploadId);
|
|
686
|
+
_classPrivateFieldSet(_this, _abortController, new AbortController());
|
|
687
|
+
});
|
|
688
|
+
_defineProperty(this, "push", function (data) {
|
|
689
|
+
if (data.size > 0) {
|
|
690
|
+
_classPrivateFieldGet(_this, _unUploadedChunks).push(data);
|
|
691
|
+
}
|
|
692
|
+
logger.info("Current unuploaded data size is ", _classPrivateFieldGet(_this, _getCurrentUnUploadedBlob).call(_this).size / 1024 / 1024, "MB");
|
|
693
|
+
if (_classPrivateFieldGet(_this, _getCurrentUnUploadedBlob).call(_this).size > _this.MIN_UPLOAD_CHUNK_SIZE) {
|
|
694
|
+
var uploadChunkToS3Promise = _classPrivateFieldGet(_this, _uploadChunkToS).call(_this, _classPrivateFieldGet(_this, _unUploadedChunks));
|
|
695
|
+
_classPrivateFieldGet(_this, _pendingS3ChunkUploads).push(uploadChunkToS3Promise);
|
|
696
|
+
_classPrivateFieldSet(_this, _unUploadedChunks, []);
|
|
697
|
+
}
|
|
698
|
+
});
|
|
699
|
+
_defineProperty(this, "completeUpload", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
700
|
+
var uploadChunkToS3Promise, resolvedS3PartUploadPromises, parts;
|
|
701
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
702
|
+
while (1) switch (_context.prev = _context.next) {
|
|
703
|
+
case 0:
|
|
704
|
+
_context.prev = 0;
|
|
705
|
+
_classPrivateFieldGet(_this, _store$1).setState({
|
|
706
|
+
status: UPLOAD_STATUS.uploading
|
|
707
|
+
});
|
|
708
|
+
|
|
709
|
+
// Upload last chunk; only if last chunk has data
|
|
710
|
+
if (_classPrivateFieldGet(_this, _getCurrentUnUploadedBlob).call(_this).size > 0) {
|
|
711
|
+
uploadChunkToS3Promise = _classPrivateFieldGet(_this, _uploadChunkToS).call(_this, _classPrivateFieldGet(_this, _unUploadedChunks));
|
|
712
|
+
_classPrivateFieldGet(_this, _pendingS3ChunkUploads).push(uploadChunkToS3Promise);
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
/**
|
|
716
|
+
* Wait for all the pending uploadToS3Promises.
|
|
717
|
+
* Else we encounter a race condition where a new request is made for presignedUrl
|
|
718
|
+
* but at the same time we reach the resolvedS3PartUploadPromises line and await
|
|
719
|
+
* the s3PartUploadPromises. And the s3PartUploadPromises is resolved before
|
|
720
|
+
* adding the new presignedUrl part upload to s3PartUploadPromises.
|
|
721
|
+
* This results in incorrect partNumbers.
|
|
722
|
+
*/
|
|
723
|
+
_context.next = 5;
|
|
724
|
+
return Promise.all(_classPrivateFieldGet(_this, _pendingS3ChunkUploads));
|
|
725
|
+
case 5:
|
|
726
|
+
_context.next = 7;
|
|
727
|
+
return Promise.all(_classPrivateFieldGet(_this, _s3PartUploadPromises));
|
|
728
|
+
case 7:
|
|
729
|
+
resolvedS3PartUploadPromises = _context.sent;
|
|
730
|
+
parts = resolvedS3PartUploadPromises.map(function (resolvedResponse) {
|
|
731
|
+
return {
|
|
732
|
+
etag: resolvedResponse.headers.etag,
|
|
733
|
+
partNumber: new URL(resolvedResponse.request.responseURL).searchParams.get("partNumber")
|
|
734
|
+
};
|
|
735
|
+
});
|
|
736
|
+
_context.next = 11;
|
|
737
|
+
return completeUploadApi.create({
|
|
738
|
+
recordingId: _classPrivateFieldGet(_this, _recordingId),
|
|
739
|
+
payload: {
|
|
740
|
+
parts: parts,
|
|
741
|
+
uploadId: _classPrivateFieldGet(_this, _uploadId)
|
|
742
|
+
}
|
|
743
|
+
});
|
|
744
|
+
case 11:
|
|
745
|
+
_context.next = 13;
|
|
746
|
+
return _classPrivateFieldGet(_this, _store$1).setState({
|
|
747
|
+
status: UPLOAD_STATUS.completed
|
|
748
|
+
});
|
|
749
|
+
case 13:
|
|
750
|
+
_classPrivateFieldGet(_this, _fireCallbacks$1).call(_this, UPLOAD_EVENT.onComplete);
|
|
751
|
+
_context.next = 19;
|
|
752
|
+
break;
|
|
753
|
+
case 16:
|
|
754
|
+
_context.prev = 16;
|
|
755
|
+
_context.t0 = _context["catch"](0);
|
|
756
|
+
logger.error(_context.t0);
|
|
757
|
+
case 19:
|
|
758
|
+
case "end":
|
|
759
|
+
return _context.stop();
|
|
760
|
+
}
|
|
761
|
+
}, _callee, null, [[0, 16]]);
|
|
762
|
+
})));
|
|
763
|
+
_defineProperty(this, "abortUpload", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
764
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
765
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
766
|
+
case 0:
|
|
767
|
+
_context2.prev = 0;
|
|
768
|
+
_classPrivateFieldGet(_this, _store$1).setState({
|
|
769
|
+
status: UPLOAD_STATUS.aborting
|
|
770
|
+
});
|
|
771
|
+
_classPrivateFieldGet(_this, _abortController).abort();
|
|
772
|
+
_context2.next = 5;
|
|
773
|
+
return abortUploadApi.create({
|
|
774
|
+
recordingId: _classPrivateFieldGet(_this, _recordingId),
|
|
775
|
+
payload: {
|
|
776
|
+
uploadId: _classPrivateFieldGet(_this, _uploadId)
|
|
777
|
+
}
|
|
778
|
+
});
|
|
779
|
+
case 5:
|
|
780
|
+
_classPrivateFieldSet(_this, _unUploadedChunks, []);
|
|
781
|
+
_classPrivateFieldSet(_this, _partNumber, 1);
|
|
782
|
+
_classPrivateFieldSet(_this, _s3PartUploadPromises, []);
|
|
783
|
+
_classPrivateFieldGet(_this, _store$1).setState({
|
|
784
|
+
status: ""
|
|
785
|
+
});
|
|
786
|
+
_classPrivateFieldSet(_this, _abortController, null);
|
|
787
|
+
_context2.next = 15;
|
|
788
|
+
break;
|
|
789
|
+
case 12:
|
|
790
|
+
_context2.prev = 12;
|
|
791
|
+
_context2.t0 = _context2["catch"](0);
|
|
792
|
+
logger.error(_context2.t0);
|
|
793
|
+
case 15:
|
|
794
|
+
case "end":
|
|
795
|
+
return _context2.stop();
|
|
796
|
+
}
|
|
797
|
+
}, _callee2, null, [[0, 12]]);
|
|
798
|
+
})));
|
|
799
|
+
_defineProperty(this, "resetState", function () {
|
|
800
|
+
_classPrivateFieldSet(_this, _recordingId, "");
|
|
801
|
+
_classPrivateFieldSet(_this, _uploadId, "");
|
|
802
|
+
_classPrivateFieldSet(_this, _unUploadedChunks, []);
|
|
803
|
+
_classPrivateFieldSet(_this, _partNumber, 1);
|
|
804
|
+
_classPrivateFieldSet(_this, _s3PartUploadPromises, []);
|
|
805
|
+
_classPrivateFieldSet(_this, _callbacks$1, {});
|
|
806
|
+
_classPrivateFieldGet(_this, _store$1).setState({
|
|
807
|
+
status: ""
|
|
808
|
+
});
|
|
809
|
+
});
|
|
810
|
+
_defineProperty(this, "addCallback", function (event, callback) {
|
|
811
|
+
var _classPrivateFieldGet2;
|
|
812
|
+
var existingCallbacks = (_classPrivateFieldGet2 = _classPrivateFieldGet(_this, _callbacks$1)[event]) !== null && _classPrivateFieldGet2 !== void 0 ? _classPrivateFieldGet2 : [];
|
|
813
|
+
_classPrivateFieldSet(_this, _callbacks$1, _objectSpread$2(_objectSpread$2({}, _classPrivateFieldGet(_this, _callbacks$1)), {}, _defineProperty({}, event, [].concat(_toConsumableArray(existingCallbacks), [callback]))));
|
|
814
|
+
});
|
|
815
|
+
_defineProperty(this, "removeCallback", function (event, callback) {
|
|
816
|
+
var _classPrivateFieldGet3;
|
|
817
|
+
var registeredCallbacks = (_classPrivateFieldGet3 = _classPrivateFieldGet(_this, _callbacks$1)[event]) !== null && _classPrivateFieldGet3 !== void 0 ? _classPrivateFieldGet3 : [];
|
|
818
|
+
var updatedCallbacks = registeredCallbacks.filter(isNot(callback));
|
|
819
|
+
_classPrivateFieldSet(_this, _callbacks$1, _objectSpread$2(_objectSpread$2({}, _classPrivateFieldGet(_this, _callbacks$1)), {}, _defineProperty({}, event, updatedCallbacks)));
|
|
820
|
+
});
|
|
821
|
+
_classPrivateFieldInitSpec$1(this, _fireCallbacks$1, {
|
|
822
|
+
writable: true,
|
|
823
|
+
value: function value(event) {
|
|
824
|
+
var _classPrivateFieldGet4;
|
|
825
|
+
var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
826
|
+
(_classPrivateFieldGet4 = _classPrivateFieldGet(_this, _callbacks$1)[event]) === null || _classPrivateFieldGet4 === void 0 ? void 0 : _classPrivateFieldGet4.forEach(function (callback) {
|
|
827
|
+
callback.apply(void 0, _toConsumableArray(args));
|
|
828
|
+
});
|
|
829
|
+
}
|
|
830
|
+
});
|
|
831
|
+
_classPrivateFieldInitSpec$1(this, _uploadChunkToS, {
|
|
832
|
+
writable: true,
|
|
833
|
+
value: function () {
|
|
834
|
+
var _value = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(chunks) {
|
|
835
|
+
var _this$partNumber, _this$partNumber2, _yield$partPresignedU, presignedUrl, s3PartUploadPromise;
|
|
836
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
837
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
838
|
+
case 0:
|
|
839
|
+
logger.info("Part ready to be uploaded: ", _classPrivateFieldGet(_this, _partNumber));
|
|
840
|
+
_context3.prev = 1;
|
|
841
|
+
_context3.next = 4;
|
|
842
|
+
return partPresignedUrlApi.create({
|
|
843
|
+
recordingId: _classPrivateFieldGet(_this, _recordingId),
|
|
844
|
+
payload: {
|
|
845
|
+
partNumber: (_classPrivateFieldSet(_this, _partNumber, (_this$partNumber = _classPrivateFieldGet(_this, _partNumber), _this$partNumber2 = _this$partNumber++, _this$partNumber)), _this$partNumber2),
|
|
846
|
+
uploadId: _classPrivateFieldGet(_this, _uploadId)
|
|
847
|
+
}
|
|
848
|
+
});
|
|
849
|
+
case 4:
|
|
850
|
+
_yield$partPresignedU = _context3.sent;
|
|
851
|
+
presignedUrl = _yield$partPresignedU.presignedUrl;
|
|
852
|
+
s3PartUploadPromise = s3Api.presignedUpload({
|
|
853
|
+
presignedUrl: presignedUrl,
|
|
854
|
+
blob: new Blob(chunks, {
|
|
855
|
+
type: 'video/webm;codecs="vp9"'
|
|
856
|
+
}),
|
|
857
|
+
config: {
|
|
858
|
+
includeMetadataInResponse: true,
|
|
859
|
+
signal: _classPrivateFieldGet(_this, _abortController).signal
|
|
860
|
+
}
|
|
861
|
+
});
|
|
862
|
+
_classPrivateFieldGet(_this, _s3PartUploadPromises).push(s3PartUploadPromise);
|
|
863
|
+
_context3.next = 13;
|
|
864
|
+
break;
|
|
865
|
+
case 10:
|
|
866
|
+
_context3.prev = 10;
|
|
867
|
+
_context3.t0 = _context3["catch"](1);
|
|
868
|
+
if (!axios.isCancel(_context3.t0)) logger.error(_context3.t0);
|
|
869
|
+
case 13:
|
|
870
|
+
return _context3.abrupt("return");
|
|
871
|
+
case 14:
|
|
872
|
+
case "end":
|
|
873
|
+
return _context3.stop();
|
|
874
|
+
}
|
|
875
|
+
}, _callee3, null, [[1, 10]]);
|
|
876
|
+
}));
|
|
877
|
+
function value(_x) {
|
|
878
|
+
return _value.apply(this, arguments);
|
|
879
|
+
}
|
|
880
|
+
return value;
|
|
881
|
+
}()
|
|
882
|
+
});
|
|
883
|
+
_classPrivateFieldInitSpec$1(this, _getCurrentUnUploadedBlob, {
|
|
884
|
+
writable: true,
|
|
885
|
+
value: function value() {
|
|
886
|
+
return new Blob(_classPrivateFieldGet(_this, _unUploadedChunks), {
|
|
887
|
+
type: 'video/webm;codecs="vp9"'
|
|
888
|
+
});
|
|
889
|
+
}
|
|
890
|
+
});
|
|
891
|
+
_classPrivateFieldSet(this, _store$1, prepareStore$1());
|
|
892
|
+
}
|
|
893
|
+
|
|
894
|
+
/** @type {import("neetocommons/react-utils").ZustandStoreHook} */
|
|
895
|
+
_createClass(MultipartS3Uploader, [{
|
|
896
|
+
key: "useMultipartS3UploadStore",
|
|
897
|
+
get: function get() {
|
|
898
|
+
return _classPrivateFieldGet(this, _store$1);
|
|
899
|
+
}
|
|
900
|
+
}]);
|
|
901
|
+
return MultipartS3Uploader;
|
|
902
|
+
}();
|
|
903
|
+
var multipartS3Uploader = new MultipartS3Uploader();
|
|
904
|
+
|
|
905
|
+
// https://www.w3.org/TR/screen-capture/#displaycapturesurfacetype
|
|
906
|
+
var DISPLAY_SURFACE = {
|
|
907
|
+
monitor: "monitor",
|
|
908
|
+
window: "window",
|
|
909
|
+
browser: "browser"
|
|
910
|
+
};
|
|
911
|
+
|
|
912
|
+
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; }
|
|
913
|
+
function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$1(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$1(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
914
|
+
var initialState = {
|
|
915
|
+
status: SCREEN_RECORDER_STATUS.idle,
|
|
916
|
+
error: "",
|
|
917
|
+
elapsedTime: 0,
|
|
918
|
+
countdownTimeLeft: 3
|
|
919
|
+
};
|
|
920
|
+
var prepareStore = function prepareStore() {
|
|
921
|
+
return create$3(withImmutableActions(function (set) {
|
|
922
|
+
return _objectSpread$1(_objectSpread$1({}, initialState), {}, {
|
|
923
|
+
resetState: function resetState() {
|
|
924
|
+
return set(initialState);
|
|
925
|
+
}
|
|
926
|
+
});
|
|
927
|
+
}));
|
|
928
|
+
};
|
|
929
|
+
|
|
930
|
+
var getUnSupportedConstraints = function getUnSupportedConstraints(mediaType) {
|
|
931
|
+
var supportedMediaConstraints = navigator.mediaDevices.getSupportedConstraints();
|
|
932
|
+
return Object.keys(mediaType).filter(function (constraint) {
|
|
933
|
+
return !supportedMediaConstraints[constraint];
|
|
934
|
+
});
|
|
935
|
+
};
|
|
936
|
+
var checkConstraints = function checkConstraints() {
|
|
937
|
+
if (isNil(navigator.mediaDevices)) {
|
|
938
|
+
return;
|
|
939
|
+
}
|
|
940
|
+
for (var _len = arguments.length, mediaTypes = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
941
|
+
mediaTypes[_key] = arguments[_key];
|
|
942
|
+
}
|
|
943
|
+
var unSupportedConstraints = mediaTypes.filter(function (mediaType) {
|
|
944
|
+
return _typeof$1(mediaType) === "object";
|
|
945
|
+
}).map(getUnSupportedConstraints).flat();
|
|
946
|
+
if (isNotEmpty(unSupportedConstraints)) {
|
|
947
|
+
// eslint-disable-next-line no-console
|
|
948
|
+
console.error("The constraints ".concat(unSupportedConstraints.join(","), " doesn't support on this browser."));
|
|
949
|
+
}
|
|
950
|
+
};
|
|
951
|
+
var isStreamEnded = function isStreamEnded(mediaStream) {
|
|
952
|
+
return existsBy({
|
|
953
|
+
readyState: "ended"
|
|
954
|
+
}, mediaStream.getTracks());
|
|
955
|
+
};
|
|
956
|
+
|
|
957
|
+
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; }
|
|
958
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
959
|
+
function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
|
|
960
|
+
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
|
961
|
+
var _audio = /*#__PURE__*/new WeakMap();
|
|
962
|
+
var _video = /*#__PURE__*/new WeakMap();
|
|
963
|
+
var _mediaRecorder = /*#__PURE__*/new WeakMap();
|
|
964
|
+
var _mediaStream = /*#__PURE__*/new WeakMap();
|
|
965
|
+
var _store = /*#__PURE__*/new WeakMap();
|
|
966
|
+
var _mediaChunks = /*#__PURE__*/new WeakMap();
|
|
967
|
+
var _callbacks = /*#__PURE__*/new WeakMap();
|
|
968
|
+
var _lastTimerUpdatedAt = /*#__PURE__*/new WeakMap();
|
|
969
|
+
var _timerId = /*#__PURE__*/new WeakMap();
|
|
970
|
+
var _countdownTimerId = /*#__PURE__*/new WeakMap();
|
|
971
|
+
var _checkCompatibility = /*#__PURE__*/new WeakMap();
|
|
972
|
+
var _acquireMediaStream = /*#__PURE__*/new WeakMap();
|
|
973
|
+
var _fireCallbacks = /*#__PURE__*/new WeakMap();
|
|
974
|
+
var _onRecordingStart = /*#__PURE__*/new WeakMap();
|
|
975
|
+
var _onRecordingActive = /*#__PURE__*/new WeakMap();
|
|
976
|
+
var _onRecordingStop = /*#__PURE__*/new WeakMap();
|
|
977
|
+
var _countdownAndStartRecording = /*#__PURE__*/new WeakMap();
|
|
978
|
+
var _startTimer = /*#__PURE__*/new WeakMap();
|
|
979
|
+
var _stopTimer = /*#__PURE__*/new WeakMap();
|
|
980
|
+
var ScreenRecorder = /*#__PURE__*/function () {
|
|
981
|
+
function ScreenRecorder(audio, video) {
|
|
982
|
+
var _this = this;
|
|
983
|
+
_classCallCheck(this, ScreenRecorder);
|
|
984
|
+
_classPrivateFieldInitSpec(this, _audio, {
|
|
985
|
+
writable: true,
|
|
986
|
+
value: void 0
|
|
987
|
+
});
|
|
988
|
+
_classPrivateFieldInitSpec(this, _video, {
|
|
989
|
+
writable: true,
|
|
990
|
+
value: void 0
|
|
991
|
+
});
|
|
992
|
+
_classPrivateFieldInitSpec(this, _mediaRecorder, {
|
|
993
|
+
writable: true,
|
|
994
|
+
value: void 0
|
|
995
|
+
});
|
|
996
|
+
_classPrivateFieldInitSpec(this, _mediaStream, {
|
|
997
|
+
writable: true,
|
|
998
|
+
value: void 0
|
|
999
|
+
});
|
|
1000
|
+
_classPrivateFieldInitSpec(this, _store, {
|
|
1001
|
+
writable: true,
|
|
1002
|
+
value: void 0
|
|
1003
|
+
});
|
|
1004
|
+
_classPrivateFieldInitSpec(this, _mediaChunks, {
|
|
1005
|
+
writable: true,
|
|
1006
|
+
value: []
|
|
1007
|
+
});
|
|
1008
|
+
_classPrivateFieldInitSpec(this, _callbacks, {
|
|
1009
|
+
writable: true,
|
|
1010
|
+
value: {}
|
|
1011
|
+
});
|
|
1012
|
+
_classPrivateFieldInitSpec(this, _lastTimerUpdatedAt, {
|
|
1013
|
+
writable: true,
|
|
1014
|
+
value: 0
|
|
1015
|
+
});
|
|
1016
|
+
_classPrivateFieldInitSpec(this, _timerId, {
|
|
1017
|
+
writable: true,
|
|
1018
|
+
value: void 0
|
|
1019
|
+
});
|
|
1020
|
+
_classPrivateFieldInitSpec(this, _countdownTimerId, {
|
|
1021
|
+
writable: true,
|
|
1022
|
+
value: void 0
|
|
1023
|
+
});
|
|
1024
|
+
_defineProperty(this, "getPreviewStream", function () {
|
|
1025
|
+
return new MediaStream(_classPrivateFieldGet(_this, _mediaStream).getVideoTracks());
|
|
1026
|
+
});
|
|
1027
|
+
_defineProperty(this, "getMediaBlobUrl", function () {
|
|
1028
|
+
var blob = new Blob(_classPrivateFieldGet(_this, _mediaChunks), {
|
|
1029
|
+
type: 'video/webm;codecs="vp9"'
|
|
1030
|
+
});
|
|
1031
|
+
|
|
1032
|
+
// TODO: Revoke the object url
|
|
1033
|
+
return URL.createObjectURL(blob);
|
|
1034
|
+
});
|
|
1035
|
+
_defineProperty(this, "getWebmMediaBlob", function () {
|
|
1036
|
+
return new Blob(_classPrivateFieldGet(_this, _mediaChunks), {
|
|
1037
|
+
type: 'video/webm;codecs="vp9"'
|
|
1038
|
+
});
|
|
1039
|
+
});
|
|
1040
|
+
_defineProperty(this, "addCallback", function (event, callback) {
|
|
1041
|
+
var _classPrivateFieldGet2;
|
|
1042
|
+
var existingCallbacks = (_classPrivateFieldGet2 = _classPrivateFieldGet(_this, _callbacks)[event]) !== null && _classPrivateFieldGet2 !== void 0 ? _classPrivateFieldGet2 : [];
|
|
1043
|
+
_classPrivateFieldSet(_this, _callbacks, _objectSpread(_objectSpread({}, _classPrivateFieldGet(_this, _callbacks)), {}, _defineProperty({}, event, [].concat(_toConsumableArray(existingCallbacks), [callback]))));
|
|
1044
|
+
});
|
|
1045
|
+
_defineProperty(this, "removeCallback", function (event, callback) {
|
|
1046
|
+
var _classPrivateFieldGet3;
|
|
1047
|
+
var registeredCallbacks = (_classPrivateFieldGet3 = _classPrivateFieldGet(_this, _callbacks)[event]) !== null && _classPrivateFieldGet3 !== void 0 ? _classPrivateFieldGet3 : [];
|
|
1048
|
+
var updatedCallbacks = registeredCallbacks.filter(isNot(callback));
|
|
1049
|
+
_classPrivateFieldSet(_this, _callbacks, _objectSpread(_objectSpread({}, _classPrivateFieldGet(_this, _callbacks)), {}, _defineProperty({}, event, updatedCallbacks)));
|
|
1050
|
+
});
|
|
1051
|
+
_defineProperty(this, "removeAllCallbacksByEvent", function (event) {
|
|
1052
|
+
delete _classPrivateFieldGet(_this, _callbacks)[event];
|
|
1053
|
+
});
|
|
1054
|
+
_defineProperty(this, "startRecording", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
1055
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
1056
|
+
while (1) switch (_context.prev = _context.next) {
|
|
1057
|
+
case 0:
|
|
1058
|
+
_classPrivateFieldGet(_this, _store).setState(pick(["error"], initialState));
|
|
1059
|
+
if (_classPrivateFieldGet(_this, _mediaStream)) {
|
|
1060
|
+
_context.next = 4;
|
|
1061
|
+
break;
|
|
1062
|
+
}
|
|
1063
|
+
_context.next = 4;
|
|
1064
|
+
return _classPrivateFieldGet(_this, _acquireMediaStream).call(_this);
|
|
1065
|
+
case 4:
|
|
1066
|
+
if (!(_classPrivateFieldGet(_this, _mediaStream) && isStreamEnded(_classPrivateFieldGet(_this, _mediaStream)))) {
|
|
1067
|
+
_context.next = 7;
|
|
1068
|
+
break;
|
|
1069
|
+
}
|
|
1070
|
+
_context.next = 7;
|
|
1071
|
+
return _classPrivateFieldGet(_this, _acquireMediaStream).call(_this);
|
|
1072
|
+
case 7:
|
|
1073
|
+
if (!(!_classPrivateFieldGet(_this, _mediaStream) || isStreamEnded(_classPrivateFieldGet(_this, _mediaStream)))) {
|
|
1074
|
+
_context.next = 9;
|
|
1075
|
+
break;
|
|
1076
|
+
}
|
|
1077
|
+
return _context.abrupt("return");
|
|
1078
|
+
case 9:
|
|
1079
|
+
_classPrivateFieldSet(_this, _mediaChunks, []);
|
|
1080
|
+
_classPrivateFieldSet(_this, _mediaRecorder, new MediaRecorder(_classPrivateFieldGet(_this, _mediaStream)));
|
|
1081
|
+
_classPrivateFieldGet(_this, _mediaRecorder).ondataavailable = _classPrivateFieldGet(_this, _onRecordingActive);
|
|
1082
|
+
_classPrivateFieldGet(_this, _mediaRecorder).onstart = _classPrivateFieldGet(_this, _onRecordingStart);
|
|
1083
|
+
_classPrivateFieldGet(_this, _mediaRecorder).onstop = _classPrivateFieldGet(_this, _onRecordingStop);
|
|
1084
|
+
_classPrivateFieldGet(_this, _mediaRecorder).onerror = function () {
|
|
1085
|
+
_classPrivateFieldGet(_this, _store).setState({
|
|
1086
|
+
status: SCREEN_RECORDER_STATUS.idle,
|
|
1087
|
+
error: SCREEN_RECORDER_ERROR.NoRecorder
|
|
1088
|
+
});
|
|
1089
|
+
};
|
|
1090
|
+
_classPrivateFieldGet(_this, _countdownAndStartRecording).call(_this);
|
|
1091
|
+
case 16:
|
|
1092
|
+
case "end":
|
|
1093
|
+
return _context.stop();
|
|
1094
|
+
}
|
|
1095
|
+
}, _callee);
|
|
1096
|
+
})));
|
|
1097
|
+
_defineProperty(this, "stopRecording", function () {
|
|
1098
|
+
var _classPrivateFieldGet4;
|
|
1099
|
+
if (((_classPrivateFieldGet4 = _classPrivateFieldGet(_this, _mediaRecorder)) === null || _classPrivateFieldGet4 === void 0 ? void 0 : _classPrivateFieldGet4.state) === "inactive") {
|
|
1100
|
+
// When recording is stopped from the 'Stop Sharing' overlay
|
|
1101
|
+
// before it even starts, i.e during the countdown.
|
|
1102
|
+
clearInterval(_classPrivateFieldGet(_this, _countdownTimerId));
|
|
1103
|
+
_classPrivateFieldGet(_this, _mediaStream).getTracks().forEach(function (track) {
|
|
1104
|
+
return track.stop();
|
|
1105
|
+
});
|
|
1106
|
+
_classPrivateFieldGet(_this, _fireCallbacks).call(_this, SCREEN_RECORDER_EVENT.onDiscardDuringCountdown);
|
|
1107
|
+
return;
|
|
1108
|
+
}
|
|
1109
|
+
_classPrivateFieldGet(_this, _store).setState({
|
|
1110
|
+
status: SCREEN_RECORDER_STATUS.stopping
|
|
1111
|
+
});
|
|
1112
|
+
_classPrivateFieldGet(_this, _mediaRecorder).stop();
|
|
1113
|
+
_classPrivateFieldGet(_this, _mediaStream) && _classPrivateFieldGet(_this, _mediaStream).getTracks().forEach(function (track) {
|
|
1114
|
+
return track.stop();
|
|
1115
|
+
});
|
|
1116
|
+
_classPrivateFieldGet(_this, _stopTimer).call(_this);
|
|
1117
|
+
});
|
|
1118
|
+
_defineProperty(this, "pauseRecording", function () {
|
|
1119
|
+
var _classPrivateFieldGet5;
|
|
1120
|
+
if (((_classPrivateFieldGet5 = _classPrivateFieldGet(_this, _mediaRecorder)) === null || _classPrivateFieldGet5 === void 0 ? void 0 : _classPrivateFieldGet5.state) === "recording") {
|
|
1121
|
+
_classPrivateFieldGet(_this, _store).setState({
|
|
1122
|
+
status: SCREEN_RECORDER_STATUS.paused
|
|
1123
|
+
});
|
|
1124
|
+
_classPrivateFieldGet(_this, _mediaRecorder).pause();
|
|
1125
|
+
}
|
|
1126
|
+
_classPrivateFieldGet(_this, _stopTimer).call(_this);
|
|
1127
|
+
});
|
|
1128
|
+
_defineProperty(this, "resumeRecording", function () {
|
|
1129
|
+
var _classPrivateFieldGet6;
|
|
1130
|
+
if (((_classPrivateFieldGet6 = _classPrivateFieldGet(_this, _mediaRecorder)) === null || _classPrivateFieldGet6 === void 0 ? void 0 : _classPrivateFieldGet6.state) === "paused") {
|
|
1131
|
+
_classPrivateFieldGet(_this, _store).setState({
|
|
1132
|
+
status: SCREEN_RECORDER_STATUS.recording
|
|
1133
|
+
});
|
|
1134
|
+
_classPrivateFieldGet(_this, _mediaRecorder).resume();
|
|
1135
|
+
}
|
|
1136
|
+
_classPrivateFieldGet(_this, _startTimer).call(_this);
|
|
1137
|
+
});
|
|
1138
|
+
_defineProperty(this, "discardRecording", function () {
|
|
1139
|
+
var _classPrivateFieldGet7;
|
|
1140
|
+
if (((_classPrivateFieldGet7 = _classPrivateFieldGet(_this, _mediaRecorder)) === null || _classPrivateFieldGet7 === void 0 ? void 0 : _classPrivateFieldGet7.state) === "inactive") return;
|
|
1141
|
+
_classPrivateFieldGet(_this, _store).setState({
|
|
1142
|
+
status: SCREEN_RECORDER_STATUS.stopping
|
|
1143
|
+
});
|
|
1144
|
+
_this.removeAllCallbacksByEvent(SCREEN_RECORDER_EVENT.onStop);
|
|
1145
|
+
_classPrivateFieldGet(_this, _mediaRecorder).stop();
|
|
1146
|
+
_classPrivateFieldGet(_this, _mediaStream) && _classPrivateFieldGet(_this, _mediaStream).getTracks().forEach(function (track) {
|
|
1147
|
+
return track.stop();
|
|
1148
|
+
});
|
|
1149
|
+
clearInterval(_classPrivateFieldGet(_this, _timerId));
|
|
1150
|
+
_classPrivateFieldGet(_this, _store).setState(pick(["elapsedTime"], initialState));
|
|
1151
|
+
_classPrivateFieldSet(_this, _mediaChunks, []);
|
|
1152
|
+
_classPrivateFieldGet(_this, _fireCallbacks).call(_this, SCREEN_RECORDER_EVENT.onDiscard);
|
|
1153
|
+
});
|
|
1154
|
+
_defineProperty(this, "restartRecording", function () {
|
|
1155
|
+
_classPrivateFieldGet(_this, _store).setState({
|
|
1156
|
+
status: SCREEN_RECORDER_STATUS.stopping
|
|
1157
|
+
});
|
|
1158
|
+
_this.removeAllCallbacksByEvent(SCREEN_RECORDER_EVENT.onStop);
|
|
1159
|
+
_classPrivateFieldGet(_this, _mediaRecorder).stop();
|
|
1160
|
+
clearInterval(_classPrivateFieldGet(_this, _timerId));
|
|
1161
|
+
_classPrivateFieldGet(_this, _store).setState(pick(["elapsedTime", "countdownTimeLeft"], initialState));
|
|
1162
|
+
_classPrivateFieldSet(_this, _mediaChunks, []);
|
|
1163
|
+
_classPrivateFieldGet(_this, _fireCallbacks).call(_this, SCREEN_RECORDER_EVENT.onRestart);
|
|
1164
|
+
_classPrivateFieldGet(_this, _countdownAndStartRecording).call(_this);
|
|
1165
|
+
});
|
|
1166
|
+
_defineProperty(this, "resetState", function () {
|
|
1167
|
+
_classPrivateFieldSet(_this, _mediaChunks, []);
|
|
1168
|
+
_classPrivateFieldSet(_this, _callbacks, {});
|
|
1169
|
+
clearInterval(_classPrivateFieldGet(_this, _timerId));
|
|
1170
|
+
clearInterval(_classPrivateFieldGet(_this, _countdownTimerId));
|
|
1171
|
+
_classPrivateFieldGet(_this, _store).getState().resetState();
|
|
1172
|
+
});
|
|
1173
|
+
_defineProperty(this, "revokePermissions", function () {
|
|
1174
|
+
if (!_classPrivateFieldGet(_this, _mediaRecorder)) return;
|
|
1175
|
+
_classPrivateFieldGet(_this, _mediaRecorder).onstop = null;
|
|
1176
|
+
_classPrivateFieldGet(_this, _mediaStream).getTracks().forEach(function (track) {
|
|
1177
|
+
return track.stop();
|
|
1178
|
+
});
|
|
1179
|
+
});
|
|
1180
|
+
_classPrivateFieldInitSpec(this, _checkCompatibility, {
|
|
1181
|
+
writable: true,
|
|
1182
|
+
value: function value() {
|
|
1183
|
+
var _navigator$mediaDevic;
|
|
1184
|
+
if (!((_navigator$mediaDevic = navigator.mediaDevices) !== null && _navigator$mediaDevic !== void 0 && _navigator$mediaDevic.getDisplayMedia)) {
|
|
1185
|
+
_classPrivateFieldGet(_this, _store).setState({
|
|
1186
|
+
error: SCREEN_RECORDER_ERROR.UnSupportedBrowser
|
|
1187
|
+
});
|
|
1188
|
+
}
|
|
1189
|
+
checkConstraints(_classPrivateFieldGet(_this, _audio), _classPrivateFieldGet(_this, _video));
|
|
1190
|
+
}
|
|
1191
|
+
});
|
|
1192
|
+
_classPrivateFieldInitSpec(this, _acquireMediaStream, {
|
|
1193
|
+
writable: true,
|
|
1194
|
+
value: function () {
|
|
1195
|
+
var _value = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
1196
|
+
var stream, audioStream;
|
|
1197
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
1198
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
1199
|
+
case 0:
|
|
1200
|
+
_classPrivateFieldGet(_this, _store).setState({
|
|
1201
|
+
status: SCREEN_RECORDER_STATUS.acquiring_media
|
|
1202
|
+
});
|
|
1203
|
+
_context2.prev = 1;
|
|
1204
|
+
_context2.next = 4;
|
|
1205
|
+
return window.navigator.mediaDevices.getDisplayMedia({
|
|
1206
|
+
video: _classPrivateFieldGet(_this, _video) || true
|
|
1207
|
+
});
|
|
1208
|
+
case 4:
|
|
1209
|
+
stream = _context2.sent;
|
|
1210
|
+
// Event triggered when the user clicks on the stop sharing overlay button
|
|
1211
|
+
stream.getVideoTracks()[0].addEventListener("ended", function () {
|
|
1212
|
+
_this.stopRecording();
|
|
1213
|
+
});
|
|
1214
|
+
if (!_classPrivateFieldGet(_this, _audio)) {
|
|
1215
|
+
_context2.next = 11;
|
|
1216
|
+
break;
|
|
1217
|
+
}
|
|
1218
|
+
_context2.next = 9;
|
|
1219
|
+
return window.navigator.mediaDevices.getUserMedia({
|
|
1220
|
+
audio: _classPrivateFieldGet(_this, _audio)
|
|
1221
|
+
});
|
|
1222
|
+
case 9:
|
|
1223
|
+
audioStream = _context2.sent;
|
|
1224
|
+
audioStream.getAudioTracks().forEach(function (audioTrack) {
|
|
1225
|
+
return stream.addTrack(audioTrack);
|
|
1226
|
+
});
|
|
1227
|
+
case 11:
|
|
1228
|
+
_classPrivateFieldSet(_this, _mediaStream, stream);
|
|
1229
|
+
_classPrivateFieldGet(_this, _store).setState({
|
|
1230
|
+
status: SCREEN_RECORDER_STATUS.media_acquired
|
|
1231
|
+
});
|
|
1232
|
+
_context2.next = 18;
|
|
1233
|
+
break;
|
|
1234
|
+
case 15:
|
|
1235
|
+
_context2.prev = 15;
|
|
1236
|
+
_context2.t0 = _context2["catch"](1);
|
|
1237
|
+
_classPrivateFieldGet(_this, _store).setState({
|
|
1238
|
+
error: SCREEN_RECORDER_ERROR[_context2.t0.name],
|
|
1239
|
+
status: SCREEN_RECORDER_STATUS.idle
|
|
1240
|
+
});
|
|
1241
|
+
case 18:
|
|
1242
|
+
case "end":
|
|
1243
|
+
return _context2.stop();
|
|
1244
|
+
}
|
|
1245
|
+
}, _callee2, null, [[1, 15]]);
|
|
1246
|
+
}));
|
|
1247
|
+
function value() {
|
|
1248
|
+
return _value.apply(this, arguments);
|
|
1249
|
+
}
|
|
1250
|
+
return value;
|
|
1251
|
+
}()
|
|
1252
|
+
});
|
|
1253
|
+
_classPrivateFieldInitSpec(this, _fireCallbacks, {
|
|
1254
|
+
writable: true,
|
|
1255
|
+
value: function value(event) {
|
|
1256
|
+
var _classPrivateFieldGet8;
|
|
1257
|
+
var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
1258
|
+
(_classPrivateFieldGet8 = _classPrivateFieldGet(_this, _callbacks)[event]) === null || _classPrivateFieldGet8 === void 0 ? void 0 : _classPrivateFieldGet8.forEach(function (callback) {
|
|
1259
|
+
callback.apply(void 0, _toConsumableArray(args));
|
|
1260
|
+
});
|
|
1261
|
+
}
|
|
1262
|
+
});
|
|
1263
|
+
_classPrivateFieldInitSpec(this, _onRecordingStart, {
|
|
1264
|
+
writable: true,
|
|
1265
|
+
value: function value() {
|
|
1266
|
+
_classPrivateFieldGet(_this, _fireCallbacks).call(_this, SCREEN_RECORDER_EVENT.onStart);
|
|
1267
|
+
}
|
|
1268
|
+
});
|
|
1269
|
+
_classPrivateFieldInitSpec(this, _onRecordingActive, {
|
|
1270
|
+
writable: true,
|
|
1271
|
+
value: function value(_ref2) {
|
|
1272
|
+
var data = _ref2.data;
|
|
1273
|
+
if (data.size <= 0) return;
|
|
1274
|
+
_classPrivateFieldGet(_this, _mediaChunks).push(data);
|
|
1275
|
+
_classPrivateFieldGet(_this, _fireCallbacks).call(_this, SCREEN_RECORDER_EVENT.onDataAvailable, [data]);
|
|
1276
|
+
}
|
|
1277
|
+
});
|
|
1278
|
+
_classPrivateFieldInitSpec(this, _onRecordingStop, {
|
|
1279
|
+
writable: true,
|
|
1280
|
+
value: function value() {
|
|
1281
|
+
_classPrivateFieldGet(_this, _store).setState({
|
|
1282
|
+
status: SCREEN_RECORDER_STATUS.stopped
|
|
1283
|
+
});
|
|
1284
|
+
_classPrivateFieldGet(_this, _fireCallbacks).call(_this, SCREEN_RECORDER_EVENT.onStop);
|
|
1285
|
+
|
|
1286
|
+
// If mediaStream is active after stopping mediaRecorder, then that means that
|
|
1287
|
+
// we are restarting and not stopping.
|
|
1288
|
+
if (_classPrivateFieldGet(_this, _mediaStream).active) {
|
|
1289
|
+
_classPrivateFieldGet(_this, _store).setState({
|
|
1290
|
+
status: SCREEN_RECORDER_STATUS.restarting
|
|
1291
|
+
});
|
|
1292
|
+
}
|
|
1293
|
+
}
|
|
1294
|
+
});
|
|
1295
|
+
_classPrivateFieldInitSpec(this, _countdownAndStartRecording, {
|
|
1296
|
+
writable: true,
|
|
1297
|
+
value: function value() {
|
|
1298
|
+
_classPrivateFieldSet(_this, _countdownTimerId, setInterval(function () {
|
|
1299
|
+
_classPrivateFieldGet(_this, _store).setState(function (_ref3) {
|
|
1300
|
+
var countdownTimeLeft = _ref3.countdownTimeLeft;
|
|
1301
|
+
if (countdownTimeLeft - ONE_SECOND > 0) {
|
|
1302
|
+
return {
|
|
1303
|
+
countdownTimeLeft: countdownTimeLeft - ONE_SECOND
|
|
1304
|
+
};
|
|
1305
|
+
}
|
|
1306
|
+
_classPrivateFieldGet(_this, _store).setState({
|
|
1307
|
+
status: SCREEN_RECORDER_STATUS.recording
|
|
1308
|
+
});
|
|
1309
|
+
_classPrivateFieldGet(_this, _mediaRecorder).start(5000);
|
|
1310
|
+
_classPrivateFieldGet(_this, _startTimer).call(_this);
|
|
1311
|
+
clearInterval(_classPrivateFieldGet(_this, _countdownTimerId));
|
|
1312
|
+
return {
|
|
1313
|
+
countdownTimeLeft: 0
|
|
1314
|
+
};
|
|
1315
|
+
});
|
|
1316
|
+
}, ONE_SECOND_IN_MILLISECONDS));
|
|
1317
|
+
}
|
|
1318
|
+
});
|
|
1319
|
+
_classPrivateFieldInitSpec(this, _startTimer, {
|
|
1320
|
+
writable: true,
|
|
1321
|
+
value: function value() {
|
|
1322
|
+
_classPrivateFieldSet(_this, _lastTimerUpdatedAt, Date.now());
|
|
1323
|
+
_classPrivateFieldSet(_this, _timerId, setInterval(function () {
|
|
1324
|
+
_classPrivateFieldGet(_this, _store).setState(function (_ref4) {
|
|
1325
|
+
var elapsedTime = _ref4.elapsedTime;
|
|
1326
|
+
var now = Date.now();
|
|
1327
|
+
var newElapsedTime = elapsedTime + (now - _classPrivateFieldGet(_this, _lastTimerUpdatedAt));
|
|
1328
|
+
_classPrivateFieldSet(_this, _lastTimerUpdatedAt, now);
|
|
1329
|
+
return {
|
|
1330
|
+
elapsedTime: newElapsedTime
|
|
1331
|
+
};
|
|
1332
|
+
});
|
|
1333
|
+
}, ONE_SECOND_IN_MILLISECONDS));
|
|
1334
|
+
}
|
|
1335
|
+
});
|
|
1336
|
+
_classPrivateFieldInitSpec(this, _stopTimer, {
|
|
1337
|
+
writable: true,
|
|
1338
|
+
value: function value() {
|
|
1339
|
+
clearInterval(_classPrivateFieldGet(_this, _timerId));
|
|
1340
|
+
var newElapsedTime = _classPrivateFieldGet(_this, _store).getState().elapsedTime + (Date.now() - _classPrivateFieldGet(_this, _lastTimerUpdatedAt));
|
|
1341
|
+
_classPrivateFieldGet(_this, _store).setState({
|
|
1342
|
+
elapsedTime: newElapsedTime
|
|
1343
|
+
});
|
|
1344
|
+
}
|
|
1345
|
+
});
|
|
1346
|
+
_classPrivateFieldSet(this, _audio, audio);
|
|
1347
|
+
_classPrivateFieldSet(this, _video, video);
|
|
1348
|
+
_classPrivateFieldSet(this, _store, prepareStore());
|
|
1349
|
+
_classPrivateFieldGet(this, _store).setState({
|
|
1350
|
+
status: SCREEN_RECORDER_STATUS.idle
|
|
1351
|
+
});
|
|
1352
|
+
_classPrivateFieldGet(this, _checkCompatibility).call(this);
|
|
1353
|
+
}
|
|
1354
|
+
|
|
1355
|
+
/** @type {import("neetocommons/react-utils").ZustandStoreHook} */
|
|
1356
|
+
_createClass(ScreenRecorder, [{
|
|
1357
|
+
key: "useRecorderStore",
|
|
1358
|
+
get: function get() {
|
|
1359
|
+
return _classPrivateFieldGet(this, _store);
|
|
1360
|
+
}
|
|
1361
|
+
}]);
|
|
1362
|
+
return ScreenRecorder;
|
|
1363
|
+
}();
|
|
1364
|
+
var screenRecorder = new ScreenRecorder(true, {
|
|
1365
|
+
displaySurface: DISPLAY_SURFACE.monitor
|
|
1366
|
+
});
|
|
1367
|
+
|
|
1368
|
+
export { multipartS3Uploader, screenRecorder };
|
|
1369
|
+
//# sourceMappingURL=core.js.map
|