@atlaskit/editor-card-provider 2.0.4 → 3.0.1

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.
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
8
  exports.editorCardProvider = exports.EditorCardProvider = void 0;
9
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
9
10
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
10
11
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
11
12
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
@@ -20,8 +21,9 @@ var _linkProvider = require("@atlaskit/link-provider");
20
21
  var api = _interopRequireWildcard(require("./api"));
21
22
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
22
23
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
23
- 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
24
+ // import setimmediate to temporary fix dataloader 2.0.0 bug
24
25
  // @see https://github.com/graphql/dataloader/issues/249
26
+
25
27
  var BATCH_WAIT_TIME = 50;
26
28
  var isJiraRoadMap = function isJiraRoadMap(url) {
27
29
  return url.match(/^https:\/\/.*?\/jira\/software\/(c\/)?projects\/[^\/]+?\/boards\/.*?\/roadmap\/?/);
@@ -60,23 +62,21 @@ var EditorCardProvider = /*#__PURE__*/function () {
60
62
  (0, _createClass2.default)(EditorCardProvider, [{
61
63
  key: "batchProviders",
62
64
  value: function () {
63
- var _batchProviders = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(keys) {
65
+ var _batchProviders = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(keys) {
64
66
  var providersData;
65
- return _regeneratorRuntime().wrap(function _callee$(_context) {
66
- while (1) {
67
- switch (_context.prev = _context.next) {
68
- case 0:
69
- _context.next = 2;
70
- return this.fetchProvidersData();
71
- case 2:
72
- providersData = _context.sent;
73
- return _context.abrupt("return", keys.map(function () {
74
- return providersData;
75
- }));
76
- case 4:
77
- case "end":
78
- return _context.stop();
79
- }
67
+ return _regenerator.default.wrap(function _callee$(_context) {
68
+ while (1) switch (_context.prev = _context.next) {
69
+ case 0:
70
+ _context.next = 2;
71
+ return this.fetchProvidersData();
72
+ case 2:
73
+ providersData = _context.sent;
74
+ return _context.abrupt("return", keys.map(function () {
75
+ return providersData;
76
+ }));
77
+ case 4:
78
+ case "end":
79
+ return _context.stop();
80
80
  }
81
81
  }, _callee, this);
82
82
  }));
@@ -88,33 +88,31 @@ var EditorCardProvider = /*#__PURE__*/function () {
88
88
  }, {
89
89
  key: "check",
90
90
  value: function () {
91
- var _check = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(resourceUrl) {
91
+ var _check = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(resourceUrl) {
92
92
  var response;
93
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
94
- while (1) {
95
- switch (_context2.prev = _context2.next) {
96
- case 0:
97
- _context2.prev = 0;
98
- _context2.next = 3;
99
- return this.cardClient.fetchData(resourceUrl);
100
- case 3:
101
- response = _context2.sent;
102
- if (!((0, _utils.getStatus)(response) !== 'not_found')) {
103
- _context2.next = 6;
104
- break;
105
- }
106
- return _context2.abrupt("return", true);
107
- case 6:
108
- _context2.next = 11;
93
+ return _regenerator.default.wrap(function _callee2$(_context2) {
94
+ while (1) switch (_context2.prev = _context2.next) {
95
+ case 0:
96
+ _context2.prev = 0;
97
+ _context2.next = 3;
98
+ return this.cardClient.fetchData(resourceUrl);
99
+ case 3:
100
+ response = _context2.sent;
101
+ if (!((0, _utils.getStatus)(response) !== 'not_found')) {
102
+ _context2.next = 6;
109
103
  break;
110
- case 8:
111
- _context2.prev = 8;
112
- _context2.t0 = _context2["catch"](0);
113
- return _context2.abrupt("return", false);
114
- case 11:
115
- case "end":
116
- return _context2.stop();
117
- }
104
+ }
105
+ return _context2.abrupt("return", true);
106
+ case 6:
107
+ _context2.next = 11;
108
+ break;
109
+ case 8:
110
+ _context2.prev = 8;
111
+ _context2.t0 = _context2["catch"](0);
112
+ return _context2.abrupt("return", false);
113
+ case 11:
114
+ case "end":
115
+ return _context2.stop();
118
116
  }
119
117
  }, _callee2, this, [[0, 8]]);
120
118
  }));
@@ -126,27 +124,25 @@ var EditorCardProvider = /*#__PURE__*/function () {
126
124
  }, {
127
125
  key: "fetchProvidersData",
128
126
  value: function () {
129
- var _fetchProvidersData = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
127
+ var _fetchProvidersData = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
130
128
  var endpoint, response;
131
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
132
- while (1) {
133
- switch (_context3.prev = _context3.next) {
134
- case 0:
135
- endpoint = "".concat(this.resolverUrl, "/providers");
136
- _context3.next = 3;
137
- return api.request('post', endpoint, undefined, this.requestHeaders);
138
- case 3:
139
- response = _context3.sent;
140
- return _context3.abrupt("return", {
141
- patterns: response.providers.reduce(function (allSources, provider) {
142
- return allSources.concat(provider.patterns);
143
- }, []),
144
- userPreferences: response.userPreferences
145
- });
146
- case 5:
147
- case "end":
148
- return _context3.stop();
149
- }
129
+ return _regenerator.default.wrap(function _callee3$(_context3) {
130
+ while (1) switch (_context3.prev = _context3.next) {
131
+ case 0:
132
+ endpoint = "".concat(this.resolverUrl, "/providers");
133
+ _context3.next = 3;
134
+ return api.request('post', endpoint, undefined, this.requestHeaders);
135
+ case 3:
136
+ response = _context3.sent;
137
+ return _context3.abrupt("return", {
138
+ patterns: response.providers.reduce(function (allSources, provider) {
139
+ return allSources.concat(provider.patterns);
140
+ }, []),
141
+ userPreferences: response.userPreferences
142
+ });
143
+ case 5:
144
+ case "end":
145
+ return _context3.stop();
150
146
  }
151
147
  }, _callee3, this);
152
148
  }));
@@ -158,29 +154,27 @@ var EditorCardProvider = /*#__PURE__*/function () {
158
154
  }, {
159
155
  key: "loadProviderData",
160
156
  value: function () {
161
- var _loadProviderData = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
162
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
163
- while (1) {
164
- switch (_context4.prev = _context4.next) {
165
- case 0:
166
- _context4.prev = 0;
167
- _context4.next = 3;
168
- return this.providersLoader.load('providersData');
169
- case 3:
170
- this.providersData = _context4.sent;
171
- _context4.next = 11;
172
- break;
173
- case 6:
174
- _context4.prev = 6;
175
- _context4.t0 = _context4["catch"](0);
176
- // eslint-disable-next-line
177
- console.error('failed to fetch /providers', _context4.t0);
178
- this.providersLoader.clear('providerData');
179
- return _context4.abrupt("return", undefined);
180
- case 11:
181
- case "end":
182
- return _context4.stop();
183
- }
157
+ var _loadProviderData = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4() {
158
+ return _regenerator.default.wrap(function _callee4$(_context4) {
159
+ while (1) switch (_context4.prev = _context4.next) {
160
+ case 0:
161
+ _context4.prev = 0;
162
+ _context4.next = 3;
163
+ return this.providersLoader.load('providersData');
164
+ case 3:
165
+ this.providersData = _context4.sent;
166
+ _context4.next = 11;
167
+ break;
168
+ case 6:
169
+ _context4.prev = 6;
170
+ _context4.t0 = _context4["catch"](0);
171
+ // eslint-disable-next-line
172
+ console.error('failed to fetch /providers', _context4.t0);
173
+ this.providersLoader.clear('providerData');
174
+ return _context4.abrupt("return", undefined);
175
+ case 11:
176
+ case "end":
177
+ return _context4.stop();
184
178
  }
185
179
  }, _callee4, this, [[0, 6]]);
186
180
  }));
@@ -192,29 +186,27 @@ var EditorCardProvider = /*#__PURE__*/function () {
192
186
  }, {
193
187
  key: "findPattern",
194
188
  value: function () {
195
- var _findPattern = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(url) {
196
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
197
- while (1) {
198
- switch (_context5.prev = _context5.next) {
199
- case 0:
200
- _context5.next = 2;
201
- return this.findPatternData(url);
202
- case 2:
203
- _context5.t0 = !!_context5.sent;
204
- if (_context5.t0) {
205
- _context5.next = 7;
206
- break;
207
- }
208
- _context5.next = 6;
209
- return this.check(url);
210
- case 6:
211
- _context5.t0 = !!_context5.sent;
212
- case 7:
213
- return _context5.abrupt("return", _context5.t0);
214
- case 8:
215
- case "end":
216
- return _context5.stop();
217
- }
189
+ var _findPattern = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5(url) {
190
+ return _regenerator.default.wrap(function _callee5$(_context5) {
191
+ while (1) switch (_context5.prev = _context5.next) {
192
+ case 0:
193
+ _context5.next = 2;
194
+ return this.findPatternData(url);
195
+ case 2:
196
+ _context5.t0 = !!_context5.sent;
197
+ if (_context5.t0) {
198
+ _context5.next = 7;
199
+ break;
200
+ }
201
+ _context5.next = 6;
202
+ return this.check(url);
203
+ case 6:
204
+ _context5.t0 = !!_context5.sent;
205
+ case 7:
206
+ return _context5.abrupt("return", _context5.t0);
207
+ case 8:
208
+ case "end":
209
+ return _context5.stop();
218
210
  }
219
211
  }, _callee5, this);
220
212
  }));
@@ -236,49 +228,47 @@ var EditorCardProvider = /*#__PURE__*/function () {
236
228
  }, {
237
229
  key: "findUserPreference",
238
230
  value: function () {
239
- var _findUserPreference = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(url) {
231
+ var _findUserPreference = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6(url) {
240
232
  var _this$providersData,
241
233
  _this2 = this;
242
234
  var userPreferences, defaultAppearance, appearances, allMatchedLabeledAppearances, longestMatchedLabeledAppearance;
243
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
244
- while (1) {
245
- switch (_context6.prev = _context6.next) {
246
- case 0:
247
- if (this.providersData) {
248
- _context6.next = 3;
249
- break;
250
- }
235
+ return _regenerator.default.wrap(function _callee6$(_context6) {
236
+ while (1) switch (_context6.prev = _context6.next) {
237
+ case 0:
238
+ if (this.providersData) {
251
239
  _context6.next = 3;
252
- return this.loadProviderData();
253
- case 3:
254
- userPreferences = (_this$providersData = this.providersData) === null || _this$providersData === void 0 ? void 0 : _this$providersData.userPreferences;
255
- if (!userPreferences) {
256
- _context6.next = 12;
257
- break;
258
- }
259
- defaultAppearance = userPreferences.defaultAppearance, appearances = userPreferences.appearances;
260
- allMatchedLabeledAppearances = appearances.filter(function (_ref) {
261
- var urlSegment = _ref.urlSegment;
262
- return _this2.doesUrlMatchPath(urlSegment, url);
263
- });
264
- if (!(allMatchedLabeledAppearances.length > 0)) {
265
- _context6.next = 10;
266
- break;
267
- }
268
- longestMatchedLabeledAppearance = allMatchedLabeledAppearances.reduce(function (previousLabeledAppearance, currentLabeledAppearance) {
269
- return previousLabeledAppearance.urlSegment.length > currentLabeledAppearance.urlSegment.length ? previousLabeledAppearance : currentLabeledAppearance;
270
- });
271
- return _context6.abrupt("return", longestMatchedLabeledAppearance.appearance);
272
- case 10:
273
- if (!(defaultAppearance !== 'inline')) {
274
- _context6.next = 12;
275
- break;
276
- }
277
- return _context6.abrupt("return", defaultAppearance);
278
- case 12:
279
- case "end":
280
- return _context6.stop();
281
- }
240
+ break;
241
+ }
242
+ _context6.next = 3;
243
+ return this.loadProviderData();
244
+ case 3:
245
+ userPreferences = (_this$providersData = this.providersData) === null || _this$providersData === void 0 ? void 0 : _this$providersData.userPreferences;
246
+ if (!userPreferences) {
247
+ _context6.next = 12;
248
+ break;
249
+ }
250
+ defaultAppearance = userPreferences.defaultAppearance, appearances = userPreferences.appearances;
251
+ allMatchedLabeledAppearances = appearances.filter(function (_ref) {
252
+ var urlSegment = _ref.urlSegment;
253
+ return _this2.doesUrlMatchPath(urlSegment, url);
254
+ });
255
+ if (!(allMatchedLabeledAppearances.length > 0)) {
256
+ _context6.next = 10;
257
+ break;
258
+ }
259
+ longestMatchedLabeledAppearance = allMatchedLabeledAppearances.reduce(function (previousLabeledAppearance, currentLabeledAppearance) {
260
+ return previousLabeledAppearance.urlSegment.length > currentLabeledAppearance.urlSegment.length ? previousLabeledAppearance : currentLabeledAppearance;
261
+ });
262
+ return _context6.abrupt("return", longestMatchedLabeledAppearance.appearance);
263
+ case 10:
264
+ if (!(defaultAppearance !== 'inline')) {
265
+ _context6.next = 12;
266
+ break;
267
+ }
268
+ return _context6.abrupt("return", defaultAppearance);
269
+ case 12:
270
+ case "end":
271
+ return _context6.stop();
282
272
  }
283
273
  }, _callee6, this);
284
274
  }));
@@ -290,26 +280,24 @@ var EditorCardProvider = /*#__PURE__*/function () {
290
280
  }, {
291
281
  key: "findPatternData",
292
282
  value: function () {
293
- var _findPatternData = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(url) {
283
+ var _findPatternData = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7(url) {
294
284
  var _this$providersData2;
295
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
296
- while (1) {
297
- switch (_context7.prev = _context7.next) {
298
- case 0:
299
- if (this.providersData) {
300
- _context7.next = 3;
301
- break;
302
- }
285
+ return _regenerator.default.wrap(function _callee7$(_context7) {
286
+ while (1) switch (_context7.prev = _context7.next) {
287
+ case 0:
288
+ if (this.providersData) {
303
289
  _context7.next = 3;
304
- return this.loadProviderData();
305
- case 3:
306
- return _context7.abrupt("return", (_this$providersData2 = this.providersData) === null || _this$providersData2 === void 0 ? void 0 : _this$providersData2.patterns.find(function (pattern) {
307
- return url.match(pattern.source);
308
- }));
309
- case 4:
310
- case "end":
311
- return _context7.stop();
312
- }
290
+ break;
291
+ }
292
+ _context7.next = 3;
293
+ return this.loadProviderData();
294
+ case 3:
295
+ return _context7.abrupt("return", (_this$providersData2 = this.providersData) === null || _this$providersData2 === void 0 ? void 0 : _this$providersData2.patterns.find(function (pattern) {
296
+ return url.match(pattern.source);
297
+ }));
298
+ case 4:
299
+ case "end":
300
+ return _context7.stop();
313
301
  }
314
302
  }, _callee7, this);
315
303
  }));
@@ -334,40 +322,38 @@ var EditorCardProvider = /*#__PURE__*/function () {
334
322
  }, {
335
323
  key: "canBeResolvedAsEmbed",
336
324
  value: function () {
337
- var _canBeResolvedAsEmbed = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(url) {
325
+ var _canBeResolvedAsEmbed = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee8(url) {
338
326
  var details, data, preview;
339
- return _regeneratorRuntime().wrap(function _callee8$(_context8) {
340
- while (1) {
341
- switch (_context8.prev = _context8.next) {
342
- case 0:
343
- _context8.prev = 0;
344
- _context8.next = 3;
345
- return this.cardClient.fetchData(url);
346
- case 3:
347
- details = _context8.sent;
348
- data = details && details.data;
349
- if (data) {
350
- _context8.next = 7;
351
- break;
352
- }
353
- return _context8.abrupt("return", false);
354
- case 7:
355
- if (!((0, _utils.getStatus)(details) !== 'resolved')) {
356
- _context8.next = 9;
357
- break;
358
- }
359
- return _context8.abrupt("return", false);
360
- case 9:
361
- preview = (0, _linkingCommon.extractPreview)(data, 'web');
362
- return _context8.abrupt("return", !!preview);
363
- case 13:
364
- _context8.prev = 13;
365
- _context8.t0 = _context8["catch"](0);
366
- return _context8.abrupt("return", false);
367
- case 16:
368
- case "end":
369
- return _context8.stop();
370
- }
327
+ return _regenerator.default.wrap(function _callee8$(_context8) {
328
+ while (1) switch (_context8.prev = _context8.next) {
329
+ case 0:
330
+ _context8.prev = 0;
331
+ _context8.next = 3;
332
+ return this.cardClient.fetchData(url);
333
+ case 3:
334
+ details = _context8.sent;
335
+ data = details && details.data;
336
+ if (data) {
337
+ _context8.next = 7;
338
+ break;
339
+ }
340
+ return _context8.abrupt("return", false);
341
+ case 7:
342
+ if (!((0, _utils.getStatus)(details) !== 'resolved')) {
343
+ _context8.next = 9;
344
+ break;
345
+ }
346
+ return _context8.abrupt("return", false);
347
+ case 9:
348
+ preview = (0, _linkingCommon.extractPreview)(data, 'web');
349
+ return _context8.abrupt("return", !!preview);
350
+ case 13:
351
+ _context8.prev = 13;
352
+ _context8.t0 = _context8["catch"](0);
353
+ return _context8.abrupt("return", false);
354
+ case 16:
355
+ case "end":
356
+ return _context8.stop();
371
357
  }
372
358
  }, _callee8, this, [[0, 13]]);
373
359
  }));
@@ -379,89 +365,87 @@ var EditorCardProvider = /*#__PURE__*/function () {
379
365
  }, {
380
366
  key: "resolve",
381
367
  value: function () {
382
- var _resolve = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(url, appearance, shouldForceAppearance) {
368
+ var _resolve = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee9(url, appearance, shouldForceAppearance) {
383
369
  var hardCodedAppearance, _yield$Promise$all, _yield$Promise$all2, matchedProviderPattern, userPreference, isSupported, providerDefaultAppearance, preferredAppearance, canItBeEmbed;
384
- return _regeneratorRuntime().wrap(function _callee9$(_context9) {
385
- while (1) {
386
- switch (_context9.prev = _context9.next) {
387
- case 0:
388
- _context9.prev = 0;
389
- if (!(shouldForceAppearance === true)) {
390
- _context9.next = 3;
391
- break;
392
- }
393
- return _context9.abrupt("return", this.transformer.toAdf(url, appearance));
394
- case 3:
395
- hardCodedAppearance = this.getHardCodedAppearance(url);
396
- _context9.next = 6;
397
- return Promise.all([this.findPatternData(url), this.findUserPreference(url)]);
398
- case 6:
399
- _yield$Promise$all = _context9.sent;
400
- _yield$Promise$all2 = (0, _slicedToArray2.default)(_yield$Promise$all, 2);
401
- matchedProviderPattern = _yield$Promise$all2[0];
402
- userPreference = _yield$Promise$all2[1];
403
- if (!(shouldForceAppearance === false && userPreference === 'url')) {
404
- _context9.next = 12;
405
- break;
406
- }
407
- return _context9.abrupt("return", Promise.reject(undefined));
408
- case 12:
409
- _context9.t0 = !!matchedProviderPattern;
410
- if (_context9.t0) {
411
- _context9.next = 17;
412
- break;
413
- }
414
- _context9.next = 16;
415
- return this.check(url);
416
- case 16:
417
- _context9.t0 = _context9.sent;
418
- case 17:
419
- isSupported = _context9.t0;
420
- if (!isSupported) {
421
- _context9.next = 27;
422
- break;
423
- }
424
- providerDefaultAppearance = matchedProviderPattern === null || matchedProviderPattern === void 0 ? void 0 : matchedProviderPattern.defaultView;
425
- preferredAppearance = shouldForceAppearance === undefined ?
426
- // Ignore both User and provider's appearances if older editor that doesn't send shouldForceAppearance
427
- hardCodedAppearance || appearance :
428
- // User preferred appearance. It would be either one that has matching domain/path pattern OR
429
- // if user's default choice is NOT "inline" (so, block or embed at this point, url was dealt with above)
430
- userPreference ||
431
- // If user's default choice is "inline" or user hasn't specified preferences at all,
432
- // we check whatever one of the hardcoded providers match url (jira roadmap, polaris, etc)
433
- hardCodedAppearance ||
434
- // If non match, we see if this provider has default appearance for this particular regexp
435
- providerDefaultAppearance ||
436
- // If not, we pick what editor (or any other client) requested
437
- appearance;
438
- if (!(preferredAppearance === userPreference && userPreference === 'embed')) {
439
- _context9.next = 26;
440
- break;
441
- }
442
- _context9.next = 24;
443
- return this.canBeResolvedAsEmbed(url);
444
- case 24:
445
- canItBeEmbed = _context9.sent;
446
- if (!canItBeEmbed) {
447
- preferredAppearance = 'inline';
448
- }
449
- case 26:
450
- return _context9.abrupt("return", this.transformer.toAdf(url, preferredAppearance));
451
- case 27:
452
- _context9.next = 32;
370
+ return _regenerator.default.wrap(function _callee9$(_context9) {
371
+ while (1) switch (_context9.prev = _context9.next) {
372
+ case 0:
373
+ _context9.prev = 0;
374
+ if (!(shouldForceAppearance === true)) {
375
+ _context9.next = 3;
376
+ break;
377
+ }
378
+ return _context9.abrupt("return", this.transformer.toAdf(url, appearance));
379
+ case 3:
380
+ hardCodedAppearance = this.getHardCodedAppearance(url);
381
+ _context9.next = 6;
382
+ return Promise.all([this.findPatternData(url), this.findUserPreference(url)]);
383
+ case 6:
384
+ _yield$Promise$all = _context9.sent;
385
+ _yield$Promise$all2 = (0, _slicedToArray2.default)(_yield$Promise$all, 2);
386
+ matchedProviderPattern = _yield$Promise$all2[0];
387
+ userPreference = _yield$Promise$all2[1];
388
+ if (!(shouldForceAppearance === false && userPreference === 'url')) {
389
+ _context9.next = 12;
390
+ break;
391
+ }
392
+ return _context9.abrupt("return", Promise.reject(undefined));
393
+ case 12:
394
+ _context9.t0 = !!matchedProviderPattern;
395
+ if (_context9.t0) {
396
+ _context9.next = 17;
397
+ break;
398
+ }
399
+ _context9.next = 16;
400
+ return this.check(url);
401
+ case 16:
402
+ _context9.t0 = _context9.sent;
403
+ case 17:
404
+ isSupported = _context9.t0;
405
+ if (!isSupported) {
406
+ _context9.next = 27;
407
+ break;
408
+ }
409
+ providerDefaultAppearance = matchedProviderPattern === null || matchedProviderPattern === void 0 ? void 0 : matchedProviderPattern.defaultView;
410
+ preferredAppearance = shouldForceAppearance === undefined ?
411
+ // Ignore both User and provider's appearances if older editor that doesn't send shouldForceAppearance
412
+ hardCodedAppearance || appearance :
413
+ // User preferred appearance. It would be either one that has matching domain/path pattern OR
414
+ // if user's default choice is NOT "inline" (so, block or embed at this point, url was dealt with above)
415
+ userPreference ||
416
+ // If user's default choice is "inline" or user hasn't specified preferences at all,
417
+ // we check whatever one of the hardcoded providers match url (jira roadmap, polaris, etc)
418
+ hardCodedAppearance ||
419
+ // If non match, we see if this provider has default appearance for this particular regexp
420
+ providerDefaultAppearance ||
421
+ // If not, we pick what editor (or any other client) requested
422
+ appearance;
423
+ if (!(preferredAppearance === userPreference && userPreference === 'embed')) {
424
+ _context9.next = 26;
453
425
  break;
454
- case 29:
455
- _context9.prev = 29;
456
- _context9.t1 = _context9["catch"](0);
457
- // eslint-disable-next-line
458
- console.warn("Error when trying to check Smart Card url \"".concat(url, "\"").concat(_context9.t1 instanceof Error ? " - ".concat(_context9.t1.name, " ").concat(_context9.t1.message) : ''), _context9.t1);
459
- case 32:
460
- return _context9.abrupt("return", Promise.reject(undefined));
461
- case 33:
462
- case "end":
463
- return _context9.stop();
464
- }
426
+ }
427
+ _context9.next = 24;
428
+ return this.canBeResolvedAsEmbed(url);
429
+ case 24:
430
+ canItBeEmbed = _context9.sent;
431
+ if (!canItBeEmbed) {
432
+ preferredAppearance = 'inline';
433
+ }
434
+ case 26:
435
+ return _context9.abrupt("return", this.transformer.toAdf(url, preferredAppearance));
436
+ case 27:
437
+ _context9.next = 32;
438
+ break;
439
+ case 29:
440
+ _context9.prev = 29;
441
+ _context9.t1 = _context9["catch"](0);
442
+ // eslint-disable-next-line
443
+ console.warn("Error when trying to check Smart Card url \"".concat(url, "\"").concat(_context9.t1 instanceof Error ? " - ".concat(_context9.t1.name, " ").concat(_context9.t1.message) : ''), _context9.t1);
444
+ case 32:
445
+ return _context9.abrupt("return", Promise.reject(undefined));
446
+ case 33:
447
+ case "end":
448
+ return _context9.stop();
465
449
  }
466
450
  }, _callee9, this, [[0, 29]]);
467
451
  }));