9d99c26fac50b55fb6a68eaccc4683b7b87c19c9c5fe039107da969531855a95417c51495d3cc8e500c86ac0e103ce07176647c1b85ebeba91d72c7008f7bd 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = _regeneratorRuntime;
  6. function _regeneratorRuntime() {
  7. "use strict";
  8. exports.default = _regeneratorRuntime = function () {
  9. return _exports;
  10. };
  11. var _exports = {};
  12. var Op = Object.prototype;
  13. var hasOwn = Op.hasOwnProperty;
  14. var undefined;
  15. var $Symbol = typeof Symbol === "function" ? Symbol : {};
  16. var iteratorSymbol = $Symbol.iterator || "@@iterator";
  17. var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
  18. var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
  19. function define(obj, key, value, noFlags) {
  20. return Object.defineProperty(obj, key, {
  21. value: value,
  22. enumerable: !noFlags,
  23. configurable: !noFlags,
  24. writable: !noFlags
  25. });
  26. }
  27. try {
  28. define({}, "");
  29. } catch (_) {
  30. define = function (obj, key, value) {
  31. return obj[key] = value;
  32. };
  33. }
  34. function wrap(innerFn, outerFn, self, tryLocsList) {
  35. var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
  36. var generator = Object.create(protoGenerator.prototype);
  37. var context = new Context(tryLocsList || []);
  38. define(generator, "_invoke", makeInvokeMethod(innerFn, self, context), true);
  39. return generator;
  40. }
  41. _exports.wrap = wrap;
  42. function tryCatch(fn, obj, arg) {
  43. try {
  44. return {
  45. type: "normal",
  46. arg: fn.call(obj, arg)
  47. };
  48. } catch (err) {
  49. return {
  50. type: "throw",
  51. arg: err
  52. };
  53. }
  54. }
  55. var ContinueSentinel = {};
  56. function Generator() {}
  57. function GeneratorFunction() {}
  58. function GeneratorFunctionPrototype() {}
  59. var IteratorPrototype = {};
  60. define(IteratorPrototype, iteratorSymbol, function () {
  61. return this;
  62. });
  63. var getProto = Object.getPrototypeOf;
  64. var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
  65. if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
  66. IteratorPrototype = NativeIteratorPrototype;
  67. }
  68. var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
  69. GeneratorFunction.prototype = GeneratorFunctionPrototype;
  70. define(Gp, "constructor", GeneratorFunctionPrototype);
  71. define(GeneratorFunctionPrototype, "constructor", GeneratorFunction);
  72. GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction");
  73. function defineIteratorMethods(prototype) {
  74. ["next", "throw", "return"].forEach(function (method) {
  75. define(prototype, method, function (arg) {
  76. return this._invoke(method, arg);
  77. });
  78. });
  79. }
  80. _exports.isGeneratorFunction = function (genFun) {
  81. var ctor = typeof genFun === "function" && genFun.constructor;
  82. return ctor ? ctor === GeneratorFunction || (ctor.displayName || ctor.name) === "GeneratorFunction" : false;
  83. };
  84. _exports.mark = function (genFun) {
  85. if (Object.setPrototypeOf) {
  86. Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
  87. } else {
  88. genFun.__proto__ = GeneratorFunctionPrototype;
  89. define(genFun, toStringTagSymbol, "GeneratorFunction");
  90. }
  91. genFun.prototype = Object.create(Gp);
  92. return genFun;
  93. };
  94. _exports.awrap = function (arg) {
  95. return {
  96. __await: arg
  97. };
  98. };
  99. function AsyncIterator(generator, PromiseImpl) {
  100. function invoke(method, arg, resolve, reject) {
  101. var record = tryCatch(generator[method], generator, arg);
  102. if (record.type === "throw") {
  103. reject(record.arg);
  104. } else {
  105. var result = record.arg;
  106. var value = result.value;
  107. if (value && typeof value === "object" && hasOwn.call(value, "__await")) {
  108. return PromiseImpl.resolve(value.__await).then(function (value) {
  109. invoke("next", value, resolve, reject);
  110. }, function (err) {
  111. invoke("throw", err, resolve, reject);
  112. });
  113. }
  114. return PromiseImpl.resolve(value).then(function (unwrapped) {
  115. result.value = unwrapped;
  116. resolve(result);
  117. }, function (error) {
  118. return invoke("throw", error, resolve, reject);
  119. });
  120. }
  121. }
  122. var previousPromise;
  123. function enqueue(method, arg) {
  124. function callInvokeWithMethodAndArg() {
  125. return new PromiseImpl(function (resolve, reject) {
  126. invoke(method, arg, resolve, reject);
  127. });
  128. }
  129. return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
  130. }
  131. define(this, "_invoke", enqueue, true);
  132. }
  133. defineIteratorMethods(AsyncIterator.prototype);
  134. define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
  135. return this;
  136. });
  137. _exports.AsyncIterator = AsyncIterator;
  138. _exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
  139. if (PromiseImpl === void 0) PromiseImpl = Promise;
  140. var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
  141. return _exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
  142. return result.done ? result.value : iter.next();
  143. });
  144. };
  145. function makeInvokeMethod(innerFn, self, context) {
  146. var state = 1;
  147. return function invoke(method, arg) {
  148. if (state === 3) {
  149. throw new Error("Generator is already running");
  150. }
  151. if (state === 4) {
  152. if (method === "throw") {
  153. throw arg;
  154. }
  155. return {
  156. value: undefined,
  157. done: true
  158. };
  159. }
  160. context.method = method;
  161. context.arg = arg;
  162. while (true) {
  163. var delegate = context.delegate;
  164. if (delegate) {
  165. var delegateResult = maybeInvokeDelegate(delegate, context);
  166. if (delegateResult) {
  167. if (delegateResult === ContinueSentinel) continue;
  168. return delegateResult;
  169. }
  170. }
  171. if (context.method === "next") {
  172. context.sent = context._sent = context.arg;
  173. } else if (context.method === "throw") {
  174. if (state === 1) {
  175. state = 4;
  176. throw context.arg;
  177. }
  178. context.dispatchException(context.arg);
  179. } else if (context.method === "return") {
  180. context.abrupt("return", context.arg);
  181. }
  182. state = 3;
  183. var record = tryCatch(innerFn, self, context);
  184. if (record.type === "normal") {
  185. state = context.done ? 4 : 2;
  186. if (record.arg === ContinueSentinel) {
  187. continue;
  188. }
  189. return {
  190. value: record.arg,
  191. done: context.done
  192. };
  193. } else if (record.type === "throw") {
  194. state = 4;
  195. context.method = "throw";
  196. context.arg = record.arg;
  197. }
  198. }
  199. };
  200. }
  201. function maybeInvokeDelegate(delegate, context) {
  202. var methodName = context.method;
  203. var method = delegate.i[methodName];
  204. if (method === undefined) {
  205. context.delegate = null;
  206. if (methodName === "throw" && delegate.i["return"]) {
  207. context.method = "return";
  208. context.arg = undefined;
  209. maybeInvokeDelegate(delegate, context);
  210. if (context.method === "throw") {
  211. return ContinueSentinel;
  212. }
  213. }
  214. if (methodName !== "return") {
  215. context.method = "throw";
  216. context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method");
  217. }
  218. return ContinueSentinel;
  219. }
  220. var record = tryCatch(method, delegate.i, context.arg);
  221. if (record.type === "throw") {
  222. context.method = "throw";
  223. context.arg = record.arg;
  224. context.delegate = null;
  225. return ContinueSentinel;
  226. }
  227. var info = record.arg;
  228. if (!info) {
  229. context.method = "throw";
  230. context.arg = new TypeError("iterator result is not an object");
  231. context.delegate = null;
  232. return ContinueSentinel;
  233. }
  234. if (info.done) {
  235. context[delegate.r] = info.value;
  236. context.next = delegate.n;
  237. if (context.method !== "return") {
  238. context.method = "next";
  239. context.arg = undefined;
  240. }
  241. } else {
  242. return info;
  243. }
  244. context.delegate = null;
  245. return ContinueSentinel;
  246. }
  247. defineIteratorMethods(Gp);
  248. define(Gp, toStringTagSymbol, "Generator");
  249. define(Gp, iteratorSymbol, function () {
  250. return this;
  251. });
  252. define(Gp, "toString", function () {
  253. return "[object Generator]";
  254. });
  255. function pushTryEntry(locs) {
  256. this.tryEntries.push(locs);
  257. }
  258. function resetTryEntry(entry) {
  259. var record = entry[4] || {};
  260. record.type = "normal";
  261. record.arg = undefined;
  262. entry[4] = record;
  263. }
  264. function Context(tryLocsList) {
  265. this.tryEntries = [[-1]];
  266. tryLocsList.forEach(pushTryEntry, this);
  267. this.reset(true);
  268. }
  269. _exports.keys = function (val) {
  270. var object = Object(val);
  271. var keys = [];
  272. var key;
  273. for (var key in object) {
  274. keys.unshift(key);
  275. }
  276. return function next() {
  277. while (keys.length) {
  278. key = keys.pop();
  279. if (key in object) {
  280. next.value = key;
  281. next.done = false;
  282. return next;
  283. }
  284. }
  285. next.done = true;
  286. return next;
  287. };
  288. };
  289. function values(iterable) {
  290. if (iterable != null) {
  291. var iteratorMethod = iterable[iteratorSymbol];
  292. if (iteratorMethod) {
  293. return iteratorMethod.call(iterable);
  294. }
  295. if (typeof iterable.next === "function") {
  296. return iterable;
  297. }
  298. if (!isNaN(iterable.length)) {
  299. var i = -1,
  300. next = function next() {
  301. while (++i < iterable.length) {
  302. if (hasOwn.call(iterable, i)) {
  303. next.value = iterable[i];
  304. next.done = false;
  305. return next;
  306. }
  307. }
  308. next.value = undefined;
  309. next.done = true;
  310. return next;
  311. };
  312. return next.next = next;
  313. }
  314. }
  315. throw new TypeError(typeof iterable + " is not iterable");
  316. }
  317. _exports.values = values;
  318. Context.prototype = {
  319. constructor: Context,
  320. reset: function (skipTempReset) {
  321. this.prev = this.next = 0;
  322. this.sent = this._sent = undefined;
  323. this.done = false;
  324. this.delegate = null;
  325. this.method = "next";
  326. this.arg = undefined;
  327. this.tryEntries.forEach(resetTryEntry);
  328. if (!skipTempReset) {
  329. for (var name in this) {
  330. if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) {
  331. this[name] = undefined;
  332. }
  333. }
  334. }
  335. },
  336. stop: function () {
  337. this.done = true;
  338. var rootEntry = this.tryEntries[0];
  339. var rootRecord = rootEntry[4];
  340. if (rootRecord.type === "throw") {
  341. throw rootRecord.arg;
  342. }
  343. return this.rval;
  344. },
  345. dispatchException: function (exception) {
  346. if (this.done) {
  347. throw exception;
  348. }
  349. var context = this;
  350. function handle(loc) {
  351. record.type = "throw";
  352. record.arg = exception;
  353. context.next = loc;
  354. }
  355. for (var i = context.tryEntries.length - 1; i >= 0; --i) {
  356. var entry = this.tryEntries[i];
  357. var record = entry[4];
  358. var prev = this.prev;
  359. var catchLoc = entry[1];
  360. var finallyLoc = entry[2];
  361. if (entry[0] === -1) {
  362. handle("end");
  363. return false;
  364. }
  365. if (!catchLoc && !finallyLoc) {
  366. throw new Error("try statement without catch or finally");
  367. }
  368. if (entry[0] != null && entry[0] <= prev) {
  369. if (prev < catchLoc) {
  370. this.method = "next";
  371. this.arg = undefined;
  372. handle(catchLoc);
  373. return true;
  374. } else if (prev < finallyLoc) {
  375. handle(finallyLoc);
  376. return false;
  377. }
  378. }
  379. }
  380. },
  381. abrupt: function (type, arg) {
  382. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  383. var entry = this.tryEntries[i];
  384. if (entry[0] > -1 && entry[0] <= this.prev && this.prev < entry[2]) {
  385. var finallyEntry = entry;
  386. break;
  387. }
  388. }
  389. if (finallyEntry && (type === "break" || type === "continue") && finallyEntry[0] <= arg && arg <= finallyEntry[2]) {
  390. finallyEntry = null;
  391. }
  392. var record = finallyEntry ? finallyEntry[4] : {};
  393. record.type = type;
  394. record.arg = arg;
  395. if (finallyEntry) {
  396. this.method = "next";
  397. this.next = finallyEntry[2];
  398. return ContinueSentinel;
  399. }
  400. return this.complete(record);
  401. },
  402. complete: function (record, afterLoc) {
  403. if (record.type === "throw") {
  404. throw record.arg;
  405. }
  406. if (record.type === "break" || record.type === "continue") {
  407. this.next = record.arg;
  408. } else if (record.type === "return") {
  409. this.rval = this.arg = record.arg;
  410. this.method = "return";
  411. this.next = "end";
  412. } else if (record.type === "normal" && afterLoc) {
  413. this.next = afterLoc;
  414. }
  415. return ContinueSentinel;
  416. },
  417. finish: function (finallyLoc) {
  418. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  419. var entry = this.tryEntries[i];
  420. if (entry[2] === finallyLoc) {
  421. this.complete(entry[4], entry[3]);
  422. resetTryEntry(entry);
  423. return ContinueSentinel;
  424. }
  425. }
  426. },
  427. catch: function (tryLoc) {
  428. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  429. var entry = this.tryEntries[i];
  430. if (entry[0] === tryLoc) {
  431. var record = entry[4];
  432. if (record.type === "throw") {
  433. var thrown = record.arg;
  434. resetTryEntry(entry);
  435. }
  436. return thrown;
  437. }
  438. }
  439. throw new Error("illegal catch attempt");
  440. },
  441. delegateYield: function (iterable, resultName, nextLoc) {
  442. this.delegate = {
  443. i: values(iterable),
  444. r: resultName,
  445. n: nextLoc
  446. };
  447. if (this.method === "next") {
  448. this.arg = undefined;
  449. }
  450. return ContinueSentinel;
  451. }
  452. };
  453. return _exports;
  454. }
  455. //# sourceMappingURL=regeneratorRuntime.js.map