[ Index ] |
PHP Cross Reference of WordPress |
[Summary view] [Print] [Text view]
1 /** @license React v16.5.2 2 * react.development.js 3 * 4 * Copyright (c) Facebook, Inc. and its affiliates. 5 * 6 * This source code is licensed under the MIT license found in the 7 * LICENSE file in the root directory of this source tree. 8 */ 9 10 'use strict'; 11 12 (function (global, factory) { 13 typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : 14 typeof define === 'function' && define.amd ? define(factory) : 15 (global.React = factory()); 16 }(this, (function () { 'use strict'; 17 18 // TODO: this is special because it gets imported during build. 19 20 var ReactVersion = '16.5.2'; 21 22 // The Symbol used to tag the ReactElement-like types. If there is no native Symbol 23 // nor polyfill, then a plain number is used for performance. 24 var hasSymbol = typeof Symbol === 'function' && Symbol.for; 25 26 var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7; 27 var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca; 28 var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb; 29 var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc; 30 var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2; 31 var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd; 32 var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace; 33 var REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for('react.async_mode') : 0xeacf; 34 var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0; 35 var REACT_PLACEHOLDER_TYPE = hasSymbol ? Symbol.for('react.placeholder') : 0xead1; 36 37 var MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator; 38 var FAUX_ITERATOR_SYMBOL = '@@iterator'; 39 40 function getIteratorFn(maybeIterable) { 41 if (maybeIterable === null || typeof maybeIterable !== 'object') { 42 return null; 43 } 44 var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]; 45 if (typeof maybeIterator === 'function') { 46 return maybeIterator; 47 } 48 return null; 49 } 50 51 // Exports ReactDOM.createRoot 52 53 54 // Experimental error-boundary API that can recover from errors within a single 55 // render phase 56 57 // Suspense 58 var enableSuspense = false; 59 // Helps identify side effects in begin-phase lifecycle hooks and setState reducers: 60 61 62 // In some cases, StrictMode should also double-render lifecycles. 63 // This can be confusing for tests though, 64 // And it can be bad for performance in production. 65 // This feature flag can be used to control the behavior: 66 67 68 // To preserve the "Pause on caught exceptions" behavior of the debugger, we 69 // replay the begin phase of a failed component inside invokeGuardedCallback. 70 71 72 // Warn about deprecated, async-unsafe lifecycles; relates to RFC #6: 73 74 75 // Warn about legacy context API 76 77 78 // Gather advanced timing metrics for Profiler subtrees. 79 80 81 // Trace which interactions trigger each commit. 82 var enableSchedulerTracing = true; 83 84 // Only used in www builds. 85 86 87 // Only used in www builds. 88 89 90 // React Fire: prevent the value and checked attributes from syncing 91 // with their related DOM properties 92 93 /* 94 object-assign 95 (c) Sindre Sorhus 96 @license MIT 97 */ 98 99 100 /* eslint-disable no-unused-vars */ 101 var getOwnPropertySymbols = Object.getOwnPropertySymbols; 102 var hasOwnProperty = Object.prototype.hasOwnProperty; 103 var propIsEnumerable = Object.prototype.propertyIsEnumerable; 104 105 function toObject(val) { 106 if (val === null || val === undefined) { 107 throw new TypeError('Object.assign cannot be called with null or undefined'); 108 } 109 110 return Object(val); 111 } 112 113 function shouldUseNative() { 114 try { 115 if (!Object.assign) { 116 return false; 117 } 118 119 // Detect buggy property enumeration order in older V8 versions. 120 121 // https://bugs.chromium.org/p/v8/issues/detail?id=4118 122 var test1 = new String('abc'); // eslint-disable-line no-new-wrappers 123 test1[5] = 'de'; 124 if (Object.getOwnPropertyNames(test1)[0] === '5') { 125 return false; 126 } 127 128 // https://bugs.chromium.org/p/v8/issues/detail?id=3056 129 var test2 = {}; 130 for (var i = 0; i < 10; i++) { 131 test2['_' + String.fromCharCode(i)] = i; 132 } 133 var order2 = Object.getOwnPropertyNames(test2).map(function (n) { 134 return test2[n]; 135 }); 136 if (order2.join('') !== '0123456789') { 137 return false; 138 } 139 140 // https://bugs.chromium.org/p/v8/issues/detail?id=3056 141 var test3 = {}; 142 'abcdefghijklmnopqrst'.split('').forEach(function (letter) { 143 test3[letter] = letter; 144 }); 145 if (Object.keys(Object.assign({}, test3)).join('') !== 146 'abcdefghijklmnopqrst') { 147 return false; 148 } 149 150 return true; 151 } catch (err) { 152 // We don't expect any of the above to throw, but better to be safe. 153 return false; 154 } 155 } 156 157 var objectAssign = shouldUseNative() ? Object.assign : function (target, source) { 158 var from; 159 var to = toObject(target); 160 var symbols; 161 162 for (var s = 1; s < arguments.length; s++) { 163 from = Object(arguments[s]); 164 165 for (var key in from) { 166 if (hasOwnProperty.call(from, key)) { 167 to[key] = from[key]; 168 } 169 } 170 171 if (getOwnPropertySymbols) { 172 symbols = getOwnPropertySymbols(from); 173 for (var i = 0; i < symbols.length; i++) { 174 if (propIsEnumerable.call(from, symbols[i])) { 175 to[symbols[i]] = from[symbols[i]]; 176 } 177 } 178 } 179 } 180 181 return to; 182 }; 183 184 /** 185 * Use invariant() to assert state which your program assumes to be true. 186 * 187 * Provide sprintf-style format (only %s is supported) and arguments 188 * to provide information about what broke and what you were 189 * expecting. 190 * 191 * The invariant message will be stripped in production, but the invariant 192 * will remain to ensure logic does not differ in production. 193 */ 194 195 var validateFormat = function () {}; 196 197 { 198 validateFormat = function (format) { 199 if (format === undefined) { 200 throw new Error('invariant requires an error message argument'); 201 } 202 }; 203 } 204 205 function invariant(condition, format, a, b, c, d, e, f) { 206 validateFormat(format); 207 208 if (!condition) { 209 var error = void 0; 210 if (format === undefined) { 211 error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.'); 212 } else { 213 var args = [a, b, c, d, e, f]; 214 var argIndex = 0; 215 error = new Error(format.replace(/%s/g, function () { 216 return args[argIndex++]; 217 })); 218 error.name = 'Invariant Violation'; 219 } 220 221 error.framesToPop = 1; // we don't care about invariant's own frame 222 throw error; 223 } 224 } 225 226 // Relying on the `invariant()` implementation lets us 227 // preserve the format and params in the www builds. 228 229 /** 230 * Forked from fbjs/warning: 231 * https://github.com/facebook/fbjs/blob/e66ba20ad5be433eb54423f2b097d829324d9de6/packages/fbjs/src/__forks__/warning.js 232 * 233 * Only change is we use console.warn instead of console.error, 234 * and do nothing when 'console' is not supported. 235 * This really simplifies the code. 236 * --- 237 * Similar to invariant but only logs a warning if the condition is not met. 238 * This can be used to log issues in development environments in critical 239 * paths. Removing the logging code for production environments will keep the 240 * same logic and follow the same code paths. 241 */ 242 243 var lowPriorityWarning = function () {}; 244 245 { 246 var printWarning = function (format) { 247 for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { 248 args[_key - 1] = arguments[_key]; 249 } 250 251 var argIndex = 0; 252 var message = 'Warning: ' + format.replace(/%s/g, function () { 253 return args[argIndex++]; 254 }); 255 if (typeof console !== 'undefined') { 256 console.warn(message); 257 } 258 try { 259 // --- Welcome to debugging React --- 260 // This error was thrown as a convenience so that you can use this stack 261 // to find the callsite that caused this warning to fire. 262 throw new Error(message); 263 } catch (x) {} 264 }; 265 266 lowPriorityWarning = function (condition, format) { 267 if (format === undefined) { 268 throw new Error('`lowPriorityWarning(condition, format, ...args)` requires a warning ' + 'message argument'); 269 } 270 if (!condition) { 271 for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) { 272 args[_key2 - 2] = arguments[_key2]; 273 } 274 275 printWarning.apply(undefined, [format].concat(args)); 276 } 277 }; 278 } 279 280 var lowPriorityWarning$1 = lowPriorityWarning; 281 282 /** 283 * Similar to invariant but only logs a warning if the condition is not met. 284 * This can be used to log issues in development environments in critical 285 * paths. Removing the logging code for production environments will keep the 286 * same logic and follow the same code paths. 287 */ 288 289 var warningWithoutStack = function () {}; 290 291 { 292 warningWithoutStack = function (condition, format) { 293 for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { 294 args[_key - 2] = arguments[_key]; 295 } 296 297 if (format === undefined) { 298 throw new Error('`warningWithoutStack(condition, format, ...args)` requires a warning ' + 'message argument'); 299 } 300 if (args.length > 8) { 301 // Check before the condition to catch violations early. 302 throw new Error('warningWithoutStack() currently supports at most 8 arguments.'); 303 } 304 if (condition) { 305 return; 306 } 307 if (typeof console !== 'undefined') { 308 var _args$map = args.map(function (item) { 309 return '' + item; 310 }), 311 a = _args$map[0], 312 b = _args$map[1], 313 c = _args$map[2], 314 d = _args$map[3], 315 e = _args$map[4], 316 f = _args$map[5], 317 g = _args$map[6], 318 h = _args$map[7]; 319 320 var message = 'Warning: ' + format; 321 322 // We intentionally don't use spread (or .apply) because it breaks IE9: 323 // https://github.com/facebook/react/issues/13610 324 switch (args.length) { 325 case 0: 326 console.error(message); 327 break; 328 case 1: 329 console.error(message, a); 330 break; 331 case 2: 332 console.error(message, a, b); 333 break; 334 case 3: 335 console.error(message, a, b, c); 336 break; 337 case 4: 338 console.error(message, a, b, c, d); 339 break; 340 case 5: 341 console.error(message, a, b, c, d, e); 342 break; 343 case 6: 344 console.error(message, a, b, c, d, e, f); 345 break; 346 case 7: 347 console.error(message, a, b, c, d, e, f, g); 348 break; 349 case 8: 350 console.error(message, a, b, c, d, e, f, g, h); 351 break; 352 default: 353 throw new Error('warningWithoutStack() currently supports at most 8 arguments.'); 354 } 355 } 356 try { 357 // --- Welcome to debugging React --- 358 // This error was thrown as a convenience so that you can use this stack 359 // to find the callsite that caused this warning to fire. 360 var argIndex = 0; 361 var _message = 'Warning: ' + format.replace(/%s/g, function () { 362 return args[argIndex++]; 363 }); 364 throw new Error(_message); 365 } catch (x) {} 366 }; 367 } 368 369 var warningWithoutStack$1 = warningWithoutStack; 370 371 var didWarnStateUpdateForUnmountedComponent = {}; 372 373 function warnNoop(publicInstance, callerName) { 374 { 375 var _constructor = publicInstance.constructor; 376 var componentName = _constructor && (_constructor.displayName || _constructor.name) || 'ReactClass'; 377 var warningKey = componentName + '.' + callerName; 378 if (didWarnStateUpdateForUnmountedComponent[warningKey]) { 379 return; 380 } 381 warningWithoutStack$1(false, "Can't call %s on a component that is not yet mounted. " + 'This is a no-op, but it might indicate a bug in your application. ' + 'Instead, assign to `this.state` directly or define a `state = {};` ' + 'class property with the desired state in the %s component.', callerName, componentName); 382 didWarnStateUpdateForUnmountedComponent[warningKey] = true; 383 } 384 } 385 386 /** 387 * This is the abstract API for an update queue. 388 */ 389 var ReactNoopUpdateQueue = { 390 /** 391 * Checks whether or not this composite component is mounted. 392 * @param {ReactClass} publicInstance The instance we want to test. 393 * @return {boolean} True if mounted, false otherwise. 394 * @protected 395 * @final 396 */ 397 isMounted: function (publicInstance) { 398 return false; 399 }, 400 401 /** 402 * Forces an update. This should only be invoked when it is known with 403 * certainty that we are **not** in a DOM transaction. 404 * 405 * You may want to call this when you know that some deeper aspect of the 406 * component's state has changed but `setState` was not called. 407 * 408 * This will not invoke `shouldComponentUpdate`, but it will invoke 409 * `componentWillUpdate` and `componentDidUpdate`. 410 * 411 * @param {ReactClass} publicInstance The instance that should rerender. 412 * @param {?function} callback Called after component is updated. 413 * @param {?string} callerName name of the calling function in the public API. 414 * @internal 415 */ 416 enqueueForceUpdate: function (publicInstance, callback, callerName) { 417 warnNoop(publicInstance, 'forceUpdate'); 418 }, 419 420 /** 421 * Replaces all of the state. Always use this or `setState` to mutate state. 422 * You should treat `this.state` as immutable. 423 * 424 * There is no guarantee that `this.state` will be immediately updated, so 425 * accessing `this.state` after calling this method may return the old value. 426 * 427 * @param {ReactClass} publicInstance The instance that should rerender. 428 * @param {object} completeState Next state. 429 * @param {?function} callback Called after component is updated. 430 * @param {?string} callerName name of the calling function in the public API. 431 * @internal 432 */ 433 enqueueReplaceState: function (publicInstance, completeState, callback, callerName) { 434 warnNoop(publicInstance, 'replaceState'); 435 }, 436 437 /** 438 * Sets a subset of the state. This only exists because _pendingState is 439 * internal. This provides a merging strategy that is not available to deep 440 * properties which is confusing. TODO: Expose pendingState or don't use it 441 * during the merge. 442 * 443 * @param {ReactClass} publicInstance The instance that should rerender. 444 * @param {object} partialState Next partial state to be merged with state. 445 * @param {?function} callback Called after component is updated. 446 * @param {?string} Name of the calling function in the public API. 447 * @internal 448 */ 449 enqueueSetState: function (publicInstance, partialState, callback, callerName) { 450 warnNoop(publicInstance, 'setState'); 451 } 452 }; 453 454 var emptyObject = {}; 455 { 456 Object.freeze(emptyObject); 457 } 458 459 /** 460 * Base class helpers for the updating state of a component. 461 */ 462 function Component(props, context, updater) { 463 this.props = props; 464 this.context = context; 465 // If a component has string refs, we will assign a different object later. 466 this.refs = emptyObject; 467 // We initialize the default updater but the real one gets injected by the 468 // renderer. 469 this.updater = updater || ReactNoopUpdateQueue; 470 } 471 472 Component.prototype.isReactComponent = {}; 473 474 /** 475 * Sets a subset of the state. Always use this to mutate 476 * state. You should treat `this.state` as immutable. 477 * 478 * There is no guarantee that `this.state` will be immediately updated, so 479 * accessing `this.state` after calling this method may return the old value. 480 * 481 * There is no guarantee that calls to `setState` will run synchronously, 482 * as they may eventually be batched together. You can provide an optional 483 * callback that will be executed when the call to setState is actually 484 * completed. 485 * 486 * When a function is provided to setState, it will be called at some point in 487 * the future (not synchronously). It will be called with the up to date 488 * component arguments (state, props, context). These values can be different 489 * from this.* because your function may be called after receiveProps but before 490 * shouldComponentUpdate, and this new state, props, and context will not yet be 491 * assigned to this. 492 * 493 * @param {object|function} partialState Next partial state or function to 494 * produce next partial state to be merged with current state. 495 * @param {?function} callback Called after state is updated. 496 * @final 497 * @protected 498 */ 499 Component.prototype.setState = function (partialState, callback) { 500 !(typeof partialState === 'object' || typeof partialState === 'function' || partialState == null) ? invariant(false, 'setState(...): takes an object of state variables to update or a function which returns an object of state variables.') : void 0; 501 this.updater.enqueueSetState(this, partialState, callback, 'setState'); 502 }; 503 504 /** 505 * Forces an update. This should only be invoked when it is known with 506 * certainty that we are **not** in a DOM transaction. 507 * 508 * You may want to call this when you know that some deeper aspect of the 509 * component's state has changed but `setState` was not called. 510 * 511 * This will not invoke `shouldComponentUpdate`, but it will invoke 512 * `componentWillUpdate` and `componentDidUpdate`. 513 * 514 * @param {?function} callback Called after update is complete. 515 * @final 516 * @protected 517 */ 518 Component.prototype.forceUpdate = function (callback) { 519 this.updater.enqueueForceUpdate(this, callback, 'forceUpdate'); 520 }; 521 522 /** 523 * Deprecated APIs. These APIs used to exist on classic React classes but since 524 * we would like to deprecate them, we're not going to move them over to this 525 * modern base class. Instead, we define a getter that warns if it's accessed. 526 */ 527 { 528 var deprecatedAPIs = { 529 isMounted: ['isMounted', 'Instead, make sure to clean up subscriptions and pending requests in ' + 'componentWillUnmount to prevent memory leaks.'], 530 replaceState: ['replaceState', 'Refactor your code to use setState instead (see ' + 'https://github.com/facebook/react/issues/3236).'] 531 }; 532 var defineDeprecationWarning = function (methodName, info) { 533 Object.defineProperty(Component.prototype, methodName, { 534 get: function () { 535 lowPriorityWarning$1(false, '%s(...) is deprecated in plain JavaScript React classes. %s', info[0], info[1]); 536 return undefined; 537 } 538 }); 539 }; 540 for (var fnName in deprecatedAPIs) { 541 if (deprecatedAPIs.hasOwnProperty(fnName)) { 542 defineDeprecationWarning(fnName, deprecatedAPIs[fnName]); 543 } 544 } 545 } 546 547 function ComponentDummy() {} 548 ComponentDummy.prototype = Component.prototype; 549 550 /** 551 * Convenience component with default shallow equality check for sCU. 552 */ 553 function PureComponent(props, context, updater) { 554 this.props = props; 555 this.context = context; 556 // If a component has string refs, we will assign a different object later. 557 this.refs = emptyObject; 558 this.updater = updater || ReactNoopUpdateQueue; 559 } 560 561 var pureComponentPrototype = PureComponent.prototype = new ComponentDummy(); 562 pureComponentPrototype.constructor = PureComponent; 563 // Avoid an extra prototype jump for these methods. 564 objectAssign(pureComponentPrototype, Component.prototype); 565 pureComponentPrototype.isPureReactComponent = true; 566 567 // an immutable object with a single mutable value 568 function createRef() { 569 var refObject = { 570 current: null 571 }; 572 { 573 Object.seal(refObject); 574 } 575 return refObject; 576 } 577 578 /* eslint-disable no-var */ 579 580 // TODO: Currently there's only a single priority level, Deferred. Will add 581 // additional priorities. 582 var DEFERRED_TIMEOUT = 5000; 583 584 // Callbacks are stored as a circular, doubly linked list. 585 var firstCallbackNode = null; 586 587 var isPerformingWork = false; 588 589 var isHostCallbackScheduled = false; 590 591 var hasNativePerformanceNow = typeof performance === 'object' && typeof performance.now === 'function'; 592 593 var timeRemaining; 594 if (hasNativePerformanceNow) { 595 timeRemaining = function () { 596 // We assume that if we have a performance timer that the rAF callback 597 // gets a performance timer value. Not sure if this is always true. 598 var remaining = getFrameDeadline() - performance.now(); 599 return remaining > 0 ? remaining : 0; 600 }; 601 } else { 602 timeRemaining = function () { 603 // Fallback to Date.now() 604 var remaining = getFrameDeadline() - Date.now(); 605 return remaining > 0 ? remaining : 0; 606 }; 607 } 608 609 var deadlineObject = { 610 timeRemaining: timeRemaining, 611 didTimeout: false 612 }; 613 614 function ensureHostCallbackIsScheduled() { 615 if (isPerformingWork) { 616 // Don't schedule work yet; wait until the next time we yield. 617 return; 618 } 619 // Schedule the host callback using the earliest timeout in the list. 620 var timesOutAt = firstCallbackNode.timesOutAt; 621 if (!isHostCallbackScheduled) { 622 isHostCallbackScheduled = true; 623 } else { 624 // Cancel the existing host callback. 625 cancelCallback(); 626 } 627 requestCallback(flushWork, timesOutAt); 628 } 629 630 function flushFirstCallback(node) { 631 var flushedNode = firstCallbackNode; 632 633 // Remove the node from the list before calling the callback. That way the 634 // list is in a consistent state even if the callback throws. 635 var next = firstCallbackNode.next; 636 if (firstCallbackNode === next) { 637 // This is the last callback in the list. 638 firstCallbackNode = null; 639 next = null; 640 } else { 641 var previous = firstCallbackNode.previous; 642 firstCallbackNode = previous.next = next; 643 next.previous = previous; 644 } 645 646 flushedNode.next = flushedNode.previous = null; 647 648 // Now it's safe to call the callback. 649 var callback = flushedNode.callback; 650 callback(deadlineObject); 651 } 652 653 function flushWork(didTimeout) { 654 isPerformingWork = true; 655 deadlineObject.didTimeout = didTimeout; 656 try { 657 if (didTimeout) { 658 // Flush all the timed out callbacks without yielding. 659 while (firstCallbackNode !== null) { 660 // Read the current time. Flush all the callbacks that expire at or 661 // earlier than that time. Then read the current time again and repeat. 662 // This optimizes for as few performance.now calls as possible. 663 var currentTime = getCurrentTime(); 664 if (firstCallbackNode.timesOutAt <= currentTime) { 665 do { 666 flushFirstCallback(); 667 } while (firstCallbackNode !== null && firstCallbackNode.timesOutAt <= currentTime); 668 continue; 669 } 670 break; 671 } 672 } else { 673 // Keep flushing callbacks until we run out of time in the frame. 674 if (firstCallbackNode !== null) { 675 do { 676 flushFirstCallback(); 677 } while (firstCallbackNode !== null && getFrameDeadline() - getCurrentTime() > 0); 678 } 679 } 680 } finally { 681 isPerformingWork = false; 682 if (firstCallbackNode !== null) { 683 // There's still work remaining. Request another callback. 684 ensureHostCallbackIsScheduled(firstCallbackNode); 685 } else { 686 isHostCallbackScheduled = false; 687 } 688 } 689 } 690 691 function unstable_scheduleWork(callback, options) { 692 var currentTime = getCurrentTime(); 693 694 var timesOutAt; 695 if (options !== undefined && options !== null && options.timeout !== null && options.timeout !== undefined) { 696 // Check for an explicit timeout 697 timesOutAt = currentTime + options.timeout; 698 } else { 699 // Compute an absolute timeout using the default constant. 700 timesOutAt = currentTime + DEFERRED_TIMEOUT; 701 } 702 703 var newNode = { 704 callback: callback, 705 timesOutAt: timesOutAt, 706 next: null, 707 previous: null 708 }; 709 710 // Insert the new callback into the list, sorted by its timeout. 711 if (firstCallbackNode === null) { 712 // This is the first callback in the list. 713 firstCallbackNode = newNode.next = newNode.previous = newNode; 714 ensureHostCallbackIsScheduled(firstCallbackNode); 715 } else { 716 var next = null; 717 var node = firstCallbackNode; 718 do { 719 if (node.timesOutAt > timesOutAt) { 720 // The new callback times out before this one. 721 next = node; 722 break; 723 } 724 node = node.next; 725 } while (node !== firstCallbackNode); 726 727 if (next === null) { 728 // No callback with a later timeout was found, which means the new 729 // callback has the latest timeout in the list. 730 next = firstCallbackNode; 731 } else if (next === firstCallbackNode) { 732 // The new callback has the earliest timeout in the entire list. 733 firstCallbackNode = newNode; 734 ensureHostCallbackIsScheduled(firstCallbackNode); 735 } 736 737 var previous = next.previous; 738 previous.next = next.previous = newNode; 739 newNode.next = next; 740 newNode.previous = previous; 741 } 742 743 return newNode; 744 } 745 746 function unstable_cancelScheduledWork(callbackNode) { 747 var next = callbackNode.next; 748 if (next === null) { 749 // Already cancelled. 750 return; 751 } 752 753 if (next === callbackNode) { 754 // This is the only scheduled callback. Clear the list. 755 firstCallbackNode = null; 756 } else { 757 // Remove the callback from its position in the list. 758 if (callbackNode === firstCallbackNode) { 759 firstCallbackNode = next; 760 } 761 var previous = callbackNode.previous; 762 previous.next = next; 763 next.previous = previous; 764 } 765 766 callbackNode.next = callbackNode.previous = null; 767 } 768 769 // The remaining code is essentially a polyfill for requestIdleCallback. It 770 // works by scheduling a requestAnimationFrame, storing the time for the start 771 // of the frame, then scheduling a postMessage which gets scheduled after paint. 772 // Within the postMessage handler do as much work as possible until time + frame 773 // rate. By separating the idle call into a separate event tick we ensure that 774 // layout, paint and other browser work is counted against the available time. 775 // The frame rate is dynamically adjusted. 776 777 // We capture a local reference to any global, in case it gets polyfilled after 778 // this module is initially evaluated. We want to be using a 779 // consistent implementation. 780 var localDate = Date; 781 782 // This initialization code may run even on server environments if a component 783 // just imports ReactDOM (e.g. for findDOMNode). Some environments might not 784 // have setTimeout or clearTimeout. However, we always expect them to be defined 785 // on the client. https://github.com/facebook/react/pull/13088 786 var localSetTimeout = typeof setTimeout === 'function' ? setTimeout : undefined; 787 var localClearTimeout = typeof clearTimeout === 'function' ? clearTimeout : undefined; 788 789 // We don't expect either of these to necessarily be defined, but we will error 790 // later if they are missing on the client. 791 var localRequestAnimationFrame = typeof requestAnimationFrame === 'function' ? requestAnimationFrame : undefined; 792 var localCancelAnimationFrame = typeof cancelAnimationFrame === 'function' ? cancelAnimationFrame : undefined; 793 794 var getCurrentTime; 795 796 // requestAnimationFrame does not run when the tab is in the background. If 797 // we're backgrounded we prefer for that work to happen so that the page 798 // continues to load in the background. So we also schedule a 'setTimeout' as 799 // a fallback. 800 // TODO: Need a better heuristic for backgrounded work. 801 var ANIMATION_FRAME_TIMEOUT = 100; 802 var rAFID; 803 var rAFTimeoutID; 804 var requestAnimationFrameWithTimeout = function (callback) { 805 // schedule rAF and also a setTimeout 806 rAFID = localRequestAnimationFrame(function (timestamp) { 807 // cancel the setTimeout 808 localClearTimeout(rAFTimeoutID); 809 callback(timestamp); 810 }); 811 rAFTimeoutID = localSetTimeout(function () { 812 // cancel the requestAnimationFrame 813 localCancelAnimationFrame(rAFID); 814 callback(getCurrentTime()); 815 }, ANIMATION_FRAME_TIMEOUT); 816 }; 817 818 if (hasNativePerformanceNow) { 819 var Performance = performance; 820 getCurrentTime = function () { 821 return Performance.now(); 822 }; 823 } else { 824 getCurrentTime = function () { 825 return localDate.now(); 826 }; 827 } 828 829 var requestCallback; 830 var cancelCallback; 831 var getFrameDeadline; 832 833 if (typeof window === 'undefined') { 834 // If this accidentally gets imported in a non-browser environment, fallback 835 // to a naive implementation. 836 var timeoutID = -1; 837 requestCallback = function (callback, absoluteTimeout) { 838 timeoutID = setTimeout(callback, 0, true); 839 }; 840 cancelCallback = function () { 841 clearTimeout(timeoutID); 842 }; 843 getFrameDeadline = function () { 844 return 0; 845 }; 846 } else if (window._schedMock) { 847 // Dynamic injection, only for testing purposes. 848 var impl = window._schedMock; 849 requestCallback = impl[0]; 850 cancelCallback = impl[1]; 851 getFrameDeadline = impl[2]; 852 } else { 853 if (typeof console !== 'undefined') { 854 if (typeof localRequestAnimationFrame !== 'function') { 855 console.error("This browser doesn't support requestAnimationFrame. " + 'Make sure that you load a ' + 'polyfill in older browsers. https://fb.me/react-polyfills'); 856 } 857 if (typeof localCancelAnimationFrame !== 'function') { 858 console.error("This browser doesn't support cancelAnimationFrame. " + 'Make sure that you load a ' + 'polyfill in older browsers. https://fb.me/react-polyfills'); 859 } 860 } 861 862 var scheduledCallback = null; 863 var isIdleScheduled = false; 864 var timeoutTime = -1; 865 866 var isAnimationFrameScheduled = false; 867 868 var isPerformingIdleWork = false; 869 870 var frameDeadline = 0; 871 // We start out assuming that we run at 30fps but then the heuristic tracking 872 // will adjust this value to a faster fps if we get more frequent animation 873 // frames. 874 var previousFrameTime = 33; 875 var activeFrameTime = 33; 876 877 getFrameDeadline = function () { 878 return frameDeadline; 879 }; 880 881 // We use the postMessage trick to defer idle work until after the repaint. 882 var messageKey = '__reactIdleCallback$' + Math.random().toString(36).slice(2); 883 var idleTick = function (event) { 884 if (event.source !== window || event.data !== messageKey) { 885 return; 886 } 887 888 isIdleScheduled = false; 889 890 var currentTime = getCurrentTime(); 891 892 var didTimeout = false; 893 if (frameDeadline - currentTime <= 0) { 894 // There's no time left in this idle period. Check if the callback has 895 // a timeout and whether it's been exceeded. 896 if (timeoutTime !== -1 && timeoutTime <= currentTime) { 897 // Exceeded the timeout. Invoke the callback even though there's no 898 // time left. 899 didTimeout = true; 900 } else { 901 // No timeout. 902 if (!isAnimationFrameScheduled) { 903 // Schedule another animation callback so we retry later. 904 isAnimationFrameScheduled = true; 905 requestAnimationFrameWithTimeout(animationTick); 906 } 907 // Exit without invoking the callback. 908 return; 909 } 910 } 911 912 timeoutTime = -1; 913 var callback = scheduledCallback; 914 scheduledCallback = null; 915 if (callback !== null) { 916 isPerformingIdleWork = true; 917 try { 918 callback(didTimeout); 919 } finally { 920 isPerformingIdleWork = false; 921 } 922 } 923 }; 924 // Assumes that we have addEventListener in this environment. Might need 925 // something better for old IE. 926 window.addEventListener('message', idleTick, false); 927 928 var animationTick = function (rafTime) { 929 isAnimationFrameScheduled = false; 930 var nextFrameTime = rafTime - frameDeadline + activeFrameTime; 931 if (nextFrameTime < activeFrameTime && previousFrameTime < activeFrameTime) { 932 if (nextFrameTime < 8) { 933 // Defensive coding. We don't support higher frame rates than 120hz. 934 // If we get lower than that, it is probably a bug. 935 nextFrameTime = 8; 936 } 937 // If one frame goes long, then the next one can be short to catch up. 938 // If two frames are short in a row, then that's an indication that we 939 // actually have a higher frame rate than what we're currently optimizing. 940 // We adjust our heuristic dynamically accordingly. For example, if we're 941 // running on 120hz display or 90hz VR display. 942 // Take the max of the two in case one of them was an anomaly due to 943 // missed frame deadlines. 944 activeFrameTime = nextFrameTime < previousFrameTime ? previousFrameTime : nextFrameTime; 945 } else { 946 previousFrameTime = nextFrameTime; 947 } 948 frameDeadline = rafTime + activeFrameTime; 949 if (!isIdleScheduled) { 950 isIdleScheduled = true; 951 window.postMessage(messageKey, '*'); 952 } 953 }; 954 955 requestCallback = function (callback, absoluteTimeout) { 956 scheduledCallback = callback; 957 timeoutTime = absoluteTimeout; 958 if (isPerformingIdleWork) { 959 // If we're already performing idle work, an error must have been thrown. 960 // Don't wait for the next frame. Continue working ASAP, in a new event. 961 window.postMessage(messageKey, '*'); 962 } else if (!isAnimationFrameScheduled) { 963 // If rAF didn't already schedule one, we need to schedule a frame. 964 // TODO: If this rAF doesn't materialize because the browser throttles, we 965 // might want to still have setTimeout trigger rIC as a backup to ensure 966 // that we keep performing work. 967 isAnimationFrameScheduled = true; 968 requestAnimationFrameWithTimeout(animationTick); 969 } 970 }; 971 972 cancelCallback = function () { 973 scheduledCallback = null; 974 isIdleScheduled = false; 975 timeoutTime = -1; 976 }; 977 } 978 979 var DEFAULT_THREAD_ID = 0; 980 981 // Counters used to generate unique IDs. 982 var interactionIDCounter = 0; 983 var threadIDCounter = 0; 984 985 // Set of currently traced interactions. 986 // Interactions "stack"– 987 // Meaning that newly traced interactions are appended to the previously active set. 988 // When an interaction goes out of scope, the previous set (if any) is restored. 989 var interactionsRef = null; 990 991 // Listener(s) to notify when interactions begin and end. 992 var subscriberRef = null; 993 994 if (enableSchedulerTracing) { 995 interactionsRef = { 996 current: new Set() 997 }; 998 subscriberRef = { 999 current: null 1000 }; 1001 } 1002 1003 function unstable_clear(callback) { 1004 if (!enableSchedulerTracing) { 1005 return callback(); 1006 } 1007 1008 var prevInteractions = interactionsRef.current; 1009 interactionsRef.current = new Set(); 1010 1011 try { 1012 return callback(); 1013 } finally { 1014 interactionsRef.current = prevInteractions; 1015 } 1016 } 1017 1018 function unstable_getCurrent() { 1019 if (!enableSchedulerTracing) { 1020 return null; 1021 } else { 1022 return interactionsRef.current; 1023 } 1024 } 1025 1026 function unstable_getThreadID() { 1027 return ++threadIDCounter; 1028 } 1029 1030 function unstable_trace(name, timestamp, callback) { 1031 var threadID = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : DEFAULT_THREAD_ID; 1032 1033 if (!enableSchedulerTracing) { 1034 return callback(); 1035 } 1036 1037 var interaction = { 1038 __count: 1, 1039 id: interactionIDCounter++, 1040 name: name, 1041 timestamp: timestamp 1042 }; 1043 1044 var prevInteractions = interactionsRef.current; 1045 1046 // Traced interactions should stack/accumulate. 1047 // To do that, clone the current interactions. 1048 // The previous set will be restored upon completion. 1049 var interactions = new Set(prevInteractions); 1050 interactions.add(interaction); 1051 interactionsRef.current = interactions; 1052 1053 var subscriber = subscriberRef.current; 1054 var returnValue = void 0; 1055 1056 try { 1057 if (subscriber !== null) { 1058 subscriber.onInteractionTraced(interaction); 1059 } 1060 } finally { 1061 try { 1062 if (subscriber !== null) { 1063 subscriber.onWorkStarted(interactions, threadID); 1064 } 1065 } finally { 1066 try { 1067 returnValue = callback(); 1068 } finally { 1069 interactionsRef.current = prevInteractions; 1070 1071 try { 1072 if (subscriber !== null) { 1073 subscriber.onWorkStopped(interactions, threadID); 1074 } 1075 } finally { 1076 interaction.__count--; 1077 1078 // If no async work was scheduled for this interaction, 1079 // Notify subscribers that it's completed. 1080 if (subscriber !== null && interaction.__count === 0) { 1081 subscriber.onInteractionScheduledWorkCompleted(interaction); 1082 } 1083 } 1084 } 1085 } 1086 } 1087 1088 return returnValue; 1089 } 1090 1091 function unstable_wrap(callback) { 1092 var threadID = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_THREAD_ID; 1093 1094 if (!enableSchedulerTracing) { 1095 return callback; 1096 } 1097 1098 var wrappedInteractions = interactionsRef.current; 1099 1100 var subscriber = subscriberRef.current; 1101 if (subscriber !== null) { 1102 subscriber.onWorkScheduled(wrappedInteractions, threadID); 1103 } 1104 1105 // Update the pending async work count for the current interactions. 1106 // Update after calling subscribers in case of error. 1107 wrappedInteractions.forEach(function (interaction) { 1108 interaction.__count++; 1109 }); 1110 1111 var hasRun = false; 1112 1113 function wrapped() { 1114 var prevInteractions = interactionsRef.current; 1115 interactionsRef.current = wrappedInteractions; 1116 1117 subscriber = subscriberRef.current; 1118 1119 try { 1120 var returnValue = void 0; 1121 1122 try { 1123 if (subscriber !== null) { 1124 subscriber.onWorkStarted(wrappedInteractions, threadID); 1125 } 1126 } finally { 1127 try { 1128 returnValue = callback.apply(undefined, arguments); 1129 } finally { 1130 interactionsRef.current = prevInteractions; 1131 1132 if (subscriber !== null) { 1133 subscriber.onWorkStopped(wrappedInteractions, threadID); 1134 } 1135 } 1136 } 1137 1138 return returnValue; 1139 } finally { 1140 if (!hasRun) { 1141 // We only expect a wrapped function to be executed once, 1142 // But in the event that it's executed more than once– 1143 // Only decrement the outstanding interaction counts once. 1144 hasRun = true; 1145 1146 // Update pending async counts for all wrapped interactions. 1147 // If this was the last scheduled async work for any of them, 1148 // Mark them as completed. 1149 wrappedInteractions.forEach(function (interaction) { 1150 interaction.__count--; 1151 1152 if (subscriber !== null && interaction.__count === 0) { 1153 subscriber.onInteractionScheduledWorkCompleted(interaction); 1154 } 1155 }); 1156 } 1157 } 1158 } 1159 1160 wrapped.cancel = function cancel() { 1161 subscriber = subscriberRef.current; 1162 1163 try { 1164 if (subscriber !== null) { 1165 subscriber.onWorkCanceled(wrappedInteractions, threadID); 1166 } 1167 } finally { 1168 // Update pending async counts for all wrapped interactions. 1169 // If this was the last scheduled async work for any of them, 1170 // Mark them as completed. 1171 wrappedInteractions.forEach(function (interaction) { 1172 interaction.__count--; 1173 1174 if (subscriber && interaction.__count === 0) { 1175 subscriber.onInteractionScheduledWorkCompleted(interaction); 1176 } 1177 }); 1178 } 1179 }; 1180 1181 return wrapped; 1182 } 1183 1184 var subscribers = null; 1185 if (enableSchedulerTracing) { 1186 subscribers = new Set(); 1187 } 1188 1189 function unstable_subscribe(subscriber) { 1190 if (enableSchedulerTracing) { 1191 subscribers.add(subscriber); 1192 1193 if (subscribers.size === 1) { 1194 subscriberRef.current = { 1195 onInteractionScheduledWorkCompleted: onInteractionScheduledWorkCompleted, 1196 onInteractionTraced: onInteractionTraced, 1197 onWorkCanceled: onWorkCanceled, 1198 onWorkScheduled: onWorkScheduled, 1199 onWorkStarted: onWorkStarted, 1200 onWorkStopped: onWorkStopped 1201 }; 1202 } 1203 } 1204 } 1205 1206 function unstable_unsubscribe(subscriber) { 1207 if (enableSchedulerTracing) { 1208 subscribers.delete(subscriber); 1209 1210 if (subscribers.size === 0) { 1211 subscriberRef.current = null; 1212 } 1213 } 1214 } 1215 1216 function onInteractionTraced(interaction) { 1217 var didCatchError = false; 1218 var caughtError = null; 1219 1220 subscribers.forEach(function (subscriber) { 1221 try { 1222 subscriber.onInteractionTraced(interaction); 1223 } catch (error) { 1224 if (!didCatchError) { 1225 didCatchError = true; 1226 caughtError = error; 1227 } 1228 } 1229 }); 1230 1231 if (didCatchError) { 1232 throw caughtError; 1233 } 1234 } 1235 1236 function onInteractionScheduledWorkCompleted(interaction) { 1237 var didCatchError = false; 1238 var caughtError = null; 1239 1240 subscribers.forEach(function (subscriber) { 1241 try { 1242 subscriber.onInteractionScheduledWorkCompleted(interaction); 1243 } catch (error) { 1244 if (!didCatchError) { 1245 didCatchError = true; 1246 caughtError = error; 1247 } 1248 } 1249 }); 1250 1251 if (didCatchError) { 1252 throw caughtError; 1253 } 1254 } 1255 1256 function onWorkScheduled(interactions, threadID) { 1257 var didCatchError = false; 1258 var caughtError = null; 1259 1260 subscribers.forEach(function (subscriber) { 1261 try { 1262 subscriber.onWorkScheduled(interactions, threadID); 1263 } catch (error) { 1264 if (!didCatchError) { 1265 didCatchError = true; 1266 caughtError = error; 1267 } 1268 } 1269 }); 1270 1271 if (didCatchError) { 1272 throw caughtError; 1273 } 1274 } 1275 1276 function onWorkStarted(interactions, threadID) { 1277 var didCatchError = false; 1278 var caughtError = null; 1279 1280 subscribers.forEach(function (subscriber) { 1281 try { 1282 subscriber.onWorkStarted(interactions, threadID); 1283 } catch (error) { 1284 if (!didCatchError) { 1285 didCatchError = true; 1286 caughtError = error; 1287 } 1288 } 1289 }); 1290 1291 if (didCatchError) { 1292 throw caughtError; 1293 } 1294 } 1295 1296 function onWorkStopped(interactions, threadID) { 1297 var didCatchError = false; 1298 var caughtError = null; 1299 1300 subscribers.forEach(function (subscriber) { 1301 try { 1302 subscriber.onWorkStopped(interactions, threadID); 1303 } catch (error) { 1304 if (!didCatchError) { 1305 didCatchError = true; 1306 caughtError = error; 1307 } 1308 } 1309 }); 1310 1311 if (didCatchError) { 1312 throw caughtError; 1313 } 1314 } 1315 1316 function onWorkCanceled(interactions, threadID) { 1317 var didCatchError = false; 1318 var caughtError = null; 1319 1320 subscribers.forEach(function (subscriber) { 1321 try { 1322 subscriber.onWorkCanceled(interactions, threadID); 1323 } catch (error) { 1324 if (!didCatchError) { 1325 didCatchError = true; 1326 caughtError = error; 1327 } 1328 } 1329 }); 1330 1331 if (didCatchError) { 1332 throw caughtError; 1333 } 1334 } 1335 1336 /** 1337 * Keeps track of the current owner. 1338 * 1339 * The current owner is the component who should own any components that are 1340 * currently being constructed. 1341 */ 1342 var ReactCurrentOwner = { 1343 /** 1344 * @internal 1345 * @type {ReactComponent} 1346 */ 1347 current: null, 1348 currentDispatcher: null 1349 }; 1350 1351 var BEFORE_SLASH_RE = /^(.*)[\\\/]/; 1352 1353 var describeComponentFrame = function (name, source, ownerName) { 1354 var sourceInfo = ''; 1355 if (source) { 1356 var path = source.fileName; 1357 var fileName = path.replace(BEFORE_SLASH_RE, ''); 1358 { 1359 // In DEV, include code for a common special case: 1360 // prefer "folder/index.js" instead of just "index.js". 1361 if (/^index\./.test(fileName)) { 1362 var match = path.match(BEFORE_SLASH_RE); 1363 if (match) { 1364 var pathBeforeSlash = match[1]; 1365 if (pathBeforeSlash) { 1366 var folderName = pathBeforeSlash.replace(BEFORE_SLASH_RE, ''); 1367 fileName = folderName + '/' + fileName; 1368 } 1369 } 1370 } 1371 } 1372 sourceInfo = ' (at ' + fileName + ':' + source.lineNumber + ')'; 1373 } else if (ownerName) { 1374 sourceInfo = ' (created by ' + ownerName + ')'; 1375 } 1376 return '\n in ' + (name || 'Unknown') + sourceInfo; 1377 }; 1378 1379 var Resolved = 1; 1380 1381 1382 1383 1384 function refineResolvedThenable(thenable) { 1385 return thenable._reactStatus === Resolved ? thenable._reactResult : null; 1386 } 1387 1388 function getComponentName(type) { 1389 if (type == null) { 1390 // Host root, text node or just invalid type. 1391 return null; 1392 } 1393 { 1394 if (typeof type.tag === 'number') { 1395 warningWithoutStack$1(false, 'Received an unexpected object in getComponentName(). ' + 'This is likely a bug in React. Please file an issue.'); 1396 } 1397 } 1398 if (typeof type === 'function') { 1399 return type.displayName || type.name || null; 1400 } 1401 if (typeof type === 'string') { 1402 return type; 1403 } 1404 switch (type) { 1405 case REACT_ASYNC_MODE_TYPE: 1406 return 'AsyncMode'; 1407 case REACT_FRAGMENT_TYPE: 1408 return 'Fragment'; 1409 case REACT_PORTAL_TYPE: 1410 return 'Portal'; 1411 case REACT_PROFILER_TYPE: 1412 return 'Profiler'; 1413 case REACT_STRICT_MODE_TYPE: 1414 return 'StrictMode'; 1415 case REACT_PLACEHOLDER_TYPE: 1416 return 'Placeholder'; 1417 } 1418 if (typeof type === 'object') { 1419 switch (type.$$typeof) { 1420 case REACT_CONTEXT_TYPE: 1421 return 'Context.Consumer'; 1422 case REACT_PROVIDER_TYPE: 1423 return 'Context.Provider'; 1424 case REACT_FORWARD_REF_TYPE: 1425 var renderFn = type.render; 1426 var functionName = renderFn.displayName || renderFn.name || ''; 1427 return type.displayName || (functionName !== '' ? 'ForwardRef(' + functionName + ')' : 'ForwardRef'); 1428 } 1429 if (typeof type.then === 'function') { 1430 var thenable = type; 1431 var resolvedThenable = refineResolvedThenable(thenable); 1432 if (resolvedThenable) { 1433 return getComponentName(resolvedThenable); 1434 } 1435 } 1436 } 1437 return null; 1438 } 1439 1440 var ReactDebugCurrentFrame = {}; 1441 1442 var currentlyValidatingElement = null; 1443 1444 function setCurrentlyValidatingElement(element) { 1445 { 1446 currentlyValidatingElement = element; 1447 } 1448 } 1449 1450 { 1451 // Stack implementation injected by the current renderer. 1452 ReactDebugCurrentFrame.getCurrentStack = null; 1453 1454 ReactDebugCurrentFrame.getStackAddendum = function () { 1455 var stack = ''; 1456 1457 // Add an extra top frame while an element is being validated 1458 if (currentlyValidatingElement) { 1459 var name = getComponentName(currentlyValidatingElement.type); 1460 var owner = currentlyValidatingElement._owner; 1461 stack += describeComponentFrame(name, currentlyValidatingElement._source, owner && getComponentName(owner.type)); 1462 } 1463 1464 // Delegate to the injected renderer-specific implementation 1465 var impl = ReactDebugCurrentFrame.getCurrentStack; 1466 if (impl) { 1467 stack += impl() || ''; 1468 } 1469 1470 return stack; 1471 }; 1472 } 1473 1474 var ReactSharedInternals = { 1475 ReactCurrentOwner: ReactCurrentOwner, 1476 // Used by renderers to avoid bundling object-assign twice in UMD bundles: 1477 assign: objectAssign 1478 }; 1479 1480 { 1481 // Re-export the schedule API(s) for UMD bundles. 1482 // This avoids introducing a dependency on a new UMD global in a minor update, 1483 // Since that would be a breaking change (e.g. for all existing CodeSandboxes). 1484 // This re-export is only required for UMD bundles; 1485 // CJS bundles use the shared NPM package. 1486 objectAssign(ReactSharedInternals, { 1487 Schedule: { 1488 unstable_cancelScheduledWork: unstable_cancelScheduledWork, 1489 unstable_now: getCurrentTime, 1490 unstable_scheduleWork: unstable_scheduleWork 1491 }, 1492 ScheduleTracing: { 1493 __interactionsRef: interactionsRef, 1494 __subscriberRef: subscriberRef, 1495 unstable_clear: unstable_clear, 1496 unstable_getCurrent: unstable_getCurrent, 1497 unstable_getThreadID: unstable_getThreadID, 1498 unstable_subscribe: unstable_subscribe, 1499 unstable_trace: unstable_trace, 1500 unstable_unsubscribe: unstable_unsubscribe, 1501 unstable_wrap: unstable_wrap 1502 } 1503 }); 1504 } 1505 1506 { 1507 objectAssign(ReactSharedInternals, { 1508 // These should not be included in production. 1509 ReactDebugCurrentFrame: ReactDebugCurrentFrame, 1510 // Shim for React DOM 16.0.0 which still destructured (but not used) this. 1511 // TODO: remove in React 17.0. 1512 ReactComponentTreeHook: {} 1513 }); 1514 } 1515 1516 /** 1517 * Similar to invariant but only logs a warning if the condition is not met. 1518 * This can be used to log issues in development environments in critical 1519 * paths. Removing the logging code for production environments will keep the 1520 * same logic and follow the same code paths. 1521 */ 1522 1523 var warning = warningWithoutStack$1; 1524 1525 { 1526 warning = function (condition, format) { 1527 if (condition) { 1528 return; 1529 } 1530 var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; 1531 var stack = ReactDebugCurrentFrame.getStackAddendum(); 1532 // eslint-disable-next-line react-internal/warning-and-invariant-args 1533 1534 for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { 1535 args[_key - 2] = arguments[_key]; 1536 } 1537 1538 warningWithoutStack$1.apply(undefined, [false, format + '%s'].concat(args, [stack])); 1539 }; 1540 } 1541 1542 var warning$1 = warning; 1543 1544 var hasOwnProperty$1 = Object.prototype.hasOwnProperty; 1545 1546 var RESERVED_PROPS = { 1547 key: true, 1548 ref: true, 1549 __self: true, 1550 __source: true 1551 }; 1552 1553 var specialPropKeyWarningShown = void 0; 1554 var specialPropRefWarningShown = void 0; 1555 1556 function hasValidRef(config) { 1557 { 1558 if (hasOwnProperty$1.call(config, 'ref')) { 1559 var getter = Object.getOwnPropertyDescriptor(config, 'ref').get; 1560 if (getter && getter.isReactWarning) { 1561 return false; 1562 } 1563 } 1564 } 1565 return config.ref !== undefined; 1566 } 1567 1568 function hasValidKey(config) { 1569 { 1570 if (hasOwnProperty$1.call(config, 'key')) { 1571 var getter = Object.getOwnPropertyDescriptor(config, 'key').get; 1572 if (getter && getter.isReactWarning) { 1573 return false; 1574 } 1575 } 1576 } 1577 return config.key !== undefined; 1578 } 1579 1580 function defineKeyPropWarningGetter(props, displayName) { 1581 var warnAboutAccessingKey = function () { 1582 if (!specialPropKeyWarningShown) { 1583 specialPropKeyWarningShown = true; 1584 warningWithoutStack$1(false, '%s: `key` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://fb.me/react-special-props)', displayName); 1585 } 1586 }; 1587 warnAboutAccessingKey.isReactWarning = true; 1588 Object.defineProperty(props, 'key', { 1589 get: warnAboutAccessingKey, 1590 configurable: true 1591 }); 1592 } 1593 1594 function defineRefPropWarningGetter(props, displayName) { 1595 var warnAboutAccessingRef = function () { 1596 if (!specialPropRefWarningShown) { 1597 specialPropRefWarningShown = true; 1598 warningWithoutStack$1(false, '%s: `ref` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://fb.me/react-special-props)', displayName); 1599 } 1600 }; 1601 warnAboutAccessingRef.isReactWarning = true; 1602 Object.defineProperty(props, 'ref', { 1603 get: warnAboutAccessingRef, 1604 configurable: true 1605 }); 1606 } 1607 1608 /** 1609 * Factory method to create a new React element. This no longer adheres to 1610 * the class pattern, so do not use new to call it. Also, no instanceof check 1611 * will work. Instead test $$typeof field against Symbol.for('react.element') to check 1612 * if something is a React Element. 1613 * 1614 * @param {*} type 1615 * @param {*} key 1616 * @param {string|object} ref 1617 * @param {*} self A *temporary* helper to detect places where `this` is 1618 * different from the `owner` when React.createElement is called, so that we 1619 * can warn. We want to get rid of owner and replace string `ref`s with arrow 1620 * functions, and as long as `this` and owner are the same, there will be no 1621 * change in behavior. 1622 * @param {*} source An annotation object (added by a transpiler or otherwise) 1623 * indicating filename, line number, and/or other information. 1624 * @param {*} owner 1625 * @param {*} props 1626 * @internal 1627 */ 1628 var ReactElement = function (type, key, ref, self, source, owner, props) { 1629 var element = { 1630 // This tag allows us to uniquely identify this as a React Element 1631 $$typeof: REACT_ELEMENT_TYPE, 1632 1633 // Built-in properties that belong on the element 1634 type: type, 1635 key: key, 1636 ref: ref, 1637 props: props, 1638 1639 // Record the component responsible for creating this element. 1640 _owner: owner 1641 }; 1642 1643 { 1644 // The validation flag is currently mutative. We put it on 1645 // an external backing store so that we can freeze the whole object. 1646 // This can be replaced with a WeakMap once they are implemented in 1647 // commonly used development environments. 1648 element._store = {}; 1649 1650 // To make comparing ReactElements easier for testing purposes, we make 1651 // the validation flag non-enumerable (where possible, which should 1652 // include every environment we run tests in), so the test framework 1653 // ignores it. 1654 Object.defineProperty(element._store, 'validated', { 1655 configurable: false, 1656 enumerable: false, 1657 writable: true, 1658 value: false 1659 }); 1660 // self and source are DEV only properties. 1661 Object.defineProperty(element, '_self', { 1662 configurable: false, 1663 enumerable: false, 1664 writable: false, 1665 value: self 1666 }); 1667 // Two elements created in two different places should be considered 1668 // equal for testing purposes and therefore we hide it from enumeration. 1669 Object.defineProperty(element, '_source', { 1670 configurable: false, 1671 enumerable: false, 1672 writable: false, 1673 value: source 1674 }); 1675 if (Object.freeze) { 1676 Object.freeze(element.props); 1677 Object.freeze(element); 1678 } 1679 } 1680 1681 return element; 1682 }; 1683 1684 /** 1685 * Create and return a new ReactElement of the given type. 1686 * See https://reactjs.org/docs/react-api.html#createelement 1687 */ 1688 function createElement(type, config, children) { 1689 var propName = void 0; 1690 1691 // Reserved names are extracted 1692 var props = {}; 1693 1694 var key = null; 1695 var ref = null; 1696 var self = null; 1697 var source = null; 1698 1699 if (config != null) { 1700 if (hasValidRef(config)) { 1701 ref = config.ref; 1702 } 1703 if (hasValidKey(config)) { 1704 key = '' + config.key; 1705 } 1706 1707 self = config.__self === undefined ? null : config.__self; 1708 source = config.__source === undefined ? null : config.__source; 1709 // Remaining properties are added to a new props object 1710 for (propName in config) { 1711 if (hasOwnProperty$1.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) { 1712 props[propName] = config[propName]; 1713 } 1714 } 1715 } 1716 1717 // Children can be more than one argument, and those are transferred onto 1718 // the newly allocated props object. 1719 var childrenLength = arguments.length - 2; 1720 if (childrenLength === 1) { 1721 props.children = children; 1722 } else if (childrenLength > 1) { 1723 var childArray = Array(childrenLength); 1724 for (var i = 0; i < childrenLength; i++) { 1725 childArray[i] = arguments[i + 2]; 1726 } 1727 { 1728 if (Object.freeze) { 1729 Object.freeze(childArray); 1730 } 1731 } 1732 props.children = childArray; 1733 } 1734 1735 // Resolve default props 1736 if (type && type.defaultProps) { 1737 var defaultProps = type.defaultProps; 1738 for (propName in defaultProps) { 1739 if (props[propName] === undefined) { 1740 props[propName] = defaultProps[propName]; 1741 } 1742 } 1743 } 1744 { 1745 if (key || ref) { 1746 var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type; 1747 if (key) { 1748 defineKeyPropWarningGetter(props, displayName); 1749 } 1750 if (ref) { 1751 defineRefPropWarningGetter(props, displayName); 1752 } 1753 } 1754 } 1755 return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props); 1756 } 1757 1758 /** 1759 * Return a function that produces ReactElements of a given type. 1760 * See https://reactjs.org/docs/react-api.html#createfactory 1761 */ 1762 1763 1764 function cloneAndReplaceKey(oldElement, newKey) { 1765 var newElement = ReactElement(oldElement.type, newKey, oldElement.ref, oldElement._self, oldElement._source, oldElement._owner, oldElement.props); 1766 1767 return newElement; 1768 } 1769 1770 /** 1771 * Clone and return a new ReactElement using element as the starting point. 1772 * See https://reactjs.org/docs/react-api.html#cloneelement 1773 */ 1774 function cloneElement(element, config, children) { 1775 !!(element === null || element === undefined) ? invariant(false, 'React.cloneElement(...): The argument must be a React element, but you passed %s.', element) : void 0; 1776 1777 var propName = void 0; 1778 1779 // Original props are copied 1780 var props = objectAssign({}, element.props); 1781 1782 // Reserved names are extracted 1783 var key = element.key; 1784 var ref = element.ref; 1785 // Self is preserved since the owner is preserved. 1786 var self = element._self; 1787 // Source is preserved since cloneElement is unlikely to be targeted by a 1788 // transpiler, and the original source is probably a better indicator of the 1789 // true owner. 1790 var source = element._source; 1791 1792 // Owner will be preserved, unless ref is overridden 1793 var owner = element._owner; 1794 1795 if (config != null) { 1796 if (hasValidRef(config)) { 1797 // Silently steal the ref from the parent. 1798 ref = config.ref; 1799 owner = ReactCurrentOwner.current; 1800 } 1801 if (hasValidKey(config)) { 1802 key = '' + config.key; 1803 } 1804 1805 // Remaining properties override existing props 1806 var defaultProps = void 0; 1807 if (element.type && element.type.defaultProps) { 1808 defaultProps = element.type.defaultProps; 1809 } 1810 for (propName in config) { 1811 if (hasOwnProperty$1.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) { 1812 if (config[propName] === undefined && defaultProps !== undefined) { 1813 // Resolve default props 1814 props[propName] = defaultProps[propName]; 1815 } else { 1816 props[propName] = config[propName]; 1817 } 1818 } 1819 } 1820 } 1821 1822 // Children can be more than one argument, and those are transferred onto 1823 // the newly allocated props object. 1824 var childrenLength = arguments.length - 2; 1825 if (childrenLength === 1) { 1826 props.children = children; 1827 } else if (childrenLength > 1) { 1828 var childArray = Array(childrenLength); 1829 for (var i = 0; i < childrenLength; i++) { 1830 childArray[i] = arguments[i + 2]; 1831 } 1832 props.children = childArray; 1833 } 1834 1835 return ReactElement(element.type, key, ref, self, source, owner, props); 1836 } 1837 1838 /** 1839 * Verifies the object is a ReactElement. 1840 * See https://reactjs.org/docs/react-api.html#isvalidelement 1841 * @param {?object} object 1842 * @return {boolean} True if `object` is a ReactElement. 1843 * @final 1844 */ 1845 function isValidElement(object) { 1846 return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE; 1847 } 1848 1849 var SEPARATOR = '.'; 1850 var SUBSEPARATOR = ':'; 1851 1852 /** 1853 * Escape and wrap key so it is safe to use as a reactid 1854 * 1855 * @param {string} key to be escaped. 1856 * @return {string} the escaped key. 1857 */ 1858 function escape(key) { 1859 var escapeRegex = /[=:]/g; 1860 var escaperLookup = { 1861 '=': '=0', 1862 ':': '=2' 1863 }; 1864 var escapedString = ('' + key).replace(escapeRegex, function (match) { 1865 return escaperLookup[match]; 1866 }); 1867 1868 return '$' + escapedString; 1869 } 1870 1871 /** 1872 * TODO: Test that a single child and an array with one item have the same key 1873 * pattern. 1874 */ 1875 1876 var didWarnAboutMaps = false; 1877 1878 var userProvidedKeyEscapeRegex = /\/+/g; 1879 function escapeUserProvidedKey(text) { 1880 return ('' + text).replace(userProvidedKeyEscapeRegex, '$&/'); 1881 } 1882 1883 var POOL_SIZE = 10; 1884 var traverseContextPool = []; 1885 function getPooledTraverseContext(mapResult, keyPrefix, mapFunction, mapContext) { 1886 if (traverseContextPool.length) { 1887 var traverseContext = traverseContextPool.pop(); 1888 traverseContext.result = mapResult; 1889 traverseContext.keyPrefix = keyPrefix; 1890 traverseContext.func = mapFunction; 1891 traverseContext.context = mapContext; 1892 traverseContext.count = 0; 1893 return traverseContext; 1894 } else { 1895 return { 1896 result: mapResult, 1897 keyPrefix: keyPrefix, 1898 func: mapFunction, 1899 context: mapContext, 1900 count: 0 1901 }; 1902 } 1903 } 1904 1905 function releaseTraverseContext(traverseContext) { 1906 traverseContext.result = null; 1907 traverseContext.keyPrefix = null; 1908 traverseContext.func = null; 1909 traverseContext.context = null; 1910 traverseContext.count = 0; 1911 if (traverseContextPool.length < POOL_SIZE) { 1912 traverseContextPool.push(traverseContext); 1913 } 1914 } 1915 1916 /** 1917 * @param {?*} children Children tree container. 1918 * @param {!string} nameSoFar Name of the key path so far. 1919 * @param {!function} callback Callback to invoke with each child found. 1920 * @param {?*} traverseContext Used to pass information throughout the traversal 1921 * process. 1922 * @return {!number} The number of children in this subtree. 1923 */ 1924 function traverseAllChildrenImpl(children, nameSoFar, callback, traverseContext) { 1925 var type = typeof children; 1926 1927 if (type === 'undefined' || type === 'boolean') { 1928 // All of the above are perceived as null. 1929 children = null; 1930 } 1931 1932 var invokeCallback = false; 1933 1934 if (children === null) { 1935 invokeCallback = true; 1936 } else { 1937 switch (type) { 1938 case 'string': 1939 case 'number': 1940 invokeCallback = true; 1941 break; 1942 case 'object': 1943 switch (children.$$typeof) { 1944 case REACT_ELEMENT_TYPE: 1945 case REACT_PORTAL_TYPE: 1946 invokeCallback = true; 1947 } 1948 } 1949 } 1950 1951 if (invokeCallback) { 1952 callback(traverseContext, children, 1953 // If it's the only child, treat the name as if it was wrapped in an array 1954 // so that it's consistent if the number of children grows. 1955 nameSoFar === '' ? SEPARATOR + getComponentKey(children, 0) : nameSoFar); 1956 return 1; 1957 } 1958 1959 var child = void 0; 1960 var nextName = void 0; 1961 var subtreeCount = 0; // Count of children found in the current subtree. 1962 var nextNamePrefix = nameSoFar === '' ? SEPARATOR : nameSoFar + SUBSEPARATOR; 1963 1964 if (Array.isArray(children)) { 1965 for (var i = 0; i < children.length; i++) { 1966 child = children[i]; 1967 nextName = nextNamePrefix + getComponentKey(child, i); 1968 subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext); 1969 } 1970 } else { 1971 var iteratorFn = getIteratorFn(children); 1972 if (typeof iteratorFn === 'function') { 1973 { 1974 // Warn about using Maps as children 1975 if (iteratorFn === children.entries) { 1976 !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; 1977 didWarnAboutMaps = true; 1978 } 1979 } 1980 1981 var iterator = iteratorFn.call(children); 1982 var step = void 0; 1983 var ii = 0; 1984 while (!(step = iterator.next()).done) { 1985 child = step.value; 1986 nextName = nextNamePrefix + getComponentKey(child, ii++); 1987 subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext); 1988 } 1989 } else if (type === 'object') { 1990 var addendum = ''; 1991 { 1992 addendum = ' If you meant to render a collection of children, use an array ' + 'instead.' + ReactDebugCurrentFrame.getStackAddendum(); 1993 } 1994 var childrenString = '' + children; 1995 invariant(false, 'Objects are not valid as a React child (found: %s).%s', childrenString === '[object Object]' ? 'object with keys {' + Object.keys(children).join(', ') + '}' : childrenString, addendum); 1996 } 1997 } 1998 1999 return subtreeCount; 2000 } 2001 2002 /** 2003 * Traverses children that are typically specified as `props.children`, but 2004 * might also be specified through attributes: 2005 * 2006 * - `traverseAllChildren(this.props.children, ...)` 2007 * - `traverseAllChildren(this.props.leftPanelChildren, ...)` 2008 * 2009 * The `traverseContext` is an optional argument that is passed through the 2010 * entire traversal. It can be used to store accumulations or anything else that 2011 * the callback might find relevant. 2012 * 2013 * @param {?*} children Children tree object. 2014 * @param {!function} callback To invoke upon traversing each child. 2015 * @param {?*} traverseContext Context for traversal. 2016 * @return {!number} The number of children in this subtree. 2017 */ 2018 function traverseAllChildren(children, callback, traverseContext) { 2019 if (children == null) { 2020 return 0; 2021 } 2022 2023 return traverseAllChildrenImpl(children, '', callback, traverseContext); 2024 } 2025 2026 /** 2027 * Generate a key string that identifies a component within a set. 2028 * 2029 * @param {*} component A component that could contain a manual key. 2030 * @param {number} index Index that is used if a manual key is not provided. 2031 * @return {string} 2032 */ 2033 function getComponentKey(component, index) { 2034 // Do some typechecking here since we call this blindly. We want to ensure 2035 // that we don't block potential future ES APIs. 2036 if (typeof component === 'object' && component !== null && component.key != null) { 2037 // Explicit key 2038 return escape(component.key); 2039 } 2040 // Implicit key determined by the index in the set 2041 return index.toString(36); 2042 } 2043 2044 function forEachSingleChild(bookKeeping, child, name) { 2045 var func = bookKeeping.func, 2046 context = bookKeeping.context; 2047 2048 func.call(context, child, bookKeeping.count++); 2049 } 2050 2051 /** 2052 * Iterates through children that are typically specified as `props.children`. 2053 * 2054 * See https://reactjs.org/docs/react-api.html#reactchildrenforeach 2055 * 2056 * The provided forEachFunc(child, index) will be called for each 2057 * leaf child. 2058 * 2059 * @param {?*} children Children tree container. 2060 * @param {function(*, int)} forEachFunc 2061 * @param {*} forEachContext Context for forEachContext. 2062 */ 2063 function forEachChildren(children, forEachFunc, forEachContext) { 2064 if (children == null) { 2065 return children; 2066 } 2067 var traverseContext = getPooledTraverseContext(null, null, forEachFunc, forEachContext); 2068 traverseAllChildren(children, forEachSingleChild, traverseContext); 2069 releaseTraverseContext(traverseContext); 2070 } 2071 2072 function mapSingleChildIntoContext(bookKeeping, child, childKey) { 2073 var result = bookKeeping.result, 2074 keyPrefix = bookKeeping.keyPrefix, 2075 func = bookKeeping.func, 2076 context = bookKeeping.context; 2077 2078 2079 var mappedChild = func.call(context, child, bookKeeping.count++); 2080 if (Array.isArray(mappedChild)) { 2081 mapIntoWithKeyPrefixInternal(mappedChild, result, childKey, function (c) { 2082 return c; 2083 }); 2084 } else if (mappedChild != null) { 2085 if (isValidElement(mappedChild)) { 2086 mappedChild = cloneAndReplaceKey(mappedChild, 2087 // Keep both the (mapped) and old keys if they differ, just as 2088 // traverseAllChildren used to do for objects as children 2089 keyPrefix + (mappedChild.key && (!child || child.key !== mappedChild.key) ? escapeUserProvidedKey(mappedChild.key) + '/' : '') + childKey); 2090 } 2091 result.push(mappedChild); 2092 } 2093 } 2094 2095 function mapIntoWithKeyPrefixInternal(children, array, prefix, func, context) { 2096 var escapedPrefix = ''; 2097 if (prefix != null) { 2098 escapedPrefix = escapeUserProvidedKey(prefix) + '/'; 2099 } 2100 var traverseContext = getPooledTraverseContext(array, escapedPrefix, func, context); 2101 traverseAllChildren(children, mapSingleChildIntoContext, traverseContext); 2102 releaseTraverseContext(traverseContext); 2103 } 2104 2105 /** 2106 * Maps children that are typically specified as `props.children`. 2107 * 2108 * See https://reactjs.org/docs/react-api.html#reactchildrenmap 2109 * 2110 * The provided mapFunction(child, key, index) will be called for each 2111 * leaf child. 2112 * 2113 * @param {?*} children Children tree container. 2114 * @param {function(*, int)} func The map function. 2115 * @param {*} context Context for mapFunction. 2116 * @return {object} Object containing the ordered map of results. 2117 */ 2118 function mapChildren(children, func, context) { 2119 if (children == null) { 2120 return children; 2121 } 2122 var result = []; 2123 mapIntoWithKeyPrefixInternal(children, result, null, func, context); 2124 return result; 2125 } 2126 2127 /** 2128 * Count the number of children that are typically specified as 2129 * `props.children`. 2130 * 2131 * See https://reactjs.org/docs/react-api.html#reactchildrencount 2132 * 2133 * @param {?*} children Children tree container. 2134 * @return {number} The number of children. 2135 */ 2136 function countChildren(children) { 2137 return traverseAllChildren(children, function () { 2138 return null; 2139 }, null); 2140 } 2141 2142 /** 2143 * Flatten a children object (typically specified as `props.children`) and 2144 * return an array with appropriately re-keyed children. 2145 * 2146 * See https://reactjs.org/docs/react-api.html#reactchildrentoarray 2147 */ 2148 function toArray(children) { 2149 var result = []; 2150 mapIntoWithKeyPrefixInternal(children, result, null, function (child) { 2151 return child; 2152 }); 2153 return result; 2154 } 2155 2156 /** 2157 * Returns the first child in a collection of children and verifies that there 2158 * is only one child in the collection. 2159 * 2160 * See https://reactjs.org/docs/react-api.html#reactchildrenonly 2161 * 2162 * The current implementation of this function assumes that a single child gets 2163 * passed without a wrapper, but the purpose of this helper function is to 2164 * abstract away the particular structure of children. 2165 * 2166 * @param {?object} children Child collection structure. 2167 * @return {ReactElement} The first and only `ReactElement` contained in the 2168 * structure. 2169 */ 2170 function onlyChild(children) { 2171 !isValidElement(children) ? invariant(false, 'React.Children.only expected to receive a single React element child.') : void 0; 2172 return children; 2173 } 2174 2175 function readContext(context, observedBits) { 2176 var dispatcher = ReactCurrentOwner.currentDispatcher; 2177 !(dispatcher !== null) ? invariant(false, 'Context.unstable_read(): Context can only be read while React is rendering, e.g. inside the render method or getDerivedStateFromProps.') : void 0; 2178 return dispatcher.readContext(context, observedBits); 2179 } 2180 2181 function createContext(defaultValue, calculateChangedBits) { 2182 if (calculateChangedBits === undefined) { 2183 calculateChangedBits = null; 2184 } else { 2185 { 2186 !(calculateChangedBits === null || typeof calculateChangedBits === 'function') ? warningWithoutStack$1(false, 'createContext: Expected the optional second argument to be a ' + 'function. Instead received: %s', calculateChangedBits) : void 0; 2187 } 2188 } 2189 2190 var context = { 2191 $$typeof: REACT_CONTEXT_TYPE, 2192 _calculateChangedBits: calculateChangedBits, 2193 // As a workaround to support multiple concurrent renderers, we categorize 2194 // some renderers as primary and others as secondary. We only expect 2195 // there to be two concurrent renderers at most: React Native (primary) and 2196 // Fabric (secondary); React DOM (primary) and React ART (secondary). 2197 // Secondary renderers store their context values on separate fields. 2198 _currentValue: defaultValue, 2199 _currentValue2: defaultValue, 2200 // These are circular 2201 Provider: null, 2202 Consumer: null, 2203 unstable_read: null 2204 }; 2205 2206 context.Provider = { 2207 $$typeof: REACT_PROVIDER_TYPE, 2208 _context: context 2209 }; 2210 context.Consumer = context; 2211 context.unstable_read = readContext.bind(null, context); 2212 2213 { 2214 context._currentRenderer = null; 2215 context._currentRenderer2 = null; 2216 } 2217 2218 return context; 2219 } 2220 2221 function lazy(ctor) { 2222 var thenable = null; 2223 return { 2224 then: function (resolve, reject) { 2225 if (thenable === null) { 2226 // Lazily create thenable by wrapping in an extra thenable. 2227 thenable = ctor(); 2228 ctor = null; 2229 } 2230 return thenable.then(resolve, reject); 2231 }, 2232 2233 // React uses these fields to store the result. 2234 _reactStatus: -1, 2235 _reactResult: null 2236 }; 2237 } 2238 2239 function forwardRef(render) { 2240 { 2241 if (typeof render !== 'function') { 2242 warningWithoutStack$1(false, 'forwardRef requires a render function but was given %s.', render === null ? 'null' : typeof render); 2243 } else { 2244 !( 2245 // Do not warn for 0 arguments because it could be due to usage of the 'arguments' object 2246 render.length === 0 || render.length === 2) ? warningWithoutStack$1(false, 'forwardRef render functions accept exactly two parameters: props and ref. %s', render.length === 1 ? 'Did you forget to use the ref parameter?' : 'Any additional parameter will be undefined.') : void 0; 2247 } 2248 2249 if (render != null) { 2250 !(render.defaultProps == null && render.propTypes == null) ? warningWithoutStack$1(false, 'forwardRef render functions do not support propTypes or defaultProps. ' + 'Did you accidentally pass a React component?') : void 0; 2251 } 2252 } 2253 2254 return { 2255 $$typeof: REACT_FORWARD_REF_TYPE, 2256 render: render 2257 }; 2258 } 2259 2260 function isValidElementType(type) { 2261 return typeof type === 'string' || typeof type === 'function' || 2262 // Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill. 2263 type === REACT_FRAGMENT_TYPE || type === REACT_ASYNC_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_PLACEHOLDER_TYPE || typeof type === 'object' && type !== null && (typeof type.then === 'function' || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE); 2264 } 2265 2266 /** 2267 * Copyright (c) 2013-present, Facebook, Inc. 2268 * 2269 * This source code is licensed under the MIT license found in the 2270 * LICENSE file in the root directory of this source tree. 2271 */ 2272 2273 2274 2275 var ReactPropTypesSecret$1 = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED'; 2276 2277 var ReactPropTypesSecret_1 = ReactPropTypesSecret$1; 2278 2279 /** 2280 * Copyright (c) 2013-present, Facebook, Inc. 2281 * 2282 * This source code is licensed under the MIT license found in the 2283 * LICENSE file in the root directory of this source tree. 2284 */ 2285 2286 2287 2288 var printWarning$1 = function() {}; 2289 2290 { 2291 var ReactPropTypesSecret = ReactPropTypesSecret_1; 2292 var loggedTypeFailures = {}; 2293 2294 printWarning$1 = function(text) { 2295 var message = 'Warning: ' + text; 2296 if (typeof console !== 'undefined') { 2297 console.error(message); 2298 } 2299 try { 2300 // --- Welcome to debugging React --- 2301 // This error was thrown as a convenience so that you can use this stack 2302 // to find the callsite that caused this warning to fire. 2303 throw new Error(message); 2304 } catch (x) {} 2305 }; 2306 } 2307 2308 /** 2309 * Assert that the values match with the type specs. 2310 * Error messages are memorized and will only be shown once. 2311 * 2312 * @param {object} typeSpecs Map of name to a ReactPropType 2313 * @param {object} values Runtime values that need to be type-checked 2314 * @param {string} location e.g. "prop", "context", "child context" 2315 * @param {string} componentName Name of the component for error messages. 2316 * @param {?Function} getStack Returns the component stack. 2317 * @private 2318 */ 2319 function checkPropTypes(typeSpecs, values, location, componentName, getStack) { 2320 { 2321 for (var typeSpecName in typeSpecs) { 2322 if (typeSpecs.hasOwnProperty(typeSpecName)) { 2323 var error; 2324 // Prop type validation may throw. In case they do, we don't want to 2325 // fail the render phase where it didn't fail before. So we log it. 2326 // After these have been cleaned up, we'll let them throw. 2327 try { 2328 // This is intentionally an invariant that gets caught. It's the same 2329 // behavior as without this statement except with a better message. 2330 if (typeof typeSpecs[typeSpecName] !== 'function') { 2331 var err = Error( 2332 (componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' + 2333 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.' 2334 ); 2335 err.name = 'Invariant Violation'; 2336 throw err; 2337 } 2338 error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret); 2339 } catch (ex) { 2340 error = ex; 2341 } 2342 if (error && !(error instanceof Error)) { 2343 printWarning$1( 2344 (componentName || 'React class') + ': type specification of ' + 2345 location + ' `' + typeSpecName + '` is invalid; the type checker ' + 2346 'function must return `null` or an `Error` but returned a ' + typeof error + '. ' + 2347 'You may have forgotten to pass an argument to the type checker ' + 2348 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 2349 'shape all require an argument).' 2350 ); 2351 2352 } 2353 if (error instanceof Error && !(error.message in loggedTypeFailures)) { 2354 // Only monitor this failure once because there tends to be a lot of the 2355 // same error. 2356 loggedTypeFailures[error.message] = true; 2357 2358 var stack = getStack ? getStack() : ''; 2359 2360 printWarning$1( 2361 'Failed ' + location + ' type: ' + error.message + (stack != null ? stack : '') 2362 ); 2363 } 2364 } 2365 } 2366 } 2367 } 2368 2369 var checkPropTypes_1 = checkPropTypes; 2370 2371 /** 2372 * ReactElementValidator provides a wrapper around a element factory 2373 * which validates the props passed to the element. This is intended to be 2374 * used only in DEV and could be replaced by a static type checker for languages 2375 * that support it. 2376 */ 2377 2378 var propTypesMisspellWarningShown = void 0; 2379 2380 { 2381 propTypesMisspellWarningShown = false; 2382 } 2383 2384 function getDeclarationErrorAddendum() { 2385 if (ReactCurrentOwner.current) { 2386 var name = getComponentName(ReactCurrentOwner.current.type); 2387 if (name) { 2388 return '\n\nCheck the render method of `' + name + '`.'; 2389 } 2390 } 2391 return ''; 2392 } 2393 2394 function getSourceInfoErrorAddendum(elementProps) { 2395 if (elementProps !== null && elementProps !== undefined && elementProps.__source !== undefined) { 2396 var source = elementProps.__source; 2397 var fileName = source.fileName.replace(/^.*[\\\/]/, ''); 2398 var lineNumber = source.lineNumber; 2399 return '\n\nCheck your code at ' + fileName + ':' + lineNumber + '.'; 2400 } 2401 return ''; 2402 } 2403 2404 /** 2405 * Warn if there's no key explicitly set on dynamic arrays of children or 2406 * object keys are not valid. This allows us to keep track of children between 2407 * updates. 2408 */ 2409 var ownerHasKeyUseWarning = {}; 2410 2411 function getCurrentComponentErrorInfo(parentType) { 2412 var info = getDeclarationErrorAddendum(); 2413 2414 if (!info) { 2415 var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name; 2416 if (parentName) { 2417 info = '\n\nCheck the top-level render call using <' + parentName + '>.'; 2418 } 2419 } 2420 return info; 2421 } 2422 2423 /** 2424 * Warn if the element doesn't have an explicit key assigned to it. 2425 * This element is in an array. The array could grow and shrink or be 2426 * reordered. All children that haven't already been validated are required to 2427 * have a "key" property assigned to it. Error statuses are cached so a warning 2428 * will only be shown once. 2429 * 2430 * @internal 2431 * @param {ReactElement} element Element that requires a key. 2432 * @param {*} parentType element's parent's type. 2433 */ 2434 function validateExplicitKey(element, parentType) { 2435 if (!element._store || element._store.validated || element.key != null) { 2436 return; 2437 } 2438 element._store.validated = true; 2439 2440 var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType); 2441 if (ownerHasKeyUseWarning[currentComponentErrorInfo]) { 2442 return; 2443 } 2444 ownerHasKeyUseWarning[currentComponentErrorInfo] = true; 2445 2446 // Usually the current owner is the offender, but if it accepts children as a 2447 // property, it may be the creator of the child that's responsible for 2448 // assigning it a key. 2449 var childOwner = ''; 2450 if (element && element._owner && element._owner !== ReactCurrentOwner.current) { 2451 // Give the component that originally created this child. 2452 childOwner = ' It was passed a child from ' + getComponentName(element._owner.type) + '.'; 2453 } 2454 2455 setCurrentlyValidatingElement(element); 2456 { 2457 warning$1(false, 'Each child in an array or iterator should have a unique "key" prop.' + '%s%s See https://fb.me/react-warning-keys for more information.', currentComponentErrorInfo, childOwner); 2458 } 2459 setCurrentlyValidatingElement(null); 2460 } 2461 2462 /** 2463 * Ensure that every element either is passed in a static location, in an 2464 * array with an explicit keys property defined, or in an object literal 2465 * with valid key property. 2466 * 2467 * @internal 2468 * @param {ReactNode} node Statically passed child of any type. 2469 * @param {*} parentType node's parent's type. 2470 */ 2471 function validateChildKeys(node, parentType) { 2472 if (typeof node !== 'object') { 2473 return; 2474 } 2475 if (Array.isArray(node)) { 2476 for (var i = 0; i < node.length; i++) { 2477 var child = node[i]; 2478 if (isValidElement(child)) { 2479 validateExplicitKey(child, parentType); 2480 } 2481 } 2482 } else if (isValidElement(node)) { 2483 // This element was passed in a valid location. 2484 if (node._store) { 2485 node._store.validated = true; 2486 } 2487 } else if (node) { 2488 var iteratorFn = getIteratorFn(node); 2489 if (typeof iteratorFn === 'function') { 2490 // Entry iterators used to provide implicit keys, 2491 // but now we print a separate warning for them later. 2492 if (iteratorFn !== node.entries) { 2493 var iterator = iteratorFn.call(node); 2494 var step = void 0; 2495 while (!(step = iterator.next()).done) { 2496 if (isValidElement(step.value)) { 2497 validateExplicitKey(step.value, parentType); 2498 } 2499 } 2500 } 2501 } 2502 } 2503 } 2504 2505 /** 2506 * Given an element, validate that its props follow the propTypes definition, 2507 * provided by the type. 2508 * 2509 * @param {ReactElement} element 2510 */ 2511 function validatePropTypes(element) { 2512 var type = element.type; 2513 var name = void 0, 2514 propTypes = void 0; 2515 if (typeof type === 'function') { 2516 // Class or functional component 2517 name = type.displayName || type.name; 2518 propTypes = type.propTypes; 2519 } else if (typeof type === 'object' && type !== null && type.$$typeof === REACT_FORWARD_REF_TYPE) { 2520 // ForwardRef 2521 var functionName = type.render.displayName || type.render.name || ''; 2522 name = type.displayName || (functionName !== '' ? 'ForwardRef(' + functionName + ')' : 'ForwardRef'); 2523 propTypes = type.propTypes; 2524 } else { 2525 return; 2526 } 2527 if (propTypes) { 2528 setCurrentlyValidatingElement(element); 2529 checkPropTypes_1(propTypes, element.props, 'prop', name, ReactDebugCurrentFrame.getStackAddendum); 2530 setCurrentlyValidatingElement(null); 2531 } else if (type.PropTypes !== undefined && !propTypesMisspellWarningShown) { 2532 propTypesMisspellWarningShown = true; 2533 warningWithoutStack$1(false, 'Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?', name || 'Unknown'); 2534 } 2535 if (typeof type.getDefaultProps === 'function') { 2536 !type.getDefaultProps.isReactClassApproved ? warningWithoutStack$1(false, 'getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.') : void 0; 2537 } 2538 } 2539 2540 /** 2541 * Given a fragment, validate that it can only be provided with fragment props 2542 * @param {ReactElement} fragment 2543 */ 2544 function validateFragmentProps(fragment) { 2545 setCurrentlyValidatingElement(fragment); 2546 2547 var keys = Object.keys(fragment.props); 2548 for (var i = 0; i < keys.length; i++) { 2549 var key = keys[i]; 2550 if (key !== 'children' && key !== 'key') { 2551 warning$1(false, 'Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', key); 2552 break; 2553 } 2554 } 2555 2556 if (fragment.ref !== null) { 2557 warning$1(false, 'Invalid attribute `ref` supplied to `React.Fragment`.'); 2558 } 2559 2560 setCurrentlyValidatingElement(null); 2561 } 2562 2563 function createElementWithValidation(type, props, children) { 2564 var validType = isValidElementType(type); 2565 2566 // We warn in this case but don't throw. We expect the element creation to 2567 // succeed and there will likely be errors in render. 2568 if (!validType) { 2569 var info = ''; 2570 if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) { 2571 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."; 2572 } 2573 2574 var sourceInfo = getSourceInfoErrorAddendum(props); 2575 if (sourceInfo) { 2576 info += sourceInfo; 2577 } else { 2578 info += getDeclarationErrorAddendum(); 2579 } 2580 2581 var typeString = void 0; 2582 if (type === null) { 2583 typeString = 'null'; 2584 } else if (Array.isArray(type)) { 2585 typeString = 'array'; 2586 } else if (type !== undefined && type.$$typeof === REACT_ELEMENT_TYPE) { 2587 typeString = '<' + (getComponentName(type.type) || 'Unknown') + ' />'; 2588 info = ' Did you accidentally export a JSX literal instead of a component?'; 2589 } else { 2590 typeString = typeof type; 2591 } 2592 2593 warning$1(false, 'React.createElement: type is invalid -- expected a string (for ' + 'built-in components) or a class/function (for composite ' + 'components) but got: %s.%s', typeString, info); 2594 } 2595 2596 var element = createElement.apply(this, arguments); 2597 2598 // The result can be nullish if a mock or a custom function is used. 2599 // TODO: Drop this when these are no longer allowed as the type argument. 2600 if (element == null) { 2601 return element; 2602 } 2603 2604 // Skip key warning if the type isn't valid since our key validation logic 2605 // doesn't expect a non-string/function type and can throw confusing errors. 2606 // We don't want exception behavior to differ between dev and prod. 2607 // (Rendering will throw with a helpful message and as soon as the type is 2608 // fixed, the key warnings will appear.) 2609 if (validType) { 2610 for (var i = 2; i < arguments.length; i++) { 2611 validateChildKeys(arguments[i], type); 2612 } 2613 } 2614 2615 if (type === REACT_FRAGMENT_TYPE) { 2616 validateFragmentProps(element); 2617 } else { 2618 validatePropTypes(element); 2619 } 2620 2621 return element; 2622 } 2623 2624 function createFactoryWithValidation(type) { 2625 var validatedFactory = createElementWithValidation.bind(null, type); 2626 validatedFactory.type = type; 2627 // Legacy hook: remove it 2628 { 2629 Object.defineProperty(validatedFactory, 'type', { 2630 enumerable: false, 2631 get: function () { 2632 lowPriorityWarning$1(false, 'Factory.type is deprecated. Access the class directly ' + 'before passing it to createFactory.'); 2633 Object.defineProperty(this, 'type', { 2634 value: type 2635 }); 2636 return type; 2637 } 2638 }); 2639 } 2640 2641 return validatedFactory; 2642 } 2643 2644 function cloneElementWithValidation(element, props, children) { 2645 var newElement = cloneElement.apply(this, arguments); 2646 for (var i = 2; i < arguments.length; i++) { 2647 validateChildKeys(arguments[i], newElement.type); 2648 } 2649 validatePropTypes(newElement); 2650 return newElement; 2651 } 2652 2653 var React = { 2654 Children: { 2655 map: mapChildren, 2656 forEach: forEachChildren, 2657 count: countChildren, 2658 toArray: toArray, 2659 only: onlyChild 2660 }, 2661 2662 createRef: createRef, 2663 Component: Component, 2664 PureComponent: PureComponent, 2665 2666 createContext: createContext, 2667 forwardRef: forwardRef, 2668 2669 Fragment: REACT_FRAGMENT_TYPE, 2670 StrictMode: REACT_STRICT_MODE_TYPE, 2671 unstable_AsyncMode: REACT_ASYNC_MODE_TYPE, 2672 unstable_Profiler: REACT_PROFILER_TYPE, 2673 2674 createElement: createElementWithValidation, 2675 cloneElement: cloneElementWithValidation, 2676 createFactory: createFactoryWithValidation, 2677 isValidElement: isValidElement, 2678 2679 version: ReactVersion, 2680 2681 __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: ReactSharedInternals 2682 }; 2683 2684 if (enableSuspense) { 2685 React.Placeholder = REACT_PLACEHOLDER_TYPE; 2686 React.lazy = lazy; 2687 } 2688 2689 2690 2691 var React$2 = Object.freeze({ 2692 default: React 2693 }); 2694 2695 var React$3 = ( React$2 && React ) || React$2; 2696 2697 // TODO: decide on the top-level export form. 2698 // This is hacky but makes it work with both Rollup and Jest. 2699 var react = React$3.default || React$3; 2700 2701 return react; 2702 2703 })));
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Mon Jan 7 01:00:05 2019 | Cross-referenced by PHPXref 0.7.1 |