[ Index ] |
PHP Cross Reference of WordPress |
[Summary view] [Print] [Text view]
1 /** @license React v17.0.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 (function (global, factory) { 10 typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : 11 typeof define === 'function' && define.amd ? define(['exports'], factory) : 12 (global = global || self, factory(global.React = {})); 13 }(this, (function (exports) { 'use strict'; 14 15 // TODO: this is special because it gets imported during build. 16 var ReactVersion = '17.0.2'; 17 18 // ATTENTION 19 // When adding new symbols to this file, 20 // Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols' 21 // The Symbol used to tag the ReactElement-like types. If there is no native Symbol 22 // nor polyfill, then a plain number is used for performance. 23 var REACT_ELEMENT_TYPE = 0xeac7; 24 var REACT_PORTAL_TYPE = 0xeaca; 25 exports.Fragment = 0xeacb; 26 exports.StrictMode = 0xeacc; 27 exports.Profiler = 0xead2; 28 var REACT_PROVIDER_TYPE = 0xeacd; 29 var REACT_CONTEXT_TYPE = 0xeace; 30 var REACT_FORWARD_REF_TYPE = 0xead0; 31 exports.Suspense = 0xead1; 32 var REACT_SUSPENSE_LIST_TYPE = 0xead8; 33 var REACT_MEMO_TYPE = 0xead3; 34 var REACT_LAZY_TYPE = 0xead4; 35 var REACT_BLOCK_TYPE = 0xead9; 36 var REACT_SERVER_BLOCK_TYPE = 0xeada; 37 var REACT_FUNDAMENTAL_TYPE = 0xead5; 38 var REACT_SCOPE_TYPE = 0xead7; 39 var REACT_OPAQUE_ID_TYPE = 0xeae0; 40 var REACT_DEBUG_TRACING_MODE_TYPE = 0xeae1; 41 var REACT_OFFSCREEN_TYPE = 0xeae2; 42 var REACT_LEGACY_HIDDEN_TYPE = 0xeae3; 43 44 if (typeof Symbol === 'function' && Symbol.for) { 45 var symbolFor = Symbol.for; 46 REACT_ELEMENT_TYPE = symbolFor('react.element'); 47 REACT_PORTAL_TYPE = symbolFor('react.portal'); 48 exports.Fragment = symbolFor('react.fragment'); 49 exports.StrictMode = symbolFor('react.strict_mode'); 50 exports.Profiler = symbolFor('react.profiler'); 51 REACT_PROVIDER_TYPE = symbolFor('react.provider'); 52 REACT_CONTEXT_TYPE = symbolFor('react.context'); 53 REACT_FORWARD_REF_TYPE = symbolFor('react.forward_ref'); 54 exports.Suspense = symbolFor('react.suspense'); 55 REACT_SUSPENSE_LIST_TYPE = symbolFor('react.suspense_list'); 56 REACT_MEMO_TYPE = symbolFor('react.memo'); 57 REACT_LAZY_TYPE = symbolFor('react.lazy'); 58 REACT_BLOCK_TYPE = symbolFor('react.block'); 59 REACT_SERVER_BLOCK_TYPE = symbolFor('react.server.block'); 60 REACT_FUNDAMENTAL_TYPE = symbolFor('react.fundamental'); 61 REACT_SCOPE_TYPE = symbolFor('react.scope'); 62 REACT_OPAQUE_ID_TYPE = symbolFor('react.opaque.id'); 63 REACT_DEBUG_TRACING_MODE_TYPE = symbolFor('react.debug_trace_mode'); 64 REACT_OFFSCREEN_TYPE = symbolFor('react.offscreen'); 65 REACT_LEGACY_HIDDEN_TYPE = symbolFor('react.legacy_hidden'); 66 } 67 68 var MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator; 69 var FAUX_ITERATOR_SYMBOL = '@@iterator'; 70 function getIteratorFn(maybeIterable) { 71 if (maybeIterable === null || typeof maybeIterable !== 'object') { 72 return null; 73 } 74 75 var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]; 76 77 if (typeof maybeIterator === 'function') { 78 return maybeIterator; 79 } 80 81 return null; 82 } 83 84 var hasOwnProperty = Object.prototype.hasOwnProperty; 85 86 var _assign = function (to, from) { 87 for (var key in from) { 88 if (hasOwnProperty.call(from, key)) { 89 to[key] = from[key]; 90 } 91 } 92 }; 93 94 var assign = Object.assign || function (target, sources) { 95 if (target == null) { 96 throw new TypeError('Object.assign target cannot be null or undefined'); 97 } 98 99 var to = Object(target); 100 101 for (var nextIndex = 1; nextIndex < arguments.length; nextIndex++) { 102 var nextSource = arguments[nextIndex]; 103 104 if (nextSource != null) { 105 _assign(to, Object(nextSource)); 106 } 107 } 108 109 return to; 110 }; 111 112 /** 113 * Keeps track of the current dispatcher. 114 */ 115 var ReactCurrentDispatcher = { 116 /** 117 * @internal 118 * @type {ReactComponent} 119 */ 120 current: null 121 }; 122 123 /** 124 * Keeps track of the current batch's configuration such as how long an update 125 * should suspend for if it needs to. 126 */ 127 var ReactCurrentBatchConfig = { 128 transition: 0 129 }; 130 131 /** 132 * Keeps track of the current owner. 133 * 134 * The current owner is the component who should own any components that are 135 * currently being constructed. 136 */ 137 var ReactCurrentOwner = { 138 /** 139 * @internal 140 * @type {ReactComponent} 141 */ 142 current: null 143 }; 144 145 var ReactDebugCurrentFrame = {}; 146 var currentExtraStackFrame = null; 147 function setExtraStackFrame(stack) { 148 { 149 currentExtraStackFrame = stack; 150 } 151 } 152 153 { 154 ReactDebugCurrentFrame.setExtraStackFrame = function (stack) { 155 { 156 currentExtraStackFrame = stack; 157 } 158 }; // Stack implementation injected by the current renderer. 159 160 161 ReactDebugCurrentFrame.getCurrentStack = null; 162 163 ReactDebugCurrentFrame.getStackAddendum = function () { 164 var stack = ''; // Add an extra top frame while an element is being validated 165 166 if (currentExtraStackFrame) { 167 stack += currentExtraStackFrame; 168 } // Delegate to the injected renderer-specific implementation 169 170 171 var impl = ReactDebugCurrentFrame.getCurrentStack; 172 173 if (impl) { 174 stack += impl() || ''; 175 } 176 177 return stack; 178 }; 179 } 180 181 /** 182 * Used by act() to track whether you're inside an act() scope. 183 */ 184 var IsSomeRendererActing = { 185 current: false 186 }; 187 188 var ReactSharedInternals = { 189 ReactCurrentDispatcher: ReactCurrentDispatcher, 190 ReactCurrentBatchConfig: ReactCurrentBatchConfig, 191 ReactCurrentOwner: ReactCurrentOwner, 192 IsSomeRendererActing: IsSomeRendererActing, 193 // Used by renderers to avoid bundling object-assign twice in UMD bundles: 194 assign: assign 195 }; 196 197 { 198 ReactSharedInternals.ReactDebugCurrentFrame = ReactDebugCurrentFrame; 199 } 200 201 // by calls to these methods by a Babel plugin. 202 // 203 // In PROD (or in packages without access to React internals), 204 // they are left as they are instead. 205 206 function warn(format) { 207 { 208 for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { 209 args[_key - 1] = arguments[_key]; 210 } 211 212 printWarning('warn', format, args); 213 } 214 } 215 function error(format) { 216 { 217 for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { 218 args[_key2 - 1] = arguments[_key2]; 219 } 220 221 printWarning('error', format, args); 222 } 223 } 224 225 function printWarning(level, format, args) { 226 // When changing this logic, you might want to also 227 // update consoleWithStackDev.www.js as well. 228 { 229 var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; 230 var stack = ReactDebugCurrentFrame.getStackAddendum(); 231 232 if (stack !== '') { 233 format += '%s'; 234 args = args.concat([stack]); 235 } 236 237 var argsWithFormat = args.map(function (item) { 238 return '' + item; 239 }); // Careful: RN currently depends on this prefix 240 241 argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it 242 // breaks IE9: https://github.com/facebook/react/issues/13610 243 // eslint-disable-next-line react-internal/no-production-logging 244 245 Function.prototype.apply.call(console[level], console, argsWithFormat); 246 } 247 } 248 249 var didWarnStateUpdateForUnmountedComponent = {}; 250 251 function warnNoop(publicInstance, callerName) { 252 { 253 var _constructor = publicInstance.constructor; 254 var componentName = _constructor && (_constructor.displayName || _constructor.name) || 'ReactClass'; 255 var warningKey = componentName + "." + callerName; 256 257 if (didWarnStateUpdateForUnmountedComponent[warningKey]) { 258 return; 259 } 260 261 error("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); 262 263 didWarnStateUpdateForUnmountedComponent[warningKey] = true; 264 } 265 } 266 /** 267 * This is the abstract API for an update queue. 268 */ 269 270 271 var ReactNoopUpdateQueue = { 272 /** 273 * Checks whether or not this composite component is mounted. 274 * @param {ReactClass} publicInstance The instance we want to test. 275 * @return {boolean} True if mounted, false otherwise. 276 * @protected 277 * @final 278 */ 279 isMounted: function (publicInstance) { 280 return false; 281 }, 282 283 /** 284 * Forces an update. This should only be invoked when it is known with 285 * certainty that we are **not** in a DOM transaction. 286 * 287 * You may want to call this when you know that some deeper aspect of the 288 * component's state has changed but `setState` was not called. 289 * 290 * This will not invoke `shouldComponentUpdate`, but it will invoke 291 * `componentWillUpdate` and `componentDidUpdate`. 292 * 293 * @param {ReactClass} publicInstance The instance that should rerender. 294 * @param {?function} callback Called after component is updated. 295 * @param {?string} callerName name of the calling function in the public API. 296 * @internal 297 */ 298 enqueueForceUpdate: function (publicInstance, callback, callerName) { 299 warnNoop(publicInstance, 'forceUpdate'); 300 }, 301 302 /** 303 * Replaces all of the state. Always use this or `setState` to mutate state. 304 * You should treat `this.state` as immutable. 305 * 306 * There is no guarantee that `this.state` will be immediately updated, so 307 * accessing `this.state` after calling this method may return the old value. 308 * 309 * @param {ReactClass} publicInstance The instance that should rerender. 310 * @param {object} completeState Next state. 311 * @param {?function} callback Called after component is updated. 312 * @param {?string} callerName name of the calling function in the public API. 313 * @internal 314 */ 315 enqueueReplaceState: function (publicInstance, completeState, callback, callerName) { 316 warnNoop(publicInstance, 'replaceState'); 317 }, 318 319 /** 320 * Sets a subset of the state. This only exists because _pendingState is 321 * internal. This provides a merging strategy that is not available to deep 322 * properties which is confusing. TODO: Expose pendingState or don't use it 323 * during the merge. 324 * 325 * @param {ReactClass} publicInstance The instance that should rerender. 326 * @param {object} partialState Next partial state to be merged with state. 327 * @param {?function} callback Called after component is updated. 328 * @param {?string} Name of the calling function in the public API. 329 * @internal 330 */ 331 enqueueSetState: function (publicInstance, partialState, callback, callerName) { 332 warnNoop(publicInstance, 'setState'); 333 } 334 }; 335 336 var emptyObject = {}; 337 338 { 339 Object.freeze(emptyObject); 340 } 341 /** 342 * Base class helpers for the updating state of a component. 343 */ 344 345 346 function Component(props, context, updater) { 347 this.props = props; 348 this.context = context; // If a component has string refs, we will assign a different object later. 349 350 this.refs = emptyObject; // We initialize the default updater but the real one gets injected by the 351 // renderer. 352 353 this.updater = updater || ReactNoopUpdateQueue; 354 } 355 356 Component.prototype.isReactComponent = {}; 357 /** 358 * Sets a subset of the state. Always use this to mutate 359 * state. You should treat `this.state` as immutable. 360 * 361 * There is no guarantee that `this.state` will be immediately updated, so 362 * accessing `this.state` after calling this method may return the old value. 363 * 364 * There is no guarantee that calls to `setState` will run synchronously, 365 * as they may eventually be batched together. You can provide an optional 366 * callback that will be executed when the call to setState is actually 367 * completed. 368 * 369 * When a function is provided to setState, it will be called at some point in 370 * the future (not synchronously). It will be called with the up to date 371 * component arguments (state, props, context). These values can be different 372 * from this.* because your function may be called after receiveProps but before 373 * shouldComponentUpdate, and this new state, props, and context will not yet be 374 * assigned to this. 375 * 376 * @param {object|function} partialState Next partial state or function to 377 * produce next partial state to be merged with current state. 378 * @param {?function} callback Called after state is updated. 379 * @final 380 * @protected 381 */ 382 383 Component.prototype.setState = function (partialState, callback) { 384 if (!(typeof partialState === 'object' || typeof partialState === 'function' || partialState == null)) { 385 { 386 throw Error( "setState(...): takes an object of state variables to update or a function which returns an object of state variables." ); 387 } 388 } 389 390 this.updater.enqueueSetState(this, partialState, callback, 'setState'); 391 }; 392 /** 393 * Forces an update. This should only be invoked when it is known with 394 * certainty that we are **not** in a DOM transaction. 395 * 396 * You may want to call this when you know that some deeper aspect of the 397 * component's state has changed but `setState` was not called. 398 * 399 * This will not invoke `shouldComponentUpdate`, but it will invoke 400 * `componentWillUpdate` and `componentDidUpdate`. 401 * 402 * @param {?function} callback Called after update is complete. 403 * @final 404 * @protected 405 */ 406 407 408 Component.prototype.forceUpdate = function (callback) { 409 this.updater.enqueueForceUpdate(this, callback, 'forceUpdate'); 410 }; 411 /** 412 * Deprecated APIs. These APIs used to exist on classic React classes but since 413 * we would like to deprecate them, we're not going to move them over to this 414 * modern base class. Instead, we define a getter that warns if it's accessed. 415 */ 416 417 418 { 419 var deprecatedAPIs = { 420 isMounted: ['isMounted', 'Instead, make sure to clean up subscriptions and pending requests in ' + 'componentWillUnmount to prevent memory leaks.'], 421 replaceState: ['replaceState', 'Refactor your code to use setState instead (see ' + 'https://github.com/facebook/react/issues/3236).'] 422 }; 423 424 var defineDeprecationWarning = function (methodName, info) { 425 Object.defineProperty(Component.prototype, methodName, { 426 get: function () { 427 warn('%s(...) is deprecated in plain JavaScript React classes. %s', info[0], info[1]); 428 429 return undefined; 430 } 431 }); 432 }; 433 434 for (var fnName in deprecatedAPIs) { 435 if (deprecatedAPIs.hasOwnProperty(fnName)) { 436 defineDeprecationWarning(fnName, deprecatedAPIs[fnName]); 437 } 438 } 439 } 440 441 function ComponentDummy() {} 442 443 ComponentDummy.prototype = Component.prototype; 444 /** 445 * Convenience component with default shallow equality check for sCU. 446 */ 447 448 function PureComponent(props, context, updater) { 449 this.props = props; 450 this.context = context; // If a component has string refs, we will assign a different object later. 451 452 this.refs = emptyObject; 453 this.updater = updater || ReactNoopUpdateQueue; 454 } 455 456 var pureComponentPrototype = PureComponent.prototype = new ComponentDummy(); 457 pureComponentPrototype.constructor = PureComponent; // Avoid an extra prototype jump for these methods. 458 459 assign(pureComponentPrototype, Component.prototype); 460 461 pureComponentPrototype.isPureReactComponent = true; 462 463 // an immutable object with a single mutable value 464 function createRef() { 465 var refObject = { 466 current: null 467 }; 468 469 { 470 Object.seal(refObject); 471 } 472 473 return refObject; 474 } 475 476 function getWrappedName(outerType, innerType, wrapperName) { 477 var functionName = innerType.displayName || innerType.name || ''; 478 return outerType.displayName || (functionName !== '' ? wrapperName + "(" + functionName + ")" : wrapperName); 479 } 480 481 function getContextName(type) { 482 return type.displayName || 'Context'; 483 } 484 485 function getComponentName(type) { 486 if (type == null) { 487 // Host root, text node or just invalid type. 488 return null; 489 } 490 491 { 492 if (typeof type.tag === 'number') { 493 error('Received an unexpected object in getComponentName(). ' + 'This is likely a bug in React. Please file an issue.'); 494 } 495 } 496 497 if (typeof type === 'function') { 498 return type.displayName || type.name || null; 499 } 500 501 if (typeof type === 'string') { 502 return type; 503 } 504 505 switch (type) { 506 case exports.Fragment: 507 return 'Fragment'; 508 509 case REACT_PORTAL_TYPE: 510 return 'Portal'; 511 512 case exports.Profiler: 513 return 'Profiler'; 514 515 case exports.StrictMode: 516 return 'StrictMode'; 517 518 case exports.Suspense: 519 return 'Suspense'; 520 521 case REACT_SUSPENSE_LIST_TYPE: 522 return 'SuspenseList'; 523 } 524 525 if (typeof type === 'object') { 526 switch (type.$$typeof) { 527 case REACT_CONTEXT_TYPE: 528 var context = type; 529 return getContextName(context) + '.Consumer'; 530 531 case REACT_PROVIDER_TYPE: 532 var provider = type; 533 return getContextName(provider._context) + '.Provider'; 534 535 case REACT_FORWARD_REF_TYPE: 536 return getWrappedName(type, type.render, 'ForwardRef'); 537 538 case REACT_MEMO_TYPE: 539 return getComponentName(type.type); 540 541 case REACT_BLOCK_TYPE: 542 return getComponentName(type._render); 543 544 case REACT_LAZY_TYPE: 545 { 546 var lazyComponent = type; 547 var payload = lazyComponent._payload; 548 var init = lazyComponent._init; 549 550 try { 551 return getComponentName(init(payload)); 552 } catch (x) { 553 return null; 554 } 555 } 556 } 557 } 558 559 return null; 560 } 561 562 var hasOwnProperty$1 = Object.prototype.hasOwnProperty; 563 var RESERVED_PROPS = { 564 key: true, 565 ref: true, 566 __self: true, 567 __source: true 568 }; 569 var specialPropKeyWarningShown, specialPropRefWarningShown, didWarnAboutStringRefs; 570 571 { 572 didWarnAboutStringRefs = {}; 573 } 574 575 function hasValidRef(config) { 576 { 577 if (hasOwnProperty$1.call(config, 'ref')) { 578 var getter = Object.getOwnPropertyDescriptor(config, 'ref').get; 579 580 if (getter && getter.isReactWarning) { 581 return false; 582 } 583 } 584 } 585 586 return config.ref !== undefined; 587 } 588 589 function hasValidKey(config) { 590 { 591 if (hasOwnProperty$1.call(config, 'key')) { 592 var getter = Object.getOwnPropertyDescriptor(config, 'key').get; 593 594 if (getter && getter.isReactWarning) { 595 return false; 596 } 597 } 598 } 599 600 return config.key !== undefined; 601 } 602 603 function defineKeyPropWarningGetter(props, displayName) { 604 var warnAboutAccessingKey = function () { 605 { 606 if (!specialPropKeyWarningShown) { 607 specialPropKeyWarningShown = true; 608 609 error('%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://reactjs.org/link/special-props)', displayName); 610 } 611 } 612 }; 613 614 warnAboutAccessingKey.isReactWarning = true; 615 Object.defineProperty(props, 'key', { 616 get: warnAboutAccessingKey, 617 configurable: true 618 }); 619 } 620 621 function defineRefPropWarningGetter(props, displayName) { 622 var warnAboutAccessingRef = function () { 623 { 624 if (!specialPropRefWarningShown) { 625 specialPropRefWarningShown = true; 626 627 error('%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://reactjs.org/link/special-props)', displayName); 628 } 629 } 630 }; 631 632 warnAboutAccessingRef.isReactWarning = true; 633 Object.defineProperty(props, 'ref', { 634 get: warnAboutAccessingRef, 635 configurable: true 636 }); 637 } 638 639 function warnIfStringRefCannotBeAutoConverted(config) { 640 { 641 if (typeof config.ref === 'string' && ReactCurrentOwner.current && config.__self && ReactCurrentOwner.current.stateNode !== config.__self) { 642 var componentName = getComponentName(ReactCurrentOwner.current.type); 643 644 if (!didWarnAboutStringRefs[componentName]) { 645 error('Component "%s" contains the string ref "%s". ' + 'Support for string refs will be removed in a future major release. ' + 'This case cannot be automatically converted to an arrow function. ' + 'We ask you to manually fix this case by using useRef() or createRef() instead. ' + 'Learn more about using refs safely here: ' + 'https://reactjs.org/link/strict-mode-string-ref', componentName, config.ref); 646 647 didWarnAboutStringRefs[componentName] = true; 648 } 649 } 650 } 651 } 652 /** 653 * Factory method to create a new React element. This no longer adheres to 654 * the class pattern, so do not use new to call it. Also, instanceof check 655 * will not work. Instead test $$typeof field against Symbol.for('react.element') to check 656 * if something is a React Element. 657 * 658 * @param {*} type 659 * @param {*} props 660 * @param {*} key 661 * @param {string|object} ref 662 * @param {*} owner 663 * @param {*} self A *temporary* helper to detect places where `this` is 664 * different from the `owner` when React.createElement is called, so that we 665 * can warn. We want to get rid of owner and replace string `ref`s with arrow 666 * functions, and as long as `this` and owner are the same, there will be no 667 * change in behavior. 668 * @param {*} source An annotation object (added by a transpiler or otherwise) 669 * indicating filename, line number, and/or other information. 670 * @internal 671 */ 672 673 674 var ReactElement = function (type, key, ref, self, source, owner, props) { 675 var element = { 676 // This tag allows us to uniquely identify this as a React Element 677 $$typeof: REACT_ELEMENT_TYPE, 678 // Built-in properties that belong on the element 679 type: type, 680 key: key, 681 ref: ref, 682 props: props, 683 // Record the component responsible for creating this element. 684 _owner: owner 685 }; 686 687 { 688 // The validation flag is currently mutative. We put it on 689 // an external backing store so that we can freeze the whole object. 690 // This can be replaced with a WeakMap once they are implemented in 691 // commonly used development environments. 692 element._store = {}; // To make comparing ReactElements easier for testing purposes, we make 693 // the validation flag non-enumerable (where possible, which should 694 // include every environment we run tests in), so the test framework 695 // ignores it. 696 697 Object.defineProperty(element._store, 'validated', { 698 configurable: false, 699 enumerable: false, 700 writable: true, 701 value: false 702 }); // self and source are DEV only properties. 703 704 Object.defineProperty(element, '_self', { 705 configurable: false, 706 enumerable: false, 707 writable: false, 708 value: self 709 }); // Two elements created in two different places should be considered 710 // equal for testing purposes and therefore we hide it from enumeration. 711 712 Object.defineProperty(element, '_source', { 713 configurable: false, 714 enumerable: false, 715 writable: false, 716 value: source 717 }); 718 719 if (Object.freeze) { 720 Object.freeze(element.props); 721 Object.freeze(element); 722 } 723 } 724 725 return element; 726 }; 727 /** 728 * Create and return a new ReactElement of the given type. 729 * See https://reactjs.org/docs/react-api.html#createelement 730 */ 731 732 function createElement(type, config, children) { 733 var propName; // Reserved names are extracted 734 735 var props = {}; 736 var key = null; 737 var ref = null; 738 var self = null; 739 var source = null; 740 741 if (config != null) { 742 if (hasValidRef(config)) { 743 ref = config.ref; 744 745 { 746 warnIfStringRefCannotBeAutoConverted(config); 747 } 748 } 749 750 if (hasValidKey(config)) { 751 key = '' + config.key; 752 } 753 754 self = config.__self === undefined ? null : config.__self; 755 source = config.__source === undefined ? null : config.__source; // Remaining properties are added to a new props object 756 757 for (propName in config) { 758 if (hasOwnProperty$1.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) { 759 props[propName] = config[propName]; 760 } 761 } 762 } // Children can be more than one argument, and those are transferred onto 763 // the newly allocated props object. 764 765 766 var childrenLength = arguments.length - 2; 767 768 if (childrenLength === 1) { 769 props.children = children; 770 } else if (childrenLength > 1) { 771 var childArray = Array(childrenLength); 772 773 for (var i = 0; i < childrenLength; i++) { 774 childArray[i] = arguments[i + 2]; 775 } 776 777 { 778 if (Object.freeze) { 779 Object.freeze(childArray); 780 } 781 } 782 783 props.children = childArray; 784 } // Resolve default props 785 786 787 if (type && type.defaultProps) { 788 var defaultProps = type.defaultProps; 789 790 for (propName in defaultProps) { 791 if (props[propName] === undefined) { 792 props[propName] = defaultProps[propName]; 793 } 794 } 795 } 796 797 { 798 if (key || ref) { 799 var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type; 800 801 if (key) { 802 defineKeyPropWarningGetter(props, displayName); 803 } 804 805 if (ref) { 806 defineRefPropWarningGetter(props, displayName); 807 } 808 } 809 } 810 811 return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props); 812 } 813 function cloneAndReplaceKey(oldElement, newKey) { 814 var newElement = ReactElement(oldElement.type, newKey, oldElement.ref, oldElement._self, oldElement._source, oldElement._owner, oldElement.props); 815 return newElement; 816 } 817 /** 818 * Clone and return a new ReactElement using element as the starting point. 819 * See https://reactjs.org/docs/react-api.html#cloneelement 820 */ 821 822 function cloneElement(element, config, children) { 823 if (!!(element === null || element === undefined)) { 824 { 825 throw Error( "React.cloneElement(...): The argument must be a React element, but you passed " + element + "." ); 826 } 827 } 828 829 var propName; // Original props are copied 830 831 var props = assign({}, element.props); // Reserved names are extracted 832 833 834 var key = element.key; 835 var ref = element.ref; // Self is preserved since the owner is preserved. 836 837 var self = element._self; // Source is preserved since cloneElement is unlikely to be targeted by a 838 // transpiler, and the original source is probably a better indicator of the 839 // true owner. 840 841 var source = element._source; // Owner will be preserved, unless ref is overridden 842 843 var owner = element._owner; 844 845 if (config != null) { 846 if (hasValidRef(config)) { 847 // Silently steal the ref from the parent. 848 ref = config.ref; 849 owner = ReactCurrentOwner.current; 850 } 851 852 if (hasValidKey(config)) { 853 key = '' + config.key; 854 } // Remaining properties override existing props 855 856 857 var defaultProps; 858 859 if (element.type && element.type.defaultProps) { 860 defaultProps = element.type.defaultProps; 861 } 862 863 for (propName in config) { 864 if (hasOwnProperty$1.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) { 865 if (config[propName] === undefined && defaultProps !== undefined) { 866 // Resolve default props 867 props[propName] = defaultProps[propName]; 868 } else { 869 props[propName] = config[propName]; 870 } 871 } 872 } 873 } // Children can be more than one argument, and those are transferred onto 874 // the newly allocated props object. 875 876 877 var childrenLength = arguments.length - 2; 878 879 if (childrenLength === 1) { 880 props.children = children; 881 } else if (childrenLength > 1) { 882 var childArray = Array(childrenLength); 883 884 for (var i = 0; i < childrenLength; i++) { 885 childArray[i] = arguments[i + 2]; 886 } 887 888 props.children = childArray; 889 } 890 891 return ReactElement(element.type, key, ref, self, source, owner, props); 892 } 893 /** 894 * Verifies the object is a ReactElement. 895 * See https://reactjs.org/docs/react-api.html#isvalidelement 896 * @param {?object} object 897 * @return {boolean} True if `object` is a ReactElement. 898 * @final 899 */ 900 901 function isValidElement(object) { 902 return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE; 903 } 904 905 var SEPARATOR = '.'; 906 var SUBSEPARATOR = ':'; 907 /** 908 * Escape and wrap key so it is safe to use as a reactid 909 * 910 * @param {string} key to be escaped. 911 * @return {string} the escaped key. 912 */ 913 914 function escape(key) { 915 var escapeRegex = /[=:]/g; 916 var escaperLookup = { 917 '=': '=0', 918 ':': '=2' 919 }; 920 var escapedString = key.replace(escapeRegex, function (match) { 921 return escaperLookup[match]; 922 }); 923 return '$' + escapedString; 924 } 925 /** 926 * TODO: Test that a single child and an array with one item have the same key 927 * pattern. 928 */ 929 930 931 var didWarnAboutMaps = false; 932 var userProvidedKeyEscapeRegex = /\/+/g; 933 934 function escapeUserProvidedKey(text) { 935 return text.replace(userProvidedKeyEscapeRegex, '$&/'); 936 } 937 /** 938 * Generate a key string that identifies a element within a set. 939 * 940 * @param {*} element A element that could contain a manual key. 941 * @param {number} index Index that is used if a manual key is not provided. 942 * @return {string} 943 */ 944 945 946 function getElementKey(element, index) { 947 // Do some typechecking here since we call this blindly. We want to ensure 948 // that we don't block potential future ES APIs. 949 if (typeof element === 'object' && element !== null && element.key != null) { 950 // Explicit key 951 return escape('' + element.key); 952 } // Implicit key determined by the index in the set 953 954 955 return index.toString(36); 956 } 957 958 function mapIntoArray(children, array, escapedPrefix, nameSoFar, callback) { 959 var type = typeof children; 960 961 if (type === 'undefined' || type === 'boolean') { 962 // All of the above are perceived as null. 963 children = null; 964 } 965 966 var invokeCallback = false; 967 968 if (children === null) { 969 invokeCallback = true; 970 } else { 971 switch (type) { 972 case 'string': 973 case 'number': 974 invokeCallback = true; 975 break; 976 977 case 'object': 978 switch (children.$$typeof) { 979 case REACT_ELEMENT_TYPE: 980 case REACT_PORTAL_TYPE: 981 invokeCallback = true; 982 } 983 984 } 985 } 986 987 if (invokeCallback) { 988 var _child = children; 989 var mappedChild = callback(_child); // If it's the only child, treat the name as if it was wrapped in an array 990 // so that it's consistent if the number of children grows: 991 992 var childKey = nameSoFar === '' ? SEPARATOR + getElementKey(_child, 0) : nameSoFar; 993 994 if (Array.isArray(mappedChild)) { 995 var escapedChildKey = ''; 996 997 if (childKey != null) { 998 escapedChildKey = escapeUserProvidedKey(childKey) + '/'; 999 } 1000 1001 mapIntoArray(mappedChild, array, escapedChildKey, '', function (c) { 1002 return c; 1003 }); 1004 } else if (mappedChild != null) { 1005 if (isValidElement(mappedChild)) { 1006 mappedChild = cloneAndReplaceKey(mappedChild, // Keep both the (mapped) and old keys if they differ, just as 1007 // traverseAllChildren used to do for objects as children 1008 escapedPrefix + ( // $FlowFixMe Flow incorrectly thinks React.Portal doesn't have a key 1009 mappedChild.key && (!_child || _child.key !== mappedChild.key) ? // $FlowFixMe Flow incorrectly thinks existing element's key can be a number 1010 escapeUserProvidedKey('' + mappedChild.key) + '/' : '') + childKey); 1011 } 1012 1013 array.push(mappedChild); 1014 } 1015 1016 return 1; 1017 } 1018 1019 var child; 1020 var nextName; 1021 var subtreeCount = 0; // Count of children found in the current subtree. 1022 1023 var nextNamePrefix = nameSoFar === '' ? SEPARATOR : nameSoFar + SUBSEPARATOR; 1024 1025 if (Array.isArray(children)) { 1026 for (var i = 0; i < children.length; i++) { 1027 child = children[i]; 1028 nextName = nextNamePrefix + getElementKey(child, i); 1029 subtreeCount += mapIntoArray(child, array, escapedPrefix, nextName, callback); 1030 } 1031 } else { 1032 var iteratorFn = getIteratorFn(children); 1033 1034 if (typeof iteratorFn === 'function') { 1035 var iterableChildren = children; 1036 1037 { 1038 // Warn about using Maps as children 1039 if (iteratorFn === iterableChildren.entries) { 1040 if (!didWarnAboutMaps) { 1041 warn('Using Maps as children is not supported. ' + 'Use an array of keyed ReactElements instead.'); 1042 } 1043 1044 didWarnAboutMaps = true; 1045 } 1046 } 1047 1048 var iterator = iteratorFn.call(iterableChildren); 1049 var step; 1050 var ii = 0; 1051 1052 while (!(step = iterator.next()).done) { 1053 child = step.value; 1054 nextName = nextNamePrefix + getElementKey(child, ii++); 1055 subtreeCount += mapIntoArray(child, array, escapedPrefix, nextName, callback); 1056 } 1057 } else if (type === 'object') { 1058 var childrenString = '' + children; 1059 1060 { 1061 { 1062 throw Error( "Objects are not valid as a React child (found: " + (childrenString === '[object Object]' ? 'object with keys {' + Object.keys(children).join(', ') + '}' : childrenString) + "). If you meant to render a collection of children, use an array instead." ); 1063 } 1064 } 1065 } 1066 } 1067 1068 return subtreeCount; 1069 } 1070 1071 /** 1072 * Maps children that are typically specified as `props.children`. 1073 * 1074 * See https://reactjs.org/docs/react-api.html#reactchildrenmap 1075 * 1076 * The provided mapFunction(child, index) will be called for each 1077 * leaf child. 1078 * 1079 * @param {?*} children Children tree container. 1080 * @param {function(*, int)} func The map function. 1081 * @param {*} context Context for mapFunction. 1082 * @return {object} Object containing the ordered map of results. 1083 */ 1084 function mapChildren(children, func, context) { 1085 if (children == null) { 1086 return children; 1087 } 1088 1089 var result = []; 1090 var count = 0; 1091 mapIntoArray(children, result, '', '', function (child) { 1092 return func.call(context, child, count++); 1093 }); 1094 return result; 1095 } 1096 /** 1097 * Count the number of children that are typically specified as 1098 * `props.children`. 1099 * 1100 * See https://reactjs.org/docs/react-api.html#reactchildrencount 1101 * 1102 * @param {?*} children Children tree container. 1103 * @return {number} The number of children. 1104 */ 1105 1106 1107 function countChildren(children) { 1108 var n = 0; 1109 mapChildren(children, function () { 1110 n++; // Don't return anything 1111 }); 1112 return n; 1113 } 1114 1115 /** 1116 * Iterates through children that are typically specified as `props.children`. 1117 * 1118 * See https://reactjs.org/docs/react-api.html#reactchildrenforeach 1119 * 1120 * The provided forEachFunc(child, index) will be called for each 1121 * leaf child. 1122 * 1123 * @param {?*} children Children tree container. 1124 * @param {function(*, int)} forEachFunc 1125 * @param {*} forEachContext Context for forEachContext. 1126 */ 1127 function forEachChildren(children, forEachFunc, forEachContext) { 1128 mapChildren(children, function () { 1129 forEachFunc.apply(this, arguments); // Don't return anything. 1130 }, forEachContext); 1131 } 1132 /** 1133 * Flatten a children object (typically specified as `props.children`) and 1134 * return an array with appropriately re-keyed children. 1135 * 1136 * See https://reactjs.org/docs/react-api.html#reactchildrentoarray 1137 */ 1138 1139 1140 function toArray(children) { 1141 return mapChildren(children, function (child) { 1142 return child; 1143 }) || []; 1144 } 1145 /** 1146 * Returns the first child in a collection of children and verifies that there 1147 * is only one child in the collection. 1148 * 1149 * See https://reactjs.org/docs/react-api.html#reactchildrenonly 1150 * 1151 * The current implementation of this function assumes that a single child gets 1152 * passed without a wrapper, but the purpose of this helper function is to 1153 * abstract away the particular structure of children. 1154 * 1155 * @param {?object} children Child collection structure. 1156 * @return {ReactElement} The first and only `ReactElement` contained in the 1157 * structure. 1158 */ 1159 1160 1161 function onlyChild(children) { 1162 if (!isValidElement(children)) { 1163 { 1164 throw Error( "React.Children.only expected to receive a single React element child." ); 1165 } 1166 } 1167 1168 return children; 1169 } 1170 1171 function createContext(defaultValue, calculateChangedBits) { 1172 if (calculateChangedBits === undefined) { 1173 calculateChangedBits = null; 1174 } else { 1175 { 1176 if (calculateChangedBits !== null && typeof calculateChangedBits !== 'function') { 1177 error('createContext: Expected the optional second argument to be a ' + 'function. Instead received: %s', calculateChangedBits); 1178 } 1179 } 1180 } 1181 1182 var context = { 1183 $$typeof: REACT_CONTEXT_TYPE, 1184 _calculateChangedBits: calculateChangedBits, 1185 // As a workaround to support multiple concurrent renderers, we categorize 1186 // some renderers as primary and others as secondary. We only expect 1187 // there to be two concurrent renderers at most: React Native (primary) and 1188 // Fabric (secondary); React DOM (primary) and React ART (secondary). 1189 // Secondary renderers store their context values on separate fields. 1190 _currentValue: defaultValue, 1191 _currentValue2: defaultValue, 1192 // Used to track how many concurrent renderers this context currently 1193 // supports within in a single renderer. Such as parallel server rendering. 1194 _threadCount: 0, 1195 // These are circular 1196 Provider: null, 1197 Consumer: null 1198 }; 1199 context.Provider = { 1200 $$typeof: REACT_PROVIDER_TYPE, 1201 _context: context 1202 }; 1203 var hasWarnedAboutUsingNestedContextConsumers = false; 1204 var hasWarnedAboutUsingConsumerProvider = false; 1205 var hasWarnedAboutDisplayNameOnConsumer = false; 1206 1207 { 1208 // A separate object, but proxies back to the original context object for 1209 // backwards compatibility. It has a different $$typeof, so we can properly 1210 // warn for the incorrect usage of Context as a Consumer. 1211 var Consumer = { 1212 $$typeof: REACT_CONTEXT_TYPE, 1213 _context: context, 1214 _calculateChangedBits: context._calculateChangedBits 1215 }; // $FlowFixMe: Flow complains about not setting a value, which is intentional here 1216 1217 Object.defineProperties(Consumer, { 1218 Provider: { 1219 get: function () { 1220 if (!hasWarnedAboutUsingConsumerProvider) { 1221 hasWarnedAboutUsingConsumerProvider = true; 1222 1223 error('Rendering <Context.Consumer.Provider> is not supported and will be removed in ' + 'a future major release. Did you mean to render <Context.Provider> instead?'); 1224 } 1225 1226 return context.Provider; 1227 }, 1228 set: function (_Provider) { 1229 context.Provider = _Provider; 1230 } 1231 }, 1232 _currentValue: { 1233 get: function () { 1234 return context._currentValue; 1235 }, 1236 set: function (_currentValue) { 1237 context._currentValue = _currentValue; 1238 } 1239 }, 1240 _currentValue2: { 1241 get: function () { 1242 return context._currentValue2; 1243 }, 1244 set: function (_currentValue2) { 1245 context._currentValue2 = _currentValue2; 1246 } 1247 }, 1248 _threadCount: { 1249 get: function () { 1250 return context._threadCount; 1251 }, 1252 set: function (_threadCount) { 1253 context._threadCount = _threadCount; 1254 } 1255 }, 1256 Consumer: { 1257 get: function () { 1258 if (!hasWarnedAboutUsingNestedContextConsumers) { 1259 hasWarnedAboutUsingNestedContextConsumers = true; 1260 1261 error('Rendering <Context.Consumer.Consumer> is not supported and will be removed in ' + 'a future major release. Did you mean to render <Context.Consumer> instead?'); 1262 } 1263 1264 return context.Consumer; 1265 } 1266 }, 1267 displayName: { 1268 get: function () { 1269 return context.displayName; 1270 }, 1271 set: function (displayName) { 1272 if (!hasWarnedAboutDisplayNameOnConsumer) { 1273 warn('Setting `displayName` on Context.Consumer has no effect. ' + "You should set it directly on the context with Context.displayName = '%s'.", displayName); 1274 1275 hasWarnedAboutDisplayNameOnConsumer = true; 1276 } 1277 } 1278 } 1279 }); // $FlowFixMe: Flow complains about missing properties because it doesn't understand defineProperty 1280 1281 context.Consumer = Consumer; 1282 } 1283 1284 { 1285 context._currentRenderer = null; 1286 context._currentRenderer2 = null; 1287 } 1288 1289 return context; 1290 } 1291 1292 var Uninitialized = -1; 1293 var Pending = 0; 1294 var Resolved = 1; 1295 var Rejected = 2; 1296 1297 function lazyInitializer(payload) { 1298 if (payload._status === Uninitialized) { 1299 var ctor = payload._result; 1300 var thenable = ctor(); // Transition to the next state. 1301 1302 var pending = payload; 1303 pending._status = Pending; 1304 pending._result = thenable; 1305 thenable.then(function (moduleObject) { 1306 if (payload._status === Pending) { 1307 var defaultExport = moduleObject.default; 1308 1309 { 1310 if (defaultExport === undefined) { 1311 error('lazy: Expected the result of a dynamic import() call. ' + 'Instead received: %s\n\nYour code should look like: \n ' + // Break up imports to avoid accidentally parsing them as dependencies. 1312 'const MyComponent = lazy(() => imp' + "ort('./MyComponent'))", moduleObject); 1313 } 1314 } // Transition to the next state. 1315 1316 1317 var resolved = payload; 1318 resolved._status = Resolved; 1319 resolved._result = defaultExport; 1320 } 1321 }, function (error) { 1322 if (payload._status === Pending) { 1323 // Transition to the next state. 1324 var rejected = payload; 1325 rejected._status = Rejected; 1326 rejected._result = error; 1327 } 1328 }); 1329 } 1330 1331 if (payload._status === Resolved) { 1332 return payload._result; 1333 } else { 1334 throw payload._result; 1335 } 1336 } 1337 1338 function lazy(ctor) { 1339 var payload = { 1340 // We use these fields to store the result. 1341 _status: -1, 1342 _result: ctor 1343 }; 1344 var lazyType = { 1345 $$typeof: REACT_LAZY_TYPE, 1346 _payload: payload, 1347 _init: lazyInitializer 1348 }; 1349 1350 { 1351 // In production, this would just set it on the object. 1352 var defaultProps; 1353 var propTypes; // $FlowFixMe 1354 1355 Object.defineProperties(lazyType, { 1356 defaultProps: { 1357 configurable: true, 1358 get: function () { 1359 return defaultProps; 1360 }, 1361 set: function (newDefaultProps) { 1362 error('React.lazy(...): It is not supported to assign `defaultProps` to ' + 'a lazy component import. Either specify them where the component ' + 'is defined, or create a wrapping component around it.'); 1363 1364 defaultProps = newDefaultProps; // Match production behavior more closely: 1365 // $FlowFixMe 1366 1367 Object.defineProperty(lazyType, 'defaultProps', { 1368 enumerable: true 1369 }); 1370 } 1371 }, 1372 propTypes: { 1373 configurable: true, 1374 get: function () { 1375 return propTypes; 1376 }, 1377 set: function (newPropTypes) { 1378 error('React.lazy(...): It is not supported to assign `propTypes` to ' + 'a lazy component import. Either specify them where the component ' + 'is defined, or create a wrapping component around it.'); 1379 1380 propTypes = newPropTypes; // Match production behavior more closely: 1381 // $FlowFixMe 1382 1383 Object.defineProperty(lazyType, 'propTypes', { 1384 enumerable: true 1385 }); 1386 } 1387 } 1388 }); 1389 } 1390 1391 return lazyType; 1392 } 1393 1394 function forwardRef(render) { 1395 { 1396 if (render != null && render.$$typeof === REACT_MEMO_TYPE) { 1397 error('forwardRef requires a render function but received a `memo` ' + 'component. Instead of forwardRef(memo(...)), use ' + 'memo(forwardRef(...)).'); 1398 } else if (typeof render !== 'function') { 1399 error('forwardRef requires a render function but was given %s.', render === null ? 'null' : typeof render); 1400 } else { 1401 if (render.length !== 0 && render.length !== 2) { 1402 error('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.'); 1403 } 1404 } 1405 1406 if (render != null) { 1407 if (render.defaultProps != null || render.propTypes != null) { 1408 error('forwardRef render functions do not support propTypes or defaultProps. ' + 'Did you accidentally pass a React component?'); 1409 } 1410 } 1411 } 1412 1413 var elementType = { 1414 $$typeof: REACT_FORWARD_REF_TYPE, 1415 render: render 1416 }; 1417 1418 { 1419 var ownName; 1420 Object.defineProperty(elementType, 'displayName', { 1421 enumerable: false, 1422 configurable: true, 1423 get: function () { 1424 return ownName; 1425 }, 1426 set: function (name) { 1427 ownName = name; 1428 1429 if (render.displayName == null) { 1430 render.displayName = name; 1431 } 1432 } 1433 }); 1434 } 1435 1436 return elementType; 1437 } 1438 1439 // Filter certain DOM attributes (e.g. src, href) if their values are empty strings. 1440 1441 var enableScopeAPI = false; // Experimental Create Event Handle API. 1442 1443 function isValidElementType(type) { 1444 if (typeof type === 'string' || typeof type === 'function') { 1445 return true; 1446 } // Note: typeof might be other than 'symbol' or 'number' (e.g. if it's a polyfill). 1447 1448 1449 if (type === exports.Fragment || type === exports.Profiler || type === REACT_DEBUG_TRACING_MODE_TYPE || type === exports.StrictMode || type === exports.Suspense || type === REACT_SUSPENSE_LIST_TYPE || type === REACT_LEGACY_HIDDEN_TYPE || enableScopeAPI ) { 1450 return true; 1451 } 1452 1453 if (typeof type === 'object' && type !== null) { 1454 if (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_BLOCK_TYPE || type[0] === REACT_SERVER_BLOCK_TYPE) { 1455 return true; 1456 } 1457 } 1458 1459 return false; 1460 } 1461 1462 function memo(type, compare) { 1463 { 1464 if (!isValidElementType(type)) { 1465 error('memo: The first argument must be a component. Instead ' + 'received: %s', type === null ? 'null' : typeof type); 1466 } 1467 } 1468 1469 var elementType = { 1470 $$typeof: REACT_MEMO_TYPE, 1471 type: type, 1472 compare: compare === undefined ? null : compare 1473 }; 1474 1475 { 1476 var ownName; 1477 Object.defineProperty(elementType, 'displayName', { 1478 enumerable: false, 1479 configurable: true, 1480 get: function () { 1481 return ownName; 1482 }, 1483 set: function (name) { 1484 ownName = name; 1485 1486 if (type.displayName == null) { 1487 type.displayName = name; 1488 } 1489 } 1490 }); 1491 } 1492 1493 return elementType; 1494 } 1495 1496 function resolveDispatcher() { 1497 var dispatcher = ReactCurrentDispatcher.current; 1498 1499 if (!(dispatcher !== null)) { 1500 { 1501 throw Error( "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://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem." ); 1502 } 1503 } 1504 1505 return dispatcher; 1506 } 1507 1508 function useContext(Context, unstable_observedBits) { 1509 var dispatcher = resolveDispatcher(); 1510 1511 { 1512 if (unstable_observedBits !== undefined) { 1513 error('useContext() second argument is reserved for future ' + 'use in React. Passing it is not supported. ' + 'You passed: %s.%s', unstable_observedBits, typeof unstable_observedBits === 'number' && Array.isArray(arguments[2]) ? '\n\nDid you call array.map(useContext)? ' + 'Calling Hooks inside a loop is not supported. ' + 'Learn more at https://reactjs.org/link/rules-of-hooks' : ''); 1514 } // TODO: add a more generic warning for invalid values. 1515 1516 1517 if (Context._context !== undefined) { 1518 var realContext = Context._context; // Don't deduplicate because this legitimately causes bugs 1519 // and nobody should be using this in existing code. 1520 1521 if (realContext.Consumer === Context) { 1522 error('Calling useContext(Context.Consumer) is not supported, may cause bugs, and will be ' + 'removed in a future major release. Did you mean to call useContext(Context) instead?'); 1523 } else if (realContext.Provider === Context) { 1524 error('Calling useContext(Context.Provider) is not supported. ' + 'Did you mean to call useContext(Context) instead?'); 1525 } 1526 } 1527 } 1528 1529 return dispatcher.useContext(Context, unstable_observedBits); 1530 } 1531 function useState(initialState) { 1532 var dispatcher = resolveDispatcher(); 1533 return dispatcher.useState(initialState); 1534 } 1535 function useReducer(reducer, initialArg, init) { 1536 var dispatcher = resolveDispatcher(); 1537 return dispatcher.useReducer(reducer, initialArg, init); 1538 } 1539 function useRef(initialValue) { 1540 var dispatcher = resolveDispatcher(); 1541 return dispatcher.useRef(initialValue); 1542 } 1543 function useEffect(create, deps) { 1544 var dispatcher = resolveDispatcher(); 1545 return dispatcher.useEffect(create, deps); 1546 } 1547 function useLayoutEffect(create, deps) { 1548 var dispatcher = resolveDispatcher(); 1549 return dispatcher.useLayoutEffect(create, deps); 1550 } 1551 function useCallback(callback, deps) { 1552 var dispatcher = resolveDispatcher(); 1553 return dispatcher.useCallback(callback, deps); 1554 } 1555 function useMemo(create, deps) { 1556 var dispatcher = resolveDispatcher(); 1557 return dispatcher.useMemo(create, deps); 1558 } 1559 function useImperativeHandle(ref, create, deps) { 1560 var dispatcher = resolveDispatcher(); 1561 return dispatcher.useImperativeHandle(ref, create, deps); 1562 } 1563 function useDebugValue(value, formatterFn) { 1564 { 1565 var dispatcher = resolveDispatcher(); 1566 return dispatcher.useDebugValue(value, formatterFn); 1567 } 1568 } 1569 1570 // Helpers to patch console.logs to avoid logging during side-effect free 1571 // replaying on render function. This currently only patches the object 1572 // lazily which won't cover if the log function was extracted eagerly. 1573 // We could also eagerly patch the method. 1574 var disabledDepth = 0; 1575 var prevLog; 1576 var prevInfo; 1577 var prevWarn; 1578 var prevError; 1579 var prevGroup; 1580 var prevGroupCollapsed; 1581 var prevGroupEnd; 1582 1583 function disabledLog() {} 1584 1585 disabledLog.__reactDisabledLog = true; 1586 function disableLogs() { 1587 { 1588 if (disabledDepth === 0) { 1589 /* eslint-disable react-internal/no-production-logging */ 1590 prevLog = console.log; 1591 prevInfo = console.info; 1592 prevWarn = console.warn; 1593 prevError = console.error; 1594 prevGroup = console.group; 1595 prevGroupCollapsed = console.groupCollapsed; 1596 prevGroupEnd = console.groupEnd; // https://github.com/facebook/react/issues/19099 1597 1598 var props = { 1599 configurable: true, 1600 enumerable: true, 1601 value: disabledLog, 1602 writable: true 1603 }; // $FlowFixMe Flow thinks console is immutable. 1604 1605 Object.defineProperties(console, { 1606 info: props, 1607 log: props, 1608 warn: props, 1609 error: props, 1610 group: props, 1611 groupCollapsed: props, 1612 groupEnd: props 1613 }); 1614 /* eslint-enable react-internal/no-production-logging */ 1615 } 1616 1617 disabledDepth++; 1618 } 1619 } 1620 function reenableLogs() { 1621 { 1622 disabledDepth--; 1623 1624 if (disabledDepth === 0) { 1625 /* eslint-disable react-internal/no-production-logging */ 1626 var props = { 1627 configurable: true, 1628 enumerable: true, 1629 writable: true 1630 }; // $FlowFixMe Flow thinks console is immutable. 1631 1632 Object.defineProperties(console, { 1633 log: assign({}, props, { 1634 value: prevLog 1635 }), 1636 info: assign({}, props, { 1637 value: prevInfo 1638 }), 1639 warn: assign({}, props, { 1640 value: prevWarn 1641 }), 1642 error: assign({}, props, { 1643 value: prevError 1644 }), 1645 group: assign({}, props, { 1646 value: prevGroup 1647 }), 1648 groupCollapsed: assign({}, props, { 1649 value: prevGroupCollapsed 1650 }), 1651 groupEnd: assign({}, props, { 1652 value: prevGroupEnd 1653 }) 1654 }); 1655 /* eslint-enable react-internal/no-production-logging */ 1656 } 1657 1658 if (disabledDepth < 0) { 1659 error('disabledDepth fell below zero. ' + 'This is a bug in React. Please file an issue.'); 1660 } 1661 } 1662 } 1663 1664 var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher; 1665 var prefix; 1666 function describeBuiltInComponentFrame(name, source, ownerFn) { 1667 { 1668 if (prefix === undefined) { 1669 // Extract the VM specific prefix used by each line. 1670 try { 1671 throw Error(); 1672 } catch (x) { 1673 var match = x.stack.trim().match(/\n( *(at )?)/); 1674 prefix = match && match[1] || ''; 1675 } 1676 } // We use the prefix to ensure our stacks line up with native stack frames. 1677 1678 1679 return '\n' + prefix + name; 1680 } 1681 } 1682 var reentry = false; 1683 var componentFrameCache; 1684 1685 { 1686 var PossiblyWeakMap = typeof WeakMap === 'function' ? WeakMap : Map; 1687 componentFrameCache = new PossiblyWeakMap(); 1688 } 1689 1690 function describeNativeComponentFrame(fn, construct) { 1691 // If something asked for a stack inside a fake render, it should get ignored. 1692 if (!fn || reentry) { 1693 return ''; 1694 } 1695 1696 { 1697 var frame = componentFrameCache.get(fn); 1698 1699 if (frame !== undefined) { 1700 return frame; 1701 } 1702 } 1703 1704 var control; 1705 reentry = true; 1706 var previousPrepareStackTrace = Error.prepareStackTrace; // $FlowFixMe It does accept undefined. 1707 1708 Error.prepareStackTrace = undefined; 1709 var previousDispatcher; 1710 1711 { 1712 previousDispatcher = ReactCurrentDispatcher$1.current; // Set the dispatcher in DEV because this might be call in the render function 1713 // for warnings. 1714 1715 ReactCurrentDispatcher$1.current = null; 1716 disableLogs(); 1717 } 1718 1719 try { 1720 // This should throw. 1721 if (construct) { 1722 // Something should be setting the props in the constructor. 1723 var Fake = function () { 1724 throw Error(); 1725 }; // $FlowFixMe 1726 1727 1728 Object.defineProperty(Fake.prototype, 'props', { 1729 set: function () { 1730 // We use a throwing setter instead of frozen or non-writable props 1731 // because that won't throw in a non-strict mode function. 1732 throw Error(); 1733 } 1734 }); 1735 1736 if (typeof Reflect === 'object' && Reflect.construct) { 1737 // We construct a different control for this case to include any extra 1738 // frames added by the construct call. 1739 try { 1740 Reflect.construct(Fake, []); 1741 } catch (x) { 1742 control = x; 1743 } 1744 1745 Reflect.construct(fn, [], Fake); 1746 } else { 1747 try { 1748 Fake.call(); 1749 } catch (x) { 1750 control = x; 1751 } 1752 1753 fn.call(Fake.prototype); 1754 } 1755 } else { 1756 try { 1757 throw Error(); 1758 } catch (x) { 1759 control = x; 1760 } 1761 1762 fn(); 1763 } 1764 } catch (sample) { 1765 // This is inlined manually because closure doesn't do it for us. 1766 if (sample && control && typeof sample.stack === 'string') { 1767 // This extracts the first frame from the sample that isn't also in the control. 1768 // Skipping one frame that we assume is the frame that calls the two. 1769 var sampleLines = sample.stack.split('\n'); 1770 var controlLines = control.stack.split('\n'); 1771 var s = sampleLines.length - 1; 1772 var c = controlLines.length - 1; 1773 1774 while (s >= 1 && c >= 0 && sampleLines[s] !== controlLines[c]) { 1775 // We expect at least one stack frame to be shared. 1776 // Typically this will be the root most one. However, stack frames may be 1777 // cut off due to maximum stack limits. In this case, one maybe cut off 1778 // earlier than the other. We assume that the sample is longer or the same 1779 // and there for cut off earlier. So we should find the root most frame in 1780 // the sample somewhere in the control. 1781 c--; 1782 } 1783 1784 for (; s >= 1 && c >= 0; s--, c--) { 1785 // Next we find the first one that isn't the same which should be the 1786 // frame that called our sample function and the control. 1787 if (sampleLines[s] !== controlLines[c]) { 1788 // In V8, the first line is describing the message but other VMs don't. 1789 // If we're about to return the first line, and the control is also on the same 1790 // line, that's a pretty good indicator that our sample threw at same line as 1791 // the control. I.e. before we entered the sample frame. So we ignore this result. 1792 // This can happen if you passed a class to function component, or non-function. 1793 if (s !== 1 || c !== 1) { 1794 do { 1795 s--; 1796 c--; // We may still have similar intermediate frames from the construct call. 1797 // The next one that isn't the same should be our match though. 1798 1799 if (c < 0 || sampleLines[s] !== controlLines[c]) { 1800 // V8 adds a "new" prefix for native classes. Let's remove it to make it prettier. 1801 var _frame = '\n' + sampleLines[s].replace(' at new ', ' at '); 1802 1803 { 1804 if (typeof fn === 'function') { 1805 componentFrameCache.set(fn, _frame); 1806 } 1807 } // Return the line we found. 1808 1809 1810 return _frame; 1811 } 1812 } while (s >= 1 && c >= 0); 1813 } 1814 1815 break; 1816 } 1817 } 1818 } 1819 } finally { 1820 reentry = false; 1821 1822 { 1823 ReactCurrentDispatcher$1.current = previousDispatcher; 1824 reenableLogs(); 1825 } 1826 1827 Error.prepareStackTrace = previousPrepareStackTrace; 1828 } // Fallback to just using the name if we couldn't make it throw. 1829 1830 1831 var name = fn ? fn.displayName || fn.name : ''; 1832 var syntheticFrame = name ? describeBuiltInComponentFrame(name) : ''; 1833 1834 { 1835 if (typeof fn === 'function') { 1836 componentFrameCache.set(fn, syntheticFrame); 1837 } 1838 } 1839 1840 return syntheticFrame; 1841 } 1842 function describeFunctionComponentFrame(fn, source, ownerFn) { 1843 { 1844 return describeNativeComponentFrame(fn, false); 1845 } 1846 } 1847 1848 function shouldConstruct(Component) { 1849 var prototype = Component.prototype; 1850 return !!(prototype && prototype.isReactComponent); 1851 } 1852 1853 function describeUnknownElementTypeFrameInDEV(type, source, ownerFn) { 1854 1855 if (type == null) { 1856 return ''; 1857 } 1858 1859 if (typeof type === 'function') { 1860 { 1861 return describeNativeComponentFrame(type, shouldConstruct(type)); 1862 } 1863 } 1864 1865 if (typeof type === 'string') { 1866 return describeBuiltInComponentFrame(type); 1867 } 1868 1869 switch (type) { 1870 case exports.Suspense: 1871 return describeBuiltInComponentFrame('Suspense'); 1872 1873 case REACT_SUSPENSE_LIST_TYPE: 1874 return describeBuiltInComponentFrame('SuspenseList'); 1875 } 1876 1877 if (typeof type === 'object') { 1878 switch (type.$$typeof) { 1879 case REACT_FORWARD_REF_TYPE: 1880 return describeFunctionComponentFrame(type.render); 1881 1882 case REACT_MEMO_TYPE: 1883 // Memo may contain any component type so we recursively resolve it. 1884 return describeUnknownElementTypeFrameInDEV(type.type, source, ownerFn); 1885 1886 case REACT_BLOCK_TYPE: 1887 return describeFunctionComponentFrame(type._render); 1888 1889 case REACT_LAZY_TYPE: 1890 { 1891 var lazyComponent = type; 1892 var payload = lazyComponent._payload; 1893 var init = lazyComponent._init; 1894 1895 try { 1896 // Lazy may contain any component type so we recursively resolve it. 1897 return describeUnknownElementTypeFrameInDEV(init(payload), source, ownerFn); 1898 } catch (x) {} 1899 } 1900 } 1901 } 1902 1903 return ''; 1904 } 1905 1906 var loggedTypeFailures = {}; 1907 var ReactDebugCurrentFrame$1 = ReactSharedInternals.ReactDebugCurrentFrame; 1908 1909 function setCurrentlyValidatingElement(element) { 1910 { 1911 if (element) { 1912 var owner = element._owner; 1913 var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null); 1914 ReactDebugCurrentFrame$1.setExtraStackFrame(stack); 1915 } else { 1916 ReactDebugCurrentFrame$1.setExtraStackFrame(null); 1917 } 1918 } 1919 } 1920 1921 function checkPropTypes(typeSpecs, values, location, componentName, element) { 1922 { 1923 // $FlowFixMe This is okay but Flow doesn't know it. 1924 var has = Function.call.bind(Object.prototype.hasOwnProperty); 1925 1926 for (var typeSpecName in typeSpecs) { 1927 if (has(typeSpecs, typeSpecName)) { 1928 var error$1 = void 0; // Prop type validation may throw. In case they do, we don't want to 1929 // fail the render phase where it didn't fail before. So we log it. 1930 // After these have been cleaned up, we'll let them throw. 1931 1932 try { 1933 // This is intentionally an invariant that gets caught. It's the same 1934 // behavior as without this statement except with a better message. 1935 if (typeof typeSpecs[typeSpecName] !== 'function') { 1936 var err = Error((componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' + 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.' + 'This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.'); 1937 err.name = 'Invariant Violation'; 1938 throw err; 1939 } 1940 1941 error$1 = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED'); 1942 } catch (ex) { 1943 error$1 = ex; 1944 } 1945 1946 if (error$1 && !(error$1 instanceof Error)) { 1947 setCurrentlyValidatingElement(element); 1948 1949 error('%s: type specification of %s' + ' `%s` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a %s. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).', componentName || 'React class', location, typeSpecName, typeof error$1); 1950 1951 setCurrentlyValidatingElement(null); 1952 } 1953 1954 if (error$1 instanceof Error && !(error$1.message in loggedTypeFailures)) { 1955 // Only monitor this failure once because there tends to be a lot of the 1956 // same error. 1957 loggedTypeFailures[error$1.message] = true; 1958 setCurrentlyValidatingElement(element); 1959 1960 error('Failed %s type: %s', location, error$1.message); 1961 1962 setCurrentlyValidatingElement(null); 1963 } 1964 } 1965 } 1966 } 1967 } 1968 1969 function setCurrentlyValidatingElement$1(element) { 1970 { 1971 if (element) { 1972 var owner = element._owner; 1973 var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null); 1974 setExtraStackFrame(stack); 1975 } else { 1976 setExtraStackFrame(null); 1977 } 1978 } 1979 } 1980 1981 var propTypesMisspellWarningShown; 1982 1983 { 1984 propTypesMisspellWarningShown = false; 1985 } 1986 1987 function getDeclarationErrorAddendum() { 1988 if (ReactCurrentOwner.current) { 1989 var name = getComponentName(ReactCurrentOwner.current.type); 1990 1991 if (name) { 1992 return '\n\nCheck the render method of `' + name + '`.'; 1993 } 1994 } 1995 1996 return ''; 1997 } 1998 1999 function getSourceInfoErrorAddendum(source) { 2000 if (source !== undefined) { 2001 var fileName = source.fileName.replace(/^.*[\\\/]/, ''); 2002 var lineNumber = source.lineNumber; 2003 return '\n\nCheck your code at ' + fileName + ':' + lineNumber + '.'; 2004 } 2005 2006 return ''; 2007 } 2008 2009 function getSourceInfoErrorAddendumForProps(elementProps) { 2010 if (elementProps !== null && elementProps !== undefined) { 2011 return getSourceInfoErrorAddendum(elementProps.__source); 2012 } 2013 2014 return ''; 2015 } 2016 /** 2017 * Warn if there's no key explicitly set on dynamic arrays of children or 2018 * object keys are not valid. This allows us to keep track of children between 2019 * updates. 2020 */ 2021 2022 2023 var ownerHasKeyUseWarning = {}; 2024 2025 function getCurrentComponentErrorInfo(parentType) { 2026 var info = getDeclarationErrorAddendum(); 2027 2028 if (!info) { 2029 var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name; 2030 2031 if (parentName) { 2032 info = "\n\nCheck the top-level render call using <" + parentName + ">."; 2033 } 2034 } 2035 2036 return info; 2037 } 2038 /** 2039 * Warn if the element doesn't have an explicit key assigned to it. 2040 * This element is in an array. The array could grow and shrink or be 2041 * reordered. All children that haven't already been validated are required to 2042 * have a "key" property assigned to it. Error statuses are cached so a warning 2043 * will only be shown once. 2044 * 2045 * @internal 2046 * @param {ReactElement} element Element that requires a key. 2047 * @param {*} parentType element's parent's type. 2048 */ 2049 2050 2051 function validateExplicitKey(element, parentType) { 2052 if (!element._store || element._store.validated || element.key != null) { 2053 return; 2054 } 2055 2056 element._store.validated = true; 2057 var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType); 2058 2059 if (ownerHasKeyUseWarning[currentComponentErrorInfo]) { 2060 return; 2061 } 2062 2063 ownerHasKeyUseWarning[currentComponentErrorInfo] = true; // Usually the current owner is the offender, but if it accepts children as a 2064 // property, it may be the creator of the child that's responsible for 2065 // assigning it a key. 2066 2067 var childOwner = ''; 2068 2069 if (element && element._owner && element._owner !== ReactCurrentOwner.current) { 2070 // Give the component that originally created this child. 2071 childOwner = " It was passed a child from " + getComponentName(element._owner.type) + "."; 2072 } 2073 2074 { 2075 setCurrentlyValidatingElement$1(element); 2076 2077 error('Each child in a list should have a unique "key" prop.' + '%s%s See https://reactjs.org/link/warning-keys for more information.', currentComponentErrorInfo, childOwner); 2078 2079 setCurrentlyValidatingElement$1(null); 2080 } 2081 } 2082 /** 2083 * Ensure that every element either is passed in a static location, in an 2084 * array with an explicit keys property defined, or in an object literal 2085 * with valid key property. 2086 * 2087 * @internal 2088 * @param {ReactNode} node Statically passed child of any type. 2089 * @param {*} parentType node's parent's type. 2090 */ 2091 2092 2093 function validateChildKeys(node, parentType) { 2094 if (typeof node !== 'object') { 2095 return; 2096 } 2097 2098 if (Array.isArray(node)) { 2099 for (var i = 0; i < node.length; i++) { 2100 var child = node[i]; 2101 2102 if (isValidElement(child)) { 2103 validateExplicitKey(child, parentType); 2104 } 2105 } 2106 } else if (isValidElement(node)) { 2107 // This element was passed in a valid location. 2108 if (node._store) { 2109 node._store.validated = true; 2110 } 2111 } else if (node) { 2112 var iteratorFn = getIteratorFn(node); 2113 2114 if (typeof iteratorFn === 'function') { 2115 // Entry iterators used to provide implicit keys, 2116 // but now we print a separate warning for them later. 2117 if (iteratorFn !== node.entries) { 2118 var iterator = iteratorFn.call(node); 2119 var step; 2120 2121 while (!(step = iterator.next()).done) { 2122 if (isValidElement(step.value)) { 2123 validateExplicitKey(step.value, parentType); 2124 } 2125 } 2126 } 2127 } 2128 } 2129 } 2130 /** 2131 * Given an element, validate that its props follow the propTypes definition, 2132 * provided by the type. 2133 * 2134 * @param {ReactElement} element 2135 */ 2136 2137 2138 function validatePropTypes(element) { 2139 { 2140 var type = element.type; 2141 2142 if (type === null || type === undefined || typeof type === 'string') { 2143 return; 2144 } 2145 2146 var propTypes; 2147 2148 if (typeof type === 'function') { 2149 propTypes = type.propTypes; 2150 } else if (typeof type === 'object' && (type.$$typeof === REACT_FORWARD_REF_TYPE || // Note: Memo only checks outer props here. 2151 // Inner props are checked in the reconciler. 2152 type.$$typeof === REACT_MEMO_TYPE)) { 2153 propTypes = type.propTypes; 2154 } else { 2155 return; 2156 } 2157 2158 if (propTypes) { 2159 // Intentionally inside to avoid triggering lazy initializers: 2160 var name = getComponentName(type); 2161 checkPropTypes(propTypes, element.props, 'prop', name, element); 2162 } else if (type.PropTypes !== undefined && !propTypesMisspellWarningShown) { 2163 propTypesMisspellWarningShown = true; // Intentionally inside to avoid triggering lazy initializers: 2164 2165 var _name = getComponentName(type); 2166 2167 error('Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?', _name || 'Unknown'); 2168 } 2169 2170 if (typeof type.getDefaultProps === 'function' && !type.getDefaultProps.isReactClassApproved) { 2171 error('getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.'); 2172 } 2173 } 2174 } 2175 /** 2176 * Given a fragment, validate that it can only be provided with fragment props 2177 * @param {ReactElement} fragment 2178 */ 2179 2180 2181 function validateFragmentProps(fragment) { 2182 { 2183 var keys = Object.keys(fragment.props); 2184 2185 for (var i = 0; i < keys.length; i++) { 2186 var key = keys[i]; 2187 2188 if (key !== 'children' && key !== 'key') { 2189 setCurrentlyValidatingElement$1(fragment); 2190 2191 error('Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', key); 2192 2193 setCurrentlyValidatingElement$1(null); 2194 break; 2195 } 2196 } 2197 2198 if (fragment.ref !== null) { 2199 setCurrentlyValidatingElement$1(fragment); 2200 2201 error('Invalid attribute `ref` supplied to `React.Fragment`.'); 2202 2203 setCurrentlyValidatingElement$1(null); 2204 } 2205 } 2206 } 2207 function createElementWithValidation(type, props, children) { 2208 var validType = isValidElementType(type); // We warn in this case but don't throw. We expect the element creation to 2209 // succeed and there will likely be errors in render. 2210 2211 if (!validType) { 2212 var info = ''; 2213 2214 if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) { 2215 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."; 2216 } 2217 2218 var sourceInfo = getSourceInfoErrorAddendumForProps(props); 2219 2220 if (sourceInfo) { 2221 info += sourceInfo; 2222 } else { 2223 info += getDeclarationErrorAddendum(); 2224 } 2225 2226 var typeString; 2227 2228 if (type === null) { 2229 typeString = 'null'; 2230 } else if (Array.isArray(type)) { 2231 typeString = 'array'; 2232 } else if (type !== undefined && type.$$typeof === REACT_ELEMENT_TYPE) { 2233 typeString = "<" + (getComponentName(type.type) || 'Unknown') + " />"; 2234 info = ' Did you accidentally export a JSX literal instead of a component?'; 2235 } else { 2236 typeString = typeof type; 2237 } 2238 2239 { 2240 error('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); 2241 } 2242 } 2243 2244 var element = createElement.apply(this, arguments); // The result can be nullish if a mock or a custom function is used. 2245 // TODO: Drop this when these are no longer allowed as the type argument. 2246 2247 if (element == null) { 2248 return element; 2249 } // Skip key warning if the type isn't valid since our key validation logic 2250 // doesn't expect a non-string/function type and can throw confusing errors. 2251 // We don't want exception behavior to differ between dev and prod. 2252 // (Rendering will throw with a helpful message and as soon as the type is 2253 // fixed, the key warnings will appear.) 2254 2255 2256 if (validType) { 2257 for (var i = 2; i < arguments.length; i++) { 2258 validateChildKeys(arguments[i], type); 2259 } 2260 } 2261 2262 if (type === exports.Fragment) { 2263 validateFragmentProps(element); 2264 } else { 2265 validatePropTypes(element); 2266 } 2267 2268 return element; 2269 } 2270 var didWarnAboutDeprecatedCreateFactory = false; 2271 function createFactoryWithValidation(type) { 2272 var validatedFactory = createElementWithValidation.bind(null, type); 2273 validatedFactory.type = type; 2274 2275 { 2276 if (!didWarnAboutDeprecatedCreateFactory) { 2277 didWarnAboutDeprecatedCreateFactory = true; 2278 2279 warn('React.createFactory() is deprecated and will be removed in ' + 'a future major release. Consider using JSX ' + 'or use React.createElement() directly instead.'); 2280 } // Legacy hook: remove it 2281 2282 2283 Object.defineProperty(validatedFactory, 'type', { 2284 enumerable: false, 2285 get: function () { 2286 warn('Factory.type is deprecated. Access the class directly ' + 'before passing it to createFactory.'); 2287 2288 Object.defineProperty(this, 'type', { 2289 value: type 2290 }); 2291 return type; 2292 } 2293 }); 2294 } 2295 2296 return validatedFactory; 2297 } 2298 function cloneElementWithValidation(element, props, children) { 2299 var newElement = cloneElement.apply(this, arguments); 2300 2301 for (var i = 2; i < arguments.length; i++) { 2302 validateChildKeys(arguments[i], newElement.type); 2303 } 2304 2305 validatePropTypes(newElement); 2306 return newElement; 2307 } 2308 2309 var enableSchedulerDebugging = false; 2310 var enableProfiling = false; 2311 2312 var requestHostCallback; 2313 var requestHostTimeout; 2314 var cancelHostTimeout; 2315 var shouldYieldToHost; 2316 var requestPaint; 2317 var getCurrentTime; 2318 var forceFrameRate; 2319 var hasPerformanceNow = typeof performance === 'object' && typeof performance.now === 'function'; 2320 2321 if (hasPerformanceNow) { 2322 var localPerformance = performance; 2323 2324 getCurrentTime = function () { 2325 return localPerformance.now(); 2326 }; 2327 } else { 2328 var localDate = Date; 2329 var initialTime = localDate.now(); 2330 2331 getCurrentTime = function () { 2332 return localDate.now() - initialTime; 2333 }; 2334 } 2335 2336 if ( // If Scheduler runs in a non-DOM environment, it falls back to a naive 2337 // implementation using setTimeout. 2338 typeof window === 'undefined' || // Check if MessageChannel is supported, too. 2339 typeof MessageChannel !== 'function') { 2340 // If this accidentally gets imported in a non-browser environment, e.g. JavaScriptCore, 2341 // fallback to a naive implementation. 2342 var _callback = null; 2343 var _timeoutID = null; 2344 2345 var _flushCallback = function () { 2346 if (_callback !== null) { 2347 try { 2348 var currentTime = getCurrentTime(); 2349 var hasRemainingTime = true; 2350 2351 _callback(hasRemainingTime, currentTime); 2352 2353 _callback = null; 2354 } catch (e) { 2355 setTimeout(_flushCallback, 0); 2356 throw e; 2357 } 2358 } 2359 }; 2360 2361 requestHostCallback = function (cb) { 2362 if (_callback !== null) { 2363 // Protect against re-entrancy. 2364 setTimeout(requestHostCallback, 0, cb); 2365 } else { 2366 _callback = cb; 2367 setTimeout(_flushCallback, 0); 2368 } 2369 }; 2370 2371 requestHostTimeout = function (cb, ms) { 2372 _timeoutID = setTimeout(cb, ms); 2373 }; 2374 2375 cancelHostTimeout = function () { 2376 clearTimeout(_timeoutID); 2377 }; 2378 2379 shouldYieldToHost = function () { 2380 return false; 2381 }; 2382 2383 requestPaint = forceFrameRate = function () {}; 2384 } else { 2385 // Capture local references to native APIs, in case a polyfill overrides them. 2386 var _setTimeout = window.setTimeout; 2387 var _clearTimeout = window.clearTimeout; 2388 2389 if (typeof console !== 'undefined') { 2390 // TODO: Scheduler no longer requires these methods to be polyfilled. But 2391 // maybe we want to continue warning if they don't exist, to preserve the 2392 // option to rely on it in the future? 2393 var requestAnimationFrame = window.requestAnimationFrame; 2394 var cancelAnimationFrame = window.cancelAnimationFrame; 2395 2396 if (typeof requestAnimationFrame !== 'function') { 2397 // Using console['error'] to evade Babel and ESLint 2398 console['error']("This browser doesn't support requestAnimationFrame. " + 'Make sure that you load a ' + 'polyfill in older browsers. https://reactjs.org/link/react-polyfills'); 2399 } 2400 2401 if (typeof cancelAnimationFrame !== 'function') { 2402 // Using console['error'] to evade Babel and ESLint 2403 console['error']("This browser doesn't support cancelAnimationFrame. " + 'Make sure that you load a ' + 'polyfill in older browsers. https://reactjs.org/link/react-polyfills'); 2404 } 2405 } 2406 2407 var isMessageLoopRunning = false; 2408 var scheduledHostCallback = null; 2409 var taskTimeoutID = -1; // Scheduler periodically yields in case there is other work on the main 2410 // thread, like user events. By default, it yields multiple times per frame. 2411 // It does not attempt to align with frame boundaries, since most tasks don't 2412 // need to be frame aligned; for those that do, use requestAnimationFrame. 2413 2414 var yieldInterval = 5; 2415 var deadline = 0; // TODO: Make this configurable 2416 2417 { 2418 // `isInputPending` is not available. Since we have no way of knowing if 2419 // there's pending input, always yield at the end of the frame. 2420 shouldYieldToHost = function () { 2421 return getCurrentTime() >= deadline; 2422 }; // Since we yield every frame regardless, `requestPaint` has no effect. 2423 2424 2425 requestPaint = function () {}; 2426 } 2427 2428 forceFrameRate = function (fps) { 2429 if (fps < 0 || fps > 125) { 2430 // Using console['error'] to evade Babel and ESLint 2431 console['error']('forceFrameRate takes a positive int between 0 and 125, ' + 'forcing frame rates higher than 125 fps is not supported'); 2432 return; 2433 } 2434 2435 if (fps > 0) { 2436 yieldInterval = Math.floor(1000 / fps); 2437 } else { 2438 // reset the framerate 2439 yieldInterval = 5; 2440 } 2441 }; 2442 2443 var performWorkUntilDeadline = function () { 2444 if (scheduledHostCallback !== null) { 2445 var currentTime = getCurrentTime(); // Yield after `yieldInterval` ms, regardless of where we are in the vsync 2446 // cycle. This means there's always time remaining at the beginning of 2447 // the message event. 2448 2449 deadline = currentTime + yieldInterval; 2450 var hasTimeRemaining = true; 2451 2452 try { 2453 var hasMoreWork = scheduledHostCallback(hasTimeRemaining, currentTime); 2454 2455 if (!hasMoreWork) { 2456 isMessageLoopRunning = false; 2457 scheduledHostCallback = null; 2458 } else { 2459 // If there's more work, schedule the next message event at the end 2460 // of the preceding one. 2461 port.postMessage(null); 2462 } 2463 } catch (error) { 2464 // If a scheduler task throws, exit the current browser task so the 2465 // error can be observed. 2466 port.postMessage(null); 2467 throw error; 2468 } 2469 } else { 2470 isMessageLoopRunning = false; 2471 } // Yielding to the browser will give it a chance to paint, so we can 2472 }; 2473 2474 var channel = new MessageChannel(); 2475 var port = channel.port2; 2476 channel.port1.onmessage = performWorkUntilDeadline; 2477 2478 requestHostCallback = function (callback) { 2479 scheduledHostCallback = callback; 2480 2481 if (!isMessageLoopRunning) { 2482 isMessageLoopRunning = true; 2483 port.postMessage(null); 2484 } 2485 }; 2486 2487 requestHostTimeout = function (callback, ms) { 2488 taskTimeoutID = _setTimeout(function () { 2489 callback(getCurrentTime()); 2490 }, ms); 2491 }; 2492 2493 cancelHostTimeout = function () { 2494 _clearTimeout(taskTimeoutID); 2495 2496 taskTimeoutID = -1; 2497 }; 2498 } 2499 2500 function push(heap, node) { 2501 var index = heap.length; 2502 heap.push(node); 2503 siftUp(heap, node, index); 2504 } 2505 function peek(heap) { 2506 var first = heap[0]; 2507 return first === undefined ? null : first; 2508 } 2509 function pop(heap) { 2510 var first = heap[0]; 2511 2512 if (first !== undefined) { 2513 var last = heap.pop(); 2514 2515 if (last !== first) { 2516 heap[0] = last; 2517 siftDown(heap, last, 0); 2518 } 2519 2520 return first; 2521 } else { 2522 return null; 2523 } 2524 } 2525 2526 function siftUp(heap, node, i) { 2527 var index = i; 2528 2529 while (true) { 2530 var parentIndex = index - 1 >>> 1; 2531 var parent = heap[parentIndex]; 2532 2533 if (parent !== undefined && compare(parent, node) > 0) { 2534 // The parent is larger. Swap positions. 2535 heap[parentIndex] = node; 2536 heap[index] = parent; 2537 index = parentIndex; 2538 } else { 2539 // The parent is smaller. Exit. 2540 return; 2541 } 2542 } 2543 } 2544 2545 function siftDown(heap, node, i) { 2546 var index = i; 2547 var length = heap.length; 2548 2549 while (index < length) { 2550 var leftIndex = (index + 1) * 2 - 1; 2551 var left = heap[leftIndex]; 2552 var rightIndex = leftIndex + 1; 2553 var right = heap[rightIndex]; // If the left or right node is smaller, swap with the smaller of those. 2554 2555 if (left !== undefined && compare(left, node) < 0) { 2556 if (right !== undefined && compare(right, left) < 0) { 2557 heap[index] = right; 2558 heap[rightIndex] = node; 2559 index = rightIndex; 2560 } else { 2561 heap[index] = left; 2562 heap[leftIndex] = node; 2563 index = leftIndex; 2564 } 2565 } else if (right !== undefined && compare(right, node) < 0) { 2566 heap[index] = right; 2567 heap[rightIndex] = node; 2568 index = rightIndex; 2569 } else { 2570 // Neither child is smaller. Exit. 2571 return; 2572 } 2573 } 2574 } 2575 2576 function compare(a, b) { 2577 // Compare sort index first, then task id. 2578 var diff = a.sortIndex - b.sortIndex; 2579 return diff !== 0 ? diff : a.id - b.id; 2580 } 2581 2582 // TODO: Use symbols? 2583 var ImmediatePriority = 1; 2584 var UserBlockingPriority = 2; 2585 var NormalPriority = 3; 2586 var LowPriority = 4; 2587 var IdlePriority = 5; 2588 2589 function markTaskErrored(task, ms) { 2590 } 2591 2592 /* eslint-disable no-var */ 2593 // Math.pow(2, 30) - 1 2594 // 0b111111111111111111111111111111 2595 2596 var maxSigned31BitInt = 1073741823; // Times out immediately 2597 2598 var IMMEDIATE_PRIORITY_TIMEOUT = -1; // Eventually times out 2599 2600 var USER_BLOCKING_PRIORITY_TIMEOUT = 250; 2601 var NORMAL_PRIORITY_TIMEOUT = 5000; 2602 var LOW_PRIORITY_TIMEOUT = 10000; // Never times out 2603 2604 var IDLE_PRIORITY_TIMEOUT = maxSigned31BitInt; // Tasks are stored on a min heap 2605 2606 var taskQueue = []; 2607 var timerQueue = []; // Incrementing id counter. Used to maintain insertion order. 2608 2609 var taskIdCounter = 1; // Pausing the scheduler is useful for debugging. 2610 var currentTask = null; 2611 var currentPriorityLevel = NormalPriority; // This is set while performing work, to prevent re-entrancy. 2612 2613 var isPerformingWork = false; 2614 var isHostCallbackScheduled = false; 2615 var isHostTimeoutScheduled = false; 2616 2617 function advanceTimers(currentTime) { 2618 // Check for tasks that are no longer delayed and add them to the queue. 2619 var timer = peek(timerQueue); 2620 2621 while (timer !== null) { 2622 if (timer.callback === null) { 2623 // Timer was cancelled. 2624 pop(timerQueue); 2625 } else if (timer.startTime <= currentTime) { 2626 // Timer fired. Transfer to the task queue. 2627 pop(timerQueue); 2628 timer.sortIndex = timer.expirationTime; 2629 push(taskQueue, timer); 2630 } else { 2631 // Remaining timers are pending. 2632 return; 2633 } 2634 2635 timer = peek(timerQueue); 2636 } 2637 } 2638 2639 function handleTimeout(currentTime) { 2640 isHostTimeoutScheduled = false; 2641 advanceTimers(currentTime); 2642 2643 if (!isHostCallbackScheduled) { 2644 if (peek(taskQueue) !== null) { 2645 isHostCallbackScheduled = true; 2646 requestHostCallback(flushWork); 2647 } else { 2648 var firstTimer = peek(timerQueue); 2649 2650 if (firstTimer !== null) { 2651 requestHostTimeout(handleTimeout, firstTimer.startTime - currentTime); 2652 } 2653 } 2654 } 2655 } 2656 2657 function flushWork(hasTimeRemaining, initialTime) { 2658 2659 2660 isHostCallbackScheduled = false; 2661 2662 if (isHostTimeoutScheduled) { 2663 // We scheduled a timeout but it's no longer needed. Cancel it. 2664 isHostTimeoutScheduled = false; 2665 cancelHostTimeout(); 2666 } 2667 2668 isPerformingWork = true; 2669 var previousPriorityLevel = currentPriorityLevel; 2670 2671 try { 2672 if (enableProfiling) { 2673 try { 2674 return workLoop(hasTimeRemaining, initialTime); 2675 } catch (error) { 2676 if (currentTask !== null) { 2677 var currentTime = getCurrentTime(); 2678 markTaskErrored(currentTask, currentTime); 2679 currentTask.isQueued = false; 2680 } 2681 2682 throw error; 2683 } 2684 } else { 2685 // No catch in prod code path. 2686 return workLoop(hasTimeRemaining, initialTime); 2687 } 2688 } finally { 2689 currentTask = null; 2690 currentPriorityLevel = previousPriorityLevel; 2691 isPerformingWork = false; 2692 } 2693 } 2694 2695 function workLoop(hasTimeRemaining, initialTime) { 2696 var currentTime = initialTime; 2697 advanceTimers(currentTime); 2698 currentTask = peek(taskQueue); 2699 2700 while (currentTask !== null && !(enableSchedulerDebugging )) { 2701 if (currentTask.expirationTime > currentTime && (!hasTimeRemaining || shouldYieldToHost())) { 2702 // This currentTask hasn't expired, and we've reached the deadline. 2703 break; 2704 } 2705 2706 var callback = currentTask.callback; 2707 2708 if (typeof callback === 'function') { 2709 currentTask.callback = null; 2710 currentPriorityLevel = currentTask.priorityLevel; 2711 var didUserCallbackTimeout = currentTask.expirationTime <= currentTime; 2712 2713 var continuationCallback = callback(didUserCallbackTimeout); 2714 currentTime = getCurrentTime(); 2715 2716 if (typeof continuationCallback === 'function') { 2717 currentTask.callback = continuationCallback; 2718 } else { 2719 2720 if (currentTask === peek(taskQueue)) { 2721 pop(taskQueue); 2722 } 2723 } 2724 2725 advanceTimers(currentTime); 2726 } else { 2727 pop(taskQueue); 2728 } 2729 2730 currentTask = peek(taskQueue); 2731 } // Return whether there's additional work 2732 2733 2734 if (currentTask !== null) { 2735 return true; 2736 } else { 2737 var firstTimer = peek(timerQueue); 2738 2739 if (firstTimer !== null) { 2740 requestHostTimeout(handleTimeout, firstTimer.startTime - currentTime); 2741 } 2742 2743 return false; 2744 } 2745 } 2746 2747 function unstable_runWithPriority(priorityLevel, eventHandler) { 2748 switch (priorityLevel) { 2749 case ImmediatePriority: 2750 case UserBlockingPriority: 2751 case NormalPriority: 2752 case LowPriority: 2753 case IdlePriority: 2754 break; 2755 2756 default: 2757 priorityLevel = NormalPriority; 2758 } 2759 2760 var previousPriorityLevel = currentPriorityLevel; 2761 currentPriorityLevel = priorityLevel; 2762 2763 try { 2764 return eventHandler(); 2765 } finally { 2766 currentPriorityLevel = previousPriorityLevel; 2767 } 2768 } 2769 2770 function unstable_next(eventHandler) { 2771 var priorityLevel; 2772 2773 switch (currentPriorityLevel) { 2774 case ImmediatePriority: 2775 case UserBlockingPriority: 2776 case NormalPriority: 2777 // Shift down to normal priority 2778 priorityLevel = NormalPriority; 2779 break; 2780 2781 default: 2782 // Anything lower than normal priority should remain at the current level. 2783 priorityLevel = currentPriorityLevel; 2784 break; 2785 } 2786 2787 var previousPriorityLevel = currentPriorityLevel; 2788 currentPriorityLevel = priorityLevel; 2789 2790 try { 2791 return eventHandler(); 2792 } finally { 2793 currentPriorityLevel = previousPriorityLevel; 2794 } 2795 } 2796 2797 function unstable_wrapCallback(callback) { 2798 var parentPriorityLevel = currentPriorityLevel; 2799 return function () { 2800 // This is a fork of runWithPriority, inlined for performance. 2801 var previousPriorityLevel = currentPriorityLevel; 2802 currentPriorityLevel = parentPriorityLevel; 2803 2804 try { 2805 return callback.apply(this, arguments); 2806 } finally { 2807 currentPriorityLevel = previousPriorityLevel; 2808 } 2809 }; 2810 } 2811 2812 function unstable_scheduleCallback(priorityLevel, callback, options) { 2813 var currentTime = getCurrentTime(); 2814 var startTime; 2815 2816 if (typeof options === 'object' && options !== null) { 2817 var delay = options.delay; 2818 2819 if (typeof delay === 'number' && delay > 0) { 2820 startTime = currentTime + delay; 2821 } else { 2822 startTime = currentTime; 2823 } 2824 } else { 2825 startTime = currentTime; 2826 } 2827 2828 var timeout; 2829 2830 switch (priorityLevel) { 2831 case ImmediatePriority: 2832 timeout = IMMEDIATE_PRIORITY_TIMEOUT; 2833 break; 2834 2835 case UserBlockingPriority: 2836 timeout = USER_BLOCKING_PRIORITY_TIMEOUT; 2837 break; 2838 2839 case IdlePriority: 2840 timeout = IDLE_PRIORITY_TIMEOUT; 2841 break; 2842 2843 case LowPriority: 2844 timeout = LOW_PRIORITY_TIMEOUT; 2845 break; 2846 2847 case NormalPriority: 2848 default: 2849 timeout = NORMAL_PRIORITY_TIMEOUT; 2850 break; 2851 } 2852 2853 var expirationTime = startTime + timeout; 2854 var newTask = { 2855 id: taskIdCounter++, 2856 callback: callback, 2857 priorityLevel: priorityLevel, 2858 startTime: startTime, 2859 expirationTime: expirationTime, 2860 sortIndex: -1 2861 }; 2862 2863 if (startTime > currentTime) { 2864 // This is a delayed task. 2865 newTask.sortIndex = startTime; 2866 push(timerQueue, newTask); 2867 2868 if (peek(taskQueue) === null && newTask === peek(timerQueue)) { 2869 // All tasks are delayed, and this is the task with the earliest delay. 2870 if (isHostTimeoutScheduled) { 2871 // Cancel an existing timeout. 2872 cancelHostTimeout(); 2873 } else { 2874 isHostTimeoutScheduled = true; 2875 } // Schedule a timeout. 2876 2877 2878 requestHostTimeout(handleTimeout, startTime - currentTime); 2879 } 2880 } else { 2881 newTask.sortIndex = expirationTime; 2882 push(taskQueue, newTask); 2883 // wait until the next time we yield. 2884 2885 2886 if (!isHostCallbackScheduled && !isPerformingWork) { 2887 isHostCallbackScheduled = true; 2888 requestHostCallback(flushWork); 2889 } 2890 } 2891 2892 return newTask; 2893 } 2894 2895 function unstable_pauseExecution() { 2896 } 2897 2898 function unstable_continueExecution() { 2899 2900 if (!isHostCallbackScheduled && !isPerformingWork) { 2901 isHostCallbackScheduled = true; 2902 requestHostCallback(flushWork); 2903 } 2904 } 2905 2906 function unstable_getFirstCallbackNode() { 2907 return peek(taskQueue); 2908 } 2909 2910 function unstable_cancelCallback(task) { 2911 // remove from the queue because you can't remove arbitrary nodes from an 2912 // array based heap, only the first one.) 2913 2914 2915 task.callback = null; 2916 } 2917 2918 function unstable_getCurrentPriorityLevel() { 2919 return currentPriorityLevel; 2920 } 2921 2922 var unstable_requestPaint = requestPaint; 2923 var unstable_Profiling = null; 2924 2925 2926 2927 var Scheduler = /*#__PURE__*/Object.freeze({ 2928 __proto__: null, 2929 unstable_ImmediatePriority: ImmediatePriority, 2930 unstable_UserBlockingPriority: UserBlockingPriority, 2931 unstable_NormalPriority: NormalPriority, 2932 unstable_IdlePriority: IdlePriority, 2933 unstable_LowPriority: LowPriority, 2934 unstable_runWithPriority: unstable_runWithPriority, 2935 unstable_next: unstable_next, 2936 unstable_scheduleCallback: unstable_scheduleCallback, 2937 unstable_cancelCallback: unstable_cancelCallback, 2938 unstable_wrapCallback: unstable_wrapCallback, 2939 unstable_getCurrentPriorityLevel: unstable_getCurrentPriorityLevel, 2940 get unstable_shouldYield () { return shouldYieldToHost; }, 2941 unstable_requestPaint: unstable_requestPaint, 2942 unstable_continueExecution: unstable_continueExecution, 2943 unstable_pauseExecution: unstable_pauseExecution, 2944 unstable_getFirstCallbackNode: unstable_getFirstCallbackNode, 2945 get unstable_now () { return getCurrentTime; }, 2946 get unstable_forceFrameRate () { return forceFrameRate; }, 2947 unstable_Profiling: unstable_Profiling 2948 }); 2949 2950 var DEFAULT_THREAD_ID = 0; // Counters used to generate unique IDs. 2951 2952 var interactionIDCounter = 0; 2953 var threadIDCounter = 0; // Set of currently traced interactions. 2954 // Interactions "stack"– 2955 // Meaning that newly traced interactions are appended to the previously active set. 2956 // When an interaction goes out of scope, the previous set (if any) is restored. 2957 2958 var interactionsRef = null; // Listener(s) to notify when interactions begin and end. 2959 2960 var subscriberRef = null; 2961 2962 { 2963 interactionsRef = { 2964 current: new Set() 2965 }; 2966 subscriberRef = { 2967 current: null 2968 }; 2969 } 2970 function unstable_clear(callback) { 2971 2972 var prevInteractions = interactionsRef.current; 2973 interactionsRef.current = new Set(); 2974 2975 try { 2976 return callback(); 2977 } finally { 2978 interactionsRef.current = prevInteractions; 2979 } 2980 } 2981 function unstable_getCurrent() { 2982 { 2983 return interactionsRef.current; 2984 } 2985 } 2986 function unstable_getThreadID() { 2987 return ++threadIDCounter; 2988 } 2989 function unstable_trace(name, timestamp, callback) { 2990 var threadID = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : DEFAULT_THREAD_ID; 2991 2992 var interaction = { 2993 __count: 1, 2994 id: interactionIDCounter++, 2995 name: name, 2996 timestamp: timestamp 2997 }; 2998 var prevInteractions = interactionsRef.current; // Traced interactions should stack/accumulate. 2999 // To do that, clone the current interactions. 3000 // The previous set will be restored upon completion. 3001 3002 var interactions = new Set(prevInteractions); 3003 interactions.add(interaction); 3004 interactionsRef.current = interactions; 3005 var subscriber = subscriberRef.current; 3006 var returnValue; 3007 3008 try { 3009 if (subscriber !== null) { 3010 subscriber.onInteractionTraced(interaction); 3011 } 3012 } finally { 3013 try { 3014 if (subscriber !== null) { 3015 subscriber.onWorkStarted(interactions, threadID); 3016 } 3017 } finally { 3018 try { 3019 returnValue = callback(); 3020 } finally { 3021 interactionsRef.current = prevInteractions; 3022 3023 try { 3024 if (subscriber !== null) { 3025 subscriber.onWorkStopped(interactions, threadID); 3026 } 3027 } finally { 3028 interaction.__count--; // If no async work was scheduled for this interaction, 3029 // Notify subscribers that it's completed. 3030 3031 if (subscriber !== null && interaction.__count === 0) { 3032 subscriber.onInteractionScheduledWorkCompleted(interaction); 3033 } 3034 } 3035 } 3036 } 3037 } 3038 3039 return returnValue; 3040 } 3041 function unstable_wrap(callback) { 3042 var threadID = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_THREAD_ID; 3043 3044 var wrappedInteractions = interactionsRef.current; 3045 var subscriber = subscriberRef.current; 3046 3047 if (subscriber !== null) { 3048 subscriber.onWorkScheduled(wrappedInteractions, threadID); 3049 } // Update the pending async work count for the current interactions. 3050 // Update after calling subscribers in case of error. 3051 3052 3053 wrappedInteractions.forEach(function (interaction) { 3054 interaction.__count++; 3055 }); 3056 var hasRun = false; 3057 3058 function wrapped() { 3059 var prevInteractions = interactionsRef.current; 3060 interactionsRef.current = wrappedInteractions; 3061 subscriber = subscriberRef.current; 3062 3063 try { 3064 var returnValue; 3065 3066 try { 3067 if (subscriber !== null) { 3068 subscriber.onWorkStarted(wrappedInteractions, threadID); 3069 } 3070 } finally { 3071 try { 3072 returnValue = callback.apply(undefined, arguments); 3073 } finally { 3074 interactionsRef.current = prevInteractions; 3075 3076 if (subscriber !== null) { 3077 subscriber.onWorkStopped(wrappedInteractions, threadID); 3078 } 3079 } 3080 } 3081 3082 return returnValue; 3083 } finally { 3084 if (!hasRun) { 3085 // We only expect a wrapped function to be executed once, 3086 // But in the event that it's executed more than once– 3087 // Only decrement the outstanding interaction counts once. 3088 hasRun = true; // Update pending async counts for all wrapped interactions. 3089 // If this was the last scheduled async work for any of them, 3090 // Mark them as completed. 3091 3092 wrappedInteractions.forEach(function (interaction) { 3093 interaction.__count--; 3094 3095 if (subscriber !== null && interaction.__count === 0) { 3096 subscriber.onInteractionScheduledWorkCompleted(interaction); 3097 } 3098 }); 3099 } 3100 } 3101 } 3102 3103 wrapped.cancel = function cancel() { 3104 subscriber = subscriberRef.current; 3105 3106 try { 3107 if (subscriber !== null) { 3108 subscriber.onWorkCanceled(wrappedInteractions, threadID); 3109 } 3110 } finally { 3111 // Update pending async counts for all wrapped interactions. 3112 // If this was the last scheduled async work for any of them, 3113 // Mark them as completed. 3114 wrappedInteractions.forEach(function (interaction) { 3115 interaction.__count--; 3116 3117 if (subscriber && interaction.__count === 0) { 3118 subscriber.onInteractionScheduledWorkCompleted(interaction); 3119 } 3120 }); 3121 } 3122 }; 3123 3124 return wrapped; 3125 } 3126 3127 var subscribers = null; 3128 3129 { 3130 subscribers = new Set(); 3131 } 3132 3133 function unstable_subscribe(subscriber) { 3134 { 3135 subscribers.add(subscriber); 3136 3137 if (subscribers.size === 1) { 3138 subscriberRef.current = { 3139 onInteractionScheduledWorkCompleted: onInteractionScheduledWorkCompleted, 3140 onInteractionTraced: onInteractionTraced, 3141 onWorkCanceled: onWorkCanceled, 3142 onWorkScheduled: onWorkScheduled, 3143 onWorkStarted: onWorkStarted, 3144 onWorkStopped: onWorkStopped 3145 }; 3146 } 3147 } 3148 } 3149 function unstable_unsubscribe(subscriber) { 3150 { 3151 subscribers.delete(subscriber); 3152 3153 if (subscribers.size === 0) { 3154 subscriberRef.current = null; 3155 } 3156 } 3157 } 3158 3159 function onInteractionTraced(interaction) { 3160 var didCatchError = false; 3161 var caughtError = null; 3162 subscribers.forEach(function (subscriber) { 3163 try { 3164 subscriber.onInteractionTraced(interaction); 3165 } catch (error) { 3166 if (!didCatchError) { 3167 didCatchError = true; 3168 caughtError = error; 3169 } 3170 } 3171 }); 3172 3173 if (didCatchError) { 3174 throw caughtError; 3175 } 3176 } 3177 3178 function onInteractionScheduledWorkCompleted(interaction) { 3179 var didCatchError = false; 3180 var caughtError = null; 3181 subscribers.forEach(function (subscriber) { 3182 try { 3183 subscriber.onInteractionScheduledWorkCompleted(interaction); 3184 } catch (error) { 3185 if (!didCatchError) { 3186 didCatchError = true; 3187 caughtError = error; 3188 } 3189 } 3190 }); 3191 3192 if (didCatchError) { 3193 throw caughtError; 3194 } 3195 } 3196 3197 function onWorkScheduled(interactions, threadID) { 3198 var didCatchError = false; 3199 var caughtError = null; 3200 subscribers.forEach(function (subscriber) { 3201 try { 3202 subscriber.onWorkScheduled(interactions, threadID); 3203 } catch (error) { 3204 if (!didCatchError) { 3205 didCatchError = true; 3206 caughtError = error; 3207 } 3208 } 3209 }); 3210 3211 if (didCatchError) { 3212 throw caughtError; 3213 } 3214 } 3215 3216 function onWorkStarted(interactions, threadID) { 3217 var didCatchError = false; 3218 var caughtError = null; 3219 subscribers.forEach(function (subscriber) { 3220 try { 3221 subscriber.onWorkStarted(interactions, threadID); 3222 } catch (error) { 3223 if (!didCatchError) { 3224 didCatchError = true; 3225 caughtError = error; 3226 } 3227 } 3228 }); 3229 3230 if (didCatchError) { 3231 throw caughtError; 3232 } 3233 } 3234 3235 function onWorkStopped(interactions, threadID) { 3236 var didCatchError = false; 3237 var caughtError = null; 3238 subscribers.forEach(function (subscriber) { 3239 try { 3240 subscriber.onWorkStopped(interactions, threadID); 3241 } catch (error) { 3242 if (!didCatchError) { 3243 didCatchError = true; 3244 caughtError = error; 3245 } 3246 } 3247 }); 3248 3249 if (didCatchError) { 3250 throw caughtError; 3251 } 3252 } 3253 3254 function onWorkCanceled(interactions, threadID) { 3255 var didCatchError = false; 3256 var caughtError = null; 3257 subscribers.forEach(function (subscriber) { 3258 try { 3259 subscriber.onWorkCanceled(interactions, threadID); 3260 } catch (error) { 3261 if (!didCatchError) { 3262 didCatchError = true; 3263 caughtError = error; 3264 } 3265 } 3266 }); 3267 3268 if (didCatchError) { 3269 throw caughtError; 3270 } 3271 } 3272 3273 3274 3275 var SchedulerTracing = /*#__PURE__*/Object.freeze({ 3276 __proto__: null, 3277 get __interactionsRef () { return interactionsRef; }, 3278 get __subscriberRef () { return subscriberRef; }, 3279 unstable_clear: unstable_clear, 3280 unstable_getCurrent: unstable_getCurrent, 3281 unstable_getThreadID: unstable_getThreadID, 3282 unstable_trace: unstable_trace, 3283 unstable_wrap: unstable_wrap, 3284 unstable_subscribe: unstable_subscribe, 3285 unstable_unsubscribe: unstable_unsubscribe 3286 }); 3287 3288 var ReactSharedInternals$1 = { 3289 ReactCurrentDispatcher: ReactCurrentDispatcher, 3290 ReactCurrentOwner: ReactCurrentOwner, 3291 IsSomeRendererActing: IsSomeRendererActing, 3292 ReactCurrentBatchConfig: ReactCurrentBatchConfig, 3293 // Used by renderers to avoid bundling object-assign twice in UMD bundles: 3294 assign: assign, 3295 // Re-export the schedule API(s) for UMD bundles. 3296 // This avoids introducing a dependency on a new UMD global in a minor update, 3297 // Since that would be a breaking change (e.g. for all existing CodeSandboxes). 3298 // This re-export is only required for UMD bundles; 3299 // CJS bundles use the shared NPM package. 3300 Scheduler: Scheduler, 3301 SchedulerTracing: SchedulerTracing 3302 }; 3303 3304 { 3305 ReactSharedInternals$1.ReactDebugCurrentFrame = ReactDebugCurrentFrame; 3306 } 3307 3308 { 3309 3310 try { 3311 var frozenObject = Object.freeze({}); 3312 /* eslint-disable no-new */ 3313 3314 new Map([[frozenObject, null]]); 3315 new Set([frozenObject]); 3316 /* eslint-enable no-new */ 3317 } catch (e) { 3318 } 3319 } 3320 3321 var createElement$1 = createElementWithValidation ; 3322 var cloneElement$1 = cloneElementWithValidation ; 3323 var createFactory = createFactoryWithValidation ; 3324 var Children = { 3325 map: mapChildren, 3326 forEach: forEachChildren, 3327 count: countChildren, 3328 toArray: toArray, 3329 only: onlyChild 3330 }; 3331 3332 exports.Children = Children; 3333 exports.Component = Component; 3334 exports.PureComponent = PureComponent; 3335 exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = ReactSharedInternals$1; 3336 exports.cloneElement = cloneElement$1; 3337 exports.createContext = createContext; 3338 exports.createElement = createElement$1; 3339 exports.createFactory = createFactory; 3340 exports.createRef = createRef; 3341 exports.forwardRef = forwardRef; 3342 exports.isValidElement = isValidElement; 3343 exports.lazy = lazy; 3344 exports.memo = memo; 3345 exports.useCallback = useCallback; 3346 exports.useContext = useContext; 3347 exports.useDebugValue = useDebugValue; 3348 exports.useEffect = useEffect; 3349 exports.useImperativeHandle = useImperativeHandle; 3350 exports.useLayoutEffect = useLayoutEffect; 3351 exports.useMemo = useMemo; 3352 exports.useReducer = useReducer; 3353 exports.useRef = useRef; 3354 exports.useState = useState; 3355 exports.version = ReactVersion; 3356 3357 })));
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Dec 25 01:00:02 2024 | Cross-referenced by PHPXref 0.7.1 |