@atlaskit/media-client 21.0.0 → 22.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/dist/cjs/client/file-fetcher/error.js +4 -4
- package/dist/cjs/client/file-fetcher/index.js +283 -297
- package/dist/cjs/client/media-client.js +42 -48
- package/dist/cjs/client/media-store/index.js +389 -310
- package/dist/cjs/client/media-store/resolveAuth.js +33 -36
- package/dist/cjs/client/stargate-client.js +17 -20
- package/dist/cjs/index.js +6 -0
- package/dist/cjs/models/media.js +4 -4
- package/dist/cjs/uploader/error.js +4 -4
- package/dist/cjs/uploader/index.js +97 -108
- package/dist/cjs/utils/convertBase64ToBlob.js +2 -2
- package/dist/cjs/utils/createFileDataLoader.js +68 -73
- package/dist/cjs/utils/getDimensionsFromBlob.js +26 -29
- package/dist/cjs/utils/getVideoDimensionsFromBlob.js +27 -30
- package/dist/cjs/utils/hashing/hasherCreator.js +35 -37
- package/dist/cjs/utils/mobileUpload/error.js +4 -4
- package/dist/cjs/utils/mobileUpload/helpers.js +44 -47
- package/dist/cjs/utils/mobileUpload/stateMachine/index.js +17 -20
- package/dist/cjs/utils/parseJwt.js +52 -0
- package/dist/cjs/utils/polling/index.js +43 -46
- package/dist/cjs/utils/request/errors.js +9 -9
- package/dist/cjs/utils/request/helpers.js +154 -167
- package/dist/cjs/utils/request/index.js +27 -30
- package/dist/cjs/utils/shouldFetchRemoteFileStates.js +42 -45
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/client/file-fetcher/index.js +1 -3
- package/dist/es2019/client/media-store/index.js +58 -6
- package/dist/es2019/index.js +1 -1
- package/dist/es2019/models/media.js +3 -3
- package/dist/es2019/utils/parseJwt.js +46 -0
- package/dist/es2019/version.json +1 -1
- package/dist/esm/client/file-fetcher/error.js +4 -4
- package/dist/esm/client/file-fetcher/index.js +282 -296
- package/dist/esm/client/media-client.js +40 -47
- package/dist/esm/client/media-store/index.js +389 -310
- package/dist/esm/client/media-store/resolveAuth.js +33 -36
- package/dist/esm/client/stargate-client.js +17 -20
- package/dist/esm/index.js +1 -1
- package/dist/esm/models/media.js +3 -3
- package/dist/esm/uploader/error.js +4 -4
- package/dist/esm/uploader/index.js +97 -108
- package/dist/esm/utils/convertBase64ToBlob.js +2 -2
- package/dist/esm/utils/createFileDataLoader.js +68 -73
- package/dist/esm/utils/getDimensionsFromBlob.js +26 -29
- package/dist/esm/utils/getVideoDimensionsFromBlob.js +27 -30
- package/dist/esm/utils/hashing/hasherCreator.js +31 -34
- package/dist/esm/utils/mobileUpload/error.js +4 -4
- package/dist/esm/utils/mobileUpload/helpers.js +44 -47
- package/dist/esm/utils/mobileUpload/stateMachine/index.js +17 -20
- package/dist/esm/utils/parseJwt.js +46 -0
- package/dist/esm/utils/polling/index.js +43 -46
- package/dist/esm/utils/request/errors.js +9 -9
- package/dist/esm/utils/request/helpers.js +154 -167
- package/dist/esm/utils/request/index.js +27 -30
- package/dist/esm/utils/shouldFetchRemoteFileStates.js +42 -45
- package/dist/esm/version.json +1 -1
- package/dist/types/client/media-store/index.d.ts +15 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/utils/parseJwt.d.ts +1 -0
- package/package.json +9 -9
- package/report.api.md +31 -0
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
@@ -18,6 +17,7 @@ Object.defineProperty(exports, "isFileFetcherError", {
|
|
|
18
17
|
return _error.isFileFetcherError;
|
|
19
18
|
}
|
|
20
19
|
});
|
|
20
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
21
21
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
22
22
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
23
23
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
@@ -51,13 +51,13 @@ var _polling = require("../../utils/polling");
|
|
|
51
51
|
var _detectEmptyFile = require("../../utils/detectEmptyFile");
|
|
52
52
|
var _mediaCommon = require("@atlaskit/media-common");
|
|
53
53
|
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; }
|
|
54
|
-
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) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
55
|
-
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; } // import setimmediate to temporary fix dataloader 2.0.0 bug
|
|
54
|
+
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) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; } // import setimmediate to temporary fix dataloader 2.0.0 bug
|
|
56
55
|
// @see https://github.com/graphql/dataloader/issues/249
|
|
57
56
|
var FileFetcherImpl = /*#__PURE__*/function () {
|
|
58
57
|
function FileFetcherImpl(mediaStore, featureFlags) {
|
|
59
58
|
var _this = this;
|
|
60
59
|
(0, _classCallCheck2.default)(this, FileFetcherImpl);
|
|
60
|
+
// TODO: ----- ADD TICKET TO PASS TRACE ID to this.dataloader.load
|
|
61
61
|
(0, _defineProperty2.default)(this, "createDownloadFileStream", function (id, collectionName, occurrenceKey) {
|
|
62
62
|
var subject = (0, _createMediaSubject.createMediaSubject)();
|
|
63
63
|
var poll = new _polling.PollingFunction();
|
|
@@ -66,53 +66,51 @@ var FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
66
66
|
poll.onError = function (error) {
|
|
67
67
|
return subject.error(error);
|
|
68
68
|
};
|
|
69
|
-
poll.execute( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/
|
|
69
|
+
poll.execute( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
|
|
70
70
|
var response, fileState;
|
|
71
|
-
return
|
|
72
|
-
while (1) {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
_context.next = 5;
|
|
84
|
-
break;
|
|
85
|
-
}
|
|
86
|
-
throw new _error.FileFetcherError('emptyItems', id, {
|
|
87
|
-
collectionName: collectionName,
|
|
88
|
-
occurrenceKey: occurrenceKey
|
|
89
|
-
});
|
|
90
|
-
case 5:
|
|
91
|
-
if (!(0, _detectEmptyFile.isEmptyFile)(response)) {
|
|
92
|
-
_context.next = 7;
|
|
93
|
-
break;
|
|
94
|
-
}
|
|
95
|
-
throw new _error.FileFetcherError('zeroVersionFile', id, {
|
|
96
|
-
collectionName: collectionName,
|
|
97
|
-
occurrenceKey: occurrenceKey
|
|
98
|
-
});
|
|
99
|
-
case 7:
|
|
100
|
-
fileState = (0, _fileState.mapMediaItemToFileState)(id, response);
|
|
101
|
-
subject.next(fileState);
|
|
102
|
-
_context.t0 = fileState.status;
|
|
103
|
-
_context.next = _context.t0 === 'processing' ? 12 : _context.t0 === 'processed' ? 14 : 16;
|
|
71
|
+
return _regenerator.default.wrap(function _callee$(_context) {
|
|
72
|
+
while (1) switch (_context.prev = _context.next) {
|
|
73
|
+
case 0:
|
|
74
|
+
_context.next = 2;
|
|
75
|
+
return _this.dataloader.load({
|
|
76
|
+
id: id,
|
|
77
|
+
collectionName: collectionName
|
|
78
|
+
});
|
|
79
|
+
case 2:
|
|
80
|
+
response = _context.sent;
|
|
81
|
+
if (response) {
|
|
82
|
+
_context.next = 5;
|
|
104
83
|
break;
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
84
|
+
}
|
|
85
|
+
throw new _error.FileFetcherError('emptyItems', id, {
|
|
86
|
+
collectionName: collectionName,
|
|
87
|
+
occurrenceKey: occurrenceKey
|
|
88
|
+
});
|
|
89
|
+
case 5:
|
|
90
|
+
if (!(0, _detectEmptyFile.isEmptyFile)(response)) {
|
|
91
|
+
_context.next = 7;
|
|
92
|
+
break;
|
|
93
|
+
}
|
|
94
|
+
throw new _error.FileFetcherError('zeroVersionFile', id, {
|
|
95
|
+
collectionName: collectionName,
|
|
96
|
+
occurrenceKey: occurrenceKey
|
|
97
|
+
});
|
|
98
|
+
case 7:
|
|
99
|
+
fileState = (0, _fileState.mapMediaItemToFileState)(id, response);
|
|
100
|
+
subject.next(fileState);
|
|
101
|
+
_context.t0 = fileState.status;
|
|
102
|
+
_context.next = _context.t0 === 'processing' ? 12 : _context.t0 === 'processed' ? 14 : 16;
|
|
103
|
+
break;
|
|
104
|
+
case 12:
|
|
105
|
+
// the only case for continuing polling, otherwise this function is run once only
|
|
106
|
+
poll.next();
|
|
107
|
+
return _context.abrupt("break", 16);
|
|
108
|
+
case 14:
|
|
109
|
+
subject.complete();
|
|
110
|
+
return _context.abrupt("break", 16);
|
|
111
|
+
case 16:
|
|
112
|
+
case "end":
|
|
113
|
+
return _context.stop();
|
|
116
114
|
}
|
|
117
115
|
}, _callee);
|
|
118
116
|
})));
|
|
@@ -191,8 +189,6 @@ var FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
191
189
|
value: function getFileBinaryURL(id, collectionName) {
|
|
192
190
|
return this.mediaStore.getFileBinaryURL(id, collectionName);
|
|
193
191
|
}
|
|
194
|
-
|
|
195
|
-
// TODO: ----- ADD TICKET TO PASS TRACE ID to this.dataloader.load
|
|
196
192
|
}, {
|
|
197
193
|
key: "touchFiles",
|
|
198
194
|
value: function touchFiles(descriptors, collection, traceContext) {
|
|
@@ -227,124 +223,118 @@ var FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
227
223
|
}, {
|
|
228
224
|
key: "uploadExternal",
|
|
229
225
|
value: function () {
|
|
230
|
-
var _uploadExternal = (0, _asyncToGenerator2.default)( /*#__PURE__*/
|
|
226
|
+
var _uploadExternal = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(url, collection, traceContext) {
|
|
231
227
|
var _this3 = this;
|
|
232
228
|
var uploadableFileUpfrontIds, id, occurrenceKey, subject, deferredBlob, preview, name, fileState;
|
|
233
|
-
return
|
|
234
|
-
while (1) {
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
var
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
if (!blob) {
|
|
257
|
-
reject('Could not fetch the blob');
|
|
258
|
-
}
|
|
259
|
-
resolve({
|
|
260
|
-
value: blob,
|
|
261
|
-
origin: 'remote'
|
|
262
|
-
});
|
|
263
|
-
case 5:
|
|
264
|
-
case "end":
|
|
265
|
-
return _context2.stop();
|
|
229
|
+
return _regenerator.default.wrap(function _callee4$(_context4) {
|
|
230
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
231
|
+
case 0:
|
|
232
|
+
uploadableFileUpfrontIds = this.generateUploadableFileUpfrontIds(collection, traceContext);
|
|
233
|
+
id = uploadableFileUpfrontIds.id, occurrenceKey = uploadableFileUpfrontIds.occurrenceKey;
|
|
234
|
+
subject = (0, _createMediaSubject.createMediaSubject)();
|
|
235
|
+
deferredBlob = fetch(url).then(function (response) {
|
|
236
|
+
return response.blob();
|
|
237
|
+
}).catch(function () {
|
|
238
|
+
return undefined;
|
|
239
|
+
});
|
|
240
|
+
preview = new Promise( /*#__PURE__*/function () {
|
|
241
|
+
var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(resolve, reject) {
|
|
242
|
+
var blob;
|
|
243
|
+
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
244
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
245
|
+
case 0:
|
|
246
|
+
_context2.next = 2;
|
|
247
|
+
return deferredBlob;
|
|
248
|
+
case 2:
|
|
249
|
+
blob = _context2.sent;
|
|
250
|
+
if (!blob) {
|
|
251
|
+
reject('Could not fetch the blob');
|
|
266
252
|
}
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
mediaType: 'unknown',
|
|
280
|
-
mimeType: '',
|
|
281
|
-
id: id,
|
|
282
|
-
occurrenceKey: occurrenceKey,
|
|
283
|
-
preview: preview
|
|
253
|
+
resolve({
|
|
254
|
+
value: blob,
|
|
255
|
+
origin: 'remote'
|
|
256
|
+
});
|
|
257
|
+
case 5:
|
|
258
|
+
case "end":
|
|
259
|
+
return _context2.stop();
|
|
260
|
+
}
|
|
261
|
+
}, _callee2);
|
|
262
|
+
}));
|
|
263
|
+
return function (_x4, _x5) {
|
|
264
|
+
return _ref3.apply(this, arguments);
|
|
284
265
|
};
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
subject.next({
|
|
314
|
-
status: 'processing',
|
|
315
|
-
name: name,
|
|
316
|
-
size: size,
|
|
317
|
-
mediaType: mediaType,
|
|
318
|
-
mimeType: type,
|
|
319
|
-
id: id,
|
|
320
|
-
occurrenceKey: occurrenceKey,
|
|
321
|
-
preview: preview
|
|
322
|
-
});
|
|
323
|
-
// we don't want to wait for the file to be upload
|
|
324
|
-
_this3.upload(file, undefined, uploadableFileUpfrontIds, traceContext);
|
|
325
|
-
_context3.next = 12;
|
|
326
|
-
return (0, _getDimensionsFromBlob.getDimensionsFromBlob)(mediaType, blob);
|
|
327
|
-
case 12:
|
|
328
|
-
dimensions = _context3.sent;
|
|
329
|
-
resolve({
|
|
330
|
-
dimensions: dimensions,
|
|
331
|
-
uploadableFileUpfrontIds: uploadableFileUpfrontIds
|
|
332
|
-
});
|
|
333
|
-
case 14:
|
|
334
|
-
case "end":
|
|
335
|
-
return _context3.stop();
|
|
266
|
+
}());
|
|
267
|
+
name = url.split('/').pop() || ''; // we create a initial fileState with the minimum info that we have at this point
|
|
268
|
+
fileState = {
|
|
269
|
+
status: 'processing',
|
|
270
|
+
name: name,
|
|
271
|
+
size: 0,
|
|
272
|
+
mediaType: 'unknown',
|
|
273
|
+
mimeType: '',
|
|
274
|
+
id: id,
|
|
275
|
+
occurrenceKey: occurrenceKey,
|
|
276
|
+
preview: preview
|
|
277
|
+
};
|
|
278
|
+
subject.next(fileState);
|
|
279
|
+
// we save it into the cache as soon as possible, in case someone subscribes
|
|
280
|
+
(0, _fileStreamsCache.getFileStreamsCache)().set(id, subject);
|
|
281
|
+
return _context4.abrupt("return", new Promise( /*#__PURE__*/function () {
|
|
282
|
+
var _ref4 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(resolve, reject) {
|
|
283
|
+
var blob, type, size, file, mediaType, dimensions;
|
|
284
|
+
return _regenerator.default.wrap(function _callee3$(_context3) {
|
|
285
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
286
|
+
case 0:
|
|
287
|
+
_context3.next = 2;
|
|
288
|
+
return deferredBlob;
|
|
289
|
+
case 2:
|
|
290
|
+
blob = _context3.sent;
|
|
291
|
+
if (blob) {
|
|
292
|
+
_context3.next = 5;
|
|
293
|
+
break;
|
|
336
294
|
}
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
295
|
+
return _context3.abrupt("return", reject('Could not download remote file'));
|
|
296
|
+
case 5:
|
|
297
|
+
type = blob.type, size = blob.size;
|
|
298
|
+
file = {
|
|
299
|
+
content: blob,
|
|
300
|
+
mimeType: type,
|
|
301
|
+
collection: collection,
|
|
302
|
+
name: name
|
|
303
|
+
};
|
|
304
|
+
mediaType = (0, _mediaTypeUtils.getMediaTypeFromMimeType)(type); // we emit a richer state after the blob is fetched
|
|
305
|
+
subject.next({
|
|
306
|
+
status: 'processing',
|
|
307
|
+
name: name,
|
|
308
|
+
size: size,
|
|
309
|
+
mediaType: mediaType,
|
|
310
|
+
mimeType: type,
|
|
311
|
+
id: id,
|
|
312
|
+
occurrenceKey: occurrenceKey,
|
|
313
|
+
preview: preview
|
|
314
|
+
});
|
|
315
|
+
// we don't want to wait for the file to be upload
|
|
316
|
+
_this3.upload(file, undefined, uploadableFileUpfrontIds, traceContext);
|
|
317
|
+
_context3.next = 12;
|
|
318
|
+
return (0, _getDimensionsFromBlob.getDimensionsFromBlob)(mediaType, blob);
|
|
319
|
+
case 12:
|
|
320
|
+
dimensions = _context3.sent;
|
|
321
|
+
resolve({
|
|
322
|
+
dimensions: dimensions,
|
|
323
|
+
uploadableFileUpfrontIds: uploadableFileUpfrontIds
|
|
324
|
+
});
|
|
325
|
+
case 14:
|
|
326
|
+
case "end":
|
|
327
|
+
return _context3.stop();
|
|
328
|
+
}
|
|
329
|
+
}, _callee3);
|
|
330
|
+
}));
|
|
331
|
+
return function (_x6, _x7) {
|
|
332
|
+
return _ref4.apply(this, arguments);
|
|
333
|
+
};
|
|
334
|
+
}()));
|
|
335
|
+
case 10:
|
|
336
|
+
case "end":
|
|
337
|
+
return _context4.stop();
|
|
348
338
|
}
|
|
349
339
|
}, _callee4, this);
|
|
350
340
|
}));
|
|
@@ -498,33 +488,31 @@ var FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
498
488
|
}, {
|
|
499
489
|
key: "downloadBinary",
|
|
500
490
|
value: function () {
|
|
501
|
-
var _downloadBinary = (0, _asyncToGenerator2.default)( /*#__PURE__*/
|
|
491
|
+
var _downloadBinary = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5(id) {
|
|
502
492
|
var name,
|
|
503
493
|
collectionName,
|
|
504
494
|
url,
|
|
505
495
|
_args5 = arguments;
|
|
506
|
-
return
|
|
507
|
-
while (1) {
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
return _context5.stop();
|
|
527
|
-
}
|
|
496
|
+
return _regenerator.default.wrap(function _callee5$(_context5) {
|
|
497
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
498
|
+
case 0:
|
|
499
|
+
name = _args5.length > 1 && _args5[1] !== undefined ? _args5[1] : 'download';
|
|
500
|
+
collectionName = _args5.length > 2 ? _args5[2] : undefined;
|
|
501
|
+
_context5.next = 4;
|
|
502
|
+
return this.mediaStore.getFileBinaryURL(id, collectionName);
|
|
503
|
+
case 4:
|
|
504
|
+
url = _context5.sent;
|
|
505
|
+
(0, _downloadUrl.downloadUrl)(url, {
|
|
506
|
+
name: name
|
|
507
|
+
});
|
|
508
|
+
_globalMediaEventEmitter.globalMediaEventEmitter.emit('media-viewed', {
|
|
509
|
+
fileId: id,
|
|
510
|
+
isUserCollection: collectionName === _constants.RECENTS_COLLECTION,
|
|
511
|
+
viewingLevel: 'download'
|
|
512
|
+
});
|
|
513
|
+
case 7:
|
|
514
|
+
case "end":
|
|
515
|
+
return _context5.stop();
|
|
528
516
|
}
|
|
529
517
|
}, _callee5, this);
|
|
530
518
|
}));
|
|
@@ -536,7 +524,7 @@ var FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
536
524
|
}, {
|
|
537
525
|
key: "copyFile",
|
|
538
526
|
value: function () {
|
|
539
|
-
var _copyFile = (0, _asyncToGenerator2.default)( /*#__PURE__*/
|
|
527
|
+
var _copyFile = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6(source, destination) {
|
|
540
528
|
var options,
|
|
541
529
|
traceContext,
|
|
542
530
|
authProvider,
|
|
@@ -566,120 +554,118 @@ var FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
566
554
|
previewOverride,
|
|
567
555
|
_fileCache,
|
|
568
556
|
_args6 = arguments;
|
|
569
|
-
return
|
|
570
|
-
while (1) {
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
owner: owner
|
|
594
|
-
}
|
|
595
|
-
};
|
|
596
|
-
params = {
|
|
597
|
-
collection: destinationCollectionName,
|
|
598
|
-
replaceFileId: replaceFileId,
|
|
599
|
-
occurrenceKey: occurrenceKey
|
|
600
|
-
};
|
|
601
|
-
cache = (0, _fileStreamsCache.getFileStreamsCache)();
|
|
602
|
-
_context6.prev = 14;
|
|
603
|
-
_context6.next = 17;
|
|
604
|
-
return mediaStore.copyFileWithToken(body, params, traceContext);
|
|
605
|
-
case 17:
|
|
606
|
-
_yield$mediaStore$cop = _context6.sent;
|
|
607
|
-
copiedFile = _yield$mediaStore$cop.data;
|
|
608
|
-
// if we were passed a "mimeType", we propagate it into copiedFileWithMimeType
|
|
609
|
-
copiedFileWithMimeType = _objectSpread(_objectSpread({}, copiedFile), mimeType ? {
|
|
610
|
-
mimeType: mimeType
|
|
611
|
-
} : undefined);
|
|
612
|
-
copiedId = copiedFileWithMimeType.id, copiedMimeType = copiedFileWithMimeType.mimeType; // backend may return an "unknown" mediaType just after the copy
|
|
613
|
-
// it's better to deduce it from "copiedMimeType" using getMediaTypeFromMimeType()
|
|
614
|
-
mediaType = copiedMimeType ? (0, _mediaTypeUtils.getMediaTypeFromMimeType)(copiedMimeType) : 'unknown';
|
|
615
|
-
copiedFileState = (0, _fileState.mapMediaFileToFileState)({
|
|
616
|
-
data: copiedFileWithMimeType
|
|
617
|
-
});
|
|
618
|
-
fileCache = cache.get(copiedId);
|
|
619
|
-
subject = fileCache || (0, _createMediaSubject.createMediaSubject)(); // if we were passed a "preview", we propagate it into the copiedFileState
|
|
620
|
-
previewOverride = !(0, _fileState.isErrorFileState)(copiedFileState) && !!preview ? {
|
|
621
|
-
preview: preview
|
|
622
|
-
} : {};
|
|
623
|
-
_context6.t2 = !(0, _fileState.isFinalFileState)(copiedFileState) &&
|
|
624
|
-
// mimeType should always be returned by "copyFileWithToken"
|
|
625
|
-
// but in case it's not, we don't want to penalize "copyFile"
|
|
626
|
-
copiedMimeType;
|
|
627
|
-
if (!_context6.t2) {
|
|
628
|
-
_context6.next = 31;
|
|
629
|
-
break;
|
|
630
|
-
}
|
|
631
|
-
_context6.next = 30;
|
|
632
|
-
return (0, _shouldFetchRemoteFileStates.shouldFetchRemoteFileStates)(mediaType, copiedMimeType, preview);
|
|
633
|
-
case 30:
|
|
634
|
-
_context6.t2 = _context6.sent;
|
|
635
|
-
case 31:
|
|
636
|
-
if (!_context6.t2) {
|
|
637
|
-
_context6.next = 36;
|
|
638
|
-
break;
|
|
557
|
+
return _regenerator.default.wrap(function _callee6$(_context6) {
|
|
558
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
559
|
+
case 0:
|
|
560
|
+
options = _args6.length > 2 && _args6[2] !== undefined ? _args6[2] : {};
|
|
561
|
+
traceContext = _args6.length > 3 ? _args6[3] : undefined;
|
|
562
|
+
authProvider = source.authProvider, sourceCollection = source.collection, id = source.id;
|
|
563
|
+
destinationAuthProvider = destination.authProvider, destinationCollectionName = destination.collection, replaceFileId = destination.replaceFileId, occurrenceKey = destination.occurrenceKey;
|
|
564
|
+
preview = options.preview, mimeType = options.mimeType;
|
|
565
|
+
mediaStore = destination.mediaStore || new _mediaStore.MediaStore({
|
|
566
|
+
authProvider: destinationAuthProvider
|
|
567
|
+
});
|
|
568
|
+
_context6.t0 = _mediaCore.authToOwner;
|
|
569
|
+
_context6.next = 9;
|
|
570
|
+
return authProvider({
|
|
571
|
+
collectionName: sourceCollection
|
|
572
|
+
});
|
|
573
|
+
case 9:
|
|
574
|
+
_context6.t1 = _context6.sent;
|
|
575
|
+
owner = (0, _context6.t0)(_context6.t1);
|
|
576
|
+
body = {
|
|
577
|
+
sourceFile: {
|
|
578
|
+
id: id,
|
|
579
|
+
collection: sourceCollection,
|
|
580
|
+
owner: owner
|
|
639
581
|
}
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
582
|
+
};
|
|
583
|
+
params = {
|
|
584
|
+
collection: destinationCollectionName,
|
|
585
|
+
replaceFileId: replaceFileId,
|
|
586
|
+
occurrenceKey: occurrenceKey
|
|
587
|
+
};
|
|
588
|
+
cache = (0, _fileStreamsCache.getFileStreamsCache)();
|
|
589
|
+
_context6.prev = 14;
|
|
590
|
+
_context6.next = 17;
|
|
591
|
+
return mediaStore.copyFileWithToken(body, params, traceContext);
|
|
592
|
+
case 17:
|
|
593
|
+
_yield$mediaStore$cop = _context6.sent;
|
|
594
|
+
copiedFile = _yield$mediaStore$cop.data;
|
|
595
|
+
// if we were passed a "mimeType", we propagate it into copiedFileWithMimeType
|
|
596
|
+
copiedFileWithMimeType = _objectSpread(_objectSpread({}, copiedFile), mimeType ? {
|
|
597
|
+
mimeType: mimeType
|
|
598
|
+
} : undefined);
|
|
599
|
+
copiedId = copiedFileWithMimeType.id, copiedMimeType = copiedFileWithMimeType.mimeType; // backend may return an "unknown" mediaType just after the copy
|
|
600
|
+
// it's better to deduce it from "copiedMimeType" using getMediaTypeFromMimeType()
|
|
601
|
+
mediaType = copiedMimeType ? (0, _mediaTypeUtils.getMediaTypeFromMimeType)(copiedMimeType) : 'unknown';
|
|
602
|
+
copiedFileState = (0, _fileState.mapMediaFileToFileState)({
|
|
603
|
+
data: copiedFileWithMimeType
|
|
604
|
+
});
|
|
605
|
+
fileCache = cache.get(copiedId);
|
|
606
|
+
subject = fileCache || (0, _createMediaSubject.createMediaSubject)(); // if we were passed a "preview", we propagate it into the copiedFileState
|
|
607
|
+
previewOverride = !(0, _fileState.isErrorFileState)(copiedFileState) && !!preview ? {
|
|
608
|
+
preview: preview
|
|
609
|
+
} : {};
|
|
610
|
+
_context6.t2 = !(0, _fileState.isFinalFileState)(copiedFileState) &&
|
|
611
|
+
// mimeType should always be returned by "copyFileWithToken"
|
|
612
|
+
// but in case it's not, we don't want to penalize "copyFile"
|
|
613
|
+
copiedMimeType;
|
|
614
|
+
if (!_context6.t2) {
|
|
615
|
+
_context6.next = 31;
|
|
653
616
|
break;
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
617
|
+
}
|
|
618
|
+
_context6.next = 30;
|
|
619
|
+
return (0, _shouldFetchRemoteFileStates.shouldFetchRemoteFileStates)(mediaType, copiedMimeType, preview);
|
|
620
|
+
case 30:
|
|
621
|
+
_context6.t2 = _context6.sent;
|
|
622
|
+
case 31:
|
|
623
|
+
if (!_context6.t2) {
|
|
624
|
+
_context6.next = 36;
|
|
625
|
+
break;
|
|
626
|
+
}
|
|
627
|
+
subject.next(_objectSpread(_objectSpread(_objectSpread({}, copiedFileState), (0, _overrideMediaTypeIfUnknown.overrideMediaTypeIfUnknown)(copiedFileState, mediaType)), previewOverride));
|
|
628
|
+
processingSubscription = this.createDownloadFileStream(copiedId, destinationCollectionName, occurrenceKey).subscribe({
|
|
629
|
+
next: function next(remoteFileState) {
|
|
630
|
+
return subject.next(_objectSpread(_objectSpread(_objectSpread({}, remoteFileState), (0, _overrideMediaTypeIfUnknown.overrideMediaTypeIfUnknown)(remoteFileState, mediaType)), !(0, _fileState.isErrorFileState)(remoteFileState) && previewOverride));
|
|
631
|
+
},
|
|
632
|
+
error: function error(err) {
|
|
633
|
+
return subject.error(err);
|
|
634
|
+
},
|
|
635
|
+
complete: function complete() {
|
|
636
|
+
return subject.complete();
|
|
668
637
|
}
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
638
|
+
});
|
|
639
|
+
_context6.next = 37;
|
|
640
|
+
break;
|
|
641
|
+
case 36:
|
|
642
|
+
if (!(0, _fileState.isProcessingFileState)(copiedFileState)) {
|
|
643
|
+
subject.next(_objectSpread(_objectSpread({}, copiedFileState), !(0, _fileState.isErrorFileState)(copiedFileState) && previewOverride));
|
|
644
|
+
}
|
|
645
|
+
case 37:
|
|
646
|
+
if (!cache.has(copiedId)) {
|
|
647
|
+
(0, _fileStreamsCache.getFileStreamsCache)().set(copiedId, subject);
|
|
648
|
+
}
|
|
649
|
+
return _context6.abrupt("return", copiedFile);
|
|
650
|
+
case 41:
|
|
651
|
+
_context6.prev = 41;
|
|
652
|
+
_context6.t3 = _context6["catch"](14);
|
|
653
|
+
if (processingSubscription) {
|
|
654
|
+
processingSubscription.unsubscribe();
|
|
655
|
+
}
|
|
656
|
+
if (replaceFileId) {
|
|
657
|
+
_fileCache = cache.get(replaceFileId);
|
|
658
|
+
if (_fileCache) {
|
|
659
|
+
_fileCache.error(_context6.t3);
|
|
660
|
+
} else {
|
|
661
|
+
// Create a new subject with the error state for new subscriptions
|
|
662
|
+
cache.set(id, (0, _createMediaSubject.createMediaSubject)(_context6.t3));
|
|
677
663
|
}
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
664
|
+
}
|
|
665
|
+
throw _context6.t3;
|
|
666
|
+
case 46:
|
|
667
|
+
case "end":
|
|
668
|
+
return _context6.stop();
|
|
683
669
|
}
|
|
684
670
|
}, _callee6, this, [[14, 41]]);
|
|
685
671
|
}));
|