1 | (function (global, factory) {
|
2 | typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@tarojs/taro')) :
|
3 | typeof define === 'function' && define.amd ? define(['exports', '@tarojs/taro'], factory) :
|
4 | (factory((global.TaroTt = {}),global.taro));
|
5 | }(this, (function (exports,taro) { 'use strict';
|
6 |
|
7 | function _typeof(obj) {
|
8 | "@babel/helpers - typeof";
|
9 |
|
10 | if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
|
11 | _typeof = function (obj) {
|
12 | return typeof obj;
|
13 | };
|
14 | } else {
|
15 | _typeof = function (obj) {
|
16 | return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
17 | };
|
18 | }
|
19 |
|
20 | return _typeof(obj);
|
21 | }
|
22 |
|
23 | function _classCallCheck(instance, Constructor) {
|
24 | if (!(instance instanceof Constructor)) {
|
25 | throw new TypeError("Cannot call a class as a function");
|
26 | }
|
27 | }
|
28 |
|
29 | function _defineProperties(target, props) {
|
30 | for (var i = 0; i < props.length; i++) {
|
31 | var descriptor = props[i];
|
32 | descriptor.enumerable = descriptor.enumerable || false;
|
33 | descriptor.configurable = true;
|
34 | if ("value" in descriptor) descriptor.writable = true;
|
35 | Object.defineProperty(target, descriptor.key, descriptor);
|
36 | }
|
37 | }
|
38 |
|
39 | function _createClass(Constructor, protoProps, staticProps) {
|
40 | if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
41 | if (staticProps) _defineProperties(Constructor, staticProps);
|
42 | return Constructor;
|
43 | }
|
44 |
|
45 | function _defineProperty(obj, key, value) {
|
46 | if (key in obj) {
|
47 | Object.defineProperty(obj, key, {
|
48 | value: value,
|
49 | enumerable: true,
|
50 | configurable: true,
|
51 | writable: true
|
52 | });
|
53 | } else {
|
54 | obj[key] = value;
|
55 | }
|
56 |
|
57 | return obj;
|
58 | }
|
59 |
|
60 | function _inherits(subClass, superClass) {
|
61 | if (typeof superClass !== "function" && superClass !== null) {
|
62 | throw new TypeError("Super expression must either be null or a function");
|
63 | }
|
64 |
|
65 | subClass.prototype = Object.create(superClass && superClass.prototype, {
|
66 | constructor: {
|
67 | value: subClass,
|
68 | writable: true,
|
69 | configurable: true
|
70 | }
|
71 | });
|
72 | if (superClass) _setPrototypeOf(subClass, superClass);
|
73 | }
|
74 |
|
75 | function _getPrototypeOf(o) {
|
76 | _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
77 | return o.__proto__ || Object.getPrototypeOf(o);
|
78 | };
|
79 | return _getPrototypeOf(o);
|
80 | }
|
81 |
|
82 | function _setPrototypeOf(o, p) {
|
83 | _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
84 | o.__proto__ = p;
|
85 | return o;
|
86 | };
|
87 |
|
88 | return _setPrototypeOf(o, p);
|
89 | }
|
90 |
|
91 | function _isNativeReflectConstruct() {
|
92 | if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
93 | if (Reflect.construct.sham) return false;
|
94 | if (typeof Proxy === "function") return true;
|
95 |
|
96 | try {
|
97 | Date.prototype.toString.call(Reflect.construct(Date, [], function () {}));
|
98 | return true;
|
99 | } catch (e) {
|
100 | return false;
|
101 | }
|
102 | }
|
103 |
|
104 | function _assertThisInitialized(self) {
|
105 | if (self === void 0) {
|
106 | throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
107 | }
|
108 |
|
109 | return self;
|
110 | }
|
111 |
|
112 | function _possibleConstructorReturn(self, call) {
|
113 | if (call && (typeof call === "object" || typeof call === "function")) {
|
114 | return call;
|
115 | }
|
116 |
|
117 | return _assertThisInitialized(self);
|
118 | }
|
119 |
|
120 | function _createSuper(Derived) {
|
121 | var hasNativeReflectConstruct = _isNativeReflectConstruct();
|
122 |
|
123 | return function _createSuperInternal() {
|
124 | var Super = _getPrototypeOf(Derived),
|
125 | result;
|
126 |
|
127 | if (hasNativeReflectConstruct) {
|
128 | var NewTarget = _getPrototypeOf(this).constructor;
|
129 |
|
130 | result = Reflect.construct(Super, arguments, NewTarget);
|
131 | } else {
|
132 | result = Super.apply(this, arguments);
|
133 | }
|
134 |
|
135 | return _possibleConstructorReturn(this, result);
|
136 | };
|
137 | }
|
138 |
|
139 | function _toConsumableArray(arr) {
|
140 | return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
|
141 | }
|
142 |
|
143 | function _arrayWithoutHoles(arr) {
|
144 | if (Array.isArray(arr)) return _arrayLikeToArray(arr);
|
145 | }
|
146 |
|
147 | function _iterableToArray(iter) {
|
148 | if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter);
|
149 | }
|
150 |
|
151 | function _unsupportedIterableToArray(o, minLen) {
|
152 | if (!o) return;
|
153 | if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
154 | var n = Object.prototype.toString.call(o).slice(8, -1);
|
155 | if (n === "Object" && o.constructor) n = o.constructor.name;
|
156 | if (n === "Map" || n === "Set") return Array.from(o);
|
157 | if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
158 | }
|
159 |
|
160 | function _arrayLikeToArray(arr, len) {
|
161 | if (len == null || len > arr.length) len = arr.length;
|
162 |
|
163 | for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
164 |
|
165 | return arr2;
|
166 | }
|
167 |
|
168 | function _nonIterableSpread() {
|
169 | throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
170 | }
|
171 |
|
172 |
|
173 | var objectIs = Object.is || function (x, y) {
|
174 | if (x === y) {
|
175 | return x !== 0 || 1 / x === 1 / y;
|
176 | }
|
177 |
|
178 | return x !== x && y !== y;
|
179 | };
|
180 |
|
181 | function shallowEqual(obj1, obj2) {
|
182 | if (_typeof(obj1) !== 'object' && _typeof(obj2) !== 'object') {
|
183 | return obj1 === obj2;
|
184 | }
|
185 |
|
186 | if (obj1 === null && obj2 === null) {
|
187 | return true;
|
188 | }
|
189 |
|
190 | if (obj1 === null || obj2 === null) {
|
191 | return false;
|
192 | }
|
193 |
|
194 | if (objectIs(obj1, obj2)) {
|
195 | return true;
|
196 | }
|
197 |
|
198 | var obj1Keys = obj1 ? Object.keys(obj1) : [];
|
199 | var obj2Keys = obj2 ? Object.keys(obj2) : [];
|
200 |
|
201 | if (obj1Keys.length !== obj2Keys.length) {
|
202 | return false;
|
203 | }
|
204 |
|
205 | for (var i = 0; i < obj1Keys.length; i++) {
|
206 | var obj1KeyItem = obj1Keys[i];
|
207 |
|
208 | if (!obj2.hasOwnProperty(obj1KeyItem) || !objectIs(obj1[obj1KeyItem], obj2[obj1KeyItem])) {
|
209 | return false;
|
210 | }
|
211 | }
|
212 |
|
213 | return true;
|
214 | }
|
215 |
|
216 | var SimpleMap = function () {
|
217 | function SimpleMap() {
|
218 | _classCallCheck(this, SimpleMap);
|
219 |
|
220 | this.cache = [];
|
221 | this.size = 0;
|
222 | }
|
223 |
|
224 | _createClass(SimpleMap, [{
|
225 | key: "set",
|
226 | value: function set(k, v) {
|
227 | var len = this.cache.length;
|
228 |
|
229 | if (!len) {
|
230 | this.cache.push({
|
231 | k: k,
|
232 | v: v
|
233 | });
|
234 | this.size += 1;
|
235 | return;
|
236 | }
|
237 |
|
238 | for (var i = 0; i < len; i++) {
|
239 | var item = this.cache[i];
|
240 |
|
241 | if (item.k === k) {
|
242 | item.v = v;
|
243 | return;
|
244 | }
|
245 | }
|
246 |
|
247 | this.cache.push({
|
248 | k: k,
|
249 | v: v
|
250 | });
|
251 | this.size += 1;
|
252 | }
|
253 | }, {
|
254 | key: "get",
|
255 | value: function get(k) {
|
256 | var len = this.cache.length;
|
257 |
|
258 | if (!len) {
|
259 | return;
|
260 | }
|
261 |
|
262 | for (var i = 0; i < len; i++) {
|
263 | var item = this.cache[i];
|
264 |
|
265 | if (item.k === k) {
|
266 | return item.v;
|
267 | }
|
268 | }
|
269 | }
|
270 | }, {
|
271 | key: "has",
|
272 | value: function has(k) {
|
273 | var len = this.cache.length;
|
274 |
|
275 | if (!len) {
|
276 | return false;
|
277 | }
|
278 |
|
279 | for (var i = 0; i < len; i++) {
|
280 | var item = this.cache[i];
|
281 |
|
282 | if (item.k === k) {
|
283 | return true;
|
284 | }
|
285 | }
|
286 |
|
287 | return false;
|
288 | }
|
289 | }, {
|
290 | key: "delete",
|
291 | value: function _delete(k) {
|
292 | var len = this.cache.length;
|
293 |
|
294 | for (var i = 0; i < len; i++) {
|
295 | var item = this.cache[i];
|
296 |
|
297 | if (item.k === k) {
|
298 | this.cache.splice(i, 1);
|
299 | this.size -= 1;
|
300 | return true;
|
301 | }
|
302 | }
|
303 |
|
304 | return false;
|
305 | }
|
306 | }, {
|
307 | key: "clear",
|
308 | value: function clear() {
|
309 | var len = this.cache.length;
|
310 | this.size = 0;
|
311 |
|
312 | if (!len) {
|
313 | return;
|
314 | }
|
315 |
|
316 | while (len) {
|
317 | this.cache.pop();
|
318 | len--;
|
319 | }
|
320 | }
|
321 | }]);
|
322 |
|
323 | return SimpleMap;
|
324 | }();
|
325 |
|
326 | function addLeadingSlash(path) {
|
327 | return path.charAt(0) === '/' ? path : '/' + path;
|
328 | }
|
329 |
|
330 | function getCurrentPageUrl() {
|
331 | var pages = getCurrentPages();
|
332 | var currentPage = pages[pages.length - 1];
|
333 | return addLeadingSlash(currentPage.route || currentPage.__route__);
|
334 | }
|
335 |
|
336 | var nextTick = function nextTick(fn) {
|
337 | var _fn;
|
338 |
|
339 | for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
340 | args[_key - 1] = arguments[_key];
|
341 | }
|
342 |
|
343 | fn = typeof fn === 'function' ? (_fn = fn).bind.apply(_fn, [null].concat(args)) : fn;
|
344 | var timerFunc = tt.nextTick ? tt.nextTick : setTimeout;
|
345 | timerFunc(fn);
|
346 | };
|
347 |
|
348 | var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
349 |
|
350 | function createCommonjsModule(fn, module) {
|
351 | return module = { exports: {} }, fn(module, module.exports), module.exports;
|
352 | }
|
353 |
|
354 |
|
355 |
|
356 | var freeGlobal = _typeof(commonjsGlobal) == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
|
357 | var _freeGlobal = freeGlobal;
|
358 |
|
359 |
|
360 |
|
361 | var freeSelf = (typeof self === "undefined" ? "undefined" : _typeof(self)) == 'object' && self && self.Object === Object && self;
|
362 |
|
363 |
|
364 | var root = _freeGlobal || freeSelf || Function('return this')();
|
365 | var _root = root;
|
366 |
|
367 |
|
368 |
|
369 | var _Symbol2 = _root.Symbol;
|
370 | var _Symbol = _Symbol2;
|
371 |
|
372 |
|
373 |
|
374 | var objectProto = Object.prototype;
|
375 |
|
376 |
|
377 | var hasOwnProperty = objectProto.hasOwnProperty;
|
378 | |
379 |
|
380 |
|
381 |
|
382 |
|
383 |
|
384 | var nativeObjectToString = objectProto.toString;
|
385 |
|
386 |
|
387 | var symToStringTag = _Symbol ? _Symbol.toStringTag : undefined;
|
388 | |
389 |
|
390 |
|
391 |
|
392 |
|
393 |
|
394 |
|
395 |
|
396 | function getRawTag(value) {
|
397 | var isOwn = hasOwnProperty.call(value, symToStringTag),
|
398 | tag = value[symToStringTag];
|
399 |
|
400 | try {
|
401 | value[symToStringTag] = undefined;
|
402 | var unmasked = true;
|
403 | } catch (e) {}
|
404 |
|
405 | var result = nativeObjectToString.call(value);
|
406 |
|
407 | if (unmasked) {
|
408 | if (isOwn) {
|
409 | value[symToStringTag] = tag;
|
410 | } else {
|
411 | delete value[symToStringTag];
|
412 | }
|
413 | }
|
414 |
|
415 | return result;
|
416 | }
|
417 |
|
418 | var _getRawTag = getRawTag;
|
419 |
|
420 |
|
421 | var objectProto$1 = Object.prototype;
|
422 | |
423 |
|
424 |
|
425 |
|
426 |
|
427 |
|
428 | var nativeObjectToString$1 = objectProto$1.toString;
|
429 | |
430 |
|
431 |
|
432 |
|
433 |
|
434 |
|
435 |
|
436 |
|
437 | function objectToString(value) {
|
438 | return nativeObjectToString$1.call(value);
|
439 | }
|
440 |
|
441 | var _objectToString = objectToString;
|
442 |
|
443 |
|
444 |
|
445 | var nullTag = '[object Null]',
|
446 | undefinedTag = '[object Undefined]';
|
447 |
|
448 |
|
449 | var symToStringTag$1 = _Symbol ? _Symbol.toStringTag : undefined;
|
450 | |
451 |
|
452 |
|
453 |
|
454 |
|
455 |
|
456 |
|
457 |
|
458 | function baseGetTag(value) {
|
459 | if (value == null) {
|
460 | return value === undefined ? undefinedTag : nullTag;
|
461 | }
|
462 |
|
463 | return symToStringTag$1 && symToStringTag$1 in Object(value) ? _getRawTag(value) : _objectToString(value);
|
464 | }
|
465 |
|
466 | var _baseGetTag = baseGetTag;
|
467 |
|
468 | |
469 |
|
470 |
|
471 |
|
472 |
|
473 |
|
474 |
|
475 |
|
476 | function overArg(func, transform) {
|
477 | return function (arg) {
|
478 | return func(transform(arg));
|
479 | };
|
480 | }
|
481 |
|
482 | var _overArg = overArg;
|
483 |
|
484 |
|
485 |
|
486 | var getPrototype = _overArg(Object.getPrototypeOf, Object);
|
487 | var _getPrototype = getPrototype;
|
488 |
|
489 | |
490 |
|
491 |
|
492 |
|
493 |
|
494 |
|
495 |
|
496 |
|
497 |
|
498 |
|
499 |
|
500 |
|
501 |
|
502 |
|
503 |
|
504 |
|
505 |
|
506 |
|
507 |
|
508 |
|
509 |
|
510 |
|
511 |
|
512 |
|
513 | function isObjectLike(value) {
|
514 | return value != null && _typeof(value) == 'object';
|
515 | }
|
516 |
|
517 | var isObjectLike_1 = isObjectLike;
|
518 |
|
519 |
|
520 |
|
521 | var objectTag = '[object Object]';
|
522 |
|
523 |
|
524 | var funcProto = Function.prototype,
|
525 | objectProto$2 = Object.prototype;
|
526 |
|
527 |
|
528 | var funcToString = funcProto.toString;
|
529 |
|
530 |
|
531 | var hasOwnProperty$1 = objectProto$2.hasOwnProperty;
|
532 |
|
533 |
|
534 | var objectCtorString = funcToString.call(Object);
|
535 | |
536 |
|
537 |
|
538 |
|
539 |
|
540 |
|
541 |
|
542 |
|
543 |
|
544 |
|
545 |
|
546 |
|
547 |
|
548 |
|
549 |
|
550 |
|
551 |
|
552 |
|
553 |
|
554 |
|
555 |
|
556 |
|
557 |
|
558 |
|
559 |
|
560 |
|
561 |
|
562 |
|
563 |
|
564 | function isPlainObject(value) {
|
565 | if (!isObjectLike_1(value) || _baseGetTag(value) != objectTag) {
|
566 | return false;
|
567 | }
|
568 |
|
569 | var proto = _getPrototype(value);
|
570 |
|
571 | if (proto === null) {
|
572 | return true;
|
573 | }
|
574 |
|
575 | var Ctor = hasOwnProperty$1.call(proto, 'constructor') && proto.constructor;
|
576 | return typeof Ctor == 'function' && Ctor instanceof Ctor && funcToString.call(Ctor) == objectCtorString;
|
577 | }
|
578 |
|
579 | var isPlainObject_1 = isPlainObject;
|
580 |
|
581 | function isEmptyObject(obj) {
|
582 | if (!obj || !isPlainObject_1(obj)) {
|
583 | return false;
|
584 | }
|
585 |
|
586 | for (var n in obj) {
|
587 | if (obj.hasOwnProperty(n)) {
|
588 | return false;
|
589 | }
|
590 | }
|
591 |
|
592 | return true;
|
593 | }
|
594 | function isUndefined(o) {
|
595 | return o === undefined;
|
596 | }
|
597 | function isFunction(arg) {
|
598 | return typeof arg === 'function';
|
599 | }
|
600 | function isArray(arg) {
|
601 | return Array.isArray(arg);
|
602 | }
|
603 | function shakeFnFromObject(obj) {
|
604 | var newObj;
|
605 |
|
606 | if (isArray(obj)) {
|
607 | newObj = [];
|
608 | var len = obj.length;
|
609 |
|
610 | for (var i = 0; i < len; i++) {
|
611 | newObj.push(shakeFnFromObject(obj[i]));
|
612 | }
|
613 | } else if (isPlainObject_1(obj)) {
|
614 | newObj = {};
|
615 |
|
616 | for (var key in obj) {
|
617 | if (isFunction(obj[key])) {
|
618 | continue;
|
619 | }
|
620 |
|
621 | var ret = shakeFnFromObject(obj[key]);
|
622 | newObj[key] = ret;
|
623 | }
|
624 | } else {
|
625 | return obj;
|
626 | }
|
627 |
|
628 | return newObj;
|
629 | }
|
630 | var keyList = Object.keys;
|
631 | var hasProp = Object.prototype.hasOwnProperty;
|
632 |
|
633 | function diffArrToPath(to, from) {
|
634 | var res = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
635 | var keyPrev = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '';
|
636 | var len = to.length;
|
637 |
|
638 | var _loop = function _loop(i) {
|
639 | var toItem = to[i];
|
640 | var fromItem = from[i];
|
641 | var targetKey = "".concat(keyPrev, "[").concat(i, "]");
|
642 |
|
643 | if (toItem === fromItem) {
|
644 | return "continue";
|
645 | } else if (_typeof(toItem) !== _typeof(fromItem)) {
|
646 | res[targetKey] = toItem;
|
647 | } else {
|
648 | if (_typeof(toItem) !== 'object') {
|
649 | res[targetKey] = toItem;
|
650 | } else {
|
651 | var arrTo = isArray(toItem);
|
652 | var arrFrom = isArray(fromItem);
|
653 |
|
654 | if (arrTo !== arrFrom) {
|
655 | res[targetKey] = toItem;
|
656 | } else if (arrTo && arrFrom) {
|
657 | if (toItem.length < fromItem.length) {
|
658 | res[targetKey] = toItem;
|
659 | } else {
|
660 |
|
661 | diffArrToPath(toItem, fromItem, res, "".concat(targetKey));
|
662 | }
|
663 | } else {
|
664 | if (!toItem || !fromItem || keyList(toItem).length < keyList(fromItem).length) {
|
665 | res[targetKey] = toItem;
|
666 | } else {
|
667 |
|
668 | var shouldDiffObject = true;
|
669 | Object.keys(fromItem).some(function (key) {
|
670 | if (typeof toItem[key] === 'undefined' && typeof fromItem[key] !== 'undefined') {
|
671 | shouldDiffObject = false;
|
672 | return true;
|
673 | }
|
674 | });
|
675 |
|
676 | if (shouldDiffObject) {
|
677 | diffObjToPath(toItem, fromItem, res, "".concat(targetKey, "."));
|
678 | } else {
|
679 | res[targetKey] = toItem;
|
680 | }
|
681 | }
|
682 | }
|
683 | }
|
684 | }
|
685 | };
|
686 |
|
687 | for (var i = 0; i < len; i++) {
|
688 | var _ret = _loop(i);
|
689 |
|
690 | if (_ret === "continue") continue;
|
691 | }
|
692 |
|
693 | return res;
|
694 | }
|
695 |
|
696 |
|
697 | function diffObjToPath(to, from) {
|
698 | var res = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
699 | var keyPrev = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '';
|
700 | var keys = keyList(to);
|
701 | var len = keys.length;
|
702 |
|
703 | var _loop2 = function _loop2(i) {
|
704 | var key = keys[i];
|
705 | var toItem = to[key];
|
706 | var fromItem = from[key];
|
707 | var targetKey = "".concat(keyPrev).concat(key);
|
708 |
|
709 | if (toItem === fromItem) {
|
710 | return "continue";
|
711 | } else if (!hasProp.call(from, key)) {
|
712 | res[targetKey] = toItem;
|
713 | } else if (_typeof(toItem) !== _typeof(fromItem)) {
|
714 | res[targetKey] = toItem;
|
715 | } else {
|
716 | if (_typeof(toItem) !== 'object') {
|
717 | res[targetKey] = toItem;
|
718 | } else {
|
719 | var arrTo = isArray(toItem);
|
720 | var arrFrom = isArray(fromItem);
|
721 |
|
722 | if (arrTo !== arrFrom) {
|
723 | res[targetKey] = toItem;
|
724 | } else if (arrTo && arrFrom) {
|
725 | if (toItem.length < fromItem.length) {
|
726 | res[targetKey] = toItem;
|
727 | } else {
|
728 |
|
729 | diffArrToPath(toItem, fromItem, res, "".concat(targetKey));
|
730 | }
|
731 | } else {
|
732 |
|
733 | if (!toItem || !fromItem) {
|
734 | res[targetKey] = toItem;
|
735 | } else {
|
736 |
|
737 | var shouldDiffObject = true;
|
738 | Object.keys(fromItem).some(function (key) {
|
739 | if (typeof toItem[key] === 'undefined' && typeof fromItem[key] !== 'undefined') {
|
740 | shouldDiffObject = false;
|
741 | return true;
|
742 | }
|
743 | });
|
744 |
|
745 | if (shouldDiffObject) {
|
746 | diffObjToPath(toItem, fromItem, res, "".concat(targetKey, "."));
|
747 | } else {
|
748 | res[targetKey] = toItem;
|
749 | }
|
750 | }
|
751 | }
|
752 | }
|
753 | }
|
754 | };
|
755 |
|
756 | for (var i = 0; i < len; i++) {
|
757 | var _ret2 = _loop2(i);
|
758 |
|
759 | if (_ret2 === "continue") continue;
|
760 | }
|
761 |
|
762 | return res;
|
763 | }
|
764 | function queryToJson(str) {
|
765 | var dec = decodeURIComponent;
|
766 | var qp = str.split('&');
|
767 | var ret = {};
|
768 | var name;
|
769 | var val;
|
770 |
|
771 | for (var i = 0, l = qp.length, item; i < l; ++i) {
|
772 | item = qp[i];
|
773 |
|
774 | if (item.length) {
|
775 | var s = item.indexOf('=');
|
776 |
|
777 | if (s < 0) {
|
778 | name = dec(item);
|
779 | val = '';
|
780 | } else {
|
781 | name = dec(item.slice(0, s));
|
782 | val = dec(item.slice(s + 1));
|
783 | }
|
784 |
|
785 | if (typeof ret[name] === 'string') {
|
786 |
|
787 | ret[name] = [ret[name]];
|
788 | }
|
789 |
|
790 | if (isArray(ret[name])) {
|
791 | ret[name].push(val);
|
792 | } else {
|
793 | ret[name] = val;
|
794 | }
|
795 | }
|
796 | }
|
797 |
|
798 | return ret;
|
799 | }
|
800 |
|
801 | var _loadTime = new Date().getTime().toString();
|
802 |
|
803 | var _i = 1;
|
804 | function getUniqueKey() {
|
805 | return _loadTime + _i++;
|
806 | }
|
807 |
|
808 | function triggerLoopRef(that, dom, handler) {
|
809 | var handlerType = _typeof(handler);
|
810 |
|
811 | if (handlerType !== 'function' && handlerType !== 'object') {
|
812 | return console.warn("\u5FAA\u73AF Ref \u53EA\u652F\u6301\u51FD\u6570\u6216 createRef()\uFF0C\u5F53\u524D\u7C7B\u578B\u4E3A\uFF1A".concat(handlerType));
|
813 | }
|
814 |
|
815 | if (handlerType === 'object') {
|
816 | handler.current = dom;
|
817 | } else if (handlerType === 'function') {
|
818 | handler.call(that, dom);
|
819 | }
|
820 | }
|
821 |
|
822 | function handleLoopRef(component, id, type, handler) {
|
823 | if (!component) return null;
|
824 | var res;
|
825 |
|
826 | if (type === 'component') {
|
827 | component.selectComponent(id, function (res) {
|
828 | res = res ? res.$component || res : null;
|
829 | res && triggerLoopRef(component.$component, res, handler);
|
830 | });
|
831 | } else {
|
832 | var query = wx.createSelectorQuery()["in"](component);
|
833 | res = query.select(id);
|
834 | res && triggerLoopRef(component.$component, res, handler);
|
835 | }
|
836 |
|
837 | return null;
|
838 | }
|
839 | var id$1 = 0;
|
840 |
|
841 | function genId() {
|
842 | return String(id$1++);
|
843 | }
|
844 |
|
845 | var compIdsMapper;
|
846 |
|
847 | try {
|
848 | compIdsMapper = new Map();
|
849 | } catch (error) {
|
850 | compIdsMapper = new SimpleMap();
|
851 | }
|
852 |
|
853 | function genCompid(key, isNeedCreate) {
|
854 | if (!taro.Current || !taro.Current.current || !taro.Current.current.$scope) return [];
|
855 | var prevId = compIdsMapper.get(key);
|
856 |
|
857 | if (isNeedCreate) {
|
858 | var _id = genId();
|
859 |
|
860 | compIdsMapper.set(key, _id);
|
861 | return [prevId, _id];
|
862 | } else {
|
863 | var _id2 = prevId || genId();
|
864 |
|
865 | !prevId && compIdsMapper.set(key, _id2);
|
866 | return [null, _id2];
|
867 | }
|
868 | }
|
869 | var prefix = 0;
|
870 | function genCompPrefix() {
|
871 | return String(prefix++);
|
872 | }
|
873 |
|
874 | var data = {};
|
875 | function cacheDataSet(key, val) {
|
876 | data[key] = val;
|
877 | }
|
878 | function cacheDataGet(key, delelteAfterGet) {
|
879 | var temp = data[key];
|
880 | delelteAfterGet && delete data[key];
|
881 | return temp;
|
882 | }
|
883 | function cacheDataHas(key) {
|
884 | return key in data;
|
885 | }
|
886 |
|
887 | var Manager = function () {
|
888 | function Manager() {
|
889 | _classCallCheck(this, Manager);
|
890 |
|
891 | _defineProperty(this, "map", {});
|
892 |
|
893 | _defineProperty(this, "observers", {});
|
894 | }
|
895 |
|
896 | _createClass(Manager, [{
|
897 | key: "set",
|
898 | value: function set() {
|
899 | var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
900 | var compid = arguments.length > 1 ? arguments[1] : undefined;
|
901 | var previd = arguments.length > 2 ? arguments[2] : undefined;
|
902 | if (!compid) return;
|
903 |
|
904 | if (previd) {
|
905 | this["delete"](previd);
|
906 | }
|
907 |
|
908 | var observers = this.observers;
|
909 |
|
910 | if (!this.map[compid]) {
|
911 | Object.defineProperty(this.map, compid, {
|
912 | configurable: true,
|
913 | get: function get() {
|
914 | return this["__".concat(compid)];
|
915 | },
|
916 | set: function set(props) {
|
917 | this["__".concat(compid)] = props;
|
918 | var component = observers[compid] && observers[compid].component;
|
919 | var ComponentClass = observers[compid] && observers[compid].ComponentClass;
|
920 | if (!component || !ComponentClass || !component.__isReady) return;
|
921 | var nextProps = filterProps(ComponentClass.defaultProps, props, component.props);
|
922 | component.props = nextProps;
|
923 | nextTick(function () {
|
924 | component._unsafeCallUpdate = true;
|
925 | updateComponent(component);
|
926 | component._unsafeCallUpdate = false;
|
927 | });
|
928 | }
|
929 | });
|
930 | }
|
931 |
|
932 | this.map[compid] = props;
|
933 | }
|
934 | }, {
|
935 | key: "delete",
|
936 | value: function _delete(compid) {
|
937 | delete this.map[compid];
|
938 | delete this.map["__".concat(compid)];
|
939 | delete this.observers[compid];
|
940 | }
|
941 | }]);
|
942 |
|
943 | return Manager;
|
944 | }();
|
945 |
|
946 | var propsManager = new Manager();
|
947 |
|
948 | var anonymousFnNamePreffix = 'funPrivate';
|
949 | var preloadPrivateKey = '__preload_';
|
950 | var preloadInitedComponent = '$preloadComponent';
|
951 | var PRELOAD_DATA_KEY = 'preload';
|
952 | var pageExtraFns = ['onPullDownRefresh', 'onReachBottom', 'onShareAppMessage', 'onPageScroll', 'onTabItemTap'];
|
953 |
|
954 | function bindProperties(weappComponentConf, ComponentClass, isPage) {
|
955 | weappComponentConf.properties = {};
|
956 |
|
957 | if (isPage) {
|
958 | weappComponentConf.properties[preloadPrivateKey] = {
|
959 | type: null,
|
960 | value: null
|
961 | };
|
962 | }
|
963 |
|
964 | weappComponentConf.properties.compid = {
|
965 | type: null,
|
966 | value: null,
|
967 | observer: function observer(newVal, oldVal) {
|
968 | var _this = this;
|
969 |
|
970 |
|
971 |
|
972 |
|
973 | if (oldVal && oldVal !== newVal) {
|
974 | var extraProps = this.data.extraProps;
|
975 | var component = this.$component;
|
976 | propsManager.observers[newVal] = {
|
977 | component: component,
|
978 | ComponentClass: component.constructor
|
979 | };
|
980 | var nextProps = filterProps(component.constructor.defaultProps, propsManager.map[newVal], component.props, extraProps || null);
|
981 | this.$component.props = nextProps;
|
982 | nextTick(function () {
|
983 | _this.$component._unsafeCallUpdate = true;
|
984 | updateComponent(_this.$component);
|
985 | _this.$component._unsafeCallUpdate = false;
|
986 | });
|
987 | }
|
988 | }
|
989 | };
|
990 | }
|
991 |
|
992 | function bindBehaviors(weappComponentConf, ComponentClass) {
|
993 | if (ComponentClass.behaviors) {
|
994 | weappComponentConf.behaviors = ComponentClass.behaviors;
|
995 | }
|
996 | }
|
997 |
|
998 | function bindStaticOptions(weappComponentConf, ComponentClass) {
|
999 | if (ComponentClass.options) {
|
1000 | weappComponentConf.options = ComponentClass.options;
|
1001 | }
|
1002 | }
|
1003 |
|
1004 | function bindStaticFns(weappComponentConf, ComponentClass) {
|
1005 | for (var key in ComponentClass) {
|
1006 | typeof ComponentClass[key] === 'function' && (weappComponentConf[key] = ComponentClass[key]);
|
1007 | }
|
1008 |
|
1009 |
|
1010 | Object.getOwnPropertyNames(ComponentClass).forEach(function (key) {
|
1011 | var excludes = ['arguments', 'caller', 'length', 'name', 'prototype'];
|
1012 |
|
1013 | if (excludes.indexOf(key) < 0) {
|
1014 | typeof ComponentClass[key] === 'function' && (weappComponentConf[key] = ComponentClass[key]);
|
1015 | }
|
1016 | });
|
1017 | }
|
1018 |
|
1019 | function processEvent(eventHandlerName, obj) {
|
1020 | if (obj[eventHandlerName]) return;
|
1021 |
|
1022 | obj[eventHandlerName] = function (event) {
|
1023 | if (event) {
|
1024 | event.preventDefault = function () {};
|
1025 |
|
1026 | event.stopPropagation = function () {};
|
1027 |
|
1028 | event.currentTarget = event.currentTarget || event.target || {};
|
1029 |
|
1030 | if (event.target) {
|
1031 | Object.assign(event.target, event.detail);
|
1032 | }
|
1033 |
|
1034 | Object.assign(event.currentTarget, event.detail);
|
1035 | }
|
1036 |
|
1037 | var scope = this.$component;
|
1038 | if (!scope || !scope[eventHandlerName]) return;
|
1039 | var callScope = scope;
|
1040 | var isAnonymousFn = eventHandlerName.indexOf(anonymousFnNamePreffix) > -1;
|
1041 | var realArgs = [];
|
1042 | var detailArgs = [];
|
1043 | var datasetArgs = [];
|
1044 | var isScopeBinded = false;
|
1045 |
|
1046 | var dataset = event.currentTarget.dataset || {};
|
1047 | var bindArgs = {};
|
1048 | var eventType = event.type ? event.type.toLocaleLowerCase() : null;
|
1049 | if (event.detail && event.detail.__detail) Object.assign(dataset, event.detail.__detail);
|
1050 | Object.keys(dataset).forEach(function (key) {
|
1051 | var keyLower = key.toLocaleLowerCase();
|
1052 |
|
1053 | if (/^e/.test(keyLower)) {
|
1054 |
|
1055 | keyLower = keyLower.replace(/^e/, '');
|
1056 |
|
1057 | if (keyLower.indexOf(eventType) >= 0) {
|
1058 | var argName = keyLower.replace(eventType, '');
|
1059 |
|
1060 | if (/^(a[a-z]|so)$/.test(argName)) {
|
1061 | bindArgs[argName] = dataset[key];
|
1062 | }
|
1063 | }
|
1064 | }
|
1065 | });
|
1066 |
|
1067 | if (event.detail && event.detail.__arguments && event.detail.__arguments.length > 0) {
|
1068 | detailArgs = event.detail.__arguments;
|
1069 | }
|
1070 |
|
1071 |
|
1072 | if (!isAnonymousFn) {
|
1073 | if ('so' in bindArgs) {
|
1074 | if (bindArgs['so'] !== 'this') {
|
1075 | callScope = bindArgs['so'];
|
1076 | }
|
1077 |
|
1078 | isScopeBinded = true;
|
1079 | delete bindArgs['so'];
|
1080 | }
|
1081 |
|
1082 | if (detailArgs.length > 0) {
|
1083 | !isScopeBinded && detailArgs[0] && (callScope = detailArgs[0]);
|
1084 | detailArgs.shift();
|
1085 | }
|
1086 |
|
1087 | if (!isEmptyObject(bindArgs)) {
|
1088 | datasetArgs = Object.keys(bindArgs).sort().map(function (key) {
|
1089 | return bindArgs[key];
|
1090 | });
|
1091 | }
|
1092 |
|
1093 | realArgs = [].concat(_toConsumableArray(datasetArgs), _toConsumableArray(detailArgs), [event]);
|
1094 | } else {
|
1095 |
|
1096 | var _scope = null;
|
1097 |
|
1098 | if ('so' in bindArgs) {
|
1099 | if (bindArgs['so'] !== 'this') {
|
1100 | _scope = bindArgs['so'];
|
1101 | }
|
1102 |
|
1103 | isScopeBinded = true;
|
1104 | delete bindArgs['so'];
|
1105 | }
|
1106 |
|
1107 | if (detailArgs.length > 0) {
|
1108 | !isScopeBinded && detailArgs[0] && (callScope = detailArgs[0]);
|
1109 | detailArgs.shift();
|
1110 | }
|
1111 |
|
1112 | if (!isEmptyObject(bindArgs)) {
|
1113 | datasetArgs = Object.keys(bindArgs).sort().map(function (key) {
|
1114 | return bindArgs[key];
|
1115 | });
|
1116 | }
|
1117 |
|
1118 | realArgs = [_scope].concat(_toConsumableArray(datasetArgs), _toConsumableArray(detailArgs), [event]);
|
1119 | }
|
1120 |
|
1121 | return scope[eventHandlerName].apply(callScope, realArgs);
|
1122 | };
|
1123 | }
|
1124 |
|
1125 | function bindEvents(weappComponentConf, events, isPage) {
|
1126 | weappComponentConf.methods = weappComponentConf.methods || {};
|
1127 | var target = isPage ? weappComponentConf : weappComponentConf.methods;
|
1128 | events.forEach(function (name) {
|
1129 | processEvent(name, target);
|
1130 | });
|
1131 | }
|
1132 |
|
1133 | function filterProps() {
|
1134 | var defaultProps = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
1135 | var propsFromPropsManager = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
1136 | var curAllProps = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
1137 | var newProps = Object.assign({}, curAllProps, propsFromPropsManager);
|
1138 |
|
1139 | if (!isEmptyObject(defaultProps)) {
|
1140 | for (var propName in defaultProps) {
|
1141 | if (newProps[propName] === undefined) {
|
1142 | newProps[propName] = defaultProps[propName];
|
1143 | }
|
1144 | }
|
1145 | }
|
1146 |
|
1147 | return newProps;
|
1148 | }
|
1149 | function componentTrigger(component, key, args) {
|
1150 | args = args || [];
|
1151 |
|
1152 | if (key === 'componentDidMount') {
|
1153 | if (component['$$hasLoopRef']) {
|
1154 | taro.Current.current = component;
|
1155 | taro.Current.index = 0;
|
1156 | component._disableEffect = true;
|
1157 |
|
1158 | component._createData(component.state, component.props, true);
|
1159 |
|
1160 | component._disableEffect = false;
|
1161 | taro.Current.current = null;
|
1162 | }
|
1163 |
|
1164 | if (component['$$refs'] && component['$$refs'].length > 0) {
|
1165 | var refs = {};
|
1166 | var refComponents = [];
|
1167 | component['$$refs'].forEach(function (ref) {
|
1168 | refComponents.push(new Promise(function (resolve, reject) {
|
1169 | var query = tt.createSelectorQuery()["in"](component.$scope);
|
1170 |
|
1171 | if (ref.type === 'component') {
|
1172 | component.$scope.selectComponent("#".concat(ref.id), function (target) {
|
1173 | resolve({
|
1174 | target: target ? target.$component || target : null,
|
1175 | ref: ref
|
1176 | });
|
1177 | });
|
1178 | } else {
|
1179 | resolve({
|
1180 | target: query.select("#".concat(ref.id)),
|
1181 | ref: ref
|
1182 | });
|
1183 | }
|
1184 | }));
|
1185 | });
|
1186 | Promise.all(refComponents).then(function (targets) {
|
1187 | targets.forEach(function (_ref) {
|
1188 | var ref = _ref.ref,
|
1189 | target = _ref.target;
|
1190 | taro.commitAttachRef(ref, target, component, refs, true);
|
1191 | ref.target = target;
|
1192 | });
|
1193 | component.refs = Object.assign({}, component.refs || {}, refs);
|
1194 |
|
1195 | component[key] && typeof component[key] === 'function' && component[key].apply(component, _toConsumableArray(args));
|
1196 | })["catch"](function (err) {
|
1197 | console.error(err);
|
1198 | component[key] && typeof component[key] === 'function' && component[key].apply(component, _toConsumableArray(args));
|
1199 | });
|
1200 |
|
1201 | return;
|
1202 | }
|
1203 | }
|
1204 |
|
1205 | if (key === 'componentWillUnmount') {
|
1206 | var compid = component.$scope.data.compid;
|
1207 | if (compid) propsManager["delete"](compid);
|
1208 | }
|
1209 |
|
1210 | component[key] && typeof component[key] === 'function' && component[key].apply(component, _toConsumableArray(args));
|
1211 |
|
1212 | if (key === 'componentWillUnmount') {
|
1213 | component._dirty = true;
|
1214 | component._disable = true;
|
1215 | component.$router = {
|
1216 | params: {},
|
1217 | path: ''
|
1218 | };
|
1219 | component._pendingStates = [];
|
1220 | component._pendingCallbacks = [];
|
1221 |
|
1222 | taro.detachAllRef(component);
|
1223 | }
|
1224 |
|
1225 | if (key === 'componentWillMount') {
|
1226 | component._dirty = false;
|
1227 | component._disable = false;
|
1228 | component.state = component.getState();
|
1229 | }
|
1230 | }
|
1231 | var hasPageInited = false;
|
1232 |
|
1233 | function initComponent(ComponentClass, isPage) {
|
1234 | if (!this.$component || this.$component.__isReady) return;
|
1235 |
|
1236 |
|
1237 | this.$component.__isReady = true;
|
1238 |
|
1239 | if (isPage && !hasPageInited) {
|
1240 | hasPageInited = true;
|
1241 | }
|
1242 |
|
1243 |
|
1244 |
|
1245 |
|
1246 | if (hasPageInited && !isPage) {
|
1247 | var compid = this.data.compid;
|
1248 |
|
1249 | if (compid) {
|
1250 | propsManager.observers[compid] = {
|
1251 | component: this.$component,
|
1252 | ComponentClass: ComponentClass
|
1253 | };
|
1254 | }
|
1255 |
|
1256 | var nextProps = filterProps(ComponentClass.defaultProps, propsManager.map[compid], this.$component.props);
|
1257 | this.$component.props = nextProps;
|
1258 | }
|
1259 |
|
1260 | if (hasPageInited || isPage) {
|
1261 | mountComponent(this.$component);
|
1262 | }
|
1263 | }
|
1264 |
|
1265 | function createComponent(ComponentClass, isPage) {
|
1266 | var initData = {};
|
1267 | var componentProps = filterProps(ComponentClass.defaultProps);
|
1268 | var componentInstance = new ComponentClass(componentProps);
|
1269 | componentInstance._constructor && componentInstance._constructor(componentProps);
|
1270 |
|
1271 | try {
|
1272 | taro.Current.current = componentInstance;
|
1273 | taro.Current.index = 0;
|
1274 | componentInstance.state = componentInstance._createData() || componentInstance.state;
|
1275 | } catch (err) {
|
1276 | if (isPage) {
|
1277 | console.warn("[Taro warn] \u8BF7\u7ED9\u9875\u9762\u63D0\u4F9B\u521D\u59CB `state` \u4EE5\u63D0\u9AD8\u521D\u6B21\u6E32\u67D3\u6027\u80FD\uFF01");
|
1278 | } else {
|
1279 | console.warn("[Taro warn] \u8BF7\u7ED9\u7EC4\u4EF6\u63D0\u4F9B\u4E00\u4E2A `defaultProps` \u4EE5\u63D0\u9AD8\u521D\u6B21\u6E32\u67D3\u6027\u80FD\uFF01");
|
1280 | }
|
1281 |
|
1282 | console.warn(err);
|
1283 | }
|
1284 |
|
1285 | initData = Object.assign({}, initData, componentInstance.props, componentInstance.state);
|
1286 | var weappComponentConf = {
|
1287 | data: initData,
|
1288 | created: function created() {
|
1289 | var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
1290 | isPage && (hasPageInited = false);
|
1291 |
|
1292 | if (isPage && cacheDataHas(preloadInitedComponent)) {
|
1293 | this.$component = cacheDataGet(preloadInitedComponent, true);
|
1294 | this.$component.$componentType = 'PAGE';
|
1295 | } else {
|
1296 | this.$component = new ComponentClass({}, isPage);
|
1297 | }
|
1298 |
|
1299 | this.$component._init(this);
|
1300 |
|
1301 | this.$component.render = this.$component._createData;
|
1302 | this.$component.__propTypes = ComponentClass.propTypes;
|
1303 |
|
1304 | if (isPage) {
|
1305 | if (cacheDataHas(PRELOAD_DATA_KEY)) {
|
1306 | var data = cacheDataGet(PRELOAD_DATA_KEY, true);
|
1307 | this.$component.$router.preload = data;
|
1308 | }
|
1309 |
|
1310 | Object.assign(this.$component.$router.params, options);
|
1311 |
|
1312 | if (cacheDataHas(options[preloadPrivateKey])) {
|
1313 | this.$component.$preloadData = cacheDataGet(options[preloadPrivateKey], true);
|
1314 | } else {
|
1315 | this.$component.$preloadData = {};
|
1316 | }
|
1317 |
|
1318 | this.$component.$router.path = getCurrentPageUrl();
|
1319 | initComponent.apply(this, [ComponentClass, isPage]);
|
1320 | }
|
1321 | },
|
1322 | attached: function attached() {
|
1323 | initComponent.apply(this, [ComponentClass, isPage]);
|
1324 | },
|
1325 | ready: function ready() {
|
1326 | if (!this.$component.__mounted) {
|
1327 | this.$component.__mounted = true;
|
1328 | componentTrigger(this.$component, 'componentDidMount');
|
1329 | }
|
1330 | },
|
1331 | detached: function detached() {
|
1332 | var component = this.$component;
|
1333 | componentTrigger(component, 'componentWillUnmount');
|
1334 | component.hooks.forEach(function (hook) {
|
1335 | if (isFunction(hook.cleanup)) {
|
1336 | hook.cleanup();
|
1337 | }
|
1338 | });
|
1339 | var events = component.$$renderPropsEvents;
|
1340 |
|
1341 | if (isArray(events)) {
|
1342 | events.forEach(function (e) {
|
1343 | return taro.eventCenter.off(e);
|
1344 | });
|
1345 | }
|
1346 | }
|
1347 | };
|
1348 |
|
1349 | if (isPage) {
|
1350 | weappComponentConf['onLoad'] = weappComponentConf['created'];
|
1351 | weappComponentConf['onReady'] = weappComponentConf['ready'];
|
1352 | weappComponentConf['onUnload'] = weappComponentConf['detached'];
|
1353 |
|
1354 | weappComponentConf['onShow'] = function () {
|
1355 | componentTrigger(this.$component, 'componentDidShow');
|
1356 | };
|
1357 |
|
1358 | weappComponentConf['onHide'] = function () {
|
1359 | componentTrigger(this.$component, 'componentDidHide');
|
1360 | };
|
1361 |
|
1362 | pageExtraFns.forEach(function (fn) {
|
1363 | if (componentInstance[fn] && typeof componentInstance[fn] === 'function') {
|
1364 | weappComponentConf[fn] = function () {
|
1365 | var component = this.$component;
|
1366 |
|
1367 | if (component && component[fn] && typeof component[fn] === 'function') {
|
1368 | return component[fn].apply(component, arguments);
|
1369 | }
|
1370 | };
|
1371 | }
|
1372 | });
|
1373 | ComponentClass.$$componentPath && cacheDataSet(ComponentClass.$$componentPath, ComponentClass);
|
1374 | }
|
1375 |
|
1376 | bindProperties(weappComponentConf, ComponentClass, isPage);
|
1377 | bindBehaviors(weappComponentConf, ComponentClass);
|
1378 | bindStaticFns(weappComponentConf, ComponentClass);
|
1379 | bindStaticOptions(weappComponentConf, ComponentClass);
|
1380 | ComponentClass['$$events'] && bindEvents(weappComponentConf, ComponentClass['$$events'], isPage);
|
1381 |
|
1382 | if (ComponentClass['externalClasses'] && ComponentClass['externalClasses'].length) {
|
1383 | weappComponentConf['externalClasses'] = ComponentClass['externalClasses'];
|
1384 | }
|
1385 |
|
1386 | return weappComponentConf;
|
1387 | }
|
1388 |
|
1389 | |
1390 |
|
1391 |
|
1392 |
|
1393 |
|
1394 |
|
1395 |
|
1396 |
|
1397 | var b = "function" === typeof Symbol && Symbol["for"],
|
1398 | c = b ? Symbol["for"]("react.element") : 60103,
|
1399 | d = b ? Symbol["for"]("react.portal") : 60106,
|
1400 | e = b ? Symbol["for"]("react.fragment") : 60107,
|
1401 | f = b ? Symbol["for"]("react.strict_mode") : 60108,
|
1402 | g = b ? Symbol["for"]("react.profiler") : 60114,
|
1403 | h = b ? Symbol["for"]("react.provider") : 60109,
|
1404 | k = b ? Symbol["for"]("react.context") : 60110,
|
1405 | l = b ? Symbol["for"]("react.async_mode") : 60111,
|
1406 | m = b ? Symbol["for"]("react.concurrent_mode") : 60111,
|
1407 | n = b ? Symbol["for"]("react.forward_ref") : 60112,
|
1408 | p = b ? Symbol["for"]("react.suspense") : 60113,
|
1409 | q = b ? Symbol["for"]("react.suspense_list") : 60120,
|
1410 | r = b ? Symbol["for"]("react.memo") : 60115,
|
1411 | t = b ? Symbol["for"]("react.lazy") : 60116,
|
1412 | v = b ? Symbol["for"]("react.block") : 60121,
|
1413 | w = b ? Symbol["for"]("react.fundamental") : 60117,
|
1414 | x = b ? Symbol["for"]("react.responder") : 60118,
|
1415 | y = b ? Symbol["for"]("react.scope") : 60119;
|
1416 |
|
1417 | function z(a) {
|
1418 | if ("object" === _typeof(a) && null !== a) {
|
1419 | var u = a.$$typeof;
|
1420 |
|
1421 | switch (u) {
|
1422 | case c:
|
1423 | switch (a = a.type, a) {
|
1424 | case l:
|
1425 | case m:
|
1426 | case e:
|
1427 | case g:
|
1428 | case f:
|
1429 | case p:
|
1430 | return a;
|
1431 |
|
1432 | default:
|
1433 | switch (a = a && a.$$typeof, a) {
|
1434 | case k:
|
1435 | case n:
|
1436 | case t:
|
1437 | case r:
|
1438 | case h:
|
1439 | return a;
|
1440 |
|
1441 | default:
|
1442 | return u;
|
1443 | }
|
1444 |
|
1445 | }
|
1446 |
|
1447 | case d:
|
1448 | return u;
|
1449 | }
|
1450 | }
|
1451 | }
|
1452 |
|
1453 | function A(a) {
|
1454 | return z(a) === m;
|
1455 | }
|
1456 |
|
1457 | var AsyncMode = l;
|
1458 | var ConcurrentMode = m;
|
1459 | var ContextConsumer = k;
|
1460 | var ContextProvider = h;
|
1461 | var Element = c;
|
1462 | var ForwardRef = n;
|
1463 | var Fragment = e;
|
1464 | var Lazy = t;
|
1465 | var Memo = r;
|
1466 | var Portal = d;
|
1467 | var Profiler = g;
|
1468 | var StrictMode = f;
|
1469 | var Suspense = p;
|
1470 |
|
1471 | var isAsyncMode = function isAsyncMode(a) {
|
1472 | return A(a) || z(a) === l;
|
1473 | };
|
1474 |
|
1475 | var isConcurrentMode = A;
|
1476 |
|
1477 | var isContextConsumer = function isContextConsumer(a) {
|
1478 | return z(a) === k;
|
1479 | };
|
1480 |
|
1481 | var isContextProvider = function isContextProvider(a) {
|
1482 | return z(a) === h;
|
1483 | };
|
1484 |
|
1485 | var isElement = function isElement(a) {
|
1486 | return "object" === _typeof(a) && null !== a && a.$$typeof === c;
|
1487 | };
|
1488 |
|
1489 | var isForwardRef = function isForwardRef(a) {
|
1490 | return z(a) === n;
|
1491 | };
|
1492 |
|
1493 | var isFragment = function isFragment(a) {
|
1494 | return z(a) === e;
|
1495 | };
|
1496 |
|
1497 | var isLazy = function isLazy(a) {
|
1498 | return z(a) === t;
|
1499 | };
|
1500 |
|
1501 | var isMemo = function isMemo(a) {
|
1502 | return z(a) === r;
|
1503 | };
|
1504 |
|
1505 | var isPortal = function isPortal(a) {
|
1506 | return z(a) === d;
|
1507 | };
|
1508 |
|
1509 | var isProfiler = function isProfiler(a) {
|
1510 | return z(a) === g;
|
1511 | };
|
1512 |
|
1513 | var isStrictMode = function isStrictMode(a) {
|
1514 | return z(a) === f;
|
1515 | };
|
1516 |
|
1517 | var isSuspense = function isSuspense(a) {
|
1518 | return z(a) === p;
|
1519 | };
|
1520 |
|
1521 | var isValidElementType = function isValidElementType(a) {
|
1522 | return "string" === typeof a || "function" === typeof a || a === e || a === m || a === g || a === f || a === p || a === q || "object" === _typeof(a) && null !== a && (a.$$typeof === t || a.$$typeof === r || a.$$typeof === h || a.$$typeof === k || a.$$typeof === n || a.$$typeof === w || a.$$typeof === x || a.$$typeof === y || a.$$typeof === v);
|
1523 | };
|
1524 |
|
1525 | var typeOf = z;
|
1526 | var reactIs_production_min = {
|
1527 | AsyncMode: AsyncMode,
|
1528 | ConcurrentMode: ConcurrentMode,
|
1529 | ContextConsumer: ContextConsumer,
|
1530 | ContextProvider: ContextProvider,
|
1531 | Element: Element,
|
1532 | ForwardRef: ForwardRef,
|
1533 | Fragment: Fragment,
|
1534 | Lazy: Lazy,
|
1535 | Memo: Memo,
|
1536 | Portal: Portal,
|
1537 | Profiler: Profiler,
|
1538 | StrictMode: StrictMode,
|
1539 | Suspense: Suspense,
|
1540 | isAsyncMode: isAsyncMode,
|
1541 | isConcurrentMode: isConcurrentMode,
|
1542 | isContextConsumer: isContextConsumer,
|
1543 | isContextProvider: isContextProvider,
|
1544 | isElement: isElement,
|
1545 | isForwardRef: isForwardRef,
|
1546 | isFragment: isFragment,
|
1547 | isLazy: isLazy,
|
1548 | isMemo: isMemo,
|
1549 | isPortal: isPortal,
|
1550 | isProfiler: isProfiler,
|
1551 | isStrictMode: isStrictMode,
|
1552 | isSuspense: isSuspense,
|
1553 | isValidElementType: isValidElementType,
|
1554 | typeOf: typeOf
|
1555 | };
|
1556 |
|
1557 | var reactIs_development = createCommonjsModule(function (module, exports) {
|
1558 |
|
1559 | if (process.env.NODE_ENV !== "production") {
|
1560 | (function () {
|
1561 |
|
1562 |
|
1563 | var hasSymbol = typeof Symbol === 'function' && Symbol["for"];
|
1564 | var REACT_ELEMENT_TYPE = hasSymbol ? Symbol["for"]('react.element') : 0xeac7;
|
1565 | var REACT_PORTAL_TYPE = hasSymbol ? Symbol["for"]('react.portal') : 0xeaca;
|
1566 | var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol["for"]('react.fragment') : 0xeacb;
|
1567 | var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol["for"]('react.strict_mode') : 0xeacc;
|
1568 | var REACT_PROFILER_TYPE = hasSymbol ? Symbol["for"]('react.profiler') : 0xead2;
|
1569 | var REACT_PROVIDER_TYPE = hasSymbol ? Symbol["for"]('react.provider') : 0xeacd;
|
1570 | var REACT_CONTEXT_TYPE = hasSymbol ? Symbol["for"]('react.context') : 0xeace;
|
1571 |
|
1572 |
|
1573 | var REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol["for"]('react.async_mode') : 0xeacf;
|
1574 | var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol["for"]('react.concurrent_mode') : 0xeacf;
|
1575 | var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol["for"]('react.forward_ref') : 0xead0;
|
1576 | var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol["for"]('react.suspense') : 0xead1;
|
1577 | var REACT_SUSPENSE_LIST_TYPE = hasSymbol ? Symbol["for"]('react.suspense_list') : 0xead8;
|
1578 | var REACT_MEMO_TYPE = hasSymbol ? Symbol["for"]('react.memo') : 0xead3;
|
1579 | var REACT_LAZY_TYPE = hasSymbol ? Symbol["for"]('react.lazy') : 0xead4;
|
1580 | var REACT_BLOCK_TYPE = hasSymbol ? Symbol["for"]('react.block') : 0xead9;
|
1581 | var REACT_FUNDAMENTAL_TYPE = hasSymbol ? Symbol["for"]('react.fundamental') : 0xead5;
|
1582 | var REACT_RESPONDER_TYPE = hasSymbol ? Symbol["for"]('react.responder') : 0xead6;
|
1583 | var REACT_SCOPE_TYPE = hasSymbol ? Symbol["for"]('react.scope') : 0xead7;
|
1584 |
|
1585 | function isValidElementType(type) {
|
1586 | return typeof type === 'string' || typeof type === 'function' ||
|
1587 | type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || _typeof(type) === 'object' && type !== null && (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_RESPONDER_TYPE || type.$$typeof === REACT_SCOPE_TYPE || type.$$typeof === REACT_BLOCK_TYPE);
|
1588 | }
|
1589 |
|
1590 | function typeOf(object) {
|
1591 | if (_typeof(object) === 'object' && object !== null) {
|
1592 | var $$typeof = object.$$typeof;
|
1593 |
|
1594 | switch ($$typeof) {
|
1595 | case REACT_ELEMENT_TYPE:
|
1596 | var type = object.type;
|
1597 |
|
1598 | switch (type) {
|
1599 | case REACT_ASYNC_MODE_TYPE:
|
1600 | case REACT_CONCURRENT_MODE_TYPE:
|
1601 | case REACT_FRAGMENT_TYPE:
|
1602 | case REACT_PROFILER_TYPE:
|
1603 | case REACT_STRICT_MODE_TYPE:
|
1604 | case REACT_SUSPENSE_TYPE:
|
1605 | return type;
|
1606 |
|
1607 | default:
|
1608 | var $$typeofType = type && type.$$typeof;
|
1609 |
|
1610 | switch ($$typeofType) {
|
1611 | case REACT_CONTEXT_TYPE:
|
1612 | case REACT_FORWARD_REF_TYPE:
|
1613 | case REACT_LAZY_TYPE:
|
1614 | case REACT_MEMO_TYPE:
|
1615 | case REACT_PROVIDER_TYPE:
|
1616 | return $$typeofType;
|
1617 |
|
1618 | default:
|
1619 | return $$typeof;
|
1620 | }
|
1621 |
|
1622 | }
|
1623 |
|
1624 | case REACT_PORTAL_TYPE:
|
1625 | return $$typeof;
|
1626 | }
|
1627 | }
|
1628 |
|
1629 | return undefined;
|
1630 | }
|
1631 |
|
1632 |
|
1633 | var AsyncMode = REACT_ASYNC_MODE_TYPE;
|
1634 | var ConcurrentMode = REACT_CONCURRENT_MODE_TYPE;
|
1635 | var ContextConsumer = REACT_CONTEXT_TYPE;
|
1636 | var ContextProvider = REACT_PROVIDER_TYPE;
|
1637 | var Element = REACT_ELEMENT_TYPE;
|
1638 | var ForwardRef = REACT_FORWARD_REF_TYPE;
|
1639 | var Fragment = REACT_FRAGMENT_TYPE;
|
1640 | var Lazy = REACT_LAZY_TYPE;
|
1641 | var Memo = REACT_MEMO_TYPE;
|
1642 | var Portal = REACT_PORTAL_TYPE;
|
1643 | var Profiler = REACT_PROFILER_TYPE;
|
1644 | var StrictMode = REACT_STRICT_MODE_TYPE;
|
1645 | var Suspense = REACT_SUSPENSE_TYPE;
|
1646 | var hasWarnedAboutDeprecatedIsAsyncMode = false;
|
1647 |
|
1648 | function isAsyncMode(object) {
|
1649 | {
|
1650 | if (!hasWarnedAboutDeprecatedIsAsyncMode) {
|
1651 | hasWarnedAboutDeprecatedIsAsyncMode = true;
|
1652 |
|
1653 | console['warn']('The ReactIs.isAsyncMode() alias has been deprecated, ' + 'and will be removed in React 17+. Update your code to use ' + 'ReactIs.isConcurrentMode() instead. It has the exact same API.');
|
1654 | }
|
1655 | }
|
1656 | return isConcurrentMode(object) || typeOf(object) === REACT_ASYNC_MODE_TYPE;
|
1657 | }
|
1658 |
|
1659 | function isConcurrentMode(object) {
|
1660 | return typeOf(object) === REACT_CONCURRENT_MODE_TYPE;
|
1661 | }
|
1662 |
|
1663 | function isContextConsumer(object) {
|
1664 | return typeOf(object) === REACT_CONTEXT_TYPE;
|
1665 | }
|
1666 |
|
1667 | function isContextProvider(object) {
|
1668 | return typeOf(object) === REACT_PROVIDER_TYPE;
|
1669 | }
|
1670 |
|
1671 | function isElement(object) {
|
1672 | return _typeof(object) === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
|
1673 | }
|
1674 |
|
1675 | function isForwardRef(object) {
|
1676 | return typeOf(object) === REACT_FORWARD_REF_TYPE;
|
1677 | }
|
1678 |
|
1679 | function isFragment(object) {
|
1680 | return typeOf(object) === REACT_FRAGMENT_TYPE;
|
1681 | }
|
1682 |
|
1683 | function isLazy(object) {
|
1684 | return typeOf(object) === REACT_LAZY_TYPE;
|
1685 | }
|
1686 |
|
1687 | function isMemo(object) {
|
1688 | return typeOf(object) === REACT_MEMO_TYPE;
|
1689 | }
|
1690 |
|
1691 | function isPortal(object) {
|
1692 | return typeOf(object) === REACT_PORTAL_TYPE;
|
1693 | }
|
1694 |
|
1695 | function isProfiler(object) {
|
1696 | return typeOf(object) === REACT_PROFILER_TYPE;
|
1697 | }
|
1698 |
|
1699 | function isStrictMode(object) {
|
1700 | return typeOf(object) === REACT_STRICT_MODE_TYPE;
|
1701 | }
|
1702 |
|
1703 | function isSuspense(object) {
|
1704 | return typeOf(object) === REACT_SUSPENSE_TYPE;
|
1705 | }
|
1706 |
|
1707 | exports.AsyncMode = AsyncMode;
|
1708 | exports.ConcurrentMode = ConcurrentMode;
|
1709 | exports.ContextConsumer = ContextConsumer;
|
1710 | exports.ContextProvider = ContextProvider;
|
1711 | exports.Element = Element;
|
1712 | exports.ForwardRef = ForwardRef;
|
1713 | exports.Fragment = Fragment;
|
1714 | exports.Lazy = Lazy;
|
1715 | exports.Memo = Memo;
|
1716 | exports.Portal = Portal;
|
1717 | exports.Profiler = Profiler;
|
1718 | exports.StrictMode = StrictMode;
|
1719 | exports.Suspense = Suspense;
|
1720 | exports.isAsyncMode = isAsyncMode;
|
1721 | exports.isConcurrentMode = isConcurrentMode;
|
1722 | exports.isContextConsumer = isContextConsumer;
|
1723 | exports.isContextProvider = isContextProvider;
|
1724 | exports.isElement = isElement;
|
1725 | exports.isForwardRef = isForwardRef;
|
1726 | exports.isFragment = isFragment;
|
1727 | exports.isLazy = isLazy;
|
1728 | exports.isMemo = isMemo;
|
1729 | exports.isPortal = isPortal;
|
1730 | exports.isProfiler = isProfiler;
|
1731 | exports.isStrictMode = isStrictMode;
|
1732 | exports.isSuspense = isSuspense;
|
1733 | exports.isValidElementType = isValidElementType;
|
1734 | exports.typeOf = typeOf;
|
1735 | })();
|
1736 | }
|
1737 | });
|
1738 | var reactIs_development_1 = reactIs_development.AsyncMode;
|
1739 | var reactIs_development_2 = reactIs_development.ConcurrentMode;
|
1740 | var reactIs_development_3 = reactIs_development.ContextConsumer;
|
1741 | var reactIs_development_4 = reactIs_development.ContextProvider;
|
1742 | var reactIs_development_5 = reactIs_development.Element;
|
1743 | var reactIs_development_6 = reactIs_development.ForwardRef;
|
1744 | var reactIs_development_7 = reactIs_development.Fragment;
|
1745 | var reactIs_development_8 = reactIs_development.Lazy;
|
1746 | var reactIs_development_9 = reactIs_development.Memo;
|
1747 | var reactIs_development_10 = reactIs_development.Portal;
|
1748 | var reactIs_development_11 = reactIs_development.Profiler;
|
1749 | var reactIs_development_12 = reactIs_development.StrictMode;
|
1750 | var reactIs_development_13 = reactIs_development.Suspense;
|
1751 | var reactIs_development_14 = reactIs_development.isAsyncMode;
|
1752 | var reactIs_development_15 = reactIs_development.isConcurrentMode;
|
1753 | var reactIs_development_16 = reactIs_development.isContextConsumer;
|
1754 | var reactIs_development_17 = reactIs_development.isContextProvider;
|
1755 | var reactIs_development_18 = reactIs_development.isElement;
|
1756 | var reactIs_development_19 = reactIs_development.isForwardRef;
|
1757 | var reactIs_development_20 = reactIs_development.isFragment;
|
1758 | var reactIs_development_21 = reactIs_development.isLazy;
|
1759 | var reactIs_development_22 = reactIs_development.isMemo;
|
1760 | var reactIs_development_23 = reactIs_development.isPortal;
|
1761 | var reactIs_development_24 = reactIs_development.isProfiler;
|
1762 | var reactIs_development_25 = reactIs_development.isStrictMode;
|
1763 | var reactIs_development_26 = reactIs_development.isSuspense;
|
1764 | var reactIs_development_27 = reactIs_development.isValidElementType;
|
1765 | var reactIs_development_28 = reactIs_development.typeOf;
|
1766 |
|
1767 | var reactIs = createCommonjsModule(function (module) {
|
1768 |
|
1769 | if (process.env.NODE_ENV === 'production') {
|
1770 | module.exports = reactIs_production_min;
|
1771 | } else {
|
1772 | module.exports = reactIs_development;
|
1773 | }
|
1774 | });
|
1775 |
|
1776 | |
1777 |
|
1778 |
|
1779 |
|
1780 |
|
1781 |
|
1782 |
|
1783 | var getOwnPropertySymbols = Object.getOwnPropertySymbols;
|
1784 | var hasOwnProperty$2 = Object.prototype.hasOwnProperty;
|
1785 | var propIsEnumerable = Object.prototype.propertyIsEnumerable;
|
1786 |
|
1787 | function toObject(val) {
|
1788 | if (val === null || val === undefined) {
|
1789 | throw new TypeError('Object.assign cannot be called with null or undefined');
|
1790 | }
|
1791 |
|
1792 | return Object(val);
|
1793 | }
|
1794 |
|
1795 | function shouldUseNative() {
|
1796 | try {
|
1797 | if (!Object.assign) {
|
1798 | return false;
|
1799 | }
|
1800 |
|
1801 |
|
1802 |
|
1803 | var test1 = new String('abc');
|
1804 |
|
1805 | test1[5] = 'de';
|
1806 |
|
1807 | if (Object.getOwnPropertyNames(test1)[0] === '5') {
|
1808 | return false;
|
1809 | }
|
1810 |
|
1811 |
|
1812 | var test2 = {};
|
1813 |
|
1814 | for (var i = 0; i < 10; i++) {
|
1815 | test2['_' + String.fromCharCode(i)] = i;
|
1816 | }
|
1817 |
|
1818 | var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
|
1819 | return test2[n];
|
1820 | });
|
1821 |
|
1822 | if (order2.join('') !== '0123456789') {
|
1823 | return false;
|
1824 | }
|
1825 |
|
1826 |
|
1827 | var test3 = {};
|
1828 | 'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
|
1829 | test3[letter] = letter;
|
1830 | });
|
1831 |
|
1832 | if (Object.keys(Object.assign({}, test3)).join('') !== 'abcdefghijklmnopqrst') {
|
1833 | return false;
|
1834 | }
|
1835 |
|
1836 | return true;
|
1837 | } catch (err) {
|
1838 |
|
1839 | return false;
|
1840 | }
|
1841 | }
|
1842 |
|
1843 | var objectAssign = shouldUseNative() ? Object.assign : function (target, source) {
|
1844 | var from;
|
1845 | var to = toObject(target);
|
1846 | var symbols;
|
1847 |
|
1848 | for (var s = 1; s < arguments.length; s++) {
|
1849 | from = Object(arguments[s]);
|
1850 |
|
1851 | for (var key in from) {
|
1852 | if (hasOwnProperty$2.call(from, key)) {
|
1853 | to[key] = from[key];
|
1854 | }
|
1855 | }
|
1856 |
|
1857 | if (getOwnPropertySymbols) {
|
1858 | symbols = getOwnPropertySymbols(from);
|
1859 |
|
1860 | for (var i = 0; i < symbols.length; i++) {
|
1861 | if (propIsEnumerable.call(from, symbols[i])) {
|
1862 | to[symbols[i]] = from[symbols[i]];
|
1863 | }
|
1864 | }
|
1865 | }
|
1866 | }
|
1867 |
|
1868 | return to;
|
1869 | };
|
1870 |
|
1871 | |
1872 |
|
1873 |
|
1874 |
|
1875 |
|
1876 |
|
1877 |
|
1878 | var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
|
1879 | var ReactPropTypesSecret_1 = ReactPropTypesSecret;
|
1880 |
|
1881 | var printWarning = function printWarning() {};
|
1882 |
|
1883 | if (process.env.NODE_ENV !== 'production') {
|
1884 | var ReactPropTypesSecret$1 = ReactPropTypesSecret_1;
|
1885 | var loggedTypeFailures = {};
|
1886 | var has = Function.call.bind(Object.prototype.hasOwnProperty);
|
1887 |
|
1888 | printWarning = function printWarning(text) {
|
1889 | var message = 'Warning: ' + text;
|
1890 |
|
1891 | if (typeof console !== 'undefined') {
|
1892 | console.error(message);
|
1893 | }
|
1894 |
|
1895 | try {
|
1896 |
|
1897 |
|
1898 |
|
1899 | throw new Error(message);
|
1900 | } catch (x) {}
|
1901 | };
|
1902 | }
|
1903 | |
1904 |
|
1905 |
|
1906 |
|
1907 |
|
1908 |
|
1909 |
|
1910 |
|
1911 |
|
1912 |
|
1913 |
|
1914 |
|
1915 |
|
1916 | function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
|
1917 | if (process.env.NODE_ENV !== 'production') {
|
1918 | for (var typeSpecName in typeSpecs) {
|
1919 | if (has(typeSpecs, typeSpecName)) {
|
1920 | var error;
|
1921 |
|
1922 |
|
1923 |
|
1924 | try {
|
1925 |
|
1926 |
|
1927 | if (typeof typeSpecs[typeSpecName] !== 'function') {
|
1928 | var err = Error((componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' + 'it must be a function, usually from the `prop-types` package, but received `' + _typeof(typeSpecs[typeSpecName]) + '`.');
|
1929 | err.name = 'Invariant Violation';
|
1930 | throw err;
|
1931 | }
|
1932 |
|
1933 | error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret$1);
|
1934 | } catch (ex) {
|
1935 | error = ex;
|
1936 | }
|
1937 |
|
1938 | if (error && !(error instanceof Error)) {
|
1939 | printWarning((componentName || 'React class') + ': type specification of ' + location + ' `' + typeSpecName + '` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a ' + _typeof(error) + '. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).');
|
1940 | }
|
1941 |
|
1942 | if (error instanceof Error && !(error.message in loggedTypeFailures)) {
|
1943 |
|
1944 |
|
1945 | loggedTypeFailures[error.message] = true;
|
1946 | var stack = getStack ? getStack() : '';
|
1947 | printWarning('Failed ' + location + ' type: ' + error.message + (stack != null ? stack : ''));
|
1948 | }
|
1949 | }
|
1950 | }
|
1951 | }
|
1952 | }
|
1953 | |
1954 |
|
1955 |
|
1956 |
|
1957 |
|
1958 |
|
1959 |
|
1960 | checkPropTypes.resetWarningCache = function () {
|
1961 | if (process.env.NODE_ENV !== 'production') {
|
1962 | loggedTypeFailures = {};
|
1963 | }
|
1964 | };
|
1965 |
|
1966 | var checkPropTypes_1 = checkPropTypes;
|
1967 |
|
1968 | var has$1 = Function.call.bind(Object.prototype.hasOwnProperty);
|
1969 |
|
1970 | var printWarning$1 = function printWarning() {};
|
1971 |
|
1972 | if (process.env.NODE_ENV !== 'production') {
|
1973 | printWarning$1 = function printWarning(text) {
|
1974 | var message = 'Warning: ' + text;
|
1975 |
|
1976 | if (typeof console !== 'undefined') {
|
1977 | console.error(message);
|
1978 | }
|
1979 |
|
1980 | try {
|
1981 |
|
1982 |
|
1983 |
|
1984 | throw new Error(message);
|
1985 | } catch (x) {}
|
1986 | };
|
1987 | }
|
1988 |
|
1989 | function emptyFunctionThatReturnsNull() {
|
1990 | return null;
|
1991 | }
|
1992 |
|
1993 | var factoryWithTypeCheckers = function factoryWithTypeCheckers(isValidElement, throwOnDirectAccess) {
|
1994 |
|
1995 | var ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
|
1996 | var FAUX_ITERATOR_SYMBOL = '@@iterator';
|
1997 |
|
1998 | |
1999 |
|
2000 |
|
2001 |
|
2002 |
|
2003 |
|
2004 |
|
2005 |
|
2006 |
|
2007 |
|
2008 |
|
2009 |
|
2010 |
|
2011 |
|
2012 |
|
2013 | function getIteratorFn(maybeIterable) {
|
2014 | var iteratorFn = maybeIterable && (ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]);
|
2015 |
|
2016 | if (typeof iteratorFn === 'function') {
|
2017 | return iteratorFn;
|
2018 | }
|
2019 | }
|
2020 | |
2021 |
|
2022 |
|
2023 |
|
2024 |
|
2025 |
|
2026 |
|
2027 |
|
2028 |
|
2029 |
|
2030 |
|
2031 |
|
2032 |
|
2033 |
|
2034 |
|
2035 |
|
2036 |
|
2037 |
|
2038 |
|
2039 |
|
2040 |
|
2041 |
|
2042 |
|
2043 |
|
2044 |
|
2045 |
|
2046 |
|
2047 |
|
2048 |
|
2049 |
|
2050 |
|
2051 |
|
2052 |
|
2053 |
|
2054 |
|
2055 |
|
2056 |
|
2057 |
|
2058 |
|
2059 |
|
2060 |
|
2061 |
|
2062 |
|
2063 |
|
2064 |
|
2065 |
|
2066 |
|
2067 |
|
2068 | var ANONYMOUS = '<<anonymous>>';
|
2069 |
|
2070 |
|
2071 | var ReactPropTypes = {
|
2072 | array: createPrimitiveTypeChecker('array'),
|
2073 | bool: createPrimitiveTypeChecker('boolean'),
|
2074 | func: createPrimitiveTypeChecker('function'),
|
2075 | number: createPrimitiveTypeChecker('number'),
|
2076 | object: createPrimitiveTypeChecker('object'),
|
2077 | string: createPrimitiveTypeChecker('string'),
|
2078 | symbol: createPrimitiveTypeChecker('symbol'),
|
2079 | any: createAnyTypeChecker(),
|
2080 | arrayOf: createArrayOfTypeChecker,
|
2081 | element: createElementTypeChecker(),
|
2082 | elementType: createElementTypeTypeChecker(),
|
2083 | instanceOf: createInstanceTypeChecker,
|
2084 | node: createNodeChecker(),
|
2085 | objectOf: createObjectOfTypeChecker,
|
2086 | oneOf: createEnumTypeChecker,
|
2087 | oneOfType: createUnionTypeChecker,
|
2088 | shape: createShapeTypeChecker,
|
2089 | exact: createStrictShapeTypeChecker
|
2090 | };
|
2091 | |
2092 |
|
2093 |
|
2094 |
|
2095 |
|
2096 |
|
2097 |
|
2098 | function is(x, y) {
|
2099 |
|
2100 | if (x === y) {
|
2101 |
|
2102 |
|
2103 | return x !== 0 || 1 / x === 1 / y;
|
2104 | } else {
|
2105 |
|
2106 | return x !== x && y !== y;
|
2107 | }
|
2108 | }
|
2109 |
|
2110 |
|
2111 | |
2112 |
|
2113 |
|
2114 |
|
2115 |
|
2116 |
|
2117 |
|
2118 |
|
2119 |
|
2120 | function PropTypeError(message) {
|
2121 | this.message = message;
|
2122 | this.stack = '';
|
2123 | }
|
2124 |
|
2125 |
|
2126 | PropTypeError.prototype = Error.prototype;
|
2127 |
|
2128 | function createChainableTypeChecker(validate) {
|
2129 | if (process.env.NODE_ENV !== 'production') {
|
2130 | var manualPropTypeCallCache = {};
|
2131 | var manualPropTypeWarningCount = 0;
|
2132 | }
|
2133 |
|
2134 | function checkType(isRequired, props, propName, componentName, location, propFullName, secret) {
|
2135 | componentName = componentName || ANONYMOUS;
|
2136 | propFullName = propFullName || propName;
|
2137 |
|
2138 | if (secret !== ReactPropTypesSecret_1) {
|
2139 | if (throwOnDirectAccess) {
|
2140 |
|
2141 | var err = new Error('Calling PropTypes validators directly is not supported by the `prop-types` package. ' + 'Use `PropTypes.checkPropTypes()` to call them. ' + 'Read more at http://fb.me/use-check-prop-types');
|
2142 | err.name = 'Invariant Violation';
|
2143 | throw err;
|
2144 | } else if (process.env.NODE_ENV !== 'production' && typeof console !== 'undefined') {
|
2145 |
|
2146 | var cacheKey = componentName + ':' + propName;
|
2147 |
|
2148 | if (!manualPropTypeCallCache[cacheKey] &&
|
2149 | manualPropTypeWarningCount < 3) {
|
2150 | printWarning$1('You are manually calling a React.PropTypes validation ' + 'function for the `' + propFullName + '` prop on `' + componentName + '`. This is deprecated ' + 'and will throw in the standalone `prop-types` package. ' + 'You may be seeing this warning due to a third-party PropTypes ' + 'library. See https://fb.me/react-warning-dont-call-proptypes ' + 'for details.');
|
2151 | manualPropTypeCallCache[cacheKey] = true;
|
2152 | manualPropTypeWarningCount++;
|
2153 | }
|
2154 | }
|
2155 | }
|
2156 |
|
2157 | if (props[propName] == null) {
|
2158 | if (isRequired) {
|
2159 | if (props[propName] === null) {
|
2160 | return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required ' + ('in `' + componentName + '`, but its value is `null`.'));
|
2161 | }
|
2162 |
|
2163 | return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required in ' + ('`' + componentName + '`, but its value is `undefined`.'));
|
2164 | }
|
2165 |
|
2166 | return null;
|
2167 | } else {
|
2168 | return validate(props, propName, componentName, location, propFullName);
|
2169 | }
|
2170 | }
|
2171 |
|
2172 | var chainedCheckType = checkType.bind(null, false);
|
2173 | chainedCheckType.isRequired = checkType.bind(null, true);
|
2174 | return chainedCheckType;
|
2175 | }
|
2176 |
|
2177 | function createPrimitiveTypeChecker(expectedType) {
|
2178 | function validate(props, propName, componentName, location, propFullName, secret) {
|
2179 | var propValue = props[propName];
|
2180 | var propType = getPropType(propValue);
|
2181 |
|
2182 | if (propType !== expectedType) {
|
2183 |
|
2184 |
|
2185 |
|
2186 | var preciseType = getPreciseType(propValue);
|
2187 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.'));
|
2188 | }
|
2189 |
|
2190 | return null;
|
2191 | }
|
2192 |
|
2193 | return createChainableTypeChecker(validate);
|
2194 | }
|
2195 |
|
2196 | function createAnyTypeChecker() {
|
2197 | return createChainableTypeChecker(emptyFunctionThatReturnsNull);
|
2198 | }
|
2199 |
|
2200 | function createArrayOfTypeChecker(typeChecker) {
|
2201 | function validate(props, propName, componentName, location, propFullName) {
|
2202 | if (typeof typeChecker !== 'function') {
|
2203 | return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside arrayOf.');
|
2204 | }
|
2205 |
|
2206 | var propValue = props[propName];
|
2207 |
|
2208 | if (!Array.isArray(propValue)) {
|
2209 | var propType = getPropType(propValue);
|
2210 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an array.'));
|
2211 | }
|
2212 |
|
2213 | for (var i = 0; i < propValue.length; i++) {
|
2214 | var error = typeChecker(propValue, i, componentName, location, propFullName + '[' + i + ']', ReactPropTypesSecret_1);
|
2215 |
|
2216 | if (error instanceof Error) {
|
2217 | return error;
|
2218 | }
|
2219 | }
|
2220 |
|
2221 | return null;
|
2222 | }
|
2223 |
|
2224 | return createChainableTypeChecker(validate);
|
2225 | }
|
2226 |
|
2227 | function createElementTypeChecker() {
|
2228 | function validate(props, propName, componentName, location, propFullName) {
|
2229 | var propValue = props[propName];
|
2230 |
|
2231 | if (!isValidElement(propValue)) {
|
2232 | var propType = getPropType(propValue);
|
2233 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement.'));
|
2234 | }
|
2235 |
|
2236 | return null;
|
2237 | }
|
2238 |
|
2239 | return createChainableTypeChecker(validate);
|
2240 | }
|
2241 |
|
2242 | function createElementTypeTypeChecker() {
|
2243 | function validate(props, propName, componentName, location, propFullName) {
|
2244 | var propValue = props[propName];
|
2245 |
|
2246 | if (!reactIs.isValidElementType(propValue)) {
|
2247 | var propType = getPropType(propValue);
|
2248 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement type.'));
|
2249 | }
|
2250 |
|
2251 | return null;
|
2252 | }
|
2253 |
|
2254 | return createChainableTypeChecker(validate);
|
2255 | }
|
2256 |
|
2257 | function createInstanceTypeChecker(expectedClass) {
|
2258 | function validate(props, propName, componentName, location, propFullName) {
|
2259 | if (!(props[propName] instanceof expectedClass)) {
|
2260 | var expectedClassName = expectedClass.name || ANONYMOUS;
|
2261 | var actualClassName = getClassName(props[propName]);
|
2262 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + actualClassName + '` supplied to `' + componentName + '`, expected ') + ('instance of `' + expectedClassName + '`.'));
|
2263 | }
|
2264 |
|
2265 | return null;
|
2266 | }
|
2267 |
|
2268 | return createChainableTypeChecker(validate);
|
2269 | }
|
2270 |
|
2271 | function createEnumTypeChecker(expectedValues) {
|
2272 | if (!Array.isArray(expectedValues)) {
|
2273 | if (process.env.NODE_ENV !== 'production') {
|
2274 | if (arguments.length > 1) {
|
2275 | printWarning$1('Invalid arguments supplied to oneOf, expected an array, got ' + arguments.length + ' arguments. ' + 'A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z]).');
|
2276 | } else {
|
2277 | printWarning$1('Invalid argument supplied to oneOf, expected an array.');
|
2278 | }
|
2279 | }
|
2280 |
|
2281 | return emptyFunctionThatReturnsNull;
|
2282 | }
|
2283 |
|
2284 | function validate(props, propName, componentName, location, propFullName) {
|
2285 | var propValue = props[propName];
|
2286 |
|
2287 | for (var i = 0; i < expectedValues.length; i++) {
|
2288 | if (is(propValue, expectedValues[i])) {
|
2289 | return null;
|
2290 | }
|
2291 | }
|
2292 |
|
2293 | var valuesString = JSON.stringify(expectedValues, function replacer(key, value) {
|
2294 | var type = getPreciseType(value);
|
2295 |
|
2296 | if (type === 'symbol') {
|
2297 | return String(value);
|
2298 | }
|
2299 |
|
2300 | return value;
|
2301 | });
|
2302 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of value `' + String(propValue) + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.'));
|
2303 | }
|
2304 |
|
2305 | return createChainableTypeChecker(validate);
|
2306 | }
|
2307 |
|
2308 | function createObjectOfTypeChecker(typeChecker) {
|
2309 | function validate(props, propName, componentName, location, propFullName) {
|
2310 | if (typeof typeChecker !== 'function') {
|
2311 | return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside objectOf.');
|
2312 | }
|
2313 |
|
2314 | var propValue = props[propName];
|
2315 | var propType = getPropType(propValue);
|
2316 |
|
2317 | if (propType !== 'object') {
|
2318 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.'));
|
2319 | }
|
2320 |
|
2321 | for (var key in propValue) {
|
2322 | if (has$1(propValue, key)) {
|
2323 | var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret_1);
|
2324 |
|
2325 | if (error instanceof Error) {
|
2326 | return error;
|
2327 | }
|
2328 | }
|
2329 | }
|
2330 |
|
2331 | return null;
|
2332 | }
|
2333 |
|
2334 | return createChainableTypeChecker(validate);
|
2335 | }
|
2336 |
|
2337 | function createUnionTypeChecker(arrayOfTypeCheckers) {
|
2338 | if (!Array.isArray(arrayOfTypeCheckers)) {
|
2339 | process.env.NODE_ENV !== 'production' ? printWarning$1('Invalid argument supplied to oneOfType, expected an instance of array.') : void 0;
|
2340 | return emptyFunctionThatReturnsNull;
|
2341 | }
|
2342 |
|
2343 | for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
|
2344 | var checker = arrayOfTypeCheckers[i];
|
2345 |
|
2346 | if (typeof checker !== 'function') {
|
2347 | printWarning$1('Invalid argument supplied to oneOfType. Expected an array of check functions, but ' + 'received ' + getPostfixForTypeWarning(checker) + ' at index ' + i + '.');
|
2348 | return emptyFunctionThatReturnsNull;
|
2349 | }
|
2350 | }
|
2351 |
|
2352 | function validate(props, propName, componentName, location, propFullName) {
|
2353 | for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
|
2354 | var checker = arrayOfTypeCheckers[i];
|
2355 |
|
2356 | if (checker(props, propName, componentName, location, propFullName, ReactPropTypesSecret_1) == null) {
|
2357 | return null;
|
2358 | }
|
2359 | }
|
2360 |
|
2361 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`.'));
|
2362 | }
|
2363 |
|
2364 | return createChainableTypeChecker(validate);
|
2365 | }
|
2366 |
|
2367 | function createNodeChecker() {
|
2368 | function validate(props, propName, componentName, location, propFullName) {
|
2369 | if (!isNode(props[propName])) {
|
2370 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a ReactNode.'));
|
2371 | }
|
2372 |
|
2373 | return null;
|
2374 | }
|
2375 |
|
2376 | return createChainableTypeChecker(validate);
|
2377 | }
|
2378 |
|
2379 | function createShapeTypeChecker(shapeTypes) {
|
2380 | function validate(props, propName, componentName, location, propFullName) {
|
2381 | var propValue = props[propName];
|
2382 | var propType = getPropType(propValue);
|
2383 |
|
2384 | if (propType !== 'object') {
|
2385 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
|
2386 | }
|
2387 |
|
2388 | for (var key in shapeTypes) {
|
2389 | var checker = shapeTypes[key];
|
2390 |
|
2391 | if (!checker) {
|
2392 | continue;
|
2393 | }
|
2394 |
|
2395 | var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret_1);
|
2396 |
|
2397 | if (error) {
|
2398 | return error;
|
2399 | }
|
2400 | }
|
2401 |
|
2402 | return null;
|
2403 | }
|
2404 |
|
2405 | return createChainableTypeChecker(validate);
|
2406 | }
|
2407 |
|
2408 | function createStrictShapeTypeChecker(shapeTypes) {
|
2409 | function validate(props, propName, componentName, location, propFullName) {
|
2410 | var propValue = props[propName];
|
2411 | var propType = getPropType(propValue);
|
2412 |
|
2413 | if (propType !== 'object') {
|
2414 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
|
2415 | }
|
2416 |
|
2417 |
|
2418 |
|
2419 | var allKeys = objectAssign({}, props[propName], shapeTypes);
|
2420 |
|
2421 | for (var key in allKeys) {
|
2422 | var checker = shapeTypes[key];
|
2423 |
|
2424 | if (!checker) {
|
2425 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` key `' + key + '` supplied to `' + componentName + '`.' + '\nBad object: ' + JSON.stringify(props[propName], null, ' ') + '\nValid keys: ' + JSON.stringify(Object.keys(shapeTypes), null, ' '));
|
2426 | }
|
2427 |
|
2428 | var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret_1);
|
2429 |
|
2430 | if (error) {
|
2431 | return error;
|
2432 | }
|
2433 | }
|
2434 |
|
2435 | return null;
|
2436 | }
|
2437 |
|
2438 | return createChainableTypeChecker(validate);
|
2439 | }
|
2440 |
|
2441 | function isNode(propValue) {
|
2442 | switch (_typeof(propValue)) {
|
2443 | case 'number':
|
2444 | case 'string':
|
2445 | case 'undefined':
|
2446 | return true;
|
2447 |
|
2448 | case 'boolean':
|
2449 | return !propValue;
|
2450 |
|
2451 | case 'object':
|
2452 | if (Array.isArray(propValue)) {
|
2453 | return propValue.every(isNode);
|
2454 | }
|
2455 |
|
2456 | if (propValue === null || isValidElement(propValue)) {
|
2457 | return true;
|
2458 | }
|
2459 |
|
2460 | var iteratorFn = getIteratorFn(propValue);
|
2461 |
|
2462 | if (iteratorFn) {
|
2463 | var iterator = iteratorFn.call(propValue);
|
2464 | var step;
|
2465 |
|
2466 | if (iteratorFn !== propValue.entries) {
|
2467 | while (!(step = iterator.next()).done) {
|
2468 | if (!isNode(step.value)) {
|
2469 | return false;
|
2470 | }
|
2471 | }
|
2472 | } else {
|
2473 |
|
2474 | while (!(step = iterator.next()).done) {
|
2475 | var entry = step.value;
|
2476 |
|
2477 | if (entry) {
|
2478 | if (!isNode(entry[1])) {
|
2479 | return false;
|
2480 | }
|
2481 | }
|
2482 | }
|
2483 | }
|
2484 | } else {
|
2485 | return false;
|
2486 | }
|
2487 |
|
2488 | return true;
|
2489 |
|
2490 | default:
|
2491 | return false;
|
2492 | }
|
2493 | }
|
2494 |
|
2495 | function isSymbol(propType, propValue) {
|
2496 |
|
2497 | if (propType === 'symbol') {
|
2498 | return true;
|
2499 | }
|
2500 |
|
2501 |
|
2502 | if (!propValue) {
|
2503 | return false;
|
2504 | }
|
2505 |
|
2506 |
|
2507 | if (propValue['@@toStringTag'] === 'Symbol') {
|
2508 | return true;
|
2509 | }
|
2510 |
|
2511 |
|
2512 | if (typeof Symbol === 'function' && propValue instanceof Symbol) {
|
2513 | return true;
|
2514 | }
|
2515 |
|
2516 | return false;
|
2517 | }
|
2518 |
|
2519 |
|
2520 | function getPropType(propValue) {
|
2521 | var propType = _typeof(propValue);
|
2522 |
|
2523 | if (Array.isArray(propValue)) {
|
2524 | return 'array';
|
2525 | }
|
2526 |
|
2527 | if (propValue instanceof RegExp) {
|
2528 |
|
2529 |
|
2530 |
|
2531 | return 'object';
|
2532 | }
|
2533 |
|
2534 | if (isSymbol(propType, propValue)) {
|
2535 | return 'symbol';
|
2536 | }
|
2537 |
|
2538 | return propType;
|
2539 | }
|
2540 |
|
2541 |
|
2542 |
|
2543 | function getPreciseType(propValue) {
|
2544 | if (typeof propValue === 'undefined' || propValue === null) {
|
2545 | return '' + propValue;
|
2546 | }
|
2547 |
|
2548 | var propType = getPropType(propValue);
|
2549 |
|
2550 | if (propType === 'object') {
|
2551 | if (propValue instanceof Date) {
|
2552 | return 'date';
|
2553 | } else if (propValue instanceof RegExp) {
|
2554 | return 'regexp';
|
2555 | }
|
2556 | }
|
2557 |
|
2558 | return propType;
|
2559 | }
|
2560 |
|
2561 |
|
2562 |
|
2563 | function getPostfixForTypeWarning(value) {
|
2564 | var type = getPreciseType(value);
|
2565 |
|
2566 | switch (type) {
|
2567 | case 'array':
|
2568 | case 'object':
|
2569 | return 'an ' + type;
|
2570 |
|
2571 | case 'boolean':
|
2572 | case 'date':
|
2573 | case 'regexp':
|
2574 | return 'a ' + type;
|
2575 |
|
2576 | default:
|
2577 | return type;
|
2578 | }
|
2579 | }
|
2580 |
|
2581 |
|
2582 | function getClassName(propValue) {
|
2583 | if (!propValue.constructor || !propValue.constructor.name) {
|
2584 | return ANONYMOUS;
|
2585 | }
|
2586 |
|
2587 | return propValue.constructor.name;
|
2588 | }
|
2589 |
|
2590 | ReactPropTypes.checkPropTypes = checkPropTypes_1;
|
2591 | ReactPropTypes.resetWarningCache = checkPropTypes_1.resetWarningCache;
|
2592 | ReactPropTypes.PropTypes = ReactPropTypes;
|
2593 | return ReactPropTypes;
|
2594 | };
|
2595 |
|
2596 | function emptyFunction() {}
|
2597 |
|
2598 | function emptyFunctionWithReset() {}
|
2599 |
|
2600 | emptyFunctionWithReset.resetWarningCache = emptyFunction;
|
2601 |
|
2602 | var factoryWithThrowingShims = function factoryWithThrowingShims() {
|
2603 | function shim(props, propName, componentName, location, propFullName, secret) {
|
2604 | if (secret === ReactPropTypesSecret_1) {
|
2605 |
|
2606 | return;
|
2607 | }
|
2608 |
|
2609 | var err = new Error('Calling PropTypes validators directly is not supported by the `prop-types` package. ' + 'Use PropTypes.checkPropTypes() to call them. ' + 'Read more at http://fb.me/use-check-prop-types');
|
2610 | err.name = 'Invariant Violation';
|
2611 | throw err;
|
2612 | }
|
2613 | shim.isRequired = shim;
|
2614 |
|
2615 | function getShim() {
|
2616 | return shim;
|
2617 | }
|
2618 |
|
2619 |
|
2620 | var ReactPropTypes = {
|
2621 | array: shim,
|
2622 | bool: shim,
|
2623 | func: shim,
|
2624 | number: shim,
|
2625 | object: shim,
|
2626 | string: shim,
|
2627 | symbol: shim,
|
2628 | any: shim,
|
2629 | arrayOf: getShim,
|
2630 | element: shim,
|
2631 | elementType: shim,
|
2632 | instanceOf: getShim,
|
2633 | node: shim,
|
2634 | objectOf: getShim,
|
2635 | oneOf: getShim,
|
2636 | oneOfType: getShim,
|
2637 | shape: getShim,
|
2638 | exact: getShim,
|
2639 | checkPropTypes: emptyFunctionWithReset,
|
2640 | resetWarningCache: emptyFunction
|
2641 | };
|
2642 | ReactPropTypes.PropTypes = ReactPropTypes;
|
2643 | return ReactPropTypes;
|
2644 | };
|
2645 |
|
2646 | var propTypes = createCommonjsModule(function (module) {
|
2647 | |
2648 |
|
2649 |
|
2650 |
|
2651 |
|
2652 |
|
2653 | if (process.env.NODE_ENV !== 'production') {
|
2654 | var ReactIs = reactIs;
|
2655 |
|
2656 |
|
2657 | var throwOnDirectAccess = true;
|
2658 | module.exports = factoryWithTypeCheckers(ReactIs.isElement, throwOnDirectAccess);
|
2659 | } else {
|
2660 |
|
2661 |
|
2662 | module.exports = factoryWithThrowingShims();
|
2663 | }
|
2664 | });
|
2665 |
|
2666 | var isDEV = typeof process === 'undefined' || !process.env || process.env.NODE_ENV !== 'production';
|
2667 |
|
2668 | function hasNewLifecycle(component) {
|
2669 | var getDerivedStateFromProps = component.constructor.getDerivedStateFromProps,
|
2670 | getSnapshotBeforeUpdate = component.getSnapshotBeforeUpdate;
|
2671 | return isFunction(getDerivedStateFromProps) || isFunction(getSnapshotBeforeUpdate);
|
2672 | }
|
2673 |
|
2674 | function callGetDerivedStateFromProps(component, props, state) {
|
2675 | var getDerivedStateFromProps = component.constructor.getDerivedStateFromProps;
|
2676 | var newState;
|
2677 |
|
2678 | if (isFunction(getDerivedStateFromProps)) {
|
2679 | var partialState = getDerivedStateFromProps(props, state);
|
2680 |
|
2681 | if (!isUndefined(partialState)) {
|
2682 | newState = Object.assign({}, state, partialState);
|
2683 | } else {
|
2684 | console.warn('getDerivedStateFromProps 没有返回任何内容,这个生命周期必须返回 null 或一个新对象。');
|
2685 | }
|
2686 | }
|
2687 |
|
2688 | return newState;
|
2689 | }
|
2690 |
|
2691 | function callGetSnapshotBeforeUpdate(component, props, state) {
|
2692 | var getSnapshotBeforeUpdate = component.getSnapshotBeforeUpdate;
|
2693 | var snapshot;
|
2694 |
|
2695 | if (isFunction(getSnapshotBeforeUpdate)) {
|
2696 | snapshot = getSnapshotBeforeUpdate.call(component, props, state);
|
2697 | }
|
2698 |
|
2699 | return snapshot;
|
2700 | }
|
2701 |
|
2702 | function updateComponent(component) {
|
2703 | var props = component.props,
|
2704 | __propTypes = component.__propTypes;
|
2705 |
|
2706 | if (isDEV && __propTypes) {
|
2707 | var componentName = component.constructor.name;
|
2708 |
|
2709 | if (isUndefined(componentName)) {
|
2710 | var names = component.constructor.toString().match(/^function\s*([^\s(]+)/);
|
2711 | componentName = isArray(names) ? names[0] : 'Component';
|
2712 | }
|
2713 |
|
2714 | propTypes.checkPropTypes(__propTypes, props, 'prop', componentName);
|
2715 | }
|
2716 |
|
2717 | var prevProps = component.prevProps || props;
|
2718 | component.props = prevProps;
|
2719 |
|
2720 | if (component.__mounted && component._unsafeCallUpdate === true && !hasNewLifecycle(component) && component.componentWillReceiveProps) {
|
2721 | component._disable = true;
|
2722 | component.componentWillReceiveProps(props);
|
2723 | component._disable = false;
|
2724 | }
|
2725 |
|
2726 | var state = component.getState();
|
2727 | var prevState = component.prevState || state;
|
2728 | var stateFromProps = callGetDerivedStateFromProps(component, props, state);
|
2729 |
|
2730 | if (!isUndefined(stateFromProps)) {
|
2731 | state = stateFromProps;
|
2732 | }
|
2733 |
|
2734 | var skip = false;
|
2735 |
|
2736 | if (component.__mounted) {
|
2737 | if (typeof component.shouldComponentUpdate === 'function' && !component._isForceUpdate && component.shouldComponentUpdate(props, state) === false) {
|
2738 | skip = true;
|
2739 | } else if (!hasNewLifecycle(component) && isFunction(component.componentWillUpdate)) {
|
2740 | component.componentWillUpdate(props, state);
|
2741 | }
|
2742 | }
|
2743 |
|
2744 | component.props = props;
|
2745 | component.state = state;
|
2746 | component._dirty = false;
|
2747 | component._isForceUpdate = false;
|
2748 |
|
2749 | if (!skip) {
|
2750 | doUpdate(component, prevProps, prevState);
|
2751 | }
|
2752 |
|
2753 | component.prevProps = component.props;
|
2754 | component.prevState = component.state;
|
2755 | }
|
2756 |
|
2757 | function injectContextType(component) {
|
2758 | var ctxType = component.constructor.contextType;
|
2759 |
|
2760 | if (ctxType) {
|
2761 | var context = ctxType.context;
|
2762 | var emitter = context.emitter;
|
2763 |
|
2764 | if (emitter === null) {
|
2765 | component.context = context._defaultValue;
|
2766 | return;
|
2767 | }
|
2768 |
|
2769 | if (!component._hasContext) {
|
2770 | component._hasContext = true;
|
2771 | emitter.on(function (_) {
|
2772 | return enqueueRender(component);
|
2773 | });
|
2774 | }
|
2775 |
|
2776 | component.context = emitter.value;
|
2777 | }
|
2778 | }
|
2779 |
|
2780 | function mountComponent(component) {
|
2781 | var props = component.props;
|
2782 |
|
2783 | if (!component.__componentWillMountTriggered) {
|
2784 | component._constructor && component._constructor(props);
|
2785 | }
|
2786 |
|
2787 | var newState = callGetDerivedStateFromProps(component, props, component.state);
|
2788 |
|
2789 | if (!isUndefined(newState)) {
|
2790 | component.state = newState;
|
2791 | }
|
2792 |
|
2793 | component._dirty = false;
|
2794 | component._disable = false;
|
2795 | component._isForceUpdate = false;
|
2796 |
|
2797 | if (!component.__componentWillMountTriggered) {
|
2798 | component.__componentWillMountTriggered = true;
|
2799 |
|
2800 | if (!hasNewLifecycle(component)) {
|
2801 | componentTrigger(component, 'componentWillMount');
|
2802 | }
|
2803 | }
|
2804 |
|
2805 | doUpdate(component, props, component.state);
|
2806 | component.prevProps = component.props;
|
2807 | component.prevState = component.state;
|
2808 | }
|
2809 |
|
2810 | function doUpdate(component, prevProps, prevState) {
|
2811 | var state = component.state,
|
2812 | _component$props = component.props,
|
2813 | props = _component$props === void 0 ? {} : _component$props;
|
2814 | var data = state || {};
|
2815 |
|
2816 | if (component._createData) {
|
2817 | if (component.__isReady) {
|
2818 | injectContextType(component);
|
2819 | taro.Current.current = component;
|
2820 | taro.Current.index = 0;
|
2821 | taro.invokeEffects(component, true);
|
2822 | }
|
2823 |
|
2824 | data = component._createData(state, props) || data;
|
2825 |
|
2826 | if (component.__isReady) {
|
2827 | taro.Current.current = null;
|
2828 | }
|
2829 | }
|
2830 |
|
2831 | data = Object.assign({}, props, data);
|
2832 |
|
2833 | if (component.$usedState && component.$usedState.length) {
|
2834 | var _data = {};
|
2835 | component.$usedState.forEach(function (key) {
|
2836 | var val = taro.internal_safe_get(data, key);
|
2837 |
|
2838 | if (typeof val === 'undefined') {
|
2839 | return;
|
2840 | }
|
2841 |
|
2842 | if (_typeof(val) === 'object') {
|
2843 | if (isEmptyObject(val)) return taro.internal_safe_set(_data, key, val);
|
2844 | val = shakeFnFromObject(val);
|
2845 |
|
2846 | if (!isEmptyObject(val)) taro.internal_safe_set(_data, key, val);
|
2847 | } else {
|
2848 | taro.internal_safe_set(_data, key, val);
|
2849 | }
|
2850 | });
|
2851 | data = _data;
|
2852 | }
|
2853 |
|
2854 | data['$taroCompReady'] = true;
|
2855 | var dataDiff = diffObjToPath(data, component.$scope.data);
|
2856 | var __mounted = component.__mounted;
|
2857 | var snapshot;
|
2858 |
|
2859 | if (__mounted) {
|
2860 | snapshot = callGetSnapshotBeforeUpdate(component, prevProps, prevState);
|
2861 | }
|
2862 |
|
2863 |
|
2864 | var cbs = [];
|
2865 |
|
2866 | if (component._pendingCallbacks && component._pendingCallbacks.length) {
|
2867 | cbs = component._pendingCallbacks;
|
2868 | component._pendingCallbacks = [];
|
2869 | }
|
2870 |
|
2871 | var cb = function cb() {
|
2872 | taro.invokeEffects(component);
|
2873 |
|
2874 | if (component.__mounted) {
|
2875 | if (component['$$refs'] && component['$$refs'].length > 0) {
|
2876 | component['$$refs'].forEach(function (ref) {
|
2877 |
|
2878 | if (ref.type !== 'component') return;
|
2879 | component.$scope.selectComponent("#".concat(ref.id), function (target) {
|
2880 | target = target ? target.$component || target : null;
|
2881 | var prevRef = ref.target;
|
2882 |
|
2883 | if (target !== prevRef) {
|
2884 | taro.commitAttachRef(ref, target, component, component.refs);
|
2885 | ref.target = target;
|
2886 | }
|
2887 | });
|
2888 | });
|
2889 | }
|
2890 |
|
2891 | if (component['$$hasLoopRef']) {
|
2892 | taro.Current.current = component;
|
2893 | taro.Current.index = 0;
|
2894 | component._disableEffect = true;
|
2895 |
|
2896 | component._createData(component.state, component.props, true);
|
2897 |
|
2898 | component._disableEffect = false;
|
2899 | taro.Current.current = null;
|
2900 | }
|
2901 |
|
2902 | if (typeof component.componentDidUpdate === 'function') {
|
2903 | component.componentDidUpdate(prevProps, prevState, snapshot);
|
2904 | }
|
2905 | }
|
2906 |
|
2907 | if (cbs.length) {
|
2908 | var i = cbs.length;
|
2909 |
|
2910 | while (--i >= 0) {
|
2911 | typeof cbs[i] === 'function' && cbs[i].call(component);
|
2912 | }
|
2913 | }
|
2914 | };
|
2915 |
|
2916 | if (Object.keys(dataDiff).length === 0) {
|
2917 | cb();
|
2918 | taro.invokeEffects(component);
|
2919 | } else {
|
2920 | component.$scope.setData(dataDiff, cb);
|
2921 | }
|
2922 | }
|
2923 |
|
2924 | var items = [];
|
2925 | function enqueueRender(component) {
|
2926 | var isForceUpdate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
2927 |
|
2928 | component._isForceUpdate = isForceUpdate;
|
2929 |
|
2930 | if (!component._dirty && (component._dirty = true) && items.push(component) === 1) {
|
2931 | nextTick(function () {
|
2932 | rerender();
|
2933 | });
|
2934 | }
|
2935 | }
|
2936 | function rerender() {
|
2937 | var p;
|
2938 | var list = items;
|
2939 | items = [];
|
2940 |
|
2941 | while (p = list.pop()) {
|
2942 | if (p._dirty) {
|
2943 | updateComponent(p, true);
|
2944 | }
|
2945 | }
|
2946 | }
|
2947 |
|
2948 |
|
2949 |
|
2950 |
|
2951 |
|
2952 |
|
2953 | var PRELOAD_DATA_KEY$1 = 'preload';
|
2954 |
|
2955 | var BaseComponent = function () {
|
2956 |
|
2957 |
|
2958 |
|
2959 |
|
2960 | function BaseComponent() {
|
2961 | var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
2962 | var isPage = arguments.length > 1 ? arguments[1] : undefined;
|
2963 |
|
2964 | _classCallCheck(this, BaseComponent);
|
2965 |
|
2966 | _defineProperty(this, "__computed", {});
|
2967 |
|
2968 | _defineProperty(this, "__props", {});
|
2969 |
|
2970 | _defineProperty(this, "__isReady", false);
|
2971 |
|
2972 | _defineProperty(this, "__mounted", false);
|
2973 |
|
2974 | _defineProperty(this, "nextProps", {});
|
2975 |
|
2976 | _defineProperty(this, "_dirty", true);
|
2977 |
|
2978 | _defineProperty(this, "_disable", true);
|
2979 |
|
2980 | _defineProperty(this, "_isForceUpdate", false);
|
2981 |
|
2982 | _defineProperty(this, "_pendingStates", []);
|
2983 |
|
2984 | _defineProperty(this, "_pendingCallbacks", []);
|
2985 |
|
2986 | _defineProperty(this, "$componentType", '');
|
2987 |
|
2988 | _defineProperty(this, "refs", {});
|
2989 |
|
2990 | _defineProperty(this, "$router", {
|
2991 | params: {},
|
2992 | path: ''
|
2993 | });
|
2994 |
|
2995 | _defineProperty(this, "_afterScheduleEffect", false);
|
2996 |
|
2997 | _defineProperty(this, "_disableEffect", false);
|
2998 |
|
2999 | _defineProperty(this, "hooks", []);
|
3000 |
|
3001 | _defineProperty(this, "effects", []);
|
3002 |
|
3003 | _defineProperty(this, "layoutEffects", []);
|
3004 |
|
3005 | this.state = {};
|
3006 | this.props = props;
|
3007 | this.$componentType = isPage ? 'PAGE' : 'COMPONENT';
|
3008 | this.$prefix = genCompPrefix();
|
3009 | this.isTaroComponent = this.$componentType && this.$router && this._pendingStates;
|
3010 | }
|
3011 |
|
3012 | _createClass(BaseComponent, [{
|
3013 | key: "_constructor",
|
3014 | value: function _constructor(props) {
|
3015 | this.props = props || {};
|
3016 | }
|
3017 | }, {
|
3018 | key: "_init",
|
3019 | value: function _init(scope) {
|
3020 | this.$scope = scope;
|
3021 | }
|
3022 | }, {
|
3023 | key: "setState",
|
3024 | value: function setState(state, callback) {
|
3025 | if (state) {
|
3026 | (this._pendingStates = this._pendingStates || []).push(state);
|
3027 | }
|
3028 |
|
3029 | if (typeof callback === 'function') {
|
3030 | (this._pendingCallbacks = this._pendingCallbacks || []).push(callback);
|
3031 | }
|
3032 |
|
3033 | if (!this._disable) {
|
3034 | enqueueRender(this, callback === taro.internal_force_update);
|
3035 | }
|
3036 | }
|
3037 | }, {
|
3038 | key: "getState",
|
3039 | value: function getState() {
|
3040 | var _this = this;
|
3041 |
|
3042 | var _pendingStates = this._pendingStates,
|
3043 | state = this.state,
|
3044 | props = this.props;
|
3045 | var stateClone = Object.assign({}, state);
|
3046 | delete stateClone.__data;
|
3047 |
|
3048 | if (!_pendingStates.length) {
|
3049 | return stateClone;
|
3050 | }
|
3051 |
|
3052 | var queue = _pendingStates.concat();
|
3053 |
|
3054 | this._pendingStates.length = 0;
|
3055 | queue.forEach(function (nextState) {
|
3056 | if (typeof nextState === 'function') {
|
3057 | nextState = nextState.call(_this, stateClone, props);
|
3058 | }
|
3059 |
|
3060 | Object.assign(stateClone, nextState);
|
3061 | });
|
3062 | return stateClone;
|
3063 | }
|
3064 | }, {
|
3065 | key: "forceUpdate",
|
3066 | value: function forceUpdate(callback) {
|
3067 | if (typeof callback === 'function') {
|
3068 | (this._pendingCallbacks = this._pendingCallbacks || []).push(callback);
|
3069 | }
|
3070 |
|
3071 | this._isForceUpdate = true;
|
3072 | updateComponent(this);
|
3073 | }
|
3074 | }, {
|
3075 | key: "$preload",
|
3076 | value: function $preload(key, value) {
|
3077 | var preloadData = cacheDataGet(PRELOAD_DATA_KEY$1) || {};
|
3078 |
|
3079 | if (_typeof(key) === 'object') {
|
3080 | for (var k in key) {
|
3081 | preloadData[k] = key[k];
|
3082 | }
|
3083 | } else {
|
3084 | preloadData[key] = value;
|
3085 | }
|
3086 |
|
3087 | cacheDataSet(PRELOAD_DATA_KEY$1, preloadData);
|
3088 | }
|
3089 |
|
3090 | }, {
|
3091 | key: "__triggerPropsFn",
|
3092 | value: function __triggerPropsFn(key, args) {
|
3093 | var keyChain = key.split('.');
|
3094 | var reduxFnPrefix = '__event_';
|
3095 | var reduxFnName = reduxFnPrefix + keyChain.shift();
|
3096 |
|
3097 | if (reduxFnName in this) {
|
3098 | var scope = args.shift();
|
3099 | var fn;
|
3100 |
|
3101 | if (keyChain.length > 0) {
|
3102 | fn = taro.internal_safe_get(this[reduxFnName], keyChain.join('.'));
|
3103 | } else {
|
3104 | fn = this[reduxFnName];
|
3105 | }
|
3106 |
|
3107 | fn.apply(scope, args);
|
3108 | } else {
|
3109 |
|
3110 | var keyLower = key.toLocaleLowerCase();
|
3111 | var payload = {
|
3112 | __isCustomEvt: true,
|
3113 | __arguments: args
|
3114 | };
|
3115 | var detail = this.$scope.dataset;
|
3116 |
|
3117 | if (Object.keys(detail).length) {
|
3118 | payload.__detail = detail;
|
3119 | }
|
3120 |
|
3121 | this.$scope.triggerEvent(keyLower, payload);
|
3122 | }
|
3123 | }
|
3124 | }]);
|
3125 |
|
3126 | return BaseComponent;
|
3127 | }();
|
3128 |
|
3129 | var PureComponent = function (_Component) {
|
3130 | _inherits(PureComponent, _Component);
|
3131 |
|
3132 | var _super = _createSuper(PureComponent);
|
3133 |
|
3134 | function PureComponent() {
|
3135 | var _this;
|
3136 |
|
3137 | _classCallCheck(this, PureComponent);
|
3138 |
|
3139 | for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
3140 | args[_key] = arguments[_key];
|
3141 | }
|
3142 |
|
3143 | _this = _super.call.apply(_super, [this].concat(args));
|
3144 |
|
3145 | _defineProperty(_assertThisInitialized(_this), "isPureComponent", true);
|
3146 |
|
3147 | return _this;
|
3148 | }
|
3149 |
|
3150 | _createClass(PureComponent, [{
|
3151 | key: "shouldComponentUpdate",
|
3152 | value: function shouldComponentUpdate(nextProps, nextState) {
|
3153 | return !shallowEqual(this.props, nextProps) || !shallowEqual(this.state, nextState);
|
3154 | }
|
3155 | }]);
|
3156 |
|
3157 | return PureComponent;
|
3158 | }(BaseComponent);
|
3159 |
|
3160 | function createApp(AppClass) {
|
3161 | var app = new AppClass();
|
3162 | var weappAppConf = {
|
3163 | onLaunch: function onLaunch(options) {
|
3164 | app.$app = this;
|
3165 | app.$app.$router = app.$router = {
|
3166 | params: options
|
3167 | };
|
3168 |
|
3169 | if (app.componentWillMount) {
|
3170 | app.componentWillMount();
|
3171 | }
|
3172 |
|
3173 | if (app.componentDidMount) {
|
3174 | app.componentDidMount();
|
3175 | }
|
3176 | },
|
3177 | onShow: function onShow(options) {
|
3178 | Object.assign(app.$router.params, options);
|
3179 |
|
3180 | if (app.componentDidShow) {
|
3181 | app.componentDidShow();
|
3182 | }
|
3183 | },
|
3184 | onHide: function onHide() {
|
3185 | if (app.componentDidHide) {
|
3186 | app.componentDidHide();
|
3187 | }
|
3188 | },
|
3189 | onError: function onError(err) {
|
3190 | if (app.componentDidCatchError) {
|
3191 | app.componentDidCatchError(err);
|
3192 | }
|
3193 | },
|
3194 | onPageNotFound: function onPageNotFound(obj) {
|
3195 | if (app.componentDidNotFound) {
|
3196 | app.componentDidNotFound(obj);
|
3197 | }
|
3198 | }
|
3199 | };
|
3200 | return Object.assign(weappAppConf, app);
|
3201 | }
|
3202 |
|
3203 | var RequestQueue = {
|
3204 | MAX_REQUEST: 5,
|
3205 | queue: [],
|
3206 | pendingQueue: [],
|
3207 | request: function request(options) {
|
3208 | this.queue.push(options);
|
3209 | return this.run();
|
3210 | },
|
3211 | run: function run() {
|
3212 | var _this = this;
|
3213 |
|
3214 | if (!this.queue.length) return;
|
3215 |
|
3216 | var _loop = function _loop() {
|
3217 | var options = _this.queue.shift();
|
3218 |
|
3219 | var successFn = options.success;
|
3220 | var failFn = options.fail;
|
3221 |
|
3222 | options.success = function () {
|
3223 | _this.pendingQueue = _this.pendingQueue.filter(function (item) {
|
3224 | return item !== options;
|
3225 | });
|
3226 |
|
3227 | _this.run();
|
3228 |
|
3229 | for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
3230 | args[_key] = arguments[_key];
|
3231 | }
|
3232 |
|
3233 | successFn && successFn.apply(options, args);
|
3234 | };
|
3235 |
|
3236 | options.fail = function () {
|
3237 | _this.pendingQueue = _this.pendingQueue.filter(function (item) {
|
3238 | return item !== options;
|
3239 | });
|
3240 |
|
3241 | _this.run();
|
3242 |
|
3243 | for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
3244 | args[_key2] = arguments[_key2];
|
3245 | }
|
3246 |
|
3247 | failFn && failFn.apply(options, args);
|
3248 | };
|
3249 |
|
3250 | _this.pendingQueue.push(options);
|
3251 |
|
3252 | return {
|
3253 | v: tt.request(options)
|
3254 | };
|
3255 | };
|
3256 |
|
3257 | while (this.pendingQueue.length < this.MAX_REQUEST) {
|
3258 | var _ret = _loop();
|
3259 |
|
3260 | if (_typeof(_ret) === "object") return _ret.v;
|
3261 | }
|
3262 | }
|
3263 | };
|
3264 |
|
3265 | function taroInterceptor(chain) {
|
3266 | return request(chain.requestParams);
|
3267 | }
|
3268 |
|
3269 | var link = new taro.Link(taroInterceptor);
|
3270 |
|
3271 | function request(options) {
|
3272 | options = options || {};
|
3273 |
|
3274 | if (typeof options === 'string') {
|
3275 | options = {
|
3276 | url: options
|
3277 | };
|
3278 | }
|
3279 |
|
3280 | var originSuccess = options['success'];
|
3281 | var originFail = options['fail'];
|
3282 | var originComplete = options['complete'];
|
3283 | var requestTask;
|
3284 | var p = new Promise(function (resolve, reject) {
|
3285 | options['success'] = function (res) {
|
3286 | originSuccess && originSuccess(res);
|
3287 | resolve(res);
|
3288 | };
|
3289 |
|
3290 | options['fail'] = function (res) {
|
3291 | originFail && originFail(res);
|
3292 | reject(res);
|
3293 | };
|
3294 |
|
3295 | options['complete'] = function (res) {
|
3296 | originComplete && originComplete(res);
|
3297 | };
|
3298 |
|
3299 | requestTask = RequestQueue.request(options);
|
3300 | });
|
3301 |
|
3302 | p.abort = function (cb) {
|
3303 | cb && cb();
|
3304 |
|
3305 | if (requestTask) {
|
3306 | requestTask.abort();
|
3307 | }
|
3308 |
|
3309 | return p;
|
3310 | };
|
3311 |
|
3312 | return p;
|
3313 | }
|
3314 |
|
3315 | function processApis(taro$$1) {
|
3316 | var weApis = Object.assign({}, taro.onAndSyncApis, taro.noPromiseApis, taro.otherApis);
|
3317 | var preloadPrivateKey = '__preload_';
|
3318 | var preloadInitedComponent = '$preloadComponent';
|
3319 | Object.keys(weApis).forEach(function (key) {
|
3320 | if (!(key in tt)) {
|
3321 | taro$$1[key] = function () {
|
3322 | console.warn("\u5934\u6761\u5C0F\u7A0B\u5E8F\u6682\u4E0D\u652F\u6301 ".concat(key));
|
3323 | };
|
3324 |
|
3325 | return;
|
3326 | }
|
3327 |
|
3328 | if (!taro.onAndSyncApis[key] && !taro.noPromiseApis[key]) {
|
3329 | taro$$1[key] = function (options) {
|
3330 | for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
|
3331 | args[_key3 - 1] = arguments[_key3];
|
3332 | }
|
3333 |
|
3334 | options = options || {};
|
3335 | var task = null;
|
3336 | var obj = Object.assign({}, options);
|
3337 |
|
3338 | if (typeof options === 'string') {
|
3339 | if (args.length) {
|
3340 | var _tt;
|
3341 |
|
3342 | return (_tt = tt)[key].apply(_tt, [options].concat(args));
|
3343 | }
|
3344 |
|
3345 | return tt[key](options);
|
3346 | }
|
3347 |
|
3348 | if (key === 'navigateTo' || key === 'redirectTo') {
|
3349 | var url = obj['url'] ? obj['url'].replace(/^\//, '') : '';
|
3350 | if (url.indexOf('?') > -1) url = url.split('?')[0];
|
3351 | var Component = cacheDataGet(url);
|
3352 |
|
3353 | if (Component) {
|
3354 | var component = new Component();
|
3355 |
|
3356 | if (component.componentWillPreload) {
|
3357 | var cacheKey = getUniqueKey();
|
3358 | var MarkIndex = obj.url.indexOf('?');
|
3359 | var hasMark = MarkIndex > -1;
|
3360 | var urlQueryStr = hasMark ? obj.url.substring(MarkIndex + 1, obj.url.length) : '';
|
3361 | var params = queryToJson(urlQueryStr);
|
3362 | obj.url += (hasMark ? '&' : '?') + "".concat(preloadPrivateKey, "=").concat(cacheKey);
|
3363 | cacheDataSet(cacheKey, component.componentWillPreload(params));
|
3364 | cacheDataSet(preloadInitedComponent, component);
|
3365 | }
|
3366 | }
|
3367 | }
|
3368 |
|
3369 | var p = new Promise(function (resolve, reject) {
|
3370 | ['fail', 'success', 'complete'].forEach(function (k) {
|
3371 | obj[k] = function (res) {
|
3372 | options[k] && options[k](res);
|
3373 |
|
3374 | if (k === 'success') {
|
3375 | if (key === 'connectSocket') {
|
3376 | resolve(Promise.resolve().then(function () {
|
3377 | return Object.assign(task, res);
|
3378 | }));
|
3379 | } else {
|
3380 | resolve(res);
|
3381 | }
|
3382 | } else if (k === 'fail') {
|
3383 | reject(res);
|
3384 | }
|
3385 | };
|
3386 | });
|
3387 |
|
3388 | if (args.length) {
|
3389 | var _tt2;
|
3390 |
|
3391 | task = (_tt2 = tt)[key].apply(_tt2, [obj].concat(args));
|
3392 | } else {
|
3393 | task = tt[key](obj);
|
3394 | }
|
3395 | });
|
3396 |
|
3397 | if (key === 'uploadFile' || key === 'downloadFile') {
|
3398 | p.progress = function (cb) {
|
3399 | if (task) {
|
3400 | task.onProgressUpdate(cb);
|
3401 | }
|
3402 |
|
3403 | return p;
|
3404 | };
|
3405 |
|
3406 | p.abort = function (cb) {
|
3407 | cb && cb();
|
3408 |
|
3409 | if (task) {
|
3410 | task.abort();
|
3411 | }
|
3412 |
|
3413 | return p;
|
3414 | };
|
3415 | }
|
3416 |
|
3417 | return p;
|
3418 | };
|
3419 | } else {
|
3420 | taro$$1[key] = function () {
|
3421 | for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
|
3422 | args[_key4] = arguments[_key4];
|
3423 | }
|
3424 |
|
3425 | var argsLen = args.length;
|
3426 | var newArgs = args.concat();
|
3427 | var lastArg = newArgs[argsLen - 1];
|
3428 |
|
3429 | if (lastArg && lastArg.isTaroComponent && lastArg.$scope) {
|
3430 | newArgs.splice(argsLen - 1, 1, lastArg.$scope);
|
3431 | }
|
3432 |
|
3433 | return tt[key].apply(tt, newArgs);
|
3434 | };
|
3435 | }
|
3436 | });
|
3437 | }
|
3438 |
|
3439 | function pxTransform(size) {
|
3440 | var _ref = this.config || {},
|
3441 | _ref$designWidth = _ref.designWidth,
|
3442 | designWidth = _ref$designWidth === void 0 ? 750 : _ref$designWidth,
|
3443 | _ref$deviceRatio = _ref.deviceRatio,
|
3444 | deviceRatio = _ref$deviceRatio === void 0 ? {
|
3445 | '640': 2.34 / 2,
|
3446 | '750': 1,
|
3447 | '828': 1.81 / 2
|
3448 | } : _ref$deviceRatio;
|
3449 |
|
3450 | if (!(designWidth in deviceRatio)) {
|
3451 | throw new Error("deviceRatio \u914D\u7F6E\u4E2D\u4E0D\u5B58\u5728 ".concat(designWidth, " \u7684\u8BBE\u7F6E\uFF01"));
|
3452 | }
|
3453 |
|
3454 | return parseInt(size, 10) / deviceRatio[designWidth] + 'rpx';
|
3455 | }
|
3456 |
|
3457 | function initNativeApi(taro$$1) {
|
3458 | processApis(taro$$1);
|
3459 | taro$$1.request = link.request.bind(link);
|
3460 | taro$$1.addInterceptor = link.addInterceptor.bind(link);
|
3461 | taro$$1.cleanInterceptors = link.cleanInterceptors.bind(link);
|
3462 | taro$$1.getCurrentPages = getCurrentPages;
|
3463 | taro$$1.getApp = getApp;
|
3464 | taro$$1.initPxTransform = taro.initPxTransform.bind(taro$$1);
|
3465 | taro$$1.pxTransform = pxTransform.bind(taro$$1);
|
3466 | }
|
3467 |
|
3468 |
|
3469 | var Taro = {
|
3470 | Component: BaseComponent,
|
3471 | PureComponent: PureComponent,
|
3472 | createApp: createApp,
|
3473 | initNativeApi: initNativeApi,
|
3474 | Events: taro.Events,
|
3475 | eventCenter: taro.eventCenter,
|
3476 | getEnv: taro.getEnv,
|
3477 | createRef: taro.createRef,
|
3478 | render: taro.render,
|
3479 | ENV_TYPE: taro.ENV_TYPE,
|
3480 | internal_safe_get: taro.internal_safe_get,
|
3481 | internal_safe_set: taro.internal_safe_set,
|
3482 | internal_inline_style: taro.internal_inline_style,
|
3483 | createComponent: createComponent,
|
3484 | internal_get_original: taro.internal_get_original,
|
3485 | interceptors: taro.interceptors,
|
3486 | RefsArray: taro.RefsArray,
|
3487 | handleLoopRef: handleLoopRef,
|
3488 | propsManager: propsManager,
|
3489 | genCompid: genCompid,
|
3490 | useEffect: taro.useEffect,
|
3491 | useLayoutEffect: taro.useLayoutEffect,
|
3492 | useReducer: taro.useReducer,
|
3493 | useState: taro.useState,
|
3494 | useDidShow: taro.useDidShow,
|
3495 | useDidHide: taro.useDidHide,
|
3496 | usePullDownRefresh: taro.usePullDownRefresh,
|
3497 | useReachBottom: taro.useReachBottom,
|
3498 | usePageScroll: taro.usePageScroll,
|
3499 | useResize: taro.useResize,
|
3500 | useShareAppMessage: taro.useShareAppMessage,
|
3501 | useTabItemTap: taro.useTabItemTap,
|
3502 | useRouter: taro.useRouter,
|
3503 | useScope: taro.useScope,
|
3504 | useRef: taro.useRef,
|
3505 | useCallback: taro.useCallback,
|
3506 | useMemo: taro.useMemo,
|
3507 | useImperativeHandle: taro.useImperativeHandle,
|
3508 | useContext: taro.useContext,
|
3509 | createContext: taro.createContext,
|
3510 | memo: taro.memo,
|
3511 | shallowEqual: shallowEqual,
|
3512 | setIsUsingDiff: taro.setIsUsingDiff
|
3513 | };
|
3514 | initNativeApi(Taro);
|
3515 |
|
3516 | exports.Taro = Taro;
|
3517 | exports.default = Taro;
|
3518 |
|
3519 | Object.defineProperty(exports, '__esModule', { value: true });
|
3520 |
|
3521 | })));
|
3522 |
|