regeneratorRuntime.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  1. import _typeof from "./typeof.js";
  2. export default function _regeneratorRuntime() {
  3. "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
  4. _regeneratorRuntime = function _regeneratorRuntime() {
  5. return exports;
  6. };
  7. var exports = {},
  8. Op = Object.prototype,
  9. hasOwn = Op.hasOwnProperty,
  10. $Symbol = "function" == typeof Symbol ? Symbol : {},
  11. iteratorSymbol = $Symbol.iterator || "@@iterator",
  12. asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
  13. toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
  14. function define(obj, key, value) {
  15. return Object.defineProperty(obj, key, {
  16. value: value,
  17. enumerable: !0,
  18. configurable: !0,
  19. writable: !0
  20. }), obj[key];
  21. }
  22. try {
  23. define({}, "");
  24. } catch (err) {
  25. define = function define(obj, key, value) {
  26. return obj[key] = value;
  27. };
  28. }
  29. function wrap(innerFn, outerFn, self, tryLocsList) {
  30. var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
  31. generator = Object.create(protoGenerator.prototype),
  32. context = new Context(tryLocsList || []);
  33. return generator._invoke = function (innerFn, self, context) {
  34. var state = "suspendedStart";
  35. return function (method, arg) {
  36. if ("executing" === state) throw new Error("Generator is already running");
  37. if ("completed" === state) {
  38. if ("throw" === method) throw arg;
  39. return doneResult();
  40. }
  41. for (context.method = method, context.arg = arg;;) {
  42. var delegate = context.delegate;
  43. if (delegate) {
  44. var delegateResult = maybeInvokeDelegate(delegate, context);
  45. if (delegateResult) {
  46. if (delegateResult === ContinueSentinel) continue;
  47. return delegateResult;
  48. }
  49. }
  50. if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
  51. if ("suspendedStart" === state) throw state = "completed", context.arg;
  52. context.dispatchException(context.arg);
  53. } else "return" === context.method && context.abrupt("return", context.arg);
  54. state = "executing";
  55. var record = tryCatch(innerFn, self, context);
  56. if ("normal" === record.type) {
  57. if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
  58. return {
  59. value: record.arg,
  60. done: context.done
  61. };
  62. }
  63. "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
  64. }
  65. };
  66. }(innerFn, self, context), generator;
  67. }
  68. function tryCatch(fn, obj, arg) {
  69. try {
  70. return {
  71. type: "normal",
  72. arg: fn.call(obj, arg)
  73. };
  74. } catch (err) {
  75. return {
  76. type: "throw",
  77. arg: err
  78. };
  79. }
  80. }
  81. exports.wrap = wrap;
  82. var ContinueSentinel = {};
  83. function Generator() {}
  84. function GeneratorFunction() {}
  85. function GeneratorFunctionPrototype() {}
  86. var IteratorPrototype = {};
  87. define(IteratorPrototype, iteratorSymbol, function () {
  88. return this;
  89. });
  90. var getProto = Object.getPrototypeOf,
  91. NativeIteratorPrototype = getProto && getProto(getProto(values([])));
  92. NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
  93. var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
  94. function defineIteratorMethods(prototype) {
  95. ["next", "throw", "return"].forEach(function (method) {
  96. define(prototype, method, function (arg) {
  97. return this._invoke(method, arg);
  98. });
  99. });
  100. }
  101. function AsyncIterator(generator, PromiseImpl) {
  102. function invoke(method, arg, resolve, reject) {
  103. var record = tryCatch(generator[method], generator, arg);
  104. if ("throw" !== record.type) {
  105. var result = record.arg,
  106. value = result.value;
  107. return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
  108. invoke("next", value, resolve, reject);
  109. }, function (err) {
  110. invoke("throw", err, resolve, reject);
  111. }) : PromiseImpl.resolve(value).then(function (unwrapped) {
  112. result.value = unwrapped, resolve(result);
  113. }, function (error) {
  114. return invoke("throw", error, resolve, reject);
  115. });
  116. }
  117. reject(record.arg);
  118. }
  119. var previousPromise;
  120. this._invoke = function (method, arg) {
  121. function callInvokeWithMethodAndArg() {
  122. return new PromiseImpl(function (resolve, reject) {
  123. invoke(method, arg, resolve, reject);
  124. });
  125. }
  126. return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
  127. };
  128. }
  129. function maybeInvokeDelegate(delegate, context) {
  130. var method = delegate.iterator[context.method];
  131. if (undefined === method) {
  132. if (context.delegate = null, "throw" === context.method) {
  133. if (delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel;
  134. context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method");
  135. }
  136. return ContinueSentinel;
  137. }
  138. var record = tryCatch(method, delegate.iterator, context.arg);
  139. if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
  140. var info = record.arg;
  141. 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);
  142. }
  143. function pushTryEntry(locs) {
  144. var entry = {
  145. tryLoc: locs[0]
  146. };
  147. 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
  148. }
  149. function resetTryEntry(entry) {
  150. var record = entry.completion || {};
  151. record.type = "normal", delete record.arg, entry.completion = record;
  152. }
  153. function Context(tryLocsList) {
  154. this.tryEntries = [{
  155. tryLoc: "root"
  156. }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
  157. }
  158. function values(iterable) {
  159. if (iterable) {
  160. var iteratorMethod = iterable[iteratorSymbol];
  161. if (iteratorMethod) return iteratorMethod.call(iterable);
  162. if ("function" == typeof iterable.next) return iterable;
  163. if (!isNaN(iterable.length)) {
  164. var i = -1,
  165. next = function next() {
  166. for (; ++i < iterable.length;) {
  167. if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
  168. }
  169. return next.value = undefined, next.done = !0, next;
  170. };
  171. return next.next = next;
  172. }
  173. }
  174. return {
  175. next: doneResult
  176. };
  177. }
  178. function doneResult() {
  179. return {
  180. value: undefined,
  181. done: !0
  182. };
  183. }
  184. return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
  185. var ctor = "function" == typeof genFun && genFun.constructor;
  186. return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
  187. }, exports.mark = function (genFun) {
  188. return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
  189. }, exports.awrap = function (arg) {
  190. return {
  191. __await: arg
  192. };
  193. }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
  194. return this;
  195. }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
  196. void 0 === PromiseImpl && (PromiseImpl = Promise);
  197. var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
  198. return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
  199. return result.done ? result.value : iter.next();
  200. });
  201. }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
  202. return this;
  203. }), define(Gp, "toString", function () {
  204. return "[object Generator]";
  205. }), exports.keys = function (object) {
  206. var keys = [];
  207. for (var key in object) {
  208. keys.push(key);
  209. }
  210. return keys.reverse(), function next() {
  211. for (; keys.length;) {
  212. var key = keys.pop();
  213. if (key in object) return next.value = key, next.done = !1, next;
  214. }
  215. return next.done = !0, next;
  216. };
  217. }, exports.values = values, Context.prototype = {
  218. constructor: Context,
  219. reset: function reset(skipTempReset) {
  220. 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) {
  221. "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined);
  222. }
  223. },
  224. stop: function stop() {
  225. this.done = !0;
  226. var rootRecord = this.tryEntries[0].completion;
  227. if ("throw" === rootRecord.type) throw rootRecord.arg;
  228. return this.rval;
  229. },
  230. dispatchException: function dispatchException(exception) {
  231. if (this.done) throw exception;
  232. var context = this;
  233. function handle(loc, caught) {
  234. return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
  235. }
  236. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  237. var entry = this.tryEntries[i],
  238. record = entry.completion;
  239. if ("root" === entry.tryLoc) return handle("end");
  240. if (entry.tryLoc <= this.prev) {
  241. var hasCatch = hasOwn.call(entry, "catchLoc"),
  242. hasFinally = hasOwn.call(entry, "finallyLoc");
  243. if (hasCatch && hasFinally) {
  244. if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
  245. if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
  246. } else if (hasCatch) {
  247. if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
  248. } else {
  249. if (!hasFinally) throw new Error("try statement without catch or finally");
  250. if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
  251. }
  252. }
  253. }
  254. },
  255. abrupt: function abrupt(type, arg) {
  256. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  257. var entry = this.tryEntries[i];
  258. if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
  259. var finallyEntry = entry;
  260. break;
  261. }
  262. }
  263. finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
  264. var record = finallyEntry ? finallyEntry.completion : {};
  265. return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
  266. },
  267. complete: function complete(record, afterLoc) {
  268. if ("throw" === record.type) throw record.arg;
  269. 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;
  270. },
  271. finish: function finish(finallyLoc) {
  272. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  273. var entry = this.tryEntries[i];
  274. if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
  275. }
  276. },
  277. "catch": function _catch(tryLoc) {
  278. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  279. var entry = this.tryEntries[i];
  280. if (entry.tryLoc === tryLoc) {
  281. var record = entry.completion;
  282. if ("throw" === record.type) {
  283. var thrown = record.arg;
  284. resetTryEntry(entry);
  285. }
  286. return thrown;
  287. }
  288. }
  289. throw new Error("illegal catch attempt");
  290. },
  291. delegateYield: function delegateYield(iterable, resultName, nextLoc) {
  292. return this.delegate = {
  293. iterator: values(iterable),
  294. resultName: resultName,
  295. nextLoc: nextLoc
  296. }, "next" === this.method && (this.arg = undefined), ContinueSentinel;
  297. }
  298. }, exports;
  299. }