@atlaskit/media-client 21.0.0 → 21.1.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.
Files changed (62) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/cjs/client/file-fetcher/error.js +4 -4
  3. package/dist/cjs/client/file-fetcher/index.js +283 -297
  4. package/dist/cjs/client/media-client.js +42 -48
  5. package/dist/cjs/client/media-store/index.js +389 -310
  6. package/dist/cjs/client/media-store/resolveAuth.js +33 -36
  7. package/dist/cjs/client/stargate-client.js +17 -20
  8. package/dist/cjs/index.js +6 -0
  9. package/dist/cjs/models/media.js +4 -4
  10. package/dist/cjs/uploader/error.js +4 -4
  11. package/dist/cjs/uploader/index.js +97 -108
  12. package/dist/cjs/utils/convertBase64ToBlob.js +2 -2
  13. package/dist/cjs/utils/createFileDataLoader.js +68 -73
  14. package/dist/cjs/utils/getDimensionsFromBlob.js +26 -29
  15. package/dist/cjs/utils/getVideoDimensionsFromBlob.js +27 -30
  16. package/dist/cjs/utils/hashing/hasherCreator.js +35 -37
  17. package/dist/cjs/utils/mobileUpload/error.js +4 -4
  18. package/dist/cjs/utils/mobileUpload/helpers.js +44 -47
  19. package/dist/cjs/utils/mobileUpload/stateMachine/index.js +17 -20
  20. package/dist/cjs/utils/parseJwt.js +52 -0
  21. package/dist/cjs/utils/polling/index.js +43 -46
  22. package/dist/cjs/utils/request/errors.js +9 -9
  23. package/dist/cjs/utils/request/helpers.js +154 -167
  24. package/dist/cjs/utils/request/index.js +27 -30
  25. package/dist/cjs/utils/shouldFetchRemoteFileStates.js +42 -45
  26. package/dist/cjs/version.json +1 -1
  27. package/dist/es2019/client/file-fetcher/index.js +1 -3
  28. package/dist/es2019/client/media-store/index.js +58 -6
  29. package/dist/es2019/index.js +1 -1
  30. package/dist/es2019/models/media.js +3 -3
  31. package/dist/es2019/utils/parseJwt.js +46 -0
  32. package/dist/es2019/version.json +1 -1
  33. package/dist/esm/client/file-fetcher/error.js +4 -4
  34. package/dist/esm/client/file-fetcher/index.js +282 -296
  35. package/dist/esm/client/media-client.js +40 -47
  36. package/dist/esm/client/media-store/index.js +389 -310
  37. package/dist/esm/client/media-store/resolveAuth.js +33 -36
  38. package/dist/esm/client/stargate-client.js +17 -20
  39. package/dist/esm/index.js +1 -1
  40. package/dist/esm/models/media.js +3 -3
  41. package/dist/esm/uploader/error.js +4 -4
  42. package/dist/esm/uploader/index.js +97 -108
  43. package/dist/esm/utils/convertBase64ToBlob.js +2 -2
  44. package/dist/esm/utils/createFileDataLoader.js +68 -73
  45. package/dist/esm/utils/getDimensionsFromBlob.js +26 -29
  46. package/dist/esm/utils/getVideoDimensionsFromBlob.js +27 -30
  47. package/dist/esm/utils/hashing/hasherCreator.js +31 -34
  48. package/dist/esm/utils/mobileUpload/error.js +4 -4
  49. package/dist/esm/utils/mobileUpload/helpers.js +44 -47
  50. package/dist/esm/utils/mobileUpload/stateMachine/index.js +17 -20
  51. package/dist/esm/utils/parseJwt.js +46 -0
  52. package/dist/esm/utils/polling/index.js +43 -46
  53. package/dist/esm/utils/request/errors.js +9 -9
  54. package/dist/esm/utils/request/helpers.js +154 -167
  55. package/dist/esm/utils/request/index.js +27 -30
  56. package/dist/esm/utils/shouldFetchRemoteFileStates.js +42 -45
  57. package/dist/esm/version.json +1 -1
  58. package/dist/types/client/media-store/index.d.ts +15 -0
  59. package/dist/types/index.d.ts +1 -1
  60. package/dist/types/utils/parseJwt.d.ts +1 -0
  61. package/package.json +2 -2
  62. package/report.api.md +31 -0
@@ -1,48 +1,45 @@
1
- import _typeof from "@babel/runtime/helpers/typeof";
2
1
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
- function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; 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; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; 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); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { 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); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; 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; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
2
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
4
3
  import { MediaStoreError } from './error';
5
4
  import { rejectTimeout } from '../../utils/setTimeoutPromise';
6
5
  export var DEFAULT_AUTH_PROVIDER_TIMEOUT = 10000;
7
6
  export var resolveAuth = /*#__PURE__*/function () {
8
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(authProvider, authContext) {
7
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(authProvider, authContext) {
9
8
  var authProviderTimeout,
10
9
  auth,
11
10
  _args = arguments;
12
- return _regeneratorRuntime().wrap(function _callee$(_context) {
13
- while (1) {
14
- switch (_context.prev = _context.next) {
15
- case 0:
16
- authProviderTimeout = _args.length > 2 && _args[2] !== undefined ? _args[2] : DEFAULT_AUTH_PROVIDER_TIMEOUT;
17
- _context.prev = 1;
18
- _context.next = 4;
19
- return Promise.race([authProvider(authContext), rejectTimeout(authProviderTimeout, new MediaStoreError('authProviderTimedOut'))]);
20
- case 4:
21
- auth = _context.sent;
22
- _context.next = 12;
11
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
12
+ while (1) switch (_context.prev = _context.next) {
13
+ case 0:
14
+ authProviderTimeout = _args.length > 2 && _args[2] !== undefined ? _args[2] : DEFAULT_AUTH_PROVIDER_TIMEOUT;
15
+ _context.prev = 1;
16
+ _context.next = 4;
17
+ return Promise.race([authProvider(authContext), rejectTimeout(authProviderTimeout, new MediaStoreError('authProviderTimedOut'))]);
18
+ case 4:
19
+ auth = _context.sent;
20
+ _context.next = 12;
21
+ break;
22
+ case 7:
23
+ _context.prev = 7;
24
+ _context.t0 = _context["catch"](1);
25
+ if (!(_context.t0 instanceof MediaStoreError)) {
26
+ _context.next = 11;
23
27
  break;
24
- case 7:
25
- _context.prev = 7;
26
- _context.t0 = _context["catch"](1);
27
- if (!(_context.t0 instanceof MediaStoreError)) {
28
- _context.next = 11;
29
- break;
30
- }
31
- throw _context.t0;
32
- case 11:
33
- throw new MediaStoreError('failedAuthProvider', _context.t0 instanceof Error ? _context.t0 : undefined);
34
- case 12:
35
- if (auth) {
36
- _context.next = 14;
37
- break;
38
- }
39
- throw new MediaStoreError('emptyAuth');
40
- case 14:
41
- return _context.abrupt("return", auth);
42
- case 15:
43
- case "end":
44
- return _context.stop();
45
- }
28
+ }
29
+ throw _context.t0;
30
+ case 11:
31
+ throw new MediaStoreError('failedAuthProvider', _context.t0 instanceof Error ? _context.t0 : undefined);
32
+ case 12:
33
+ if (auth) {
34
+ _context.next = 14;
35
+ break;
36
+ }
37
+ throw new MediaStoreError('emptyAuth');
38
+ case 14:
39
+ return _context.abrupt("return", auth);
40
+ case 15:
41
+ case "end":
42
+ return _context.stop();
46
43
  }
47
44
  }, _callee, null, [[1, 7]]);
48
45
  }));
@@ -1,8 +1,7 @@
1
- import _typeof from "@babel/runtime/helpers/typeof";
2
1
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
2
  import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
4
3
  import _createClass from "@babel/runtime/helpers/createClass";
5
- function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; 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; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; 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); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { 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); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; 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; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
4
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
6
5
  export var StargateClient = /*#__PURE__*/function () {
7
6
  function StargateClient(baseUrl) {
8
7
  _classCallCheck(this, StargateClient);
@@ -11,24 +10,22 @@ export var StargateClient = /*#__PURE__*/function () {
11
10
  _createClass(StargateClient, [{
12
11
  key: "fetchToken",
13
12
  value: function () {
14
- var _fetchToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(clientId) {
15
- return _regeneratorRuntime().wrap(function _callee$(_context) {
16
- while (1) {
17
- switch (_context.prev = _context.next) {
18
- case 0:
19
- _context.next = 2;
20
- return fetch("".concat(this.baseUrl, "/media/auth/smartedge"), {
21
- credentials: 'include',
22
- headers: {
23
- 'x-client-id': clientId
24
- }
25
- });
26
- case 2:
27
- return _context.abrupt("return", _context.sent.json());
28
- case 3:
29
- case "end":
30
- return _context.stop();
31
- }
13
+ var _fetchToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(clientId) {
14
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
15
+ while (1) switch (_context.prev = _context.next) {
16
+ case 0:
17
+ _context.next = 2;
18
+ return fetch("".concat(this.baseUrl, "/media/auth/smartedge"), {
19
+ credentials: 'include',
20
+ headers: {
21
+ 'x-client-id': clientId
22
+ }
23
+ });
24
+ case 2:
25
+ return _context.abrupt("return", _context.sent.json());
26
+ case 3:
27
+ case "end":
28
+ return _context.stop();
32
29
  }
33
30
  }, _callee, this);
34
31
  }));
package/dist/esm/index.js CHANGED
@@ -22,7 +22,7 @@ export { isFileIdentifier, isExternalImageIdentifier, isDifferentIdentifier } fr
22
22
  export { withMediaClient, getMediaClient } from './utils/with-media-client-hoc';
23
23
  export { globalMediaEventEmitter } from './globalMediaEventEmitter';
24
24
  export { isMediaBlobUrl, getAttrsFromUrl, addFileAttrsToUrl, objectToQueryString } from './utils/url';
25
- export { createMediaSubscribable } from './utils/mediaSubscribable';
25
+ export { createMediaSubscribable, fromObservable } from './utils/mediaSubscribable';
26
26
  export { RECENTS_COLLECTION, MAX_RESOLUTION } from './constants';
27
27
 
28
28
  // TODO MEX-659 Remove these exports when all the usages from media-client are replaced with media-common.
@@ -12,9 +12,9 @@ export var isPreviewableType = function isPreviewableType(type, featureFlags) {
12
12
  }
13
13
  return defaultPreviewableTypes.indexOf(type) > -1;
14
14
  };
15
- export var DATA_UNIT;
16
- (function (DATA_UNIT) {
15
+ export var DATA_UNIT = /*#__PURE__*/function (DATA_UNIT) {
17
16
  DATA_UNIT[DATA_UNIT["MB"] = 1048576] = "MB";
18
17
  DATA_UNIT[DATA_UNIT["GB"] = 1073741824] = "GB";
19
18
  DATA_UNIT[DATA_UNIT["TB"] = 1099511627776] = "TB";
20
- })(DATA_UNIT || (DATA_UNIT = {}));
19
+ return DATA_UNIT;
20
+ }({});
@@ -23,10 +23,10 @@ export var UploaderError = /*#__PURE__*/function (_BaseMediaClientError) {
23
23
  get: function get() {
24
24
  var reason = this.reason,
25
25
  id = this.id,
26
- _this$metadata = this.metadata;
27
- _this$metadata = _this$metadata === void 0 ? {} : _this$metadata;
28
- var collectionName = _this$metadata.collectionName,
29
- occurrenceKey = _this$metadata.occurrenceKey;
26
+ _this$metadata = this.metadata,
27
+ _this$metadata2 = _this$metadata === void 0 ? {} : _this$metadata,
28
+ collectionName = _this$metadata2.collectionName,
29
+ occurrenceKey = _this$metadata2.occurrenceKey;
30
30
  return {
31
31
  reason: reason,
32
32
  id: id,
@@ -1,6 +1,5 @@
1
- import _typeof from "@babel/runtime/helpers/typeof";
2
1
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
- function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; 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; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; 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); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { 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); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; 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; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
2
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
4
3
  import { chunkinator } from '@atlaskit/chunkinator';
5
4
  import { from } from 'rxjs/observable/from';
6
5
  import { concatMap } from 'rxjs/operators/concatMap';
@@ -12,21 +11,19 @@ import { calculateChunkSize, fileSizeError } from './calculateChunkSize';
12
11
  // TODO: Allow to pass multiple files
13
12
 
14
13
  var hashingFunction = /*#__PURE__*/function () {
15
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(blob) {
14
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(blob) {
16
15
  var hasher;
17
- return _regeneratorRuntime().wrap(function _callee$(_context) {
18
- while (1) {
19
- switch (_context.prev = _context.next) {
20
- case 0:
21
- _context.next = 2;
22
- return createHasher();
23
- case 2:
24
- hasher = _context.sent;
25
- return _context.abrupt("return", hasher.hash(blob));
26
- case 4:
27
- case "end":
28
- return _context.stop();
29
- }
16
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
17
+ while (1) switch (_context.prev = _context.next) {
18
+ case 0:
19
+ _context.next = 2;
20
+ return createHasher();
21
+ case 2:
22
+ hasher = _context.sent;
23
+ return _context.abrupt("return", hasher.hash(blob));
24
+ case 4:
25
+ case "end":
26
+ return _context.stop();
30
27
  }
31
28
  }, _callee);
32
29
  }));
@@ -36,32 +33,30 @@ var hashingFunction = /*#__PURE__*/function () {
36
33
  }();
37
34
  var createProbingFunction = function createProbingFunction(store, deferredUploadId, collectionName, traceContext) {
38
35
  return /*#__PURE__*/function () {
39
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(chunks) {
36
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(chunks) {
40
37
  var response, results;
41
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
42
- while (1) {
43
- switch (_context2.prev = _context2.next) {
44
- case 0:
45
- _context2.t0 = store;
46
- _context2.t1 = hashedChunks(chunks);
47
- _context2.next = 4;
48
- return deferredUploadId;
49
- case 4:
50
- _context2.t2 = _context2.sent;
51
- _context2.t3 = collectionName;
52
- _context2.t4 = traceContext;
53
- _context2.next = 9;
54
- return _context2.t0.probeChunks.call(_context2.t0, _context2.t1, _context2.t2, _context2.t3, _context2.t4);
55
- case 9:
56
- response = _context2.sent;
57
- results = response.data.results;
58
- return _context2.abrupt("return", Object.values(results).map(function (result) {
59
- return result.exists;
60
- }));
61
- case 12:
62
- case "end":
63
- return _context2.stop();
64
- }
38
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
39
+ while (1) switch (_context2.prev = _context2.next) {
40
+ case 0:
41
+ _context2.t0 = store;
42
+ _context2.t1 = hashedChunks(chunks);
43
+ _context2.next = 4;
44
+ return deferredUploadId;
45
+ case 4:
46
+ _context2.t2 = _context2.sent;
47
+ _context2.t3 = collectionName;
48
+ _context2.t4 = traceContext;
49
+ _context2.next = 9;
50
+ return _context2.t0.probeChunks.call(_context2.t0, _context2.t1, _context2.t2, _context2.t3, _context2.t4);
51
+ case 9:
52
+ response = _context2.sent;
53
+ results = response.data.results;
54
+ return _context2.abrupt("return", Object.values(results).map(function (result) {
55
+ return result.exists;
56
+ }));
57
+ case 12:
58
+ case "end":
59
+ return _context2.stop();
65
60
  }
66
61
  }, _callee2);
67
62
  }));
@@ -72,29 +67,27 @@ var createProbingFunction = function createProbingFunction(store, deferredUpload
72
67
  };
73
68
  var createUploadingFunction = function createUploadingFunction(store, deferredUploadId, collectionName, traceContext) {
74
69
  return /*#__PURE__*/function () {
75
- var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(chunk) {
76
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
77
- while (1) {
78
- switch (_context3.prev = _context3.next) {
79
- case 0:
80
- _context3.t0 = store;
81
- _context3.t1 = chunk.hash;
82
- _context3.t2 = chunk.blob;
83
- _context3.next = 5;
84
- return deferredUploadId;
85
- case 5:
86
- _context3.t3 = _context3.sent;
87
- _context3.t4 = chunk.partNumber;
88
- _context3.t5 = collectionName;
89
- _context3.t6 = traceContext;
90
- _context3.next = 11;
91
- return _context3.t0.uploadChunk.call(_context3.t0, _context3.t1, _context3.t2, _context3.t3, _context3.t4, _context3.t5, _context3.t6);
92
- case 11:
93
- return _context3.abrupt("return", _context3.sent);
94
- case 12:
95
- case "end":
96
- return _context3.stop();
97
- }
70
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(chunk) {
71
+ return _regeneratorRuntime.wrap(function _callee3$(_context3) {
72
+ while (1) switch (_context3.prev = _context3.next) {
73
+ case 0:
74
+ _context3.t0 = store;
75
+ _context3.t1 = chunk.hash;
76
+ _context3.t2 = chunk.blob;
77
+ _context3.next = 5;
78
+ return deferredUploadId;
79
+ case 5:
80
+ _context3.t3 = _context3.sent;
81
+ _context3.t4 = chunk.partNumber;
82
+ _context3.t5 = collectionName;
83
+ _context3.t6 = traceContext;
84
+ _context3.next = 11;
85
+ return _context3.t0.uploadChunk.call(_context3.t0, _context3.t1, _context3.t2, _context3.t3, _context3.t4, _context3.t5, _context3.t6);
86
+ case 11:
87
+ return _context3.abrupt("return", _context3.sent);
88
+ case 12:
89
+ case "end":
90
+ return _context3.stop();
98
91
  }
99
92
  }, _callee3);
100
93
  }));
@@ -106,30 +99,28 @@ var createUploadingFunction = function createUploadingFunction(store, deferredUp
106
99
  var createProcessingFunction = function createProcessingFunction(store, deferredUploadId, collection, traceContext) {
107
100
  var offset = 0;
108
101
  return /*#__PURE__*/function () {
109
- var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(chunks) {
110
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
111
- while (1) {
112
- switch (_context4.prev = _context4.next) {
113
- case 0:
114
- _context4.t0 = store;
115
- _context4.next = 3;
116
- return deferredUploadId;
117
- case 3:
118
- _context4.t1 = _context4.sent;
119
- _context4.t2 = {
120
- chunks: hashedChunks(chunks),
121
- offset: offset
122
- };
123
- _context4.t3 = collection;
124
- _context4.t4 = traceContext;
125
- _context4.next = 9;
126
- return _context4.t0.appendChunksToUpload.call(_context4.t0, _context4.t1, _context4.t2, _context4.t3, _context4.t4);
127
- case 9:
128
- offset += chunks.length;
129
- case 10:
130
- case "end":
131
- return _context4.stop();
132
- }
102
+ var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(chunks) {
103
+ return _regeneratorRuntime.wrap(function _callee4$(_context4) {
104
+ while (1) switch (_context4.prev = _context4.next) {
105
+ case 0:
106
+ _context4.t0 = store;
107
+ _context4.next = 3;
108
+ return deferredUploadId;
109
+ case 3:
110
+ _context4.t1 = _context4.sent;
111
+ _context4.t2 = {
112
+ chunks: hashedChunks(chunks),
113
+ offset: offset
114
+ };
115
+ _context4.t3 = collection;
116
+ _context4.t4 = traceContext;
117
+ _context4.next = 9;
118
+ return _context4.t0.appendChunksToUpload.call(_context4.t0, _context4.t1, _context4.t2, _context4.t3, _context4.t4);
119
+ case 9:
120
+ offset += chunks.length;
121
+ case 10:
122
+ case "end":
123
+ return _context4.stop();
133
124
  }
134
125
  }, _callee4);
135
126
  }));
@@ -139,27 +130,25 @@ var createProcessingFunction = function createProcessingFunction(store, deferred
139
130
  }();
140
131
  };
141
132
  var createFileFromUpload = /*#__PURE__*/function () {
142
- var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(file, store, uploadableFileUpfrontIds, uploadId, traceContext) {
133
+ var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(file, store, uploadableFileUpfrontIds, uploadId, traceContext) {
143
134
  var collection, name, mimeType, id, occurrenceKey;
144
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
145
- while (1) {
146
- switch (_context5.prev = _context5.next) {
147
- case 0:
148
- collection = file.collection, name = file.name, mimeType = file.mimeType;
149
- id = uploadableFileUpfrontIds.id, occurrenceKey = uploadableFileUpfrontIds.occurrenceKey;
150
- return _context5.abrupt("return", store.createFileFromUpload({
151
- uploadId: uploadId,
152
- name: name,
153
- mimeType: mimeType
154
- }, {
155
- occurrenceKey: occurrenceKey,
156
- collection: collection,
157
- replaceFileId: id
158
- }, traceContext));
159
- case 3:
160
- case "end":
161
- return _context5.stop();
162
- }
135
+ return _regeneratorRuntime.wrap(function _callee5$(_context5) {
136
+ while (1) switch (_context5.prev = _context5.next) {
137
+ case 0:
138
+ collection = file.collection, name = file.name, mimeType = file.mimeType;
139
+ id = uploadableFileUpfrontIds.id, occurrenceKey = uploadableFileUpfrontIds.occurrenceKey;
140
+ return _context5.abrupt("return", store.createFileFromUpload({
141
+ uploadId: uploadId,
142
+ name: name,
143
+ mimeType: mimeType
144
+ }, {
145
+ occurrenceKey: occurrenceKey,
146
+ collection: collection,
147
+ replaceFileId: id
148
+ }, traceContext));
149
+ case 3:
150
+ case "end":
151
+ return _context5.stop();
163
152
  }
164
153
  }, _callee5);
165
154
  }));
@@ -3,7 +3,7 @@ export var convertBase64ToBlob = function convertBase64ToBlob(base64) {
3
3
  var base64Data = base64.split(',')[1];
4
4
  var byteCharacters = atob(base64Data);
5
5
  var byteArrays = [];
6
- var _loop = function _loop(offset) {
6
+ var _loop = function _loop() {
7
7
  var slice = byteCharacters.slice(offset, offset + sliceSize);
8
8
  var byteNumbers = slice.split('').map(function (_, i) {
9
9
  return slice.charCodeAt(i);
@@ -12,7 +12,7 @@ export var convertBase64ToBlob = function convertBase64ToBlob(base64) {
12
12
  byteArrays.push(byteArray);
13
13
  };
14
14
  for (var offset = 0; offset < byteCharacters.length; offset += sliceSize) {
15
- _loop(offset);
15
+ _loop();
16
16
  }
17
17
  return new Blob(byteArrays, {
18
18
  type: 'image/jpeg'