1 | 'use strict';
|
2 |
|
3 | Object.defineProperty(exports, '__esModule', { value: true });
|
4 |
|
5 | function createCommonjsModule(fn, module) {
|
6 | return module = { exports: {} }, fn(module, module.exports), module.exports;
|
7 | }
|
8 |
|
9 | var _global = createCommonjsModule(function (module) {
|
10 |
|
11 | var global = module.exports = typeof window != 'undefined' && window.Math == Math
|
12 | ? window : typeof self != 'undefined' && self.Math == Math ? self
|
13 |
|
14 | : Function('return this')();
|
15 | if (typeof __g == 'number') __g = global;
|
16 | });
|
17 |
|
18 | var _core = createCommonjsModule(function (module) {
|
19 | var core = module.exports = { version: '2.5.7' };
|
20 | if (typeof __e == 'number') __e = core;
|
21 | });
|
22 | var _core_1 = _core.version;
|
23 |
|
24 | var _isObject = function (it) {
|
25 | return typeof it === 'object' ? it !== null : typeof it === 'function';
|
26 | };
|
27 |
|
28 | var _anObject = function (it) {
|
29 | if (!_isObject(it)) throw TypeError(it + ' is not an object!');
|
30 | return it;
|
31 | };
|
32 |
|
33 | var _fails = function (exec) {
|
34 | try {
|
35 | return !!exec();
|
36 | } catch (e) {
|
37 | return true;
|
38 | }
|
39 | };
|
40 |
|
41 |
|
42 | var _descriptors = !_fails(function () {
|
43 | return Object.defineProperty({}, 'a', { get: function () { return 7; } }).a != 7;
|
44 | });
|
45 |
|
46 | var document$1 = _global.document;
|
47 |
|
48 | var is = _isObject(document$1) && _isObject(document$1.createElement);
|
49 | var _domCreate = function (it) {
|
50 | return is ? document$1.createElement(it) : {};
|
51 | };
|
52 |
|
53 | var _ie8DomDefine = !_descriptors && !_fails(function () {
|
54 | return Object.defineProperty(_domCreate('div'), 'a', { get: function () { return 7; } }).a != 7;
|
55 | });
|
56 |
|
57 |
|
58 |
|
59 |
|
60 |
|
61 | var _toPrimitive = function (it, S) {
|
62 | if (!_isObject(it)) return it;
|
63 | var fn, val;
|
64 | if (S && typeof (fn = it.toString) == 'function' && !_isObject(val = fn.call(it))) return val;
|
65 | if (typeof (fn = it.valueOf) == 'function' && !_isObject(val = fn.call(it))) return val;
|
66 | if (!S && typeof (fn = it.toString) == 'function' && !_isObject(val = fn.call(it))) return val;
|
67 | throw TypeError("Can't convert object to primitive value");
|
68 | };
|
69 |
|
70 | var dP = Object.defineProperty;
|
71 |
|
72 | var f = _descriptors ? Object.defineProperty : function defineProperty(O, P, Attributes) {
|
73 | _anObject(O);
|
74 | P = _toPrimitive(P, true);
|
75 | _anObject(Attributes);
|
76 | if (_ie8DomDefine) try {
|
77 | return dP(O, P, Attributes);
|
78 | } catch (e) { }
|
79 | if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported!');
|
80 | if ('value' in Attributes) O[P] = Attributes.value;
|
81 | return O;
|
82 | };
|
83 |
|
84 | var _objectDp = {
|
85 | f: f
|
86 | };
|
87 |
|
88 | var _propertyDesc = function (bitmap, value) {
|
89 | return {
|
90 | enumerable: !(bitmap & 1),
|
91 | configurable: !(bitmap & 2),
|
92 | writable: !(bitmap & 4),
|
93 | value: value
|
94 | };
|
95 | };
|
96 |
|
97 | var _hide = _descriptors ? function (object, key, value) {
|
98 | return _objectDp.f(object, key, _propertyDesc(1, value));
|
99 | } : function (object, key, value) {
|
100 | object[key] = value;
|
101 | return object;
|
102 | };
|
103 |
|
104 | var hasOwnProperty = {}.hasOwnProperty;
|
105 | var _has = function (it, key) {
|
106 | return hasOwnProperty.call(it, key);
|
107 | };
|
108 |
|
109 | var id = 0;
|
110 | var px = Math.random();
|
111 | var _uid = function (key) {
|
112 | return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36));
|
113 | };
|
114 |
|
115 | var _redefine = createCommonjsModule(function (module) {
|
116 | var SRC = _uid('src');
|
117 | var TO_STRING = 'toString';
|
118 | var $toString = Function[TO_STRING];
|
119 | var TPL = ('' + $toString).split(TO_STRING);
|
120 |
|
121 | _core.inspectSource = function (it) {
|
122 | return $toString.call(it);
|
123 | };
|
124 |
|
125 | (module.exports = function (O, key, val, safe) {
|
126 | var isFunction = typeof val == 'function';
|
127 | if (isFunction) _has(val, 'name') || _hide(val, 'name', key);
|
128 | if (O[key] === val) return;
|
129 | if (isFunction) _has(val, SRC) || _hide(val, SRC, O[key] ? '' + O[key] : TPL.join(String(key)));
|
130 | if (O === _global) {
|
131 | O[key] = val;
|
132 | } else if (!safe) {
|
133 | delete O[key];
|
134 | _hide(O, key, val);
|
135 | } else if (O[key]) {
|
136 | O[key] = val;
|
137 | } else {
|
138 | _hide(O, key, val);
|
139 | }
|
140 |
|
141 | })(Function.prototype, TO_STRING, function toString() {
|
142 | return typeof this == 'function' && this[SRC] || $toString.call(this);
|
143 | });
|
144 | });
|
145 |
|
146 | var _aFunction = function (it) {
|
147 | if (typeof it != 'function') throw TypeError(it + ' is not a function!');
|
148 | return it;
|
149 | };
|
150 |
|
151 |
|
152 |
|
153 | var _ctx = function (fn, that, length) {
|
154 | _aFunction(fn);
|
155 | if (that === undefined) return fn;
|
156 | switch (length) {
|
157 | case 1: return function (a) {
|
158 | return fn.call(that, a);
|
159 | };
|
160 | case 2: return function (a, b) {
|
161 | return fn.call(that, a, b);
|
162 | };
|
163 | case 3: return function (a, b, c) {
|
164 | return fn.call(that, a, b, c);
|
165 | };
|
166 | }
|
167 | return function (/* ...args */) {
|
168 | return fn.apply(that, arguments);
|
169 | };
|
170 | };
|
171 |
|
172 | var PROTOTYPE = 'prototype';
|
173 |
|
174 | var $export = function (type, name, source) {
|
175 | var IS_FORCED = type & $export.F;
|
176 | var IS_GLOBAL = type & $export.G;
|
177 | var IS_STATIC = type & $export.S;
|
178 | var IS_PROTO = type & $export.P;
|
179 | var IS_BIND = type & $export.B;
|
180 | var target = IS_GLOBAL ? _global : IS_STATIC ? _global[name] || (_global[name] = {}) : (_global[name] || {})[PROTOTYPE];
|
181 | var exports = IS_GLOBAL ? _core : _core[name] || (_core[name] = {});
|
182 | var expProto = exports[PROTOTYPE] || (exports[PROTOTYPE] = {});
|
183 | var key, own, out, exp;
|
184 | if (IS_GLOBAL) source = name;
|
185 | for (key in source) {
|
186 |
|
187 | own = !IS_FORCED && target && target[key] !== undefined;
|
188 |
|
189 | out = (own ? target : source)[key];
|
190 |
|
191 | exp = IS_BIND && own ? _ctx(out, _global) : IS_PROTO && typeof out == 'function' ? _ctx(Function.call, out) : out;
|
192 |
|
193 | if (target) _redefine(target, key, out, type & $export.U);
|
194 |
|
195 | if (exports[key] != out) _hide(exports, key, exp);
|
196 | if (IS_PROTO && expProto[key] != out) expProto[key] = out;
|
197 | }
|
198 | };
|
199 | _global.core = _core;
|
200 |
|
201 | $export.F = 1;
|
202 | $export.G = 2;
|
203 | $export.S = 4;
|
204 | $export.P = 8;
|
205 | $export.B = 16;
|
206 | $export.W = 32;
|
207 | $export.U = 64;
|
208 | $export.R = 128;
|
209 | var _export = $export;
|
210 |
|
211 | var toString = {}.toString;
|
212 |
|
213 | var _cof = function (it) {
|
214 | return toString.call(it).slice(8, -1);
|
215 | };
|
216 |
|
217 |
|
218 |
|
219 |
|
220 | var _iobject = Object('z').propertyIsEnumerable(0) ? Object : function (it) {
|
221 | return _cof(it) == 'String' ? it.split('') : Object(it);
|
222 | };
|
223 |
|
224 |
|
225 | var _defined = function (it) {
|
226 | if (it == undefined) throw TypeError("Can't call method on " + it);
|
227 | return it;
|
228 | };
|
229 |
|
230 |
|
231 |
|
232 |
|
233 | var _toIobject = function (it) {
|
234 | return _iobject(_defined(it));
|
235 | };
|
236 |
|
237 |
|
238 | var ceil = Math.ceil;
|
239 | var floor = Math.floor;
|
240 | var _toInteger = function (it) {
|
241 | return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it);
|
242 | };
|
243 |
|
244 |
|
245 |
|
246 | var min = Math.min;
|
247 | var _toLength = function (it) {
|
248 | return it > 0 ? min(_toInteger(it), 0x1fffffffffffff) : 0;
|
249 | };
|
250 |
|
251 | var max = Math.max;
|
252 | var min$1 = Math.min;
|
253 | var _toAbsoluteIndex = function (index, length) {
|
254 | index = _toInteger(index);
|
255 | return index < 0 ? max(index + length, 0) : min$1(index, length);
|
256 | };
|
257 |
|
258 |
|
259 |
|
260 |
|
261 |
|
262 |
|
263 | var _arrayIncludes = function (IS_INCLUDES) {
|
264 | return function ($this, el, fromIndex) {
|
265 | var O = _toIobject($this);
|
266 | var length = _toLength(O.length);
|
267 | var index = _toAbsoluteIndex(fromIndex, length);
|
268 | var value;
|
269 |
|
270 |
|
271 | if (IS_INCLUDES && el != el) while (length > index) {
|
272 | value = O[index++];
|
273 |
|
274 | if (value != value) return true;
|
275 |
|
276 | } else for (;length > index; index++) if (IS_INCLUDES || index in O) {
|
277 | if (O[index] === el) return IS_INCLUDES || index || 0;
|
278 | } return !IS_INCLUDES && -1;
|
279 | };
|
280 | };
|
281 |
|
282 | var _library = false;
|
283 |
|
284 | var _shared = createCommonjsModule(function (module) {
|
285 | var SHARED = '__core-js_shared__';
|
286 | var store = _global[SHARED] || (_global[SHARED] = {});
|
287 |
|
288 | (module.exports = function (key, value) {
|
289 | return store[key] || (store[key] = value !== undefined ? value : {});
|
290 | })('versions', []).push({
|
291 | version: _core.version,
|
292 | mode: 'global',
|
293 | copyright: '© 2018 Denis Pushkarev (zloirock.ru)'
|
294 | });
|
295 | });
|
296 |
|
297 | var shared = _shared('keys');
|
298 |
|
299 | var _sharedKey = function (key) {
|
300 | return shared[key] || (shared[key] = _uid(key));
|
301 | };
|
302 |
|
303 | var arrayIndexOf = _arrayIncludes(false);
|
304 | var IE_PROTO = _sharedKey('IE_PROTO');
|
305 |
|
306 | var _objectKeysInternal = function (object, names) {
|
307 | var O = _toIobject(object);
|
308 | var i = 0;
|
309 | var result = [];
|
310 | var key;
|
311 | for (key in O) if (key != IE_PROTO) _has(O, key) && result.push(key);
|
312 |
|
313 | while (names.length > i) if (_has(O, key = names[i++])) {
|
314 | ~arrayIndexOf(result, key) || result.push(key);
|
315 | }
|
316 | return result;
|
317 | };
|
318 |
|
319 |
|
320 | var _enumBugKeys = (
|
321 | 'constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf'
|
322 | ).split(',');
|
323 |
|
324 |
|
325 |
|
326 |
|
327 |
|
328 | var _objectKeys = Object.keys || function keys(O) {
|
329 | return _objectKeysInternal(O, _enumBugKeys);
|
330 | };
|
331 |
|
332 | var f$1 = Object.getOwnPropertySymbols;
|
333 |
|
334 | var _objectGops = {
|
335 | f: f$1
|
336 | };
|
337 |
|
338 | var f$2 = {}.propertyIsEnumerable;
|
339 |
|
340 | var _objectPie = {
|
341 | f: f$2
|
342 | };
|
343 |
|
344 |
|
345 |
|
346 | var _toObject = function (it) {
|
347 | return Object(_defined(it));
|
348 | };
|
349 |
|
350 |
|
351 |
|
352 |
|
353 |
|
354 |
|
355 |
|
356 | var $assign = Object.assign;
|
357 |
|
358 |
|
359 | var _objectAssign = !$assign || _fails(function () {
|
360 | var A = {};
|
361 | var B = {};
|
362 |
|
363 | var S = Symbol();
|
364 | var K = 'abcdefghijklmnopqrst';
|
365 | A[S] = 7;
|
366 | K.split('').forEach(function (k) { B[k] = k; });
|
367 | return $assign({}, A)[S] != 7 || Object.keys($assign({}, B)).join('') != K;
|
368 | }) ? function assign(target, source) {
|
369 | var T = _toObject(target);
|
370 | var aLen = arguments.length;
|
371 | var index = 1;
|
372 | var getSymbols = _objectGops.f;
|
373 | var isEnum = _objectPie.f;
|
374 | while (aLen > index) {
|
375 | var S = _iobject(arguments[index++]);
|
376 | var keys = getSymbols ? _objectKeys(S).concat(getSymbols(S)) : _objectKeys(S);
|
377 | var length = keys.length;
|
378 | var j = 0;
|
379 | var key;
|
380 | while (length > j) if (isEnum.call(S, key = keys[j++])) T[key] = S[key];
|
381 | } return T;
|
382 | } : $assign;
|
383 |
|
384 |
|
385 |
|
386 |
|
387 | _export(_export.S + _export.F, 'Object', { assign: _objectAssign });
|
388 |
|
389 | function _typeof(obj) {
|
390 | if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
|
391 | _typeof = function (obj) {
|
392 | return typeof obj;
|
393 | };
|
394 | } else {
|
395 | _typeof = function (obj) {
|
396 | return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
397 | };
|
398 | }
|
399 |
|
400 | return _typeof(obj);
|
401 | }
|
402 |
|
403 | function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
404 | try {
|
405 | var info = gen[key](arg);
|
406 | var value = info.value;
|
407 | } catch (error) {
|
408 | reject(error);
|
409 | return;
|
410 | }
|
411 |
|
412 | if (info.done) {
|
413 | resolve(value);
|
414 | } else {
|
415 | Promise.resolve(value).then(_next, _throw);
|
416 | }
|
417 | }
|
418 |
|
419 | function _asyncToGenerator(fn) {
|
420 | return function () {
|
421 | var self = this,
|
422 | args = arguments;
|
423 | return new Promise(function (resolve, reject) {
|
424 | var gen = fn.apply(self, args);
|
425 |
|
426 | function _next(value) {
|
427 | asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
428 | }
|
429 |
|
430 | function _throw(err) {
|
431 | asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
432 | }
|
433 |
|
434 | _next(undefined);
|
435 | });
|
436 | };
|
437 | }
|
438 |
|
439 | function _classCallCheck(instance, Constructor) {
|
440 | if (!(instance instanceof Constructor)) {
|
441 | throw new TypeError("Cannot call a class as a function");
|
442 | }
|
443 | }
|
444 |
|
445 | function _defineProperties(target, props) {
|
446 | for (var i = 0; i < props.length; i++) {
|
447 | var descriptor = props[i];
|
448 | descriptor.enumerable = descriptor.enumerable || false;
|
449 | descriptor.configurable = true;
|
450 | if ("value" in descriptor) descriptor.writable = true;
|
451 | Object.defineProperty(target, descriptor.key, descriptor);
|
452 | }
|
453 | }
|
454 |
|
455 | function _createClass(Constructor, protoProps, staticProps) {
|
456 | if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
457 | if (staticProps) _defineProperties(Constructor, staticProps);
|
458 | return Constructor;
|
459 | }
|
460 |
|
461 | function _defineProperty(obj, key, value) {
|
462 | if (key in obj) {
|
463 | Object.defineProperty(obj, key, {
|
464 | value: value,
|
465 | enumerable: true,
|
466 | configurable: true,
|
467 | writable: true
|
468 | });
|
469 | } else {
|
470 | obj[key] = value;
|
471 | }
|
472 |
|
473 | return obj;
|
474 | }
|
475 |
|
476 | function _toConsumableArray(arr) {
|
477 | return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread();
|
478 | }
|
479 |
|
480 | function _arrayWithoutHoles(arr) {
|
481 | if (Array.isArray(arr)) {
|
482 | for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
|
483 |
|
484 | return arr2;
|
485 | }
|
486 | }
|
487 |
|
488 | function _iterableToArray(iter) {
|
489 | if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
|
490 | }
|
491 |
|
492 | function _nonIterableSpread() {
|
493 | throw new TypeError("Invalid attempt to spread non-iterable instance");
|
494 | }
|
495 |
|
496 |
|
497 |
|
498 |
|
499 |
|
500 | var Model =
|
501 |
|
502 | function () {
|
503 | function Model() {
|
504 | _classCallCheck(this, Model);
|
505 | }
|
506 |
|
507 | _createClass(Model, null, [{
|
508 | key: "deserialize",
|
509 |
|
510 | |
511 |
|
512 |
|
513 |
|
514 |
|
515 | value: function deserialize(record) {
|
516 | return Object.assign({}, record);
|
517 | }
|
518 | }, {
|
519 | key: "attributes",
|
520 |
|
521 | |
522 |
|
523 |
|
524 | get: function get() {
|
525 | return [];
|
526 | }
|
527 | |
528 |
|
529 |
|
530 |
|
531 | }, {
|
532 | key: "relationship",
|
533 | get: function get() {
|
534 | return {};
|
535 | }
|
536 | }]);
|
537 |
|
538 | return Model;
|
539 | }();
|
540 |
|
541 | var _wks = createCommonjsModule(function (module) {
|
542 | var store = _shared('wks');
|
543 |
|
544 | var Symbol = _global.Symbol;
|
545 | var USE_SYMBOL = typeof Symbol == 'function';
|
546 |
|
547 | var $exports = module.exports = function (name) {
|
548 | return store[name] || (store[name] =
|
549 | USE_SYMBOL && Symbol[name] || (USE_SYMBOL ? Symbol : _uid)('Symbol.' + name));
|
550 | };
|
551 |
|
552 | $exports.store = store;
|
553 | });
|
554 |
|
555 |
|
556 | var UNSCOPABLES = _wks('unscopables');
|
557 | var ArrayProto = Array.prototype;
|
558 | if (ArrayProto[UNSCOPABLES] == undefined) _hide(ArrayProto, UNSCOPABLES, {});
|
559 | var _addToUnscopables = function (key) {
|
560 | ArrayProto[UNSCOPABLES][key] = true;
|
561 | };
|
562 |
|
563 |
|
564 |
|
565 | var $includes = _arrayIncludes(true);
|
566 |
|
567 | _export(_export.P, 'Array', {
|
568 | includes: function includes(el /* , fromIndex = 0 */) {
|
569 | return $includes(this, el, arguments.length > 1 ? arguments[1] : undefined);
|
570 | }
|
571 | });
|
572 |
|
573 | _addToUnscopables('includes');
|
574 |
|
575 |
|
576 |
|
577 |
|
578 | var MATCH = _wks('match');
|
579 | var _isRegexp = function (it) {
|
580 | var isRegExp;
|
581 | return _isObject(it) && ((isRegExp = it[MATCH]) !== undefined ? !!isRegExp : _cof(it) == 'RegExp');
|
582 | };
|
583 |
|
584 |
|
585 |
|
586 |
|
587 |
|
588 | var _stringContext = function (that, searchString, NAME) {
|
589 | if (_isRegexp(searchString)) throw TypeError('String#' + NAME + " doesn't accept regex!");
|
590 | return String(_defined(that));
|
591 | };
|
592 |
|
593 | var MATCH$1 = _wks('match');
|
594 | var _failsIsRegexp = function (KEY) {
|
595 | var re = /./;
|
596 | try {
|
597 | '/./'[KEY](re);
|
598 | } catch (e) {
|
599 | try {
|
600 | re[MATCH$1] = false;
|
601 | return !'/./'[KEY](re);
|
602 | } catch (f) { }
|
603 | } return true;
|
604 | };
|
605 |
|
606 | var INCLUDES = 'includes';
|
607 |
|
608 | _export(_export.P + _export.F * _failsIsRegexp(INCLUDES), 'String', {
|
609 | includes: function includes(searchString /* , position = 0 */) {
|
610 | return !!~_stringContext(this, searchString, INCLUDES)
|
611 | .indexOf(searchString, arguments.length > 1 ? arguments[1] : undefined);
|
612 | }
|
613 | });
|
614 |
|
615 | var _objectDps = _descriptors ? Object.defineProperties : function defineProperties(O, Properties) {
|
616 | _anObject(O);
|
617 | var keys = _objectKeys(Properties);
|
618 | var length = keys.length;
|
619 | var i = 0;
|
620 | var P;
|
621 | while (length > i) _objectDp.f(O, P = keys[i++], Properties[P]);
|
622 | return O;
|
623 | };
|
624 |
|
625 | var document$2 = _global.document;
|
626 | var _html = document$2 && document$2.documentElement;
|
627 |
|
628 |
|
629 |
|
630 |
|
631 |
|
632 | var IE_PROTO$1 = _sharedKey('IE_PROTO');
|
633 | var Empty = function () { };
|
634 | var PROTOTYPE$1 = 'prototype';
|
635 |
|
636 |
|
637 | var createDict = function () {
|
638 |
|
639 | var iframe = _domCreate('iframe');
|
640 | var i = _enumBugKeys.length;
|
641 | var lt = '<';
|
642 | var gt = '>';
|
643 | var iframeDocument;
|
644 | iframe.style.display = 'none';
|
645 | _html.appendChild(iframe);
|
646 | iframe.src = 'javascript:';
|
647 |
|
648 |
|
649 | iframeDocument = iframe.contentWindow.document;
|
650 | iframeDocument.open();
|
651 | iframeDocument.write(lt + 'script' + gt + 'document.F=Object' + lt + '/script' + gt);
|
652 | iframeDocument.close();
|
653 | createDict = iframeDocument.F;
|
654 | while (i--) delete createDict[PROTOTYPE$1][_enumBugKeys[i]];
|
655 | return createDict();
|
656 | };
|
657 |
|
658 | var _objectCreate = Object.create || function create(O, Properties) {
|
659 | var result;
|
660 | if (O !== null) {
|
661 | Empty[PROTOTYPE$1] = _anObject(O);
|
662 | result = new Empty();
|
663 | Empty[PROTOTYPE$1] = null;
|
664 |
|
665 | result[IE_PROTO$1] = O;
|
666 | } else result = createDict();
|
667 | return Properties === undefined ? result : _objectDps(result, Properties);
|
668 | };
|
669 |
|
670 | var _redefineAll = function (target, src, safe) {
|
671 | for (var key in src) _redefine(target, key, src[key], safe);
|
672 | return target;
|
673 | };
|
674 |
|
675 | var _anInstance = function (it, Constructor, name, forbiddenField) {
|
676 | if (!(it instanceof Constructor) || (forbiddenField !== undefined && forbiddenField in it)) {
|
677 | throw TypeError(name + ': incorrect invocation!');
|
678 | } return it;
|
679 | };
|
680 |
|
681 |
|
682 |
|
683 | var _iterCall = function (iterator, fn, value, entries) {
|
684 | try {
|
685 | return entries ? fn(_anObject(value)[0], value[1]) : fn(value);
|
686 |
|
687 | } catch (e) {
|
688 | var ret = iterator['return'];
|
689 | if (ret !== undefined) _anObject(ret.call(iterator));
|
690 | throw e;
|
691 | }
|
692 | };
|
693 |
|
694 | var _iterators = {};
|
695 |
|
696 |
|
697 |
|
698 | var ITERATOR = _wks('iterator');
|
699 | var ArrayProto$1 = Array.prototype;
|
700 |
|
701 | var _isArrayIter = function (it) {
|
702 | return it !== undefined && (_iterators.Array === it || ArrayProto$1[ITERATOR] === it);
|
703 | };
|
704 |
|
705 |
|
706 |
|
707 | var TAG = _wks('toStringTag');
|
708 |
|
709 | var ARG = _cof(function () { return arguments; }()) == 'Arguments';
|
710 |
|
711 |
|
712 | var tryGet = function (it, key) {
|
713 | try {
|
714 | return it[key];
|
715 | } catch (e) { }
|
716 | };
|
717 |
|
718 | var _classof = function (it) {
|
719 | var O, T, B;
|
720 | return it === undefined ? 'Undefined' : it === null ? 'Null'
|
721 |
|
722 | : typeof (T = tryGet(O = Object(it), TAG)) == 'string' ? T
|
723 |
|
724 | : ARG ? _cof(O)
|
725 |
|
726 | : (B = _cof(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : B;
|
727 | };
|
728 |
|
729 | var ITERATOR$1 = _wks('iterator');
|
730 |
|
731 | var core_getIteratorMethod = _core.getIteratorMethod = function (it) {
|
732 | if (it != undefined) return it[ITERATOR$1]
|
733 | || it['@@iterator']
|
734 | || _iterators[_classof(it)];
|
735 | };
|
736 |
|
737 | var _forOf = createCommonjsModule(function (module) {
|
738 | var BREAK = {};
|
739 | var RETURN = {};
|
740 | var exports = module.exports = function (iterable, entries, fn, that, ITERATOR) {
|
741 | var iterFn = ITERATOR ? function () { return iterable; } : core_getIteratorMethod(iterable);
|
742 | var f = _ctx(fn, that, entries ? 2 : 1);
|
743 | var index = 0;
|
744 | var length, step, iterator, result;
|
745 | if (typeof iterFn != 'function') throw TypeError(iterable + ' is not iterable!');
|
746 |
|
747 | if (_isArrayIter(iterFn)) for (length = _toLength(iterable.length); length > index; index++) {
|
748 | result = entries ? f(_anObject(step = iterable[index])[0], step[1]) : f(iterable[index]);
|
749 | if (result === BREAK || result === RETURN) return result;
|
750 | } else for (iterator = iterFn.call(iterable); !(step = iterator.next()).done;) {
|
751 | result = _iterCall(iterator, f, step.value, entries);
|
752 | if (result === BREAK || result === RETURN) return result;
|
753 | }
|
754 | };
|
755 | exports.BREAK = BREAK;
|
756 | exports.RETURN = RETURN;
|
757 | });
|
758 |
|
759 | var def = _objectDp.f;
|
760 |
|
761 | var TAG$1 = _wks('toStringTag');
|
762 |
|
763 | var _setToStringTag = function (it, tag, stat) {
|
764 | if (it && !_has(it = stat ? it : it.prototype, TAG$1)) def(it, TAG$1, { configurable: true, value: tag });
|
765 | };
|
766 |
|
767 | var IteratorPrototype = {};
|
768 |
|
769 |
|
770 | _hide(IteratorPrototype, _wks('iterator'), function () { return this; });
|
771 |
|
772 | var _iterCreate = function (Constructor, NAME, next) {
|
773 | Constructor.prototype = _objectCreate(IteratorPrototype, { next: _propertyDesc(1, next) });
|
774 | _setToStringTag(Constructor, NAME + ' Iterator');
|
775 | };
|
776 |
|
777 |
|
778 |
|
779 |
|
780 | var IE_PROTO$2 = _sharedKey('IE_PROTO');
|
781 | var ObjectProto = Object.prototype;
|
782 |
|
783 | var _objectGpo = Object.getPrototypeOf || function (O) {
|
784 | O = _toObject(O);
|
785 | if (_has(O, IE_PROTO$2)) return O[IE_PROTO$2];
|
786 | if (typeof O.constructor == 'function' && O instanceof O.constructor) {
|
787 | return O.constructor.prototype;
|
788 | } return O instanceof Object ? ObjectProto : null;
|
789 | };
|
790 |
|
791 | var ITERATOR$2 = _wks('iterator');
|
792 | var BUGGY = !([].keys && 'next' in [].keys());
|
793 | var FF_ITERATOR = '@@iterator';
|
794 | var KEYS = 'keys';
|
795 | var VALUES = 'values';
|
796 |
|
797 | var returnThis = function () { return this; };
|
798 |
|
799 | var _iterDefine = function (Base, NAME, Constructor, next, DEFAULT, IS_SET, FORCED) {
|
800 | _iterCreate(Constructor, NAME, next);
|
801 | var getMethod = function (kind) {
|
802 | if (!BUGGY && kind in proto) return proto[kind];
|
803 | switch (kind) {
|
804 | case KEYS: return function keys() { return new Constructor(this, kind); };
|
805 | case VALUES: return function values() { return new Constructor(this, kind); };
|
806 | } return function entries() { return new Constructor(this, kind); };
|
807 | };
|
808 | var TAG = NAME + ' Iterator';
|
809 | var DEF_VALUES = DEFAULT == VALUES;
|
810 | var VALUES_BUG = false;
|
811 | var proto = Base.prototype;
|
812 | var $native = proto[ITERATOR$2] || proto[FF_ITERATOR] || DEFAULT && proto[DEFAULT];
|
813 | var $default = $native || getMethod(DEFAULT);
|
814 | var $entries = DEFAULT ? !DEF_VALUES ? $default : getMethod('entries') : undefined;
|
815 | var $anyNative = NAME == 'Array' ? proto.entries || $native : $native;
|
816 | var methods, key, IteratorPrototype;
|
817 |
|
818 | if ($anyNative) {
|
819 | IteratorPrototype = _objectGpo($anyNative.call(new Base()));
|
820 | if (IteratorPrototype !== Object.prototype && IteratorPrototype.next) {
|
821 |
|
822 | _setToStringTag(IteratorPrototype, TAG, true);
|
823 |
|
824 | if (!_library && typeof IteratorPrototype[ITERATOR$2] != 'function') _hide(IteratorPrototype, ITERATOR$2, returnThis);
|
825 | }
|
826 | }
|
827 |
|
828 | if (DEF_VALUES && $native && $native.name !== VALUES) {
|
829 | VALUES_BUG = true;
|
830 | $default = function values() { return $native.call(this); };
|
831 | }
|
832 |
|
833 | if ((!_library || FORCED) && (BUGGY || VALUES_BUG || !proto[ITERATOR$2])) {
|
834 | _hide(proto, ITERATOR$2, $default);
|
835 | }
|
836 |
|
837 | _iterators[NAME] = $default;
|
838 | _iterators[TAG] = returnThis;
|
839 | if (DEFAULT) {
|
840 | methods = {
|
841 | values: DEF_VALUES ? $default : getMethod(VALUES),
|
842 | keys: IS_SET ? $default : getMethod(KEYS),
|
843 | entries: $entries
|
844 | };
|
845 | if (FORCED) for (key in methods) {
|
846 | if (!(key in proto)) _redefine(proto, key, methods[key]);
|
847 | } else _export(_export.P + _export.F * (BUGGY || VALUES_BUG), NAME, methods);
|
848 | }
|
849 | return methods;
|
850 | };
|
851 |
|
852 | var _iterStep = function (done, value) {
|
853 | return { value: value, done: !!done };
|
854 | };
|
855 |
|
856 | var SPECIES = _wks('species');
|
857 |
|
858 | var _setSpecies = function (KEY) {
|
859 | var C = _global[KEY];
|
860 | if (_descriptors && C && !C[SPECIES]) _objectDp.f(C, SPECIES, {
|
861 | configurable: true,
|
862 | get: function () { return this; }
|
863 | });
|
864 | };
|
865 |
|
866 | var _meta = createCommonjsModule(function (module) {
|
867 | var META = _uid('meta');
|
868 |
|
869 |
|
870 | var setDesc = _objectDp.f;
|
871 | var id = 0;
|
872 | var isExtensible = Object.isExtensible || function () {
|
873 | return true;
|
874 | };
|
875 | var FREEZE = !_fails(function () {
|
876 | return isExtensible(Object.preventExtensions({}));
|
877 | });
|
878 | var setMeta = function (it) {
|
879 | setDesc(it, META, { value: {
|
880 | i: 'O' + ++id,
|
881 | w: {}
|
882 | } });
|
883 | };
|
884 | var fastKey = function (it, create) {
|
885 |
|
886 | if (!_isObject(it)) return typeof it == 'symbol' ? it : (typeof it == 'string' ? 'S' : 'P') + it;
|
887 | if (!_has(it, META)) {
|
888 |
|
889 | if (!isExtensible(it)) return 'F';
|
890 |
|
891 | if (!create) return 'E';
|
892 |
|
893 | setMeta(it);
|
894 |
|
895 | } return it[META].i;
|
896 | };
|
897 | var getWeak = function (it, create) {
|
898 | if (!_has(it, META)) {
|
899 |
|
900 | if (!isExtensible(it)) return true;
|
901 |
|
902 | if (!create) return false;
|
903 |
|
904 | setMeta(it);
|
905 |
|
906 | } return it[META].w;
|
907 | };
|
908 |
|
909 | var onFreeze = function (it) {
|
910 | if (FREEZE && meta.NEED && isExtensible(it) && !_has(it, META)) setMeta(it);
|
911 | return it;
|
912 | };
|
913 | var meta = module.exports = {
|
914 | KEY: META,
|
915 | NEED: false,
|
916 | fastKey: fastKey,
|
917 | getWeak: getWeak,
|
918 | onFreeze: onFreeze
|
919 | };
|
920 | });
|
921 | var _meta_1 = _meta.KEY;
|
922 | var _meta_2 = _meta.NEED;
|
923 | var _meta_3 = _meta.fastKey;
|
924 | var _meta_4 = _meta.getWeak;
|
925 | var _meta_5 = _meta.onFreeze;
|
926 |
|
927 | var _validateCollection = function (it, TYPE) {
|
928 | if (!_isObject(it) || it._t !== TYPE) throw TypeError('Incompatible receiver, ' + TYPE + ' required!');
|
929 | return it;
|
930 | };
|
931 |
|
932 | var dP$1 = _objectDp.f;
|
933 |
|
934 |
|
935 |
|
936 |
|
937 |
|
938 |
|
939 |
|
940 |
|
941 |
|
942 | var fastKey = _meta.fastKey;
|
943 |
|
944 | var SIZE = _descriptors ? '_s' : 'size';
|
945 |
|
946 | var getEntry = function (that, key) {
|
947 |
|
948 | var index = fastKey(key);
|
949 | var entry;
|
950 | if (index !== 'F') return that._i[index];
|
951 |
|
952 | for (entry = that._f; entry; entry = entry.n) {
|
953 | if (entry.k == key) return entry;
|
954 | }
|
955 | };
|
956 |
|
957 | var _collectionStrong = {
|
958 | getConstructor: function (wrapper, NAME, IS_MAP, ADDER) {
|
959 | var C = wrapper(function (that, iterable) {
|
960 | _anInstance(that, C, NAME, '_i');
|
961 | that._t = NAME;
|
962 | that._i = _objectCreate(null);
|
963 | that._f = undefined;
|
964 | that._l = undefined;
|
965 | that[SIZE] = 0;
|
966 | if (iterable != undefined) _forOf(iterable, IS_MAP, that[ADDER], that);
|
967 | });
|
968 | _redefineAll(C.prototype, {
|
969 |
|
970 |
|
971 | clear: function clear() {
|
972 | for (var that = _validateCollection(this, NAME), data = that._i, entry = that._f; entry; entry = entry.n) {
|
973 | entry.r = true;
|
974 | if (entry.p) entry.p = entry.p.n = undefined;
|
975 | delete data[entry.i];
|
976 | }
|
977 | that._f = that._l = undefined;
|
978 | that[SIZE] = 0;
|
979 | },
|
980 |
|
981 |
|
982 | 'delete': function (key) {
|
983 | var that = _validateCollection(this, NAME);
|
984 | var entry = getEntry(that, key);
|
985 | if (entry) {
|
986 | var next = entry.n;
|
987 | var prev = entry.p;
|
988 | delete that._i[entry.i];
|
989 | entry.r = true;
|
990 | if (prev) prev.n = next;
|
991 | if (next) next.p = prev;
|
992 | if (that._f == entry) that._f = next;
|
993 | if (that._l == entry) that._l = prev;
|
994 | that[SIZE]--;
|
995 | } return !!entry;
|
996 | },
|
997 |
|
998 |
|
999 | forEach: function forEach(callbackfn /* , that = undefined */) {
|
1000 | _validateCollection(this, NAME);
|
1001 | var f = _ctx(callbackfn, arguments.length > 1 ? arguments[1] : undefined, 3);
|
1002 | var entry;
|
1003 | while (entry = entry ? entry.n : this._f) {
|
1004 | f(entry.v, entry.k, this);
|
1005 |
|
1006 | while (entry && entry.r) entry = entry.p;
|
1007 | }
|
1008 | },
|
1009 |
|
1010 |
|
1011 | has: function has(key) {
|
1012 | return !!getEntry(_validateCollection(this, NAME), key);
|
1013 | }
|
1014 | });
|
1015 | if (_descriptors) dP$1(C.prototype, 'size', {
|
1016 | get: function () {
|
1017 | return _validateCollection(this, NAME)[SIZE];
|
1018 | }
|
1019 | });
|
1020 | return C;
|
1021 | },
|
1022 | def: function (that, key, value) {
|
1023 | var entry = getEntry(that, key);
|
1024 | var prev, index;
|
1025 |
|
1026 | if (entry) {
|
1027 | entry.v = value;
|
1028 |
|
1029 | } else {
|
1030 | that._l = entry = {
|
1031 | i: index = fastKey(key, true),
|
1032 | k: key,
|
1033 | v: value,
|
1034 | p: prev = that._l,
|
1035 | n: undefined,
|
1036 | r: false
|
1037 | };
|
1038 | if (!that._f) that._f = entry;
|
1039 | if (prev) prev.n = entry;
|
1040 | that[SIZE]++;
|
1041 |
|
1042 | if (index !== 'F') that._i[index] = entry;
|
1043 | } return that;
|
1044 | },
|
1045 | getEntry: getEntry,
|
1046 | setStrong: function (C, NAME, IS_MAP) {
|
1047 |
|
1048 |
|
1049 | _iterDefine(C, NAME, function (iterated, kind) {
|
1050 | this._t = _validateCollection(iterated, NAME);
|
1051 | this._k = kind;
|
1052 | this._l = undefined;
|
1053 | }, function () {
|
1054 | var that = this;
|
1055 | var kind = that._k;
|
1056 | var entry = that._l;
|
1057 |
|
1058 | while (entry && entry.r) entry = entry.p;
|
1059 |
|
1060 | if (!that._t || !(that._l = entry = entry ? entry.n : that._t._f)) {
|
1061 |
|
1062 | that._t = undefined;
|
1063 | return _iterStep(1);
|
1064 | }
|
1065 |
|
1066 | if (kind == 'keys') return _iterStep(0, entry.k);
|
1067 | if (kind == 'values') return _iterStep(0, entry.v);
|
1068 | return _iterStep(0, [entry.k, entry.v]);
|
1069 | }, IS_MAP ? 'entries' : 'values', !IS_MAP, true);
|
1070 |
|
1071 |
|
1072 | _setSpecies(NAME);
|
1073 | }
|
1074 | };
|
1075 |
|
1076 | var ITERATOR$3 = _wks('iterator');
|
1077 | var SAFE_CLOSING = false;
|
1078 |
|
1079 | try {
|
1080 | var riter = [7][ITERATOR$3]();
|
1081 | riter['return'] = function () { SAFE_CLOSING = true; };
|
1082 | } catch (e) { }
|
1083 |
|
1084 | var _iterDetect = function (exec, skipClosing) {
|
1085 | if (!skipClosing && !SAFE_CLOSING) return false;
|
1086 | var safe = false;
|
1087 | try {
|
1088 | var arr = [7];
|
1089 | var iter = arr[ITERATOR$3]();
|
1090 | iter.next = function () { return { done: safe = true }; };
|
1091 | arr[ITERATOR$3] = function () { return iter; };
|
1092 | exec(arr);
|
1093 | } catch (e) { }
|
1094 | return safe;
|
1095 | };
|
1096 |
|
1097 | var gOPD = Object.getOwnPropertyDescriptor;
|
1098 |
|
1099 | var f$3 = _descriptors ? gOPD : function getOwnPropertyDescriptor(O, P) {
|
1100 | O = _toIobject(O);
|
1101 | P = _toPrimitive(P, true);
|
1102 | if (_ie8DomDefine) try {
|
1103 | return gOPD(O, P);
|
1104 | } catch (e) { }
|
1105 | if (_has(O, P)) return _propertyDesc(!_objectPie.f.call(O, P), O[P]);
|
1106 | };
|
1107 |
|
1108 | var _objectGopd = {
|
1109 | f: f$3
|
1110 | };
|
1111 |
|
1112 |
|
1113 |
|
1114 |
|
1115 |
|
1116 | var check = function (O, proto) {
|
1117 | _anObject(O);
|
1118 | if (!_isObject(proto) && proto !== null) throw TypeError(proto + ": can't set as prototype!");
|
1119 | };
|
1120 | var _setProto = {
|
1121 | set: Object.setPrototypeOf || ('__proto__' in {} ?
|
1122 | function (test, buggy, set) {
|
1123 | try {
|
1124 | set = _ctx(Function.call, _objectGopd.f(Object.prototype, '__proto__').set, 2);
|
1125 | set(test, []);
|
1126 | buggy = !(test instanceof Array);
|
1127 | } catch (e) { buggy = true; }
|
1128 | return function setPrototypeOf(O, proto) {
|
1129 | check(O, proto);
|
1130 | if (buggy) O.__proto__ = proto;
|
1131 | else set(O, proto);
|
1132 | return O;
|
1133 | };
|
1134 | }({}, false) : undefined),
|
1135 | check: check
|
1136 | };
|
1137 |
|
1138 | var setPrototypeOf = _setProto.set;
|
1139 | var _inheritIfRequired = function (that, target, C) {
|
1140 | var S = target.constructor;
|
1141 | var P;
|
1142 | if (S !== C && typeof S == 'function' && (P = S.prototype) !== C.prototype && _isObject(P) && setPrototypeOf) {
|
1143 | setPrototypeOf(that, P);
|
1144 | } return that;
|
1145 | };
|
1146 |
|
1147 | var _collection = function (NAME, wrapper, methods, common, IS_MAP, IS_WEAK) {
|
1148 | var Base = _global[NAME];
|
1149 | var C = Base;
|
1150 | var ADDER = IS_MAP ? 'set' : 'add';
|
1151 | var proto = C && C.prototype;
|
1152 | var O = {};
|
1153 | var fixMethod = function (KEY) {
|
1154 | var fn = proto[KEY];
|
1155 | _redefine(proto, KEY,
|
1156 | KEY == 'delete' ? function (a) {
|
1157 | return IS_WEAK && !_isObject(a) ? false : fn.call(this, a === 0 ? 0 : a);
|
1158 | } : KEY == 'has' ? function has(a) {
|
1159 | return IS_WEAK && !_isObject(a) ? false : fn.call(this, a === 0 ? 0 : a);
|
1160 | } : KEY == 'get' ? function get(a) {
|
1161 | return IS_WEAK && !_isObject(a) ? undefined : fn.call(this, a === 0 ? 0 : a);
|
1162 | } : KEY == 'add' ? function add(a) { fn.call(this, a === 0 ? 0 : a); return this; }
|
1163 | : function set(a, b) { fn.call(this, a === 0 ? 0 : a, b); return this; }
|
1164 | );
|
1165 | };
|
1166 | if (typeof C != 'function' || !(IS_WEAK || proto.forEach && !_fails(function () {
|
1167 | new C().entries().next();
|
1168 | }))) {
|
1169 |
|
1170 | C = common.getConstructor(wrapper, NAME, IS_MAP, ADDER);
|
1171 | _redefineAll(C.prototype, methods);
|
1172 | _meta.NEED = true;
|
1173 | } else {
|
1174 | var instance = new C();
|
1175 |
|
1176 | var HASNT_CHAINING = instance[ADDER](IS_WEAK ? {} : -0, 1) != instance;
|
1177 |
|
1178 | var THROWS_ON_PRIMITIVES = _fails(function () { instance.has(1); });
|
1179 |
|
1180 | var ACCEPT_ITERABLES = _iterDetect(function (iter) { new C(iter); });
|
1181 |
|
1182 | var BUGGY_ZERO = !IS_WEAK && _fails(function () {
|
1183 |
|
1184 | var $instance = new C();
|
1185 | var index = 5;
|
1186 | while (index--) $instance[ADDER](index, index);
|
1187 | return !$instance.has(-0);
|
1188 | });
|
1189 | if (!ACCEPT_ITERABLES) {
|
1190 | C = wrapper(function (target, iterable) {
|
1191 | _anInstance(target, C, NAME);
|
1192 | var that = _inheritIfRequired(new Base(), target, C);
|
1193 | if (iterable != undefined) _forOf(iterable, IS_MAP, that[ADDER], that);
|
1194 | return that;
|
1195 | });
|
1196 | C.prototype = proto;
|
1197 | proto.constructor = C;
|
1198 | }
|
1199 | if (THROWS_ON_PRIMITIVES || BUGGY_ZERO) {
|
1200 | fixMethod('delete');
|
1201 | fixMethod('has');
|
1202 | IS_MAP && fixMethod('get');
|
1203 | }
|
1204 | if (BUGGY_ZERO || HASNT_CHAINING) fixMethod(ADDER);
|
1205 |
|
1206 | if (IS_WEAK && proto.clear) delete proto.clear;
|
1207 | }
|
1208 |
|
1209 | _setToStringTag(C, NAME);
|
1210 |
|
1211 | O[NAME] = C;
|
1212 | _export(_export.G + _export.W + _export.F * (C != Base), O);
|
1213 |
|
1214 | if (!IS_WEAK) common.setStrong(C, NAME, IS_MAP);
|
1215 |
|
1216 | return C;
|
1217 | };
|
1218 |
|
1219 | var SET = 'Set';
|
1220 |
|
1221 |
|
1222 | var es6_set = _collection(SET, function (get) {
|
1223 | return function Set() { return get(this, arguments.length > 0 ? arguments[0] : undefined); };
|
1224 | }, {
|
1225 |
|
1226 | add: function add(value) {
|
1227 | return _collectionStrong.def(_validateCollection(this, SET), value = value === 0 ? 0 : value, value);
|
1228 | }
|
1229 | }, _collectionStrong);
|
1230 |
|
1231 |
|
1232 |
|
1233 | var _isArray = Array.isArray || function isArray(arg) {
|
1234 | return _cof(arg) == 'Array';
|
1235 | };
|
1236 |
|
1237 | var SPECIES$1 = _wks('species');
|
1238 |
|
1239 | var _arraySpeciesConstructor = function (original) {
|
1240 | var C;
|
1241 | if (_isArray(original)) {
|
1242 | C = original.constructor;
|
1243 |
|
1244 | if (typeof C == 'function' && (C === Array || _isArray(C.prototype))) C = undefined;
|
1245 | if (_isObject(C)) {
|
1246 | C = C[SPECIES$1];
|
1247 | if (C === null) C = undefined;
|
1248 | }
|
1249 | } return C === undefined ? Array : C;
|
1250 | };
|
1251 |
|
1252 |
|
1253 |
|
1254 |
|
1255 | var _arraySpeciesCreate = function (original, length) {
|
1256 | return new (_arraySpeciesConstructor(original))(length);
|
1257 | };
|
1258 |
|
1259 |
|
1260 |
|
1261 |
|
1262 |
|
1263 |
|
1264 |
|
1265 |
|
1266 |
|
1267 |
|
1268 |
|
1269 |
|
1270 |
|
1271 | var _arrayMethods = function (TYPE, $create) {
|
1272 | var IS_MAP = TYPE == 1;
|
1273 | var IS_FILTER = TYPE == 2;
|
1274 | var IS_SOME = TYPE == 3;
|
1275 | var IS_EVERY = TYPE == 4;
|
1276 | var IS_FIND_INDEX = TYPE == 6;
|
1277 | var NO_HOLES = TYPE == 5 || IS_FIND_INDEX;
|
1278 | var create = $create || _arraySpeciesCreate;
|
1279 | return function ($this, callbackfn, that) {
|
1280 | var O = _toObject($this);
|
1281 | var self = _iobject(O);
|
1282 | var f = _ctx(callbackfn, that, 3);
|
1283 | var length = _toLength(self.length);
|
1284 | var index = 0;
|
1285 | var result = IS_MAP ? create($this, length) : IS_FILTER ? create($this, 0) : undefined;
|
1286 | var val, res;
|
1287 | for (;length > index; index++) if (NO_HOLES || index in self) {
|
1288 | val = self[index];
|
1289 | res = f(val, index, O);
|
1290 | if (TYPE) {
|
1291 | if (IS_MAP) result[index] = res;
|
1292 | else if (res) switch (TYPE) {
|
1293 | case 3: return true;
|
1294 | case 5: return val;
|
1295 | case 6: return index;
|
1296 | case 2: result.push(val);
|
1297 | } else if (IS_EVERY) return false;
|
1298 | }
|
1299 | }
|
1300 | return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : result;
|
1301 | };
|
1302 | };
|
1303 |
|
1304 |
|
1305 |
|
1306 | var $find = _arrayMethods(5);
|
1307 | var KEY = 'find';
|
1308 | var forced = true;
|
1309 |
|
1310 | if (KEY in []) Array(1)[KEY](function () { forced = false; });
|
1311 | _export(_export.P + _export.F * forced, 'Array', {
|
1312 | find: function find(callbackfn /* , that = undefined */) {
|
1313 | return $find(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
|
1314 | }
|
1315 | });
|
1316 | _addToUnscopables(KEY);
|
1317 |
|
1318 |
|
1319 |
|
1320 | var _flags = function () {
|
1321 | var that = _anObject(this);
|
1322 | var result = '';
|
1323 | if (that.global) result += 'g';
|
1324 | if (that.ignoreCase) result += 'i';
|
1325 | if (that.multiline) result += 'm';
|
1326 | if (that.unicode) result += 'u';
|
1327 | if (that.sticky) result += 'y';
|
1328 | return result;
|
1329 | };
|
1330 |
|
1331 |
|
1332 | if (_descriptors && /./g.flags != 'g') _objectDp.f(RegExp.prototype, 'flags', {
|
1333 | configurable: true,
|
1334 | get: _flags
|
1335 | });
|
1336 |
|
1337 | var TO_STRING = 'toString';
|
1338 | var $toString = /./[TO_STRING];
|
1339 |
|
1340 | var define = function (fn) {
|
1341 | _redefine(RegExp.prototype, TO_STRING, fn, true);
|
1342 | };
|
1343 |
|
1344 |
|
1345 | if (_fails(function () { return $toString.call({ source: 'a', flags: 'b' }) != '/a/b'; })) {
|
1346 | define(function toString() {
|
1347 | var R = _anObject(this);
|
1348 | return '/'.concat(R.source, '/',
|
1349 | 'flags' in R ? R.flags : !_descriptors && R instanceof RegExp ? _flags.call(R) : undefined);
|
1350 | });
|
1351 |
|
1352 | } else if ($toString.name != TO_STRING) {
|
1353 | define(function toString() {
|
1354 | return $toString.call(this);
|
1355 | });
|
1356 | }
|
1357 |
|
1358 |
|
1359 |
|
1360 |
|
1361 |
|
1362 | var _objectSap = function (KEY, exec) {
|
1363 | var fn = (_core.Object || {})[KEY] || Object[KEY];
|
1364 | var exp = {};
|
1365 | exp[KEY] = exec(fn);
|
1366 | _export(_export.S + _export.F * _fails(function () { fn(1); }), 'Object', exp);
|
1367 | };
|
1368 |
|
1369 |
|
1370 |
|
1371 |
|
1372 |
|
1373 | _objectSap('keys', function () {
|
1374 | return function keys(it) {
|
1375 | return _objectKeys(_toObject(it));
|
1376 | };
|
1377 | });
|
1378 |
|
1379 |
|
1380 |
|
1381 |
|
1382 | var SPECIES$2 = _wks('species');
|
1383 | var _speciesConstructor = function (O, D) {
|
1384 | var C = _anObject(O).constructor;
|
1385 | var S;
|
1386 | return C === undefined || (S = _anObject(C)[SPECIES$2]) == undefined ? D : _aFunction(S);
|
1387 | };
|
1388 |
|
1389 |
|
1390 | var _invoke = function (fn, args, that) {
|
1391 | var un = that === undefined;
|
1392 | switch (args.length) {
|
1393 | case 0: return un ? fn()
|
1394 | : fn.call(that);
|
1395 | case 1: return un ? fn(args[0])
|
1396 | : fn.call(that, args[0]);
|
1397 | case 2: return un ? fn(args[0], args[1])
|
1398 | : fn.call(that, args[0], args[1]);
|
1399 | case 3: return un ? fn(args[0], args[1], args[2])
|
1400 | : fn.call(that, args[0], args[1], args[2]);
|
1401 | case 4: return un ? fn(args[0], args[1], args[2], args[3])
|
1402 | : fn.call(that, args[0], args[1], args[2], args[3]);
|
1403 | } return fn.apply(that, args);
|
1404 | };
|
1405 |
|
1406 | var process = _global.process;
|
1407 | var setTask = _global.setImmediate;
|
1408 | var clearTask = _global.clearImmediate;
|
1409 | var MessageChannel = _global.MessageChannel;
|
1410 | var Dispatch = _global.Dispatch;
|
1411 | var counter = 0;
|
1412 | var queue = {};
|
1413 | var ONREADYSTATECHANGE = 'onreadystatechange';
|
1414 | var defer, channel, port;
|
1415 | var run = function () {
|
1416 | var id = +this;
|
1417 |
|
1418 | if (queue.hasOwnProperty(id)) {
|
1419 | var fn = queue[id];
|
1420 | delete queue[id];
|
1421 | fn();
|
1422 | }
|
1423 | };
|
1424 | var listener = function (event) {
|
1425 | run.call(event.data);
|
1426 | };
|
1427 |
|
1428 | if (!setTask || !clearTask) {
|
1429 | setTask = function setImmediate(fn) {
|
1430 | var args = [];
|
1431 | var i = 1;
|
1432 | while (arguments.length > i) args.push(arguments[i++]);
|
1433 | queue[++counter] = function () {
|
1434 |
|
1435 | _invoke(typeof fn == 'function' ? fn : Function(fn), args);
|
1436 | };
|
1437 | defer(counter);
|
1438 | return counter;
|
1439 | };
|
1440 | clearTask = function clearImmediate(id) {
|
1441 | delete queue[id];
|
1442 | };
|
1443 |
|
1444 | if (_cof(process) == 'process') {
|
1445 | defer = function (id) {
|
1446 | process.nextTick(_ctx(run, id, 1));
|
1447 | };
|
1448 |
|
1449 | } else if (Dispatch && Dispatch.now) {
|
1450 | defer = function (id) {
|
1451 | Dispatch.now(_ctx(run, id, 1));
|
1452 | };
|
1453 |
|
1454 | } else if (MessageChannel) {
|
1455 | channel = new MessageChannel();
|
1456 | port = channel.port2;
|
1457 | channel.port1.onmessage = listener;
|
1458 | defer = _ctx(port.postMessage, port, 1);
|
1459 |
|
1460 |
|
1461 | } else if (_global.addEventListener && typeof postMessage == 'function' && !_global.importScripts) {
|
1462 | defer = function (id) {
|
1463 | _global.postMessage(id + '', '*');
|
1464 | };
|
1465 | _global.addEventListener('message', listener, false);
|
1466 |
|
1467 | } else if (ONREADYSTATECHANGE in _domCreate('script')) {
|
1468 | defer = function (id) {
|
1469 | _html.appendChild(_domCreate('script'))[ONREADYSTATECHANGE] = function () {
|
1470 | _html.removeChild(this);
|
1471 | run.call(id);
|
1472 | };
|
1473 | };
|
1474 |
|
1475 | } else {
|
1476 | defer = function (id) {
|
1477 | setTimeout(_ctx(run, id, 1), 0);
|
1478 | };
|
1479 | }
|
1480 | }
|
1481 | var _task = {
|
1482 | set: setTask,
|
1483 | clear: clearTask
|
1484 | };
|
1485 |
|
1486 | var macrotask = _task.set;
|
1487 | var Observer = _global.MutationObserver || _global.WebKitMutationObserver;
|
1488 | var process$1 = _global.process;
|
1489 | var Promise$1 = _global.Promise;
|
1490 | var isNode = _cof(process$1) == 'process';
|
1491 |
|
1492 | var _microtask = function () {
|
1493 | var head, last, notify;
|
1494 |
|
1495 | var flush = function () {
|
1496 | var parent, fn;
|
1497 | if (isNode && (parent = process$1.domain)) parent.exit();
|
1498 | while (head) {
|
1499 | fn = head.fn;
|
1500 | head = head.next;
|
1501 | try {
|
1502 | fn();
|
1503 | } catch (e) {
|
1504 | if (head) notify();
|
1505 | else last = undefined;
|
1506 | throw e;
|
1507 | }
|
1508 | } last = undefined;
|
1509 | if (parent) parent.enter();
|
1510 | };
|
1511 |
|
1512 |
|
1513 | if (isNode) {
|
1514 | notify = function () {
|
1515 | process$1.nextTick(flush);
|
1516 | };
|
1517 |
|
1518 | } else if (Observer && !(_global.navigator && _global.navigator.standalone)) {
|
1519 | var toggle = true;
|
1520 | var node = document.createTextNode('');
|
1521 | new Observer(flush).observe(node, { characterData: true });
|
1522 | notify = function () {
|
1523 | node.data = toggle = !toggle;
|
1524 | };
|
1525 |
|
1526 | } else if (Promise$1 && Promise$1.resolve) {
|
1527 |
|
1528 | var promise = Promise$1.resolve(undefined);
|
1529 | notify = function () {
|
1530 | promise.then(flush);
|
1531 | };
|
1532 |
|
1533 |
|
1534 |
|
1535 |
|
1536 |
|
1537 |
|
1538 | } else {
|
1539 | notify = function () {
|
1540 |
|
1541 | macrotask.call(_global, flush);
|
1542 | };
|
1543 | }
|
1544 |
|
1545 | return function (fn) {
|
1546 | var task = { fn: fn, next: undefined };
|
1547 | if (last) last.next = task;
|
1548 | if (!head) {
|
1549 | head = task;
|
1550 | notify();
|
1551 | } last = task;
|
1552 | };
|
1553 | };
|
1554 |
|
1555 |
|
1556 |
|
1557 |
|
1558 | function PromiseCapability(C) {
|
1559 | var resolve, reject;
|
1560 | this.promise = new C(function ($$resolve, $$reject) {
|
1561 | if (resolve !== undefined || reject !== undefined) throw TypeError('Bad Promise constructor');
|
1562 | resolve = $$resolve;
|
1563 | reject = $$reject;
|
1564 | });
|
1565 | this.resolve = _aFunction(resolve);
|
1566 | this.reject = _aFunction(reject);
|
1567 | }
|
1568 |
|
1569 | var f$4 = function (C) {
|
1570 | return new PromiseCapability(C);
|
1571 | };
|
1572 |
|
1573 | var _newPromiseCapability = {
|
1574 | f: f$4
|
1575 | };
|
1576 |
|
1577 | var _perform = function (exec) {
|
1578 | try {
|
1579 | return { e: false, v: exec() };
|
1580 | } catch (e) {
|
1581 | return { e: true, v: e };
|
1582 | }
|
1583 | };
|
1584 |
|
1585 | var navigator = _global.navigator;
|
1586 |
|
1587 | var _userAgent = navigator && navigator.userAgent || '';
|
1588 |
|
1589 | var _promiseResolve = function (C, x) {
|
1590 | _anObject(C);
|
1591 | if (_isObject(x) && x.constructor === C) return x;
|
1592 | var promiseCapability = _newPromiseCapability.f(C);
|
1593 | var resolve = promiseCapability.resolve;
|
1594 | resolve(x);
|
1595 | return promiseCapability.promise;
|
1596 | };
|
1597 |
|
1598 | var task = _task.set;
|
1599 | var microtask = _microtask();
|
1600 |
|
1601 |
|
1602 |
|
1603 |
|
1604 | var PROMISE = 'Promise';
|
1605 | var TypeError$1 = _global.TypeError;
|
1606 | var process$2 = _global.process;
|
1607 | var versions = process$2 && process$2.versions;
|
1608 | var v8 = versions && versions.v8 || '';
|
1609 | var $Promise = _global[PROMISE];
|
1610 | var isNode$1 = _classof(process$2) == 'process';
|
1611 | var empty = function () { };
|
1612 | var Internal, newGenericPromiseCapability, OwnPromiseCapability, Wrapper;
|
1613 | var newPromiseCapability = newGenericPromiseCapability = _newPromiseCapability.f;
|
1614 |
|
1615 | var USE_NATIVE = !!function () {
|
1616 | try {
|
1617 |
|
1618 | var promise = $Promise.resolve(1);
|
1619 | var FakePromise = (promise.constructor = {})[_wks('species')] = function (exec) {
|
1620 | exec(empty, empty);
|
1621 | };
|
1622 |
|
1623 | return (isNode$1 || typeof PromiseRejectionEvent == 'function')
|
1624 | && promise.then(empty) instanceof FakePromise
|
1625 |
|
1626 |
|
1627 |
|
1628 | && v8.indexOf('6.6') !== 0
|
1629 | && _userAgent.indexOf('Chrome/66') === -1;
|
1630 | } catch (e) { }
|
1631 | }();
|
1632 |
|
1633 |
|
1634 | var isThenable = function (it) {
|
1635 | var then;
|
1636 | return _isObject(it) && typeof (then = it.then) == 'function' ? then : false;
|
1637 | };
|
1638 | var notify = function (promise, isReject) {
|
1639 | if (promise._n) return;
|
1640 | promise._n = true;
|
1641 | var chain = promise._c;
|
1642 | microtask(function () {
|
1643 | var value = promise._v;
|
1644 | var ok = promise._s == 1;
|
1645 | var i = 0;
|
1646 | var run = function (reaction) {
|
1647 | var handler = ok ? reaction.ok : reaction.fail;
|
1648 | var resolve = reaction.resolve;
|
1649 | var reject = reaction.reject;
|
1650 | var domain = reaction.domain;
|
1651 | var result, then, exited;
|
1652 | try {
|
1653 | if (handler) {
|
1654 | if (!ok) {
|
1655 | if (promise._h == 2) onHandleUnhandled(promise);
|
1656 | promise._h = 1;
|
1657 | }
|
1658 | if (handler === true) result = value;
|
1659 | else {
|
1660 | if (domain) domain.enter();
|
1661 | result = handler(value);
|
1662 | if (domain) {
|
1663 | domain.exit();
|
1664 | exited = true;
|
1665 | }
|
1666 | }
|
1667 | if (result === reaction.promise) {
|
1668 | reject(TypeError$1('Promise-chain cycle'));
|
1669 | } else if (then = isThenable(result)) {
|
1670 | then.call(result, resolve, reject);
|
1671 | } else resolve(result);
|
1672 | } else reject(value);
|
1673 | } catch (e) {
|
1674 | if (domain && !exited) domain.exit();
|
1675 | reject(e);
|
1676 | }
|
1677 | };
|
1678 | while (chain.length > i) run(chain[i++]);
|
1679 | promise._c = [];
|
1680 | promise._n = false;
|
1681 | if (isReject && !promise._h) onUnhandled(promise);
|
1682 | });
|
1683 | };
|
1684 | var onUnhandled = function (promise) {
|
1685 | task.call(_global, function () {
|
1686 | var value = promise._v;
|
1687 | var unhandled = isUnhandled(promise);
|
1688 | var result, handler, console;
|
1689 | if (unhandled) {
|
1690 | result = _perform(function () {
|
1691 | if (isNode$1) {
|
1692 | process$2.emit('unhandledRejection', value, promise);
|
1693 | } else if (handler = _global.onunhandledrejection) {
|
1694 | handler({ promise: promise, reason: value });
|
1695 | } else if ((console = _global.console) && console.error) {
|
1696 | console.error('Unhandled promise rejection', value);
|
1697 | }
|
1698 | });
|
1699 |
|
1700 | promise._h = isNode$1 || isUnhandled(promise) ? 2 : 1;
|
1701 | } promise._a = undefined;
|
1702 | if (unhandled && result.e) throw result.v;
|
1703 | });
|
1704 | };
|
1705 | var isUnhandled = function (promise) {
|
1706 | return promise._h !== 1 && (promise._a || promise._c).length === 0;
|
1707 | };
|
1708 | var onHandleUnhandled = function (promise) {
|
1709 | task.call(_global, function () {
|
1710 | var handler;
|
1711 | if (isNode$1) {
|
1712 | process$2.emit('rejectionHandled', promise);
|
1713 | } else if (handler = _global.onrejectionhandled) {
|
1714 | handler({ promise: promise, reason: promise._v });
|
1715 | }
|
1716 | });
|
1717 | };
|
1718 | var $reject = function (value) {
|
1719 | var promise = this;
|
1720 | if (promise._d) return;
|
1721 | promise._d = true;
|
1722 | promise = promise._w || promise;
|
1723 | promise._v = value;
|
1724 | promise._s = 2;
|
1725 | if (!promise._a) promise._a = promise._c.slice();
|
1726 | notify(promise, true);
|
1727 | };
|
1728 | var $resolve = function (value) {
|
1729 | var promise = this;
|
1730 | var then;
|
1731 | if (promise._d) return;
|
1732 | promise._d = true;
|
1733 | promise = promise._w || promise;
|
1734 | try {
|
1735 | if (promise === value) throw TypeError$1("Promise can't be resolved itself");
|
1736 | if (then = isThenable(value)) {
|
1737 | microtask(function () {
|
1738 | var wrapper = { _w: promise, _d: false };
|
1739 | try {
|
1740 | then.call(value, _ctx($resolve, wrapper, 1), _ctx($reject, wrapper, 1));
|
1741 | } catch (e) {
|
1742 | $reject.call(wrapper, e);
|
1743 | }
|
1744 | });
|
1745 | } else {
|
1746 | promise._v = value;
|
1747 | promise._s = 1;
|
1748 | notify(promise, false);
|
1749 | }
|
1750 | } catch (e) {
|
1751 | $reject.call({ _w: promise, _d: false }, e);
|
1752 | }
|
1753 | };
|
1754 |
|
1755 |
|
1756 | if (!USE_NATIVE) {
|
1757 |
|
1758 | $Promise = function Promise(executor) {
|
1759 | _anInstance(this, $Promise, PROMISE, '_h');
|
1760 | _aFunction(executor);
|
1761 | Internal.call(this);
|
1762 | try {
|
1763 | executor(_ctx($resolve, this, 1), _ctx($reject, this, 1));
|
1764 | } catch (err) {
|
1765 | $reject.call(this, err);
|
1766 | }
|
1767 | };
|
1768 |
|
1769 | Internal = function Promise(executor) {
|
1770 | this._c = [];
|
1771 | this._a = undefined;
|
1772 | this._s = 0;
|
1773 | this._d = false;
|
1774 | this._v = undefined;
|
1775 | this._h = 0;
|
1776 | this._n = false;
|
1777 | };
|
1778 | Internal.prototype = _redefineAll($Promise.prototype, {
|
1779 |
|
1780 | then: function then(onFulfilled, onRejected) {
|
1781 | var reaction = newPromiseCapability(_speciesConstructor(this, $Promise));
|
1782 | reaction.ok = typeof onFulfilled == 'function' ? onFulfilled : true;
|
1783 | reaction.fail = typeof onRejected == 'function' && onRejected;
|
1784 | reaction.domain = isNode$1 ? process$2.domain : undefined;
|
1785 | this._c.push(reaction);
|
1786 | if (this._a) this._a.push(reaction);
|
1787 | if (this._s) notify(this, false);
|
1788 | return reaction.promise;
|
1789 | },
|
1790 |
|
1791 | 'catch': function (onRejected) {
|
1792 | return this.then(undefined, onRejected);
|
1793 | }
|
1794 | });
|
1795 | OwnPromiseCapability = function () {
|
1796 | var promise = new Internal();
|
1797 | this.promise = promise;
|
1798 | this.resolve = _ctx($resolve, promise, 1);
|
1799 | this.reject = _ctx($reject, promise, 1);
|
1800 | };
|
1801 | _newPromiseCapability.f = newPromiseCapability = function (C) {
|
1802 | return C === $Promise || C === Wrapper
|
1803 | ? new OwnPromiseCapability(C)
|
1804 | : newGenericPromiseCapability(C);
|
1805 | };
|
1806 | }
|
1807 |
|
1808 | _export(_export.G + _export.W + _export.F * !USE_NATIVE, { Promise: $Promise });
|
1809 | _setToStringTag($Promise, PROMISE);
|
1810 | _setSpecies(PROMISE);
|
1811 | Wrapper = _core[PROMISE];
|
1812 |
|
1813 |
|
1814 | _export(_export.S + _export.F * !USE_NATIVE, PROMISE, {
|
1815 |
|
1816 | reject: function reject(r) {
|
1817 | var capability = newPromiseCapability(this);
|
1818 | var $$reject = capability.reject;
|
1819 | $$reject(r);
|
1820 | return capability.promise;
|
1821 | }
|
1822 | });
|
1823 | _export(_export.S + _export.F * (_library || !USE_NATIVE), PROMISE, {
|
1824 |
|
1825 | resolve: function resolve(x) {
|
1826 | return _promiseResolve(_library && this === Wrapper ? $Promise : this, x);
|
1827 | }
|
1828 | });
|
1829 | _export(_export.S + _export.F * !(USE_NATIVE && _iterDetect(function (iter) {
|
1830 | $Promise.all(iter)['catch'](empty);
|
1831 | })), PROMISE, {
|
1832 |
|
1833 | all: function all(iterable) {
|
1834 | var C = this;
|
1835 | var capability = newPromiseCapability(C);
|
1836 | var resolve = capability.resolve;
|
1837 | var reject = capability.reject;
|
1838 | var result = _perform(function () {
|
1839 | var values = [];
|
1840 | var index = 0;
|
1841 | var remaining = 1;
|
1842 | _forOf(iterable, false, function (promise) {
|
1843 | var $index = index++;
|
1844 | var alreadyCalled = false;
|
1845 | values.push(undefined);
|
1846 | remaining++;
|
1847 | C.resolve(promise).then(function (value) {
|
1848 | if (alreadyCalled) return;
|
1849 | alreadyCalled = true;
|
1850 | values[$index] = value;
|
1851 | --remaining || resolve(values);
|
1852 | }, reject);
|
1853 | });
|
1854 | --remaining || resolve(values);
|
1855 | });
|
1856 | if (result.e) reject(result.v);
|
1857 | return capability.promise;
|
1858 | },
|
1859 |
|
1860 | race: function race(iterable) {
|
1861 | var C = this;
|
1862 | var capability = newPromiseCapability(C);
|
1863 | var reject = capability.reject;
|
1864 | var result = _perform(function () {
|
1865 | _forOf(iterable, false, function (promise) {
|
1866 | C.resolve(promise).then(capability.resolve, reject);
|
1867 | });
|
1868 | });
|
1869 | if (result.e) reject(result.v);
|
1870 | return capability.promise;
|
1871 | }
|
1872 | });
|
1873 |
|
1874 |
|
1875 |
|
1876 |
|
1877 |
|
1878 | var es6_array_iterator = _iterDefine(Array, 'Array', function (iterated, kind) {
|
1879 | this._t = _toIobject(iterated);
|
1880 | this._i = 0;
|
1881 | this._k = kind;
|
1882 |
|
1883 | }, function () {
|
1884 | var O = this._t;
|
1885 | var kind = this._k;
|
1886 | var index = this._i++;
|
1887 | if (!O || index >= O.length) {
|
1888 | this._t = undefined;
|
1889 | return _iterStep(1);
|
1890 | }
|
1891 | if (kind == 'keys') return _iterStep(0, index);
|
1892 | if (kind == 'values') return _iterStep(0, O[index]);
|
1893 | return _iterStep(0, [index, O[index]]);
|
1894 | }, 'values');
|
1895 |
|
1896 |
|
1897 | _iterators.Arguments = _iterators.Array;
|
1898 |
|
1899 | _addToUnscopables('keys');
|
1900 | _addToUnscopables('values');
|
1901 | _addToUnscopables('entries');
|
1902 |
|
1903 |
|
1904 |
|
1905 | var _stringAt = function (TO_STRING) {
|
1906 | return function (that, pos) {
|
1907 | var s = String(_defined(that));
|
1908 | var i = _toInteger(pos);
|
1909 | var l = s.length;
|
1910 | var a, b;
|
1911 | if (i < 0 || i >= l) return TO_STRING ? '' : undefined;
|
1912 | a = s.charCodeAt(i);
|
1913 | return a < 0xd800 || a > 0xdbff || i + 1 === l || (b = s.charCodeAt(i + 1)) < 0xdc00 || b > 0xdfff
|
1914 | ? TO_STRING ? s.charAt(i) : a
|
1915 | : TO_STRING ? s.slice(i, i + 2) : (a - 0xd800 << 10) + (b - 0xdc00) + 0x10000;
|
1916 | };
|
1917 | };
|
1918 |
|
1919 | var $at = _stringAt(true);
|
1920 |
|
1921 |
|
1922 | _iterDefine(String, 'String', function (iterated) {
|
1923 | this._t = String(iterated);
|
1924 | this._i = 0;
|
1925 |
|
1926 | }, function () {
|
1927 | var O = this._t;
|
1928 | var index = this._i;
|
1929 | var point;
|
1930 | if (index >= O.length) return { value: undefined, done: true };
|
1931 | point = $at(O, index);
|
1932 | this._i += point.length;
|
1933 | return { value: point, done: false };
|
1934 | });
|
1935 |
|
1936 | var ITERATOR$4 = _wks('iterator');
|
1937 | var TO_STRING_TAG = _wks('toStringTag');
|
1938 | var ArrayValues = _iterators.Array;
|
1939 |
|
1940 | var DOMIterables = {
|
1941 | CSSRuleList: true,
|
1942 | CSSStyleDeclaration: false,
|
1943 | CSSValueList: false,
|
1944 | ClientRectList: false,
|
1945 | DOMRectList: false,
|
1946 | DOMStringList: false,
|
1947 | DOMTokenList: true,
|
1948 | DataTransferItemList: false,
|
1949 | FileList: false,
|
1950 | HTMLAllCollection: false,
|
1951 | HTMLCollection: false,
|
1952 | HTMLFormElement: false,
|
1953 | HTMLSelectElement: false,
|
1954 | MediaList: true,
|
1955 | MimeTypeArray: false,
|
1956 | NamedNodeMap: false,
|
1957 | NodeList: true,
|
1958 | PaintRequestList: false,
|
1959 | Plugin: false,
|
1960 | PluginArray: false,
|
1961 | SVGLengthList: false,
|
1962 | SVGNumberList: false,
|
1963 | SVGPathSegList: false,
|
1964 | SVGPointList: false,
|
1965 | SVGStringList: false,
|
1966 | SVGTransformList: false,
|
1967 | SourceBufferList: false,
|
1968 | StyleSheetList: true,
|
1969 | TextTrackCueList: false,
|
1970 | TextTrackList: false,
|
1971 | TouchList: false
|
1972 | };
|
1973 |
|
1974 | for (var collections = _objectKeys(DOMIterables), i = 0; i < collections.length; i++) {
|
1975 | var NAME = collections[i];
|
1976 | var explicit = DOMIterables[NAME];
|
1977 | var Collection = _global[NAME];
|
1978 | var proto = Collection && Collection.prototype;
|
1979 | var key;
|
1980 | if (proto) {
|
1981 | if (!proto[ITERATOR$4]) _hide(proto, ITERATOR$4, ArrayValues);
|
1982 | if (!proto[TO_STRING_TAG]) _hide(proto, TO_STRING_TAG, NAME);
|
1983 | _iterators[NAME] = ArrayValues;
|
1984 | if (explicit) for (key in es6_array_iterator) if (!proto[key]) _redefine(proto, key, es6_array_iterator[key], true);
|
1985 | }
|
1986 | }
|
1987 |
|
1988 | var runtime = createCommonjsModule(function (module) {
|
1989 |
|
1990 |
|
1991 |
|
1992 |
|
1993 |
|
1994 |
|
1995 |
|
1996 | !(function(global) {
|
1997 |
|
1998 | var Op = Object.prototype;
|
1999 | var hasOwn = Op.hasOwnProperty;
|
2000 | var undefined;
|
2001 | var $Symbol = typeof Symbol === "function" ? Symbol : {};
|
2002 | var iteratorSymbol = $Symbol.iterator || "@@iterator";
|
2003 | var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
|
2004 | var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
|
2005 | var runtime = global.regeneratorRuntime;
|
2006 | if (runtime) {
|
2007 | {
|
2008 |
|
2009 |
|
2010 | module.exports = runtime;
|
2011 | }
|
2012 |
|
2013 |
|
2014 | return;
|
2015 | }
|
2016 |
|
2017 |
|
2018 |
|
2019 | runtime = global.regeneratorRuntime = module.exports;
|
2020 |
|
2021 | function wrap(innerFn, outerFn, self, tryLocsList) {
|
2022 |
|
2023 | var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
|
2024 | var generator = Object.create(protoGenerator.prototype);
|
2025 | var context = new Context(tryLocsList || []);
|
2026 |
|
2027 |
|
2028 |
|
2029 | generator._invoke = makeInvokeMethod(innerFn, self, context);
|
2030 |
|
2031 | return generator;
|
2032 | }
|
2033 | runtime.wrap = wrap;
|
2034 |
|
2035 |
|
2036 |
|
2037 |
|
2038 |
|
2039 |
|
2040 |
|
2041 |
|
2042 |
|
2043 |
|
2044 |
|
2045 | function tryCatch(fn, obj, arg) {
|
2046 | try {
|
2047 | return { type: "normal", arg: fn.call(obj, arg) };
|
2048 | } catch (err) {
|
2049 | return { type: "throw", arg: err };
|
2050 | }
|
2051 | }
|
2052 |
|
2053 | var GenStateSuspendedStart = "suspendedStart";
|
2054 | var GenStateSuspendedYield = "suspendedYield";
|
2055 | var GenStateExecuting = "executing";
|
2056 | var GenStateCompleted = "completed";
|
2057 |
|
2058 |
|
2059 |
|
2060 | var ContinueSentinel = {};
|
2061 |
|
2062 |
|
2063 |
|
2064 |
|
2065 |
|
2066 | function Generator() {}
|
2067 | function GeneratorFunction() {}
|
2068 | function GeneratorFunctionPrototype() {}
|
2069 |
|
2070 |
|
2071 |
|
2072 | var IteratorPrototype = {};
|
2073 | IteratorPrototype[iteratorSymbol] = function () {
|
2074 | return this;
|
2075 | };
|
2076 |
|
2077 | var getProto = Object.getPrototypeOf;
|
2078 | var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
|
2079 | if (NativeIteratorPrototype &&
|
2080 | NativeIteratorPrototype !== Op &&
|
2081 | hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
|
2082 |
|
2083 |
|
2084 | IteratorPrototype = NativeIteratorPrototype;
|
2085 | }
|
2086 |
|
2087 | var Gp = GeneratorFunctionPrototype.prototype =
|
2088 | Generator.prototype = Object.create(IteratorPrototype);
|
2089 | GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
|
2090 | GeneratorFunctionPrototype.constructor = GeneratorFunction;
|
2091 | GeneratorFunctionPrototype[toStringTagSymbol] =
|
2092 | GeneratorFunction.displayName = "GeneratorFunction";
|
2093 |
|
2094 |
|
2095 |
|
2096 | function defineIteratorMethods(prototype) {
|
2097 | ["next", "throw", "return"].forEach(function(method) {
|
2098 | prototype[method] = function(arg) {
|
2099 | return this._invoke(method, arg);
|
2100 | };
|
2101 | });
|
2102 | }
|
2103 |
|
2104 | runtime.isGeneratorFunction = function(genFun) {
|
2105 | var ctor = typeof genFun === "function" && genFun.constructor;
|
2106 | return ctor
|
2107 | ? ctor === GeneratorFunction ||
|
2108 |
|
2109 |
|
2110 | (ctor.displayName || ctor.name) === "GeneratorFunction"
|
2111 | : false;
|
2112 | };
|
2113 |
|
2114 | runtime.mark = function(genFun) {
|
2115 | if (Object.setPrototypeOf) {
|
2116 | Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
|
2117 | } else {
|
2118 | genFun.__proto__ = GeneratorFunctionPrototype;
|
2119 | if (!(toStringTagSymbol in genFun)) {
|
2120 | genFun[toStringTagSymbol] = "GeneratorFunction";
|
2121 | }
|
2122 | }
|
2123 | genFun.prototype = Object.create(Gp);
|
2124 | return genFun;
|
2125 | };
|
2126 |
|
2127 |
|
2128 |
|
2129 |
|
2130 |
|
2131 | runtime.awrap = function(arg) {
|
2132 | return { __await: arg };
|
2133 | };
|
2134 |
|
2135 | function AsyncIterator(generator) {
|
2136 | function invoke(method, arg, resolve, reject) {
|
2137 | var record = tryCatch(generator[method], generator, arg);
|
2138 | if (record.type === "throw") {
|
2139 | reject(record.arg);
|
2140 | } else {
|
2141 | var result = record.arg;
|
2142 | var value = result.value;
|
2143 | if (value &&
|
2144 | typeof value === "object" &&
|
2145 | hasOwn.call(value, "__await")) {
|
2146 | return Promise.resolve(value.__await).then(function(value) {
|
2147 | invoke("next", value, resolve, reject);
|
2148 | }, function(err) {
|
2149 | invoke("throw", err, resolve, reject);
|
2150 | });
|
2151 | }
|
2152 |
|
2153 | return Promise.resolve(value).then(function(unwrapped) {
|
2154 |
|
2155 |
|
2156 |
|
2157 |
|
2158 |
|
2159 |
|
2160 |
|
2161 |
|
2162 |
|
2163 |
|
2164 |
|
2165 |
|
2166 |
|
2167 |
|
2168 |
|
2169 | result.value = unwrapped;
|
2170 | resolve(result);
|
2171 | }, reject);
|
2172 | }
|
2173 | }
|
2174 |
|
2175 | var previousPromise;
|
2176 |
|
2177 | function enqueue(method, arg) {
|
2178 | function callInvokeWithMethodAndArg() {
|
2179 | return new Promise(function(resolve, reject) {
|
2180 | invoke(method, arg, resolve, reject);
|
2181 | });
|
2182 | }
|
2183 |
|
2184 | return previousPromise =
|
2185 |
|
2186 |
|
2187 |
|
2188 |
|
2189 |
|
2190 |
|
2191 |
|
2192 |
|
2193 |
|
2194 |
|
2195 |
|
2196 |
|
2197 | previousPromise ? previousPromise.then(
|
2198 | callInvokeWithMethodAndArg,
|
2199 |
|
2200 |
|
2201 | callInvokeWithMethodAndArg
|
2202 | ) : callInvokeWithMethodAndArg();
|
2203 | }
|
2204 |
|
2205 |
|
2206 |
|
2207 | this._invoke = enqueue;
|
2208 | }
|
2209 |
|
2210 | defineIteratorMethods(AsyncIterator.prototype);
|
2211 | AsyncIterator.prototype[asyncIteratorSymbol] = function () {
|
2212 | return this;
|
2213 | };
|
2214 | runtime.AsyncIterator = AsyncIterator;
|
2215 |
|
2216 |
|
2217 |
|
2218 |
|
2219 | runtime.async = function(innerFn, outerFn, self, tryLocsList) {
|
2220 | var iter = new AsyncIterator(
|
2221 | wrap(innerFn, outerFn, self, tryLocsList)
|
2222 | );
|
2223 |
|
2224 | return runtime.isGeneratorFunction(outerFn)
|
2225 | ? iter
|
2226 | : iter.next().then(function(result) {
|
2227 | return result.done ? result.value : iter.next();
|
2228 | });
|
2229 | };
|
2230 |
|
2231 | function makeInvokeMethod(innerFn, self, context) {
|
2232 | var state = GenStateSuspendedStart;
|
2233 |
|
2234 | return function invoke(method, arg) {
|
2235 | if (state === GenStateExecuting) {
|
2236 | throw new Error("Generator is already running");
|
2237 | }
|
2238 |
|
2239 | if (state === GenStateCompleted) {
|
2240 | if (method === "throw") {
|
2241 | throw arg;
|
2242 | }
|
2243 |
|
2244 |
|
2245 |
|
2246 | return doneResult();
|
2247 | }
|
2248 |
|
2249 | context.method = method;
|
2250 | context.arg = arg;
|
2251 |
|
2252 | while (true) {
|
2253 | var delegate = context.delegate;
|
2254 | if (delegate) {
|
2255 | var delegateResult = maybeInvokeDelegate(delegate, context);
|
2256 | if (delegateResult) {
|
2257 | if (delegateResult === ContinueSentinel) continue;
|
2258 | return delegateResult;
|
2259 | }
|
2260 | }
|
2261 |
|
2262 | if (context.method === "next") {
|
2263 |
|
2264 |
|
2265 | context.sent = context._sent = context.arg;
|
2266 |
|
2267 | } else if (context.method === "throw") {
|
2268 | if (state === GenStateSuspendedStart) {
|
2269 | state = GenStateCompleted;
|
2270 | throw context.arg;
|
2271 | }
|
2272 |
|
2273 | context.dispatchException(context.arg);
|
2274 |
|
2275 | } else if (context.method === "return") {
|
2276 | context.abrupt("return", context.arg);
|
2277 | }
|
2278 |
|
2279 | state = GenStateExecuting;
|
2280 |
|
2281 | var record = tryCatch(innerFn, self, context);
|
2282 | if (record.type === "normal") {
|
2283 |
|
2284 |
|
2285 | state = context.done
|
2286 | ? GenStateCompleted
|
2287 | : GenStateSuspendedYield;
|
2288 |
|
2289 | if (record.arg === ContinueSentinel) {
|
2290 | continue;
|
2291 | }
|
2292 |
|
2293 | return {
|
2294 | value: record.arg,
|
2295 | done: context.done
|
2296 | };
|
2297 |
|
2298 | } else if (record.type === "throw") {
|
2299 | state = GenStateCompleted;
|
2300 |
|
2301 |
|
2302 | context.method = "throw";
|
2303 | context.arg = record.arg;
|
2304 | }
|
2305 | }
|
2306 | };
|
2307 | }
|
2308 |
|
2309 |
|
2310 |
|
2311 |
|
2312 |
|
2313 | function maybeInvokeDelegate(delegate, context) {
|
2314 | var method = delegate.iterator[context.method];
|
2315 | if (method === undefined) {
|
2316 |
|
2317 |
|
2318 | context.delegate = null;
|
2319 |
|
2320 | if (context.method === "throw") {
|
2321 | if (delegate.iterator.return) {
|
2322 |
|
2323 |
|
2324 | context.method = "return";
|
2325 | context.arg = undefined;
|
2326 | maybeInvokeDelegate(delegate, context);
|
2327 |
|
2328 | if (context.method === "throw") {
|
2329 |
|
2330 |
|
2331 | return ContinueSentinel;
|
2332 | }
|
2333 | }
|
2334 |
|
2335 | context.method = "throw";
|
2336 | context.arg = new TypeError(
|
2337 | "The iterator does not provide a 'throw' method");
|
2338 | }
|
2339 |
|
2340 | return ContinueSentinel;
|
2341 | }
|
2342 |
|
2343 | var record = tryCatch(method, delegate.iterator, context.arg);
|
2344 |
|
2345 | if (record.type === "throw") {
|
2346 | context.method = "throw";
|
2347 | context.arg = record.arg;
|
2348 | context.delegate = null;
|
2349 | return ContinueSentinel;
|
2350 | }
|
2351 |
|
2352 | var info = record.arg;
|
2353 |
|
2354 | if (! info) {
|
2355 | context.method = "throw";
|
2356 | context.arg = new TypeError("iterator result is not an object");
|
2357 | context.delegate = null;
|
2358 | return ContinueSentinel;
|
2359 | }
|
2360 |
|
2361 | if (info.done) {
|
2362 |
|
2363 |
|
2364 | context[delegate.resultName] = info.value;
|
2365 |
|
2366 |
|
2367 | context.next = delegate.nextLoc;
|
2368 |
|
2369 |
|
2370 |
|
2371 |
|
2372 |
|
2373 |
|
2374 |
|
2375 | if (context.method !== "return") {
|
2376 | context.method = "next";
|
2377 | context.arg = undefined;
|
2378 | }
|
2379 |
|
2380 | } else {
|
2381 |
|
2382 | return info;
|
2383 | }
|
2384 |
|
2385 |
|
2386 |
|
2387 | context.delegate = null;
|
2388 | return ContinueSentinel;
|
2389 | }
|
2390 |
|
2391 |
|
2392 |
|
2393 | defineIteratorMethods(Gp);
|
2394 |
|
2395 | Gp[toStringTagSymbol] = "Generator";
|
2396 |
|
2397 |
|
2398 |
|
2399 |
|
2400 |
|
2401 |
|
2402 | Gp[iteratorSymbol] = function() {
|
2403 | return this;
|
2404 | };
|
2405 |
|
2406 | Gp.toString = function() {
|
2407 | return "[object Generator]";
|
2408 | };
|
2409 |
|
2410 | function pushTryEntry(locs) {
|
2411 | var entry = { tryLoc: locs[0] };
|
2412 |
|
2413 | if (1 in locs) {
|
2414 | entry.catchLoc = locs[1];
|
2415 | }
|
2416 |
|
2417 | if (2 in locs) {
|
2418 | entry.finallyLoc = locs[2];
|
2419 | entry.afterLoc = locs[3];
|
2420 | }
|
2421 |
|
2422 | this.tryEntries.push(entry);
|
2423 | }
|
2424 |
|
2425 | function resetTryEntry(entry) {
|
2426 | var record = entry.completion || {};
|
2427 | record.type = "normal";
|
2428 | delete record.arg;
|
2429 | entry.completion = record;
|
2430 | }
|
2431 |
|
2432 | function Context(tryLocsList) {
|
2433 |
|
2434 |
|
2435 |
|
2436 | this.tryEntries = [{ tryLoc: "root" }];
|
2437 | tryLocsList.forEach(pushTryEntry, this);
|
2438 | this.reset(true);
|
2439 | }
|
2440 |
|
2441 | runtime.keys = function(object) {
|
2442 | var keys = [];
|
2443 | for (var key in object) {
|
2444 | keys.push(key);
|
2445 | }
|
2446 | keys.reverse();
|
2447 |
|
2448 |
|
2449 |
|
2450 | return function next() {
|
2451 | while (keys.length) {
|
2452 | var key = keys.pop();
|
2453 | if (key in object) {
|
2454 | next.value = key;
|
2455 | next.done = false;
|
2456 | return next;
|
2457 | }
|
2458 | }
|
2459 |
|
2460 |
|
2461 |
|
2462 |
|
2463 | next.done = true;
|
2464 | return next;
|
2465 | };
|
2466 | };
|
2467 |
|
2468 | function values(iterable) {
|
2469 | if (iterable) {
|
2470 | var iteratorMethod = iterable[iteratorSymbol];
|
2471 | if (iteratorMethod) {
|
2472 | return iteratorMethod.call(iterable);
|
2473 | }
|
2474 |
|
2475 | if (typeof iterable.next === "function") {
|
2476 | return iterable;
|
2477 | }
|
2478 |
|
2479 | if (!isNaN(iterable.length)) {
|
2480 | var i = -1, next = function next() {
|
2481 | while (++i < iterable.length) {
|
2482 | if (hasOwn.call(iterable, i)) {
|
2483 | next.value = iterable[i];
|
2484 | next.done = false;
|
2485 | return next;
|
2486 | }
|
2487 | }
|
2488 |
|
2489 | next.value = undefined;
|
2490 | next.done = true;
|
2491 |
|
2492 | return next;
|
2493 | };
|
2494 |
|
2495 | return next.next = next;
|
2496 | }
|
2497 | }
|
2498 |
|
2499 |
|
2500 | return { next: doneResult };
|
2501 | }
|
2502 | runtime.values = values;
|
2503 |
|
2504 | function doneResult() {
|
2505 | return { value: undefined, done: true };
|
2506 | }
|
2507 |
|
2508 | Context.prototype = {
|
2509 | constructor: Context,
|
2510 |
|
2511 | reset: function(skipTempReset) {
|
2512 | this.prev = 0;
|
2513 | this.next = 0;
|
2514 |
|
2515 |
|
2516 | this.sent = this._sent = undefined;
|
2517 | this.done = false;
|
2518 | this.delegate = null;
|
2519 |
|
2520 | this.method = "next";
|
2521 | this.arg = undefined;
|
2522 |
|
2523 | this.tryEntries.forEach(resetTryEntry);
|
2524 |
|
2525 | if (!skipTempReset) {
|
2526 | for (var name in this) {
|
2527 |
|
2528 | if (name.charAt(0) === "t" &&
|
2529 | hasOwn.call(this, name) &&
|
2530 | !isNaN(+name.slice(1))) {
|
2531 | this[name] = undefined;
|
2532 | }
|
2533 | }
|
2534 | }
|
2535 | },
|
2536 |
|
2537 | stop: function() {
|
2538 | this.done = true;
|
2539 |
|
2540 | var rootEntry = this.tryEntries[0];
|
2541 | var rootRecord = rootEntry.completion;
|
2542 | if (rootRecord.type === "throw") {
|
2543 | throw rootRecord.arg;
|
2544 | }
|
2545 |
|
2546 | return this.rval;
|
2547 | },
|
2548 |
|
2549 | dispatchException: function(exception) {
|
2550 | if (this.done) {
|
2551 | throw exception;
|
2552 | }
|
2553 |
|
2554 | var context = this;
|
2555 | function handle(loc, caught) {
|
2556 | record.type = "throw";
|
2557 | record.arg = exception;
|
2558 | context.next = loc;
|
2559 |
|
2560 | if (caught) {
|
2561 |
|
2562 |
|
2563 | context.method = "next";
|
2564 | context.arg = undefined;
|
2565 | }
|
2566 |
|
2567 | return !! caught;
|
2568 | }
|
2569 |
|
2570 | for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
2571 | var entry = this.tryEntries[i];
|
2572 | var record = entry.completion;
|
2573 |
|
2574 | if (entry.tryLoc === "root") {
|
2575 |
|
2576 |
|
2577 |
|
2578 | return handle("end");
|
2579 | }
|
2580 |
|
2581 | if (entry.tryLoc <= this.prev) {
|
2582 | var hasCatch = hasOwn.call(entry, "catchLoc");
|
2583 | var hasFinally = hasOwn.call(entry, "finallyLoc");
|
2584 |
|
2585 | if (hasCatch && hasFinally) {
|
2586 | if (this.prev < entry.catchLoc) {
|
2587 | return handle(entry.catchLoc, true);
|
2588 | } else if (this.prev < entry.finallyLoc) {
|
2589 | return handle(entry.finallyLoc);
|
2590 | }
|
2591 |
|
2592 | } else if (hasCatch) {
|
2593 | if (this.prev < entry.catchLoc) {
|
2594 | return handle(entry.catchLoc, true);
|
2595 | }
|
2596 |
|
2597 | } else if (hasFinally) {
|
2598 | if (this.prev < entry.finallyLoc) {
|
2599 | return handle(entry.finallyLoc);
|
2600 | }
|
2601 |
|
2602 | } else {
|
2603 | throw new Error("try statement without catch or finally");
|
2604 | }
|
2605 | }
|
2606 | }
|
2607 | },
|
2608 |
|
2609 | abrupt: function(type, arg) {
|
2610 | for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
2611 | var entry = this.tryEntries[i];
|
2612 | if (entry.tryLoc <= this.prev &&
|
2613 | hasOwn.call(entry, "finallyLoc") &&
|
2614 | this.prev < entry.finallyLoc) {
|
2615 | var finallyEntry = entry;
|
2616 | break;
|
2617 | }
|
2618 | }
|
2619 |
|
2620 | if (finallyEntry &&
|
2621 | (type === "break" ||
|
2622 | type === "continue") &&
|
2623 | finallyEntry.tryLoc <= arg &&
|
2624 | arg <= finallyEntry.finallyLoc) {
|
2625 |
|
2626 |
|
2627 | finallyEntry = null;
|
2628 | }
|
2629 |
|
2630 | var record = finallyEntry ? finallyEntry.completion : {};
|
2631 | record.type = type;
|
2632 | record.arg = arg;
|
2633 |
|
2634 | if (finallyEntry) {
|
2635 | this.method = "next";
|
2636 | this.next = finallyEntry.finallyLoc;
|
2637 | return ContinueSentinel;
|
2638 | }
|
2639 |
|
2640 | return this.complete(record);
|
2641 | },
|
2642 |
|
2643 | complete: function(record, afterLoc) {
|
2644 | if (record.type === "throw") {
|
2645 | throw record.arg;
|
2646 | }
|
2647 |
|
2648 | if (record.type === "break" ||
|
2649 | record.type === "continue") {
|
2650 | this.next = record.arg;
|
2651 | } else if (record.type === "return") {
|
2652 | this.rval = this.arg = record.arg;
|
2653 | this.method = "return";
|
2654 | this.next = "end";
|
2655 | } else if (record.type === "normal" && afterLoc) {
|
2656 | this.next = afterLoc;
|
2657 | }
|
2658 |
|
2659 | return ContinueSentinel;
|
2660 | },
|
2661 |
|
2662 | finish: function(finallyLoc) {
|
2663 | for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
2664 | var entry = this.tryEntries[i];
|
2665 | if (entry.finallyLoc === finallyLoc) {
|
2666 | this.complete(entry.completion, entry.afterLoc);
|
2667 | resetTryEntry(entry);
|
2668 | return ContinueSentinel;
|
2669 | }
|
2670 | }
|
2671 | },
|
2672 |
|
2673 | "catch": function(tryLoc) {
|
2674 | for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
2675 | var entry = this.tryEntries[i];
|
2676 | if (entry.tryLoc === tryLoc) {
|
2677 | var record = entry.completion;
|
2678 | if (record.type === "throw") {
|
2679 | var thrown = record.arg;
|
2680 | resetTryEntry(entry);
|
2681 | }
|
2682 | return thrown;
|
2683 | }
|
2684 | }
|
2685 |
|
2686 |
|
2687 |
|
2688 | throw new Error("illegal catch attempt");
|
2689 | },
|
2690 |
|
2691 | delegateYield: function(iterable, resultName, nextLoc) {
|
2692 | this.delegate = {
|
2693 | iterator: values(iterable),
|
2694 | resultName: resultName,
|
2695 | nextLoc: nextLoc
|
2696 | };
|
2697 |
|
2698 | if (this.method === "next") {
|
2699 |
|
2700 |
|
2701 | this.arg = undefined;
|
2702 | }
|
2703 |
|
2704 | return ContinueSentinel;
|
2705 | }
|
2706 | };
|
2707 | })(
|
2708 |
|
2709 |
|
2710 |
|
2711 | (function() { return this })() || Function("return this")()
|
2712 | );
|
2713 | });
|
2714 |
|
2715 |
|
2716 |
|
2717 |
|
2718 |
|
2719 | var Batch =
|
2720 |
|
2721 | function () {
|
2722 | |
2723 |
|
2724 |
|
2725 | function Batch(store) {
|
2726 | _classCallCheck(this, Batch);
|
2727 |
|
2728 | this.store = store;
|
2729 | this.queues = [];
|
2730 | }
|
2731 | |
2732 |
|
2733 |
|
2734 |
|
2735 |
|
2736 |
|
2737 |
|
2738 | _createClass(Batch, [{
|
2739 | key: "set",
|
2740 | value: function set(type, records) {
|
2741 | this.queues.push({
|
2742 | operation: 'set',
|
2743 | data: {
|
2744 | type: type,
|
2745 | records: records
|
2746 | }
|
2747 | });
|
2748 | }
|
2749 | |
2750 |
|
2751 |
|
2752 |
|
2753 |
|
2754 |
|
2755 |
|
2756 | }, {
|
2757 | key: "update",
|
2758 | value: function update(type, id, attribute) {
|
2759 | this.queues.push({
|
2760 | operation: 'update',
|
2761 | data: {
|
2762 | type: type,
|
2763 | id: id,
|
2764 | attribute: attribute
|
2765 | }
|
2766 | });
|
2767 | }
|
2768 | |
2769 |
|
2770 |
|
2771 |
|
2772 |
|
2773 |
|
2774 | }, {
|
2775 | key: "delete",
|
2776 | value: function _delete(type, id) {
|
2777 | this.queues.push({
|
2778 | operation: 'delete',
|
2779 | data: {
|
2780 | type: type,
|
2781 | id: id
|
2782 | }
|
2783 | });
|
2784 | }
|
2785 | |
2786 |
|
2787 |
|
2788 |
|
2789 |
|
2790 | }, {
|
2791 | key: "commit",
|
2792 | value: function commit(option) {
|
2793 | var _this = this;
|
2794 |
|
2795 | this.queues.forEach(function (_ref, index) {
|
2796 | var operation = _ref.operation,
|
2797 | data = _ref.data;
|
2798 | var finalOption = option;
|
2799 |
|
2800 | if (!finalOption) {
|
2801 | var isBackgroundOperation = index !== _this.queues.length - 1;
|
2802 | finalOption = {
|
2803 | isBackgroundOperation: isBackgroundOperation
|
2804 | };
|
2805 | }
|
2806 |
|
2807 | if (operation === 'set') {
|
2808 | _this.store.set(data.type, data.records, finalOption);
|
2809 | } else if (operation === 'update') {
|
2810 | _this.store.update(data.type, data.id, data.attribute, finalOption);
|
2811 | } else if (operation === 'delete') {
|
2812 | _this.store.delete(data.type, data.id, finalOption);
|
2813 | }
|
2814 | });
|
2815 | this.queues = [];
|
2816 | }
|
2817 | }]);
|
2818 |
|
2819 | return Batch;
|
2820 | }();
|
2821 |
|
2822 |
|
2823 |
|
2824 |
|
2825 |
|
2826 |
|
2827 |
|
2828 |
|
2829 | function getCardinality(model, type, attribute) {
|
2830 | var meta = model[type].relationship[attribute];
|
2831 |
|
2832 | if (meta.kind === 'belongsTo') {
|
2833 | if (meta.inverse) {
|
2834 | var inverseMeta = model[meta.type].relationship[meta.inverse];
|
2835 |
|
2836 | if (inverseMeta.kind === 'belongsTo') {
|
2837 | return 'oneToOne';
|
2838 | }
|
2839 |
|
2840 | return 'oneToMany';
|
2841 | }
|
2842 |
|
2843 | return 'oneToNone';
|
2844 | }
|
2845 |
|
2846 | if (meta.inverse) {
|
2847 | var _inverseMeta = model[meta.type].relationship[meta.inverse];
|
2848 |
|
2849 | if (_inverseMeta.kind === 'belongsTo') {
|
2850 | return 'oneToMany';
|
2851 | }
|
2852 |
|
2853 | return 'manyToMany';
|
2854 | }
|
2855 |
|
2856 | return 'manyToNone';
|
2857 | }
|
2858 |
|
2859 |
|
2860 |
|
2861 |
|
2862 |
|
2863 | function getDefaultRecord(model) {
|
2864 | var defaultRecord = {};
|
2865 | model.attributes.forEach(function (attribute) {
|
2866 | defaultRecord[attribute] = null;
|
2867 | });
|
2868 | Object.keys(model.relationship).forEach(function (relationshipKey) {
|
2869 | if (model.relationship[relationshipKey].kind === 'belongsTo') {
|
2870 | defaultRecord[relationshipKey] = null;
|
2871 | } else {
|
2872 | defaultRecord[relationshipKey] = [];
|
2873 | }
|
2874 | });
|
2875 | return defaultRecord;
|
2876 | }
|
2877 |
|
2878 |
|
2879 |
|
2880 |
|
2881 |
|
2882 |
|
2883 | function normalizeBelongsTo(record) {
|
2884 | if (typeof record === 'string' || record === null) {
|
2885 | return record;
|
2886 | }
|
2887 |
|
2888 | if (_typeof(record) === 'object') {
|
2889 | return record.id;
|
2890 | }
|
2891 |
|
2892 | return null;
|
2893 | }
|
2894 |
|
2895 |
|
2896 |
|
2897 |
|
2898 |
|
2899 |
|
2900 |
|
2901 | function normalizeHasMany(records) {
|
2902 | if (Array.isArray(records)) {
|
2903 | return records.map(function (record) {
|
2904 | if (typeof record === 'string') {
|
2905 | return record;
|
2906 | }
|
2907 |
|
2908 | return record.id;
|
2909 | });
|
2910 | }
|
2911 |
|
2912 | return [];
|
2913 | }
|
2914 |
|
2915 |
|
2916 |
|
2917 |
|
2918 |
|
2919 |
|
2920 |
|
2921 | function normalize(model, record) {
|
2922 | var normalizedRecord = {
|
2923 | id: record.id
|
2924 | };
|
2925 | model.attributes.forEach(function (attribute) {
|
2926 | normalizedRecord[attribute] = Object.prototype.hasOwnProperty.call(record, attribute) ? record[attribute] : null;
|
2927 | });
|
2928 | Object.keys(model.relationship).forEach(function (relationshipKey) {
|
2929 | if (model.relationship[relationshipKey].kind === 'belongsTo') {
|
2930 | normalizedRecord[relationshipKey] = normalizeBelongsTo(record[relationshipKey]);
|
2931 | } else {
|
2932 | normalizedRecord[relationshipKey] = normalizeHasMany(record[relationshipKey]);
|
2933 | }
|
2934 | });
|
2935 | return normalizedRecord;
|
2936 | }
|
2937 |
|
2938 |
|
2939 |
|
2940 |
|
2941 |
|
2942 |
|
2943 | var Store =
|
2944 |
|
2945 | function () {
|
2946 | |
2947 |
|
2948 |
|
2949 |
|
2950 |
|
2951 | |
2952 |
|
2953 |
|
2954 |
|
2955 | function Store(model) {
|
2956 | _classCallCheck(this, Store);
|
2957 |
|
2958 | this.model = model;
|
2959 | this.state = this.buildInitialState();
|
2960 | this.subscription = {};
|
2961 | }
|
2962 | |
2963 |
|
2964 |
|
2965 |
|
2966 |
|
2967 |
|
2968 |
|
2969 |
|
2970 | _createClass(Store, [{
|
2971 | key: "set",
|
2972 | value: function set(type, record) {
|
2973 | var option = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
2974 |
|
2975 | if (record.id) {
|
2976 | var modelForType = this.model[type];
|
2977 | var deserializedRecord = option.isDeserialized ? record : modelForType.deserialize(record);
|
2978 |
|
2979 | if (deserializedRecord) {
|
2980 | var normalizedRecord = normalize(modelForType, deserializedRecord);
|
2981 | this.state[type].data[normalizedRecord.id] = normalizedRecord;
|
2982 | this.syncAddedRelationships(type, deserializedRecord);
|
2983 |
|
2984 | if (!option.isBackgroundOperation) {
|
2985 | this.triggerSubscriptions();
|
2986 | }
|
2987 | }
|
2988 | } else {
|
2989 | throw new Error('Record to set has no ID');
|
2990 | }
|
2991 | }
|
2992 | |
2993 |
|
2994 |
|
2995 |
|
2996 |
|
2997 |
|
2998 |
|
2999 |
|
3000 | }, {
|
3001 | key: "update",
|
3002 | value: function update(type, id, attribute) {
|
3003 | var option = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
3004 | var cachedRecord = this.getStateForRecord(type, id);
|
3005 |
|
3006 | if (cachedRecord) {
|
3007 | var modelForType = this.model[type];
|
3008 | var updatedRecord = modelForType.deserialize(Object.assign({}, cachedRecord, attribute, {
|
3009 | id: id
|
3010 | }));
|
3011 | this.set(type, updatedRecord, {
|
3012 | isBackgroundOperation: true,
|
3013 | isDeserialized: true
|
3014 | });
|
3015 | this.syncRemovedRelationships(type, updatedRecord, cachedRecord);
|
3016 |
|
3017 | if (!option.isBackgroundOperation) {
|
3018 | this.triggerSubscriptions();
|
3019 | }
|
3020 | } else {
|
3021 | throw new Error('Record doesn\'t exist');
|
3022 | }
|
3023 | }
|
3024 | |
3025 |
|
3026 |
|
3027 |
|
3028 |
|
3029 |
|
3030 |
|
3031 | }, {
|
3032 | key: "delete",
|
3033 | value: function _delete(type, id) {
|
3034 | var option = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
3035 | var cachedRecord = this.getStateForRecord(type, id);
|
3036 |
|
3037 | if (cachedRecord) {
|
3038 | var modelForType = this.model[type];
|
3039 | var defaultRecord = getDefaultRecord(modelForType, type);
|
3040 | this.update(type, id, defaultRecord, {
|
3041 | isBackgroundOperation: true
|
3042 | });
|
3043 | delete this.state[type].data[id];
|
3044 |
|
3045 | if (!option.isBackgroundOperation) {
|
3046 | this.triggerSubscriptions();
|
3047 | }
|
3048 | } else {
|
3049 | throw new Error('Record doesn\'t exist');
|
3050 | }
|
3051 | }
|
3052 | |
3053 |
|
3054 |
|
3055 |
|
3056 |
|
3057 |
|
3058 |
|
3059 |
|
3060 | }, {
|
3061 | key: "get",
|
3062 | value: function () {
|
3063 | var _get$$1 = _asyncToGenerator(
|
3064 |
|
3065 | regeneratorRuntime.mark(function _callee(type, id) {
|
3066 | var option,
|
3067 | record,
|
3068 | recordState,
|
3069 | _args = arguments;
|
3070 | return regeneratorRuntime.wrap(function _callee$(_context) {
|
3071 | while (1) {
|
3072 | switch (_context.prev = _context.next) {
|
3073 | case 0:
|
3074 | option = _args.length > 2 && _args[2] !== undefined ? _args[2] : {};
|
3075 |
|
3076 | if (!(!this.isRecordAttributePopulated(type, id) && option.fetch)) {
|
3077 | _context.next = 8;
|
3078 | break;
|
3079 | }
|
3080 |
|
3081 | _context.next = 4;
|
3082 | return option.fetch();
|
3083 |
|
3084 | case 4:
|
3085 | record = _context.sent;
|
3086 |
|
3087 | if (record) {
|
3088 | _context.next = 7;
|
3089 | break;
|
3090 | }
|
3091 |
|
3092 | return _context.abrupt("return", null);
|
3093 |
|
3094 | case 7:
|
3095 | this.set(type, record, {
|
3096 | isBackgroundOperation: true
|
3097 | });
|
3098 |
|
3099 | case 8:
|
3100 | recordState = this.getStateForRecord(type, id);
|
3101 |
|
3102 | if (!(recordState && option.include)) {
|
3103 | _context.next = 12;
|
3104 | break;
|
3105 | }
|
3106 |
|
3107 | _context.next = 12;
|
3108 | return this.includeRelationships(type, recordState, option);
|
3109 |
|
3110 | case 12:
|
3111 | return _context.abrupt("return", this.getCachedRecord(type, id));
|
3112 |
|
3113 | case 13:
|
3114 | case "end":
|
3115 | return _context.stop();
|
3116 | }
|
3117 | }
|
3118 | }, _callee, this);
|
3119 | }));
|
3120 |
|
3121 | return function get(_x, _x2) {
|
3122 | return _get$$1.apply(this, arguments);
|
3123 | };
|
3124 | }()
|
3125 | |
3126 |
|
3127 |
|
3128 |
|
3129 |
|
3130 |
|
3131 |
|
3132 | }, {
|
3133 | key: "getAll",
|
3134 | value: function () {
|
3135 | var _getAll = _asyncToGenerator(
|
3136 |
|
3137 | regeneratorRuntime.mark(function _callee2(type) {
|
3138 | var _this = this;
|
3139 |
|
3140 | var option,
|
3141 | records,
|
3142 | _args2 = arguments;
|
3143 | return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
3144 | while (1) {
|
3145 | switch (_context2.prev = _context2.next) {
|
3146 | case 0:
|
3147 | option = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : {};
|
3148 |
|
3149 | if (!(option.fetch && !this.state[type].isDataComplete)) {
|
3150 | _context2.next = 10;
|
3151 | break;
|
3152 | }
|
3153 |
|
3154 | _context2.next = 4;
|
3155 | return option.fetch();
|
3156 |
|
3157 | case 4:
|
3158 | _context2.t0 = _context2.sent;
|
3159 |
|
3160 | if (_context2.t0) {
|
3161 | _context2.next = 7;
|
3162 | break;
|
3163 | }
|
3164 |
|
3165 | _context2.t0 = [];
|
3166 |
|
3167 | case 7:
|
3168 | records = _context2.t0;
|
3169 | records.forEach(function (record) {
|
3170 | return _this.set(type, record, {
|
3171 | isBackgroundOperation: true
|
3172 | });
|
3173 | });
|
3174 | this.state[type].isDataComplete = true;
|
3175 |
|
3176 | case 10:
|
3177 | return _context2.abrupt("return", Promise.all(Object.keys(this.state[type].data).map(function (id) {
|
3178 | return _this.get(type, id, {
|
3179 | include: option.include
|
3180 | });
|
3181 | })));
|
3182 |
|
3183 | case 11:
|
3184 | case "end":
|
3185 | return _context2.stop();
|
3186 | }
|
3187 | }
|
3188 | }, _callee2, this);
|
3189 | }));
|
3190 |
|
3191 | return function getAll(_x3) {
|
3192 | return _getAll.apply(this, arguments);
|
3193 | };
|
3194 | }()
|
3195 | |
3196 |
|
3197 |
|
3198 |
|
3199 |
|
3200 |
|
3201 |
|
3202 | }, {
|
3203 | key: "query",
|
3204 | value: function () {
|
3205 | var _query = _asyncToGenerator(
|
3206 |
|
3207 | regeneratorRuntime.mark(function _callee3(type) {
|
3208 | var _this2 = this;
|
3209 |
|
3210 | var option,
|
3211 | records,
|
3212 | _args3 = arguments;
|
3213 | return regeneratorRuntime.wrap(function _callee3$(_context3) {
|
3214 | while (1) {
|
3215 | switch (_context3.prev = _context3.next) {
|
3216 | case 0:
|
3217 | option = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : {};
|
3218 | _context3.next = 3;
|
3219 | return option.fetch();
|
3220 |
|
3221 | case 3:
|
3222 | _context3.t0 = _context3.sent;
|
3223 |
|
3224 | if (_context3.t0) {
|
3225 | _context3.next = 6;
|
3226 | break;
|
3227 | }
|
3228 |
|
3229 | _context3.t0 = [];
|
3230 |
|
3231 | case 6:
|
3232 | records = _context3.t0;
|
3233 | records.forEach(function (record) {
|
3234 | return _this2.set(type, record, {
|
3235 | isBackgroundOperation: true
|
3236 | });
|
3237 | });
|
3238 | return _context3.abrupt("return", Promise.all(records.map(function (record) {
|
3239 | return _this2.get(type, record.id, {
|
3240 | include: option.include
|
3241 | });
|
3242 | })));
|
3243 |
|
3244 | case 9:
|
3245 | case "end":
|
3246 | return _context3.stop();
|
3247 | }
|
3248 | }
|
3249 | }, _callee3, this);
|
3250 | }));
|
3251 |
|
3252 | return function query(_x4) {
|
3253 | return _query.apply(this, arguments);
|
3254 | };
|
3255 | }()
|
3256 | |
3257 |
|
3258 |
|
3259 |
|
3260 | |
3261 |
|
3262 |
|
3263 |
|
3264 |
|
3265 |
|
3266 |
|
3267 | }, {
|
3268 | key: "subscribe",
|
3269 | value: function subscribe(callback) {
|
3270 | var _this3 = this;
|
3271 |
|
3272 | var id = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Math.random().toString(32).slice(2).substr(0, 5);
|
3273 | this.subscription[id] = callback;
|
3274 | return function () {
|
3275 | return delete _this3.subscription[id];
|
3276 | };
|
3277 | }
|
3278 | |
3279 |
|
3280 |
|
3281 |
|
3282 |
|
3283 | }, {
|
3284 | key: "batch",
|
3285 | value: function batch() {
|
3286 | return new Batch(this);
|
3287 | }
|
3288 | |
3289 |
|
3290 |
|
3291 |
|
3292 |
|
3293 |
|
3294 | }, {
|
3295 | key: "buildInitialState",
|
3296 | value: function buildInitialState() {
|
3297 | var model = this.model;
|
3298 | var state = {};
|
3299 | Object.keys(model).forEach(function (modelKey) {
|
3300 | state[modelKey] = {
|
3301 | isDataComplete: false,
|
3302 | data: {}
|
3303 | };
|
3304 | });
|
3305 | return state;
|
3306 | }
|
3307 | |
3308 |
|
3309 |
|
3310 |
|
3311 |
|
3312 |
|
3313 |
|
3314 |
|
3315 |
|
3316 | }, {
|
3317 | key: "getCachedRecord",
|
3318 | value: function getCachedRecord(type, id) {
|
3319 | var _this4 = this;
|
3320 |
|
3321 | var nestLevel = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
3322 |
|
3323 | if (this.state[type].data[id]) {
|
3324 | var cachedRecord = Object.assign({}, this.state[type].data[id]);
|
3325 | var modelForType = this.model[type];
|
3326 | Object.keys(modelForType.relationship).forEach(function (relationshipKey) {
|
3327 | var descriptor = modelForType.relationship[relationshipKey];
|
3328 |
|
3329 | if (descriptor.kind === 'belongsTo' && cachedRecord[relationshipKey]) {
|
3330 | var belongsToId = cachedRecord[relationshipKey];
|
3331 |
|
3332 | if (nestLevel < 1) {
|
3333 | cachedRecord[relationshipKey] = _this4.getCachedRecord(descriptor.type, belongsToId, nestLevel + 1);
|
3334 | } else {
|
3335 | cachedRecord[relationshipKey] = Object.assign({}, _this4.state[descriptor.type].data[belongsToId]);
|
3336 | }
|
3337 | } else if (descriptor.kind === 'hasMany' && cachedRecord[relationshipKey].length > 0) {
|
3338 | cachedRecord[relationshipKey] = cachedRecord[relationshipKey].map(function (hasManyId) {
|
3339 | if (nestLevel < 1) {
|
3340 | return _this4.getCachedRecord(descriptor.type, hasManyId, nestLevel + 1);
|
3341 | }
|
3342 |
|
3343 | return Object.assign({}, _this4.state[descriptor.type].data[hasManyId]);
|
3344 | });
|
3345 | }
|
3346 | });
|
3347 | return cachedRecord;
|
3348 | }
|
3349 |
|
3350 | return null;
|
3351 | }
|
3352 | |
3353 |
|
3354 |
|
3355 |
|
3356 |
|
3357 |
|
3358 |
|
3359 |
|
3360 | }, {
|
3361 | key: "getStateForRecord",
|
3362 | value: function getStateForRecord(type, id) {
|
3363 | return this.state[type].data[id] || null;
|
3364 | }
|
3365 | |
3366 |
|
3367 |
|
3368 |
|
3369 |
|
3370 |
|
3371 |
|
3372 |
|
3373 | }, {
|
3374 | key: "isRecordAttributePopulated",
|
3375 | value: function isRecordAttributePopulated(type, id) {
|
3376 | var currentRecordState = this.getStateForRecord(type, id);
|
3377 |
|
3378 | if (currentRecordState) {
|
3379 | var attributes = this.model[type].attributes;
|
3380 | var populatedAttribute = attributes.find(function (key) {
|
3381 | if (currentRecordState[key] === null || Array.isArray(currentRecordState[key]) && currentRecordState[key].length === 0) {
|
3382 | return false;
|
3383 | }
|
3384 |
|
3385 | return true;
|
3386 | });
|
3387 | return populatedAttribute;
|
3388 | }
|
3389 |
|
3390 | return false;
|
3391 | }
|
3392 | |
3393 |
|
3394 |
|
3395 |
|
3396 |
|
3397 |
|
3398 |
|
3399 |
|
3400 |
|
3401 |
|
3402 | }, {
|
3403 | key: "includeRelationship",
|
3404 | value: function () {
|
3405 | var _includeRelationship = _asyncToGenerator(
|
3406 |
|
3407 | regeneratorRuntime.mark(function _callee4(type, record, option, key, descriptor) {
|
3408 | var _this5 = this;
|
3409 |
|
3410 | var includedData, _includedData, includedDataIds, uniqueHasManyIds;
|
3411 |
|
3412 | return regeneratorRuntime.wrap(function _callee4$(_context4) {
|
3413 | while (1) {
|
3414 | switch (_context4.prev = _context4.next) {
|
3415 | case 0:
|
3416 | if (!(descriptor.kind === 'belongsTo')) {
|
3417 | _context4.next = 9;
|
3418 | break;
|
3419 | }
|
3420 |
|
3421 | if (!(record[key] === null || !this.isRecordAttributePopulated(descriptor.type, record[key]))) {
|
3422 | _context4.next = 7;
|
3423 | break;
|
3424 | }
|
3425 |
|
3426 | _context4.next = 4;
|
3427 | return option.include[key](record);
|
3428 |
|
3429 | case 4:
|
3430 | includedData = _context4.sent;
|
3431 | this.set(descriptor.type, includedData, {
|
3432 | isBackgroundOperation: true
|
3433 | });
|
3434 | this.update(type, record.id, _defineProperty({}, key, includedData.id), {
|
3435 | isBackgroundOperation: true
|
3436 | });
|
3437 |
|
3438 | case 7:
|
3439 | _context4.next = 17;
|
3440 | break;
|
3441 |
|
3442 | case 9:
|
3443 | if (!(descriptor.kind === 'hasMany')) {
|
3444 | _context4.next = 17;
|
3445 | break;
|
3446 | }
|
3447 |
|
3448 | _context4.next = 12;
|
3449 | return option.include[key](record);
|
3450 |
|
3451 | case 12:
|
3452 | _includedData = _context4.sent;
|
3453 |
|
3454 | _includedData.forEach(function (data) {
|
3455 | return _this5.set(descriptor.type, data, {
|
3456 | isBackgroundOperation: true
|
3457 | });
|
3458 | });
|
3459 |
|
3460 | includedDataIds = _includedData.map(function (data) {
|
3461 | return data.id;
|
3462 | });
|
3463 | uniqueHasManyIds = _toConsumableArray(new Set(_toConsumableArray(record[key]).concat(_toConsumableArray(includedDataIds))));
|
3464 | this.update(type, record.id, _defineProperty({}, key, uniqueHasManyIds), {
|
3465 | isBackgroundOperation: true
|
3466 | });
|
3467 |
|
3468 | case 17:
|
3469 | case "end":
|
3470 | return _context4.stop();
|
3471 | }
|
3472 | }
|
3473 | }, _callee4, this);
|
3474 | }));
|
3475 |
|
3476 | return function includeRelationship(_x5, _x6, _x7, _x8, _x9) {
|
3477 | return _includeRelationship.apply(this, arguments);
|
3478 | };
|
3479 | }()
|
3480 | |
3481 |
|
3482 |
|
3483 |
|
3484 |
|
3485 |
|
3486 |
|
3487 |
|
3488 | }, {
|
3489 | key: "includeRelationships",
|
3490 | value: function () {
|
3491 | var _includeRelationships = _asyncToGenerator(
|
3492 |
|
3493 | regeneratorRuntime.mark(function _callee5(type, record, option) {
|
3494 | var _this6 = this;
|
3495 |
|
3496 | var relationship, includes;
|
3497 | return regeneratorRuntime.wrap(function _callee5$(_context5) {
|
3498 | while (1) {
|
3499 | switch (_context5.prev = _context5.next) {
|
3500 | case 0:
|
3501 | relationship = this.model[type].relationship;
|
3502 | includes = [];
|
3503 | Object.keys(relationship).forEach(function (key) {
|
3504 | if (option.include[key]) {
|
3505 | includes.push(_this6.includeRelationship(type, record, option, key, relationship[key]));
|
3506 | }
|
3507 | });
|
3508 | _context5.next = 5;
|
3509 | return Promise.all(includes);
|
3510 |
|
3511 | case 5:
|
3512 | case "end":
|
3513 | return _context5.stop();
|
3514 | }
|
3515 | }
|
3516 | }, _callee5, this);
|
3517 | }));
|
3518 |
|
3519 | return function includeRelationships(_x10, _x11, _x12) {
|
3520 | return _includeRelationships.apply(this, arguments);
|
3521 | };
|
3522 | }()
|
3523 | |
3524 |
|
3525 |
|
3526 |
|
3527 |
|
3528 |
|
3529 |
|
3530 |
|
3531 | }, {
|
3532 | key: "syncAddedBelongsTo",
|
3533 | value: function syncAddedBelongsTo(type, record, belongsToAttribute) {
|
3534 | var cardinality = getCardinality(this.model, type, belongsToAttribute);
|
3535 | var descriptor = this.model[type].relationship[belongsToAttribute];
|
3536 | var recordToSync;
|
3537 |
|
3538 | if (_typeof(record[belongsToAttribute]) === 'object' && record[belongsToAttribute] !== null) {
|
3539 | recordToSync = this.model[descriptor.type].deserialize(record[belongsToAttribute]);
|
3540 | } else {
|
3541 | recordToSync = {
|
3542 | id: record[belongsToAttribute]
|
3543 | };
|
3544 | }
|
3545 |
|
3546 | if (cardinality === 'oneToOne') {
|
3547 | var cachedRecord = this.getStateForRecord(descriptor.type, recordToSync.id);
|
3548 |
|
3549 | if (!cachedRecord || !cachedRecord[descriptor.inverse]) {
|
3550 | var newRecord = Object.assign(recordToSync, _defineProperty({}, descriptor.inverse, record.id));
|
3551 | this.set(descriptor.type, newRecord, {
|
3552 | isBackgroundOperation: true
|
3553 | });
|
3554 | }
|
3555 | } else if (cardinality === 'oneToMany') {
|
3556 | var _cachedRecord = this.getStateForRecord(descriptor.type, recordToSync.id);
|
3557 |
|
3558 | if (!_cachedRecord) {
|
3559 | var _newRecord = Object.assign(recordToSync, _defineProperty({}, descriptor.inverse, [record.id]));
|
3560 |
|
3561 | this.set(descriptor.type, _newRecord, {
|
3562 | isBackgroundOperation: true
|
3563 | });
|
3564 | } else if (!_cachedRecord[descriptor.inverse].find(function (id) {
|
3565 | return id === record.id;
|
3566 | })) {
|
3567 | _cachedRecord[descriptor.inverse].push(record.id);
|
3568 | }
|
3569 | } else {
|
3570 | var _cachedRecord2 = this.getStateForRecord(descriptor.type, recordToSync.id) || {};
|
3571 |
|
3572 | var _newRecord2 = Object.assign(_cachedRecord2, recordToSync);
|
3573 |
|
3574 | this.set(descriptor.type, _newRecord2, {
|
3575 | isBackgroundOperation: true
|
3576 | });
|
3577 | }
|
3578 | }
|
3579 | |
3580 |
|
3581 |
|
3582 |
|
3583 |
|
3584 |
|
3585 |
|
3586 |
|
3587 | }, {
|
3588 | key: "syncAddedHasMany",
|
3589 | value: function syncAddedHasMany(type, record, hasManyAttribute) {
|
3590 | var _this7 = this;
|
3591 |
|
3592 | var recordsToSync = record[hasManyAttribute];
|
3593 |
|
3594 | if (Array.isArray(recordsToSync)) {
|
3595 | recordsToSync.forEach(function (item) {
|
3596 | var cardinality = getCardinality(_this7.model, type, hasManyAttribute);
|
3597 | var descriptor = _this7.model[type].relationship[hasManyAttribute];
|
3598 | var recordToSync;
|
3599 |
|
3600 | if (_typeof(item) === 'object' && item !== null) {
|
3601 | recordToSync = _this7.model[descriptor.type].deserialize(item);
|
3602 | } else {
|
3603 | recordToSync = {
|
3604 | id: item
|
3605 | };
|
3606 | }
|
3607 |
|
3608 | if (cardinality === 'oneToMany') {
|
3609 | var cachedRecord = _this7.getStateForRecord(descriptor.type, recordToSync.id);
|
3610 |
|
3611 | if (!cachedRecord) {
|
3612 | var newRecord = Object.assign(recordToSync, _defineProperty({}, descriptor.inverse, record.id));
|
3613 |
|
3614 | _this7.set(descriptor.type, newRecord, {
|
3615 | isBackgroundOperation: true
|
3616 | });
|
3617 | } else {
|
3618 | cachedRecord[descriptor.inverse] = record.id;
|
3619 | }
|
3620 | } else if (cardinality === 'manyToMany') {
|
3621 | var _cachedRecord3 = _this7.getStateForRecord(descriptor.type, recordToSync.id);
|
3622 |
|
3623 | if (!_cachedRecord3) {
|
3624 | var _newRecord3 = Object.assign(recordToSync, _defineProperty({}, descriptor.inverse, [record.id]));
|
3625 |
|
3626 | _this7.set(descriptor.type, _newRecord3, {
|
3627 | isBackgroundOperation: true
|
3628 | });
|
3629 | } else if (!_cachedRecord3[descriptor.inverse].find(function (id) {
|
3630 | return id === record.id;
|
3631 | })) {
|
3632 | _cachedRecord3[descriptor.inverse].push(record.id);
|
3633 | }
|
3634 | } else {
|
3635 | var _cachedRecord4 = _this7.getStateForRecord(descriptor.type, recordToSync.id) || {};
|
3636 |
|
3637 | var _newRecord4 = Object.assign(_cachedRecord4, recordToSync);
|
3638 |
|
3639 | _this7.set(descriptor.type, _newRecord4, {
|
3640 | isBackgroundOperation: true
|
3641 | });
|
3642 | }
|
3643 | });
|
3644 | }
|
3645 | }
|
3646 | |
3647 |
|
3648 |
|
3649 |
|
3650 |
|
3651 |
|
3652 |
|
3653 |
|
3654 | }, {
|
3655 | key: "syncExistingHasMany",
|
3656 | value: function syncExistingHasMany(type, record, hasManyAttribute) {
|
3657 | var cardinality = getCardinality(this.model, type, hasManyAttribute);
|
3658 | var descriptor = this.model[type].relationship[hasManyAttribute];
|
3659 | var inverseData = this.state[descriptor.type].data;
|
3660 | var recordId = _typeof(record) === 'object' && record !== null ? record.id : record;
|
3661 |
|
3662 | if (cardinality === 'oneToMany') {
|
3663 | var currentHasManyState = this.state[type].data[recordId][hasManyAttribute];
|
3664 | var inverseIds = Object.keys(this.state[descriptor.type].data).filter(function (id) {
|
3665 | return inverseData[id][descriptor.inverse] === recordId;
|
3666 | });
|
3667 | inverseIds.forEach(function (id) {
|
3668 | if (!currentHasManyState.includes(id)) {
|
3669 | currentHasManyState.push(id);
|
3670 | }
|
3671 | });
|
3672 | } else if (cardinality === 'manyToMany') {
|
3673 | var _currentHasManyState = this.state[type].data[recordId][hasManyAttribute];
|
3674 |
|
3675 | var _inverseIds = Object.keys(this.state[descriptor.type].data).filter(function (id) {
|
3676 | return inverseData[id][descriptor.inverse].includes(recordId);
|
3677 | });
|
3678 |
|
3679 | _inverseIds.forEach(function (id) {
|
3680 | if (!_currentHasManyState.includes(id)) {
|
3681 | _currentHasManyState.push(id);
|
3682 | }
|
3683 | });
|
3684 | }
|
3685 | }
|
3686 | |
3687 |
|
3688 |
|
3689 |
|
3690 |
|
3691 |
|
3692 |
|
3693 | }, {
|
3694 | key: "syncAddedRelationships",
|
3695 | value: function syncAddedRelationships(type, record) {
|
3696 | var _this8 = this;
|
3697 |
|
3698 | Object.keys(this.model[type].relationship).forEach(function (relationshipKey) {
|
3699 | var kind = _this8.model[type].relationship[relationshipKey].kind;
|
3700 |
|
3701 | if (record[relationshipKey]) {
|
3702 | if (kind === 'belongsTo') {
|
3703 | _this8.syncAddedBelongsTo(type, record, relationshipKey);
|
3704 | } else {
|
3705 | _this8.syncAddedHasMany(type, record, relationshipKey);
|
3706 | }
|
3707 | } else if (kind === 'hasMany') {
|
3708 | _this8.syncExistingHasMany(type, record, relationshipKey);
|
3709 | }
|
3710 | });
|
3711 | }
|
3712 | |
3713 |
|
3714 |
|
3715 |
|
3716 |
|
3717 |
|
3718 |
|
3719 |
|
3720 |
|
3721 |
|
3722 | }, {
|
3723 | key: "syncRemovedBelongsToRelationship",
|
3724 | value: function syncRemovedBelongsToRelationship(type, currentRecord, oldRecord, key, descriptor) {
|
3725 | if (currentRecord[key] === null && currentRecord[key] !== oldRecord[key]) {
|
3726 | var inverseRecord = this.getStateForRecord(descriptor.type, oldRecord[key]);
|
3727 |
|
3728 | if (inverseRecord) {
|
3729 | var cardinality = getCardinality(this.model, type, key);
|
3730 |
|
3731 | if (cardinality === 'oneToOne') {
|
3732 | inverseRecord[descriptor.inverse] = null;
|
3733 | } else if (cardinality === 'oneToMany') {
|
3734 | inverseRecord[descriptor.inverse] = inverseRecord[descriptor.inverse].filter(function (id) {
|
3735 | return id !== oldRecord.id;
|
3736 | });
|
3737 | }
|
3738 | }
|
3739 | }
|
3740 | }
|
3741 | |
3742 |
|
3743 |
|
3744 |
|
3745 |
|
3746 |
|
3747 |
|
3748 |
|
3749 |
|
3750 |
|
3751 | }, {
|
3752 | key: "syncRemovedHasManyRelationship",
|
3753 | value: function syncRemovedHasManyRelationship(type, currentRecord, oldRecord, key, descriptor) {
|
3754 | var _this9 = this;
|
3755 |
|
3756 | var removedRecords = oldRecord[key].filter(function (record) {
|
3757 | return !currentRecord[key].includes(record);
|
3758 | });
|
3759 | removedRecords.forEach(function (removedRecord) {
|
3760 | var inverseRecord = _this9.getStateForRecord(descriptor.type, removedRecord);
|
3761 |
|
3762 | if (inverseRecord) {
|
3763 | var cardinality = getCardinality(_this9.model, type, key);
|
3764 |
|
3765 | if (cardinality === 'oneToMany') {
|
3766 | inverseRecord[descriptor.inverse] = null;
|
3767 | } else if (cardinality === 'manyToMany') {
|
3768 | inverseRecord[descriptor.inverse] = inverseRecord[descriptor.inverse].filter(function (id) {
|
3769 | return id !== oldRecord.id;
|
3770 | });
|
3771 | }
|
3772 | }
|
3773 | });
|
3774 | }
|
3775 | |
3776 |
|
3777 |
|
3778 |
|
3779 |
|
3780 |
|
3781 |
|
3782 |
|
3783 | }, {
|
3784 | key: "syncRemovedRelationships",
|
3785 | value: function syncRemovedRelationships(type, currentRecord, oldRecord) {
|
3786 | var _this10 = this;
|
3787 |
|
3788 | var model = this.model[type];
|
3789 | Object.keys(model.relationship).forEach(function (attributeKey) {
|
3790 | var descriptor = model.relationship[attributeKey];
|
3791 |
|
3792 | if (descriptor.kind === 'belongsTo') {
|
3793 | _this10.syncRemovedBelongsToRelationship(type, currentRecord, oldRecord, attributeKey, descriptor);
|
3794 | } else if (descriptor.kind === 'hasMany') {
|
3795 | _this10.syncRemovedHasManyRelationship(type, currentRecord, oldRecord, attributeKey, descriptor);
|
3796 | }
|
3797 | });
|
3798 | }
|
3799 | |
3800 |
|
3801 |
|
3802 |
|
3803 |
|
3804 | }, {
|
3805 | key: "triggerSubscriptions",
|
3806 | value: function triggerSubscriptions() {
|
3807 | var _this11 = this;
|
3808 |
|
3809 | Object.keys(this.subscription).forEach(function (key) {
|
3810 | try {
|
3811 | _this11.subscription[key]();
|
3812 | } catch (error) {
|
3813 | delete _this11.subscription[key];
|
3814 | }
|
3815 | });
|
3816 | }
|
3817 | }]);
|
3818 |
|
3819 | return Store;
|
3820 | }();
|
3821 |
|
3822 | exports.Model = Model;
|
3823 | exports.Store = Store;
|