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