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