1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 | 'use strict';
|
11 |
|
12 |
|
13 |
|
14 | if (process.env.NODE_ENV !== "production") {
|
15 | (function() {
|
16 | 'use strict';
|
17 |
|
18 | Object.defineProperty(exports, '__esModule', { value: true });
|
19 |
|
20 | var React = require('react');
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 | function ReactError(error) {
|
30 | error.name = 'Invariant Violation';
|
31 | return error;
|
32 | }
|
33 |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 |
|
43 |
|
44 |
|
45 |
|
46 |
|
47 |
|
48 |
|
49 |
|
50 |
|
51 | var warningWithoutStack = function () {};
|
52 |
|
53 | {
|
54 | warningWithoutStack = function (condition, format) {
|
55 | for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
56 | args[_key - 2] = arguments[_key];
|
57 | }
|
58 |
|
59 | if (format === undefined) {
|
60 | throw new Error('`warningWithoutStack(condition, format, ...args)` requires a warning ' + 'message argument');
|
61 | }
|
62 |
|
63 | if (args.length > 8) {
|
64 |
|
65 | throw new Error('warningWithoutStack() currently supports at most 8 arguments.');
|
66 | }
|
67 |
|
68 | if (condition) {
|
69 | return;
|
70 | }
|
71 |
|
72 | if (typeof console !== 'undefined') {
|
73 | var argsWithFormat = args.map(function (item) {
|
74 | return '' + item;
|
75 | });
|
76 | argsWithFormat.unshift('Warning: ' + format);
|
77 |
|
78 |
|
79 | Function.prototype.apply.call(console.error, console, argsWithFormat);
|
80 | }
|
81 |
|
82 | try {
|
83 |
|
84 |
|
85 |
|
86 | var argIndex = 0;
|
87 | var message = 'Warning: ' + format.replace(/%s/g, function () {
|
88 | return args[argIndex++];
|
89 | });
|
90 | throw new Error(message);
|
91 | } catch (x) {}
|
92 | };
|
93 | }
|
94 |
|
95 | var warningWithoutStack$1 = warningWithoutStack;
|
96 |
|
97 |
|
98 |
|
99 |
|
100 |
|
101 |
|
102 |
|
103 |
|
104 |
|
105 |
|
106 |
|
107 |
|
108 |
|
109 |
|
110 |
|
111 |
|
112 |
|
113 | function get(key) {
|
114 | return key._reactInternalFiber;
|
115 | }
|
116 |
|
117 | var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
118 |
|
119 |
|
120 |
|
121 | if (!ReactSharedInternals.hasOwnProperty('ReactCurrentDispatcher')) {
|
122 | ReactSharedInternals.ReactCurrentDispatcher = {
|
123 | current: null
|
124 | };
|
125 | }
|
126 |
|
127 | if (!ReactSharedInternals.hasOwnProperty('ReactCurrentBatchConfig')) {
|
128 | ReactSharedInternals.ReactCurrentBatchConfig = {
|
129 | suspense: null
|
130 | };
|
131 | }
|
132 |
|
133 |
|
134 |
|
135 | var hasSymbol = typeof Symbol === 'function' && Symbol.for;
|
136 |
|
137 | var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;
|
138 | var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb;
|
139 | var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc;
|
140 | var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
|
141 | var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
|
142 | var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace;
|
143 |
|
144 |
|
145 |
|
146 |
|
147 | var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
|
148 | var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1;
|
149 | var REACT_SUSPENSE_LIST_TYPE = hasSymbol ? Symbol.for('react.suspense_list') : 0xead8;
|
150 | var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;
|
151 | var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4;
|
152 |
|
153 | {
|
154 |
|
155 | }
|
156 |
|
157 | var Resolved = 1;
|
158 |
|
159 | function refineResolvedLazyComponent(lazyComponent) {
|
160 | return lazyComponent._status === Resolved ? lazyComponent._result : null;
|
161 | }
|
162 |
|
163 | function getWrappedName(outerType, innerType, wrapperName) {
|
164 | var functionName = innerType.displayName || innerType.name || '';
|
165 | return outerType.displayName || (functionName !== '' ? wrapperName + "(" + functionName + ")" : wrapperName);
|
166 | }
|
167 |
|
168 | function getComponentName(type) {
|
169 | if (type == null) {
|
170 |
|
171 | return null;
|
172 | }
|
173 |
|
174 | {
|
175 | if (typeof type.tag === 'number') {
|
176 | warningWithoutStack$1(false, 'Received an unexpected object in getComponentName(). ' + 'This is likely a bug in React. Please file an issue.');
|
177 | }
|
178 | }
|
179 |
|
180 | if (typeof type === 'function') {
|
181 | return type.displayName || type.name || null;
|
182 | }
|
183 |
|
184 | if (typeof type === 'string') {
|
185 | return type;
|
186 | }
|
187 |
|
188 | switch (type) {
|
189 | case REACT_FRAGMENT_TYPE:
|
190 | return 'Fragment';
|
191 |
|
192 | case REACT_PORTAL_TYPE:
|
193 | return 'Portal';
|
194 |
|
195 | case REACT_PROFILER_TYPE:
|
196 | return "Profiler";
|
197 |
|
198 | case REACT_STRICT_MODE_TYPE:
|
199 | return 'StrictMode';
|
200 |
|
201 | case REACT_SUSPENSE_TYPE:
|
202 | return 'Suspense';
|
203 |
|
204 | case REACT_SUSPENSE_LIST_TYPE:
|
205 | return 'SuspenseList';
|
206 | }
|
207 |
|
208 | if (typeof type === 'object') {
|
209 | switch (type.$$typeof) {
|
210 | case REACT_CONTEXT_TYPE:
|
211 | return 'Context.Consumer';
|
212 |
|
213 | case REACT_PROVIDER_TYPE:
|
214 | return 'Context.Provider';
|
215 |
|
216 | case REACT_FORWARD_REF_TYPE:
|
217 | return getWrappedName(type, type.render, 'ForwardRef');
|
218 |
|
219 | case REACT_MEMO_TYPE:
|
220 | return getComponentName(type.type);
|
221 |
|
222 | case REACT_LAZY_TYPE:
|
223 | {
|
224 | var thenable = type;
|
225 | var resolvedThenable = refineResolvedLazyComponent(thenable);
|
226 |
|
227 | if (resolvedThenable) {
|
228 | return getComponentName(resolvedThenable);
|
229 | }
|
230 |
|
231 | break;
|
232 | }
|
233 | }
|
234 | }
|
235 |
|
236 | return null;
|
237 | }
|
238 |
|
239 | var ClassComponent = 1;
|
240 |
|
241 |
|
242 | var HostRoot = 3;
|
243 |
|
244 | var HostPortal = 4;
|
245 |
|
246 | var HostComponent = 5;
|
247 | var HostText = 6;
|
248 |
|
249 |
|
250 |
|
251 |
|
252 |
|
253 |
|
254 | var SuspenseComponent = 13;
|
255 |
|
256 |
|
257 |
|
258 |
|
259 |
|
260 |
|
261 | var FundamentalComponent = 20;
|
262 |
|
263 |
|
264 | var NoEffect =
|
265 |
|
266 | 0;
|
267 |
|
268 |
|
269 | var Placement =
|
270 |
|
271 | 2;
|
272 |
|
273 |
|
274 |
|
275 |
|
276 |
|
277 |
|
278 |
|
279 |
|
280 |
|
281 | var Hydrating =
|
282 |
|
283 | 1024;
|
284 |
|
285 |
|
286 |
|
287 |
|
288 |
|
289 |
|
290 |
|
291 |
|
292 |
|
293 |
|
294 |
|
295 |
|
296 |
|
297 |
|
298 |
|
299 |
|
300 |
|
301 |
|
302 |
|
303 |
|
304 |
|
305 |
|
306 |
|
307 |
|
308 |
|
309 |
|
310 |
|
311 |
|
312 |
|
313 |
|
314 |
|
315 |
|
316 |
|
317 |
|
318 |
|
319 |
|
320 |
|
321 |
|
322 |
|
323 |
|
324 |
|
325 |
|
326 |
|
327 |
|
328 | var enableFundamentalAPI = false;
|
329 |
|
330 |
|
331 |
|
332 |
|
333 |
|
334 |
|
335 |
|
336 |
|
337 |
|
338 |
|
339 |
|
340 |
|
341 |
|
342 |
|
343 |
|
344 |
|
345 |
|
346 |
|
347 |
|
348 |
|
349 |
|
350 |
|
351 |
|
352 | var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;
|
353 | function getNearestMountedFiber(fiber) {
|
354 | var node = fiber;
|
355 | var nearestMounted = fiber;
|
356 |
|
357 | if (!fiber.alternate) {
|
358 |
|
359 |
|
360 | var nextNode = node;
|
361 |
|
362 | do {
|
363 | node = nextNode;
|
364 |
|
365 | if ((node.effectTag & (Placement | Hydrating)) !== NoEffect) {
|
366 |
|
367 |
|
368 |
|
369 | nearestMounted = node.return;
|
370 | }
|
371 |
|
372 | nextNode = node.return;
|
373 | } while (nextNode);
|
374 | } else {
|
375 | while (node.return) {
|
376 | node = node.return;
|
377 | }
|
378 | }
|
379 |
|
380 | if (node.tag === HostRoot) {
|
381 |
|
382 |
|
383 | return nearestMounted;
|
384 | }
|
385 |
|
386 |
|
387 |
|
388 | return null;
|
389 | }
|
390 | function getSuspenseInstanceFromFiber(fiber) {
|
391 | if (fiber.tag === SuspenseComponent) {
|
392 | var suspenseState = fiber.memoizedState;
|
393 |
|
394 | if (suspenseState === null) {
|
395 | var current = fiber.alternate;
|
396 |
|
397 | if (current !== null) {
|
398 | suspenseState = current.memoizedState;
|
399 | }
|
400 | }
|
401 |
|
402 | if (suspenseState !== null) {
|
403 | return suspenseState.dehydrated;
|
404 | }
|
405 | }
|
406 |
|
407 | return null;
|
408 | }
|
409 | function getContainerFromFiber(fiber) {
|
410 | return fiber.tag === HostRoot ? fiber.stateNode.containerInfo : null;
|
411 | }
|
412 | function isFiberMounted(fiber) {
|
413 | return getNearestMountedFiber(fiber) === fiber;
|
414 | }
|
415 | function isMounted(component) {
|
416 | {
|
417 | var owner = ReactCurrentOwner.current;
|
418 |
|
419 | if (owner !== null && owner.tag === ClassComponent) {
|
420 | var ownerFiber = owner;
|
421 | var instance = ownerFiber.stateNode;
|
422 | !instance._warnedAboutRefsInRender ? warningWithoutStack$1(false, '%s is accessing isMounted inside its render() function. ' + 'render() should be a pure function of props and state. It should ' + 'never access something that requires stale data from the previous ' + 'render, such as refs. Move this logic to componentDidMount and ' + 'componentDidUpdate instead.', getComponentName(ownerFiber.type) || 'A component') : void 0;
|
423 | instance._warnedAboutRefsInRender = true;
|
424 | }
|
425 | }
|
426 |
|
427 | var fiber = get(component);
|
428 |
|
429 | if (!fiber) {
|
430 | return false;
|
431 | }
|
432 |
|
433 | return getNearestMountedFiber(fiber) === fiber;
|
434 | }
|
435 |
|
436 | function assertIsMounted(fiber) {
|
437 | (function () {
|
438 | if (!(getNearestMountedFiber(fiber) === fiber)) {
|
439 | {
|
440 | throw ReactError(Error("Unable to find node on an unmounted component."));
|
441 | }
|
442 | }
|
443 | })();
|
444 | }
|
445 |
|
446 | function findCurrentFiberUsingSlowPath(fiber) {
|
447 | var alternate = fiber.alternate;
|
448 |
|
449 | if (!alternate) {
|
450 |
|
451 | var nearestMounted = getNearestMountedFiber(fiber);
|
452 |
|
453 | (function () {
|
454 | if (!(nearestMounted !== null)) {
|
455 | {
|
456 | throw ReactError(Error("Unable to find node on an unmounted component."));
|
457 | }
|
458 | }
|
459 | })();
|
460 |
|
461 | if (nearestMounted !== fiber) {
|
462 | return null;
|
463 | }
|
464 |
|
465 | return fiber;
|
466 | }
|
467 |
|
468 |
|
469 |
|
470 |
|
471 | var a = fiber;
|
472 | var b = alternate;
|
473 |
|
474 | while (true) {
|
475 | var parentA = a.return;
|
476 |
|
477 | if (parentA === null) {
|
478 |
|
479 | break;
|
480 | }
|
481 |
|
482 | var parentB = parentA.alternate;
|
483 |
|
484 | if (parentB === null) {
|
485 |
|
486 |
|
487 |
|
488 |
|
489 | var nextParent = parentA.return;
|
490 |
|
491 | if (nextParent !== null) {
|
492 | a = b = nextParent;
|
493 | continue;
|
494 | }
|
495 |
|
496 |
|
497 | break;
|
498 | }
|
499 |
|
500 |
|
501 |
|
502 |
|
503 | if (parentA.child === parentB.child) {
|
504 | var child = parentA.child;
|
505 |
|
506 | while (child) {
|
507 | if (child === a) {
|
508 |
|
509 | assertIsMounted(parentA);
|
510 | return fiber;
|
511 | }
|
512 |
|
513 | if (child === b) {
|
514 |
|
515 | assertIsMounted(parentA);
|
516 | return alternate;
|
517 | }
|
518 |
|
519 | child = child.sibling;
|
520 | }
|
521 |
|
522 |
|
523 |
|
524 | (function () {
|
525 | {
|
526 | {
|
527 | throw ReactError(Error("Unable to find node on an unmounted component."));
|
528 | }
|
529 | }
|
530 | })();
|
531 | }
|
532 |
|
533 | if (a.return !== b.return) {
|
534 |
|
535 |
|
536 |
|
537 |
|
538 | a = parentA;
|
539 | b = parentB;
|
540 | } else {
|
541 |
|
542 |
|
543 |
|
544 |
|
545 |
|
546 | var didFindChild = false;
|
547 | var _child = parentA.child;
|
548 |
|
549 | while (_child) {
|
550 | if (_child === a) {
|
551 | didFindChild = true;
|
552 | a = parentA;
|
553 | b = parentB;
|
554 | break;
|
555 | }
|
556 |
|
557 | if (_child === b) {
|
558 | didFindChild = true;
|
559 | b = parentA;
|
560 | a = parentB;
|
561 | break;
|
562 | }
|
563 |
|
564 | _child = _child.sibling;
|
565 | }
|
566 |
|
567 | if (!didFindChild) {
|
568 |
|
569 | _child = parentB.child;
|
570 |
|
571 | while (_child) {
|
572 | if (_child === a) {
|
573 | didFindChild = true;
|
574 | a = parentB;
|
575 | b = parentA;
|
576 | break;
|
577 | }
|
578 |
|
579 | if (_child === b) {
|
580 | didFindChild = true;
|
581 | b = parentB;
|
582 | a = parentA;
|
583 | break;
|
584 | }
|
585 |
|
586 | _child = _child.sibling;
|
587 | }
|
588 |
|
589 | (function () {
|
590 | if (!didFindChild) {
|
591 | {
|
592 | throw ReactError(Error("Child was not found in either parent set. This indicates a bug in React related to the return pointer. Please file an issue."));
|
593 | }
|
594 | }
|
595 | })();
|
596 | }
|
597 | }
|
598 |
|
599 | (function () {
|
600 | if (!(a.alternate === b)) {
|
601 | {
|
602 | throw ReactError(Error("Return fibers should always be each others' alternates. This error is likely caused by a bug in React. Please file an issue."));
|
603 | }
|
604 | }
|
605 | })();
|
606 | }
|
607 |
|
608 |
|
609 |
|
610 | (function () {
|
611 | if (!(a.tag === HostRoot)) {
|
612 | {
|
613 | throw ReactError(Error("Unable to find node on an unmounted component."));
|
614 | }
|
615 | }
|
616 | })();
|
617 |
|
618 | if (a.stateNode.current === a) {
|
619 |
|
620 | return fiber;
|
621 | }
|
622 |
|
623 |
|
624 | return alternate;
|
625 | }
|
626 | function findCurrentHostFiber(parent) {
|
627 | var currentParent = findCurrentFiberUsingSlowPath(parent);
|
628 |
|
629 | if (!currentParent) {
|
630 | return null;
|
631 | }
|
632 |
|
633 |
|
634 | var node = currentParent;
|
635 |
|
636 | while (true) {
|
637 | if (node.tag === HostComponent || node.tag === HostText) {
|
638 | return node;
|
639 | } else if (node.child) {
|
640 | node.child.return = node;
|
641 | node = node.child;
|
642 | continue;
|
643 | }
|
644 |
|
645 | if (node === currentParent) {
|
646 | return null;
|
647 | }
|
648 |
|
649 | while (!node.sibling) {
|
650 | if (!node.return || node.return === currentParent) {
|
651 | return null;
|
652 | }
|
653 |
|
654 | node = node.return;
|
655 | }
|
656 |
|
657 | node.sibling.return = node.return;
|
658 | node = node.sibling;
|
659 | }
|
660 |
|
661 |
|
662 |
|
663 | return null;
|
664 | }
|
665 | function findCurrentHostFiberWithNoPortals(parent) {
|
666 | var currentParent = findCurrentFiberUsingSlowPath(parent);
|
667 |
|
668 | if (!currentParent) {
|
669 | return null;
|
670 | }
|
671 |
|
672 |
|
673 | var node = currentParent;
|
674 |
|
675 | while (true) {
|
676 | if (node.tag === HostComponent || node.tag === HostText || enableFundamentalAPI && node.tag === FundamentalComponent) {
|
677 | return node;
|
678 | } else if (node.child && node.tag !== HostPortal) {
|
679 | node.child.return = node;
|
680 | node = node.child;
|
681 | continue;
|
682 | }
|
683 |
|
684 | if (node === currentParent) {
|
685 | return null;
|
686 | }
|
687 |
|
688 | while (!node.sibling) {
|
689 | if (!node.return || node.return === currentParent) {
|
690 | return null;
|
691 | }
|
692 |
|
693 | node = node.return;
|
694 | }
|
695 |
|
696 | node.sibling.return = node.return;
|
697 | node = node.sibling;
|
698 | }
|
699 |
|
700 |
|
701 |
|
702 | return null;
|
703 | }
|
704 |
|
705 | exports.getNearestMountedFiber = getNearestMountedFiber;
|
706 | exports.getSuspenseInstanceFromFiber = getSuspenseInstanceFromFiber;
|
707 | exports.getContainerFromFiber = getContainerFromFiber;
|
708 | exports.isFiberMounted = isFiberMounted;
|
709 | exports.isMounted = isMounted;
|
710 | exports.findCurrentFiberUsingSlowPath = findCurrentFiberUsingSlowPath;
|
711 | exports.findCurrentHostFiber = findCurrentHostFiber;
|
712 | exports.findCurrentHostFiberWithNoPortals = findCurrentHostFiberWithNoPortals;
|
713 | })();
|
714 | }
|