1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 | 'use strict';
|
11 |
|
12 | (function (global, factory) {
|
13 | typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('react')) :
|
14 | typeof define === 'function' && define.amd ? define(['react'], factory) :
|
15 | (global.ReactART = factory(global.React));
|
16 | }(this, (function (React) { 'use strict';
|
17 |
|
18 | var ReactInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
19 |
|
20 | var _assign = ReactInternals.assign;
|
21 |
|
22 |
|
23 |
|
24 | var ReactVersion = '16.8.5';
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 | var validateFormat = function () {};
|
38 |
|
39 | {
|
40 | validateFormat = function (format) {
|
41 | if (format === undefined) {
|
42 | throw new Error('invariant requires an error message argument');
|
43 | }
|
44 | };
|
45 | }
|
46 |
|
47 | function invariant(condition, format, a, b, c, d, e, f) {
|
48 | validateFormat(format);
|
49 |
|
50 | if (!condition) {
|
51 | var error = void 0;
|
52 | if (format === undefined) {
|
53 | error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.');
|
54 | } else {
|
55 | var args = [a, b, c, d, e, f];
|
56 | var argIndex = 0;
|
57 | error = new Error(format.replace(/%s/g, function () {
|
58 | return args[argIndex++];
|
59 | }));
|
60 | error.name = 'Invariant Violation';
|
61 | }
|
62 |
|
63 | error.framesToPop = 1;
|
64 | throw error;
|
65 | }
|
66 | }
|
67 |
|
68 |
|
69 |
|
70 |
|
71 |
|
72 |
|
73 |
|
74 |
|
75 |
|
76 |
|
77 |
|
78 | var warningWithoutStack = function () {};
|
79 |
|
80 | {
|
81 | warningWithoutStack = function (condition, format) {
|
82 | for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
83 | args[_key - 2] = arguments[_key];
|
84 | }
|
85 |
|
86 | if (format === undefined) {
|
87 | throw new Error('`warningWithoutStack(condition, format, ...args)` requires a warning ' + 'message argument');
|
88 | }
|
89 | if (args.length > 8) {
|
90 |
|
91 | throw new Error('warningWithoutStack() currently supports at most 8 arguments.');
|
92 | }
|
93 | if (condition) {
|
94 | return;
|
95 | }
|
96 | if (typeof console !== 'undefined') {
|
97 | var argsWithFormat = args.map(function (item) {
|
98 | return '' + item;
|
99 | });
|
100 | argsWithFormat.unshift('Warning: ' + format);
|
101 |
|
102 |
|
103 |
|
104 | Function.prototype.apply.call(console.error, console, argsWithFormat);
|
105 | }
|
106 | try {
|
107 |
|
108 |
|
109 |
|
110 | var argIndex = 0;
|
111 | var message = 'Warning: ' + format.replace(/%s/g, function () {
|
112 | return args[argIndex++];
|
113 | });
|
114 | throw new Error(message);
|
115 | } catch (x) {}
|
116 | };
|
117 | }
|
118 |
|
119 | var warningWithoutStack$1 = warningWithoutStack;
|
120 |
|
121 |
|
122 |
|
123 |
|
124 |
|
125 |
|
126 |
|
127 |
|
128 |
|
129 |
|
130 |
|
131 |
|
132 |
|
133 |
|
134 |
|
135 |
|
136 |
|
137 |
|
138 | function get(key) {
|
139 | return key._reactInternalFiber;
|
140 | }
|
141 |
|
142 |
|
143 |
|
144 | function set(key, value) {
|
145 | key._reactInternalFiber = value;
|
146 | }
|
147 |
|
148 | var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
149 |
|
150 |
|
151 |
|
152 |
|
153 | if (!ReactSharedInternals.hasOwnProperty('ReactCurrentDispatcher')) {
|
154 | ReactSharedInternals.ReactCurrentDispatcher = {
|
155 | current: null
|
156 | };
|
157 | }
|
158 |
|
159 |
|
160 |
|
161 | var hasSymbol = typeof Symbol === 'function' && Symbol.for;
|
162 |
|
163 | var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7;
|
164 | var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;
|
165 | var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb;
|
166 | var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc;
|
167 | var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
|
168 | var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
|
169 | var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace;
|
170 |
|
171 | var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf;
|
172 | var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
|
173 | var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1;
|
174 | var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;
|
175 | var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4;
|
176 |
|
177 | var MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
|
178 | var FAUX_ITERATOR_SYMBOL = '@@iterator';
|
179 |
|
180 | function getIteratorFn(maybeIterable) {
|
181 | if (maybeIterable === null || typeof maybeIterable !== 'object') {
|
182 | return null;
|
183 | }
|
184 | var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
|
185 | if (typeof maybeIterator === 'function') {
|
186 | return maybeIterator;
|
187 | }
|
188 | return null;
|
189 | }
|
190 |
|
191 | var Pending = 0;
|
192 | var Resolved = 1;
|
193 | var Rejected = 2;
|
194 |
|
195 | function refineResolvedLazyComponent(lazyComponent) {
|
196 | return lazyComponent._status === Resolved ? lazyComponent._result : null;
|
197 | }
|
198 |
|
199 | function getWrappedName(outerType, innerType, wrapperName) {
|
200 | var functionName = innerType.displayName || innerType.name || '';
|
201 | return outerType.displayName || (functionName !== '' ? wrapperName + '(' + functionName + ')' : wrapperName);
|
202 | }
|
203 |
|
204 | function getComponentName(type) {
|
205 | if (type == null) {
|
206 |
|
207 | return null;
|
208 | }
|
209 | {
|
210 | if (typeof type.tag === 'number') {
|
211 | warningWithoutStack$1(false, 'Received an unexpected object in getComponentName(). ' + 'This is likely a bug in React. Please file an issue.');
|
212 | }
|
213 | }
|
214 | if (typeof type === 'function') {
|
215 | return type.displayName || type.name || null;
|
216 | }
|
217 | if (typeof type === 'string') {
|
218 | return type;
|
219 | }
|
220 | switch (type) {
|
221 | case REACT_CONCURRENT_MODE_TYPE:
|
222 | return 'ConcurrentMode';
|
223 | case REACT_FRAGMENT_TYPE:
|
224 | return 'Fragment';
|
225 | case REACT_PORTAL_TYPE:
|
226 | return 'Portal';
|
227 | case REACT_PROFILER_TYPE:
|
228 | return 'Profiler';
|
229 | case REACT_STRICT_MODE_TYPE:
|
230 | return 'StrictMode';
|
231 | case REACT_SUSPENSE_TYPE:
|
232 | return 'Suspense';
|
233 | }
|
234 | if (typeof type === 'object') {
|
235 | switch (type.$$typeof) {
|
236 | case REACT_CONTEXT_TYPE:
|
237 | return 'Context.Consumer';
|
238 | case REACT_PROVIDER_TYPE:
|
239 | return 'Context.Provider';
|
240 | case REACT_FORWARD_REF_TYPE:
|
241 | return getWrappedName(type, type.render, 'ForwardRef');
|
242 | case REACT_MEMO_TYPE:
|
243 | return getComponentName(type.type);
|
244 | case REACT_LAZY_TYPE:
|
245 | {
|
246 | var thenable = type;
|
247 | var resolvedThenable = refineResolvedLazyComponent(thenable);
|
248 | if (resolvedThenable) {
|
249 | return getComponentName(resolvedThenable);
|
250 | }
|
251 | }
|
252 | }
|
253 | }
|
254 | return null;
|
255 | }
|
256 |
|
257 | var FunctionComponent = 0;
|
258 | var ClassComponent = 1;
|
259 | var IndeterminateComponent = 2;
|
260 | var HostRoot = 3;
|
261 | var HostPortal = 4;
|
262 | var HostComponent = 5;
|
263 | var HostText = 6;
|
264 | var Fragment = 7;
|
265 | var Mode = 8;
|
266 | var ContextConsumer = 9;
|
267 | var ContextProvider = 10;
|
268 | var ForwardRef = 11;
|
269 | var Profiler = 12;
|
270 | var SuspenseComponent = 13;
|
271 | var MemoComponent = 14;
|
272 | var SimpleMemoComponent = 15;
|
273 | var LazyComponent = 16;
|
274 | var IncompleteClassComponent = 17;
|
275 | var DehydratedSuspenseComponent = 18;
|
276 |
|
277 |
|
278 | var NoEffect = 0;
|
279 | var PerformedWork = 1;
|
280 |
|
281 |
|
282 | var Placement = 2;
|
283 | var Update = 4;
|
284 | var PlacementAndUpdate = 6;
|
285 | var Deletion = 8;
|
286 | var ContentReset = 16;
|
287 | var Callback = 32;
|
288 | var DidCapture = 64;
|
289 | var Ref = 128;
|
290 | var Snapshot = 256;
|
291 | var Passive = 512;
|
292 |
|
293 |
|
294 | var LifecycleEffectMask = 932;
|
295 |
|
296 |
|
297 | var HostEffectMask = 1023;
|
298 |
|
299 | var Incomplete = 1024;
|
300 | var ShouldCapture = 2048;
|
301 |
|
302 | var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;
|
303 |
|
304 | var MOUNTING = 1;
|
305 | var MOUNTED = 2;
|
306 | var UNMOUNTED = 3;
|
307 |
|
308 | function isFiberMountedImpl(fiber) {
|
309 | var node = fiber;
|
310 | if (!fiber.alternate) {
|
311 |
|
312 |
|
313 | if ((node.effectTag & Placement) !== NoEffect) {
|
314 | return MOUNTING;
|
315 | }
|
316 | while (node.return) {
|
317 | node = node.return;
|
318 | if ((node.effectTag & Placement) !== NoEffect) {
|
319 | return MOUNTING;
|
320 | }
|
321 | }
|
322 | } else {
|
323 | while (node.return) {
|
324 | node = node.return;
|
325 | }
|
326 | }
|
327 | if (node.tag === HostRoot) {
|
328 |
|
329 |
|
330 | return MOUNTED;
|
331 | }
|
332 |
|
333 |
|
334 | return UNMOUNTED;
|
335 | }
|
336 |
|
337 | function isFiberMounted(fiber) {
|
338 | return isFiberMountedImpl(fiber) === MOUNTED;
|
339 | }
|
340 |
|
341 | function isMounted(component) {
|
342 | {
|
343 | var owner = ReactCurrentOwner.current;
|
344 | if (owner !== null && owner.tag === ClassComponent) {
|
345 | var ownerFiber = owner;
|
346 | var instance = ownerFiber.stateNode;
|
347 | !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;
|
348 | instance._warnedAboutRefsInRender = true;
|
349 | }
|
350 | }
|
351 |
|
352 | var fiber = get(component);
|
353 | if (!fiber) {
|
354 | return false;
|
355 | }
|
356 | return isFiberMountedImpl(fiber) === MOUNTED;
|
357 | }
|
358 |
|
359 | function assertIsMounted(fiber) {
|
360 | !(isFiberMountedImpl(fiber) === MOUNTED) ? invariant(false, 'Unable to find node on an unmounted component.') : void 0;
|
361 | }
|
362 |
|
363 | function findCurrentFiberUsingSlowPath(fiber) {
|
364 | var alternate = fiber.alternate;
|
365 | if (!alternate) {
|
366 |
|
367 | var state = isFiberMountedImpl(fiber);
|
368 | !(state !== UNMOUNTED) ? invariant(false, 'Unable to find node on an unmounted component.') : void 0;
|
369 | if (state === MOUNTING) {
|
370 | return null;
|
371 | }
|
372 | return fiber;
|
373 | }
|
374 |
|
375 |
|
376 |
|
377 | var a = fiber;
|
378 | var b = alternate;
|
379 | while (true) {
|
380 | var parentA = a.return;
|
381 | var parentB = parentA ? parentA.alternate : null;
|
382 | if (!parentA || !parentB) {
|
383 |
|
384 | break;
|
385 | }
|
386 |
|
387 |
|
388 |
|
389 |
|
390 | if (parentA.child === parentB.child) {
|
391 | var child = parentA.child;
|
392 | while (child) {
|
393 | if (child === a) {
|
394 |
|
395 | assertIsMounted(parentA);
|
396 | return fiber;
|
397 | }
|
398 | if (child === b) {
|
399 |
|
400 | assertIsMounted(parentA);
|
401 | return alternate;
|
402 | }
|
403 | child = child.sibling;
|
404 | }
|
405 |
|
406 |
|
407 | invariant(false, 'Unable to find node on an unmounted component.');
|
408 | }
|
409 |
|
410 | if (a.return !== b.return) {
|
411 |
|
412 |
|
413 |
|
414 |
|
415 | a = parentA;
|
416 | b = parentB;
|
417 | } else {
|
418 |
|
419 |
|
420 |
|
421 |
|
422 |
|
423 | var didFindChild = false;
|
424 | var _child = parentA.child;
|
425 | while (_child) {
|
426 | if (_child === a) {
|
427 | didFindChild = true;
|
428 | a = parentA;
|
429 | b = parentB;
|
430 | break;
|
431 | }
|
432 | if (_child === b) {
|
433 | didFindChild = true;
|
434 | b = parentA;
|
435 | a = parentB;
|
436 | break;
|
437 | }
|
438 | _child = _child.sibling;
|
439 | }
|
440 | if (!didFindChild) {
|
441 |
|
442 | _child = parentB.child;
|
443 | while (_child) {
|
444 | if (_child === a) {
|
445 | didFindChild = true;
|
446 | a = parentB;
|
447 | b = parentA;
|
448 | break;
|
449 | }
|
450 | if (_child === b) {
|
451 | didFindChild = true;
|
452 | b = parentB;
|
453 | a = parentA;
|
454 | break;
|
455 | }
|
456 | _child = _child.sibling;
|
457 | }
|
458 | !didFindChild ? invariant(false, 'Child was not found in either parent set. This indicates a bug in React related to the return pointer. Please file an issue.') : void 0;
|
459 | }
|
460 | }
|
461 |
|
462 | !(a.alternate === b) ? invariant(false, 'Return fibers should always be each others\' alternates. This error is likely caused by a bug in React. Please file an issue.') : void 0;
|
463 | }
|
464 |
|
465 |
|
466 | !(a.tag === HostRoot) ? invariant(false, 'Unable to find node on an unmounted component.') : void 0;
|
467 | if (a.stateNode.current === a) {
|
468 |
|
469 | return fiber;
|
470 | }
|
471 |
|
472 | return alternate;
|
473 | }
|
474 |
|
475 | function findCurrentHostFiber(parent) {
|
476 | var currentParent = findCurrentFiberUsingSlowPath(parent);
|
477 | if (!currentParent) {
|
478 | return null;
|
479 | }
|
480 |
|
481 |
|
482 | var node = currentParent;
|
483 | while (true) {
|
484 | if (node.tag === HostComponent || node.tag === HostText) {
|
485 | return node;
|
486 | } else if (node.child) {
|
487 | node.child.return = node;
|
488 | node = node.child;
|
489 | continue;
|
490 | }
|
491 | if (node === currentParent) {
|
492 | return null;
|
493 | }
|
494 | while (!node.sibling) {
|
495 | if (!node.return || node.return === currentParent) {
|
496 | return null;
|
497 | }
|
498 | node = node.return;
|
499 | }
|
500 | node.sibling.return = node.return;
|
501 | node = node.sibling;
|
502 | }
|
503 |
|
504 |
|
505 | return null;
|
506 | }
|
507 |
|
508 | var ReactInternals$1 = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
509 |
|
510 | var _ReactInternals$Sched = ReactInternals$1.Scheduler;
|
511 | var unstable_cancelCallback = _ReactInternals$Sched.unstable_cancelCallback;
|
512 | var unstable_now = _ReactInternals$Sched.unstable_now;
|
513 | var unstable_scheduleCallback = _ReactInternals$Sched.unstable_scheduleCallback;
|
514 | var unstable_shouldYield = _ReactInternals$Sched.unstable_shouldYield;
|
515 | var unstable_getFirstCallbackNode = _ReactInternals$Sched.unstable_getFirstCallbackNode;
|
516 | var unstable_runWithPriority = _ReactInternals$Sched.unstable_runWithPriority;
|
517 | var unstable_next = _ReactInternals$Sched.unstable_next;
|
518 | var unstable_continueExecution = _ReactInternals$Sched.unstable_continueExecution;
|
519 | var unstable_pauseExecution = _ReactInternals$Sched.unstable_pauseExecution;
|
520 | var unstable_getCurrentPriorityLevel = _ReactInternals$Sched.unstable_getCurrentPriorityLevel;
|
521 | var unstable_ImmediatePriority = _ReactInternals$Sched.unstable_ImmediatePriority;
|
522 | var unstable_UserBlockingPriority = _ReactInternals$Sched.unstable_UserBlockingPriority;
|
523 | var unstable_NormalPriority = _ReactInternals$Sched.unstable_NormalPriority;
|
524 | var unstable_LowPriority = _ReactInternals$Sched.unstable_LowPriority;
|
525 | var unstable_IdlePriority = _ReactInternals$Sched.unstable_IdlePriority;
|
526 |
|
527 | var _class = function(mixins){
|
528 | var proto = {};
|
529 | for (var i = 0, l = arguments.length; i < l; i++){
|
530 | var mixin = arguments[i];
|
531 | if (typeof mixin == 'function') mixin = mixin.prototype;
|
532 | for (var key in mixin) proto[key] = mixin[key];
|
533 | }
|
534 | if (!proto.initialize) proto.initialize = function(){};
|
535 | proto.constructor = function(a,b,c,d,e,f,g,h){
|
536 | return new proto.initialize(a,b,c,d,e,f,g,h);
|
537 | };
|
538 | proto.constructor.prototype = proto.initialize.prototype = proto;
|
539 | return proto.constructor;
|
540 | };
|
541 |
|
542 | function Transform(xx, yx, xy, yy, x, y){
|
543 | if (xx && typeof xx == 'object'){
|
544 | yx = xx.yx; yy = xx.yy; y = xx.y;
|
545 | xy = xx.xy; x = xx.x; xx = xx.xx;
|
546 | }
|
547 | this.xx = xx == null ? 1 : xx;
|
548 | this.yx = yx || 0;
|
549 | this.xy = xy || 0;
|
550 | this.yy = yy == null ? 1 : yy;
|
551 | this.x = (x == null ? this.x : x) || 0;
|
552 | this.y = (y == null ? this.y : y) || 0;
|
553 | this._transform();
|
554 | return this;
|
555 | }
|
556 |
|
557 | var transform = _class({
|
558 |
|
559 | initialize: Transform,
|
560 |
|
561 | _transform: function(){},
|
562 |
|
563 | xx: 1, yx: 0, x: 0,
|
564 | xy: 0, yy: 1, y: 0,
|
565 |
|
566 | transform: function(xx, yx, xy, yy, x, y){
|
567 | var m = this;
|
568 | if (xx && typeof xx == 'object'){
|
569 | yx = xx.yx; yy = xx.yy; y = xx.y;
|
570 | xy = xx.xy; x = xx.x; xx = xx.xx;
|
571 | }
|
572 | if (!x) x = 0;
|
573 | if (!y) y = 0;
|
574 | return this.transformTo(
|
575 | m.xx * xx + m.xy * yx,
|
576 | m.yx * xx + m.yy * yx,
|
577 | m.xx * xy + m.xy * yy,
|
578 | m.yx * xy + m.yy * yy,
|
579 | m.xx * x + m.xy * y + m.x,
|
580 | m.yx * x + m.yy * y + m.y
|
581 | );
|
582 | },
|
583 |
|
584 | transformTo: Transform,
|
585 |
|
586 | translate: function(x, y){
|
587 | return this.transform(1, 0, 0, 1, x, y);
|
588 | },
|
589 |
|
590 | move: function(x, y){
|
591 | this.x += x || 0;
|
592 | this.y += y || 0;
|
593 | this._transform();
|
594 | return this;
|
595 | },
|
596 |
|
597 | scale: function(x, y){
|
598 | if (y == null) y = x;
|
599 | return this.transform(x, 0, 0, y, 0, 0);
|
600 | },
|
601 |
|
602 | rotate: function(deg, x, y){
|
603 | if (x == null || y == null){
|
604 | x = (this.left || 0) + (this.width || 0) / 2;
|
605 | y = (this.top || 0) + (this.height || 0) / 2;
|
606 | }
|
607 |
|
608 | var rad = deg * Math.PI / 180, sin = Math.sin(rad), cos = Math.cos(rad);
|
609 |
|
610 | this.transform(1, 0, 0, 1, x, y);
|
611 | var m = this;
|
612 |
|
613 | return this.transformTo(
|
614 | cos * m.xx - sin * m.yx,
|
615 | sin * m.xx + cos * m.yx,
|
616 | cos * m.xy - sin * m.yy,
|
617 | sin * m.xy + cos * m.yy,
|
618 | m.x,
|
619 | m.y
|
620 | ).transform(1, 0, 0, 1, -x, -y);
|
621 | },
|
622 |
|
623 | moveTo: function(x, y){
|
624 | var m = this;
|
625 | return this.transformTo(m.xx, m.yx, m.xy, m.yy, x, y);
|
626 | },
|
627 |
|
628 | rotateTo: function(deg, x, y){
|
629 | var m = this;
|
630 | var flip = m.yx / m.xx > m.yy / m.xy ? -1 : 1;
|
631 | if (m.xx < 0 ? m.xy >= 0 : m.xy < 0) flip = -flip;
|
632 | return this.rotate(deg - Math.atan2(flip * m.yx, flip * m.xx) * 180 / Math.PI, x, y);
|
633 | },
|
634 |
|
635 | scaleTo: function(x, y){
|
636 |
|
637 | var m = this;
|
638 |
|
639 | var h = Math.sqrt(m.xx * m.xx + m.yx * m.yx);
|
640 | m.xx /= h; m.yx /= h;
|
641 |
|
642 | h = Math.sqrt(m.yy * m.yy + m.xy * m.xy);
|
643 | m.yy /= h; m.xy /= h;
|
644 |
|
645 | return this.scale(x, y);
|
646 | },
|
647 |
|
648 | resizeTo: function(width, height){
|
649 | var w = this.width, h = this.height;
|
650 | if (!w || !h) return this;
|
651 | return this.scaleTo(width / w, height / h);
|
652 | },
|
653 |
|
654 | |
655 |
|
656 |
|
657 |
|
658 |
|
659 |
|
660 |
|
661 |
|
662 |
|
663 |
|
664 |
|
665 |
|
666 |
|
667 |
|
668 | inversePoint: function(x, y){
|
669 | var a = this.xx, b = this.yx,
|
670 | c = this.xy, d = this.yy,
|
671 | e = this.x, f = this.y;
|
672 | var det = b * c - a * d;
|
673 | if (det == 0) return null;
|
674 | return {
|
675 | x: (d * (e - x) + c * (y - f)) / det,
|
676 | y: (a * (f - y) + b * (x - e)) / det
|
677 | };
|
678 | },
|
679 |
|
680 | point: function(x, y){
|
681 | var m = this;
|
682 | return {
|
683 | x: m.xx * x + m.xy * y + m.x,
|
684 | y: m.yx * x + m.yy * y + m.y
|
685 | };
|
686 | }
|
687 |
|
688 | });
|
689 |
|
690 | var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
691 |
|
692 |
|
693 |
|
694 |
|
695 |
|
696 | function createCommonjsModule(fn, module) {
|
697 | return module = { exports: {} }, fn(module, module.exports), module.exports;
|
698 | }
|
699 |
|
700 | var current = createCommonjsModule(function (module, exports) {
|
701 | function warning(){
|
702 | throw new Error('You must require a mode before requiring anything else.');
|
703 | }
|
704 |
|
705 | exports.Surface = warning;
|
706 | exports.Path = warning;
|
707 | exports.Shape = warning;
|
708 | exports.Group = warning;
|
709 | exports.ClippingRectangle = warning;
|
710 | exports.Text = warning;
|
711 |
|
712 | exports.setCurrent = function(mode){
|
713 | for (var key in mode){
|
714 | exports[key] = mode[key];
|
715 | }
|
716 | };
|
717 | });
|
718 |
|
719 | var current_1 = current.Surface;
|
720 | var current_2 = current.Path;
|
721 | var current_3 = current.Shape;
|
722 | var current_4 = current.Group;
|
723 | var current_5 = current.ClippingRectangle;
|
724 | var current_6 = current.Text;
|
725 | var current_7 = current.setCurrent;
|
726 |
|
727 | var TYPES = {
|
728 | CLIPPING_RECTANGLE: 'ClippingRectangle',
|
729 | GROUP: 'Group',
|
730 | SHAPE: 'Shape',
|
731 | TEXT: 'Text'
|
732 | };
|
733 |
|
734 | var EVENT_TYPES = {
|
735 | onClick: 'click',
|
736 | onMouseMove: 'mousemove',
|
737 | onMouseOver: 'mouseover',
|
738 | onMouseOut: 'mouseout',
|
739 | onMouseUp: 'mouseup',
|
740 | onMouseDown: 'mousedown'
|
741 | };
|
742 |
|
743 | function childrenAsString(children) {
|
744 | if (!children) {
|
745 | return '';
|
746 | } else if (typeof children === 'string') {
|
747 | return children;
|
748 | } else if (children.length) {
|
749 | return children.join('');
|
750 | } else {
|
751 | return '';
|
752 | }
|
753 | }
|
754 |
|
755 |
|
756 |
|
757 |
|
758 | function shim() {
|
759 | invariant(false, 'The current renderer does not support persistence. This error is likely caused by a bug in React. Please file an issue.');
|
760 | }
|
761 |
|
762 |
|
763 | var supportsPersistence = false;
|
764 | var cloneInstance = shim;
|
765 | var createContainerChildSet = shim;
|
766 | var appendChildToContainerChildSet = shim;
|
767 | var finalizeContainerChildren = shim;
|
768 | var replaceContainerChildren = shim;
|
769 | var cloneHiddenInstance = shim;
|
770 | var cloneUnhiddenInstance = shim;
|
771 | var createHiddenTextInstance = shim;
|
772 |
|
773 |
|
774 |
|
775 |
|
776 | function shim$1() {
|
777 | invariant(false, 'The current renderer does not support hydration. This error is likely caused by a bug in React. Please file an issue.');
|
778 | }
|
779 |
|
780 |
|
781 |
|
782 | var supportsHydration = false;
|
783 | var canHydrateInstance = shim$1;
|
784 | var canHydrateTextInstance = shim$1;
|
785 | var canHydrateSuspenseInstance = shim$1;
|
786 | var getNextHydratableSibling = shim$1;
|
787 | var getFirstHydratableChild = shim$1;
|
788 | var hydrateInstance = shim$1;
|
789 | var hydrateTextInstance = shim$1;
|
790 | var getNextHydratableInstanceAfterSuspenseInstance = shim$1;
|
791 | var clearSuspenseBoundary = shim$1;
|
792 | var clearSuspenseBoundaryFromContainer = shim$1;
|
793 | var didNotMatchHydratedContainerTextInstance = shim$1;
|
794 | var didNotMatchHydratedTextInstance = shim$1;
|
795 | var didNotHydrateContainerInstance = shim$1;
|
796 | var didNotHydrateInstance = shim$1;
|
797 | var didNotFindHydratableContainerInstance = shim$1;
|
798 | var didNotFindHydratableContainerTextInstance = shim$1;
|
799 | var didNotFindHydratableContainerSuspenseInstance = shim$1;
|
800 | var didNotFindHydratableInstance = shim$1;
|
801 | var didNotFindHydratableTextInstance = shim$1;
|
802 | var didNotFindHydratableSuspenseInstance = shim$1;
|
803 |
|
804 | var pooledTransform = new transform();
|
805 |
|
806 | var NO_CONTEXT = {};
|
807 | var UPDATE_SIGNAL = {};
|
808 | {
|
809 | Object.freeze(NO_CONTEXT);
|
810 | Object.freeze(UPDATE_SIGNAL);
|
811 | }
|
812 |
|
813 |
|
814 |
|
815 | function addEventListeners(instance, type, listener) {
|
816 |
|
817 |
|
818 | if (!instance._listeners) {
|
819 | instance._listeners = {};
|
820 | instance._subscriptions = {};
|
821 | }
|
822 |
|
823 | instance._listeners[type] = listener;
|
824 |
|
825 | if (listener) {
|
826 | if (!instance._subscriptions[type]) {
|
827 | instance._subscriptions[type] = instance.subscribe(type, createEventHandler(instance), instance);
|
828 | }
|
829 | } else {
|
830 | if (instance._subscriptions[type]) {
|
831 | instance._subscriptions[type]();
|
832 | delete instance._subscriptions[type];
|
833 | }
|
834 | }
|
835 | }
|
836 |
|
837 | function createEventHandler(instance) {
|
838 | return function handleEvent(event) {
|
839 | var listener = instance._listeners[event.type];
|
840 |
|
841 | if (!listener) {
|
842 |
|
843 | } else if (typeof listener === 'function') {
|
844 | listener.call(instance, event);
|
845 | } else if (listener.handleEvent) {
|
846 | listener.handleEvent(event);
|
847 | }
|
848 | };
|
849 | }
|
850 |
|
851 | function destroyEventListeners(instance) {
|
852 | if (instance._subscriptions) {
|
853 | for (var type in instance._subscriptions) {
|
854 | instance._subscriptions[type]();
|
855 | }
|
856 | }
|
857 |
|
858 | instance._subscriptions = null;
|
859 | instance._listeners = null;
|
860 | }
|
861 |
|
862 | function getScaleX(props) {
|
863 | if (props.scaleX != null) {
|
864 | return props.scaleX;
|
865 | } else if (props.scale != null) {
|
866 | return props.scale;
|
867 | } else {
|
868 | return 1;
|
869 | }
|
870 | }
|
871 |
|
872 | function getScaleY(props) {
|
873 | if (props.scaleY != null) {
|
874 | return props.scaleY;
|
875 | } else if (props.scale != null) {
|
876 | return props.scale;
|
877 | } else {
|
878 | return 1;
|
879 | }
|
880 | }
|
881 |
|
882 | function isSameFont(oldFont, newFont) {
|
883 | if (oldFont === newFont) {
|
884 | return true;
|
885 | } else if (typeof newFont === 'string' || typeof oldFont === 'string') {
|
886 | return false;
|
887 | } else {
|
888 | return newFont.fontSize === oldFont.fontSize && newFont.fontStyle === oldFont.fontStyle && newFont.fontVariant === oldFont.fontVariant && newFont.fontWeight === oldFont.fontWeight && newFont.fontFamily === oldFont.fontFamily;
|
889 | }
|
890 | }
|
891 |
|
892 |
|
893 |
|
894 | function applyClippingRectangleProps(instance, props) {
|
895 | var prevProps = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
896 |
|
897 | applyNodeProps(instance, props, prevProps);
|
898 |
|
899 | instance.width = props.width;
|
900 | instance.height = props.height;
|
901 | }
|
902 |
|
903 | function applyGroupProps(instance, props) {
|
904 | var prevProps = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
905 |
|
906 | applyNodeProps(instance, props, prevProps);
|
907 |
|
908 | instance.width = props.width;
|
909 | instance.height = props.height;
|
910 | }
|
911 |
|
912 | function applyNodeProps(instance, props) {
|
913 | var prevProps = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
914 |
|
915 | var scaleX = getScaleX(props);
|
916 | var scaleY = getScaleY(props);
|
917 |
|
918 | pooledTransform.transformTo(1, 0, 0, 1, 0, 0).move(props.x || 0, props.y || 0).rotate(props.rotation || 0, props.originX, props.originY).scale(scaleX, scaleY, props.originX, props.originY);
|
919 |
|
920 | if (props.transform != null) {
|
921 | pooledTransform.transform(props.transform);
|
922 | }
|
923 |
|
924 | if (instance.xx !== pooledTransform.xx || instance.yx !== pooledTransform.yx || instance.xy !== pooledTransform.xy || instance.yy !== pooledTransform.yy || instance.x !== pooledTransform.x || instance.y !== pooledTransform.y) {
|
925 | instance.transformTo(pooledTransform);
|
926 | }
|
927 |
|
928 | if (props.cursor !== prevProps.cursor || props.title !== prevProps.title) {
|
929 | instance.indicate(props.cursor, props.title);
|
930 | }
|
931 |
|
932 | if (instance.blend && props.opacity !== prevProps.opacity) {
|
933 | instance.blend(props.opacity == null ? 1 : props.opacity);
|
934 | }
|
935 |
|
936 | if (props.visible !== prevProps.visible) {
|
937 | if (props.visible == null || props.visible) {
|
938 | instance.show();
|
939 | } else {
|
940 | instance.hide();
|
941 | }
|
942 | }
|
943 |
|
944 | for (var type in EVENT_TYPES) {
|
945 | addEventListeners(instance, EVENT_TYPES[type], props[type]);
|
946 | }
|
947 | }
|
948 |
|
949 | function applyRenderableNodeProps(instance, props) {
|
950 | var prevProps = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
951 |
|
952 | applyNodeProps(instance, props, prevProps);
|
953 |
|
954 | if (prevProps.fill !== props.fill) {
|
955 | if (props.fill && props.fill.applyFill) {
|
956 | props.fill.applyFill(instance);
|
957 | } else {
|
958 | instance.fill(props.fill);
|
959 | }
|
960 | }
|
961 | if (prevProps.stroke !== props.stroke || prevProps.strokeWidth !== props.strokeWidth || prevProps.strokeCap !== props.strokeCap || prevProps.strokeJoin !== props.strokeJoin ||
|
962 |
|
963 | prevProps.strokeDash !== props.strokeDash) {
|
964 | instance.stroke(props.stroke, props.strokeWidth, props.strokeCap, props.strokeJoin, props.strokeDash);
|
965 | }
|
966 | }
|
967 |
|
968 | function applyShapeProps(instance, props) {
|
969 | var prevProps = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
970 |
|
971 | applyRenderableNodeProps(instance, props, prevProps);
|
972 |
|
973 | var path = props.d || childrenAsString(props.children);
|
974 |
|
975 | var prevDelta = instance._prevDelta;
|
976 | var prevPath = instance._prevPath;
|
977 |
|
978 | if (path !== prevPath || path.delta !== prevDelta || prevProps.height !== props.height || prevProps.width !== props.width) {
|
979 | instance.draw(path, props.width, props.height);
|
980 |
|
981 | instance._prevDelta = path.delta;
|
982 | instance._prevPath = path;
|
983 | }
|
984 | }
|
985 |
|
986 | function applyTextProps(instance, props) {
|
987 | var prevProps = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
988 |
|
989 | applyRenderableNodeProps(instance, props, prevProps);
|
990 |
|
991 | var string = props.children;
|
992 |
|
993 | if (instance._currentString !== string || !isSameFont(props.font, prevProps.font) || props.alignment !== prevProps.alignment || props.path !== prevProps.path) {
|
994 | instance.draw(string, props.font, props.alignment, props.path);
|
995 |
|
996 | instance._currentString = string;
|
997 | }
|
998 | }
|
999 |
|
1000 | function appendInitialChild(parentInstance, child) {
|
1001 | if (typeof child === 'string') {
|
1002 |
|
1003 | invariant(false, 'Text children should already be flattened.');
|
1004 | return;
|
1005 | }
|
1006 |
|
1007 | child.inject(parentInstance);
|
1008 | }
|
1009 |
|
1010 | function createInstance(type, props, internalInstanceHandle) {
|
1011 | var instance = void 0;
|
1012 |
|
1013 | switch (type) {
|
1014 | case TYPES.CLIPPING_RECTANGLE:
|
1015 | instance = current.ClippingRectangle();
|
1016 | instance._applyProps = applyClippingRectangleProps;
|
1017 | break;
|
1018 | case TYPES.GROUP:
|
1019 | instance = current.Group();
|
1020 | instance._applyProps = applyGroupProps;
|
1021 | break;
|
1022 | case TYPES.SHAPE:
|
1023 | instance = current.Shape();
|
1024 | instance._applyProps = applyShapeProps;
|
1025 | break;
|
1026 | case TYPES.TEXT:
|
1027 | instance = current.Text(props.children, props.font, props.alignment, props.path);
|
1028 | instance._applyProps = applyTextProps;
|
1029 | break;
|
1030 | }
|
1031 |
|
1032 | !instance ? invariant(false, 'ReactART does not support the type "%s"', type) : void 0;
|
1033 |
|
1034 | instance._applyProps(instance, props);
|
1035 |
|
1036 | return instance;
|
1037 | }
|
1038 |
|
1039 | function createTextInstance(text, rootContainerInstance, internalInstanceHandle) {
|
1040 | return text;
|
1041 | }
|
1042 |
|
1043 | function finalizeInitialChildren(domElement, type, props) {
|
1044 | return false;
|
1045 | }
|
1046 |
|
1047 | function getPublicInstance(instance) {
|
1048 | return instance;
|
1049 | }
|
1050 |
|
1051 | function prepareForCommit() {
|
1052 |
|
1053 | }
|
1054 |
|
1055 | function prepareUpdate(domElement, type, oldProps, newProps) {
|
1056 | return UPDATE_SIGNAL;
|
1057 | }
|
1058 |
|
1059 | function resetAfterCommit() {
|
1060 |
|
1061 | }
|
1062 |
|
1063 | function resetTextContent(domElement) {
|
1064 |
|
1065 | }
|
1066 |
|
1067 | function shouldDeprioritizeSubtree(type, props) {
|
1068 | return false;
|
1069 | }
|
1070 |
|
1071 | function getRootHostContext() {
|
1072 | return NO_CONTEXT;
|
1073 | }
|
1074 |
|
1075 | function getChildHostContext() {
|
1076 | return NO_CONTEXT;
|
1077 | }
|
1078 |
|
1079 | var scheduleTimeout = setTimeout;
|
1080 | var cancelTimeout = clearTimeout;
|
1081 | var noTimeout = -1;
|
1082 | var schedulePassiveEffects = unstable_scheduleCallback;
|
1083 | var cancelPassiveEffects = unstable_cancelCallback;
|
1084 |
|
1085 | function shouldSetTextContent(type, props) {
|
1086 | return typeof props.children === 'string' || typeof props.children === 'number';
|
1087 | }
|
1088 |
|
1089 |
|
1090 | var isPrimaryRenderer = false;
|
1091 |
|
1092 | var supportsMutation = true;
|
1093 |
|
1094 | function appendChild(parentInstance, child) {
|
1095 | if (child.parentNode === parentInstance) {
|
1096 | child.eject();
|
1097 | }
|
1098 | child.inject(parentInstance);
|
1099 | }
|
1100 |
|
1101 | function appendChildToContainer(parentInstance, child) {
|
1102 | if (child.parentNode === parentInstance) {
|
1103 | child.eject();
|
1104 | }
|
1105 | child.inject(parentInstance);
|
1106 | }
|
1107 |
|
1108 | function insertBefore(parentInstance, child, beforeChild) {
|
1109 | !(child !== beforeChild) ? invariant(false, 'ReactART: Can not insert node before itself') : void 0;
|
1110 | child.injectBefore(beforeChild);
|
1111 | }
|
1112 |
|
1113 | function insertInContainerBefore(parentInstance, child, beforeChild) {
|
1114 | !(child !== beforeChild) ? invariant(false, 'ReactART: Can not insert node before itself') : void 0;
|
1115 | child.injectBefore(beforeChild);
|
1116 | }
|
1117 |
|
1118 | function removeChild(parentInstance, child) {
|
1119 | destroyEventListeners(child);
|
1120 | child.eject();
|
1121 | }
|
1122 |
|
1123 | function removeChildFromContainer(parentInstance, child) {
|
1124 | destroyEventListeners(child);
|
1125 | child.eject();
|
1126 | }
|
1127 |
|
1128 |
|
1129 |
|
1130 |
|
1131 |
|
1132 | function commitUpdate(instance, updatePayload, type, oldProps, newProps) {
|
1133 | instance._applyProps(instance, newProps, oldProps);
|
1134 | }
|
1135 |
|
1136 | function hideInstance(instance) {
|
1137 | instance.hide();
|
1138 | }
|
1139 |
|
1140 |
|
1141 |
|
1142 | function unhideInstance(instance, props) {
|
1143 | if (props.visible == null || props.visible) {
|
1144 | instance.show();
|
1145 | }
|
1146 | }
|
1147 |
|
1148 | function unhideTextInstance(textInstance, text) {
|
1149 |
|
1150 | }
|
1151 |
|
1152 |
|
1153 |
|
1154 |
|
1155 |
|
1156 |
|
1157 |
|
1158 |
|
1159 |
|
1160 |
|
1161 | var ReactPropTypesSecret$1 = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
|
1162 |
|
1163 | var ReactPropTypesSecret_1 = ReactPropTypesSecret$1;
|
1164 |
|
1165 |
|
1166 |
|
1167 |
|
1168 |
|
1169 |
|
1170 |
|
1171 |
|
1172 |
|
1173 |
|
1174 | var printWarning = function() {};
|
1175 |
|
1176 | {
|
1177 | var ReactPropTypesSecret = ReactPropTypesSecret_1;
|
1178 | var loggedTypeFailures = {};
|
1179 |
|
1180 | printWarning = function(text) {
|
1181 | var message = 'Warning: ' + text;
|
1182 | if (typeof console !== 'undefined') {
|
1183 | console.error(message);
|
1184 | }
|
1185 | try {
|
1186 |
|
1187 |
|
1188 |
|
1189 | throw new Error(message);
|
1190 | } catch (x) {}
|
1191 | };
|
1192 | }
|
1193 |
|
1194 |
|
1195 |
|
1196 |
|
1197 |
|
1198 |
|
1199 |
|
1200 |
|
1201 |
|
1202 |
|
1203 |
|
1204 |
|
1205 | function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
|
1206 | {
|
1207 | for (var typeSpecName in typeSpecs) {
|
1208 | if (typeSpecs.hasOwnProperty(typeSpecName)) {
|
1209 | var error;
|
1210 |
|
1211 |
|
1212 |
|
1213 | try {
|
1214 |
|
1215 |
|
1216 | if (typeof typeSpecs[typeSpecName] !== 'function') {
|
1217 | var err = Error(
|
1218 | (componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' +
|
1219 | 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.'
|
1220 | );
|
1221 | err.name = 'Invariant Violation';
|
1222 | throw err;
|
1223 | }
|
1224 | error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret);
|
1225 | } catch (ex) {
|
1226 | error = ex;
|
1227 | }
|
1228 | if (error && !(error instanceof Error)) {
|
1229 | printWarning(
|
1230 | (componentName || 'React class') + ': type specification of ' +
|
1231 | location + ' `' + typeSpecName + '` is invalid; the type checker ' +
|
1232 | 'function must return `null` or an `Error` but returned a ' + typeof error + '. ' +
|
1233 | 'You may have forgotten to pass an argument to the type checker ' +
|
1234 | 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' +
|
1235 | 'shape all require an argument).'
|
1236 | );
|
1237 |
|
1238 | }
|
1239 | if (error instanceof Error && !(error.message in loggedTypeFailures)) {
|
1240 |
|
1241 |
|
1242 | loggedTypeFailures[error.message] = true;
|
1243 |
|
1244 | var stack = getStack ? getStack() : '';
|
1245 |
|
1246 | printWarning(
|
1247 | 'Failed ' + location + ' type: ' + error.message + (stack != null ? stack : '')
|
1248 | );
|
1249 | }
|
1250 | }
|
1251 | }
|
1252 | }
|
1253 | }
|
1254 |
|
1255 | var checkPropTypes_1 = checkPropTypes;
|
1256 |
|
1257 | var BEFORE_SLASH_RE = /^(.*)[\\\/]/;
|
1258 |
|
1259 | var describeComponentFrame = function (name, source, ownerName) {
|
1260 | var sourceInfo = '';
|
1261 | if (source) {
|
1262 | var path = source.fileName;
|
1263 | var fileName = path.replace(BEFORE_SLASH_RE, '');
|
1264 | {
|
1265 |
|
1266 |
|
1267 | if (/^index\./.test(fileName)) {
|
1268 | var match = path.match(BEFORE_SLASH_RE);
|
1269 | if (match) {
|
1270 | var pathBeforeSlash = match[1];
|
1271 | if (pathBeforeSlash) {
|
1272 | var folderName = pathBeforeSlash.replace(BEFORE_SLASH_RE, '');
|
1273 | fileName = folderName + '/' + fileName;
|
1274 | }
|
1275 | }
|
1276 | }
|
1277 | }
|
1278 | sourceInfo = ' (at ' + fileName + ':' + source.lineNumber + ')';
|
1279 | } else if (ownerName) {
|
1280 | sourceInfo = ' (created by ' + ownerName + ')';
|
1281 | }
|
1282 | return '\n in ' + (name || 'Unknown') + sourceInfo;
|
1283 | };
|
1284 |
|
1285 | var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
|
1286 |
|
1287 | function describeFiber(fiber) {
|
1288 | switch (fiber.tag) {
|
1289 | case HostRoot:
|
1290 | case HostPortal:
|
1291 | case HostText:
|
1292 | case Fragment:
|
1293 | case ContextProvider:
|
1294 | case ContextConsumer:
|
1295 | return '';
|
1296 | default:
|
1297 | var owner = fiber._debugOwner;
|
1298 | var source = fiber._debugSource;
|
1299 | var name = getComponentName(fiber.type);
|
1300 | var ownerName = null;
|
1301 | if (owner) {
|
1302 | ownerName = getComponentName(owner.type);
|
1303 | }
|
1304 | return describeComponentFrame(name, source, ownerName);
|
1305 | }
|
1306 | }
|
1307 |
|
1308 | function getStackByFiberInDevAndProd(workInProgress) {
|
1309 | var info = '';
|
1310 | var node = workInProgress;
|
1311 | do {
|
1312 | info += describeFiber(node);
|
1313 | node = node.return;
|
1314 | } while (node);
|
1315 | return info;
|
1316 | }
|
1317 |
|
1318 | var current$1 = null;
|
1319 | var phase = null;
|
1320 |
|
1321 | function getCurrentFiberOwnerNameInDevOrNull() {
|
1322 | {
|
1323 | if (current$1 === null) {
|
1324 | return null;
|
1325 | }
|
1326 | var owner = current$1._debugOwner;
|
1327 | if (owner !== null && typeof owner !== 'undefined') {
|
1328 | return getComponentName(owner.type);
|
1329 | }
|
1330 | }
|
1331 | return null;
|
1332 | }
|
1333 |
|
1334 | function getCurrentFiberStackInDev() {
|
1335 | {
|
1336 | if (current$1 === null) {
|
1337 | return '';
|
1338 | }
|
1339 |
|
1340 |
|
1341 | return getStackByFiberInDevAndProd(current$1);
|
1342 | }
|
1343 | return '';
|
1344 | }
|
1345 |
|
1346 | function resetCurrentFiber() {
|
1347 | {
|
1348 | ReactDebugCurrentFrame.getCurrentStack = null;
|
1349 | current$1 = null;
|
1350 | phase = null;
|
1351 | }
|
1352 | }
|
1353 |
|
1354 | function setCurrentFiber(fiber) {
|
1355 | {
|
1356 | ReactDebugCurrentFrame.getCurrentStack = getCurrentFiberStackInDev;
|
1357 | current$1 = fiber;
|
1358 | phase = null;
|
1359 | }
|
1360 | }
|
1361 |
|
1362 | function setCurrentPhase(lifeCyclePhase) {
|
1363 | {
|
1364 | phase = lifeCyclePhase;
|
1365 | }
|
1366 | }
|
1367 |
|
1368 | var enableUserTimingAPI = true;
|
1369 |
|
1370 |
|
1371 | var debugRenderPhaseSideEffects = false;
|
1372 |
|
1373 |
|
1374 |
|
1375 |
|
1376 |
|
1377 | var debugRenderPhaseSideEffectsForStrictMode = true;
|
1378 |
|
1379 |
|
1380 |
|
1381 | var replayFailedUnitOfWorkWithInvokeGuardedCallback = true;
|
1382 |
|
1383 |
|
1384 | var warnAboutDeprecatedLifecycles = false;
|
1385 |
|
1386 |
|
1387 | var enableProfilerTimer = true;
|
1388 |
|
1389 |
|
1390 | var enableSchedulerTracing = true;
|
1391 |
|
1392 |
|
1393 | var enableSuspenseServerRenderer = false;
|
1394 |
|
1395 |
|
1396 |
|
1397 |
|
1398 |
|
1399 |
|
1400 |
|
1401 |
|
1402 |
|
1403 |
|
1404 |
|
1405 |
|
1406 |
|
1407 |
|
1408 |
|
1409 |
|
1410 | var reactEmoji = '\u269B';
|
1411 | var warningEmoji = '\u26D4';
|
1412 | var supportsUserTiming = typeof performance !== 'undefined' && typeof performance.mark === 'function' && typeof performance.clearMarks === 'function' && typeof performance.measure === 'function' && typeof performance.clearMeasures === 'function';
|
1413 |
|
1414 |
|
1415 |
|
1416 | var currentFiber = null;
|
1417 |
|
1418 |
|
1419 |
|
1420 |
|
1421 | var currentPhase = null;
|
1422 | var currentPhaseFiber = null;
|
1423 |
|
1424 |
|
1425 |
|
1426 | var isCommitting = false;
|
1427 | var hasScheduledUpdateInCurrentCommit = false;
|
1428 | var hasScheduledUpdateInCurrentPhase = false;
|
1429 | var commitCountInCurrentWorkLoop = 0;
|
1430 | var effectCountInCurrentCommit = 0;
|
1431 | var isWaitingForCallback = false;
|
1432 |
|
1433 |
|
1434 | var labelsInCurrentCommit = new Set();
|
1435 |
|
1436 | var formatMarkName = function (markName) {
|
1437 | return reactEmoji + ' ' + markName;
|
1438 | };
|
1439 |
|
1440 | var formatLabel = function (label, warning) {
|
1441 | var prefix = warning ? warningEmoji + ' ' : reactEmoji + ' ';
|
1442 | var suffix = warning ? ' Warning: ' + warning : '';
|
1443 | return '' + prefix + label + suffix;
|
1444 | };
|
1445 |
|
1446 | var beginMark = function (markName) {
|
1447 | performance.mark(formatMarkName(markName));
|
1448 | };
|
1449 |
|
1450 | var clearMark = function (markName) {
|
1451 | performance.clearMarks(formatMarkName(markName));
|
1452 | };
|
1453 |
|
1454 | var endMark = function (label, markName, warning) {
|
1455 | var formattedMarkName = formatMarkName(markName);
|
1456 | var formattedLabel = formatLabel(label, warning);
|
1457 | try {
|
1458 | performance.measure(formattedLabel, formattedMarkName);
|
1459 | } catch (err) {}
|
1460 |
|
1461 |
|
1462 |
|
1463 |
|
1464 |
|
1465 | performance.clearMarks(formattedMarkName);
|
1466 | performance.clearMeasures(formattedLabel);
|
1467 | };
|
1468 |
|
1469 | var getFiberMarkName = function (label, debugID) {
|
1470 | return label + ' (#' + debugID + ')';
|
1471 | };
|
1472 |
|
1473 | var getFiberLabel = function (componentName, isMounted, phase) {
|
1474 | if (phase === null) {
|
1475 |
|
1476 | return componentName + ' [' + (isMounted ? 'update' : 'mount') + ']';
|
1477 | } else {
|
1478 |
|
1479 | return componentName + '.' + phase;
|
1480 | }
|
1481 | };
|
1482 |
|
1483 | var beginFiberMark = function (fiber, phase) {
|
1484 | var componentName = getComponentName(fiber.type) || 'Unknown';
|
1485 | var debugID = fiber._debugID;
|
1486 | var isMounted = fiber.alternate !== null;
|
1487 | var label = getFiberLabel(componentName, isMounted, phase);
|
1488 |
|
1489 | if (isCommitting && labelsInCurrentCommit.has(label)) {
|
1490 |
|
1491 |
|
1492 |
|
1493 | return false;
|
1494 | }
|
1495 | labelsInCurrentCommit.add(label);
|
1496 |
|
1497 | var markName = getFiberMarkName(label, debugID);
|
1498 | beginMark(markName);
|
1499 | return true;
|
1500 | };
|
1501 |
|
1502 | var clearFiberMark = function (fiber, phase) {
|
1503 | var componentName = getComponentName(fiber.type) || 'Unknown';
|
1504 | var debugID = fiber._debugID;
|
1505 | var isMounted = fiber.alternate !== null;
|
1506 | var label = getFiberLabel(componentName, isMounted, phase);
|
1507 | var markName = getFiberMarkName(label, debugID);
|
1508 | clearMark(markName);
|
1509 | };
|
1510 |
|
1511 | var endFiberMark = function (fiber, phase, warning) {
|
1512 | var componentName = getComponentName(fiber.type) || 'Unknown';
|
1513 | var debugID = fiber._debugID;
|
1514 | var isMounted = fiber.alternate !== null;
|
1515 | var label = getFiberLabel(componentName, isMounted, phase);
|
1516 | var markName = getFiberMarkName(label, debugID);
|
1517 | endMark(label, markName, warning);
|
1518 | };
|
1519 |
|
1520 | var shouldIgnoreFiber = function (fiber) {
|
1521 |
|
1522 |
|
1523 | switch (fiber.tag) {
|
1524 | case HostRoot:
|
1525 | case HostComponent:
|
1526 | case HostText:
|
1527 | case HostPortal:
|
1528 | case Fragment:
|
1529 | case ContextProvider:
|
1530 | case ContextConsumer:
|
1531 | case Mode:
|
1532 | return true;
|
1533 | default:
|
1534 | return false;
|
1535 | }
|
1536 | };
|
1537 |
|
1538 | var clearPendingPhaseMeasurement = function () {
|
1539 | if (currentPhase !== null && currentPhaseFiber !== null) {
|
1540 | clearFiberMark(currentPhaseFiber, currentPhase);
|
1541 | }
|
1542 | currentPhaseFiber = null;
|
1543 | currentPhase = null;
|
1544 | hasScheduledUpdateInCurrentPhase = false;
|
1545 | };
|
1546 |
|
1547 | var pauseTimers = function () {
|
1548 |
|
1549 |
|
1550 | var fiber = currentFiber;
|
1551 | while (fiber) {
|
1552 | if (fiber._debugIsCurrentlyTiming) {
|
1553 | endFiberMark(fiber, null, null);
|
1554 | }
|
1555 | fiber = fiber.return;
|
1556 | }
|
1557 | };
|
1558 |
|
1559 | var resumeTimersRecursively = function (fiber) {
|
1560 | if (fiber.return !== null) {
|
1561 | resumeTimersRecursively(fiber.return);
|
1562 | }
|
1563 | if (fiber._debugIsCurrentlyTiming) {
|
1564 | beginFiberMark(fiber, null);
|
1565 | }
|
1566 | };
|
1567 |
|
1568 | var resumeTimers = function () {
|
1569 |
|
1570 | if (currentFiber !== null) {
|
1571 | resumeTimersRecursively(currentFiber);
|
1572 | }
|
1573 | };
|
1574 |
|
1575 | function recordEffect() {
|
1576 | if (enableUserTimingAPI) {
|
1577 | effectCountInCurrentCommit++;
|
1578 | }
|
1579 | }
|
1580 |
|
1581 | function recordScheduleUpdate() {
|
1582 | if (enableUserTimingAPI) {
|
1583 | if (isCommitting) {
|
1584 | hasScheduledUpdateInCurrentCommit = true;
|
1585 | }
|
1586 | if (currentPhase !== null && currentPhase !== 'componentWillMount' && currentPhase !== 'componentWillReceiveProps') {
|
1587 | hasScheduledUpdateInCurrentPhase = true;
|
1588 | }
|
1589 | }
|
1590 | }
|
1591 |
|
1592 | function startRequestCallbackTimer() {
|
1593 | if (enableUserTimingAPI) {
|
1594 | if (supportsUserTiming && !isWaitingForCallback) {
|
1595 | isWaitingForCallback = true;
|
1596 | beginMark('(Waiting for async callback...)');
|
1597 | }
|
1598 | }
|
1599 | }
|
1600 |
|
1601 | function stopRequestCallbackTimer(didExpire, expirationTime) {
|
1602 | if (enableUserTimingAPI) {
|
1603 | if (supportsUserTiming) {
|
1604 | isWaitingForCallback = false;
|
1605 | var warning = didExpire ? 'React was blocked by main thread' : null;
|
1606 | endMark('(Waiting for async callback... will force flush in ' + expirationTime + ' ms)', '(Waiting for async callback...)', warning);
|
1607 | }
|
1608 | }
|
1609 | }
|
1610 |
|
1611 | function startWorkTimer(fiber) {
|
1612 | if (enableUserTimingAPI) {
|
1613 | if (!supportsUserTiming || shouldIgnoreFiber(fiber)) {
|
1614 | return;
|
1615 | }
|
1616 |
|
1617 | currentFiber = fiber;
|
1618 | if (!beginFiberMark(fiber, null)) {
|
1619 | return;
|
1620 | }
|
1621 | fiber._debugIsCurrentlyTiming = true;
|
1622 | }
|
1623 | }
|
1624 |
|
1625 | function cancelWorkTimer(fiber) {
|
1626 | if (enableUserTimingAPI) {
|
1627 | if (!supportsUserTiming || shouldIgnoreFiber(fiber)) {
|
1628 | return;
|
1629 | }
|
1630 |
|
1631 |
|
1632 | fiber._debugIsCurrentlyTiming = false;
|
1633 | clearFiberMark(fiber, null);
|
1634 | }
|
1635 | }
|
1636 |
|
1637 | function stopWorkTimer(fiber) {
|
1638 | if (enableUserTimingAPI) {
|
1639 | if (!supportsUserTiming || shouldIgnoreFiber(fiber)) {
|
1640 | return;
|
1641 | }
|
1642 |
|
1643 | currentFiber = fiber.return;
|
1644 | if (!fiber._debugIsCurrentlyTiming) {
|
1645 | return;
|
1646 | }
|
1647 | fiber._debugIsCurrentlyTiming = false;
|
1648 | endFiberMark(fiber, null, null);
|
1649 | }
|
1650 | }
|
1651 |
|
1652 | function stopFailedWorkTimer(fiber) {
|
1653 | if (enableUserTimingAPI) {
|
1654 | if (!supportsUserTiming || shouldIgnoreFiber(fiber)) {
|
1655 | return;
|
1656 | }
|
1657 |
|
1658 | currentFiber = fiber.return;
|
1659 | if (!fiber._debugIsCurrentlyTiming) {
|
1660 | return;
|
1661 | }
|
1662 | fiber._debugIsCurrentlyTiming = false;
|
1663 | var warning = fiber.tag === SuspenseComponent || fiber.tag === DehydratedSuspenseComponent ? 'Rendering was suspended' : 'An error was thrown inside this error boundary';
|
1664 | endFiberMark(fiber, null, warning);
|
1665 | }
|
1666 | }
|
1667 |
|
1668 | function startPhaseTimer(fiber, phase) {
|
1669 | if (enableUserTimingAPI) {
|
1670 | if (!supportsUserTiming) {
|
1671 | return;
|
1672 | }
|
1673 | clearPendingPhaseMeasurement();
|
1674 | if (!beginFiberMark(fiber, phase)) {
|
1675 | return;
|
1676 | }
|
1677 | currentPhaseFiber = fiber;
|
1678 | currentPhase = phase;
|
1679 | }
|
1680 | }
|
1681 |
|
1682 | function stopPhaseTimer() {
|
1683 | if (enableUserTimingAPI) {
|
1684 | if (!supportsUserTiming) {
|
1685 | return;
|
1686 | }
|
1687 | if (currentPhase !== null && currentPhaseFiber !== null) {
|
1688 | var warning = hasScheduledUpdateInCurrentPhase ? 'Scheduled a cascading update' : null;
|
1689 | endFiberMark(currentPhaseFiber, currentPhase, warning);
|
1690 | }
|
1691 | currentPhase = null;
|
1692 | currentPhaseFiber = null;
|
1693 | }
|
1694 | }
|
1695 |
|
1696 | function startWorkLoopTimer(nextUnitOfWork) {
|
1697 | if (enableUserTimingAPI) {
|
1698 | currentFiber = nextUnitOfWork;
|
1699 | if (!supportsUserTiming) {
|
1700 | return;
|
1701 | }
|
1702 | commitCountInCurrentWorkLoop = 0;
|
1703 |
|
1704 |
|
1705 | beginMark('(React Tree Reconciliation)');
|
1706 |
|
1707 | resumeTimers();
|
1708 | }
|
1709 | }
|
1710 |
|
1711 | function stopWorkLoopTimer(interruptedBy, didCompleteRoot) {
|
1712 | if (enableUserTimingAPI) {
|
1713 | if (!supportsUserTiming) {
|
1714 | return;
|
1715 | }
|
1716 | var warning = null;
|
1717 | if (interruptedBy !== null) {
|
1718 | if (interruptedBy.tag === HostRoot) {
|
1719 | warning = 'A top-level update interrupted the previous render';
|
1720 | } else {
|
1721 | var componentName = getComponentName(interruptedBy.type) || 'Unknown';
|
1722 | warning = 'An update to ' + componentName + ' interrupted the previous render';
|
1723 | }
|
1724 | } else if (commitCountInCurrentWorkLoop > 1) {
|
1725 | warning = 'There were cascading updates';
|
1726 | }
|
1727 | commitCountInCurrentWorkLoop = 0;
|
1728 | var label = didCompleteRoot ? '(React Tree Reconciliation: Completed Root)' : '(React Tree Reconciliation: Yielded)';
|
1729 |
|
1730 | pauseTimers();
|
1731 | endMark(label, '(React Tree Reconciliation)', warning);
|
1732 | }
|
1733 | }
|
1734 |
|
1735 | function startCommitTimer() {
|
1736 | if (enableUserTimingAPI) {
|
1737 | if (!supportsUserTiming) {
|
1738 | return;
|
1739 | }
|
1740 | isCommitting = true;
|
1741 | hasScheduledUpdateInCurrentCommit = false;
|
1742 | labelsInCurrentCommit.clear();
|
1743 | beginMark('(Committing Changes)');
|
1744 | }
|
1745 | }
|
1746 |
|
1747 | function stopCommitTimer() {
|
1748 | if (enableUserTimingAPI) {
|
1749 | if (!supportsUserTiming) {
|
1750 | return;
|
1751 | }
|
1752 |
|
1753 | var warning = null;
|
1754 | if (hasScheduledUpdateInCurrentCommit) {
|
1755 | warning = 'Lifecycle hook scheduled a cascading update';
|
1756 | } else if (commitCountInCurrentWorkLoop > 0) {
|
1757 | warning = 'Caused by a cascading update in earlier commit';
|
1758 | }
|
1759 | hasScheduledUpdateInCurrentCommit = false;
|
1760 | commitCountInCurrentWorkLoop++;
|
1761 | isCommitting = false;
|
1762 | labelsInCurrentCommit.clear();
|
1763 |
|
1764 | endMark('(Committing Changes)', '(Committing Changes)', warning);
|
1765 | }
|
1766 | }
|
1767 |
|
1768 | function startCommitSnapshotEffectsTimer() {
|
1769 | if (enableUserTimingAPI) {
|
1770 | if (!supportsUserTiming) {
|
1771 | return;
|
1772 | }
|
1773 | effectCountInCurrentCommit = 0;
|
1774 | beginMark('(Committing Snapshot Effects)');
|
1775 | }
|
1776 | }
|
1777 |
|
1778 | function stopCommitSnapshotEffectsTimer() {
|
1779 | if (enableUserTimingAPI) {
|
1780 | if (!supportsUserTiming) {
|
1781 | return;
|
1782 | }
|
1783 | var count = effectCountInCurrentCommit;
|
1784 | effectCountInCurrentCommit = 0;
|
1785 | endMark('(Committing Snapshot Effects: ' + count + ' Total)', '(Committing Snapshot Effects)', null);
|
1786 | }
|
1787 | }
|
1788 |
|
1789 | function startCommitHostEffectsTimer() {
|
1790 | if (enableUserTimingAPI) {
|
1791 | if (!supportsUserTiming) {
|
1792 | return;
|
1793 | }
|
1794 | effectCountInCurrentCommit = 0;
|
1795 | beginMark('(Committing Host Effects)');
|
1796 | }
|
1797 | }
|
1798 |
|
1799 | function stopCommitHostEffectsTimer() {
|
1800 | if (enableUserTimingAPI) {
|
1801 | if (!supportsUserTiming) {
|
1802 | return;
|
1803 | }
|
1804 | var count = effectCountInCurrentCommit;
|
1805 | effectCountInCurrentCommit = 0;
|
1806 | endMark('(Committing Host Effects: ' + count + ' Total)', '(Committing Host Effects)', null);
|
1807 | }
|
1808 | }
|
1809 |
|
1810 | function startCommitLifeCyclesTimer() {
|
1811 | if (enableUserTimingAPI) {
|
1812 | if (!supportsUserTiming) {
|
1813 | return;
|
1814 | }
|
1815 | effectCountInCurrentCommit = 0;
|
1816 | beginMark('(Calling Lifecycle Methods)');
|
1817 | }
|
1818 | }
|
1819 |
|
1820 | function stopCommitLifeCyclesTimer() {
|
1821 | if (enableUserTimingAPI) {
|
1822 | if (!supportsUserTiming) {
|
1823 | return;
|
1824 | }
|
1825 | var count = effectCountInCurrentCommit;
|
1826 | effectCountInCurrentCommit = 0;
|
1827 | endMark('(Calling Lifecycle Methods: ' + count + ' Total)', '(Calling Lifecycle Methods)', null);
|
1828 | }
|
1829 | }
|
1830 |
|
1831 | var valueStack = [];
|
1832 |
|
1833 | var fiberStack = void 0;
|
1834 |
|
1835 | {
|
1836 | fiberStack = [];
|
1837 | }
|
1838 |
|
1839 | var index = -1;
|
1840 |
|
1841 | function createCursor(defaultValue) {
|
1842 | return {
|
1843 | current: defaultValue
|
1844 | };
|
1845 | }
|
1846 |
|
1847 | function pop(cursor, fiber) {
|
1848 | if (index < 0) {
|
1849 | {
|
1850 | warningWithoutStack$1(false, 'Unexpected pop.');
|
1851 | }
|
1852 | return;
|
1853 | }
|
1854 |
|
1855 | {
|
1856 | if (fiber !== fiberStack[index]) {
|
1857 | warningWithoutStack$1(false, 'Unexpected Fiber popped.');
|
1858 | }
|
1859 | }
|
1860 |
|
1861 | cursor.current = valueStack[index];
|
1862 |
|
1863 | valueStack[index] = null;
|
1864 |
|
1865 | {
|
1866 | fiberStack[index] = null;
|
1867 | }
|
1868 |
|
1869 | index--;
|
1870 | }
|
1871 |
|
1872 | function push(cursor, value, fiber) {
|
1873 | index++;
|
1874 |
|
1875 | valueStack[index] = cursor.current;
|
1876 |
|
1877 | {
|
1878 | fiberStack[index] = fiber;
|
1879 | }
|
1880 |
|
1881 | cursor.current = value;
|
1882 | }
|
1883 |
|
1884 | function checkThatStackIsEmpty() {
|
1885 | {
|
1886 | if (index !== -1) {
|
1887 | warningWithoutStack$1(false, 'Expected an empty stack. Something was not reset properly.');
|
1888 | }
|
1889 | }
|
1890 | }
|
1891 |
|
1892 | function resetStackAfterFatalErrorInDev() {
|
1893 | {
|
1894 | index = -1;
|
1895 | valueStack.length = 0;
|
1896 | fiberStack.length = 0;
|
1897 | }
|
1898 | }
|
1899 |
|
1900 | var warnedAboutMissingGetChildContext = void 0;
|
1901 |
|
1902 | {
|
1903 | warnedAboutMissingGetChildContext = {};
|
1904 | }
|
1905 |
|
1906 | var emptyContextObject = {};
|
1907 | {
|
1908 | Object.freeze(emptyContextObject);
|
1909 | }
|
1910 |
|
1911 |
|
1912 | var contextStackCursor = createCursor(emptyContextObject);
|
1913 |
|
1914 | var didPerformWorkStackCursor = createCursor(false);
|
1915 |
|
1916 |
|
1917 |
|
1918 | var previousContext = emptyContextObject;
|
1919 |
|
1920 | function getUnmaskedContext(workInProgress, Component, didPushOwnContextIfProvider) {
|
1921 | if (didPushOwnContextIfProvider && isContextProvider(Component)) {
|
1922 |
|
1923 |
|
1924 |
|
1925 |
|
1926 | return previousContext;
|
1927 | }
|
1928 | return contextStackCursor.current;
|
1929 | }
|
1930 |
|
1931 | function cacheContext(workInProgress, unmaskedContext, maskedContext) {
|
1932 | var instance = workInProgress.stateNode;
|
1933 | instance.__reactInternalMemoizedUnmaskedChildContext = unmaskedContext;
|
1934 | instance.__reactInternalMemoizedMaskedChildContext = maskedContext;
|
1935 | }
|
1936 |
|
1937 | function getMaskedContext(workInProgress, unmaskedContext) {
|
1938 | var type = workInProgress.type;
|
1939 | var contextTypes = type.contextTypes;
|
1940 | if (!contextTypes) {
|
1941 | return emptyContextObject;
|
1942 | }
|
1943 |
|
1944 |
|
1945 |
|
1946 |
|
1947 | var instance = workInProgress.stateNode;
|
1948 | if (instance && instance.__reactInternalMemoizedUnmaskedChildContext === unmaskedContext) {
|
1949 | return instance.__reactInternalMemoizedMaskedChildContext;
|
1950 | }
|
1951 |
|
1952 | var context = {};
|
1953 | for (var key in contextTypes) {
|
1954 | context[key] = unmaskedContext[key];
|
1955 | }
|
1956 |
|
1957 | {
|
1958 | var name = getComponentName(type) || 'Unknown';
|
1959 | checkPropTypes_1(contextTypes, context, 'context', name, getCurrentFiberStackInDev);
|
1960 | }
|
1961 |
|
1962 |
|
1963 |
|
1964 | if (instance) {
|
1965 | cacheContext(workInProgress, unmaskedContext, context);
|
1966 | }
|
1967 |
|
1968 | return context;
|
1969 | }
|
1970 |
|
1971 | function hasContextChanged() {
|
1972 | return didPerformWorkStackCursor.current;
|
1973 | }
|
1974 |
|
1975 | function isContextProvider(type) {
|
1976 | var childContextTypes = type.childContextTypes;
|
1977 | return childContextTypes !== null && childContextTypes !== undefined;
|
1978 | }
|
1979 |
|
1980 | function popContext(fiber) {
|
1981 | pop(didPerformWorkStackCursor, fiber);
|
1982 | pop(contextStackCursor, fiber);
|
1983 | }
|
1984 |
|
1985 | function popTopLevelContextObject(fiber) {
|
1986 | pop(didPerformWorkStackCursor, fiber);
|
1987 | pop(contextStackCursor, fiber);
|
1988 | }
|
1989 |
|
1990 | function pushTopLevelContextObject(fiber, context, didChange) {
|
1991 | !(contextStackCursor.current === emptyContextObject) ? invariant(false, 'Unexpected context found on stack. This error is likely caused by a bug in React. Please file an issue.') : void 0;
|
1992 |
|
1993 | push(contextStackCursor, context, fiber);
|
1994 | push(didPerformWorkStackCursor, didChange, fiber);
|
1995 | }
|
1996 |
|
1997 | function processChildContext(fiber, type, parentContext) {
|
1998 | var instance = fiber.stateNode;
|
1999 | var childContextTypes = type.childContextTypes;
|
2000 |
|
2001 |
|
2002 |
|
2003 | if (typeof instance.getChildContext !== 'function') {
|
2004 | {
|
2005 | var componentName = getComponentName(type) || 'Unknown';
|
2006 |
|
2007 | if (!warnedAboutMissingGetChildContext[componentName]) {
|
2008 | warnedAboutMissingGetChildContext[componentName] = true;
|
2009 | warningWithoutStack$1(false, '%s.childContextTypes is specified but there is no getChildContext() method ' + 'on the instance. You can either define getChildContext() on %s or remove ' + 'childContextTypes from it.', componentName, componentName);
|
2010 | }
|
2011 | }
|
2012 | return parentContext;
|
2013 | }
|
2014 |
|
2015 | var childContext = void 0;
|
2016 | {
|
2017 | setCurrentPhase('getChildContext');
|
2018 | }
|
2019 | startPhaseTimer(fiber, 'getChildContext');
|
2020 | childContext = instance.getChildContext();
|
2021 | stopPhaseTimer();
|
2022 | {
|
2023 | setCurrentPhase(null);
|
2024 | }
|
2025 | for (var contextKey in childContext) {
|
2026 | !(contextKey in childContextTypes) ? invariant(false, '%s.getChildContext(): key "%s" is not defined in childContextTypes.', getComponentName(type) || 'Unknown', contextKey) : void 0;
|
2027 | }
|
2028 | {
|
2029 | var name = getComponentName(type) || 'Unknown';
|
2030 | checkPropTypes_1(childContextTypes, childContext, 'child context', name,
|
2031 |
|
2032 |
|
2033 |
|
2034 |
|
2035 |
|
2036 | getCurrentFiberStackInDev);
|
2037 | }
|
2038 |
|
2039 | return _assign({}, parentContext, childContext);
|
2040 | }
|
2041 |
|
2042 | function pushContextProvider(workInProgress) {
|
2043 | var instance = workInProgress.stateNode;
|
2044 |
|
2045 |
|
2046 |
|
2047 | var memoizedMergedChildContext = instance && instance.__reactInternalMemoizedMergedChildContext || emptyContextObject;
|
2048 |
|
2049 |
|
2050 |
|
2051 | previousContext = contextStackCursor.current;
|
2052 | push(contextStackCursor, memoizedMergedChildContext, workInProgress);
|
2053 | push(didPerformWorkStackCursor, didPerformWorkStackCursor.current, workInProgress);
|
2054 |
|
2055 | return true;
|
2056 | }
|
2057 |
|
2058 | function invalidateContextProvider(workInProgress, type, didChange) {
|
2059 | var instance = workInProgress.stateNode;
|
2060 | !instance ? invariant(false, 'Expected to have an instance by this point. This error is likely caused by a bug in React. Please file an issue.') : void 0;
|
2061 |
|
2062 | if (didChange) {
|
2063 |
|
2064 |
|
2065 |
|
2066 | var mergedContext = processChildContext(workInProgress, type, previousContext);
|
2067 | instance.__reactInternalMemoizedMergedChildContext = mergedContext;
|
2068 |
|
2069 |
|
2070 |
|
2071 | pop(didPerformWorkStackCursor, workInProgress);
|
2072 | pop(contextStackCursor, workInProgress);
|
2073 |
|
2074 | push(contextStackCursor, mergedContext, workInProgress);
|
2075 | push(didPerformWorkStackCursor, didChange, workInProgress);
|
2076 | } else {
|
2077 | pop(didPerformWorkStackCursor, workInProgress);
|
2078 | push(didPerformWorkStackCursor, didChange, workInProgress);
|
2079 | }
|
2080 | }
|
2081 |
|
2082 | function findCurrentUnmaskedContext(fiber) {
|
2083 |
|
2084 |
|
2085 | !(isFiberMounted(fiber) && fiber.tag === ClassComponent) ? invariant(false, 'Expected subtree parent to be a mounted class component. This error is likely caused by a bug in React. Please file an issue.') : void 0;
|
2086 |
|
2087 | var node = fiber;
|
2088 | do {
|
2089 | switch (node.tag) {
|
2090 | case HostRoot:
|
2091 | return node.stateNode.context;
|
2092 | case ClassComponent:
|
2093 | {
|
2094 | var Component = node.type;
|
2095 | if (isContextProvider(Component)) {
|
2096 | return node.stateNode.__reactInternalMemoizedMergedChildContext;
|
2097 | }
|
2098 | break;
|
2099 | }
|
2100 | }
|
2101 | node = node.return;
|
2102 | } while (node !== null);
|
2103 | invariant(false, 'Found unexpected detached subtree parent. This error is likely caused by a bug in React. Please file an issue.');
|
2104 | }
|
2105 |
|
2106 | var onCommitFiberRoot = null;
|
2107 | var onCommitFiberUnmount = null;
|
2108 | var hasLoggedError = false;
|
2109 |
|
2110 | function catchErrors(fn) {
|
2111 | return function (arg) {
|
2112 | try {
|
2113 | return fn(arg);
|
2114 | } catch (err) {
|
2115 | if (true && !hasLoggedError) {
|
2116 | hasLoggedError = true;
|
2117 | warningWithoutStack$1(false, 'React DevTools encountered an error: %s', err);
|
2118 | }
|
2119 | }
|
2120 | };
|
2121 | }
|
2122 |
|
2123 | var isDevToolsPresent = typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined';
|
2124 |
|
2125 | function injectInternals(internals) {
|
2126 | if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ === 'undefined') {
|
2127 |
|
2128 | return false;
|
2129 | }
|
2130 | var hook = __REACT_DEVTOOLS_GLOBAL_HOOK__;
|
2131 | if (hook.isDisabled) {
|
2132 |
|
2133 |
|
2134 |
|
2135 | return true;
|
2136 | }
|
2137 | if (!hook.supportsFiber) {
|
2138 | {
|
2139 | warningWithoutStack$1(false, 'The installed version of React DevTools is too old and will not work ' + 'with the current version of React. Please update React DevTools. ' + 'https://fb.me/react-devtools');
|
2140 | }
|
2141 |
|
2142 | return true;
|
2143 | }
|
2144 | try {
|
2145 | var rendererID = hook.inject(internals);
|
2146 |
|
2147 | onCommitFiberRoot = catchErrors(function (root) {
|
2148 | return hook.onCommitFiberRoot(rendererID, root);
|
2149 | });
|
2150 | onCommitFiberUnmount = catchErrors(function (fiber) {
|
2151 | return hook.onCommitFiberUnmount(rendererID, fiber);
|
2152 | });
|
2153 | } catch (err) {
|
2154 |
|
2155 | {
|
2156 | warningWithoutStack$1(false, 'React DevTools encountered an error: %s.', err);
|
2157 | }
|
2158 | }
|
2159 |
|
2160 | return true;
|
2161 | }
|
2162 |
|
2163 | function onCommitRoot(root) {
|
2164 | if (typeof onCommitFiberRoot === 'function') {
|
2165 | onCommitFiberRoot(root);
|
2166 | }
|
2167 | }
|
2168 |
|
2169 | function onCommitUnmount(fiber) {
|
2170 | if (typeof onCommitFiberUnmount === 'function') {
|
2171 | onCommitFiberUnmount(fiber);
|
2172 | }
|
2173 | }
|
2174 |
|
2175 |
|
2176 |
|
2177 |
|
2178 | var maxSigned31BitInt = 1073741823;
|
2179 |
|
2180 | var NoWork = 0;
|
2181 | var Never = 1;
|
2182 | var Sync = maxSigned31BitInt;
|
2183 |
|
2184 | var UNIT_SIZE = 10;
|
2185 | var MAGIC_NUMBER_OFFSET = maxSigned31BitInt - 1;
|
2186 |
|
2187 |
|
2188 | function msToExpirationTime(ms) {
|
2189 |
|
2190 | return MAGIC_NUMBER_OFFSET - (ms / UNIT_SIZE | 0);
|
2191 | }
|
2192 |
|
2193 | function expirationTimeToMs(expirationTime) {
|
2194 | return (MAGIC_NUMBER_OFFSET - expirationTime) * UNIT_SIZE;
|
2195 | }
|
2196 |
|
2197 | function ceiling(num, precision) {
|
2198 | return ((num / precision | 0) + 1) * precision;
|
2199 | }
|
2200 |
|
2201 | function computeExpirationBucket(currentTime, expirationInMs, bucketSizeMs) {
|
2202 | return MAGIC_NUMBER_OFFSET - ceiling(MAGIC_NUMBER_OFFSET - currentTime + expirationInMs / UNIT_SIZE, bucketSizeMs / UNIT_SIZE);
|
2203 | }
|
2204 |
|
2205 | var LOW_PRIORITY_EXPIRATION = 5000;
|
2206 | var LOW_PRIORITY_BATCH_SIZE = 250;
|
2207 |
|
2208 | function computeAsyncExpiration(currentTime) {
|
2209 | return computeExpirationBucket(currentTime, LOW_PRIORITY_EXPIRATION, LOW_PRIORITY_BATCH_SIZE);
|
2210 | }
|
2211 |
|
2212 |
|
2213 |
|
2214 |
|
2215 |
|
2216 |
|
2217 |
|
2218 |
|
2219 |
|
2220 |
|
2221 |
|
2222 |
|
2223 | var HIGH_PRIORITY_EXPIRATION = 500;
|
2224 | var HIGH_PRIORITY_BATCH_SIZE = 100;
|
2225 |
|
2226 | function computeInteractiveExpiration(currentTime) {
|
2227 | return computeExpirationBucket(currentTime, HIGH_PRIORITY_EXPIRATION, HIGH_PRIORITY_BATCH_SIZE);
|
2228 | }
|
2229 |
|
2230 | var NoContext = 0;
|
2231 | var ConcurrentMode = 1;
|
2232 | var StrictMode = 2;
|
2233 | var ProfileMode = 4;
|
2234 |
|
2235 | var hasBadMapPolyfill = void 0;
|
2236 |
|
2237 | {
|
2238 | hasBadMapPolyfill = false;
|
2239 | try {
|
2240 | var nonExtensibleObject = Object.preventExtensions({});
|
2241 | var testMap = new Map([[nonExtensibleObject, null]]);
|
2242 | var testSet = new Set([nonExtensibleObject]);
|
2243 |
|
2244 |
|
2245 |
|
2246 | testMap.set(0, 0);
|
2247 | testSet.add(0);
|
2248 | } catch (e) {
|
2249 |
|
2250 | hasBadMapPolyfill = true;
|
2251 | }
|
2252 | }
|
2253 |
|
2254 |
|
2255 |
|
2256 |
|
2257 |
|
2258 | var debugCounter = void 0;
|
2259 |
|
2260 | {
|
2261 | debugCounter = 1;
|
2262 | }
|
2263 |
|
2264 | function FiberNode(tag, pendingProps, key, mode) {
|
2265 |
|
2266 | this.tag = tag;
|
2267 | this.key = key;
|
2268 | this.elementType = null;
|
2269 | this.type = null;
|
2270 | this.stateNode = null;
|
2271 |
|
2272 |
|
2273 | this.return = null;
|
2274 | this.child = null;
|
2275 | this.sibling = null;
|
2276 | this.index = 0;
|
2277 |
|
2278 | this.ref = null;
|
2279 |
|
2280 | this.pendingProps = pendingProps;
|
2281 | this.memoizedProps = null;
|
2282 | this.updateQueue = null;
|
2283 | this.memoizedState = null;
|
2284 | this.contextDependencies = null;
|
2285 |
|
2286 | this.mode = mode;
|
2287 |
|
2288 |
|
2289 | this.effectTag = NoEffect;
|
2290 | this.nextEffect = null;
|
2291 |
|
2292 | this.firstEffect = null;
|
2293 | this.lastEffect = null;
|
2294 |
|
2295 | this.expirationTime = NoWork;
|
2296 | this.childExpirationTime = NoWork;
|
2297 |
|
2298 | this.alternate = null;
|
2299 |
|
2300 | if (enableProfilerTimer) {
|
2301 |
|
2302 |
|
2303 |
|
2304 |
|
2305 |
|
2306 |
|
2307 |
|
2308 |
|
2309 |
|
2310 |
|
2311 |
|
2312 |
|
2313 | this.actualDuration = Number.NaN;
|
2314 | this.actualStartTime = Number.NaN;
|
2315 | this.selfBaseDuration = Number.NaN;
|
2316 | this.treeBaseDuration = Number.NaN;
|
2317 |
|
2318 |
|
2319 |
|
2320 |
|
2321 | this.actualDuration = 0;
|
2322 | this.actualStartTime = -1;
|
2323 | this.selfBaseDuration = 0;
|
2324 | this.treeBaseDuration = 0;
|
2325 | }
|
2326 |
|
2327 | {
|
2328 | this._debugID = debugCounter++;
|
2329 | this._debugSource = null;
|
2330 | this._debugOwner = null;
|
2331 | this._debugIsCurrentlyTiming = false;
|
2332 | this._debugHookTypes = null;
|
2333 | if (!hasBadMapPolyfill && typeof Object.preventExtensions === 'function') {
|
2334 | Object.preventExtensions(this);
|
2335 | }
|
2336 | }
|
2337 | }
|
2338 |
|
2339 |
|
2340 |
|
2341 |
|
2342 |
|
2343 |
|
2344 |
|
2345 |
|
2346 |
|
2347 |
|
2348 |
|
2349 |
|
2350 |
|
2351 |
|
2352 | var createFiber = function (tag, pendingProps, key, mode) {
|
2353 |
|
2354 | return new FiberNode(tag, pendingProps, key, mode);
|
2355 | };
|
2356 |
|
2357 | function shouldConstruct(Component) {
|
2358 | var prototype = Component.prototype;
|
2359 | return !!(prototype && prototype.isReactComponent);
|
2360 | }
|
2361 |
|
2362 | function isSimpleFunctionComponent(type) {
|
2363 | return typeof type === 'function' && !shouldConstruct(type) && type.defaultProps === undefined;
|
2364 | }
|
2365 |
|
2366 | function resolveLazyComponentTag(Component) {
|
2367 | if (typeof Component === 'function') {
|
2368 | return shouldConstruct(Component) ? ClassComponent : FunctionComponent;
|
2369 | } else if (Component !== undefined && Component !== null) {
|
2370 | var $$typeof = Component.$$typeof;
|
2371 | if ($$typeof === REACT_FORWARD_REF_TYPE) {
|
2372 | return ForwardRef;
|
2373 | }
|
2374 | if ($$typeof === REACT_MEMO_TYPE) {
|
2375 | return MemoComponent;
|
2376 | }
|
2377 | }
|
2378 | return IndeterminateComponent;
|
2379 | }
|
2380 |
|
2381 |
|
2382 | function createWorkInProgress(current, pendingProps, expirationTime) {
|
2383 | var workInProgress = current.alternate;
|
2384 | if (workInProgress === null) {
|
2385 |
|
2386 |
|
2387 |
|
2388 |
|
2389 |
|
2390 | workInProgress = createFiber(current.tag, pendingProps, current.key, current.mode);
|
2391 | workInProgress.elementType = current.elementType;
|
2392 | workInProgress.type = current.type;
|
2393 | workInProgress.stateNode = current.stateNode;
|
2394 |
|
2395 | {
|
2396 |
|
2397 | workInProgress._debugID = current._debugID;
|
2398 | workInProgress._debugSource = current._debugSource;
|
2399 | workInProgress._debugOwner = current._debugOwner;
|
2400 | workInProgress._debugHookTypes = current._debugHookTypes;
|
2401 | }
|
2402 |
|
2403 | workInProgress.alternate = current;
|
2404 | current.alternate = workInProgress;
|
2405 | } else {
|
2406 | workInProgress.pendingProps = pendingProps;
|
2407 |
|
2408 |
|
2409 |
|
2410 | workInProgress.effectTag = NoEffect;
|
2411 |
|
2412 |
|
2413 | workInProgress.nextEffect = null;
|
2414 | workInProgress.firstEffect = null;
|
2415 | workInProgress.lastEffect = null;
|
2416 |
|
2417 | if (enableProfilerTimer) {
|
2418 |
|
2419 |
|
2420 |
|
2421 |
|
2422 | workInProgress.actualDuration = 0;
|
2423 | workInProgress.actualStartTime = -1;
|
2424 | }
|
2425 | }
|
2426 |
|
2427 | workInProgress.childExpirationTime = current.childExpirationTime;
|
2428 | workInProgress.expirationTime = current.expirationTime;
|
2429 |
|
2430 | workInProgress.child = current.child;
|
2431 | workInProgress.memoizedProps = current.memoizedProps;
|
2432 | workInProgress.memoizedState = current.memoizedState;
|
2433 | workInProgress.updateQueue = current.updateQueue;
|
2434 | workInProgress.contextDependencies = current.contextDependencies;
|
2435 |
|
2436 |
|
2437 | workInProgress.sibling = current.sibling;
|
2438 | workInProgress.index = current.index;
|
2439 | workInProgress.ref = current.ref;
|
2440 |
|
2441 | if (enableProfilerTimer) {
|
2442 | workInProgress.selfBaseDuration = current.selfBaseDuration;
|
2443 | workInProgress.treeBaseDuration = current.treeBaseDuration;
|
2444 | }
|
2445 |
|
2446 | return workInProgress;
|
2447 | }
|
2448 |
|
2449 | function createHostRootFiber(isConcurrent) {
|
2450 | var mode = isConcurrent ? ConcurrentMode | StrictMode : NoContext;
|
2451 |
|
2452 | if (enableProfilerTimer && isDevToolsPresent) {
|
2453 |
|
2454 |
|
2455 |
|
2456 | mode |= ProfileMode;
|
2457 | }
|
2458 |
|
2459 | return createFiber(HostRoot, null, null, mode);
|
2460 | }
|
2461 |
|
2462 | function createFiberFromTypeAndProps(type, // React$ElementType
|
2463 | key, pendingProps, owner, mode, expirationTime) {
|
2464 | var fiber = void 0;
|
2465 |
|
2466 | var fiberTag = IndeterminateComponent;
|
2467 |
|
2468 | var resolvedType = type;
|
2469 | if (typeof type === 'function') {
|
2470 | if (shouldConstruct(type)) {
|
2471 | fiberTag = ClassComponent;
|
2472 | }
|
2473 | } else if (typeof type === 'string') {
|
2474 | fiberTag = HostComponent;
|
2475 | } else {
|
2476 | getTag: switch (type) {
|
2477 | case REACT_FRAGMENT_TYPE:
|
2478 | return createFiberFromFragment(pendingProps.children, mode, expirationTime, key);
|
2479 | case REACT_CONCURRENT_MODE_TYPE:
|
2480 | return createFiberFromMode(pendingProps, mode | ConcurrentMode | StrictMode, expirationTime, key);
|
2481 | case REACT_STRICT_MODE_TYPE:
|
2482 | return createFiberFromMode(pendingProps, mode | StrictMode, expirationTime, key);
|
2483 | case REACT_PROFILER_TYPE:
|
2484 | return createFiberFromProfiler(pendingProps, mode, expirationTime, key);
|
2485 | case REACT_SUSPENSE_TYPE:
|
2486 | return createFiberFromSuspense(pendingProps, mode, expirationTime, key);
|
2487 | default:
|
2488 | {
|
2489 | if (typeof type === 'object' && type !== null) {
|
2490 | switch (type.$$typeof) {
|
2491 | case REACT_PROVIDER_TYPE:
|
2492 | fiberTag = ContextProvider;
|
2493 | break getTag;
|
2494 | case REACT_CONTEXT_TYPE:
|
2495 |
|
2496 | fiberTag = ContextConsumer;
|
2497 | break getTag;
|
2498 | case REACT_FORWARD_REF_TYPE:
|
2499 | fiberTag = ForwardRef;
|
2500 | break getTag;
|
2501 | case REACT_MEMO_TYPE:
|
2502 | fiberTag = MemoComponent;
|
2503 | break getTag;
|
2504 | case REACT_LAZY_TYPE:
|
2505 | fiberTag = LazyComponent;
|
2506 | resolvedType = null;
|
2507 | break getTag;
|
2508 | }
|
2509 | }
|
2510 | var info = '';
|
2511 | {
|
2512 | if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) {
|
2513 | info += ' You likely forgot to export your component from the file ' + "it's defined in, or you might have mixed up default and " + 'named imports.';
|
2514 | }
|
2515 | var ownerName = owner ? getComponentName(owner.type) : null;
|
2516 | if (ownerName) {
|
2517 | info += '\n\nCheck the render method of `' + ownerName + '`.';
|
2518 | }
|
2519 | }
|
2520 | invariant(false, 'Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s', type == null ? type : typeof type, info);
|
2521 | }
|
2522 | }
|
2523 | }
|
2524 |
|
2525 | fiber = createFiber(fiberTag, pendingProps, key, mode);
|
2526 | fiber.elementType = type;
|
2527 | fiber.type = resolvedType;
|
2528 | fiber.expirationTime = expirationTime;
|
2529 |
|
2530 | return fiber;
|
2531 | }
|
2532 |
|
2533 | function createFiberFromElement(element, mode, expirationTime) {
|
2534 | var owner = null;
|
2535 | {
|
2536 | owner = element._owner;
|
2537 | }
|
2538 | var type = element.type;
|
2539 | var key = element.key;
|
2540 | var pendingProps = element.props;
|
2541 | var fiber = createFiberFromTypeAndProps(type, key, pendingProps, owner, mode, expirationTime);
|
2542 | {
|
2543 | fiber._debugSource = element._source;
|
2544 | fiber._debugOwner = element._owner;
|
2545 | }
|
2546 | return fiber;
|
2547 | }
|
2548 |
|
2549 | function createFiberFromFragment(elements, mode, expirationTime, key) {
|
2550 | var fiber = createFiber(Fragment, elements, key, mode);
|
2551 | fiber.expirationTime = expirationTime;
|
2552 | return fiber;
|
2553 | }
|
2554 |
|
2555 | function createFiberFromProfiler(pendingProps, mode, expirationTime, key) {
|
2556 | {
|
2557 | if (typeof pendingProps.id !== 'string' || typeof pendingProps.onRender !== 'function') {
|
2558 | warningWithoutStack$1(false, 'Profiler must specify an "id" string and "onRender" function as props');
|
2559 | }
|
2560 | }
|
2561 |
|
2562 | var fiber = createFiber(Profiler, pendingProps, key, mode | ProfileMode);
|
2563 |
|
2564 | fiber.elementType = REACT_PROFILER_TYPE;
|
2565 | fiber.type = REACT_PROFILER_TYPE;
|
2566 | fiber.expirationTime = expirationTime;
|
2567 |
|
2568 | return fiber;
|
2569 | }
|
2570 |
|
2571 | function createFiberFromMode(pendingProps, mode, expirationTime, key) {
|
2572 | var fiber = createFiber(Mode, pendingProps, key, mode);
|
2573 |
|
2574 |
|
2575 | var type = (mode & ConcurrentMode) === NoContext ? REACT_STRICT_MODE_TYPE : REACT_CONCURRENT_MODE_TYPE;
|
2576 | fiber.elementType = type;
|
2577 | fiber.type = type;
|
2578 |
|
2579 | fiber.expirationTime = expirationTime;
|
2580 | return fiber;
|
2581 | }
|
2582 |
|
2583 | function createFiberFromSuspense(pendingProps, mode, expirationTime, key) {
|
2584 | var fiber = createFiber(SuspenseComponent, pendingProps, key, mode);
|
2585 |
|
2586 |
|
2587 | var type = REACT_SUSPENSE_TYPE;
|
2588 | fiber.elementType = type;
|
2589 | fiber.type = type;
|
2590 |
|
2591 | fiber.expirationTime = expirationTime;
|
2592 | return fiber;
|
2593 | }
|
2594 |
|
2595 | function createFiberFromText(content, mode, expirationTime) {
|
2596 | var fiber = createFiber(HostText, content, null, mode);
|
2597 | fiber.expirationTime = expirationTime;
|
2598 | return fiber;
|
2599 | }
|
2600 |
|
2601 | function createFiberFromHostInstanceForDeletion() {
|
2602 | var fiber = createFiber(HostComponent, null, null, NoContext);
|
2603 |
|
2604 | fiber.elementType = 'DELETED';
|
2605 | fiber.type = 'DELETED';
|
2606 | return fiber;
|
2607 | }
|
2608 |
|
2609 | function createFiberFromPortal(portal, mode, expirationTime) {
|
2610 | var pendingProps = portal.children !== null ? portal.children : [];
|
2611 | var fiber = createFiber(HostPortal, pendingProps, portal.key, mode);
|
2612 | fiber.expirationTime = expirationTime;
|
2613 | fiber.stateNode = {
|
2614 | containerInfo: portal.containerInfo,
|
2615 | pendingChildren: null,
|
2616 | implementation: portal.implementation
|
2617 | };
|
2618 | return fiber;
|
2619 | }
|
2620 |
|
2621 |
|
2622 | function assignFiberPropertiesInDEV(target, source) {
|
2623 | if (target === null) {
|
2624 |
|
2625 |
|
2626 | target = createFiber(IndeterminateComponent, null, null, NoContext);
|
2627 | }
|
2628 |
|
2629 |
|
2630 |
|
2631 |
|
2632 |
|
2633 |
|
2634 |
|
2635 | target.tag = source.tag;
|
2636 | target.key = source.key;
|
2637 | target.elementType = source.elementType;
|
2638 | target.type = source.type;
|
2639 | target.stateNode = source.stateNode;
|
2640 | target.return = source.return;
|
2641 | target.child = source.child;
|
2642 | target.sibling = source.sibling;
|
2643 | target.index = source.index;
|
2644 | target.ref = source.ref;
|
2645 | target.pendingProps = source.pendingProps;
|
2646 | target.memoizedProps = source.memoizedProps;
|
2647 | target.updateQueue = source.updateQueue;
|
2648 | target.memoizedState = source.memoizedState;
|
2649 | target.contextDependencies = source.contextDependencies;
|
2650 | target.mode = source.mode;
|
2651 | target.effectTag = source.effectTag;
|
2652 | target.nextEffect = source.nextEffect;
|
2653 | target.firstEffect = source.firstEffect;
|
2654 | target.lastEffect = source.lastEffect;
|
2655 | target.expirationTime = source.expirationTime;
|
2656 | target.childExpirationTime = source.childExpirationTime;
|
2657 | target.alternate = source.alternate;
|
2658 | if (enableProfilerTimer) {
|
2659 | target.actualDuration = source.actualDuration;
|
2660 | target.actualStartTime = source.actualStartTime;
|
2661 | target.selfBaseDuration = source.selfBaseDuration;
|
2662 | target.treeBaseDuration = source.treeBaseDuration;
|
2663 | }
|
2664 | target._debugID = source._debugID;
|
2665 | target._debugSource = source._debugSource;
|
2666 | target._debugOwner = source._debugOwner;
|
2667 | target._debugIsCurrentlyTiming = source._debugIsCurrentlyTiming;
|
2668 | target._debugHookTypes = source._debugHookTypes;
|
2669 | return target;
|
2670 | }
|
2671 |
|
2672 | var ReactInternals$2 = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
2673 |
|
2674 | var _ReactInternals$Sched$1 = ReactInternals$2.SchedulerTracing;
|
2675 | var __interactionsRef = _ReactInternals$Sched$1.__interactionsRef;
|
2676 | var __subscriberRef = _ReactInternals$Sched$1.__subscriberRef;
|
2677 | var unstable_clear = _ReactInternals$Sched$1.unstable_clear;
|
2678 | var unstable_getCurrent = _ReactInternals$Sched$1.unstable_getCurrent;
|
2679 | var unstable_getThreadID = _ReactInternals$Sched$1.unstable_getThreadID;
|
2680 | var unstable_subscribe = _ReactInternals$Sched$1.unstable_subscribe;
|
2681 | var unstable_trace = _ReactInternals$Sched$1.unstable_trace;
|
2682 | var unstable_unsubscribe = _ReactInternals$Sched$1.unstable_unsubscribe;
|
2683 | var unstable_wrap = _ReactInternals$Sched$1.unstable_wrap;
|
2684 |
|
2685 |
|
2686 |
|
2687 |
|
2688 |
|
2689 |
|
2690 |
|
2691 |
|
2692 |
|
2693 |
|
2694 |
|
2695 |
|
2696 |
|
2697 |
|
2698 |
|
2699 |
|
2700 |
|
2701 | function createFiberRoot(containerInfo, isConcurrent, hydrate) {
|
2702 |
|
2703 |
|
2704 | var uninitializedFiber = createHostRootFiber(isConcurrent);
|
2705 |
|
2706 | var root = void 0;
|
2707 | if (enableSchedulerTracing) {
|
2708 | root = {
|
2709 | current: uninitializedFiber,
|
2710 | containerInfo: containerInfo,
|
2711 | pendingChildren: null,
|
2712 |
|
2713 | earliestPendingTime: NoWork,
|
2714 | latestPendingTime: NoWork,
|
2715 | earliestSuspendedTime: NoWork,
|
2716 | latestSuspendedTime: NoWork,
|
2717 | latestPingedTime: NoWork,
|
2718 |
|
2719 | pingCache: null,
|
2720 |
|
2721 | didError: false,
|
2722 |
|
2723 | pendingCommitExpirationTime: NoWork,
|
2724 | finishedWork: null,
|
2725 | timeoutHandle: noTimeout,
|
2726 | context: null,
|
2727 | pendingContext: null,
|
2728 | hydrate: hydrate,
|
2729 | nextExpirationTimeToWorkOn: NoWork,
|
2730 | expirationTime: NoWork,
|
2731 | firstBatch: null,
|
2732 | nextScheduledRoot: null,
|
2733 |
|
2734 | interactionThreadID: unstable_getThreadID(),
|
2735 | memoizedInteractions: new Set(),
|
2736 | pendingInteractionMap: new Map()
|
2737 | };
|
2738 | } else {
|
2739 | root = {
|
2740 | current: uninitializedFiber,
|
2741 | containerInfo: containerInfo,
|
2742 | pendingChildren: null,
|
2743 |
|
2744 | pingCache: null,
|
2745 |
|
2746 | earliestPendingTime: NoWork,
|
2747 | latestPendingTime: NoWork,
|
2748 | earliestSuspendedTime: NoWork,
|
2749 | latestSuspendedTime: NoWork,
|
2750 | latestPingedTime: NoWork,
|
2751 |
|
2752 | didError: false,
|
2753 |
|
2754 | pendingCommitExpirationTime: NoWork,
|
2755 | finishedWork: null,
|
2756 | timeoutHandle: noTimeout,
|
2757 | context: null,
|
2758 | pendingContext: null,
|
2759 | hydrate: hydrate,
|
2760 | nextExpirationTimeToWorkOn: NoWork,
|
2761 | expirationTime: NoWork,
|
2762 | firstBatch: null,
|
2763 | nextScheduledRoot: null
|
2764 | };
|
2765 | }
|
2766 |
|
2767 | uninitializedFiber.stateNode = root;
|
2768 |
|
2769 |
|
2770 |
|
2771 |
|
2772 |
|
2773 | return root;
|
2774 | }
|
2775 |
|
2776 | var invokeGuardedCallbackImpl = function (name, func, context, a, b, c, d, e, f) {
|
2777 | var funcArgs = Array.prototype.slice.call(arguments, 3);
|
2778 | try {
|
2779 | func.apply(context, funcArgs);
|
2780 | } catch (error) {
|
2781 | this.onError(error);
|
2782 | }
|
2783 | };
|
2784 |
|
2785 | {
|
2786 |
|
2787 |
|
2788 |
|
2789 |
|
2790 |
|
2791 |
|
2792 |
|
2793 |
|
2794 |
|
2795 |
|
2796 |
|
2797 |
|
2798 |
|
2799 |
|
2800 |
|
2801 |
|
2802 |
|
2803 |
|
2804 |
|
2805 |
|
2806 |
|
2807 | if (typeof window !== 'undefined' && typeof window.dispatchEvent === 'function' && typeof document !== 'undefined' && typeof document.createEvent === 'function') {
|
2808 | var fakeNode = document.createElement('react');
|
2809 |
|
2810 | var invokeGuardedCallbackDev = function (name, func, context, a, b, c, d, e, f) {
|
2811 |
|
2812 |
|
2813 |
|
2814 |
|
2815 | !(typeof document !== 'undefined') ? invariant(false, 'The `document` global was defined when React was initialized, but is not defined anymore. This can happen in a test environment if a component schedules an update from an asynchronous callback, but the test has already finished running. To solve this, you can either unmount the component at the end of your test (and ensure that any asynchronous operations get canceled in `componentWillUnmount`), or you can change the test itself to be asynchronous.') : void 0;
|
2816 | var evt = document.createEvent('Event');
|
2817 |
|
2818 |
|
2819 |
|
2820 |
|
2821 |
|
2822 |
|
2823 |
|
2824 | var didError = true;
|
2825 |
|
2826 |
|
2827 |
|
2828 |
|
2829 | var windowEvent = window.event;
|
2830 |
|
2831 |
|
2832 |
|
2833 | var windowEventDescriptor = Object.getOwnPropertyDescriptor(window, 'event');
|
2834 |
|
2835 |
|
2836 |
|
2837 |
|
2838 | var funcArgs = Array.prototype.slice.call(arguments, 3);
|
2839 | function callCallback() {
|
2840 |
|
2841 |
|
2842 |
|
2843 |
|
2844 | fakeNode.removeEventListener(evtType, callCallback, false);
|
2845 |
|
2846 |
|
2847 |
|
2848 |
|
2849 |
|
2850 | if (typeof window.event !== 'undefined' && window.hasOwnProperty('event')) {
|
2851 | window.event = windowEvent;
|
2852 | }
|
2853 |
|
2854 | func.apply(context, funcArgs);
|
2855 | didError = false;
|
2856 | }
|
2857 |
|
2858 |
|
2859 |
|
2860 |
|
2861 |
|
2862 |
|
2863 |
|
2864 |
|
2865 |
|
2866 |
|
2867 |
|
2868 |
|
2869 | var error = void 0;
|
2870 |
|
2871 | var didSetError = false;
|
2872 | var isCrossOriginError = false;
|
2873 |
|
2874 | function handleWindowError(event) {
|
2875 | error = event.error;
|
2876 | didSetError = true;
|
2877 | if (error === null && event.colno === 0 && event.lineno === 0) {
|
2878 | isCrossOriginError = true;
|
2879 | }
|
2880 | if (event.defaultPrevented) {
|
2881 |
|
2882 |
|
2883 |
|
2884 | if (error != null && typeof error === 'object') {
|
2885 | try {
|
2886 | error._suppressLogging = true;
|
2887 | } catch (inner) {
|
2888 |
|
2889 | }
|
2890 | }
|
2891 | }
|
2892 | }
|
2893 |
|
2894 |
|
2895 | var evtType = 'react-' + (name ? name : 'invokeguardedcallback');
|
2896 |
|
2897 |
|
2898 | window.addEventListener('error', handleWindowError);
|
2899 | fakeNode.addEventListener(evtType, callCallback, false);
|
2900 |
|
2901 |
|
2902 |
|
2903 | evt.initEvent(evtType, false, false);
|
2904 | fakeNode.dispatchEvent(evt);
|
2905 |
|
2906 | if (windowEventDescriptor) {
|
2907 | Object.defineProperty(window, 'event', windowEventDescriptor);
|
2908 | }
|
2909 |
|
2910 | if (didError) {
|
2911 | if (!didSetError) {
|
2912 |
|
2913 | error = new Error('An error was thrown inside one of your components, but React ' + "doesn't know what it was. This is likely due to browser " + 'flakiness. React does its best to preserve the "Pause on ' + 'exceptions" behavior of the DevTools, which requires some ' + "DEV-mode only tricks. It's possible that these don't work in " + 'your browser. Try triggering the error in production mode, ' + 'or switching to a modern browser. If you suspect that this is ' + 'actually an issue with React, please file an issue.');
|
2914 | } else if (isCrossOriginError) {
|
2915 | error = new Error("A cross-origin error was thrown. React doesn't have access to " + 'the actual error object in development. ' + 'See https://fb.me/react-crossorigin-error for more information.');
|
2916 | }
|
2917 | this.onError(error);
|
2918 | }
|
2919 |
|
2920 |
|
2921 | window.removeEventListener('error', handleWindowError);
|
2922 | };
|
2923 |
|
2924 | invokeGuardedCallbackImpl = invokeGuardedCallbackDev;
|
2925 | }
|
2926 | }
|
2927 |
|
2928 | var invokeGuardedCallbackImpl$1 = invokeGuardedCallbackImpl;
|
2929 |
|
2930 |
|
2931 | var hasError = false;
|
2932 | var caughtError = null;
|
2933 |
|
2934 | var reporter = {
|
2935 | onError: function (error) {
|
2936 | hasError = true;
|
2937 | caughtError = error;
|
2938 | }
|
2939 | };
|
2940 |
|
2941 |
|
2942 |
|
2943 |
|
2944 |
|
2945 |
|
2946 |
|
2947 |
|
2948 |
|
2949 |
|
2950 |
|
2951 |
|
2952 |
|
2953 |
|
2954 | function invokeGuardedCallback(name, func, context, a, b, c, d, e, f) {
|
2955 | hasError = false;
|
2956 | caughtError = null;
|
2957 | invokeGuardedCallbackImpl$1.apply(reporter, arguments);
|
2958 | }
|
2959 |
|
2960 |
|
2961 |
|
2962 |
|
2963 |
|
2964 |
|
2965 |
|
2966 |
|
2967 |
|
2968 |
|
2969 |
|
2970 |
|
2971 |
|
2972 |
|
2973 |
|
2974 |
|
2975 |
|
2976 |
|
2977 |
|
2978 | function hasCaughtError() {
|
2979 | return hasError;
|
2980 | }
|
2981 |
|
2982 | function clearCaughtError() {
|
2983 | if (hasError) {
|
2984 | var error = caughtError;
|
2985 | hasError = false;
|
2986 | caughtError = null;
|
2987 | return error;
|
2988 | } else {
|
2989 | invariant(false, 'clearCaughtError was called but no error was captured. This error is likely caused by a bug in React. Please file an issue.');
|
2990 | }
|
2991 | }
|
2992 |
|
2993 |
|
2994 |
|
2995 |
|
2996 |
|
2997 |
|
2998 |
|
2999 |
|
3000 |
|
3001 |
|
3002 |
|
3003 |
|
3004 |
|
3005 |
|
3006 |
|
3007 | var lowPriorityWarning = function () {};
|
3008 |
|
3009 | {
|
3010 | var printWarning$1 = function (format) {
|
3011 | for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
3012 | args[_key - 1] = arguments[_key];
|
3013 | }
|
3014 |
|
3015 | var argIndex = 0;
|
3016 | var message = 'Warning: ' + format.replace(/%s/g, function () {
|
3017 | return args[argIndex++];
|
3018 | });
|
3019 | if (typeof console !== 'undefined') {
|
3020 | console.warn(message);
|
3021 | }
|
3022 | try {
|
3023 |
|
3024 |
|
3025 |
|
3026 | throw new Error(message);
|
3027 | } catch (x) {}
|
3028 | };
|
3029 |
|
3030 | lowPriorityWarning = function (condition, format) {
|
3031 | if (format === undefined) {
|
3032 | throw new Error('`lowPriorityWarning(condition, format, ...args)` requires a warning ' + 'message argument');
|
3033 | }
|
3034 | if (!condition) {
|
3035 | for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
|
3036 | args[_key2 - 2] = arguments[_key2];
|
3037 | }
|
3038 |
|
3039 | printWarning$1.apply(undefined, [format].concat(args));
|
3040 | }
|
3041 | };
|
3042 | }
|
3043 |
|
3044 | var lowPriorityWarning$1 = lowPriorityWarning;
|
3045 |
|
3046 | var ReactStrictModeWarnings = {
|
3047 | discardPendingWarnings: function () {},
|
3048 | flushPendingDeprecationWarnings: function () {},
|
3049 | flushPendingUnsafeLifecycleWarnings: function () {},
|
3050 | recordDeprecationWarnings: function (fiber, instance) {},
|
3051 | recordUnsafeLifecycleWarnings: function (fiber, instance) {},
|
3052 | recordLegacyContextWarning: function (fiber, instance) {},
|
3053 | flushLegacyContextWarning: function () {}
|
3054 | };
|
3055 |
|
3056 | {
|
3057 | var LIFECYCLE_SUGGESTIONS = {
|
3058 | UNSAFE_componentWillMount: 'componentDidMount',
|
3059 | UNSAFE_componentWillReceiveProps: 'static getDerivedStateFromProps',
|
3060 | UNSAFE_componentWillUpdate: 'componentDidUpdate'
|
3061 | };
|
3062 |
|
3063 | var pendingComponentWillMountWarnings = [];
|
3064 | var pendingComponentWillReceivePropsWarnings = [];
|
3065 | var pendingComponentWillUpdateWarnings = [];
|
3066 | var pendingUnsafeLifecycleWarnings = new Map();
|
3067 | var pendingLegacyContextWarning = new Map();
|
3068 |
|
3069 |
|
3070 | var didWarnAboutDeprecatedLifecycles = new Set();
|
3071 | var didWarnAboutUnsafeLifecycles = new Set();
|
3072 | var didWarnAboutLegacyContext = new Set();
|
3073 |
|
3074 | var setToSortedString = function (set) {
|
3075 | var array = [];
|
3076 | set.forEach(function (value) {
|
3077 | array.push(value);
|
3078 | });
|
3079 | return array.sort().join(', ');
|
3080 | };
|
3081 |
|
3082 | ReactStrictModeWarnings.discardPendingWarnings = function () {
|
3083 | pendingComponentWillMountWarnings = [];
|
3084 | pendingComponentWillReceivePropsWarnings = [];
|
3085 | pendingComponentWillUpdateWarnings = [];
|
3086 | pendingUnsafeLifecycleWarnings = new Map();
|
3087 | pendingLegacyContextWarning = new Map();
|
3088 | };
|
3089 |
|
3090 | ReactStrictModeWarnings.flushPendingUnsafeLifecycleWarnings = function () {
|
3091 | pendingUnsafeLifecycleWarnings.forEach(function (lifecycleWarningsMap, strictRoot) {
|
3092 | var lifecyclesWarningMessages = [];
|
3093 |
|
3094 | Object.keys(lifecycleWarningsMap).forEach(function (lifecycle) {
|
3095 | var lifecycleWarnings = lifecycleWarningsMap[lifecycle];
|
3096 | if (lifecycleWarnings.length > 0) {
|
3097 | var componentNames = new Set();
|
3098 | lifecycleWarnings.forEach(function (fiber) {
|
3099 | componentNames.add(getComponentName(fiber.type) || 'Component');
|
3100 | didWarnAboutUnsafeLifecycles.add(fiber.type);
|
3101 | });
|
3102 |
|
3103 | var formatted = lifecycle.replace('UNSAFE_', '');
|
3104 | var suggestion = LIFECYCLE_SUGGESTIONS[lifecycle];
|
3105 | var sortedComponentNames = setToSortedString(componentNames);
|
3106 |
|
3107 | lifecyclesWarningMessages.push(formatted + ': Please update the following components to use ' + (suggestion + ' instead: ' + sortedComponentNames));
|
3108 | }
|
3109 | });
|
3110 |
|
3111 | if (lifecyclesWarningMessages.length > 0) {
|
3112 | var strictRootComponentStack = getStackByFiberInDevAndProd(strictRoot);
|
3113 |
|
3114 | warningWithoutStack$1(false, 'Unsafe lifecycle methods were found within a strict-mode tree:%s' + '\n\n%s' + '\n\nLearn more about this warning here:' + '\nhttps://fb.me/react-strict-mode-warnings', strictRootComponentStack, lifecyclesWarningMessages.join('\n\n'));
|
3115 | }
|
3116 | });
|
3117 |
|
3118 | pendingUnsafeLifecycleWarnings = new Map();
|
3119 | };
|
3120 |
|
3121 | var findStrictRoot = function (fiber) {
|
3122 | var maybeStrictRoot = null;
|
3123 |
|
3124 | var node = fiber;
|
3125 | while (node !== null) {
|
3126 | if (node.mode & StrictMode) {
|
3127 | maybeStrictRoot = node;
|
3128 | }
|
3129 | node = node.return;
|
3130 | }
|
3131 |
|
3132 | return maybeStrictRoot;
|
3133 | };
|
3134 |
|
3135 | ReactStrictModeWarnings.flushPendingDeprecationWarnings = function () {
|
3136 | if (pendingComponentWillMountWarnings.length > 0) {
|
3137 | var uniqueNames = new Set();
|
3138 | pendingComponentWillMountWarnings.forEach(function (fiber) {
|
3139 | uniqueNames.add(getComponentName(fiber.type) || 'Component');
|
3140 | didWarnAboutDeprecatedLifecycles.add(fiber.type);
|
3141 | });
|
3142 |
|
3143 | var sortedNames = setToSortedString(uniqueNames);
|
3144 |
|
3145 | lowPriorityWarning$1(false, 'componentWillMount is deprecated and will be removed in the next major version. ' + 'Use componentDidMount instead. As a temporary workaround, ' + 'you can rename to UNSAFE_componentWillMount.' + '\n\nPlease update the following components: %s' + '\n\nLearn more about this warning here:' + '\nhttps://fb.me/react-async-component-lifecycle-hooks', sortedNames);
|
3146 |
|
3147 | pendingComponentWillMountWarnings = [];
|
3148 | }
|
3149 |
|
3150 | if (pendingComponentWillReceivePropsWarnings.length > 0) {
|
3151 | var _uniqueNames = new Set();
|
3152 | pendingComponentWillReceivePropsWarnings.forEach(function (fiber) {
|
3153 | _uniqueNames.add(getComponentName(fiber.type) || 'Component');
|
3154 | didWarnAboutDeprecatedLifecycles.add(fiber.type);
|
3155 | });
|
3156 |
|
3157 | var _sortedNames = setToSortedString(_uniqueNames);
|
3158 |
|
3159 | lowPriorityWarning$1(false, 'componentWillReceiveProps is deprecated and will be removed in the next major version. ' + 'Use static getDerivedStateFromProps instead.' + '\n\nPlease update the following components: %s' + '\n\nLearn more about this warning here:' + '\nhttps://fb.me/react-async-component-lifecycle-hooks', _sortedNames);
|
3160 |
|
3161 | pendingComponentWillReceivePropsWarnings = [];
|
3162 | }
|
3163 |
|
3164 | if (pendingComponentWillUpdateWarnings.length > 0) {
|
3165 | var _uniqueNames2 = new Set();
|
3166 | pendingComponentWillUpdateWarnings.forEach(function (fiber) {
|
3167 | _uniqueNames2.add(getComponentName(fiber.type) || 'Component');
|
3168 | didWarnAboutDeprecatedLifecycles.add(fiber.type);
|
3169 | });
|
3170 |
|
3171 | var _sortedNames2 = setToSortedString(_uniqueNames2);
|
3172 |
|
3173 | lowPriorityWarning$1(false, 'componentWillUpdate is deprecated and will be removed in the next major version. ' + 'Use componentDidUpdate instead. As a temporary workaround, ' + 'you can rename to UNSAFE_componentWillUpdate.' + '\n\nPlease update the following components: %s' + '\n\nLearn more about this warning here:' + '\nhttps://fb.me/react-async-component-lifecycle-hooks', _sortedNames2);
|
3174 |
|
3175 | pendingComponentWillUpdateWarnings = [];
|
3176 | }
|
3177 | };
|
3178 |
|
3179 | ReactStrictModeWarnings.recordDeprecationWarnings = function (fiber, instance) {
|
3180 |
|
3181 | if (didWarnAboutDeprecatedLifecycles.has(fiber.type)) {
|
3182 | return;
|
3183 | }
|
3184 |
|
3185 |
|
3186 | if (typeof instance.componentWillMount === 'function' && instance.componentWillMount.__suppressDeprecationWarning !== true) {
|
3187 | pendingComponentWillMountWarnings.push(fiber);
|
3188 | }
|
3189 | if (typeof instance.componentWillReceiveProps === 'function' && instance.componentWillReceiveProps.__suppressDeprecationWarning !== true) {
|
3190 | pendingComponentWillReceivePropsWarnings.push(fiber);
|
3191 | }
|
3192 | if (typeof instance.componentWillUpdate === 'function' && instance.componentWillUpdate.__suppressDeprecationWarning !== true) {
|
3193 | pendingComponentWillUpdateWarnings.push(fiber);
|
3194 | }
|
3195 | };
|
3196 |
|
3197 | ReactStrictModeWarnings.recordUnsafeLifecycleWarnings = function (fiber, instance) {
|
3198 | var strictRoot = findStrictRoot(fiber);
|
3199 | if (strictRoot === null) {
|
3200 | warningWithoutStack$1(false, 'Expected to find a StrictMode component in a strict mode tree. ' + 'This error is likely caused by a bug in React. Please file an issue.');
|
3201 | return;
|
3202 | }
|
3203 |
|
3204 |
|
3205 |
|
3206 |
|
3207 |
|
3208 |
|
3209 | if (didWarnAboutUnsafeLifecycles.has(fiber.type)) {
|
3210 | return;
|
3211 | }
|
3212 |
|
3213 | var warningsForRoot = void 0;
|
3214 | if (!pendingUnsafeLifecycleWarnings.has(strictRoot)) {
|
3215 | warningsForRoot = {
|
3216 | UNSAFE_componentWillMount: [],
|
3217 | UNSAFE_componentWillReceiveProps: [],
|
3218 | UNSAFE_componentWillUpdate: []
|
3219 | };
|
3220 |
|
3221 | pendingUnsafeLifecycleWarnings.set(strictRoot, warningsForRoot);
|
3222 | } else {
|
3223 | warningsForRoot = pendingUnsafeLifecycleWarnings.get(strictRoot);
|
3224 | }
|
3225 |
|
3226 | var unsafeLifecycles = [];
|
3227 | if (typeof instance.componentWillMount === 'function' && instance.componentWillMount.__suppressDeprecationWarning !== true || typeof instance.UNSAFE_componentWillMount === 'function') {
|
3228 | unsafeLifecycles.push('UNSAFE_componentWillMount');
|
3229 | }
|
3230 | if (typeof instance.componentWillReceiveProps === 'function' && instance.componentWillReceiveProps.__suppressDeprecationWarning !== true || typeof instance.UNSAFE_componentWillReceiveProps === 'function') {
|
3231 | unsafeLifecycles.push('UNSAFE_componentWillReceiveProps');
|
3232 | }
|
3233 | if (typeof instance.componentWillUpdate === 'function' && instance.componentWillUpdate.__suppressDeprecationWarning !== true || typeof instance.UNSAFE_componentWillUpdate === 'function') {
|
3234 | unsafeLifecycles.push('UNSAFE_componentWillUpdate');
|
3235 | }
|
3236 |
|
3237 | if (unsafeLifecycles.length > 0) {
|
3238 | unsafeLifecycles.forEach(function (lifecycle) {
|
3239 | warningsForRoot[lifecycle].push(fiber);
|
3240 | });
|
3241 | }
|
3242 | };
|
3243 |
|
3244 | ReactStrictModeWarnings.recordLegacyContextWarning = function (fiber, instance) {
|
3245 | var strictRoot = findStrictRoot(fiber);
|
3246 | if (strictRoot === null) {
|
3247 | warningWithoutStack$1(false, 'Expected to find a StrictMode component in a strict mode tree. ' + 'This error is likely caused by a bug in React. Please file an issue.');
|
3248 | return;
|
3249 | }
|
3250 |
|
3251 |
|
3252 | if (didWarnAboutLegacyContext.has(fiber.type)) {
|
3253 | return;
|
3254 | }
|
3255 |
|
3256 | var warningsForRoot = pendingLegacyContextWarning.get(strictRoot);
|
3257 |
|
3258 | if (fiber.type.contextTypes != null || fiber.type.childContextTypes != null || instance !== null && typeof instance.getChildContext === 'function') {
|
3259 | if (warningsForRoot === undefined) {
|
3260 | warningsForRoot = [];
|
3261 | pendingLegacyContextWarning.set(strictRoot, warningsForRoot);
|
3262 | }
|
3263 | warningsForRoot.push(fiber);
|
3264 | }
|
3265 | };
|
3266 |
|
3267 | ReactStrictModeWarnings.flushLegacyContextWarning = function () {
|
3268 | pendingLegacyContextWarning.forEach(function (fiberArray, strictRoot) {
|
3269 | var uniqueNames = new Set();
|
3270 | fiberArray.forEach(function (fiber) {
|
3271 | uniqueNames.add(getComponentName(fiber.type) || 'Component');
|
3272 | didWarnAboutLegacyContext.add(fiber.type);
|
3273 | });
|
3274 |
|
3275 | var sortedNames = setToSortedString(uniqueNames);
|
3276 | var strictRootComponentStack = getStackByFiberInDevAndProd(strictRoot);
|
3277 |
|
3278 | warningWithoutStack$1(false, 'Legacy context API has been detected within a strict-mode tree: %s' + '\n\nPlease update the following components: %s' + '\n\nLearn more about this warning here:' + '\nhttps://fb.me/react-strict-mode-warnings', strictRootComponentStack, sortedNames);
|
3279 | });
|
3280 | };
|
3281 | }
|
3282 |
|
3283 |
|
3284 |
|
3285 |
|
3286 |
|
3287 | var ReactFiberInstrumentation = {
|
3288 | debugTool: null
|
3289 | };
|
3290 |
|
3291 | var ReactFiberInstrumentation_1 = ReactFiberInstrumentation;
|
3292 |
|
3293 |
|
3294 |
|
3295 |
|
3296 |
|
3297 | function markPendingPriorityLevel(root, expirationTime) {
|
3298 |
|
3299 |
|
3300 |
|
3301 | root.didError = false;
|
3302 |
|
3303 |
|
3304 | var earliestPendingTime = root.earliestPendingTime;
|
3305 | if (earliestPendingTime === NoWork) {
|
3306 |
|
3307 | root.earliestPendingTime = root.latestPendingTime = expirationTime;
|
3308 | } else {
|
3309 | if (earliestPendingTime < expirationTime) {
|
3310 |
|
3311 | root.earliestPendingTime = expirationTime;
|
3312 | } else {
|
3313 | var latestPendingTime = root.latestPendingTime;
|
3314 | if (latestPendingTime > expirationTime) {
|
3315 |
|
3316 | root.latestPendingTime = expirationTime;
|
3317 | }
|
3318 | }
|
3319 | }
|
3320 | findNextExpirationTimeToWorkOn(expirationTime, root);
|
3321 | }
|
3322 |
|
3323 | function markCommittedPriorityLevels(root, earliestRemainingTime) {
|
3324 | root.didError = false;
|
3325 |
|
3326 | if (earliestRemainingTime === NoWork) {
|
3327 |
|
3328 | root.earliestPendingTime = NoWork;
|
3329 | root.latestPendingTime = NoWork;
|
3330 | root.earliestSuspendedTime = NoWork;
|
3331 | root.latestSuspendedTime = NoWork;
|
3332 | root.latestPingedTime = NoWork;
|
3333 | findNextExpirationTimeToWorkOn(NoWork, root);
|
3334 | return;
|
3335 | }
|
3336 |
|
3337 | if (earliestRemainingTime < root.latestPingedTime) {
|
3338 | root.latestPingedTime = NoWork;
|
3339 | }
|
3340 |
|
3341 |
|
3342 | var latestPendingTime = root.latestPendingTime;
|
3343 | if (latestPendingTime !== NoWork) {
|
3344 | if (latestPendingTime > earliestRemainingTime) {
|
3345 |
|
3346 | root.earliestPendingTime = root.latestPendingTime = NoWork;
|
3347 | } else {
|
3348 | var earliestPendingTime = root.earliestPendingTime;
|
3349 | if (earliestPendingTime > earliestRemainingTime) {
|
3350 |
|
3351 |
|
3352 | root.earliestPendingTime = root.latestPendingTime;
|
3353 | }
|
3354 | }
|
3355 | }
|
3356 |
|
3357 |
|
3358 |
|
3359 |
|
3360 |
|
3361 | var earliestSuspendedTime = root.earliestSuspendedTime;
|
3362 | if (earliestSuspendedTime === NoWork) {
|
3363 |
|
3364 |
|
3365 | markPendingPriorityLevel(root, earliestRemainingTime);
|
3366 | findNextExpirationTimeToWorkOn(NoWork, root);
|
3367 | return;
|
3368 | }
|
3369 |
|
3370 | var latestSuspendedTime = root.latestSuspendedTime;
|
3371 | if (earliestRemainingTime < latestSuspendedTime) {
|
3372 |
|
3373 |
|
3374 | root.earliestSuspendedTime = NoWork;
|
3375 | root.latestSuspendedTime = NoWork;
|
3376 | root.latestPingedTime = NoWork;
|
3377 |
|
3378 |
|
3379 |
|
3380 | markPendingPriorityLevel(root, earliestRemainingTime);
|
3381 | findNextExpirationTimeToWorkOn(NoWork, root);
|
3382 | return;
|
3383 | }
|
3384 |
|
3385 | if (earliestRemainingTime > earliestSuspendedTime) {
|
3386 |
|
3387 |
|
3388 | markPendingPriorityLevel(root, earliestRemainingTime);
|
3389 | findNextExpirationTimeToWorkOn(NoWork, root);
|
3390 | return;
|
3391 | }
|
3392 |
|
3393 |
|
3394 |
|
3395 | findNextExpirationTimeToWorkOn(NoWork, root);
|
3396 | }
|
3397 |
|
3398 | function hasLowerPriorityWork(root, erroredExpirationTime) {
|
3399 | var latestPendingTime = root.latestPendingTime;
|
3400 | var latestSuspendedTime = root.latestSuspendedTime;
|
3401 | var latestPingedTime = root.latestPingedTime;
|
3402 | return latestPendingTime !== NoWork && latestPendingTime < erroredExpirationTime || latestSuspendedTime !== NoWork && latestSuspendedTime < erroredExpirationTime || latestPingedTime !== NoWork && latestPingedTime < erroredExpirationTime;
|
3403 | }
|
3404 |
|
3405 | function isPriorityLevelSuspended(root, expirationTime) {
|
3406 | var earliestSuspendedTime = root.earliestSuspendedTime;
|
3407 | var latestSuspendedTime = root.latestSuspendedTime;
|
3408 | return earliestSuspendedTime !== NoWork && expirationTime <= earliestSuspendedTime && expirationTime >= latestSuspendedTime;
|
3409 | }
|
3410 |
|
3411 | function markSuspendedPriorityLevel(root, suspendedTime) {
|
3412 | root.didError = false;
|
3413 | clearPing(root, suspendedTime);
|
3414 |
|
3415 |
|
3416 | var earliestPendingTime = root.earliestPendingTime;
|
3417 | var latestPendingTime = root.latestPendingTime;
|
3418 | if (earliestPendingTime === suspendedTime) {
|
3419 | if (latestPendingTime === suspendedTime) {
|
3420 |
|
3421 | root.earliestPendingTime = root.latestPendingTime = NoWork;
|
3422 | } else {
|
3423 |
|
3424 |
|
3425 | root.earliestPendingTime = latestPendingTime;
|
3426 | }
|
3427 | } else if (latestPendingTime === suspendedTime) {
|
3428 |
|
3429 |
|
3430 | root.latestPendingTime = earliestPendingTime;
|
3431 | }
|
3432 |
|
3433 |
|
3434 | var earliestSuspendedTime = root.earliestSuspendedTime;
|
3435 | var latestSuspendedTime = root.latestSuspendedTime;
|
3436 | if (earliestSuspendedTime === NoWork) {
|
3437 |
|
3438 | root.earliestSuspendedTime = root.latestSuspendedTime = suspendedTime;
|
3439 | } else {
|
3440 | if (earliestSuspendedTime < suspendedTime) {
|
3441 |
|
3442 | root.earliestSuspendedTime = suspendedTime;
|
3443 | } else if (latestSuspendedTime > suspendedTime) {
|
3444 |
|
3445 | root.latestSuspendedTime = suspendedTime;
|
3446 | }
|
3447 | }
|
3448 |
|
3449 | findNextExpirationTimeToWorkOn(suspendedTime, root);
|
3450 | }
|
3451 |
|
3452 | function markPingedPriorityLevel(root, pingedTime) {
|
3453 | root.didError = false;
|
3454 |
|
3455 |
|
3456 |
|
3457 |
|
3458 | var latestPingedTime = root.latestPingedTime;
|
3459 | if (latestPingedTime === NoWork || latestPingedTime > pingedTime) {
|
3460 | root.latestPingedTime = pingedTime;
|
3461 | }
|
3462 | findNextExpirationTimeToWorkOn(pingedTime, root);
|
3463 | }
|
3464 |
|
3465 | function clearPing(root, completedTime) {
|
3466 | var latestPingedTime = root.latestPingedTime;
|
3467 | if (latestPingedTime >= completedTime) {
|
3468 | root.latestPingedTime = NoWork;
|
3469 | }
|
3470 | }
|
3471 |
|
3472 | function findEarliestOutstandingPriorityLevel(root, renderExpirationTime) {
|
3473 | var earliestExpirationTime = renderExpirationTime;
|
3474 |
|
3475 | var earliestPendingTime = root.earliestPendingTime;
|
3476 | var earliestSuspendedTime = root.earliestSuspendedTime;
|
3477 | if (earliestPendingTime > earliestExpirationTime) {
|
3478 | earliestExpirationTime = earliestPendingTime;
|
3479 | }
|
3480 | if (earliestSuspendedTime > earliestExpirationTime) {
|
3481 | earliestExpirationTime = earliestSuspendedTime;
|
3482 | }
|
3483 | return earliestExpirationTime;
|
3484 | }
|
3485 |
|
3486 | function didExpireAtExpirationTime(root, currentTime) {
|
3487 | var expirationTime = root.expirationTime;
|
3488 | if (expirationTime !== NoWork && currentTime <= expirationTime) {
|
3489 |
|
3490 | root.nextExpirationTimeToWorkOn = currentTime;
|
3491 | }
|
3492 | }
|
3493 |
|
3494 | function findNextExpirationTimeToWorkOn(completedExpirationTime, root) {
|
3495 | var earliestSuspendedTime = root.earliestSuspendedTime;
|
3496 | var latestSuspendedTime = root.latestSuspendedTime;
|
3497 | var earliestPendingTime = root.earliestPendingTime;
|
3498 | var latestPingedTime = root.latestPingedTime;
|
3499 |
|
3500 |
|
3501 |
|
3502 | var nextExpirationTimeToWorkOn = earliestPendingTime !== NoWork ? earliestPendingTime : latestPingedTime;
|
3503 |
|
3504 |
|
3505 |
|
3506 | if (nextExpirationTimeToWorkOn === NoWork && (completedExpirationTime === NoWork || latestSuspendedTime < completedExpirationTime)) {
|
3507 |
|
3508 |
|
3509 |
|
3510 | nextExpirationTimeToWorkOn = latestSuspendedTime;
|
3511 | }
|
3512 |
|
3513 | var expirationTime = nextExpirationTimeToWorkOn;
|
3514 | if (expirationTime !== NoWork && earliestSuspendedTime > expirationTime) {
|
3515 |
|
3516 | expirationTime = earliestSuspendedTime;
|
3517 | }
|
3518 |
|
3519 | root.nextExpirationTimeToWorkOn = nextExpirationTimeToWorkOn;
|
3520 | root.expirationTime = expirationTime;
|
3521 | }
|
3522 |
|
3523 |
|
3524 |
|
3525 |
|
3526 |
|
3527 |
|
3528 |
|
3529 |
|
3530 | var warning = warningWithoutStack$1;
|
3531 |
|
3532 | {
|
3533 | warning = function (condition, format) {
|
3534 | if (condition) {
|
3535 | return;
|
3536 | }
|
3537 | var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
|
3538 | var stack = ReactDebugCurrentFrame.getStackAddendum();
|
3539 |
|
3540 |
|
3541 | for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
3542 | args[_key - 2] = arguments[_key];
|
3543 | }
|
3544 |
|
3545 | warningWithoutStack$1.apply(undefined, [false, format + '%s'].concat(args, [stack]));
|
3546 | };
|
3547 | }
|
3548 |
|
3549 | var warning$1 = warning;
|
3550 |
|
3551 |
|
3552 |
|
3553 |
|
3554 |
|
3555 | function is(x, y) {
|
3556 | return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y
|
3557 | ;
|
3558 | }
|
3559 |
|
3560 | var hasOwnProperty = Object.prototype.hasOwnProperty;
|
3561 |
|
3562 |
|
3563 |
|
3564 |
|
3565 |
|
3566 |
|
3567 | function shallowEqual(objA, objB) {
|
3568 | if (is(objA, objB)) {
|
3569 | return true;
|
3570 | }
|
3571 |
|
3572 | if (typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null) {
|
3573 | return false;
|
3574 | }
|
3575 |
|
3576 | var keysA = Object.keys(objA);
|
3577 | var keysB = Object.keys(objB);
|
3578 |
|
3579 | if (keysA.length !== keysB.length) {
|
3580 | return false;
|
3581 | }
|
3582 |
|
3583 |
|
3584 | for (var i = 0; i < keysA.length; i++) {
|
3585 | if (!hasOwnProperty.call(objB, keysA[i]) || !is(objA[keysA[i]], objB[keysA[i]])) {
|
3586 | return false;
|
3587 | }
|
3588 | }
|
3589 |
|
3590 | return true;
|
3591 | }
|
3592 |
|
3593 | function resolveDefaultProps(Component, baseProps) {
|
3594 | if (Component && Component.defaultProps) {
|
3595 |
|
3596 | var props = _assign({}, baseProps);
|
3597 | var defaultProps = Component.defaultProps;
|
3598 | for (var propName in defaultProps) {
|
3599 | if (props[propName] === undefined) {
|
3600 | props[propName] = defaultProps[propName];
|
3601 | }
|
3602 | }
|
3603 | return props;
|
3604 | }
|
3605 | return baseProps;
|
3606 | }
|
3607 |
|
3608 | function readLazyComponentType(lazyComponent) {
|
3609 | var status = lazyComponent._status;
|
3610 | var result = lazyComponent._result;
|
3611 | switch (status) {
|
3612 | case Resolved:
|
3613 | {
|
3614 | var Component = result;
|
3615 | return Component;
|
3616 | }
|
3617 | case Rejected:
|
3618 | {
|
3619 | var error = result;
|
3620 | throw error;
|
3621 | }
|
3622 | case Pending:
|
3623 | {
|
3624 | var thenable = result;
|
3625 | throw thenable;
|
3626 | }
|
3627 | default:
|
3628 | {
|
3629 | lazyComponent._status = Pending;
|
3630 | var ctor = lazyComponent._ctor;
|
3631 | var _thenable = ctor();
|
3632 | _thenable.then(function (moduleObject) {
|
3633 | if (lazyComponent._status === Pending) {
|
3634 | var defaultExport = moduleObject.default;
|
3635 | {
|
3636 | if (defaultExport === undefined) {
|
3637 | warning$1(false, 'lazy: Expected the result of a dynamic import() call. ' + 'Instead received: %s\n\nYour code should look like: \n ' + "const MyComponent = lazy(() => import('./MyComponent'))", moduleObject);
|
3638 | }
|
3639 | }
|
3640 | lazyComponent._status = Resolved;
|
3641 | lazyComponent._result = defaultExport;
|
3642 | }
|
3643 | }, function (error) {
|
3644 | if (lazyComponent._status === Pending) {
|
3645 | lazyComponent._status = Rejected;
|
3646 | lazyComponent._result = error;
|
3647 | }
|
3648 | });
|
3649 |
|
3650 | switch (lazyComponent._status) {
|
3651 | case Resolved:
|
3652 | return lazyComponent._result;
|
3653 | case Rejected:
|
3654 | throw lazyComponent._result;
|
3655 | }
|
3656 | lazyComponent._result = _thenable;
|
3657 | throw _thenable;
|
3658 | }
|
3659 | }
|
3660 | }
|
3661 |
|
3662 | var fakeInternalInstance = {};
|
3663 | var isArray$1 = Array.isArray;
|
3664 |
|
3665 |
|
3666 |
|
3667 | var emptyRefsObject = new React.Component().refs;
|
3668 |
|
3669 | var didWarnAboutStateAssignmentForComponent = void 0;
|
3670 | var didWarnAboutUninitializedState = void 0;
|
3671 | var didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate = void 0;
|
3672 | var didWarnAboutLegacyLifecyclesAndDerivedState = void 0;
|
3673 | var didWarnAboutUndefinedDerivedState = void 0;
|
3674 | var warnOnUndefinedDerivedState = void 0;
|
3675 | var warnOnInvalidCallback = void 0;
|
3676 | var didWarnAboutDirectlyAssigningPropsToState = void 0;
|
3677 | var didWarnAboutContextTypeAndContextTypes = void 0;
|
3678 | var didWarnAboutInvalidateContextType = void 0;
|
3679 |
|
3680 | {
|
3681 | didWarnAboutStateAssignmentForComponent = new Set();
|
3682 | didWarnAboutUninitializedState = new Set();
|
3683 | didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate = new Set();
|
3684 | didWarnAboutLegacyLifecyclesAndDerivedState = new Set();
|
3685 | didWarnAboutDirectlyAssigningPropsToState = new Set();
|
3686 | didWarnAboutUndefinedDerivedState = new Set();
|
3687 | didWarnAboutContextTypeAndContextTypes = new Set();
|
3688 | didWarnAboutInvalidateContextType = new Set();
|
3689 |
|
3690 | var didWarnOnInvalidCallback = new Set();
|
3691 |
|
3692 | warnOnInvalidCallback = function (callback, callerName) {
|
3693 | if (callback === null || typeof callback === 'function') {
|
3694 | return;
|
3695 | }
|
3696 | var key = callerName + '_' + callback;
|
3697 | if (!didWarnOnInvalidCallback.has(key)) {
|
3698 | didWarnOnInvalidCallback.add(key);
|
3699 | warningWithoutStack$1(false, '%s(...): Expected the last optional `callback` argument to be a ' + 'function. Instead received: %s.', callerName, callback);
|
3700 | }
|
3701 | };
|
3702 |
|
3703 | warnOnUndefinedDerivedState = function (type, partialState) {
|
3704 | if (partialState === undefined) {
|
3705 | var componentName = getComponentName(type) || 'Component';
|
3706 | if (!didWarnAboutUndefinedDerivedState.has(componentName)) {
|
3707 | didWarnAboutUndefinedDerivedState.add(componentName);
|
3708 | warningWithoutStack$1(false, '%s.getDerivedStateFromProps(): A valid state object (or null) must be returned. ' + 'You have returned undefined.', componentName);
|
3709 | }
|
3710 | }
|
3711 | };
|
3712 |
|
3713 |
|
3714 |
|
3715 |
|
3716 |
|
3717 |
|
3718 | Object.defineProperty(fakeInternalInstance, '_processChildContext', {
|
3719 | enumerable: false,
|
3720 | value: function () {
|
3721 | invariant(false, '_processChildContext is not available in React 16+. This likely means you have multiple copies of React and are attempting to nest a React 15 tree inside a React 16 tree using unstable_renderSubtreeIntoContainer, which isn\'t supported. Try to make sure you have only one copy of React (and ideally, switch to ReactDOM.createPortal).');
|
3722 | }
|
3723 | });
|
3724 | Object.freeze(fakeInternalInstance);
|
3725 | }
|
3726 |
|
3727 | function applyDerivedStateFromProps(workInProgress, ctor, getDerivedStateFromProps, nextProps) {
|
3728 | var prevState = workInProgress.memoizedState;
|
3729 |
|
3730 | {
|
3731 | if (debugRenderPhaseSideEffects || debugRenderPhaseSideEffectsForStrictMode && workInProgress.mode & StrictMode) {
|
3732 |
|
3733 | getDerivedStateFromProps(nextProps, prevState);
|
3734 | }
|
3735 | }
|
3736 |
|
3737 | var partialState = getDerivedStateFromProps(nextProps, prevState);
|
3738 |
|
3739 | {
|
3740 | warnOnUndefinedDerivedState(ctor, partialState);
|
3741 | }
|
3742 |
|
3743 | var memoizedState = partialState === null || partialState === undefined ? prevState : _assign({}, prevState, partialState);
|
3744 | workInProgress.memoizedState = memoizedState;
|
3745 |
|
3746 |
|
3747 |
|
3748 | var updateQueue = workInProgress.updateQueue;
|
3749 | if (updateQueue !== null && workInProgress.expirationTime === NoWork) {
|
3750 | updateQueue.baseState = memoizedState;
|
3751 | }
|
3752 | }
|
3753 |
|
3754 | var classComponentUpdater = {
|
3755 | isMounted: isMounted,
|
3756 | enqueueSetState: function (inst, payload, callback) {
|
3757 | var fiber = get(inst);
|
3758 | var currentTime = requestCurrentTime();
|
3759 | var expirationTime = computeExpirationForFiber(currentTime, fiber);
|
3760 |
|
3761 | var update = createUpdate(expirationTime);
|
3762 | update.payload = payload;
|
3763 | if (callback !== undefined && callback !== null) {
|
3764 | {
|
3765 | warnOnInvalidCallback(callback, 'setState');
|
3766 | }
|
3767 | update.callback = callback;
|
3768 | }
|
3769 |
|
3770 | flushPassiveEffects();
|
3771 | enqueueUpdate(fiber, update);
|
3772 | scheduleWork(fiber, expirationTime);
|
3773 | },
|
3774 | enqueueReplaceState: function (inst, payload, callback) {
|
3775 | var fiber = get(inst);
|
3776 | var currentTime = requestCurrentTime();
|
3777 | var expirationTime = computeExpirationForFiber(currentTime, fiber);
|
3778 |
|
3779 | var update = createUpdate(expirationTime);
|
3780 | update.tag = ReplaceState;
|
3781 | update.payload = payload;
|
3782 |
|
3783 | if (callback !== undefined && callback !== null) {
|
3784 | {
|
3785 | warnOnInvalidCallback(callback, 'replaceState');
|
3786 | }
|
3787 | update.callback = callback;
|
3788 | }
|
3789 |
|
3790 | flushPassiveEffects();
|
3791 | enqueueUpdate(fiber, update);
|
3792 | scheduleWork(fiber, expirationTime);
|
3793 | },
|
3794 | enqueueForceUpdate: function (inst, callback) {
|
3795 | var fiber = get(inst);
|
3796 | var currentTime = requestCurrentTime();
|
3797 | var expirationTime = computeExpirationForFiber(currentTime, fiber);
|
3798 |
|
3799 | var update = createUpdate(expirationTime);
|
3800 | update.tag = ForceUpdate;
|
3801 |
|
3802 | if (callback !== undefined && callback !== null) {
|
3803 | {
|
3804 | warnOnInvalidCallback(callback, 'forceUpdate');
|
3805 | }
|
3806 | update.callback = callback;
|
3807 | }
|
3808 |
|
3809 | flushPassiveEffects();
|
3810 | enqueueUpdate(fiber, update);
|
3811 | scheduleWork(fiber, expirationTime);
|
3812 | }
|
3813 | };
|
3814 |
|
3815 | function checkShouldComponentUpdate(workInProgress, ctor, oldProps, newProps, oldState, newState, nextContext) {
|
3816 | var instance = workInProgress.stateNode;
|
3817 | if (typeof instance.shouldComponentUpdate === 'function') {
|
3818 | startPhaseTimer(workInProgress, 'shouldComponentUpdate');
|
3819 | var shouldUpdate = instance.shouldComponentUpdate(newProps, newState, nextContext);
|
3820 | stopPhaseTimer();
|
3821 |
|
3822 | {
|
3823 | !(shouldUpdate !== undefined) ? warningWithoutStack$1(false, '%s.shouldComponentUpdate(): Returned undefined instead of a ' + 'boolean value. Make sure to return true or false.', getComponentName(ctor) || 'Component') : void 0;
|
3824 | }
|
3825 |
|
3826 | return shouldUpdate;
|
3827 | }
|
3828 |
|
3829 | if (ctor.prototype && ctor.prototype.isPureReactComponent) {
|
3830 | return !shallowEqual(oldProps, newProps) || !shallowEqual(oldState, newState);
|
3831 | }
|
3832 |
|
3833 | return true;
|
3834 | }
|
3835 |
|
3836 | function checkClassInstance(workInProgress, ctor, newProps) {
|
3837 | var instance = workInProgress.stateNode;
|
3838 | {
|
3839 | var name = getComponentName(ctor) || 'Component';
|
3840 | var renderPresent = instance.render;
|
3841 |
|
3842 | if (!renderPresent) {
|
3843 | if (ctor.prototype && typeof ctor.prototype.render === 'function') {
|
3844 | warningWithoutStack$1(false, '%s(...): No `render` method found on the returned component ' + 'instance: did you accidentally return an object from the constructor?', name);
|
3845 | } else {
|
3846 | warningWithoutStack$1(false, '%s(...): No `render` method found on the returned component ' + 'instance: you may have forgotten to define `render`.', name);
|
3847 | }
|
3848 | }
|
3849 |
|
3850 | var noGetInitialStateOnES6 = !instance.getInitialState || instance.getInitialState.isReactClassApproved || instance.state;
|
3851 | !noGetInitialStateOnES6 ? warningWithoutStack$1(false, 'getInitialState was defined on %s, a plain JavaScript class. ' + 'This is only supported for classes created using React.createClass. ' + 'Did you mean to define a state property instead?', name) : void 0;
|
3852 | var noGetDefaultPropsOnES6 = !instance.getDefaultProps || instance.getDefaultProps.isReactClassApproved;
|
3853 | !noGetDefaultPropsOnES6 ? warningWithoutStack$1(false, 'getDefaultProps was defined on %s, a plain JavaScript class. ' + 'This is only supported for classes created using React.createClass. ' + 'Use a static property to define defaultProps instead.', name) : void 0;
|
3854 | var noInstancePropTypes = !instance.propTypes;
|
3855 | !noInstancePropTypes ? warningWithoutStack$1(false, 'propTypes was defined as an instance property on %s. Use a static ' + 'property to define propTypes instead.', name) : void 0;
|
3856 | var noInstanceContextType = !instance.contextType;
|
3857 | !noInstanceContextType ? warningWithoutStack$1(false, 'contextType was defined as an instance property on %s. Use a static ' + 'property to define contextType instead.', name) : void 0;
|
3858 | var noInstanceContextTypes = !instance.contextTypes;
|
3859 | !noInstanceContextTypes ? warningWithoutStack$1(false, 'contextTypes was defined as an instance property on %s. Use a static ' + 'property to define contextTypes instead.', name) : void 0;
|
3860 |
|
3861 | if (ctor.contextType && ctor.contextTypes && !didWarnAboutContextTypeAndContextTypes.has(ctor)) {
|
3862 | didWarnAboutContextTypeAndContextTypes.add(ctor);
|
3863 | warningWithoutStack$1(false, '%s declares both contextTypes and contextType static properties. ' + 'The legacy contextTypes property will be ignored.', name);
|
3864 | }
|
3865 |
|
3866 | var noComponentShouldUpdate = typeof instance.componentShouldUpdate !== 'function';
|
3867 | !noComponentShouldUpdate ? warningWithoutStack$1(false, '%s has a method called ' + 'componentShouldUpdate(). Did you mean shouldComponentUpdate()? ' + 'The name is phrased as a question because the function is ' + 'expected to return a value.', name) : void 0;
|
3868 | if (ctor.prototype && ctor.prototype.isPureReactComponent && typeof instance.shouldComponentUpdate !== 'undefined') {
|
3869 | warningWithoutStack$1(false, '%s has a method called shouldComponentUpdate(). ' + 'shouldComponentUpdate should not be used when extending React.PureComponent. ' + 'Please extend React.Component if shouldComponentUpdate is used.', getComponentName(ctor) || 'A pure component');
|
3870 | }
|
3871 | var noComponentDidUnmount = typeof instance.componentDidUnmount !== 'function';
|
3872 | !noComponentDidUnmount ? warningWithoutStack$1(false, '%s has a method called ' + 'componentDidUnmount(). But there is no such lifecycle method. ' + 'Did you mean componentWillUnmount()?', name) : void 0;
|
3873 | var noComponentDidReceiveProps = typeof instance.componentDidReceiveProps !== 'function';
|
3874 | !noComponentDidReceiveProps ? warningWithoutStack$1(false, '%s has a method called ' + 'componentDidReceiveProps(). But there is no such lifecycle method. ' + 'If you meant to update the state in response to changing props, ' + 'use componentWillReceiveProps(). If you meant to fetch data or ' + 'run side-effects or mutations after React has updated the UI, use componentDidUpdate().', name) : void 0;
|
3875 | var noComponentWillRecieveProps = typeof instance.componentWillRecieveProps !== 'function';
|
3876 | !noComponentWillRecieveProps ? warningWithoutStack$1(false, '%s has a method called ' + 'componentWillRecieveProps(). Did you mean componentWillReceiveProps()?', name) : void 0;
|
3877 | var noUnsafeComponentWillRecieveProps = typeof instance.UNSAFE_componentWillRecieveProps !== 'function';
|
3878 | !noUnsafeComponentWillRecieveProps ? warningWithoutStack$1(false, '%s has a method called ' + 'UNSAFE_componentWillRecieveProps(). Did you mean UNSAFE_componentWillReceiveProps()?', name) : void 0;
|
3879 | var hasMutatedProps = instance.props !== newProps;
|
3880 | !(instance.props === undefined || !hasMutatedProps) ? warningWithoutStack$1(false, '%s(...): When calling super() in `%s`, make sure to pass ' + "up the same props that your component's constructor was passed.", name, name) : void 0;
|
3881 | var noInstanceDefaultProps = !instance.defaultProps;
|
3882 | !noInstanceDefaultProps ? warningWithoutStack$1(false, 'Setting defaultProps as an instance property on %s is not supported and will be ignored.' + ' Instead, define defaultProps as a static property on %s.', name, name) : void 0;
|
3883 |
|
3884 | if (typeof instance.getSnapshotBeforeUpdate === 'function' && typeof instance.componentDidUpdate !== 'function' && !didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate.has(ctor)) {
|
3885 | didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate.add(ctor);
|
3886 | warningWithoutStack$1(false, '%s: getSnapshotBeforeUpdate() should be used with componentDidUpdate(). ' + 'This component defines getSnapshotBeforeUpdate() only.', getComponentName(ctor));
|
3887 | }
|
3888 |
|
3889 | var noInstanceGetDerivedStateFromProps = typeof instance.getDerivedStateFromProps !== 'function';
|
3890 | !noInstanceGetDerivedStateFromProps ? warningWithoutStack$1(false, '%s: getDerivedStateFromProps() is defined as an instance method ' + 'and will be ignored. Instead, declare it as a static method.', name) : void 0;
|
3891 | var noInstanceGetDerivedStateFromCatch = typeof instance.getDerivedStateFromError !== 'function';
|
3892 | !noInstanceGetDerivedStateFromCatch ? warningWithoutStack$1(false, '%s: getDerivedStateFromError() is defined as an instance method ' + 'and will be ignored. Instead, declare it as a static method.', name) : void 0;
|
3893 | var noStaticGetSnapshotBeforeUpdate = typeof ctor.getSnapshotBeforeUpdate !== 'function';
|
3894 | !noStaticGetSnapshotBeforeUpdate ? warningWithoutStack$1(false, '%s: getSnapshotBeforeUpdate() is defined as a static method ' + 'and will be ignored. Instead, declare it as an instance method.', name) : void 0;
|
3895 | var _state = instance.state;
|
3896 | if (_state && (typeof _state !== 'object' || isArray$1(_state))) {
|
3897 | warningWithoutStack$1(false, '%s.state: must be set to an object or null', name);
|
3898 | }
|
3899 | if (typeof instance.getChildContext === 'function') {
|
3900 | !(typeof ctor.childContextTypes === 'object') ? warningWithoutStack$1(false, '%s.getChildContext(): childContextTypes must be defined in order to ' + 'use getChildContext().', name) : void 0;
|
3901 | }
|
3902 | }
|
3903 | }
|
3904 |
|
3905 | function adoptClassInstance(workInProgress, instance) {
|
3906 | instance.updater = classComponentUpdater;
|
3907 | workInProgress.stateNode = instance;
|
3908 |
|
3909 | set(instance, workInProgress);
|
3910 | {
|
3911 | instance._reactInternalInstance = fakeInternalInstance;
|
3912 | }
|
3913 | }
|
3914 |
|
3915 | function constructClassInstance(workInProgress, ctor, props, renderExpirationTime) {
|
3916 | var isLegacyContextConsumer = false;
|
3917 | var unmaskedContext = emptyContextObject;
|
3918 | var context = null;
|
3919 | var contextType = ctor.contextType;
|
3920 | if (typeof contextType === 'object' && contextType !== null) {
|
3921 | {
|
3922 | if (contextType.$$typeof !== REACT_CONTEXT_TYPE && !didWarnAboutInvalidateContextType.has(ctor)) {
|
3923 | didWarnAboutInvalidateContextType.add(ctor);
|
3924 | warningWithoutStack$1(false, '%s defines an invalid contextType. ' + 'contextType should point to the Context object returned by React.createContext(). ' + 'Did you accidentally pass the Context.Provider instead?', getComponentName(ctor) || 'Component');
|
3925 | }
|
3926 | }
|
3927 |
|
3928 | context = readContext(contextType);
|
3929 | } else {
|
3930 | unmaskedContext = getUnmaskedContext(workInProgress, ctor, true);
|
3931 | var contextTypes = ctor.contextTypes;
|
3932 | isLegacyContextConsumer = contextTypes !== null && contextTypes !== undefined;
|
3933 | context = isLegacyContextConsumer ? getMaskedContext(workInProgress, unmaskedContext) : emptyContextObject;
|
3934 | }
|
3935 |
|
3936 |
|
3937 | {
|
3938 | if (debugRenderPhaseSideEffects || debugRenderPhaseSideEffectsForStrictMode && workInProgress.mode & StrictMode) {
|
3939 | new ctor(props, context);
|
3940 | }
|
3941 | }
|
3942 |
|
3943 | var instance = new ctor(props, context);
|
3944 | var state = workInProgress.memoizedState = instance.state !== null && instance.state !== undefined ? instance.state : null;
|
3945 | adoptClassInstance(workInProgress, instance);
|
3946 |
|
3947 | {
|
3948 | if (typeof ctor.getDerivedStateFromProps === 'function' && state === null) {
|
3949 | var componentName = getComponentName(ctor) || 'Component';
|
3950 | if (!didWarnAboutUninitializedState.has(componentName)) {
|
3951 | didWarnAboutUninitializedState.add(componentName);
|
3952 | warningWithoutStack$1(false, '`%s` uses `getDerivedStateFromProps` but its initial state is ' + '%s. This is not recommended. Instead, define the initial state by ' + 'assigning an object to `this.state` in the constructor of `%s`. ' + 'This ensures that `getDerivedStateFromProps` arguments have a consistent shape.', componentName, instance.state === null ? 'null' : 'undefined', componentName);
|
3953 | }
|
3954 | }
|
3955 |
|
3956 |
|
3957 |
|
3958 |
|
3959 | if (typeof ctor.getDerivedStateFromProps === 'function' || typeof instance.getSnapshotBeforeUpdate === 'function') {
|
3960 | var foundWillMountName = null;
|
3961 | var foundWillReceivePropsName = null;
|
3962 | var foundWillUpdateName = null;
|
3963 | if (typeof instance.componentWillMount === 'function' && instance.componentWillMount.__suppressDeprecationWarning !== true) {
|
3964 | foundWillMountName = 'componentWillMount';
|
3965 | } else if (typeof instance.UNSAFE_componentWillMount === 'function') {
|
3966 | foundWillMountName = 'UNSAFE_componentWillMount';
|
3967 | }
|
3968 | if (typeof instance.componentWillReceiveProps === 'function' && instance.componentWillReceiveProps.__suppressDeprecationWarning !== true) {
|
3969 | foundWillReceivePropsName = 'componentWillReceiveProps';
|
3970 | } else if (typeof instance.UNSAFE_componentWillReceiveProps === 'function') {
|
3971 | foundWillReceivePropsName = 'UNSAFE_componentWillReceiveProps';
|
3972 | }
|
3973 | if (typeof instance.componentWillUpdate === 'function' && instance.componentWillUpdate.__suppressDeprecationWarning !== true) {
|
3974 | foundWillUpdateName = 'componentWillUpdate';
|
3975 | } else if (typeof instance.UNSAFE_componentWillUpdate === 'function') {
|
3976 | foundWillUpdateName = 'UNSAFE_componentWillUpdate';
|
3977 | }
|
3978 | if (foundWillMountName !== null || foundWillReceivePropsName !== null || foundWillUpdateName !== null) {
|
3979 | var _componentName = getComponentName(ctor) || 'Component';
|
3980 | var newApiName = typeof ctor.getDerivedStateFromProps === 'function' ? 'getDerivedStateFromProps()' : 'getSnapshotBeforeUpdate()';
|
3981 | if (!didWarnAboutLegacyLifecyclesAndDerivedState.has(_componentName)) {
|
3982 | didWarnAboutLegacyLifecyclesAndDerivedState.add(_componentName);
|
3983 | warningWithoutStack$1(false, 'Unsafe legacy lifecycles will not be called for components using new component APIs.\n\n' + '%s uses %s but also contains the following legacy lifecycles:%s%s%s\n\n' + 'The above lifecycles should be removed. Learn more about this warning here:\n' + 'https://fb.me/react-async-component-lifecycle-hooks', _componentName, newApiName, foundWillMountName !== null ? '\n ' + foundWillMountName : '', foundWillReceivePropsName !== null ? '\n ' + foundWillReceivePropsName : '', foundWillUpdateName !== null ? '\n ' + foundWillUpdateName : '');
|
3984 | }
|
3985 | }
|
3986 | }
|
3987 | }
|
3988 |
|
3989 |
|
3990 |
|
3991 | if (isLegacyContextConsumer) {
|
3992 | cacheContext(workInProgress, unmaskedContext, context);
|
3993 | }
|
3994 |
|
3995 | return instance;
|
3996 | }
|
3997 |
|
3998 | function callComponentWillMount(workInProgress, instance) {
|
3999 | startPhaseTimer(workInProgress, 'componentWillMount');
|
4000 | var oldState = instance.state;
|
4001 |
|
4002 | if (typeof instance.componentWillMount === 'function') {
|
4003 | instance.componentWillMount();
|
4004 | }
|
4005 | if (typeof instance.UNSAFE_componentWillMount === 'function') {
|
4006 | instance.UNSAFE_componentWillMount();
|
4007 | }
|
4008 |
|
4009 | stopPhaseTimer();
|
4010 |
|
4011 | if (oldState !== instance.state) {
|
4012 | {
|
4013 | warningWithoutStack$1(false, '%s.componentWillMount(): Assigning directly to this.state is ' + "deprecated (except inside a component's " + 'constructor). Use setState instead.', getComponentName(workInProgress.type) || 'Component');
|
4014 | }
|
4015 | classComponentUpdater.enqueueReplaceState(instance, instance.state, null);
|
4016 | }
|
4017 | }
|
4018 |
|
4019 | function callComponentWillReceiveProps(workInProgress, instance, newProps, nextContext) {
|
4020 | var oldState = instance.state;
|
4021 | startPhaseTimer(workInProgress, 'componentWillReceiveProps');
|
4022 | if (typeof instance.componentWillReceiveProps === 'function') {
|
4023 | instance.componentWillReceiveProps(newProps, nextContext);
|
4024 | }
|
4025 | if (typeof instance.UNSAFE_componentWillReceiveProps === 'function') {
|
4026 | instance.UNSAFE_componentWillReceiveProps(newProps, nextContext);
|
4027 | }
|
4028 | stopPhaseTimer();
|
4029 |
|
4030 | if (instance.state !== oldState) {
|
4031 | {
|
4032 | var componentName = getComponentName(workInProgress.type) || 'Component';
|
4033 | if (!didWarnAboutStateAssignmentForComponent.has(componentName)) {
|
4034 | didWarnAboutStateAssignmentForComponent.add(componentName);
|
4035 | warningWithoutStack$1(false, '%s.componentWillReceiveProps(): Assigning directly to ' + "this.state is deprecated (except inside a component's " + 'constructor). Use setState instead.', componentName);
|
4036 | }
|
4037 | }
|
4038 | classComponentUpdater.enqueueReplaceState(instance, instance.state, null);
|
4039 | }
|
4040 | }
|
4041 |
|
4042 |
|
4043 | function mountClassInstance(workInProgress, ctor, newProps, renderExpirationTime) {
|
4044 | {
|
4045 | checkClassInstance(workInProgress, ctor, newProps);
|
4046 | }
|
4047 |
|
4048 | var instance = workInProgress.stateNode;
|
4049 | instance.props = newProps;
|
4050 | instance.state = workInProgress.memoizedState;
|
4051 | instance.refs = emptyRefsObject;
|
4052 |
|
4053 | var contextType = ctor.contextType;
|
4054 | if (typeof contextType === 'object' && contextType !== null) {
|
4055 | instance.context = readContext(contextType);
|
4056 | } else {
|
4057 | var unmaskedContext = getUnmaskedContext(workInProgress, ctor, true);
|
4058 | instance.context = getMaskedContext(workInProgress, unmaskedContext);
|
4059 | }
|
4060 |
|
4061 | {
|
4062 | if (instance.state === newProps) {
|
4063 | var componentName = getComponentName(ctor) || 'Component';
|
4064 | if (!didWarnAboutDirectlyAssigningPropsToState.has(componentName)) {
|
4065 | didWarnAboutDirectlyAssigningPropsToState.add(componentName);
|
4066 | warningWithoutStack$1(false, '%s: It is not recommended to assign props directly to state ' + "because updates to props won't be reflected in state. " + 'In most cases, it is better to use props directly.', componentName);
|
4067 | }
|
4068 | }
|
4069 |
|
4070 | if (workInProgress.mode & StrictMode) {
|
4071 | ReactStrictModeWarnings.recordUnsafeLifecycleWarnings(workInProgress, instance);
|
4072 |
|
4073 | ReactStrictModeWarnings.recordLegacyContextWarning(workInProgress, instance);
|
4074 | }
|
4075 |
|
4076 | if (warnAboutDeprecatedLifecycles) {
|
4077 | ReactStrictModeWarnings.recordDeprecationWarnings(workInProgress, instance);
|
4078 | }
|
4079 | }
|
4080 |
|
4081 | var updateQueue = workInProgress.updateQueue;
|
4082 | if (updateQueue !== null) {
|
4083 | processUpdateQueue(workInProgress, updateQueue, newProps, instance, renderExpirationTime);
|
4084 | instance.state = workInProgress.memoizedState;
|
4085 | }
|
4086 |
|
4087 | var getDerivedStateFromProps = ctor.getDerivedStateFromProps;
|
4088 | if (typeof getDerivedStateFromProps === 'function') {
|
4089 | applyDerivedStateFromProps(workInProgress, ctor, getDerivedStateFromProps, newProps);
|
4090 | instance.state = workInProgress.memoizedState;
|
4091 | }
|
4092 |
|
4093 |
|
4094 |
|
4095 | if (typeof ctor.getDerivedStateFromProps !== 'function' && typeof instance.getSnapshotBeforeUpdate !== 'function' && (typeof instance.UNSAFE_componentWillMount === 'function' || typeof instance.componentWillMount === 'function')) {
|
4096 | callComponentWillMount(workInProgress, instance);
|
4097 |
|
4098 |
|
4099 | updateQueue = workInProgress.updateQueue;
|
4100 | if (updateQueue !== null) {
|
4101 | processUpdateQueue(workInProgress, updateQueue, newProps, instance, renderExpirationTime);
|
4102 | instance.state = workInProgress.memoizedState;
|
4103 | }
|
4104 | }
|
4105 |
|
4106 | if (typeof instance.componentDidMount === 'function') {
|
4107 | workInProgress.effectTag |= Update;
|
4108 | }
|
4109 | }
|
4110 |
|
4111 | function resumeMountClassInstance(workInProgress, ctor, newProps, renderExpirationTime) {
|
4112 | var instance = workInProgress.stateNode;
|
4113 |
|
4114 | var oldProps = workInProgress.memoizedProps;
|
4115 | instance.props = oldProps;
|
4116 |
|
4117 | var oldContext = instance.context;
|
4118 | var contextType = ctor.contextType;
|
4119 | var nextContext = void 0;
|
4120 | if (typeof contextType === 'object' && contextType !== null) {
|
4121 | nextContext = readContext(contextType);
|
4122 | } else {
|
4123 | var nextLegacyUnmaskedContext = getUnmaskedContext(workInProgress, ctor, true);
|
4124 | nextContext = getMaskedContext(workInProgress, nextLegacyUnmaskedContext);
|
4125 | }
|
4126 |
|
4127 | var getDerivedStateFromProps = ctor.getDerivedStateFromProps;
|
4128 | var hasNewLifecycles = typeof getDerivedStateFromProps === 'function' || typeof instance.getSnapshotBeforeUpdate === 'function';
|
4129 |
|
4130 |
|
4131 |
|
4132 |
|
4133 |
|
4134 |
|
4135 |
|
4136 | if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillReceiveProps === 'function' || typeof instance.componentWillReceiveProps === 'function')) {
|
4137 | if (oldProps !== newProps || oldContext !== nextContext) {
|
4138 | callComponentWillReceiveProps(workInProgress, instance, newProps, nextContext);
|
4139 | }
|
4140 | }
|
4141 |
|
4142 | resetHasForceUpdateBeforeProcessing();
|
4143 |
|
4144 | var oldState = workInProgress.memoizedState;
|
4145 | var newState = instance.state = oldState;
|
4146 | var updateQueue = workInProgress.updateQueue;
|
4147 | if (updateQueue !== null) {
|
4148 | processUpdateQueue(workInProgress, updateQueue, newProps, instance, renderExpirationTime);
|
4149 | newState = workInProgress.memoizedState;
|
4150 | }
|
4151 | if (oldProps === newProps && oldState === newState && !hasContextChanged() && !checkHasForceUpdateAfterProcessing()) {
|
4152 |
|
4153 |
|
4154 | if (typeof instance.componentDidMount === 'function') {
|
4155 | workInProgress.effectTag |= Update;
|
4156 | }
|
4157 | return false;
|
4158 | }
|
4159 |
|
4160 | if (typeof getDerivedStateFromProps === 'function') {
|
4161 | applyDerivedStateFromProps(workInProgress, ctor, getDerivedStateFromProps, newProps);
|
4162 | newState = workInProgress.memoizedState;
|
4163 | }
|
4164 |
|
4165 | var shouldUpdate = checkHasForceUpdateAfterProcessing() || checkShouldComponentUpdate(workInProgress, ctor, oldProps, newProps, oldState, newState, nextContext);
|
4166 |
|
4167 | if (shouldUpdate) {
|
4168 |
|
4169 |
|
4170 | if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillMount === 'function' || typeof instance.componentWillMount === 'function')) {
|
4171 | startPhaseTimer(workInProgress, 'componentWillMount');
|
4172 | if (typeof instance.componentWillMount === 'function') {
|
4173 | instance.componentWillMount();
|
4174 | }
|
4175 | if (typeof instance.UNSAFE_componentWillMount === 'function') {
|
4176 | instance.UNSAFE_componentWillMount();
|
4177 | }
|
4178 | stopPhaseTimer();
|
4179 | }
|
4180 | if (typeof instance.componentDidMount === 'function') {
|
4181 | workInProgress.effectTag |= Update;
|
4182 | }
|
4183 | } else {
|
4184 |
|
4185 |
|
4186 | if (typeof instance.componentDidMount === 'function') {
|
4187 | workInProgress.effectTag |= Update;
|
4188 | }
|
4189 |
|
4190 |
|
4191 |
|
4192 | workInProgress.memoizedProps = newProps;
|
4193 | workInProgress.memoizedState = newState;
|
4194 | }
|
4195 |
|
4196 |
|
4197 |
|
4198 | instance.props = newProps;
|
4199 | instance.state = newState;
|
4200 | instance.context = nextContext;
|
4201 |
|
4202 | return shouldUpdate;
|
4203 | }
|
4204 |
|
4205 |
|
4206 | function updateClassInstance(current, workInProgress, ctor, newProps, renderExpirationTime) {
|
4207 | var instance = workInProgress.stateNode;
|
4208 |
|
4209 | var oldProps = workInProgress.memoizedProps;
|
4210 | instance.props = workInProgress.type === workInProgress.elementType ? oldProps : resolveDefaultProps(workInProgress.type, oldProps);
|
4211 |
|
4212 | var oldContext = instance.context;
|
4213 | var contextType = ctor.contextType;
|
4214 | var nextContext = void 0;
|
4215 | if (typeof contextType === 'object' && contextType !== null) {
|
4216 | nextContext = readContext(contextType);
|
4217 | } else {
|
4218 | var nextUnmaskedContext = getUnmaskedContext(workInProgress, ctor, true);
|
4219 | nextContext = getMaskedContext(workInProgress, nextUnmaskedContext);
|
4220 | }
|
4221 |
|
4222 | var getDerivedStateFromProps = ctor.getDerivedStateFromProps;
|
4223 | var hasNewLifecycles = typeof getDerivedStateFromProps === 'function' || typeof instance.getSnapshotBeforeUpdate === 'function';
|
4224 |
|
4225 |
|
4226 |
|
4227 |
|
4228 |
|
4229 |
|
4230 |
|
4231 | if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillReceiveProps === 'function' || typeof instance.componentWillReceiveProps === 'function')) {
|
4232 | if (oldProps !== newProps || oldContext !== nextContext) {
|
4233 | callComponentWillReceiveProps(workInProgress, instance, newProps, nextContext);
|
4234 | }
|
4235 | }
|
4236 |
|
4237 | resetHasForceUpdateBeforeProcessing();
|
4238 |
|
4239 | var oldState = workInProgress.memoizedState;
|
4240 | var newState = instance.state = oldState;
|
4241 | var updateQueue = workInProgress.updateQueue;
|
4242 | if (updateQueue !== null) {
|
4243 | processUpdateQueue(workInProgress, updateQueue, newProps, instance, renderExpirationTime);
|
4244 | newState = workInProgress.memoizedState;
|
4245 | }
|
4246 |
|
4247 | if (oldProps === newProps && oldState === newState && !hasContextChanged() && !checkHasForceUpdateAfterProcessing()) {
|
4248 |
|
4249 |
|
4250 | if (typeof instance.componentDidUpdate === 'function') {
|
4251 | if (oldProps !== current.memoizedProps || oldState !== current.memoizedState) {
|
4252 | workInProgress.effectTag |= Update;
|
4253 | }
|
4254 | }
|
4255 | if (typeof instance.getSnapshotBeforeUpdate === 'function') {
|
4256 | if (oldProps !== current.memoizedProps || oldState !== current.memoizedState) {
|
4257 | workInProgress.effectTag |= Snapshot;
|
4258 | }
|
4259 | }
|
4260 | return false;
|
4261 | }
|
4262 |
|
4263 | if (typeof getDerivedStateFromProps === 'function') {
|
4264 | applyDerivedStateFromProps(workInProgress, ctor, getDerivedStateFromProps, newProps);
|
4265 | newState = workInProgress.memoizedState;
|
4266 | }
|
4267 |
|
4268 | var shouldUpdate = checkHasForceUpdateAfterProcessing() || checkShouldComponentUpdate(workInProgress, ctor, oldProps, newProps, oldState, newState, nextContext);
|
4269 |
|
4270 | if (shouldUpdate) {
|
4271 |
|
4272 |
|
4273 | if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillUpdate === 'function' || typeof instance.componentWillUpdate === 'function')) {
|
4274 | startPhaseTimer(workInProgress, 'componentWillUpdate');
|
4275 | if (typeof instance.componentWillUpdate === 'function') {
|
4276 | instance.componentWillUpdate(newProps, newState, nextContext);
|
4277 | }
|
4278 | if (typeof instance.UNSAFE_componentWillUpdate === 'function') {
|
4279 | instance.UNSAFE_componentWillUpdate(newProps, newState, nextContext);
|
4280 | }
|
4281 | stopPhaseTimer();
|
4282 | }
|
4283 | if (typeof instance.componentDidUpdate === 'function') {
|
4284 | workInProgress.effectTag |= Update;
|
4285 | }
|
4286 | if (typeof instance.getSnapshotBeforeUpdate === 'function') {
|
4287 | workInProgress.effectTag |= Snapshot;
|
4288 | }
|
4289 | } else {
|
4290 |
|
4291 |
|
4292 | if (typeof instance.componentDidUpdate === 'function') {
|
4293 | if (oldProps !== current.memoizedProps || oldState !== current.memoizedState) {
|
4294 | workInProgress.effectTag |= Update;
|
4295 | }
|
4296 | }
|
4297 | if (typeof instance.getSnapshotBeforeUpdate === 'function') {
|
4298 | if (oldProps !== current.memoizedProps || oldState !== current.memoizedState) {
|
4299 | workInProgress.effectTag |= Snapshot;
|
4300 | }
|
4301 | }
|
4302 |
|
4303 |
|
4304 |
|
4305 | workInProgress.memoizedProps = newProps;
|
4306 | workInProgress.memoizedState = newState;
|
4307 | }
|
4308 |
|
4309 |
|
4310 |
|
4311 | instance.props = newProps;
|
4312 | instance.state = newState;
|
4313 | instance.context = nextContext;
|
4314 |
|
4315 | return shouldUpdate;
|
4316 | }
|
4317 |
|
4318 | var didWarnAboutMaps = void 0;
|
4319 | var didWarnAboutGenerators = void 0;
|
4320 | var didWarnAboutStringRefInStrictMode = void 0;
|
4321 | var ownerHasKeyUseWarning = void 0;
|
4322 | var ownerHasFunctionTypeWarning = void 0;
|
4323 | var warnForMissingKey = function (child) {};
|
4324 |
|
4325 | {
|
4326 | didWarnAboutMaps = false;
|
4327 | didWarnAboutGenerators = false;
|
4328 | didWarnAboutStringRefInStrictMode = {};
|
4329 |
|
4330 | |
4331 |
|
4332 |
|
4333 |
|
4334 |
|
4335 | ownerHasKeyUseWarning = {};
|
4336 | ownerHasFunctionTypeWarning = {};
|
4337 |
|
4338 | warnForMissingKey = function (child) {
|
4339 | if (child === null || typeof child !== 'object') {
|
4340 | return;
|
4341 | }
|
4342 | if (!child._store || child._store.validated || child.key != null) {
|
4343 | return;
|
4344 | }
|
4345 | !(typeof child._store === 'object') ? invariant(false, 'React Component in warnForMissingKey should have a _store. This error is likely caused by a bug in React. Please file an issue.') : void 0;
|
4346 | child._store.validated = true;
|
4347 |
|
4348 | var currentComponentErrorInfo = 'Each child in a list should have a unique ' + '"key" prop. See https://fb.me/react-warning-keys for ' + 'more information.' + getCurrentFiberStackInDev();
|
4349 | if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {
|
4350 | return;
|
4351 | }
|
4352 | ownerHasKeyUseWarning[currentComponentErrorInfo] = true;
|
4353 |
|
4354 | warning$1(false, 'Each child in a list should have a unique ' + '"key" prop. See https://fb.me/react-warning-keys for ' + 'more information.');
|
4355 | };
|
4356 | }
|
4357 |
|
4358 | var isArray = Array.isArray;
|
4359 |
|
4360 | function coerceRef(returnFiber, current, element) {
|
4361 | var mixedRef = element.ref;
|
4362 | if (mixedRef !== null && typeof mixedRef !== 'function' && typeof mixedRef !== 'object') {
|
4363 | {
|
4364 | if (returnFiber.mode & StrictMode) {
|
4365 | var componentName = getComponentName(returnFiber.type) || 'Component';
|
4366 | if (!didWarnAboutStringRefInStrictMode[componentName]) {
|
4367 | warningWithoutStack$1(false, 'A string ref, "%s", has been found within a strict mode tree. ' + 'String refs are a source of potential bugs and should be avoided. ' + 'We recommend using createRef() instead.' + '\n%s' + '\n\nLearn more about using refs safely here:' + '\nhttps://fb.me/react-strict-mode-string-ref', mixedRef, getStackByFiberInDevAndProd(returnFiber));
|
4368 | didWarnAboutStringRefInStrictMode[componentName] = true;
|
4369 | }
|
4370 | }
|
4371 | }
|
4372 |
|
4373 | if (element._owner) {
|
4374 | var owner = element._owner;
|
4375 | var inst = void 0;
|
4376 | if (owner) {
|
4377 | var ownerFiber = owner;
|
4378 | !(ownerFiber.tag === ClassComponent) ? invariant(false, 'Function components cannot have refs. Did you mean to use React.forwardRef()?') : void 0;
|
4379 | inst = ownerFiber.stateNode;
|
4380 | }
|
4381 | !inst ? invariant(false, 'Missing owner for string ref %s. This error is likely caused by a bug in React. Please file an issue.', mixedRef) : void 0;
|
4382 | var stringRef = '' + mixedRef;
|
4383 |
|
4384 | if (current !== null && current.ref !== null && typeof current.ref === 'function' && current.ref._stringRef === stringRef) {
|
4385 | return current.ref;
|
4386 | }
|
4387 | var ref = function (value) {
|
4388 | var refs = inst.refs;
|
4389 | if (refs === emptyRefsObject) {
|
4390 |
|
4391 | refs = inst.refs = {};
|
4392 | }
|
4393 | if (value === null) {
|
4394 | delete refs[stringRef];
|
4395 | } else {
|
4396 | refs[stringRef] = value;
|
4397 | }
|
4398 | };
|
4399 | ref._stringRef = stringRef;
|
4400 | return ref;
|
4401 | } else {
|
4402 | !(typeof mixedRef === 'string') ? invariant(false, 'Expected ref to be a function, a string, an object returned by React.createRef(), or null.') : void 0;
|
4403 | !element._owner ? invariant(false, 'Element ref was specified as a string (%s) but no owner was set. This could happen for one of the following reasons:\n1. You may be adding a ref to a function component\n2. You may be adding a ref to a component that was not created inside a component\'s render method\n3. You have multiple copies of React loaded\nSee https://fb.me/react-refs-must-have-owner for more information.', mixedRef) : void 0;
|
4404 | }
|
4405 | }
|
4406 | return mixedRef;
|
4407 | }
|
4408 |
|
4409 | function throwOnInvalidObjectType(returnFiber, newChild) {
|
4410 | if (returnFiber.type !== 'textarea') {
|
4411 | var addendum = '';
|
4412 | {
|
4413 | addendum = ' If you meant to render a collection of children, use an array ' + 'instead.' + getCurrentFiberStackInDev();
|
4414 | }
|
4415 | invariant(false, 'Objects are not valid as a React child (found: %s).%s', Object.prototype.toString.call(newChild) === '[object Object]' ? 'object with keys {' + Object.keys(newChild).join(', ') + '}' : newChild, addendum);
|
4416 | }
|
4417 | }
|
4418 |
|
4419 | function warnOnFunctionType() {
|
4420 | var currentComponentErrorInfo = 'Functions are not valid as a React child. This may happen if ' + 'you return a Component instead of <Component /> from render. ' + 'Or maybe you meant to call this function rather than return it.' + getCurrentFiberStackInDev();
|
4421 |
|
4422 | if (ownerHasFunctionTypeWarning[currentComponentErrorInfo]) {
|
4423 | return;
|
4424 | }
|
4425 | ownerHasFunctionTypeWarning[currentComponentErrorInfo] = true;
|
4426 |
|
4427 | warning$1(false, 'Functions are not valid as a React child. This may happen if ' + 'you return a Component instead of <Component /> from render. ' + 'Or maybe you meant to call this function rather than return it.');
|
4428 | }
|
4429 |
|
4430 |
|
4431 |
|
4432 |
|
4433 |
|
4434 | function ChildReconciler(shouldTrackSideEffects) {
|
4435 | function deleteChild(returnFiber, childToDelete) {
|
4436 | if (!shouldTrackSideEffects) {
|
4437 |
|
4438 | return;
|
4439 | }
|
4440 |
|
4441 |
|
4442 |
|
4443 |
|
4444 |
|
4445 | var last = returnFiber.lastEffect;
|
4446 | if (last !== null) {
|
4447 | last.nextEffect = childToDelete;
|
4448 | returnFiber.lastEffect = childToDelete;
|
4449 | } else {
|
4450 | returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;
|
4451 | }
|
4452 | childToDelete.nextEffect = null;
|
4453 | childToDelete.effectTag = Deletion;
|
4454 | }
|
4455 |
|
4456 | function deleteRemainingChildren(returnFiber, currentFirstChild) {
|
4457 | if (!shouldTrackSideEffects) {
|
4458 |
|
4459 | return null;
|
4460 | }
|
4461 |
|
4462 |
|
4463 |
|
4464 | var childToDelete = currentFirstChild;
|
4465 | while (childToDelete !== null) {
|
4466 | deleteChild(returnFiber, childToDelete);
|
4467 | childToDelete = childToDelete.sibling;
|
4468 | }
|
4469 | return null;
|
4470 | }
|
4471 |
|
4472 | function mapRemainingChildren(returnFiber, currentFirstChild) {
|
4473 |
|
4474 |
|
4475 | var existingChildren = new Map();
|
4476 |
|
4477 | var existingChild = currentFirstChild;
|
4478 | while (existingChild !== null) {
|
4479 | if (existingChild.key !== null) {
|
4480 | existingChildren.set(existingChild.key, existingChild);
|
4481 | } else {
|
4482 | existingChildren.set(existingChild.index, existingChild);
|
4483 | }
|
4484 | existingChild = existingChild.sibling;
|
4485 | }
|
4486 | return existingChildren;
|
4487 | }
|
4488 |
|
4489 | function useFiber(fiber, pendingProps, expirationTime) {
|
4490 |
|
4491 |
|
4492 | var clone = createWorkInProgress(fiber, pendingProps, expirationTime);
|
4493 | clone.index = 0;
|
4494 | clone.sibling = null;
|
4495 | return clone;
|
4496 | }
|
4497 |
|
4498 | function placeChild(newFiber, lastPlacedIndex, newIndex) {
|
4499 | newFiber.index = newIndex;
|
4500 | if (!shouldTrackSideEffects) {
|
4501 |
|
4502 | return lastPlacedIndex;
|
4503 | }
|
4504 | var current = newFiber.alternate;
|
4505 | if (current !== null) {
|
4506 | var oldIndex = current.index;
|
4507 | if (oldIndex < lastPlacedIndex) {
|
4508 |
|
4509 | newFiber.effectTag = Placement;
|
4510 | return lastPlacedIndex;
|
4511 | } else {
|
4512 |
|
4513 | return oldIndex;
|
4514 | }
|
4515 | } else {
|
4516 |
|
4517 | newFiber.effectTag = Placement;
|
4518 | return lastPlacedIndex;
|
4519 | }
|
4520 | }
|
4521 |
|
4522 | function placeSingleChild(newFiber) {
|
4523 |
|
4524 |
|
4525 | if (shouldTrackSideEffects && newFiber.alternate === null) {
|
4526 | newFiber.effectTag = Placement;
|
4527 | }
|
4528 | return newFiber;
|
4529 | }
|
4530 |
|
4531 | function updateTextNode(returnFiber, current, textContent, expirationTime) {
|
4532 | if (current === null || current.tag !== HostText) {
|
4533 |
|
4534 | var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);
|
4535 | created.return = returnFiber;
|
4536 | return created;
|
4537 | } else {
|
4538 |
|
4539 | var existing = useFiber(current, textContent, expirationTime);
|
4540 | existing.return = returnFiber;
|
4541 | return existing;
|
4542 | }
|
4543 | }
|
4544 |
|
4545 | function updateElement(returnFiber, current, element, expirationTime) {
|
4546 | if (current !== null && current.elementType === element.type) {
|
4547 |
|
4548 | var existing = useFiber(current, element.props, expirationTime);
|
4549 | existing.ref = coerceRef(returnFiber, current, element);
|
4550 | existing.return = returnFiber;
|
4551 | {
|
4552 | existing._debugSource = element._source;
|
4553 | existing._debugOwner = element._owner;
|
4554 | }
|
4555 | return existing;
|
4556 | } else {
|
4557 |
|
4558 | var created = createFiberFromElement(element, returnFiber.mode, expirationTime);
|
4559 | created.ref = coerceRef(returnFiber, current, element);
|
4560 | created.return = returnFiber;
|
4561 | return created;
|
4562 | }
|
4563 | }
|
4564 |
|
4565 | function updatePortal(returnFiber, current, portal, expirationTime) {
|
4566 | if (current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.implementation) {
|
4567 |
|
4568 | var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);
|
4569 | created.return = returnFiber;
|
4570 | return created;
|
4571 | } else {
|
4572 |
|
4573 | var existing = useFiber(current, portal.children || [], expirationTime);
|
4574 | existing.return = returnFiber;
|
4575 | return existing;
|
4576 | }
|
4577 | }
|
4578 |
|
4579 | function updateFragment(returnFiber, current, fragment, expirationTime, key) {
|
4580 | if (current === null || current.tag !== Fragment) {
|
4581 |
|
4582 | var created = createFiberFromFragment(fragment, returnFiber.mode, expirationTime, key);
|
4583 | created.return = returnFiber;
|
4584 | return created;
|
4585 | } else {
|
4586 |
|
4587 | var existing = useFiber(current, fragment, expirationTime);
|
4588 | existing.return = returnFiber;
|
4589 | return existing;
|
4590 | }
|
4591 | }
|
4592 |
|
4593 | function createChild(returnFiber, newChild, expirationTime) {
|
4594 | if (typeof newChild === 'string' || typeof newChild === 'number') {
|
4595 |
|
4596 |
|
4597 |
|
4598 | var created = createFiberFromText('' + newChild, returnFiber.mode, expirationTime);
|
4599 | created.return = returnFiber;
|
4600 | return created;
|
4601 | }
|
4602 |
|
4603 | if (typeof newChild === 'object' && newChild !== null) {
|
4604 | switch (newChild.$$typeof) {
|
4605 | case REACT_ELEMENT_TYPE:
|
4606 | {
|
4607 | var _created = createFiberFromElement(newChild, returnFiber.mode, expirationTime);
|
4608 | _created.ref = coerceRef(returnFiber, null, newChild);
|
4609 | _created.return = returnFiber;
|
4610 | return _created;
|
4611 | }
|
4612 | case REACT_PORTAL_TYPE:
|
4613 | {
|
4614 | var _created2 = createFiberFromPortal(newChild, returnFiber.mode, expirationTime);
|
4615 | _created2.return = returnFiber;
|
4616 | return _created2;
|
4617 | }
|
4618 | }
|
4619 |
|
4620 | if (isArray(newChild) || getIteratorFn(newChild)) {
|
4621 | var _created3 = createFiberFromFragment(newChild, returnFiber.mode, expirationTime, null);
|
4622 | _created3.return = returnFiber;
|
4623 | return _created3;
|
4624 | }
|
4625 |
|
4626 | throwOnInvalidObjectType(returnFiber, newChild);
|
4627 | }
|
4628 |
|
4629 | {
|
4630 | if (typeof newChild === 'function') {
|
4631 | warnOnFunctionType();
|
4632 | }
|
4633 | }
|
4634 |
|
4635 | return null;
|
4636 | }
|
4637 |
|
4638 | function updateSlot(returnFiber, oldFiber, newChild, expirationTime) {
|
4639 |
|
4640 |
|
4641 | var key = oldFiber !== null ? oldFiber.key : null;
|
4642 |
|
4643 | if (typeof newChild === 'string' || typeof newChild === 'number') {
|
4644 |
|
4645 |
|
4646 |
|
4647 | if (key !== null) {
|
4648 | return null;
|
4649 | }
|
4650 | return updateTextNode(returnFiber, oldFiber, '' + newChild, expirationTime);
|
4651 | }
|
4652 |
|
4653 | if (typeof newChild === 'object' && newChild !== null) {
|
4654 | switch (newChild.$$typeof) {
|
4655 | case REACT_ELEMENT_TYPE:
|
4656 | {
|
4657 | if (newChild.key === key) {
|
4658 | if (newChild.type === REACT_FRAGMENT_TYPE) {
|
4659 | return updateFragment(returnFiber, oldFiber, newChild.props.children, expirationTime, key);
|
4660 | }
|
4661 | return updateElement(returnFiber, oldFiber, newChild, expirationTime);
|
4662 | } else {
|
4663 | return null;
|
4664 | }
|
4665 | }
|
4666 | case REACT_PORTAL_TYPE:
|
4667 | {
|
4668 | if (newChild.key === key) {
|
4669 | return updatePortal(returnFiber, oldFiber, newChild, expirationTime);
|
4670 | } else {
|
4671 | return null;
|
4672 | }
|
4673 | }
|
4674 | }
|
4675 |
|
4676 | if (isArray(newChild) || getIteratorFn(newChild)) {
|
4677 | if (key !== null) {
|
4678 | return null;
|
4679 | }
|
4680 |
|
4681 | return updateFragment(returnFiber, oldFiber, newChild, expirationTime, null);
|
4682 | }
|
4683 |
|
4684 | throwOnInvalidObjectType(returnFiber, newChild);
|
4685 | }
|
4686 |
|
4687 | {
|
4688 | if (typeof newChild === 'function') {
|
4689 | warnOnFunctionType();
|
4690 | }
|
4691 | }
|
4692 |
|
4693 | return null;
|
4694 | }
|
4695 |
|
4696 | function updateFromMap(existingChildren, returnFiber, newIdx, newChild, expirationTime) {
|
4697 | if (typeof newChild === 'string' || typeof newChild === 'number') {
|
4698 |
|
4699 |
|
4700 | var matchedFiber = existingChildren.get(newIdx) || null;
|
4701 | return updateTextNode(returnFiber, matchedFiber, '' + newChild, expirationTime);
|
4702 | }
|
4703 |
|
4704 | if (typeof newChild === 'object' && newChild !== null) {
|
4705 | switch (newChild.$$typeof) {
|
4706 | case REACT_ELEMENT_TYPE:
|
4707 | {
|
4708 | var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;
|
4709 | if (newChild.type === REACT_FRAGMENT_TYPE) {
|
4710 | return updateFragment(returnFiber, _matchedFiber, newChild.props.children, expirationTime, newChild.key);
|
4711 | }
|
4712 | return updateElement(returnFiber, _matchedFiber, newChild, expirationTime);
|
4713 | }
|
4714 | case REACT_PORTAL_TYPE:
|
4715 | {
|
4716 | var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;
|
4717 | return updatePortal(returnFiber, _matchedFiber2, newChild, expirationTime);
|
4718 | }
|
4719 | }
|
4720 |
|
4721 | if (isArray(newChild) || getIteratorFn(newChild)) {
|
4722 | var _matchedFiber3 = existingChildren.get(newIdx) || null;
|
4723 | return updateFragment(returnFiber, _matchedFiber3, newChild, expirationTime, null);
|
4724 | }
|
4725 |
|
4726 | throwOnInvalidObjectType(returnFiber, newChild);
|
4727 | }
|
4728 |
|
4729 | {
|
4730 | if (typeof newChild === 'function') {
|
4731 | warnOnFunctionType();
|
4732 | }
|
4733 | }
|
4734 |
|
4735 | return null;
|
4736 | }
|
4737 |
|
4738 | |
4739 |
|
4740 |
|
4741 | function warnOnInvalidKey(child, knownKeys) {
|
4742 | {
|
4743 | if (typeof child !== 'object' || child === null) {
|
4744 | return knownKeys;
|
4745 | }
|
4746 | switch (child.$$typeof) {
|
4747 | case REACT_ELEMENT_TYPE:
|
4748 | case REACT_PORTAL_TYPE:
|
4749 | warnForMissingKey(child);
|
4750 | var key = child.key;
|
4751 | if (typeof key !== 'string') {
|
4752 | break;
|
4753 | }
|
4754 | if (knownKeys === null) {
|
4755 | knownKeys = new Set();
|
4756 | knownKeys.add(key);
|
4757 | break;
|
4758 | }
|
4759 | if (!knownKeys.has(key)) {
|
4760 | knownKeys.add(key);
|
4761 | break;
|
4762 | }
|
4763 | warning$1(false, 'Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.', key);
|
4764 | break;
|
4765 | default:
|
4766 | break;
|
4767 | }
|
4768 | }
|
4769 | return knownKeys;
|
4770 | }
|
4771 |
|
4772 | function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) {
|
4773 |
|
4774 |
|
4775 |
|
4776 |
|
4777 |
|
4778 |
|
4779 |
|
4780 |
|
4781 |
|
4782 |
|
4783 |
|
4784 |
|
4785 |
|
4786 |
|
4787 |
|
4788 |
|
4789 |
|
4790 |
|
4791 |
|
4792 | {
|
4793 |
|
4794 | var knownKeys = null;
|
4795 | for (var i = 0; i < newChildren.length; i++) {
|
4796 | var child = newChildren[i];
|
4797 | knownKeys = warnOnInvalidKey(child, knownKeys);
|
4798 | }
|
4799 | }
|
4800 |
|
4801 | var resultingFirstChild = null;
|
4802 | var previousNewFiber = null;
|
4803 |
|
4804 | var oldFiber = currentFirstChild;
|
4805 | var lastPlacedIndex = 0;
|
4806 | var newIdx = 0;
|
4807 | var nextOldFiber = null;
|
4808 | for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {
|
4809 | if (oldFiber.index > newIdx) {
|
4810 | nextOldFiber = oldFiber;
|
4811 | oldFiber = null;
|
4812 | } else {
|
4813 | nextOldFiber = oldFiber.sibling;
|
4814 | }
|
4815 | var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], expirationTime);
|
4816 | if (newFiber === null) {
|
4817 |
|
4818 |
|
4819 |
|
4820 |
|
4821 | if (oldFiber === null) {
|
4822 | oldFiber = nextOldFiber;
|
4823 | }
|
4824 | break;
|
4825 | }
|
4826 | if (shouldTrackSideEffects) {
|
4827 | if (oldFiber && newFiber.alternate === null) {
|
4828 |
|
4829 |
|
4830 | deleteChild(returnFiber, oldFiber);
|
4831 | }
|
4832 | }
|
4833 | lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);
|
4834 | if (previousNewFiber === null) {
|
4835 |
|
4836 | resultingFirstChild = newFiber;
|
4837 | } else {
|
4838 |
|
4839 |
|
4840 |
|
4841 |
|
4842 | previousNewFiber.sibling = newFiber;
|
4843 | }
|
4844 | previousNewFiber = newFiber;
|
4845 | oldFiber = nextOldFiber;
|
4846 | }
|
4847 |
|
4848 | if (newIdx === newChildren.length) {
|
4849 |
|
4850 | deleteRemainingChildren(returnFiber, oldFiber);
|
4851 | return resultingFirstChild;
|
4852 | }
|
4853 |
|
4854 | if (oldFiber === null) {
|
4855 |
|
4856 |
|
4857 | for (; newIdx < newChildren.length; newIdx++) {
|
4858 | var _newFiber = createChild(returnFiber, newChildren[newIdx], expirationTime);
|
4859 | if (!_newFiber) {
|
4860 | continue;
|
4861 | }
|
4862 | lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);
|
4863 | if (previousNewFiber === null) {
|
4864 |
|
4865 | resultingFirstChild = _newFiber;
|
4866 | } else {
|
4867 | previousNewFiber.sibling = _newFiber;
|
4868 | }
|
4869 | previousNewFiber = _newFiber;
|
4870 | }
|
4871 | return resultingFirstChild;
|
4872 | }
|
4873 |
|
4874 |
|
4875 | var existingChildren = mapRemainingChildren(returnFiber, oldFiber);
|
4876 |
|
4877 |
|
4878 | for (; newIdx < newChildren.length; newIdx++) {
|
4879 | var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], expirationTime);
|
4880 | if (_newFiber2) {
|
4881 | if (shouldTrackSideEffects) {
|
4882 | if (_newFiber2.alternate !== null) {
|
4883 |
|
4884 |
|
4885 |
|
4886 |
|
4887 | existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);
|
4888 | }
|
4889 | }
|
4890 | lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);
|
4891 | if (previousNewFiber === null) {
|
4892 | resultingFirstChild = _newFiber2;
|
4893 | } else {
|
4894 | previousNewFiber.sibling = _newFiber2;
|
4895 | }
|
4896 | previousNewFiber = _newFiber2;
|
4897 | }
|
4898 | }
|
4899 |
|
4900 | if (shouldTrackSideEffects) {
|
4901 |
|
4902 |
|
4903 | existingChildren.forEach(function (child) {
|
4904 | return deleteChild(returnFiber, child);
|
4905 | });
|
4906 | }
|
4907 |
|
4908 | return resultingFirstChild;
|
4909 | }
|
4910 |
|
4911 | function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, expirationTime) {
|
4912 |
|
4913 |
|
4914 |
|
4915 | var iteratorFn = getIteratorFn(newChildrenIterable);
|
4916 | !(typeof iteratorFn === 'function') ? invariant(false, 'An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.') : void 0;
|
4917 |
|
4918 | {
|
4919 |
|
4920 |
|
4921 | if (typeof Symbol === 'function' &&
|
4922 |
|
4923 | newChildrenIterable[Symbol.toStringTag] === 'Generator') {
|
4924 | !didWarnAboutGenerators ? warning$1(false, 'Using Generators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. Keep in mind ' + 'you might need to polyfill these features for older browsers.') : void 0;
|
4925 | didWarnAboutGenerators = true;
|
4926 | }
|
4927 |
|
4928 |
|
4929 | if (newChildrenIterable.entries === iteratorFn) {
|
4930 | !didWarnAboutMaps ? warning$1(false, 'Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.') : void 0;
|
4931 | didWarnAboutMaps = true;
|
4932 | }
|
4933 |
|
4934 |
|
4935 |
|
4936 | var _newChildren = iteratorFn.call(newChildrenIterable);
|
4937 | if (_newChildren) {
|
4938 | var knownKeys = null;
|
4939 | var _step = _newChildren.next();
|
4940 | for (; !_step.done; _step = _newChildren.next()) {
|
4941 | var child = _step.value;
|
4942 | knownKeys = warnOnInvalidKey(child, knownKeys);
|
4943 | }
|
4944 | }
|
4945 | }
|
4946 |
|
4947 | var newChildren = iteratorFn.call(newChildrenIterable);
|
4948 | !(newChildren != null) ? invariant(false, 'An iterable object provided no iterator.') : void 0;
|
4949 |
|
4950 | var resultingFirstChild = null;
|
4951 | var previousNewFiber = null;
|
4952 |
|
4953 | var oldFiber = currentFirstChild;
|
4954 | var lastPlacedIndex = 0;
|
4955 | var newIdx = 0;
|
4956 | var nextOldFiber = null;
|
4957 |
|
4958 | var step = newChildren.next();
|
4959 | for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {
|
4960 | if (oldFiber.index > newIdx) {
|
4961 | nextOldFiber = oldFiber;
|
4962 | oldFiber = null;
|
4963 | } else {
|
4964 | nextOldFiber = oldFiber.sibling;
|
4965 | }
|
4966 | var newFiber = updateSlot(returnFiber, oldFiber, step.value, expirationTime);
|
4967 | if (newFiber === null) {
|
4968 |
|
4969 |
|
4970 |
|
4971 |
|
4972 | if (!oldFiber) {
|
4973 | oldFiber = nextOldFiber;
|
4974 | }
|
4975 | break;
|
4976 | }
|
4977 | if (shouldTrackSideEffects) {
|
4978 | if (oldFiber && newFiber.alternate === null) {
|
4979 |
|
4980 |
|
4981 | deleteChild(returnFiber, oldFiber);
|
4982 | }
|
4983 | }
|
4984 | lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);
|
4985 | if (previousNewFiber === null) {
|
4986 |
|
4987 | resultingFirstChild = newFiber;
|
4988 | } else {
|
4989 |
|
4990 |
|
4991 |
|
4992 |
|
4993 | previousNewFiber.sibling = newFiber;
|
4994 | }
|
4995 | previousNewFiber = newFiber;
|
4996 | oldFiber = nextOldFiber;
|
4997 | }
|
4998 |
|
4999 | if (step.done) {
|
5000 |
|
5001 | deleteRemainingChildren(returnFiber, oldFiber);
|
5002 | return resultingFirstChild;
|
5003 | }
|
5004 |
|
5005 | if (oldFiber === null) {
|
5006 |
|
5007 |
|
5008 | for (; !step.done; newIdx++, step = newChildren.next()) {
|
5009 | var _newFiber3 = createChild(returnFiber, step.value, expirationTime);
|
5010 | if (_newFiber3 === null) {
|
5011 | continue;
|
5012 | }
|
5013 | lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);
|
5014 | if (previousNewFiber === null) {
|
5015 |
|
5016 | resultingFirstChild = _newFiber3;
|
5017 | } else {
|
5018 | previousNewFiber.sibling = _newFiber3;
|
5019 | }
|
5020 | previousNewFiber = _newFiber3;
|
5021 | }
|
5022 | return resultingFirstChild;
|
5023 | }
|
5024 |
|
5025 |
|
5026 | var existingChildren = mapRemainingChildren(returnFiber, oldFiber);
|
5027 |
|
5028 |
|
5029 | for (; !step.done; newIdx++, step = newChildren.next()) {
|
5030 | var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, expirationTime);
|
5031 | if (_newFiber4 !== null) {
|
5032 | if (shouldTrackSideEffects) {
|
5033 | if (_newFiber4.alternate !== null) {
|
5034 |
|
5035 |
|
5036 |
|
5037 |
|
5038 | existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);
|
5039 | }
|
5040 | }
|
5041 | lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);
|
5042 | if (previousNewFiber === null) {
|
5043 | resultingFirstChild = _newFiber4;
|
5044 | } else {
|
5045 | previousNewFiber.sibling = _newFiber4;
|
5046 | }
|
5047 | previousNewFiber = _newFiber4;
|
5048 | }
|
5049 | }
|
5050 |
|
5051 | if (shouldTrackSideEffects) {
|
5052 |
|
5053 |
|
5054 | existingChildren.forEach(function (child) {
|
5055 | return deleteChild(returnFiber, child);
|
5056 | });
|
5057 | }
|
5058 |
|
5059 | return resultingFirstChild;
|
5060 | }
|
5061 |
|
5062 | function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, expirationTime) {
|
5063 |
|
5064 |
|
5065 | if (currentFirstChild !== null && currentFirstChild.tag === HostText) {
|
5066 |
|
5067 |
|
5068 | deleteRemainingChildren(returnFiber, currentFirstChild.sibling);
|
5069 | var existing = useFiber(currentFirstChild, textContent, expirationTime);
|
5070 | existing.return = returnFiber;
|
5071 | return existing;
|
5072 | }
|
5073 |
|
5074 |
|
5075 | deleteRemainingChildren(returnFiber, currentFirstChild);
|
5076 | var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);
|
5077 | created.return = returnFiber;
|
5078 | return created;
|
5079 | }
|
5080 |
|
5081 | function reconcileSingleElement(returnFiber, currentFirstChild, element, expirationTime) {
|
5082 | var key = element.key;
|
5083 | var child = currentFirstChild;
|
5084 | while (child !== null) {
|
5085 |
|
5086 |
|
5087 | if (child.key === key) {
|
5088 | if (child.tag === Fragment ? element.type === REACT_FRAGMENT_TYPE : child.elementType === element.type) {
|
5089 | deleteRemainingChildren(returnFiber, child.sibling);
|
5090 | var existing = useFiber(child, element.type === REACT_FRAGMENT_TYPE ? element.props.children : element.props, expirationTime);
|
5091 | existing.ref = coerceRef(returnFiber, child, element);
|
5092 | existing.return = returnFiber;
|
5093 | {
|
5094 | existing._debugSource = element._source;
|
5095 | existing._debugOwner = element._owner;
|
5096 | }
|
5097 | return existing;
|
5098 | } else {
|
5099 | deleteRemainingChildren(returnFiber, child);
|
5100 | break;
|
5101 | }
|
5102 | } else {
|
5103 | deleteChild(returnFiber, child);
|
5104 | }
|
5105 | child = child.sibling;
|
5106 | }
|
5107 |
|
5108 | if (element.type === REACT_FRAGMENT_TYPE) {
|
5109 | var created = createFiberFromFragment(element.props.children, returnFiber.mode, expirationTime, element.key);
|
5110 | created.return = returnFiber;
|
5111 | return created;
|
5112 | } else {
|
5113 | var _created4 = createFiberFromElement(element, returnFiber.mode, expirationTime);
|
5114 | _created4.ref = coerceRef(returnFiber, currentFirstChild, element);
|
5115 | _created4.return = returnFiber;
|
5116 | return _created4;
|
5117 | }
|
5118 | }
|
5119 |
|
5120 | function reconcileSinglePortal(returnFiber, currentFirstChild, portal, expirationTime) {
|
5121 | var key = portal.key;
|
5122 | var child = currentFirstChild;
|
5123 | while (child !== null) {
|
5124 |
|
5125 |
|
5126 | if (child.key === key) {
|
5127 | if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {
|
5128 | deleteRemainingChildren(returnFiber, child.sibling);
|
5129 | var existing = useFiber(child, portal.children || [], expirationTime);
|
5130 | existing.return = returnFiber;
|
5131 | return existing;
|
5132 | } else {
|
5133 | deleteRemainingChildren(returnFiber, child);
|
5134 | break;
|
5135 | }
|
5136 | } else {
|
5137 | deleteChild(returnFiber, child);
|
5138 | }
|
5139 | child = child.sibling;
|
5140 | }
|
5141 |
|
5142 | var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);
|
5143 | created.return = returnFiber;
|
5144 | return created;
|
5145 | }
|
5146 |
|
5147 |
|
5148 |
|
5149 |
|
5150 | function reconcileChildFibers(returnFiber, currentFirstChild, newChild, expirationTime) {
|
5151 |
|
5152 |
|
5153 |
|
5154 |
|
5155 |
|
5156 |
|
5157 |
|
5158 |
|
5159 | var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;
|
5160 | if (isUnkeyedTopLevelFragment) {
|
5161 | newChild = newChild.props.children;
|
5162 | }
|
5163 |
|
5164 |
|
5165 | var isObject = typeof newChild === 'object' && newChild !== null;
|
5166 |
|
5167 | if (isObject) {
|
5168 | switch (newChild.$$typeof) {
|
5169 | case REACT_ELEMENT_TYPE:
|
5170 | return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, expirationTime));
|
5171 | case REACT_PORTAL_TYPE:
|
5172 | return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, expirationTime));
|
5173 | }
|
5174 | }
|
5175 |
|
5176 | if (typeof newChild === 'string' || typeof newChild === 'number') {
|
5177 | return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, expirationTime));
|
5178 | }
|
5179 |
|
5180 | if (isArray(newChild)) {
|
5181 | return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, expirationTime);
|
5182 | }
|
5183 |
|
5184 | if (getIteratorFn(newChild)) {
|
5185 | return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, expirationTime);
|
5186 | }
|
5187 |
|
5188 | if (isObject) {
|
5189 | throwOnInvalidObjectType(returnFiber, newChild);
|
5190 | }
|
5191 |
|
5192 | {
|
5193 | if (typeof newChild === 'function') {
|
5194 | warnOnFunctionType();
|
5195 | }
|
5196 | }
|
5197 | if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {
|
5198 |
|
5199 |
|
5200 |
|
5201 | switch (returnFiber.tag) {
|
5202 | case ClassComponent:
|
5203 | {
|
5204 | {
|
5205 | var instance = returnFiber.stateNode;
|
5206 | if (instance.render._isMockFunction) {
|
5207 |
|
5208 | break;
|
5209 | }
|
5210 | }
|
5211 | }
|
5212 |
|
5213 |
|
5214 |
|
5215 | case FunctionComponent:
|
5216 | {
|
5217 | var Component = returnFiber.type;
|
5218 | invariant(false, '%s(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.', Component.displayName || Component.name || 'Component');
|
5219 | }
|
5220 | }
|
5221 | }
|
5222 |
|
5223 |
|
5224 | return deleteRemainingChildren(returnFiber, currentFirstChild);
|
5225 | }
|
5226 |
|
5227 | return reconcileChildFibers;
|
5228 | }
|
5229 |
|
5230 | var reconcileChildFibers = ChildReconciler(true);
|
5231 | var mountChildFibers = ChildReconciler(false);
|
5232 |
|
5233 | function cloneChildFibers(current, workInProgress) {
|
5234 | !(current === null || workInProgress.child === current.child) ? invariant(false, 'Resuming work not yet implemented.') : void 0;
|
5235 |
|
5236 | if (workInProgress.child === null) {
|
5237 | return;
|
5238 | }
|
5239 |
|
5240 | var currentChild = workInProgress.child;
|
5241 | var newChild = createWorkInProgress(currentChild, currentChild.pendingProps, currentChild.expirationTime);
|
5242 | workInProgress.child = newChild;
|
5243 |
|
5244 | newChild.return = workInProgress;
|
5245 | while (currentChild.sibling !== null) {
|
5246 | currentChild = currentChild.sibling;
|
5247 | newChild = newChild.sibling = createWorkInProgress(currentChild, currentChild.pendingProps, currentChild.expirationTime);
|
5248 | newChild.return = workInProgress;
|
5249 | }
|
5250 | newChild.sibling = null;
|
5251 | }
|
5252 |
|
5253 | var NO_CONTEXT$1 = {};
|
5254 |
|
5255 | var contextStackCursor$1 = createCursor(NO_CONTEXT$1);
|
5256 | var contextFiberStackCursor = createCursor(NO_CONTEXT$1);
|
5257 | var rootInstanceStackCursor = createCursor(NO_CONTEXT$1);
|
5258 |
|
5259 | function requiredContext(c) {
|
5260 | !(c !== NO_CONTEXT$1) ? invariant(false, 'Expected host context to exist. This error is likely caused by a bug in React. Please file an issue.') : void 0;
|
5261 | return c;
|
5262 | }
|
5263 |
|
5264 | function getRootHostContainer() {
|
5265 | var rootInstance = requiredContext(rootInstanceStackCursor.current);
|
5266 | return rootInstance;
|
5267 | }
|
5268 |
|
5269 | function pushHostContainer(fiber, nextRootInstance) {
|
5270 |
|
5271 |
|
5272 | push(rootInstanceStackCursor, nextRootInstance, fiber);
|
5273 |
|
5274 |
|
5275 | push(contextFiberStackCursor, fiber, fiber);
|
5276 |
|
5277 |
|
5278 |
|
5279 |
|
5280 |
|
5281 |
|
5282 | push(contextStackCursor$1, NO_CONTEXT$1, fiber);
|
5283 | var nextRootContext = getRootHostContext(nextRootInstance);
|
5284 |
|
5285 | pop(contextStackCursor$1, fiber);
|
5286 | push(contextStackCursor$1, nextRootContext, fiber);
|
5287 | }
|
5288 |
|
5289 | function popHostContainer(fiber) {
|
5290 | pop(contextStackCursor$1, fiber);
|
5291 | pop(contextFiberStackCursor, fiber);
|
5292 | pop(rootInstanceStackCursor, fiber);
|
5293 | }
|
5294 |
|
5295 | function getHostContext() {
|
5296 | var context = requiredContext(contextStackCursor$1.current);
|
5297 | return context;
|
5298 | }
|
5299 |
|
5300 | function pushHostContext(fiber) {
|
5301 | var rootInstance = requiredContext(rootInstanceStackCursor.current);
|
5302 | var context = requiredContext(contextStackCursor$1.current);
|
5303 | var nextContext = getChildHostContext(context, fiber.type, rootInstance);
|
5304 |
|
5305 |
|
5306 | if (context === nextContext) {
|
5307 | return;
|
5308 | }
|
5309 |
|
5310 |
|
5311 |
|
5312 | push(contextFiberStackCursor, fiber, fiber);
|
5313 | push(contextStackCursor$1, nextContext, fiber);
|
5314 | }
|
5315 |
|
5316 | function popHostContext(fiber) {
|
5317 |
|
5318 |
|
5319 | if (contextFiberStackCursor.current !== fiber) {
|
5320 | return;
|
5321 | }
|
5322 |
|
5323 | pop(contextStackCursor$1, fiber);
|
5324 | pop(contextFiberStackCursor, fiber);
|
5325 | }
|
5326 |
|
5327 | var NoEffect$1 = 0;
|
5328 | var UnmountSnapshot = 2;
|
5329 | var UnmountMutation = 4;
|
5330 | var MountMutation = 8;
|
5331 | var UnmountLayout = 16;
|
5332 | var MountLayout = 32;
|
5333 | var MountPassive = 64;
|
5334 | var UnmountPassive = 128;
|
5335 |
|
5336 | var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher;
|
5337 |
|
5338 |
|
5339 | var didWarnAboutMismatchedHooksForComponent = void 0;
|
5340 | {
|
5341 | didWarnAboutMismatchedHooksForComponent = new Set();
|
5342 | }
|
5343 |
|
5344 |
|
5345 | var renderExpirationTime = NoWork;
|
5346 |
|
5347 |
|
5348 | var currentlyRenderingFiber$1 = null;
|
5349 |
|
5350 |
|
5351 |
|
5352 |
|
5353 |
|
5354 | var currentHook = null;
|
5355 | var nextCurrentHook = null;
|
5356 | var firstWorkInProgressHook = null;
|
5357 | var workInProgressHook = null;
|
5358 | var nextWorkInProgressHook = null;
|
5359 |
|
5360 | var remainingExpirationTime = NoWork;
|
5361 | var componentUpdateQueue = null;
|
5362 | var sideEffectTag = 0;
|
5363 |
|
5364 |
|
5365 |
|
5366 |
|
5367 |
|
5368 |
|
5369 |
|
5370 |
|
5371 |
|
5372 |
|
5373 | var didScheduleRenderPhaseUpdate = false;
|
5374 |
|
5375 | var renderPhaseUpdates = null;
|
5376 |
|
5377 | var numberOfReRenders = 0;
|
5378 | var RE_RENDER_LIMIT = 25;
|
5379 |
|
5380 |
|
5381 | var currentHookNameInDev = null;
|
5382 |
|
5383 |
|
5384 |
|
5385 |
|
5386 | var hookTypesDev = null;
|
5387 | var hookTypesUpdateIndexDev = -1;
|
5388 |
|
5389 | function mountHookTypesDev() {
|
5390 | {
|
5391 | var hookName = currentHookNameInDev;
|
5392 |
|
5393 | if (hookTypesDev === null) {
|
5394 | hookTypesDev = [hookName];
|
5395 | } else {
|
5396 | hookTypesDev.push(hookName);
|
5397 | }
|
5398 | }
|
5399 | }
|
5400 |
|
5401 | function updateHookTypesDev() {
|
5402 | {
|
5403 | var hookName = currentHookNameInDev;
|
5404 |
|
5405 | if (hookTypesDev !== null) {
|
5406 | hookTypesUpdateIndexDev++;
|
5407 | if (hookTypesDev[hookTypesUpdateIndexDev] !== hookName) {
|
5408 | warnOnHookMismatchInDev(hookName);
|
5409 | }
|
5410 | }
|
5411 | }
|
5412 | }
|
5413 |
|
5414 | function warnOnHookMismatchInDev(currentHookName) {
|
5415 | {
|
5416 | var componentName = getComponentName(currentlyRenderingFiber$1.type);
|
5417 | if (!didWarnAboutMismatchedHooksForComponent.has(componentName)) {
|
5418 | didWarnAboutMismatchedHooksForComponent.add(componentName);
|
5419 |
|
5420 | if (hookTypesDev !== null) {
|
5421 | var table = '';
|
5422 |
|
5423 | var secondColumnStart = 30;
|
5424 |
|
5425 | for (var i = 0; i <= hookTypesUpdateIndexDev; i++) {
|
5426 | var oldHookName = hookTypesDev[i];
|
5427 | var newHookName = i === hookTypesUpdateIndexDev ? currentHookName : oldHookName;
|
5428 |
|
5429 | var row = i + 1 + '. ' + oldHookName;
|
5430 |
|
5431 |
|
5432 |
|
5433 | while (row.length < secondColumnStart) {
|
5434 | row += ' ';
|
5435 | }
|
5436 |
|
5437 | row += newHookName + '\n';
|
5438 |
|
5439 | table += row;
|
5440 | }
|
5441 |
|
5442 | warning$1(false, 'React has detected a change in the order of Hooks called by %s. ' + 'This will lead to bugs and errors if not fixed. ' + 'For more information, read the Rules of Hooks: https://fb.me/rules-of-hooks\n\n' + ' Previous render Next render\n' + ' ------------------------------------------------------\n' + '%s' + ' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n', componentName, table);
|
5443 | }
|
5444 | }
|
5445 | }
|
5446 | }
|
5447 |
|
5448 | function throwInvalidHookError() {
|
5449 | invariant(false, 'Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem.');
|
5450 | }
|
5451 |
|
5452 | function areHookInputsEqual(nextDeps, prevDeps) {
|
5453 | if (prevDeps === null) {
|
5454 | {
|
5455 | warning$1(false, '%s received a final argument during this render, but not during ' + 'the previous render. Even though the final argument is optional, ' + 'its type cannot change between renders.', currentHookNameInDev);
|
5456 | }
|
5457 | return false;
|
5458 | }
|
5459 |
|
5460 | {
|
5461 |
|
5462 |
|
5463 | if (nextDeps.length !== prevDeps.length) {
|
5464 | warning$1(false, 'The final argument passed to %s changed size between renders. The ' + 'order and size of this array must remain constant.\n\n' + 'Previous: %s\n' + 'Incoming: %s', currentHookNameInDev, '[' + nextDeps.join(', ') + ']', '[' + prevDeps.join(', ') + ']');
|
5465 | }
|
5466 | }
|
5467 | for (var i = 0; i < prevDeps.length && i < nextDeps.length; i++) {
|
5468 | if (is(nextDeps[i], prevDeps[i])) {
|
5469 | continue;
|
5470 | }
|
5471 | return false;
|
5472 | }
|
5473 | return true;
|
5474 | }
|
5475 |
|
5476 | function renderWithHooks(current, workInProgress, Component, props, refOrContext, nextRenderExpirationTime) {
|
5477 | renderExpirationTime = nextRenderExpirationTime;
|
5478 | currentlyRenderingFiber$1 = workInProgress;
|
5479 | nextCurrentHook = current !== null ? current.memoizedState : null;
|
5480 |
|
5481 | {
|
5482 | hookTypesDev = current !== null ? current._debugHookTypes : null;
|
5483 | hookTypesUpdateIndexDev = -1;
|
5484 | }
|
5485 |
|
5486 |
|
5487 |
|
5488 |
|
5489 |
|
5490 |
|
5491 |
|
5492 |
|
5493 |
|
5494 |
|
5495 |
|
5496 |
|
5497 |
|
5498 |
|
5499 |
|
5500 |
|
5501 |
|
5502 |
|
5503 |
|
5504 |
|
5505 | {
|
5506 | if (nextCurrentHook !== null) {
|
5507 | ReactCurrentDispatcher$1.current = HooksDispatcherOnUpdateInDEV;
|
5508 | } else if (hookTypesDev !== null) {
|
5509 |
|
5510 |
|
5511 |
|
5512 |
|
5513 |
|
5514 | ReactCurrentDispatcher$1.current = HooksDispatcherOnMountWithHookTypesInDEV;
|
5515 | } else {
|
5516 | ReactCurrentDispatcher$1.current = HooksDispatcherOnMountInDEV;
|
5517 | }
|
5518 | }
|
5519 |
|
5520 | var children = Component(props, refOrContext);
|
5521 |
|
5522 | if (didScheduleRenderPhaseUpdate) {
|
5523 | do {
|
5524 | didScheduleRenderPhaseUpdate = false;
|
5525 | numberOfReRenders += 1;
|
5526 |
|
5527 |
|
5528 | nextCurrentHook = current !== null ? current.memoizedState : null;
|
5529 | nextWorkInProgressHook = firstWorkInProgressHook;
|
5530 |
|
5531 | currentHook = null;
|
5532 | workInProgressHook = null;
|
5533 | componentUpdateQueue = null;
|
5534 |
|
5535 | {
|
5536 |
|
5537 | hookTypesUpdateIndexDev = -1;
|
5538 | }
|
5539 |
|
5540 | ReactCurrentDispatcher$1.current = HooksDispatcherOnUpdateInDEV;
|
5541 |
|
5542 | children = Component(props, refOrContext);
|
5543 | } while (didScheduleRenderPhaseUpdate);
|
5544 |
|
5545 | renderPhaseUpdates = null;
|
5546 | numberOfReRenders = 0;
|
5547 | }
|
5548 |
|
5549 |
|
5550 |
|
5551 | ReactCurrentDispatcher$1.current = ContextOnlyDispatcher;
|
5552 |
|
5553 | var renderedWork = currentlyRenderingFiber$1;
|
5554 |
|
5555 | renderedWork.memoizedState = firstWorkInProgressHook;
|
5556 | renderedWork.expirationTime = remainingExpirationTime;
|
5557 | renderedWork.updateQueue = componentUpdateQueue;
|
5558 | renderedWork.effectTag |= sideEffectTag;
|
5559 |
|
5560 | {
|
5561 | renderedWork._debugHookTypes = hookTypesDev;
|
5562 | }
|
5563 |
|
5564 |
|
5565 |
|
5566 | var didRenderTooFewHooks = currentHook !== null && currentHook.next !== null;
|
5567 |
|
5568 | renderExpirationTime = NoWork;
|
5569 | currentlyRenderingFiber$1 = null;
|
5570 |
|
5571 | currentHook = null;
|
5572 | nextCurrentHook = null;
|
5573 | firstWorkInProgressHook = null;
|
5574 | workInProgressHook = null;
|
5575 | nextWorkInProgressHook = null;
|
5576 |
|
5577 | {
|
5578 | currentHookNameInDev = null;
|
5579 | hookTypesDev = null;
|
5580 | hookTypesUpdateIndexDev = -1;
|
5581 | }
|
5582 |
|
5583 | remainingExpirationTime = NoWork;
|
5584 | componentUpdateQueue = null;
|
5585 | sideEffectTag = 0;
|
5586 |
|
5587 |
|
5588 |
|
5589 |
|
5590 |
|
5591 |
|
5592 | !!didRenderTooFewHooks ? invariant(false, 'Rendered fewer hooks than expected. This may be caused by an accidental early return statement.') : void 0;
|
5593 |
|
5594 | return children;
|
5595 | }
|
5596 |
|
5597 | function bailoutHooks(current, workInProgress, expirationTime) {
|
5598 | workInProgress.updateQueue = current.updateQueue;
|
5599 | workInProgress.effectTag &= ~(Passive | Update);
|
5600 | if (current.expirationTime <= expirationTime) {
|
5601 | current.expirationTime = NoWork;
|
5602 | }
|
5603 | }
|
5604 |
|
5605 | function resetHooks() {
|
5606 |
|
5607 |
|
5608 | ReactCurrentDispatcher$1.current = ContextOnlyDispatcher;
|
5609 |
|
5610 |
|
5611 |
|
5612 |
|
5613 | renderExpirationTime = NoWork;
|
5614 | currentlyRenderingFiber$1 = null;
|
5615 |
|
5616 | currentHook = null;
|
5617 | nextCurrentHook = null;
|
5618 | firstWorkInProgressHook = null;
|
5619 | workInProgressHook = null;
|
5620 | nextWorkInProgressHook = null;
|
5621 |
|
5622 | {
|
5623 | hookTypesDev = null;
|
5624 | hookTypesUpdateIndexDev = -1;
|
5625 |
|
5626 | currentHookNameInDev = null;
|
5627 | }
|
5628 |
|
5629 | remainingExpirationTime = NoWork;
|
5630 | componentUpdateQueue = null;
|
5631 | sideEffectTag = 0;
|
5632 |
|
5633 | didScheduleRenderPhaseUpdate = false;
|
5634 | renderPhaseUpdates = null;
|
5635 | numberOfReRenders = 0;
|
5636 | }
|
5637 |
|
5638 | function mountWorkInProgressHook() {
|
5639 | var hook = {
|
5640 | memoizedState: null,
|
5641 |
|
5642 | baseState: null,
|
5643 | queue: null,
|
5644 | baseUpdate: null,
|
5645 |
|
5646 | next: null
|
5647 | };
|
5648 |
|
5649 | if (workInProgressHook === null) {
|
5650 |
|
5651 | firstWorkInProgressHook = workInProgressHook = hook;
|
5652 | } else {
|
5653 |
|
5654 | workInProgressHook = workInProgressHook.next = hook;
|
5655 | }
|
5656 | return workInProgressHook;
|
5657 | }
|
5658 |
|
5659 | function updateWorkInProgressHook() {
|
5660 |
|
5661 |
|
5662 |
|
5663 |
|
5664 |
|
5665 | if (nextWorkInProgressHook !== null) {
|
5666 |
|
5667 | workInProgressHook = nextWorkInProgressHook;
|
5668 | nextWorkInProgressHook = workInProgressHook.next;
|
5669 |
|
5670 | currentHook = nextCurrentHook;
|
5671 | nextCurrentHook = currentHook !== null ? currentHook.next : null;
|
5672 | } else {
|
5673 |
|
5674 | !(nextCurrentHook !== null) ? invariant(false, 'Rendered more hooks than during the previous render.') : void 0;
|
5675 | currentHook = nextCurrentHook;
|
5676 |
|
5677 | var newHook = {
|
5678 | memoizedState: currentHook.memoizedState,
|
5679 |
|
5680 | baseState: currentHook.baseState,
|
5681 | queue: currentHook.queue,
|
5682 | baseUpdate: currentHook.baseUpdate,
|
5683 |
|
5684 | next: null
|
5685 | };
|
5686 |
|
5687 | if (workInProgressHook === null) {
|
5688 |
|
5689 | workInProgressHook = firstWorkInProgressHook = newHook;
|
5690 | } else {
|
5691 |
|
5692 | workInProgressHook = workInProgressHook.next = newHook;
|
5693 | }
|
5694 | nextCurrentHook = currentHook.next;
|
5695 | }
|
5696 | return workInProgressHook;
|
5697 | }
|
5698 |
|
5699 | function createFunctionComponentUpdateQueue() {
|
5700 | return {
|
5701 | lastEffect: null
|
5702 | };
|
5703 | }
|
5704 |
|
5705 | function basicStateReducer(state, action) {
|
5706 | return typeof action === 'function' ? action(state) : action;
|
5707 | }
|
5708 |
|
5709 | function mountReducer(reducer, initialArg, init) {
|
5710 | var hook = mountWorkInProgressHook();
|
5711 | var initialState = void 0;
|
5712 | if (init !== undefined) {
|
5713 | initialState = init(initialArg);
|
5714 | } else {
|
5715 | initialState = initialArg;
|
5716 | }
|
5717 | hook.memoizedState = hook.baseState = initialState;
|
5718 | var queue = hook.queue = {
|
5719 | last: null,
|
5720 | dispatch: null,
|
5721 | eagerReducer: reducer,
|
5722 | eagerState: initialState
|
5723 | };
|
5724 | var dispatch = queue.dispatch = dispatchAction.bind(null,
|
5725 |
|
5726 | currentlyRenderingFiber$1, queue);
|
5727 | return [hook.memoizedState, dispatch];
|
5728 | }
|
5729 |
|
5730 | function updateReducer(reducer, initialArg, init) {
|
5731 | var hook = updateWorkInProgressHook();
|
5732 | var queue = hook.queue;
|
5733 | !(queue !== null) ? invariant(false, 'Should have a queue. This is likely a bug in React. Please file an issue.') : void 0;
|
5734 |
|
5735 | if (numberOfReRenders > 0) {
|
5736 |
|
5737 | var _dispatch = queue.dispatch;
|
5738 | if (renderPhaseUpdates !== null) {
|
5739 |
|
5740 | var firstRenderPhaseUpdate = renderPhaseUpdates.get(queue);
|
5741 | if (firstRenderPhaseUpdate !== undefined) {
|
5742 | renderPhaseUpdates.delete(queue);
|
5743 | var newState = hook.memoizedState;
|
5744 | var update = firstRenderPhaseUpdate;
|
5745 | do {
|
5746 |
|
5747 |
|
5748 |
|
5749 | var _action = update.action;
|
5750 | newState = reducer(newState, _action);
|
5751 | update = update.next;
|
5752 | } while (update !== null);
|
5753 |
|
5754 |
|
5755 |
|
5756 | if (!is(newState, hook.memoizedState)) {
|
5757 | markWorkInProgressReceivedUpdate();
|
5758 | }
|
5759 |
|
5760 | hook.memoizedState = newState;
|
5761 |
|
5762 |
|
5763 |
|
5764 |
|
5765 | if (hook.baseUpdate === queue.last) {
|
5766 | hook.baseState = newState;
|
5767 | }
|
5768 |
|
5769 | queue.eagerReducer = reducer;
|
5770 | queue.eagerState = newState;
|
5771 |
|
5772 | return [newState, _dispatch];
|
5773 | }
|
5774 | }
|
5775 | return [hook.memoizedState, _dispatch];
|
5776 | }
|
5777 |
|
5778 |
|
5779 | var last = queue.last;
|
5780 |
|
5781 | var baseUpdate = hook.baseUpdate;
|
5782 | var baseState = hook.baseState;
|
5783 |
|
5784 |
|
5785 | var first = void 0;
|
5786 | if (baseUpdate !== null) {
|
5787 | if (last !== null) {
|
5788 |
|
5789 |
|
5790 |
|
5791 | last.next = null;
|
5792 | }
|
5793 | first = baseUpdate.next;
|
5794 | } else {
|
5795 | first = last !== null ? last.next : null;
|
5796 | }
|
5797 | if (first !== null) {
|
5798 | var _newState = baseState;
|
5799 | var newBaseState = null;
|
5800 | var newBaseUpdate = null;
|
5801 | var prevUpdate = baseUpdate;
|
5802 | var _update = first;
|
5803 | var didSkip = false;
|
5804 | do {
|
5805 | var updateExpirationTime = _update.expirationTime;
|
5806 | if (updateExpirationTime < renderExpirationTime) {
|
5807 |
|
5808 |
|
5809 |
|
5810 | if (!didSkip) {
|
5811 | didSkip = true;
|
5812 | newBaseUpdate = prevUpdate;
|
5813 | newBaseState = _newState;
|
5814 | }
|
5815 |
|
5816 | if (updateExpirationTime > remainingExpirationTime) {
|
5817 | remainingExpirationTime = updateExpirationTime;
|
5818 | }
|
5819 | } else {
|
5820 |
|
5821 | if (_update.eagerReducer === reducer) {
|
5822 |
|
5823 |
|
5824 | _newState = _update.eagerState;
|
5825 | } else {
|
5826 | var _action2 = _update.action;
|
5827 | _newState = reducer(_newState, _action2);
|
5828 | }
|
5829 | }
|
5830 | prevUpdate = _update;
|
5831 | _update = _update.next;
|
5832 | } while (_update !== null && _update !== first);
|
5833 |
|
5834 | if (!didSkip) {
|
5835 | newBaseUpdate = prevUpdate;
|
5836 | newBaseState = _newState;
|
5837 | }
|
5838 |
|
5839 |
|
5840 |
|
5841 | if (!is(_newState, hook.memoizedState)) {
|
5842 | markWorkInProgressReceivedUpdate();
|
5843 | }
|
5844 |
|
5845 | hook.memoizedState = _newState;
|
5846 | hook.baseUpdate = newBaseUpdate;
|
5847 | hook.baseState = newBaseState;
|
5848 |
|
5849 | queue.eagerReducer = reducer;
|
5850 | queue.eagerState = _newState;
|
5851 | }
|
5852 |
|
5853 | var dispatch = queue.dispatch;
|
5854 | return [hook.memoizedState, dispatch];
|
5855 | }
|
5856 |
|
5857 | function mountState(initialState) {
|
5858 | var hook = mountWorkInProgressHook();
|
5859 | if (typeof initialState === 'function') {
|
5860 | initialState = initialState();
|
5861 | }
|
5862 | hook.memoizedState = hook.baseState = initialState;
|
5863 | var queue = hook.queue = {
|
5864 | last: null,
|
5865 | dispatch: null,
|
5866 | eagerReducer: basicStateReducer,
|
5867 | eagerState: initialState
|
5868 | };
|
5869 | var dispatch = queue.dispatch = dispatchAction.bind(null,
|
5870 |
|
5871 | currentlyRenderingFiber$1, queue);
|
5872 | return [hook.memoizedState, dispatch];
|
5873 | }
|
5874 |
|
5875 | function updateState(initialState) {
|
5876 | return updateReducer(basicStateReducer, initialState);
|
5877 | }
|
5878 |
|
5879 | function pushEffect(tag, create, destroy, deps) {
|
5880 | var effect = {
|
5881 | tag: tag,
|
5882 | create: create,
|
5883 | destroy: destroy,
|
5884 | deps: deps,
|
5885 |
|
5886 | next: null
|
5887 | };
|
5888 | if (componentUpdateQueue === null) {
|
5889 | componentUpdateQueue = createFunctionComponentUpdateQueue();
|
5890 | componentUpdateQueue.lastEffect = effect.next = effect;
|
5891 | } else {
|
5892 | var _lastEffect = componentUpdateQueue.lastEffect;
|
5893 | if (_lastEffect === null) {
|
5894 | componentUpdateQueue.lastEffect = effect.next = effect;
|
5895 | } else {
|
5896 | var firstEffect = _lastEffect.next;
|
5897 | _lastEffect.next = effect;
|
5898 | effect.next = firstEffect;
|
5899 | componentUpdateQueue.lastEffect = effect;
|
5900 | }
|
5901 | }
|
5902 | return effect;
|
5903 | }
|
5904 |
|
5905 | function mountRef(initialValue) {
|
5906 | var hook = mountWorkInProgressHook();
|
5907 | var ref = { current: initialValue };
|
5908 | {
|
5909 | Object.seal(ref);
|
5910 | }
|
5911 | hook.memoizedState = ref;
|
5912 | return ref;
|
5913 | }
|
5914 |
|
5915 | function updateRef(initialValue) {
|
5916 | var hook = updateWorkInProgressHook();
|
5917 | return hook.memoizedState;
|
5918 | }
|
5919 |
|
5920 | function mountEffectImpl(fiberEffectTag, hookEffectTag, create, deps) {
|
5921 | var hook = mountWorkInProgressHook();
|
5922 | var nextDeps = deps === undefined ? null : deps;
|
5923 | sideEffectTag |= fiberEffectTag;
|
5924 | hook.memoizedState = pushEffect(hookEffectTag, create, undefined, nextDeps);
|
5925 | }
|
5926 |
|
5927 | function updateEffectImpl(fiberEffectTag, hookEffectTag, create, deps) {
|
5928 | var hook = updateWorkInProgressHook();
|
5929 | var nextDeps = deps === undefined ? null : deps;
|
5930 | var destroy = undefined;
|
5931 |
|
5932 | if (currentHook !== null) {
|
5933 | var prevEffect = currentHook.memoizedState;
|
5934 | destroy = prevEffect.destroy;
|
5935 | if (nextDeps !== null) {
|
5936 | var prevDeps = prevEffect.deps;
|
5937 | if (areHookInputsEqual(nextDeps, prevDeps)) {
|
5938 | pushEffect(NoEffect$1, create, destroy, nextDeps);
|
5939 | return;
|
5940 | }
|
5941 | }
|
5942 | }
|
5943 |
|
5944 | sideEffectTag |= fiberEffectTag;
|
5945 | hook.memoizedState = pushEffect(hookEffectTag, create, destroy, nextDeps);
|
5946 | }
|
5947 |
|
5948 | function mountEffect(create, deps) {
|
5949 | return mountEffectImpl(Update | Passive, UnmountPassive | MountPassive, create, deps);
|
5950 | }
|
5951 |
|
5952 | function updateEffect(create, deps) {
|
5953 | return updateEffectImpl(Update | Passive, UnmountPassive | MountPassive, create, deps);
|
5954 | }
|
5955 |
|
5956 | function mountLayoutEffect(create, deps) {
|
5957 | return mountEffectImpl(Update, UnmountMutation | MountLayout, create, deps);
|
5958 | }
|
5959 |
|
5960 | function updateLayoutEffect(create, deps) {
|
5961 | return updateEffectImpl(Update, UnmountMutation | MountLayout, create, deps);
|
5962 | }
|
5963 |
|
5964 | function imperativeHandleEffect(create, ref) {
|
5965 | if (typeof ref === 'function') {
|
5966 | var refCallback = ref;
|
5967 | var _inst = create();
|
5968 | refCallback(_inst);
|
5969 | return function () {
|
5970 | refCallback(null);
|
5971 | };
|
5972 | } else if (ref !== null && ref !== undefined) {
|
5973 | var refObject = ref;
|
5974 | {
|
5975 | !refObject.hasOwnProperty('current') ? warning$1(false, 'Expected useImperativeHandle() first argument to either be a ' + 'ref callback or React.createRef() object. Instead received: %s.', 'an object with keys {' + Object.keys(refObject).join(', ') + '}') : void 0;
|
5976 | }
|
5977 | var _inst2 = create();
|
5978 | refObject.current = _inst2;
|
5979 | return function () {
|
5980 | refObject.current = null;
|
5981 | };
|
5982 | }
|
5983 | }
|
5984 |
|
5985 | function mountImperativeHandle(ref, create, deps) {
|
5986 | {
|
5987 | !(typeof create === 'function') ? warning$1(false, 'Expected useImperativeHandle() second argument to be a function ' + 'that creates a handle. Instead received: %s.', create !== null ? typeof create : 'null') : void 0;
|
5988 | }
|
5989 |
|
5990 |
|
5991 | var effectDeps = deps !== null && deps !== undefined ? deps.concat([ref]) : null;
|
5992 |
|
5993 | return mountEffectImpl(Update, UnmountMutation | MountLayout, imperativeHandleEffect.bind(null, create, ref), effectDeps);
|
5994 | }
|
5995 |
|
5996 | function updateImperativeHandle(ref, create, deps) {
|
5997 | {
|
5998 | !(typeof create === 'function') ? warning$1(false, 'Expected useImperativeHandle() second argument to be a function ' + 'that creates a handle. Instead received: %s.', create !== null ? typeof create : 'null') : void 0;
|
5999 | }
|
6000 |
|
6001 |
|
6002 | var effectDeps = deps !== null && deps !== undefined ? deps.concat([ref]) : null;
|
6003 |
|
6004 | return updateEffectImpl(Update, UnmountMutation | MountLayout, imperativeHandleEffect.bind(null, create, ref), effectDeps);
|
6005 | }
|
6006 |
|
6007 | function mountDebugValue(value, formatterFn) {
|
6008 |
|
6009 |
|
6010 |
|
6011 | }
|
6012 |
|
6013 | var updateDebugValue = mountDebugValue;
|
6014 |
|
6015 | function mountCallback(callback, deps) {
|
6016 | var hook = mountWorkInProgressHook();
|
6017 | var nextDeps = deps === undefined ? null : deps;
|
6018 | hook.memoizedState = [callback, nextDeps];
|
6019 | return callback;
|
6020 | }
|
6021 |
|
6022 | function updateCallback(callback, deps) {
|
6023 | var hook = updateWorkInProgressHook();
|
6024 | var nextDeps = deps === undefined ? null : deps;
|
6025 | var prevState = hook.memoizedState;
|
6026 | if (prevState !== null) {
|
6027 | if (nextDeps !== null) {
|
6028 | var prevDeps = prevState[1];
|
6029 | if (areHookInputsEqual(nextDeps, prevDeps)) {
|
6030 | return prevState[0];
|
6031 | }
|
6032 | }
|
6033 | }
|
6034 | hook.memoizedState = [callback, nextDeps];
|
6035 | return callback;
|
6036 | }
|
6037 |
|
6038 | function mountMemo(nextCreate, deps) {
|
6039 | var hook = mountWorkInProgressHook();
|
6040 | var nextDeps = deps === undefined ? null : deps;
|
6041 | var nextValue = nextCreate();
|
6042 | hook.memoizedState = [nextValue, nextDeps];
|
6043 | return nextValue;
|
6044 | }
|
6045 |
|
6046 | function updateMemo(nextCreate, deps) {
|
6047 | var hook = updateWorkInProgressHook();
|
6048 | var nextDeps = deps === undefined ? null : deps;
|
6049 | var prevState = hook.memoizedState;
|
6050 | if (prevState !== null) {
|
6051 |
|
6052 | if (nextDeps !== null) {
|
6053 | var prevDeps = prevState[1];
|
6054 | if (areHookInputsEqual(nextDeps, prevDeps)) {
|
6055 | return prevState[0];
|
6056 | }
|
6057 | }
|
6058 | }
|
6059 | var nextValue = nextCreate();
|
6060 | hook.memoizedState = [nextValue, nextDeps];
|
6061 | return nextValue;
|
6062 | }
|
6063 |
|
6064 |
|
6065 |
|
6066 | var shouldWarnForUnbatchedSetState = false;
|
6067 |
|
6068 | {
|
6069 |
|
6070 |
|
6071 |
|
6072 | if ('undefined' !== typeof jest) {
|
6073 | shouldWarnForUnbatchedSetState = true;
|
6074 | }
|
6075 | }
|
6076 |
|
6077 | function dispatchAction(fiber, queue, action) {
|
6078 | !(numberOfReRenders < RE_RENDER_LIMIT) ? invariant(false, 'Too many re-renders. React limits the number of renders to prevent an infinite loop.') : void 0;
|
6079 |
|
6080 | {
|
6081 | !(arguments.length <= 3) ? warning$1(false, "State updates from the useState() and useReducer() Hooks don't support the " + 'second callback argument. To execute a side effect after ' + 'rendering, declare it in the component body with useEffect().') : void 0;
|
6082 | }
|
6083 |
|
6084 | var alternate = fiber.alternate;
|
6085 | if (fiber === currentlyRenderingFiber$1 || alternate !== null && alternate === currentlyRenderingFiber$1) {
|
6086 |
|
6087 |
|
6088 |
|
6089 | didScheduleRenderPhaseUpdate = true;
|
6090 | var update = {
|
6091 | expirationTime: renderExpirationTime,
|
6092 | action: action,
|
6093 | eagerReducer: null,
|
6094 | eagerState: null,
|
6095 | next: null
|
6096 | };
|
6097 | if (renderPhaseUpdates === null) {
|
6098 | renderPhaseUpdates = new Map();
|
6099 | }
|
6100 | var firstRenderPhaseUpdate = renderPhaseUpdates.get(queue);
|
6101 | if (firstRenderPhaseUpdate === undefined) {
|
6102 | renderPhaseUpdates.set(queue, update);
|
6103 | } else {
|
6104 |
|
6105 | var lastRenderPhaseUpdate = firstRenderPhaseUpdate;
|
6106 | while (lastRenderPhaseUpdate.next !== null) {
|
6107 | lastRenderPhaseUpdate = lastRenderPhaseUpdate.next;
|
6108 | }
|
6109 | lastRenderPhaseUpdate.next = update;
|
6110 | }
|
6111 | } else {
|
6112 | flushPassiveEffects();
|
6113 |
|
6114 | var currentTime = requestCurrentTime();
|
6115 | var _expirationTime = computeExpirationForFiber(currentTime, fiber);
|
6116 |
|
6117 | var _update2 = {
|
6118 | expirationTime: _expirationTime,
|
6119 | action: action,
|
6120 | eagerReducer: null,
|
6121 | eagerState: null,
|
6122 | next: null
|
6123 | };
|
6124 |
|
6125 |
|
6126 | var _last = queue.last;
|
6127 | if (_last === null) {
|
6128 |
|
6129 | _update2.next = _update2;
|
6130 | } else {
|
6131 | var first = _last.next;
|
6132 | if (first !== null) {
|
6133 |
|
6134 | _update2.next = first;
|
6135 | }
|
6136 | _last.next = _update2;
|
6137 | }
|
6138 | queue.last = _update2;
|
6139 |
|
6140 | if (fiber.expirationTime === NoWork && (alternate === null || alternate.expirationTime === NoWork)) {
|
6141 |
|
6142 |
|
6143 |
|
6144 | var _eagerReducer = queue.eagerReducer;
|
6145 | if (_eagerReducer !== null) {
|
6146 | var prevDispatcher = void 0;
|
6147 | {
|
6148 | prevDispatcher = ReactCurrentDispatcher$1.current;
|
6149 | ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
|
6150 | }
|
6151 | try {
|
6152 | var currentState = queue.eagerState;
|
6153 | var _eagerState = _eagerReducer(currentState, action);
|
6154 |
|
6155 |
|
6156 |
|
6157 |
|
6158 | _update2.eagerReducer = _eagerReducer;
|
6159 | _update2.eagerState = _eagerState;
|
6160 | if (is(_eagerState, currentState)) {
|
6161 |
|
6162 |
|
6163 |
|
6164 |
|
6165 | return;
|
6166 | }
|
6167 | } catch (error) {
|
6168 |
|
6169 | } finally {
|
6170 | {
|
6171 | ReactCurrentDispatcher$1.current = prevDispatcher;
|
6172 | }
|
6173 | }
|
6174 | }
|
6175 | }
|
6176 | {
|
6177 | if (shouldWarnForUnbatchedSetState === true) {
|
6178 | warnIfNotCurrentlyBatchingInDev(fiber);
|
6179 | }
|
6180 | }
|
6181 | scheduleWork(fiber, _expirationTime);
|
6182 | }
|
6183 | }
|
6184 |
|
6185 | var ContextOnlyDispatcher = {
|
6186 | readContext: readContext,
|
6187 |
|
6188 | useCallback: throwInvalidHookError,
|
6189 | useContext: throwInvalidHookError,
|
6190 | useEffect: throwInvalidHookError,
|
6191 | useImperativeHandle: throwInvalidHookError,
|
6192 | useLayoutEffect: throwInvalidHookError,
|
6193 | useMemo: throwInvalidHookError,
|
6194 | useReducer: throwInvalidHookError,
|
6195 | useRef: throwInvalidHookError,
|
6196 | useState: throwInvalidHookError,
|
6197 | useDebugValue: throwInvalidHookError
|
6198 | };
|
6199 |
|
6200 | var HooksDispatcherOnMountInDEV = null;
|
6201 | var HooksDispatcherOnMountWithHookTypesInDEV = null;
|
6202 | var HooksDispatcherOnUpdateInDEV = null;
|
6203 | var InvalidNestedHooksDispatcherOnMountInDEV = null;
|
6204 | var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
|
6205 |
|
6206 | {
|
6207 | var warnInvalidContextAccess = function () {
|
6208 | warning$1(false, 'Context can only be read while React is rendering. ' + 'In classes, you can read it in the render method or getDerivedStateFromProps. ' + 'In function components, you can read it directly in the function body, but not ' + 'inside Hooks like useReducer() or useMemo().');
|
6209 | };
|
6210 |
|
6211 | var warnInvalidHookAccess = function () {
|
6212 | warning$1(false, 'Do not call Hooks inside useEffect(...), useMemo(...), or other built-in Hooks. ' + 'You can only call Hooks at the top level of your React function. ' + 'For more information, see ' + 'https://fb.me/rules-of-hooks');
|
6213 | };
|
6214 |
|
6215 | HooksDispatcherOnMountInDEV = {
|
6216 | readContext: function (context, observedBits) {
|
6217 | return readContext(context, observedBits);
|
6218 | },
|
6219 | useCallback: function (callback, deps) {
|
6220 | currentHookNameInDev = 'useCallback';
|
6221 | mountHookTypesDev();
|
6222 | return mountCallback(callback, deps);
|
6223 | },
|
6224 | useContext: function (context, observedBits) {
|
6225 | currentHookNameInDev = 'useContext';
|
6226 | mountHookTypesDev();
|
6227 | return readContext(context, observedBits);
|
6228 | },
|
6229 | useEffect: function (create, deps) {
|
6230 | currentHookNameInDev = 'useEffect';
|
6231 | mountHookTypesDev();
|
6232 | return mountEffect(create, deps);
|
6233 | },
|
6234 | useImperativeHandle: function (ref, create, deps) {
|
6235 | currentHookNameInDev = 'useImperativeHandle';
|
6236 | mountHookTypesDev();
|
6237 | return mountImperativeHandle(ref, create, deps);
|
6238 | },
|
6239 | useLayoutEffect: function (create, deps) {
|
6240 | currentHookNameInDev = 'useLayoutEffect';
|
6241 | mountHookTypesDev();
|
6242 | return mountLayoutEffect(create, deps);
|
6243 | },
|
6244 | useMemo: function (create, deps) {
|
6245 | currentHookNameInDev = 'useMemo';
|
6246 | mountHookTypesDev();
|
6247 | var prevDispatcher = ReactCurrentDispatcher$1.current;
|
6248 | ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
|
6249 | try {
|
6250 | return mountMemo(create, deps);
|
6251 | } finally {
|
6252 | ReactCurrentDispatcher$1.current = prevDispatcher;
|
6253 | }
|
6254 | },
|
6255 | useReducer: function (reducer, initialArg, init) {
|
6256 | currentHookNameInDev = 'useReducer';
|
6257 | mountHookTypesDev();
|
6258 | var prevDispatcher = ReactCurrentDispatcher$1.current;
|
6259 | ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
|
6260 | try {
|
6261 | return mountReducer(reducer, initialArg, init);
|
6262 | } finally {
|
6263 | ReactCurrentDispatcher$1.current = prevDispatcher;
|
6264 | }
|
6265 | },
|
6266 | useRef: function (initialValue) {
|
6267 | currentHookNameInDev = 'useRef';
|
6268 | mountHookTypesDev();
|
6269 | return mountRef(initialValue);
|
6270 | },
|
6271 | useState: function (initialState) {
|
6272 | currentHookNameInDev = 'useState';
|
6273 | mountHookTypesDev();
|
6274 | var prevDispatcher = ReactCurrentDispatcher$1.current;
|
6275 | ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
|
6276 | try {
|
6277 | return mountState(initialState);
|
6278 | } finally {
|
6279 | ReactCurrentDispatcher$1.current = prevDispatcher;
|
6280 | }
|
6281 | },
|
6282 | useDebugValue: function (value, formatterFn) {
|
6283 | currentHookNameInDev = 'useDebugValue';
|
6284 | mountHookTypesDev();
|
6285 | return mountDebugValue(value, formatterFn);
|
6286 | }
|
6287 | };
|
6288 |
|
6289 | HooksDispatcherOnMountWithHookTypesInDEV = {
|
6290 | readContext: function (context, observedBits) {
|
6291 | return readContext(context, observedBits);
|
6292 | },
|
6293 | useCallback: function (callback, deps) {
|
6294 | currentHookNameInDev = 'useCallback';
|
6295 | updateHookTypesDev();
|
6296 | return mountCallback(callback, deps);
|
6297 | },
|
6298 | useContext: function (context, observedBits) {
|
6299 | currentHookNameInDev = 'useContext';
|
6300 | updateHookTypesDev();
|
6301 | return readContext(context, observedBits);
|
6302 | },
|
6303 | useEffect: function (create, deps) {
|
6304 | currentHookNameInDev = 'useEffect';
|
6305 | updateHookTypesDev();
|
6306 | return mountEffect(create, deps);
|
6307 | },
|
6308 | useImperativeHandle: function (ref, create, deps) {
|
6309 | currentHookNameInDev = 'useImperativeHandle';
|
6310 | updateHookTypesDev();
|
6311 | return mountImperativeHandle(ref, create, deps);
|
6312 | },
|
6313 | useLayoutEffect: function (create, deps) {
|
6314 | currentHookNameInDev = 'useLayoutEffect';
|
6315 | updateHookTypesDev();
|
6316 | return mountLayoutEffect(create, deps);
|
6317 | },
|
6318 | useMemo: function (create, deps) {
|
6319 | currentHookNameInDev = 'useMemo';
|
6320 | updateHookTypesDev();
|
6321 | var prevDispatcher = ReactCurrentDispatcher$1.current;
|
6322 | ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
|
6323 | try {
|
6324 | return mountMemo(create, deps);
|
6325 | } finally {
|
6326 | ReactCurrentDispatcher$1.current = prevDispatcher;
|
6327 | }
|
6328 | },
|
6329 | useReducer: function (reducer, initialArg, init) {
|
6330 | currentHookNameInDev = 'useReducer';
|
6331 | updateHookTypesDev();
|
6332 | var prevDispatcher = ReactCurrentDispatcher$1.current;
|
6333 | ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
|
6334 | try {
|
6335 | return mountReducer(reducer, initialArg, init);
|
6336 | } finally {
|
6337 | ReactCurrentDispatcher$1.current = prevDispatcher;
|
6338 | }
|
6339 | },
|
6340 | useRef: function (initialValue) {
|
6341 | currentHookNameInDev = 'useRef';
|
6342 | updateHookTypesDev();
|
6343 | return mountRef(initialValue);
|
6344 | },
|
6345 | useState: function (initialState) {
|
6346 | currentHookNameInDev = 'useState';
|
6347 | updateHookTypesDev();
|
6348 | var prevDispatcher = ReactCurrentDispatcher$1.current;
|
6349 | ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
|
6350 | try {
|
6351 | return mountState(initialState);
|
6352 | } finally {
|
6353 | ReactCurrentDispatcher$1.current = prevDispatcher;
|
6354 | }
|
6355 | },
|
6356 | useDebugValue: function (value, formatterFn) {
|
6357 | currentHookNameInDev = 'useDebugValue';
|
6358 | updateHookTypesDev();
|
6359 | return mountDebugValue(value, formatterFn);
|
6360 | }
|
6361 | };
|
6362 |
|
6363 | HooksDispatcherOnUpdateInDEV = {
|
6364 | readContext: function (context, observedBits) {
|
6365 | return readContext(context, observedBits);
|
6366 | },
|
6367 | useCallback: function (callback, deps) {
|
6368 | currentHookNameInDev = 'useCallback';
|
6369 | updateHookTypesDev();
|
6370 | return updateCallback(callback, deps);
|
6371 | },
|
6372 | useContext: function (context, observedBits) {
|
6373 | currentHookNameInDev = 'useContext';
|
6374 | updateHookTypesDev();
|
6375 | return readContext(context, observedBits);
|
6376 | },
|
6377 | useEffect: function (create, deps) {
|
6378 | currentHookNameInDev = 'useEffect';
|
6379 | updateHookTypesDev();
|
6380 | return updateEffect(create, deps);
|
6381 | },
|
6382 | useImperativeHandle: function (ref, create, deps) {
|
6383 | currentHookNameInDev = 'useImperativeHandle';
|
6384 | updateHookTypesDev();
|
6385 | return updateImperativeHandle(ref, create, deps);
|
6386 | },
|
6387 | useLayoutEffect: function (create, deps) {
|
6388 | currentHookNameInDev = 'useLayoutEffect';
|
6389 | updateHookTypesDev();
|
6390 | return updateLayoutEffect(create, deps);
|
6391 | },
|
6392 | useMemo: function (create, deps) {
|
6393 | currentHookNameInDev = 'useMemo';
|
6394 | updateHookTypesDev();
|
6395 | var prevDispatcher = ReactCurrentDispatcher$1.current;
|
6396 | ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
|
6397 | try {
|
6398 | return updateMemo(create, deps);
|
6399 | } finally {
|
6400 | ReactCurrentDispatcher$1.current = prevDispatcher;
|
6401 | }
|
6402 | },
|
6403 | useReducer: function (reducer, initialArg, init) {
|
6404 | currentHookNameInDev = 'useReducer';
|
6405 | updateHookTypesDev();
|
6406 | var prevDispatcher = ReactCurrentDispatcher$1.current;
|
6407 | ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
|
6408 | try {
|
6409 | return updateReducer(reducer, initialArg, init);
|
6410 | } finally {
|
6411 | ReactCurrentDispatcher$1.current = prevDispatcher;
|
6412 | }
|
6413 | },
|
6414 | useRef: function (initialValue) {
|
6415 | currentHookNameInDev = 'useRef';
|
6416 | updateHookTypesDev();
|
6417 | return updateRef(initialValue);
|
6418 | },
|
6419 | useState: function (initialState) {
|
6420 | currentHookNameInDev = 'useState';
|
6421 | updateHookTypesDev();
|
6422 | var prevDispatcher = ReactCurrentDispatcher$1.current;
|
6423 | ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
|
6424 | try {
|
6425 | return updateState(initialState);
|
6426 | } finally {
|
6427 | ReactCurrentDispatcher$1.current = prevDispatcher;
|
6428 | }
|
6429 | },
|
6430 | useDebugValue: function (value, formatterFn) {
|
6431 | currentHookNameInDev = 'useDebugValue';
|
6432 | updateHookTypesDev();
|
6433 | return updateDebugValue(value, formatterFn);
|
6434 | }
|
6435 | };
|
6436 |
|
6437 | InvalidNestedHooksDispatcherOnMountInDEV = {
|
6438 | readContext: function (context, observedBits) {
|
6439 | warnInvalidContextAccess();
|
6440 | return readContext(context, observedBits);
|
6441 | },
|
6442 | useCallback: function (callback, deps) {
|
6443 | currentHookNameInDev = 'useCallback';
|
6444 | warnInvalidHookAccess();
|
6445 | mountHookTypesDev();
|
6446 | return mountCallback(callback, deps);
|
6447 | },
|
6448 | useContext: function (context, observedBits) {
|
6449 | currentHookNameInDev = 'useContext';
|
6450 | warnInvalidHookAccess();
|
6451 | mountHookTypesDev();
|
6452 | return readContext(context, observedBits);
|
6453 | },
|
6454 | useEffect: function (create, deps) {
|
6455 | currentHookNameInDev = 'useEffect';
|
6456 | warnInvalidHookAccess();
|
6457 | mountHookTypesDev();
|
6458 | return mountEffect(create, deps);
|
6459 | },
|
6460 | useImperativeHandle: function (ref, create, deps) {
|
6461 | currentHookNameInDev = 'useImperativeHandle';
|
6462 | warnInvalidHookAccess();
|
6463 | mountHookTypesDev();
|
6464 | return mountImperativeHandle(ref, create, deps);
|
6465 | },
|
6466 | useLayoutEffect: function (create, deps) {
|
6467 | currentHookNameInDev = 'useLayoutEffect';
|
6468 | warnInvalidHookAccess();
|
6469 | mountHookTypesDev();
|
6470 | return mountLayoutEffect(create, deps);
|
6471 | },
|
6472 | useMemo: function (create, deps) {
|
6473 | currentHookNameInDev = 'useMemo';
|
6474 | warnInvalidHookAccess();
|
6475 | mountHookTypesDev();
|
6476 | var prevDispatcher = ReactCurrentDispatcher$1.current;
|
6477 | ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
|
6478 | try {
|
6479 | return mountMemo(create, deps);
|
6480 | } finally {
|
6481 | ReactCurrentDispatcher$1.current = prevDispatcher;
|
6482 | }
|
6483 | },
|
6484 | useReducer: function (reducer, initialArg, init) {
|
6485 | currentHookNameInDev = 'useReducer';
|
6486 | warnInvalidHookAccess();
|
6487 | mountHookTypesDev();
|
6488 | var prevDispatcher = ReactCurrentDispatcher$1.current;
|
6489 | ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
|
6490 | try {
|
6491 | return mountReducer(reducer, initialArg, init);
|
6492 | } finally {
|
6493 | ReactCurrentDispatcher$1.current = prevDispatcher;
|
6494 | }
|
6495 | },
|
6496 | useRef: function (initialValue) {
|
6497 | currentHookNameInDev = 'useRef';
|
6498 | warnInvalidHookAccess();
|
6499 | mountHookTypesDev();
|
6500 | return mountRef(initialValue);
|
6501 | },
|
6502 | useState: function (initialState) {
|
6503 | currentHookNameInDev = 'useState';
|
6504 | warnInvalidHookAccess();
|
6505 | mountHookTypesDev();
|
6506 | var prevDispatcher = ReactCurrentDispatcher$1.current;
|
6507 | ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
|
6508 | try {
|
6509 | return mountState(initialState);
|
6510 | } finally {
|
6511 | ReactCurrentDispatcher$1.current = prevDispatcher;
|
6512 | }
|
6513 | },
|
6514 | useDebugValue: function (value, formatterFn) {
|
6515 | currentHookNameInDev = 'useDebugValue';
|
6516 | warnInvalidHookAccess();
|
6517 | mountHookTypesDev();
|
6518 | return mountDebugValue(value, formatterFn);
|
6519 | }
|
6520 | };
|
6521 |
|
6522 | InvalidNestedHooksDispatcherOnUpdateInDEV = {
|
6523 | readContext: function (context, observedBits) {
|
6524 | warnInvalidContextAccess();
|
6525 | return readContext(context, observedBits);
|
6526 | },
|
6527 | useCallback: function (callback, deps) {
|
6528 | currentHookNameInDev = 'useCallback';
|
6529 | warnInvalidHookAccess();
|
6530 | updateHookTypesDev();
|
6531 | return updateCallback(callback, deps);
|
6532 | },
|
6533 | useContext: function (context, observedBits) {
|
6534 | currentHookNameInDev = 'useContext';
|
6535 | warnInvalidHookAccess();
|
6536 | updateHookTypesDev();
|
6537 | return readContext(context, observedBits);
|
6538 | },
|
6539 | useEffect: function (create, deps) {
|
6540 | currentHookNameInDev = 'useEffect';
|
6541 | warnInvalidHookAccess();
|
6542 | updateHookTypesDev();
|
6543 | return updateEffect(create, deps);
|
6544 | },
|
6545 | useImperativeHandle: function (ref, create, deps) {
|
6546 | currentHookNameInDev = 'useImperativeHandle';
|
6547 | warnInvalidHookAccess();
|
6548 | updateHookTypesDev();
|
6549 | return updateImperativeHandle(ref, create, deps);
|
6550 | },
|
6551 | useLayoutEffect: function (create, deps) {
|
6552 | currentHookNameInDev = 'useLayoutEffect';
|
6553 | warnInvalidHookAccess();
|
6554 | updateHookTypesDev();
|
6555 | return updateLayoutEffect(create, deps);
|
6556 | },
|
6557 | useMemo: function (create, deps) {
|
6558 | currentHookNameInDev = 'useMemo';
|
6559 | warnInvalidHookAccess();
|
6560 | updateHookTypesDev();
|
6561 | var prevDispatcher = ReactCurrentDispatcher$1.current;
|
6562 | ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
|
6563 | try {
|
6564 | return updateMemo(create, deps);
|
6565 | } finally {
|
6566 | ReactCurrentDispatcher$1.current = prevDispatcher;
|
6567 | }
|
6568 | },
|
6569 | useReducer: function (reducer, initialArg, init) {
|
6570 | currentHookNameInDev = 'useReducer';
|
6571 | warnInvalidHookAccess();
|
6572 | updateHookTypesDev();
|
6573 | var prevDispatcher = ReactCurrentDispatcher$1.current;
|
6574 | ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
|
6575 | try {
|
6576 | return updateReducer(reducer, initialArg, init);
|
6577 | } finally {
|
6578 | ReactCurrentDispatcher$1.current = prevDispatcher;
|
6579 | }
|
6580 | },
|
6581 | useRef: function (initialValue) {
|
6582 | currentHookNameInDev = 'useRef';
|
6583 | warnInvalidHookAccess();
|
6584 | updateHookTypesDev();
|
6585 | return updateRef(initialValue);
|
6586 | },
|
6587 | useState: function (initialState) {
|
6588 | currentHookNameInDev = 'useState';
|
6589 | warnInvalidHookAccess();
|
6590 | updateHookTypesDev();
|
6591 | var prevDispatcher = ReactCurrentDispatcher$1.current;
|
6592 | ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
|
6593 | try {
|
6594 | return updateState(initialState);
|
6595 | } finally {
|
6596 | ReactCurrentDispatcher$1.current = prevDispatcher;
|
6597 | }
|
6598 | },
|
6599 | useDebugValue: function (value, formatterFn) {
|
6600 | currentHookNameInDev = 'useDebugValue';
|
6601 | warnInvalidHookAccess();
|
6602 | updateHookTypesDev();
|
6603 | return updateDebugValue(value, formatterFn);
|
6604 | }
|
6605 | };
|
6606 | }
|
6607 |
|
6608 | var commitTime = 0;
|
6609 | var profilerStartTime = -1;
|
6610 |
|
6611 | function getCommitTime() {
|
6612 | return commitTime;
|
6613 | }
|
6614 |
|
6615 | function recordCommitTime() {
|
6616 | if (!enableProfilerTimer) {
|
6617 | return;
|
6618 | }
|
6619 | commitTime = unstable_now();
|
6620 | }
|
6621 |
|
6622 | function startProfilerTimer(fiber) {
|
6623 | if (!enableProfilerTimer) {
|
6624 | return;
|
6625 | }
|
6626 |
|
6627 | profilerStartTime = unstable_now();
|
6628 |
|
6629 | if (fiber.actualStartTime < 0) {
|
6630 | fiber.actualStartTime = unstable_now();
|
6631 | }
|
6632 | }
|
6633 |
|
6634 | function stopProfilerTimerIfRunning(fiber) {
|
6635 | if (!enableProfilerTimer) {
|
6636 | return;
|
6637 | }
|
6638 | profilerStartTime = -1;
|
6639 | }
|
6640 |
|
6641 | function stopProfilerTimerIfRunningAndRecordDelta(fiber, overrideBaseTime) {
|
6642 | if (!enableProfilerTimer) {
|
6643 | return;
|
6644 | }
|
6645 |
|
6646 | if (profilerStartTime >= 0) {
|
6647 | var elapsedTime = unstable_now() - profilerStartTime;
|
6648 | fiber.actualDuration += elapsedTime;
|
6649 | if (overrideBaseTime) {
|
6650 | fiber.selfBaseDuration = elapsedTime;
|
6651 | }
|
6652 | profilerStartTime = -1;
|
6653 | }
|
6654 | }
|
6655 |
|
6656 |
|
6657 |
|
6658 | var hydrationParentFiber = null;
|
6659 | var nextHydratableInstance = null;
|
6660 | var isHydrating = false;
|
6661 |
|
6662 | function enterHydrationState(fiber) {
|
6663 | if (!supportsHydration) {
|
6664 | return false;
|
6665 | }
|
6666 |
|
6667 | var parentInstance = fiber.stateNode.containerInfo;
|
6668 | nextHydratableInstance = getFirstHydratableChild(parentInstance);
|
6669 | hydrationParentFiber = fiber;
|
6670 | isHydrating = true;
|
6671 | return true;
|
6672 | }
|
6673 |
|
6674 | function reenterHydrationStateFromDehydratedSuspenseInstance(fiber) {
|
6675 | if (!supportsHydration) {
|
6676 | return false;
|
6677 | }
|
6678 |
|
6679 | var suspenseInstance = fiber.stateNode;
|
6680 | nextHydratableInstance = getNextHydratableSibling(suspenseInstance);
|
6681 | popToNextHostParent(fiber);
|
6682 | isHydrating = true;
|
6683 | return true;
|
6684 | }
|
6685 |
|
6686 | function deleteHydratableInstance(returnFiber, instance) {
|
6687 | {
|
6688 | switch (returnFiber.tag) {
|
6689 | case HostRoot:
|
6690 | didNotHydrateContainerInstance(returnFiber.stateNode.containerInfo, instance);
|
6691 | break;
|
6692 | case HostComponent:
|
6693 | didNotHydrateInstance(returnFiber.type, returnFiber.memoizedProps, returnFiber.stateNode, instance);
|
6694 | break;
|
6695 | }
|
6696 | }
|
6697 |
|
6698 | var childToDelete = createFiberFromHostInstanceForDeletion();
|
6699 | childToDelete.stateNode = instance;
|
6700 | childToDelete.return = returnFiber;
|
6701 | childToDelete.effectTag = Deletion;
|
6702 |
|
6703 |
|
6704 |
|
6705 |
|
6706 |
|
6707 |
|
6708 | if (returnFiber.lastEffect !== null) {
|
6709 | returnFiber.lastEffect.nextEffect = childToDelete;
|
6710 | returnFiber.lastEffect = childToDelete;
|
6711 | } else {
|
6712 | returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;
|
6713 | }
|
6714 | }
|
6715 |
|
6716 | function insertNonHydratedInstance(returnFiber, fiber) {
|
6717 | fiber.effectTag |= Placement;
|
6718 | {
|
6719 | switch (returnFiber.tag) {
|
6720 | case HostRoot:
|
6721 | {
|
6722 | var parentContainer = returnFiber.stateNode.containerInfo;
|
6723 | switch (fiber.tag) {
|
6724 | case HostComponent:
|
6725 | var type = fiber.type;
|
6726 | var props = fiber.pendingProps;
|
6727 | didNotFindHydratableContainerInstance(parentContainer, type, props);
|
6728 | break;
|
6729 | case HostText:
|
6730 | var text = fiber.pendingProps;
|
6731 | didNotFindHydratableContainerTextInstance(parentContainer, text);
|
6732 | break;
|
6733 | case SuspenseComponent:
|
6734 | didNotFindHydratableContainerSuspenseInstance(parentContainer);
|
6735 | break;
|
6736 | }
|
6737 | break;
|
6738 | }
|
6739 | case HostComponent:
|
6740 | {
|
6741 | var parentType = returnFiber.type;
|
6742 | var parentProps = returnFiber.memoizedProps;
|
6743 | var parentInstance = returnFiber.stateNode;
|
6744 | switch (fiber.tag) {
|
6745 | case HostComponent:
|
6746 | var _type = fiber.type;
|
6747 | var _props = fiber.pendingProps;
|
6748 | didNotFindHydratableInstance(parentType, parentProps, parentInstance, _type, _props);
|
6749 | break;
|
6750 | case HostText:
|
6751 | var _text = fiber.pendingProps;
|
6752 | didNotFindHydratableTextInstance(parentType, parentProps, parentInstance, _text);
|
6753 | break;
|
6754 | case SuspenseComponent:
|
6755 | didNotFindHydratableSuspenseInstance(parentType, parentProps, parentInstance);
|
6756 | break;
|
6757 | }
|
6758 | break;
|
6759 | }
|
6760 | default:
|
6761 | return;
|
6762 | }
|
6763 | }
|
6764 | }
|
6765 |
|
6766 | function tryHydrate(fiber, nextInstance) {
|
6767 | switch (fiber.tag) {
|
6768 | case HostComponent:
|
6769 | {
|
6770 | var type = fiber.type;
|
6771 | var props = fiber.pendingProps;
|
6772 | var instance = canHydrateInstance(nextInstance, type, props);
|
6773 | if (instance !== null) {
|
6774 | fiber.stateNode = instance;
|
6775 | return true;
|
6776 | }
|
6777 | return false;
|
6778 | }
|
6779 | case HostText:
|
6780 | {
|
6781 | var text = fiber.pendingProps;
|
6782 | var textInstance = canHydrateTextInstance(nextInstance, text);
|
6783 | if (textInstance !== null) {
|
6784 | fiber.stateNode = textInstance;
|
6785 | return true;
|
6786 | }
|
6787 | return false;
|
6788 | }
|
6789 | case SuspenseComponent:
|
6790 | {
|
6791 | if (enableSuspenseServerRenderer) {
|
6792 | var suspenseInstance = canHydrateSuspenseInstance(nextInstance);
|
6793 | if (suspenseInstance !== null) {
|
6794 |
|
6795 | fiber.tag = DehydratedSuspenseComponent;
|
6796 | fiber.stateNode = suspenseInstance;
|
6797 | return true;
|
6798 | }
|
6799 | }
|
6800 | return false;
|
6801 | }
|
6802 | default:
|
6803 | return false;
|
6804 | }
|
6805 | }
|
6806 |
|
6807 | function tryToClaimNextHydratableInstance(fiber) {
|
6808 | if (!isHydrating) {
|
6809 | return;
|
6810 | }
|
6811 | var nextInstance = nextHydratableInstance;
|
6812 | if (!nextInstance) {
|
6813 |
|
6814 | insertNonHydratedInstance(hydrationParentFiber, fiber);
|
6815 | isHydrating = false;
|
6816 | hydrationParentFiber = fiber;
|
6817 | return;
|
6818 | }
|
6819 | var firstAttemptedInstance = nextInstance;
|
6820 | if (!tryHydrate(fiber, nextInstance)) {
|
6821 |
|
6822 |
|
6823 |
|
6824 | nextInstance = getNextHydratableSibling(firstAttemptedInstance);
|
6825 | if (!nextInstance || !tryHydrate(fiber, nextInstance)) {
|
6826 |
|
6827 | insertNonHydratedInstance(hydrationParentFiber, fiber);
|
6828 | isHydrating = false;
|
6829 | hydrationParentFiber = fiber;
|
6830 | return;
|
6831 | }
|
6832 |
|
6833 |
|
6834 |
|
6835 |
|
6836 | deleteHydratableInstance(hydrationParentFiber, firstAttemptedInstance);
|
6837 | }
|
6838 | hydrationParentFiber = fiber;
|
6839 | nextHydratableInstance = getFirstHydratableChild(nextInstance);
|
6840 | }
|
6841 |
|
6842 | function prepareToHydrateHostInstance(fiber, rootContainerInstance, hostContext) {
|
6843 | if (!supportsHydration) {
|
6844 | invariant(false, 'Expected prepareToHydrateHostInstance() to never be called. This error is likely caused by a bug in React. Please file an issue.');
|
6845 | }
|
6846 |
|
6847 | var instance = fiber.stateNode;
|
6848 | var updatePayload = hydrateInstance(instance, fiber.type, fiber.memoizedProps, rootContainerInstance, hostContext, fiber);
|
6849 |
|
6850 | fiber.updateQueue = updatePayload;
|
6851 |
|
6852 |
|
6853 | if (updatePayload !== null) {
|
6854 | return true;
|
6855 | }
|
6856 | return false;
|
6857 | }
|
6858 |
|
6859 | function prepareToHydrateHostTextInstance(fiber) {
|
6860 | if (!supportsHydration) {
|
6861 | invariant(false, 'Expected prepareToHydrateHostTextInstance() to never be called. This error is likely caused by a bug in React. Please file an issue.');
|
6862 | }
|
6863 |
|
6864 | var textInstance = fiber.stateNode;
|
6865 | var textContent = fiber.memoizedProps;
|
6866 | var shouldUpdate = hydrateTextInstance(textInstance, textContent, fiber);
|
6867 | {
|
6868 | if (shouldUpdate) {
|
6869 |
|
6870 |
|
6871 | var returnFiber = hydrationParentFiber;
|
6872 | if (returnFiber !== null) {
|
6873 | switch (returnFiber.tag) {
|
6874 | case HostRoot:
|
6875 | {
|
6876 | var parentContainer = returnFiber.stateNode.containerInfo;
|
6877 | didNotMatchHydratedContainerTextInstance(parentContainer, textInstance, textContent);
|
6878 | break;
|
6879 | }
|
6880 | case HostComponent:
|
6881 | {
|
6882 | var parentType = returnFiber.type;
|
6883 | var parentProps = returnFiber.memoizedProps;
|
6884 | var parentInstance = returnFiber.stateNode;
|
6885 | didNotMatchHydratedTextInstance(parentType, parentProps, parentInstance, textInstance, textContent);
|
6886 | break;
|
6887 | }
|
6888 | }
|
6889 | }
|
6890 | }
|
6891 | }
|
6892 | return shouldUpdate;
|
6893 | }
|
6894 |
|
6895 | function skipPastDehydratedSuspenseInstance(fiber) {
|
6896 | if (!supportsHydration) {
|
6897 | invariant(false, 'Expected skipPastDehydratedSuspenseInstance() to never be called. This error is likely caused by a bug in React. Please file an issue.');
|
6898 | }
|
6899 | var suspenseInstance = fiber.stateNode;
|
6900 | !suspenseInstance ? invariant(false, 'Expected to have a hydrated suspense instance. This error is likely caused by a bug in React. Please file an issue.') : void 0;
|
6901 | nextHydratableInstance = getNextHydratableInstanceAfterSuspenseInstance(suspenseInstance);
|
6902 | }
|
6903 |
|
6904 | function popToNextHostParent(fiber) {
|
6905 | var parent = fiber.return;
|
6906 | while (parent !== null && parent.tag !== HostComponent && parent.tag !== HostRoot && parent.tag !== DehydratedSuspenseComponent) {
|
6907 | parent = parent.return;
|
6908 | }
|
6909 | hydrationParentFiber = parent;
|
6910 | }
|
6911 |
|
6912 | function popHydrationState(fiber) {
|
6913 | if (!supportsHydration) {
|
6914 | return false;
|
6915 | }
|
6916 | if (fiber !== hydrationParentFiber) {
|
6917 |
|
6918 |
|
6919 | return false;
|
6920 | }
|
6921 | if (!isHydrating) {
|
6922 |
|
6923 |
|
6924 |
|
6925 | popToNextHostParent(fiber);
|
6926 | isHydrating = true;
|
6927 | return false;
|
6928 | }
|
6929 |
|
6930 | var type = fiber.type;
|
6931 |
|
6932 |
|
6933 |
|
6934 |
|
6935 |
|
6936 |
|
6937 | if (fiber.tag !== HostComponent || type !== 'head' && type !== 'body' && !shouldSetTextContent(type, fiber.memoizedProps)) {
|
6938 | var nextInstance = nextHydratableInstance;
|
6939 | while (nextInstance) {
|
6940 | deleteHydratableInstance(fiber, nextInstance);
|
6941 | nextInstance = getNextHydratableSibling(nextInstance);
|
6942 | }
|
6943 | }
|
6944 |
|
6945 | popToNextHostParent(fiber);
|
6946 | nextHydratableInstance = hydrationParentFiber ? getNextHydratableSibling(fiber.stateNode) : null;
|
6947 | return true;
|
6948 | }
|
6949 |
|
6950 | function resetHydrationState() {
|
6951 | if (!supportsHydration) {
|
6952 | return;
|
6953 | }
|
6954 |
|
6955 | hydrationParentFiber = null;
|
6956 | nextHydratableInstance = null;
|
6957 | isHydrating = false;
|
6958 | }
|
6959 |
|
6960 | var ReactCurrentOwner$2 = ReactSharedInternals.ReactCurrentOwner;
|
6961 |
|
6962 | var didReceiveUpdate = false;
|
6963 |
|
6964 | var didWarnAboutBadClass = void 0;
|
6965 | var didWarnAboutContextTypeOnFunctionComponent = void 0;
|
6966 | var didWarnAboutGetDerivedStateOnFunctionComponent = void 0;
|
6967 | var didWarnAboutFunctionRefs = void 0;
|
6968 | var didWarnAboutReassigningProps = void 0;
|
6969 |
|
6970 | {
|
6971 | didWarnAboutBadClass = {};
|
6972 | didWarnAboutContextTypeOnFunctionComponent = {};
|
6973 | didWarnAboutGetDerivedStateOnFunctionComponent = {};
|
6974 | didWarnAboutFunctionRefs = {};
|
6975 | didWarnAboutReassigningProps = false;
|
6976 | }
|
6977 |
|
6978 | function reconcileChildren(current, workInProgress, nextChildren, renderExpirationTime) {
|
6979 | if (current === null) {
|
6980 |
|
6981 |
|
6982 |
|
6983 |
|
6984 | workInProgress.child = mountChildFibers(workInProgress, null, nextChildren, renderExpirationTime);
|
6985 | } else {
|
6986 |
|
6987 |
|
6988 |
|
6989 |
|
6990 |
|
6991 |
|
6992 | workInProgress.child = reconcileChildFibers(workInProgress, current.child, nextChildren, renderExpirationTime);
|
6993 | }
|
6994 | }
|
6995 |
|
6996 | function forceUnmountCurrentAndReconcile(current, workInProgress, nextChildren, renderExpirationTime) {
|
6997 |
|
6998 |
|
6999 |
|
7000 |
|
7001 |
|
7002 |
|
7003 |
|
7004 |
|
7005 | workInProgress.child = reconcileChildFibers(workInProgress, current.child, null, renderExpirationTime);
|
7006 |
|
7007 |
|
7008 |
|
7009 |
|
7010 | workInProgress.child = reconcileChildFibers(workInProgress, null, nextChildren, renderExpirationTime);
|
7011 | }
|
7012 |
|
7013 | function updateForwardRef(current, workInProgress, Component, nextProps, renderExpirationTime) {
|
7014 |
|
7015 |
|
7016 |
|
7017 |
|
7018 | {
|
7019 | if (workInProgress.type !== workInProgress.elementType) {
|
7020 |
|
7021 |
|
7022 | var innerPropTypes = Component.propTypes;
|
7023 | if (innerPropTypes) {
|
7024 | checkPropTypes_1(innerPropTypes, nextProps,
|
7025 | 'prop', getComponentName(Component), getCurrentFiberStackInDev);
|
7026 | }
|
7027 | }
|
7028 | }
|
7029 |
|
7030 | var render = Component.render;
|
7031 | var ref = workInProgress.ref;
|
7032 |
|
7033 |
|
7034 | var nextChildren = void 0;
|
7035 | prepareToReadContext(workInProgress, renderExpirationTime);
|
7036 | {
|
7037 | ReactCurrentOwner$2.current = workInProgress;
|
7038 | setCurrentPhase('render');
|
7039 | nextChildren = renderWithHooks(current, workInProgress, render, nextProps, ref, renderExpirationTime);
|
7040 | if (debugRenderPhaseSideEffects || debugRenderPhaseSideEffectsForStrictMode && workInProgress.mode & StrictMode) {
|
7041 |
|
7042 | if (workInProgress.memoizedState !== null) {
|
7043 | nextChildren = renderWithHooks(current, workInProgress, render, nextProps, ref, renderExpirationTime);
|
7044 | }
|
7045 | }
|
7046 | setCurrentPhase(null);
|
7047 | }
|
7048 |
|
7049 | if (current !== null && !didReceiveUpdate) {
|
7050 | bailoutHooks(current, workInProgress, renderExpirationTime);
|
7051 | return bailoutOnAlreadyFinishedWork(current, workInProgress, renderExpirationTime);
|
7052 | }
|
7053 |
|
7054 |
|
7055 | workInProgress.effectTag |= PerformedWork;
|
7056 | reconcileChildren(current, workInProgress, nextChildren, renderExpirationTime);
|
7057 | return workInProgress.child;
|
7058 | }
|
7059 |
|
7060 | function updateMemoComponent(current, workInProgress, Component, nextProps, updateExpirationTime, renderExpirationTime) {
|
7061 | if (current === null) {
|
7062 | var type = Component.type;
|
7063 | if (isSimpleFunctionComponent(type) && Component.compare === null &&
|
7064 |
|
7065 | Component.defaultProps === undefined) {
|
7066 |
|
7067 |
|
7068 |
|
7069 | workInProgress.tag = SimpleMemoComponent;
|
7070 | workInProgress.type = type;
|
7071 | {
|
7072 | validateFunctionComponentInDev(workInProgress, type);
|
7073 | }
|
7074 | return updateSimpleMemoComponent(current, workInProgress, type, nextProps, updateExpirationTime, renderExpirationTime);
|
7075 | }
|
7076 | {
|
7077 | var innerPropTypes = type.propTypes;
|
7078 | if (innerPropTypes) {
|
7079 |
|
7080 |
|
7081 | checkPropTypes_1(innerPropTypes, nextProps,
|
7082 | 'prop', getComponentName(type), getCurrentFiberStackInDev);
|
7083 | }
|
7084 | }
|
7085 | var child = createFiberFromTypeAndProps(Component.type, null, nextProps, null, workInProgress.mode, renderExpirationTime);
|
7086 | child.ref = workInProgress.ref;
|
7087 | child.return = workInProgress;
|
7088 | workInProgress.child = child;
|
7089 | return child;
|
7090 | }
|
7091 | {
|
7092 | var _type = Component.type;
|
7093 | var _innerPropTypes = _type.propTypes;
|
7094 | if (_innerPropTypes) {
|
7095 |
|
7096 |
|
7097 | checkPropTypes_1(_innerPropTypes, nextProps,
|
7098 | 'prop', getComponentName(_type), getCurrentFiberStackInDev);
|
7099 | }
|
7100 | }
|
7101 | var currentChild = current.child;
|
7102 | if (updateExpirationTime < renderExpirationTime) {
|
7103 |
|
7104 |
|
7105 | var prevProps = currentChild.memoizedProps;
|
7106 |
|
7107 | var compare = Component.compare;
|
7108 | compare = compare !== null ? compare : shallowEqual;
|
7109 | if (compare(prevProps, nextProps) && current.ref === workInProgress.ref) {
|
7110 | return bailoutOnAlreadyFinishedWork(current, workInProgress, renderExpirationTime);
|
7111 | }
|
7112 | }
|
7113 |
|
7114 | workInProgress.effectTag |= PerformedWork;
|
7115 | var newChild = createWorkInProgress(currentChild, nextProps, renderExpirationTime);
|
7116 | newChild.ref = workInProgress.ref;
|
7117 | newChild.return = workInProgress;
|
7118 | workInProgress.child = newChild;
|
7119 | return newChild;
|
7120 | }
|
7121 |
|
7122 | function updateSimpleMemoComponent(current, workInProgress, Component, nextProps, updateExpirationTime, renderExpirationTime) {
|
7123 |
|
7124 |
|
7125 |
|
7126 |
|
7127 | {
|
7128 | if (workInProgress.type !== workInProgress.elementType) {
|
7129 |
|
7130 |
|
7131 | var outerMemoType = workInProgress.elementType;
|
7132 | if (outerMemoType.$$typeof === REACT_LAZY_TYPE) {
|
7133 |
|
7134 |
|
7135 |
|
7136 | outerMemoType = refineResolvedLazyComponent(outerMemoType);
|
7137 | }
|
7138 | var outerPropTypes = outerMemoType && outerMemoType.propTypes;
|
7139 | if (outerPropTypes) {
|
7140 | checkPropTypes_1(outerPropTypes, nextProps,
|
7141 | 'prop', getComponentName(outerMemoType), getCurrentFiberStackInDev);
|
7142 | }
|
7143 |
|
7144 | }
|
7145 | }
|
7146 | if (current !== null) {
|
7147 | var prevProps = current.memoizedProps;
|
7148 | if (shallowEqual(prevProps, nextProps) && current.ref === workInProgress.ref) {
|
7149 | didReceiveUpdate = false;
|
7150 | if (updateExpirationTime < renderExpirationTime) {
|
7151 | return bailoutOnAlreadyFinishedWork(current, workInProgress, renderExpirationTime);
|
7152 | }
|
7153 | }
|
7154 | }
|
7155 | return updateFunctionComponent(current, workInProgress, Component, nextProps, renderExpirationTime);
|
7156 | }
|
7157 |
|
7158 | function updateFragment(current, workInProgress, renderExpirationTime) {
|
7159 | var nextChildren = workInProgress.pendingProps;
|
7160 | reconcileChildren(current, workInProgress, nextChildren, renderExpirationTime);
|
7161 | return workInProgress.child;
|
7162 | }
|
7163 |
|
7164 | function updateMode(current, workInProgress, renderExpirationTime) {
|
7165 | var nextChildren = workInProgress.pendingProps.children;
|
7166 | reconcileChildren(current, workInProgress, nextChildren, renderExpirationTime);
|
7167 | return workInProgress.child;
|
7168 | }
|
7169 |
|
7170 | function updateProfiler(current, workInProgress, renderExpirationTime) {
|
7171 | if (enableProfilerTimer) {
|
7172 | workInProgress.effectTag |= Update;
|
7173 | }
|
7174 | var nextProps = workInProgress.pendingProps;
|
7175 | var nextChildren = nextProps.children;
|
7176 | reconcileChildren(current, workInProgress, nextChildren, renderExpirationTime);
|
7177 | return workInProgress.child;
|
7178 | }
|
7179 |
|
7180 | function markRef(current, workInProgress) {
|
7181 | var ref = workInProgress.ref;
|
7182 | if (current === null && ref !== null || current !== null && current.ref !== ref) {
|
7183 |
|
7184 | workInProgress.effectTag |= Ref;
|
7185 | }
|
7186 | }
|
7187 |
|
7188 | function updateFunctionComponent(current, workInProgress, Component, nextProps, renderExpirationTime) {
|
7189 | {
|
7190 | if (workInProgress.type !== workInProgress.elementType) {
|
7191 |
|
7192 |
|
7193 | var innerPropTypes = Component.propTypes;
|
7194 | if (innerPropTypes) {
|
7195 | checkPropTypes_1(innerPropTypes, nextProps,
|
7196 | 'prop', getComponentName(Component), getCurrentFiberStackInDev);
|
7197 | }
|
7198 | }
|
7199 | }
|
7200 |
|
7201 | var unmaskedContext = getUnmaskedContext(workInProgress, Component, true);
|
7202 | var context = getMaskedContext(workInProgress, unmaskedContext);
|
7203 |
|
7204 | var nextChildren = void 0;
|
7205 | prepareToReadContext(workInProgress, renderExpirationTime);
|
7206 | {
|
7207 | ReactCurrentOwner$2.current = workInProgress;
|
7208 | setCurrentPhase('render');
|
7209 | nextChildren = renderWithHooks(current, workInProgress, Component, nextProps, context, renderExpirationTime);
|
7210 | if (debugRenderPhaseSideEffects || debugRenderPhaseSideEffectsForStrictMode && workInProgress.mode & StrictMode) {
|
7211 |
|
7212 | if (workInProgress.memoizedState !== null) {
|
7213 | nextChildren = renderWithHooks(current, workInProgress, Component, nextProps, context, renderExpirationTime);
|
7214 | }
|
7215 | }
|
7216 | setCurrentPhase(null);
|
7217 | }
|
7218 |
|
7219 | if (current !== null && !didReceiveUpdate) {
|
7220 | bailoutHooks(current, workInProgress, renderExpirationTime);
|
7221 | return bailoutOnAlreadyFinishedWork(current, workInProgress, renderExpirationTime);
|
7222 | }
|
7223 |
|
7224 |
|
7225 | workInProgress.effectTag |= PerformedWork;
|
7226 | reconcileChildren(current, workInProgress, nextChildren, renderExpirationTime);
|
7227 | return workInProgress.child;
|
7228 | }
|
7229 |
|
7230 | function updateClassComponent(current, workInProgress, Component, nextProps, renderExpirationTime) {
|
7231 | {
|
7232 | if (workInProgress.type !== workInProgress.elementType) {
|
7233 |
|
7234 |
|
7235 | var innerPropTypes = Component.propTypes;
|
7236 | if (innerPropTypes) {
|
7237 | checkPropTypes_1(innerPropTypes, nextProps,
|
7238 | 'prop', getComponentName(Component), getCurrentFiberStackInDev);
|
7239 | }
|
7240 | }
|
7241 | }
|
7242 |
|
7243 |
|
7244 |
|
7245 |
|
7246 | var hasContext = void 0;
|
7247 | if (isContextProvider(Component)) {
|
7248 | hasContext = true;
|
7249 | pushContextProvider(workInProgress);
|
7250 | } else {
|
7251 | hasContext = false;
|
7252 | }
|
7253 | prepareToReadContext(workInProgress, renderExpirationTime);
|
7254 |
|
7255 | var instance = workInProgress.stateNode;
|
7256 | var shouldUpdate = void 0;
|
7257 | if (instance === null) {
|
7258 | if (current !== null) {
|
7259 |
|
7260 |
|
7261 |
|
7262 |
|
7263 | current.alternate = null;
|
7264 | workInProgress.alternate = null;
|
7265 |
|
7266 | workInProgress.effectTag |= Placement;
|
7267 | }
|
7268 |
|
7269 | constructClassInstance(workInProgress, Component, nextProps, renderExpirationTime);
|
7270 | mountClassInstance(workInProgress, Component, nextProps, renderExpirationTime);
|
7271 | shouldUpdate = true;
|
7272 | } else if (current === null) {
|
7273 |
|
7274 | shouldUpdate = resumeMountClassInstance(workInProgress, Component, nextProps, renderExpirationTime);
|
7275 | } else {
|
7276 | shouldUpdate = updateClassInstance(current, workInProgress, Component, nextProps, renderExpirationTime);
|
7277 | }
|
7278 | var nextUnitOfWork = finishClassComponent(current, workInProgress, Component, shouldUpdate, hasContext, renderExpirationTime);
|
7279 | {
|
7280 | var inst = workInProgress.stateNode;
|
7281 | if (inst.props !== nextProps) {
|
7282 | !didWarnAboutReassigningProps ? warning$1(false, 'It looks like %s is reassigning its own `this.props` while rendering. ' + 'This is not supported and can lead to confusing bugs.', getComponentName(workInProgress.type) || 'a component') : void 0;
|
7283 | didWarnAboutReassigningProps = true;
|
7284 | }
|
7285 | }
|
7286 | return nextUnitOfWork;
|
7287 | }
|
7288 |
|
7289 | function finishClassComponent(current, workInProgress, Component, shouldUpdate, hasContext, renderExpirationTime) {
|
7290 |
|
7291 | markRef(current, workInProgress);
|
7292 |
|
7293 | var didCaptureError = (workInProgress.effectTag & DidCapture) !== NoEffect;
|
7294 |
|
7295 | if (!shouldUpdate && !didCaptureError) {
|
7296 |
|
7297 | if (hasContext) {
|
7298 | invalidateContextProvider(workInProgress, Component, false);
|
7299 | }
|
7300 |
|
7301 | return bailoutOnAlreadyFinishedWork(current, workInProgress, renderExpirationTime);
|
7302 | }
|
7303 |
|
7304 | var instance = workInProgress.stateNode;
|
7305 |
|
7306 |
|
7307 | ReactCurrentOwner$2.current = workInProgress;
|
7308 | var nextChildren = void 0;
|
7309 | if (didCaptureError && typeof Component.getDerivedStateFromError !== 'function') {
|
7310 |
|
7311 |
|
7312 |
|
7313 |
|
7314 |
|
7315 | nextChildren = null;
|
7316 |
|
7317 | if (enableProfilerTimer) {
|
7318 | stopProfilerTimerIfRunning(workInProgress);
|
7319 | }
|
7320 | } else {
|
7321 | {
|
7322 | setCurrentPhase('render');
|
7323 | nextChildren = instance.render();
|
7324 | if (debugRenderPhaseSideEffects || debugRenderPhaseSideEffectsForStrictMode && workInProgress.mode & StrictMode) {
|
7325 | instance.render();
|
7326 | }
|
7327 | setCurrentPhase(null);
|
7328 | }
|
7329 | }
|
7330 |
|
7331 |
|
7332 | workInProgress.effectTag |= PerformedWork;
|
7333 | if (current !== null && didCaptureError) {
|
7334 |
|
7335 |
|
7336 |
|
7337 |
|
7338 | forceUnmountCurrentAndReconcile(current, workInProgress, nextChildren, renderExpirationTime);
|
7339 | } else {
|
7340 | reconcileChildren(current, workInProgress, nextChildren, renderExpirationTime);
|
7341 | }
|
7342 |
|
7343 |
|
7344 |
|
7345 | workInProgress.memoizedState = instance.state;
|
7346 |
|
7347 |
|
7348 | if (hasContext) {
|
7349 | invalidateContextProvider(workInProgress, Component, true);
|
7350 | }
|
7351 |
|
7352 | return workInProgress.child;
|
7353 | }
|
7354 |
|
7355 | function pushHostRootContext(workInProgress) {
|
7356 | var root = workInProgress.stateNode;
|
7357 | if (root.pendingContext) {
|
7358 | pushTopLevelContextObject(workInProgress, root.pendingContext, root.pendingContext !== root.context);
|
7359 | } else if (root.context) {
|
7360 |
|
7361 | pushTopLevelContextObject(workInProgress, root.context, false);
|
7362 | }
|
7363 | pushHostContainer(workInProgress, root.containerInfo);
|
7364 | }
|
7365 |
|
7366 | function updateHostRoot(current, workInProgress, renderExpirationTime) {
|
7367 | pushHostRootContext(workInProgress);
|
7368 | var updateQueue = workInProgress.updateQueue;
|
7369 | !(updateQueue !== null) ? invariant(false, 'If the root does not have an updateQueue, we should have already bailed out. This error is likely caused by a bug in React. Please file an issue.') : void 0;
|
7370 | var nextProps = workInProgress.pendingProps;
|
7371 | var prevState = workInProgress.memoizedState;
|
7372 | var prevChildren = prevState !== null ? prevState.element : null;
|
7373 | processUpdateQueue(workInProgress, updateQueue, nextProps, null, renderExpirationTime);
|
7374 | var nextState = workInProgress.memoizedState;
|
7375 |
|
7376 |
|
7377 | var nextChildren = nextState.element;
|
7378 | if (nextChildren === prevChildren) {
|
7379 |
|
7380 |
|
7381 | resetHydrationState();
|
7382 | return bailoutOnAlreadyFinishedWork(current, workInProgress, renderExpirationTime);
|
7383 | }
|
7384 | var root = workInProgress.stateNode;
|
7385 | if ((current === null || current.child === null) && root.hydrate && enterHydrationState(workInProgress)) {
|
7386 |
|
7387 |
|
7388 |
|
7389 |
|
7390 |
|
7391 |
|
7392 |
|
7393 |
|
7394 |
|
7395 | workInProgress.effectTag |= Placement;
|
7396 |
|
7397 |
|
7398 |
|
7399 |
|
7400 | workInProgress.child = mountChildFibers(workInProgress, null, nextChildren, renderExpirationTime);
|
7401 | } else {
|
7402 |
|
7403 |
|
7404 | reconcileChildren(current, workInProgress, nextChildren, renderExpirationTime);
|
7405 | resetHydrationState();
|
7406 | }
|
7407 | return workInProgress.child;
|
7408 | }
|
7409 |
|
7410 | function updateHostComponent(current, workInProgress, renderExpirationTime) {
|
7411 | pushHostContext(workInProgress);
|
7412 |
|
7413 | if (current === null) {
|
7414 | tryToClaimNextHydratableInstance(workInProgress);
|
7415 | }
|
7416 |
|
7417 | var type = workInProgress.type;
|
7418 | var nextProps = workInProgress.pendingProps;
|
7419 | var prevProps = current !== null ? current.memoizedProps : null;
|
7420 |
|
7421 | var nextChildren = nextProps.children;
|
7422 | var isDirectTextChild = shouldSetTextContent(type, nextProps);
|
7423 |
|
7424 | if (isDirectTextChild) {
|
7425 |
|
7426 |
|
7427 |
|
7428 |
|
7429 | nextChildren = null;
|
7430 | } else if (prevProps !== null && shouldSetTextContent(type, prevProps)) {
|
7431 |
|
7432 |
|
7433 | workInProgress.effectTag |= ContentReset;
|
7434 | }
|
7435 |
|
7436 | markRef(current, workInProgress);
|
7437 |
|
7438 |
|
7439 | if (renderExpirationTime !== Never && workInProgress.mode & ConcurrentMode && shouldDeprioritizeSubtree(type, nextProps)) {
|
7440 |
|
7441 | workInProgress.expirationTime = workInProgress.childExpirationTime = Never;
|
7442 | return null;
|
7443 | }
|
7444 |
|
7445 | reconcileChildren(current, workInProgress, nextChildren, renderExpirationTime);
|
7446 | return workInProgress.child;
|
7447 | }
|
7448 |
|
7449 | function updateHostText(current, workInProgress) {
|
7450 | if (current === null) {
|
7451 | tryToClaimNextHydratableInstance(workInProgress);
|
7452 | }
|
7453 |
|
7454 |
|
7455 | return null;
|
7456 | }
|
7457 |
|
7458 | function mountLazyComponent(_current, workInProgress, elementType, updateExpirationTime, renderExpirationTime) {
|
7459 | if (_current !== null) {
|
7460 |
|
7461 |
|
7462 |
|
7463 |
|
7464 | _current.alternate = null;
|
7465 | workInProgress.alternate = null;
|
7466 |
|
7467 | workInProgress.effectTag |= Placement;
|
7468 | }
|
7469 |
|
7470 | var props = workInProgress.pendingProps;
|
7471 |
|
7472 |
|
7473 | cancelWorkTimer(workInProgress);
|
7474 | var Component = readLazyComponentType(elementType);
|
7475 |
|
7476 | workInProgress.type = Component;
|
7477 | var resolvedTag = workInProgress.tag = resolveLazyComponentTag(Component);
|
7478 | startWorkTimer(workInProgress);
|
7479 | var resolvedProps = resolveDefaultProps(Component, props);
|
7480 | var child = void 0;
|
7481 | switch (resolvedTag) {
|
7482 | case FunctionComponent:
|
7483 | {
|
7484 | {
|
7485 | validateFunctionComponentInDev(workInProgress, Component);
|
7486 | }
|
7487 | child = updateFunctionComponent(null, workInProgress, Component, resolvedProps, renderExpirationTime);
|
7488 | break;
|
7489 | }
|
7490 | case ClassComponent:
|
7491 | {
|
7492 | child = updateClassComponent(null, workInProgress, Component, resolvedProps, renderExpirationTime);
|
7493 | break;
|
7494 | }
|
7495 | case ForwardRef:
|
7496 | {
|
7497 | child = updateForwardRef(null, workInProgress, Component, resolvedProps, renderExpirationTime);
|
7498 | break;
|
7499 | }
|
7500 | case MemoComponent:
|
7501 | {
|
7502 | {
|
7503 | if (workInProgress.type !== workInProgress.elementType) {
|
7504 | var outerPropTypes = Component.propTypes;
|
7505 | if (outerPropTypes) {
|
7506 | checkPropTypes_1(outerPropTypes, resolvedProps,
|
7507 | 'prop', getComponentName(Component), getCurrentFiberStackInDev);
|
7508 | }
|
7509 | }
|
7510 | }
|
7511 | child = updateMemoComponent(null, workInProgress, Component, resolveDefaultProps(Component.type, resolvedProps),
|
7512 | updateExpirationTime, renderExpirationTime);
|
7513 | break;
|
7514 | }
|
7515 | default:
|
7516 | {
|
7517 | var hint = '';
|
7518 | {
|
7519 | if (Component !== null && typeof Component === 'object' && Component.$$typeof === REACT_LAZY_TYPE) {
|
7520 | hint = ' Did you wrap a component in React.lazy() more than once?';
|
7521 | }
|
7522 | }
|
7523 |
|
7524 |
|
7525 |
|
7526 | invariant(false, 'Element type is invalid. Received a promise that resolves to: %s. Lazy element type must resolve to a class or function.%s', Component, hint);
|
7527 | }
|
7528 | }
|
7529 | return child;
|
7530 | }
|
7531 |
|
7532 | function mountIncompleteClassComponent(_current, workInProgress, Component, nextProps, renderExpirationTime) {
|
7533 | if (_current !== null) {
|
7534 |
|
7535 |
|
7536 |
|
7537 |
|
7538 | _current.alternate = null;
|
7539 | workInProgress.alternate = null;
|
7540 |
|
7541 | workInProgress.effectTag |= Placement;
|
7542 | }
|
7543 |
|
7544 |
|
7545 | workInProgress.tag = ClassComponent;
|
7546 |
|
7547 |
|
7548 |
|
7549 |
|
7550 |
|
7551 |
|
7552 | var hasContext = void 0;
|
7553 | if (isContextProvider(Component)) {
|
7554 | hasContext = true;
|
7555 | pushContextProvider(workInProgress);
|
7556 | } else {
|
7557 | hasContext = false;
|
7558 | }
|
7559 | prepareToReadContext(workInProgress, renderExpirationTime);
|
7560 |
|
7561 | constructClassInstance(workInProgress, Component, nextProps, renderExpirationTime);
|
7562 | mountClassInstance(workInProgress, Component, nextProps, renderExpirationTime);
|
7563 |
|
7564 | return finishClassComponent(null, workInProgress, Component, true, hasContext, renderExpirationTime);
|
7565 | }
|
7566 |
|
7567 | function mountIndeterminateComponent(_current, workInProgress, Component, renderExpirationTime) {
|
7568 | if (_current !== null) {
|
7569 |
|
7570 |
|
7571 |
|
7572 |
|
7573 | _current.alternate = null;
|
7574 | workInProgress.alternate = null;
|
7575 |
|
7576 | workInProgress.effectTag |= Placement;
|
7577 | }
|
7578 |
|
7579 | var props = workInProgress.pendingProps;
|
7580 | var unmaskedContext = getUnmaskedContext(workInProgress, Component, false);
|
7581 | var context = getMaskedContext(workInProgress, unmaskedContext);
|
7582 |
|
7583 | prepareToReadContext(workInProgress, renderExpirationTime);
|
7584 |
|
7585 | var value = void 0;
|
7586 |
|
7587 | {
|
7588 | if (Component.prototype && typeof Component.prototype.render === 'function') {
|
7589 | var componentName = getComponentName(Component) || 'Unknown';
|
7590 |
|
7591 | if (!didWarnAboutBadClass[componentName]) {
|
7592 | warningWithoutStack$1(false, "The <%s /> component appears to have a render method, but doesn't extend React.Component. " + 'This is likely to cause errors. Change %s to extend React.Component instead.', componentName, componentName);
|
7593 | didWarnAboutBadClass[componentName] = true;
|
7594 | }
|
7595 | }
|
7596 |
|
7597 | if (workInProgress.mode & StrictMode) {
|
7598 | ReactStrictModeWarnings.recordLegacyContextWarning(workInProgress, null);
|
7599 | }
|
7600 |
|
7601 | ReactCurrentOwner$2.current = workInProgress;
|
7602 | value = renderWithHooks(null, workInProgress, Component, props, context, renderExpirationTime);
|
7603 | }
|
7604 |
|
7605 | workInProgress.effectTag |= PerformedWork;
|
7606 |
|
7607 | if (typeof value === 'object' && value !== null && typeof value.render === 'function' && value.$$typeof === undefined) {
|
7608 |
|
7609 | workInProgress.tag = ClassComponent;
|
7610 |
|
7611 |
|
7612 | resetHooks();
|
7613 |
|
7614 |
|
7615 |
|
7616 |
|
7617 | var hasContext = false;
|
7618 | if (isContextProvider(Component)) {
|
7619 | hasContext = true;
|
7620 | pushContextProvider(workInProgress);
|
7621 | } else {
|
7622 | hasContext = false;
|
7623 | }
|
7624 |
|
7625 | workInProgress.memoizedState = value.state !== null && value.state !== undefined ? value.state : null;
|
7626 |
|
7627 | var getDerivedStateFromProps = Component.getDerivedStateFromProps;
|
7628 | if (typeof getDerivedStateFromProps === 'function') {
|
7629 | applyDerivedStateFromProps(workInProgress, Component, getDerivedStateFromProps, props);
|
7630 | }
|
7631 |
|
7632 | adoptClassInstance(workInProgress, value);
|
7633 | mountClassInstance(workInProgress, Component, props, renderExpirationTime);
|
7634 | return finishClassComponent(null, workInProgress, Component, true, hasContext, renderExpirationTime);
|
7635 | } else {
|
7636 |
|
7637 | workInProgress.tag = FunctionComponent;
|
7638 | {
|
7639 | if (debugRenderPhaseSideEffects || debugRenderPhaseSideEffectsForStrictMode && workInProgress.mode & StrictMode) {
|
7640 |
|
7641 | if (workInProgress.memoizedState !== null) {
|
7642 | value = renderWithHooks(null, workInProgress, Component, props, context, renderExpirationTime);
|
7643 | }
|
7644 | }
|
7645 | }
|
7646 | reconcileChildren(null, workInProgress, value, renderExpirationTime);
|
7647 | {
|
7648 | validateFunctionComponentInDev(workInProgress, Component);
|
7649 | }
|
7650 | return workInProgress.child;
|
7651 | }
|
7652 | }
|
7653 |
|
7654 | function validateFunctionComponentInDev(workInProgress, Component) {
|
7655 | if (Component) {
|
7656 | !!Component.childContextTypes ? warningWithoutStack$1(false, '%s(...): childContextTypes cannot be defined on a function component.', Component.displayName || Component.name || 'Component') : void 0;
|
7657 | }
|
7658 | if (workInProgress.ref !== null) {
|
7659 | var info = '';
|
7660 | var ownerName = getCurrentFiberOwnerNameInDevOrNull();
|
7661 | if (ownerName) {
|
7662 | info += '\n\nCheck the render method of `' + ownerName + '`.';
|
7663 | }
|
7664 |
|
7665 | var warningKey = ownerName || workInProgress._debugID || '';
|
7666 | var debugSource = workInProgress._debugSource;
|
7667 | if (debugSource) {
|
7668 | warningKey = debugSource.fileName + ':' + debugSource.lineNumber;
|
7669 | }
|
7670 | if (!didWarnAboutFunctionRefs[warningKey]) {
|
7671 | didWarnAboutFunctionRefs[warningKey] = true;
|
7672 | warning$1(false, 'Function components cannot be given refs. ' + 'Attempts to access this ref will fail. ' + 'Did you mean to use React.forwardRef()?%s', info);
|
7673 | }
|
7674 | }
|
7675 |
|
7676 | if (typeof Component.getDerivedStateFromProps === 'function') {
|
7677 | var componentName = getComponentName(Component) || 'Unknown';
|
7678 |
|
7679 | if (!didWarnAboutGetDerivedStateOnFunctionComponent[componentName]) {
|
7680 | warningWithoutStack$1(false, '%s: Function components do not support getDerivedStateFromProps.', componentName);
|
7681 | didWarnAboutGetDerivedStateOnFunctionComponent[componentName] = true;
|
7682 | }
|
7683 | }
|
7684 |
|
7685 | if (typeof Component.contextType === 'object' && Component.contextType !== null) {
|
7686 | var _componentName = getComponentName(Component) || 'Unknown';
|
7687 |
|
7688 | if (!didWarnAboutContextTypeOnFunctionComponent[_componentName]) {
|
7689 | warningWithoutStack$1(false, '%s: Function components do not support contextType.', _componentName);
|
7690 | didWarnAboutContextTypeOnFunctionComponent[_componentName] = true;
|
7691 | }
|
7692 | }
|
7693 | }
|
7694 |
|
7695 | function updateSuspenseComponent(current, workInProgress, renderExpirationTime) {
|
7696 | var mode = workInProgress.mode;
|
7697 | var nextProps = workInProgress.pendingProps;
|
7698 |
|
7699 |
|
7700 |
|
7701 | var nextState = workInProgress.memoizedState;
|
7702 |
|
7703 | var nextDidTimeout = void 0;
|
7704 | if ((workInProgress.effectTag & DidCapture) === NoEffect) {
|
7705 |
|
7706 | nextState = null;
|
7707 | nextDidTimeout = false;
|
7708 | } else {
|
7709 |
|
7710 |
|
7711 | nextState = {
|
7712 | timedOutAt: nextState !== null ? nextState.timedOutAt : NoWork
|
7713 | };
|
7714 | nextDidTimeout = true;
|
7715 | workInProgress.effectTag &= ~DidCapture;
|
7716 | }
|
7717 |
|
7718 |
|
7719 |
|
7720 |
|
7721 |
|
7722 |
|
7723 |
|
7724 |
|
7725 |
|
7726 |
|
7727 |
|
7728 |
|
7729 |
|
7730 |
|
7731 |
|
7732 |
|
7733 |
|
7734 |
|
7735 |
|
7736 |
|
7737 |
|
7738 |
|
7739 |
|
7740 |
|
7741 |
|
7742 |
|
7743 | var child = void 0;
|
7744 |
|
7745 |
|
7746 |
|
7747 |
|
7748 | var next = void 0;
|
7749 | if (current === null) {
|
7750 | if (enableSuspenseServerRenderer) {
|
7751 |
|
7752 |
|
7753 | if (nextProps.fallback !== undefined) {
|
7754 | tryToClaimNextHydratableInstance(workInProgress);
|
7755 |
|
7756 | if (workInProgress.tag === DehydratedSuspenseComponent) {
|
7757 | return updateDehydratedSuspenseComponent(null, workInProgress, renderExpirationTime);
|
7758 | }
|
7759 | }
|
7760 | }
|
7761 |
|
7762 |
|
7763 |
|
7764 | if (nextDidTimeout) {
|
7765 |
|
7766 | var nextFallbackChildren = nextProps.fallback;
|
7767 | var primaryChildFragment = createFiberFromFragment(null, mode, NoWork, null);
|
7768 |
|
7769 | if ((workInProgress.mode & ConcurrentMode) === NoContext) {
|
7770 |
|
7771 | var progressedState = workInProgress.memoizedState;
|
7772 | var progressedPrimaryChild = progressedState !== null ? workInProgress.child.child : workInProgress.child;
|
7773 | primaryChildFragment.child = progressedPrimaryChild;
|
7774 | }
|
7775 |
|
7776 | var fallbackChildFragment = createFiberFromFragment(nextFallbackChildren, mode, renderExpirationTime, null);
|
7777 | primaryChildFragment.sibling = fallbackChildFragment;
|
7778 | child = primaryChildFragment;
|
7779 |
|
7780 |
|
7781 | next = fallbackChildFragment;
|
7782 | child.return = next.return = workInProgress;
|
7783 | } else {
|
7784 |
|
7785 | var nextPrimaryChildren = nextProps.children;
|
7786 | child = next = mountChildFibers(workInProgress, null, nextPrimaryChildren, renderExpirationTime);
|
7787 | }
|
7788 | } else {
|
7789 |
|
7790 |
|
7791 | var prevState = current.memoizedState;
|
7792 | var prevDidTimeout = prevState !== null;
|
7793 | if (prevDidTimeout) {
|
7794 |
|
7795 | var currentPrimaryChildFragment = current.child;
|
7796 | var currentFallbackChildFragment = currentPrimaryChildFragment.sibling;
|
7797 | if (nextDidTimeout) {
|
7798 |
|
7799 |
|
7800 | var _nextFallbackChildren = nextProps.fallback;
|
7801 | var _primaryChildFragment = createWorkInProgress(currentPrimaryChildFragment, currentPrimaryChildFragment.pendingProps, NoWork);
|
7802 |
|
7803 | if ((workInProgress.mode & ConcurrentMode) === NoContext) {
|
7804 |
|
7805 | var _progressedState = workInProgress.memoizedState;
|
7806 | var _progressedPrimaryChild = _progressedState !== null ? workInProgress.child.child : workInProgress.child;
|
7807 | if (_progressedPrimaryChild !== currentPrimaryChildFragment.child) {
|
7808 | _primaryChildFragment.child = _progressedPrimaryChild;
|
7809 | }
|
7810 | }
|
7811 |
|
7812 |
|
7813 |
|
7814 | if (enableProfilerTimer && workInProgress.mode & ProfileMode) {
|
7815 |
|
7816 | var treeBaseDuration = 0;
|
7817 | var hiddenChild = _primaryChildFragment.child;
|
7818 | while (hiddenChild !== null) {
|
7819 | treeBaseDuration += hiddenChild.treeBaseDuration;
|
7820 | hiddenChild = hiddenChild.sibling;
|
7821 | }
|
7822 | _primaryChildFragment.treeBaseDuration = treeBaseDuration;
|
7823 | }
|
7824 |
|
7825 |
|
7826 |
|
7827 | var _fallbackChildFragment = _primaryChildFragment.sibling = createWorkInProgress(currentFallbackChildFragment, _nextFallbackChildren, currentFallbackChildFragment.expirationTime);
|
7828 | child = _primaryChildFragment;
|
7829 | _primaryChildFragment.childExpirationTime = NoWork;
|
7830 |
|
7831 |
|
7832 | next = _fallbackChildFragment;
|
7833 | child.return = next.return = workInProgress;
|
7834 | } else {
|
7835 |
|
7836 |
|
7837 | var _nextPrimaryChildren = nextProps.children;
|
7838 | var currentPrimaryChild = currentPrimaryChildFragment.child;
|
7839 | var primaryChild = reconcileChildFibers(workInProgress, currentPrimaryChild, _nextPrimaryChildren, renderExpirationTime);
|
7840 |
|
7841 |
|
7842 |
|
7843 |
|
7844 |
|
7845 |
|
7846 |
|
7847 |
|
7848 | child = next = primaryChild;
|
7849 | }
|
7850 | } else {
|
7851 |
|
7852 |
|
7853 | var _currentPrimaryChild = current.child;
|
7854 | if (nextDidTimeout) {
|
7855 |
|
7856 |
|
7857 | var _nextFallbackChildren2 = nextProps.fallback;
|
7858 | var _primaryChildFragment2 = createFiberFromFragment(
|
7859 |
|
7860 |
|
7861 | null, mode, NoWork, null);
|
7862 | _primaryChildFragment2.child = _currentPrimaryChild;
|
7863 |
|
7864 |
|
7865 |
|
7866 |
|
7867 |
|
7868 |
|
7869 | if ((workInProgress.mode & ConcurrentMode) === NoContext) {
|
7870 |
|
7871 | var _progressedState2 = workInProgress.memoizedState;
|
7872 | var _progressedPrimaryChild2 = _progressedState2 !== null ? workInProgress.child.child : workInProgress.child;
|
7873 | _primaryChildFragment2.child = _progressedPrimaryChild2;
|
7874 | }
|
7875 |
|
7876 |
|
7877 |
|
7878 | if (enableProfilerTimer && workInProgress.mode & ProfileMode) {
|
7879 |
|
7880 | var _treeBaseDuration = 0;
|
7881 | var _hiddenChild = _primaryChildFragment2.child;
|
7882 | while (_hiddenChild !== null) {
|
7883 | _treeBaseDuration += _hiddenChild.treeBaseDuration;
|
7884 | _hiddenChild = _hiddenChild.sibling;
|
7885 | }
|
7886 | _primaryChildFragment2.treeBaseDuration = _treeBaseDuration;
|
7887 | }
|
7888 |
|
7889 |
|
7890 | var _fallbackChildFragment2 = _primaryChildFragment2.sibling = createFiberFromFragment(_nextFallbackChildren2, mode, renderExpirationTime, null);
|
7891 | _fallbackChildFragment2.effectTag |= Placement;
|
7892 | child = _primaryChildFragment2;
|
7893 | _primaryChildFragment2.childExpirationTime = NoWork;
|
7894 |
|
7895 |
|
7896 | next = _fallbackChildFragment2;
|
7897 | child.return = next.return = workInProgress;
|
7898 | } else {
|
7899 |
|
7900 |
|
7901 | var _nextPrimaryChildren2 = nextProps.children;
|
7902 | next = child = reconcileChildFibers(workInProgress, _currentPrimaryChild, _nextPrimaryChildren2, renderExpirationTime);
|
7903 | }
|
7904 | }
|
7905 | workInProgress.stateNode = current.stateNode;
|
7906 | }
|
7907 |
|
7908 | workInProgress.memoizedState = nextState;
|
7909 | workInProgress.child = child;
|
7910 | return next;
|
7911 | }
|
7912 |
|
7913 | function updateDehydratedSuspenseComponent(current, workInProgress, renderExpirationTime) {
|
7914 | if (current === null) {
|
7915 |
|
7916 |
|
7917 | workInProgress.expirationTime = Never;
|
7918 | return null;
|
7919 | }
|
7920 |
|
7921 |
|
7922 | var hasContextChanged$$1 = current.childExpirationTime >= renderExpirationTime;
|
7923 | if (didReceiveUpdate || hasContextChanged$$1) {
|
7924 |
|
7925 |
|
7926 |
|
7927 |
|
7928 |
|
7929 |
|
7930 |
|
7931 |
|
7932 | current.alternate = null;
|
7933 | workInProgress.alternate = null;
|
7934 |
|
7935 |
|
7936 | var returnFiber = workInProgress.return;
|
7937 | !(returnFiber !== null) ? invariant(false, 'Suspense boundaries are never on the root. This is probably a bug in React.') : void 0;
|
7938 | var last = returnFiber.lastEffect;
|
7939 | if (last !== null) {
|
7940 | last.nextEffect = current;
|
7941 | returnFiber.lastEffect = current;
|
7942 | } else {
|
7943 | returnFiber.firstEffect = returnFiber.lastEffect = current;
|
7944 | }
|
7945 | current.nextEffect = null;
|
7946 | current.effectTag = Deletion;
|
7947 |
|
7948 |
|
7949 | workInProgress.tag = SuspenseComponent;
|
7950 | workInProgress.stateNode = null;
|
7951 | workInProgress.memoizedState = null;
|
7952 |
|
7953 | workInProgress.effectTag |= Placement;
|
7954 |
|
7955 | return updateSuspenseComponent(null, workInProgress, renderExpirationTime);
|
7956 | }
|
7957 | if ((workInProgress.effectTag & DidCapture) === NoEffect) {
|
7958 |
|
7959 | reenterHydrationStateFromDehydratedSuspenseInstance(workInProgress);
|
7960 | var nextProps = workInProgress.pendingProps;
|
7961 | var nextChildren = nextProps.children;
|
7962 | workInProgress.child = mountChildFibers(workInProgress, null, nextChildren, renderExpirationTime);
|
7963 | return workInProgress.child;
|
7964 | } else {
|
7965 |
|
7966 |
|
7967 | workInProgress.child = null;
|
7968 | return null;
|
7969 | }
|
7970 | }
|
7971 |
|
7972 | function updatePortalComponent(current, workInProgress, renderExpirationTime) {
|
7973 | pushHostContainer(workInProgress, workInProgress.stateNode.containerInfo);
|
7974 | var nextChildren = workInProgress.pendingProps;
|
7975 | if (current === null) {
|
7976 |
|
7977 |
|
7978 |
|
7979 |
|
7980 |
|
7981 | workInProgress.child = reconcileChildFibers(workInProgress, null, nextChildren, renderExpirationTime);
|
7982 | } else {
|
7983 | reconcileChildren(current, workInProgress, nextChildren, renderExpirationTime);
|
7984 | }
|
7985 | return workInProgress.child;
|
7986 | }
|
7987 |
|
7988 | function updateContextProvider(current, workInProgress, renderExpirationTime) {
|
7989 | var providerType = workInProgress.type;
|
7990 | var context = providerType._context;
|
7991 |
|
7992 | var newProps = workInProgress.pendingProps;
|
7993 | var oldProps = workInProgress.memoizedProps;
|
7994 |
|
7995 | var newValue = newProps.value;
|
7996 |
|
7997 | {
|
7998 | var providerPropTypes = workInProgress.type.propTypes;
|
7999 |
|
8000 | if (providerPropTypes) {
|
8001 | checkPropTypes_1(providerPropTypes, newProps, 'prop', 'Context.Provider', getCurrentFiberStackInDev);
|
8002 | }
|
8003 | }
|
8004 |
|
8005 | pushProvider(workInProgress, newValue);
|
8006 |
|
8007 | if (oldProps !== null) {
|
8008 | var oldValue = oldProps.value;
|
8009 | var changedBits = calculateChangedBits(context, newValue, oldValue);
|
8010 | if (changedBits === 0) {
|
8011 |
|
8012 | if (oldProps.children === newProps.children && !hasContextChanged()) {
|
8013 | return bailoutOnAlreadyFinishedWork(current, workInProgress, renderExpirationTime);
|
8014 | }
|
8015 | } else {
|
8016 |
|
8017 |
|
8018 | propagateContextChange(workInProgress, context, changedBits, renderExpirationTime);
|
8019 | }
|
8020 | }
|
8021 |
|
8022 | var newChildren = newProps.children;
|
8023 | reconcileChildren(current, workInProgress, newChildren, renderExpirationTime);
|
8024 | return workInProgress.child;
|
8025 | }
|
8026 |
|
8027 | var hasWarnedAboutUsingContextAsConsumer = false;
|
8028 |
|
8029 | function updateContextConsumer(current, workInProgress, renderExpirationTime) {
|
8030 | var context = workInProgress.type;
|
8031 |
|
8032 |
|
8033 |
|
8034 |
|
8035 |
|
8036 |
|
8037 |
|
8038 | {
|
8039 | if (context._context === undefined) {
|
8040 |
|
8041 |
|
8042 |
|
8043 | if (context !== context.Consumer) {
|
8044 | if (!hasWarnedAboutUsingContextAsConsumer) {
|
8045 | hasWarnedAboutUsingContextAsConsumer = true;
|
8046 | warning$1(false, 'Rendering <Context> directly is not supported and will be removed in ' + 'a future major release. Did you mean to render <Context.Consumer> instead?');
|
8047 | }
|
8048 | }
|
8049 | } else {
|
8050 | context = context._context;
|
8051 | }
|
8052 | }
|
8053 | var newProps = workInProgress.pendingProps;
|
8054 | var render = newProps.children;
|
8055 |
|
8056 | {
|
8057 | !(typeof render === 'function') ? warningWithoutStack$1(false, 'A context consumer was rendered with multiple children, or a child ' + "that isn't a function. A context consumer expects a single child " + 'that is a function. If you did pass a function, make sure there ' + 'is no trailing or leading whitespace around it.') : void 0;
|
8058 | }
|
8059 |
|
8060 | prepareToReadContext(workInProgress, renderExpirationTime);
|
8061 | var newValue = readContext(context, newProps.unstable_observedBits);
|
8062 | var newChildren = void 0;
|
8063 | {
|
8064 | ReactCurrentOwner$2.current = workInProgress;
|
8065 | setCurrentPhase('render');
|
8066 | newChildren = render(newValue);
|
8067 | setCurrentPhase(null);
|
8068 | }
|
8069 |
|
8070 |
|
8071 | workInProgress.effectTag |= PerformedWork;
|
8072 | reconcileChildren(current, workInProgress, newChildren, renderExpirationTime);
|
8073 | return workInProgress.child;
|
8074 | }
|
8075 |
|
8076 | function markWorkInProgressReceivedUpdate() {
|
8077 | didReceiveUpdate = true;
|
8078 | }
|
8079 |
|
8080 | function bailoutOnAlreadyFinishedWork(current, workInProgress, renderExpirationTime) {
|
8081 | cancelWorkTimer(workInProgress);
|
8082 |
|
8083 | if (current !== null) {
|
8084 |
|
8085 | workInProgress.contextDependencies = current.contextDependencies;
|
8086 | }
|
8087 |
|
8088 | if (enableProfilerTimer) {
|
8089 |
|
8090 | stopProfilerTimerIfRunning(workInProgress);
|
8091 | }
|
8092 |
|
8093 |
|
8094 | var childExpirationTime = workInProgress.childExpirationTime;
|
8095 | if (childExpirationTime < renderExpirationTime) {
|
8096 |
|
8097 |
|
8098 |
|
8099 | return null;
|
8100 | } else {
|
8101 |
|
8102 |
|
8103 | cloneChildFibers(current, workInProgress);
|
8104 | return workInProgress.child;
|
8105 | }
|
8106 | }
|
8107 |
|
8108 | function beginWork(current, workInProgress, renderExpirationTime) {
|
8109 | var updateExpirationTime = workInProgress.expirationTime;
|
8110 |
|
8111 | if (current !== null) {
|
8112 | var oldProps = current.memoizedProps;
|
8113 | var newProps = workInProgress.pendingProps;
|
8114 |
|
8115 | if (oldProps !== newProps || hasContextChanged()) {
|
8116 |
|
8117 |
|
8118 | didReceiveUpdate = true;
|
8119 | } else if (updateExpirationTime < renderExpirationTime) {
|
8120 | didReceiveUpdate = false;
|
8121 |
|
8122 |
|
8123 |
|
8124 | switch (workInProgress.tag) {
|
8125 | case HostRoot:
|
8126 | pushHostRootContext(workInProgress);
|
8127 | resetHydrationState();
|
8128 | break;
|
8129 | case HostComponent:
|
8130 | pushHostContext(workInProgress);
|
8131 | break;
|
8132 | case ClassComponent:
|
8133 | {
|
8134 | var Component = workInProgress.type;
|
8135 | if (isContextProvider(Component)) {
|
8136 | pushContextProvider(workInProgress);
|
8137 | }
|
8138 | break;
|
8139 | }
|
8140 | case HostPortal:
|
8141 | pushHostContainer(workInProgress, workInProgress.stateNode.containerInfo);
|
8142 | break;
|
8143 | case ContextProvider:
|
8144 | {
|
8145 | var newValue = workInProgress.memoizedProps.value;
|
8146 | pushProvider(workInProgress, newValue);
|
8147 | break;
|
8148 | }
|
8149 | case Profiler:
|
8150 | if (enableProfilerTimer) {
|
8151 | workInProgress.effectTag |= Update;
|
8152 | }
|
8153 | break;
|
8154 | case SuspenseComponent:
|
8155 | {
|
8156 | var state = workInProgress.memoizedState;
|
8157 | var didTimeout = state !== null;
|
8158 | if (didTimeout) {
|
8159 |
|
8160 |
|
8161 |
|
8162 | var primaryChildFragment = workInProgress.child;
|
8163 | var primaryChildExpirationTime = primaryChildFragment.childExpirationTime;
|
8164 | if (primaryChildExpirationTime !== NoWork && primaryChildExpirationTime >= renderExpirationTime) {
|
8165 |
|
8166 |
|
8167 | return updateSuspenseComponent(current, workInProgress, renderExpirationTime);
|
8168 | } else {
|
8169 |
|
8170 |
|
8171 | var child = bailoutOnAlreadyFinishedWork(current, workInProgress, renderExpirationTime);
|
8172 | if (child !== null) {
|
8173 |
|
8174 |
|
8175 | return child.sibling;
|
8176 | } else {
|
8177 | return null;
|
8178 | }
|
8179 | }
|
8180 | }
|
8181 | break;
|
8182 | }
|
8183 | case DehydratedSuspenseComponent:
|
8184 | {
|
8185 | if (enableSuspenseServerRenderer) {
|
8186 |
|
8187 |
|
8188 |
|
8189 | workInProgress.effectTag |= DidCapture;
|
8190 | break;
|
8191 | }
|
8192 | }
|
8193 | }
|
8194 | return bailoutOnAlreadyFinishedWork(current, workInProgress, renderExpirationTime);
|
8195 | }
|
8196 | } else {
|
8197 | didReceiveUpdate = false;
|
8198 | }
|
8199 |
|
8200 |
|
8201 | workInProgress.expirationTime = NoWork;
|
8202 |
|
8203 | switch (workInProgress.tag) {
|
8204 | case IndeterminateComponent:
|
8205 | {
|
8206 | var elementType = workInProgress.elementType;
|
8207 | return mountIndeterminateComponent(current, workInProgress, elementType, renderExpirationTime);
|
8208 | }
|
8209 | case LazyComponent:
|
8210 | {
|
8211 | var _elementType = workInProgress.elementType;
|
8212 | return mountLazyComponent(current, workInProgress, _elementType, updateExpirationTime, renderExpirationTime);
|
8213 | }
|
8214 | case FunctionComponent:
|
8215 | {
|
8216 | var _Component = workInProgress.type;
|
8217 | var unresolvedProps = workInProgress.pendingProps;
|
8218 | var resolvedProps = workInProgress.elementType === _Component ? unresolvedProps : resolveDefaultProps(_Component, unresolvedProps);
|
8219 | return updateFunctionComponent(current, workInProgress, _Component, resolvedProps, renderExpirationTime);
|
8220 | }
|
8221 | case ClassComponent:
|
8222 | {
|
8223 | var _Component2 = workInProgress.type;
|
8224 | var _unresolvedProps = workInProgress.pendingProps;
|
8225 | var _resolvedProps = workInProgress.elementType === _Component2 ? _unresolvedProps : resolveDefaultProps(_Component2, _unresolvedProps);
|
8226 | return updateClassComponent(current, workInProgress, _Component2, _resolvedProps, renderExpirationTime);
|
8227 | }
|
8228 | case HostRoot:
|
8229 | return updateHostRoot(current, workInProgress, renderExpirationTime);
|
8230 | case HostComponent:
|
8231 | return updateHostComponent(current, workInProgress, renderExpirationTime);
|
8232 | case HostText:
|
8233 | return updateHostText(current, workInProgress);
|
8234 | case SuspenseComponent:
|
8235 | return updateSuspenseComponent(current, workInProgress, renderExpirationTime);
|
8236 | case HostPortal:
|
8237 | return updatePortalComponent(current, workInProgress, renderExpirationTime);
|
8238 | case ForwardRef:
|
8239 | {
|
8240 | var type = workInProgress.type;
|
8241 | var _unresolvedProps2 = workInProgress.pendingProps;
|
8242 | var _resolvedProps2 = workInProgress.elementType === type ? _unresolvedProps2 : resolveDefaultProps(type, _unresolvedProps2);
|
8243 | return updateForwardRef(current, workInProgress, type, _resolvedProps2, renderExpirationTime);
|
8244 | }
|
8245 | case Fragment:
|
8246 | return updateFragment(current, workInProgress, renderExpirationTime);
|
8247 | case Mode:
|
8248 | return updateMode(current, workInProgress, renderExpirationTime);
|
8249 | case Profiler:
|
8250 | return updateProfiler(current, workInProgress, renderExpirationTime);
|
8251 | case ContextProvider:
|
8252 | return updateContextProvider(current, workInProgress, renderExpirationTime);
|
8253 | case ContextConsumer:
|
8254 | return updateContextConsumer(current, workInProgress, renderExpirationTime);
|
8255 | case MemoComponent:
|
8256 | {
|
8257 | var _type2 = workInProgress.type;
|
8258 | var _unresolvedProps3 = workInProgress.pendingProps;
|
8259 |
|
8260 | var _resolvedProps3 = resolveDefaultProps(_type2, _unresolvedProps3);
|
8261 | {
|
8262 | if (workInProgress.type !== workInProgress.elementType) {
|
8263 | var outerPropTypes = _type2.propTypes;
|
8264 | if (outerPropTypes) {
|
8265 | checkPropTypes_1(outerPropTypes, _resolvedProps3,
|
8266 | 'prop', getComponentName(_type2), getCurrentFiberStackInDev);
|
8267 | }
|
8268 | }
|
8269 | }
|
8270 | _resolvedProps3 = resolveDefaultProps(_type2.type, _resolvedProps3);
|
8271 | return updateMemoComponent(current, workInProgress, _type2, _resolvedProps3, updateExpirationTime, renderExpirationTime);
|
8272 | }
|
8273 | case SimpleMemoComponent:
|
8274 | {
|
8275 | return updateSimpleMemoComponent(current, workInProgress, workInProgress.type, workInProgress.pendingProps, updateExpirationTime, renderExpirationTime);
|
8276 | }
|
8277 | case IncompleteClassComponent:
|
8278 | {
|
8279 | var _Component3 = workInProgress.type;
|
8280 | var _unresolvedProps4 = workInProgress.pendingProps;
|
8281 | var _resolvedProps4 = workInProgress.elementType === _Component3 ? _unresolvedProps4 : resolveDefaultProps(_Component3, _unresolvedProps4);
|
8282 | return mountIncompleteClassComponent(current, workInProgress, _Component3, _resolvedProps4, renderExpirationTime);
|
8283 | }
|
8284 | case DehydratedSuspenseComponent:
|
8285 | {
|
8286 | if (enableSuspenseServerRenderer) {
|
8287 | return updateDehydratedSuspenseComponent(current, workInProgress, renderExpirationTime);
|
8288 | }
|
8289 | break;
|
8290 | }
|
8291 | }
|
8292 | invariant(false, 'Unknown unit of work tag. This error is likely caused by a bug in React. Please file an issue.');
|
8293 | }
|
8294 |
|
8295 | var valueCursor = createCursor(null);
|
8296 |
|
8297 | var rendererSigil = void 0;
|
8298 | {
|
8299 |
|
8300 | rendererSigil = {};
|
8301 | }
|
8302 |
|
8303 | var currentlyRenderingFiber = null;
|
8304 | var lastContextDependency = null;
|
8305 | var lastContextWithAllBitsObserved = null;
|
8306 |
|
8307 | var isDisallowedContextReadInDEV = false;
|
8308 |
|
8309 | function resetContextDependences() {
|
8310 |
|
8311 |
|
8312 | currentlyRenderingFiber = null;
|
8313 | lastContextDependency = null;
|
8314 | lastContextWithAllBitsObserved = null;
|
8315 | {
|
8316 | isDisallowedContextReadInDEV = false;
|
8317 | }
|
8318 | }
|
8319 |
|
8320 | function enterDisallowedContextReadInDEV() {
|
8321 | {
|
8322 | isDisallowedContextReadInDEV = true;
|
8323 | }
|
8324 | }
|
8325 |
|
8326 | function exitDisallowedContextReadInDEV() {
|
8327 | {
|
8328 | isDisallowedContextReadInDEV = false;
|
8329 | }
|
8330 | }
|
8331 |
|
8332 | function pushProvider(providerFiber, nextValue) {
|
8333 | var context = providerFiber.type._context;
|
8334 |
|
8335 | if (isPrimaryRenderer) {
|
8336 | push(valueCursor, context._currentValue, providerFiber);
|
8337 |
|
8338 | context._currentValue = nextValue;
|
8339 | {
|
8340 | !(context._currentRenderer === undefined || context._currentRenderer === null || context._currentRenderer === rendererSigil) ? warningWithoutStack$1(false, 'Detected multiple renderers concurrently rendering the ' + 'same context provider. This is currently unsupported.') : void 0;
|
8341 | context._currentRenderer = rendererSigil;
|
8342 | }
|
8343 | } else {
|
8344 | push(valueCursor, context._currentValue2, providerFiber);
|
8345 |
|
8346 | context._currentValue2 = nextValue;
|
8347 | {
|
8348 | !(context._currentRenderer2 === undefined || context._currentRenderer2 === null || context._currentRenderer2 === rendererSigil) ? warningWithoutStack$1(false, 'Detected multiple renderers concurrently rendering the ' + 'same context provider. This is currently unsupported.') : void 0;
|
8349 | context._currentRenderer2 = rendererSigil;
|
8350 | }
|
8351 | }
|
8352 | }
|
8353 |
|
8354 | function popProvider(providerFiber) {
|
8355 | var currentValue = valueCursor.current;
|
8356 |
|
8357 | pop(valueCursor, providerFiber);
|
8358 |
|
8359 | var context = providerFiber.type._context;
|
8360 | if (isPrimaryRenderer) {
|
8361 | context._currentValue = currentValue;
|
8362 | } else {
|
8363 | context._currentValue2 = currentValue;
|
8364 | }
|
8365 | }
|
8366 |
|
8367 | function calculateChangedBits(context, newValue, oldValue) {
|
8368 | if (is(oldValue, newValue)) {
|
8369 |
|
8370 | return 0;
|
8371 | } else {
|
8372 | var changedBits = typeof context._calculateChangedBits === 'function' ? context._calculateChangedBits(oldValue, newValue) : maxSigned31BitInt;
|
8373 |
|
8374 | {
|
8375 | !((changedBits & maxSigned31BitInt) === changedBits) ? warning$1(false, 'calculateChangedBits: Expected the return value to be a ' + '31-bit integer. Instead received: %s', changedBits) : void 0;
|
8376 | }
|
8377 | return changedBits | 0;
|
8378 | }
|
8379 | }
|
8380 |
|
8381 | function scheduleWorkOnParentPath(parent, renderExpirationTime) {
|
8382 |
|
8383 |
|
8384 | var node = parent;
|
8385 | while (node !== null) {
|
8386 | var alternate = node.alternate;
|
8387 | if (node.childExpirationTime < renderExpirationTime) {
|
8388 | node.childExpirationTime = renderExpirationTime;
|
8389 | if (alternate !== null && alternate.childExpirationTime < renderExpirationTime) {
|
8390 | alternate.childExpirationTime = renderExpirationTime;
|
8391 | }
|
8392 | } else if (alternate !== null && alternate.childExpirationTime < renderExpirationTime) {
|
8393 | alternate.childExpirationTime = renderExpirationTime;
|
8394 | } else {
|
8395 |
|
8396 |
|
8397 | break;
|
8398 | }
|
8399 | node = node.return;
|
8400 | }
|
8401 | }
|
8402 |
|
8403 | function propagateContextChange(workInProgress, context, changedBits, renderExpirationTime) {
|
8404 | var fiber = workInProgress.child;
|
8405 | if (fiber !== null) {
|
8406 |
|
8407 | fiber.return = workInProgress;
|
8408 | }
|
8409 | while (fiber !== null) {
|
8410 | var nextFiber = void 0;
|
8411 |
|
8412 |
|
8413 | var list = fiber.contextDependencies;
|
8414 | if (list !== null) {
|
8415 | nextFiber = fiber.child;
|
8416 |
|
8417 | var dependency = list.first;
|
8418 | while (dependency !== null) {
|
8419 |
|
8420 | if (dependency.context === context && (dependency.observedBits & changedBits) !== 0) {
|
8421 |
|
8422 |
|
8423 | if (fiber.tag === ClassComponent) {
|
8424 |
|
8425 | var update = createUpdate(renderExpirationTime);
|
8426 | update.tag = ForceUpdate;
|
8427 |
|
8428 |
|
8429 |
|
8430 |
|
8431 | enqueueUpdate(fiber, update);
|
8432 | }
|
8433 |
|
8434 | if (fiber.expirationTime < renderExpirationTime) {
|
8435 | fiber.expirationTime = renderExpirationTime;
|
8436 | }
|
8437 | var alternate = fiber.alternate;
|
8438 | if (alternate !== null && alternate.expirationTime < renderExpirationTime) {
|
8439 | alternate.expirationTime = renderExpirationTime;
|
8440 | }
|
8441 |
|
8442 | scheduleWorkOnParentPath(fiber.return, renderExpirationTime);
|
8443 |
|
8444 |
|
8445 | if (list.expirationTime < renderExpirationTime) {
|
8446 | list.expirationTime = renderExpirationTime;
|
8447 | }
|
8448 |
|
8449 |
|
8450 |
|
8451 | break;
|
8452 | }
|
8453 | dependency = dependency.next;
|
8454 | }
|
8455 | } else if (fiber.tag === ContextProvider) {
|
8456 |
|
8457 | nextFiber = fiber.type === workInProgress.type ? null : fiber.child;
|
8458 | } else if (enableSuspenseServerRenderer && fiber.tag === DehydratedSuspenseComponent) {
|
8459 |
|
8460 |
|
8461 |
|
8462 | if (fiber.expirationTime < renderExpirationTime) {
|
8463 | fiber.expirationTime = renderExpirationTime;
|
8464 | }
|
8465 | var _alternate = fiber.alternate;
|
8466 | if (_alternate !== null && _alternate.expirationTime < renderExpirationTime) {
|
8467 | _alternate.expirationTime = renderExpirationTime;
|
8468 | }
|
8469 |
|
8470 |
|
8471 |
|
8472 |
|
8473 | scheduleWorkOnParentPath(fiber, renderExpirationTime);
|
8474 | nextFiber = fiber.sibling;
|
8475 | } else {
|
8476 |
|
8477 | nextFiber = fiber.child;
|
8478 | }
|
8479 |
|
8480 | if (nextFiber !== null) {
|
8481 |
|
8482 | nextFiber.return = fiber;
|
8483 | } else {
|
8484 |
|
8485 | nextFiber = fiber;
|
8486 | while (nextFiber !== null) {
|
8487 | if (nextFiber === workInProgress) {
|
8488 |
|
8489 | nextFiber = null;
|
8490 | break;
|
8491 | }
|
8492 | var sibling = nextFiber.sibling;
|
8493 | if (sibling !== null) {
|
8494 |
|
8495 | sibling.return = nextFiber.return;
|
8496 | nextFiber = sibling;
|
8497 | break;
|
8498 | }
|
8499 |
|
8500 | nextFiber = nextFiber.return;
|
8501 | }
|
8502 | }
|
8503 | fiber = nextFiber;
|
8504 | }
|
8505 | }
|
8506 |
|
8507 | function prepareToReadContext(workInProgress, renderExpirationTime) {
|
8508 | currentlyRenderingFiber = workInProgress;
|
8509 | lastContextDependency = null;
|
8510 | lastContextWithAllBitsObserved = null;
|
8511 |
|
8512 | var currentDependencies = workInProgress.contextDependencies;
|
8513 | if (currentDependencies !== null && currentDependencies.expirationTime >= renderExpirationTime) {
|
8514 |
|
8515 | markWorkInProgressReceivedUpdate();
|
8516 | }
|
8517 |
|
8518 |
|
8519 | workInProgress.contextDependencies = null;
|
8520 | }
|
8521 |
|
8522 | function readContext(context, observedBits) {
|
8523 | {
|
8524 |
|
8525 |
|
8526 | !!isDisallowedContextReadInDEV ? warning$1(false, 'Context can only be read while React is rendering. ' + 'In classes, you can read it in the render method or getDerivedStateFromProps. ' + 'In function components, you can read it directly in the function body, but not ' + 'inside Hooks like useReducer() or useMemo().') : void 0;
|
8527 | }
|
8528 |
|
8529 | if (lastContextWithAllBitsObserved === context) {
|
8530 |
|
8531 | } else if (observedBits === false || observedBits === 0) {
|
8532 |
|
8533 | } else {
|
8534 | var resolvedObservedBits = void 0;
|
8535 | if (typeof observedBits !== 'number' || observedBits === maxSigned31BitInt) {
|
8536 |
|
8537 | lastContextWithAllBitsObserved = context;
|
8538 | resolvedObservedBits = maxSigned31BitInt;
|
8539 | } else {
|
8540 | resolvedObservedBits = observedBits;
|
8541 | }
|
8542 |
|
8543 | var contextItem = {
|
8544 | context: context,
|
8545 | observedBits: resolvedObservedBits,
|
8546 | next: null
|
8547 | };
|
8548 |
|
8549 | if (lastContextDependency === null) {
|
8550 | !(currentlyRenderingFiber !== null) ? invariant(false, 'Context can only be read while React is rendering. In classes, you can read it in the render method or getDerivedStateFromProps. In function components, you can read it directly in the function body, but not inside Hooks like useReducer() or useMemo().') : void 0;
|
8551 |
|
8552 |
|
8553 | lastContextDependency = contextItem;
|
8554 | currentlyRenderingFiber.contextDependencies = {
|
8555 | first: contextItem,
|
8556 | expirationTime: NoWork
|
8557 | };
|
8558 | } else {
|
8559 |
|
8560 | lastContextDependency = lastContextDependency.next = contextItem;
|
8561 | }
|
8562 | }
|
8563 | return isPrimaryRenderer ? context._currentValue : context._currentValue2;
|
8564 | }
|
8565 |
|
8566 |
|
8567 |
|
8568 |
|
8569 |
|
8570 |
|
8571 |
|
8572 |
|
8573 |
|
8574 |
|
8575 |
|
8576 |
|
8577 |
|
8578 |
|
8579 |
|
8580 |
|
8581 |
|
8582 |
|
8583 |
|
8584 |
|
8585 |
|
8586 |
|
8587 |
|
8588 |
|
8589 |
|
8590 |
|
8591 |
|
8592 |
|
8593 |
|
8594 |
|
8595 |
|
8596 |
|
8597 |
|
8598 |
|
8599 |
|
8600 |
|
8601 |
|
8602 |
|
8603 |
|
8604 |
|
8605 |
|
8606 |
|
8607 |
|
8608 |
|
8609 |
|
8610 |
|
8611 |
|
8612 |
|
8613 |
|
8614 |
|
8615 |
|
8616 |
|
8617 |
|
8618 |
|
8619 |
|
8620 |
|
8621 |
|
8622 |
|
8623 |
|
8624 |
|
8625 |
|
8626 |
|
8627 |
|
8628 |
|
8629 |
|
8630 |
|
8631 |
|
8632 |
|
8633 |
|
8634 |
|
8635 |
|
8636 |
|
8637 |
|
8638 |
|
8639 |
|
8640 |
|
8641 |
|
8642 |
|
8643 | var UpdateState = 0;
|
8644 | var ReplaceState = 1;
|
8645 | var ForceUpdate = 2;
|
8646 | var CaptureUpdate = 3;
|
8647 |
|
8648 |
|
8649 |
|
8650 |
|
8651 | var hasForceUpdate = false;
|
8652 |
|
8653 | var didWarnUpdateInsideUpdate = void 0;
|
8654 | var currentlyProcessingQueue = void 0;
|
8655 | var resetCurrentlyProcessingQueue = void 0;
|
8656 | {
|
8657 | didWarnUpdateInsideUpdate = false;
|
8658 | currentlyProcessingQueue = null;
|
8659 | resetCurrentlyProcessingQueue = function () {
|
8660 | currentlyProcessingQueue = null;
|
8661 | };
|
8662 | }
|
8663 |
|
8664 | function createUpdateQueue(baseState) {
|
8665 | var queue = {
|
8666 | baseState: baseState,
|
8667 | firstUpdate: null,
|
8668 | lastUpdate: null,
|
8669 | firstCapturedUpdate: null,
|
8670 | lastCapturedUpdate: null,
|
8671 | firstEffect: null,
|
8672 | lastEffect: null,
|
8673 | firstCapturedEffect: null,
|
8674 | lastCapturedEffect: null
|
8675 | };
|
8676 | return queue;
|
8677 | }
|
8678 |
|
8679 | function cloneUpdateQueue(currentQueue) {
|
8680 | var queue = {
|
8681 | baseState: currentQueue.baseState,
|
8682 | firstUpdate: currentQueue.firstUpdate,
|
8683 | lastUpdate: currentQueue.lastUpdate,
|
8684 |
|
8685 |
|
8686 |
|
8687 | firstCapturedUpdate: null,
|
8688 | lastCapturedUpdate: null,
|
8689 |
|
8690 | firstEffect: null,
|
8691 | lastEffect: null,
|
8692 |
|
8693 | firstCapturedEffect: null,
|
8694 | lastCapturedEffect: null
|
8695 | };
|
8696 | return queue;
|
8697 | }
|
8698 |
|
8699 | function createUpdate(expirationTime) {
|
8700 | return {
|
8701 | expirationTime: expirationTime,
|
8702 |
|
8703 | tag: UpdateState,
|
8704 | payload: null,
|
8705 | callback: null,
|
8706 |
|
8707 | next: null,
|
8708 | nextEffect: null
|
8709 | };
|
8710 | }
|
8711 |
|
8712 | function appendUpdateToQueue(queue, update) {
|
8713 |
|
8714 | if (queue.lastUpdate === null) {
|
8715 |
|
8716 | queue.firstUpdate = queue.lastUpdate = update;
|
8717 | } else {
|
8718 | queue.lastUpdate.next = update;
|
8719 | queue.lastUpdate = update;
|
8720 | }
|
8721 | }
|
8722 |
|
8723 | function enqueueUpdate(fiber, update) {
|
8724 |
|
8725 | var alternate = fiber.alternate;
|
8726 | var queue1 = void 0;
|
8727 | var queue2 = void 0;
|
8728 | if (alternate === null) {
|
8729 |
|
8730 | queue1 = fiber.updateQueue;
|
8731 | queue2 = null;
|
8732 | if (queue1 === null) {
|
8733 | queue1 = fiber.updateQueue = createUpdateQueue(fiber.memoizedState);
|
8734 | }
|
8735 | } else {
|
8736 |
|
8737 | queue1 = fiber.updateQueue;
|
8738 | queue2 = alternate.updateQueue;
|
8739 | if (queue1 === null) {
|
8740 | if (queue2 === null) {
|
8741 |
|
8742 | queue1 = fiber.updateQueue = createUpdateQueue(fiber.memoizedState);
|
8743 | queue2 = alternate.updateQueue = createUpdateQueue(alternate.memoizedState);
|
8744 | } else {
|
8745 |
|
8746 | queue1 = fiber.updateQueue = cloneUpdateQueue(queue2);
|
8747 | }
|
8748 | } else {
|
8749 | if (queue2 === null) {
|
8750 |
|
8751 | queue2 = alternate.updateQueue = cloneUpdateQueue(queue1);
|
8752 | } else {
|
8753 |
|
8754 | }
|
8755 | }
|
8756 | }
|
8757 | if (queue2 === null || queue1 === queue2) {
|
8758 |
|
8759 | appendUpdateToQueue(queue1, update);
|
8760 | } else {
|
8761 |
|
8762 |
|
8763 |
|
8764 | if (queue1.lastUpdate === null || queue2.lastUpdate === null) {
|
8765 |
|
8766 | appendUpdateToQueue(queue1, update);
|
8767 | appendUpdateToQueue(queue2, update);
|
8768 | } else {
|
8769 |
|
8770 |
|
8771 | appendUpdateToQueue(queue1, update);
|
8772 |
|
8773 | queue2.lastUpdate = update;
|
8774 | }
|
8775 | }
|
8776 |
|
8777 | {
|
8778 | if (fiber.tag === ClassComponent && (currentlyProcessingQueue === queue1 || queue2 !== null && currentlyProcessingQueue === queue2) && !didWarnUpdateInsideUpdate) {
|
8779 | warningWithoutStack$1(false, 'An update (setState, replaceState, or forceUpdate) was scheduled ' + 'from inside an update function. Update functions should be pure, ' + 'with zero side-effects. Consider using componentDidUpdate or a ' + 'callback.');
|
8780 | didWarnUpdateInsideUpdate = true;
|
8781 | }
|
8782 | }
|
8783 | }
|
8784 |
|
8785 | function enqueueCapturedUpdate(workInProgress, update) {
|
8786 |
|
8787 |
|
8788 | var workInProgressQueue = workInProgress.updateQueue;
|
8789 | if (workInProgressQueue === null) {
|
8790 | workInProgressQueue = workInProgress.updateQueue = createUpdateQueue(workInProgress.memoizedState);
|
8791 | } else {
|
8792 |
|
8793 |
|
8794 |
|
8795 | workInProgressQueue = ensureWorkInProgressQueueIsAClone(workInProgress, workInProgressQueue);
|
8796 | }
|
8797 |
|
8798 |
|
8799 | if (workInProgressQueue.lastCapturedUpdate === null) {
|
8800 |
|
8801 | workInProgressQueue.firstCapturedUpdate = workInProgressQueue.lastCapturedUpdate = update;
|
8802 | } else {
|
8803 | workInProgressQueue.lastCapturedUpdate.next = update;
|
8804 | workInProgressQueue.lastCapturedUpdate = update;
|
8805 | }
|
8806 | }
|
8807 |
|
8808 | function ensureWorkInProgressQueueIsAClone(workInProgress, queue) {
|
8809 | var current = workInProgress.alternate;
|
8810 | if (current !== null) {
|
8811 |
|
8812 |
|
8813 | if (queue === current.updateQueue) {
|
8814 | queue = workInProgress.updateQueue = cloneUpdateQueue(queue);
|
8815 | }
|
8816 | }
|
8817 | return queue;
|
8818 | }
|
8819 |
|
8820 | function getStateFromUpdate(workInProgress, queue, update, prevState, nextProps, instance) {
|
8821 | switch (update.tag) {
|
8822 | case ReplaceState:
|
8823 | {
|
8824 | var _payload = update.payload;
|
8825 | if (typeof _payload === 'function') {
|
8826 |
|
8827 | {
|
8828 | enterDisallowedContextReadInDEV();
|
8829 | if (debugRenderPhaseSideEffects || debugRenderPhaseSideEffectsForStrictMode && workInProgress.mode & StrictMode) {
|
8830 | _payload.call(instance, prevState, nextProps);
|
8831 | }
|
8832 | }
|
8833 | var nextState = _payload.call(instance, prevState, nextProps);
|
8834 | {
|
8835 | exitDisallowedContextReadInDEV();
|
8836 | }
|
8837 | return nextState;
|
8838 | }
|
8839 |
|
8840 | return _payload;
|
8841 | }
|
8842 | case CaptureUpdate:
|
8843 | {
|
8844 | workInProgress.effectTag = workInProgress.effectTag & ~ShouldCapture | DidCapture;
|
8845 | }
|
8846 |
|
8847 | case UpdateState:
|
8848 | {
|
8849 | var _payload2 = update.payload;
|
8850 | var partialState = void 0;
|
8851 | if (typeof _payload2 === 'function') {
|
8852 |
|
8853 | {
|
8854 | enterDisallowedContextReadInDEV();
|
8855 | if (debugRenderPhaseSideEffects || debugRenderPhaseSideEffectsForStrictMode && workInProgress.mode & StrictMode) {
|
8856 | _payload2.call(instance, prevState, nextProps);
|
8857 | }
|
8858 | }
|
8859 | partialState = _payload2.call(instance, prevState, nextProps);
|
8860 | {
|
8861 | exitDisallowedContextReadInDEV();
|
8862 | }
|
8863 | } else {
|
8864 |
|
8865 | partialState = _payload2;
|
8866 | }
|
8867 | if (partialState === null || partialState === undefined) {
|
8868 |
|
8869 | return prevState;
|
8870 | }
|
8871 |
|
8872 | return _assign({}, prevState, partialState);
|
8873 | }
|
8874 | case ForceUpdate:
|
8875 | {
|
8876 | hasForceUpdate = true;
|
8877 | return prevState;
|
8878 | }
|
8879 | }
|
8880 | return prevState;
|
8881 | }
|
8882 |
|
8883 | function processUpdateQueue(workInProgress, queue, props, instance, renderExpirationTime) {
|
8884 | hasForceUpdate = false;
|
8885 |
|
8886 | queue = ensureWorkInProgressQueueIsAClone(workInProgress, queue);
|
8887 |
|
8888 | {
|
8889 | currentlyProcessingQueue = queue;
|
8890 | }
|
8891 |
|
8892 |
|
8893 | var newBaseState = queue.baseState;
|
8894 | var newFirstUpdate = null;
|
8895 | var newExpirationTime = NoWork;
|
8896 |
|
8897 |
|
8898 | var update = queue.firstUpdate;
|
8899 | var resultState = newBaseState;
|
8900 | while (update !== null) {
|
8901 | var updateExpirationTime = update.expirationTime;
|
8902 | if (updateExpirationTime < renderExpirationTime) {
|
8903 |
|
8904 | if (newFirstUpdate === null) {
|
8905 |
|
8906 |
|
8907 | newFirstUpdate = update;
|
8908 |
|
8909 |
|
8910 | newBaseState = resultState;
|
8911 | }
|
8912 |
|
8913 |
|
8914 | if (newExpirationTime < updateExpirationTime) {
|
8915 | newExpirationTime = updateExpirationTime;
|
8916 | }
|
8917 | } else {
|
8918 |
|
8919 |
|
8920 | resultState = getStateFromUpdate(workInProgress, queue, update, resultState, props, instance);
|
8921 | var _callback = update.callback;
|
8922 | if (_callback !== null) {
|
8923 | workInProgress.effectTag |= Callback;
|
8924 |
|
8925 | update.nextEffect = null;
|
8926 | if (queue.lastEffect === null) {
|
8927 | queue.firstEffect = queue.lastEffect = update;
|
8928 | } else {
|
8929 | queue.lastEffect.nextEffect = update;
|
8930 | queue.lastEffect = update;
|
8931 | }
|
8932 | }
|
8933 | }
|
8934 |
|
8935 | update = update.next;
|
8936 | }
|
8937 |
|
8938 |
|
8939 | var newFirstCapturedUpdate = null;
|
8940 | update = queue.firstCapturedUpdate;
|
8941 | while (update !== null) {
|
8942 | var _updateExpirationTime = update.expirationTime;
|
8943 | if (_updateExpirationTime < renderExpirationTime) {
|
8944 |
|
8945 | if (newFirstCapturedUpdate === null) {
|
8946 |
|
8947 |
|
8948 | newFirstCapturedUpdate = update;
|
8949 |
|
8950 |
|
8951 | if (newFirstUpdate === null) {
|
8952 | newBaseState = resultState;
|
8953 | }
|
8954 | }
|
8955 |
|
8956 |
|
8957 | if (newExpirationTime < _updateExpirationTime) {
|
8958 | newExpirationTime = _updateExpirationTime;
|
8959 | }
|
8960 | } else {
|
8961 |
|
8962 |
|
8963 | resultState = getStateFromUpdate(workInProgress, queue, update, resultState, props, instance);
|
8964 | var _callback2 = update.callback;
|
8965 | if (_callback2 !== null) {
|
8966 | workInProgress.effectTag |= Callback;
|
8967 |
|
8968 | update.nextEffect = null;
|
8969 | if (queue.lastCapturedEffect === null) {
|
8970 | queue.firstCapturedEffect = queue.lastCapturedEffect = update;
|
8971 | } else {
|
8972 | queue.lastCapturedEffect.nextEffect = update;
|
8973 | queue.lastCapturedEffect = update;
|
8974 | }
|
8975 | }
|
8976 | }
|
8977 | update = update.next;
|
8978 | }
|
8979 |
|
8980 | if (newFirstUpdate === null) {
|
8981 | queue.lastUpdate = null;
|
8982 | }
|
8983 | if (newFirstCapturedUpdate === null) {
|
8984 | queue.lastCapturedUpdate = null;
|
8985 | } else {
|
8986 | workInProgress.effectTag |= Callback;
|
8987 | }
|
8988 | if (newFirstUpdate === null && newFirstCapturedUpdate === null) {
|
8989 |
|
8990 |
|
8991 | newBaseState = resultState;
|
8992 | }
|
8993 |
|
8994 | queue.baseState = newBaseState;
|
8995 | queue.firstUpdate = newFirstUpdate;
|
8996 | queue.firstCapturedUpdate = newFirstCapturedUpdate;
|
8997 |
|
8998 |
|
8999 |
|
9000 |
|
9001 |
|
9002 |
|
9003 |
|
9004 |
|
9005 | workInProgress.expirationTime = newExpirationTime;
|
9006 | workInProgress.memoizedState = resultState;
|
9007 |
|
9008 | {
|
9009 | currentlyProcessingQueue = null;
|
9010 | }
|
9011 | }
|
9012 |
|
9013 | function callCallback(callback, context) {
|
9014 | !(typeof callback === 'function') ? invariant(false, 'Invalid argument passed as callback. Expected a function. Instead received: %s', callback) : void 0;
|
9015 | callback.call(context);
|
9016 | }
|
9017 |
|
9018 | function resetHasForceUpdateBeforeProcessing() {
|
9019 | hasForceUpdate = false;
|
9020 | }
|
9021 |
|
9022 | function checkHasForceUpdateAfterProcessing() {
|
9023 | return hasForceUpdate;
|
9024 | }
|
9025 |
|
9026 | function commitUpdateQueue(finishedWork, finishedQueue, instance, renderExpirationTime) {
|
9027 |
|
9028 |
|
9029 |
|
9030 |
|
9031 | if (finishedQueue.firstCapturedUpdate !== null) {
|
9032 |
|
9033 | if (finishedQueue.lastUpdate !== null) {
|
9034 | finishedQueue.lastUpdate.next = finishedQueue.firstCapturedUpdate;
|
9035 | finishedQueue.lastUpdate = finishedQueue.lastCapturedUpdate;
|
9036 | }
|
9037 |
|
9038 | finishedQueue.firstCapturedUpdate = finishedQueue.lastCapturedUpdate = null;
|
9039 | }
|
9040 |
|
9041 |
|
9042 | commitUpdateEffects(finishedQueue.firstEffect, instance);
|
9043 | finishedQueue.firstEffect = finishedQueue.lastEffect = null;
|
9044 |
|
9045 | commitUpdateEffects(finishedQueue.firstCapturedEffect, instance);
|
9046 | finishedQueue.firstCapturedEffect = finishedQueue.lastCapturedEffect = null;
|
9047 | }
|
9048 |
|
9049 | function commitUpdateEffects(effect, instance) {
|
9050 | while (effect !== null) {
|
9051 | var _callback3 = effect.callback;
|
9052 | if (_callback3 !== null) {
|
9053 | effect.callback = null;
|
9054 | callCallback(_callback3, instance);
|
9055 | }
|
9056 | effect = effect.nextEffect;
|
9057 | }
|
9058 | }
|
9059 |
|
9060 | function createCapturedValue(value, source) {
|
9061 |
|
9062 |
|
9063 | return {
|
9064 | value: value,
|
9065 | source: source,
|
9066 | stack: getStackByFiberInDevAndProd(source)
|
9067 | };
|
9068 | }
|
9069 |
|
9070 | function markUpdate(workInProgress) {
|
9071 |
|
9072 |
|
9073 | workInProgress.effectTag |= Update;
|
9074 | }
|
9075 |
|
9076 | function markRef$1(workInProgress) {
|
9077 | workInProgress.effectTag |= Ref;
|
9078 | }
|
9079 |
|
9080 | var appendAllChildren = void 0;
|
9081 | var updateHostContainer = void 0;
|
9082 | var updateHostComponent$1 = void 0;
|
9083 | var updateHostText$1 = void 0;
|
9084 | if (supportsMutation) {
|
9085 |
|
9086 |
|
9087 | appendAllChildren = function (parent, workInProgress, needsVisibilityToggle, isHidden) {
|
9088 |
|
9089 |
|
9090 | var node = workInProgress.child;
|
9091 | while (node !== null) {
|
9092 | if (node.tag === HostComponent || node.tag === HostText) {
|
9093 | appendInitialChild(parent, node.stateNode);
|
9094 | } else if (node.tag === HostPortal) {
|
9095 |
|
9096 |
|
9097 |
|
9098 | } else if (node.child !== null) {
|
9099 | node.child.return = node;
|
9100 | node = node.child;
|
9101 | continue;
|
9102 | }
|
9103 | if (node === workInProgress) {
|
9104 | return;
|
9105 | }
|
9106 | while (node.sibling === null) {
|
9107 | if (node.return === null || node.return === workInProgress) {
|
9108 | return;
|
9109 | }
|
9110 | node = node.return;
|
9111 | }
|
9112 | node.sibling.return = node.return;
|
9113 | node = node.sibling;
|
9114 | }
|
9115 | };
|
9116 |
|
9117 | updateHostContainer = function (workInProgress) {
|
9118 |
|
9119 | };
|
9120 | updateHostComponent$1 = function (current, workInProgress, type, newProps, rootContainerInstance) {
|
9121 |
|
9122 |
|
9123 | var oldProps = current.memoizedProps;
|
9124 | if (oldProps === newProps) {
|
9125 |
|
9126 |
|
9127 | return;
|
9128 | }
|
9129 |
|
9130 |
|
9131 |
|
9132 |
|
9133 |
|
9134 | var instance = workInProgress.stateNode;
|
9135 | var currentHostContext = getHostContext();
|
9136 |
|
9137 |
|
9138 |
|
9139 | var updatePayload = prepareUpdate(instance, type, oldProps, newProps, rootContainerInstance, currentHostContext);
|
9140 |
|
9141 | workInProgress.updateQueue = updatePayload;
|
9142 |
|
9143 |
|
9144 | if (updatePayload) {
|
9145 | markUpdate(workInProgress);
|
9146 | }
|
9147 | };
|
9148 | updateHostText$1 = function (current, workInProgress, oldText, newText) {
|
9149 |
|
9150 | if (oldText !== newText) {
|
9151 | markUpdate(workInProgress);
|
9152 | }
|
9153 | };
|
9154 | } else if (supportsPersistence) {
|
9155 |
|
9156 |
|
9157 | appendAllChildren = function (parent, workInProgress, needsVisibilityToggle, isHidden) {
|
9158 |
|
9159 |
|
9160 | var node = workInProgress.child;
|
9161 | while (node !== null) {
|
9162 |
|
9163 | branches: if (node.tag === HostComponent) {
|
9164 | var instance = node.stateNode;
|
9165 | if (needsVisibilityToggle) {
|
9166 | var props = node.memoizedProps;
|
9167 | var type = node.type;
|
9168 | if (isHidden) {
|
9169 |
|
9170 | instance = cloneHiddenInstance(instance, type, props, node);
|
9171 | } else {
|
9172 |
|
9173 |
|
9174 |
|
9175 | instance = cloneUnhiddenInstance(instance, type, props, node);
|
9176 | }
|
9177 | node.stateNode = instance;
|
9178 | }
|
9179 | appendInitialChild(parent, instance);
|
9180 | } else if (node.tag === HostText) {
|
9181 | var _instance = node.stateNode;
|
9182 | if (needsVisibilityToggle) {
|
9183 | var text = node.memoizedProps;
|
9184 | var rootContainerInstance = getRootHostContainer();
|
9185 | var currentHostContext = getHostContext();
|
9186 | if (isHidden) {
|
9187 | _instance = createHiddenTextInstance(text, rootContainerInstance, currentHostContext, workInProgress);
|
9188 | } else {
|
9189 | _instance = createTextInstance(text, rootContainerInstance, currentHostContext, workInProgress);
|
9190 | }
|
9191 | node.stateNode = _instance;
|
9192 | }
|
9193 | appendInitialChild(parent, _instance);
|
9194 | } else if (node.tag === HostPortal) {
|
9195 |
|
9196 |
|
9197 |
|
9198 | } else if (node.tag === SuspenseComponent) {
|
9199 | var current = node.alternate;
|
9200 | if (current !== null) {
|
9201 | var oldState = current.memoizedState;
|
9202 | var newState = node.memoizedState;
|
9203 | var oldIsHidden = oldState !== null;
|
9204 | var newIsHidden = newState !== null;
|
9205 | if (oldIsHidden !== newIsHidden) {
|
9206 |
|
9207 |
|
9208 |
|
9209 | var primaryChildParent = newIsHidden ? node.child : node;
|
9210 | if (primaryChildParent !== null) {
|
9211 | appendAllChildren(parent, primaryChildParent, true, newIsHidden);
|
9212 | }
|
9213 |
|
9214 | break branches;
|
9215 | }
|
9216 | }
|
9217 | if (node.child !== null) {
|
9218 |
|
9219 | node.child.return = node;
|
9220 | node = node.child;
|
9221 | continue;
|
9222 | }
|
9223 | } else if (node.child !== null) {
|
9224 | node.child.return = node;
|
9225 | node = node.child;
|
9226 | continue;
|
9227 | }
|
9228 |
|
9229 | node = node;
|
9230 | if (node === workInProgress) {
|
9231 | return;
|
9232 | }
|
9233 | while (node.sibling === null) {
|
9234 | if (node.return === null || node.return === workInProgress) {
|
9235 | return;
|
9236 | }
|
9237 | node = node.return;
|
9238 | }
|
9239 | node.sibling.return = node.return;
|
9240 | node = node.sibling;
|
9241 | }
|
9242 | };
|
9243 |
|
9244 |
|
9245 | var appendAllChildrenToContainer = function (containerChildSet, workInProgress, needsVisibilityToggle, isHidden) {
|
9246 |
|
9247 |
|
9248 | var node = workInProgress.child;
|
9249 | while (node !== null) {
|
9250 |
|
9251 | branches: if (node.tag === HostComponent) {
|
9252 | var instance = node.stateNode;
|
9253 | if (needsVisibilityToggle) {
|
9254 | var props = node.memoizedProps;
|
9255 | var type = node.type;
|
9256 | if (isHidden) {
|
9257 |
|
9258 | instance = cloneHiddenInstance(instance, type, props, node);
|
9259 | } else {
|
9260 |
|
9261 |
|
9262 |
|
9263 | instance = cloneUnhiddenInstance(instance, type, props, node);
|
9264 | }
|
9265 | node.stateNode = instance;
|
9266 | }
|
9267 | appendChildToContainerChildSet(containerChildSet, instance);
|
9268 | } else if (node.tag === HostText) {
|
9269 | var _instance2 = node.stateNode;
|
9270 | if (needsVisibilityToggle) {
|
9271 | var text = node.memoizedProps;
|
9272 | var rootContainerInstance = getRootHostContainer();
|
9273 | var currentHostContext = getHostContext();
|
9274 | if (isHidden) {
|
9275 | _instance2 = createHiddenTextInstance(text, rootContainerInstance, currentHostContext, workInProgress);
|
9276 | } else {
|
9277 | _instance2 = createTextInstance(text, rootContainerInstance, currentHostContext, workInProgress);
|
9278 | }
|
9279 | node.stateNode = _instance2;
|
9280 | }
|
9281 | appendChildToContainerChildSet(containerChildSet, _instance2);
|
9282 | } else if (node.tag === HostPortal) {
|
9283 |
|
9284 |
|
9285 |
|
9286 | } else if (node.tag === SuspenseComponent) {
|
9287 | var current = node.alternate;
|
9288 | if (current !== null) {
|
9289 | var oldState = current.memoizedState;
|
9290 | var newState = node.memoizedState;
|
9291 | var oldIsHidden = oldState !== null;
|
9292 | var newIsHidden = newState !== null;
|
9293 | if (oldIsHidden !== newIsHidden) {
|
9294 |
|
9295 |
|
9296 |
|
9297 | var primaryChildParent = newIsHidden ? node.child : node;
|
9298 | if (primaryChildParent !== null) {
|
9299 | appendAllChildrenToContainer(containerChildSet, primaryChildParent, true, newIsHidden);
|
9300 | }
|
9301 |
|
9302 | break branches;
|
9303 | }
|
9304 | }
|
9305 | if (node.child !== null) {
|
9306 |
|
9307 | node.child.return = node;
|
9308 | node = node.child;
|
9309 | continue;
|
9310 | }
|
9311 | } else if (node.child !== null) {
|
9312 | node.child.return = node;
|
9313 | node = node.child;
|
9314 | continue;
|
9315 | }
|
9316 |
|
9317 | node = node;
|
9318 | if (node === workInProgress) {
|
9319 | return;
|
9320 | }
|
9321 | while (node.sibling === null) {
|
9322 | if (node.return === null || node.return === workInProgress) {
|
9323 | return;
|
9324 | }
|
9325 | node = node.return;
|
9326 | }
|
9327 | node.sibling.return = node.return;
|
9328 | node = node.sibling;
|
9329 | }
|
9330 | };
|
9331 | updateHostContainer = function (workInProgress) {
|
9332 | var portalOrRoot = workInProgress.stateNode;
|
9333 | var childrenUnchanged = workInProgress.firstEffect === null;
|
9334 | if (childrenUnchanged) {
|
9335 |
|
9336 | } else {
|
9337 | var container = portalOrRoot.containerInfo;
|
9338 | var newChildSet = createContainerChildSet(container);
|
9339 |
|
9340 | appendAllChildrenToContainer(newChildSet, workInProgress, false, false);
|
9341 | portalOrRoot.pendingChildren = newChildSet;
|
9342 |
|
9343 | markUpdate(workInProgress);
|
9344 | finalizeContainerChildren(container, newChildSet);
|
9345 | }
|
9346 | };
|
9347 | updateHostComponent$1 = function (current, workInProgress, type, newProps, rootContainerInstance) {
|
9348 | var currentInstance = current.stateNode;
|
9349 | var oldProps = current.memoizedProps;
|
9350 |
|
9351 |
|
9352 | var childrenUnchanged = workInProgress.firstEffect === null;
|
9353 | if (childrenUnchanged && oldProps === newProps) {
|
9354 |
|
9355 |
|
9356 | workInProgress.stateNode = currentInstance;
|
9357 | return;
|
9358 | }
|
9359 | var recyclableInstance = workInProgress.stateNode;
|
9360 | var currentHostContext = getHostContext();
|
9361 | var updatePayload = null;
|
9362 | if (oldProps !== newProps) {
|
9363 | updatePayload = prepareUpdate(recyclableInstance, type, oldProps, newProps, rootContainerInstance, currentHostContext);
|
9364 | }
|
9365 | if (childrenUnchanged && updatePayload === null) {
|
9366 |
|
9367 |
|
9368 | workInProgress.stateNode = currentInstance;
|
9369 | return;
|
9370 | }
|
9371 | var newInstance = cloneInstance(currentInstance, updatePayload, type, oldProps, newProps, workInProgress, childrenUnchanged, recyclableInstance);
|
9372 | if (finalizeInitialChildren(newInstance, type, newProps, rootContainerInstance, currentHostContext)) {
|
9373 | markUpdate(workInProgress);
|
9374 | }
|
9375 | workInProgress.stateNode = newInstance;
|
9376 | if (childrenUnchanged) {
|
9377 |
|
9378 |
|
9379 |
|
9380 | markUpdate(workInProgress);
|
9381 | } else {
|
9382 |
|
9383 | appendAllChildren(newInstance, workInProgress, false, false);
|
9384 | }
|
9385 | };
|
9386 | updateHostText$1 = function (current, workInProgress, oldText, newText) {
|
9387 | if (oldText !== newText) {
|
9388 |
|
9389 | var rootContainerInstance = getRootHostContainer();
|
9390 | var currentHostContext = getHostContext();
|
9391 | workInProgress.stateNode = createTextInstance(newText, rootContainerInstance, currentHostContext, workInProgress);
|
9392 |
|
9393 |
|
9394 | markUpdate(workInProgress);
|
9395 | }
|
9396 | };
|
9397 | } else {
|
9398 |
|
9399 | updateHostContainer = function (workInProgress) {
|
9400 |
|
9401 | };
|
9402 | updateHostComponent$1 = function (current, workInProgress, type, newProps, rootContainerInstance) {
|
9403 |
|
9404 | };
|
9405 | updateHostText$1 = function (current, workInProgress, oldText, newText) {
|
9406 |
|
9407 | };
|
9408 | }
|
9409 |
|
9410 | function completeWork(current, workInProgress, renderExpirationTime) {
|
9411 | var newProps = workInProgress.pendingProps;
|
9412 |
|
9413 | switch (workInProgress.tag) {
|
9414 | case IndeterminateComponent:
|
9415 | break;
|
9416 | case LazyComponent:
|
9417 | break;
|
9418 | case SimpleMemoComponent:
|
9419 | case FunctionComponent:
|
9420 | break;
|
9421 | case ClassComponent:
|
9422 | {
|
9423 | var Component = workInProgress.type;
|
9424 | if (isContextProvider(Component)) {
|
9425 | popContext(workInProgress);
|
9426 | }
|
9427 | break;
|
9428 | }
|
9429 | case HostRoot:
|
9430 | {
|
9431 | popHostContainer(workInProgress);
|
9432 | popTopLevelContextObject(workInProgress);
|
9433 | var fiberRoot = workInProgress.stateNode;
|
9434 | if (fiberRoot.pendingContext) {
|
9435 | fiberRoot.context = fiberRoot.pendingContext;
|
9436 | fiberRoot.pendingContext = null;
|
9437 | }
|
9438 | if (current === null || current.child === null) {
|
9439 |
|
9440 |
|
9441 | popHydrationState(workInProgress);
|
9442 |
|
9443 |
|
9444 | workInProgress.effectTag &= ~Placement;
|
9445 | }
|
9446 | updateHostContainer(workInProgress);
|
9447 | break;
|
9448 | }
|
9449 | case HostComponent:
|
9450 | {
|
9451 | popHostContext(workInProgress);
|
9452 | var rootContainerInstance = getRootHostContainer();
|
9453 | var type = workInProgress.type;
|
9454 | if (current !== null && workInProgress.stateNode != null) {
|
9455 | updateHostComponent$1(current, workInProgress, type, newProps, rootContainerInstance);
|
9456 |
|
9457 | if (current.ref !== workInProgress.ref) {
|
9458 | markRef$1(workInProgress);
|
9459 | }
|
9460 | } else {
|
9461 | if (!newProps) {
|
9462 | !(workInProgress.stateNode !== null) ? invariant(false, 'We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue.') : void 0;
|
9463 |
|
9464 | break;
|
9465 | }
|
9466 |
|
9467 | var currentHostContext = getHostContext();
|
9468 |
|
9469 |
|
9470 |
|
9471 |
|
9472 | var wasHydrated = popHydrationState(workInProgress);
|
9473 | if (wasHydrated) {
|
9474 |
|
9475 |
|
9476 | if (prepareToHydrateHostInstance(workInProgress, rootContainerInstance, currentHostContext)) {
|
9477 |
|
9478 |
|
9479 | markUpdate(workInProgress);
|
9480 | }
|
9481 | } else {
|
9482 | var instance = createInstance(type, newProps, rootContainerInstance, currentHostContext, workInProgress);
|
9483 |
|
9484 | appendAllChildren(instance, workInProgress, false, false);
|
9485 |
|
9486 |
|
9487 |
|
9488 |
|
9489 | if (finalizeInitialChildren(instance, type, newProps, rootContainerInstance, currentHostContext)) {
|
9490 | markUpdate(workInProgress);
|
9491 | }
|
9492 | workInProgress.stateNode = instance;
|
9493 | }
|
9494 |
|
9495 | if (workInProgress.ref !== null) {
|
9496 |
|
9497 | markRef$1(workInProgress);
|
9498 | }
|
9499 | }
|
9500 | break;
|
9501 | }
|
9502 | case HostText:
|
9503 | {
|
9504 | var newText = newProps;
|
9505 | if (current && workInProgress.stateNode != null) {
|
9506 | var oldText = current.memoizedProps;
|
9507 |
|
9508 |
|
9509 | updateHostText$1(current, workInProgress, oldText, newText);
|
9510 | } else {
|
9511 | if (typeof newText !== 'string') {
|
9512 | !(workInProgress.stateNode !== null) ? invariant(false, 'We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue.') : void 0;
|
9513 |
|
9514 | }
|
9515 | var _rootContainerInstance = getRootHostContainer();
|
9516 | var _currentHostContext = getHostContext();
|
9517 | var _wasHydrated = popHydrationState(workInProgress);
|
9518 | if (_wasHydrated) {
|
9519 | if (prepareToHydrateHostTextInstance(workInProgress)) {
|
9520 | markUpdate(workInProgress);
|
9521 | }
|
9522 | } else {
|
9523 | workInProgress.stateNode = createTextInstance(newText, _rootContainerInstance, _currentHostContext, workInProgress);
|
9524 | }
|
9525 | }
|
9526 | break;
|
9527 | }
|
9528 | case ForwardRef:
|
9529 | break;
|
9530 | case SuspenseComponent:
|
9531 | {
|
9532 | var nextState = workInProgress.memoizedState;
|
9533 | if ((workInProgress.effectTag & DidCapture) !== NoEffect) {
|
9534 |
|
9535 | workInProgress.expirationTime = renderExpirationTime;
|
9536 |
|
9537 | return workInProgress;
|
9538 | }
|
9539 |
|
9540 | var nextDidTimeout = nextState !== null;
|
9541 | var prevDidTimeout = current !== null && current.memoizedState !== null;
|
9542 |
|
9543 | if (current !== null && !nextDidTimeout && prevDidTimeout) {
|
9544 |
|
9545 |
|
9546 |
|
9547 | var currentFallbackChild = current.child.sibling;
|
9548 | if (currentFallbackChild !== null) {
|
9549 |
|
9550 | var first = workInProgress.firstEffect;
|
9551 | if (first !== null) {
|
9552 | workInProgress.firstEffect = currentFallbackChild;
|
9553 | currentFallbackChild.nextEffect = first;
|
9554 | } else {
|
9555 | workInProgress.firstEffect = workInProgress.lastEffect = currentFallbackChild;
|
9556 | currentFallbackChild.nextEffect = null;
|
9557 | }
|
9558 | currentFallbackChild.effectTag = Deletion;
|
9559 | }
|
9560 | }
|
9561 |
|
9562 | if (nextDidTimeout || prevDidTimeout) {
|
9563 |
|
9564 |
|
9565 |
|
9566 | workInProgress.effectTag |= Update;
|
9567 | }
|
9568 | break;
|
9569 | }
|
9570 | case Fragment:
|
9571 | break;
|
9572 | case Mode:
|
9573 | break;
|
9574 | case Profiler:
|
9575 | break;
|
9576 | case HostPortal:
|
9577 | popHostContainer(workInProgress);
|
9578 | updateHostContainer(workInProgress);
|
9579 | break;
|
9580 | case ContextProvider:
|
9581 |
|
9582 | popProvider(workInProgress);
|
9583 | break;
|
9584 | case ContextConsumer:
|
9585 | break;
|
9586 | case MemoComponent:
|
9587 | break;
|
9588 | case IncompleteClassComponent:
|
9589 | {
|
9590 |
|
9591 |
|
9592 | var _Component = workInProgress.type;
|
9593 | if (isContextProvider(_Component)) {
|
9594 | popContext(workInProgress);
|
9595 | }
|
9596 | break;
|
9597 | }
|
9598 | case DehydratedSuspenseComponent:
|
9599 | {
|
9600 | if (enableSuspenseServerRenderer) {
|
9601 | if (current === null) {
|
9602 | var _wasHydrated2 = popHydrationState(workInProgress);
|
9603 | !_wasHydrated2 ? invariant(false, 'A dehydrated suspense component was completed without a hydrated node. This is probably a bug in React.') : void 0;
|
9604 | skipPastDehydratedSuspenseInstance(workInProgress);
|
9605 | } else if ((workInProgress.effectTag & DidCapture) === NoEffect) {
|
9606 |
|
9607 |
|
9608 |
|
9609 | current.alternate = null;
|
9610 | workInProgress.alternate = null;
|
9611 | workInProgress.tag = SuspenseComponent;
|
9612 | workInProgress.memoizedState = null;
|
9613 | workInProgress.stateNode = null;
|
9614 | }
|
9615 | }
|
9616 | break;
|
9617 | }
|
9618 | default:
|
9619 | invariant(false, 'Unknown unit of work tag. This error is likely caused by a bug in React. Please file an issue.');
|
9620 | }
|
9621 |
|
9622 | return null;
|
9623 | }
|
9624 |
|
9625 | function shouldCaptureSuspense(workInProgress) {
|
9626 |
|
9627 | if (workInProgress.memoizedProps.fallback === undefined) {
|
9628 | return false;
|
9629 | }
|
9630 |
|
9631 |
|
9632 | var nextState = workInProgress.memoizedState;
|
9633 | return nextState === null;
|
9634 | }
|
9635 |
|
9636 |
|
9637 |
|
9638 |
|
9639 | function showErrorDialog(capturedError) {
|
9640 | return true;
|
9641 | }
|
9642 |
|
9643 | function logCapturedError(capturedError) {
|
9644 | var logError = showErrorDialog(capturedError);
|
9645 |
|
9646 |
|
9647 |
|
9648 | if (logError === false) {
|
9649 | return;
|
9650 | }
|
9651 |
|
9652 | var error = capturedError.error;
|
9653 | {
|
9654 | var componentName = capturedError.componentName,
|
9655 | componentStack = capturedError.componentStack,
|
9656 | errorBoundaryName = capturedError.errorBoundaryName,
|
9657 | errorBoundaryFound = capturedError.errorBoundaryFound,
|
9658 | willRetry = capturedError.willRetry;
|
9659 |
|
9660 |
|
9661 |
|
9662 |
|
9663 |
|
9664 | if (error != null && error._suppressLogging) {
|
9665 | if (errorBoundaryFound && willRetry) {
|
9666 |
|
9667 |
|
9668 |
|
9669 | return;
|
9670 | }
|
9671 |
|
9672 |
|
9673 |
|
9674 |
|
9675 | console.error(error);
|
9676 |
|
9677 |
|
9678 | }
|
9679 |
|
9680 | var componentNameMessage = componentName ? 'The above error occurred in the <' + componentName + '> component:' : 'The above error occurred in one of your React components:';
|
9681 |
|
9682 | var errorBoundaryMessage = void 0;
|
9683 |
|
9684 | if (errorBoundaryFound && errorBoundaryName) {
|
9685 | if (willRetry) {
|
9686 | errorBoundaryMessage = 'React will try to recreate this component tree from scratch ' + ('using the error boundary you provided, ' + errorBoundaryName + '.');
|
9687 | } else {
|
9688 | errorBoundaryMessage = 'This error was initially handled by the error boundary ' + errorBoundaryName + '.\n' + 'Recreating the tree from scratch failed so React will unmount the tree.';
|
9689 | }
|
9690 | } else {
|
9691 | errorBoundaryMessage = 'Consider adding an error boundary to your tree to customize error handling behavior.\n' + 'Visit https://fb.me/react-error-boundaries to learn more about error boundaries.';
|
9692 | }
|
9693 | var combinedMessage = '' + componentNameMessage + componentStack + '\n\n' + ('' + errorBoundaryMessage);
|
9694 |
|
9695 |
|
9696 |
|
9697 |
|
9698 |
|
9699 | console.error(combinedMessage);
|
9700 | }
|
9701 | }
|
9702 |
|
9703 | var didWarnAboutUndefinedSnapshotBeforeUpdate = null;
|
9704 | {
|
9705 | didWarnAboutUndefinedSnapshotBeforeUpdate = new Set();
|
9706 | }
|
9707 |
|
9708 | var PossiblyWeakSet$1 = typeof WeakSet === 'function' ? WeakSet : Set;
|
9709 |
|
9710 | function logError(boundary, errorInfo) {
|
9711 | var source = errorInfo.source;
|
9712 | var stack = errorInfo.stack;
|
9713 | if (stack === null && source !== null) {
|
9714 | stack = getStackByFiberInDevAndProd(source);
|
9715 | }
|
9716 |
|
9717 | var capturedError = {
|
9718 | componentName: source !== null ? getComponentName(source.type) : null,
|
9719 | componentStack: stack !== null ? stack : '',
|
9720 | error: errorInfo.value,
|
9721 | errorBoundary: null,
|
9722 | errorBoundaryName: null,
|
9723 | errorBoundaryFound: false,
|
9724 | willRetry: false
|
9725 | };
|
9726 |
|
9727 | if (boundary !== null && boundary.tag === ClassComponent) {
|
9728 | capturedError.errorBoundary = boundary.stateNode;
|
9729 | capturedError.errorBoundaryName = getComponentName(boundary.type);
|
9730 | capturedError.errorBoundaryFound = true;
|
9731 | capturedError.willRetry = true;
|
9732 | }
|
9733 |
|
9734 | try {
|
9735 | logCapturedError(capturedError);
|
9736 | } catch (e) {
|
9737 |
|
9738 |
|
9739 |
|
9740 |
|
9741 | setTimeout(function () {
|
9742 | throw e;
|
9743 | });
|
9744 | }
|
9745 | }
|
9746 |
|
9747 | var callComponentWillUnmountWithTimer = function (current, instance) {
|
9748 | startPhaseTimer(current, 'componentWillUnmount');
|
9749 | instance.props = current.memoizedProps;
|
9750 | instance.state = current.memoizedState;
|
9751 | instance.componentWillUnmount();
|
9752 | stopPhaseTimer();
|
9753 | };
|
9754 |
|
9755 |
|
9756 | function safelyCallComponentWillUnmount(current, instance) {
|
9757 | {
|
9758 | invokeGuardedCallback(null, callComponentWillUnmountWithTimer, null, current, instance);
|
9759 | if (hasCaughtError()) {
|
9760 | var unmountError = clearCaughtError();
|
9761 | captureCommitPhaseError(current, unmountError);
|
9762 | }
|
9763 | }
|
9764 | }
|
9765 |
|
9766 | function safelyDetachRef(current) {
|
9767 | var ref = current.ref;
|
9768 | if (ref !== null) {
|
9769 | if (typeof ref === 'function') {
|
9770 | {
|
9771 | invokeGuardedCallback(null, ref, null, null);
|
9772 | if (hasCaughtError()) {
|
9773 | var refError = clearCaughtError();
|
9774 | captureCommitPhaseError(current, refError);
|
9775 | }
|
9776 | }
|
9777 | } else {
|
9778 | ref.current = null;
|
9779 | }
|
9780 | }
|
9781 | }
|
9782 |
|
9783 | function safelyCallDestroy(current, destroy) {
|
9784 | {
|
9785 | invokeGuardedCallback(null, destroy, null);
|
9786 | if (hasCaughtError()) {
|
9787 | var error = clearCaughtError();
|
9788 | captureCommitPhaseError(current, error);
|
9789 | }
|
9790 | }
|
9791 | }
|
9792 |
|
9793 | function commitBeforeMutationLifeCycles(current, finishedWork) {
|
9794 | switch (finishedWork.tag) {
|
9795 | case FunctionComponent:
|
9796 | case ForwardRef:
|
9797 | case SimpleMemoComponent:
|
9798 | {
|
9799 | commitHookEffectList(UnmountSnapshot, NoEffect$1, finishedWork);
|
9800 | return;
|
9801 | }
|
9802 | case ClassComponent:
|
9803 | {
|
9804 | if (finishedWork.effectTag & Snapshot) {
|
9805 | if (current !== null) {
|
9806 | var prevProps = current.memoizedProps;
|
9807 | var prevState = current.memoizedState;
|
9808 | startPhaseTimer(finishedWork, 'getSnapshotBeforeUpdate');
|
9809 | var instance = finishedWork.stateNode;
|
9810 |
|
9811 |
|
9812 |
|
9813 | {
|
9814 | if (finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps) {
|
9815 | !(instance.props === finishedWork.memoizedProps) ? warning$1(false, 'Expected %s props to match memoized props before ' + 'getSnapshotBeforeUpdate. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.props`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance') : void 0;
|
9816 | !(instance.state === finishedWork.memoizedState) ? warning$1(false, 'Expected %s state to match memoized state before ' + 'getSnapshotBeforeUpdate. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.props`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance') : void 0;
|
9817 | }
|
9818 | }
|
9819 | var snapshot = instance.getSnapshotBeforeUpdate(finishedWork.elementType === finishedWork.type ? prevProps : resolveDefaultProps(finishedWork.type, prevProps), prevState);
|
9820 | {
|
9821 | var didWarnSet = didWarnAboutUndefinedSnapshotBeforeUpdate;
|
9822 | if (snapshot === undefined && !didWarnSet.has(finishedWork.type)) {
|
9823 | didWarnSet.add(finishedWork.type);
|
9824 | warningWithoutStack$1(false, '%s.getSnapshotBeforeUpdate(): A snapshot value (or null) ' + 'must be returned. You have returned undefined.', getComponentName(finishedWork.type));
|
9825 | }
|
9826 | }
|
9827 | instance.__reactInternalSnapshotBeforeUpdate = snapshot;
|
9828 | stopPhaseTimer();
|
9829 | }
|
9830 | }
|
9831 | return;
|
9832 | }
|
9833 | case HostRoot:
|
9834 | case HostComponent:
|
9835 | case HostText:
|
9836 | case HostPortal:
|
9837 | case IncompleteClassComponent:
|
9838 |
|
9839 | return;
|
9840 | default:
|
9841 | {
|
9842 | invariant(false, 'This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue.');
|
9843 | }
|
9844 | }
|
9845 | }
|
9846 |
|
9847 | function commitHookEffectList(unmountTag, mountTag, finishedWork) {
|
9848 | var updateQueue = finishedWork.updateQueue;
|
9849 | var lastEffect = updateQueue !== null ? updateQueue.lastEffect : null;
|
9850 | if (lastEffect !== null) {
|
9851 | var firstEffect = lastEffect.next;
|
9852 | var effect = firstEffect;
|
9853 | do {
|
9854 | if ((effect.tag & unmountTag) !== NoEffect$1) {
|
9855 |
|
9856 | var destroy = effect.destroy;
|
9857 | effect.destroy = undefined;
|
9858 | if (destroy !== undefined) {
|
9859 | destroy();
|
9860 | }
|
9861 | }
|
9862 | if ((effect.tag & mountTag) !== NoEffect$1) {
|
9863 |
|
9864 | var create = effect.create;
|
9865 | effect.destroy = create();
|
9866 |
|
9867 | {
|
9868 | var _destroy = effect.destroy;
|
9869 | if (_destroy !== undefined && typeof _destroy !== 'function') {
|
9870 | var addendum = void 0;
|
9871 | if (_destroy === null) {
|
9872 | addendum = ' You returned null. If your effect does not require clean ' + 'up, return undefined (or nothing).';
|
9873 | } else if (typeof _destroy.then === 'function') {
|
9874 | addendum = '\n\nIt looks like you wrote useEffect(async () => ...) or returned a Promise. ' + 'Instead, write the async function inside your effect ' + 'and call it immediately:\n\n' + 'useEffect(() => {\n' + ' async function fetchData() {\n' + ' // You can await here\n' + ' const response = await MyAPI.getData(someId);\n' + ' // ...\n' + ' }\n' + ' fetchData();\n' + '}, [someId]); // Or [] if effect doesn\'t need props or state\n\n' + 'Learn more about data fetching with Hooks: https://fb.me/react-hooks-data-fetching';
|
9875 | } else {
|
9876 | addendum = ' You returned: ' + _destroy;
|
9877 | }
|
9878 | warningWithoutStack$1(false, 'An effect function must not return anything besides a function, ' + 'which is used for clean-up.%s%s', addendum, getStackByFiberInDevAndProd(finishedWork));
|
9879 | }
|
9880 | }
|
9881 | }
|
9882 | effect = effect.next;
|
9883 | } while (effect !== firstEffect);
|
9884 | }
|
9885 | }
|
9886 |
|
9887 | function commitPassiveHookEffects(finishedWork) {
|
9888 | commitHookEffectList(UnmountPassive, NoEffect$1, finishedWork);
|
9889 | commitHookEffectList(NoEffect$1, MountPassive, finishedWork);
|
9890 | }
|
9891 |
|
9892 | function commitLifeCycles(finishedRoot, current, finishedWork, committedExpirationTime) {
|
9893 | switch (finishedWork.tag) {
|
9894 | case FunctionComponent:
|
9895 | case ForwardRef:
|
9896 | case SimpleMemoComponent:
|
9897 | {
|
9898 | commitHookEffectList(UnmountLayout, MountLayout, finishedWork);
|
9899 | break;
|
9900 | }
|
9901 | case ClassComponent:
|
9902 | {
|
9903 | var instance = finishedWork.stateNode;
|
9904 | if (finishedWork.effectTag & Update) {
|
9905 | if (current === null) {
|
9906 | startPhaseTimer(finishedWork, 'componentDidMount');
|
9907 |
|
9908 |
|
9909 |
|
9910 | {
|
9911 | if (finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps) {
|
9912 | !(instance.props === finishedWork.memoizedProps) ? warning$1(false, 'Expected %s props to match memoized props before ' + 'componentDidMount. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.props`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance') : void 0;
|
9913 | !(instance.state === finishedWork.memoizedState) ? warning$1(false, 'Expected %s state to match memoized state before ' + 'componentDidMount. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.props`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance') : void 0;
|
9914 | }
|
9915 | }
|
9916 | instance.componentDidMount();
|
9917 | stopPhaseTimer();
|
9918 | } else {
|
9919 | var prevProps = finishedWork.elementType === finishedWork.type ? current.memoizedProps : resolveDefaultProps(finishedWork.type, current.memoizedProps);
|
9920 | var prevState = current.memoizedState;
|
9921 | startPhaseTimer(finishedWork, 'componentDidUpdate');
|
9922 |
|
9923 |
|
9924 |
|
9925 | {
|
9926 | if (finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps) {
|
9927 | !(instance.props === finishedWork.memoizedProps) ? warning$1(false, 'Expected %s props to match memoized props before ' + 'componentDidUpdate. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.props`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance') : void 0;
|
9928 | !(instance.state === finishedWork.memoizedState) ? warning$1(false, 'Expected %s state to match memoized state before ' + 'componentDidUpdate. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.props`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance') : void 0;
|
9929 | }
|
9930 | }
|
9931 | instance.componentDidUpdate(prevProps, prevState, instance.__reactInternalSnapshotBeforeUpdate);
|
9932 | stopPhaseTimer();
|
9933 | }
|
9934 | }
|
9935 | var updateQueue = finishedWork.updateQueue;
|
9936 | if (updateQueue !== null) {
|
9937 | {
|
9938 | if (finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps) {
|
9939 | !(instance.props === finishedWork.memoizedProps) ? warning$1(false, 'Expected %s props to match memoized props before ' + 'processing the update queue. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.props`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance') : void 0;
|
9940 | !(instance.state === finishedWork.memoizedState) ? warning$1(false, 'Expected %s state to match memoized state before ' + 'processing the update queue. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.props`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance') : void 0;
|
9941 | }
|
9942 | }
|
9943 |
|
9944 |
|
9945 |
|
9946 | commitUpdateQueue(finishedWork, updateQueue, instance, committedExpirationTime);
|
9947 | }
|
9948 | return;
|
9949 | }
|
9950 | case HostRoot:
|
9951 | {
|
9952 | var _updateQueue = finishedWork.updateQueue;
|
9953 | if (_updateQueue !== null) {
|
9954 | var _instance = null;
|
9955 | if (finishedWork.child !== null) {
|
9956 | switch (finishedWork.child.tag) {
|
9957 | case HostComponent:
|
9958 | _instance = getPublicInstance(finishedWork.child.stateNode);
|
9959 | break;
|
9960 | case ClassComponent:
|
9961 | _instance = finishedWork.child.stateNode;
|
9962 | break;
|
9963 | }
|
9964 | }
|
9965 | commitUpdateQueue(finishedWork, _updateQueue, _instance, committedExpirationTime);
|
9966 | }
|
9967 | return;
|
9968 | }
|
9969 | case HostComponent:
|
9970 | {
|
9971 | var _instance2 = finishedWork.stateNode;
|
9972 |
|
9973 |
|
9974 |
|
9975 |
|
9976 |
|
9977 | if (current === null && finishedWork.effectTag & Update) {
|
9978 | var type = finishedWork.type;
|
9979 | var props = finishedWork.memoizedProps;
|
9980 |
|
9981 | }
|
9982 |
|
9983 | return;
|
9984 | }
|
9985 | case HostText:
|
9986 | {
|
9987 |
|
9988 | return;
|
9989 | }
|
9990 | case HostPortal:
|
9991 | {
|
9992 |
|
9993 | return;
|
9994 | }
|
9995 | case Profiler:
|
9996 | {
|
9997 | if (enableProfilerTimer) {
|
9998 | var onRender = finishedWork.memoizedProps.onRender;
|
9999 |
|
10000 | if (enableSchedulerTracing) {
|
10001 | onRender(finishedWork.memoizedProps.id, current === null ? 'mount' : 'update', finishedWork.actualDuration, finishedWork.treeBaseDuration, finishedWork.actualStartTime, getCommitTime(), finishedRoot.memoizedInteractions);
|
10002 | } else {
|
10003 | onRender(finishedWork.memoizedProps.id, current === null ? 'mount' : 'update', finishedWork.actualDuration, finishedWork.treeBaseDuration, finishedWork.actualStartTime, getCommitTime());
|
10004 | }
|
10005 | }
|
10006 | return;
|
10007 | }
|
10008 | case SuspenseComponent:
|
10009 | break;
|
10010 | case IncompleteClassComponent:
|
10011 | break;
|
10012 | default:
|
10013 | {
|
10014 | invariant(false, 'This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue.');
|
10015 | }
|
10016 | }
|
10017 | }
|
10018 |
|
10019 | function hideOrUnhideAllChildren(finishedWork, isHidden) {
|
10020 | if (supportsMutation) {
|
10021 |
|
10022 | var node = finishedWork;
|
10023 | while (true) {
|
10024 | if (node.tag === HostComponent) {
|
10025 | var instance = node.stateNode;
|
10026 | if (isHidden) {
|
10027 | hideInstance(instance);
|
10028 | } else {
|
10029 | unhideInstance(node.stateNode, node.memoizedProps);
|
10030 | }
|
10031 | } else if (node.tag === HostText) {
|
10032 | var _instance3 = node.stateNode;
|
10033 | if (isHidden) {
|
10034 |
|
10035 | } else {
|
10036 | unhideTextInstance(_instance3, node.memoizedProps);
|
10037 | }
|
10038 | } else if (node.tag === SuspenseComponent && node.memoizedState !== null) {
|
10039 |
|
10040 | var fallbackChildFragment = node.child.sibling;
|
10041 | fallbackChildFragment.return = node;
|
10042 | node = fallbackChildFragment;
|
10043 | continue;
|
10044 | } else if (node.child !== null) {
|
10045 | node.child.return = node;
|
10046 | node = node.child;
|
10047 | continue;
|
10048 | }
|
10049 | if (node === finishedWork) {
|
10050 | return;
|
10051 | }
|
10052 | while (node.sibling === null) {
|
10053 | if (node.return === null || node.return === finishedWork) {
|
10054 | return;
|
10055 | }
|
10056 | node = node.return;
|
10057 | }
|
10058 | node.sibling.return = node.return;
|
10059 | node = node.sibling;
|
10060 | }
|
10061 | }
|
10062 | }
|
10063 |
|
10064 | function commitAttachRef(finishedWork) {
|
10065 | var ref = finishedWork.ref;
|
10066 | if (ref !== null) {
|
10067 | var instance = finishedWork.stateNode;
|
10068 | var instanceToUse = void 0;
|
10069 | switch (finishedWork.tag) {
|
10070 | case HostComponent:
|
10071 | instanceToUse = getPublicInstance(instance);
|
10072 | break;
|
10073 | default:
|
10074 | instanceToUse = instance;
|
10075 | }
|
10076 | if (typeof ref === 'function') {
|
10077 | ref(instanceToUse);
|
10078 | } else {
|
10079 | {
|
10080 | if (!ref.hasOwnProperty('current')) {
|
10081 | warningWithoutStack$1(false, 'Unexpected ref object provided for %s. ' + 'Use either a ref-setter function or React.createRef().%s', getComponentName(finishedWork.type), getStackByFiberInDevAndProd(finishedWork));
|
10082 | }
|
10083 | }
|
10084 |
|
10085 | ref.current = instanceToUse;
|
10086 | }
|
10087 | }
|
10088 | }
|
10089 |
|
10090 | function commitDetachRef(current) {
|
10091 | var currentRef = current.ref;
|
10092 | if (currentRef !== null) {
|
10093 | if (typeof currentRef === 'function') {
|
10094 | currentRef(null);
|
10095 | } else {
|
10096 | currentRef.current = null;
|
10097 | }
|
10098 | }
|
10099 | }
|
10100 |
|
10101 |
|
10102 |
|
10103 |
|
10104 | function commitUnmount(current) {
|
10105 | onCommitUnmount(current);
|
10106 |
|
10107 | switch (current.tag) {
|
10108 | case FunctionComponent:
|
10109 | case ForwardRef:
|
10110 | case MemoComponent:
|
10111 | case SimpleMemoComponent:
|
10112 | {
|
10113 | var updateQueue = current.updateQueue;
|
10114 | if (updateQueue !== null) {
|
10115 | var lastEffect = updateQueue.lastEffect;
|
10116 | if (lastEffect !== null) {
|
10117 | var firstEffect = lastEffect.next;
|
10118 | var effect = firstEffect;
|
10119 | do {
|
10120 | var destroy = effect.destroy;
|
10121 | if (destroy !== undefined) {
|
10122 | safelyCallDestroy(current, destroy);
|
10123 | }
|
10124 | effect = effect.next;
|
10125 | } while (effect !== firstEffect);
|
10126 | }
|
10127 | }
|
10128 | break;
|
10129 | }
|
10130 | case ClassComponent:
|
10131 | {
|
10132 | safelyDetachRef(current);
|
10133 | var instance = current.stateNode;
|
10134 | if (typeof instance.componentWillUnmount === 'function') {
|
10135 | safelyCallComponentWillUnmount(current, instance);
|
10136 | }
|
10137 | return;
|
10138 | }
|
10139 | case HostComponent:
|
10140 | {
|
10141 | safelyDetachRef(current);
|
10142 | return;
|
10143 | }
|
10144 | case HostPortal:
|
10145 | {
|
10146 |
|
10147 |
|
10148 |
|
10149 | if (supportsMutation) {
|
10150 | unmountHostComponents(current);
|
10151 | } else if (supportsPersistence) {
|
10152 | emptyPortalContainer(current);
|
10153 | }
|
10154 | return;
|
10155 | }
|
10156 | }
|
10157 | }
|
10158 |
|
10159 | function commitNestedUnmounts(root) {
|
10160 |
|
10161 |
|
10162 |
|
10163 |
|
10164 | var node = root;
|
10165 | while (true) {
|
10166 | commitUnmount(node);
|
10167 |
|
10168 |
|
10169 | if (node.child !== null && (
|
10170 |
|
10171 |
|
10172 | !supportsMutation || node.tag !== HostPortal)) {
|
10173 | node.child.return = node;
|
10174 | node = node.child;
|
10175 | continue;
|
10176 | }
|
10177 | if (node === root) {
|
10178 | return;
|
10179 | }
|
10180 | while (node.sibling === null) {
|
10181 | if (node.return === null || node.return === root) {
|
10182 | return;
|
10183 | }
|
10184 | node = node.return;
|
10185 | }
|
10186 | node.sibling.return = node.return;
|
10187 | node = node.sibling;
|
10188 | }
|
10189 | }
|
10190 |
|
10191 | function detachFiber(current) {
|
10192 |
|
10193 |
|
10194 |
|
10195 |
|
10196 |
|
10197 | current.return = null;
|
10198 | current.child = null;
|
10199 | current.memoizedState = null;
|
10200 | current.updateQueue = null;
|
10201 | var alternate = current.alternate;
|
10202 | if (alternate !== null) {
|
10203 | alternate.return = null;
|
10204 | alternate.child = null;
|
10205 | alternate.memoizedState = null;
|
10206 | alternate.updateQueue = null;
|
10207 | }
|
10208 | }
|
10209 |
|
10210 | function emptyPortalContainer(current) {
|
10211 | if (!supportsPersistence) {
|
10212 | return;
|
10213 | }
|
10214 |
|
10215 | var portal = current.stateNode;
|
10216 | var containerInfo = portal.containerInfo;
|
10217 |
|
10218 | var emptyChildSet = createContainerChildSet(containerInfo);
|
10219 | replaceContainerChildren(containerInfo, emptyChildSet);
|
10220 | }
|
10221 |
|
10222 | function commitContainer(finishedWork) {
|
10223 | if (!supportsPersistence) {
|
10224 | return;
|
10225 | }
|
10226 |
|
10227 | switch (finishedWork.tag) {
|
10228 | case ClassComponent:
|
10229 | {
|
10230 | return;
|
10231 | }
|
10232 | case HostComponent:
|
10233 | {
|
10234 | return;
|
10235 | }
|
10236 | case HostText:
|
10237 | {
|
10238 | return;
|
10239 | }
|
10240 | case HostRoot:
|
10241 | case HostPortal:
|
10242 | {
|
10243 | var portalOrRoot = finishedWork.stateNode;
|
10244 | var containerInfo = portalOrRoot.containerInfo,
|
10245 | _pendingChildren = portalOrRoot.pendingChildren;
|
10246 |
|
10247 | replaceContainerChildren(containerInfo, _pendingChildren);
|
10248 | return;
|
10249 | }
|
10250 | default:
|
10251 | {
|
10252 | invariant(false, 'This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue.');
|
10253 | }
|
10254 | }
|
10255 | }
|
10256 |
|
10257 | function getHostParentFiber(fiber) {
|
10258 | var parent = fiber.return;
|
10259 | while (parent !== null) {
|
10260 | if (isHostParent(parent)) {
|
10261 | return parent;
|
10262 | }
|
10263 | parent = parent.return;
|
10264 | }
|
10265 | invariant(false, 'Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue.');
|
10266 | }
|
10267 |
|
10268 | function isHostParent(fiber) {
|
10269 | return fiber.tag === HostComponent || fiber.tag === HostRoot || fiber.tag === HostPortal;
|
10270 | }
|
10271 |
|
10272 | function getHostSibling(fiber) {
|
10273 |
|
10274 |
|
10275 |
|
10276 | var node = fiber;
|
10277 | siblings: while (true) {
|
10278 |
|
10279 | while (node.sibling === null) {
|
10280 | if (node.return === null || isHostParent(node.return)) {
|
10281 |
|
10282 |
|
10283 | return null;
|
10284 | }
|
10285 | node = node.return;
|
10286 | }
|
10287 | node.sibling.return = node.return;
|
10288 | node = node.sibling;
|
10289 | while (node.tag !== HostComponent && node.tag !== HostText && node.tag !== DehydratedSuspenseComponent) {
|
10290 |
|
10291 |
|
10292 | if (node.effectTag & Placement) {
|
10293 |
|
10294 | continue siblings;
|
10295 | }
|
10296 |
|
10297 |
|
10298 | if (node.child === null || node.tag === HostPortal) {
|
10299 | continue siblings;
|
10300 | } else {
|
10301 | node.child.return = node;
|
10302 | node = node.child;
|
10303 | }
|
10304 | }
|
10305 |
|
10306 | if (!(node.effectTag & Placement)) {
|
10307 |
|
10308 | return node.stateNode;
|
10309 | }
|
10310 | }
|
10311 | }
|
10312 |
|
10313 | function commitPlacement(finishedWork) {
|
10314 | if (!supportsMutation) {
|
10315 | return;
|
10316 | }
|
10317 |
|
10318 |
|
10319 | var parentFiber = getHostParentFiber(finishedWork);
|
10320 |
|
10321 |
|
10322 | var parent = void 0;
|
10323 | var isContainer = void 0;
|
10324 |
|
10325 | switch (parentFiber.tag) {
|
10326 | case HostComponent:
|
10327 | parent = parentFiber.stateNode;
|
10328 | isContainer = false;
|
10329 | break;
|
10330 | case HostRoot:
|
10331 | parent = parentFiber.stateNode.containerInfo;
|
10332 | isContainer = true;
|
10333 | break;
|
10334 | case HostPortal:
|
10335 | parent = parentFiber.stateNode.containerInfo;
|
10336 | isContainer = true;
|
10337 | break;
|
10338 | default:
|
10339 | invariant(false, 'Invalid host parent fiber. This error is likely caused by a bug in React. Please file an issue.');
|
10340 | }
|
10341 | if (parentFiber.effectTag & ContentReset) {
|
10342 |
|
10343 | parentFiber.effectTag &= ~ContentReset;
|
10344 | }
|
10345 |
|
10346 | var before = getHostSibling(finishedWork);
|
10347 |
|
10348 |
|
10349 | var node = finishedWork;
|
10350 | while (true) {
|
10351 | if (node.tag === HostComponent || node.tag === HostText) {
|
10352 | if (before) {
|
10353 | if (isContainer) {
|
10354 | insertInContainerBefore(parent, node.stateNode, before);
|
10355 | } else {
|
10356 | insertBefore(parent, node.stateNode, before);
|
10357 | }
|
10358 | } else {
|
10359 | if (isContainer) {
|
10360 | appendChildToContainer(parent, node.stateNode);
|
10361 | } else {
|
10362 | appendChild(parent, node.stateNode);
|
10363 | }
|
10364 | }
|
10365 | } else if (node.tag === HostPortal) {
|
10366 |
|
10367 |
|
10368 |
|
10369 | } else if (node.child !== null) {
|
10370 | node.child.return = node;
|
10371 | node = node.child;
|
10372 | continue;
|
10373 | }
|
10374 | if (node === finishedWork) {
|
10375 | return;
|
10376 | }
|
10377 | while (node.sibling === null) {
|
10378 | if (node.return === null || node.return === finishedWork) {
|
10379 | return;
|
10380 | }
|
10381 | node = node.return;
|
10382 | }
|
10383 | node.sibling.return = node.return;
|
10384 | node = node.sibling;
|
10385 | }
|
10386 | }
|
10387 |
|
10388 | function unmountHostComponents(current) {
|
10389 |
|
10390 | var node = current;
|
10391 |
|
10392 |
|
10393 |
|
10394 | var currentParentIsValid = false;
|
10395 |
|
10396 |
|
10397 | var currentParent = void 0;
|
10398 | var currentParentIsContainer = void 0;
|
10399 |
|
10400 | while (true) {
|
10401 | if (!currentParentIsValid) {
|
10402 | var parent = node.return;
|
10403 | findParent: while (true) {
|
10404 | !(parent !== null) ? invariant(false, 'Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue.') : void 0;
|
10405 | switch (parent.tag) {
|
10406 | case HostComponent:
|
10407 | currentParent = parent.stateNode;
|
10408 | currentParentIsContainer = false;
|
10409 | break findParent;
|
10410 | case HostRoot:
|
10411 | currentParent = parent.stateNode.containerInfo;
|
10412 | currentParentIsContainer = true;
|
10413 | break findParent;
|
10414 | case HostPortal:
|
10415 | currentParent = parent.stateNode.containerInfo;
|
10416 | currentParentIsContainer = true;
|
10417 | break findParent;
|
10418 | }
|
10419 | parent = parent.return;
|
10420 | }
|
10421 | currentParentIsValid = true;
|
10422 | }
|
10423 |
|
10424 | if (node.tag === HostComponent || node.tag === HostText) {
|
10425 | commitNestedUnmounts(node);
|
10426 |
|
10427 |
|
10428 | if (currentParentIsContainer) {
|
10429 | removeChildFromContainer(currentParent, node.stateNode);
|
10430 | } else {
|
10431 | removeChild(currentParent, node.stateNode);
|
10432 | }
|
10433 |
|
10434 | } else if (enableSuspenseServerRenderer && node.tag === DehydratedSuspenseComponent) {
|
10435 |
|
10436 | if (currentParentIsContainer) {
|
10437 | clearSuspenseBoundaryFromContainer(currentParent, node.stateNode);
|
10438 | } else {
|
10439 | clearSuspenseBoundary(currentParent, node.stateNode);
|
10440 | }
|
10441 | } else if (node.tag === HostPortal) {
|
10442 | if (node.child !== null) {
|
10443 |
|
10444 |
|
10445 | currentParent = node.stateNode.containerInfo;
|
10446 | currentParentIsContainer = true;
|
10447 |
|
10448 | node.child.return = node;
|
10449 | node = node.child;
|
10450 | continue;
|
10451 | }
|
10452 | } else {
|
10453 | commitUnmount(node);
|
10454 |
|
10455 | if (node.child !== null) {
|
10456 | node.child.return = node;
|
10457 | node = node.child;
|
10458 | continue;
|
10459 | }
|
10460 | }
|
10461 | if (node === current) {
|
10462 | return;
|
10463 | }
|
10464 | while (node.sibling === null) {
|
10465 | if (node.return === null || node.return === current) {
|
10466 | return;
|
10467 | }
|
10468 | node = node.return;
|
10469 | if (node.tag === HostPortal) {
|
10470 |
|
10471 |
|
10472 | currentParentIsValid = false;
|
10473 | }
|
10474 | }
|
10475 | node.sibling.return = node.return;
|
10476 | node = node.sibling;
|
10477 | }
|
10478 | }
|
10479 |
|
10480 | function commitDeletion(current) {
|
10481 | if (supportsMutation) {
|
10482 |
|
10483 |
|
10484 | unmountHostComponents(current);
|
10485 | } else {
|
10486 |
|
10487 | commitNestedUnmounts(current);
|
10488 | }
|
10489 | detachFiber(current);
|
10490 | }
|
10491 |
|
10492 | function commitWork(current, finishedWork) {
|
10493 | if (!supportsMutation) {
|
10494 | switch (finishedWork.tag) {
|
10495 | case FunctionComponent:
|
10496 | case ForwardRef:
|
10497 | case MemoComponent:
|
10498 | case SimpleMemoComponent:
|
10499 | {
|
10500 |
|
10501 |
|
10502 | commitHookEffectList(UnmountMutation, MountMutation, finishedWork);
|
10503 | return;
|
10504 | }
|
10505 | }
|
10506 |
|
10507 | commitContainer(finishedWork);
|
10508 | return;
|
10509 | }
|
10510 |
|
10511 | switch (finishedWork.tag) {
|
10512 | case FunctionComponent:
|
10513 | case ForwardRef:
|
10514 | case MemoComponent:
|
10515 | case SimpleMemoComponent:
|
10516 | {
|
10517 |
|
10518 |
|
10519 | commitHookEffectList(UnmountMutation, MountMutation, finishedWork);
|
10520 | return;
|
10521 | }
|
10522 | case ClassComponent:
|
10523 | {
|
10524 | return;
|
10525 | }
|
10526 | case HostComponent:
|
10527 | {
|
10528 | var instance = finishedWork.stateNode;
|
10529 | if (instance != null) {
|
10530 |
|
10531 | var newProps = finishedWork.memoizedProps;
|
10532 |
|
10533 |
|
10534 |
|
10535 | var oldProps = current !== null ? current.memoizedProps : newProps;
|
10536 | var type = finishedWork.type;
|
10537 |
|
10538 | var updatePayload = finishedWork.updateQueue;
|
10539 | finishedWork.updateQueue = null;
|
10540 | if (updatePayload !== null) {
|
10541 | commitUpdate(instance, updatePayload, type, oldProps, newProps, finishedWork);
|
10542 | }
|
10543 | }
|
10544 | return;
|
10545 | }
|
10546 | case HostText:
|
10547 | {
|
10548 | !(finishedWork.stateNode !== null) ? invariant(false, 'This should have a text node initialized. This error is likely caused by a bug in React. Please file an issue.') : void 0;
|
10549 | var textInstance = finishedWork.stateNode;
|
10550 | var newText = finishedWork.memoizedProps;
|
10551 |
|
10552 |
|
10553 |
|
10554 | var oldText = current !== null ? current.memoizedProps : newText;
|
10555 | return;
|
10556 | }
|
10557 | case HostRoot:
|
10558 | {
|
10559 | return;
|
10560 | }
|
10561 | case Profiler:
|
10562 | {
|
10563 | return;
|
10564 | }
|
10565 | case SuspenseComponent:
|
10566 | {
|
10567 | var newState = finishedWork.memoizedState;
|
10568 |
|
10569 | var newDidTimeout = void 0;
|
10570 | var primaryChildParent = finishedWork;
|
10571 | if (newState === null) {
|
10572 | newDidTimeout = false;
|
10573 | } else {
|
10574 | newDidTimeout = true;
|
10575 | primaryChildParent = finishedWork.child;
|
10576 | if (newState.timedOutAt === NoWork) {
|
10577 |
|
10578 |
|
10579 |
|
10580 | newState.timedOutAt = requestCurrentTime();
|
10581 | }
|
10582 | }
|
10583 |
|
10584 | if (primaryChildParent !== null) {
|
10585 | hideOrUnhideAllChildren(primaryChildParent, newDidTimeout);
|
10586 | }
|
10587 |
|
10588 |
|
10589 |
|
10590 |
|
10591 | var thenables = finishedWork.updateQueue;
|
10592 | if (thenables !== null) {
|
10593 | finishedWork.updateQueue = null;
|
10594 | var retryCache = finishedWork.stateNode;
|
10595 | if (retryCache === null) {
|
10596 | retryCache = finishedWork.stateNode = new PossiblyWeakSet$1();
|
10597 | }
|
10598 | thenables.forEach(function (thenable) {
|
10599 |
|
10600 | var retry = retryTimedOutBoundary.bind(null, finishedWork, thenable);
|
10601 | if (enableSchedulerTracing) {
|
10602 | retry = unstable_wrap(retry);
|
10603 | }
|
10604 | if (!retryCache.has(thenable)) {
|
10605 | retryCache.add(thenable);
|
10606 | thenable.then(retry, retry);
|
10607 | }
|
10608 | });
|
10609 | }
|
10610 |
|
10611 | return;
|
10612 | }
|
10613 | case IncompleteClassComponent:
|
10614 | {
|
10615 | return;
|
10616 | }
|
10617 | default:
|
10618 | {
|
10619 | invariant(false, 'This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue.');
|
10620 | }
|
10621 | }
|
10622 | }
|
10623 |
|
10624 | function commitResetTextContent(current) {
|
10625 | if (!supportsMutation) {
|
10626 | return;
|
10627 | }
|
10628 | resetTextContent(current.stateNode);
|
10629 | }
|
10630 |
|
10631 | var PossiblyWeakSet = typeof WeakSet === 'function' ? WeakSet : Set;
|
10632 | var PossiblyWeakMap = typeof WeakMap === 'function' ? WeakMap : Map;
|
10633 |
|
10634 | function createRootErrorUpdate(fiber, errorInfo, expirationTime) {
|
10635 | var update = createUpdate(expirationTime);
|
10636 |
|
10637 | update.tag = CaptureUpdate;
|
10638 |
|
10639 |
|
10640 | update.payload = { element: null };
|
10641 | var error = errorInfo.value;
|
10642 | update.callback = function () {
|
10643 | onUncaughtError(error);
|
10644 | logError(fiber, errorInfo);
|
10645 | };
|
10646 | return update;
|
10647 | }
|
10648 |
|
10649 | function createClassErrorUpdate(fiber, errorInfo, expirationTime) {
|
10650 | var update = createUpdate(expirationTime);
|
10651 | update.tag = CaptureUpdate;
|
10652 | var getDerivedStateFromError = fiber.type.getDerivedStateFromError;
|
10653 | if (typeof getDerivedStateFromError === 'function') {
|
10654 | var error = errorInfo.value;
|
10655 | update.payload = function () {
|
10656 | return getDerivedStateFromError(error);
|
10657 | };
|
10658 | }
|
10659 |
|
10660 | var inst = fiber.stateNode;
|
10661 | if (inst !== null && typeof inst.componentDidCatch === 'function') {
|
10662 | update.callback = function callback() {
|
10663 | if (typeof getDerivedStateFromError !== 'function') {
|
10664 |
|
10665 |
|
10666 |
|
10667 |
|
10668 |
|
10669 | markLegacyErrorBoundaryAsFailed(this);
|
10670 | }
|
10671 | var error = errorInfo.value;
|
10672 | var stack = errorInfo.stack;
|
10673 | logError(fiber, errorInfo);
|
10674 | this.componentDidCatch(error, {
|
10675 | componentStack: stack !== null ? stack : ''
|
10676 | });
|
10677 | {
|
10678 | if (typeof getDerivedStateFromError !== 'function') {
|
10679 |
|
10680 |
|
10681 |
|
10682 | !(fiber.expirationTime === Sync) ? warningWithoutStack$1(false, '%s: Error boundaries should implement getDerivedStateFromError(). ' + 'In that method, return a state update to display an error message or fallback UI.', getComponentName(fiber.type) || 'Unknown') : void 0;
|
10683 | }
|
10684 | }
|
10685 | };
|
10686 | }
|
10687 | return update;
|
10688 | }
|
10689 |
|
10690 | function attachPingListener(root, renderExpirationTime, thenable) {
|
10691 |
|
10692 |
|
10693 |
|
10694 | var pingCache = root.pingCache;
|
10695 | var threadIDs = void 0;
|
10696 | if (pingCache === null) {
|
10697 | pingCache = root.pingCache = new PossiblyWeakMap();
|
10698 | threadIDs = new Set();
|
10699 | pingCache.set(thenable, threadIDs);
|
10700 | } else {
|
10701 | threadIDs = pingCache.get(thenable);
|
10702 | if (threadIDs === undefined) {
|
10703 | threadIDs = new Set();
|
10704 | pingCache.set(thenable, threadIDs);
|
10705 | }
|
10706 | }
|
10707 | if (!threadIDs.has(renderExpirationTime)) {
|
10708 |
|
10709 | threadIDs.add(renderExpirationTime);
|
10710 | var ping = pingSuspendedRoot.bind(null, root, thenable, renderExpirationTime);
|
10711 | if (enableSchedulerTracing) {
|
10712 | ping = unstable_wrap(ping);
|
10713 | }
|
10714 | thenable.then(ping, ping);
|
10715 | }
|
10716 | }
|
10717 |
|
10718 | function throwException(root, returnFiber, sourceFiber, value, renderExpirationTime) {
|
10719 |
|
10720 | sourceFiber.effectTag |= Incomplete;
|
10721 |
|
10722 | sourceFiber.firstEffect = sourceFiber.lastEffect = null;
|
10723 |
|
10724 | if (value !== null && typeof value === 'object' && typeof value.then === 'function') {
|
10725 |
|
10726 | var thenable = value;
|
10727 |
|
10728 |
|
10729 |
|
10730 |
|
10731 |
|
10732 |
|
10733 | var _workInProgress = returnFiber;
|
10734 | var earliestTimeoutMs = -1;
|
10735 | var startTimeMs = -1;
|
10736 | do {
|
10737 | if (_workInProgress.tag === SuspenseComponent) {
|
10738 | var current = _workInProgress.alternate;
|
10739 | if (current !== null) {
|
10740 | var currentState = current.memoizedState;
|
10741 | if (currentState !== null) {
|
10742 |
|
10743 |
|
10744 | var timedOutAt = currentState.timedOutAt;
|
10745 | startTimeMs = expirationTimeToMs(timedOutAt);
|
10746 |
|
10747 | break;
|
10748 | }
|
10749 | }
|
10750 | var timeoutPropMs = _workInProgress.pendingProps.maxDuration;
|
10751 | if (typeof timeoutPropMs === 'number') {
|
10752 | if (timeoutPropMs <= 0) {
|
10753 | earliestTimeoutMs = 0;
|
10754 | } else if (earliestTimeoutMs === -1 || timeoutPropMs < earliestTimeoutMs) {
|
10755 | earliestTimeoutMs = timeoutPropMs;
|
10756 | }
|
10757 | }
|
10758 | }
|
10759 |
|
10760 |
|
10761 |
|
10762 | _workInProgress = _workInProgress.return;
|
10763 | } while (_workInProgress !== null);
|
10764 |
|
10765 |
|
10766 | _workInProgress = returnFiber;
|
10767 | do {
|
10768 | if (_workInProgress.tag === SuspenseComponent && shouldCaptureSuspense(_workInProgress)) {
|
10769 |
|
10770 |
|
10771 |
|
10772 | var thenables = _workInProgress.updateQueue;
|
10773 | if (thenables === null) {
|
10774 | var updateQueue = new Set();
|
10775 | updateQueue.add(thenable);
|
10776 | _workInProgress.updateQueue = updateQueue;
|
10777 | } else {
|
10778 | thenables.add(thenable);
|
10779 | }
|
10780 |
|
10781 |
|
10782 |
|
10783 |
|
10784 |
|
10785 |
|
10786 |
|
10787 |
|
10788 |
|
10789 | if ((_workInProgress.mode & ConcurrentMode) === NoEffect) {
|
10790 | _workInProgress.effectTag |= DidCapture;
|
10791 |
|
10792 |
|
10793 |
|
10794 |
|
10795 | sourceFiber.effectTag &= ~(LifecycleEffectMask | Incomplete);
|
10796 |
|
10797 | if (sourceFiber.tag === ClassComponent) {
|
10798 | var currentSourceFiber = sourceFiber.alternate;
|
10799 | if (currentSourceFiber === null) {
|
10800 |
|
10801 |
|
10802 |
|
10803 | sourceFiber.tag = IncompleteClassComponent;
|
10804 | } else {
|
10805 |
|
10806 |
|
10807 |
|
10808 | var update = createUpdate(Sync);
|
10809 | update.tag = ForceUpdate;
|
10810 | enqueueUpdate(sourceFiber, update);
|
10811 | }
|
10812 | }
|
10813 |
|
10814 |
|
10815 |
|
10816 | sourceFiber.expirationTime = Sync;
|
10817 |
|
10818 |
|
10819 | return;
|
10820 | }
|
10821 |
|
10822 |
|
10823 |
|
10824 |
|
10825 | attachPingListener(root, renderExpirationTime, thenable);
|
10826 |
|
10827 | var absoluteTimeoutMs = void 0;
|
10828 | if (earliestTimeoutMs === -1) {
|
10829 |
|
10830 |
|
10831 |
|
10832 | absoluteTimeoutMs = maxSigned31BitInt;
|
10833 | } else {
|
10834 | if (startTimeMs === -1) {
|
10835 |
|
10836 |
|
10837 |
|
10838 |
|
10839 |
|
10840 |
|
10841 |
|
10842 |
|
10843 |
|
10844 | var earliestExpirationTime = findEarliestOutstandingPriorityLevel(root, renderExpirationTime);
|
10845 | var earliestExpirationTimeMs = expirationTimeToMs(earliestExpirationTime);
|
10846 | startTimeMs = earliestExpirationTimeMs - LOW_PRIORITY_EXPIRATION;
|
10847 | }
|
10848 | absoluteTimeoutMs = startTimeMs + earliestTimeoutMs;
|
10849 | }
|
10850 |
|
10851 |
|
10852 |
|
10853 |
|
10854 |
|
10855 | renderDidSuspend(root, absoluteTimeoutMs, renderExpirationTime);
|
10856 |
|
10857 | _workInProgress.effectTag |= ShouldCapture;
|
10858 | _workInProgress.expirationTime = renderExpirationTime;
|
10859 | return;
|
10860 | } else if (enableSuspenseServerRenderer && _workInProgress.tag === DehydratedSuspenseComponent) {
|
10861 | attachPingListener(root, renderExpirationTime, thenable);
|
10862 |
|
10863 |
|
10864 | var retryCache = _workInProgress.memoizedState;
|
10865 | if (retryCache === null) {
|
10866 | retryCache = _workInProgress.memoizedState = new PossiblyWeakSet();
|
10867 | var _current = _workInProgress.alternate;
|
10868 | !_current ? invariant(false, 'A dehydrated suspense boundary must commit before trying to render. This is probably a bug in React.') : void 0;
|
10869 | _current.memoizedState = retryCache;
|
10870 | }
|
10871 |
|
10872 | if (!retryCache.has(thenable)) {
|
10873 | retryCache.add(thenable);
|
10874 | var retry = retryTimedOutBoundary.bind(null, _workInProgress, thenable);
|
10875 | if (enableSchedulerTracing) {
|
10876 | retry = unstable_wrap(retry);
|
10877 | }
|
10878 | thenable.then(retry, retry);
|
10879 | }
|
10880 | _workInProgress.effectTag |= ShouldCapture;
|
10881 | _workInProgress.expirationTime = renderExpirationTime;
|
10882 | return;
|
10883 | }
|
10884 |
|
10885 |
|
10886 | _workInProgress = _workInProgress.return;
|
10887 | } while (_workInProgress !== null);
|
10888 |
|
10889 |
|
10890 | value = new Error((getComponentName(sourceFiber.type) || 'A React component') + ' suspended while rendering, but no fallback UI was specified.\n' + '\n' + 'Add a <Suspense fallback=...> component higher in the tree to ' + 'provide a loading indicator or placeholder to display.' + getStackByFiberInDevAndProd(sourceFiber));
|
10891 | }
|
10892 |
|
10893 |
|
10894 |
|
10895 |
|
10896 | renderDidError();
|
10897 | value = createCapturedValue(value, sourceFiber);
|
10898 | var workInProgress = returnFiber;
|
10899 | do {
|
10900 | switch (workInProgress.tag) {
|
10901 | case HostRoot:
|
10902 | {
|
10903 | var _errorInfo = value;
|
10904 | workInProgress.effectTag |= ShouldCapture;
|
10905 | workInProgress.expirationTime = renderExpirationTime;
|
10906 | var _update = createRootErrorUpdate(workInProgress, _errorInfo, renderExpirationTime);
|
10907 | enqueueCapturedUpdate(workInProgress, _update);
|
10908 | return;
|
10909 | }
|
10910 | case ClassComponent:
|
10911 |
|
10912 | var errorInfo = value;
|
10913 | var ctor = workInProgress.type;
|
10914 | var instance = workInProgress.stateNode;
|
10915 | if ((workInProgress.effectTag & DidCapture) === NoEffect && (typeof ctor.getDerivedStateFromError === 'function' || instance !== null && typeof instance.componentDidCatch === 'function' && !isAlreadyFailedLegacyErrorBoundary(instance))) {
|
10916 | workInProgress.effectTag |= ShouldCapture;
|
10917 | workInProgress.expirationTime = renderExpirationTime;
|
10918 |
|
10919 | var _update2 = createClassErrorUpdate(workInProgress, errorInfo, renderExpirationTime);
|
10920 | enqueueCapturedUpdate(workInProgress, _update2);
|
10921 | return;
|
10922 | }
|
10923 | break;
|
10924 | default:
|
10925 | break;
|
10926 | }
|
10927 | workInProgress = workInProgress.return;
|
10928 | } while (workInProgress !== null);
|
10929 | }
|
10930 |
|
10931 | function unwindWork(workInProgress, renderExpirationTime) {
|
10932 | switch (workInProgress.tag) {
|
10933 | case ClassComponent:
|
10934 | {
|
10935 | var Component = workInProgress.type;
|
10936 | if (isContextProvider(Component)) {
|
10937 | popContext(workInProgress);
|
10938 | }
|
10939 | var effectTag = workInProgress.effectTag;
|
10940 | if (effectTag & ShouldCapture) {
|
10941 | workInProgress.effectTag = effectTag & ~ShouldCapture | DidCapture;
|
10942 | return workInProgress;
|
10943 | }
|
10944 | return null;
|
10945 | }
|
10946 | case HostRoot:
|
10947 | {
|
10948 | popHostContainer(workInProgress);
|
10949 | popTopLevelContextObject(workInProgress);
|
10950 | var _effectTag = workInProgress.effectTag;
|
10951 | !((_effectTag & DidCapture) === NoEffect) ? invariant(false, 'The root failed to unmount after an error. This is likely a bug in React. Please file an issue.') : void 0;
|
10952 | workInProgress.effectTag = _effectTag & ~ShouldCapture | DidCapture;
|
10953 | return workInProgress;
|
10954 | }
|
10955 | case HostComponent:
|
10956 | {
|
10957 |
|
10958 | popHostContext(workInProgress);
|
10959 | return null;
|
10960 | }
|
10961 | case SuspenseComponent:
|
10962 | {
|
10963 | var _effectTag2 = workInProgress.effectTag;
|
10964 | if (_effectTag2 & ShouldCapture) {
|
10965 | workInProgress.effectTag = _effectTag2 & ~ShouldCapture | DidCapture;
|
10966 |
|
10967 | return workInProgress;
|
10968 | }
|
10969 | return null;
|
10970 | }
|
10971 | case DehydratedSuspenseComponent:
|
10972 | {
|
10973 | if (enableSuspenseServerRenderer) {
|
10974 |
|
10975 | var _effectTag3 = workInProgress.effectTag;
|
10976 | if (_effectTag3 & ShouldCapture) {
|
10977 | workInProgress.effectTag = _effectTag3 & ~ShouldCapture | DidCapture;
|
10978 |
|
10979 | return workInProgress;
|
10980 | }
|
10981 | }
|
10982 | return null;
|
10983 | }
|
10984 | case HostPortal:
|
10985 | popHostContainer(workInProgress);
|
10986 | return null;
|
10987 | case ContextProvider:
|
10988 | popProvider(workInProgress);
|
10989 | return null;
|
10990 | default:
|
10991 | return null;
|
10992 | }
|
10993 | }
|
10994 |
|
10995 | function unwindInterruptedWork(interruptedWork) {
|
10996 | switch (interruptedWork.tag) {
|
10997 | case ClassComponent:
|
10998 | {
|
10999 | var childContextTypes = interruptedWork.type.childContextTypes;
|
11000 | if (childContextTypes !== null && childContextTypes !== undefined) {
|
11001 | popContext(interruptedWork);
|
11002 | }
|
11003 | break;
|
11004 | }
|
11005 | case HostRoot:
|
11006 | {
|
11007 | popHostContainer(interruptedWork);
|
11008 | popTopLevelContextObject(interruptedWork);
|
11009 | break;
|
11010 | }
|
11011 | case HostComponent:
|
11012 | {
|
11013 | popHostContext(interruptedWork);
|
11014 | break;
|
11015 | }
|
11016 | case HostPortal:
|
11017 | popHostContainer(interruptedWork);
|
11018 | break;
|
11019 | case ContextProvider:
|
11020 | popProvider(interruptedWork);
|
11021 | break;
|
11022 | default:
|
11023 | break;
|
11024 | }
|
11025 | }
|
11026 |
|
11027 | var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;
|
11028 | var ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner;
|
11029 |
|
11030 |
|
11031 | var didWarnAboutStateTransition = void 0;
|
11032 | var didWarnSetStateChildContext = void 0;
|
11033 | var warnAboutUpdateOnUnmounted = void 0;
|
11034 | var warnAboutInvalidUpdates = void 0;
|
11035 |
|
11036 | if (enableSchedulerTracing) {
|
11037 |
|
11038 |
|
11039 | !(__interactionsRef != null && __interactionsRef.current != null) ? invariant(false, 'It is not supported to run the profiling version of a renderer (for example, `react-dom/profiling`) without also replacing the `scheduler/tracing` module with `scheduler/tracing-profiling`. Your bundler might have a setting for aliasing both modules. Learn more at http://fb.me/react-profiling') : void 0;
|
11040 | }
|
11041 |
|
11042 | {
|
11043 | didWarnAboutStateTransition = false;
|
11044 | didWarnSetStateChildContext = false;
|
11045 | var didWarnStateUpdateForUnmountedComponent = {};
|
11046 |
|
11047 | warnAboutUpdateOnUnmounted = function (fiber, isClass) {
|
11048 |
|
11049 |
|
11050 | var componentName = getComponentName(fiber.type) || 'ReactComponent';
|
11051 | if (didWarnStateUpdateForUnmountedComponent[componentName]) {
|
11052 | return;
|
11053 | }
|
11054 | warningWithoutStack$1(false, "Can't perform a React state update on an unmounted component. This " + 'is a no-op, but it indicates a memory leak in your application. To ' + 'fix, cancel all subscriptions and asynchronous tasks in %s.%s', isClass ? 'the componentWillUnmount method' : 'a useEffect cleanup function', getStackByFiberInDevAndProd(fiber));
|
11055 | didWarnStateUpdateForUnmountedComponent[componentName] = true;
|
11056 | };
|
11057 |
|
11058 | warnAboutInvalidUpdates = function (instance) {
|
11059 | switch (phase) {
|
11060 | case 'getChildContext':
|
11061 | if (didWarnSetStateChildContext) {
|
11062 | return;
|
11063 | }
|
11064 | warningWithoutStack$1(false, 'setState(...): Cannot call setState() inside getChildContext()');
|
11065 | didWarnSetStateChildContext = true;
|
11066 | break;
|
11067 | case 'render':
|
11068 | if (didWarnAboutStateTransition) {
|
11069 | return;
|
11070 | }
|
11071 | warningWithoutStack$1(false, 'Cannot update during an existing state transition (such as within ' + '`render`). Render methods should be a pure function of props and state.');
|
11072 | didWarnAboutStateTransition = true;
|
11073 | break;
|
11074 | }
|
11075 | };
|
11076 | }
|
11077 |
|
11078 | var isWorking = false;
|
11079 |
|
11080 |
|
11081 | var nextUnitOfWork = null;
|
11082 | var nextRoot = null;
|
11083 |
|
11084 | var nextRenderExpirationTime = NoWork;
|
11085 | var nextLatestAbsoluteTimeoutMs = -1;
|
11086 | var nextRenderDidError = false;
|
11087 |
|
11088 |
|
11089 | var nextEffect = null;
|
11090 |
|
11091 | var isCommitting$1 = false;
|
11092 | var rootWithPendingPassiveEffects = null;
|
11093 | var passiveEffectCallbackHandle = null;
|
11094 | var passiveEffectCallback = null;
|
11095 |
|
11096 | var legacyErrorBoundariesThatAlreadyFailed = null;
|
11097 |
|
11098 |
|
11099 | var interruptedBy = null;
|
11100 |
|
11101 | var stashedWorkInProgressProperties = void 0;
|
11102 | var replayUnitOfWork = void 0;
|
11103 | var mayReplayFailedUnitOfWork = void 0;
|
11104 | var isReplayingFailedUnitOfWork = void 0;
|
11105 | var originalReplayError = void 0;
|
11106 | var rethrowOriginalError = void 0;
|
11107 | if (true && replayFailedUnitOfWorkWithInvokeGuardedCallback) {
|
11108 | stashedWorkInProgressProperties = null;
|
11109 | mayReplayFailedUnitOfWork = true;
|
11110 | isReplayingFailedUnitOfWork = false;
|
11111 | originalReplayError = null;
|
11112 | replayUnitOfWork = function (failedUnitOfWork, thrownValue, isYieldy) {
|
11113 | if (thrownValue !== null && typeof thrownValue === 'object' && typeof thrownValue.then === 'function') {
|
11114 |
|
11115 |
|
11116 |
|
11117 | return;
|
11118 | }
|
11119 |
|
11120 |
|
11121 | if (stashedWorkInProgressProperties === null) {
|
11122 |
|
11123 | warningWithoutStack$1(false, 'Could not replay rendering after an error. This is likely a bug in React. ' + 'Please file an issue.');
|
11124 | return;
|
11125 | }
|
11126 | assignFiberPropertiesInDEV(failedUnitOfWork, stashedWorkInProgressProperties);
|
11127 |
|
11128 | switch (failedUnitOfWork.tag) {
|
11129 | case HostRoot:
|
11130 | popHostContainer(failedUnitOfWork);
|
11131 | popTopLevelContextObject(failedUnitOfWork);
|
11132 | break;
|
11133 | case HostComponent:
|
11134 | popHostContext(failedUnitOfWork);
|
11135 | break;
|
11136 | case ClassComponent:
|
11137 | {
|
11138 | var Component = failedUnitOfWork.type;
|
11139 | if (isContextProvider(Component)) {
|
11140 | popContext(failedUnitOfWork);
|
11141 | }
|
11142 | break;
|
11143 | }
|
11144 | case HostPortal:
|
11145 | popHostContainer(failedUnitOfWork);
|
11146 | break;
|
11147 | case ContextProvider:
|
11148 | popProvider(failedUnitOfWork);
|
11149 | break;
|
11150 | }
|
11151 |
|
11152 | isReplayingFailedUnitOfWork = true;
|
11153 | originalReplayError = thrownValue;
|
11154 | invokeGuardedCallback(null, workLoop, null, isYieldy);
|
11155 | isReplayingFailedUnitOfWork = false;
|
11156 | originalReplayError = null;
|
11157 | if (hasCaughtError()) {
|
11158 | var replayError = clearCaughtError();
|
11159 | if (replayError != null && thrownValue != null) {
|
11160 | try {
|
11161 |
|
11162 |
|
11163 | if (replayError._suppressLogging) {
|
11164 |
|
11165 | thrownValue._suppressLogging = true;
|
11166 | }
|
11167 | } catch (inner) {
|
11168 |
|
11169 | }
|
11170 | }
|
11171 | } else {
|
11172 |
|
11173 |
|
11174 | nextUnitOfWork = failedUnitOfWork;
|
11175 | }
|
11176 | };
|
11177 | rethrowOriginalError = function () {
|
11178 | throw originalReplayError;
|
11179 | };
|
11180 | }
|
11181 |
|
11182 | function resetStack() {
|
11183 | if (nextUnitOfWork !== null) {
|
11184 | var interruptedWork = nextUnitOfWork.return;
|
11185 | while (interruptedWork !== null) {
|
11186 | unwindInterruptedWork(interruptedWork);
|
11187 | interruptedWork = interruptedWork.return;
|
11188 | }
|
11189 | }
|
11190 |
|
11191 | {
|
11192 | ReactStrictModeWarnings.discardPendingWarnings();
|
11193 | checkThatStackIsEmpty();
|
11194 | }
|
11195 |
|
11196 | nextRoot = null;
|
11197 | nextRenderExpirationTime = NoWork;
|
11198 | nextLatestAbsoluteTimeoutMs = -1;
|
11199 | nextRenderDidError = false;
|
11200 | nextUnitOfWork = null;
|
11201 | }
|
11202 |
|
11203 | function commitAllHostEffects() {
|
11204 | while (nextEffect !== null) {
|
11205 | {
|
11206 | setCurrentFiber(nextEffect);
|
11207 | }
|
11208 | recordEffect();
|
11209 |
|
11210 | var effectTag = nextEffect.effectTag;
|
11211 |
|
11212 | if (effectTag & ContentReset) {
|
11213 | commitResetTextContent(nextEffect);
|
11214 | }
|
11215 |
|
11216 | if (effectTag & Ref) {
|
11217 | var current = nextEffect.alternate;
|
11218 | if (current !== null) {
|
11219 | commitDetachRef(current);
|
11220 | }
|
11221 | }
|
11222 |
|
11223 |
|
11224 |
|
11225 |
|
11226 |
|
11227 | var primaryEffectTag = effectTag & (Placement | Update | Deletion);
|
11228 | switch (primaryEffectTag) {
|
11229 | case Placement:
|
11230 | {
|
11231 | commitPlacement(nextEffect);
|
11232 |
|
11233 |
|
11234 |
|
11235 |
|
11236 |
|
11237 | nextEffect.effectTag &= ~Placement;
|
11238 | break;
|
11239 | }
|
11240 | case PlacementAndUpdate:
|
11241 | {
|
11242 |
|
11243 | commitPlacement(nextEffect);
|
11244 |
|
11245 |
|
11246 | nextEffect.effectTag &= ~Placement;
|
11247 |
|
11248 |
|
11249 | var _current = nextEffect.alternate;
|
11250 | commitWork(_current, nextEffect);
|
11251 | break;
|
11252 | }
|
11253 | case Update:
|
11254 | {
|
11255 | var _current2 = nextEffect.alternate;
|
11256 | commitWork(_current2, nextEffect);
|
11257 | break;
|
11258 | }
|
11259 | case Deletion:
|
11260 | {
|
11261 | commitDeletion(nextEffect);
|
11262 | break;
|
11263 | }
|
11264 | }
|
11265 | nextEffect = nextEffect.nextEffect;
|
11266 | }
|
11267 |
|
11268 | {
|
11269 | resetCurrentFiber();
|
11270 | }
|
11271 | }
|
11272 |
|
11273 | function commitBeforeMutationLifecycles() {
|
11274 | while (nextEffect !== null) {
|
11275 | {
|
11276 | setCurrentFiber(nextEffect);
|
11277 | }
|
11278 |
|
11279 | var effectTag = nextEffect.effectTag;
|
11280 | if (effectTag & Snapshot) {
|
11281 | recordEffect();
|
11282 | var current = nextEffect.alternate;
|
11283 | commitBeforeMutationLifeCycles(current, nextEffect);
|
11284 | }
|
11285 |
|
11286 | nextEffect = nextEffect.nextEffect;
|
11287 | }
|
11288 |
|
11289 | {
|
11290 | resetCurrentFiber();
|
11291 | }
|
11292 | }
|
11293 |
|
11294 | function commitAllLifeCycles(finishedRoot, committedExpirationTime) {
|
11295 | {
|
11296 | ReactStrictModeWarnings.flushPendingUnsafeLifecycleWarnings();
|
11297 | ReactStrictModeWarnings.flushLegacyContextWarning();
|
11298 |
|
11299 | if (warnAboutDeprecatedLifecycles) {
|
11300 | ReactStrictModeWarnings.flushPendingDeprecationWarnings();
|
11301 | }
|
11302 | }
|
11303 | while (nextEffect !== null) {
|
11304 | {
|
11305 | setCurrentFiber(nextEffect);
|
11306 | }
|
11307 | var effectTag = nextEffect.effectTag;
|
11308 |
|
11309 | if (effectTag & (Update | Callback)) {
|
11310 | recordEffect();
|
11311 | var current = nextEffect.alternate;
|
11312 | commitLifeCycles(finishedRoot, current, nextEffect, committedExpirationTime);
|
11313 | }
|
11314 |
|
11315 | if (effectTag & Ref) {
|
11316 | recordEffect();
|
11317 | commitAttachRef(nextEffect);
|
11318 | }
|
11319 |
|
11320 | if (effectTag & Passive) {
|
11321 | rootWithPendingPassiveEffects = finishedRoot;
|
11322 | }
|
11323 |
|
11324 | nextEffect = nextEffect.nextEffect;
|
11325 | }
|
11326 | {
|
11327 | resetCurrentFiber();
|
11328 | }
|
11329 | }
|
11330 |
|
11331 | function commitPassiveEffects(root, firstEffect) {
|
11332 | rootWithPendingPassiveEffects = null;
|
11333 | passiveEffectCallbackHandle = null;
|
11334 | passiveEffectCallback = null;
|
11335 |
|
11336 |
|
11337 | var previousIsRendering = isRendering;
|
11338 | isRendering = true;
|
11339 |
|
11340 | var effect = firstEffect;
|
11341 | do {
|
11342 | {
|
11343 | setCurrentFiber(effect);
|
11344 | }
|
11345 |
|
11346 | if (effect.effectTag & Passive) {
|
11347 | var didError = false;
|
11348 | var error = void 0;
|
11349 | {
|
11350 | invokeGuardedCallback(null, commitPassiveHookEffects, null, effect);
|
11351 | if (hasCaughtError()) {
|
11352 | didError = true;
|
11353 | error = clearCaughtError();
|
11354 | }
|
11355 | }
|
11356 | if (didError) {
|
11357 | captureCommitPhaseError(effect, error);
|
11358 | }
|
11359 | }
|
11360 | effect = effect.nextEffect;
|
11361 | } while (effect !== null);
|
11362 | {
|
11363 | resetCurrentFiber();
|
11364 | }
|
11365 |
|
11366 | isRendering = previousIsRendering;
|
11367 |
|
11368 |
|
11369 | var rootExpirationTime = root.expirationTime;
|
11370 | if (rootExpirationTime !== NoWork) {
|
11371 | requestWork(root, rootExpirationTime);
|
11372 | }
|
11373 |
|
11374 | if (!isBatchingUpdates && !isRendering) {
|
11375 | performSyncWork();
|
11376 | }
|
11377 | }
|
11378 |
|
11379 | function isAlreadyFailedLegacyErrorBoundary(instance) {
|
11380 | return legacyErrorBoundariesThatAlreadyFailed !== null && legacyErrorBoundariesThatAlreadyFailed.has(instance);
|
11381 | }
|
11382 |
|
11383 | function markLegacyErrorBoundaryAsFailed(instance) {
|
11384 | if (legacyErrorBoundariesThatAlreadyFailed === null) {
|
11385 | legacyErrorBoundariesThatAlreadyFailed = new Set([instance]);
|
11386 | } else {
|
11387 | legacyErrorBoundariesThatAlreadyFailed.add(instance);
|
11388 | }
|
11389 | }
|
11390 |
|
11391 | function flushPassiveEffects() {
|
11392 | if (passiveEffectCallbackHandle !== null) {
|
11393 | cancelPassiveEffects(passiveEffectCallbackHandle);
|
11394 | }
|
11395 | if (passiveEffectCallback !== null) {
|
11396 |
|
11397 |
|
11398 | passiveEffectCallback();
|
11399 | }
|
11400 | }
|
11401 |
|
11402 | function commitRoot(root, finishedWork) {
|
11403 | isWorking = true;
|
11404 | isCommitting$1 = true;
|
11405 | startCommitTimer();
|
11406 |
|
11407 | !(root.current !== finishedWork) ? invariant(false, 'Cannot commit the same tree as before. This is probably a bug related to the return field. This error is likely caused by a bug in React. Please file an issue.') : void 0;
|
11408 | var committedExpirationTime = root.pendingCommitExpirationTime;
|
11409 | !(committedExpirationTime !== NoWork) ? invariant(false, 'Cannot commit an incomplete root. This error is likely caused by a bug in React. Please file an issue.') : void 0;
|
11410 | root.pendingCommitExpirationTime = NoWork;
|
11411 |
|
11412 |
|
11413 |
|
11414 |
|
11415 | var updateExpirationTimeBeforeCommit = finishedWork.expirationTime;
|
11416 | var childExpirationTimeBeforeCommit = finishedWork.childExpirationTime;
|
11417 | var earliestRemainingTimeBeforeCommit = childExpirationTimeBeforeCommit > updateExpirationTimeBeforeCommit ? childExpirationTimeBeforeCommit : updateExpirationTimeBeforeCommit;
|
11418 | markCommittedPriorityLevels(root, earliestRemainingTimeBeforeCommit);
|
11419 |
|
11420 | var prevInteractions = null;
|
11421 | if (enableSchedulerTracing) {
|
11422 |
|
11423 |
|
11424 | prevInteractions = __interactionsRef.current;
|
11425 | __interactionsRef.current = root.memoizedInteractions;
|
11426 | }
|
11427 |
|
11428 |
|
11429 | ReactCurrentOwner$1.current = null;
|
11430 |
|
11431 | var firstEffect = void 0;
|
11432 | if (finishedWork.effectTag > PerformedWork) {
|
11433 |
|
11434 |
|
11435 |
|
11436 |
|
11437 | if (finishedWork.lastEffect !== null) {
|
11438 | finishedWork.lastEffect.nextEffect = finishedWork;
|
11439 | firstEffect = finishedWork.firstEffect;
|
11440 | } else {
|
11441 | firstEffect = finishedWork;
|
11442 | }
|
11443 | } else {
|
11444 |
|
11445 | firstEffect = finishedWork.firstEffect;
|
11446 | }
|
11447 |
|
11448 | prepareForCommit(root.containerInfo);
|
11449 |
|
11450 |
|
11451 | nextEffect = firstEffect;
|
11452 | startCommitSnapshotEffectsTimer();
|
11453 | while (nextEffect !== null) {
|
11454 | var didError = false;
|
11455 | var error = void 0;
|
11456 | {
|
11457 | invokeGuardedCallback(null, commitBeforeMutationLifecycles, null);
|
11458 | if (hasCaughtError()) {
|
11459 | didError = true;
|
11460 | error = clearCaughtError();
|
11461 | }
|
11462 | }
|
11463 | if (didError) {
|
11464 | !(nextEffect !== null) ? invariant(false, 'Should have next effect. This error is likely caused by a bug in React. Please file an issue.') : void 0;
|
11465 | captureCommitPhaseError(nextEffect, error);
|
11466 |
|
11467 | if (nextEffect !== null) {
|
11468 | nextEffect = nextEffect.nextEffect;
|
11469 | }
|
11470 | }
|
11471 | }
|
11472 | stopCommitSnapshotEffectsTimer();
|
11473 |
|
11474 | if (enableProfilerTimer) {
|
11475 |
|
11476 |
|
11477 | recordCommitTime();
|
11478 | }
|
11479 |
|
11480 |
|
11481 |
|
11482 |
|
11483 | nextEffect = firstEffect;
|
11484 | startCommitHostEffectsTimer();
|
11485 | while (nextEffect !== null) {
|
11486 | var _didError = false;
|
11487 | var _error = void 0;
|
11488 | {
|
11489 | invokeGuardedCallback(null, commitAllHostEffects, null);
|
11490 | if (hasCaughtError()) {
|
11491 | _didError = true;
|
11492 | _error = clearCaughtError();
|
11493 | }
|
11494 | }
|
11495 | if (_didError) {
|
11496 | !(nextEffect !== null) ? invariant(false, 'Should have next effect. This error is likely caused by a bug in React. Please file an issue.') : void 0;
|
11497 | captureCommitPhaseError(nextEffect, _error);
|
11498 |
|
11499 | if (nextEffect !== null) {
|
11500 | nextEffect = nextEffect.nextEffect;
|
11501 | }
|
11502 | }
|
11503 | }
|
11504 | stopCommitHostEffectsTimer();
|
11505 |
|
11506 | resetAfterCommit(root.containerInfo);
|
11507 |
|
11508 |
|
11509 |
|
11510 |
|
11511 |
|
11512 | root.current = finishedWork;
|
11513 |
|
11514 |
|
11515 |
|
11516 |
|
11517 |
|
11518 | nextEffect = firstEffect;
|
11519 | startCommitLifeCyclesTimer();
|
11520 | while (nextEffect !== null) {
|
11521 | var _didError2 = false;
|
11522 | var _error2 = void 0;
|
11523 | {
|
11524 | invokeGuardedCallback(null, commitAllLifeCycles, null, root, committedExpirationTime);
|
11525 | if (hasCaughtError()) {
|
11526 | _didError2 = true;
|
11527 | _error2 = clearCaughtError();
|
11528 | }
|
11529 | }
|
11530 | if (_didError2) {
|
11531 | !(nextEffect !== null) ? invariant(false, 'Should have next effect. This error is likely caused by a bug in React. Please file an issue.') : void 0;
|
11532 | captureCommitPhaseError(nextEffect, _error2);
|
11533 | if (nextEffect !== null) {
|
11534 | nextEffect = nextEffect.nextEffect;
|
11535 | }
|
11536 | }
|
11537 | }
|
11538 |
|
11539 | if (firstEffect !== null && rootWithPendingPassiveEffects !== null) {
|
11540 |
|
11541 |
|
11542 |
|
11543 |
|
11544 | var callback = commitPassiveEffects.bind(null, root, firstEffect);
|
11545 | if (enableSchedulerTracing) {
|
11546 |
|
11547 |
|
11548 |
|
11549 | callback = unstable_wrap(callback);
|
11550 | }
|
11551 | passiveEffectCallbackHandle = unstable_runWithPriority(unstable_NormalPriority, function () {
|
11552 | return schedulePassiveEffects(callback);
|
11553 | });
|
11554 | passiveEffectCallback = callback;
|
11555 | }
|
11556 |
|
11557 | isCommitting$1 = false;
|
11558 | isWorking = false;
|
11559 | stopCommitLifeCyclesTimer();
|
11560 | stopCommitTimer();
|
11561 | onCommitRoot(finishedWork.stateNode);
|
11562 | if (true && ReactFiberInstrumentation_1.debugTool) {
|
11563 | ReactFiberInstrumentation_1.debugTool.onCommitWork(finishedWork);
|
11564 | }
|
11565 |
|
11566 | var updateExpirationTimeAfterCommit = finishedWork.expirationTime;
|
11567 | var childExpirationTimeAfterCommit = finishedWork.childExpirationTime;
|
11568 | var earliestRemainingTimeAfterCommit = childExpirationTimeAfterCommit > updateExpirationTimeAfterCommit ? childExpirationTimeAfterCommit : updateExpirationTimeAfterCommit;
|
11569 | if (earliestRemainingTimeAfterCommit === NoWork) {
|
11570 |
|
11571 |
|
11572 | legacyErrorBoundariesThatAlreadyFailed = null;
|
11573 | }
|
11574 | onCommit(root, earliestRemainingTimeAfterCommit);
|
11575 |
|
11576 | if (enableSchedulerTracing) {
|
11577 | __interactionsRef.current = prevInteractions;
|
11578 |
|
11579 | var subscriber = void 0;
|
11580 |
|
11581 | try {
|
11582 | subscriber = __subscriberRef.current;
|
11583 | if (subscriber !== null && root.memoizedInteractions.size > 0) {
|
11584 | var threadID = computeThreadID(committedExpirationTime, root.interactionThreadID);
|
11585 | subscriber.onWorkStopped(root.memoizedInteractions, threadID);
|
11586 | }
|
11587 | } catch (error) {
|
11588 |
|
11589 |
|
11590 | if (!hasUnhandledError) {
|
11591 | hasUnhandledError = true;
|
11592 | unhandledError = error;
|
11593 | }
|
11594 | } finally {
|
11595 |
|
11596 |
|
11597 |
|
11598 | var pendingInteractionMap = root.pendingInteractionMap;
|
11599 | pendingInteractionMap.forEach(function (scheduledInteractions, scheduledExpirationTime) {
|
11600 |
|
11601 |
|
11602 |
|
11603 | if (scheduledExpirationTime > earliestRemainingTimeAfterCommit) {
|
11604 | pendingInteractionMap.delete(scheduledExpirationTime);
|
11605 |
|
11606 | scheduledInteractions.forEach(function (interaction) {
|
11607 | interaction.__count--;
|
11608 |
|
11609 | if (subscriber !== null && interaction.__count === 0) {
|
11610 | try {
|
11611 | subscriber.onInteractionScheduledWorkCompleted(interaction);
|
11612 | } catch (error) {
|
11613 |
|
11614 |
|
11615 | if (!hasUnhandledError) {
|
11616 | hasUnhandledError = true;
|
11617 | unhandledError = error;
|
11618 | }
|
11619 | }
|
11620 | }
|
11621 | });
|
11622 | }
|
11623 | });
|
11624 | }
|
11625 | }
|
11626 | }
|
11627 |
|
11628 | function resetChildExpirationTime(workInProgress, renderTime) {
|
11629 | if (renderTime !== Never && workInProgress.childExpirationTime === Never) {
|
11630 |
|
11631 |
|
11632 | return;
|
11633 | }
|
11634 |
|
11635 | var newChildExpirationTime = NoWork;
|
11636 |
|
11637 |
|
11638 | if (enableProfilerTimer && workInProgress.mode & ProfileMode) {
|
11639 |
|
11640 |
|
11641 | var actualDuration = workInProgress.actualDuration;
|
11642 | var treeBaseDuration = workInProgress.selfBaseDuration;
|
11643 |
|
11644 |
|
11645 |
|
11646 |
|
11647 |
|
11648 |
|
11649 |
|
11650 |
|
11651 | var shouldBubbleActualDurations = workInProgress.alternate === null || workInProgress.child !== workInProgress.alternate.child;
|
11652 |
|
11653 | var child = workInProgress.child;
|
11654 | while (child !== null) {
|
11655 | var childUpdateExpirationTime = child.expirationTime;
|
11656 | var childChildExpirationTime = child.childExpirationTime;
|
11657 | if (childUpdateExpirationTime > newChildExpirationTime) {
|
11658 | newChildExpirationTime = childUpdateExpirationTime;
|
11659 | }
|
11660 | if (childChildExpirationTime > newChildExpirationTime) {
|
11661 | newChildExpirationTime = childChildExpirationTime;
|
11662 | }
|
11663 | if (shouldBubbleActualDurations) {
|
11664 | actualDuration += child.actualDuration;
|
11665 | }
|
11666 | treeBaseDuration += child.treeBaseDuration;
|
11667 | child = child.sibling;
|
11668 | }
|
11669 | workInProgress.actualDuration = actualDuration;
|
11670 | workInProgress.treeBaseDuration = treeBaseDuration;
|
11671 | } else {
|
11672 | var _child = workInProgress.child;
|
11673 | while (_child !== null) {
|
11674 | var _childUpdateExpirationTime = _child.expirationTime;
|
11675 | var _childChildExpirationTime = _child.childExpirationTime;
|
11676 | if (_childUpdateExpirationTime > newChildExpirationTime) {
|
11677 | newChildExpirationTime = _childUpdateExpirationTime;
|
11678 | }
|
11679 | if (_childChildExpirationTime > newChildExpirationTime) {
|
11680 | newChildExpirationTime = _childChildExpirationTime;
|
11681 | }
|
11682 | _child = _child.sibling;
|
11683 | }
|
11684 | }
|
11685 |
|
11686 | workInProgress.childExpirationTime = newChildExpirationTime;
|
11687 | }
|
11688 |
|
11689 | function completeUnitOfWork(workInProgress) {
|
11690 |
|
11691 |
|
11692 |
|
11693 | while (true) {
|
11694 |
|
11695 |
|
11696 |
|
11697 |
|
11698 | var current = workInProgress.alternate;
|
11699 | {
|
11700 | setCurrentFiber(workInProgress);
|
11701 | }
|
11702 |
|
11703 | var returnFiber = workInProgress.return;
|
11704 | var siblingFiber = workInProgress.sibling;
|
11705 |
|
11706 | if ((workInProgress.effectTag & Incomplete) === NoEffect) {
|
11707 | if (true && replayFailedUnitOfWorkWithInvokeGuardedCallback) {
|
11708 |
|
11709 | mayReplayFailedUnitOfWork = false;
|
11710 | }
|
11711 |
|
11712 |
|
11713 | nextUnitOfWork = workInProgress;
|
11714 | if (enableProfilerTimer) {
|
11715 | if (workInProgress.mode & ProfileMode) {
|
11716 | startProfilerTimer(workInProgress);
|
11717 | }
|
11718 | nextUnitOfWork = completeWork(current, workInProgress, nextRenderExpirationTime);
|
11719 | if (workInProgress.mode & ProfileMode) {
|
11720 |
|
11721 | stopProfilerTimerIfRunningAndRecordDelta(workInProgress, false);
|
11722 | }
|
11723 | } else {
|
11724 | nextUnitOfWork = completeWork(current, workInProgress, nextRenderExpirationTime);
|
11725 | }
|
11726 | if (true && replayFailedUnitOfWorkWithInvokeGuardedCallback) {
|
11727 |
|
11728 | mayReplayFailedUnitOfWork = true;
|
11729 | }
|
11730 | stopWorkTimer(workInProgress);
|
11731 | resetChildExpirationTime(workInProgress, nextRenderExpirationTime);
|
11732 | {
|
11733 | resetCurrentFiber();
|
11734 | }
|
11735 |
|
11736 | if (nextUnitOfWork !== null) {
|
11737 |
|
11738 | return nextUnitOfWork;
|
11739 | }
|
11740 |
|
11741 | if (returnFiber !== null &&
|
11742 |
|
11743 | (returnFiber.effectTag & Incomplete) === NoEffect) {
|
11744 |
|
11745 |
|
11746 |
|
11747 | if (returnFiber.firstEffect === null) {
|
11748 | returnFiber.firstEffect = workInProgress.firstEffect;
|
11749 | }
|
11750 | if (workInProgress.lastEffect !== null) {
|
11751 | if (returnFiber.lastEffect !== null) {
|
11752 | returnFiber.lastEffect.nextEffect = workInProgress.firstEffect;
|
11753 | }
|
11754 | returnFiber.lastEffect = workInProgress.lastEffect;
|
11755 | }
|
11756 |
|
11757 |
|
11758 |
|
11759 |
|
11760 |
|
11761 |
|
11762 |
|
11763 | var effectTag = workInProgress.effectTag;
|
11764 |
|
11765 |
|
11766 | if (effectTag > PerformedWork) {
|
11767 | if (returnFiber.lastEffect !== null) {
|
11768 | returnFiber.lastEffect.nextEffect = workInProgress;
|
11769 | } else {
|
11770 | returnFiber.firstEffect = workInProgress;
|
11771 | }
|
11772 | returnFiber.lastEffect = workInProgress;
|
11773 | }
|
11774 | }
|
11775 |
|
11776 | if (true && ReactFiberInstrumentation_1.debugTool) {
|
11777 | ReactFiberInstrumentation_1.debugTool.onCompleteWork(workInProgress);
|
11778 | }
|
11779 |
|
11780 | if (siblingFiber !== null) {
|
11781 |
|
11782 | return siblingFiber;
|
11783 | } else if (returnFiber !== null) {
|
11784 |
|
11785 | workInProgress = returnFiber;
|
11786 | continue;
|
11787 | } else {
|
11788 |
|
11789 | return null;
|
11790 | }
|
11791 | } else {
|
11792 | if (enableProfilerTimer && workInProgress.mode & ProfileMode) {
|
11793 |
|
11794 | stopProfilerTimerIfRunningAndRecordDelta(workInProgress, false);
|
11795 |
|
11796 |
|
11797 | var actualDuration = workInProgress.actualDuration;
|
11798 | var child = workInProgress.child;
|
11799 | while (child !== null) {
|
11800 | actualDuration += child.actualDuration;
|
11801 | child = child.sibling;
|
11802 | }
|
11803 | workInProgress.actualDuration = actualDuration;
|
11804 | }
|
11805 |
|
11806 |
|
11807 |
|
11808 |
|
11809 | var next = unwindWork(workInProgress, nextRenderExpirationTime);
|
11810 |
|
11811 | if (workInProgress.effectTag & DidCapture) {
|
11812 |
|
11813 | stopFailedWorkTimer(workInProgress);
|
11814 | } else {
|
11815 | stopWorkTimer(workInProgress);
|
11816 | }
|
11817 |
|
11818 | {
|
11819 | resetCurrentFiber();
|
11820 | }
|
11821 |
|
11822 | if (next !== null) {
|
11823 | stopWorkTimer(workInProgress);
|
11824 | if (true && ReactFiberInstrumentation_1.debugTool) {
|
11825 | ReactFiberInstrumentation_1.debugTool.onCompleteWork(workInProgress);
|
11826 | }
|
11827 |
|
11828 |
|
11829 |
|
11830 |
|
11831 |
|
11832 | next.effectTag &= HostEffectMask;
|
11833 | return next;
|
11834 | }
|
11835 |
|
11836 | if (returnFiber !== null) {
|
11837 |
|
11838 | returnFiber.firstEffect = returnFiber.lastEffect = null;
|
11839 | returnFiber.effectTag |= Incomplete;
|
11840 | }
|
11841 |
|
11842 | if (true && ReactFiberInstrumentation_1.debugTool) {
|
11843 | ReactFiberInstrumentation_1.debugTool.onCompleteWork(workInProgress);
|
11844 | }
|
11845 |
|
11846 | if (siblingFiber !== null) {
|
11847 |
|
11848 | return siblingFiber;
|
11849 | } else if (returnFiber !== null) {
|
11850 |
|
11851 | workInProgress = returnFiber;
|
11852 | continue;
|
11853 | } else {
|
11854 | return null;
|
11855 | }
|
11856 | }
|
11857 | }
|
11858 |
|
11859 |
|
11860 |
|
11861 |
|
11862 | return null;
|
11863 | }
|
11864 |
|
11865 | function performUnitOfWork(workInProgress) {
|
11866 |
|
11867 |
|
11868 |
|
11869 |
|
11870 | var current = workInProgress.alternate;
|
11871 |
|
11872 |
|
11873 | startWorkTimer(workInProgress);
|
11874 | {
|
11875 | setCurrentFiber(workInProgress);
|
11876 | }
|
11877 |
|
11878 | if (true && replayFailedUnitOfWorkWithInvokeGuardedCallback) {
|
11879 | stashedWorkInProgressProperties = assignFiberPropertiesInDEV(stashedWorkInProgressProperties, workInProgress);
|
11880 | }
|
11881 |
|
11882 | var next = void 0;
|
11883 | if (enableProfilerTimer) {
|
11884 | if (workInProgress.mode & ProfileMode) {
|
11885 | startProfilerTimer(workInProgress);
|
11886 | }
|
11887 |
|
11888 | next = beginWork(current, workInProgress, nextRenderExpirationTime);
|
11889 | workInProgress.memoizedProps = workInProgress.pendingProps;
|
11890 |
|
11891 | if (workInProgress.mode & ProfileMode) {
|
11892 |
|
11893 | stopProfilerTimerIfRunningAndRecordDelta(workInProgress, true);
|
11894 | }
|
11895 | } else {
|
11896 | next = beginWork(current, workInProgress, nextRenderExpirationTime);
|
11897 | workInProgress.memoizedProps = workInProgress.pendingProps;
|
11898 | }
|
11899 |
|
11900 | {
|
11901 | resetCurrentFiber();
|
11902 | if (isReplayingFailedUnitOfWork) {
|
11903 |
|
11904 |
|
11905 |
|
11906 |
|
11907 | rethrowOriginalError();
|
11908 | }
|
11909 | }
|
11910 | if (true && ReactFiberInstrumentation_1.debugTool) {
|
11911 | ReactFiberInstrumentation_1.debugTool.onBeginWork(workInProgress);
|
11912 | }
|
11913 |
|
11914 | if (next === null) {
|
11915 |
|
11916 | next = completeUnitOfWork(workInProgress);
|
11917 | }
|
11918 |
|
11919 | ReactCurrentOwner$1.current = null;
|
11920 |
|
11921 | return next;
|
11922 | }
|
11923 |
|
11924 | function workLoop(isYieldy) {
|
11925 | if (!isYieldy) {
|
11926 |
|
11927 | while (nextUnitOfWork !== null) {
|
11928 | nextUnitOfWork = performUnitOfWork(nextUnitOfWork);
|
11929 | }
|
11930 | } else {
|
11931 |
|
11932 | while (nextUnitOfWork !== null && !shouldYieldToRenderer()) {
|
11933 | nextUnitOfWork = performUnitOfWork(nextUnitOfWork);
|
11934 | }
|
11935 | }
|
11936 | }
|
11937 |
|
11938 | function renderRoot(root, isYieldy) {
|
11939 | !!isWorking ? invariant(false, 'renderRoot was called recursively. This error is likely caused by a bug in React. Please file an issue.') : void 0;
|
11940 |
|
11941 | flushPassiveEffects();
|
11942 |
|
11943 | isWorking = true;
|
11944 | var previousDispatcher = ReactCurrentDispatcher.current;
|
11945 | ReactCurrentDispatcher.current = ContextOnlyDispatcher;
|
11946 |
|
11947 | var expirationTime = root.nextExpirationTimeToWorkOn;
|
11948 |
|
11949 |
|
11950 |
|
11951 | if (expirationTime !== nextRenderExpirationTime || root !== nextRoot || nextUnitOfWork === null) {
|
11952 |
|
11953 | resetStack();
|
11954 | nextRoot = root;
|
11955 | nextRenderExpirationTime = expirationTime;
|
11956 | nextUnitOfWork = createWorkInProgress(nextRoot.current, null, nextRenderExpirationTime);
|
11957 | root.pendingCommitExpirationTime = NoWork;
|
11958 |
|
11959 | if (enableSchedulerTracing) {
|
11960 |
|
11961 |
|
11962 | var interactions = new Set();
|
11963 | root.pendingInteractionMap.forEach(function (scheduledInteractions, scheduledExpirationTime) {
|
11964 | if (scheduledExpirationTime >= expirationTime) {
|
11965 | scheduledInteractions.forEach(function (interaction) {
|
11966 | return interactions.add(interaction);
|
11967 | });
|
11968 | }
|
11969 | });
|
11970 |
|
11971 |
|
11972 |
|
11973 |
|
11974 |
|
11975 | root.memoizedInteractions = interactions;
|
11976 |
|
11977 | if (interactions.size > 0) {
|
11978 | var subscriber = __subscriberRef.current;
|
11979 | if (subscriber !== null) {
|
11980 | var threadID = computeThreadID(expirationTime, root.interactionThreadID);
|
11981 | try {
|
11982 | subscriber.onWorkStarted(interactions, threadID);
|
11983 | } catch (error) {
|
11984 |
|
11985 |
|
11986 |
|
11987 | if (!hasUnhandledError) {
|
11988 | hasUnhandledError = true;
|
11989 | unhandledError = error;
|
11990 | }
|
11991 | }
|
11992 | }
|
11993 | }
|
11994 | }
|
11995 | }
|
11996 |
|
11997 | var prevInteractions = null;
|
11998 | if (enableSchedulerTracing) {
|
11999 |
|
12000 |
|
12001 | prevInteractions = __interactionsRef.current;
|
12002 | __interactionsRef.current = root.memoizedInteractions;
|
12003 | }
|
12004 |
|
12005 | var didFatal = false;
|
12006 |
|
12007 | startWorkLoopTimer(nextUnitOfWork);
|
12008 |
|
12009 | do {
|
12010 | try {
|
12011 | workLoop(isYieldy);
|
12012 | } catch (thrownValue) {
|
12013 | resetContextDependences();
|
12014 | resetHooks();
|
12015 |
|
12016 |
|
12017 |
|
12018 | var mayReplay = void 0;
|
12019 | if (true && replayFailedUnitOfWorkWithInvokeGuardedCallback) {
|
12020 | mayReplay = mayReplayFailedUnitOfWork;
|
12021 | mayReplayFailedUnitOfWork = true;
|
12022 | }
|
12023 |
|
12024 | if (nextUnitOfWork === null) {
|
12025 |
|
12026 | didFatal = true;
|
12027 | onUncaughtError(thrownValue);
|
12028 | } else {
|
12029 | if (enableProfilerTimer && nextUnitOfWork.mode & ProfileMode) {
|
12030 |
|
12031 |
|
12032 | stopProfilerTimerIfRunningAndRecordDelta(nextUnitOfWork, true);
|
12033 | }
|
12034 |
|
12035 | {
|
12036 |
|
12037 |
|
12038 | resetCurrentlyProcessingQueue();
|
12039 | }
|
12040 |
|
12041 | if (true && replayFailedUnitOfWorkWithInvokeGuardedCallback) {
|
12042 | if (mayReplay) {
|
12043 | var failedUnitOfWork = nextUnitOfWork;
|
12044 | replayUnitOfWork(failedUnitOfWork, thrownValue, isYieldy);
|
12045 | }
|
12046 | }
|
12047 |
|
12048 |
|
12049 |
|
12050 |
|
12051 | !(nextUnitOfWork !== null) ? invariant(false, 'Failed to replay rendering after an error. This is likely caused by a bug in React. Please file an issue with a reproducing case to help us find it.') : void 0;
|
12052 |
|
12053 | var sourceFiber = nextUnitOfWork;
|
12054 | var returnFiber = sourceFiber.return;
|
12055 | if (returnFiber === null) {
|
12056 |
|
12057 |
|
12058 |
|
12059 |
|
12060 |
|
12061 |
|
12062 | didFatal = true;
|
12063 | onUncaughtError(thrownValue);
|
12064 | } else {
|
12065 | throwException(root, returnFiber, sourceFiber, thrownValue, nextRenderExpirationTime);
|
12066 | nextUnitOfWork = completeUnitOfWork(sourceFiber);
|
12067 | continue;
|
12068 | }
|
12069 | }
|
12070 | }
|
12071 | break;
|
12072 | } while (true);
|
12073 |
|
12074 | if (enableSchedulerTracing) {
|
12075 |
|
12076 | __interactionsRef.current = prevInteractions;
|
12077 | }
|
12078 |
|
12079 |
|
12080 | isWorking = false;
|
12081 | ReactCurrentDispatcher.current = previousDispatcher;
|
12082 | resetContextDependences();
|
12083 | resetHooks();
|
12084 |
|
12085 |
|
12086 | if (didFatal) {
|
12087 | var _didCompleteRoot = false;
|
12088 | stopWorkLoopTimer(interruptedBy, _didCompleteRoot);
|
12089 | interruptedBy = null;
|
12090 |
|
12091 | {
|
12092 | resetStackAfterFatalErrorInDev();
|
12093 | }
|
12094 |
|
12095 |
|
12096 |
|
12097 | nextRoot = null;
|
12098 | onFatal(root);
|
12099 | return;
|
12100 | }
|
12101 |
|
12102 | if (nextUnitOfWork !== null) {
|
12103 |
|
12104 |
|
12105 |
|
12106 |
|
12107 | var _didCompleteRoot2 = false;
|
12108 | stopWorkLoopTimer(interruptedBy, _didCompleteRoot2);
|
12109 | interruptedBy = null;
|
12110 | onYield(root);
|
12111 | return;
|
12112 | }
|
12113 |
|
12114 |
|
12115 | var didCompleteRoot = true;
|
12116 | stopWorkLoopTimer(interruptedBy, didCompleteRoot);
|
12117 | var rootWorkInProgress = root.current.alternate;
|
12118 | !(rootWorkInProgress !== null) ? invariant(false, 'Finished root should have a work-in-progress. This error is likely caused by a bug in React. Please file an issue.') : void 0;
|
12119 |
|
12120 |
|
12121 |
|
12122 |
|
12123 | nextRoot = null;
|
12124 | interruptedBy = null;
|
12125 |
|
12126 | if (nextRenderDidError) {
|
12127 |
|
12128 | if (hasLowerPriorityWork(root, expirationTime)) {
|
12129 |
|
12130 |
|
12131 |
|
12132 |
|
12133 |
|
12134 | markSuspendedPriorityLevel(root, expirationTime);
|
12135 | var suspendedExpirationTime = expirationTime;
|
12136 | var rootExpirationTime = root.expirationTime;
|
12137 | onSuspend(root, rootWorkInProgress, suspendedExpirationTime, rootExpirationTime, -1
|
12138 | );
|
12139 | return;
|
12140 | } else if (
|
12141 |
|
12142 |
|
12143 |
|
12144 |
|
12145 | !root.didError && isYieldy) {
|
12146 | root.didError = true;
|
12147 | var _suspendedExpirationTime = root.nextExpirationTimeToWorkOn = expirationTime;
|
12148 | var _rootExpirationTime = root.expirationTime = Sync;
|
12149 | onSuspend(root, rootWorkInProgress, _suspendedExpirationTime, _rootExpirationTime, -1
|
12150 | );
|
12151 | return;
|
12152 | }
|
12153 | }
|
12154 |
|
12155 | if (isYieldy && nextLatestAbsoluteTimeoutMs !== -1) {
|
12156 |
|
12157 | var _suspendedExpirationTime2 = expirationTime;
|
12158 | markSuspendedPriorityLevel(root, _suspendedExpirationTime2);
|
12159 |
|
12160 |
|
12161 |
|
12162 |
|
12163 | var earliestExpirationTime = findEarliestOutstandingPriorityLevel(root, expirationTime);
|
12164 | var earliestExpirationTimeMs = expirationTimeToMs(earliestExpirationTime);
|
12165 | if (earliestExpirationTimeMs < nextLatestAbsoluteTimeoutMs) {
|
12166 | nextLatestAbsoluteTimeoutMs = earliestExpirationTimeMs;
|
12167 | }
|
12168 |
|
12169 |
|
12170 |
|
12171 |
|
12172 |
|
12173 | var currentTimeMs = expirationTimeToMs(requestCurrentTime());
|
12174 | var msUntilTimeout = nextLatestAbsoluteTimeoutMs - currentTimeMs;
|
12175 | msUntilTimeout = msUntilTimeout < 0 ? 0 : msUntilTimeout;
|
12176 |
|
12177 |
|
12178 |
|
12179 | var _rootExpirationTime2 = root.expirationTime;
|
12180 | onSuspend(root, rootWorkInProgress, _suspendedExpirationTime2, _rootExpirationTime2, msUntilTimeout);
|
12181 | return;
|
12182 | }
|
12183 |
|
12184 |
|
12185 | onComplete(root, rootWorkInProgress, expirationTime);
|
12186 | }
|
12187 |
|
12188 | function captureCommitPhaseError(sourceFiber, value) {
|
12189 | var expirationTime = Sync;
|
12190 | var fiber = sourceFiber.return;
|
12191 | while (fiber !== null) {
|
12192 | switch (fiber.tag) {
|
12193 | case ClassComponent:
|
12194 | var ctor = fiber.type;
|
12195 | var instance = fiber.stateNode;
|
12196 | if (typeof ctor.getDerivedStateFromError === 'function' || typeof instance.componentDidCatch === 'function' && !isAlreadyFailedLegacyErrorBoundary(instance)) {
|
12197 | var errorInfo = createCapturedValue(value, sourceFiber);
|
12198 | var update = createClassErrorUpdate(fiber, errorInfo, expirationTime);
|
12199 | enqueueUpdate(fiber, update);
|
12200 | scheduleWork(fiber, expirationTime);
|
12201 | return;
|
12202 | }
|
12203 | break;
|
12204 | case HostRoot:
|
12205 | {
|
12206 | var _errorInfo = createCapturedValue(value, sourceFiber);
|
12207 | var _update = createRootErrorUpdate(fiber, _errorInfo, expirationTime);
|
12208 | enqueueUpdate(fiber, _update);
|
12209 | scheduleWork(fiber, expirationTime);
|
12210 | return;
|
12211 | }
|
12212 | }
|
12213 | fiber = fiber.return;
|
12214 | }
|
12215 |
|
12216 | if (sourceFiber.tag === HostRoot) {
|
12217 |
|
12218 |
|
12219 | var rootFiber = sourceFiber;
|
12220 | var _errorInfo2 = createCapturedValue(value, rootFiber);
|
12221 | var _update2 = createRootErrorUpdate(rootFiber, _errorInfo2, expirationTime);
|
12222 | enqueueUpdate(rootFiber, _update2);
|
12223 | scheduleWork(rootFiber, expirationTime);
|
12224 | }
|
12225 | }
|
12226 |
|
12227 | function computeThreadID(expirationTime, interactionThreadID) {
|
12228 |
|
12229 | return expirationTime * 1000 + interactionThreadID;
|
12230 | }
|
12231 |
|
12232 | function computeExpirationForFiber(currentTime, fiber) {
|
12233 | var priorityLevel = unstable_getCurrentPriorityLevel();
|
12234 |
|
12235 | var expirationTime = void 0;
|
12236 | if ((fiber.mode & ConcurrentMode) === NoContext) {
|
12237 |
|
12238 | expirationTime = Sync;
|
12239 | } else if (isWorking && !isCommitting$1) {
|
12240 |
|
12241 | expirationTime = nextRenderExpirationTime;
|
12242 | } else {
|
12243 | switch (priorityLevel) {
|
12244 | case unstable_ImmediatePriority:
|
12245 | expirationTime = Sync;
|
12246 | break;
|
12247 | case unstable_UserBlockingPriority:
|
12248 | expirationTime = computeInteractiveExpiration(currentTime);
|
12249 | break;
|
12250 | case unstable_NormalPriority:
|
12251 |
|
12252 | expirationTime = computeAsyncExpiration(currentTime);
|
12253 | break;
|
12254 | case unstable_LowPriority:
|
12255 | case unstable_IdlePriority:
|
12256 | expirationTime = Never;
|
12257 | break;
|
12258 | default:
|
12259 | invariant(false, 'Unknown priority level. This error is likely caused by a bug in React. Please file an issue.');
|
12260 | }
|
12261 |
|
12262 |
|
12263 |
|
12264 | if (nextRoot !== null && expirationTime === nextRenderExpirationTime) {
|
12265 | expirationTime -= 1;
|
12266 | }
|
12267 | }
|
12268 |
|
12269 |
|
12270 |
|
12271 |
|
12272 |
|
12273 | return expirationTime;
|
12274 | }
|
12275 |
|
12276 | function renderDidSuspend(root, absoluteTimeoutMs, suspendedTime) {
|
12277 |
|
12278 | if (absoluteTimeoutMs >= 0 && nextLatestAbsoluteTimeoutMs < absoluteTimeoutMs) {
|
12279 | nextLatestAbsoluteTimeoutMs = absoluteTimeoutMs;
|
12280 | }
|
12281 | }
|
12282 |
|
12283 | function renderDidError() {
|
12284 | nextRenderDidError = true;
|
12285 | }
|
12286 |
|
12287 | function pingSuspendedRoot(root, thenable, pingTime) {
|
12288 |
|
12289 |
|
12290 |
|
12291 | var pingCache = root.pingCache;
|
12292 | if (pingCache !== null) {
|
12293 |
|
12294 |
|
12295 | pingCache.delete(thenable);
|
12296 | }
|
12297 |
|
12298 | if (nextRoot !== null && nextRenderExpirationTime === pingTime) {
|
12299 |
|
12300 |
|
12301 | nextRoot = null;
|
12302 | } else {
|
12303 |
|
12304 | if (isPriorityLevelSuspended(root, pingTime)) {
|
12305 |
|
12306 | markPingedPriorityLevel(root, pingTime);
|
12307 | var rootExpirationTime = root.expirationTime;
|
12308 | if (rootExpirationTime !== NoWork) {
|
12309 | requestWork(root, rootExpirationTime);
|
12310 | }
|
12311 | }
|
12312 | }
|
12313 | }
|
12314 |
|
12315 | function retryTimedOutBoundary(boundaryFiber, thenable) {
|
12316 |
|
12317 |
|
12318 |
|
12319 | var retryCache = void 0;
|
12320 | if (enableSuspenseServerRenderer) {
|
12321 | switch (boundaryFiber.tag) {
|
12322 | case SuspenseComponent:
|
12323 | retryCache = boundaryFiber.stateNode;
|
12324 | break;
|
12325 | case DehydratedSuspenseComponent:
|
12326 | retryCache = boundaryFiber.memoizedState;
|
12327 | break;
|
12328 | default:
|
12329 | invariant(false, 'Pinged unknown suspense boundary type. This is probably a bug in React.');
|
12330 | }
|
12331 | } else {
|
12332 | retryCache = boundaryFiber.stateNode;
|
12333 | }
|
12334 | if (retryCache !== null) {
|
12335 |
|
12336 |
|
12337 | retryCache.delete(thenable);
|
12338 | }
|
12339 |
|
12340 | var currentTime = requestCurrentTime();
|
12341 | var retryTime = computeExpirationForFiber(currentTime, boundaryFiber);
|
12342 | var root = scheduleWorkToRoot(boundaryFiber, retryTime);
|
12343 | if (root !== null) {
|
12344 | markPendingPriorityLevel(root, retryTime);
|
12345 | var rootExpirationTime = root.expirationTime;
|
12346 | if (rootExpirationTime !== NoWork) {
|
12347 | requestWork(root, rootExpirationTime);
|
12348 | }
|
12349 | }
|
12350 | }
|
12351 |
|
12352 | function scheduleWorkToRoot(fiber, expirationTime) {
|
12353 | recordScheduleUpdate();
|
12354 |
|
12355 | {
|
12356 | if (fiber.tag === ClassComponent) {
|
12357 | var instance = fiber.stateNode;
|
12358 | warnAboutInvalidUpdates(instance);
|
12359 | }
|
12360 | }
|
12361 |
|
12362 |
|
12363 | if (fiber.expirationTime < expirationTime) {
|
12364 | fiber.expirationTime = expirationTime;
|
12365 | }
|
12366 | var alternate = fiber.alternate;
|
12367 | if (alternate !== null && alternate.expirationTime < expirationTime) {
|
12368 | alternate.expirationTime = expirationTime;
|
12369 | }
|
12370 |
|
12371 | var node = fiber.return;
|
12372 | var root = null;
|
12373 | if (node === null && fiber.tag === HostRoot) {
|
12374 | root = fiber.stateNode;
|
12375 | } else {
|
12376 | while (node !== null) {
|
12377 | alternate = node.alternate;
|
12378 | if (node.childExpirationTime < expirationTime) {
|
12379 | node.childExpirationTime = expirationTime;
|
12380 | if (alternate !== null && alternate.childExpirationTime < expirationTime) {
|
12381 | alternate.childExpirationTime = expirationTime;
|
12382 | }
|
12383 | } else if (alternate !== null && alternate.childExpirationTime < expirationTime) {
|
12384 | alternate.childExpirationTime = expirationTime;
|
12385 | }
|
12386 | if (node.return === null && node.tag === HostRoot) {
|
12387 | root = node.stateNode;
|
12388 | break;
|
12389 | }
|
12390 | node = node.return;
|
12391 | }
|
12392 | }
|
12393 |
|
12394 | if (enableSchedulerTracing) {
|
12395 | if (root !== null) {
|
12396 | var interactions = __interactionsRef.current;
|
12397 | if (interactions.size > 0) {
|
12398 | var pendingInteractionMap = root.pendingInteractionMap;
|
12399 | var pendingInteractions = pendingInteractionMap.get(expirationTime);
|
12400 | if (pendingInteractions != null) {
|
12401 | interactions.forEach(function (interaction) {
|
12402 | if (!pendingInteractions.has(interaction)) {
|
12403 |
|
12404 | interaction.__count++;
|
12405 | }
|
12406 |
|
12407 | pendingInteractions.add(interaction);
|
12408 | });
|
12409 | } else {
|
12410 | pendingInteractionMap.set(expirationTime, new Set(interactions));
|
12411 |
|
12412 |
|
12413 | interactions.forEach(function (interaction) {
|
12414 | interaction.__count++;
|
12415 | });
|
12416 | }
|
12417 |
|
12418 | var subscriber = __subscriberRef.current;
|
12419 | if (subscriber !== null) {
|
12420 | var threadID = computeThreadID(expirationTime, root.interactionThreadID);
|
12421 | subscriber.onWorkScheduled(interactions, threadID);
|
12422 | }
|
12423 | }
|
12424 | }
|
12425 | }
|
12426 | return root;
|
12427 | }
|
12428 |
|
12429 | function warnIfNotCurrentlyBatchingInDev(fiber) {
|
12430 | {
|
12431 | if (isRendering === false && isBatchingUpdates === false) {
|
12432 | warningWithoutStack$1(false, 'An update to %s inside a test was not wrapped in act(...).\n\n' + 'When testing, code that causes React state updates should be wrapped into act(...):\n\n' + 'act(() => {\n' + ' /* fire events that update state */\n' + '});\n' + '/* assert on the output */\n\n' + "This ensures that you're testing the behavior the user would see in the browser." + ' Learn more at https://fb.me/react-wrap-tests-with-act' + '%s', getComponentName(fiber.type), getStackByFiberInDevAndProd(fiber));
|
12433 | }
|
12434 | }
|
12435 | }
|
12436 |
|
12437 | function scheduleWork(fiber, expirationTime) {
|
12438 | var root = scheduleWorkToRoot(fiber, expirationTime);
|
12439 | if (root === null) {
|
12440 | {
|
12441 | switch (fiber.tag) {
|
12442 | case ClassComponent:
|
12443 | warnAboutUpdateOnUnmounted(fiber, true);
|
12444 | break;
|
12445 | case FunctionComponent:
|
12446 | case ForwardRef:
|
12447 | case MemoComponent:
|
12448 | case SimpleMemoComponent:
|
12449 | warnAboutUpdateOnUnmounted(fiber, false);
|
12450 | break;
|
12451 | }
|
12452 | }
|
12453 | return;
|
12454 | }
|
12455 |
|
12456 | if (!isWorking && nextRenderExpirationTime !== NoWork && expirationTime > nextRenderExpirationTime) {
|
12457 |
|
12458 | interruptedBy = fiber;
|
12459 | resetStack();
|
12460 | }
|
12461 | markPendingPriorityLevel(root, expirationTime);
|
12462 | if (
|
12463 |
|
12464 |
|
12465 | !isWorking || isCommitting$1 ||
|
12466 |
|
12467 | nextRoot !== root) {
|
12468 | var rootExpirationTime = root.expirationTime;
|
12469 | requestWork(root, rootExpirationTime);
|
12470 | }
|
12471 | if (nestedUpdateCount > NESTED_UPDATE_LIMIT) {
|
12472 |
|
12473 | nestedUpdateCount = 0;
|
12474 | invariant(false, 'Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops.');
|
12475 | }
|
12476 | }
|
12477 |
|
12478 |
|
12479 |
|
12480 |
|
12481 |
|
12482 | var firstScheduledRoot = null;
|
12483 | var lastScheduledRoot = null;
|
12484 |
|
12485 | var callbackExpirationTime = NoWork;
|
12486 | var callbackID = void 0;
|
12487 | var isRendering = false;
|
12488 | var nextFlushedRoot = null;
|
12489 | var nextFlushedExpirationTime = NoWork;
|
12490 | var hasUnhandledError = false;
|
12491 | var unhandledError = null;
|
12492 |
|
12493 | var isBatchingUpdates = false;
|
12494 | var isUnbatchingUpdates = false;
|
12495 |
|
12496 | var completedBatches = null;
|
12497 |
|
12498 | var originalStartTimeMs = unstable_now();
|
12499 | var currentRendererTime = msToExpirationTime(originalStartTimeMs);
|
12500 | var currentSchedulerTime = currentRendererTime;
|
12501 |
|
12502 |
|
12503 | var NESTED_UPDATE_LIMIT = 50;
|
12504 | var nestedUpdateCount = 0;
|
12505 | var lastCommittedRootDuringThisBatch = null;
|
12506 |
|
12507 | function recomputeCurrentRendererTime() {
|
12508 | var currentTimeMs = unstable_now() - originalStartTimeMs;
|
12509 | currentRendererTime = msToExpirationTime(currentTimeMs);
|
12510 | }
|
12511 |
|
12512 | function scheduleCallbackWithExpirationTime(root, expirationTime) {
|
12513 | if (callbackExpirationTime !== NoWork) {
|
12514 |
|
12515 | if (expirationTime < callbackExpirationTime) {
|
12516 |
|
12517 | return;
|
12518 | } else {
|
12519 | if (callbackID !== null) {
|
12520 |
|
12521 |
|
12522 | unstable_cancelCallback(callbackID);
|
12523 | }
|
12524 | }
|
12525 |
|
12526 | } else {
|
12527 | startRequestCallbackTimer();
|
12528 | }
|
12529 |
|
12530 | callbackExpirationTime = expirationTime;
|
12531 | var currentMs = unstable_now() - originalStartTimeMs;
|
12532 | var expirationTimeMs = expirationTimeToMs(expirationTime);
|
12533 | var timeout = expirationTimeMs - currentMs;
|
12534 | callbackID = unstable_scheduleCallback(performAsyncWork, { timeout: timeout });
|
12535 | }
|
12536 |
|
12537 |
|
12538 |
|
12539 |
|
12540 |
|
12541 | function onFatal(root) {
|
12542 | root.finishedWork = null;
|
12543 | }
|
12544 |
|
12545 | function onComplete(root, finishedWork, expirationTime) {
|
12546 | root.pendingCommitExpirationTime = expirationTime;
|
12547 | root.finishedWork = finishedWork;
|
12548 | }
|
12549 |
|
12550 | function onSuspend(root, finishedWork, suspendedExpirationTime, rootExpirationTime, msUntilTimeout) {
|
12551 | root.expirationTime = rootExpirationTime;
|
12552 | if (msUntilTimeout === 0 && !shouldYieldToRenderer()) {
|
12553 |
|
12554 | root.pendingCommitExpirationTime = suspendedExpirationTime;
|
12555 | root.finishedWork = finishedWork;
|
12556 | } else if (msUntilTimeout > 0) {
|
12557 |
|
12558 | root.timeoutHandle = scheduleTimeout(onTimeout.bind(null, root, finishedWork, suspendedExpirationTime), msUntilTimeout);
|
12559 | }
|
12560 | }
|
12561 |
|
12562 | function onYield(root) {
|
12563 | root.finishedWork = null;
|
12564 | }
|
12565 |
|
12566 | function onTimeout(root, finishedWork, suspendedExpirationTime) {
|
12567 |
|
12568 | root.pendingCommitExpirationTime = suspendedExpirationTime;
|
12569 | root.finishedWork = finishedWork;
|
12570 |
|
12571 |
|
12572 |
|
12573 | recomputeCurrentRendererTime();
|
12574 | currentSchedulerTime = currentRendererTime;
|
12575 | flushRoot(root, suspendedExpirationTime);
|
12576 | }
|
12577 |
|
12578 | function onCommit(root, expirationTime) {
|
12579 | root.expirationTime = expirationTime;
|
12580 | root.finishedWork = null;
|
12581 | }
|
12582 |
|
12583 | function requestCurrentTime() {
|
12584 |
|
12585 |
|
12586 |
|
12587 |
|
12588 |
|
12589 |
|
12590 |
|
12591 |
|
12592 |
|
12593 |
|
12594 |
|
12595 |
|
12596 |
|
12597 |
|
12598 |
|
12599 |
|
12600 |
|
12601 |
|
12602 |
|
12603 | if (isRendering) {
|
12604 |
|
12605 | return currentSchedulerTime;
|
12606 | }
|
12607 |
|
12608 | findHighestPriorityRoot();
|
12609 | if (nextFlushedExpirationTime === NoWork || nextFlushedExpirationTime === Never) {
|
12610 |
|
12611 |
|
12612 | recomputeCurrentRendererTime();
|
12613 | currentSchedulerTime = currentRendererTime;
|
12614 | return currentSchedulerTime;
|
12615 | }
|
12616 |
|
12617 |
|
12618 |
|
12619 |
|
12620 |
|
12621 | return currentSchedulerTime;
|
12622 | }
|
12623 |
|
12624 |
|
12625 |
|
12626 | function requestWork(root, expirationTime) {
|
12627 | addRootToSchedule(root, expirationTime);
|
12628 | if (isRendering) {
|
12629 |
|
12630 |
|
12631 | return;
|
12632 | }
|
12633 |
|
12634 | if (isBatchingUpdates) {
|
12635 |
|
12636 | if (isUnbatchingUpdates) {
|
12637 |
|
12638 |
|
12639 | nextFlushedRoot = root;
|
12640 | nextFlushedExpirationTime = Sync;
|
12641 | performWorkOnRoot(root, Sync, false);
|
12642 | }
|
12643 | return;
|
12644 | }
|
12645 |
|
12646 |
|
12647 | if (expirationTime === Sync) {
|
12648 | performSyncWork();
|
12649 | } else {
|
12650 | scheduleCallbackWithExpirationTime(root, expirationTime);
|
12651 | }
|
12652 | }
|
12653 |
|
12654 | function addRootToSchedule(root, expirationTime) {
|
12655 |
|
12656 |
|
12657 | if (root.nextScheduledRoot === null) {
|
12658 |
|
12659 | root.expirationTime = expirationTime;
|
12660 | if (lastScheduledRoot === null) {
|
12661 | firstScheduledRoot = lastScheduledRoot = root;
|
12662 | root.nextScheduledRoot = root;
|
12663 | } else {
|
12664 | lastScheduledRoot.nextScheduledRoot = root;
|
12665 | lastScheduledRoot = root;
|
12666 | lastScheduledRoot.nextScheduledRoot = firstScheduledRoot;
|
12667 | }
|
12668 | } else {
|
12669 |
|
12670 | var remainingExpirationTime = root.expirationTime;
|
12671 | if (expirationTime > remainingExpirationTime) {
|
12672 |
|
12673 | root.expirationTime = expirationTime;
|
12674 | }
|
12675 | }
|
12676 | }
|
12677 |
|
12678 | function findHighestPriorityRoot() {
|
12679 | var highestPriorityWork = NoWork;
|
12680 | var highestPriorityRoot = null;
|
12681 | if (lastScheduledRoot !== null) {
|
12682 | var previousScheduledRoot = lastScheduledRoot;
|
12683 | var root = firstScheduledRoot;
|
12684 | while (root !== null) {
|
12685 | var remainingExpirationTime = root.expirationTime;
|
12686 | if (remainingExpirationTime === NoWork) {
|
12687 |
|
12688 |
|
12689 |
|
12690 |
|
12691 |
|
12692 | !(previousScheduledRoot !== null && lastScheduledRoot !== null) ? invariant(false, 'Should have a previous and last root. This error is likely caused by a bug in React. Please file an issue.') : void 0;
|
12693 | if (root === root.nextScheduledRoot) {
|
12694 |
|
12695 | root.nextScheduledRoot = null;
|
12696 | firstScheduledRoot = lastScheduledRoot = null;
|
12697 | break;
|
12698 | } else if (root === firstScheduledRoot) {
|
12699 |
|
12700 | var next = root.nextScheduledRoot;
|
12701 | firstScheduledRoot = next;
|
12702 | lastScheduledRoot.nextScheduledRoot = next;
|
12703 | root.nextScheduledRoot = null;
|
12704 | } else if (root === lastScheduledRoot) {
|
12705 |
|
12706 | lastScheduledRoot = previousScheduledRoot;
|
12707 | lastScheduledRoot.nextScheduledRoot = firstScheduledRoot;
|
12708 | root.nextScheduledRoot = null;
|
12709 | break;
|
12710 | } else {
|
12711 | previousScheduledRoot.nextScheduledRoot = root.nextScheduledRoot;
|
12712 | root.nextScheduledRoot = null;
|
12713 | }
|
12714 | root = previousScheduledRoot.nextScheduledRoot;
|
12715 | } else {
|
12716 | if (remainingExpirationTime > highestPriorityWork) {
|
12717 |
|
12718 | highestPriorityWork = remainingExpirationTime;
|
12719 | highestPriorityRoot = root;
|
12720 | }
|
12721 | if (root === lastScheduledRoot) {
|
12722 | break;
|
12723 | }
|
12724 | if (highestPriorityWork === Sync) {
|
12725 |
|
12726 |
|
12727 | break;
|
12728 | }
|
12729 | previousScheduledRoot = root;
|
12730 | root = root.nextScheduledRoot;
|
12731 | }
|
12732 | }
|
12733 | }
|
12734 |
|
12735 | nextFlushedRoot = highestPriorityRoot;
|
12736 | nextFlushedExpirationTime = highestPriorityWork;
|
12737 | }
|
12738 |
|
12739 |
|
12740 |
|
12741 |
|
12742 | var didYield = false;
|
12743 | function shouldYieldToRenderer() {
|
12744 | if (didYield) {
|
12745 | return true;
|
12746 | }
|
12747 | if (unstable_shouldYield()) {
|
12748 | didYield = true;
|
12749 | return true;
|
12750 | }
|
12751 | return false;
|
12752 | }
|
12753 |
|
12754 | function performAsyncWork() {
|
12755 | try {
|
12756 | if (!shouldYieldToRenderer()) {
|
12757 |
|
12758 |
|
12759 |
|
12760 |
|
12761 |
|
12762 | if (firstScheduledRoot !== null) {
|
12763 | recomputeCurrentRendererTime();
|
12764 | var root = firstScheduledRoot;
|
12765 | do {
|
12766 | didExpireAtExpirationTime(root, currentRendererTime);
|
12767 |
|
12768 | root = root.nextScheduledRoot;
|
12769 | } while (root !== firstScheduledRoot);
|
12770 | }
|
12771 | }
|
12772 | performWork(NoWork, true);
|
12773 | } finally {
|
12774 | didYield = false;
|
12775 | }
|
12776 | }
|
12777 |
|
12778 | function performSyncWork() {
|
12779 | performWork(Sync, false);
|
12780 | }
|
12781 |
|
12782 | function performWork(minExpirationTime, isYieldy) {
|
12783 |
|
12784 |
|
12785 | findHighestPriorityRoot();
|
12786 |
|
12787 | if (isYieldy) {
|
12788 | recomputeCurrentRendererTime();
|
12789 | currentSchedulerTime = currentRendererTime;
|
12790 |
|
12791 | if (enableUserTimingAPI) {
|
12792 | var didExpire = nextFlushedExpirationTime > currentRendererTime;
|
12793 | var timeout = expirationTimeToMs(nextFlushedExpirationTime);
|
12794 | stopRequestCallbackTimer(didExpire, timeout);
|
12795 | }
|
12796 |
|
12797 | while (nextFlushedRoot !== null && nextFlushedExpirationTime !== NoWork && minExpirationTime <= nextFlushedExpirationTime && !(didYield && currentRendererTime > nextFlushedExpirationTime)) {
|
12798 | performWorkOnRoot(nextFlushedRoot, nextFlushedExpirationTime, currentRendererTime > nextFlushedExpirationTime);
|
12799 | findHighestPriorityRoot();
|
12800 | recomputeCurrentRendererTime();
|
12801 | currentSchedulerTime = currentRendererTime;
|
12802 | }
|
12803 | } else {
|
12804 | while (nextFlushedRoot !== null && nextFlushedExpirationTime !== NoWork && minExpirationTime <= nextFlushedExpirationTime) {
|
12805 | performWorkOnRoot(nextFlushedRoot, nextFlushedExpirationTime, false);
|
12806 | findHighestPriorityRoot();
|
12807 | }
|
12808 | }
|
12809 |
|
12810 |
|
12811 |
|
12812 |
|
12813 |
|
12814 | if (isYieldy) {
|
12815 | callbackExpirationTime = NoWork;
|
12816 | callbackID = null;
|
12817 | }
|
12818 |
|
12819 | if (nextFlushedExpirationTime !== NoWork) {
|
12820 | scheduleCallbackWithExpirationTime(nextFlushedRoot, nextFlushedExpirationTime);
|
12821 | }
|
12822 |
|
12823 |
|
12824 | finishRendering();
|
12825 | }
|
12826 |
|
12827 | function flushRoot(root, expirationTime) {
|
12828 | !!isRendering ? invariant(false, 'work.commit(): Cannot commit while already rendering. This likely means you attempted to commit from inside a lifecycle method.') : void 0;
|
12829 |
|
12830 |
|
12831 |
|
12832 | nextFlushedRoot = root;
|
12833 | nextFlushedExpirationTime = expirationTime;
|
12834 | performWorkOnRoot(root, expirationTime, false);
|
12835 |
|
12836 | performSyncWork();
|
12837 | }
|
12838 |
|
12839 | function finishRendering() {
|
12840 | nestedUpdateCount = 0;
|
12841 | lastCommittedRootDuringThisBatch = null;
|
12842 |
|
12843 | if (completedBatches !== null) {
|
12844 | var batches = completedBatches;
|
12845 | completedBatches = null;
|
12846 | for (var i = 0; i < batches.length; i++) {
|
12847 | var batch = batches[i];
|
12848 | try {
|
12849 | batch._onComplete();
|
12850 | } catch (error) {
|
12851 | if (!hasUnhandledError) {
|
12852 | hasUnhandledError = true;
|
12853 | unhandledError = error;
|
12854 | }
|
12855 | }
|
12856 | }
|
12857 | }
|
12858 |
|
12859 | if (hasUnhandledError) {
|
12860 | var error = unhandledError;
|
12861 | unhandledError = null;
|
12862 | hasUnhandledError = false;
|
12863 | throw error;
|
12864 | }
|
12865 | }
|
12866 |
|
12867 | function performWorkOnRoot(root, expirationTime, isYieldy) {
|
12868 | !!isRendering ? invariant(false, 'performWorkOnRoot was called recursively. This error is likely caused by a bug in React. Please file an issue.') : void 0;
|
12869 |
|
12870 | isRendering = true;
|
12871 |
|
12872 |
|
12873 | if (!isYieldy) {
|
12874 |
|
12875 |
|
12876 |
|
12877 |
|
12878 |
|
12879 | var finishedWork = root.finishedWork;
|
12880 | if (finishedWork !== null) {
|
12881 |
|
12882 | completeRoot(root, finishedWork, expirationTime);
|
12883 | } else {
|
12884 | root.finishedWork = null;
|
12885 |
|
12886 |
|
12887 | var timeoutHandle = root.timeoutHandle;
|
12888 | if (timeoutHandle !== noTimeout) {
|
12889 | root.timeoutHandle = noTimeout;
|
12890 |
|
12891 | cancelTimeout(timeoutHandle);
|
12892 | }
|
12893 | renderRoot(root, isYieldy);
|
12894 | finishedWork = root.finishedWork;
|
12895 | if (finishedWork !== null) {
|
12896 |
|
12897 | completeRoot(root, finishedWork, expirationTime);
|
12898 | }
|
12899 | }
|
12900 | } else {
|
12901 |
|
12902 | var _finishedWork = root.finishedWork;
|
12903 | if (_finishedWork !== null) {
|
12904 |
|
12905 | completeRoot(root, _finishedWork, expirationTime);
|
12906 | } else {
|
12907 | root.finishedWork = null;
|
12908 |
|
12909 |
|
12910 | var _timeoutHandle = root.timeoutHandle;
|
12911 | if (_timeoutHandle !== noTimeout) {
|
12912 | root.timeoutHandle = noTimeout;
|
12913 |
|
12914 | cancelTimeout(_timeoutHandle);
|
12915 | }
|
12916 | renderRoot(root, isYieldy);
|
12917 | _finishedWork = root.finishedWork;
|
12918 | if (_finishedWork !== null) {
|
12919 |
|
12920 |
|
12921 | if (!shouldYieldToRenderer()) {
|
12922 |
|
12923 | completeRoot(root, _finishedWork, expirationTime);
|
12924 | } else {
|
12925 |
|
12926 |
|
12927 | root.finishedWork = _finishedWork;
|
12928 | }
|
12929 | }
|
12930 | }
|
12931 | }
|
12932 |
|
12933 | isRendering = false;
|
12934 | }
|
12935 |
|
12936 | function completeRoot(root, finishedWork, expirationTime) {
|
12937 |
|
12938 | var firstBatch = root.firstBatch;
|
12939 | if (firstBatch !== null && firstBatch._expirationTime >= expirationTime) {
|
12940 | if (completedBatches === null) {
|
12941 | completedBatches = [firstBatch];
|
12942 | } else {
|
12943 | completedBatches.push(firstBatch);
|
12944 | }
|
12945 | if (firstBatch._defer) {
|
12946 |
|
12947 |
|
12948 | root.finishedWork = finishedWork;
|
12949 | root.expirationTime = NoWork;
|
12950 | return;
|
12951 | }
|
12952 | }
|
12953 |
|
12954 |
|
12955 | root.finishedWork = null;
|
12956 |
|
12957 |
|
12958 |
|
12959 | if (root === lastCommittedRootDuringThisBatch) {
|
12960 |
|
12961 |
|
12962 | nestedUpdateCount++;
|
12963 | } else {
|
12964 |
|
12965 | lastCommittedRootDuringThisBatch = root;
|
12966 | nestedUpdateCount = 0;
|
12967 | }
|
12968 | unstable_runWithPriority(unstable_ImmediatePriority, function () {
|
12969 | commitRoot(root, finishedWork);
|
12970 | });
|
12971 | }
|
12972 |
|
12973 | function onUncaughtError(error) {
|
12974 | !(nextFlushedRoot !== null) ? invariant(false, 'Should be working on a root. This error is likely caused by a bug in React. Please file an issue.') : void 0;
|
12975 |
|
12976 |
|
12977 | nextFlushedRoot.expirationTime = NoWork;
|
12978 | if (!hasUnhandledError) {
|
12979 | hasUnhandledError = true;
|
12980 | unhandledError = error;
|
12981 | }
|
12982 | }
|
12983 |
|
12984 |
|
12985 |
|
12986 |
|
12987 |
|
12988 | var didWarnAboutNestedUpdates = void 0;
|
12989 | {
|
12990 | didWarnAboutNestedUpdates = false;
|
12991 |
|
12992 | }
|
12993 |
|
12994 | function getContextForSubtree(parentComponent) {
|
12995 | if (!parentComponent) {
|
12996 | return emptyContextObject;
|
12997 | }
|
12998 |
|
12999 | var fiber = get(parentComponent);
|
13000 | var parentContext = findCurrentUnmaskedContext(fiber);
|
13001 |
|
13002 | if (fiber.tag === ClassComponent) {
|
13003 | var Component = fiber.type;
|
13004 | if (isContextProvider(Component)) {
|
13005 | return processChildContext(fiber, Component, parentContext);
|
13006 | }
|
13007 | }
|
13008 |
|
13009 | return parentContext;
|
13010 | }
|
13011 |
|
13012 | function scheduleRootUpdate(current$$1, element, expirationTime, callback) {
|
13013 | {
|
13014 | if (phase === 'render' && current$1 !== null && !didWarnAboutNestedUpdates) {
|
13015 | didWarnAboutNestedUpdates = true;
|
13016 | warningWithoutStack$1(false, 'Render methods should be a pure function of props and state; ' + 'triggering nested component updates from render is not allowed. ' + 'If necessary, trigger nested updates in componentDidUpdate.\n\n' + 'Check the render method of %s.', getComponentName(current$1.type) || 'Unknown');
|
13017 | }
|
13018 | }
|
13019 |
|
13020 | var update = createUpdate(expirationTime);
|
13021 |
|
13022 |
|
13023 | update.payload = { element: element };
|
13024 |
|
13025 | callback = callback === undefined ? null : callback;
|
13026 | if (callback !== null) {
|
13027 | !(typeof callback === 'function') ? warningWithoutStack$1(false, 'render(...): Expected the last optional `callback` argument to be a ' + 'function. Instead received: %s.', callback) : void 0;
|
13028 | update.callback = callback;
|
13029 | }
|
13030 |
|
13031 | flushPassiveEffects();
|
13032 | enqueueUpdate(current$$1, update);
|
13033 | scheduleWork(current$$1, expirationTime);
|
13034 |
|
13035 | return expirationTime;
|
13036 | }
|
13037 |
|
13038 | function updateContainerAtExpirationTime(element, container, parentComponent, expirationTime, callback) {
|
13039 |
|
13040 | var current$$1 = container.current;
|
13041 |
|
13042 | {
|
13043 | if (ReactFiberInstrumentation_1.debugTool) {
|
13044 | if (current$$1.alternate === null) {
|
13045 | ReactFiberInstrumentation_1.debugTool.onMountContainer(container);
|
13046 | } else if (element === null) {
|
13047 | ReactFiberInstrumentation_1.debugTool.onUnmountContainer(container);
|
13048 | } else {
|
13049 | ReactFiberInstrumentation_1.debugTool.onUpdateContainer(container);
|
13050 | }
|
13051 | }
|
13052 | }
|
13053 |
|
13054 | var context = getContextForSubtree(parentComponent);
|
13055 | if (container.context === null) {
|
13056 | container.context = context;
|
13057 | } else {
|
13058 | container.pendingContext = context;
|
13059 | }
|
13060 |
|
13061 | return scheduleRootUpdate(current$$1, element, expirationTime, callback);
|
13062 | }
|
13063 |
|
13064 | function createContainer(containerInfo, isConcurrent, hydrate) {
|
13065 | return createFiberRoot(containerInfo, isConcurrent, hydrate);
|
13066 | }
|
13067 |
|
13068 | function updateContainer(element, container, parentComponent, callback) {
|
13069 | var current$$1 = container.current;
|
13070 | var currentTime = requestCurrentTime();
|
13071 | var expirationTime = computeExpirationForFiber(currentTime, current$$1);
|
13072 | return updateContainerAtExpirationTime(element, container, parentComponent, expirationTime, callback);
|
13073 | }
|
13074 |
|
13075 |
|
13076 |
|
13077 |
|
13078 |
|
13079 | var overrideProps = null;
|
13080 |
|
13081 | {
|
13082 | var copyWithSetImpl = function (obj, path, idx, value) {
|
13083 | if (idx >= path.length) {
|
13084 | return value;
|
13085 | }
|
13086 | var key = path[idx];
|
13087 | var updated = Array.isArray(obj) ? obj.slice() : _assign({}, obj);
|
13088 |
|
13089 | updated[key] = copyWithSetImpl(obj[key], path, idx + 1, value);
|
13090 | return updated;
|
13091 | };
|
13092 |
|
13093 | var copyWithSet = function (obj, path, value) {
|
13094 | return copyWithSetImpl(obj, path, 0, value);
|
13095 | };
|
13096 |
|
13097 |
|
13098 | overrideProps = function (fiber, path, value) {
|
13099 | flushPassiveEffects();
|
13100 | fiber.pendingProps = copyWithSet(fiber.memoizedProps, path, value);
|
13101 | if (fiber.alternate) {
|
13102 | fiber.alternate.pendingProps = fiber.pendingProps;
|
13103 | }
|
13104 | scheduleWork(fiber, Sync);
|
13105 | };
|
13106 | }
|
13107 |
|
13108 | function injectIntoDevTools(devToolsConfig) {
|
13109 | var findFiberByHostInstance = devToolsConfig.findFiberByHostInstance;
|
13110 | var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;
|
13111 |
|
13112 |
|
13113 | return injectInternals(_assign({}, devToolsConfig, {
|
13114 | overrideProps: overrideProps,
|
13115 | currentDispatcherRef: ReactCurrentDispatcher,
|
13116 | findHostInstanceByFiber: function (fiber) {
|
13117 | var hostFiber = findCurrentHostFiber(fiber);
|
13118 | if (hostFiber === null) {
|
13119 | return null;
|
13120 | }
|
13121 | return hostFiber.stateNode;
|
13122 | },
|
13123 | findFiberByHostInstance: function (instance) {
|
13124 | if (!findFiberByHostInstance) {
|
13125 |
|
13126 | return null;
|
13127 | }
|
13128 | return findFiberByHostInstance(instance);
|
13129 | }
|
13130 | }));
|
13131 | }
|
13132 |
|
13133 |
|
13134 |
|
13135 |
|
13136 | var container = _class({
|
13137 |
|
13138 | grab: function(){
|
13139 | for (var i = 0; i < arguments.length; i++) arguments[i].inject(this);
|
13140 | return this;
|
13141 | },
|
13142 |
|
13143 | empty: function(){
|
13144 | var node;
|
13145 | while (node = this.firstChild) node.eject();
|
13146 | return this;
|
13147 | }
|
13148 |
|
13149 | });
|
13150 |
|
13151 | function elementFrom(node){
|
13152 | if (node.toElement) return node.toElement();
|
13153 | if (node.getDOMNode) return node.getDOMNode();
|
13154 | if (node.getNode) return node.getNode();
|
13155 | return node;
|
13156 | }
|
13157 |
|
13158 | var native_1 = _class({
|
13159 |
|
13160 |
|
13161 |
|
13162 | toElement: function(){
|
13163 | return this.element;
|
13164 | },
|
13165 |
|
13166 | getDOMNode: function(){
|
13167 | return this.toElement();
|
13168 | },
|
13169 |
|
13170 | getNode: function(){
|
13171 | return this.toElement();
|
13172 | },
|
13173 |
|
13174 |
|
13175 |
|
13176 | inject: function(container){
|
13177 | (container.containerElement || elementFrom(container))
|
13178 | .appendChild(this.element);
|
13179 | return this;
|
13180 | },
|
13181 |
|
13182 | injectBefore: function(sibling){
|
13183 | var element = elementFrom(sibling);
|
13184 | element.parentNode.insertBefore(this.element, element);
|
13185 | return this;
|
13186 | },
|
13187 |
|
13188 | eject: function(){
|
13189 | var element = this.element, parent = element.parentNode;
|
13190 | if (parent) parent.removeChild(element);
|
13191 | return this;
|
13192 | },
|
13193 |
|
13194 |
|
13195 |
|
13196 | subscribe: function(type, fn, bind){
|
13197 | if (typeof type != 'string'){
|
13198 | var subscriptions = [];
|
13199 | for (var t in type) subscriptions.push(this.subscribe(t, type[t]));
|
13200 | return function(){
|
13201 | for (var i = 0, l = subscriptions.length; i < l; i++)
|
13202 | subscriptions[i]();
|
13203 | return this;
|
13204 | };
|
13205 | } else {
|
13206 | if (!bind) bind = this;
|
13207 | var bound;
|
13208 | if (typeof fn === 'function'){
|
13209 | bound = fn.bind ? fn.bind(bind)
|
13210 | : function(){ return fn.apply(bind, arguments); };
|
13211 | } else {
|
13212 | bound = fn;
|
13213 | }
|
13214 | var element = this.element;
|
13215 | if (element.addEventListener){
|
13216 | element.addEventListener(type, bound, false);
|
13217 | return function(){
|
13218 | element.removeEventListener(type, bound, false);
|
13219 | return this;
|
13220 | };
|
13221 | } else {
|
13222 | element.attachEvent('on' + type, bound);
|
13223 | return function(){
|
13224 | element.detachEvent('on' + type, bound);
|
13225 | return this;
|
13226 | };
|
13227 | }
|
13228 | }
|
13229 | }
|
13230 |
|
13231 | });
|
13232 |
|
13233 | var fps = 1000 / 60;
|
13234 | var invalids = [];
|
13235 | var renderTimer;
|
13236 | var renderInvalids = function(){
|
13237 | clearTimeout(renderTimer);
|
13238 | renderTimer = null;
|
13239 | var canvases = invalids;
|
13240 | invalids = [];
|
13241 | for (var i = 0, l = canvases.length; i < l; i++){
|
13242 | var c = canvases[i];
|
13243 | c._valid = true;
|
13244 | c.render();
|
13245 | }
|
13246 | };
|
13247 |
|
13248 | var resolution = typeof window !== 'undefined' && window.devicePixelRatio || 1;
|
13249 |
|
13250 | var previousHit = null;
|
13251 | var previousHitSurface = null;
|
13252 |
|
13253 | var CanvasSurface = _class(native_1, container, {
|
13254 |
|
13255 | initialize: function(width, height, existingElement){
|
13256 | var element = this.element = existingElement || document.createElement('canvas');
|
13257 | var context = this.context = element.getContext('2d');
|
13258 | this._valid = true;
|
13259 | if (width != null && height != null) this.resize(width, height);
|
13260 |
|
13261 | element.addEventListener('mousemove', this, false);
|
13262 | element.addEventListener('mouseout', this, false);
|
13263 | element.addEventListener('mouseover', this, false);
|
13264 | element.addEventListener('mouseup', this, false);
|
13265 | element.addEventListener('mousedown', this, false);
|
13266 | element.addEventListener('click', this, false);
|
13267 | },
|
13268 |
|
13269 | handleEvent: function(event){
|
13270 | if (event.clientX == null) return;
|
13271 | var element = this.element,
|
13272 | rect = element.getBoundingClientRect(),
|
13273 | x = event.clientX - rect.left - element.clientLeft,
|
13274 | y = event.clientY - rect.top - element.clientTop,
|
13275 | hit = this.hitTest(x, y);
|
13276 |
|
13277 | if (hit !== previousHit){
|
13278 | if (previousHit){
|
13279 | previousHit.dispatch({
|
13280 | type: 'mouseout',
|
13281 | target: previousHit,
|
13282 | relatedTarget: hit,
|
13283 | sourceEvent: event
|
13284 | });
|
13285 | }
|
13286 | if (hit){
|
13287 | hit.dispatch({
|
13288 | type: 'mouseover',
|
13289 | target: hit,
|
13290 | relatedTarget: previousHit,
|
13291 | sourceEvent: event
|
13292 | });
|
13293 | }
|
13294 | previousHit = hit;
|
13295 | previousHitSurface = this;
|
13296 | this.refreshCursor();
|
13297 | }
|
13298 |
|
13299 | if (hit) hit.dispatch(event);
|
13300 | },
|
13301 |
|
13302 | refreshCursor: function(){
|
13303 | if (previousHitSurface !== this) return;
|
13304 | var hit = previousHit, hitCursor = '', hitTooltip = '';
|
13305 | while (hit){
|
13306 | if (!hitCursor && hit._cursor){
|
13307 | hitCursor = hit._cursor;
|
13308 | if (hitTooltip) break;
|
13309 | }
|
13310 | if (!hitTooltip && hit._tooltip){
|
13311 | hitTooltip = hit._tooltip;
|
13312 | if (hitCursor) break;
|
13313 | }
|
13314 | hit = hit.parentNode;
|
13315 | }
|
13316 |
|
13317 | this.element.style.cursor = hitCursor;
|
13318 | this.element.title = hitTooltip;
|
13319 | },
|
13320 |
|
13321 | resize: function(width, height){
|
13322 | var element = this.element;
|
13323 | element.setAttribute('width', width * resolution);
|
13324 | element.setAttribute('height', height * resolution);
|
13325 | element.style.width = width + 'px';
|
13326 | element.style.height = height + 'px';
|
13327 | this.width = width;
|
13328 | this.height = height;
|
13329 | return this;
|
13330 | },
|
13331 |
|
13332 | invalidate: function(left, top, width, height){
|
13333 | if (this._valid){
|
13334 | this._valid = false;
|
13335 | invalids.push(this);
|
13336 | if (!renderTimer){
|
13337 | if (window.mozRequestAnimationFrame){
|
13338 | renderTimer = true;
|
13339 | window.mozRequestAnimationFrame(renderInvalids);
|
13340 | } else {
|
13341 | renderTimer = setTimeout(renderInvalids, fps);
|
13342 | }
|
13343 | }
|
13344 | }
|
13345 | return this;
|
13346 | },
|
13347 |
|
13348 | hitTest: function(x, y){
|
13349 | if (x < 0 || y < 0 || x > this.width || y > this.height) return null;
|
13350 | var node = this.lastChild;
|
13351 | while (node){
|
13352 | var hit = node.hitTest(x, y);
|
13353 | if (hit) return hit;
|
13354 | node = node.previousSibling;
|
13355 | }
|
13356 | return null;
|
13357 | },
|
13358 |
|
13359 | render: function(){
|
13360 | var node = this.firstChild, context = this.context;
|
13361 | context.setTransform(resolution, 0, 0, resolution, 0, 0);
|
13362 | context.clearRect(0, 0, this.width, this.height);
|
13363 | while (node){
|
13364 | node.renderTo(context, resolution, 0, 0, resolution, 0, 0);
|
13365 | node = node.nextSibling;
|
13366 | }
|
13367 | this.refreshCursor();
|
13368 | }
|
13369 |
|
13370 | });
|
13371 |
|
13372 | CanvasSurface.tagName = 'canvas';
|
13373 |
|
13374 | var surface = CanvasSurface;
|
13375 |
|
13376 | var path$2 = _class({
|
13377 |
|
13378 | initialize: function(path){
|
13379 | this.reset().push(path);
|
13380 | },
|
13381 |
|
13382 |
|
13383 |
|
13384 | push: function(){
|
13385 | var p = Array.prototype.join.call(arguments, ' ')
|
13386 | .match(/[a-df-z]|[\-+]?(?:[\d\.]e[\-+]?|[^\s\-+,a-z])+/ig);
|
13387 | if (!p) return this;
|
13388 |
|
13389 | var last, cmd = p[0], i = 1;
|
13390 | while (cmd){
|
13391 | switch (cmd){
|
13392 | case 'm': this.move(p[i++], p[i++]); break;
|
13393 | case 'l': this.line(p[i++], p[i++]); break;
|
13394 | case 'c': this.curve(p[i++], p[i++], p[i++], p[i++], p[i++], p[i++]); break;
|
13395 | case 's': this.curve(p[i++], p[i++], null, null, p[i++], p[i++]); break;
|
13396 | case 'q': this.curve(p[i++], p[i++], p[i++], p[i++]); break;
|
13397 | case 't': this.curve(p[i++], p[i++]); break;
|
13398 | case 'a': this.arc(p[i+5], p[i+6], p[i], p[i+1], p[i+3], !+p[i+4], p[i+2]); i += 7; break;
|
13399 | case 'h': this.line(p[i++], 0); break;
|
13400 | case 'v': this.line(0, p[i++]); break;
|
13401 |
|
13402 | case 'M': this.moveTo(p[i++], p[i++]); break;
|
13403 | case 'L': this.lineTo(p[i++], p[i++]); break;
|
13404 | case 'C': this.curveTo(p[i++], p[i++], p[i++], p[i++], p[i++], p[i++]); break;
|
13405 | case 'S': this.curveTo(p[i++], p[i++], null, null, p[i++], p[i++]); break;
|
13406 | case 'Q': this.curveTo(p[i++], p[i++], p[i++], p[i++]); break;
|
13407 | case 'T': this.curveTo(p[i++], p[i++]); break;
|
13408 | case 'A': this.arcTo(p[i+5], p[i+6], p[i], p[i+1], p[i+3], !+p[i+4], p[i+2]); i += 7; break;
|
13409 | case 'H': this.lineTo(p[i++], this.penY); break;
|
13410 | case 'V': this.lineTo(this.penX, p[i++]); break;
|
13411 |
|
13412 | case 'Z': case 'z': this.close(); break;
|
13413 | default: cmd = last; i--; continue;
|
13414 | }
|
13415 |
|
13416 | last = cmd;
|
13417 | if (last == 'm') last = 'l';
|
13418 | else if (last == 'M') last = 'L';
|
13419 | cmd = p[i++];
|
13420 | }
|
13421 | return this;
|
13422 | },
|
13423 |
|
13424 |
|
13425 |
|
13426 | reset: function(){
|
13427 | this.penX = this.penY = 0;
|
13428 | this.penDownX = this.penDownY = null;
|
13429 | this._pivotX = this._pivotY = 0;
|
13430 | this.onReset();
|
13431 | return this;
|
13432 | },
|
13433 |
|
13434 | move: function(x,y){
|
13435 | this.onMove(this.penX, this.penY, this._pivotX = this.penX += (+x), this._pivotY = this.penY += (+y));
|
13436 | return this;
|
13437 | },
|
13438 | moveTo: function(x,y){
|
13439 | this.onMove(this.penX, this.penY, this._pivotX = this.penX = (+x), this._pivotY = this.penY = (+y));
|
13440 | return this;
|
13441 | },
|
13442 |
|
13443 | line: function(x,y){
|
13444 | return this.lineTo(this.penX + (+x), this.penY + (+y));
|
13445 | },
|
13446 | lineTo: function(x,y){
|
13447 | if (this.penDownX == null){ this.penDownX = this.penX; this.penDownY = this.penY; }
|
13448 | this.onLine(this.penX, this.penY, this._pivotX = this.penX = (+x), this._pivotY = this.penY = (+y));
|
13449 | return this;
|
13450 | },
|
13451 |
|
13452 | curve: function(c1x, c1y, c2x, c2y, ex, ey){
|
13453 | var x = this.penX, y = this.penY;
|
13454 | return this.curveTo(
|
13455 | x + (+c1x), y + (+c1y),
|
13456 | c2x == null ? null : x + (+c2x),
|
13457 | c2y == null ? null : y + (+c2y),
|
13458 | ex == null ? null : x + (+ex),
|
13459 | ey == null ? null : y + (+ey)
|
13460 | );
|
13461 | },
|
13462 | curveTo: function(c1x, c1y, c2x, c2y, ex, ey){
|
13463 | var x = this.penX, y = this.penY;
|
13464 | if (c2x == null){
|
13465 | c2x = +c1x; c2y = +c1y;
|
13466 | c1x = (x * 2) - (this._pivotX || 0); c1y = (y * 2) - (this._pivotY || 0);
|
13467 | }
|
13468 | if (ex == null){
|
13469 | this._pivotX = +c1x; this._pivotY = +c1y;
|
13470 | ex = +c2x; ey = +c2y;
|
13471 | c2x = (ex + (+c1x) * 2) / 3; c2y = (ey + (+c1y) * 2) / 3;
|
13472 | c1x = (x + (+c1x) * 2) / 3; c1y = (y + (+c1y) * 2) / 3;
|
13473 | } else {
|
13474 | this._pivotX = +c2x; this._pivotY = +c2y;
|
13475 | }
|
13476 | if (this.penDownX == null){ this.penDownX = x; this.penDownY = y; }
|
13477 | this.onBezierCurve(x, y, +c1x, +c1y, +c2x, +c2y, this.penX = +ex, this.penY = +ey);
|
13478 | return this;
|
13479 | },
|
13480 |
|
13481 | arc: function(x, y, rx, ry, outer, counterClockwise, rotation){
|
13482 | return this.arcTo(this.penX + (+x), this.penY + (+y), rx, ry, outer, counterClockwise, rotation);
|
13483 | },
|
13484 | arcTo: function(x, y, rx, ry, outer, counterClockwise, rotation){
|
13485 | ry = Math.abs(+ry || +rx || (+y - this.penY));
|
13486 | rx = Math.abs(+rx || (+x - this.penX));
|
13487 |
|
13488 | if (!rx || !ry || (x == this.penX && y == this.penY)) return this.lineTo(x, y);
|
13489 |
|
13490 | var tX = this.penX, tY = this.penY, clockwise = !+counterClockwise, large = !!+outer;
|
13491 |
|
13492 | var rad = rotation ? rotation * Math.PI / 180 : 0, cos = Math.cos(rad), sin = Math.sin(rad);
|
13493 | x -= tX; y -= tY;
|
13494 |
|
13495 |
|
13496 | var cx = cos * x / 2 + sin * y / 2,
|
13497 | cy = -sin * x / 2 + cos * y / 2,
|
13498 | rxry = rx * rx * ry * ry,
|
13499 | rycx = ry * ry * cx * cx,
|
13500 | rxcy = rx * rx * cy * cy,
|
13501 | a = rxry - rxcy - rycx;
|
13502 |
|
13503 | if (a < 0){
|
13504 | a = Math.sqrt(1 - a / rxry);
|
13505 | rx *= a; ry *= a;
|
13506 | cx = x / 2; cy = y / 2;
|
13507 | } else {
|
13508 | a = Math.sqrt(a / (rxcy + rycx));
|
13509 | if (large == clockwise) a = -a;
|
13510 | var cxd = -a * cy * rx / ry,
|
13511 | cyd = a * cx * ry / rx;
|
13512 | cx = cos * cxd - sin * cyd + x / 2;
|
13513 | cy = sin * cxd + cos * cyd + y / 2;
|
13514 | }
|
13515 |
|
13516 |
|
13517 | var xx = cos / rx, yx = sin / rx,
|
13518 | xy = -sin / ry, yy = cos / ry;
|
13519 |
|
13520 |
|
13521 | var sa = Math.atan2(xy * -cx + yy * -cy, xx * -cx + yx * -cy),
|
13522 | ea = Math.atan2(xy * (x - cx) + yy * (y - cy), xx * (x - cx) + yx * (y - cy));
|
13523 |
|
13524 | cx += tX; cy += tY;
|
13525 | x += tX; y += tY;
|
13526 |
|
13527 |
|
13528 | if (this.penDownX == null){ this.penDownX = this.penX; this.penDownY = this.penY; }
|
13529 | this.onArc(
|
13530 | tX, tY, this._pivotX = this.penX = x, this._pivotY = this.penY = y,
|
13531 | cx, cy, rx, ry, sa, ea, !clockwise, rotation
|
13532 | );
|
13533 | return this;
|
13534 | },
|
13535 |
|
13536 | counterArc: function(x, y, rx, ry, outer){
|
13537 | return this.arc(x, y, rx, ry, outer, true);
|
13538 | },
|
13539 | counterArcTo: function(x, y, rx, ry, outer){
|
13540 | return this.arcTo(x, y, rx, ry, outer, true);
|
13541 | },
|
13542 |
|
13543 | close: function(){
|
13544 | if (this.penDownX != null){
|
13545 | this.onClose(this.penX, this.penY, this.penX = this.penDownX, this.penY = this.penDownY);
|
13546 | this.penDownX = null;
|
13547 | }
|
13548 | return this;
|
13549 | },
|
13550 |
|
13551 |
|
13552 |
|
13553 | onReset: function(){
|
13554 | },
|
13555 |
|
13556 | onMove: function(sx, sy, ex, ey){
|
13557 | },
|
13558 |
|
13559 | onLine: function(sx, sy, ex, ey){
|
13560 | this.onBezierCurve(sx, sy, sx, sy, ex, ey, ex, ey);
|
13561 | },
|
13562 |
|
13563 | onBezierCurve: function(sx, sy, c1x, c1y, c2x, c2y, ex, ey){
|
13564 | var gx = ex - sx, gy = ey - sy,
|
13565 | g = gx * gx + gy * gy,
|
13566 | v1, v2, cx, cy, u;
|
13567 |
|
13568 | cx = c1x - sx; cy = c1y - sy;
|
13569 | u = cx * gx + cy * gy;
|
13570 |
|
13571 | if (u > g){
|
13572 | cx -= gx;
|
13573 | cy -= gy;
|
13574 | } else if (u > 0 && g != 0){
|
13575 | cx -= u/g * gx;
|
13576 | cy -= u/g * gy;
|
13577 | }
|
13578 |
|
13579 | v1 = cx * cx + cy * cy;
|
13580 |
|
13581 | cx = c2x - sx; cy = c2y - sy;
|
13582 | u = cx * gx + cy * gy;
|
13583 |
|
13584 | if (u > g){
|
13585 | cx -= gx;
|
13586 | cy -= gy;
|
13587 | } else if (u > 0 && g != 0){
|
13588 | cx -= u/g * gx;
|
13589 | cy -= u/g * gy;
|
13590 | }
|
13591 |
|
13592 | v2 = cx * cx + cy * cy;
|
13593 |
|
13594 | if (v1 < 0.01 && v2 < 0.01){
|
13595 | this.onLine(sx, sy, ex, ey);
|
13596 | return;
|
13597 | }
|
13598 |
|
13599 |
|
13600 | if (isNaN(v1) || isNaN(v2)){
|
13601 | throw new Error('Bad input');
|
13602 | }
|
13603 |
|
13604 |
|
13605 | var s1x = (c1x + c2x) * 0.5, s1y = (c1y + c2y) * 0.5,
|
13606 | l1x = (c1x + sx) * 0.5, l1y = (c1y + sy) * 0.5,
|
13607 | l2x = (l1x + s1x) * 0.5, l2y = (l1y + s1y) * 0.5,
|
13608 | r2x = (ex + c2x) * 0.5, r2y = (ey + c2y) * 0.5,
|
13609 | r1x = (r2x + s1x) * 0.5, r1y = (r2y + s1y) * 0.5,
|
13610 | l2r1x = (l2x + r1x) * 0.5, l2r1y = (l2y + r1y) * 0.5;
|
13611 |
|
13612 |
|
13613 | this.onBezierCurve(sx, sy, l1x, l1y, l2x, l2y, l2r1x, l2r1y);
|
13614 | this.onBezierCurve(l2r1x, l2r1y, r1x, r1y, r2x, r2y, ex, ey);
|
13615 | },
|
13616 |
|
13617 | onArc: function(sx, sy, ex, ey, cx, cy, rx, ry, sa, ea, ccw, rotation){
|
13618 |
|
13619 | var rad = rotation ? rotation * Math.PI / 180 : 0, cos = Math.cos(rad), sin = Math.sin(rad),
|
13620 | xx = cos * rx, yx = -sin * ry,
|
13621 | xy = sin * rx, yy = cos * ry;
|
13622 |
|
13623 |
|
13624 | var arc = ea - sa;
|
13625 | if (arc < 0 && !ccw) arc += Math.PI * 2;
|
13626 | else if (arc > 0 && ccw) arc -= Math.PI * 2;
|
13627 |
|
13628 | var n = Math.ceil(Math.abs(arc / (Math.PI / 2))),
|
13629 | step = arc / n,
|
13630 | k = (4 / 3) * Math.tan(step / 4);
|
13631 |
|
13632 | var x = Math.cos(sa), y = Math.sin(sa);
|
13633 |
|
13634 | for (var i = 0; i < n; i++){
|
13635 | var cp1x = x - k * y, cp1y = y + k * x;
|
13636 |
|
13637 | sa += step;
|
13638 | x = Math.cos(sa); y = Math.sin(sa);
|
13639 |
|
13640 | var cp2x = x + k * y, cp2y = y - k * x;
|
13641 |
|
13642 | this.onBezierCurve(
|
13643 | sx, sy,
|
13644 | cx + xx * cp1x + yx * cp1y, cy + xy * cp1x + yy * cp1y,
|
13645 | cx + xx * cp2x + yx * cp2y, cy + xy * cp2x + yy * cp2y,
|
13646 | (sx = (cx + xx * x + yx * y)), (sy = (cy + xy * x + yy * y))
|
13647 | );
|
13648 | }
|
13649 | },
|
13650 |
|
13651 | onClose: function(sx, sy, ex, ey){
|
13652 | this.onLine(sx, sy, ex, ey);
|
13653 | }
|
13654 |
|
13655 | });
|
13656 |
|
13657 | var CanvasPath = _class(path$2, {
|
13658 |
|
13659 | initialize: function(path){
|
13660 | this.reset();
|
13661 | if (path instanceof CanvasPath){
|
13662 | this.path = path.path.slice(0);
|
13663 | } else if (path){
|
13664 | if (path.applyToPath)
|
13665 | path.applyToPath(this);
|
13666 | else
|
13667 | this.push(path);
|
13668 | }
|
13669 | },
|
13670 |
|
13671 | onReset: function(){
|
13672 | this.path = [];
|
13673 | },
|
13674 |
|
13675 | onMove: function(sx, sy, x, y){
|
13676 | this.path.push(function(context){
|
13677 | context.moveTo(x, y);
|
13678 | });
|
13679 | },
|
13680 |
|
13681 | onLine: function(sx, sy, x, y){
|
13682 | this.path.push(function(context){
|
13683 | context.lineTo(x, y);
|
13684 | });
|
13685 | },
|
13686 |
|
13687 | onBezierCurve: function(sx, sy, p1x, p1y, p2x, p2y, x, y){
|
13688 | this.path.push(function(context){
|
13689 | context.bezierCurveTo(p1x, p1y, p2x, p2y, x, y);
|
13690 | });
|
13691 | },
|
13692 |
|
13693 | _arcToBezier: path$2.prototype.onArc,
|
13694 |
|
13695 | onArc: function(sx, sy, ex, ey, cx, cy, rx, ry, sa, ea, ccw, rotation){
|
13696 | if (rx != ry || rotation) return this._arcToBezier(sx, sy, ex, ey, cx, cy, rx, ry, sa, ea, ccw, rotation);
|
13697 | this.path.push(function(context){
|
13698 | context.arc(cx, cy, rx, sa, ea, ccw);
|
13699 | });
|
13700 | },
|
13701 |
|
13702 | onClose: function(){
|
13703 | this.path.push(function(context){
|
13704 | context.closePath();
|
13705 | });
|
13706 | },
|
13707 |
|
13708 | toCommands: function(){
|
13709 | return this.path.slice(0);
|
13710 | }
|
13711 |
|
13712 | });
|
13713 |
|
13714 | var path = CanvasPath;
|
13715 |
|
13716 | var colors = {
|
13717 | maroon: '#800000', red: '#ff0000', orange: '#ffA500', yellow: '#ffff00', olive: '#808000',
|
13718 | purple: '#800080', fuchsia: "#ff00ff", white: '#ffffff', lime: '#00ff00', green: '#008000',
|
13719 | navy: '#000080', blue: '#0000ff', aqua: '#00ffff', teal: '#008080',
|
13720 | black: '#000000', silver: '#c0c0c0', gray: '#808080'
|
13721 | };
|
13722 |
|
13723 | var map = function(array, fn){
|
13724 | var results = [];
|
13725 | for (var i = 0, l = array.length; i < l; i++)
|
13726 | results[i] = fn(array[i], i);
|
13727 | return results;
|
13728 | };
|
13729 |
|
13730 | var Color = function(color, type){
|
13731 |
|
13732 | if (color.isColor){
|
13733 |
|
13734 | this.red = color.red;
|
13735 | this.green = color.green;
|
13736 | this.blue = color.blue;
|
13737 | this.alpha = color.alpha;
|
13738 |
|
13739 | } else {
|
13740 |
|
13741 | var namedColor = colors[color];
|
13742 | if (namedColor){
|
13743 | color = namedColor;
|
13744 | type = 'hex';
|
13745 | }
|
13746 |
|
13747 | switch (typeof color){
|
13748 | case 'string': if (!type) type = (type = color.match(/^rgb|^hsb|^hsl/)) ? type[0] : 'hex'; break;
|
13749 | case 'object': type = type || 'rgb'; color = color.toString(); break;
|
13750 | case 'number': type = 'hex'; color = color.toString(16); break;
|
13751 | }
|
13752 |
|
13753 | color = Color['parse' + type.toUpperCase()](color);
|
13754 | this.red = color[0];
|
13755 | this.green = color[1];
|
13756 | this.blue = color[2];
|
13757 | this.alpha = color[3];
|
13758 | }
|
13759 |
|
13760 | this.isColor = true;
|
13761 |
|
13762 | };
|
13763 |
|
13764 | var limit = function(number, min, max){
|
13765 | return Math.min(max, Math.max(min, number));
|
13766 | };
|
13767 |
|
13768 | var listMatch = /([-.\d]+\%?)\s*,\s*([-.\d]+\%?)\s*,\s*([-.\d]+\%?)\s*,?\s*([-.\d]*\%?)/;
|
13769 | var hexMatch = /^#?([a-f0-9]{1,2})([a-f0-9]{1,2})([a-f0-9]{1,2})([a-f0-9]{0,2})$/i;
|
13770 |
|
13771 | Color.parseRGB = function(color){
|
13772 | return map(color.match(listMatch).slice(1), function(bit, i){
|
13773 | if (bit) bit = parseFloat(bit) * (bit[bit.length - 1] == '%' ? 2.55 : 1);
|
13774 | return (i < 3) ? Math.round(((bit %= 256) < 0) ? bit + 256 : bit) : limit(((bit === '') ? 1 : Number(bit)), 0, 1);
|
13775 | });
|
13776 | };
|
13777 |
|
13778 | Color.parseHEX = function(color){
|
13779 | if (color.length == 1) color = color + color + color;
|
13780 | return map(color.match(hexMatch).slice(1), function(bit, i){
|
13781 | if (i == 3) return (bit) ? parseInt(bit, 16) / 255 : 1;
|
13782 | return parseInt((bit.length == 1) ? bit + bit : bit, 16);
|
13783 | });
|
13784 | };
|
13785 |
|
13786 | Color.parseHSB = function(color){
|
13787 | var hsb = map(color.match(listMatch).slice(1), function(bit, i){
|
13788 | if (bit) bit = parseFloat(bit);
|
13789 | if (i === 0) return Math.round(((bit %= 360) < 0) ? (bit + 360) : bit);
|
13790 | else if (i < 3) return limit(Math.round(bit), 0, 100);
|
13791 | else return limit(((bit === '') ? 1 : Number(bit)), 0, 1);
|
13792 | });
|
13793 |
|
13794 | var a = hsb[3];
|
13795 | var br = Math.round(hsb[2] / 100 * 255);
|
13796 | if (hsb[1] == 0) return [br, br, br, a];
|
13797 |
|
13798 | var hue = hsb[0];
|
13799 | var f = hue % 60;
|
13800 | var p = Math.round((hsb[2] * (100 - hsb[1])) / 10000 * 255);
|
13801 | var q = Math.round((hsb[2] * (6000 - hsb[1] * f)) / 600000 * 255);
|
13802 | var t = Math.round((hsb[2] * (6000 - hsb[1] * (60 - f))) / 600000 * 255);
|
13803 |
|
13804 | switch (Math.floor(hue / 60)){
|
13805 | case 0: return [br, t, p, a];
|
13806 | case 1: return [q, br, p, a];
|
13807 | case 2: return [p, br, t, a];
|
13808 | case 3: return [p, q, br, a];
|
13809 | case 4: return [t, p, br, a];
|
13810 | default: return [br, p, q, a];
|
13811 | }
|
13812 | };
|
13813 |
|
13814 | Color.parseHSL = function(color){
|
13815 | var hsb = map(color.match(listMatch).slice(1), function(bit, i){
|
13816 | if (bit) bit = parseFloat(bit);
|
13817 | if (i === 0) return Math.round(((bit %= 360) < 0) ? (bit + 360) : bit);
|
13818 | else if (i < 3) return limit(Math.round(bit), 0, 100);
|
13819 | else return limit(((bit === '') ? 1 : Number(bit)), 0, 1);
|
13820 | });
|
13821 |
|
13822 | var h = hsb[0] / 60;
|
13823 | var s = hsb[1] / 100;
|
13824 | var l = hsb[2] / 100;
|
13825 | var a = hsb[3];
|
13826 |
|
13827 | var c = (1 - Math.abs(2 * l - 1)) * s;
|
13828 | var x = c * (1 - Math.abs(h % 2 - 1));
|
13829 | var m = l - c / 2;
|
13830 |
|
13831 | var p = Math.round((c + m) * 255);
|
13832 | var q = Math.round((x + m) * 255);
|
13833 | var t = Math.round((m) * 255);
|
13834 |
|
13835 | switch (Math.floor(h)){
|
13836 | case 0: return [p, q, t, a];
|
13837 | case 1: return [q, p, t, a];
|
13838 | case 2: return [t, p, q, a];
|
13839 | case 3: return [t, q, p, a];
|
13840 | case 4: return [q, t, p, a];
|
13841 | default: return [p, t, q, a];
|
13842 | }
|
13843 | };
|
13844 |
|
13845 | var toString = function(type, array){
|
13846 | if (array[3] != 1) type += 'a';
|
13847 | else array.pop();
|
13848 | return type + '(' + array.join(', ') + ')';
|
13849 | };
|
13850 |
|
13851 | Color.prototype = {
|
13852 |
|
13853 | toHSB: function(array){
|
13854 | var red = this.red, green = this.green, blue = this.blue, alpha = this.alpha;
|
13855 |
|
13856 | var max = Math.max(red, green, blue), min = Math.min(red, green, blue), delta = max - min;
|
13857 | var hue = 0, saturation = (delta != 0) ? delta / max : 0, brightness = max / 255;
|
13858 | if (saturation){
|
13859 | var rr = (max - red) / delta, gr = (max - green) / delta, br = (max - blue) / delta;
|
13860 | hue = (red == max) ? br - gr : (green == max) ? 2 + rr - br : 4 + gr - rr;
|
13861 | if ((hue /= 6) < 0) hue++;
|
13862 | }
|
13863 |
|
13864 | var hsb = [Math.round(hue * 360), Math.round(saturation * 100), Math.round(brightness * 100), alpha];
|
13865 |
|
13866 | return (array) ? hsb : toString('hsb', hsb);
|
13867 | },
|
13868 |
|
13869 | toHSL: function(array){
|
13870 | var red = this.red, green = this.green, blue = this.blue, alpha = this.alpha;
|
13871 |
|
13872 | var max = Math.max(red, green, blue), min = Math.min(red, green, blue), delta = max - min;
|
13873 | var hue = 0, saturation = (delta != 0) ? delta / (255 - Math.abs((max + min) - 255)) : 0, lightness = (max + min) / 512;
|
13874 | if (saturation){
|
13875 | var rr = (max - red) / delta, gr = (max - green) / delta, br = (max - blue) / delta;
|
13876 | hue = (red == max) ? br - gr : (green == max) ? 2 + rr - br : 4 + gr - rr;
|
13877 | if ((hue /= 6) < 0) hue++;
|
13878 | }
|
13879 |
|
13880 | var hsl = [Math.round(hue * 360), Math.round(saturation * 100), Math.round(lightness * 100), alpha];
|
13881 |
|
13882 | return (array) ? hsl : toString('hsl', hsl);
|
13883 | },
|
13884 |
|
13885 | toHEX: function(array){
|
13886 |
|
13887 | var a = this.alpha;
|
13888 | var alpha = ((a = Math.round((a * 255)).toString(16)).length == 1) ? a + a : a;
|
13889 |
|
13890 | var hex = map([this.red, this.green, this.blue], function(bit){
|
13891 | bit = bit.toString(16);
|
13892 | return (bit.length == 1) ? '0' + bit : bit;
|
13893 | });
|
13894 |
|
13895 | return (array) ? hex.concat(alpha) : '#' + hex.join('') + ((alpha == 'ff') ? '' : alpha);
|
13896 | },
|
13897 |
|
13898 | toRGB: function(array){
|
13899 | var rgb = [this.red, this.green, this.blue, this.alpha];
|
13900 | return (array) ? rgb : toString('rgb', rgb);
|
13901 | }
|
13902 |
|
13903 | };
|
13904 |
|
13905 | Color.prototype.toString = Color.prototype.toRGB;
|
13906 |
|
13907 | Color.hex = function(hex){
|
13908 | return new Color(hex, 'hex');
|
13909 | };
|
13910 |
|
13911 | if (commonjsGlobal.hex == null) commonjsGlobal.hex = Color.hex;
|
13912 |
|
13913 | Color.hsb = function(h, s, b, a){
|
13914 | return new Color([h || 0, s || 0, b || 0, (a == null) ? 1 : a], 'hsb');
|
13915 | };
|
13916 |
|
13917 | if (commonjsGlobal.hsb == null) commonjsGlobal.hsb = Color.hsb;
|
13918 |
|
13919 | Color.hsl = function(h, s, l, a){
|
13920 | return new Color([h || 0, s || 0, l || 0, (a == null) ? 1 : a], 'hsl');
|
13921 | };
|
13922 |
|
13923 | if (commonjsGlobal.hsl == null) commonjsGlobal.hsl = Color.hsl;
|
13924 |
|
13925 | Color.rgb = function(r, g, b, a){
|
13926 | return new Color([r || 0, g || 0, b || 0, (a == null) ? 1 : a], 'rgb');
|
13927 | };
|
13928 |
|
13929 | if (commonjsGlobal.rgb == null) commonjsGlobal.rgb = Color.rgb;
|
13930 |
|
13931 | Color.detach = function(color){
|
13932 | color = new Color(color);
|
13933 | return [Color.rgb(color.red, color.green, color.blue).toString(), color.alpha];
|
13934 | };
|
13935 |
|
13936 | var color = Color;
|
13937 |
|
13938 | var dummy = _class({
|
13939 |
|
13940 |
|
13941 |
|
13942 | _resetPlacement: function(){
|
13943 | var container = this.parentNode;
|
13944 | if (container){
|
13945 | var previous = this.previousSibling, next = this.nextSibling;
|
13946 | if (previous){
|
13947 | previous.nextSibling = next;
|
13948 | } else {
|
13949 | container.firstChild = next;
|
13950 | }
|
13951 | if (next){
|
13952 | next.previousSibling = previous;
|
13953 | } else {
|
13954 | container.lastChild = this.previousSibling;
|
13955 | }
|
13956 | }
|
13957 | this.previousSibling = null;
|
13958 | this.nextSibling = null;
|
13959 | this.parentNode = null;
|
13960 | return this;
|
13961 | },
|
13962 |
|
13963 | inject: function(container){
|
13964 | this._resetPlacement();
|
13965 | var last = container.lastChild;
|
13966 | if (last){
|
13967 | last.nextSibling = this;
|
13968 | this.previousSibling = last;
|
13969 | } else {
|
13970 | container.firstChild = this;
|
13971 | }
|
13972 | container.lastChild = this;
|
13973 | this.parentNode = container;
|
13974 | this._place();
|
13975 | return this;
|
13976 | },
|
13977 |
|
13978 | injectBefore: function(sibling){
|
13979 | this._resetPlacement();
|
13980 | var container = sibling.parentNode;
|
13981 | if (!container) return this;
|
13982 | var previous = sibling.previousSibling;
|
13983 | if (previous){
|
13984 | previous.nextSibling = this;
|
13985 | this.previousSibling = previous;
|
13986 | } else {
|
13987 | container.firstChild = this;
|
13988 | }
|
13989 | sibling.previousSibling = this;
|
13990 | this.nextSibling = sibling;
|
13991 | this.parentNode = container;
|
13992 | this._place();
|
13993 | return this;
|
13994 | },
|
13995 |
|
13996 | eject: function(){
|
13997 | this._resetPlacement();
|
13998 | this._place();
|
13999 | return this;
|
14000 | },
|
14001 |
|
14002 | _place: function(){},
|
14003 |
|
14004 |
|
14005 |
|
14006 | dispatch: function(event){
|
14007 | var events = this._events,
|
14008 | listeners = events && events[event.type];
|
14009 | if (listeners){
|
14010 | listeners = listeners.slice(0);
|
14011 | for (var i = 0, l = listeners.length; i < l; i++){
|
14012 | var fn = listeners[i], result;
|
14013 | if (typeof fn == 'function')
|
14014 | result = fn.call(this, event);
|
14015 | else
|
14016 | result = fn.handleEvent(event);
|
14017 | if (result === false) event.preventDefault();
|
14018 | }
|
14019 | }
|
14020 | if (this.parentNode && this.parentNode.dispatch){
|
14021 | this.parentNode.dispatch(event);
|
14022 | }
|
14023 | },
|
14024 |
|
14025 | subscribe: function(type, fn, bind){
|
14026 | if (typeof type != 'string'){
|
14027 | var subscriptions = [];
|
14028 | for (var t in type) subscriptions.push(this.subscribe(t, type[t]));
|
14029 | return function(){
|
14030 | for (var i = 0, l = subscriptions.length; i < l; i++)
|
14031 | subscriptions[i]();
|
14032 | return this;
|
14033 | };
|
14034 | } else {
|
14035 | var bound = typeof fn === 'function' ? fn.bind(bind || this) : fn,
|
14036 | events = this._events || (this._events = {}),
|
14037 | listeners = events[type] || (events[type] = []);
|
14038 | listeners.push(bound);
|
14039 | return function(){
|
14040 |
|
14041 | for (var i = 0, l = listeners.length; i < l; i++){
|
14042 | if (listeners[i] === bound){
|
14043 | listeners.splice(i, 1);
|
14044 | break;
|
14045 | }
|
14046 | }
|
14047 | }
|
14048 | }
|
14049 | }
|
14050 |
|
14051 | });
|
14052 |
|
14053 | var CanvasNode = _class(transform, dummy, {
|
14054 |
|
14055 | invalidate: function(){
|
14056 | if (this.parentNode) this.parentNode.invalidate();
|
14057 | if (this._layer) this._layerCache = null;
|
14058 | return this;
|
14059 | },
|
14060 |
|
14061 | _place: function(){
|
14062 | this.invalidate();
|
14063 | },
|
14064 |
|
14065 | _transform: function(){
|
14066 | this.invalidate();
|
14067 | },
|
14068 |
|
14069 | blend: function(opacity){
|
14070 | if (opacity >= 1 && this._layer) this._layer = null;
|
14071 | this._opacity = opacity;
|
14072 | if (this.parentNode) this.parentNode.invalidate();
|
14073 | return this;
|
14074 | },
|
14075 |
|
14076 |
|
14077 |
|
14078 | hide: function(){
|
14079 | this._invisible = true;
|
14080 | if (this.parentNode) this.parentNode.invalidate();
|
14081 | return this;
|
14082 | },
|
14083 |
|
14084 | show: function(){
|
14085 | this._invisible = false;
|
14086 | if (this.parentNode) this.parentNode.invalidate();
|
14087 | return this;
|
14088 | },
|
14089 |
|
14090 |
|
14091 |
|
14092 | indicate: function(cursor, tooltip){
|
14093 | this._cursor = cursor;
|
14094 | this._tooltip = tooltip;
|
14095 | return this.invalidate();
|
14096 | },
|
14097 |
|
14098 | hitTest: function(x, y){
|
14099 | if (this._invisible) return null;
|
14100 | var point = this.inversePoint(x, y);
|
14101 | if (!point) return null;
|
14102 | return this.localHitTest(point.x, point.y);
|
14103 | },
|
14104 |
|
14105 |
|
14106 |
|
14107 | renderTo: function(context, xx, yx, xy, yy, x, y){
|
14108 | var opacity = this._opacity;
|
14109 | if (opacity == null || opacity >= 1){
|
14110 | return this.renderLayerTo(context, xx, yx, xy, yy, x, y);
|
14111 | }
|
14112 |
|
14113 |
|
14114 |
|
14115 | var layer = this._layer, canvas, isDirty = true,
|
14116 | w = context.canvas.width, h = context.canvas.height;
|
14117 | if (layer){
|
14118 | layer.setTransform(1, 0, 0, 1, 0, 0);
|
14119 | canvas = layer.canvas;
|
14120 | if (canvas.width < w || canvas.height < h){
|
14121 | canvas.width = w;
|
14122 | canvas.height = h;
|
14123 | } else {
|
14124 | var c = this._layerCache;
|
14125 | if (c && c.xx === xx && c.yx === yx && c.xy === xy
|
14126 | && c.yy === yy && c.x === x && c.y === y){
|
14127 | isDirty = false;
|
14128 | } else {
|
14129 | layer.clearRect(0, 0, w, h);
|
14130 | }
|
14131 | }
|
14132 | } else {
|
14133 | canvas = document.createElement('canvas');
|
14134 | canvas.width = w;
|
14135 | canvas.height = h;
|
14136 | this._layer = layer = canvas.getContext('2d');
|
14137 | }
|
14138 |
|
14139 | if (isDirty){
|
14140 | this.renderLayerTo(layer, xx, yx, xy, yy, x, y);
|
14141 | this._layerCache = {
|
14142 | xx: xx,
|
14143 | yx: yx,
|
14144 | xy: xy,
|
14145 | yy: yy,
|
14146 | x: x,
|
14147 | y: y
|
14148 | };
|
14149 | }
|
14150 |
|
14151 | context.globalAlpha = opacity;
|
14152 | context.setTransform(1, 0, 0, 1, 0, 0);
|
14153 | context.drawImage(
|
14154 | canvas,
|
14155 | 0, 0, w, h,
|
14156 | 0, 0, w, h
|
14157 | );
|
14158 | context.globalAlpha = 1;
|
14159 | }
|
14160 |
|
14161 | });
|
14162 |
|
14163 | var node = CanvasNode;
|
14164 |
|
14165 | var genericCanvas = typeof document !== 'undefined' && document.createElement('canvas');
|
14166 | var genericContext = genericCanvas && genericCanvas.getContext && genericCanvas.getContext('2d');
|
14167 |
|
14168 | function recolorImage(img, color1, color2){
|
14169 |
|
14170 | color1 = color.detach(color1);
|
14171 | color2 = color.detach(color2);
|
14172 | var canvas = document.createElement('canvas'),
|
14173 | context = canvas.getContext('2d');
|
14174 | canvas.width = img.width;
|
14175 | canvas.height = img.height;
|
14176 | context.fillStyle = color2[0];
|
14177 | context.fillRect(0, 0, img.width, img.height);
|
14178 | context.globalCompositeOperation = 'lighter';
|
14179 | context.drawImage(img, 0, 0);
|
14180 | return canvas;
|
14181 | }
|
14182 |
|
14183 | var Base = _class(node, {
|
14184 |
|
14185 | initialize: function(){
|
14186 | this._fill = null;
|
14187 | this._pendingFill = null;
|
14188 | this._fillTransform = null;
|
14189 | this._stroke = null;
|
14190 | this._strokeCap = null;
|
14191 | this._strokeDash = null;
|
14192 | this._strokeJoin = null;
|
14193 | this._strokeWidth = null;
|
14194 | },
|
14195 |
|
14196 |
|
14197 |
|
14198 | _addColors: function(gradient, stops){
|
14199 |
|
14200 |
|
14201 | if ('length' in stops) for (var i = 0, l = stops.length - 1; i <= l; i++)
|
14202 | gradient.addColorStop(i / l, new color(stops[i]).toString());
|
14203 | else for (var offset in stops)
|
14204 | gradient.addColorStop(offset, new color(stops[offset]).toString());
|
14205 | return gradient;
|
14206 | },
|
14207 |
|
14208 |
|
14209 | fill: function(color$$1){
|
14210 | if (arguments.length > 1) return this.fillLinear(arguments);
|
14211 | if (this._pendingFill) this._pendingFill();
|
14212 | this._fill = color$$1 ? new color(color$$1).toString() : null;
|
14213 | return this.invalidate();
|
14214 | },
|
14215 |
|
14216 | fillRadial: function(stops, focusX, focusY, radiusX, radiusY, centerX, centerY){
|
14217 | if (focusX == null) focusX = (this.left || 0) + (this.width || 0) * 0.5;
|
14218 | if (focusY == null) focusY = (this.top || 0) + (this.height || 0) * 0.5;
|
14219 | if (radiusY == null) radiusY = radiusX || (this.height * 0.5) || 0;
|
14220 | if (radiusX == null) radiusX = (this.width || 0) * 0.5;
|
14221 | if (centerX == null) centerX = focusX;
|
14222 | if (centerY == null) centerY = focusY;
|
14223 |
|
14224 | centerX += centerX - focusX;
|
14225 | centerY += centerY - focusY;
|
14226 |
|
14227 | if (radiusX === 0 || radiusX === '0') return this.fillLinear(stops);
|
14228 | var ys = radiusY / radiusX;
|
14229 |
|
14230 | if (this._pendingFill) this._pendingFill();
|
14231 |
|
14232 | var gradient = genericContext.createRadialGradient(focusX, focusY / ys, 0, centerX, centerY / ys, radiusX * 2);
|
14233 |
|
14234 |
|
14235 | if ('length' in stops) for (var i = 0, l = stops.length - 1; i <= l; i++){
|
14236 | gradient.addColorStop(i / l / 2, new color(stops[i]).toString());
|
14237 | gradient.addColorStop(1 - i / l / 2, new color(stops[i]).toString());
|
14238 | } else for (var offset in stops){
|
14239 | gradient.addColorStop(offset / 2, new color(stops[offset]).toString());
|
14240 | gradient.addColorStop(1- offset / 2, new color(stops[offset]).toString());
|
14241 | }
|
14242 |
|
14243 | this._fill = gradient;
|
14244 | this._fillTransform = new transform(1, 0, 0, ys);
|
14245 | return this.invalidate();
|
14246 | },
|
14247 |
|
14248 | fillLinear: function(stops, x1, y1, x2, y2){
|
14249 | if (arguments.length < 5){
|
14250 | var angle = ((x1 == null) ? 270 : x1) * Math.PI / 180;
|
14251 |
|
14252 | var x = Math.cos(angle), y = -Math.sin(angle),
|
14253 | l = (Math.abs(x) + Math.abs(y)) / 2,
|
14254 | w = this.width || 1, h = this.height || 1;
|
14255 |
|
14256 | x *= l; y *= l;
|
14257 |
|
14258 | x1 = 0.5 - x;
|
14259 | x2 = 0.5 + x;
|
14260 | y1 = 0.5 - y;
|
14261 | y2 = 0.5 + y;
|
14262 | this._fillTransform = new transform(w, 0, 0, h);
|
14263 | } else {
|
14264 | this._fillTransform = null;
|
14265 | }
|
14266 | if (this._pendingFill) this._pendingFill();
|
14267 | var gradient = genericContext.createLinearGradient(x1, y1, x2, y2);
|
14268 | this._addColors(gradient, stops);
|
14269 | this._fill = gradient;
|
14270 | return this.invalidate();
|
14271 | },
|
14272 |
|
14273 | fillImage: function(url, width, height, left, top, color1, color2){
|
14274 | if (this._pendingFill) this._pendingFill();
|
14275 | var img = url;
|
14276 | if (!(img instanceof Image)){
|
14277 | img = new Image();
|
14278 | img.src = url;
|
14279 | }
|
14280 | if (img.width && img.height){
|
14281 | return this._fillImage(img, width, height, left || 0, top || 0, color1, color2);
|
14282 | }
|
14283 |
|
14284 |
|
14285 | this._fill = null;
|
14286 | var self = this,
|
14287 | callback = function(){
|
14288 | cancel();
|
14289 | self._fillImage(img, width, height, left || 0, top || 0, color1, color2);
|
14290 | },
|
14291 | cancel = function(){
|
14292 | img.removeEventListener('load', callback, false);
|
14293 | self._pendingFill = null;
|
14294 | };
|
14295 | this._pendingFill = cancel;
|
14296 | img.addEventListener('load', callback, false);
|
14297 | return this;
|
14298 | },
|
14299 |
|
14300 | _fillImage: function(img, width, height, left, top, color1, color2){
|
14301 | var w = width ? width / img.width : 1,
|
14302 | h = height ? height / img.height : 1;
|
14303 | if (color1 != null) img = recolorImage(img, color1, color2);
|
14304 | this._fill = genericContext.createPattern(img, 'repeat');
|
14305 | this._fillTransform = new transform(w, 0, 0, h, left || 0, top || 0);
|
14306 | return this.invalidate();
|
14307 | },
|
14308 |
|
14309 | stroke: function(color$$1, width, cap, join, dash){
|
14310 | this._stroke = color$$1 ? new color(color$$1).toString() : null;
|
14311 | this._strokeWidth = (width != null) ? width : 1;
|
14312 | this._strokeCap = (cap != null) ? cap : 'round';
|
14313 | this._strokeJoin = (join != null) ? join : 'round';
|
14314 | this._strokeDash = dash;
|
14315 | return this.invalidate();
|
14316 | },
|
14317 |
|
14318 |
|
14319 |
|
14320 | element_renderTo: node.prototype.renderTo,
|
14321 |
|
14322 | renderTo: function(context, xx, yx, xy, yy, x, y){
|
14323 | var opacity = this._opacity;
|
14324 | if (opacity == null || opacity >= 1){
|
14325 | return this.renderLayerTo(context, xx, yx, xy, yy, x, y);
|
14326 | }
|
14327 | if (this._fill && this._stroke){
|
14328 | return this.element_renderTo(context, xx, yx, xy, yy, x, y);
|
14329 | }
|
14330 | context.globalAlpha = opacity;
|
14331 | var r = this.renderLayerTo(context, xx, yx, xy, yy, x, y);
|
14332 | context.globalAlpha = 1;
|
14333 | return r;
|
14334 | },
|
14335 |
|
14336 | renderLayerTo: function(context, xx, yx, xy, yy, x, y){
|
14337 | context.setTransform(xx, yx, xy, yy, x, y);
|
14338 | this.renderShapeTo(context);
|
14339 | }
|
14340 |
|
14341 | });
|
14342 |
|
14343 | Base._genericContext = genericContext;
|
14344 |
|
14345 | var base = Base;
|
14346 |
|
14347 | var shape = _class(base, {
|
14348 |
|
14349 | base_initialize: base.prototype.initialize,
|
14350 |
|
14351 | initialize: function(path$$1, width, height){
|
14352 | this.base_initialize();
|
14353 | this.width = width;
|
14354 | this.height = height;
|
14355 | if (path$$1 != null) this.draw(path$$1);
|
14356 | },
|
14357 |
|
14358 | draw: function(path$$1, width, height){
|
14359 | if (!(path$$1 instanceof path)) path$$1 = new path(path$$1);
|
14360 | this.path = path$$1;
|
14361 | this._commands = path$$1.toCommands();
|
14362 | if (width != null) this.width = width;
|
14363 | if (height != null) this.height = height;
|
14364 | return this.invalidate();
|
14365 | },
|
14366 |
|
14367 | localHitTest: function(x, y){
|
14368 | if (!this._fill) return null;
|
14369 | if (this.width == null || this.height == null){
|
14370 | var context = base._genericContext, commands = this._commands;
|
14371 | if (!commands) return null;
|
14372 | context.beginPath();
|
14373 | for (var i = 0, l = commands.length; i < l; i++)
|
14374 | commands[i](context);
|
14375 | return context.isPointInPath(x, y) ? this : null;
|
14376 | }
|
14377 | if (x > 0 && y > 0 && x < this.width && y < this.height){
|
14378 | return this;
|
14379 | }
|
14380 | return null;
|
14381 | },
|
14382 |
|
14383 | renderShapeTo: function(context){
|
14384 | if (this._invisible || !this._commands || (!this._fill && !this._stroke)) {
|
14385 | return null;
|
14386 | }
|
14387 | context.transform(this.xx, this.yx, this.xy, this.yy, this.x, this.y);
|
14388 | var commands = this._commands,
|
14389 | fill = this._fill,
|
14390 | stroke = this._stroke,
|
14391 | dash = this._strokeDash;
|
14392 |
|
14393 | context.beginPath();
|
14394 |
|
14395 | if (dash) {
|
14396 | if (context.setLineDash) {
|
14397 | context.setLineDash(dash);
|
14398 | } else {
|
14399 |
|
14400 | context.mozDash = dash;
|
14401 | }
|
14402 |
|
14403 | } else {
|
14404 | if (context.setLineDash) {
|
14405 | context.setLineDash([]);
|
14406 | } else {
|
14407 | context.mozDash = null;
|
14408 | }
|
14409 | }
|
14410 |
|
14411 | for (var i = 0, l = commands.length; i < l; i++)
|
14412 | commands[i](context);
|
14413 |
|
14414 | if (fill){
|
14415 | var m = this._fillTransform;
|
14416 | if (m){
|
14417 | context.save();
|
14418 | context.transform(m.xx, m.yx, m.xy, m.yy, m.x, m.y);
|
14419 | context.fillStyle = fill;
|
14420 | context.fill();
|
14421 | context.restore();
|
14422 | } else {
|
14423 | context.fillStyle = fill;
|
14424 | context.fill();
|
14425 | }
|
14426 | }
|
14427 | if (stroke){
|
14428 | context.strokeStyle = stroke;
|
14429 | context.lineWidth = this._strokeWidth;
|
14430 | context.lineCap = this._strokeCap;
|
14431 | context.lineJoin = this._strokeJoin;
|
14432 | context.stroke();
|
14433 | }
|
14434 | }
|
14435 |
|
14436 | });
|
14437 |
|
14438 | var group = _class(node, container, {
|
14439 |
|
14440 | initialize: function(width, height){
|
14441 | this.width = width;
|
14442 | this.height = height;
|
14443 | },
|
14444 |
|
14445 | localHitTest: function(x, y){
|
14446 | var node$$2 = this.lastChild;
|
14447 | while (node$$2){
|
14448 | var hit = node$$2.hitTest(x, y);
|
14449 | if (hit) return hit;
|
14450 | node$$2 = node$$2.previousSibling;
|
14451 | }
|
14452 | return null;
|
14453 | },
|
14454 |
|
14455 | renderLayerTo: function(context, xx, yx, xy, yy, x, y){
|
14456 | if (this._invisible) return;
|
14457 |
|
14458 | x = xx * this.x + xy * this.y + x;
|
14459 | y = yx * this.x + yy * this.y + y;
|
14460 |
|
14461 | var t = xx;
|
14462 | xx = t * this.xx + xy * this.yx;
|
14463 | xy = t * this.xy + xy * this.yy;
|
14464 | t = yx;
|
14465 | yx = t * this.xx + yy * this.yx;
|
14466 | yy = t * this.xy + yy * this.yy;
|
14467 |
|
14468 | var node$$2 = this.firstChild;
|
14469 | while (node$$2){
|
14470 | node$$2.renderTo(context, xx, yx, xy, yy, x, y);
|
14471 | node$$2 = node$$2.nextSibling;
|
14472 | }
|
14473 | }
|
14474 |
|
14475 | });
|
14476 |
|
14477 | var clippingrectangle = _class(node, container, {
|
14478 |
|
14479 | initialize: function(width, height){
|
14480 | this.width = width;
|
14481 | this.height = height;
|
14482 | },
|
14483 |
|
14484 | localHitTest: function(x, y) {
|
14485 | var node$$2 = this.lastChild;
|
14486 | while (node$$2){
|
14487 | var hit = node$$2.hitTest(x, y);
|
14488 | if (hit) return hit;
|
14489 | node$$2 = node$$2.previousSibling;
|
14490 | }
|
14491 | return null;
|
14492 | },
|
14493 |
|
14494 | renderLayerTo: function(context, xx, yx, xy, yy, x, y) {
|
14495 | context.setTransform(xx, yx, xy, yy, x, y);
|
14496 | context.save();
|
14497 |
|
14498 | context.beginPath();
|
14499 | context.rect(this.x, this.y, this.width, this.height);
|
14500 | context.clip();
|
14501 |
|
14502 | var node$$2 = this.firstChild;
|
14503 | while(node$$2) {
|
14504 | node$$2.renderTo(context, xx, yx, xy, yy, x, y);
|
14505 | node$$2 = node$$2.nextSibling;
|
14506 | }
|
14507 | context.restore();
|
14508 | }
|
14509 | });
|
14510 |
|
14511 | var fontAnchors = { middle: 'center' };
|
14512 |
|
14513 | var text = _class(base, {
|
14514 |
|
14515 | base_initialize: base.prototype.initialize,
|
14516 |
|
14517 | initialize: function(text, font, alignment, path){
|
14518 | this.base_initialize();
|
14519 | this.draw.apply(this, arguments);
|
14520 | },
|
14521 |
|
14522 | draw: function(text, font, alignment, path){
|
14523 | var em;
|
14524 | if (typeof font == 'string'){
|
14525 | em = Number(/(\d+)/.exec(font)[0]);
|
14526 | } else if (font){
|
14527 | em = parseFloat(font.fontSize || font['font-size'] || '12');
|
14528 | font = (font.fontStyle || font['font-style'] || '') + ' ' +
|
14529 | (font.fontVariant || font['font-variant'] || '') + ' ' +
|
14530 | (font.fontWeight || font['font-weight'] || '') + ' ' +
|
14531 | em + 'px ' +
|
14532 | (font.fontFamily || font['font-family'] || 'Arial');
|
14533 | } else {
|
14534 | font = this._font;
|
14535 | }
|
14536 |
|
14537 | var lines = text && text.split(/\r?\n/);
|
14538 | this._font = font;
|
14539 | this._fontSize = em;
|
14540 | this._text = lines;
|
14541 | this._alignment = fontAnchors[alignment] || alignment || 'left';
|
14542 |
|
14543 | var context = base._genericContext;
|
14544 |
|
14545 | context.font = this._font;
|
14546 | context.textAlign = this._alignment;
|
14547 | context.textBaseline = 'middle';
|
14548 |
|
14549 | lines = this._text;
|
14550 | var l = lines.length, width = 0;
|
14551 | for (var i = 0; i < l; i++){
|
14552 | var w = context.measureText(lines[i]).width;
|
14553 | if (w > width) width = w;
|
14554 | }
|
14555 | this.width = width;
|
14556 | this.height = l ? l * 1.1 * em : 0;
|
14557 | return this.invalidate();
|
14558 | },
|
14559 |
|
14560 |
|
14561 |
|
14562 | localHitTest: function(x, y){
|
14563 | if (!this._fill) return null;
|
14564 | if (x > 0 && y > 0 && x < this.width && y < this.height){
|
14565 | return this;
|
14566 | }
|
14567 | return null;
|
14568 | },
|
14569 |
|
14570 |
|
14571 |
|
14572 | renderShapeTo: function(context){
|
14573 | if (this._invisible || !this._text || (!this._fill && !this._stroke)) {
|
14574 | return null;
|
14575 | }
|
14576 | context.transform(this.xx, this.yx, this.xy, this.yy, this.x, this.y);
|
14577 | var fill = this._fill,
|
14578 | stroke = this._stroke,
|
14579 | text = this._text,
|
14580 | dash = this._strokeDash;
|
14581 |
|
14582 | context.font = this._font;
|
14583 | context.textAlign = this._alignment;
|
14584 | context.textBaseline = 'middle';
|
14585 |
|
14586 | var em = this._fontSize,
|
14587 | y = em / 2,
|
14588 | lineHeight = 1.1 * em,
|
14589 | lines = text,
|
14590 | l = lines.length;
|
14591 |
|
14592 | if (fill){
|
14593 | context.fillStyle = fill;
|
14594 | for (var i = 0; i < l; i++)
|
14595 | context.fillText(lines[i], 0, y + i * lineHeight);
|
14596 | }
|
14597 | if (stroke){
|
14598 | if (dash) {
|
14599 | if (context.setLineDash) {
|
14600 | context.setLineDash(dash);
|
14601 | } else {
|
14602 |
|
14603 | context.mozDash = dash;
|
14604 | }
|
14605 |
|
14606 | } else {
|
14607 | if (context.setLineDash) {
|
14608 | context.setLineDash([]);
|
14609 | } else {
|
14610 | context.mozDash = null;
|
14611 | }
|
14612 | }
|
14613 |
|
14614 | context.strokeStyle = stroke;
|
14615 | context.lineWidth = this._strokeWidth;
|
14616 | context.lineCap = this._strokeCap;
|
14617 | context.lineJoin = this._strokeJoin;
|
14618 | for (i = 0; i < l; i++)
|
14619 | context.strokeText(lines[i], 0, y + i * lineHeight);
|
14620 | }
|
14621 | }
|
14622 |
|
14623 | });
|
14624 |
|
14625 | var VMLCSS = 'behavior:url(#default#VML);display:inline-block;position:absolute;left:0px;top:0px;';
|
14626 |
|
14627 | var styleSheet;
|
14628 | var styledTags = {};
|
14629 | var styleTag = function(tag){
|
14630 | if (styleSheet) styledTags[tag] = styleSheet.addRule('av\\:' + tag, VMLCSS);
|
14631 | };
|
14632 |
|
14633 | var init = function(document){
|
14634 |
|
14635 | var namespaces;
|
14636 | try {
|
14637 | namespaces = document.namespaces;
|
14638 | } catch (e) {
|
14639 | }
|
14640 | if (!namespaces) return false;
|
14641 |
|
14642 | namespaces.add('av', 'urn:schemas-microsoft-com:vml');
|
14643 | namespaces.add('ao', 'urn:schemas-microsoft-com:office:office');
|
14644 |
|
14645 | styleSheet = document.createStyleSheet();
|
14646 | styleSheet.addRule('vml', 'display:inline-block;position:relative;overflow:hidden;');
|
14647 |
|
14648 |
|
14649 |
|
14650 |
|
14651 |
|
14652 |
|
14653 |
|
14654 | styleTag('vml');
|
14655 |
|
14656 | return true;
|
14657 |
|
14658 | };
|
14659 |
|
14660 | var createElement = function(tag){
|
14661 | if (!(tag in styledTags)) styleTag(tag);
|
14662 | return document.createElement('av:' + tag);
|
14663 | };
|
14664 |
|
14665 | var dom = {
|
14666 | init: init,
|
14667 | createElement: createElement
|
14668 | };
|
14669 |
|
14670 | var precision = 100;
|
14671 |
|
14672 | var VMLSurface = _class(native_1, container, {
|
14673 |
|
14674 | initialize: function VMLSurface(width, height, existingElement){
|
14675 | this.element = existingElement || document.createElement('vml');
|
14676 | this.containerElement = dom.createElement('group');
|
14677 | this.element.appendChild(this.containerElement);
|
14678 | if (width != null && height != null) this.resize(width, height);
|
14679 | },
|
14680 |
|
14681 | resize: function(width, height){
|
14682 | this.width = width;
|
14683 | this.height = height;
|
14684 |
|
14685 | var style = this.element.style;
|
14686 | style.pixelWidth = width;
|
14687 | style.pixelHeight = height;
|
14688 |
|
14689 | style = this.containerElement.style;
|
14690 | style.width = width;
|
14691 | style.height = height;
|
14692 |
|
14693 | var halfPixel = (0.5 * precision);
|
14694 |
|
14695 | this.containerElement.coordorigin = halfPixel + ',' + halfPixel;
|
14696 | this.containerElement.coordsize = (width * precision) + ',' + (height * precision);
|
14697 |
|
14698 | return this;
|
14699 | }
|
14700 |
|
14701 | });
|
14702 |
|
14703 | VMLSurface.tagName = 'av:vml';
|
14704 |
|
14705 | var surface$2 = VMLSurface;
|
14706 |
|
14707 | var precision$1 = 100;
|
14708 |
|
14709 | var round = Math.round;
|
14710 |
|
14711 | var VMLPath = _class(path$2, {
|
14712 |
|
14713 | initialize: function(path){
|
14714 | this.reset();
|
14715 | if (path instanceof VMLPath){
|
14716 | this.path = [Array.prototype.join.call(path.path, ' ')];
|
14717 | } else if (path){
|
14718 | if (path.applyToPath)
|
14719 | path.applyToPath(this);
|
14720 | else
|
14721 | this.push(path);
|
14722 | }
|
14723 | },
|
14724 |
|
14725 | onReset: function(){
|
14726 | this.path = [];
|
14727 | },
|
14728 |
|
14729 | onMove: function(sx, sy, x, y){
|
14730 | this.path.push('m', round(x * precision$1), round(y * precision$1));
|
14731 | },
|
14732 |
|
14733 | onLine: function(sx, sy, x, y){
|
14734 | this.path.push('l', round(x * precision$1), round(y * precision$1));
|
14735 | },
|
14736 |
|
14737 | onBezierCurve: function(sx, sy, p1x, p1y, p2x, p2y, x, y){
|
14738 | this.path.push('c',
|
14739 | round(p1x * precision$1), round(p1y * precision$1),
|
14740 | round(p2x * precision$1), round(p2y * precision$1),
|
14741 | round(x * precision$1), round(y * precision$1)
|
14742 | );
|
14743 | },
|
14744 |
|
14745 | _arcToBezier: path$2.prototype.onArc,
|
14746 |
|
14747 | onArc: function(sx, sy, ex, ey, cx, cy, rx, ry, sa, ea, ccw, rotation){
|
14748 | if (rx != ry || rotation) return this._arcToBezier(sx, sy, ex, ey, cx, cy, rx, ry, sa, ea, ccw, rotation);
|
14749 | cx *= precision$1;
|
14750 | cy *= precision$1;
|
14751 | rx *= precision$1;
|
14752 | this.path.push(ccw ? 'at' : 'wa',
|
14753 | round(cx - rx), round(cy - rx),
|
14754 | round(cx + rx), round(cy + rx),
|
14755 | round(sx * precision$1), round(sy * precision$1),
|
14756 | round(ex * precision$1), round(ey * precision$1)
|
14757 | );
|
14758 | },
|
14759 |
|
14760 | onClose: function(){
|
14761 | this.path.push('x');
|
14762 | },
|
14763 |
|
14764 | toVML: function(){
|
14765 | return this.path.join(' ');
|
14766 | }
|
14767 |
|
14768 | });
|
14769 |
|
14770 | VMLPath.prototype.toString = VMLPath.prototype.toVML;
|
14771 |
|
14772 | var path$4 = VMLPath;
|
14773 |
|
14774 | var shadow = _class(dummy, native_1, {
|
14775 |
|
14776 | dummy_inject: dummy.prototype.inject,
|
14777 | dummy_injectBefore: dummy.prototype.injectBefore,
|
14778 | dummy_eject: dummy.prototype.eject,
|
14779 | native_inject: native_1.prototype.inject,
|
14780 | native_injectBefore: native_1.prototype.injectBefore,
|
14781 | native_eject: native_1.prototype.eject,
|
14782 |
|
14783 | inject: function(container){
|
14784 | this.dummy_inject(container);
|
14785 | this.native_inject(container);
|
14786 | return this;
|
14787 | },
|
14788 |
|
14789 | injectBefore: function(sibling){
|
14790 | this.dummy_injectBefore(sibling);
|
14791 | this.native_injectBefore(sibling);
|
14792 | return this;
|
14793 | },
|
14794 |
|
14795 | eject: function(){
|
14796 | this.dummy_eject();
|
14797 | this.native_eject();
|
14798 | return this;
|
14799 | }
|
14800 |
|
14801 | });
|
14802 |
|
14803 | var node$2 = _class(shadow, transform, {
|
14804 |
|
14805 | initialize: function(tag){
|
14806 |
|
14807 | var element = this.element = dom.createElement(tag);
|
14808 |
|
14809 | },
|
14810 |
|
14811 | _place: function(){
|
14812 | if (this.parentNode){
|
14813 | this._transform();
|
14814 | }
|
14815 | },
|
14816 |
|
14817 |
|
14818 |
|
14819 | hide: function(){
|
14820 | this.element.style.display = 'none';
|
14821 | return this;
|
14822 | },
|
14823 |
|
14824 | show: function(){
|
14825 | this.element.style.display = '';
|
14826 | return this;
|
14827 | },
|
14828 |
|
14829 |
|
14830 |
|
14831 | indicate: function(cursor, tooltip){
|
14832 | if (cursor) this.element.style.cursor = cursor;
|
14833 | if (tooltip) this.element.title = tooltip;
|
14834 | return this;
|
14835 | }
|
14836 |
|
14837 | });
|
14838 |
|
14839 | var precision$3 = 100;
|
14840 |
|
14841 | var defaultBox = { left: 0, top: 0, width: 500, height: 500 };
|
14842 |
|
14843 | var base$2 = _class(node$2, {
|
14844 |
|
14845 | element_initialize: node$2.prototype.initialize,
|
14846 |
|
14847 | initialize: function(tag){
|
14848 | this.element_initialize(tag);
|
14849 | var element = this.element;
|
14850 |
|
14851 | var skew = this.skewElement = dom.createElement('skew');
|
14852 | skew.on = true;
|
14853 | element.appendChild(skew);
|
14854 |
|
14855 | var fill = this.fillElement = dom.createElement('fill');
|
14856 | fill.on = false;
|
14857 | element.appendChild(fill);
|
14858 |
|
14859 | var stroke = this.strokeElement = dom.createElement('stroke');
|
14860 | stroke.on = false;
|
14861 | element.appendChild(stroke);
|
14862 | },
|
14863 |
|
14864 |
|
14865 |
|
14866 | _transform: function(){
|
14867 | var container = this.parentNode;
|
14868 |
|
14869 |
|
14870 | var m = container ? new transform(container._activeTransform).transform(this) : this;
|
14871 |
|
14872 |
|
14873 |
|
14874 | var box = this._boxCoords || this._size || defaultBox;
|
14875 |
|
14876 | var originX = box.left || 0,
|
14877 | originY = box.top || 0,
|
14878 | width = box.width || 1,
|
14879 | height = box.height || 1;
|
14880 |
|
14881 |
|
14882 | var flip = m.yx / m.xx > m.yy / m.xy;
|
14883 | if (m.xx < 0 ? m.xy >= 0 : m.xy < 0) flip = !flip;
|
14884 | flip = flip ? -1 : 1;
|
14885 |
|
14886 | m = new transform().scale(flip, 1).transform(m);
|
14887 |
|
14888 |
|
14889 | var rotation = Math.atan2(-m.xy, m.yy) * 180 / Math.PI;
|
14890 |
|
14891 |
|
14892 | var rad = rotation * Math.PI / 180, sin = Math.sin(rad), cos = Math.cos(rad);
|
14893 |
|
14894 | var transform$$2 = new transform(
|
14895 | (m.xx * cos - m.xy * sin),
|
14896 | (m.yx * cos - m.yy * sin) * flip,
|
14897 | (m.xy * cos + m.xx * sin) * flip,
|
14898 | (m.yy * cos + m.yx * sin)
|
14899 | );
|
14900 |
|
14901 | var rotationTransform = new transform().rotate(rotation, 0, 0);
|
14902 |
|
14903 | var shapeToBox = new transform().rotate(-rotation, 0, 0).transform(m).moveTo(0,0);
|
14904 |
|
14905 |
|
14906 | width *= Math.abs(shapeToBox.xx);
|
14907 | height *= Math.abs(shapeToBox.yy);
|
14908 |
|
14909 |
|
14910 | var left = m.x, top = m.y;
|
14911 |
|
14912 |
|
14913 | var vx = -width / 2, vy = -height / 2;
|
14914 | var point = rotationTransform.point(vx, vy);
|
14915 | left -= point.x - vx;
|
14916 | top -= point.y - vy;
|
14917 |
|
14918 |
|
14919 | var rsm = new transform(m).moveTo(0,0);
|
14920 | point = rsm.point(originX, originY);
|
14921 | left += point.x;
|
14922 | top += point.y;
|
14923 |
|
14924 | if (flip < 0) left = -left - width;
|
14925 |
|
14926 |
|
14927 | var point0 = rsm.point(-originX, -originY);
|
14928 | var point1 = rotationTransform.point(width, height);
|
14929 | var point2 = rotationTransform.point(width, 0);
|
14930 | var point3 = rotationTransform.point(0, height);
|
14931 |
|
14932 | var minX = Math.min(0, point1.x, point2.x, point3.x),
|
14933 | maxX = Math.max(0, point1.x, point2.x, point3.x),
|
14934 | minY = Math.min(0, point1.y, point2.y, point3.y),
|
14935 | maxY = Math.max(0, point1.y, point2.y, point3.y);
|
14936 |
|
14937 | var transformOriginX = (point0.x - point1.x / 2) / (maxX - minX) * flip,
|
14938 | transformOriginY = (point0.y - point1.y / 2) / (maxY - minY);
|
14939 |
|
14940 |
|
14941 | point = shapeToBox.point(originX, originY);
|
14942 | originX = point.x;
|
14943 | originY = point.y;
|
14944 |
|
14945 |
|
14946 | var strokeWidth = this._strokeWidth;
|
14947 | if (strokeWidth){
|
14948 |
|
14949 |
|
14950 | var vx = m.xx + m.xy, vy = m.yy + m.yx;
|
14951 | strokeWidth *= Math.sqrt(vx * vx + vy * vy) / Math.sqrt(2);
|
14952 | }
|
14953 |
|
14954 |
|
14955 | originX *= precision$3;
|
14956 | originY *= precision$3;
|
14957 | left *= precision$3;
|
14958 | top *= precision$3;
|
14959 | width *= precision$3;
|
14960 | height *= precision$3;
|
14961 |
|
14962 |
|
14963 | var element = this.element;
|
14964 | element.coordorigin = originX + ',' + originY;
|
14965 | element.coordsize = width + ',' + height;
|
14966 | element.style.left = left + 'px';
|
14967 | element.style.top = top + 'px';
|
14968 | element.style.width = width;
|
14969 | element.style.height = height;
|
14970 | element.style.rotation = rotation.toFixed(8);
|
14971 | element.style.flip = flip < 0 ? 'x' : '';
|
14972 |
|
14973 |
|
14974 | var skew = this.skewElement;
|
14975 | skew.matrix = [transform$$2.xx.toFixed(4), transform$$2.xy.toFixed(4), transform$$2.yx.toFixed(4), transform$$2.yy.toFixed(4), 0, 0];
|
14976 | skew.origin = transformOriginX + ',' + transformOriginY;
|
14977 |
|
14978 |
|
14979 | this.strokeElement.weight = strokeWidth + 'px';
|
14980 | },
|
14981 |
|
14982 |
|
14983 |
|
14984 | _createGradient: function(style, stops){
|
14985 | var fill = this.fillElement;
|
14986 |
|
14987 |
|
14988 | this.element.removeChild(fill);
|
14989 |
|
14990 | fill.type = style;
|
14991 | fill.method = 'none';
|
14992 | fill.rotate = true;
|
14993 |
|
14994 | var colors = [], color1, color2;
|
14995 |
|
14996 | var addColor = function(offset, color$$2){
|
14997 | color$$2 = color.detach(color$$2);
|
14998 | if (color1 == null) color1 = color2 = color$$2;
|
14999 | else color2 = color$$2;
|
15000 | colors.push(offset + ' ' + color$$2[0]);
|
15001 | };
|
15002 |
|
15003 |
|
15004 | if ('length' in stops) for (var i = 0, l = stops.length - 1; i <= l; i++) addColor(i / l, stops[i]);
|
15005 | else for (var offset in stops) addColor(offset, stops[offset]);
|
15006 |
|
15007 | fill.color = color1[0];
|
15008 | fill.color2 = color2[0];
|
15009 |
|
15010 |
|
15011 | fill.colors = colors;
|
15012 |
|
15013 |
|
15014 | fill.opacity = color2[1];
|
15015 | fill['ao:opacity2'] = color1[1];
|
15016 |
|
15017 | fill.on = true;
|
15018 | this.element.appendChild(fill);
|
15019 | return fill;
|
15020 | },
|
15021 |
|
15022 | _setColor: function(type, color$$2){
|
15023 | var element = type == 'fill' ? this.fillElement : this.strokeElement;
|
15024 | if (color$$2 == null){
|
15025 | element.on = false;
|
15026 | } else {
|
15027 | color$$2 = color.detach(color$$2);
|
15028 | element.color = color$$2[0];
|
15029 | element.opacity = color$$2[1];
|
15030 | element.on = true;
|
15031 | }
|
15032 | },
|
15033 |
|
15034 | fill: function(color$$2){
|
15035 | if (arguments.length > 1){
|
15036 | this.fillLinear(arguments);
|
15037 | } else {
|
15038 | this._boxCoords = defaultBox;
|
15039 | var fill = this.fillElement;
|
15040 | fill.type = 'solid';
|
15041 | fill.color2 = '';
|
15042 | fill['ao:opacity2'] = '';
|
15043 | if (fill.colors) fill.colors.value = '';
|
15044 | this._setColor('fill', color$$2);
|
15045 | }
|
15046 | return this;
|
15047 | },
|
15048 |
|
15049 | fillRadial: function(stops, focusX, focusY, radiusX, radiusY, centerX, centerY){
|
15050 | var fill = this._createGradient('gradientradial', stops);
|
15051 | if (focusX == null) focusX = this.left + this.width * 0.5;
|
15052 | if (focusY == null) focusY = this.top + this.height * 0.5;
|
15053 | if (radiusY == null) radiusY = radiusX || (this.height * 0.5);
|
15054 | if (radiusX == null) radiusX = this.width * 0.5;
|
15055 | if (centerX == null) centerX = focusX;
|
15056 | if (centerY == null) centerY = focusY;
|
15057 |
|
15058 | centerX += centerX - focusX;
|
15059 | centerY += centerY - focusY;
|
15060 |
|
15061 | var box = this._boxCoords = {
|
15062 | left: centerX - radiusX * 2,
|
15063 | top: centerY - radiusY * 2,
|
15064 | width: radiusX * 4,
|
15065 | height: radiusY * 4
|
15066 | };
|
15067 | focusX -= box.left;
|
15068 | focusY -= box.top;
|
15069 | focusX /= box.width;
|
15070 | focusY /= box.height;
|
15071 |
|
15072 | fill.focussize = '0 0';
|
15073 | fill.focusposition = focusX + ',' + focusY;
|
15074 | fill.focus = '50%';
|
15075 |
|
15076 | this._transform();
|
15077 |
|
15078 | return this;
|
15079 | },
|
15080 |
|
15081 | fillLinear: function(stops, x1, y1, x2, y2){
|
15082 | var fill = this._createGradient('gradient', stops);
|
15083 | fill.focus = '100%';
|
15084 | if (arguments.length == 5){
|
15085 | var w = Math.abs(x2 - x1), h = Math.abs(y2 - y1);
|
15086 | this._boxCoords = {
|
15087 | left: Math.min(x1, x2),
|
15088 | top: Math.min(y1, y2),
|
15089 | width: w < 1 ? h : w,
|
15090 | height: h < 1 ? w : h
|
15091 | };
|
15092 | fill.angle = (360 + Math.atan2((x2 - x1) / h, (y2 - y1) / w) * 180 / Math.PI) % 360;
|
15093 | } else {
|
15094 | this._boxCoords = null;
|
15095 | fill.angle = (x1 == null) ? 0 : (90 + x1) % 360;
|
15096 | }
|
15097 | this._transform();
|
15098 | return this;
|
15099 | },
|
15100 |
|
15101 | fillImage: function(url, width, height, left, top, color1, color2){
|
15102 | var fill = this.fillElement;
|
15103 | if (color1 != null){
|
15104 | color1 = color.detach(color1);
|
15105 | if (color2 != null) color2 = color.detach(color2);
|
15106 | fill.type = 'pattern';
|
15107 | fill.color = color1[0];
|
15108 | fill.color2 = color2 == null ? color1[0] : color2[0];
|
15109 | fill.opacity = color2 == null ? 0 : color2[1];
|
15110 | fill['ao:opacity2'] = color1[1];
|
15111 | } else {
|
15112 | fill.type = 'tile';
|
15113 | fill.color = '';
|
15114 | fill.color2 = '';
|
15115 | fill.opacity = 1;
|
15116 | fill['ao:opacity2'] = 1;
|
15117 | }
|
15118 | if (fill.colors) fill.colors.value = '';
|
15119 | fill.rotate = true;
|
15120 | fill.src = url;
|
15121 |
|
15122 | fill.size = '1,1';
|
15123 | fill.position = '0,0';
|
15124 | fill.origin = '0,0';
|
15125 | fill.aspect = 'ignore';
|
15126 | fill.on = true;
|
15127 |
|
15128 | if (!left) left = 0;
|
15129 | if (!top) top = 0;
|
15130 | this._boxCoords = width ? { left: left + 0.5, top: top + 0.5, width: width, height: height } : null;
|
15131 | this._transform();
|
15132 | return this;
|
15133 | },
|
15134 |
|
15135 |
|
15136 |
|
15137 | stroke: function(color$$2, width, cap, join){
|
15138 | var stroke = this.strokeElement;
|
15139 | this._strokeWidth = (width != null) ? width : 1;
|
15140 | stroke.weight = (width != null) ? width + 'px' : 1;
|
15141 | stroke.endcap = (cap != null) ? ((cap == 'butt') ? 'flat' : cap) : 'round';
|
15142 | stroke.joinstyle = (join != null) ? join : 'round';
|
15143 |
|
15144 | this._setColor('stroke', color$$2);
|
15145 | return this;
|
15146 | }
|
15147 |
|
15148 | });
|
15149 |
|
15150 | var precision$2 = 100;
|
15151 |
|
15152 | var shape$2 = _class(base$2, {
|
15153 |
|
15154 | base_initialize: base$2.prototype.initialize,
|
15155 |
|
15156 | initialize: function(path, width, height){
|
15157 | this.base_initialize('shape');
|
15158 |
|
15159 | var p = this.pathElement = dom.createElement('path');
|
15160 | p.gradientshapeok = true;
|
15161 | this.element.appendChild(p);
|
15162 |
|
15163 | this.width = width;
|
15164 | this.height = height;
|
15165 |
|
15166 | if (path != null) this.draw(path);
|
15167 | },
|
15168 |
|
15169 |
|
15170 |
|
15171 | draw: function(path, width, height){
|
15172 |
|
15173 | if (!(path instanceof path$4)) path = new path$4(path);
|
15174 | this._vml = path.toVML();
|
15175 |
|
15176 |
|
15177 | if (width != null) this.width = width;
|
15178 | if (height != null) this.height = height;
|
15179 |
|
15180 | if (!this._boxCoords) this._transform();
|
15181 | this._redraw(this._prefix, this._suffix);
|
15182 |
|
15183 | return this;
|
15184 | },
|
15185 |
|
15186 |
|
15187 |
|
15188 | _redraw: function(prefix, suffix){
|
15189 | var vml = this._vml || '';
|
15190 |
|
15191 | this._prefix = prefix;
|
15192 | this._suffix = suffix;
|
15193 | if (prefix){
|
15194 | vml = [
|
15195 | prefix, vml, suffix,
|
15196 |
|
15197 | 'ns e', vml, 'nf'
|
15198 | ].join(' ');
|
15199 | }
|
15200 |
|
15201 | this.element.path = vml + 'e';
|
15202 | },
|
15203 |
|
15204 | fillRadial: function(stops, focusX, focusY, radiusX, radiusY, centerX, centerY){
|
15205 | var fill = this._createGradient('gradientradial', stops);
|
15206 | if (focusX == null) focusX = (this.left || 0) + (this.width || 0) * 0.5;
|
15207 | if (focusY == null) focusY = (this.top || 0) + (this.height || 0) * 0.5;
|
15208 | if (radiusY == null) radiusY = radiusX || (this.height * 0.5) || 0;
|
15209 | if (radiusX == null) radiusX = (this.width || 0) * 0.5;
|
15210 | if (centerX == null) centerX = focusX;
|
15211 | if (centerY == null) centerY = focusY;
|
15212 |
|
15213 | centerX += centerX - focusX;
|
15214 | centerY += centerY - focusY;
|
15215 |
|
15216 | var cx = Math.round(centerX * precision$2),
|
15217 | cy = Math.round(centerY * precision$2),
|
15218 |
|
15219 | rx = Math.round(radiusX * 2 * precision$2),
|
15220 | ry = Math.round(radiusY * 2 * precision$2),
|
15221 |
|
15222 | arc = ['wa', cx - rx, cy - ry, cx + rx, cy + ry].join(' ');
|
15223 |
|
15224 | this._redraw(
|
15225 |
|
15226 | ['m', cx, cy - ry, 'l', cx, cy - ry].join(' '),
|
15227 |
|
15228 | [
|
15229 | 'm', cx, cy - ry,
|
15230 | arc, cx, cy - ry, cx, cy + ry, arc, cx, cy + ry, cx, cy - ry,
|
15231 | arc, cx, cy - ry, cx, cy + ry, arc, cx, cy + ry, cx, cy - ry
|
15232 | ].join(' ')
|
15233 | );
|
15234 |
|
15235 | this._boxCoords = { left: focusX - 2, top: focusY - 2, width: 4, height: 4 };
|
15236 |
|
15237 | fill.focusposition = '0.5,0.5';
|
15238 | fill.focussize = '0 0';
|
15239 | fill.focus = '50%';
|
15240 |
|
15241 | this._transform();
|
15242 |
|
15243 | return this;
|
15244 | }
|
15245 |
|
15246 | });
|
15247 |
|
15248 | var group$2 = _class(node$2, container, {
|
15249 |
|
15250 | element_initialize: node$2.prototype.initialize,
|
15251 |
|
15252 | initialize: function(width, height){
|
15253 | this.element_initialize('group');
|
15254 | this.width = width;
|
15255 | this.height = height;
|
15256 | },
|
15257 |
|
15258 | _transform: function(){
|
15259 | var element = this.element;
|
15260 | element.coordorigin = '0,0';
|
15261 | element.coordsize = '1000,1000';
|
15262 | element.style.left = 0;
|
15263 | element.style.top = 0;
|
15264 | element.style.width = 1000;
|
15265 | element.style.height = 1000;
|
15266 | element.style.rotation = 0;
|
15267 |
|
15268 | var container$$2 = this.parentNode;
|
15269 | this._activeTransform = container$$2 ? new transform(container$$2._activeTransform).transform(this) : this;
|
15270 | var node = this.firstChild;
|
15271 | while (node){
|
15272 | node._transform();
|
15273 | node = node.nextSibling;
|
15274 | }
|
15275 | }
|
15276 |
|
15277 | });
|
15278 |
|
15279 | var clippingrectangle$2 = _class(node$2, container, {
|
15280 |
|
15281 | element_initialize: node$2.prototype.initialize,
|
15282 |
|
15283 | initialize: function(width, height){
|
15284 | this.element_initialize('clippingrectangle');
|
15285 | this.width = width;
|
15286 | this.height = height;
|
15287 | },
|
15288 |
|
15289 | _transform: function(){
|
15290 | var element = this.element;
|
15291 | element.clip = true;
|
15292 | element.coordorigin = -this.x + ',' + (-1 * this.y);
|
15293 | element.coordsize = this.width + ',' + this.height;
|
15294 |
|
15295 |
|
15296 | element.style.clipLeft = this.x;
|
15297 | element.style.clipRight = this.width + this.x;
|
15298 | element.style.clipTop = this.y;
|
15299 | element.style.left = -this.x;
|
15300 | element.style.top = -this.y;
|
15301 | element.style.width = this.width + this.x;
|
15302 | element.style.height = this.height + this.y;
|
15303 | element.style.rotation = 0;
|
15304 |
|
15305 | var container$$2 = this.parentNode;
|
15306 | this._activeTransform = container$$2 ? new transform(container$$2._activeTransform).transform(this) : this;
|
15307 | var node = this.firstChild;
|
15308 | while (node){
|
15309 | node._transform();
|
15310 | node = node.nextSibling;
|
15311 | }
|
15312 | }
|
15313 |
|
15314 | });
|
15315 |
|
15316 | var fontAnchors$1 = { start: 'left', middle: 'center', end: 'right' };
|
15317 |
|
15318 | var text$2 = _class(base$2, {
|
15319 |
|
15320 | base_initialize: base$2.prototype.initialize,
|
15321 |
|
15322 | initialize: function(text, font, alignment, path){
|
15323 | this.base_initialize('shape');
|
15324 |
|
15325 | var p = this.pathElement = dom.createElement('path');
|
15326 | p.textpathok = true;
|
15327 | this.element.appendChild(p);
|
15328 |
|
15329 | p = this.textPathElement = dom.createElement("textpath");
|
15330 | p.on = true;
|
15331 | p.style['v-text-align'] = 'left';
|
15332 | this.element.appendChild(p);
|
15333 |
|
15334 | this.draw.apply(this, arguments);
|
15335 | },
|
15336 |
|
15337 | draw: function(text, font, alignment, path){
|
15338 | var element = this.element,
|
15339 | textPath = this.textPathElement,
|
15340 | style = textPath.style;
|
15341 |
|
15342 | textPath.string = text;
|
15343 |
|
15344 | if (font){
|
15345 | if (typeof font == 'string'){
|
15346 | style.font = font;
|
15347 | } else {
|
15348 | for (var key in font){
|
15349 | var ckey = key.camelCase ? key.camelCase() : key;
|
15350 | if (ckey == 'fontFamily') style[ckey] = "'" + font[key] + "'";
|
15351 |
|
15352 |
|
15353 |
|
15354 |
|
15355 | else style[ckey] = font[key];
|
15356 | }
|
15357 | }
|
15358 | }
|
15359 |
|
15360 | if (alignment) style['v-text-align'] = fontAnchors$1[alignment] || alignment;
|
15361 |
|
15362 | if (path){
|
15363 | this.currentPath = path = new path$4(path);
|
15364 | this.element.path = path.toVML();
|
15365 | } else if (!this.currentPath){
|
15366 | var i = -1, offsetRows = '\n';
|
15367 | while ((i = text.indexOf('\n', i + 1)) > -1) offsetRows += '\n';
|
15368 | textPath.string = offsetRows + textPath.string;
|
15369 | this.element.path = 'm0,0l1,0';
|
15370 | }
|
15371 |
|
15372 |
|
15373 |
|
15374 |
|
15375 | element = element.cloneNode(true);
|
15376 | style = element.style;
|
15377 |
|
15378 |
|
15379 | element.coordorigin = '0,0';
|
15380 | element.coordsize = '10000,10000';
|
15381 | style.left = '0px';
|
15382 | style.top = '0px';
|
15383 | style.width = '10000px';
|
15384 | style.height = '10000px';
|
15385 | style.rotation = 0;
|
15386 | element.removeChild(element.firstChild);
|
15387 |
|
15388 |
|
15389 |
|
15390 | var canvas = new surface$2(1, 1),
|
15391 | group = new group$2(),
|
15392 | body = element.ownerDocument.body;
|
15393 |
|
15394 | canvas.inject(body);
|
15395 | group.element.appendChild(element);
|
15396 | group.inject(canvas);
|
15397 |
|
15398 | var ebb = element.getBoundingClientRect(),
|
15399 | cbb = canvas.toElement().getBoundingClientRect();
|
15400 |
|
15401 | canvas.eject();
|
15402 |
|
15403 | this.left = ebb.left - cbb.left;
|
15404 | this.top = ebb.top - cbb.top;
|
15405 | this.width = ebb.right - ebb.left;
|
15406 | this.height = ebb.bottom - ebb.top;
|
15407 | this.right = ebb.right - cbb.left;
|
15408 | this.bottom = ebb.bottom - cbb.top;
|
15409 |
|
15410 | this._transform();
|
15411 |
|
15412 |
|
15413 | return this;
|
15414 | }
|
15415 |
|
15416 | });
|
15417 |
|
15418 | var fastNoSideEffects = createCommonjsModule(function (module, exports) {
|
15419 | var hasCanvas = function(){
|
15420 |
|
15421 | var canvas = document.createElement('canvas');
|
15422 | return canvas && !!canvas.getContext;
|
15423 |
|
15424 | };
|
15425 |
|
15426 | if (hasCanvas()) {
|
15427 | exports.Surface = surface;
|
15428 | exports.Path = path;
|
15429 | exports.Shape = shape;
|
15430 | exports.Group = group;
|
15431 | exports.ClippingRectangle = clippingrectangle;
|
15432 | exports.Text = text;
|
15433 | } else {
|
15434 | exports.Surface = surface$2;
|
15435 | exports.Path = path$4;
|
15436 | exports.Shape = shape$2;
|
15437 | exports.Group = group$2;
|
15438 | exports.ClippingRectangle = clippingrectangle$2;
|
15439 | exports.Text = text$2;
|
15440 |
|
15441 | var DOM$$1 = dom;
|
15442 | if (typeof document !== 'undefined') DOM$$1.init(document);
|
15443 | }
|
15444 | });
|
15445 |
|
15446 | var fastNoSideEffects_1 = fastNoSideEffects.Surface;
|
15447 | var fastNoSideEffects_2 = fastNoSideEffects.Path;
|
15448 | var fastNoSideEffects_3 = fastNoSideEffects.Shape;
|
15449 | var fastNoSideEffects_4 = fastNoSideEffects.Group;
|
15450 | var fastNoSideEffects_5 = fastNoSideEffects.ClippingRectangle;
|
15451 | var fastNoSideEffects_6 = fastNoSideEffects.Text;
|
15452 |
|
15453 | var _extends = _assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
15454 |
|
15455 | function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
15456 |
|
15457 | function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
15458 |
|
15459 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
15460 |
|
15461 | current.setCurrent(
|
15462 |
|
15463 | fastNoSideEffects);
|
15464 |
|
15465 |
|
15466 |
|
15467 | var slice = Array.prototype.slice;
|
15468 |
|
15469 | var LinearGradient = function () {
|
15470 | function LinearGradient(stops, x1, y1, x2, y2) {
|
15471 | _classCallCheck(this, LinearGradient);
|
15472 |
|
15473 | this._args = slice.call(arguments);
|
15474 | }
|
15475 |
|
15476 | LinearGradient.prototype.applyFill = function applyFill(node) {
|
15477 | node.fillLinear.apply(node, this._args);
|
15478 | };
|
15479 |
|
15480 | return LinearGradient;
|
15481 | }();
|
15482 |
|
15483 | var RadialGradient = function () {
|
15484 | function RadialGradient(stops, fx, fy, rx, ry, cx, cy) {
|
15485 | _classCallCheck(this, RadialGradient);
|
15486 |
|
15487 | this._args = slice.call(arguments);
|
15488 | }
|
15489 |
|
15490 | RadialGradient.prototype.applyFill = function applyFill(node) {
|
15491 | node.fillRadial.apply(node, this._args);
|
15492 | };
|
15493 |
|
15494 | return RadialGradient;
|
15495 | }();
|
15496 |
|
15497 | var Pattern = function () {
|
15498 | function Pattern(url, width, height, left, top) {
|
15499 | _classCallCheck(this, Pattern);
|
15500 |
|
15501 | this._args = slice.call(arguments);
|
15502 | }
|
15503 |
|
15504 | Pattern.prototype.applyFill = function applyFill(node) {
|
15505 | node.fillImage.apply(node, this._args);
|
15506 | };
|
15507 |
|
15508 | return Pattern;
|
15509 | }();
|
15510 |
|
15511 |
|
15512 |
|
15513 | var Surface = function (_React$Component) {
|
15514 | _inherits(Surface, _React$Component);
|
15515 |
|
15516 | function Surface() {
|
15517 | _classCallCheck(this, Surface);
|
15518 |
|
15519 | return _possibleConstructorReturn(this, _React$Component.apply(this, arguments));
|
15520 | }
|
15521 |
|
15522 | Surface.prototype.componentDidMount = function componentDidMount() {
|
15523 | var _props = this.props,
|
15524 | height = _props.height,
|
15525 | width = _props.width;
|
15526 |
|
15527 |
|
15528 | this._surface = current.Surface(+width, +height, this._tagRef);
|
15529 |
|
15530 | this._mountNode = createContainer(this._surface);
|
15531 | updateContainer(this.props.children, this._mountNode, this);
|
15532 | };
|
15533 |
|
15534 | Surface.prototype.componentDidUpdate = function componentDidUpdate(prevProps, prevState) {
|
15535 | var props = this.props;
|
15536 |
|
15537 | if (props.height !== prevProps.height || props.width !== prevProps.width) {
|
15538 | this._surface.resize(+props.width, +props.height);
|
15539 | }
|
15540 |
|
15541 | updateContainer(this.props.children, this._mountNode, this);
|
15542 |
|
15543 | if (this._surface.render) {
|
15544 | this._surface.render();
|
15545 | }
|
15546 | };
|
15547 |
|
15548 | Surface.prototype.componentWillUnmount = function componentWillUnmount() {
|
15549 | updateContainer(null, this._mountNode, this);
|
15550 | };
|
15551 |
|
15552 | Surface.prototype.render = function render() {
|
15553 | var _this2 = this;
|
15554 |
|
15555 |
|
15556 |
|
15557 |
|
15558 |
|
15559 | var props = this.props;
|
15560 |
|
15561 |
|
15562 | var Tag = current.Surface.tagName;
|
15563 |
|
15564 | return React.createElement(Tag, {
|
15565 | ref: function (ref) {
|
15566 | return _this2._tagRef = ref;
|
15567 | },
|
15568 | accessKey: props.accessKey,
|
15569 | className: props.className,
|
15570 | draggable: props.draggable,
|
15571 | role: props.role,
|
15572 | style: props.style,
|
15573 | tabIndex: props.tabIndex,
|
15574 | title: props.title
|
15575 | });
|
15576 | };
|
15577 |
|
15578 | return Surface;
|
15579 | }(React.Component);
|
15580 |
|
15581 | var Text = function (_React$Component2) {
|
15582 | _inherits(Text, _React$Component2);
|
15583 |
|
15584 | function Text(props) {
|
15585 | _classCallCheck(this, Text);
|
15586 |
|
15587 |
|
15588 |
|
15589 | var _this3 = _possibleConstructorReturn(this, _React$Component2.call(this, props));
|
15590 |
|
15591 | ['height', 'width', 'x', 'y'].forEach(function (key) {
|
15592 | Object.defineProperty(_this3, key, {
|
15593 | get: function () {
|
15594 | return this._text ? this._text[key] : undefined;
|
15595 | }
|
15596 | });
|
15597 | });
|
15598 | return _this3;
|
15599 | }
|
15600 |
|
15601 | Text.prototype.render = function render() {
|
15602 | var _this4 = this;
|
15603 |
|
15604 |
|
15605 | var T = TYPES.TEXT;
|
15606 | return React.createElement(
|
15607 | T,
|
15608 | _extends({}, this.props, { ref: function (t) {
|
15609 | return _this4._text = t;
|
15610 | } }),
|
15611 | childrenAsString(this.props.children)
|
15612 | );
|
15613 | };
|
15614 |
|
15615 | return Text;
|
15616 | }(React.Component);
|
15617 |
|
15618 | injectIntoDevTools({
|
15619 | findFiberByHostInstance: function () {
|
15620 | return null;
|
15621 | },
|
15622 | bundleType: 1,
|
15623 | version: ReactVersion,
|
15624 | rendererPackageName: 'react-art'
|
15625 | });
|
15626 |
|
15627 |
|
15628 |
|
15629 | var ClippingRectangle = TYPES.CLIPPING_RECTANGLE;
|
15630 | var Group = TYPES.GROUP;
|
15631 | var Shape = TYPES.SHAPE;
|
15632 | var Path = current.Path;
|
15633 |
|
15634 |
|
15635 | var ReactART = Object.freeze({
|
15636 | ClippingRectangle: ClippingRectangle,
|
15637 | Group: Group,
|
15638 | Shape: Shape,
|
15639 | Path: Path,
|
15640 | LinearGradient: LinearGradient,
|
15641 | Pattern: Pattern,
|
15642 | RadialGradient: RadialGradient,
|
15643 | Surface: Surface,
|
15644 | Text: Text,
|
15645 | Transform: transform
|
15646 | });
|
15647 |
|
15648 | var reactArt = ReactART;
|
15649 |
|
15650 | return reactArt;
|
15651 |
|
15652 | })));
|