vendor: 78 bytes, lines 1-3
1/******/ (() => { // webpackBootstrap 2/******/ var __webpack_modules__ = ({ 3
vendor: 895,407 bytes, lines 4-26271
4/***/ "./.yarn/__virtual__/react-dom-virtual-fc19a1cf20/0/cache/react-dom-npm-17.0.1-588d0088ca-baaeb735ad.zip/node_modules/react-dom/cjs/react-dom.development.js": 5/*!*******************************************************************************************************************************************************************!*\ 6 !*** ./.yarn/__virtual__/react-dom-virtual-fc19a1cf20/0/cache/react-dom-npm-17.0.1-588d0088ca-baaeb735ad.zip/node_modules/react-dom/cjs/react-dom.development.js ***! 7 \*******************************************************************************************************************************************************************/ 8/***/ ((__unused_webpack_module, exports, __webpack_require__) => { 9 10"use strict"; 11/** @license React v17.0.1 12 * react-dom.development.js 13 * 14 * Copyright (c) Facebook, Inc. and its affiliates. 15 * 16 * This source code is licensed under the MIT license found in the 17 * LICENSE file in the root directory of this source tree. 18 */ 19 20 21 22if (true) { 23 (function() { 24'use strict'; 25 26var React = __webpack_require__(/*! react */ "./.yarn/cache/react-npm-17.0.1-98658812fc-23ada2f8fe.zip/node_modules/react/index.js"); 27var _assign = __webpack_require__(/*! object-assign */ "./.yarn/cache/object-assign-npm-4.1.1-1004ad6dec-fcc6e4ea8c.zip/node_modules/object-assign/index.js"); 28var Scheduler = __webpack_require__(/*! scheduler */ "./.yarn/cache/scheduler-npm-0.20.2-90beaecfba-898917fa47.zip/node_modules/scheduler/index.js"); 29var tracing = __webpack_require__(/*! scheduler/tracing */ "./.yarn/cache/scheduler-npm-0.20.2-90beaecfba-898917fa47.zip/node_modules/scheduler/tracing.js"); 30 31var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; 32 33// by calls to these methods by a Babel plugin. 34// 35// In PROD (or in packages without access to React internals), 36// they are left as they are instead. 37 38function warn(format) { 39 { 40 for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { 41 args[_key - 1] = arguments[_key]; 42 } 43 44 printWarning('warn', format, args); 45 } 46} 47function error(format) { 48 { 49 for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { 50 args[_key2 - 1] = arguments[_key2]; 51 } 52 53 printWarning('error', format, args); 54 } 55} 56 57function printWarning(level, format, args) { 58 // When changing this logic, you might want to also 59 // update consoleWithStackDev.www.js as well. 60 { 61 var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; 62 var stack = ReactDebugCurrentFrame.getStackAddendum(); 63 64 if (stack !== '') { 65 format += '%s'; 66 args = args.concat([stack]); 67 } 68 69 var argsWithFormat = args.map(function (item) { 70 return '' + item; 71 }); // Careful: RN currently depends on this prefix 72 73 argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it 74 // breaks IE9: https://github.com/facebook/react/issues/13610 75 // eslint-disable-next-line react-internal/no-production-logging 76 77 Function.prototype.apply.call(console[level], console, argsWithFormat); 78 } 79} 80 81if (!React) { 82 { 83 throw Error( "ReactDOM was loaded before React. Make sure you load the React package before loading ReactDOM." ); 84 } 85} 86 87var FunctionComponent = 0; 88var ClassComponent = 1; 89var IndeterminateComponent = 2; // Before we know whether it is function or class 90 91var HostRoot = 3; // Root of a host tree. Could be nested inside another node. 92 93var HostPortal = 4; // A subtree. Could be an entry point to a different renderer. 94 95var HostComponent = 5; 96var HostText = 6; 97var Fragment = 7; 98var Mode = 8; 99var ContextConsumer = 9; 100var ContextProvider = 10; 101var ForwardRef = 11; 102var Profiler = 12; 103var SuspenseComponent = 13; 104var MemoComponent = 14; 105var SimpleMemoComponent = 15; 106var LazyComponent = 16; 107var IncompleteClassComponent = 17; 108var DehydratedFragment = 18; 109var SuspenseListComponent = 19; 110var FundamentalComponent = 20; 111var ScopeComponent = 21; 112var Block = 22; 113var OffscreenComponent = 23; 114var LegacyHiddenComponent = 24; 115 116// Filter certain DOM attributes (e.g. src, href) if their values are empty strings. 117 118var enableProfilerTimer = true; // Record durations for commit and passive effects phases. 119 120var enableFundamentalAPI = false; // Experimental Scope support. 121var enableNewReconciler = false; // Errors that are thrown while unmounting (or after in the case of passive effects) 122var warnAboutStringRefs = false; 123 124var allNativeEvents = new Set(); 125/** 126 * Mapping from registration name to event name 127 */ 128 129 130var registrationNameDependencies = {}; 131/** 132 * Mapping from lowercase registration names to the properly cased version, 133 * used to warn in the case of missing event handlers. Available 134 * only in true. 135 * @type {Object} 136 */ 137 138var possibleRegistrationNames = {} ; // Trust the developer to only use possibleRegistrationNames in true 139 140function registerTwoPhaseEvent(registrationName, dependencies) { 141 registerDirectEvent(registrationName, dependencies); 142 registerDirectEvent(registrationName + 'Capture', dependencies); 143} 144function registerDirectEvent(registrationName, dependencies) { 145 { 146 if (registrationNameDependencies[registrationName]) { 147 error('EventRegistry: More than one plugin attempted to publish the same ' + 'registration name, `%s`.', registrationName); 148 } 149 } 150 151 registrationNameDependencies[registrationName] = dependencies; 152 153 { 154 var lowerCasedName = registrationName.toLowerCase(); 155 possibleRegistrationNames[lowerCasedName] = registrationName; 156 157 if (registrationName === 'onDoubleClick') { 158 possibleRegistrationNames.ondblclick = registrationName; 159 } 160 } 161 162 for (var i = 0; i < dependencies.length; i++) { 163 allNativeEvents.add(dependencies[i]); 164 } 165} 166 167var canUseDOM = !!(typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined'); 168 169// A reserved attribute. 170// It is handled by React separately and shouldn't be written to the DOM. 171var RESERVED = 0; // A simple string attribute. 172// Attributes that aren't in the filter are presumed to have this type. 173 174var STRING = 1; // A string attribute that accepts booleans in React. In HTML, these are called 175// "enumerated" attributes with "true" and "false" as possible values. 176// When true, it should be set to a "true" string. 177// When false, it should be set to a "false" string. 178 179var BOOLEANISH_STRING = 2; // A real boolean attribute. 180// When true, it should be present (set either to an empty string or its name). 181// When false, it should be omitted. 182 183var BOOLEAN = 3; // An attribute that can be used as a flag as well as with a value. 184// When true, it should be present (set either to an empty string or its name). 185// When false, it should be omitted. 186// For any other value, should be present with that value. 187 188var OVERLOADED_BOOLEAN = 4; // An attribute that must be numeric or parse as a numeric. 189// When falsy, it should be removed. 190 191var NUMERIC = 5; // An attribute that must be positive numeric or parse as a positive numeric. 192// When falsy, it should be removed. 193 194var POSITIVE_NUMERIC = 6; 195 196/* eslint-disable max-len */ 197var ATTRIBUTE_NAME_START_CHAR = ":A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD"; 198/* eslint-enable max-len */ 199 200var ATTRIBUTE_NAME_CHAR = ATTRIBUTE_NAME_START_CHAR + "\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040"; 201var ROOT_ATTRIBUTE_NAME = 'data-reactroot'; 202var VALID_ATTRIBUTE_NAME_REGEX = new RegExp('^[' + ATTRIBUTE_NAME_START_CHAR + '][' + ATTRIBUTE_NAME_CHAR + ']*$'); 203var hasOwnProperty = Object.prototype.hasOwnProperty; 204var illegalAttributeNameCache = {}; 205var validatedAttributeNameCache = {}; 206function isAttributeNameSafe(attributeName) { 207 if (hasOwnProperty.call(validatedAttributeNameCache, attributeName)) { 208 return true; 209 } 210 211 if (hasOwnProperty.call(illegalAttributeNameCache, attributeName)) { 212 return false; 213 } 214 215 if (VALID_ATTRIBUTE_NAME_REGEX.test(attributeName)) { 216 validatedAttributeNameCache[attributeName] = true; 217 return true; 218 } 219 220 illegalAttributeNameCache[attributeName] = true; 221 222 { 223 error('Invalid attribute name: `%s`', attributeName); 224 } 225 226 return false; 227} 228function shouldIgnoreAttribute(name, propertyInfo, isCustomComponentTag) { 229 if (propertyInfo !== null) { 230 return propertyInfo.type === RESERVED; 231 } 232 233 if (isCustomComponentTag) { 234 return false; 235 } 236 237 if (name.length > 2 && (name[0] === 'o' || name[0] === 'O') && (name[1] === 'n' || name[1] === 'N')) { 238 return true; 239 } 240 241 return false; 242} 243function shouldRemoveAttributeWithWarning(name, value, propertyInfo, isCustomComponentTag) { 244 if (propertyInfo !== null && propertyInfo.type === RESERVED) { 245 return false; 246 } 247 248 switch (typeof value) { 249 case 'function': // $FlowIssue symbol is perfectly valid here 250 251 case 'symbol': 252 // eslint-disable-line 253 return true; 254 255 case 'boolean': 256 { 257 if (isCustomComponentTag) { 258 return false; 259 } 260 261 if (propertyInfo !== null) { 262 return !propertyInfo.acceptsBooleans; 263 } else { 264 var prefix = name.toLowerCase().slice(0, 5); 265 return prefix !== 'data-' && prefix !== 'aria-'; 266 } 267 } 268 269 default: 270 return false; 271 } 272} 273function shouldRemoveAttribute(name, value, propertyInfo, isCustomComponentTag) { 274 if (value === null || typeof value === 'undefined') { 275 return true; 276 } 277 278 if (shouldRemoveAttributeWithWarning(name, value, propertyInfo, isCustomComponentTag)) { 279 return true; 280 } 281 282 if (isCustomComponentTag) { 283 return false; 284 } 285 286 if (propertyInfo !== null) { 287 288 switch (propertyInfo.type) { 289 case BOOLEAN: 290 return !value; 291 292 case OVERLOADED_BOOLEAN: 293 return value === false; 294 295 case NUMERIC: 296 return isNaN(value); 297 298 case POSITIVE_NUMERIC: 299 return isNaN(value) || value < 1; 300 } 301 } 302 303 return false; 304} 305function getPropertyInfo(name) { 306 return properties.hasOwnProperty(name) ? properties[name] : null; 307} 308 309function PropertyInfoRecord(name, type, mustUseProperty, attributeName, attributeNamespace, sanitizeURL, removeEmptyString) { 310 this.acceptsBooleans = type === BOOLEANISH_STRING || type === BOOLEAN || type === OVERLOADED_BOOLEAN; 311 this.attributeName = attributeName; 312 this.attributeNamespace = attributeNamespace; 313 this.mustUseProperty = mustUseProperty; 314 this.propertyName = name; 315 this.type = type; 316 this.sanitizeURL = sanitizeURL; 317 this.removeEmptyString = removeEmptyString; 318} // When adding attributes to this list, be sure to also add them to 319// the `possibleStandardNames` module to ensure casing and incorrect 320// name warnings. 321 322 323var properties = {}; // These props are reserved by React. They shouldn't be written to the DOM. 324 325var reservedProps = ['children', 'dangerouslySetInnerHTML', // TODO: This prevents the assignment of defaultValue to regular 326// elements (not just inputs). Now that ReactDOMInput assigns to the 327// defaultValue property -- do we need this? 328'defaultValue', 'defaultChecked', 'innerHTML', 'suppressContentEditableWarning', 'suppressHydrationWarning', 'style']; 329reservedProps.forEach(function (name) { 330 properties[name] = new PropertyInfoRecord(name, RESERVED, false, // mustUseProperty 331 name, // attributeName 332 null, // attributeNamespace 333 false, // sanitizeURL 334 false); 335}); // A few React string attributes have a different name. 336// This is a mapping from React prop names to the attribute names. 337 338[['acceptCharset', 'accept-charset'], ['className', 'class'], ['htmlFor', 'for'], ['httpEquiv', 'http-equiv']].forEach(function (_ref) { 339 var name = _ref[0], 340 attributeName = _ref[1]; 341 properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty 342 attributeName, // attributeName 343 null, // attributeNamespace 344 false, // sanitizeURL 345 false); 346}); // These are "enumerated" HTML attributes that accept "true" and "false". 347// In React, we let users pass `true` and `false` even though technically 348// these aren't boolean attributes (they are coerced to strings). 349 350['contentEditable', 'draggable', 'spellCheck', 'value'].forEach(function (name) { 351 properties[name] = new PropertyInfoRecord(name, BOOLEANISH_STRING, false, // mustUseProperty 352 name.toLowerCase(), // attributeName 353 null, // attributeNamespace 354 false, // sanitizeURL 355 false); 356}); // These are "enumerated" SVG attributes that accept "true" and "false". 357// In React, we let users pass `true` and `false` even though technically 358// these aren't boolean attributes (they are coerced to strings). 359// Since these are SVG attributes, their attribute names are case-sensitive. 360 361['autoReverse', 'externalResourcesRequired', 'focusable', 'preserveAlpha'].forEach(function (name) { 362 properties[name] = new PropertyInfoRecord(name, BOOLEANISH_STRING, false, // mustUseProperty 363 name, // attributeName 364 null, // attributeNamespace 365 false, // sanitizeURL 366 false); 367}); // These are HTML boolean attributes. 368 369['allowFullScreen', 'async', // Note: there is a special case that prevents it from being written to the DOM 370// on the client side because the browsers are inconsistent. Instead we call focus(). 371'autoFocus', 'autoPlay', 'controls', 'default', 'defer', 'disabled', 'disablePictureInPicture', 'disableRemotePlayback', 'formNoValidate', 'hidden', 'loop', 'noModule', 'noValidate', 'open', 'playsInline', 'readOnly', 'required', 'reversed', 'scoped', 'seamless', // Microdata 372'itemScope'].forEach(function (name) { 373 properties[name] = new PropertyInfoRecord(name, BOOLEAN, false, // mustUseProperty 374 name.toLowerCase(), // attributeName 375 null, // attributeNamespace 376 false, // sanitizeURL 377 false); 378}); // These are the few React props that we set as DOM properties 379// rather than attributes. These are all booleans. 380 381['checked', // Note: `option.selected` is not updated if `select.multiple` is 382// disabled with `removeAttribute`. We have special logic for handling this. 383'multiple', 'muted', 'selected' // NOTE: if you add a camelCased prop to this list, 384// you'll need to set attributeName to name.toLowerCase() 385// instead in the assignment below. 386].forEach(function (name) { 387 properties[name] = new PropertyInfoRecord(name, BOOLEAN, true, // mustUseProperty 388 name, // attributeName 389 null, // attributeNamespace 390 false, // sanitizeURL 391 false); 392}); // These are HTML attributes that are "overloaded booleans": they behave like 393// booleans, but can also accept a string value. 394 395['capture', 'download' // NOTE: if you add a camelCased prop to this list, 396// you'll need to set attributeName to name.toLowerCase() 397// instead in the assignment below. 398].forEach(function (name) { 399 properties[name] = new PropertyInfoRecord(name, OVERLOADED_BOOLEAN, false, // mustUseProperty 400 name, // attributeName 401 null, // attributeNamespace 402 false, // sanitizeURL 403 false); 404}); // These are HTML attributes that must be positive numbers. 405 406['cols', 'rows', 'size', 'span' // NOTE: if you add a camelCased prop to this list, 407// you'll need to set attributeName to name.toLowerCase() 408// instead in the assignment below. 409].forEach(function (name) { 410 properties[name] = new PropertyInfoRecord(name, POSITIVE_NUMERIC, false, // mustUseProperty 411 name, // attributeName 412 null, // attributeNamespace 413 false, // sanitizeURL 414 false); 415}); // These are HTML attributes that must be numbers. 416 417['rowSpan', 'start'].forEach(function (name) { 418 properties[name] = new PropertyInfoRecord(name, NUMERIC, false, // mustUseProperty 419 name.toLowerCase(), // attributeName 420 null, // attributeNamespace 421 false, // sanitizeURL 422 false); 423}); 424var CAMELIZE = /[\-\:]([a-z])/g; 425 426var capitalize = function (token) { 427 return token[1].toUpperCase(); 428}; // This is a list of all SVG attributes that need special casing, namespacing, 429// or boolean value assignment. Regular attributes that just accept strings 430// and have the same names are omitted, just like in the HTML attribute filter. 431// Some of these attributes can be hard to find. This list was created by 432// scraping the MDN documentation. 433 434 435['accent-height', 'alignment-baseline', 'arabic-form', 'baseline-shift', 'cap-height', 'clip-path', 'clip-rule', 'color-interpolation', 'color-interpolation-filters', 'color-profile', 'color-rendering', 'dominant-baseline', 'enable-background', 'fill-opacity', 'fill-rule', 'flood-color', 'flood-opacity', 'font-family', 'font-size', 'font-size-adjust', 'font-stretch', 'font-style', 'font-variant', 'font-weight', 'glyph-name', 'glyph-orientation-horizontal', 'glyph-orientation-vertical', 'horiz-adv-x', 'horiz-origin-x', 'image-rendering', 'letter-spacing', 'lighting-color', 'marker-end', 'marker-mid', 'marker-start', 'overline-position', 'overline-thickness', 'paint-order', 'panose-1', 'pointer-events', 'rendering-intent', 'shape-rendering', 'stop-color', 'stop-opacity', 'strikethrough-position', 'strikethrough-thickness', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke-width', 'text-anchor', 'text-decoration', 'text-rendering', 'underline-position', 'underline-thickness', 'unicode-bidi', 'unicode-range', 'units-per-em', 'v-alphabetic', 'v-hanging', 'v-ideographic', 'v-mathematical', 'vector-effect', 'vert-adv-y', 'vert-origin-x', 'vert-origin-y', 'word-spacing', 'writing-mode', 'xmlns:xlink', 'x-height' // NOTE: if you add a camelCased prop to this list, 436// you'll need to set attributeName to name.toLowerCase() 437// instead in the assignment below. 438].forEach(function (attributeName) { 439 var name = attributeName.replace(CAMELIZE, capitalize); 440 properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty 441 attributeName, null, // attributeNamespace 442 false, // sanitizeURL 443 false); 444}); // String SVG attributes with the xlink namespace. 445 446['xlink:actuate', 'xlink:arcrole', 'xlink:role', 'xlink:show', 'xlink:title', 'xlink:type' // NOTE: if you add a camelCased prop to this list, 447// you'll need to set attributeName to name.toLowerCase() 448// instead in the assignment below. 449].forEach(function (attributeName) { 450 var name = attributeName.replace(CAMELIZE, capitalize); 451 properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty 452 attributeName, 'http://www.w3.org/1999/xlink', false, // sanitizeURL 453 false); 454}); // String SVG attributes with the xml namespace. 455 456['xml:base', 'xml:lang', 'xml:space' // NOTE: if you add a camelCased prop to this list, 457// you'll need to set attributeName to name.toLowerCase() 458// instead in the assignment below. 459].forEach(function (attributeName) { 460 var name = attributeName.replace(CAMELIZE, capitalize); 461 properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty 462 attributeName, 'http://www.w3.org/XML/1998/namespace', false, // sanitizeURL 463 false); 464}); // These attribute exists both in HTML and SVG. 465// The attribute name is case-sensitive in SVG so we can't just use 466// the React name like we do for attributes that exist only in HTML. 467 468['tabIndex', 'crossOrigin'].forEach(function (attributeName) { 469 properties[attributeName] = new PropertyInfoRecord(attributeName, STRING, false, // mustUseProperty 470 attributeName.toLowerCase(), // attributeName 471 null, // attributeNamespace 472 false, // sanitizeURL 473 false); 474}); // These attributes accept URLs. These must not allow javascript: URLS. 475// These will also need to accept Trusted Types object in the future. 476 477var xlinkHref = 'xlinkHref'; 478properties[xlinkHref] = new PropertyInfoRecord('xlinkHref', STRING, false, // mustUseProperty 479'xlink:href', 'http://www.w3.org/1999/xlink', true, // sanitizeURL 480false); 481['src', 'href', 'action', 'formAction'].forEach(function (attributeName) { 482 properties[attributeName] = new PropertyInfoRecord(attributeName, STRING, false, // mustUseProperty 483 attributeName.toLowerCase(), // attributeName 484 null, // attributeNamespace 485 true, // sanitizeURL 486 true); 487}); 488 489// and any newline or tab are filtered out as if they're not part of the URL. 490// https://url.spec.whatwg.org/#url-parsing 491// Tab or newline are defined as \r\n\t: 492// https://infra.spec.whatwg.org/#ascii-tab-or-newline 493// A C0 control is a code point in the range \u0000 NULL to \u001F 494// INFORMATION SEPARATOR ONE, inclusive: 495// https://infra.spec.whatwg.org/#c0-control-or-space 496 497/* eslint-disable max-len */ 498 499var isJavaScriptProtocol = /^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*\:/i; 500var didWarn = false; 501 502function sanitizeURL(url) { 503 { 504 if (!didWarn && isJavaScriptProtocol.test(url)) { 505 didWarn = true; 506 507 error('A future version of React will block javascript: URLs as a security precaution. ' + 'Use event handlers instead if you can. If you need to generate unsafe HTML try ' + 'using dangerouslySetInnerHTML instead. React was passed %s.', JSON.stringify(url)); 508 } 509 } 510} 511 512/** 513 * Get the value for a property on a node. Only used in DEV for SSR validation. 514 * The "expected" argument is used as a hint of what the expected value is. 515 * Some properties have multiple equivalent values. 516 */ 517function getValueForProperty(node, name, expected, propertyInfo) { 518 { 519 if (propertyInfo.mustUseProperty) { 520 var propertyName = propertyInfo.propertyName; 521 return node[propertyName]; 522 } else { 523 if ( propertyInfo.sanitizeURL) { 524 // If we haven't fully disabled javascript: URLs, and if 525 // the hydration is successful of a javascript: URL, we 526 // still want to warn on the client. 527 sanitizeURL('' + expected); 528 } 529 530 var attributeName = propertyInfo.attributeName; 531 var stringValue = null; 532 533 if (propertyInfo.type === OVERLOADED_BOOLEAN) { 534 if (node.hasAttribute(attributeName)) { 535 var value = node.getAttribute(attributeName); 536 537 if (value === '') { 538 return true; 539 } 540 541 if (shouldRemoveAttribute(name, expected, propertyInfo, false)) { 542 return value; 543 } 544 545 if (value === '' + expected) { 546 return expected; 547 } 548 549 return value; 550 } 551 } else if (node.hasAttribute(attributeName)) { 552 if (shouldRemoveAttribute(name, expected, propertyInfo, false)) { 553 // We had an attribute but shouldn't have had one, so read it 554 // for the error message. 555 return node.getAttribute(attributeName); 556 } 557 558 if (propertyInfo.type === BOOLEAN) { 559 // If this was a boolean, it doesn't matter what the value is 560 // the fact that we have it is the same as the expected. 561 return expected; 562 } // Even if this property uses a namespace we use getAttribute 563 // because we assume its namespaced name is the same as our config. 564 // To use getAttributeNS we need the local name which we don't have 565 // in our config atm. 566 567 568 stringValue = node.getAttribute(attributeName); 569 } 570 571 if (shouldRemoveAttribute(name, expected, propertyInfo, false)) { 572 return stringValue === null ? expected : stringValue; 573 } else if (stringValue === '' + expected) { 574 return expected; 575 } else { 576 return stringValue; 577 } 578 } 579 } 580} 581/** 582 * Get the value for a attribute on a node. Only used in DEV for SSR validation. 583 * The third argument is used as a hint of what the expected value is. Some 584 * attributes have multiple equivalent values. 585 */ 586 587function getValueForAttribute(node, name, expected) { 588 { 589 if (!isAttributeNameSafe(name)) { 590 return; 591 } // If the object is an opaque reference ID, it's expected that 592 // the next prop is different than the server value, so just return 593 // expected 594 595 596 if (isOpaqueHydratingObject(expected)) { 597 return expected; 598 } 599 600 if (!node.hasAttribute(name)) { 601 return expected === undefined ? undefined : null; 602 } 603 604 var value = node.getAttribute(name); 605 606 if (value === '' + expected) { 607 return expected; 608 } 609 610 return value; 611 } 612} 613/** 614 * Sets the value for a property on a node. 615 * 616 * @param {DOMElement} node 617 * @param {string} name 618 * @param {*} value 619 */ 620 621function setValueForProperty(node, name, value, isCustomComponentTag) { 622 var propertyInfo = getPropertyInfo(name); 623 624 if (shouldIgnoreAttribute(name, propertyInfo, isCustomComponentTag)) { 625 return; 626 } 627 628 if (shouldRemoveAttribute(name, value, propertyInfo, isCustomComponentTag)) { 629 value = null; 630 } // If the prop isn't in the special list, treat it as a simple attribute. 631 632 633 if (isCustomComponentTag || propertyInfo === null) { 634 if (isAttributeNameSafe(name)) { 635 var _attributeName = name; 636 637 if (value === null) { 638 node.removeAttribute(_attributeName); 639 } else { 640 node.setAttribute(_attributeName, '' + value); 641 } 642 } 643 644 return; 645 } 646 647 var mustUseProperty = propertyInfo.mustUseProperty; 648 649 if (mustUseProperty) { 650 var propertyName = propertyInfo.propertyName; 651 652 if (value === null) { 653 var type = propertyInfo.type; 654 node[propertyName] = type === BOOLEAN ? false : ''; 655 } else { 656 // Contrary to `setAttribute`, object properties are properly 657 // `toString`ed by IE8/9. 658 node[propertyName] = value; 659 } 660 661 return; 662 } // The rest are treated as attributes with special cases. 663 664 665 var attributeName = propertyInfo.attributeName, 666 attributeNamespace = propertyInfo.attributeNamespace; 667 668 if (value === null) { 669 node.removeAttribute(attributeName); 670 } else { 671 var _type = propertyInfo.type; 672 var attributeValue; 673 674 if (_type === BOOLEAN || _type === OVERLOADED_BOOLEAN && value === true) { 675 // If attribute type is boolean, we know for sure it won't be an execution sink 676 // and we won't require Trusted Type here. 677 attributeValue = ''; 678 } else { 679 // `setAttribute` with objects becomes only `[object]` in IE8/9, 680 // ('' + value) makes it output the correct toString()-value. 681 { 682 attributeValue = '' + value; 683 } 684 685 if (propertyInfo.sanitizeURL) { 686 sanitizeURL(attributeValue.toString()); 687 } 688 } 689 690 if (attributeNamespace) { 691 node.setAttributeNS(attributeNamespace, attributeName, attributeValue); 692 } else { 693 node.setAttribute(attributeName, attributeValue); 694 } 695 } 696} 697 698// ATTENTION 699// When adding new symbols to this file, 700// Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols' 701// The Symbol used to tag the ReactElement-like types. If there is no native Symbol 702// nor polyfill, then a plain number is used for performance. 703var REACT_ELEMENT_TYPE = 0xeac7; 704var REACT_PORTAL_TYPE = 0xeaca; 705var REACT_FRAGMENT_TYPE = 0xeacb; 706var REACT_STRICT_MODE_TYPE = 0xeacc; 707var REACT_PROFILER_TYPE = 0xead2; 708var REACT_PROVIDER_TYPE = 0xeacd; 709var REACT_CONTEXT_TYPE = 0xeace; 710var REACT_FORWARD_REF_TYPE = 0xead0; 711var REACT_SUSPENSE_TYPE = 0xead1; 712var REACT_SUSPENSE_LIST_TYPE = 0xead8; 713var REACT_MEMO_TYPE = 0xead3; 714var REACT_LAZY_TYPE = 0xead4; 715var REACT_BLOCK_TYPE = 0xead9; 716var REACT_SERVER_BLOCK_TYPE = 0xeada; 717var REACT_FUNDAMENTAL_TYPE = 0xead5; 718var REACT_SCOPE_TYPE = 0xead7; 719var REACT_OPAQUE_ID_TYPE = 0xeae0; 720var REACT_DEBUG_TRACING_MODE_TYPE = 0xeae1; 721var REACT_OFFSCREEN_TYPE = 0xeae2; 722var REACT_LEGACY_HIDDEN_TYPE = 0xeae3; 723 724if (typeof Symbol === 'function' && Symbol.for) { 725 var symbolFor = Symbol.for; 726 REACT_ELEMENT_TYPE = symbolFor('react.element'); 727 REACT_PORTAL_TYPE = symbolFor('react.portal'); 728 REACT_FRAGMENT_TYPE = symbolFor('react.fragment'); 729 REACT_STRICT_MODE_TYPE = symbolFor('react.strict_mode'); 730 REACT_PROFILER_TYPE = symbolFor('react.profiler'); 731 REACT_PROVIDER_TYPE = symbolFor('react.provider'); 732 REACT_CONTEXT_TYPE = symbolFor('react.context'); 733 REACT_FORWARD_REF_TYPE = symbolFor('react.forward_ref'); 734 REACT_SUSPENSE_TYPE = symbolFor('react.suspense'); 735 REACT_SUSPENSE_LIST_TYPE = symbolFor('react.suspense_list'); 736 REACT_MEMO_TYPE = symbolFor('react.memo'); 737 REACT_LAZY_TYPE = symbolFor('react.lazy'); 738 REACT_BLOCK_TYPE = symbolFor('react.block'); 739 REACT_SERVER_BLOCK_TYPE = symbolFor('react.server.block'); 740 REACT_FUNDAMENTAL_TYPE = symbolFor('react.fundamental'); 741 REACT_SCOPE_TYPE = symbolFor('react.scope'); 742 REACT_OPAQUE_ID_TYPE = symbolFor('react.opaque.id'); 743 REACT_DEBUG_TRACING_MODE_TYPE = symbolFor('react.debug_trace_mode'); 744 REACT_OFFSCREEN_TYPE = symbolFor('react.offscreen'); 745 REACT_LEGACY_HIDDEN_TYPE = symbolFor('react.legacy_hidden'); 746} 747 748var MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator; 749var FAUX_ITERATOR_SYMBOL = '@@iterator'; 750function getIteratorFn(maybeIterable) { 751 if (maybeIterable === null || typeof maybeIterable !== 'object') { 752 return null; 753 } 754 755 var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]; 756 757 if (typeof maybeIterator === 'function') { 758 return maybeIterator; 759 } 760 761 return null; 762} 763 764// Helpers to patch console.logs to avoid logging during side-effect free 765// replaying on render function. This currently only patches the object 766// lazily which won't cover if the log function was extracted eagerly. 767// We could also eagerly patch the method. 768var disabledDepth = 0; 769var prevLog; 770var prevInfo; 771var prevWarn; 772var prevError; 773var prevGroup; 774var prevGroupCollapsed; 775var prevGroupEnd; 776 777function disabledLog() {} 778 779disabledLog.__reactDisabledLog = true; 780function disableLogs() { 781 { 782 if (disabledDepth === 0) { 783 /* eslint-disable react-internal/no-production-logging */ 784 prevLog = console.log; 785 prevInfo = console.info; 786 prevWarn = console.warn; 787 prevError = console.error; 788 prevGroup = console.group; 789 prevGroupCollapsed = console.groupCollapsed; 790 prevGroupEnd = console.groupEnd; // https://github.com/facebook/react/issues/19099 791 792 var props = { 793 configurable: true, 794 enumerable: true, 795 value: disabledLog, 796 writable: true 797 }; // $FlowFixMe Flow thinks console is immutable. 798 799 Object.defineProperties(console, { 800 info: props, 801 log: props, 802 warn: props, 803 error: props, 804 group: props, 805 groupCollapsed: props, 806 groupEnd: props 807 }); 808 /* eslint-enable react-internal/no-production-logging */ 809 } 810 811 disabledDepth++; 812 } 813} 814function reenableLogs() { 815 { 816 disabledDepth--; 817 818 if (disabledDepth === 0) { 819 /* eslint-disable react-internal/no-production-logging */ 820 var props = { 821 configurable: true, 822 enumerable: true, 823 writable: true 824 }; // $FlowFixMe Flow thinks console is immutable. 825 826 Object.defineProperties(console, { 827 log: _assign({}, props, { 828 value: prevLog 829 }), 830 info: _assign({}, props, { 831 value: prevInfo 832 }), 833 warn: _assign({}, props, { 834 value: prevWarn 835 }), 836 error: _assign({}, props, { 837 value: prevError 838 }), 839 group: _assign({}, props, { 840 value: prevGroup 841 }), 842 groupCollapsed: _assign({}, props, { 843 value: prevGroupCollapsed 844 }), 845 groupEnd: _assign({}, props, { 846 value: prevGroupEnd 847 }) 848 }); 849 /* eslint-enable react-internal/no-production-logging */ 850 } 851 852 if (disabledDepth < 0) { 853 error('disabledDepth fell below zero. ' + 'This is a bug in React. Please file an issue.'); 854 } 855 } 856} 857 858var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher; 859var prefix; 860function describeBuiltInComponentFrame(name, source, ownerFn) { 861 { 862 if (prefix === undefined) { 863 // Extract the VM specific prefix used by each line. 864 try { 865 throw Error(); 866 } catch (x) { 867 var match = x.stack.trim().match(/\n( *(at )?)/); 868 prefix = match && match[1] || ''; 869 } 870 } // We use the prefix to ensure our stacks line up with native stack frames. 871 872 873 return '\n' + prefix + name; 874 } 875} 876var reentry = false; 877var componentFrameCache; 878 879{ 880 var PossiblyWeakMap = typeof WeakMap === 'function' ? WeakMap : Map; 881 componentFrameCache = new PossiblyWeakMap(); 882} 883 884function describeNativeComponentFrame(fn, construct) { 885 // If something asked for a stack inside a fake render, it should get ignored. 886 if (!fn || reentry) { 887 return ''; 888 } 889 890 { 891 var frame = componentFrameCache.get(fn); 892 893 if (frame !== undefined) { 894 return frame; 895 } 896 } 897 898 var control; 899 reentry = true; 900 var previousPrepareStackTrace = Error.prepareStackTrace; // $FlowFixMe It does accept undefined. 901 902 Error.prepareStackTrace = undefined; 903 var previousDispatcher; 904 905 { 906 previousDispatcher = ReactCurrentDispatcher.current; // Set the dispatcher in DEV because this might be call in the render function 907 // for warnings. 908 909 ReactCurrentDispatcher.current = null; 910 disableLogs(); 911 } 912 913 try { 914 // This should throw. 915 if (construct) { 916 // Something should be setting the props in the constructor. 917 var Fake = function () { 918 throw Error(); 919 }; // $FlowFixMe 920 921 922 Object.defineProperty(Fake.prototype, 'props', { 923 set: function () { 924 // We use a throwing setter instead of frozen or non-writable props 925 // because that won't throw in a non-strict mode function. 926 throw Error(); 927 } 928 }); 929 930 if (typeof Reflect === 'object' && Reflect.construct) { 931 // We construct a different control for this case to include any extra 932 // frames added by the construct call. 933 try { 934 Reflect.construct(Fake, []); 935 } catch (x) { 936 control = x; 937 } 938 939 Reflect.construct(fn, [], Fake); 940 } else { 941 try { 942 Fake.call(); 943 } catch (x) { 944 control = x; 945 } 946 947 fn.call(Fake.prototype); 948 } 949 } else { 950 try { 951 throw Error(); 952 } catch (x) { 953 control = x; 954 } 955 956 fn(); 957 } 958 } catch (sample) { 959 // This is inlined manually because closure doesn't do it for us. 960 if (sample && control && typeof sample.stack === 'string') { 961 // This extracts the first frame from the sample that isn't also in the control. 962 // Skipping one frame that we assume is the frame that calls the two. 963 var sampleLines = sample.stack.split('\n'); 964 var controlLines = control.stack.split('\n'); 965 var s = sampleLines.length - 1; 966 var c = controlLines.length - 1; 967 968 while (s >= 1 && c >= 0 && sampleLines[s] !== controlLines[c]) { 969 // We expect at least one stack frame to be shared. 970 // Typically this will be the root most one. However, stack frames may be 971 // cut off due to maximum stack limits. In this case, one maybe cut off 972 // earlier than the other. We assume that the sample is longer or the same 973 // and there for cut off earlier. So we should find the root most frame in 974 // the sample somewhere in the control. 975 c--; 976 } 977 978 for (; s >= 1 && c >= 0; s--, c--) { 979 // Next we find the first one that isn't the same which should be the 980 // frame that called our sample function and the control. 981 if (sampleLines[s] !== controlLines[c]) { 982 // In V8, the first line is describing the message but other VMs don't. 983 // If we're about to return the first line, and the control is also on the same 984 // line, that's a pretty good indicator that our sample threw at same line as 985 // the control. I.e. before we entered the sample frame. So we ignore this result. 986 // This can happen if you passed a class to function component, or non-function. 987 if (s !== 1 || c !== 1) { 988 do { 989 s--; 990 c--; // We may still have similar intermediate frames from the construct call. 991 // The next one that isn't the same should be our match though. 992 993 if (c < 0 || sampleLines[s] !== controlLines[c]) { 994 // V8 adds a "new" prefix for native classes. Let's remove it to make it prettier. 995 var _frame = '\n' + sampleLines[s].replace(' at new ', ' at '); 996 997 { 998 if (typeof fn === 'function') { 999 componentFrameCache.set(fn, _frame); 1000 } 1001 } // Return the line we found. 1002 1003 1004 return _frame; 1005 } 1006 } while (s >= 1 && c >= 0); 1007 } 1008 1009 break; 1010 } 1011 } 1012 } 1013 } finally { 1014 reentry = false; 1015 1016 { 1017 ReactCurrentDispatcher.current = previousDispatcher; 1018 reenableLogs(); 1019 } 1020 1021 Error.prepareStackTrace = previousPrepareStackTrace; 1022 } // Fallback to just using the name if we couldn't make it throw. 1023 1024 1025 var name = fn ? fn.displayName || fn.name : ''; 1026 var syntheticFrame = name ? describeBuiltInComponentFrame(name) : ''; 1027 1028 { 1029 if (typeof fn === 'function') { 1030 componentFrameCache.set(fn, syntheticFrame); 1031 } 1032 } 1033 1034 return syntheticFrame; 1035} 1036 1037function describeClassComponentFrame(ctor, source, ownerFn) { 1038 { 1039 return describeNativeComponentFrame(ctor, true); 1040 } 1041} 1042function describeFunctionComponentFrame(fn, source, ownerFn) { 1043 { 1044 return describeNativeComponentFrame(fn, false); 1045 } 1046} 1047 1048function shouldConstruct(Component) { 1049 var prototype = Component.prototype; 1050 return !!(prototype && prototype.isReactComponent); 1051} 1052 1053function describeUnknownElementTypeFrameInDEV(type, source, ownerFn) { 1054 1055 if (type == null) { 1056 return ''; 1057 } 1058 1059 if (typeof type === 'function') { 1060 { 1061 return describeNativeComponentFrame(type, shouldConstruct(type)); 1062 } 1063 } 1064 1065 if (typeof type === 'string') { 1066 return describeBuiltInComponentFrame(type); 1067 } 1068 1069 switch (type) { 1070 case REACT_SUSPENSE_TYPE: 1071 return describeBuiltInComponentFrame('Suspense'); 1072 1073 case REACT_SUSPENSE_LIST_TYPE: 1074 return describeBuiltInComponentFrame('SuspenseList'); 1075 } 1076 1077 if (typeof type === 'object') { 1078 switch (type.$$typeof) { 1079 case REACT_FORWARD_REF_TYPE: 1080 return describeFunctionComponentFrame(type.render); 1081 1082 case REACT_MEMO_TYPE: 1083 // Memo may contain any component type so we recursively resolve it. 1084 return describeUnknownElementTypeFrameInDEV(type.type, source, ownerFn); 1085 1086 case REACT_BLOCK_TYPE: 1087 return describeFunctionComponentFrame(type._render); 1088 1089 case REACT_LAZY_TYPE: 1090 { 1091 var lazyComponent = type; 1092 var payload = lazyComponent._payload; 1093 var init = lazyComponent._init; 1094 1095 try { 1096 // Lazy may contain any component type so we recursively resolve it. 1097 return describeUnknownElementTypeFrameInDEV(init(payload), source, ownerFn); 1098 } catch (x) {} 1099 } 1100 } 1101 } 1102 1103 return ''; 1104} 1105 1106function describeFiber(fiber) { 1107 var owner = fiber._debugOwner ? fiber._debugOwner.type : null ; 1108 var source = fiber._debugSource ; 1109 1110 switch (fiber.tag) { 1111 case HostComponent: 1112 return describeBuiltInComponentFrame(fiber.type); 1113 1114 case LazyComponent: 1115 return describeBuiltInComponentFrame('Lazy'); 1116 1117 case SuspenseComponent: 1118 return describeBuiltInComponentFrame('Suspense'); 1119 1120 case SuspenseListComponent: 1121 return describeBuiltInComponentFrame('SuspenseList'); 1122 1123 case FunctionComponent: 1124 case IndeterminateComponent: 1125 case SimpleMemoComponent: 1126 return describeFunctionComponentFrame(fiber.type); 1127 1128 case ForwardRef: 1129 return describeFunctionComponentFrame(fiber.type.render); 1130 1131 case Block: 1132 return describeFunctionComponentFrame(fiber.type._render); 1133 1134 case ClassComponent: 1135 return describeClassComponentFrame(fiber.type); 1136 1137 default: 1138 return ''; 1139 } 1140} 1141 1142function getStackByFiberInDevAndProd(workInProgress) { 1143 try { 1144 var info = ''; 1145 var node = workInProgress; 1146 1147 do { 1148 info += describeFiber(node); 1149 node = node.return; 1150 } while (node); 1151 1152 return info; 1153 } catch (x) { 1154 return '\nError generating stack: ' + x.message + '\n' + x.stack; 1155 } 1156} 1157 1158function getWrappedName(outerType, innerType, wrapperName) { 1159 var functionName = innerType.displayName || innerType.name || ''; 1160 return outerType.displayName || (functionName !== '' ? wrapperName + "(" + functionName + ")" : wrapperName); 1161} 1162 1163function getContextName(type) { 1164 return type.displayName || 'Context'; 1165} 1166 1167function getComponentName(type) { 1168 if (type == null) { 1169 // Host root, text node or just invalid type. 1170 return null; 1171 } 1172 1173 { 1174 if (typeof type.tag === 'number') { 1175 error('Received an unexpected object in getComponentName(). ' + 'This is likely a bug in React. Please file an issue.'); 1176 } 1177 } 1178 1179 if (typeof type === 'function') { 1180 return type.displayName || type.name || null; 1181 } 1182 1183 if (typeof type === 'string') { 1184 return type; 1185 } 1186 1187 switch (type) { 1188 case REACT_FRAGMENT_TYPE: 1189 return 'Fragment'; 1190 1191 case REACT_PORTAL_TYPE: 1192 return 'Portal'; 1193 1194 case REACT_PROFILER_TYPE: 1195 return 'Profiler'; 1196 1197 case REACT_STRICT_MODE_TYPE: 1198 return 'StrictMode'; 1199 1200 case REACT_SUSPENSE_TYPE: 1201 return 'Suspense'; 1202 1203 case REACT_SUSPENSE_LIST_TYPE: 1204 return 'SuspenseList'; 1205 } 1206 1207 if (typeof type === 'object') { 1208 switch (type.$$typeof) { 1209 case REACT_CONTEXT_TYPE: 1210 var context = type; 1211 return getContextName(context) + '.Consumer'; 1212 1213 case REACT_PROVIDER_TYPE: 1214 var provider = type; 1215 return getContextName(provider._context) + '.Provider'; 1216 1217 case REACT_FORWARD_REF_TYPE: 1218 return getWrappedName(type, type.render, 'ForwardRef'); 1219 1220 case REACT_MEMO_TYPE: 1221 return getComponentName(type.type); 1222 1223 case REACT_BLOCK_TYPE: 1224 return getComponentName(type._render); 1225 1226 case REACT_LAZY_TYPE: 1227 { 1228 var lazyComponent = type; 1229 var payload = lazyComponent._payload; 1230 var init = lazyComponent._init; 1231 1232 try { 1233 return getComponentName(init(payload)); 1234 } catch (x) { 1235 return null; 1236 } 1237 } 1238 } 1239 } 1240 1241 return null; 1242} 1243 1244var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; 1245var current = null; 1246var isRendering = false; 1247function getCurrentFiberOwnerNameInDevOrNull() { 1248 { 1249 if (current === null) { 1250 return null; 1251 } 1252 1253 var owner = current._debugOwner; 1254 1255 if (owner !== null && typeof owner !== 'undefined') { 1256 return getComponentName(owner.type); 1257 } 1258 } 1259 1260 return null; 1261} 1262 1263function getCurrentFiberStackInDev() { 1264 { 1265 if (current === null) { 1266 return ''; 1267 } // Safe because if current fiber exists, we are reconciling, 1268 // and it is guaranteed to be the work-in-progress version. 1269 1270 1271 return getStackByFiberInDevAndProd(current); 1272 } 1273} 1274 1275function resetCurrentFiber() { 1276 { 1277 ReactDebugCurrentFrame.getCurrentStack = null; 1278 current = null; 1279 isRendering = false; 1280 } 1281} 1282function setCurrentFiber(fiber) { 1283 { 1284 ReactDebugCurrentFrame.getCurrentStack = getCurrentFiberStackInDev; 1285 current = fiber; 1286 isRendering = false; 1287 } 1288} 1289function setIsRendering(rendering) { 1290 { 1291 isRendering = rendering; 1292 } 1293} 1294function getIsRendering() { 1295 { 1296 return isRendering; 1297 } 1298} 1299 1300// Flow does not allow string concatenation of most non-string types. To work 1301// around this limitation, we use an opaque type that can only be obtained by 1302// passing the value through getToStringValue first. 1303function toString(value) { 1304 return '' + value; 1305} 1306function getToStringValue(value) { 1307 switch (typeof value) { 1308 case 'boolean': 1309 case 'number': 1310 case 'object': 1311 case 'string': 1312 case 'undefined': 1313 return value; 1314 1315 default: 1316 // function, symbol are assigned as empty strings 1317 return ''; 1318 } 1319} 1320 1321var hasReadOnlyValue = { 1322 button: true, 1323 checkbox: true, 1324 image: true, 1325 hidden: true, 1326 radio: true, 1327 reset: true, 1328 submit: true 1329}; 1330function checkControlledValueProps(tagName, props) { 1331 { 1332 if (!(hasReadOnlyValue[props.type] || props.onChange || props.onInput || props.readOnly || props.disabled || props.value == null)) { 1333 error('You provided a `value` prop to a form field without an ' + '`onChange` handler. This will render a read-only field. If ' + 'the field should be mutable use `defaultValue`. Otherwise, ' + 'set either `onChange` or `readOnly`.'); 1334 } 1335 1336 if (!(props.onChange || props.readOnly || props.disabled || props.checked == null)) { 1337 error('You provided a `checked` prop to a form field without an ' + '`onChange` handler. This will render a read-only field. If ' + 'the field should be mutable use `defaultChecked`. Otherwise, ' + 'set either `onChange` or `readOnly`.'); 1338 } 1339 } 1340} 1341 1342function isCheckable(elem) { 1343 var type = elem.type; 1344 var nodeName = elem.nodeName; 1345 return nodeName && nodeName.toLowerCase() === 'input' && (type === 'checkbox' || type === 'radio'); 1346} 1347 1348function getTracker(node) { 1349 return node._valueTracker; 1350} 1351 1352function detachTracker(node) { 1353 node._valueTracker = null; 1354} 1355 1356function getValueFromNode(node) { 1357 var value = ''; 1358 1359 if (!node) { 1360 return value; 1361 } 1362 1363 if (isCheckable(node)) { 1364 value = node.checked ? 'true' : 'false'; 1365 } else { 1366 value = node.value; 1367 } 1368 1369 return value; 1370} 1371 1372function trackValueOnNode(node) { 1373 var valueField = isCheckable(node) ? 'checked' : 'value'; 1374 var descriptor = Object.getOwnPropertyDescriptor(node.constructor.prototype, valueField); 1375 var currentValue = '' + node[valueField]; // if someone has already defined a value or Safari, then bail 1376 // and don't track value will cause over reporting of changes, 1377 // but it's better then a hard failure 1378 // (needed for certain tests that spyOn input values and Safari) 1379 1380 if (node.hasOwnProperty(valueField) || typeof descriptor === 'undefined' || typeof descriptor.get !== 'function' || typeof descriptor.set !== 'function') { 1381 return; 1382 } 1383 1384 var get = descriptor.get, 1385 set = descriptor.set; 1386 Object.defineProperty(node, valueField, { 1387 configurable: true, 1388 get: function () { 1389 return get.call(this); 1390 }, 1391 set: function (value) { 1392 currentValue = '' + value; 1393 set.call(this, value); 1394 } 1395 }); // We could've passed this the first time 1396 // but it triggers a bug in IE11 and Edge 14/15. 1397 // Calling defineProperty() again should be equivalent. 1398 // https://github.com/facebook/react/issues/11768 1399 1400 Object.defineProperty(node, valueField, { 1401 enumerable: descriptor.enumerable 1402 }); 1403 var tracker = { 1404 getValue: function () { 1405 return currentValue; 1406 }, 1407 setValue: function (value) { 1408 currentValue = '' + value; 1409 }, 1410 stopTracking: function () { 1411 detachTracker(node); 1412 delete node[valueField]; 1413 } 1414 }; 1415 return tracker; 1416} 1417 1418function track(node) { 1419 if (getTracker(node)) { 1420 return; 1421 } // TODO: Once it's just Fiber we can move this to node._wrapperState 1422 1423 1424 node._valueTracker = trackValueOnNode(node); 1425} 1426function updateValueIfChanged(node) { 1427 if (!node) { 1428 return false; 1429 } 1430 1431 var tracker = getTracker(node); // if there is no tracker at this point it's unlikely 1432 // that trying again will succeed 1433 1434 if (!tracker) { 1435 return true; 1436 } 1437 1438 var lastValue = tracker.getValue(); 1439 var nextValue = getValueFromNode(node); 1440 1441 if (nextValue !== lastValue) { 1442 tracker.setValue(nextValue); 1443 return true; 1444 } 1445 1446 return false; 1447} 1448 1449function getActiveElement(doc) { 1450 doc = doc || (typeof document !== 'undefined' ? document : undefined); 1451 1452 if (typeof doc === 'undefined') { 1453 return null; 1454 } 1455 1456 try { 1457 return doc.activeElement || doc.body; 1458 } catch (e) { 1459 return doc.body; 1460 } 1461} 1462 1463var didWarnValueDefaultValue = false; 1464var didWarnCheckedDefaultChecked = false; 1465var didWarnControlledToUncontrolled = false; 1466var didWarnUncontrolledToControlled = false; 1467 1468function isControlled(props) { 1469 var usesChecked = props.type === 'checkbox' || props.type === 'radio'; 1470 return usesChecked ? props.checked != null : props.value != null; 1471} 1472/** 1473 * Implements an <input> host component that allows setting these optional 1474 * props: `checked`, `value`, `defaultChecked`, and `defaultValue`. 1475 * 1476 * If `checked` or `value` are not supplied (or null/undefined), user actions 1477 * that affect the checked state or value will trigger updates to the element. 1478 * 1479 * If they are supplied (and not null/undefined), the rendered element will not 1480 * trigger updates to the element. Instead, the props must change in order for 1481 * the rendered element to be updated. 1482 * 1483 * The rendered element will be initialized as unchecked (or `defaultChecked`) 1484 * with an empty value (or `defaultValue`). 1485 * 1486 * See http://www.w3.org/TR/2012/WD-html5-20121025/the-input-element.html 1487 */ 1488 1489 1490function getHostProps(element, props) { 1491 var node = element; 1492 var checked = props.checked; 1493 1494 var hostProps = _assign({}, props, { 1495 defaultChecked: undefined, 1496 defaultValue: undefined, 1497 value: undefined, 1498 checked: checked != null ? checked : node._wrapperState.initialChecked 1499 }); 1500 1501 return hostProps; 1502} 1503function initWrapperState(element, props) { 1504 { 1505 checkControlledValueProps('input', props); 1506 1507 if (props.checked !== undefined && props.defaultChecked !== undefined && !didWarnCheckedDefaultChecked) { 1508 error('%s contains an input of type %s with both checked and defaultChecked props. ' + 'Input elements must be either controlled or uncontrolled ' + '(specify either the checked prop, or the defaultChecked prop, but not ' + 'both). Decide between using a controlled or uncontrolled input ' + 'element and remove one of these props. More info: ' + 'https://reactjs.org/link/controlled-components', getCurrentFiberOwnerNameInDevOrNull() || 'A component', props.type); 1509 1510 didWarnCheckedDefaultChecked = true; 1511 } 1512 1513 if (props.value !== undefined && props.defaultValue !== undefined && !didWarnValueDefaultValue) { 1514 error('%s contains an input of type %s with both value and defaultValue props. ' + 'Input elements must be either controlled or uncontrolled ' + '(specify either the value prop, or the defaultValue prop, but not ' + 'both). Decide between using a controlled or uncontrolled input ' + 'element and remove one of these props. More info: ' + 'https://reactjs.org/link/controlled-components', getCurrentFiberOwnerNameInDevOrNull() || 'A component', props.type); 1515 1516 didWarnValueDefaultValue = true; 1517 } 1518 } 1519 1520 var node = element; 1521 var defaultValue = props.defaultValue == null ? '' : props.defaultValue; 1522 node._wrapperState = { 1523 initialChecked: props.checked != null ? props.checked : props.defaultChecked, 1524 initialValue: getToStringValue(props.value != null ? props.value : defaultValue), 1525 controlled: isControlled(props) 1526 }; 1527} 1528function updateChecked(element, props) { 1529 var node = element; 1530 var checked = props.checked; 1531 1532 if (checked != null) { 1533 setValueForProperty(node, 'checked', checked, false); 1534 } 1535} 1536function updateWrapper(element, props) { 1537 var node = element; 1538 1539 { 1540 var controlled = isControlled(props); 1541 1542 if (!node._wrapperState.controlled && controlled && !didWarnUncontrolledToControlled) { 1543 error('A component is changing an uncontrolled input to be controlled. ' + 'This is likely caused by the value changing from undefined to ' + 'a defined value, which should not happen. ' + 'Decide between using a controlled or uncontrolled input ' + 'element for the lifetime of the component. More info: https://reactjs.org/link/controlled-components'); 1544 1545 didWarnUncontrolledToControlled = true; 1546 } 1547 1548 if (node._wrapperState.controlled && !controlled && !didWarnControlledToUncontrolled) { 1549 error('A component is changing a controlled input to be uncontrolled. ' + 'This is likely caused by the value changing from a defined to ' + 'undefined, which should not happen. ' + 'Decide between using a controlled or uncontrolled input ' + 'element for the lifetime of the component. More info: https://reactjs.org/link/controlled-components'); 1550 1551 didWarnControlledToUncontrolled = true; 1552 } 1553 } 1554 1555 updateChecked(element, props); 1556 var value = getToStringValue(props.value); 1557 var type = props.type; 1558 1559 if (value != null) { 1560 if (type === 'number') { 1561 if (value === 0 && node.value === '' || // We explicitly want to coerce to number here if possible. 1562 // eslint-disable-next-line 1563 node.value != value) { 1564 node.value = toString(value); 1565 } 1566 } else if (node.value !== toString(value)) { 1567 node.value = toString(value); 1568 } 1569 } else if (type === 'submit' || type === 'reset') { 1570 // Submit/reset inputs need the attribute removed completely to avoid 1571 // blank-text buttons. 1572 node.removeAttribute('value'); 1573 return; 1574 } 1575 1576 { 1577 // When syncing the value attribute, the value comes from a cascade of 1578 // properties: 1579 // 1. The value React property 1580 // 2. The defaultValue React property 1581 // 3. Otherwise there should be no change 1582 if (props.hasOwnProperty('value')) { 1583 setDefaultValue(node, props.type, value); 1584 } else if (props.hasOwnProperty('defaultValue')) { 1585 setDefaultValue(node, props.type, getToStringValue(props.defaultValue)); 1586 } 1587 } 1588 1589 { 1590 // When syncing the checked attribute, it only changes when it needs 1591 // to be removed, such as transitioning from a checkbox into a text input 1592 if (props.checked == null && props.defaultChecked != null) { 1593 node.defaultChecked = !!props.defaultChecked; 1594 } 1595 } 1596} 1597function postMountWrapper(element, props, isHydrating) { 1598 var node = element; // Do not assign value if it is already set. This prevents user text input 1599 // from being lost during SSR hydration. 1600 1601 if (props.hasOwnProperty('value') || props.hasOwnProperty('defaultValue')) { 1602 var type = props.type; 1603 var isButton = type === 'submit' || type === 'reset'; // Avoid setting value attribute on submit/reset inputs as it overrides the 1604 // default value provided by the browser. See: #12872 1605 1606 if (isButton && (props.value === undefined || props.value === null)) { 1607 return; 1608 } 1609 1610 var initialValue = toString(node._wrapperState.initialValue); // Do not assign value if it is already set. This prevents user text input 1611 // from being lost during SSR hydration. 1612 1613 if (!isHydrating) { 1614 { 1615 // When syncing the value attribute, the value property should use 1616 // the wrapperState._initialValue property. This uses: 1617 // 1618 // 1. The value React property when present 1619 // 2. The defaultValue React property when present 1620 // 3. An empty string 1621 if (initialValue !== node.value) { 1622 node.value = initialValue; 1623 } 1624 } 1625 } 1626 1627 { 1628 // Otherwise, the value attribute is synchronized to the property, 1629 // so we assign defaultValue to the same thing as the value property 1630 // assignment step above. 1631 node.defaultValue = initialValue; 1632 } 1633 } // Normally, we'd just do `node.checked = node.checked` upon initial mount, less this bug 1634 // this is needed to work around a chrome bug where setting defaultChecked 1635 // will sometimes influence the value of checked (even after detachment). 1636 // Reference: https://bugs.chromium.org/p/chromium/issues/detail?id=608416 1637 // We need to temporarily unset name to avoid disrupting radio button groups. 1638 1639 1640 var name = node.name; 1641 1642 if (name !== '') { 1643 node.name = ''; 1644 } 1645 1646 { 1647 // When syncing the checked attribute, both the checked property and 1648 // attribute are assigned at the same time using defaultChecked. This uses: 1649 // 1650 // 1. The checked React property when present 1651 // 2. The defaultChecked React property when present 1652 // 3. Otherwise, false 1653 node.defaultChecked = !node.defaultChecked; 1654 node.defaultChecked = !!node._wrapperState.initialChecked; 1655 } 1656 1657 if (name !== '') { 1658 node.name = name; 1659 } 1660} 1661function restoreControlledState(element, props) { 1662 var node = element; 1663 updateWrapper(node, props); 1664 updateNamedCousins(node, props); 1665} 1666 1667function updateNamedCousins(rootNode, props) { 1668 var name = props.name; 1669 1670 if (props.type === 'radio' && name != null) { 1671 var queryRoot = rootNode; 1672 1673 while (queryRoot.parentNode) { 1674 queryRoot = queryRoot.parentNode; 1675 } // If `rootNode.form` was non-null, then we could try `form.elements`, 1676 // but that sometimes behaves strangely in IE8. We could also try using 1677 // `form.getElementsByName`, but that will only return direct children 1678 // and won't include inputs that use the HTML5 `form=` attribute. Since 1679 // the input might not even be in a form. It might not even be in the 1680 // document. Let's just use the local `querySelectorAll` to ensure we don't 1681 // miss anything. 1682 1683 1684 var group = queryRoot.querySelectorAll('input[name=' + JSON.stringify('' + name) + '][type="radio"]'); 1685 1686 for (var i = 0; i < group.length; i++) { 1687 var otherNode = group[i]; 1688 1689 if (otherNode === rootNode || otherNode.form !== rootNode.form) { 1690 continue; 1691 } // This will throw if radio buttons rendered by different copies of React 1692 // and the same name are rendered into the same form (same as #1939). 1693 // That's probably okay; we don't support it just as we don't support 1694 // mixing React radio buttons with non-React ones. 1695 1696 1697 var otherProps = getFiberCurrentPropsFromNode(otherNode); 1698 1699 if (!otherProps) { 1700 { 1701 throw Error( "ReactDOMInput: Mixing React and non-React radio inputs with the same `name` is not supported." ); 1702 } 1703 } // We need update the tracked value on the named cousin since the value 1704 // was changed but the input saw no event or value set 1705 1706 1707 updateValueIfChanged(otherNode); // If this is a controlled radio button group, forcing the input that 1708 // was previously checked to update will cause it to be come re-checked 1709 // as appropriate. 1710 1711 updateWrapper(otherNode, otherProps); 1712 } 1713 } 1714} // In Chrome, assigning defaultValue to certain input types triggers input validation. 1715// For number inputs, the display value loses trailing decimal points. For email inputs, 1716// Chrome raises "The specified value <x> is not a valid email address". 1717// 1718// Here we check to see if the defaultValue has actually changed, avoiding these problems 1719// when the user is inputting text 1720// 1721// https://github.com/facebook/react/issues/7253 1722 1723 1724function setDefaultValue(node, type, value) { 1725 if ( // Focused number inputs synchronize on blur. See ChangeEventPlugin.js 1726 type !== 'number' || getActiveElement(node.ownerDocument) !== node) { 1727 if (value == null) { 1728 node.defaultValue = toString(node._wrapperState.initialValue); 1729 } else if (node.defaultValue !== toString(value)) { 1730 node.defaultValue = toString(value); 1731 } 1732 } 1733} 1734 1735var didWarnSelectedSetOnOption = false; 1736var didWarnInvalidChild = false; 1737 1738function flattenChildren(children) { 1739 var content = ''; // Flatten children. We'll warn if they are invalid 1740 // during validateProps() which runs for hydration too. 1741 // Note that this would throw on non-element objects. 1742 // Elements are stringified (which is normally irrelevant 1743 // but matters for <fbt>). 1744 1745 React.Children.forEach(children, function (child) { 1746 if (child == null) { 1747 return; 1748 } 1749 1750 content += child; // Note: we don't warn about invalid children here. 1751 // Instead, this is done separately below so that 1752 // it happens during the hydration code path too. 1753 }); 1754 return content; 1755} 1756/** 1757 * Implements an <option> host component that warns when `selected` is set. 1758 */ 1759 1760 1761function validateProps(element, props) { 1762 { 1763 // This mirrors the code path above, but runs for hydration too. 1764 // Warn about invalid children here so that client and hydration are consistent. 1765 // TODO: this seems like it could cause a DEV-only throw for hydration 1766 // if children contains a non-element object. We should try to avoid that. 1767 if (typeof props.children === 'object' && props.children !== null) { 1768 React.Children.forEach(props.children, function (child) { 1769 if (child == null) { 1770 return; 1771 } 1772 1773 if (typeof child === 'string' || typeof child === 'number') { 1774 return; 1775 } 1776 1777 if (typeof child.type !== 'string') { 1778 return; 1779 } 1780 1781 if (!didWarnInvalidChild) { 1782 didWarnInvalidChild = true; 1783 1784 error('Only strings and numbers are supported as <option> children.'); 1785 } 1786 }); 1787 } // TODO: Remove support for `selected` in <option>. 1788 1789 1790 if (props.selected != null && !didWarnSelectedSetOnOption) { 1791 error('Use the `defaultValue` or `value` props on <select> instead of ' + 'setting `selected` on <option>.'); 1792 1793 didWarnSelectedSetOnOption = true; 1794 } 1795 } 1796} 1797function postMountWrapper$1(element, props) { 1798 // value="" should make a value attribute (#6219) 1799 if (props.value != null) { 1800 element.setAttribute('value', toString(getToStringValue(props.value))); 1801 } 1802} 1803function getHostProps$1(element, props) { 1804 var hostProps = _assign({ 1805 children: undefined 1806 }, props); 1807 1808 var content = flattenChildren(props.children); 1809 1810 if (content) { 1811 hostProps.children = content; 1812 } 1813 1814 return hostProps; 1815} 1816 1817var didWarnValueDefaultValue$1; 1818 1819{ 1820 didWarnValueDefaultValue$1 = false; 1821} 1822 1823function getDeclarationErrorAddendum() { 1824 var ownerName = getCurrentFiberOwnerNameInDevOrNull(); 1825 1826 if (ownerName) { 1827 return '\n\nCheck the render method of `' + ownerName + '`.'; 1828 } 1829 1830 return ''; 1831} 1832 1833var valuePropNames = ['value', 'defaultValue']; 1834/** 1835 * Validation function for `value` and `defaultValue`. 1836 */ 1837 1838function checkSelectPropTypes(props) { 1839 { 1840 checkControlledValueProps('select', props); 1841 1842 for (var i = 0; i < valuePropNames.length; i++) { 1843 var propName = valuePropNames[i]; 1844 1845 if (props[propName] == null) { 1846 continue; 1847 } 1848 1849 var isArray = Array.isArray(props[propName]); 1850 1851 if (props.multiple && !isArray) { 1852 error('The `%s` prop supplied to <select> must be an array if ' + '`multiple` is true.%s', propName, getDeclarationErrorAddendum()); 1853 } else if (!props.multiple && isArray) { 1854 error('The `%s` prop supplied to <select> must be a scalar ' + 'value if `multiple` is false.%s', propName, getDeclarationErrorAddendum()); 1855 } 1856 } 1857 } 1858} 1859 1860function updateOptions(node, multiple, propValue, setDefaultSelected) { 1861 var options = node.options; 1862 1863 if (multiple) { 1864 var selectedValues = propValue; 1865 var selectedValue = {}; 1866 1867 for (var i = 0; i < selectedValues.length; i++) { 1868 // Prefix to avoid chaos with special keys. 1869 selectedValue['$' + selectedValues[i]] = true; 1870 } 1871 1872 for (var _i = 0; _i < options.length; _i++) { 1873 var selected = selectedValue.hasOwnProperty('$' + options[_i].value); 1874 1875 if (options[_i].selected !== selected) { 1876 options[_i].selected = selected; 1877 } 1878 1879 if (selected && setDefaultSelected) { 1880 options[_i].defaultSelected = true; 1881 } 1882 } 1883 } else { 1884 // Do not set `select.value` as exact behavior isn't consistent across all 1885 // browsers for all cases. 1886 var _selectedValue = toString(getToStringValue(propValue)); 1887 1888 var defaultSelected = null; 1889 1890 for (var _i2 = 0; _i2 < options.length; _i2++) { 1891 if (options[_i2].value === _selectedValue) { 1892 options[_i2].selected = true; 1893 1894 if (setDefaultSelected) { 1895 options[_i2].defaultSelected = true; 1896 } 1897 1898 return; 1899 } 1900 1901 if (defaultSelected === null && !options[_i2].disabled) { 1902 defaultSelected = options[_i2]; 1903 } 1904 } 1905 1906 if (defaultSelected !== null) { 1907 defaultSelected.selected = true; 1908 } 1909 } 1910} 1911/** 1912 * Implements a <select> host component that allows optionally setting the 1913 * props `value` and `defaultValue`. If `multiple` is false, the prop must be a 1914 * stringable. If `multiple` is true, the prop must be an array of stringables. 1915 * 1916 * If `value` is not supplied (or null/undefined), user actions that change the 1917 * selected option will trigger updates to the rendered options. 1918 * 1919 * If it is supplied (and not null/undefined), the rendered options will not 1920 * update in response to user actions. Instead, the `value` prop must change in 1921 * order for the rendered options to update. 1922 * 1923 * If `defaultValue` is provided, any options with the supplied values will be 1924 * selected. 1925 */ 1926 1927 1928function getHostProps$2(element, props) { 1929 return _assign({}, props, { 1930 value: undefined 1931 }); 1932} 1933function initWrapperState$1(element, props) { 1934 var node = element; 1935 1936 { 1937 checkSelectPropTypes(props); 1938 } 1939 1940 node._wrapperState = { 1941 wasMultiple: !!props.multiple 1942 }; 1943 1944 { 1945 if (props.value !== undefined && props.defaultValue !== undefined && !didWarnValueDefaultValue$1) { 1946 error('Select elements must be either controlled or uncontrolled ' + '(specify either the value prop, or the defaultValue prop, but not ' + 'both). Decide between using a controlled or uncontrolled select ' + 'element and remove one of these props. More info: ' + 'https://reactjs.org/link/controlled-components'); 1947 1948 didWarnValueDefaultValue$1 = true; 1949 } 1950 } 1951} 1952function postMountWrapper$2(element, props) { 1953 var node = element; 1954 node.multiple = !!props.multiple; 1955 var value = props.value; 1956 1957 if (value != null) { 1958 updateOptions(node, !!props.multiple, value, false); 1959 } else if (props.defaultValue != null) { 1960 updateOptions(node, !!props.multiple, props.defaultValue, true); 1961 } 1962} 1963function postUpdateWrapper(element, props) { 1964 var node = element; 1965 var wasMultiple = node._wrapperState.wasMultiple; 1966 node._wrapperState.wasMultiple = !!props.multiple; 1967 var value = props.value; 1968 1969 if (value != null) { 1970 updateOptions(node, !!props.multiple, value, false); 1971 } else if (wasMultiple !== !!props.multiple) { 1972 // For simplicity, reapply `defaultValue` if `multiple` is toggled. 1973 if (props.defaultValue != null) { 1974 updateOptions(node, !!props.multiple, props.defaultValue, true); 1975 } else { 1976 // Revert the select back to its default unselected state. 1977 updateOptions(node, !!props.multiple, props.multiple ? [] : '', false); 1978 } 1979 } 1980} 1981function restoreControlledState$1(element, props) { 1982 var node = element; 1983 var value = props.value; 1984 1985 if (value != null) { 1986 updateOptions(node, !!props.multiple, value, false); 1987 } 1988} 1989 1990var didWarnValDefaultVal = false; 1991 1992/** 1993 * Implements a <textarea> host component that allows setting `value`, and 1994 * `defaultValue`. This differs from the traditional DOM API because value is 1995 * usually set as PCDATA children. 1996 * 1997 * If `value` is not supplied (or null/undefined), user actions that affect the 1998 * value will trigger updates to the element. 1999 * 2000 * If `value` is supplied (and not null/undefined), the rendered element will 2001 * not trigger updates to the element. Instead, the `value` prop must change in 2002 * order for the rendered element to be updated. 2003 * 2004 * The rendered element will be initialized with an empty value, the prop 2005 * `defaultValue` if specified, or the children content (deprecated). 2006 */ 2007function getHostProps$3(element, props) { 2008 var node = element; 2009 2010 if (!(props.dangerouslySetInnerHTML == null)) { 2011 { 2012 throw Error( "`dangerouslySetInnerHTML` does not make sense on <textarea>." ); 2013 } 2014 } // Always set children to the same thing. In IE9, the selection range will 2015 // get reset if `textContent` is mutated. We could add a check in setTextContent 2016 // to only set the value if/when the value differs from the node value (which would 2017 // completely solve this IE9 bug), but Sebastian+Sophie seemed to like this 2018 // solution. The value can be a boolean or object so that's why it's forced 2019 // to be a string. 2020 2021 2022 var hostProps = _assign({}, props, { 2023 value: undefined, 2024 defaultValue: undefined, 2025 children: toString(node._wrapperState.initialValue) 2026 }); 2027 2028 return hostProps; 2029} 2030function initWrapperState$2(element, props) { 2031 var node = element; 2032 2033 { 2034 checkControlledValueProps('textarea', props); 2035 2036 if (props.value !== undefined && props.defaultValue !== undefined && !didWarnValDefaultVal) { 2037 error('%s contains a textarea with both value and defaultValue props. ' + 'Textarea elements must be either controlled or uncontrolled ' + '(specify either the value prop, or the defaultValue prop, but not ' + 'both). Decide between using a controlled or uncontrolled textarea ' + 'and remove one of these props. More info: ' + 'https://reactjs.org/link/controlled-components', getCurrentFiberOwnerNameInDevOrNull() || 'A component'); 2038 2039 didWarnValDefaultVal = true; 2040 } 2041 } 2042 2043 var initialValue = props.value; // Only bother fetching default value if we're going to use it 2044 2045 if (initialValue == null) { 2046 var children = props.children, 2047 defaultValue = props.defaultValue; 2048 2049 if (children != null) { 2050 { 2051 error('Use the `defaultValue` or `value` props instead of setting ' + 'children on <textarea>.'); 2052 } 2053 2054 { 2055 if (!(defaultValue == null)) { 2056 { 2057 throw Error( "If you supply `defaultValue` on a <textarea>, do not pass children." ); 2058 } 2059 } 2060 2061 if (Array.isArray(children)) { 2062 if (!(children.length <= 1)) { 2063 { 2064 throw Error( "<textarea> can only have at most one child." ); 2065 } 2066 } 2067 2068 children = children[0]; 2069 } 2070 2071 defaultValue = children; 2072 } 2073 } 2074 2075 if (defaultValue == null) { 2076 defaultValue = ''; 2077 } 2078 2079 initialValue = defaultValue; 2080 } 2081 2082 node._wrapperState = { 2083 initialValue: getToStringValue(initialValue) 2084 }; 2085} 2086function updateWrapper$1(element, props) { 2087 var node = element; 2088 var value = getToStringValue(props.value); 2089 var defaultValue = getToStringValue(props.defaultValue); 2090 2091 if (value != null) { 2092 // Cast `value` to a string to ensure the value is set correctly. While 2093 // browsers typically do this as necessary, jsdom doesn't. 2094 var newValue = toString(value); // To avoid side effects (such as losing text selection), only set value if changed 2095 2096 if (newValue !== node.value) { 2097 node.value = newValue; 2098 } 2099 2100 if (props.defaultValue == null && node.defaultValue !== newValue) { 2101 node.defaultValue = newValue; 2102 } 2103 } 2104 2105 if (defaultValue != null) { 2106 node.defaultValue = toString(defaultValue); 2107 } 2108} 2109function postMountWrapper$3(element, props) { 2110 var node = element; // This is in postMount because we need access to the DOM node, which is not 2111 // available until after the component has mounted. 2112 2113 var textContent = node.textContent; // Only set node.value if textContent is equal to the expected 2114 // initial value. In IE10/IE11 there is a bug where the placeholder attribute 2115 // will populate textContent as well. 2116 // https://developer.microsoft.com/microsoft-edge/platform/issues/101525/ 2117 2118 if (textContent === node._wrapperState.initialValue) { 2119 if (textContent !== '' && textContent !== null) { 2120 node.value = textContent; 2121 } 2122 } 2123} 2124function restoreControlledState$2(element, props) { 2125 // DOM component is still mounted; update 2126 updateWrapper$1(element, props); 2127} 2128 2129var HTML_NAMESPACE = 'http://www.w3.org/1999/xhtml'; 2130var MATH_NAMESPACE = 'http://www.w3.org/1998/Math/MathML'; 2131var SVG_NAMESPACE = 'http://www.w3.org/2000/svg'; 2132var Namespaces = { 2133 html: HTML_NAMESPACE, 2134 mathml: MATH_NAMESPACE, 2135 svg: SVG_NAMESPACE 2136}; // Assumes there is no parent namespace. 2137 2138function getIntrinsicNamespace(type) { 2139 switch (type) { 2140 case 'svg': 2141 return SVG_NAMESPACE; 2142 2143 case 'math': 2144 return MATH_NAMESPACE; 2145 2146 default: 2147 return HTML_NAMESPACE; 2148 } 2149} 2150function getChildNamespace(parentNamespace, type) { 2151 if (parentNamespace == null || parentNamespace === HTML_NAMESPACE) { 2152 // No (or default) parent namespace: potential entry point. 2153 return getIntrinsicNamespace(type); 2154 } 2155 2156 if (parentNamespace === SVG_NAMESPACE && type === 'foreignObject') { 2157 // We're leaving SVG. 2158 return HTML_NAMESPACE; 2159 } // By default, pass namespace below. 2160 2161 2162 return parentNamespace; 2163} 2164 2165/* globals MSApp */ 2166 2167/** 2168 * Create a function which has 'unsafe' privileges (required by windows8 apps) 2169 */ 2170var createMicrosoftUnsafeLocalFunction = function (func) { 2171 if (typeof MSApp !== 'undefined' && MSApp.execUnsafeLocalFunction) { 2172 return function (arg0, arg1, arg2, arg3) { 2173 MSApp.execUnsafeLocalFunction(function () { 2174 return func(arg0, arg1, arg2, arg3); 2175 }); 2176 }; 2177 } else { 2178 return func; 2179 } 2180}; 2181 2182var reusableSVGContainer; 2183/** 2184 * Set the innerHTML property of a node 2185 * 2186 * @param {DOMElement} node 2187 * @param {string} html 2188 * @internal 2189 */ 2190 2191var setInnerHTML = createMicrosoftUnsafeLocalFunction(function (node, html) { 2192 if (node.namespaceURI === Namespaces.svg) { 2193 2194 if (!('innerHTML' in node)) { 2195 // IE does not have innerHTML for SVG nodes, so instead we inject the 2196 // new markup in a temp node and then move the child nodes across into 2197 // the target node 2198 reusableSVGContainer = reusableSVGContainer || document.createElement('div'); 2199 reusableSVGContainer.innerHTML = '<svg>' + html.valueOf().toString() + '</svg>'; 2200 var svgNode = reusableSVGContainer.firstChild; 2201 2202 while (node.firstChild) { 2203 node.removeChild(node.firstChild); 2204 } 2205 2206 while (svgNode.firstChild) { 2207 node.appendChild(svgNode.firstChild); 2208 } 2209 2210 return; 2211 } 2212 } 2213 2214 node.innerHTML = html; 2215}); 2216 2217/** 2218 * HTML nodeType values that represent the type of the node 2219 */ 2220var ELEMENT_NODE = 1; 2221var TEXT_NODE = 3; 2222var COMMENT_NODE = 8; 2223var DOCUMENT_NODE = 9; 2224var DOCUMENT_FRAGMENT_NODE = 11; 2225 2226/** 2227 * Set the textContent property of a node. For text updates, it's faster 2228 * to set the `nodeValue` of the Text node directly instead of using 2229 * `.textContent` which will remove the existing node and create a new one. 2230 * 2231 * @param {DOMElement} node 2232 * @param {string} text 2233 * @internal 2234 */ 2235 2236var setTextContent = function (node, text) { 2237 if (text) { 2238 var firstChild = node.firstChild; 2239 2240 if (firstChild && firstChild === node.lastChild && firstChild.nodeType === TEXT_NODE) { 2241 firstChild.nodeValue = text; 2242 return; 2243 } 2244 } 2245 2246 node.textContent = text; 2247}; 2248 2249// List derived from Gecko source code: 2250// https://github.com/mozilla/gecko-dev/blob/4e638efc71/layout/style/test/property_database.js 2251var shorthandToLonghand = { 2252 animation: ['animationDelay', 'animationDirection', 'animationDuration', 'animationFillMode', 'animationIterationCount', 'animationName', 'animationPlayState', 'animationTimingFunction'], 2253 background: ['backgroundAttachment', 'backgroundClip', 'backgroundColor', 'backgroundImage', 'backgroundOrigin', 'backgroundPositionX', 'backgroundPositionY', 'backgroundRepeat', 'backgroundSize'], 2254 backgroundPosition: ['backgroundPositionX', 'backgroundPositionY'], 2255 border: ['borderBottomColor', 'borderBottomStyle', 'borderBottomWidth', 'borderImageOutset', 'borderImageRepeat', 'borderImageSlice', 'borderImageSource', 'borderImageWidth', 'borderLeftColor', 'borderLeftStyle', 'borderLeftWidth', 'borderRightColor', 'borderRightStyle', 'borderRightWidth', 'borderTopColor', 'borderTopStyle', 'borderTopWidth'], 2256 borderBlockEnd: ['borderBlockEndColor', 'borderBlockEndStyle', 'borderBlockEndWidth'], 2257 borderBlockStart: ['borderBlockStartColor', 'borderBlockStartStyle', 'borderBlockStartWidth'], 2258 borderBottom: ['borderBottomColor', 'borderBottomStyle', 'borderBottomWidth'], 2259 borderColor: ['borderBottomColor', 'borderLeftColor', 'borderRightColor', 'borderTopColor'], 2260 borderImage: ['borderImageOutset', 'borderImageRepeat', 'borderImageSlice', 'borderImageSource', 'borderImageWidth'], 2261 borderInlineEnd: ['borderInlineEndColor', 'borderInlineEndStyle', 'borderInlineEndWidth'], 2262 borderInlineStart: ['borderInlineStartColor', 'borderInlineStartStyle', 'borderInlineStartWidth'], 2263 borderLeft: ['borderLeftColor', 'borderLeftStyle', 'borderLeftWidth'], 2264 borderRadius: ['borderBottomLeftRadius', 'borderBottomRightRadius', 'borderTopLeftRadius', 'borderTopRightRadius'], 2265 borderRight: ['borderRightColor', 'borderRightStyle', 'borderRightWidth'], 2266 borderStyle: ['borderBottomStyle', 'borderLeftStyle', 'borderRightStyle', 'borderTopStyle'], 2267 borderTop: ['borderTopColor', 'borderTopStyle', 'borderTopWidth'], 2268 borderWidth: ['borderBottomWidth', 'borderLeftWidth', 'borderRightWidth', 'borderTopWidth'], 2269 columnRule: ['columnRuleColor', 'columnRuleStyle', 'columnRuleWidth'], 2270 columns: ['columnCount', 'columnWidth'], 2271 flex: ['flexBasis', 'flexGrow', 'flexShrink'], 2272 flexFlow: ['flexDirection', 'flexWrap'], 2273 font: ['fontFamily', 'fontFeatureSettings', 'fontKerning', 'fontLanguageOverride', 'fontSize', 'fontSizeAdjust', 'fontStretch', 'fontStyle', 'fontVariant', 'fontVariantAlternates', 'fontVariantCaps', 'fontVariantEastAsian', 'fontVariantLigatures', 'fontVariantNumeric', 'fontVariantPosition', 'fontWeight', 'lineHeight'], 2274 fontVariant: ['fontVariantAlternates', 'fontVariantCaps', 'fontVariantEastAsian', 'fontVariantLigatures', 'fontVariantNumeric', 'fontVariantPosition'], 2275 gap: ['columnGap', 'rowGap'], 2276 grid: ['gridAutoColumns', 'gridAutoFlow', 'gridAutoRows', 'gridTemplateAreas', 'gridTemplateColumns', 'gridTemplateRows'], 2277 gridArea: ['gridColumnEnd', 'gridColumnStart', 'gridRowEnd', 'gridRowStart'], 2278 gridColumn: ['gridColumnEnd', 'gridColumnStart'], 2279 gridColumnGap: ['columnGap'], 2280 gridGap: ['columnGap', 'rowGap'], 2281 gridRow: ['gridRowEnd', 'gridRowStart'], 2282 gridRowGap: ['rowGap'], 2283 gridTemplate: ['gridTemplateAreas', 'gridTemplateColumns', 'gridTemplateRows'], 2284 listStyle: ['listStyleImage', 'listStylePosition', 'listStyleType'], 2285 margin: ['marginBottom', 'marginLeft', 'marginRight', 'marginTop'], 2286 marker: ['markerEnd', 'markerMid', 'markerStart'], 2287 mask: ['maskClip', 'maskComposite', 'maskImage', 'maskMode', 'maskOrigin', 'maskPositionX', 'maskPositionY', 'maskRepeat', 'maskSize'], 2288 maskPosition: ['maskPositionX', 'maskPositionY'], 2289 outline: ['outlineColor', 'outlineStyle', 'outlineWidth'], 2290 overflow: ['overflowX', 'overflowY'], 2291 padding: ['paddingBottom', 'paddingLeft', 'paddingRight', 'paddingTop'], 2292 placeContent: ['alignContent', 'justifyContent'], 2293 placeItems: ['alignItems', 'justifyItems'], 2294 placeSelf: ['alignSelf', 'justifySelf'], 2295 textDecoration: ['textDecorationColor', 'textDecorationLine', 'textDecorationStyle'], 2296 textEmphasis: ['textEmphasisColor', 'textEmphasisStyle'], 2297 transition: ['transitionDelay', 'transitionDuration', 'transitionProperty', 'transitionTimingFunction'], 2298 wordWrap: ['overflowWrap'] 2299}; 2300 2301/** 2302 * CSS properties which accept numbers but are not in units of "px". 2303 */ 2304var isUnitlessNumber = { 2305 animationIterationCount: true, 2306 borderImageOutset: true, 2307 borderImageSlice: true, 2308 borderImageWidth: true, 2309 boxFlex: true, 2310 boxFlexGroup: true, 2311 boxOrdinalGroup: true, 2312 columnCount: true, 2313 columns: true, 2314 flex: true, 2315 flexGrow: true, 2316 flexPositive: true, 2317 flexShrink: true, 2318 flexNegative: true, 2319 flexOrder: true, 2320 gridArea: true, 2321 gridRow: true, 2322 gridRowEnd: true, 2323 gridRowSpan: true, 2324 gridRowStart: true, 2325 gridColumn: true, 2326 gridColumnEnd: true, 2327 gridColumnSpan: true, 2328 gridColumnStart: true, 2329 fontWeight: true, 2330 lineClamp: true, 2331 lineHeight: true, 2332 opacity: true, 2333 order: true, 2334 orphans: true, 2335 tabSize: true, 2336 widows: true, 2337 zIndex: true, 2338 zoom: true, 2339 // SVG-related properties 2340 fillOpacity: true, 2341 floodOpacity: true, 2342 stopOpacity: true, 2343 strokeDasharray: true, 2344 strokeDashoffset: true, 2345 strokeMiterlimit: true, 2346 strokeOpacity: true, 2347 strokeWidth: true 2348}; 2349/** 2350 * @param {string} prefix vendor-specific prefix, eg: Webkit 2351 * @param {string} key style name, eg: transitionDuration 2352 * @return {string} style name prefixed with `prefix`, properly camelCased, eg: 2353 * WebkitTransitionDuration 2354 */ 2355 2356function prefixKey(prefix, key) { 2357 return prefix + key.charAt(0).toUpperCase() + key.substring(1); 2358} 2359/** 2360 * Support style names that may come passed in prefixed by adding permutations 2361 * of vendor prefixes. 2362 */ 2363 2364 2365var prefixes = ['Webkit', 'ms', 'Moz', 'O']; // Using Object.keys here, or else the vanilla for-in loop makes IE8 go into an 2366// infinite loop, because it iterates over the newly added props too. 2367 2368Object.keys(isUnitlessNumber).forEach(function (prop) { 2369 prefixes.forEach(function (prefix) { 2370 isUnitlessNumber[prefixKey(prefix, prop)] = isUnitlessNumber[prop]; 2371 }); 2372}); 2373 2374/** 2375 * Convert a value into the proper css writable value. The style name `name` 2376 * should be logical (no hyphens), as specified 2377 * in `CSSProperty.isUnitlessNumber`. 2378 * 2379 * @param {string} name CSS property name such as `topMargin`. 2380 * @param {*} value CSS property value such as `10px`. 2381 * @return {string} Normalized style value with dimensions applied. 2382 */ 2383 2384function dangerousStyleValue(name, value, isCustomProperty) { 2385 // Note that we've removed escapeTextForBrowser() calls here since the 2386 // whole string will be escaped when the attribute is injected into 2387 // the markup. If you provide unsafe user data here they can inject 2388 // arbitrary CSS which may be problematic (I couldn't repro this): 2389 // https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet 2390 // http://www.thespanner.co.uk/2007/11/26/ultimate-xss-css-injection/ 2391 // This is not an XSS hole but instead a potential CSS injection issue 2392 // which has lead to a greater discussion about how we're going to 2393 // trust URLs moving forward. See #2115901 2394 var isEmpty = value == null || typeof value === 'boolean' || value === ''; 2395 2396 if (isEmpty) { 2397 return ''; 2398 } 2399 2400 if (!isCustomProperty && typeof value === 'number' && value !== 0 && !(isUnitlessNumber.hasOwnProperty(name) && isUnitlessNumber[name])) { 2401 return value + 'px'; // Presumes implicit 'px' suffix for unitless numbers 2402 } 2403 2404 return ('' + value).trim(); 2405} 2406 2407var uppercasePattern = /([A-Z])/g; 2408var msPattern = /^ms-/; 2409/** 2410 * Hyphenates a camelcased CSS property name, for example: 2411 * 2412 * > hyphenateStyleName('backgroundColor') 2413 * < "background-color" 2414 * > hyphenateStyleName('MozTransition') 2415 * < "-moz-transition" 2416 * > hyphenateStyleName('msTransition') 2417 * < "-ms-transition" 2418 * 2419 * As Modernizr suggests (http://modernizr.com/docs/#prefixed), an `ms` prefix 2420 * is converted to `-ms-`. 2421 */ 2422 2423function hyphenateStyleName(name) { 2424 return name.replace(uppercasePattern, '-$1').toLowerCase().replace(msPattern, '-ms-'); 2425} 2426 2427var warnValidStyle = function () {}; 2428 2429{ 2430 // 'msTransform' is correct, but the other prefixes should be capitalized 2431 var badVendoredStyleNamePattern = /^(?:webkit|moz|o)[A-Z]/; 2432 var msPattern$1 = /^-ms-/; 2433 var hyphenPattern = /-(.)/g; // style values shouldn't contain a semicolon 2434 2435 var badStyleValueWithSemicolonPattern = /;\s*$/; 2436 var warnedStyleNames = {}; 2437 var warnedStyleValues = {}; 2438 var warnedForNaNValue = false; 2439 var warnedForInfinityValue = false; 2440 2441 var camelize = function (string) { 2442 return string.replace(hyphenPattern, function (_, character) { 2443 return character.toUpperCase(); 2444 }); 2445 }; 2446 2447 var warnHyphenatedStyleName = function (name) { 2448 if (warnedStyleNames.hasOwnProperty(name) && warnedStyleNames[name]) { 2449 return; 2450 } 2451 2452 warnedStyleNames[name] = true; 2453 2454 error('Unsupported style property %s. Did you mean %s?', name, // As Andi Smith suggests 2455 // (http://www.andismith.com/blog/2012/02/modernizr-prefixed/), an `-ms` prefix 2456 // is converted to lowercase `ms`. 2457 camelize(name.replace(msPattern$1, 'ms-'))); 2458 }; 2459 2460 var warnBadVendoredStyleName = function (name) { 2461 if (warnedStyleNames.hasOwnProperty(name) && warnedStyleNames[name]) { 2462 return; 2463 } 2464 2465 warnedStyleNames[name] = true; 2466 2467 error('Unsupported vendor-prefixed style property %s. Did you mean %s?', name, name.charAt(0).toUpperCase() + name.slice(1)); 2468 }; 2469 2470 var warnStyleValueWithSemicolon = function (name, value) { 2471 if (warnedStyleValues.hasOwnProperty(value) && warnedStyleValues[value]) { 2472 return; 2473 } 2474 2475 warnedStyleValues[value] = true; 2476 2477 error("Style property values shouldn't contain a semicolon. " + 'Try "%s: %s" instead.', name, value.replace(badStyleValueWithSemicolonPattern, '')); 2478 }; 2479 2480 var warnStyleValueIsNaN = function (name, value) { 2481 if (warnedForNaNValue) { 2482 return; 2483 } 2484 2485 warnedForNaNValue = true; 2486 2487 error('`NaN` is an invalid value for the `%s` css style property.', name); 2488 }; 2489 2490 var warnStyleValueIsInfinity = function (name, value) { 2491 if (warnedForInfinityValue) { 2492 return; 2493 } 2494 2495 warnedForInfinityValue = true; 2496 2497 error('`Infinity` is an invalid value for the `%s` css style property.', name); 2498 }; 2499 2500 warnValidStyle = function (name, value) { 2501 if (name.indexOf('-') > -1) { 2502 warnHyphenatedStyleName(name); 2503 } else if (badVendoredStyleNamePattern.test(name)) { 2504 warnBadVendoredStyleName(name); 2505 } else if (badStyleValueWithSemicolonPattern.test(value)) { 2506 warnStyleValueWithSemicolon(name, value); 2507 } 2508 2509 if (typeof value === 'number') { 2510 if (isNaN(value)) { 2511 warnStyleValueIsNaN(name, value); 2512 } else if (!isFinite(value)) { 2513 warnStyleValueIsInfinity(name, value); 2514 } 2515 } 2516 }; 2517} 2518 2519var warnValidStyle$1 = warnValidStyle; 2520 2521/** 2522 * Operations for dealing with CSS properties. 2523 */ 2524 2525/** 2526 * This creates a string that is expected to be equivalent to the style 2527 * attribute generated by server-side rendering. It by-passes warnings and 2528 * security checks so it's not safe to use this value for anything other than 2529 * comparison. It is only used in DEV for SSR validation. 2530 */ 2531 2532function createDangerousStringForStyles(styles) { 2533 { 2534 var serialized = ''; 2535 var delimiter = ''; 2536 2537 for (var styleName in styles) { 2538 if (!styles.hasOwnProperty(styleName)) { 2539 continue; 2540 } 2541 2542 var styleValue = styles[styleName]; 2543 2544 if (styleValue != null) { 2545 var isCustomProperty = styleName.indexOf('--') === 0; 2546 serialized += delimiter + (isCustomProperty ? styleName : hyphenateStyleName(styleName)) + ':'; 2547 serialized += dangerousStyleValue(styleName, styleValue, isCustomProperty); 2548 delimiter = ';'; 2549 } 2550 } 2551 2552 return serialized || null; 2553 } 2554} 2555/** 2556 * Sets the value for multiple styles on a node. If a value is specified as 2557 * '' (empty string), the corresponding style property will be unset. 2558 * 2559 * @param {DOMElement} node 2560 * @param {object} styles 2561 */ 2562 2563function setValueForStyles(node, styles) { 2564 var style = node.style; 2565 2566 for (var styleName in styles) { 2567 if (!styles.hasOwnProperty(styleName)) { 2568 continue; 2569 } 2570 2571 var isCustomProperty = styleName.indexOf('--') === 0; 2572 2573 { 2574 if (!isCustomProperty) { 2575 warnValidStyle$1(styleName, styles[styleName]); 2576 } 2577 } 2578 2579 var styleValue = dangerousStyleValue(styleName, styles[styleName], isCustomProperty); 2580 2581 if (styleName === 'float') { 2582 styleName = 'cssFloat'; 2583 } 2584 2585 if (isCustomProperty) { 2586 style.setProperty(styleName, styleValue); 2587 } else { 2588 style[styleName] = styleValue; 2589 } 2590 } 2591} 2592 2593function isValueEmpty(value) { 2594 return value == null || typeof value === 'boolean' || value === ''; 2595} 2596/** 2597 * Given {color: 'red', overflow: 'hidden'} returns { 2598 * color: 'color', 2599 * overflowX: 'overflow', 2600 * overflowY: 'overflow', 2601 * }. This can be read as "the overflowY property was set by the overflow 2602 * shorthand". That is, the values are the property that each was derived from. 2603 */ 2604 2605 2606function expandShorthandMap(styles) { 2607 var expanded = {}; 2608 2609 for (var key in styles) { 2610 var longhands = shorthandToLonghand[key] || [key]; 2611 2612 for (var i = 0; i < longhands.length; i++) { 2613 expanded[longhands[i]] = key; 2614 } 2615 } 2616 2617 return expanded; 2618} 2619/** 2620 * When mixing shorthand and longhand property names, we warn during updates if 2621 * we expect an incorrect result to occur. In particular, we warn for: 2622 * 2623 * Updating a shorthand property (longhand gets overwritten): 2624 * {font: 'foo', fontVariant: 'bar'} -> {font: 'baz', fontVariant: 'bar'} 2625 * becomes .style.font = 'baz' 2626 * Removing a shorthand property (longhand gets lost too): 2627 * {font: 'foo', fontVariant: 'bar'} -> {fontVariant: 'bar'} 2628 * becomes .style.font = '' 2629 * Removing a longhand property (should revert to shorthand; doesn't): 2630 * {font: 'foo', fontVariant: 'bar'} -> {font: 'foo'} 2631 * becomes .style.fontVariant = '' 2632 */ 2633 2634 2635function validateShorthandPropertyCollisionInDev(styleUpdates, nextStyles) { 2636 { 2637 if (!nextStyles) { 2638 return; 2639 } 2640 2641 var expandedUpdates = expandShorthandMap(styleUpdates); 2642 var expandedStyles = expandShorthandMap(nextStyles); 2643 var warnedAbout = {}; 2644 2645 for (var key in expandedUpdates) { 2646 var originalKey = expandedUpdates[key]; 2647 var correctOriginalKey = expandedStyles[key]; 2648 2649 if (correctOriginalKey && originalKey !== correctOriginalKey) { 2650 var warningKey = originalKey + ',' + correctOriginalKey; 2651 2652 if (warnedAbout[warningKey]) { 2653 continue; 2654 } 2655 2656 warnedAbout[warningKey] = true; 2657 2658 error('%s a style property during rerender (%s) when a ' + 'conflicting property is set (%s) can lead to styling bugs. To ' + "avoid this, don't mix shorthand and non-shorthand properties " + 'for the same value; instead, replace the shorthand with ' + 'separate values.', isValueEmpty(styleUpdates[originalKey]) ? 'Removing' : 'Updating', originalKey, correctOriginalKey); 2659 } 2660 } 2661 } 2662} 2663 2664// For HTML, certain tags should omit their close tag. We keep a list for 2665// those special-case tags. 2666var omittedCloseTags = { 2667 area: true, 2668 base: true, 2669 br: true, 2670 col: true, 2671 embed: true, 2672 hr: true, 2673 img: true, 2674 input: true, 2675 keygen: true, 2676 link: true, 2677 meta: true, 2678 param: true, 2679 source: true, 2680 track: true, 2681 wbr: true // NOTE: menuitem's close tag should be omitted, but that causes problems. 2682 2683}; 2684 2685// `omittedCloseTags` except that `menuitem` should still have its closing tag. 2686 2687var voidElementTags = _assign({ 2688 menuitem: true 2689}, omittedCloseTags); 2690 2691var HTML = '__html'; 2692 2693function assertValidProps(tag, props) { 2694 if (!props) { 2695 return; 2696 } // Note the use of `==` which checks for null or undefined. 2697 2698 2699 if (voidElementTags[tag]) { 2700 if (!(props.children == null && props.dangerouslySetInnerHTML == null)) { 2701 { 2702 throw Error( tag + " is a void element tag and must neither have `children` nor use `dangerouslySetInnerHTML`." ); 2703 } 2704 } 2705 } 2706 2707 if (props.dangerouslySetInnerHTML != null) { 2708 if (!(props.children == null)) { 2709 { 2710 throw Error( "Can only set one of `children` or `props.dangerouslySetInnerHTML`." ); 2711 } 2712 } 2713 2714 if (!(typeof props.dangerouslySetInnerHTML === 'object' && HTML in props.dangerouslySetInnerHTML)) { 2715 { 2716 throw Error( "`props.dangerouslySetInnerHTML` must be in the form `{__html: ...}`. Please visit https://reactjs.org/link/dangerously-set-inner-html for more information." ); 2717 } 2718 } 2719 } 2720 2721 { 2722 if (!props.suppressContentEditableWarning && props.contentEditable && props.children != null) { 2723 error('A component is `contentEditable` and contains `children` managed by ' + 'React. It is now your responsibility to guarantee that none of ' + 'those nodes are unexpectedly modified or duplicated. This is ' + 'probably not intentional.'); 2724 } 2725 } 2726 2727 if (!(props.style == null || typeof props.style === 'object')) { 2728 { 2729 throw Error( "The `style` prop expects a mapping from style properties to values, not a string. For example, style={{marginRight: spacing + 'em'}} when using JSX." ); 2730 } 2731 } 2732} 2733 2734function isCustomComponent(tagName, props) { 2735 if (tagName.indexOf('-') === -1) { 2736 return typeof props.is === 'string'; 2737 } 2738 2739 switch (tagName) { 2740 // These are reserved SVG and MathML elements. 2741 // We don't mind this list too much because we expect it to never grow. 2742 // The alternative is to track the namespace in a few places which is convoluted. 2743 // https://w3c.github.io/webcomponents/spec/custom/#custom-elements-core-concepts 2744 case 'annotation-xml': 2745 case 'color-profile': 2746 case 'font-face': 2747 case 'font-face-src': 2748 case 'font-face-uri': 2749 case 'font-face-format': 2750 case 'font-face-name': 2751 case 'missing-glyph': 2752 return false; 2753 2754 default: 2755 return true; 2756 } 2757} 2758 2759// When adding attributes to the HTML or SVG allowed attribute list, be sure to 2760// also add them to this module to ensure casing and incorrect name 2761// warnings. 2762var possibleStandardNames = { 2763 // HTML 2764 accept: 'accept', 2765 acceptcharset: 'acceptCharset', 2766 'accept-charset': 'acceptCharset', 2767 accesskey: 'accessKey', 2768 action: 'action', 2769 allowfullscreen: 'allowFullScreen', 2770 alt: 'alt', 2771 as: 'as', 2772 async: 'async', 2773 autocapitalize: 'autoCapitalize', 2774 autocomplete: 'autoComplete', 2775 autocorrect: 'autoCorrect', 2776 autofocus: 'autoFocus', 2777 autoplay: 'autoPlay', 2778 autosave: 'autoSave', 2779 capture: 'capture', 2780 cellpadding: 'cellPadding', 2781 cellspacing: 'cellSpacing', 2782 challenge: 'challenge', 2783 charset: 'charSet', 2784 checked: 'checked', 2785 children: 'children', 2786 cite: 'cite', 2787 class: 'className', 2788 classid: 'classID', 2789 classname: 'className', 2790 cols: 'cols', 2791 colspan: 'colSpan', 2792 content: 'content', 2793 contenteditable: 'contentEditable', 2794 contextmenu: 'contextMenu', 2795 controls: 'controls', 2796 controlslist: 'controlsList', 2797 coords: 'coords', 2798 crossorigin: 'crossOrigin', 2799 dangerouslysetinnerhtml: 'dangerouslySetInnerHTML', 2800 data: 'data', 2801 datetime: 'dateTime', 2802 default: 'default', 2803 defaultchecked: 'defaultChecked', 2804 defaultvalue: 'defaultValue', 2805 defer: 'defer', 2806 dir: 'dir', 2807 disabled: 'disabled', 2808 disablepictureinpicture: 'disablePictureInPicture', 2809 disableremoteplayback: 'disableRemotePlayback', 2810 download: 'download', 2811 draggable: 'draggable', 2812 enctype: 'encType', 2813 enterkeyhint: 'enterKeyHint', 2814 for: 'htmlFor', 2815 form: 'form', 2816 formmethod: 'formMethod', 2817 formaction: 'formAction', 2818 formenctype: 'formEncType', 2819 formnovalidate: 'formNoValidate', 2820 formtarget: 'formTarget', 2821 frameborder: 'frameBorder', 2822 headers: 'headers', 2823 height: 'height', 2824 hidden: 'hidden', 2825 high: 'high', 2826 href: 'href', 2827 hreflang: 'hrefLang', 2828 htmlfor: 'htmlFor', 2829 httpequiv: 'httpEquiv', 2830 'http-equiv': 'httpEquiv', 2831 icon: 'icon', 2832 id: 'id', 2833 innerhtml: 'innerHTML', 2834 inputmode: 'inputMode', 2835 integrity: 'integrity', 2836 is: 'is', 2837 itemid: 'itemID', 2838 itemprop: 'itemProp', 2839 itemref: 'itemRef', 2840 itemscope: 'itemScope', 2841 itemtype: 'itemType', 2842 keyparams: 'keyParams', 2843 keytype: 'keyType', 2844 kind: 'kind', 2845 label: 'label', 2846 lang: 'lang', 2847 list: 'list', 2848 loop: 'loop', 2849 low: 'low', 2850 manifest: 'manifest', 2851 marginwidth: 'marginWidth', 2852 marginheight: 'marginHeight', 2853 max: 'max', 2854 maxlength: 'maxLength', 2855 media: 'media', 2856 mediagroup: 'mediaGroup', 2857 method: 'method', 2858 min: 'min', 2859 minlength: 'minLength', 2860 multiple: 'multiple', 2861 muted: 'muted', 2862 name: 'name', 2863 nomodule: 'noModule', 2864 nonce: 'nonce', 2865 novalidate: 'noValidate', 2866 open: 'open', 2867 optimum: 'optimum', 2868 pattern: 'pattern', 2869 placeholder: 'placeholder', 2870 playsinline: 'playsInline', 2871 poster: 'poster', 2872 preload: 'preload', 2873 profile: 'profile', 2874 radiogroup: 'radioGroup', 2875 readonly: 'readOnly', 2876 referrerpolicy: 'referrerPolicy', 2877 rel: 'rel', 2878 required: 'required', 2879 reversed: 'reversed', 2880 role: 'role', 2881 rows: 'rows', 2882 rowspan: 'rowSpan', 2883 sandbox: 'sandbox', 2884 scope: 'scope', 2885 scoped: 'scoped', 2886 scrolling: 'scrolling', 2887 seamless: 'seamless', 2888 selected: 'selected', 2889 shape: 'shape', 2890 size: 'size', 2891 sizes: 'sizes', 2892 span: 'span', 2893 spellcheck: 'spellCheck', 2894 src: 'src', 2895 srcdoc: 'srcDoc', 2896 srclang: 'srcLang', 2897 srcset: 'srcSet', 2898 start: 'start', 2899 step: 'step', 2900 style: 'style', 2901 summary: 'summary', 2902 tabindex: 'tabIndex', 2903 target: 'target', 2904 title: 'title', 2905 type: 'type', 2906 usemap: 'useMap', 2907 value: 'value', 2908 width: 'width', 2909 wmode: 'wmode', 2910 wrap: 'wrap', 2911 // SVG 2912 about: 'about', 2913 accentheight: 'accentHeight', 2914 'accent-height': 'accentHeight', 2915 accumulate: 'accumulate', 2916 additive: 'additive', 2917 alignmentbaseline: 'alignmentBaseline', 2918 'alignment-baseline': 'alignmentBaseline', 2919 allowreorder: 'allowReorder', 2920 alphabetic: 'alphabetic', 2921 amplitude: 'amplitude', 2922 arabicform: 'arabicForm', 2923 'arabic-form': 'arabicForm', 2924 ascent: 'ascent', 2925 attributename: 'attributeName', 2926 attributetype: 'attributeType', 2927 autoreverse: 'autoReverse', 2928 azimuth: 'azimuth', 2929 basefrequency: 'baseFrequency', 2930 baselineshift: 'baselineShift', 2931 'baseline-shift': 'baselineShift', 2932 baseprofile: 'baseProfile', 2933 bbox: 'bbox', 2934 begin: 'begin', 2935 bias: 'bias', 2936 by: 'by', 2937 calcmode: 'calcMode', 2938 capheight: 'capHeight', 2939 'cap-height': 'capHeight', 2940 clip: 'clip', 2941 clippath: 'clipPath', 2942 'clip-path': 'clipPath', 2943 clippathunits: 'clipPathUnits', 2944 cliprule: 'clipRule', 2945 'clip-rule': 'clipRule', 2946 color: 'color', 2947 colorinterpolation: 'colorInterpolation', 2948 'color-interpolation': 'colorInterpolation', 2949 colorinterpolationfilters: 'colorInterpolationFilters', 2950 'color-interpolation-filters': 'colorInterpolationFilters', 2951 colorprofile: 'colorProfile', 2952 'color-profile': 'colorProfile', 2953 colorrendering: 'colorRendering', 2954 'color-rendering': 'colorRendering', 2955 contentscripttype: 'contentScriptType', 2956 contentstyletype: 'contentStyleType', 2957 cursor: 'cursor', 2958 cx: 'cx', 2959 cy: 'cy', 2960 d: 'd', 2961 datatype: 'datatype', 2962 decelerate: 'decelerate', 2963 descent: 'descent', 2964 diffuseconstant: 'diffuseConstant', 2965 direction: 'direction', 2966 display: 'display', 2967 divisor: 'divisor', 2968 dominantbaseline: 'dominantBaseline', 2969 'dominant-baseline': 'dominantBaseline', 2970 dur: 'dur', 2971 dx: 'dx', 2972 dy: 'dy', 2973 edgemode: 'edgeMode', 2974 elevation: 'elevation', 2975 enablebackground: 'enableBackground', 2976 'enable-background': 'enableBackground', 2977 end: 'end', 2978 exponent: 'exponent', 2979 externalresourcesrequired: 'externalResourcesRequired', 2980 fill: 'fill', 2981 fillopacity: 'fillOpacity', 2982 'fill-opacity': 'fillOpacity', 2983 fillrule: 'fillRule', 2984 'fill-rule': 'fillRule', 2985 filter: 'filter', 2986 filterres: 'filterRes', 2987 filterunits: 'filterUnits', 2988 floodopacity: 'floodOpacity', 2989 'flood-opacity': 'floodOpacity', 2990 floodcolor: 'floodColor', 2991 'flood-color': 'floodColor', 2992 focusable: 'focusable', 2993 fontfamily: 'fontFamily', 2994 'font-family': 'fontFamily', 2995 fontsize: 'fontSize', 2996 'font-size': 'fontSize', 2997 fontsizeadjust: 'fontSizeAdjust', 2998 'font-size-adjust': 'fontSizeAdjust', 2999 fontstretch: 'fontStretch', 3000 'font-stretch': 'fontStretch', 3001 fontstyle: 'fontStyle', 3002 'font-style': 'fontStyle', 3003 fontvariant: 'fontVariant', 3004 'font-variant': 'fontVariant', 3005 fontweight: 'fontWeight', 3006 'font-weight': 'fontWeight', 3007 format: 'format', 3008 from: 'from', 3009 fx: 'fx', 3010 fy: 'fy', 3011 g1: 'g1', 3012 g2: 'g2', 3013 glyphname: 'glyphName', 3014 'glyph-name': 'glyphName', 3015 glyphorientationhorizontal: 'glyphOrientationHorizontal', 3016 'glyph-orientation-horizontal': 'glyphOrientationHorizontal', 3017 glyphorientationvertical: 'glyphOrientationVertical', 3018 'glyph-orientation-vertical': 'glyphOrientationVertical', 3019 glyphref: 'glyphRef', 3020 gradienttransform: 'gradientTransform', 3021 gradientunits: 'gradientUnits', 3022 hanging: 'hanging', 3023 horizadvx: 'horizAdvX', 3024 'horiz-adv-x': 'horizAdvX', 3025 horizoriginx: 'horizOriginX', 3026 'horiz-origin-x': 'horizOriginX', 3027 ideographic: 'ideographic', 3028 imagerendering: 'imageRendering', 3029 'image-rendering': 'imageRendering', 3030 in2: 'in2', 3031 in: 'in', 3032 inlist: 'inlist', 3033 intercept: 'intercept', 3034 k1: 'k1', 3035 k2: 'k2', 3036 k3: 'k3', 3037 k4: 'k4', 3038 k: 'k', 3039 kernelmatrix: 'kernelMatrix', 3040 kernelunitlength: 'kernelUnitLength', 3041 kerning: 'kerning', 3042 keypoints: 'keyPoints', 3043 keysplines: 'keySplines', 3044 keytimes: 'keyTimes', 3045 lengthadjust: 'lengthAdjust', 3046 letterspacing: 'letterSpacing', 3047 'letter-spacing': 'letterSpacing', 3048 lightingcolor: 'lightingColor', 3049 'lighting-color': 'lightingColor', 3050 limitingconeangle: 'limitingConeAngle', 3051 local: 'local', 3052 markerend: 'markerEnd', 3053 'marker-end': 'markerEnd', 3054 markerheight: 'markerHeight', 3055 markermid: 'markerMid', 3056 'marker-mid': 'markerMid', 3057 markerstart: 'markerStart', 3058 'marker-start': 'markerStart', 3059 markerunits: 'markerUnits', 3060 markerwidth: 'markerWidth', 3061 mask: 'mask', 3062 maskcontentunits: 'maskContentUnits', 3063 maskunits: 'maskUnits', 3064 mathematical: 'mathematical', 3065 mode: 'mode', 3066 numoctaves: 'numOctaves', 3067 offset: 'offset', 3068 opacity: 'opacity', 3069 operator: 'operator', 3070 order: 'order', 3071 orient: 'orient', 3072 orientation: 'orientation', 3073 origin: 'origin', 3074 overflow: 'overflow', 3075 overlineposition: 'overlinePosition', 3076 'overline-position': 'overlinePosition', 3077 overlinethickness: 'overlineThickness', 3078 'overline-thickness': 'overlineThickness', 3079 paintorder: 'paintOrder', 3080 'paint-order': 'paintOrder', 3081 panose1: 'panose1', 3082 'panose-1': 'panose1', 3083 pathlength: 'pathLength', 3084 patterncontentunits: 'patternContentUnits', 3085 patterntransform: 'patternTransform', 3086 patternunits: 'patternUnits', 3087 pointerevents: 'pointerEvents', 3088 'pointer-events': 'pointerEvents', 3089 points: 'points', 3090 pointsatx: 'pointsAtX', 3091 pointsaty: 'pointsAtY', 3092 pointsatz: 'pointsAtZ', 3093 prefix: 'prefix', 3094 preservealpha: 'preserveAlpha', 3095 preserveaspectratio: 'preserveAspectRatio', 3096 primitiveunits: 'primitiveUnits', 3097 property: 'property', 3098 r: 'r', 3099 radius: 'radius', 3100 refx: 'refX', 3101 refy: 'refY', 3102 renderingintent: 'renderingIntent', 3103 'rendering-intent': 'renderingIntent', 3104 repeatcount: 'repeatCount', 3105 repeatdur: 'repeatDur', 3106 requiredextensions: 'requiredExtensions', 3107 requiredfeatures: 'requiredFeatures', 3108 resource: 'resource', 3109 restart: 'restart', 3110 result: 'result', 3111 results: 'results', 3112 rotate: 'rotate', 3113 rx: 'rx', 3114 ry: 'ry', 3115 scale: 'scale', 3116 security: 'security', 3117 seed: 'seed', 3118 shaperendering: 'shapeRendering', 3119 'shape-rendering': 'shapeRendering', 3120 slope: 'slope', 3121 spacing: 'spacing', 3122 specularconstant: 'specularConstant', 3123 specularexponent: 'specularExponent', 3124 speed: 'speed', 3125 spreadmethod: 'spreadMethod', 3126 startoffset: 'startOffset', 3127 stddeviation: 'stdDeviation', 3128 stemh: 'stemh', 3129 stemv: 'stemv', 3130 stitchtiles: 'stitchTiles', 3131 stopcolor: 'stopColor', 3132 'stop-color': 'stopColor', 3133 stopopacity: 'stopOpacity', 3134 'stop-opacity': 'stopOpacity', 3135 strikethroughposition: 'strikethroughPosition', 3136 'strikethrough-position': 'strikethroughPosition', 3137 strikethroughthickness: 'strikethroughThickness', 3138 'strikethrough-thickness': 'strikethroughThickness', 3139 string: 'string', 3140 stroke: 'stroke', 3141 strokedasharray: 'strokeDasharray', 3142 'stroke-dasharray': 'strokeDasharray', 3143 strokedashoffset: 'strokeDashoffset', 3144 'stroke-dashoffset': 'strokeDashoffset', 3145 strokelinecap: 'strokeLinecap', 3146 'stroke-linecap': 'strokeLinecap', 3147 strokelinejoin: 'strokeLinejoin', 3148 'stroke-linejoin': 'strokeLinejoin', 3149 strokemiterlimit: 'strokeMiterlimit', 3150 'stroke-miterlimit': 'strokeMiterlimit', 3151 strokewidth: 'strokeWidth', 3152 'stroke-width': 'strokeWidth', 3153 strokeopacity: 'strokeOpacity', 3154 'stroke-opacity': 'strokeOpacity', 3155 suppresscontenteditablewarning: 'suppressContentEditableWarning', 3156 suppresshydrationwarning: 'suppressHydrationWarning', 3157 surfacescale: 'surfaceScale', 3158 systemlanguage: 'systemLanguage', 3159 tablevalues: 'tableValues', 3160 targetx: 'targetX', 3161 targety: 'targetY', 3162 textanchor: 'textAnchor', 3163 'text-anchor': 'textAnchor', 3164 textdecoration: 'textDecoration', 3165 'text-decoration': 'textDecoration', 3166 textlength: 'textLength', 3167 textrendering: 'textRendering', 3168 'text-rendering': 'textRendering', 3169 to: 'to', 3170 transform: 'transform', 3171 typeof: 'typeof', 3172 u1: 'u1', 3173 u2: 'u2', 3174 underlineposition: 'underlinePosition', 3175 'underline-position': 'underlinePosition', 3176 underlinethickness: 'underlineThickness', 3177 'underline-thickness': 'underlineThickness', 3178 unicode: 'unicode', 3179 unicodebidi: 'unicodeBidi', 3180 'unicode-bidi': 'unicodeBidi', 3181 unicoderange: 'unicodeRange', 3182 'unicode-range': 'unicodeRange', 3183 unitsperem: 'unitsPerEm', 3184 'units-per-em': 'unitsPerEm', 3185 unselectable: 'unselectable', 3186 valphabetic: 'vAlphabetic', 3187 'v-alphabetic': 'vAlphabetic', 3188 values: 'values', 3189 vectoreffect: 'vectorEffect', 3190 'vector-effect': 'vectorEffect', 3191 version: 'version', 3192 vertadvy: 'vertAdvY', 3193 'vert-adv-y': 'vertAdvY', 3194 vertoriginx: 'vertOriginX', 3195 'vert-origin-x': 'vertOriginX', 3196 vertoriginy: 'vertOriginY', 3197 'vert-origin-y': 'vertOriginY', 3198 vhanging: 'vHanging', 3199 'v-hanging': 'vHanging', 3200 videographic: 'vIdeographic', 3201 'v-ideographic': 'vIdeographic', 3202 viewbox: 'viewBox', 3203 viewtarget: 'viewTarget', 3204 visibility: 'visibility', 3205 vmathematical: 'vMathematical', 3206 'v-mathematical': 'vMathematical', 3207 vocab: 'vocab', 3208 widths: 'widths', 3209 wordspacing: 'wordSpacing', 3210 'word-spacing': 'wordSpacing', 3211 writingmode: 'writingMode', 3212 'writing-mode': 'writingMode', 3213 x1: 'x1', 3214 x2: 'x2', 3215 x: 'x', 3216 xchannelselector: 'xChannelSelector', 3217 xheight: 'xHeight', 3218 'x-height': 'xHeight', 3219 xlinkactuate: 'xlinkActuate', 3220 'xlink:actuate': 'xlinkActuate', 3221 xlinkarcrole: 'xlinkArcrole', 3222 'xlink:arcrole': 'xlinkArcrole', 3223 xlinkhref: 'xlinkHref', 3224 'xlink:href': 'xlinkHref', 3225 xlinkrole: 'xlinkRole', 3226 'xlink:role': 'xlinkRole', 3227 xlinkshow: 'xlinkShow', 3228 'xlink:show': 'xlinkShow', 3229 xlinktitle: 'xlinkTitle', 3230 'xlink:title': 'xlinkTitle', 3231 xlinktype: 'xlinkType', 3232 'xlink:type': 'xlinkType', 3233 xmlbase: 'xmlBase', 3234 'xml:base': 'xmlBase', 3235 xmllang: 'xmlLang', 3236 'xml:lang': 'xmlLang', 3237 xmlns: 'xmlns', 3238 'xml:space': 'xmlSpace', 3239 xmlnsxlink: 'xmlnsXlink', 3240 'xmlns:xlink': 'xmlnsXlink', 3241 xmlspace: 'xmlSpace', 3242 y1: 'y1', 3243 y2: 'y2', 3244 y: 'y', 3245 ychannelselector: 'yChannelSelector', 3246 z: 'z', 3247 zoomandpan: 'zoomAndPan' 3248}; 3249 3250var ariaProperties = { 3251 'aria-current': 0, 3252 // state 3253 'aria-details': 0, 3254 'aria-disabled': 0, 3255 // state 3256 'aria-hidden': 0, 3257 // state 3258 'aria-invalid': 0, 3259 // state 3260 'aria-keyshortcuts': 0, 3261 'aria-label': 0, 3262 'aria-roledescription': 0, 3263 // Widget Attributes 3264 'aria-autocomplete': 0, 3265 'aria-checked': 0, 3266 'aria-expanded': 0, 3267 'aria-haspopup': 0, 3268 'aria-level': 0, 3269 'aria-modal': 0, 3270 'aria-multiline': 0, 3271 'aria-multiselectable': 0, 3272 'aria-orientation': 0, 3273 'aria-placeholder': 0, 3274 'aria-pressed': 0, 3275 'aria-readonly': 0, 3276 'aria-required': 0, 3277 'aria-selected': 0, 3278 'aria-sort': 0, 3279 'aria-valuemax': 0, 3280 'aria-valuemin': 0, 3281 'aria-valuenow': 0, 3282 'aria-valuetext': 0, 3283 // Live Region Attributes 3284 'aria-atomic': 0, 3285 'aria-busy': 0, 3286 'aria-live': 0, 3287 'aria-relevant': 0, 3288 // Drag-and-Drop Attributes 3289 'aria-dropeffect': 0, 3290 'aria-grabbed': 0, 3291 // Relationship Attributes 3292 'aria-activedescendant': 0, 3293 'aria-colcount': 0, 3294 'aria-colindex': 0, 3295 'aria-colspan': 0, 3296 'aria-controls': 0, 3297 'aria-describedby': 0, 3298 'aria-errormessage': 0, 3299 'aria-flowto': 0, 3300 'aria-labelledby': 0, 3301 'aria-owns': 0, 3302 'aria-posinset': 0, 3303 'aria-rowcount': 0, 3304 'aria-rowindex': 0, 3305 'aria-rowspan': 0, 3306 'aria-setsize': 0 3307}; 3308 3309var warnedProperties = {}; 3310var rARIA = new RegExp('^(aria)-[' + ATTRIBUTE_NAME_CHAR + ']*$'); 3311var rARIACamel = new RegExp('^(aria)[A-Z][' + ATTRIBUTE_NAME_CHAR + ']*$'); 3312var hasOwnProperty$1 = Object.prototype.hasOwnProperty; 3313 3314function validateProperty(tagName, name) { 3315 { 3316 if (hasOwnProperty$1.call(warnedProperties, name) && warnedProperties[name]) { 3317 return true; 3318 } 3319 3320 if (rARIACamel.test(name)) { 3321 var ariaName = 'aria-' + name.slice(4).toLowerCase(); 3322 var correctName = ariaProperties.hasOwnProperty(ariaName) ? ariaName : null; // If this is an aria-* attribute, but is not listed in the known DOM 3323 // DOM properties, then it is an invalid aria-* attribute. 3324 3325 if (correctName == null) { 3326 error('Invalid ARIA attribute `%s`. ARIA attributes follow the pattern aria-* and must be lowercase.', name); 3327 3328 warnedProperties[name] = true; 3329 return true; 3330 } // aria-* attributes should be lowercase; suggest the lowercase version. 3331 3332 3333 if (name !== correctName) { 3334 error('Invalid ARIA attribute `%s`. Did you mean `%s`?', name, correctName); 3335 3336 warnedProperties[name] = true; 3337 return true; 3338 } 3339 } 3340 3341 if (rARIA.test(name)) { 3342 var lowerCasedName = name.toLowerCase(); 3343 var standardName = ariaProperties.hasOwnProperty(lowerCasedName) ? lowerCasedName : null; // If this is an aria-* attribute, but is not listed in the known DOM 3344 // DOM properties, then it is an invalid aria-* attribute. 3345 3346 if (standardName == null) { 3347 warnedProperties[name] = true; 3348 return false; 3349 } // aria-* attributes should be lowercase; suggest the lowercase version. 3350 3351 3352 if (name !== standardName) { 3353 error('Unknown ARIA attribute `%s`. Did you mean `%s`?', name, standardName); 3354 3355 warnedProperties[name] = true; 3356 return true; 3357 } 3358 } 3359 } 3360 3361 return true; 3362} 3363 3364function warnInvalidARIAProps(type, props) { 3365 { 3366 var invalidProps = []; 3367 3368 for (var key in props) { 3369 var isValid = validateProperty(type, key); 3370 3371 if (!isValid) { 3372 invalidProps.push(key); 3373 } 3374 } 3375 3376 var unknownPropString = invalidProps.map(function (prop) { 3377 return '`' + prop + '`'; 3378 }).join(', '); 3379 3380 if (invalidProps.length === 1) { 3381 error('Invalid aria prop %s on <%s> tag. ' + 'For details, see https://reactjs.org/link/invalid-aria-props', unknownPropString, type); 3382 } else if (invalidProps.length > 1) { 3383 error('Invalid aria props %s on <%s> tag. ' + 'For details, see https://reactjs.org/link/invalid-aria-props', unknownPropString, type); 3384 } 3385 } 3386} 3387 3388function validateProperties(type, props) { 3389 if (isCustomComponent(type, props)) { 3390 return; 3391 } 3392 3393 warnInvalidARIAProps(type, props); 3394} 3395 3396var didWarnValueNull = false; 3397function validateProperties$1(type, props) { 3398 { 3399 if (type !== 'input' && type !== 'textarea' && type !== 'select') { 3400 return; 3401 } 3402 3403 if (props != null && props.value === null && !didWarnValueNull) { 3404 didWarnValueNull = true; 3405 3406 if (type === 'select' && props.multiple) { 3407 error('`value` prop on `%s` should not be null. ' + 'Consider using an empty array when `multiple` is set to `true` ' + 'to clear the component or `undefined` for uncontrolled components.', type); 3408 } else { 3409 error('`value` prop on `%s` should not be null. ' + 'Consider using an empty string to clear the component or `undefined` ' + 'for uncontrolled components.', type); 3410 } 3411 } 3412 } 3413} 3414 3415var validateProperty$1 = function () {}; 3416 3417{ 3418 var warnedProperties$1 = {}; 3419 var _hasOwnProperty = Object.prototype.hasOwnProperty; 3420 var EVENT_NAME_REGEX = /^on./; 3421 var INVALID_EVENT_NAME_REGEX = /^on[^A-Z]/; 3422 var rARIA$1 = new RegExp('^(aria)-[' + ATTRIBUTE_NAME_CHAR + ']*$'); 3423 var rARIACamel$1 = new RegExp('^(aria)[A-Z][' + ATTRIBUTE_NAME_CHAR + ']*$'); 3424 3425 validateProperty$1 = function (tagName, name, value, eventRegistry) { 3426 if (_hasOwnProperty.call(warnedProperties$1, name) && warnedProperties$1[name]) { 3427 return true; 3428 } 3429 3430 var lowerCasedName = name.toLowerCase(); 3431 3432 if (lowerCasedName === 'onfocusin' || lowerCasedName === 'onfocusout') { 3433 error('React uses onFocus and onBlur instead of onFocusIn and onFocusOut. ' + 'All React events are normalized to bubble, so onFocusIn and onFocusOut ' + 'are not needed/supported by React.'); 3434 3435 warnedProperties$1[name] = true; 3436 return true; 3437 } // We can't rely on the event system being injected on the server. 3438 3439 3440 if (eventRegistry != null) { 3441 var registrationNameDependencies = eventRegistry.registrationNameDependencies, 3442 possibleRegistrationNames = eventRegistry.possibleRegistrationNames; 3443 3444 if (registrationNameDependencies.hasOwnProperty(name)) { 3445 return true; 3446 } 3447 3448 var registrationName = possibleRegistrationNames.hasOwnProperty(lowerCasedName) ? possibleRegistrationNames[lowerCasedName] : null; 3449 3450 if (registrationName != null) { 3451 error('Invalid event handler property `%s`. Did you mean `%s`?', name, registrationName); 3452 3453 warnedProperties$1[name] = true; 3454 return true; 3455 } 3456 3457 if (EVENT_NAME_REGEX.test(name)) { 3458 error('Unknown event handler property `%s`. It will be ignored.', name); 3459 3460 warnedProperties$1[name] = true; 3461 return true; 3462 } 3463 } else if (EVENT_NAME_REGEX.test(name)) { 3464 // If no event plugins have been injected, we are in a server environment. 3465 // So we can't tell if the event name is correct for sure, but we can filter 3466 // out known bad ones like `onclick`. We can't suggest a specific replacement though. 3467 if (INVALID_EVENT_NAME_REGEX.test(name)) { 3468 error('Invalid event handler property `%s`. ' + 'React events use the camelCase naming convention, for example `onClick`.', name); 3469 } 3470 3471 warnedProperties$1[name] = true; 3472 return true; 3473 } // Let the ARIA attribute hook validate ARIA attributes 3474 3475 3476 if (rARIA$1.test(name) || rARIACamel$1.test(name)) { 3477 return true; 3478 } 3479 3480 if (lowerCasedName === 'innerhtml') { 3481 error('Directly setting property `innerHTML` is not permitted. ' + 'For more information, lookup documentation on `dangerouslySetInnerHTML`.'); 3482 3483 warnedProperties$1[name] = true; 3484 return true; 3485 } 3486 3487 if (lowerCasedName === 'aria') { 3488 error('The `aria` attribute is reserved for future use in React. ' + 'Pass individual `aria-` attributes instead.'); 3489 3490 warnedProperties$1[name] = true; 3491 return true; 3492 } 3493 3494 if (lowerCasedName === 'is' && value !== null && value !== undefined && typeof value !== 'string') { 3495 error('Received a `%s` for a string attribute `is`. If this is expected, cast ' + 'the value to a string.', typeof value); 3496 3497 warnedProperties$1[name] = true; 3498 return true; 3499 } 3500 3501 if (typeof value === 'number' && isNaN(value)) { 3502 error('Received NaN for the `%s` attribute. If this is expected, cast ' + 'the value to a string.', name); 3503 3504 warnedProperties$1[name] = true; 3505 return true; 3506 } 3507 3508 var propertyInfo = getPropertyInfo(name); 3509 var isReserved = propertyInfo !== null && propertyInfo.type === RESERVED; // Known attributes should match the casing specified in the property config. 3510 3511 if (possibleStandardNames.hasOwnProperty(lowerCasedName)) { 3512 var standardName = possibleStandardNames[lowerCasedName]; 3513 3514 if (standardName !== name) { 3515 error('Invalid DOM property `%s`. Did you mean `%s`?', name, standardName); 3516 3517 warnedProperties$1[name] = true; 3518 return true; 3519 } 3520 } else if (!isReserved && name !== lowerCasedName) { 3521 // Unknown attributes should have lowercase casing since that's how they 3522 // will be cased anyway with server rendering. 3523 error('React does not recognize the `%s` prop on a DOM element. If you ' + 'intentionally want it to appear in the DOM as a custom ' + 'attribute, spell it as lowercase `%s` instead. ' + 'If you accidentally passed it from a parent component, remove ' + 'it from the DOM element.', name, lowerCasedName); 3524 3525 warnedProperties$1[name] = true; 3526 return true; 3527 } 3528 3529 if (typeof value === 'boolean' && shouldRemoveAttributeWithWarning(name, value, propertyInfo, false)) { 3530 if (value) { 3531 error('Received `%s` for a non-boolean attribute `%s`.\n\n' + 'If you want to write it to the DOM, pass a string instead: ' + '%s="%s" or %s={value.toString()}.', value, name, name, value, name); 3532 } else { 3533 error('Received `%s` for a non-boolean attribute `%s`.\n\n' + 'If you want to write it to the DOM, pass a string instead: ' + '%s="%s" or %s={value.toString()}.\n\n' + 'If you used to conditionally omit it with %s={condition && value}, ' + 'pass %s={condition ? value : undefined} instead.', value, name, name, value, name, name, name); 3534 } 3535 3536 warnedProperties$1[name] = true; 3537 return true; 3538 } // Now that we've validated casing, do not validate 3539 // data types for reserved props 3540 3541 3542 if (isReserved) { 3543 return true; 3544 } // Warn when a known attribute is a bad type 3545 3546 3547 if (shouldRemoveAttributeWithWarning(name, value, propertyInfo, false)) { 3548 warnedProperties$1[name] = true; 3549 return false; 3550 } // Warn when passing the strings 'false' or 'true' into a boolean prop 3551 3552 3553 if ((value === 'false' || value === 'true') && propertyInfo !== null && propertyInfo.type === BOOLEAN) { 3554 error('Received the string `%s` for the boolean attribute `%s`. ' + '%s ' + 'Did you mean %s={%s}?', value, name, value === 'false' ? 'The browser will interpret it as a truthy value.' : 'Although this works, it will not work as expected if you pass the string "false".', name, value); 3555 3556 warnedProperties$1[name] = true; 3557 return true; 3558 } 3559 3560 return true; 3561 }; 3562} 3563 3564var warnUnknownProperties = function (type, props, eventRegistry) { 3565 { 3566 var unknownProps = []; 3567 3568 for (var key in props) { 3569 var isValid = validateProperty$1(type, key, props[key], eventRegistry); 3570 3571 if (!isValid) { 3572 unknownProps.push(key); 3573 } 3574 } 3575 3576 var unknownPropString = unknownProps.map(function (prop) { 3577 return '`' + prop + '`'; 3578 }).join(', '); 3579 3580 if (unknownProps.length === 1) { 3581 error('Invalid value for prop %s on <%s> tag. Either remove it from the element, ' + 'or pass a string or number value to keep it in the DOM. ' + 'For details, see https://reactjs.org/link/attribute-behavior ', unknownPropString, type); 3582 } else if (unknownProps.length > 1) { 3583 error('Invalid values for props %s on <%s> tag. Either remove them from the element, ' + 'or pass a string or number value to keep them in the DOM. ' + 'For details, see https://reactjs.org/link/attribute-behavior ', unknownPropString, type); 3584 } 3585 } 3586}; 3587 3588function validateProperties$2(type, props, eventRegistry) { 3589 if (isCustomComponent(type, props)) { 3590 return; 3591 } 3592 3593 warnUnknownProperties(type, props, eventRegistry); 3594} 3595 3596var IS_EVENT_HANDLE_NON_MANAGED_NODE = 1; 3597var IS_NON_DELEGATED = 1 << 1; 3598var IS_CAPTURE_PHASE = 1 << 2; 3599var IS_REPLAYED = 1 << 4; 3600// set to LEGACY_FB_SUPPORT. LEGACY_FB_SUPPORT only gets set when 3601// we call willDeferLaterForLegacyFBSupport, thus not bailing out 3602// will result in endless cycles like an infinite loop. 3603// We also don't want to defer during event replaying. 3604 3605var SHOULD_NOT_PROCESS_POLYFILL_EVENT_PLUGINS = IS_EVENT_HANDLE_NON_MANAGED_NODE | IS_NON_DELEGATED | IS_CAPTURE_PHASE; 3606 3607/** 3608 * Gets the target node from a native browser event by accounting for 3609 * inconsistencies in browser DOM APIs. 3610 * 3611 * @param {object} nativeEvent Native browser event. 3612 * @return {DOMEventTarget} Target node. 3613 */ 3614 3615function getEventTarget(nativeEvent) { 3616 // Fallback to nativeEvent.srcElement for IE9 3617 // https://github.com/facebook/react/issues/12506 3618 var target = nativeEvent.target || nativeEvent.srcElement || window; // Normalize SVG <use> element events #4963 3619 3620 if (target.correspondingUseElement) { 3621 target = target.correspondingUseElement; 3622 } // Safari may fire events on text nodes (Node.TEXT_NODE is 3). 3623 // @see http://www.quirksmode.org/js/events_properties.html 3624 3625 3626 return target.nodeType === TEXT_NODE ? target.parentNode : target; 3627} 3628 3629var restoreImpl = null; 3630var restoreTarget = null; 3631var restoreQueue = null; 3632 3633function restoreStateOfTarget(target) { 3634 // We perform this translation at the end of the event loop so that we 3635 // always receive the correct fiber here 3636 var internalInstance = getInstanceFromNode(target); 3637 3638 if (!internalInstance) { 3639 // Unmounted 3640 return; 3641 } 3642 3643 if (!(typeof restoreImpl === 'function')) { 3644 { 3645 throw Error( "setRestoreImplementation() needs to be called to handle a target for controlled events. This error is likely caused by a bug in React. Please file an issue." ); 3646 } 3647 } 3648 3649 var stateNode = internalInstance.stateNode; // Guard against Fiber being unmounted. 3650 3651 if (stateNode) { 3652 var _props = getFiberCurrentPropsFromNode(stateNode); 3653 3654 restoreImpl(internalInstance.stateNode, internalInstance.type, _props); 3655 } 3656} 3657 3658function setRestoreImplementation(impl) { 3659 restoreImpl = impl; 3660} 3661function enqueueStateRestore(target) { 3662 if (restoreTarget) { 3663 if (restoreQueue) { 3664 restoreQueue.push(target); 3665 } else { 3666 restoreQueue = [target]; 3667 } 3668 } else { 3669 restoreTarget = target; 3670 } 3671} 3672function needsStateRestore() { 3673 return restoreTarget !== null || restoreQueue !== null; 3674} 3675function restoreStateIfNeeded() { 3676 if (!restoreTarget) { 3677 return; 3678 } 3679 3680 var target = restoreTarget; 3681 var queuedTargets = restoreQueue; 3682 restoreTarget = null; 3683 restoreQueue = null; 3684 restoreStateOfTarget(target); 3685 3686 if (queuedTargets) { 3687 for (var i = 0; i < queuedTargets.length; i++) { 3688 restoreStateOfTarget(queuedTargets[i]); 3689 } 3690 } 3691} 3692 3693// the renderer. Such as when we're dispatching events or if third party 3694// libraries need to call batchedUpdates. Eventually, this API will go away when 3695// everything is batched by default. We'll then have a similar API to opt-out of 3696// scheduled work and instead do synchronous work. 3697// Defaults 3698 3699var batchedUpdatesImpl = function (fn, bookkeeping) { 3700 return fn(bookkeeping); 3701}; 3702 3703var discreteUpdatesImpl = function (fn, a, b, c, d) { 3704 return fn(a, b, c, d); 3705}; 3706 3707var flushDiscreteUpdatesImpl = function () {}; 3708 3709var batchedEventUpdatesImpl = batchedUpdatesImpl; 3710var isInsideEventHandler = false; 3711var isBatchingEventUpdates = false; 3712 3713function finishEventHandler() { 3714 // Here we wait until all updates have propagated, which is important 3715 // when using controlled components within layers: 3716 // https://github.com/facebook/react/issues/1698 3717 // Then we restore state of any controlled component. 3718 var controlledComponentsHavePendingUpdates = needsStateRestore(); 3719 3720 if (controlledComponentsHavePendingUpdates) { 3721 // If a controlled event was fired, we may need to restore the state of 3722 // the DOM node back to the controlled value. This is necessary when React 3723 // bails out of the update without touching the DOM. 3724 flushDiscreteUpdatesImpl(); 3725 restoreStateIfNeeded(); 3726 } 3727} 3728 3729function batchedUpdates(fn, bookkeeping) { 3730 if (isInsideEventHandler) { 3731 // If we are currently inside another batch, we need to wait until it 3732 // fully completes before restoring state. 3733 return fn(bookkeeping); 3734 } 3735 3736 isInsideEventHandler = true; 3737 3738 try { 3739 return batchedUpdatesImpl(fn, bookkeeping); 3740 } finally { 3741 isInsideEventHandler = false; 3742 finishEventHandler(); 3743 } 3744} 3745function batchedEventUpdates(fn, a, b) { 3746 if (isBatchingEventUpdates) { 3747 // If we are currently inside another batch, we need to wait until it 3748 // fully completes before restoring state. 3749 return fn(a, b); 3750 } 3751 3752 isBatchingEventUpdates = true; 3753 3754 try { 3755 return batchedEventUpdatesImpl(fn, a, b); 3756 } finally { 3757 isBatchingEventUpdates = false; 3758 finishEventHandler(); 3759 } 3760} 3761function discreteUpdates(fn, a, b, c, d) { 3762 var prevIsInsideEventHandler = isInsideEventHandler; 3763 isInsideEventHandler = true; 3764 3765 try { 3766 return discreteUpdatesImpl(fn, a, b, c, d); 3767 } finally { 3768 isInsideEventHandler = prevIsInsideEventHandler; 3769 3770 if (!isInsideEventHandler) { 3771 finishEventHandler(); 3772 } 3773 } 3774} 3775function flushDiscreteUpdatesIfNeeded(timeStamp) { 3776 { 3777 if (!isInsideEventHandler) { 3778 flushDiscreteUpdatesImpl(); 3779 } 3780 } 3781} 3782function setBatchingImplementation(_batchedUpdatesImpl, _discreteUpdatesImpl, _flushDiscreteUpdatesImpl, _batchedEventUpdatesImpl) { 3783 batchedUpdatesImpl = _batchedUpdatesImpl; 3784 discreteUpdatesImpl = _discreteUpdatesImpl; 3785 flushDiscreteUpdatesImpl = _flushDiscreteUpdatesImpl; 3786 batchedEventUpdatesImpl = _batchedEventUpdatesImpl; 3787} 3788 3789function isInteractive(tag) { 3790 return tag === 'button' || tag === 'input' || tag === 'select' || tag === 'textarea'; 3791} 3792 3793function shouldPreventMouseEvent(name, type, props) { 3794 switch (name) { 3795 case 'onClick': 3796 case 'onClickCapture': 3797 case 'onDoubleClick': 3798 case 'onDoubleClickCapture': 3799 case 'onMouseDown': 3800 case 'onMouseDownCapture': 3801 case 'onMouseMove': 3802 case 'onMouseMoveCapture': 3803 case 'onMouseUp': 3804 case 'onMouseUpCapture': 3805 case 'onMouseEnter': 3806 return !!(props.disabled && isInteractive(type)); 3807 3808 default: 3809 return false; 3810 } 3811} 3812/** 3813 * @param {object} inst The instance, which is the source of events. 3814 * @param {string} registrationName Name of listener (e.g. `onClick`). 3815 * @return {?function} The stored callback. 3816 */ 3817 3818 3819function getListener(inst, registrationName) { 3820 var stateNode = inst.stateNode; 3821 3822 if (stateNode === null) { 3823 // Work in progress (ex: onload events in incremental mode). 3824 return null; 3825 } 3826 3827 var props = getFiberCurrentPropsFromNode(stateNode); 3828 3829 if (props === null) { 3830 // Work in progress. 3831 return null; 3832 } 3833 3834 var listener = props[registrationName]; 3835 3836 if (shouldPreventMouseEvent(registrationName, inst.type, props)) { 3837 return null; 3838 } 3839 3840 if (!(!listener || typeof listener === 'function')) { 3841 { 3842 throw Error( "Expected `" + registrationName + "` listener to be a function, instead got a value of `" + typeof listener + "` type." ); 3843 } 3844 } 3845 3846 return listener; 3847} 3848 3849var passiveBrowserEventsSupported = false; // Check if browser support events with passive listeners 3850// https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#Safely_detecting_option_support 3851 3852if (canUseDOM) { 3853 try { 3854 var options = {}; // $FlowFixMe: Ignore Flow complaining about needing a value 3855 3856 Object.defineProperty(options, 'passive', { 3857 get: function () { 3858 passiveBrowserEventsSupported = true; 3859 } 3860 }); 3861 window.addEventListener('test', options, options); 3862 window.removeEventListener('test', options, options); 3863 } catch (e) { 3864 passiveBrowserEventsSupported = false; 3865 } 3866} 3867 3868function invokeGuardedCallbackProd(name, func, context, a, b, c, d, e, f) { 3869 var funcArgs = Array.prototype.slice.call(arguments, 3); 3870 3871 try { 3872 func.apply(context, funcArgs); 3873 } catch (error) { 3874 this.onError(error); 3875 } 3876} 3877 3878var invokeGuardedCallbackImpl = invokeGuardedCallbackProd; 3879 3880{ 3881 // In DEV mode, we swap out invokeGuardedCallback for a special version 3882 // that plays more nicely with the browser's DevTools. The idea is to preserve 3883 // "Pause on exceptions" behavior. Because React wraps all user-provided 3884 // functions in invokeGuardedCallback, and the production version of 3885 // invokeGuardedCallback uses a try-catch, all user exceptions are treated 3886 // like caught exceptions, and the DevTools won't pause unless the developer 3887 // takes the extra step of enabling pause on caught exceptions. This is 3888 // unintuitive, though, because even though React has caught the error, from 3889 // the developer's perspective, the error is uncaught. 3890 // 3891 // To preserve the expected "Pause on exceptions" behavior, we don't use a 3892 // try-catch in DEV. Instead, we synchronously dispatch a fake event to a fake 3893 // DOM node, and call the user-provided callback from inside an event handler 3894 // for that fake event. If the callback throws, the error is "captured" using 3895 // a global event handler. But because the error happens in a different 3896 // event loop context, it does not interrupt the normal program flow. 3897 // Effectively, this gives us try-catch behavior without actually using 3898 // try-catch. Neat! 3899 // Check that the browser supports the APIs we need to implement our special 3900 // DEV version of invokeGuardedCallback 3901 if (typeof window !== 'undefined' && typeof window.dispatchEvent === 'function' && typeof document !== 'undefined' && typeof document.createEvent === 'function') { 3902 var fakeNode = document.createElement('react'); 3903 3904 invokeGuardedCallbackImpl = function invokeGuardedCallbackDev(name, func, context, a, b, c, d, e, f) { 3905 // If document doesn't exist we know for sure we will crash in this method 3906 // when we call document.createEvent(). However this can cause confusing 3907 // errors: https://github.com/facebookincubator/create-react-app/issues/3482 3908 // So we preemptively throw with a better message instead. 3909 if (!(typeof document !== 'undefined')) { 3910 { 3911 throw Error( "The `document` global was defined when React was initialized, but is not defined anymore. This can happen in a test environment if a component schedules an update from an asynchronous callback, but the test has already finished running. To solve this, you can either unmount the component at the end of your test (and ensure that any asynchronous operations get canceled in `componentWillUnmount`), or you can change the test itself to be asynchronous." ); 3912 } 3913 } 3914 3915 var evt = document.createEvent('Event'); 3916 var didCall = false; // Keeps track of whether the user-provided callback threw an error. We 3917 // set this to true at the beginning, then set it to false right after 3918 // calling the function. If the function errors, `didError` will never be 3919 // set to false. This strategy works even if the browser is flaky and 3920 // fails to call our global error handler, because it doesn't rely on 3921 // the error event at all. 3922 3923 var didError = true; // Keeps track of the value of window.event so that we can reset it 3924 // during the callback to let user code access window.event in the 3925 // browsers that support it. 3926 3927 var windowEvent = window.event; // Keeps track of the descriptor of window.event to restore it after event 3928 // dispatching: https://github.com/facebook/react/issues/13688 3929 3930 var windowEventDescriptor = Object.getOwnPropertyDescriptor(window, 'event'); 3931 3932 function restoreAfterDispatch() { 3933 // We immediately remove the callback from event listeners so that 3934 // nested `invokeGuardedCallback` calls do not clash. Otherwise, a 3935 // nested call would trigger the fake event handlers of any call higher 3936 // in the stack. 3937 fakeNode.removeEventListener(evtType, callCallback, false); // We check for window.hasOwnProperty('event') to prevent the 3938 // window.event assignment in both IE <= 10 as they throw an error 3939 // "Member not found" in strict mode, and in Firefox which does not 3940 // support window.event. 3941 3942 if (typeof window.event !== 'undefined' && window.hasOwnProperty('event')) { 3943 window.event = windowEvent; 3944 } 3945 } // Create an event handler for our fake event. We will synchronously 3946 // dispatch our fake event using `dispatchEvent`. Inside the handler, we 3947 // call the user-provided callback. 3948 3949 3950 var funcArgs = Array.prototype.slice.call(arguments, 3); 3951 3952 function callCallback() { 3953 didCall = true; 3954 restoreAfterDispatch(); 3955 func.apply(context, funcArgs); 3956 didError = false; 3957 } // Create a global error event handler. We use this to capture the value 3958 // that was thrown. It's possible that this error handler will fire more 3959 // than once; for example, if non-React code also calls `dispatchEvent` 3960 // and a handler for that event throws. We should be resilient to most of 3961 // those cases. Even if our error event handler fires more than once, the 3962 // last error event is always used. If the callback actually does error, 3963 // we know that the last error event is the correct one, because it's not 3964 // possible for anything else to have happened in between our callback 3965 // erroring and the code that follows the `dispatchEvent` call below. If 3966 // the callback doesn't error, but the error event was fired, we know to 3967 // ignore it because `didError` will be false, as described above. 3968 3969 3970 var error; // Use this to track whether the error event is ever called. 3971 3972 var didSetError = false; 3973 var isCrossOriginError = false; 3974 3975 function handleWindowError(event) { 3976 error = event.error; 3977 didSetError = true; 3978 3979 if (error === null && event.colno === 0 && event.lineno === 0) { 3980 isCrossOriginError = true; 3981 } 3982 3983 if (event.defaultPrevented) { 3984 // Some other error handler has prevented default. 3985 // Browsers silence the error report if this happens. 3986 // We'll remember this to later decide whether to log it or not. 3987 if (error != null && typeof error === 'object') { 3988 try { 3989 error._suppressLogging = true; 3990 } catch (inner) {// Ignore. 3991 } 3992 } 3993 } 3994 } // Create a fake event type. 3995 3996 3997 var evtType = "react-" + (name ? name : 'invokeguardedcallback'); // Attach our event handlers 3998 3999 window.addEventListener('error', handleWindowError); 4000 fakeNode.addEventListener(evtType, callCallback, false); // Synchronously dispatch our fake event. If the user-provided function 4001 // errors, it will trigger our global error handler. 4002 4003 evt.initEvent(evtType, false, false); 4004 fakeNode.dispatchEvent(evt); 4005 4006 if (windowEventDescriptor) { 4007 Object.defineProperty(window, 'event', windowEventDescriptor); 4008 } 4009 4010 if (didCall && didError) { 4011 if (!didSetError) { 4012 // The callback errored, but the error event never fired. 4013 error = new Error('An error was thrown inside one of your components, but React ' + "doesn't know what it was. This is likely due to browser " + 'flakiness. React does its best to preserve the "Pause on ' + 'exceptions" behavior of the DevTools, which requires some ' + "DEV-mode only tricks. It's possible that these don't work in " + 'your browser. Try triggering the error in production mode, ' + 'or switching to a modern browser. If you suspect that this is ' + 'actually an issue with React, please file an issue.'); 4014 } else if (isCrossOriginError) { 4015 error = new Error("A cross-origin error was thrown. React doesn't have access to " + 'the actual error object in development. ' + 'See https://reactjs.org/link/crossorigin-error for more information.'); 4016 } 4017 4018 this.onError(error); 4019 } // Remove our event listeners 4020 4021 4022 window.removeEventListener('error', handleWindowError); 4023 4024 if (!didCall) { 4025 // Something went really wrong, and our event was not dispatched. 4026 // https://github.com/facebook/react/issues/16734 4027 // https://github.com/facebook/react/issues/16585 4028 // Fall back to the production implementation. 4029 restoreAfterDispatch(); 4030 return invokeGuardedCallbackProd.apply(this, arguments); 4031 } 4032 }; 4033 } 4034} 4035 4036var invokeGuardedCallbackImpl$1 = invokeGuardedCallbackImpl; 4037 4038var hasError = false; 4039var caughtError = null; // Used by event system to capture/rethrow the first error. 4040 4041var hasRethrowError = false; 4042var rethrowError = null; 4043var reporter = { 4044 onError: function (error) { 4045 hasError = true; 4046 caughtError = error; 4047 } 4048}; 4049/** 4050 * Call a function while guarding against errors that happens within it. 4051 * Returns an error if it throws, otherwise null. 4052 * 4053 * In production, this is implemented using a try-catch. The reason we don't 4054 * use a try-catch directly is so that we can swap out a different 4055 * implementation in DEV mode. 4056 * 4057 * @param {String} name of the guard to use for logging or debugging 4058 * @param {Function} func The function to invoke 4059 * @param {*} context The context to use when calling the function 4060 * @param {...*} args Arguments for function 4061 */ 4062 4063function invokeGuardedCallback(name, func, context, a, b, c, d, e, f) { 4064 hasError = false; 4065 caughtError = null; 4066 invokeGuardedCallbackImpl$1.apply(reporter, arguments); 4067} 4068/** 4069 * Same as invokeGuardedCallback, but instead of returning an error, it stores 4070 * it in a global so it can be rethrown by `rethrowCaughtError` later. 4071 * TODO: See if caughtError and rethrowError can be unified. 4072 * 4073 * @param {String} name of the guard to use for logging or debugging 4074 * @param {Function} func The function to invoke 4075 * @param {*} context The context to use when calling the function 4076 * @param {...*} args Arguments for function 4077 */ 4078 4079function invokeGuardedCallbackAndCatchFirstError(name, func, context, a, b, c, d, e, f) { 4080 invokeGuardedCallback.apply(this, arguments); 4081 4082 if (hasError) { 4083 var error = clearCaughtError(); 4084 4085 if (!hasRethrowError) { 4086 hasRethrowError = true; 4087 rethrowError = error; 4088 } 4089 } 4090} 4091/** 4092 * During execution of guarded functions we will capture the first error which 4093 * we will rethrow to be handled by the top level error handler. 4094 */ 4095 4096function rethrowCaughtError() { 4097 if (hasRethrowError) { 4098 var error = rethrowError; 4099 hasRethrowError = false; 4100 rethrowError = null; 4101 throw error; 4102 } 4103} 4104function hasCaughtError() { 4105 return hasError; 4106} 4107function clearCaughtError() { 4108 if (hasError) { 4109 var error = caughtError; 4110 hasError = false; 4111 caughtError = null; 4112 return error; 4113 } else { 4114 { 4115 { 4116 throw Error( "clearCaughtError was called but no error was captured. This error is likely caused by a bug in React. Please file an issue." ); 4117 } 4118 } 4119 } 4120} 4121 4122/** 4123 * `ReactInstanceMap` maintains a mapping from a public facing stateful 4124 * instance (key) and the internal representation (value). This allows public 4125 * methods to accept the user facing instance as an argument and map them back 4126 * to internal methods. 4127 * 4128 * Note that this module is currently shared and assumed to be stateless. 4129 * If this becomes an actual Map, that will break. 4130 */ 4131function get(key) { 4132 return key._reactInternals; 4133} 4134function has(key) { 4135 return key._reactInternals !== undefined; 4136} 4137function set(key, value) { 4138 key._reactInternals = value; 4139} 4140 4141// Don't change these two values. They're used by React Dev Tools. 4142var NoFlags = 4143/* */ 41440; 4145var PerformedWork = 4146/* */ 41471; // You can change the rest (and add more). 4148 4149var Placement = 4150/* */ 41512; 4152var Update = 4153/* */ 41544; 4155var PlacementAndUpdate = 4156/* */ 41576; 4158var Deletion = 4159/* */ 41608; 4161var ContentReset = 4162/* */ 416316; 4164var Callback = 4165/* */ 416632; 4167var DidCapture = 4168/* */ 416964; 4170var Ref = 4171/* */ 4172128; 4173var Snapshot = 4174/* */ 4175256; 4176var Passive = 4177/* */ 4178512; // TODO (effects) Remove this bit once the new reconciler is synced to the old. 4179 4180var PassiveUnmountPendingDev = 4181/* */ 41828192; 4183var Hydrating = 4184/* */ 41851024; 4186var HydratingAndUpdate = 4187/* */ 41881028; // Passive & Update & Callback & Ref & Snapshot 4189 4190var LifecycleEffectMask = 4191/* */ 4192932; // Union of all host effects 4193 4194var HostEffectMask = 4195/* */ 41962047; // These are not really side effects, but we still reuse this field. 4197 4198var Incomplete = 4199/* */ 42002048; 4201var ShouldCapture = 4202/* */ 42034096; 4204var ForceUpdateForLegacySuspense = 4205/* */ 420616384; // Static tags describe aspects of a fiber that are not specific to a render, 4207 4208var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner; 4209function getNearestMountedFiber(fiber) { 4210 var node = fiber; 4211 var nearestMounted = fiber; 4212 4213 if (!fiber.alternate) { 4214 // If there is no alternate, this might be a new tree that isn't inserted 4215 // yet. If it is, then it will have a pending insertion effect on it. 4216 var nextNode = node; 4217 4218 do { 4219 node = nextNode; 4220 4221 if ((node.flags & (Placement | Hydrating)) !== NoFlags) { 4222 // This is an insertion or in-progress hydration. The nearest possible 4223 // mounted fiber is the parent but we need to continue to figure out 4224 // if that one is still mounted. 4225 nearestMounted = node.return; 4226 } 4227 4228 nextNode = node.return; 4229 } while (nextNode); 4230 } else { 4231 while (node.return) { 4232 node = node.return; 4233 } 4234 } 4235 4236 if (node.tag === HostRoot) { 4237 // TODO: Check if this was a nested HostRoot when used with 4238 // renderContainerIntoSubtree. 4239 return nearestMounted; 4240 } // If we didn't hit the root, that means that we're in an disconnected tree 4241 // that has been unmounted. 4242 4243 4244 return null; 4245} 4246function getSuspenseInstanceFromFiber(fiber) { 4247 if (fiber.tag === SuspenseComponent) { 4248 var suspenseState = fiber.memoizedState; 4249 4250 if (suspenseState === null) { 4251 var current = fiber.alternate; 4252 4253 if (current !== null) { 4254 suspenseState = current.memoizedState; 4255 } 4256 } 4257 4258 if (suspenseState !== null) { 4259 return suspenseState.dehydrated; 4260 } 4261 } 4262 4263 return null; 4264} 4265function getContainerFromFiber(fiber) { 4266 return fiber.tag === HostRoot ? fiber.stateNode.containerInfo : null; 4267} 4268function isFiberMounted(fiber) { 4269 return getNearestMountedFiber(fiber) === fiber; 4270} 4271function isMounted(component) { 4272 { 4273 var owner = ReactCurrentOwner.current; 4274 4275 if (owner !== null && owner.tag === ClassComponent) { 4276 var ownerFiber = owner; 4277 var instance = ownerFiber.stateNode; 4278 4279 if (!instance._warnedAboutRefsInRender) { 4280 error('%s is accessing isMounted inside its render() function. ' + 'render() should be a pure function of props and state. It should ' + 'never access something that requires stale data from the previous ' + 'render, such as refs. Move this logic to componentDidMount and ' + 'componentDidUpdate instead.', getComponentName(ownerFiber.type) || 'A component'); 4281 } 4282 4283 instance._warnedAboutRefsInRender = true; 4284 } 4285 } 4286 4287 var fiber = get(component); 4288 4289 if (!fiber) { 4290 return false; 4291 } 4292 4293 return getNearestMountedFiber(fiber) === fiber; 4294} 4295 4296function assertIsMounted(fiber) { 4297 if (!(getNearestMountedFiber(fiber) === fiber)) { 4298 { 4299 throw Error( "Unable to find node on an unmounted component." ); 4300 } 4301 } 4302} 4303 4304function findCurrentFiberUsingSlowPath(fiber) { 4305 var alternate = fiber.alternate; 4306 4307 if (!alternate) { 4308 // If there is no alternate, then we only need to check if it is mounted. 4309 var nearestMounted = getNearestMountedFiber(fiber); 4310 4311 if (!(nearestMounted !== null)) { 4312 { 4313 throw Error( "Unable to find node on an unmounted component." ); 4314 } 4315 } 4316 4317 if (nearestMounted !== fiber) { 4318 return null; 4319 } 4320 4321 return fiber; 4322 } // If we have two possible branches, we'll walk backwards up to the root 4323 // to see what path the root points to. On the way we may hit one of the 4324 // special cases and we'll deal with them. 4325 4326 4327 var a = fiber; 4328 var b = alternate; 4329 4330 while (true) { 4331 var parentA = a.return; 4332 4333 if (parentA === null) { 4334 // We're at the root. 4335 break; 4336 } 4337 4338 var parentB = parentA.alternate; 4339 4340 if (parentB === null) { 4341 // There is no alternate. This is an unusual case. Currently, it only 4342 // happens when a Suspense component is hidden. An extra fragment fiber 4343 // is inserted in between the Suspense fiber and its children. Skip 4344 // over this extra fragment fiber and proceed to the next parent. 4345 var nextParent = parentA.return; 4346 4347 if (nextParent !== null) { 4348 a = b = nextParent; 4349 continue; 4350 } // If there's no parent, we're at the root. 4351 4352 4353 break; 4354 } // If both copies of the parent fiber point to the same child, we can 4355 // assume that the child is current. This happens when we bailout on low 4356 // priority: the bailed out fiber's child reuses the current child. 4357 4358 4359 if (parentA.child === parentB.child) { 4360 var child = parentA.child; 4361 4362 while (child) { 4363 if (child === a) { 4364 // We've determined that A is the current branch. 4365 assertIsMounted(parentA); 4366 return fiber; 4367 } 4368 4369 if (child === b) { 4370 // We've determined that B is the current branch. 4371 assertIsMounted(parentA); 4372 return alternate; 4373 } 4374 4375 child = child.sibling; 4376 } // We should never have an alternate for any mounting node. So the only 4377 // way this could possibly happen is if this was unmounted, if at all. 4378 4379 4380 { 4381 { 4382 throw Error( "Unable to find node on an unmounted component." ); 4383 } 4384 } 4385 } 4386 4387 if (a.return !== b.return) { 4388 // The return pointer of A and the return pointer of B point to different 4389 // fibers. We assume that return pointers never criss-cross, so A must 4390 // belong to the child set of A.return, and B must belong to the child 4391 // set of B.return. 4392 a = parentA; 4393 b = parentB; 4394 } else { 4395 // The return pointers point to the same fiber. We'll have to use the 4396 // default, slow path: scan the child sets of each parent alternate to see 4397 // which child belongs to which set. 4398 // 4399 // Search parent A's child set 4400 var didFindChild = false; 4401 var _child = parentA.child; 4402 4403 while (_child) { 4404 if (_child === a) { 4405 didFindChild = true; 4406 a = parentA; 4407 b = parentB; 4408 break; 4409 } 4410 4411 if (_child === b) { 4412 didFindChild = true; 4413 b = parentA; 4414 a = parentB; 4415 break; 4416 } 4417 4418 _child = _child.sibling; 4419 } 4420 4421 if (!didFindChild) { 4422 // Search parent B's child set 4423 _child = parentB.child; 4424 4425 while (_child) { 4426 if (_child === a) { 4427 didFindChild = true; 4428 a = parentB; 4429 b = parentA; 4430 break; 4431 } 4432 4433 if (_child === b) { 4434 didFindChild = true; 4435 b = parentB; 4436 a = parentA; 4437 break; 4438 } 4439 4440 _child = _child.sibling; 4441 } 4442 4443 if (!didFindChild) { 4444 { 4445 throw Error( "Child was not found in either parent set. This indicates a bug in React related to the return pointer. Please file an issue." ); 4446 } 4447 } 4448 } 4449 } 4450 4451 if (!(a.alternate === b)) { 4452 { 4453 throw Error( "Return fibers should always be each others' alternates. This error is likely caused by a bug in React. Please file an issue." ); 4454 } 4455 } 4456 } // If the root is not a host container, we're in a disconnected tree. I.e. 4457 // unmounted. 4458 4459 4460 if (!(a.tag === HostRoot)) { 4461 { 4462 throw Error( "Unable to find node on an unmounted component." ); 4463 } 4464 } 4465 4466 if (a.stateNode.current === a) { 4467 // We've determined that A is the current branch. 4468 return fiber; 4469 } // Otherwise B has to be current branch. 4470 4471 4472 return alternate; 4473} 4474function findCurrentHostFiber(parent) { 4475 var currentParent = findCurrentFiberUsingSlowPath(parent); 4476 4477 if (!currentParent) { 4478 return null; 4479 } // Next we'll drill down this component to find the first HostComponent/Text. 4480 4481 4482 var node = currentParent; 4483 4484 while (true) { 4485 if (node.tag === HostComponent || node.tag === HostText) { 4486 return node; 4487 } else if (node.child) { 4488 node.child.return = node; 4489 node = node.child; 4490 continue; 4491 } 4492 4493 if (node === currentParent) { 4494 return null; 4495 } 4496 4497 while (!node.sibling) { 4498 if (!node.return || node.return === currentParent) { 4499 return null; 4500 } 4501 4502 node = node.return; 4503 } 4504 4505 node.sibling.return = node.return; 4506 node = node.sibling; 4507 } // Flow needs the return null here, but ESLint complains about it. 4508 // eslint-disable-next-line no-unreachable 4509 4510 4511 return null; 4512} 4513function findCurrentHostFiberWithNoPortals(parent) { 4514 var currentParent = findCurrentFiberUsingSlowPath(parent); 4515 4516 if (!currentParent) { 4517 return null; 4518 } // Next we'll drill down this component to find the first HostComponent/Text. 4519 4520 4521 var node = currentParent; 4522 4523 while (true) { 4524 if (node.tag === HostComponent || node.tag === HostText || enableFundamentalAPI ) { 4525 return node; 4526 } else if (node.child && node.tag !== HostPortal) { 4527 node.child.return = node; 4528 node = node.child; 4529 continue; 4530 } 4531 4532 if (node === currentParent) { 4533 return null; 4534 } 4535 4536 while (!node.sibling) { 4537 if (!node.return || node.return === currentParent) { 4538 return null; 4539 } 4540 4541 node = node.return; 4542 } 4543 4544 node.sibling.return = node.return; 4545 node = node.sibling; 4546 } // Flow needs the return null here, but ESLint complains about it. 4547 // eslint-disable-next-line no-unreachable 4548 4549 4550 return null; 4551} 4552function doesFiberContain(parentFiber, childFiber) { 4553 var node = childFiber; 4554 var parentFiberAlternate = parentFiber.alternate; 4555 4556 while (node !== null) { 4557 if (node === parentFiber || node === parentFiberAlternate) { 4558 return true; 4559 } 4560 4561 node = node.return; 4562 } 4563 4564 return false; 4565} 4566 4567var attemptUserBlockingHydration; 4568function setAttemptUserBlockingHydration(fn) { 4569 attemptUserBlockingHydration = fn; 4570} 4571var attemptContinuousHydration; 4572function setAttemptContinuousHydration(fn) { 4573 attemptContinuousHydration = fn; 4574} 4575var attemptHydrationAtCurrentPriority; 4576function setAttemptHydrationAtCurrentPriority(fn) { 4577 attemptHydrationAtCurrentPriority = fn; 4578} 4579var attemptHydrationAtPriority; 4580function setAttemptHydrationAtPriority(fn) { 4581 attemptHydrationAtPriority = fn; 4582} // TODO: Upgrade this definition once we're on a newer version of Flow that 4583var hasScheduledReplayAttempt = false; // The queue of discrete events to be replayed. 4584 4585var queuedDiscreteEvents = []; // Indicates if any continuous event targets are non-null for early bailout. 4586// if the last target was dehydrated. 4587 4588var queuedFocus = null; 4589var queuedDrag = null; 4590var queuedMouse = null; // For pointer events there can be one latest event per pointerId. 4591 4592var queuedPointers = new Map(); 4593var queuedPointerCaptures = new Map(); // We could consider replaying selectionchange and touchmoves too. 4594 4595var queuedExplicitHydrationTargets = []; 4596function hasQueuedDiscreteEvents() { 4597 return queuedDiscreteEvents.length > 0; 4598} 4599var discreteReplayableEvents = ['mousedown', 'mouseup', 'touchcancel', 'touchend', 'touchstart', 'auxclick', 'dblclick', 'pointercancel', 'pointerdown', 'pointerup', 'dragend', 'dragstart', 'drop', 'compositionend', 'compositionstart', 'keydown', 'keypress', 'keyup', 'input', 'textInput', // Intentionally camelCase 4600'copy', 'cut', 'paste', 'click', 'change', 'contextmenu', 'reset', 'submit']; 4601function isReplayableDiscreteEvent(eventType) { 4602 return discreteReplayableEvents.indexOf(eventType) > -1; 4603} 4604 4605function createQueuedReplayableEvent(blockedOn, domEventName, eventSystemFlags, targetContainer, nativeEvent) { 4606 return { 4607 blockedOn: blockedOn, 4608 domEventName: domEventName, 4609 eventSystemFlags: eventSystemFlags | IS_REPLAYED, 4610 nativeEvent: nativeEvent, 4611 targetContainers: [targetContainer] 4612 }; 4613} 4614 4615function queueDiscreteEvent(blockedOn, domEventName, eventSystemFlags, targetContainer, nativeEvent) { 4616 var queuedEvent = createQueuedReplayableEvent(blockedOn, domEventName, eventSystemFlags, targetContainer, nativeEvent); 4617 queuedDiscreteEvents.push(queuedEvent); 4618} // Resets the replaying for this type of continuous event to no event. 4619 4620function clearIfContinuousEvent(domEventName, nativeEvent) { 4621 switch (domEventName) { 4622 case 'focusin': 4623 case 'focusout': 4624 queuedFocus = null; 4625 break; 4626 4627 case 'dragenter': 4628 case 'dragleave': 4629 queuedDrag = null; 4630 break; 4631 4632 case 'mouseover': 4633 case 'mouseout': 4634 queuedMouse = null; 4635 break; 4636 4637 case 'pointerover': 4638 case 'pointerout': 4639 { 4640 var pointerId = nativeEvent.pointerId; 4641 queuedPointers.delete(pointerId); 4642 break; 4643 } 4644 4645 case 'gotpointercapture': 4646 case 'lostpointercapture': 4647 { 4648 var _pointerId = nativeEvent.pointerId; 4649 queuedPointerCaptures.delete(_pointerId); 4650 break; 4651 } 4652 } 4653} 4654 4655function accumulateOrCreateContinuousQueuedReplayableEvent(existingQueuedEvent, blockedOn, domEventName, eventSystemFlags, targetContainer, nativeEvent) { 4656 if (existingQueuedEvent === null || existingQueuedEvent.nativeEvent !== nativeEvent) { 4657 var queuedEvent = createQueuedReplayableEvent(blockedOn, domEventName, eventSystemFlags, targetContainer, nativeEvent); 4658 4659 if (blockedOn !== null) { 4660 var _fiber2 = getInstanceFromNode(blockedOn); 4661 4662 if (_fiber2 !== null) { 4663 // Attempt to increase the priority of this target. 4664 attemptContinuousHydration(_fiber2); 4665 } 4666 } 4667 4668 return queuedEvent; 4669 } // If we have already queued this exact event, then it's because 4670 // the different event systems have different DOM event listeners. 4671 // We can accumulate the flags, and the targetContainers, and 4672 // store a single event to be replayed. 4673 4674 4675 existingQueuedEvent.eventSystemFlags |= eventSystemFlags; 4676 var targetContainers = existingQueuedEvent.targetContainers; 4677 4678 if (targetContainer !== null && targetContainers.indexOf(targetContainer) === -1) { 4679 targetContainers.push(targetContainer); 4680 } 4681 4682 return existingQueuedEvent; 4683} 4684 4685function queueIfContinuousEvent(blockedOn, domEventName, eventSystemFlags, targetContainer, nativeEvent) { 4686 // These set relatedTarget to null because the replayed event will be treated as if we 4687 // moved from outside the window (no target) onto the target once it hydrates. 4688 // Instead of mutating we could clone the event. 4689 switch (domEventName) { 4690 case 'focusin': 4691 { 4692 var focusEvent = nativeEvent; 4693 queuedFocus = accumulateOrCreateContinuousQueuedReplayableEvent(queuedFocus, blockedOn, domEventName, eventSystemFlags, targetContainer, focusEvent); 4694 return true; 4695 } 4696 4697 case 'dragenter': 4698 { 4699 var dragEvent = nativeEvent; 4700 queuedDrag = accumulateOrCreateContinuousQueuedReplayableEvent(queuedDrag, blockedOn, domEventName, eventSystemFlags, targetContainer, dragEvent); 4701 return true; 4702 } 4703 4704 case 'mouseover': 4705 { 4706 var mouseEvent = nativeEvent; 4707 queuedMouse = accumulateOrCreateContinuousQueuedReplayableEvent(queuedMouse, blockedOn, domEventName, eventSystemFlags, targetContainer, mouseEvent); 4708 return true; 4709 } 4710 4711 case 'pointerover': 4712 { 4713 var pointerEvent = nativeEvent; 4714 var pointerId = pointerEvent.pointerId; 4715 queuedPointers.set(pointerId, accumulateOrCreateContinuousQueuedReplayableEvent(queuedPointers.get(pointerId) || null, blockedOn, domEventName, eventSystemFlags, targetContainer, pointerEvent)); 4716 return true; 4717 } 4718 4719 case 'gotpointercapture': 4720 { 4721 var _pointerEvent = nativeEvent; 4722 var _pointerId2 = _pointerEvent.pointerId; 4723 queuedPointerCaptures.set(_pointerId2, accumulateOrCreateContinuousQueuedReplayableEvent(queuedPointerCaptures.get(_pointerId2) || null, blockedOn, domEventName, eventSystemFlags, targetContainer, _pointerEvent)); 4724 return true; 4725 } 4726 } 4727 4728 return false; 4729} // Check if this target is unblocked. Returns true if it's unblocked. 4730 4731function attemptExplicitHydrationTarget(queuedTarget) { 4732 // TODO: This function shares a lot of logic with attemptToDispatchEvent. 4733 // Try to unify them. It's a bit tricky since it would require two return 4734 // values. 4735 var targetInst = getClosestInstanceFromNode(queuedTarget.target); 4736 4737 if (targetInst !== null) { 4738 var nearestMounted = getNearestMountedFiber(targetInst); 4739 4740 if (nearestMounted !== null) { 4741 var tag = nearestMounted.tag; 4742 4743 if (tag === SuspenseComponent) { 4744 var instance = getSuspenseInstanceFromFiber(nearestMounted); 4745 4746 if (instance !== null) { 4747 // We're blocked on hydrating this boundary. 4748 // Increase its priority. 4749 queuedTarget.blockedOn = instance; 4750 attemptHydrationAtPriority(queuedTarget.lanePriority, function () { 4751 Scheduler.unstable_runWithPriority(queuedTarget.priority, function () { 4752 attemptHydrationAtCurrentPriority(nearestMounted); 4753 }); 4754 }); 4755 return; 4756 } 4757 } else if (tag === HostRoot) { 4758 var root = nearestMounted.stateNode; 4759 4760 if (root.hydrate) { 4761 queuedTarget.blockedOn = getContainerFromFiber(nearestMounted); // We don't currently have a way to increase the priority of 4762 // a root other than sync. 4763 4764 return; 4765 } 4766 } 4767 } 4768 } 4769 4770 queuedTarget.blockedOn = null; 4771} 4772 4773function attemptReplayContinuousQueuedEvent(queuedEvent) { 4774 if (queuedEvent.blockedOn !== null) { 4775 return false; 4776 } 4777 4778 var targetContainers = queuedEvent.targetContainers; 4779 4780 while (targetContainers.length > 0) { 4781 var targetContainer = targetContainers[0]; 4782 var nextBlockedOn = attemptToDispatchEvent(queuedEvent.domEventName, queuedEvent.eventSystemFlags, targetContainer, queuedEvent.nativeEvent); 4783 4784 if (nextBlockedOn !== null) { 4785 // We're still blocked. Try again later. 4786 var _fiber3 = getInstanceFromNode(nextBlockedOn); 4787 4788 if (_fiber3 !== null) { 4789 attemptContinuousHydration(_fiber3); 4790 } 4791 4792 queuedEvent.blockedOn = nextBlockedOn; 4793 return false; 4794 } // This target container was successfully dispatched. Try the next. 4795 4796 4797 targetContainers.shift(); 4798 } 4799 4800 return true; 4801} 4802 4803function attemptReplayContinuousQueuedEventInMap(queuedEvent, key, map) { 4804 if (attemptReplayContinuousQueuedEvent(queuedEvent)) { 4805 map.delete(key); 4806 } 4807} 4808 4809function replayUnblockedEvents() { 4810 hasScheduledReplayAttempt = false; // First replay discrete events. 4811 4812 while (queuedDiscreteEvents.length > 0) { 4813 var nextDiscreteEvent = queuedDiscreteEvents[0]; 4814 4815 if (nextDiscreteEvent.blockedOn !== null) { 4816 // We're still blocked. 4817 // Increase the priority of this boundary to unblock 4818 // the next discrete event. 4819 var _fiber4 = getInstanceFromNode(nextDiscreteEvent.blockedOn); 4820 4821 if (_fiber4 !== null) { 4822 attemptUserBlockingHydration(_fiber4); 4823 } 4824 4825 break; 4826 } 4827 4828 var targetContainers = nextDiscreteEvent.targetContainers; 4829 4830 while (targetContainers.length > 0) { 4831 var targetContainer = targetContainers[0]; 4832 var nextBlockedOn = attemptToDispatchEvent(nextDiscreteEvent.domEventName, nextDiscreteEvent.eventSystemFlags, targetContainer, nextDiscreteEvent.nativeEvent); 4833 4834 if (nextBlockedOn !== null) { 4835 // We're still blocked. Try again later. 4836 nextDiscreteEvent.blockedOn = nextBlockedOn; 4837 break; 4838 } // This target container was successfully dispatched. Try the next. 4839 4840 4841 targetContainers.shift(); 4842 } 4843 4844 if (nextDiscreteEvent.blockedOn === null) { 4845 // We've successfully replayed the first event. Let's try the next one. 4846 queuedDiscreteEvents.shift(); 4847 } 4848 } // Next replay any continuous events. 4849 4850 4851 if (queuedFocus !== null && attemptReplayContinuousQueuedEvent(queuedFocus)) { 4852 queuedFocus = null; 4853 } 4854 4855 if (queuedDrag !== null && attemptReplayContinuousQueuedEvent(queuedDrag)) { 4856 queuedDrag = null; 4857 } 4858 4859 if (queuedMouse !== null && attemptReplayContinuousQueuedEvent(queuedMouse)) { 4860 queuedMouse = null; 4861 } 4862 4863 queuedPointers.forEach(attemptReplayContinuousQueuedEventInMap); 4864 queuedPointerCaptures.forEach(attemptReplayContinuousQueuedEventInMap); 4865} 4866 4867function scheduleCallbackIfUnblocked(queuedEvent, unblocked) { 4868 if (queuedEvent.blockedOn === unblocked) { 4869 queuedEvent.blockedOn = null; 4870 4871 if (!hasScheduledReplayAttempt) { 4872 hasScheduledReplayAttempt = true; // Schedule a callback to attempt replaying as many events as are 4873 // now unblocked. This first might not actually be unblocked yet. 4874 // We could check it early to avoid scheduling an unnecessary callback. 4875 4876 Scheduler.unstable_scheduleCallback(Scheduler.unstable_NormalPriority, replayUnblockedEvents); 4877 } 4878 } 4879} 4880 4881function retryIfBlockedOn(unblocked) { 4882 // Mark anything that was blocked on this as no longer blocked 4883 // and eligible for a replay. 4884 if (queuedDiscreteEvents.length > 0) { 4885 scheduleCallbackIfUnblocked(queuedDiscreteEvents[0], unblocked); // This is a exponential search for each boundary that commits. I think it's 4886 // worth it because we expect very few discrete events to queue up and once 4887 // we are actually fully unblocked it will be fast to replay them. 4888 4889 for (var i = 1; i < queuedDiscreteEvents.length; i++) { 4890 var queuedEvent = queuedDiscreteEvents[i]; 4891 4892 if (queuedEvent.blockedOn === unblocked) { 4893 queuedEvent.blockedOn = null; 4894 } 4895 } 4896 } 4897 4898 if (queuedFocus !== null) { 4899 scheduleCallbackIfUnblocked(queuedFocus, unblocked); 4900 } 4901 4902 if (queuedDrag !== null) { 4903 scheduleCallbackIfUnblocked(queuedDrag, unblocked); 4904 } 4905 4906 if (queuedMouse !== null) { 4907 scheduleCallbackIfUnblocked(queuedMouse, unblocked); 4908 } 4909 4910 var unblock = function (queuedEvent) { 4911 return scheduleCallbackIfUnblocked(queuedEvent, unblocked); 4912 }; 4913 4914 queuedPointers.forEach(unblock); 4915 queuedPointerCaptures.forEach(unblock); 4916 4917 for (var _i = 0; _i < queuedExplicitHydrationTargets.length; _i++) { 4918 var queuedTarget = queuedExplicitHydrationTargets[_i]; 4919 4920 if (queuedTarget.blockedOn === unblocked) { 4921 queuedTarget.blockedOn = null; 4922 } 4923 } 4924 4925 while (queuedExplicitHydrationTargets.length > 0) { 4926 var nextExplicitTarget = queuedExplicitHydrationTargets[0]; 4927 4928 if (nextExplicitTarget.blockedOn !== null) { 4929 // We're still blocked. 4930 break; 4931 } else { 4932 attemptExplicitHydrationTarget(nextExplicitTarget); 4933 4934 if (nextExplicitTarget.blockedOn === null) { 4935 // We're unblocked. 4936 queuedExplicitHydrationTargets.shift(); 4937 } 4938 } 4939 } 4940} 4941 4942var DiscreteEvent = 0; 4943var UserBlockingEvent = 1; 4944var ContinuousEvent = 2; 4945 4946/** 4947 * Generate a mapping of standard vendor prefixes using the defined style property and event name. 4948 * 4949 * @param {string} styleProp 4950 * @param {string} eventName 4951 * @returns {object} 4952 */ 4953 4954function makePrefixMap(styleProp, eventName) { 4955 var prefixes = {}; 4956 prefixes[styleProp.toLowerCase()] = eventName.toLowerCase(); 4957 prefixes['Webkit' + styleProp] = 'webkit' + eventName; 4958 prefixes['Moz' + styleProp] = 'moz' + eventName; 4959 return prefixes; 4960} 4961/** 4962 * A list of event names to a configurable list of vendor prefixes. 4963 */ 4964 4965 4966var vendorPrefixes = { 4967 animationend: makePrefixMap('Animation', 'AnimationEnd'), 4968 animationiteration: makePrefixMap('Animation', 'AnimationIteration'), 4969 animationstart: makePrefixMap('Animation', 'AnimationStart'), 4970 transitionend: makePrefixMap('Transition', 'TransitionEnd') 4971}; 4972/** 4973 * Event names that have already been detected and prefixed (if applicable). 4974 */ 4975 4976var prefixedEventNames = {}; 4977/** 4978 * Element to check for prefixes on. 4979 */ 4980 4981var style = {}; 4982/** 4983 * Bootstrap if a DOM exists. 4984 */ 4985 4986if (canUseDOM) { 4987 style = document.createElement('div').style; // On some platforms, in particular some releases of Android 4.x, 4988 // the un-prefixed "animation" and "transition" properties are defined on the 4989 // style object but the events that fire will still be prefixed, so we need 4990 // to check if the un-prefixed events are usable, and if not remove them from the map. 4991 4992 if (!('AnimationEvent' in window)) { 4993 delete vendorPrefixes.animationend.animation; 4994 delete vendorPrefixes.animationiteration.animation; 4995 delete vendorPrefixes.animationstart.animation; 4996 } // Same as above 4997 4998 4999 if (!('TransitionEvent' in window)) { 5000 delete vendorPrefixes.transitionend.transition; 5001 } 5002} 5003/** 5004 * Attempts to determine the correct vendor prefixed event name. 5005 * 5006 * @param {string} eventName 5007 * @returns {string} 5008 */ 5009 5010 5011function getVendorPrefixedEventName(eventName) { 5012 if (prefixedEventNames[eventName]) { 5013 return prefixedEventNames[eventName]; 5014 } else if (!vendorPrefixes[eventName]) { 5015 return eventName; 5016 } 5017 5018 var prefixMap = vendorPrefixes[eventName]; 5019 5020 for (var styleProp in prefixMap) { 5021 if (prefixMap.hasOwnProperty(styleProp) && styleProp in style) { 5022 return prefixedEventNames[eventName] = prefixMap[styleProp]; 5023 } 5024 } 5025 5026 return eventName; 5027} 5028 5029var ANIMATION_END = getVendorPrefixedEventName('animationend'); 5030var ANIMATION_ITERATION = getVendorPrefixedEventName('animationiteration'); 5031var ANIMATION_START = getVendorPrefixedEventName('animationstart'); 5032var TRANSITION_END = getVendorPrefixedEventName('transitionend'); 5033 5034var topLevelEventsToReactNames = new Map(); 5035var eventPriorities = new Map(); // We store most of the events in this module in pairs of two strings so we can re-use 5036// the code required to apply the same logic for event prioritization and that of the 5037// SimpleEventPlugin. This complicates things slightly, but the aim is to reduce code 5038// duplication (for which there would be quite a bit). For the events that are not needed 5039// for the SimpleEventPlugin (otherDiscreteEvents) we process them separately as an 5040// array of top level events. 5041// Lastly, we ignore prettier so we can keep the formatting sane. 5042// prettier-ignore 5043 5044var discreteEventPairsForSimpleEventPlugin = ['cancel', 'cancel', 'click', 'click', 'close', 'close', 'contextmenu', 'contextMenu', 'copy', 'copy', 'cut', 'cut', 'auxclick', 'auxClick', 'dblclick', 'doubleClick', // Careful! 5045'dragend', 'dragEnd', 'dragstart', 'dragStart', 'drop', 'drop', 'focusin', 'focus', // Careful! 5046'focusout', 'blur', // Careful! 5047'input', 'input', 'invalid', 'invalid', 'keydown', 'keyDown', 'keypress', 'keyPress', 'keyup', 'keyUp', 'mousedown', 'mouseDown', 'mouseup', 'mouseUp', 'paste', 'paste', 'pause', 'pause', 'play', 'play', 'pointercancel', 'pointerCancel', 'pointerdown', 'pointerDown', 'pointerup', 'pointerUp', 'ratechange', 'rateChange', 'reset', 'reset', 'seeked', 'seeked', 'submit', 'submit', 'touchcancel', 'touchCancel', 'touchend', 'touchEnd', 'touchstart', 'touchStart', 'volumechange', 'volumeChange']; 5048var otherDiscreteEvents = ['change', 'selectionchange', 'textInput', 'compositionstart', 'compositionend', 'compositionupdate']; 5049 5050 5051var userBlockingPairsForSimpleEventPlugin = ['drag', 'drag', 'dragenter', 'dragEnter', 'dragexit', 'dragExit', 'dragleave', 'dragLeave', 'dragover', 'dragOver', 'mousemove', 'mouseMove', 'mouseout', 'mouseOut', 'mouseover', 'mouseOver', 'pointermove', 'pointerMove', 'pointerout', 'pointerOut', 'pointerover', 'pointerOver', 'scroll', 'scroll', 'toggle', 'toggle', 'touchmove', 'touchMove', 'wheel', 'wheel']; // prettier-ignore 5052 5053var continuousPairsForSimpleEventPlugin = ['abort', 'abort', ANIMATION_END, 'animationEnd', ANIMATION_ITERATION, 'animationIteration', ANIMATION_START, 'animationStart', 'canplay', 'canPlay', 'canplaythrough', 'canPlayThrough', 'durationchange', 'durationChange', 'emptied', 'emptied', 'encrypted', 'encrypted', 'ended', 'ended', 'error', 'error', 'gotpointercapture', 'gotPointerCapture', 'load', 'load', 'loadeddata', 'loadedData', 'loadedmetadata', 'loadedMetadata', 'loadstart', 'loadStart', 'lostpointercapture', 'lostPointerCapture', 'playing', 'playing', 'progress', 'progress', 'seeking', 'seeking', 'stalled', 'stalled', 'suspend', 'suspend', 'timeupdate', 'timeUpdate', TRANSITION_END, 'transitionEnd', 'waiting', 'waiting']; 5054/** 5055 * Turns 5056 * ['abort', ...] 5057 * 5058 * into 5059 * 5060 * topLevelEventsToReactNames = new Map([ 5061 * ['abort', 'onAbort'], 5062 * ]); 5063 * 5064 * and registers them. 5065 */ 5066 5067function registerSimplePluginEventsAndSetTheirPriorities(eventTypes, priority) { 5068 // As the event types are in pairs of two, we need to iterate 5069 // through in twos. The events are in pairs of two to save code 5070 // and improve init perf of processing this array, as it will 5071 // result in far fewer object allocations and property accesses 5072 // if we only use three arrays to process all the categories of 5073 // instead of tuples. 5074 for (var i = 0; i < eventTypes.length; i += 2) { 5075 var topEvent = eventTypes[i]; 5076 var event = eventTypes[i + 1]; 5077 var capitalizedEvent = event[0].toUpperCase() + event.slice(1); 5078 var reactName = 'on' + capitalizedEvent; 5079 eventPriorities.set(topEvent, priority); 5080 topLevelEventsToReactNames.set(topEvent, reactName); 5081 registerTwoPhaseEvent(reactName, [topEvent]); 5082 } 5083} 5084 5085function setEventPriorities(eventTypes, priority) { 5086 for (var i = 0; i < eventTypes.length; i++) { 5087 eventPriorities.set(eventTypes[i], priority); 5088 } 5089} 5090 5091function getEventPriorityForPluginSystem(domEventName) { 5092 var priority = eventPriorities.get(domEventName); // Default to a ContinuousEvent. Note: we might 5093 // want to warn if we can't detect the priority 5094 // for the event. 5095 5096 return priority === undefined ? ContinuousEvent : priority; 5097} 5098function registerSimpleEvents() { 5099 registerSimplePluginEventsAndSetTheirPriorities(discreteEventPairsForSimpleEventPlugin, DiscreteEvent); 5100 registerSimplePluginEventsAndSetTheirPriorities(userBlockingPairsForSimpleEventPlugin, UserBlockingEvent); 5101 registerSimplePluginEventsAndSetTheirPriorities(continuousPairsForSimpleEventPlugin, ContinuousEvent); 5102 setEventPriorities(otherDiscreteEvents, DiscreteEvent); 5103} 5104 5105var Scheduler_now = Scheduler.unstable_now; 5106 5107{ 5108 // Provide explicit error message when production+profiling bundle of e.g. 5109 // react-dom is used with production (non-profiling) bundle of 5110 // scheduler/tracing 5111 if (!(tracing.__interactionsRef != null && tracing.__interactionsRef.current != null)) { 5112 { 5113 throw Error( "It is not supported to run the profiling version of a renderer (for example, `react-dom/profiling`) without also replacing the `scheduler/tracing` module with `scheduler/tracing-profiling`. Your bundler might have a setting for aliasing both modules. Learn more at https://reactjs.org/link/profiling" ); 5114 } 5115 } 5116} 5117// ascending numbers so we can compare them like numbers. They start at 90 to 5118// avoid clashing with Scheduler's priorities. 5119 5120var ImmediatePriority = 99; 5121var UserBlockingPriority = 98; 5122var NormalPriority = 97; 5123var LowPriority = 96; 5124var IdlePriority = 95; // NoPriority is the absence of priority. Also React-only. 5125 5126var NoPriority = 90; 5127var initialTimeMs = Scheduler_now(); // If the initial timestamp is reasonably small, use Scheduler's `now` directly. 5128 5129var SyncLanePriority = 15; 5130var SyncBatchedLanePriority = 14; 5131var InputDiscreteHydrationLanePriority = 13; 5132var InputDiscreteLanePriority = 12; 5133var InputContinuousHydrationLanePriority = 11; 5134var InputContinuousLanePriority = 10; 5135var DefaultHydrationLanePriority = 9; 5136var DefaultLanePriority = 8; 5137var TransitionHydrationPriority = 7; 5138var TransitionPriority = 6; 5139var RetryLanePriority = 5; 5140var SelectiveHydrationLanePriority = 4; 5141var IdleHydrationLanePriority = 3; 5142var IdleLanePriority = 2; 5143var OffscreenLanePriority = 1; 5144var NoLanePriority = 0; 5145var TotalLanes = 31; 5146var NoLanes = 5147/* */ 51480; 5149var NoLane = 5150/* */ 51510; 5152var SyncLane = 5153/* */ 51541; 5155var SyncBatchedLane = 5156/* */ 51572; 5158var InputDiscreteHydrationLane = 5159/* */ 51604; 5161var InputDiscreteLanes = 5162/* */ 516324; 5164var InputContinuousHydrationLane = 5165/* */ 516632; 5167var InputContinuousLanes = 5168/* */ 5169192; 5170var DefaultHydrationLane = 5171/* */ 5172256; 5173var DefaultLanes = 5174/* */ 51753584; 5176var TransitionHydrationLane = 5177/* */ 51784096; 5179var TransitionLanes = 5180/* */ 51814186112; 5182var RetryLanes = 5183/* */ 518462914560; 5185var SomeRetryLane = 5186/* */ 518733554432; 5188var SelectiveHydrationLane = 5189/* */ 519067108864; 5191var NonIdleLanes = 5192/* */ 5193134217727; 5194var IdleHydrationLane = 5195/* */ 5196134217728; 5197var IdleLanes = 5198/* */ 5199805306368; 5200var OffscreenLane = 5201/* */ 52021073741824; 5203var NoTimestamp = -1; 5204function setCurrentUpdateLanePriority(newLanePriority) { 5205} // "Registers" used to "return" multiple values 5206// Used by getHighestPriorityLanes and getNextLanes: 5207 5208var return_highestLanePriority = DefaultLanePriority; 5209 5210function getHighestPriorityLanes(lanes) { 5211 if ((SyncLane & lanes) !== NoLanes) { 5212 return_highestLanePriority = SyncLanePriority; 5213 return SyncLane; 5214 } 5215 5216 if ((SyncBatchedLane & lanes) !== NoLanes) { 5217 return_highestLanePriority = SyncBatchedLanePriority; 5218 return SyncBatchedLane; 5219 } 5220 5221 if ((InputDiscreteHydrationLane & lanes) !== NoLanes) { 5222 return_highestLanePriority = InputDiscreteHydrationLanePriority; 5223 return InputDiscreteHydrationLane; 5224 } 5225 5226 var inputDiscreteLanes = InputDiscreteLanes & lanes; 5227 5228 if (inputDiscreteLanes !== NoLanes) { 5229 return_highestLanePriority = InputDiscreteLanePriority; 5230 return inputDiscreteLanes; 5231 } 5232 5233 if ((lanes & InputContinuousHydrationLane) !== NoLanes) { 5234 return_highestLanePriority = InputContinuousHydrationLanePriority; 5235 return InputContinuousHydrationLane; 5236 } 5237 5238 var inputContinuousLanes = InputContinuousLanes & lanes; 5239 5240 if (inputContinuousLanes !== NoLanes) { 5241 return_highestLanePriority = InputContinuousLanePriority; 5242 return inputContinuousLanes; 5243 } 5244 5245 if ((lanes & DefaultHydrationLane) !== NoLanes) { 5246 return_highestLanePriority = DefaultHydrationLanePriority; 5247 return DefaultHydrationLane; 5248 } 5249 5250 var defaultLanes = DefaultLanes & lanes; 5251 5252 if (defaultLanes !== NoLanes) { 5253 return_highestLanePriority = DefaultLanePriority; 5254 return defaultLanes; 5255 } 5256 5257 if ((lanes & TransitionHydrationLane) !== NoLanes) { 5258 return_highestLanePriority = TransitionHydrationPriority; 5259 return TransitionHydrationLane; 5260 } 5261 5262 var transitionLanes = TransitionLanes & lanes; 5263 5264 if (transitionLanes !== NoLanes) { 5265 return_highestLanePriority = TransitionPriority; 5266 return transitionLanes; 5267 } 5268 5269 var retryLanes = RetryLanes & lanes; 5270 5271 if (retryLanes !== NoLanes) { 5272 return_highestLanePriority = RetryLanePriority; 5273 return retryLanes; 5274 } 5275 5276 if (lanes & SelectiveHydrationLane) { 5277 return_highestLanePriority = SelectiveHydrationLanePriority; 5278 return SelectiveHydrationLane; 5279 } 5280 5281 if ((lanes & IdleHydrationLane) !== NoLanes) { 5282 return_highestLanePriority = IdleHydrationLanePriority; 5283 return IdleHydrationLane; 5284 } 5285 5286 var idleLanes = IdleLanes & lanes; 5287 5288 if (idleLanes !== NoLanes) { 5289 return_highestLanePriority = IdleLanePriority; 5290 return idleLanes; 5291 } 5292 5293 if ((OffscreenLane & lanes) !== NoLanes) { 5294 return_highestLanePriority = OffscreenLanePriority; 5295 return OffscreenLane; 5296 } 5297 5298 { 5299 error('Should have found matching lanes. This is a bug in React.'); 5300 } // This shouldn't be reachable, but as a fallback, return the entire bitmask. 5301 5302 5303 return_highestLanePriority = DefaultLanePriority; 5304 return lanes; 5305} 5306 5307function schedulerPriorityToLanePriority(schedulerPriorityLevel) { 5308 switch (schedulerPriorityLevel) { 5309 case ImmediatePriority: 5310 return SyncLanePriority; 5311 5312 case UserBlockingPriority: 5313 return InputContinuousLanePriority; 5314 5315 case NormalPriority: 5316 case LowPriority: 5317 // TODO: Handle LowSchedulerPriority, somehow. Maybe the same lane as hydration. 5318 return DefaultLanePriority; 5319 5320 case IdlePriority: 5321 return IdleLanePriority; 5322 5323 default: 5324 return NoLanePriority; 5325 } 5326} 5327function lanePriorityToSchedulerPriority(lanePriority) { 5328 switch (lanePriority) { 5329 case SyncLanePriority: 5330 case SyncBatchedLanePriority: 5331 return ImmediatePriority; 5332 5333 case InputDiscreteHydrationLanePriority: 5334 case InputDiscreteLanePriority: 5335 case InputContinuousHydrationLanePriority: 5336 case InputContinuousLanePriority: 5337 return UserBlockingPriority; 5338 5339 case DefaultHydrationLanePriority: 5340 case DefaultLanePriority: 5341 case TransitionHydrationPriority: 5342 case TransitionPriority: 5343 case SelectiveHydrationLanePriority: 5344 case RetryLanePriority: 5345 return NormalPriority; 5346 5347 case IdleHydrationLanePriority: 5348 case IdleLanePriority: 5349 case OffscreenLanePriority: 5350 return IdlePriority; 5351 5352 case NoLanePriority: 5353 return NoPriority; 5354 5355 default: 5356 { 5357 { 5358 throw Error( "Invalid update priority: " + lanePriority + ". This is a bug in React." ); 5359 } 5360 } 5361 5362 } 5363} 5364function getNextLanes(root, wipLanes) { 5365 // Early bailout if there's no pending work left. 5366 var pendingLanes = root.pendingLanes; 5367 5368 if (pendingLanes === NoLanes) { 5369 return_highestLanePriority = NoLanePriority; 5370 return NoLanes; 5371 } 5372 5373 var nextLanes = NoLanes; 5374 var nextLanePriority = NoLanePriority; 5375 var expiredLanes = root.expiredLanes; 5376 var suspendedLanes = root.suspendedLanes; 5377 var pingedLanes = root.pingedLanes; // Check if any work has expired. 5378 5379 if (expiredLanes !== NoLanes) { 5380 nextLanes = expiredLanes; 5381 nextLanePriority = return_highestLanePriority = SyncLanePriority; 5382 } else { 5383 // Do not work on any idle work until all the non-idle work has finished, 5384 // even if the work is suspended. 5385 var nonIdlePendingLanes = pendingLanes & NonIdleLanes; 5386 5387 if (nonIdlePendingLanes !== NoLanes) { 5388 var nonIdleUnblockedLanes = nonIdlePendingLanes & ~suspendedLanes; 5389 5390 if (nonIdleUnblockedLanes !== NoLanes) { 5391 nextLanes = getHighestPriorityLanes(nonIdleUnblockedLanes); 5392 nextLanePriority = return_highestLanePriority; 5393 } else { 5394 var nonIdlePingedLanes = nonIdlePendingLanes & pingedLanes; 5395 5396 if (nonIdlePingedLanes !== NoLanes) { 5397 nextLanes = getHighestPriorityLanes(nonIdlePingedLanes); 5398 nextLanePriority = return_highestLanePriority; 5399 } 5400 } 5401 } else { 5402 // The only remaining work is Idle. 5403 var unblockedLanes = pendingLanes & ~suspendedLanes; 5404 5405 if (unblockedLanes !== NoLanes) { 5406 nextLanes = getHighestPriorityLanes(unblockedLanes); 5407 nextLanePriority = return_highestLanePriority; 5408 } else { 5409 if (pingedLanes !== NoLanes) { 5410 nextLanes = getHighestPriorityLanes(pingedLanes); 5411 nextLanePriority = return_highestLanePriority; 5412 } 5413 } 5414 } 5415 } 5416 5417 if (nextLanes === NoLanes) { 5418 // This should only be reachable if we're suspended 5419 // TODO: Consider warning in this path if a fallback timer is not scheduled. 5420 return NoLanes; 5421 } // If there are higher priority lanes, we'll include them even if they 5422 // are suspended. 5423 5424 5425 nextLanes = pendingLanes & getEqualOrHigherPriorityLanes(nextLanes); // If we're already in the middle of a render, switching lanes will interrupt 5426 // it and we'll lose our progress. We should only do this if the new lanes are 5427 // higher priority. 5428 5429 if (wipLanes !== NoLanes && wipLanes !== nextLanes && // If we already suspended with a delay, then interrupting is fine. Don't 5430 // bother waiting until the root is complete. 5431 (wipLanes & suspendedLanes) === NoLanes) { 5432 getHighestPriorityLanes(wipLanes); 5433 var wipLanePriority = return_highestLanePriority; 5434 5435 if (nextLanePriority <= wipLanePriority) { 5436 return wipLanes; 5437 } else { 5438 return_highestLanePriority = nextLanePriority; 5439 } 5440 } // Check for entangled lanes and add them to the batch. 5441 // 5442 // A lane is said to be entangled with another when it's not allowed to render 5443 // in a batch that does not also include the other lane. Typically we do this 5444 // when multiple updates have the same source, and we only want to respond to 5445 // the most recent event from that source. 5446 // 5447 // Note that we apply entanglements *after* checking for partial work above. 5448 // This means that if a lane is entangled during an interleaved event while 5449 // it's already rendering, we won't interrupt it. This is intentional, since 5450 // entanglement is usually "best effort": we'll try our best to render the 5451 // lanes in the same batch, but it's not worth throwing out partially 5452 // completed work in order to do it. 5453 // 5454 // For those exceptions where entanglement is semantically important, like 5455 // useMutableSource, we should ensure that there is no partial work at the 5456 // time we apply the entanglement. 5457 5458 5459 var entangledLanes = root.entangledLanes; 5460 5461 if (entangledLanes !== NoLanes) { 5462 var entanglements = root.entanglements; 5463 var lanes = nextLanes & entangledLanes; 5464 5465 while (lanes > 0) { 5466 var index = pickArbitraryLaneIndex(lanes); 5467 var lane = 1 << index; 5468 nextLanes |= entanglements[index]; 5469 lanes &= ~lane; 5470 } 5471 } 5472 5473 return nextLanes; 5474} 5475function getMostRecentEventTime(root, lanes) { 5476 var eventTimes = root.eventTimes; 5477 var mostRecentEventTime = NoTimestamp; 5478 5479 while (lanes > 0) { 5480 var index = pickArbitraryLaneIndex(lanes); 5481 var lane = 1 << index; 5482 var eventTime = eventTimes[index]; 5483 5484 if (eventTime > mostRecentEventTime) { 5485 mostRecentEventTime = eventTime; 5486 } 5487 5488 lanes &= ~lane; 5489 } 5490 5491 return mostRecentEventTime; 5492} 5493 5494function computeExpirationTime(lane, currentTime) { 5495 // TODO: Expiration heuristic is constant per lane, so could use a map. 5496 getHighestPriorityLanes(lane); 5497 var priority = return_highestLanePriority; 5498 5499 if (priority >= InputContinuousLanePriority) { 5500 // User interactions should expire slightly more quickly. 5501 // 5502 // NOTE: This is set to the corresponding constant as in Scheduler.js. When 5503 // we made it larger, a product metric in www regressed, suggesting there's 5504 // a user interaction that's being starved by a series of synchronous 5505 // updates. If that theory is correct, the proper solution is to fix the 5506 // starvation. However, this scenario supports the idea that expiration 5507 // times are an important safeguard when starvation does happen. 5508 // 5509 // Also note that, in the case of user input specifically, this will soon no 5510 // longer be an issue because we plan to make user input synchronous by 5511 // default (until you enter `startTransition`, of course.) 5512 // 5513 // If weren't planning to make these updates synchronous soon anyway, I 5514 // would probably make this number a configurable parameter. 5515 return currentTime + 250; 5516 } else if (priority >= TransitionPriority) { 5517 return currentTime + 5000; 5518 } else { 5519 // Anything idle priority or lower should never expire. 5520 return NoTimestamp; 5521 } 5522} 5523 5524function markStarvedLanesAsExpired(root, currentTime) { 5525 // TODO: This gets called every time we yield. We can optimize by storing 5526 // the earliest expiration time on the root. Then use that to quickly bail out 5527 // of this function. 5528 var pendingLanes = root.pendingLanes; 5529 var suspendedLanes = root.suspendedLanes; 5530 var pingedLanes = root.pingedLanes; 5531 var expirationTimes = root.expirationTimes; // Iterate through the pending lanes and check if we've reached their 5532 // expiration time. If so, we'll assume the update is being starved and mark 5533 // it as expired to force it to finish. 5534 5535 var lanes = pendingLanes; 5536 5537 while (lanes > 0) { 5538 var index = pickArbitraryLaneIndex(lanes); 5539 var lane = 1 << index; 5540 var expirationTime = expirationTimes[index]; 5541 5542 if (expirationTime === NoTimestamp) { 5543 // Found a pending lane with no expiration time. If it's not suspended, or 5544 // if it's pinged, assume it's CPU-bound. Compute a new expiration time 5545 // using the current time. 5546 if ((lane & suspendedLanes) === NoLanes || (lane & pingedLanes) !== NoLanes) { 5547 // Assumes timestamps are monotonically increasing. 5548 expirationTimes[index] = computeExpirationTime(lane, currentTime); 5549 } 5550 } else if (expirationTime <= currentTime) { 5551 // This lane expired 5552 root.expiredLanes |= lane; 5553 } 5554 5555 lanes &= ~lane; 5556 } 5557} // This returns the highest priority pending lanes regardless of whether they 5558function getLanesToRetrySynchronouslyOnError(root) { 5559 var everythingButOffscreen = root.pendingLanes & ~OffscreenLane; 5560 5561 if (everythingButOffscreen !== NoLanes) { 5562 return everythingButOffscreen; 5563 } 5564 5565 if (everythingButOffscreen & OffscreenLane) { 5566 return OffscreenLane; 5567 } 5568 5569 return NoLanes; 5570} 5571function returnNextLanesPriority() { 5572 return return_highestLanePriority; 5573} 5574function includesNonIdleWork(lanes) { 5575 return (lanes & NonIdleLanes) !== NoLanes; 5576} 5577function includesOnlyRetries(lanes) { 5578 return (lanes & RetryLanes) === lanes; 5579} 5580function includesOnlyTransitions(lanes) { 5581 return (lanes & TransitionLanes) === lanes; 5582} // To ensure consistency across multiple updates in the same event, this should 5583// be a pure function, so that it always returns the same lane for given inputs. 5584 5585function findUpdateLane(lanePriority, wipLanes) { 5586 switch (lanePriority) { 5587 case NoLanePriority: 5588 break; 5589 5590 case SyncLanePriority: 5591 return SyncLane; 5592 5593 case SyncBatchedLanePriority: 5594 return SyncBatchedLane; 5595 5596 case InputDiscreteLanePriority: 5597 { 5598 var _lane = pickArbitraryLane(InputDiscreteLanes & ~wipLanes); 5599 5600 if (_lane === NoLane) { 5601 // Shift to the next priority level 5602 return findUpdateLane(InputContinuousLanePriority, wipLanes); 5603 } 5604 5605 return _lane; 5606 } 5607 5608 case InputContinuousLanePriority: 5609 { 5610 var _lane2 = pickArbitraryLane(InputContinuousLanes & ~wipLanes); 5611 5612 if (_lane2 === NoLane) { 5613 // Shift to the next priority level 5614 return findUpdateLane(DefaultLanePriority, wipLanes); 5615 } 5616 5617 return _lane2; 5618 } 5619 5620 case DefaultLanePriority: 5621 { 5622 var _lane3 = pickArbitraryLane(DefaultLanes & ~wipLanes); 5623 5624 if (_lane3 === NoLane) { 5625 // If all the default lanes are already being worked on, look for a 5626 // lane in the transition range. 5627 _lane3 = pickArbitraryLane(TransitionLanes & ~wipLanes); 5628 5629 if (_lane3 === NoLane) { 5630 // All the transition lanes are taken, too. This should be very 5631 // rare, but as a last resort, pick a default lane. This will have 5632 // the effect of interrupting the current work-in-progress render. 5633 _lane3 = pickArbitraryLane(DefaultLanes); 5634 } 5635 } 5636 5637 return _lane3; 5638 } 5639 5640 case TransitionPriority: // Should be handled by findTransitionLane instead 5641 5642 case RetryLanePriority: 5643 // Should be handled by findRetryLane instead 5644 break; 5645 5646 case IdleLanePriority: 5647 var lane = pickArbitraryLane(IdleLanes & ~wipLanes); 5648 5649 if (lane === NoLane) { 5650 lane = pickArbitraryLane(IdleLanes); 5651 } 5652 5653 return lane; 5654 } 5655 5656 { 5657 { 5658 throw Error( "Invalid update priority: " + lanePriority + ". This is a bug in React." ); 5659 } 5660 } 5661} // To ensure consistency across multiple updates in the same event, this should 5662// be pure function, so that it always returns the same lane for given inputs. 5663 5664function findTransitionLane(wipLanes, pendingLanes) { 5665 // First look for lanes that are completely unclaimed, i.e. have no 5666 // pending work. 5667 var lane = pickArbitraryLane(TransitionLanes & ~pendingLanes); 5668 5669 if (lane === NoLane) { 5670 // If all lanes have pending work, look for a lane that isn't currently 5671 // being worked on. 5672 lane = pickArbitraryLane(TransitionLanes & ~wipLanes); 5673 5674 if (lane === NoLane) { 5675 // If everything is being worked on, pick any lane. This has the 5676 // effect of interrupting the current work-in-progress. 5677 lane = pickArbitraryLane(TransitionLanes); 5678 } 5679 } 5680 5681 return lane; 5682} // To ensure consistency across multiple updates in the same event, this should 5683// be pure function, so that it always returns the same lane for given inputs. 5684 5685function findRetryLane(wipLanes) { 5686 // This is a fork of `findUpdateLane` designed specifically for Suspense 5687 // "retries" — a special update that attempts to flip a Suspense boundary 5688 // from its placeholder state to its primary/resolved state. 5689 var lane = pickArbitraryLane(RetryLanes & ~wipLanes); 5690 5691 if (lane === NoLane) { 5692 lane = pickArbitraryLane(RetryLanes); 5693 } 5694 5695 return lane; 5696} 5697 5698function getHighestPriorityLane(lanes) { 5699 return lanes & -lanes; 5700} 5701 5702function getLowestPriorityLane(lanes) { 5703 // This finds the most significant non-zero bit. 5704 var index = 31 - clz32(lanes); 5705 return index < 0 ? NoLanes : 1 << index; 5706} 5707 5708function getEqualOrHigherPriorityLanes(lanes) { 5709 return (getLowestPriorityLane(lanes) << 1) - 1; 5710} 5711 5712function pickArbitraryLane(lanes) { 5713 // This wrapper function gets inlined. Only exists so to communicate that it 5714 // doesn't matter which bit is selected; you can pick any bit without 5715 // affecting the algorithms where its used. Here I'm using 5716 // getHighestPriorityLane because it requires the fewest operations. 5717 return getHighestPriorityLane(lanes); 5718} 5719 5720function pickArbitraryLaneIndex(lanes) { 5721 return 31 - clz32(lanes); 5722} 5723 5724function laneToIndex(lane) { 5725 return pickArbitraryLaneIndex(lane); 5726} 5727 5728function includesSomeLane(a, b) { 5729 return (a & b) !== NoLanes; 5730} 5731function isSubsetOfLanes(set, subset) { 5732 return (set & subset) === subset; 5733} 5734function mergeLanes(a, b) { 5735 return a | b; 5736} 5737function removeLanes(set, subset) { 5738 return set & ~subset; 5739} // Seems redundant, but it changes the type from a single lane (used for 5740// updates) to a group of lanes (used for flushing work). 5741 5742function laneToLanes(lane) { 5743 return lane; 5744} 5745function higherPriorityLane(a, b) { 5746 // This works because the bit ranges decrease in priority as you go left. 5747 return a !== NoLane && a < b ? a : b; 5748} 5749function createLaneMap(initial) { 5750 // Intentionally pushing one by one. 5751 // https://v8.dev/blog/elements-kinds#avoid-creating-holes 5752 var laneMap = []; 5753 5754 for (var i = 0; i < TotalLanes; i++) { 5755 laneMap.push(initial); 5756 } 5757 5758 return laneMap; 5759} 5760function markRootUpdated(root, updateLane, eventTime) { 5761 root.pendingLanes |= updateLane; // TODO: Theoretically, any update to any lane can unblock any other lane. But 5762 // it's not practical to try every single possible combination. We need a 5763 // heuristic to decide which lanes to attempt to render, and in which batches. 5764 // For now, we use the same heuristic as in the old ExpirationTimes model: 5765 // retry any lane at equal or lower priority, but don't try updates at higher 5766 // priority without also including the lower priority updates. This works well 5767 // when considering updates across different priority levels, but isn't 5768 // sufficient for updates within the same priority, since we want to treat 5769 // those updates as parallel. 5770 // Unsuspend any update at equal or lower priority. 5771 5772 var higherPriorityLanes = updateLane - 1; // Turns 0b1000 into 0b0111 5773 5774 root.suspendedLanes &= higherPriorityLanes; 5775 root.pingedLanes &= higherPriorityLanes; 5776 var eventTimes = root.eventTimes; 5777 var index = laneToIndex(updateLane); // We can always overwrite an existing timestamp because we prefer the most 5778 // recent event, and we assume time is monotonically increasing. 5779 5780 eventTimes[index] = eventTime; 5781} 5782function markRootSuspended(root, suspendedLanes) { 5783 root.suspendedLanes |= suspendedLanes; 5784 root.pingedLanes &= ~suspendedLanes; // The suspended lanes are no longer CPU-bound. Clear their expiration times. 5785 5786 var expirationTimes = root.expirationTimes; 5787 var lanes = suspendedLanes; 5788 5789 while (lanes > 0) { 5790 var index = pickArbitraryLaneIndex(lanes); 5791 var lane = 1 << index; 5792 expirationTimes[index] = NoTimestamp; 5793 lanes &= ~lane; 5794 } 5795} 5796function markRootPinged(root, pingedLanes, eventTime) { 5797 root.pingedLanes |= root.suspendedLanes & pingedLanes; 5798} 5799function markDiscreteUpdatesExpired(root) { 5800 root.expiredLanes |= InputDiscreteLanes & root.pendingLanes; 5801} 5802function hasDiscreteLanes(lanes) { 5803 return (lanes & InputDiscreteLanes) !== NoLanes; 5804} 5805function markRootMutableRead(root, updateLane) { 5806 root.mutableReadLanes |= updateLane & root.pendingLanes; 5807} 5808function markRootFinished(root, remainingLanes) { 5809 var noLongerPendingLanes = root.pendingLanes & ~remainingLanes; 5810 root.pendingLanes = remainingLanes; // Let's try everything again 5811 5812 root.suspendedLanes = 0; 5813 root.pingedLanes = 0; 5814 root.expiredLanes &= remainingLanes; 5815 root.mutableReadLanes &= remainingLanes; 5816 root.entangledLanes &= remainingLanes; 5817 var entanglements = root.entanglements; 5818 var eventTimes = root.eventTimes; 5819 var expirationTimes = root.expirationTimes; // Clear the lanes that no longer have pending work 5820 5821 var lanes = noLongerPendingLanes; 5822 5823 while (lanes > 0) { 5824 var index = pickArbitraryLaneIndex(lanes); 5825 var lane = 1 << index; 5826 entanglements[index] = NoLanes; 5827 eventTimes[index] = NoTimestamp; 5828 expirationTimes[index] = NoTimestamp; 5829 lanes &= ~lane; 5830 } 5831} 5832function markRootEntangled(root, entangledLanes) { 5833 root.entangledLanes |= entangledLanes; 5834 var entanglements = root.entanglements; 5835 var lanes = entangledLanes; 5836 5837 while (lanes > 0) { 5838 var index = pickArbitraryLaneIndex(lanes); 5839 var lane = 1 << index; 5840 entanglements[index] |= entangledLanes; 5841 lanes &= ~lane; 5842 } 5843} 5844var clz32 = Math.clz32 ? Math.clz32 : clz32Fallback; // Count leading zeros. Only used on lanes, so assume input is an integer. 5845// Based on: 5846// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/clz32 5847 5848var log = Math.log; 5849var LN2 = Math.LN2; 5850 5851function clz32Fallback(lanes) { 5852 if (lanes === 0) { 5853 return 32; 5854 } 5855 5856 return 31 - (log(lanes) / LN2 | 0) | 0; 5857} 5858 5859// Intentionally not named imports because Rollup would use dynamic dispatch for 5860var UserBlockingPriority$1 = Scheduler.unstable_UserBlockingPriority, 5861 runWithPriority = Scheduler.unstable_runWithPriority; // TODO: can we stop exporting these? 5862 5863var _enabled = true; // This is exported in FB builds for use by legacy FB layer infra. 5864// We'd like to remove this but it's not clear if this is safe. 5865 5866function setEnabled(enabled) { 5867 _enabled = !!enabled; 5868} 5869function isEnabled() { 5870 return _enabled; 5871} 5872function createEventListenerWrapperWithPriority(targetContainer, domEventName, eventSystemFlags) { 5873 var eventPriority = getEventPriorityForPluginSystem(domEventName); 5874 var listenerWrapper; 5875 5876 switch (eventPriority) { 5877 case DiscreteEvent: 5878 listenerWrapper = dispatchDiscreteEvent; 5879 break; 5880 5881 case UserBlockingEvent: 5882 listenerWrapper = dispatchUserBlockingUpdate; 5883 break; 5884 5885 case ContinuousEvent: 5886 default: 5887 listenerWrapper = dispatchEvent; 5888 break; 5889 } 5890 5891 return listenerWrapper.bind(null, domEventName, eventSystemFlags, targetContainer); 5892} 5893 5894function dispatchDiscreteEvent(domEventName, eventSystemFlags, container, nativeEvent) { 5895 { 5896 flushDiscreteUpdatesIfNeeded(nativeEvent.timeStamp); 5897 } 5898 5899 discreteUpdates(dispatchEvent, domEventName, eventSystemFlags, container, nativeEvent); 5900} 5901 5902function dispatchUserBlockingUpdate(domEventName, eventSystemFlags, container, nativeEvent) { 5903 { 5904 runWithPriority(UserBlockingPriority$1, dispatchEvent.bind(null, domEventName, eventSystemFlags, container, nativeEvent)); 5905 } 5906} 5907 5908function dispatchEvent(domEventName, eventSystemFlags, targetContainer, nativeEvent) { 5909 if (!_enabled) { 5910 return; 5911 } 5912 5913 var allowReplay = true; 5914 5915 { 5916 // TODO: replaying capture phase events is currently broken 5917 // because we used to do it during top-level native bubble handlers 5918 // but now we use different bubble and capture handlers. 5919 // In eager mode, we attach capture listeners early, so we need 5920 // to filter them out until we fix the logic to handle them correctly. 5921 // This could've been outside the flag but I put it inside to reduce risk. 5922 allowReplay = (eventSystemFlags & IS_CAPTURE_PHASE) === 0; 5923 } 5924 5925 if (allowReplay && hasQueuedDiscreteEvents() && isReplayableDiscreteEvent(domEventName)) { 5926 // If we already have a queue of discrete events, and this is another discrete 5927 // event, then we can't dispatch it regardless of its target, since they 5928 // need to dispatch in order. 5929 queueDiscreteEvent(null, // Flags that we're not actually blocked on anything as far as we know. 5930 domEventName, eventSystemFlags, targetContainer, nativeEvent); 5931 return; 5932 } 5933 5934 var blockedOn = attemptToDispatchEvent(domEventName, eventSystemFlags, targetContainer, nativeEvent); 5935 5936 if (blockedOn === null) { 5937 // We successfully dispatched this event. 5938 if (allowReplay) { 5939 clearIfContinuousEvent(domEventName, nativeEvent); 5940 } 5941 5942 return; 5943 } 5944 5945 if (allowReplay) { 5946 if (isReplayableDiscreteEvent(domEventName)) { 5947 // This this to be replayed later once the target is available. 5948 queueDiscreteEvent(blockedOn, domEventName, eventSystemFlags, targetContainer, nativeEvent); 5949 return; 5950 } 5951 5952 if (queueIfContinuousEvent(blockedOn, domEventName, eventSystemFlags, targetContainer, nativeEvent)) { 5953 return; 5954 } // We need to clear only if we didn't queue because 5955 // queueing is accummulative. 5956 5957 5958 clearIfContinuousEvent(domEventName, nativeEvent); 5959 } // This is not replayable so we'll invoke it but without a target, 5960 // in case the event system needs to trace it. 5961 5962 5963 dispatchEventForPluginEventSystem(domEventName, eventSystemFlags, nativeEvent, null, targetContainer); 5964} // Attempt dispatching an event. Returns a SuspenseInstance or Container if it's blocked. 5965 5966function attemptToDispatchEvent(domEventName, eventSystemFlags, targetContainer, nativeEvent) { 5967 // TODO: Warn if _enabled is false. 5968 var nativeEventTarget = getEventTarget(nativeEvent); 5969 var targetInst = getClosestInstanceFromNode(nativeEventTarget); 5970 5971 if (targetInst !== null) { 5972 var nearestMounted = getNearestMountedFiber(targetInst); 5973 5974 if (nearestMounted === null) { 5975 // This tree has been unmounted already. Dispatch without a target. 5976 targetInst = null; 5977 } else { 5978 var tag = nearestMounted.tag; 5979 5980 if (tag === SuspenseComponent) { 5981 var instance = getSuspenseInstanceFromFiber(nearestMounted); 5982 5983 if (instance !== null) { 5984 // Queue the event to be replayed later. Abort dispatching since we 5985 // don't want this event dispatched twice through the event system. 5986 // TODO: If this is the first discrete event in the queue. Schedule an increased 5987 // priority for this boundary. 5988 return instance; 5989 } // This shouldn't happen, something went wrong but to avoid blocking 5990 // the whole system, dispatch the event without a target. 5991 // TODO: Warn. 5992 5993 5994 targetInst = null; 5995 } else if (tag === HostRoot) { 5996 var root = nearestMounted.stateNode; 5997 5998 if (root.hydrate) { 5999 // If this happens during a replay something went wrong and it might block 6000 // the whole system. 6001 return getContainerFromFiber(nearestMounted); 6002 } 6003 6004 targetInst = null; 6005 } else if (nearestMounted !== targetInst) { 6006 // If we get an event (ex: img onload) before committing that 6007 // component's mount, ignore it for now (that is, treat it as if it was an 6008 // event on a non-React tree). We might also consider queueing events and 6009 // dispatching them after the mount. 6010 targetInst = null; 6011 } 6012 } 6013 } 6014 6015 dispatchEventForPluginEventSystem(domEventName, eventSystemFlags, nativeEvent, targetInst, targetContainer); // We're not blocked on anything. 6016 6017 return null; 6018} 6019 6020function addEventBubbleListener(target, eventType, listener) { 6021 target.addEventListener(eventType, listener, false); 6022 return listener; 6023} 6024function addEventCaptureListener(target, eventType, listener) { 6025 target.addEventListener(eventType, listener, true); 6026 return listener; 6027} 6028function addEventCaptureListenerWithPassiveFlag(target, eventType, listener, passive) { 6029 target.addEventListener(eventType, listener, { 6030 capture: true, 6031 passive: passive 6032 }); 6033 return listener; 6034} 6035function addEventBubbleListenerWithPassiveFlag(target, eventType, listener, passive) { 6036 target.addEventListener(eventType, listener, { 6037 passive: passive 6038 }); 6039 return listener; 6040} 6041 6042/** 6043 * These variables store information about text content of a target node, 6044 * allowing comparison of content before and after a given event. 6045 * 6046 * Identify the node where selection currently begins, then observe 6047 * both its text content and its current position in the DOM. Since the 6048 * browser may natively replace the target node during composition, we can 6049 * use its position to find its replacement. 6050 * 6051 * 6052 */ 6053var root = null; 6054var startText = null; 6055var fallbackText = null; 6056function initialize(nativeEventTarget) { 6057 root = nativeEventTarget; 6058 startText = getText(); 6059 return true; 6060} 6061function reset() { 6062 root = null; 6063 startText = null; 6064 fallbackText = null; 6065} 6066function getData() { 6067 if (fallbackText) { 6068 return fallbackText; 6069 } 6070 6071 var start; 6072 var startValue = startText; 6073 var startLength = startValue.length; 6074 var end; 6075 var endValue = getText(); 6076 var endLength = endValue.length; 6077 6078 for (start = 0; start < startLength; start++) { 6079 if (startValue[start] !== endValue[start]) { 6080 break; 6081 } 6082 } 6083 6084 var minEnd = startLength - start; 6085 6086 for (end = 1; end <= minEnd; end++) { 6087 if (startValue[startLength - end] !== endValue[endLength - end]) { 6088 break; 6089 } 6090 } 6091 6092 var sliceTail = end > 1 ? 1 - end : undefined; 6093 fallbackText = endValue.slice(start, sliceTail); 6094 return fallbackText; 6095} 6096function getText() { 6097 if ('value' in root) { 6098 return root.value; 6099 } 6100 6101 return root.textContent; 6102} 6103 6104/** 6105 * `charCode` represents the actual "character code" and is safe to use with 6106 * `String.fromCharCode`. As such, only keys that correspond to printable 6107 * characters produce a valid `charCode`, the only exception to this is Enter. 6108 * The Tab-key is considered non-printable and does not have a `charCode`, 6109 * presumably because it does not produce a tab-character in browsers. 6110 * 6111 * @param {object} nativeEvent Native browser event. 6112 * @return {number} Normalized `charCode` property. 6113 */ 6114function getEventCharCode(nativeEvent) { 6115 var charCode; 6116 var keyCode = nativeEvent.keyCode; 6117 6118 if ('charCode' in nativeEvent) { 6119 charCode = nativeEvent.charCode; // FF does not set `charCode` for the Enter-key, check against `keyCode`. 6120 6121 if (charCode === 0 && keyCode === 13) { 6122 charCode = 13; 6123 } 6124 } else { 6125 // IE8 does not implement `charCode`, but `keyCode` has the correct value. 6126 charCode = keyCode; 6127 } // IE and Edge (on Windows) and Chrome / Safari (on Windows and Linux) 6128 // report Enter as charCode 10 when ctrl is pressed. 6129 6130 6131 if (charCode === 10) { 6132 charCode = 13; 6133 } // Some non-printable keys are reported in `charCode`/`keyCode`, discard them. 6134 // Must not discard the (non-)printable Enter-key. 6135 6136 6137 if (charCode >= 32 || charCode === 13) { 6138 return charCode; 6139 } 6140 6141 return 0; 6142} 6143 6144function functionThatReturnsTrue() { 6145 return true; 6146} 6147 6148function functionThatReturnsFalse() { 6149 return false; 6150} // This is intentionally a factory so that we have different returned constructors. 6151// If we had a single constructor, it would be megamorphic and engines would deopt. 6152 6153 6154function createSyntheticEvent(Interface) { 6155 /** 6156 * Synthetic events are dispatched by event plugins, typically in response to a 6157 * top-level event delegation handler. 6158 * 6159 * These systems should generally use pooling to reduce the frequency of garbage 6160 * collection. The system should check `isPersistent` to determine whether the 6161 * event should be released into the pool after being dispatched. Users that 6162 * need a persisted event should invoke `persist`. 6163 * 6164 * Synthetic events (and subclasses) implement the DOM Level 3 Events API by 6165 * normalizing browser quirks. Subclasses do not necessarily have to implement a 6166 * DOM interface; custom application-specific events can also subclass this. 6167 */ 6168 function SyntheticBaseEvent(reactName, reactEventType, targetInst, nativeEvent, nativeEventTarget) { 6169 this._reactName = reactName; 6170 this._targetInst = targetInst; 6171 this.type = reactEventType; 6172 this.nativeEvent = nativeEvent; 6173 this.target = nativeEventTarget; 6174 this.currentTarget = null; 6175 6176 for (var _propName in Interface) { 6177 if (!Interface.hasOwnProperty(_propName)) { 6178 continue; 6179 } 6180 6181 var normalize = Interface[_propName]; 6182 6183 if (normalize) { 6184 this[_propName] = normalize(nativeEvent); 6185 } else { 6186 this[_propName] = nativeEvent[_propName]; 6187 } 6188 } 6189 6190 var defaultPrevented = nativeEvent.defaultPrevented != null ? nativeEvent.defaultPrevented : nativeEvent.returnValue === false; 6191 6192 if (defaultPrevented) { 6193 this.isDefaultPrevented = functionThatReturnsTrue; 6194 } else { 6195 this.isDefaultPrevented = functionThatReturnsFalse; 6196 } 6197 6198 this.isPropagationStopped = functionThatReturnsFalse; 6199 return this; 6200 } 6201 6202 _assign(SyntheticBaseEvent.prototype, { 6203 preventDefault: function () { 6204 this.defaultPrevented = true; 6205 var event = this.nativeEvent; 6206 6207 if (!event) { 6208 return; 6209 } 6210 6211 if (event.preventDefault) { 6212 event.preventDefault(); // $FlowFixMe - flow is not aware of `unknown` in IE 6213 } else if (typeof event.returnValue !== 'unknown') { 6214 event.returnValue = false; 6215 } 6216 6217 this.isDefaultPrevented = functionThatReturnsTrue; 6218 }, 6219 stopPropagation: function () { 6220 var event = this.nativeEvent; 6221 6222 if (!event) { 6223 return; 6224 } 6225 6226 if (event.stopPropagation) { 6227 event.stopPropagation(); // $FlowFixMe - flow is not aware of `unknown` in IE 6228 } else if (typeof event.cancelBubble !== 'unknown') { 6229 // The ChangeEventPlugin registers a "propertychange" event for 6230 // IE. This event does not support bubbling or cancelling, and 6231 // any references to cancelBubble throw "Member not found". A 6232 // typeof check of "unknown" circumvents this issue (and is also 6233 // IE specific). 6234 event.cancelBubble = true; 6235 } 6236 6237 this.isPropagationStopped = functionThatReturnsTrue; 6238 }, 6239 6240 /** 6241 * We release all dispatched `SyntheticEvent`s after each event loop, adding 6242 * them back into the pool. This allows a way to hold onto a reference that 6243 * won't be added back into the pool. 6244 */ 6245 persist: function () {// Modern event system doesn't use pooling. 6246 }, 6247 6248 /** 6249 * Checks if this event should be released back into the pool. 6250 * 6251 * @return {boolean} True if this should not be released, false otherwise. 6252 */ 6253 isPersistent: functionThatReturnsTrue 6254 }); 6255 6256 return SyntheticBaseEvent; 6257} 6258/** 6259 * @interface Event 6260 * @see http://www.w3.org/TR/DOM-Level-3-Events/ 6261 */ 6262 6263 6264var EventInterface = { 6265 eventPhase: 0, 6266 bubbles: 0, 6267 cancelable: 0, 6268 timeStamp: function (event) { 6269 return event.timeStamp || Date.now(); 6270 }, 6271 defaultPrevented: 0, 6272 isTrusted: 0 6273}; 6274var SyntheticEvent = createSyntheticEvent(EventInterface); 6275 6276var UIEventInterface = _assign({}, EventInterface, { 6277 view: 0, 6278 detail: 0 6279}); 6280 6281var SyntheticUIEvent = createSyntheticEvent(UIEventInterface); 6282var lastMovementX; 6283var lastMovementY; 6284var lastMouseEvent; 6285 6286function updateMouseMovementPolyfillState(event) { 6287 if (event !== lastMouseEvent) { 6288 if (lastMouseEvent && event.type === 'mousemove') { 6289 lastMovementX = event.screenX - lastMouseEvent.screenX; 6290 lastMovementY = event.screenY - lastMouseEvent.screenY; 6291 } else { 6292 lastMovementX = 0; 6293 lastMovementY = 0; 6294 } 6295 6296 lastMouseEvent = event; 6297 } 6298} 6299/** 6300 * @interface MouseEvent 6301 * @see http://www.w3.org/TR/DOM-Level-3-Events/ 6302 */ 6303 6304 6305var MouseEventInterface = _assign({}, UIEventInterface, { 6306 screenX: 0, 6307 screenY: 0, 6308 clientX: 0, 6309 clientY: 0, 6310 pageX: 0, 6311 pageY: 0, 6312 ctrlKey: 0, 6313 shiftKey: 0, 6314 altKey: 0, 6315 metaKey: 0, 6316 getModifierState: getEventModifierState, 6317 button: 0, 6318 buttons: 0, 6319 relatedTarget: function (event) { 6320 if (event.relatedTarget === undefined) return event.fromElement === event.srcElement ? event.toElement : event.fromElement; 6321 return event.relatedTarget; 6322 }, 6323 movementX: function (event) { 6324 if ('movementX' in event) { 6325 return event.movementX; 6326 } 6327 6328 updateMouseMovementPolyfillState(event); 6329 return lastMovementX; 6330 }, 6331 movementY: function (event) { 6332 if ('movementY' in event) { 6333 return event.movementY; 6334 } // Don't need to call updateMouseMovementPolyfillState() here 6335 // because it's guaranteed to have already run when movementX 6336 // was copied. 6337 6338 6339 return lastMovementY; 6340 } 6341}); 6342 6343var SyntheticMouseEvent = createSyntheticEvent(MouseEventInterface); 6344/** 6345 * @interface DragEvent 6346 * @see http://www.w3.org/TR/DOM-Level-3-Events/ 6347 */ 6348 6349var DragEventInterface = _assign({}, MouseEventInterface, { 6350 dataTransfer: 0 6351}); 6352 6353var SyntheticDragEvent = createSyntheticEvent(DragEventInterface); 6354/** 6355 * @interface FocusEvent 6356 * @see http://www.w3.org/TR/DOM-Level-3-Events/ 6357 */ 6358 6359var FocusEventInterface = _assign({}, UIEventInterface, { 6360 relatedTarget: 0 6361}); 6362 6363var SyntheticFocusEvent = createSyntheticEvent(FocusEventInterface); 6364/** 6365 * @interface Event 6366 * @see http://www.w3.org/TR/css3-animations/#AnimationEvent-interface 6367 * @see https://developer.mozilla.org/en-US/docs/Web/API/AnimationEvent 6368 */ 6369 6370var AnimationEventInterface = _assign({}, EventInterface, { 6371 animationName: 0, 6372 elapsedTime: 0, 6373 pseudoElement: 0 6374}); 6375 6376var SyntheticAnimationEvent = createSyntheticEvent(AnimationEventInterface); 6377/** 6378 * @interface Event 6379 * @see http://www.w3.org/TR/clipboard-apis/ 6380 */ 6381 6382var ClipboardEventInterface = _assign({}, EventInterface, { 6383 clipboardData: function (event) { 6384 return 'clipboardData' in event ? event.clipboardData : window.clipboardData; 6385 } 6386}); 6387 6388var SyntheticClipboardEvent = createSyntheticEvent(ClipboardEventInterface); 6389/** 6390 * @interface Event 6391 * @see http://www.w3.org/TR/DOM-Level-3-Events/#events-compositionevents 6392 */ 6393 6394var CompositionEventInterface = _assign({}, EventInterface, { 6395 data: 0 6396}); 6397 6398var SyntheticCompositionEvent = createSyntheticEvent(CompositionEventInterface); 6399/** 6400 * @interface Event 6401 * @see http://www.w3.org/TR/2013/WD-DOM-Level-3-Events-20131105 6402 * /#events-inputevents 6403 */ 6404// Happens to share the same list for now. 6405 6406var SyntheticInputEvent = SyntheticCompositionEvent; 6407/** 6408 * Normalization of deprecated HTML5 `key` values 6409 * @see https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent#Key_names 6410 */ 6411 6412var normalizeKey = { 6413 Esc: 'Escape', 6414 Spacebar: ' ', 6415 Left: 'ArrowLeft', 6416 Up: 'ArrowUp', 6417 Right: 'ArrowRight', 6418 Down: 'ArrowDown', 6419 Del: 'Delete', 6420 Win: 'OS', 6421 Menu: 'ContextMenu', 6422 Apps: 'ContextMenu', 6423 Scroll: 'ScrollLock', 6424 MozPrintableKey: 'Unidentified' 6425}; 6426/** 6427 * Translation from legacy `keyCode` to HTML5 `key` 6428 * Only special keys supported, all others depend on keyboard layout or browser 6429 * @see https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent#Key_names 6430 */ 6431 6432var translateToKey = { 6433 '8': 'Backspace', 6434 '9': 'Tab', 6435 '12': 'Clear', 6436 '13': 'Enter', 6437 '16': 'Shift', 6438 '17': 'Control', 6439 '18': 'Alt', 6440 '19': 'Pause', 6441 '20': 'CapsLock', 6442 '27': 'Escape', 6443 '32': ' ', 6444 '33': 'PageUp', 6445 '34': 'PageDown', 6446 '35': 'End', 6447 '36': 'Home', 6448 '37': 'ArrowLeft', 6449 '38': 'ArrowUp', 6450 '39': 'ArrowRight', 6451 '40': 'ArrowDown', 6452 '45': 'Insert', 6453 '46': 'Delete', 6454 '112': 'F1', 6455 '113': 'F2', 6456 '114': 'F3', 6457 '115': 'F4', 6458 '116': 'F5', 6459 '117': 'F6', 6460 '118': 'F7', 6461 '119': 'F8', 6462 '120': 'F9', 6463 '121': 'F10', 6464 '122': 'F11', 6465 '123': 'F12', 6466 '144': 'NumLock', 6467 '145': 'ScrollLock', 6468 '224': 'Meta' 6469}; 6470/** 6471 * @param {object} nativeEvent Native browser event. 6472 * @return {string} Normalized `key` property. 6473 */ 6474 6475function getEventKey(nativeEvent) { 6476 if (nativeEvent.key) { 6477 // Normalize inconsistent values reported by browsers due to 6478 // implementations of a working draft specification. 6479 // FireFox implements `key` but returns `MozPrintableKey` for all 6480 // printable characters (normalized to `Unidentified`), ignore it. 6481 var key = normalizeKey[nativeEvent.key] || nativeEvent.key; 6482 6483 if (key !== 'Unidentified') { 6484 return key; 6485 } 6486 } // Browser does not implement `key`, polyfill as much of it as we can. 6487 6488 6489 if (nativeEvent.type === 'keypress') { 6490 var charCode = getEventCharCode(nativeEvent); // The enter-key is technically both printable and non-printable and can 6491 // thus be captured by `keypress`, no other non-printable key should. 6492 6493 return charCode === 13 ? 'Enter' : String.fromCharCode(charCode); 6494 } 6495 6496 if (nativeEvent.type === 'keydown' || nativeEvent.type === 'keyup') { 6497 // While user keyboard layout determines the actual meaning of each 6498 // `keyCode` value, almost all function keys have a universal value. 6499 return translateToKey[nativeEvent.keyCode] || 'Unidentified'; 6500 } 6501 6502 return ''; 6503} 6504/** 6505 * Translation from modifier key to the associated property in the event. 6506 * @see http://www.w3.org/TR/DOM-Level-3-Events/#keys-Modifiers 6507 */ 6508 6509 6510var modifierKeyToProp = { 6511 Alt: 'altKey', 6512 Control: 'ctrlKey', 6513 Meta: 'metaKey', 6514 Shift: 'shiftKey' 6515}; // Older browsers (Safari <= 10, iOS Safari <= 10.2) do not support 6516// getModifierState. If getModifierState is not supported, we map it to a set of 6517// modifier keys exposed by the event. In this case, Lock-keys are not supported. 6518 6519function modifierStateGetter(keyArg) { 6520 var syntheticEvent = this; 6521 var nativeEvent = syntheticEvent.nativeEvent; 6522 6523 if (nativeEvent.getModifierState) { 6524 return nativeEvent.getModifierState(keyArg); 6525 } 6526 6527 var keyProp = modifierKeyToProp[keyArg]; 6528 return keyProp ? !!nativeEvent[keyProp] : false; 6529} 6530 6531function getEventModifierState(nativeEvent) { 6532 return modifierStateGetter; 6533} 6534/** 6535 * @interface KeyboardEvent 6536 * @see http://www.w3.org/TR/DOM-Level-3-Events/ 6537 */ 6538 6539 6540var KeyboardEventInterface = _assign({}, UIEventInterface, { 6541 key: getEventKey, 6542 code: 0, 6543 location: 0, 6544 ctrlKey: 0, 6545 shiftKey: 0, 6546 altKey: 0, 6547 metaKey: 0, 6548 repeat: 0, 6549 locale: 0, 6550 getModifierState: getEventModifierState, 6551 // Legacy Interface 6552 charCode: function (event) { 6553 // `charCode` is the result of a KeyPress event and represents the value of 6554 // the actual printable character. 6555 // KeyPress is deprecated, but its replacement is not yet final and not 6556 // implemented in any major browser. Only KeyPress has charCode. 6557 if (event.type === 'keypress') { 6558 return getEventCharCode(event); 6559 } 6560 6561 return 0; 6562 }, 6563 keyCode: function (event) { 6564 // `keyCode` is the result of a KeyDown/Up event and represents the value of 6565 // physical keyboard key. 6566 // The actual meaning of the value depends on the users' keyboard layout 6567 // which cannot be detected. Assuming that it is a US keyboard layout 6568 // provides a surprisingly accurate mapping for US and European users. 6569 // Due to this, it is left to the user to implement at this time. 6570 if (event.type === 'keydown' || event.type === 'keyup') { 6571 return event.keyCode; 6572 } 6573 6574 return 0; 6575 }, 6576 which: function (event) { 6577 // `which` is an alias for either `keyCode` or `charCode` depending on the 6578 // type of the event. 6579 if (event.type === 'keypress') { 6580 return getEventCharCode(event); 6581 } 6582 6583 if (event.type === 'keydown' || event.type === 'keyup') { 6584 return event.keyCode; 6585 } 6586 6587 return 0; 6588 } 6589}); 6590 6591var SyntheticKeyboardEvent = createSyntheticEvent(KeyboardEventInterface); 6592/** 6593 * @interface PointerEvent 6594 * @see http://www.w3.org/TR/pointerevents/ 6595 */ 6596 6597var PointerEventInterface = _assign({}, MouseEventInterface, { 6598 pointerId: 0, 6599 width: 0, 6600 height: 0, 6601 pressure: 0, 6602 tangentialPressure: 0, 6603 tiltX: 0, 6604 tiltY: 0, 6605 twist: 0, 6606 pointerType: 0, 6607 isPrimary: 0 6608}); 6609 6610var SyntheticPointerEvent = createSyntheticEvent(PointerEventInterface); 6611/** 6612 * @interface TouchEvent 6613 * @see http://www.w3.org/TR/touch-events/ 6614 */ 6615 6616var TouchEventInterface = _assign({}, UIEventInterface, { 6617 touches: 0, 6618 targetTouches: 0, 6619 changedTouches: 0, 6620 altKey: 0, 6621 metaKey: 0, 6622 ctrlKey: 0, 6623 shiftKey: 0, 6624 getModifierState: getEventModifierState 6625}); 6626 6627var SyntheticTouchEvent = createSyntheticEvent(TouchEventInterface); 6628/** 6629 * @interface Event 6630 * @see http://www.w3.org/TR/2009/WD-css3-transitions-20090320/#transition-events- 6631 * @see https://developer.mozilla.org/en-US/docs/Web/API/TransitionEvent 6632 */ 6633 6634var TransitionEventInterface = _assign({}, EventInterface, { 6635 propertyName: 0, 6636 elapsedTime: 0, 6637 pseudoElement: 0 6638}); 6639 6640var SyntheticTransitionEvent = createSyntheticEvent(TransitionEventInterface); 6641/** 6642 * @interface WheelEvent 6643 * @see http://www.w3.org/TR/DOM-Level-3-Events/ 6644 */ 6645 6646var WheelEventInterface = _assign({}, MouseEventInterface, { 6647 deltaX: function (event) { 6648 return 'deltaX' in event ? event.deltaX : // Fallback to `wheelDeltaX` for Webkit and normalize (right is positive). 6649 'wheelDeltaX' in event ? -event.wheelDeltaX : 0; 6650 }, 6651 deltaY: function (event) { 6652 return 'deltaY' in event ? event.deltaY : // Fallback to `wheelDeltaY` for Webkit and normalize (down is positive). 6653 'wheelDeltaY' in event ? -event.wheelDeltaY : // Fallback to `wheelDelta` for IE<9 and normalize (down is positive). 6654 'wheelDelta' in event ? -event.wheelDelta : 0; 6655 }, 6656 deltaZ: 0, 6657 // Browsers without "deltaMode" is reporting in raw wheel delta where one 6658 // notch on the scroll is always +/- 120, roughly equivalent to pixels. 6659 // A good approximation of DOM_DELTA_LINE (1) is 5% of viewport size or 6660 // ~40 pixels, for DOM_DELTA_SCREEN (2) it is 87.5% of viewport size. 6661 deltaMode: 0 6662}); 6663 6664var SyntheticWheelEvent = createSyntheticEvent(WheelEventInterface); 6665 6666var END_KEYCODES = [9, 13, 27, 32]; // Tab, Return, Esc, Space 6667 6668var START_KEYCODE = 229; 6669var canUseCompositionEvent = canUseDOM && 'CompositionEvent' in window; 6670var documentMode = null; 6671 6672if (canUseDOM && 'documentMode' in document) { 6673 documentMode = document.documentMode; 6674} // Webkit offers a very useful `textInput` event that can be used to 6675// directly represent `beforeInput`. The IE `textinput` event is not as 6676// useful, so we don't use it. 6677 6678 6679var canUseTextInputEvent = canUseDOM && 'TextEvent' in window && !documentMode; // In IE9+, we have access to composition events, but the data supplied 6680// by the native compositionend event may be incorrect. Japanese ideographic 6681// spaces, for instance (\u3000) are not recorded correctly. 6682 6683var useFallbackCompositionData = canUseDOM && (!canUseCompositionEvent || documentMode && documentMode > 8 && documentMode <= 11); 6684var SPACEBAR_CODE = 32; 6685var SPACEBAR_CHAR = String.fromCharCode(SPACEBAR_CODE); 6686 6687function registerEvents() { 6688 registerTwoPhaseEvent('onBeforeInput', ['compositionend', 'keypress', 'textInput', 'paste']); 6689 registerTwoPhaseEvent('onCompositionEnd', ['compositionend', 'focusout', 'keydown', 'keypress', 'keyup', 'mousedown']); 6690 registerTwoPhaseEvent('onCompositionStart', ['compositionstart', 'focusout', 'keydown', 'keypress', 'keyup', 'mousedown']); 6691 registerTwoPhaseEvent('onCompositionUpdate', ['compositionupdate', 'focusout', 'keydown', 'keypress', 'keyup', 'mousedown']); 6692} // Track whether we've ever handled a keypress on the space key. 6693 6694 6695var hasSpaceKeypress = false; 6696/** 6697 * Return whether a native keypress event is assumed to be a command. 6698 * This is required because Firefox fires `keypress` events for key commands 6699 * (cut, copy, select-all, etc.) even though no character is inserted. 6700 */ 6701 6702function isKeypressCommand(nativeEvent) { 6703 return (nativeEvent.ctrlKey || nativeEvent.altKey || nativeEvent.metaKey) && // ctrlKey && altKey is equivalent to AltGr, and is not a command. 6704 !(nativeEvent.ctrlKey && nativeEvent.altKey); 6705} 6706/** 6707 * Translate native top level events into event types. 6708 */ 6709 6710 6711function getCompositionEventType(domEventName) { 6712 switch (domEventName) { 6713 case 'compositionstart': 6714 return 'onCompositionStart'; 6715 6716 case 'compositionend': 6717 return 'onCompositionEnd'; 6718 6719 case 'compositionupdate': 6720 return 'onCompositionUpdate'; 6721 } 6722} 6723/** 6724 * Does our fallback best-guess model think this event signifies that 6725 * composition has begun? 6726 */ 6727 6728 6729function isFallbackCompositionStart(domEventName, nativeEvent) { 6730 return domEventName === 'keydown' && nativeEvent.keyCode === START_KEYCODE; 6731} 6732/** 6733 * Does our fallback mode think that this event is the end of composition? 6734 */ 6735 6736 6737function isFallbackCompositionEnd(domEventName, nativeEvent) { 6738 switch (domEventName) { 6739 case 'keyup': 6740 // Command keys insert or clear IME input. 6741 return END_KEYCODES.indexOf(nativeEvent.keyCode) !== -1; 6742 6743 case 'keydown': 6744 // Expect IME keyCode on each keydown. If we get any other 6745 // code we must have exited earlier. 6746 return nativeEvent.keyCode !== START_KEYCODE; 6747 6748 case 'keypress': 6749 case 'mousedown': 6750 case 'focusout': 6751 // Events are not possible without cancelling IME. 6752 return true; 6753 6754 default: 6755 return false; 6756 } 6757} 6758/** 6759 * Google Input Tools provides composition data via a CustomEvent, 6760 * with the `data` property populated in the `detail` object. If this 6761 * is available on the event object, use it. If not, this is a plain 6762 * composition event and we have nothing special to extract. 6763 * 6764 * @param {object} nativeEvent 6765 * @return {?string} 6766 */ 6767 6768 6769function getDataFromCustomEvent(nativeEvent) { 6770 var detail = nativeEvent.detail; 6771 6772 if (typeof detail === 'object' && 'data' in detail) { 6773 return detail.data; 6774 } 6775 6776 return null; 6777} 6778/** 6779 * Check if a composition event was triggered by Korean IME. 6780 * Our fallback mode does not work well with IE's Korean IME, 6781 * so just use native composition events when Korean IME is used. 6782 * Although CompositionEvent.locale property is deprecated, 6783 * it is available in IE, where our fallback mode is enabled. 6784 * 6785 * @param {object} nativeEvent 6786 * @return {boolean} 6787 */ 6788 6789 6790function isUsingKoreanIME(nativeEvent) { 6791 return nativeEvent.locale === 'ko'; 6792} // Track the current IME composition status, if any. 6793 6794 6795var isComposing = false; 6796/** 6797 * @return {?object} A SyntheticCompositionEvent. 6798 */ 6799 6800function extractCompositionEvent(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget) { 6801 var eventType; 6802 var fallbackData; 6803 6804 if (canUseCompositionEvent) { 6805 eventType = getCompositionEventType(domEventName); 6806 } else if (!isComposing) { 6807 if (isFallbackCompositionStart(domEventName, nativeEvent)) { 6808 eventType = 'onCompositionStart'; 6809 } 6810 } else if (isFallbackCompositionEnd(domEventName, nativeEvent)) { 6811 eventType = 'onCompositionEnd'; 6812 } 6813 6814 if (!eventType) { 6815 return null; 6816 } 6817 6818 if (useFallbackCompositionData && !isUsingKoreanIME(nativeEvent)) { 6819 // The current composition is stored statically and must not be 6820 // overwritten while composition continues. 6821 if (!isComposing && eventType === 'onCompositionStart') { 6822 isComposing = initialize(nativeEventTarget); 6823 } else if (eventType === 'onCompositionEnd') { 6824 if (isComposing) { 6825 fallbackData = getData(); 6826 } 6827 } 6828 } 6829 6830 var listeners = accumulateTwoPhaseListeners(targetInst, eventType); 6831 6832 if (listeners.length > 0) { 6833 var event = new SyntheticCompositionEvent(eventType, domEventName, null, nativeEvent, nativeEventTarget); 6834 dispatchQueue.push({ 6835 event: event, 6836 listeners: listeners 6837 }); 6838 6839 if (fallbackData) { 6840 // Inject data generated from fallback path into the synthetic event. 6841 // This matches the property of native CompositionEventInterface. 6842 event.data = fallbackData; 6843 } else { 6844 var customData = getDataFromCustomEvent(nativeEvent); 6845 6846 if (customData !== null) { 6847 event.data = customData; 6848 } 6849 } 6850 } 6851} 6852 6853function getNativeBeforeInputChars(domEventName, nativeEvent) { 6854 switch (domEventName) { 6855 case 'compositionend': 6856 return getDataFromCustomEvent(nativeEvent); 6857 6858 case 'keypress': 6859 /** 6860 * If native `textInput` events are available, our goal is to make 6861 * use of them. However, there is a special case: the spacebar key. 6862 * In Webkit, preventing default on a spacebar `textInput` event 6863 * cancels character insertion, but it *also* causes the browser 6864 * to fall back to its default spacebar behavior of scrolling the 6865 * page. 6866 * 6867 * Tracking at: 6868 * https://code.google.com/p/chromium/issues/detail?id=355103 6869 * 6870 * To avoid this issue, use the keypress event as if no `textInput` 6871 * event is available. 6872 */ 6873 var which = nativeEvent.which; 6874 6875 if (which !== SPACEBAR_CODE) { 6876 return null; 6877 } 6878 6879 hasSpaceKeypress = true; 6880 return SPACEBAR_CHAR; 6881 6882 case 'textInput': 6883 // Record the characters to be added to the DOM. 6884 var chars = nativeEvent.data; // If it's a spacebar character, assume that we have already handled 6885 // it at the keypress level and bail immediately. Android Chrome 6886 // doesn't give us keycodes, so we need to ignore it. 6887 6888 if (chars === SPACEBAR_CHAR && hasSpaceKeypress) { 6889 return null; 6890 } 6891 6892 return chars; 6893 6894 default: 6895 // For other native event types, do nothing. 6896 return null; 6897 } 6898} 6899/** 6900 * For browsers that do not provide the `textInput` event, extract the 6901 * appropriate string to use for SyntheticInputEvent. 6902 */ 6903 6904 6905function getFallbackBeforeInputChars(domEventName, nativeEvent) { 6906 // If we are currently composing (IME) and using a fallback to do so, 6907 // try to extract the composed characters from the fallback object. 6908 // If composition event is available, we extract a string only at 6909 // compositionevent, otherwise extract it at fallback events. 6910 if (isComposing) { 6911 if (domEventName === 'compositionend' || !canUseCompositionEvent && isFallbackCompositionEnd(domEventName, nativeEvent)) { 6912 var chars = getData(); 6913 reset(); 6914 isComposing = false; 6915 return chars; 6916 } 6917 6918 return null; 6919 } 6920 6921 switch (domEventName) { 6922 case 'paste': 6923 // If a paste event occurs after a keypress, throw out the input 6924 // chars. Paste events should not lead to BeforeInput events. 6925 return null; 6926 6927 case 'keypress': 6928 /** 6929 * As of v27, Firefox may fire keypress events even when no character 6930 * will be inserted. A few possibilities: 6931 * 6932 * - `which` is `0`. Arrow keys, Esc key, etc. 6933 * 6934 * - `which` is the pressed key code, but no char is available. 6935 * Ex: 'AltGr + d` in Polish. There is no modified character for 6936 * this key combination and no character is inserted into the 6937 * document, but FF fires the keypress for char code `100` anyway. 6938 * No `input` event will occur. 6939 * 6940 * - `which` is the pressed key code, but a command combination is 6941 * being used. Ex: `Cmd+C`. No character is inserted, and no 6942 * `input` event will occur. 6943 */ 6944 if (!isKeypressCommand(nativeEvent)) { 6945 // IE fires the `keypress` event when a user types an emoji via 6946 // Touch keyboard of Windows. In such a case, the `char` property 6947 // holds an emoji character like `\uD83D\uDE0A`. Because its length 6948 // is 2, the property `which` does not represent an emoji correctly. 6949 // In such a case, we directly return the `char` property instead of 6950 // using `which`. 6951 if (nativeEvent.char && nativeEvent.char.length > 1) { 6952 return nativeEvent.char; 6953 } else if (nativeEvent.which) { 6954 return String.fromCharCode(nativeEvent.which); 6955 } 6956 } 6957 6958 return null; 6959 6960 case 'compositionend': 6961 return useFallbackCompositionData && !isUsingKoreanIME(nativeEvent) ? null : nativeEvent.data; 6962 6963 default: 6964 return null; 6965 } 6966} 6967/** 6968 * Extract a SyntheticInputEvent for `beforeInput`, based on either native 6969 * `textInput` or fallback behavior. 6970 * 6971 * @return {?object} A SyntheticInputEvent. 6972 */ 6973 6974 6975function extractBeforeInputEvent(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget) { 6976 var chars; 6977 6978 if (canUseTextInputEvent) { 6979 chars = getNativeBeforeInputChars(domEventName, nativeEvent); 6980 } else { 6981 chars = getFallbackBeforeInputChars(domEventName, nativeEvent); 6982 } // If no characters are being inserted, no BeforeInput event should 6983 // be fired. 6984 6985 6986 if (!chars) { 6987 return null; 6988 } 6989 6990 var listeners = accumulateTwoPhaseListeners(targetInst, 'onBeforeInput'); 6991 6992 if (listeners.length > 0) { 6993 var event = new SyntheticInputEvent('onBeforeInput', 'beforeinput', null, nativeEvent, nativeEventTarget); 6994 dispatchQueue.push({ 6995 event: event, 6996 listeners: listeners 6997 }); 6998 event.data = chars; 6999 } 7000} 7001/** 7002 * Create an `onBeforeInput` event to match 7003 * http://www.w3.org/TR/2013/WD-DOM-Level-3-Events-20131105/#events-inputevents. 7004 * 7005 * This event plugin is based on the native `textInput` event 7006 * available in Chrome, Safari, Opera, and IE. This event fires after 7007 * `onKeyPress` and `onCompositionEnd`, but before `onInput`. 7008 * 7009 * `beforeInput` is spec'd but not implemented in any browsers, and 7010 * the `input` event does not provide any useful information about what has 7011 * actually been added, contrary to the spec. Thus, `textInput` is the best 7012 * available event to identify the characters that have actually been inserted 7013 * into the target node. 7014 * 7015 * This plugin is also responsible for emitting `composition` events, thus 7016 * allowing us to share composition fallback code for both `beforeInput` and 7017 * `composition` event types. 7018 */ 7019 7020 7021function extractEvents(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags, targetContainer) { 7022 extractCompositionEvent(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget); 7023 extractBeforeInputEvent(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget); 7024} 7025 7026/** 7027 * @see http://www.whatwg.org/specs/web-apps/current-work/multipage/the-input-element.html#input-type-attr-summary 7028 */ 7029var supportedInputTypes = { 7030 color: true, 7031 date: true, 7032 datetime: true, 7033 'datetime-local': true, 7034 email: true, 7035 month: true, 7036 number: true, 7037 password: true, 7038 range: true, 7039 search: true, 7040 tel: true, 7041 text: true, 7042 time: true, 7043 url: true, 7044 week: true 7045}; 7046 7047function isTextInputElement(elem) { 7048 var nodeName = elem && elem.nodeName && elem.nodeName.toLowerCase(); 7049 7050 if (nodeName === 'input') { 7051 return !!supportedInputTypes[elem.type]; 7052 } 7053 7054 if (nodeName === 'textarea') { 7055 return true; 7056 } 7057 7058 return false; 7059} 7060 7061/** 7062 * Checks if an event is supported in the current execution environment. 7063 * 7064 * NOTE: This will not work correctly for non-generic events such as `change`, 7065 * `reset`, `load`, `error`, and `select`. 7066 * 7067 * Borrows from Modernizr. 7068 * 7069 * @param {string} eventNameSuffix Event name, e.g. "click". 7070 * @return {boolean} True if the event is supported. 7071 * @internal 7072 * @license Modernizr 3.0.0pre (Custom Build) | MIT 7073 */ 7074 7075function isEventSupported(eventNameSuffix) { 7076 if (!canUseDOM) { 7077 return false; 7078 } 7079 7080 var eventName = 'on' + eventNameSuffix; 7081 var isSupported = (eventName in document); 7082 7083 if (!isSupported) { 7084 var element = document.createElement('div'); 7085 element.setAttribute(eventName, 'return;'); 7086 isSupported = typeof element[eventName] === 'function'; 7087 } 7088 7089 return isSupported; 7090} 7091 7092function registerEvents$1() { 7093 registerTwoPhaseEvent('onChange', ['change', 'click', 'focusin', 'focusout', 'input', 'keydown', 'keyup', 'selectionchange']); 7094} 7095 7096function createAndAccumulateChangeEvent(dispatchQueue, inst, nativeEvent, target) { 7097 // Flag this event loop as needing state restore. 7098 enqueueStateRestore(target); 7099 var listeners = accumulateTwoPhaseListeners(inst, 'onChange'); 7100 7101 if (listeners.length > 0) { 7102 var event = new SyntheticEvent('onChange', 'change', null, nativeEvent, target); 7103 dispatchQueue.push({ 7104 event: event, 7105 listeners: listeners 7106 }); 7107 } 7108} 7109/** 7110 * For IE shims 7111 */ 7112 7113 7114var activeElement = null; 7115var activeElementInst = null; 7116/** 7117 * SECTION: handle `change` event 7118 */ 7119 7120function shouldUseChangeEvent(elem) { 7121 var nodeName = elem.nodeName && elem.nodeName.toLowerCase(); 7122 return nodeName === 'select' || nodeName === 'input' && elem.type === 'file'; 7123} 7124 7125function manualDispatchChangeEvent(nativeEvent) { 7126 var dispatchQueue = []; 7127 createAndAccumulateChangeEvent(dispatchQueue, activeElementInst, nativeEvent, getEventTarget(nativeEvent)); // If change and propertychange bubbled, we'd just bind to it like all the 7128 // other events and have it go through ReactBrowserEventEmitter. Since it 7129 // doesn't, we manually listen for the events and so we have to enqueue and 7130 // process the abstract event manually. 7131 // 7132 // Batching is necessary here in order to ensure that all event handlers run 7133 // before the next rerender (including event handlers attached to ancestor 7134 // elements instead of directly on the input). Without this, controlled 7135 // components don't work properly in conjunction with event bubbling because 7136 // the component is rerendered and the value reverted before all the event 7137 // handlers can run. See https://github.com/facebook/react/issues/708. 7138 7139 batchedUpdates(runEventInBatch, dispatchQueue); 7140} 7141 7142function runEventInBatch(dispatchQueue) { 7143 processDispatchQueue(dispatchQueue, 0); 7144} 7145 7146function getInstIfValueChanged(targetInst) { 7147 var targetNode = getNodeFromInstance(targetInst); 7148 7149 if (updateValueIfChanged(targetNode)) { 7150 return targetInst; 7151 } 7152} 7153 7154function getTargetInstForChangeEvent(domEventName, targetInst) { 7155 if (domEventName === 'change') { 7156 return targetInst; 7157 } 7158} 7159/** 7160 * SECTION: handle `input` event 7161 */ 7162 7163 7164var isInputEventSupported = false; 7165 7166if (canUseDOM) { 7167 // IE9 claims to support the input event but fails to trigger it when 7168 // deleting text, so we ignore its input events. 7169 isInputEventSupported = isEventSupported('input') && (!document.documentMode || document.documentMode > 9); 7170} 7171/** 7172 * (For IE <=9) Starts tracking propertychange events on the passed-in element 7173 * and override the value property so that we can distinguish user events from 7174 * value changes in JS. 7175 */ 7176 7177 7178function startWatchingForValueChange(target, targetInst) { 7179 activeElement = target; 7180 activeElementInst = targetInst; 7181 activeElement.attachEvent('onpropertychange', handlePropertyChange); 7182} 7183/** 7184 * (For IE <=9) Removes the event listeners from the currently-tracked element, 7185 * if any exists. 7186 */ 7187 7188 7189function stopWatchingForValueChange() { 7190 if (!activeElement) { 7191 return; 7192 } 7193 7194 activeElement.detachEvent('onpropertychange', handlePropertyChange); 7195 activeElement = null; 7196 activeElementInst = null; 7197} 7198/** 7199 * (For IE <=9) Handles a propertychange event, sending a `change` event if 7200 * the value of the active element has changed. 7201 */ 7202 7203 7204function handlePropertyChange(nativeEvent) { 7205 if (nativeEvent.propertyName !== 'value') { 7206 return; 7207 } 7208 7209 if (getInstIfValueChanged(activeElementInst)) { 7210 manualDispatchChangeEvent(nativeEvent); 7211 } 7212} 7213 7214function handleEventsForInputEventPolyfill(domEventName, target, targetInst) { 7215 if (domEventName === 'focusin') { 7216 // In IE9, propertychange fires for most input events but is buggy and 7217 // doesn't fire when text is deleted, but conveniently, selectionchange 7218 // appears to fire in all of the remaining cases so we catch those and 7219 // forward the event if the value has changed 7220 // In either case, we don't want to call the event handler if the value 7221 // is changed from JS so we redefine a setter for `.value` that updates 7222 // our activeElementValue variable, allowing us to ignore those changes 7223 // 7224 // stopWatching() should be a noop here but we call it just in case we 7225 // missed a blur event somehow. 7226 stopWatchingForValueChange(); 7227 startWatchingForValueChange(target, targetInst); 7228 } else if (domEventName === 'focusout') { 7229 stopWatchingForValueChange(); 7230 } 7231} // For IE8 and IE9. 7232 7233 7234function getTargetInstForInputEventPolyfill(domEventName, targetInst) { 7235 if (domEventName === 'selectionchange' || domEventName === 'keyup' || domEventName === 'keydown') { 7236 // On the selectionchange event, the target is just document which isn't 7237 // helpful for us so just check activeElement instead. 7238 // 7239 // 99% of the time, keydown and keyup aren't necessary. IE8 fails to fire 7240 // propertychange on the first input event after setting `value` from a 7241 // script and fires only keydown, keypress, keyup. Catching keyup usually 7242 // gets it and catching keydown lets us fire an event for the first 7243 // keystroke if user does a key repeat (it'll be a little delayed: right 7244 // before the second keystroke). Other input methods (e.g., paste) seem to 7245 // fire selectionchange normally. 7246 return getInstIfValueChanged(activeElementInst); 7247 } 7248} 7249/** 7250 * SECTION: handle `click` event 7251 */ 7252 7253 7254function shouldUseClickEvent(elem) { 7255 // Use the `click` event to detect changes to checkbox and radio inputs. 7256 // This approach works across all browsers, whereas `change` does not fire 7257 // until `blur` in IE8. 7258 var nodeName = elem.nodeName; 7259 return nodeName && nodeName.toLowerCase() === 'input' && (elem.type === 'checkbox' || elem.type === 'radio'); 7260} 7261 7262function getTargetInstForClickEvent(domEventName, targetInst) { 7263 if (domEventName === 'click') { 7264 return getInstIfValueChanged(targetInst); 7265 } 7266} 7267 7268function getTargetInstForInputOrChangeEvent(domEventName, targetInst) { 7269 if (domEventName === 'input' || domEventName === 'change') { 7270 return getInstIfValueChanged(targetInst); 7271 } 7272} 7273 7274function handleControlledInputBlur(node) { 7275 var state = node._wrapperState; 7276 7277 if (!state || !state.controlled || node.type !== 'number') { 7278 return; 7279 } 7280 7281 { 7282 // If controlled, assign the value attribute to the current value on blur 7283 setDefaultValue(node, 'number', node.value); 7284 } 7285} 7286/** 7287 * This plugin creates an `onChange` event that normalizes change events 7288 * across form elements. This event fires at a time when it's possible to 7289 * change the element's value without seeing a flicker. 7290 * 7291 * Supported elements are: 7292 * - input (see `isTextInputElement`) 7293 * - textarea 7294 * - select 7295 */ 7296 7297 7298function extractEvents$1(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags, targetContainer) { 7299 var targetNode = targetInst ? getNodeFromInstance(targetInst) : window; 7300 var getTargetInstFunc, handleEventFunc; 7301 7302 if (shouldUseChangeEvent(targetNode)) { 7303 getTargetInstFunc = getTargetInstForChangeEvent; 7304 } else if (isTextInputElement(targetNode)) { 7305 if (isInputEventSupported) { 7306 getTargetInstFunc = getTargetInstForInputOrChangeEvent; 7307 } else { 7308 getTargetInstFunc = getTargetInstForInputEventPolyfill; 7309 handleEventFunc = handleEventsForInputEventPolyfill; 7310 } 7311 } else if (shouldUseClickEvent(targetNode)) { 7312 getTargetInstFunc = getTargetInstForClickEvent; 7313 } 7314 7315 if (getTargetInstFunc) { 7316 var inst = getTargetInstFunc(domEventName, targetInst); 7317 7318 if (inst) { 7319 createAndAccumulateChangeEvent(dispatchQueue, inst, nativeEvent, nativeEventTarget); 7320 return; 7321 } 7322 } 7323 7324 if (handleEventFunc) { 7325 handleEventFunc(domEventName, targetNode, targetInst); 7326 } // When blurring, set the value attribute for number inputs 7327 7328 7329 if (domEventName === 'focusout') { 7330 handleControlledInputBlur(targetNode); 7331 } 7332} 7333 7334function registerEvents$2() { 7335 registerDirectEvent('onMouseEnter', ['mouseout', 'mouseover']); 7336 registerDirectEvent('onMouseLeave', ['mouseout', 'mouseover']); 7337 registerDirectEvent('onPointerEnter', ['pointerout', 'pointerover']); 7338 registerDirectEvent('onPointerLeave', ['pointerout', 'pointerover']); 7339} 7340/** 7341 * For almost every interaction we care about, there will be both a top-level 7342 * `mouseover` and `mouseout` event that occurs. Only use `mouseout` so that 7343 * we do not extract duplicate events. However, moving the mouse into the 7344 * browser from outside will not fire a `mouseout` event. In this case, we use 7345 * the `mouseover` top-level event. 7346 */ 7347 7348 7349function extractEvents$2(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags, targetContainer) { 7350 var isOverEvent = domEventName === 'mouseover' || domEventName === 'pointerover'; 7351 var isOutEvent = domEventName === 'mouseout' || domEventName === 'pointerout'; 7352 7353 if (isOverEvent && (eventSystemFlags & IS_REPLAYED) === 0) { 7354 // If this is an over event with a target, we might have already dispatched 7355 // the event in the out event of the other target. If this is replayed, 7356 // then it's because we couldn't dispatch against this target previously 7357 // so we have to do it now instead. 7358 var related = nativeEvent.relatedTarget || nativeEvent.fromElement; 7359 7360 if (related) { 7361 // If the related node is managed by React, we can assume that we have 7362 // already dispatched the corresponding events during its mouseout. 7363 if (getClosestInstanceFromNode(related) || isContainerMarkedAsRoot(related)) { 7364 return; 7365 } 7366 } 7367 } 7368 7369 if (!isOutEvent && !isOverEvent) { 7370 // Must not be a mouse or pointer in or out - ignoring. 7371 return; 7372 } 7373 7374 var win; // TODO: why is this nullable in the types but we read from it? 7375 7376 if (nativeEventTarget.window === nativeEventTarget) { 7377 // `nativeEventTarget` is probably a window object. 7378 win = nativeEventTarget; 7379 } else { 7380 // TODO: Figure out why `ownerDocument` is sometimes undefined in IE8. 7381 var doc = nativeEventTarget.ownerDocument; 7382 7383 if (doc) { 7384 win = doc.defaultView || doc.parentWindow; 7385 } else { 7386 win = window; 7387 } 7388 } 7389 7390 var from; 7391 var to; 7392 7393 if (isOutEvent) { 7394 var _related = nativeEvent.relatedTarget || nativeEvent.toElement; 7395 7396 from = targetInst; 7397 to = _related ? getClosestInstanceFromNode(_related) : null; 7398 7399 if (to !== null) { 7400 var nearestMounted = getNearestMountedFiber(to); 7401 7402 if (to !== nearestMounted || to.tag !== HostComponent && to.tag !== HostText) { 7403 to = null; 7404 } 7405 } 7406 } else { 7407 // Moving to a node from outside the window. 7408 from = null; 7409 to = targetInst; 7410 } 7411 7412 if (from === to) { 7413 // Nothing pertains to our managed components. 7414 return; 7415 } 7416 7417 var SyntheticEventCtor = SyntheticMouseEvent; 7418 var leaveEventType = 'onMouseLeave'; 7419 var enterEventType = 'onMouseEnter'; 7420 var eventTypePrefix = 'mouse'; 7421 7422 if (domEventName === 'pointerout' || domEventName === 'pointerover') { 7423 SyntheticEventCtor = SyntheticPointerEvent; 7424 leaveEventType = 'onPointerLeave'; 7425 enterEventType = 'onPointerEnter'; 7426 eventTypePrefix = 'pointer'; 7427 } 7428 7429 var fromNode = from == null ? win : getNodeFromInstance(from); 7430 var toNode = to == null ? win : getNodeFromInstance(to); 7431 var leave = new SyntheticEventCtor(leaveEventType, eventTypePrefix + 'leave', from, nativeEvent, nativeEventTarget); 7432 leave.target = fromNode; 7433 leave.relatedTarget = toNode; 7434 var enter = null; // We should only process this nativeEvent if we are processing 7435 // the first ancestor. Next time, we will ignore the event. 7436 7437 var nativeTargetInst = getClosestInstanceFromNode(nativeEventTarget); 7438 7439 if (nativeTargetInst === targetInst) { 7440 var enterEvent = new SyntheticEventCtor(enterEventType, eventTypePrefix + 'enter', to, nativeEvent, nativeEventTarget); 7441 enterEvent.target = toNode; 7442 enterEvent.relatedTarget = fromNode; 7443 enter = enterEvent; 7444 } 7445 7446 accumulateEnterLeaveTwoPhaseListeners(dispatchQueue, leave, enter, from, to); 7447} 7448 7449/** 7450 * inlined Object.is polyfill to avoid requiring consumers ship their own 7451 * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is 7452 */ 7453function is(x, y) { 7454 return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y // eslint-disable-line no-self-compare 7455 ; 7456} 7457 7458var objectIs = typeof Object.is === 'function' ? Object.is : is; 7459 7460var hasOwnProperty$2 = Object.prototype.hasOwnProperty; 7461/** 7462 * Performs equality by iterating through keys on an object and returning false 7463 * when any key has values which are not strictly equal between the arguments. 7464 * Returns true when the values of all keys are strictly equal. 7465 */ 7466 7467function shallowEqual(objA, objB) { 7468 if (objectIs(objA, objB)) { 7469 return true; 7470 } 7471 7472 if (typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null) { 7473 return false; 7474 } 7475 7476 var keysA = Object.keys(objA); 7477 var keysB = Object.keys(objB); 7478 7479 if (keysA.length !== keysB.length) { 7480 return false; 7481 } // Test for A's keys different from B. 7482 7483 7484 for (var i = 0; i < keysA.length; i++) { 7485 if (!hasOwnProperty$2.call(objB, keysA[i]) || !objectIs(objA[keysA[i]], objB[keysA[i]])) { 7486 return false; 7487 } 7488 } 7489 7490 return true; 7491} 7492 7493/** 7494 * Given any node return the first leaf node without children. 7495 * 7496 * @param {DOMElement|DOMTextNode} node 7497 * @return {DOMElement|DOMTextNode} 7498 */ 7499 7500function getLeafNode(node) { 7501 while (node && node.firstChild) { 7502 node = node.firstChild; 7503 } 7504 7505 return node; 7506} 7507/** 7508 * Get the next sibling within a container. This will walk up the 7509 * DOM if a node's siblings have been exhausted. 7510 * 7511 * @param {DOMElement|DOMTextNode} node 7512 * @return {?DOMElement|DOMTextNode} 7513 */ 7514 7515 7516function getSiblingNode(node) { 7517 while (node) { 7518 if (node.nextSibling) { 7519 return node.nextSibling; 7520 } 7521 7522 node = node.parentNode; 7523 } 7524} 7525/** 7526 * Get object describing the nodes which contain characters at offset. 7527 * 7528 * @param {DOMElement|DOMTextNode} root 7529 * @param {number} offset 7530 * @return {?object} 7531 */ 7532 7533 7534function getNodeForCharacterOffset(root, offset) { 7535 var node = getLeafNode(root); 7536 var nodeStart = 0; 7537 var nodeEnd = 0; 7538 7539 while (node) { 7540 if (node.nodeType === TEXT_NODE) { 7541 nodeEnd = nodeStart + node.textContent.length; 7542 7543 if (nodeStart <= offset && nodeEnd >= offset) { 7544 return { 7545 node: node, 7546 offset: offset - nodeStart 7547 }; 7548 } 7549 7550 nodeStart = nodeEnd; 7551 } 7552 7553 node = getLeafNode(getSiblingNode(node)); 7554 } 7555} 7556 7557/** 7558 * @param {DOMElement} outerNode 7559 * @return {?object} 7560 */ 7561 7562function getOffsets(outerNode) { 7563 var ownerDocument = outerNode.ownerDocument; 7564 var win = ownerDocument && ownerDocument.defaultView || window; 7565 var selection = win.getSelection && win.getSelection(); 7566 7567 if (!selection || selection.rangeCount === 0) { 7568 return null; 7569 } 7570 7571 var anchorNode = selection.anchorNode, 7572 anchorOffset = selection.anchorOffset, 7573 focusNode = selection.focusNode, 7574 focusOffset = selection.focusOffset; // In Firefox, anchorNode and focusNode can be "anonymous divs", e.g. the 7575 // up/down buttons on an <input type="number">. Anonymous divs do not seem to 7576 // expose properties, triggering a "Permission denied error" if any of its 7577 // properties are accessed. The only seemingly possible way to avoid erroring 7578 // is to access a property that typically works for non-anonymous divs and 7579 // catch any error that may otherwise arise. See 7580 // https://bugzilla.mozilla.org/show_bug.cgi?id=208427 7581 7582 try { 7583 /* eslint-disable no-unused-expressions */ 7584 anchorNode.nodeType; 7585 focusNode.nodeType; 7586 /* eslint-enable no-unused-expressions */ 7587 } catch (e) { 7588 return null; 7589 } 7590 7591 return getModernOffsetsFromPoints(outerNode, anchorNode, anchorOffset, focusNode, focusOffset); 7592} 7593/** 7594 * Returns {start, end} where `start` is the character/codepoint index of 7595 * (anchorNode, anchorOffset) within the textContent of `outerNode`, and 7596 * `end` is the index of (focusNode, focusOffset). 7597 * 7598 * Returns null if you pass in garbage input but we should probably just crash. 7599 * 7600 * Exported only for testing. 7601 */ 7602 7603function getModernOffsetsFromPoints(outerNode, anchorNode, anchorOffset, focusNode, focusOffset) { 7604 var length = 0; 7605 var start = -1; 7606 var end = -1; 7607 var indexWithinAnchor = 0; 7608 var indexWithinFocus = 0; 7609 var node = outerNode; 7610 var parentNode = null; 7611 7612 outer: while (true) { 7613 var next = null; 7614 7615 while (true) { 7616 if (node === anchorNode && (anchorOffset === 0 || node.nodeType === TEXT_NODE)) { 7617 start = length + anchorOffset; 7618 } 7619 7620 if (node === focusNode && (focusOffset === 0 || node.nodeType === TEXT_NODE)) { 7621 end = length + focusOffset; 7622 } 7623 7624 if (node.nodeType === TEXT_NODE) { 7625 length += node.nodeValue.length; 7626 } 7627 7628 if ((next = node.firstChild) === null) { 7629 break; 7630 } // Moving from `node` to its first child `next`. 7631 7632 7633 parentNode = node; 7634 node = next; 7635 } 7636 7637 while (true) { 7638 if (node === outerNode) { 7639 // If `outerNode` has children, this is always the second time visiting 7640 // it. If it has no children, this is still the first loop, and the only 7641 // valid selection is anchorNode and focusNode both equal to this node 7642 // and both offsets 0, in which case we will have handled above. 7643 break outer; 7644 } 7645 7646 if (parentNode === anchorNode && ++indexWithinAnchor === anchorOffset) { 7647 start = length; 7648 } 7649 7650 if (parentNode === focusNode && ++indexWithinFocus === focusOffset) { 7651 end = length; 7652 } 7653 7654 if ((next = node.nextSibling) !== null) { 7655 break; 7656 } 7657 7658 node = parentNode; 7659 parentNode = node.parentNode; 7660 } // Moving from `node` to its next sibling `next`. 7661 7662 7663 node = next; 7664 } 7665 7666 if (start === -1 || end === -1) { 7667 // This should never happen. (Would happen if the anchor/focus nodes aren't 7668 // actually inside the passed-in node.) 7669 return null; 7670 } 7671 7672 return { 7673 start: start, 7674 end: end 7675 }; 7676} 7677/** 7678 * In modern non-IE browsers, we can support both forward and backward 7679 * selections. 7680 * 7681 * Note: IE10+ supports the Selection object, but it does not support 7682 * the `extend` method, which means that even in modern IE, it's not possible 7683 * to programmatically create a backward selection. Thus, for all IE 7684 * versions, we use the old IE API to create our selections. 7685 * 7686 * @param {DOMElement|DOMTextNode} node 7687 * @param {object} offsets 7688 */ 7689 7690function setOffsets(node, offsets) { 7691 var doc = node.ownerDocument || document; 7692 var win = doc && doc.defaultView || window; // Edge fails with "Object expected" in some scenarios. 7693 // (For instance: TinyMCE editor used in a list component that supports pasting to add more, 7694 // fails when pasting 100+ items) 7695 7696 if (!win.getSelection) { 7697 return; 7698 } 7699 7700 var selection = win.getSelection(); 7701 var length = node.textContent.length; 7702 var start = Math.min(offsets.start, length); 7703 var end = offsets.end === undefined ? start : Math.min(offsets.end, length); // IE 11 uses modern selection, but doesn't support the extend method. 7704 // Flip backward selections, so we can set with a single range. 7705 7706 if (!selection.extend && start > end) { 7707 var temp = end; 7708 end = start; 7709 start = temp; 7710 } 7711 7712 var startMarker = getNodeForCharacterOffset(node, start); 7713 var endMarker = getNodeForCharacterOffset(node, end); 7714 7715 if (startMarker && endMarker) { 7716 if (selection.rangeCount === 1 && selection.anchorNode === startMarker.node && selection.anchorOffset === startMarker.offset && selection.focusNode === endMarker.node && selection.focusOffset === endMarker.offset) { 7717 return; 7718 } 7719 7720 var range = doc.createRange(); 7721 range.setStart(startMarker.node, startMarker.offset); 7722 selection.removeAllRanges(); 7723 7724 if (start > end) { 7725 selection.addRange(range); 7726 selection.extend(endMarker.node, endMarker.offset); 7727 } else { 7728 range.setEnd(endMarker.node, endMarker.offset); 7729 selection.addRange(range); 7730 } 7731 } 7732} 7733 7734function isTextNode(node) { 7735 return node && node.nodeType === TEXT_NODE; 7736} 7737 7738function containsNode(outerNode, innerNode) { 7739 if (!outerNode || !innerNode) { 7740 return false; 7741 } else if (outerNode === innerNode) { 7742 return true; 7743 } else if (isTextNode(outerNode)) { 7744 return false; 7745 } else if (isTextNode(innerNode)) { 7746 return containsNode(outerNode, innerNode.parentNode); 7747 } else if ('contains' in outerNode) { 7748 return outerNode.contains(innerNode); 7749 } else if (outerNode.compareDocumentPosition) { 7750 return !!(outerNode.compareDocumentPosition(innerNode) & 16); 7751 } else { 7752 return false; 7753 } 7754} 7755 7756function isInDocument(node) { 7757 return node && node.ownerDocument && containsNode(node.ownerDocument.documentElement, node); 7758} 7759 7760function isSameOriginFrame(iframe) { 7761 try { 7762 // Accessing the contentDocument of a HTMLIframeElement can cause the browser 7763 // to throw, e.g. if it has a cross-origin src attribute. 7764 // Safari will show an error in the console when the access results in "Blocked a frame with origin". e.g: 7765 // iframe.contentDocument.defaultView; 7766 // A safety way is to access one of the cross origin properties: Window or Location 7767 // Which might result in "SecurityError" DOM Exception and it is compatible to Safari. 7768 // https://html.spec.whatwg.org/multipage/browsers.html#integration-with-idl 7769 return typeof iframe.contentWindow.location.href === 'string'; 7770 } catch (err) { 7771 return false; 7772 } 7773} 7774 7775function getActiveElementDeep() { 7776 var win = window; 7777 var element = getActiveElement(); 7778 7779 while (element instanceof win.HTMLIFrameElement) { 7780 if (isSameOriginFrame(element)) { 7781 win = element.contentWindow; 7782 } else { 7783 return element; 7784 } 7785 7786 element = getActiveElement(win.document); 7787 } 7788 7789 return element; 7790} 7791/** 7792 * @ReactInputSelection: React input selection module. Based on Selection.js, 7793 * but modified to be suitable for react and has a couple of bug fixes (doesn't 7794 * assume buttons have range selections allowed). 7795 * Input selection module for React. 7796 */ 7797 7798/** 7799 * @hasSelectionCapabilities: we get the element types that support selection 7800 * from https://html.spec.whatwg.org/#do-not-apply, looking at `selectionStart` 7801 * and `selectionEnd` rows. 7802 */ 7803 7804 7805function hasSelectionCapabilities(elem) { 7806 var nodeName = elem && elem.nodeName && elem.nodeName.toLowerCase(); 7807 return nodeName && (nodeName === 'input' && (elem.type === 'text' || elem.type === 'search' || elem.type === 'tel' || elem.type === 'url' || elem.type === 'password') || nodeName === 'textarea' || elem.contentEditable === 'true'); 7808} 7809function getSelectionInformation() { 7810 var focusedElem = getActiveElementDeep(); 7811 return { 7812 focusedElem: focusedElem, 7813 selectionRange: hasSelectionCapabilities(focusedElem) ? getSelection(focusedElem) : null 7814 }; 7815} 7816/** 7817 * @restoreSelection: If any selection information was potentially lost, 7818 * restore it. This is useful when performing operations that could remove dom 7819 * nodes and place them back in, resulting in focus being lost. 7820 */ 7821 7822function restoreSelection(priorSelectionInformation) { 7823 var curFocusedElem = getActiveElementDeep(); 7824 var priorFocusedElem = priorSelectionInformation.focusedElem; 7825 var priorSelectionRange = priorSelectionInformation.selectionRange; 7826 7827 if (curFocusedElem !== priorFocusedElem && isInDocument(priorFocusedElem)) { 7828 if (priorSelectionRange !== null && hasSelectionCapabilities(priorFocusedElem)) { 7829 setSelection(priorFocusedElem, priorSelectionRange); 7830 } // Focusing a node can change the scroll position, which is undesirable 7831 7832 7833 var ancestors = []; 7834 var ancestor = priorFocusedElem; 7835 7836 while (ancestor = ancestor.parentNode) { 7837 if (ancestor.nodeType === ELEMENT_NODE) { 7838 ancestors.push({ 7839 element: ancestor, 7840 left: ancestor.scrollLeft, 7841 top: ancestor.scrollTop 7842 }); 7843 } 7844 } 7845 7846 if (typeof priorFocusedElem.focus === 'function') { 7847 priorFocusedElem.focus(); 7848 } 7849 7850 for (var i = 0; i < ancestors.length; i++) { 7851 var info = ancestors[i]; 7852 info.element.scrollLeft = info.left; 7853 info.element.scrollTop = info.top; 7854 } 7855 } 7856} 7857/** 7858 * @getSelection: Gets the selection bounds of a focused textarea, input or 7859 * contentEditable node. 7860 * -@input: Look up selection bounds of this input 7861 * -@return {start: selectionStart, end: selectionEnd} 7862 */ 7863 7864function getSelection(input) { 7865 var selection; 7866 7867 if ('selectionStart' in input) { 7868 // Modern browser with input or textarea. 7869 selection = { 7870 start: input.selectionStart, 7871 end: input.selectionEnd 7872 }; 7873 } else { 7874 // Content editable or old IE textarea. 7875 selection = getOffsets(input); 7876 } 7877 7878 return selection || { 7879 start: 0, 7880 end: 0 7881 }; 7882} 7883/** 7884 * @setSelection: Sets the selection bounds of a textarea or input and focuses 7885 * the input. 7886 * -@input Set selection bounds of this input or textarea 7887 * -@offsets Object of same form that is returned from get* 7888 */ 7889 7890function setSelection(input, offsets) { 7891 var start = offsets.start; 7892 var end = offsets.end; 7893 7894 if (end === undefined) { 7895 end = start; 7896 } 7897 7898 if ('selectionStart' in input) { 7899 input.selectionStart = start; 7900 input.selectionEnd = Math.min(end, input.value.length); 7901 } else { 7902 setOffsets(input, offsets); 7903 } 7904} 7905 7906var skipSelectionChangeEvent = canUseDOM && 'documentMode' in document && document.documentMode <= 11; 7907 7908function registerEvents$3() { 7909 registerTwoPhaseEvent('onSelect', ['focusout', 'contextmenu', 'dragend', 'focusin', 'keydown', 'keyup', 'mousedown', 'mouseup', 'selectionchange']); 7910} 7911 7912var activeElement$1 = null; 7913var activeElementInst$1 = null; 7914var lastSelection = null; 7915var mouseDown = false; 7916/** 7917 * Get an object which is a unique representation of the current selection. 7918 * 7919 * The return value will not be consistent across nodes or browsers, but 7920 * two identical selections on the same node will return identical objects. 7921 */ 7922 7923function getSelection$1(node) { 7924 if ('selectionStart' in node && hasSelectionCapabilities(node)) { 7925 return { 7926 start: node.selectionStart, 7927 end: node.selectionEnd 7928 }; 7929 } else { 7930 var win = node.ownerDocument && node.ownerDocument.defaultView || window; 7931 var selection = win.getSelection(); 7932 return { 7933 anchorNode: selection.anchorNode, 7934 anchorOffset: selection.anchorOffset, 7935 focusNode: selection.focusNode, 7936 focusOffset: selection.focusOffset 7937 }; 7938 } 7939} 7940/** 7941 * Get document associated with the event target. 7942 */ 7943 7944 7945function getEventTargetDocument(eventTarget) { 7946 return eventTarget.window === eventTarget ? eventTarget.document : eventTarget.nodeType === DOCUMENT_NODE ? eventTarget : eventTarget.ownerDocument; 7947} 7948/** 7949 * Poll selection to see whether it's changed. 7950 * 7951 * @param {object} nativeEvent 7952 * @param {object} nativeEventTarget 7953 * @return {?SyntheticEvent} 7954 */ 7955 7956 7957function constructSelectEvent(dispatchQueue, nativeEvent, nativeEventTarget) { 7958 // Ensure we have the right element, and that the user is not dragging a 7959 // selection (this matches native `select` event behavior). In HTML5, select 7960 // fires only on input and textarea thus if there's no focused element we 7961 // won't dispatch. 7962 var doc = getEventTargetDocument(nativeEventTarget); 7963 7964 if (mouseDown || activeElement$1 == null || activeElement$1 !== getActiveElement(doc)) { 7965 return; 7966 } // Only fire when selection has actually changed. 7967 7968 7969 var currentSelection = getSelection$1(activeElement$1); 7970 7971 if (!lastSelection || !shallowEqual(lastSelection, currentSelection)) { 7972 lastSelection = currentSelection; 7973 var listeners = accumulateTwoPhaseListeners(activeElementInst$1, 'onSelect'); 7974 7975 if (listeners.length > 0) { 7976 var event = new SyntheticEvent('onSelect', 'select', null, nativeEvent, nativeEventTarget); 7977 dispatchQueue.push({ 7978 event: event, 7979 listeners: listeners 7980 }); 7981 event.target = activeElement$1; 7982 } 7983 } 7984} 7985/** 7986 * This plugin creates an `onSelect` event that normalizes select events 7987 * across form elements. 7988 * 7989 * Supported elements are: 7990 * - input (see `isTextInputElement`) 7991 * - textarea 7992 * - contentEditable 7993 * 7994 * This differs from native browser implementations in the following ways: 7995 * - Fires on contentEditable fields as well as inputs. 7996 * - Fires for collapsed selection. 7997 * - Fires after user input. 7998 */ 7999 8000 8001function extractEvents$3(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags, targetContainer) { 8002 8003 var targetNode = targetInst ? getNodeFromInstance(targetInst) : window; 8004 8005 switch (domEventName) { 8006 // Track the input node that has focus. 8007 case 'focusin': 8008 if (isTextInputElement(targetNode) || targetNode.contentEditable === 'true') { 8009 activeElement$1 = targetNode; 8010 activeElementInst$1 = targetInst; 8011 lastSelection = null; 8012 } 8013 8014 break; 8015 8016 case 'focusout': 8017 activeElement$1 = null; 8018 activeElementInst$1 = null; 8019 lastSelection = null; 8020 break; 8021 // Don't fire the event while the user is dragging. This matches the 8022 // semantics of the native select event. 8023 8024 case 'mousedown': 8025 mouseDown = true; 8026 break; 8027 8028 case 'contextmenu': 8029 case 'mouseup': 8030 case 'dragend': 8031 mouseDown = false; 8032 constructSelectEvent(dispatchQueue, nativeEvent, nativeEventTarget); 8033 break; 8034 // Chrome and IE fire non-standard event when selection is changed (and 8035 // sometimes when it hasn't). IE's event fires out of order with respect 8036 // to key and input events on deletion, so we discard it. 8037 // 8038 // Firefox doesn't support selectionchange, so check selection status 8039 // after each key entry. The selection changes after keydown and before 8040 // keyup, but we check on keydown as well in the case of holding down a 8041 // key, when multiple keydown events are fired but only one keyup is. 8042 // This is also our approach for IE handling, for the reason above. 8043 8044 case 'selectionchange': 8045 if (skipSelectionChangeEvent) { 8046 break; 8047 } 8048 8049 // falls through 8050 8051 case 'keydown': 8052 case 'keyup': 8053 constructSelectEvent(dispatchQueue, nativeEvent, nativeEventTarget); 8054 } 8055} 8056 8057function extractEvents$4(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags, targetContainer) { 8058 var reactName = topLevelEventsToReactNames.get(domEventName); 8059 8060 if (reactName === undefined) { 8061 return; 8062 } 8063 8064 var SyntheticEventCtor = SyntheticEvent; 8065 var reactEventType = domEventName; 8066 8067 switch (domEventName) { 8068 case 'keypress': 8069 // Firefox creates a keypress event for function keys too. This removes 8070 // the unwanted keypress events. Enter is however both printable and 8071 // non-printable. One would expect Tab to be as well (but it isn't). 8072 if (getEventCharCode(nativeEvent) === 0) { 8073 return; 8074 } 8075 8076 /* falls through */ 8077 8078 case 'keydown': 8079 case 'keyup': 8080 SyntheticEventCtor = SyntheticKeyboardEvent; 8081 break; 8082 8083 case 'focusin': 8084 reactEventType = 'focus'; 8085 SyntheticEventCtor = SyntheticFocusEvent; 8086 break; 8087 8088 case 'focusout': 8089 reactEventType = 'blur'; 8090 SyntheticEventCtor = SyntheticFocusEvent; 8091 break; 8092 8093 case 'beforeblur': 8094 case 'afterblur': 8095 SyntheticEventCtor = SyntheticFocusEvent; 8096 break; 8097 8098 case 'click': 8099 // Firefox creates a click event on right mouse clicks. This removes the 8100 // unwanted click events. 8101 if (nativeEvent.button === 2) { 8102 return; 8103 } 8104 8105 /* falls through */ 8106 8107 case 'auxclick': 8108 case 'dblclick': 8109 case 'mousedown': 8110 case 'mousemove': 8111 case 'mouseup': // TODO: Disabled elements should not respond to mouse events 8112 8113 /* falls through */ 8114 8115 case 'mouseout': 8116 case 'mouseover': 8117 case 'contextmenu': 8118 SyntheticEventCtor = SyntheticMouseEvent; 8119 break; 8120 8121 case 'drag': 8122 case 'dragend': 8123 case 'dragenter': 8124 case 'dragexit': 8125 case 'dragleave': 8126 case 'dragover': 8127 case 'dragstart': 8128 case 'drop': 8129 SyntheticEventCtor = SyntheticDragEvent; 8130 break; 8131 8132 case 'touchcancel': 8133 case 'touchend': 8134 case 'touchmove': 8135 case 'touchstart': 8136 SyntheticEventCtor = SyntheticTouchEvent; 8137 break; 8138 8139 case ANIMATION_END: 8140 case ANIMATION_ITERATION: 8141 case ANIMATION_START: 8142 SyntheticEventCtor = SyntheticAnimationEvent; 8143 break; 8144 8145 case TRANSITION_END: 8146 SyntheticEventCtor = SyntheticTransitionEvent; 8147 break; 8148 8149 case 'scroll': 8150 SyntheticEventCtor = SyntheticUIEvent; 8151 break; 8152 8153 case 'wheel': 8154 SyntheticEventCtor = SyntheticWheelEvent; 8155 break; 8156 8157 case 'copy': 8158 case 'cut': 8159 case 'paste': 8160 SyntheticEventCtor = SyntheticClipboardEvent; 8161 break; 8162 8163 case 'gotpointercapture': 8164 case 'lostpointercapture': 8165 case 'pointercancel': 8166 case 'pointerdown': 8167 case 'pointermove': 8168 case 'pointerout': 8169 case 'pointerover': 8170 case 'pointerup': 8171 SyntheticEventCtor = SyntheticPointerEvent; 8172 break; 8173 } 8174 8175 var inCapturePhase = (eventSystemFlags & IS_CAPTURE_PHASE) !== 0; 8176 8177 { 8178 // Some events don't bubble in the browser. 8179 // In the past, React has always bubbled them, but this can be surprising. 8180 // We're going to try aligning closer to the browser behavior by not bubbling 8181 // them in React either. We'll start by not bubbling onScroll, and then expand. 8182 var accumulateTargetOnly = !inCapturePhase && // TODO: ideally, we'd eventually add all events from 8183 // nonDelegatedEvents list in DOMPluginEventSystem. 8184 // Then we can remove this special list. 8185 // This is a breaking change that can wait until React 18. 8186 domEventName === 'scroll'; 8187 8188 var _listeners = accumulateSinglePhaseListeners(targetInst, reactName, nativeEvent.type, inCapturePhase, accumulateTargetOnly); 8189 8190 if (_listeners.length > 0) { 8191 // Intentionally create event lazily. 8192 var _event = new SyntheticEventCtor(reactName, reactEventType, null, nativeEvent, nativeEventTarget); 8193 8194 dispatchQueue.push({ 8195 event: _event, 8196 listeners: _listeners 8197 }); 8198 } 8199 } 8200} 8201 8202// TODO: remove top-level side effect. 8203registerSimpleEvents(); 8204registerEvents$2(); 8205registerEvents$1(); 8206registerEvents$3(); 8207registerEvents(); 8208 8209function extractEvents$5(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags, targetContainer) { 8210 // TODO: we should remove the concept of a "SimpleEventPlugin". 8211 // This is the basic functionality of the event system. All 8212 // the other plugins are essentially polyfills. So the plugin 8213 // should probably be inlined somewhere and have its logic 8214 // be core the to event system. This would potentially allow 8215 // us to ship builds of React without the polyfilled plugins below. 8216 extractEvents$4(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags); 8217 var shouldProcessPolyfillPlugins = (eventSystemFlags & SHOULD_NOT_PROCESS_POLYFILL_EVENT_PLUGINS) === 0; // We don't process these events unless we are in the 8218 // event's native "bubble" phase, which means that we're 8219 // not in the capture phase. That's because we emulate 8220 // the capture phase here still. This is a trade-off, 8221 // because in an ideal world we would not emulate and use 8222 // the phases properly, like we do with the SimpleEvent 8223 // plugin. However, the plugins below either expect 8224 // emulation (EnterLeave) or use state localized to that 8225 // plugin (BeforeInput, Change, Select). The state in 8226 // these modules complicates things, as you'll essentially 8227 // get the case where the capture phase event might change 8228 // state, only for the following bubble event to come in 8229 // later and not trigger anything as the state now 8230 // invalidates the heuristics of the event plugin. We 8231 // could alter all these plugins to work in such ways, but 8232 // that might cause other unknown side-effects that we 8233 // can't forsee right now. 8234 8235 if (shouldProcessPolyfillPlugins) { 8236 extractEvents$2(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags); 8237 extractEvents$1(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget); 8238 extractEvents$3(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget); 8239 extractEvents(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget); 8240 } 8241} // List of events that need to be individually attached to media elements. 8242 8243 8244var mediaEventTypes = ['abort', 'canplay', 'canplaythrough', 'durationchange', 'emptied', 'encrypted', 'ended', 'error', 'loadeddata', 'loadedmetadata', 'loadstart', 'pause', 'play', 'playing', 'progress', 'ratechange', 'seeked', 'seeking', 'stalled', 'suspend', 'timeupdate', 'volumechange', 'waiting']; // We should not delegate these events to the container, but rather 8245// set them on the actual target element itself. This is primarily 8246// because these events do not consistently bubble in the DOM. 8247 8248var nonDelegatedEvents = new Set(['cancel', 'close', 'invalid', 'load', 'scroll', 'toggle'].concat(mediaEventTypes)); 8249 8250function executeDispatch(event, listener, currentTarget) { 8251 var type = event.type || 'unknown-event'; 8252 event.currentTarget = currentTarget; 8253 invokeGuardedCallbackAndCatchFirstError(type, listener, undefined, event); 8254 event.currentTarget = null; 8255} 8256 8257function processDispatchQueueItemsInOrder(event, dispatchListeners, inCapturePhase) { 8258 var previousInstance; 8259 8260 if (inCapturePhase) { 8261 for (var i = dispatchListeners.length - 1; i >= 0; i--) { 8262 var _dispatchListeners$i = dispatchListeners[i], 8263 instance = _dispatchListeners$i.instance, 8264 currentTarget = _dispatchListeners$i.currentTarget, 8265 listener = _dispatchListeners$i.listener; 8266 8267 if (instance !== previousInstance && event.isPropagationStopped()) { 8268 return; 8269 } 8270 8271 executeDispatch(event, listener, currentTarget); 8272 previousInstance = instance; 8273 } 8274 } else { 8275 for (var _i = 0; _i < dispatchListeners.length; _i++) { 8276 var _dispatchListeners$_i = dispatchListeners[_i], 8277 _instance = _dispatchListeners$_i.instance, 8278 _currentTarget = _dispatchListeners$_i.currentTarget, 8279 _listener = _dispatchListeners$_i.listener; 8280 8281 if (_instance !== previousInstance && event.isPropagationStopped()) { 8282 return; 8283 } 8284 8285 executeDispatch(event, _listener, _currentTarget); 8286 previousInstance = _instance; 8287 } 8288 } 8289} 8290 8291function processDispatchQueue(dispatchQueue, eventSystemFlags) { 8292 var inCapturePhase = (eventSystemFlags & IS_CAPTURE_PHASE) !== 0; 8293 8294 for (var i = 0; i < dispatchQueue.length; i++) { 8295 var _dispatchQueue$i = dispatchQueue[i], 8296 event = _dispatchQueue$i.event, 8297 listeners = _dispatchQueue$i.listeners; 8298 processDispatchQueueItemsInOrder(event, listeners, inCapturePhase); // event system doesn't use pooling. 8299 } // This would be a good time to rethrow if any of the event handlers threw. 8300 8301 8302 rethrowCaughtError(); 8303} 8304 8305function dispatchEventsForPlugins(domEventName, eventSystemFlags, nativeEvent, targetInst, targetContainer) { 8306 var nativeEventTarget = getEventTarget(nativeEvent); 8307 var dispatchQueue = []; 8308 extractEvents$5(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags); 8309 processDispatchQueue(dispatchQueue, eventSystemFlags); 8310} 8311 8312function listenToNonDelegatedEvent(domEventName, targetElement) { 8313 var isCapturePhaseListener = false; 8314 var listenerSet = getEventListenerSet(targetElement); 8315 var listenerSetKey = getListenerSetKey(domEventName, isCapturePhaseListener); 8316 8317 if (!listenerSet.has(listenerSetKey)) { 8318 addTrappedEventListener(targetElement, domEventName, IS_NON_DELEGATED, isCapturePhaseListener); 8319 listenerSet.add(listenerSetKey); 8320 } 8321} 8322var listeningMarker = '_reactListening' + Math.random().toString(36).slice(2); 8323function listenToAllSupportedEvents(rootContainerElement) { 8324 { 8325 if (rootContainerElement[listeningMarker]) { 8326 // Performance optimization: don't iterate through events 8327 // for the same portal container or root node more than once. 8328 // TODO: once we remove the flag, we may be able to also 8329 // remove some of the bookkeeping maps used for laziness. 8330 return; 8331 } 8332 8333 rootContainerElement[listeningMarker] = true; 8334 allNativeEvents.forEach(function (domEventName) { 8335 if (!nonDelegatedEvents.has(domEventName)) { 8336 listenToNativeEvent(domEventName, false, rootContainerElement, null); 8337 } 8338 8339 listenToNativeEvent(domEventName, true, rootContainerElement, null); 8340 }); 8341 } 8342} 8343function listenToNativeEvent(domEventName, isCapturePhaseListener, rootContainerElement, targetElement) { 8344 var eventSystemFlags = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0; 8345 var target = rootContainerElement; // selectionchange needs to be attached to the document 8346 // otherwise it won't capture incoming events that are only 8347 // triggered on the document directly. 8348 8349 if (domEventName === 'selectionchange' && rootContainerElement.nodeType !== DOCUMENT_NODE) { 8350 target = rootContainerElement.ownerDocument; 8351 } // If the event can be delegated (or is capture phase), we can 8352 // register it to the root container. Otherwise, we should 8353 // register the event to the target element and mark it as 8354 // a non-delegated event. 8355 8356 8357 if (targetElement !== null && !isCapturePhaseListener && nonDelegatedEvents.has(domEventName)) { 8358 // For all non-delegated events, apart from scroll, we attach 8359 // their event listeners to the respective elements that their 8360 // events fire on. That means we can skip this step, as event 8361 // listener has already been added previously. However, we 8362 // special case the scroll event because the reality is that any 8363 // element can scroll. 8364 // TODO: ideally, we'd eventually apply the same logic to all 8365 // events from the nonDelegatedEvents list. Then we can remove 8366 // this special case and use the same logic for all events. 8367 if (domEventName !== 'scroll') { 8368 return; 8369 } 8370 8371 eventSystemFlags |= IS_NON_DELEGATED; 8372 target = targetElement; 8373 } 8374 8375 var listenerSet = getEventListenerSet(target); 8376 var listenerSetKey = getListenerSetKey(domEventName, isCapturePhaseListener); // If the listener entry is empty or we should upgrade, then 8377 // we need to trap an event listener onto the target. 8378 8379 if (!listenerSet.has(listenerSetKey)) { 8380 if (isCapturePhaseListener) { 8381 eventSystemFlags |= IS_CAPTURE_PHASE; 8382 } 8383 8384 addTrappedEventListener(target, domEventName, eventSystemFlags, isCapturePhaseListener); 8385 listenerSet.add(listenerSetKey); 8386 } 8387} 8388 8389function addTrappedEventListener(targetContainer, domEventName, eventSystemFlags, isCapturePhaseListener, isDeferredListenerForLegacyFBSupport) { 8390 var listener = createEventListenerWrapperWithPriority(targetContainer, domEventName, eventSystemFlags); // If passive option is not supported, then the event will be 8391 // active and not passive. 8392 8393 var isPassiveListener = undefined; 8394 8395 if (passiveBrowserEventsSupported) { 8396 // Browsers introduced an intervention, making these events 8397 // passive by default on document. React doesn't bind them 8398 // to document anymore, but changing this now would undo 8399 // the performance wins from the change. So we emulate 8400 // the existing behavior manually on the roots now. 8401 // https://github.com/facebook/react/issues/19651 8402 if (domEventName === 'touchstart' || domEventName === 'touchmove' || domEventName === 'wheel') { 8403 isPassiveListener = true; 8404 } 8405 } 8406 8407 targetContainer = targetContainer; 8408 var unsubscribeListener; // When legacyFBSupport is enabled, it's for when we 8409 8410 8411 if (isCapturePhaseListener) { 8412 if (isPassiveListener !== undefined) { 8413 unsubscribeListener = addEventCaptureListenerWithPassiveFlag(targetContainer, domEventName, listener, isPassiveListener); 8414 } else { 8415 unsubscribeListener = addEventCaptureListener(targetContainer, domEventName, listener); 8416 } 8417 } else { 8418 if (isPassiveListener !== undefined) { 8419 unsubscribeListener = addEventBubbleListenerWithPassiveFlag(targetContainer, domEventName, listener, isPassiveListener); 8420 } else { 8421 unsubscribeListener = addEventBubbleListener(targetContainer, domEventName, listener); 8422 } 8423 } 8424} 8425 8426function isMatchingRootContainer(grandContainer, targetContainer) { 8427 return grandContainer === targetContainer || grandContainer.nodeType === COMMENT_NODE && grandContainer.parentNode === targetContainer; 8428} 8429 8430function dispatchEventForPluginEventSystem(domEventName, eventSystemFlags, nativeEvent, targetInst, targetContainer) { 8431 var ancestorInst = targetInst; 8432 8433 if ((eventSystemFlags & IS_EVENT_HANDLE_NON_MANAGED_NODE) === 0 && (eventSystemFlags & IS_NON_DELEGATED) === 0) { 8434 var targetContainerNode = targetContainer; // If we are using the legacy FB support flag, we 8435 8436 if (targetInst !== null) { 8437 // The below logic attempts to work out if we need to change 8438 // the target fiber to a different ancestor. We had similar logic 8439 // in the legacy event system, except the big difference between 8440 // systems is that the modern event system now has an event listener 8441 // attached to each React Root and React Portal Root. Together, 8442 // the DOM nodes representing these roots are the "rootContainer". 8443 // To figure out which ancestor instance we should use, we traverse 8444 // up the fiber tree from the target instance and attempt to find 8445 // root boundaries that match that of our current "rootContainer". 8446 // If we find that "rootContainer", we find the parent fiber 8447 // sub-tree for that root and make that our ancestor instance. 8448 var node = targetInst; 8449 8450 mainLoop: while (true) { 8451 if (node === null) { 8452 return; 8453 } 8454 8455 var nodeTag = node.tag; 8456 8457 if (nodeTag === HostRoot || nodeTag === HostPortal) { 8458 var container = node.stateNode.containerInfo; 8459 8460 if (isMatchingRootContainer(container, targetContainerNode)) { 8461 break; 8462 } 8463 8464 if (nodeTag === HostPortal) { 8465 // The target is a portal, but it's not the rootContainer we're looking for. 8466 // Normally portals handle their own events all the way down to the root. 8467 // So we should be able to stop now. However, we don't know if this portal 8468 // was part of *our* root. 8469 var grandNode = node.return; 8470 8471 while (grandNode !== null) { 8472 var grandTag = grandNode.tag; 8473 8474 if (grandTag === HostRoot || grandTag === HostPortal) { 8475 var grandContainer = grandNode.stateNode.containerInfo; 8476 8477 if (isMatchingRootContainer(grandContainer, targetContainerNode)) { 8478 // This is the rootContainer we're looking for and we found it as 8479 // a parent of the Portal. That means we can ignore it because the 8480 // Portal will bubble through to us. 8481 return; 8482 } 8483 } 8484 8485 grandNode = grandNode.return; 8486 } 8487 } // Now we need to find it's corresponding host fiber in the other 8488 // tree. To do this we can use getClosestInstanceFromNode, but we 8489 // need to validate that the fiber is a host instance, otherwise 8490 // we need to traverse up through the DOM till we find the correct 8491 // node that is from the other tree. 8492 8493 8494 while (container !== null) { 8495 var parentNode = getClosestInstanceFromNode(container); 8496 8497 if (parentNode === null) { 8498 return; 8499 } 8500 8501 var parentTag = parentNode.tag; 8502 8503 if (parentTag === HostComponent || parentTag === HostText) { 8504 node = ancestorInst = parentNode; 8505 continue mainLoop; 8506 } 8507 8508 container = container.parentNode; 8509 } 8510 } 8511 8512 node = node.return; 8513 } 8514 } 8515 } 8516 8517 batchedEventUpdates(function () { 8518 return dispatchEventsForPlugins(domEventName, eventSystemFlags, nativeEvent, ancestorInst); 8519 }); 8520} 8521 8522function createDispatchListener(instance, listener, currentTarget) { 8523 return { 8524 instance: instance, 8525 listener: listener, 8526 currentTarget: currentTarget 8527 }; 8528} 8529 8530function accumulateSinglePhaseListeners(targetFiber, reactName, nativeEventType, inCapturePhase, accumulateTargetOnly) { 8531 var captureName = reactName !== null ? reactName + 'Capture' : null; 8532 var reactEventName = inCapturePhase ? captureName : reactName; 8533 var listeners = []; 8534 var instance = targetFiber; 8535 var lastHostComponent = null; // Accumulate all instances and listeners via the target -> root path. 8536 8537 while (instance !== null) { 8538 var _instance2 = instance, 8539 stateNode = _instance2.stateNode, 8540 tag = _instance2.tag; // Handle listeners that are on HostComponents (i.e. <div>) 8541 8542 if (tag === HostComponent && stateNode !== null) { 8543 lastHostComponent = stateNode; // createEventHandle listeners 8544 8545 8546 if (reactEventName !== null) { 8547 var listener = getListener(instance, reactEventName); 8548 8549 if (listener != null) { 8550 listeners.push(createDispatchListener(instance, listener, lastHostComponent)); 8551 } 8552 } 8553 } // If we are only accumulating events for the target, then we don't 8554 // continue to propagate through the React fiber tree to find other 8555 // listeners. 8556 8557 8558 if (accumulateTargetOnly) { 8559 break; 8560 } 8561 8562 instance = instance.return; 8563 } 8564 8565 return listeners; 8566} // We should only use this function for: 8567// - BeforeInputEventPlugin 8568// - ChangeEventPlugin 8569// - SelectEventPlugin 8570// This is because we only process these plugins 8571// in the bubble phase, so we need to accumulate two 8572// phase event listeners (via emulation). 8573 8574function accumulateTwoPhaseListeners(targetFiber, reactName) { 8575 var captureName = reactName + 'Capture'; 8576 var listeners = []; 8577 var instance = targetFiber; // Accumulate all instances and listeners via the target -> root path. 8578 8579 while (instance !== null) { 8580 var _instance3 = instance, 8581 stateNode = _instance3.stateNode, 8582 tag = _instance3.tag; // Handle listeners that are on HostComponents (i.e. <div>) 8583 8584 if (tag === HostComponent && stateNode !== null) { 8585 var currentTarget = stateNode; 8586 var captureListener = getListener(instance, captureName); 8587 8588 if (captureListener != null) { 8589 listeners.unshift(createDispatchListener(instance, captureListener, currentTarget)); 8590 } 8591 8592 var bubbleListener = getListener(instance, reactName); 8593 8594 if (bubbleListener != null) { 8595 listeners.push(createDispatchListener(instance, bubbleListener, currentTarget)); 8596 } 8597 } 8598 8599 instance = instance.return; 8600 } 8601 8602 return listeners; 8603} 8604 8605function getParent(inst) { 8606 if (inst === null) { 8607 return null; 8608 } 8609 8610 do { 8611 inst = inst.return; // TODO: If this is a HostRoot we might want to bail out. 8612 // That is depending on if we want nested subtrees (layers) to bubble 8613 // events to their parent. We could also go through parentNode on the 8614 // host node but that wouldn't work for React Native and doesn't let us 8615 // do the portal feature. 8616 } while (inst && inst.tag !== HostComponent); 8617 8618 if (inst) { 8619 return inst; 8620 } 8621 8622 return null; 8623} 8624/** 8625 * Return the lowest common ancestor of A and B, or null if they are in 8626 * different trees. 8627 */ 8628 8629 8630function getLowestCommonAncestor(instA, instB) { 8631 var nodeA = instA; 8632 var nodeB = instB; 8633 var depthA = 0; 8634 8635 for (var tempA = nodeA; tempA; tempA = getParent(tempA)) { 8636 depthA++; 8637 } 8638 8639 var depthB = 0; 8640 8641 for (var tempB = nodeB; tempB; tempB = getParent(tempB)) { 8642 depthB++; 8643 } // If A is deeper, crawl up. 8644 8645 8646 while (depthA - depthB > 0) { 8647 nodeA = getParent(nodeA); 8648 depthA--; 8649 } // If B is deeper, crawl up. 8650 8651 8652 while (depthB - depthA > 0) { 8653 nodeB = getParent(nodeB); 8654 depthB--; 8655 } // Walk in lockstep until we find a match. 8656 8657 8658 var depth = depthA; 8659 8660 while (depth--) { 8661 if (nodeA === nodeB || nodeB !== null && nodeA === nodeB.alternate) { 8662 return nodeA; 8663 } 8664 8665 nodeA = getParent(nodeA); 8666 nodeB = getParent(nodeB); 8667 } 8668 8669 return null; 8670} 8671 8672function accumulateEnterLeaveListenersForEvent(dispatchQueue, event, target, common, inCapturePhase) { 8673 var registrationName = event._reactName; 8674 var listeners = []; 8675 var instance = target; 8676 8677 while (instance !== null) { 8678 if (instance === common) { 8679 break; 8680 } 8681 8682 var _instance4 = instance, 8683 alternate = _instance4.alternate, 8684 stateNode = _instance4.stateNode, 8685 tag = _instance4.tag; 8686 8687 if (alternate !== null && alternate === common) { 8688 break; 8689 } 8690 8691 if (tag === HostComponent && stateNode !== null) { 8692 var currentTarget = stateNode; 8693 8694 if (inCapturePhase) { 8695 var captureListener = getListener(instance, registrationName); 8696 8697 if (captureListener != null) { 8698 listeners.unshift(createDispatchListener(instance, captureListener, currentTarget)); 8699 } 8700 } else if (!inCapturePhase) { 8701 var bubbleListener = getListener(instance, registrationName); 8702 8703 if (bubbleListener != null) { 8704 listeners.push(createDispatchListener(instance, bubbleListener, currentTarget)); 8705 } 8706 } 8707 } 8708 8709 instance = instance.return; 8710 } 8711 8712 if (listeners.length !== 0) { 8713 dispatchQueue.push({ 8714 event: event, 8715 listeners: listeners 8716 }); 8717 } 8718} // We should only use this function for: 8719// - EnterLeaveEventPlugin 8720// This is because we only process this plugin 8721// in the bubble phase, so we need to accumulate two 8722// phase event listeners. 8723 8724 8725function accumulateEnterLeaveTwoPhaseListeners(dispatchQueue, leaveEvent, enterEvent, from, to) { 8726 var common = from && to ? getLowestCommonAncestor(from, to) : null; 8727 8728 if (from !== null) { 8729 accumulateEnterLeaveListenersForEvent(dispatchQueue, leaveEvent, from, common, false); 8730 } 8731 8732 if (to !== null && enterEvent !== null) { 8733 accumulateEnterLeaveListenersForEvent(dispatchQueue, enterEvent, to, common, true); 8734 } 8735} 8736function getListenerSetKey(domEventName, capture) { 8737 return domEventName + "__" + (capture ? 'capture' : 'bubble'); 8738} 8739 8740var didWarnInvalidHydration = false; 8741var DANGEROUSLY_SET_INNER_HTML = 'dangerouslySetInnerHTML'; 8742var SUPPRESS_CONTENT_EDITABLE_WARNING = 'suppressContentEditableWarning'; 8743var SUPPRESS_HYDRATION_WARNING = 'suppressHydrationWarning'; 8744var AUTOFOCUS = 'autoFocus'; 8745var CHILDREN = 'children'; 8746var STYLE = 'style'; 8747var HTML$1 = '__html'; 8748var HTML_NAMESPACE$1 = Namespaces.html; 8749var warnedUnknownTags; 8750var suppressHydrationWarning; 8751var validatePropertiesInDevelopment; 8752var warnForTextDifference; 8753var warnForPropDifference; 8754var warnForExtraAttributes; 8755var warnForInvalidEventListener; 8756var canDiffStyleForHydrationWarning; 8757var normalizeMarkupForTextOrAttribute; 8758var normalizeHTML; 8759 8760{ 8761 warnedUnknownTags = { 8762 // There are working polyfills for <dialog>. Let people use it. 8763 dialog: true, 8764 // Electron ships a custom <webview> tag to display external web content in 8765 // an isolated frame and process. 8766 // This tag is not present in non Electron environments such as JSDom which 8767 // is often used for testing purposes. 8768 // @see https://electronjs.org/docs/api/webview-tag 8769 webview: true 8770 }; 8771 8772 validatePropertiesInDevelopment = function (type, props) { 8773 validateProperties(type, props); 8774 validateProperties$1(type, props); 8775 validateProperties$2(type, props, { 8776 registrationNameDependencies: registrationNameDependencies, 8777 possibleRegistrationNames: possibleRegistrationNames 8778 }); 8779 }; // IE 11 parses & normalizes the style attribute as opposed to other 8780 // browsers. It adds spaces and sorts the properties in some 8781 // non-alphabetical order. Handling that would require sorting CSS 8782 // properties in the client & server versions or applying 8783 // `expectedStyle` to a temporary DOM node to read its `style` attribute 8784 // normalized. Since it only affects IE, we're skipping style warnings 8785 // in that browser completely in favor of doing all that work. 8786 // See https://github.com/facebook/react/issues/11807 8787 8788 8789 canDiffStyleForHydrationWarning = canUseDOM && !document.documentMode; // HTML parsing normalizes CR and CRLF to LF. 8790 // It also can turn \u0000 into \uFFFD inside attributes. 8791 // https://www.w3.org/TR/html5/single-page.html#preprocessing-the-input-stream 8792 // If we have a mismatch, it might be caused by that. 8793 // We will still patch up in this case but not fire the warning. 8794 8795 var NORMALIZE_NEWLINES_REGEX = /\r\n?/g; 8796 var NORMALIZE_NULL_AND_REPLACEMENT_REGEX = /\u0000|\uFFFD/g; 8797 8798 normalizeMarkupForTextOrAttribute = function (markup) { 8799 var markupString = typeof markup === 'string' ? markup : '' + markup; 8800 return markupString.replace(NORMALIZE_NEWLINES_REGEX, '\n').replace(NORMALIZE_NULL_AND_REPLACEMENT_REGEX, ''); 8801 }; 8802 8803 warnForTextDifference = function (serverText, clientText) { 8804 if (didWarnInvalidHydration) { 8805 return; 8806 } 8807 8808 var normalizedClientText = normalizeMarkupForTextOrAttribute(clientText); 8809 var normalizedServerText = normalizeMarkupForTextOrAttribute(serverText); 8810 8811 if (normalizedServerText === normalizedClientText) { 8812 return; 8813 } 8814 8815 didWarnInvalidHydration = true; 8816 8817 error('Text content did not match. Server: "%s" Client: "%s"', normalizedServerText, normalizedClientText); 8818 }; 8819 8820 warnForPropDifference = function (propName, serverValue, clientValue) { 8821 if (didWarnInvalidHydration) { 8822 return; 8823 } 8824 8825 var normalizedClientValue = normalizeMarkupForTextOrAttribute(clientValue); 8826 var normalizedServerValue = normalizeMarkupForTextOrAttribute(serverValue); 8827 8828 if (normalizedServerValue === normalizedClientValue) { 8829 return; 8830 } 8831 8832 didWarnInvalidHydration = true; 8833 8834 error('Prop `%s` did not match. Server: %s Client: %s', propName, JSON.stringify(normalizedServerValue), JSON.stringify(normalizedClientValue)); 8835 }; 8836 8837 warnForExtraAttributes = function (attributeNames) { 8838 if (didWarnInvalidHydration) { 8839 return; 8840 } 8841 8842 didWarnInvalidHydration = true; 8843 var names = []; 8844 attributeNames.forEach(function (name) { 8845 names.push(name); 8846 }); 8847 8848 error('Extra attributes from the server: %s', names); 8849 }; 8850 8851 warnForInvalidEventListener = function (registrationName, listener) { 8852 if (listener === false) { 8853 error('Expected `%s` listener to be a function, instead got `false`.\n\n' + 'If you used to conditionally omit it with %s={condition && value}, ' + 'pass %s={condition ? value : undefined} instead.', registrationName, registrationName, registrationName); 8854 } else { 8855 error('Expected `%s` listener to be a function, instead got a value of `%s` type.', registrationName, typeof listener); 8856 } 8857 }; // Parse the HTML and read it back to normalize the HTML string so that it 8858 // can be used for comparison. 8859 8860 8861 normalizeHTML = function (parent, html) { 8862 // We could have created a separate document here to avoid 8863 // re-initializing custom elements if they exist. But this breaks 8864 // how <noscript> is being handled. So we use the same document. 8865 // See the discussion in https://github.com/facebook/react/pull/11157. 8866 var testElement = parent.namespaceURI === HTML_NAMESPACE$1 ? parent.ownerDocument.createElement(parent.tagName) : parent.ownerDocument.createElementNS(parent.namespaceURI, parent.tagName); 8867 testElement.innerHTML = html; 8868 return testElement.innerHTML; 8869 }; 8870} 8871 8872function getOwnerDocumentFromRootContainer(rootContainerElement) { 8873 return rootContainerElement.nodeType === DOCUMENT_NODE ? rootContainerElement : rootContainerElement.ownerDocument; 8874} 8875 8876function noop() {} 8877 8878function trapClickOnNonInteractiveElement(node) { 8879 // Mobile Safari does not fire properly bubble click events on 8880 // non-interactive elements, which means delegated click listeners do not 8881 // fire. The workaround for this bug involves attaching an empty click 8882 // listener on the target node. 8883 // https://www.quirksmode.org/blog/archives/2010/09/click_event_del.html 8884 // Just set it using the onclick property so that we don't have to manage any 8885 // bookkeeping for it. Not sure if we need to clear it when the listener is 8886 // removed. 8887 // TODO: Only do this for the relevant Safaris maybe? 8888 node.onclick = noop; 8889} 8890 8891function setInitialDOMProperties(tag, domElement, rootContainerElement, nextProps, isCustomComponentTag) { 8892 for (var propKey in nextProps) { 8893 if (!nextProps.hasOwnProperty(propKey)) { 8894 continue; 8895 } 8896 8897 var nextProp = nextProps[propKey]; 8898 8899 if (propKey === STYLE) { 8900 { 8901 if (nextProp) { 8902 // Freeze the next style object so that we can assume it won't be 8903 // mutated. We have already warned for this in the past. 8904 Object.freeze(nextProp); 8905 } 8906 } // Relies on `updateStylesByID` not mutating `styleUpdates`. 8907 8908 8909 setValueForStyles(domElement, nextProp); 8910 } else if (propKey === DANGEROUSLY_SET_INNER_HTML) { 8911 var nextHtml = nextProp ? nextProp[HTML$1] : undefined; 8912 8913 if (nextHtml != null) { 8914 setInnerHTML(domElement, nextHtml); 8915 } 8916 } else if (propKey === CHILDREN) { 8917 if (typeof nextProp === 'string') { 8918 // Avoid setting initial textContent when the text is empty. In IE11 setting 8919 // textContent on a <textarea> will cause the placeholder to not 8920 // show within the <textarea> until it has been focused and blurred again. 8921 // https://github.com/facebook/react/issues/6731#issuecomment-254874553 8922 var canSetTextContent = tag !== 'textarea' || nextProp !== ''; 8923 8924 if (canSetTextContent) { 8925 setTextContent(domElement, nextProp); 8926 } 8927 } else if (typeof nextProp === 'number') { 8928 setTextContent(domElement, '' + nextProp); 8929 } 8930 } else if (propKey === SUPPRESS_CONTENT_EDITABLE_WARNING || propKey === SUPPRESS_HYDRATION_WARNING) ; else if (propKey === AUTOFOCUS) ; else if (registrationNameDependencies.hasOwnProperty(propKey)) { 8931 if (nextProp != null) { 8932 if ( typeof nextProp !== 'function') { 8933 warnForInvalidEventListener(propKey, nextProp); 8934 } 8935 8936 if (propKey === 'onScroll') { 8937 listenToNonDelegatedEvent('scroll', domElement); 8938 } 8939 } 8940 } else if (nextProp != null) { 8941 setValueForProperty(domElement, propKey, nextProp, isCustomComponentTag); 8942 } 8943 } 8944} 8945 8946function updateDOMProperties(domElement, updatePayload, wasCustomComponentTag, isCustomComponentTag) { 8947 // TODO: Handle wasCustomComponentTag 8948 for (var i = 0; i < updatePayload.length; i += 2) { 8949 var propKey = updatePayload[i]; 8950 var propValue = updatePayload[i + 1]; 8951 8952 if (propKey === STYLE) { 8953 setValueForStyles(domElement, propValue); 8954 } else if (propKey === DANGEROUSLY_SET_INNER_HTML) { 8955 setInnerHTML(domElement, propValue); 8956 } else if (propKey === CHILDREN) { 8957 setTextContent(domElement, propValue); 8958 } else { 8959 setValueForProperty(domElement, propKey, propValue, isCustomComponentTag); 8960 } 8961 } 8962} 8963 8964function createElement(type, props, rootContainerElement, parentNamespace) { 8965 var isCustomComponentTag; // We create tags in the namespace of their parent container, except HTML 8966 // tags get no namespace. 8967 8968 var ownerDocument = getOwnerDocumentFromRootContainer(rootContainerElement); 8969 var domElement; 8970 var namespaceURI = parentNamespace; 8971 8972 if (namespaceURI === HTML_NAMESPACE$1) { 8973 namespaceURI = getIntrinsicNamespace(type); 8974 } 8975 8976 if (namespaceURI === HTML_NAMESPACE$1) { 8977 { 8978 isCustomComponentTag = isCustomComponent(type, props); // Should this check be gated by parent namespace? Not sure we want to 8979 // allow <SVG> or <mATH>. 8980 8981 if (!isCustomComponentTag && type !== type.toLowerCase()) { 8982 error('<%s /> is using incorrect casing. ' + 'Use PascalCase for React components, ' + 'or lowercase for HTML elements.', type); 8983 } 8984 } 8985 8986 if (type === 'script') { 8987 // Create the script via .innerHTML so its "parser-inserted" flag is 8988 // set to true and it does not execute 8989 var div = ownerDocument.createElement('div'); 8990 8991 div.innerHTML = '<script><' + '/script>'; // eslint-disable-line 8992 // This is guaranteed to yield a script element. 8993 8994 var firstChild = div.firstChild; 8995 domElement = div.removeChild(firstChild); 8996 } else if (typeof props.is === 'string') { 8997 // $FlowIssue `createElement` should be updated for Web Components 8998 domElement = ownerDocument.createElement(type, { 8999 is: props.is 9000 }); 9001 } else { 9002 // Separate else branch instead of using `props.is || undefined` above because of a Firefox bug. 9003 // See discussion in https://github.com/facebook/react/pull/6896 9004 // and discussion in https://bugzilla.mozilla.org/show_bug.cgi?id=1276240 9005 domElement = ownerDocument.createElement(type); // Normally attributes are assigned in `setInitialDOMProperties`, however the `multiple` and `size` 9006 // attributes on `select`s needs to be added before `option`s are inserted. 9007 // This prevents: 9008 // - a bug where the `select` does not scroll to the correct option because singular 9009 // `select` elements automatically pick the first item #13222 9010 // - a bug where the `select` set the first item as selected despite the `size` attribute #14239 9011 // See https://github.com/facebook/react/issues/13222 9012 // and https://github.com/facebook/react/issues/14239 9013 9014 if (type === 'select') { 9015 var node = domElement; 9016 9017 if (props.multiple) { 9018 node.multiple = true; 9019 } else if (props.size) { 9020 // Setting a size greater than 1 causes a select to behave like `multiple=true`, where 9021 // it is possible that no option is selected. 9022 // 9023 // This is only necessary when a select in "single selection mode". 9024 node.size = props.size; 9025 } 9026 } 9027 } 9028 } else { 9029 domElement = ownerDocument.createElementNS(namespaceURI, type); 9030 } 9031 9032 { 9033 if (namespaceURI === HTML_NAMESPACE$1) { 9034 if (!isCustomComponentTag && Object.prototype.toString.call(domElement) === '[object HTMLUnknownElement]' && !Object.prototype.hasOwnProperty.call(warnedUnknownTags, type)) { 9035 warnedUnknownTags[type] = true; 9036 9037 error('The tag <%s> is unrecognized in this browser. ' + 'If you meant to render a React component, start its name with ' + 'an uppercase letter.', type); 9038 } 9039 } 9040 } 9041 9042 return domElement; 9043} 9044function createTextNode(text, rootContainerElement) { 9045 return getOwnerDocumentFromRootContainer(rootContainerElement).createTextNode(text); 9046} 9047function setInitialProperties(domElement, tag, rawProps, rootContainerElement) { 9048 var isCustomComponentTag = isCustomComponent(tag, rawProps); 9049 9050 { 9051 validatePropertiesInDevelopment(tag, rawProps); 9052 } // TODO: Make sure that we check isMounted before firing any of these events. 9053 9054 9055 var props; 9056 9057 switch (tag) { 9058 case 'dialog': 9059 listenToNonDelegatedEvent('cancel', domElement); 9060 listenToNonDelegatedEvent('close', domElement); 9061 props = rawProps; 9062 break; 9063 9064 case 'iframe': 9065 case 'object': 9066 case 'embed': 9067 // We listen to this event in case to ensure emulated bubble 9068 // listeners still fire for the load event. 9069 listenToNonDelegatedEvent('load', domElement); 9070 props = rawProps; 9071 break; 9072 9073 case 'video': 9074 case 'audio': 9075 // We listen to these events in case to ensure emulated bubble 9076 // listeners still fire for all the media events. 9077 for (var i = 0; i < mediaEventTypes.length; i++) { 9078 listenToNonDelegatedEvent(mediaEventTypes[i], domElement); 9079 } 9080 9081 props = rawProps; 9082 break; 9083 9084 case 'source': 9085 // We listen to this event in case to ensure emulated bubble 9086 // listeners still fire for the error event. 9087 listenToNonDelegatedEvent('error', domElement); 9088 props = rawProps; 9089 break; 9090 9091 case 'img': 9092 case 'image': 9093 case 'link': 9094 // We listen to these events in case to ensure emulated bubble 9095 // listeners still fire for error and load events. 9096 listenToNonDelegatedEvent('error', domElement); 9097 listenToNonDelegatedEvent('load', domElement); 9098 props = rawProps; 9099 break; 9100 9101 case 'details': 9102 // We listen to this event in case to ensure emulated bubble 9103 // listeners still fire for the toggle event. 9104 listenToNonDelegatedEvent('toggle', domElement); 9105 props = rawProps; 9106 break; 9107 9108 case 'input': 9109 initWrapperState(domElement, rawProps); 9110 props = getHostProps(domElement, rawProps); // We listen to this event in case to ensure emulated bubble 9111 // listeners still fire for the invalid event. 9112 9113 listenToNonDelegatedEvent('invalid', domElement); 9114 9115 break; 9116 9117 case 'option': 9118 validateProps(domElement, rawProps); 9119 props = getHostProps$1(domElement, rawProps); 9120 break; 9121 9122 case 'select': 9123 initWrapperState$1(domElement, rawProps); 9124 props = getHostProps$2(domElement, rawProps); // We listen to this event in case to ensure emulated bubble 9125 // listeners still fire for the invalid event. 9126 9127 listenToNonDelegatedEvent('invalid', domElement); 9128 9129 break; 9130 9131 case 'textarea': 9132 initWrapperState$2(domElement, rawProps); 9133 props = getHostProps$3(domElement, rawProps); // We listen to this event in case to ensure emulated bubble 9134 // listeners still fire for the invalid event. 9135 9136 listenToNonDelegatedEvent('invalid', domElement); 9137 9138 break; 9139 9140 default: 9141 props = rawProps; 9142 } 9143 9144 assertValidProps(tag, props); 9145 setInitialDOMProperties(tag, domElement, rootContainerElement, props, isCustomComponentTag); 9146 9147 switch (tag) { 9148 case 'input': 9149 // TODO: Make sure we check if this is still unmounted or do any clean 9150 // up necessary since we never stop tracking anymore. 9151 track(domElement); 9152 postMountWrapper(domElement, rawProps, false); 9153 break; 9154 9155 case 'textarea': 9156 // TODO: Make sure we check if this is still unmounted or do any clean 9157 // up necessary since we never stop tracking anymore. 9158 track(domElement); 9159 postMountWrapper$3(domElement); 9160 break; 9161 9162 case 'option': 9163 postMountWrapper$1(domElement, rawProps); 9164 break; 9165 9166 case 'select': 9167 postMountWrapper$2(domElement, rawProps); 9168 break; 9169 9170 default: 9171 if (typeof props.onClick === 'function') { 9172 // TODO: This cast may not be sound for SVG, MathML or custom elements. 9173 trapClickOnNonInteractiveElement(domElement); 9174 } 9175 9176 break; 9177 } 9178} // Calculate the diff between the two objects. 9179 9180function diffProperties(domElement, tag, lastRawProps, nextRawProps, rootContainerElement) { 9181 { 9182 validatePropertiesInDevelopment(tag, nextRawProps); 9183 } 9184 9185 var updatePayload = null; 9186 var lastProps; 9187 var nextProps; 9188 9189 switch (tag) { 9190 case 'input': 9191 lastProps = getHostProps(domElement, lastRawProps); 9192 nextProps = getHostProps(domElement, nextRawProps); 9193 updatePayload = []; 9194 break; 9195 9196 case 'option': 9197 lastProps = getHostProps$1(domElement, lastRawProps); 9198 nextProps = getHostProps$1(domElement, nextRawProps); 9199 updatePayload = []; 9200 break; 9201 9202 case 'select': 9203 lastProps = getHostProps$2(domElement, lastRawProps); 9204 nextProps = getHostProps$2(domElement, nextRawProps); 9205 updatePayload = []; 9206 break; 9207 9208 case 'textarea': 9209 lastProps = getHostProps$3(domElement, lastRawProps); 9210 nextProps = getHostProps$3(domElement, nextRawProps); 9211 updatePayload = []; 9212 break; 9213 9214 default: 9215 lastProps = lastRawProps; 9216 nextProps = nextRawProps; 9217 9218 if (typeof lastProps.onClick !== 'function' && typeof nextProps.onClick === 'function') { 9219 // TODO: This cast may not be sound for SVG, MathML or custom elements. 9220 trapClickOnNonInteractiveElement(domElement); 9221 } 9222 9223 break; 9224 } 9225 9226 assertValidProps(tag, nextProps); 9227 var propKey; 9228 var styleName; 9229 var styleUpdates = null; 9230 9231 for (propKey in lastProps) { 9232 if (nextProps.hasOwnProperty(propKey) || !lastProps.hasOwnProperty(propKey) || lastProps[propKey] == null) { 9233 continue; 9234 } 9235 9236 if (propKey === STYLE) { 9237 var lastStyle = lastProps[propKey]; 9238 9239 for (styleName in lastStyle) { 9240 if (lastStyle.hasOwnProperty(styleName)) { 9241 if (!styleUpdates) { 9242 styleUpdates = {}; 9243 } 9244 9245 styleUpdates[styleName] = ''; 9246 } 9247 } 9248 } else if (propKey === DANGEROUSLY_SET_INNER_HTML || propKey === CHILDREN) ; else if (propKey === SUPPRESS_CONTENT_EDITABLE_WARNING || propKey === SUPPRESS_HYDRATION_WARNING) ; else if (propKey === AUTOFOCUS) ; else if (registrationNameDependencies.hasOwnProperty(propKey)) { 9249 // This is a special case. If any listener updates we need to ensure 9250 // that the "current" fiber pointer gets updated so we need a commit 9251 // to update this element. 9252 if (!updatePayload) { 9253 updatePayload = []; 9254 } 9255 } else { 9256 // For all other deleted properties we add it to the queue. We use 9257 // the allowed property list in the commit phase instead. 9258 (updatePayload = updatePayload || []).push(propKey, null); 9259 } 9260 } 9261 9262 for (propKey in nextProps) { 9263 var nextProp = nextProps[propKey]; 9264 var lastProp = lastProps != null ? lastProps[propKey] : undefined; 9265 9266 if (!nextProps.hasOwnProperty(propKey) || nextProp === lastProp || nextProp == null && lastProp == null) { 9267 continue; 9268 } 9269 9270 if (propKey === STYLE) { 9271 { 9272 if (nextProp) { 9273 // Freeze the next style object so that we can assume it won't be 9274 // mutated. We have already warned for this in the past. 9275 Object.freeze(nextProp); 9276 } 9277 } 9278 9279 if (lastProp) { 9280 // Unset styles on `lastProp` but not on `nextProp`. 9281 for (styleName in lastProp) { 9282 if (lastProp.hasOwnProperty(styleName) && (!nextProp || !nextProp.hasOwnProperty(styleName))) { 9283 if (!styleUpdates) { 9284 styleUpdates = {}; 9285 } 9286 9287 styleUpdates[styleName] = ''; 9288 } 9289 } // Update styles that changed since `lastProp`. 9290 9291 9292 for (styleName in nextProp) { 9293 if (nextProp.hasOwnProperty(styleName) && lastProp[styleName] !== nextProp[styleName]) { 9294 if (!styleUpdates) { 9295 styleUpdates = {}; 9296 } 9297 9298 styleUpdates[styleName] = nextProp[styleName]; 9299 } 9300 } 9301 } else { 9302 // Relies on `updateStylesByID` not mutating `styleUpdates`. 9303 if (!styleUpdates) { 9304 if (!updatePayload) { 9305 updatePayload = []; 9306 } 9307 9308 updatePayload.push(propKey, styleUpdates); 9309 } 9310 9311 styleUpdates = nextProp; 9312 } 9313 } else if (propKey === DANGEROUSLY_SET_INNER_HTML) { 9314 var nextHtml = nextProp ? nextProp[HTML$1] : undefined; 9315 var lastHtml = lastProp ? lastProp[HTML$1] : undefined; 9316 9317 if (nextHtml != null) { 9318 if (lastHtml !== nextHtml) { 9319 (updatePayload = updatePayload || []).push(propKey, nextHtml); 9320 } 9321 } 9322 } else if (propKey === CHILDREN) { 9323 if (typeof nextProp === 'string' || typeof nextProp === 'number') { 9324 (updatePayload = updatePayload || []).push(propKey, '' + nextProp); 9325 } 9326 } else if (propKey === SUPPRESS_CONTENT_EDITABLE_WARNING || propKey === SUPPRESS_HYDRATION_WARNING) ; else if (registrationNameDependencies.hasOwnProperty(propKey)) { 9327 if (nextProp != null) { 9328 // We eagerly listen to this even though we haven't committed yet. 9329 if ( typeof nextProp !== 'function') { 9330 warnForInvalidEventListener(propKey, nextProp); 9331 } 9332 9333 if (propKey === 'onScroll') { 9334 listenToNonDelegatedEvent('scroll', domElement); 9335 } 9336 } 9337 9338 if (!updatePayload && lastProp !== nextProp) { 9339 // This is a special case. If any listener updates we need to ensure 9340 // that the "current" props pointer gets updated so we need a commit 9341 // to update this element. 9342 updatePayload = []; 9343 } 9344 } else if (typeof nextProp === 'object' && nextProp !== null && nextProp.$$typeof === REACT_OPAQUE_ID_TYPE) { 9345 // If we encounter useOpaqueReference's opaque object, this means we are hydrating. 9346 // In this case, call the opaque object's toString function which generates a new client 9347 // ID so client and server IDs match and throws to rerender. 9348 nextProp.toString(); 9349 } else { 9350 // For any other property we always add it to the queue and then we 9351 // filter it out using the allowed property list during the commit. 9352 (updatePayload = updatePayload || []).push(propKey, nextProp); 9353 } 9354 } 9355 9356 if (styleUpdates) { 9357 { 9358 validateShorthandPropertyCollisionInDev(styleUpdates, nextProps[STYLE]); 9359 } 9360 9361 (updatePayload = updatePayload || []).push(STYLE, styleUpdates); 9362 } 9363 9364 return updatePayload; 9365} // Apply the diff. 9366 9367function updateProperties(domElement, updatePayload, tag, lastRawProps, nextRawProps) { 9368 // Update checked *before* name. 9369 // In the middle of an update, it is possible to have multiple checked. 9370 // When a checked radio tries to change name, browser makes another radio's checked false. 9371 if (tag === 'input' && nextRawProps.type === 'radio' && nextRawProps.name != null) { 9372 updateChecked(domElement, nextRawProps); 9373 } 9374 9375 var wasCustomComponentTag = isCustomComponent(tag, lastRawProps); 9376 var isCustomComponentTag = isCustomComponent(tag, nextRawProps); // Apply the diff. 9377 9378 updateDOMProperties(domElement, updatePayload, wasCustomComponentTag, isCustomComponentTag); // TODO: Ensure that an update gets scheduled if any of the special props 9379 // changed. 9380 9381 switch (tag) { 9382 case 'input': 9383 // Update the wrapper around inputs *after* updating props. This has to 9384 // happen after `updateDOMProperties`. Otherwise HTML5 input validations 9385 // raise warnings and prevent the new value from being assigned. 9386 updateWrapper(domElement, nextRawProps); 9387 break; 9388 9389 case 'textarea': 9390 updateWrapper$1(domElement, nextRawProps); 9391 break; 9392 9393 case 'select': 9394 // <select> value update needs to occur after <option> children 9395 // reconciliation 9396 postUpdateWrapper(domElement, nextRawProps); 9397 break; 9398 } 9399} 9400 9401function getPossibleStandardName(propName) { 9402 { 9403 var lowerCasedName = propName.toLowerCase(); 9404 9405 if (!possibleStandardNames.hasOwnProperty(lowerCasedName)) { 9406 return null; 9407 } 9408 9409 return possibleStandardNames[lowerCasedName] || null; 9410 } 9411} 9412 9413function diffHydratedProperties(domElement, tag, rawProps, parentNamespace, rootContainerElement) { 9414 var isCustomComponentTag; 9415 var extraAttributeNames; 9416 9417 { 9418 suppressHydrationWarning = rawProps[SUPPRESS_HYDRATION_WARNING] === true; 9419 isCustomComponentTag = isCustomComponent(tag, rawProps); 9420 validatePropertiesInDevelopment(tag, rawProps); 9421 } // TODO: Make sure that we check isMounted before firing any of these events. 9422 9423 9424 switch (tag) { 9425 case 'dialog': 9426 listenToNonDelegatedEvent('cancel', domElement); 9427 listenToNonDelegatedEvent('close', domElement); 9428 break; 9429 9430 case 'iframe': 9431 case 'object': 9432 case 'embed': 9433 // We listen to this event in case to ensure emulated bubble 9434 // listeners still fire for the load event. 9435 listenToNonDelegatedEvent('load', domElement); 9436 break; 9437 9438 case 'video': 9439 case 'audio': 9440 // We listen to these events in case to ensure emulated bubble 9441 // listeners still fire for all the media events. 9442 for (var i = 0; i < mediaEventTypes.length; i++) { 9443 listenToNonDelegatedEvent(mediaEventTypes[i], domElement); 9444 } 9445 9446 break; 9447 9448 case 'source': 9449 // We listen to this event in case to ensure emulated bubble 9450 // listeners still fire for the error event. 9451 listenToNonDelegatedEvent('error', domElement); 9452 break; 9453 9454 case 'img': 9455 case 'image': 9456 case 'link': 9457 // We listen to these events in case to ensure emulated bubble 9458 // listeners still fire for error and load events. 9459 listenToNonDelegatedEvent('error', domElement); 9460 listenToNonDelegatedEvent('load', domElement); 9461 break; 9462 9463 case 'details': 9464 // We listen to this event in case to ensure emulated bubble 9465 // listeners still fire for the toggle event. 9466 listenToNonDelegatedEvent('toggle', domElement); 9467 break; 9468 9469 case 'input': 9470 initWrapperState(domElement, rawProps); // We listen to this event in case to ensure emulated bubble 9471 // listeners still fire for the invalid event. 9472 9473 listenToNonDelegatedEvent('invalid', domElement); 9474 9475 break; 9476 9477 case 'option': 9478 validateProps(domElement, rawProps); 9479 break; 9480 9481 case 'select': 9482 initWrapperState$1(domElement, rawProps); // We listen to this event in case to ensure emulated bubble 9483 // listeners still fire for the invalid event. 9484 9485 listenToNonDelegatedEvent('invalid', domElement); 9486 9487 break; 9488 9489 case 'textarea': 9490 initWrapperState$2(domElement, rawProps); // We listen to this event in case to ensure emulated bubble 9491 // listeners still fire for the invalid event. 9492 9493 listenToNonDelegatedEvent('invalid', domElement); 9494 9495 break; 9496 } 9497 9498 assertValidProps(tag, rawProps); 9499 9500 { 9501 extraAttributeNames = new Set(); 9502 var attributes = domElement.attributes; 9503 9504 for (var _i = 0; _i < attributes.length; _i++) { 9505 var name = attributes[_i].name.toLowerCase(); 9506 9507 switch (name) { 9508 // Built-in SSR attribute is allowed 9509 case 'data-reactroot': 9510 break; 9511 // Controlled attributes are not validated 9512 // TODO: Only ignore them on controlled tags. 9513 9514 case 'value': 9515 break; 9516 9517 case 'checked': 9518 break; 9519 9520 case 'selected': 9521 break; 9522 9523 default: 9524 // Intentionally use the original name. 9525 // See discussion in https://github.com/facebook/react/pull/10676. 9526 extraAttributeNames.add(attributes[_i].name); 9527 } 9528 } 9529 } 9530 9531 var updatePayload = null; 9532 9533 for (var propKey in rawProps) { 9534 if (!rawProps.hasOwnProperty(propKey)) { 9535 continue; 9536 } 9537 9538 var nextProp = rawProps[propKey]; 9539 9540 if (propKey === CHILDREN) { 9541 // For text content children we compare against textContent. This 9542 // might match additional HTML that is hidden when we read it using 9543 // textContent. E.g. "foo" will match "f<span>oo</span>" but that still 9544 // satisfies our requirement. Our requirement is not to produce perfect 9545 // HTML and attributes. Ideally we should preserve structure but it's 9546 // ok not to if the visible content is still enough to indicate what 9547 // even listeners these nodes might be wired up to. 9548 // TODO: Warn if there is more than a single textNode as a child. 9549 // TODO: Should we use domElement.firstChild.nodeValue to compare? 9550 if (typeof nextProp === 'string') { 9551 if (domElement.textContent !== nextProp) { 9552 if ( !suppressHydrationWarning) { 9553 warnForTextDifference(domElement.textContent, nextProp); 9554 } 9555 9556 updatePayload = [CHILDREN, nextProp]; 9557 } 9558 } else if (typeof nextProp === 'number') { 9559 if (domElement.textContent !== '' + nextProp) { 9560 if ( !suppressHydrationWarning) { 9561 warnForTextDifference(domElement.textContent, nextProp); 9562 } 9563 9564 updatePayload = [CHILDREN, '' + nextProp]; 9565 } 9566 } 9567 } else if (registrationNameDependencies.hasOwnProperty(propKey)) { 9568 if (nextProp != null) { 9569 if ( typeof nextProp !== 'function') { 9570 warnForInvalidEventListener(propKey, nextProp); 9571 } 9572 9573 if (propKey === 'onScroll') { 9574 listenToNonDelegatedEvent('scroll', domElement); 9575 } 9576 } 9577 } else if ( // Convince Flow we've calculated it (it's DEV-only in this method.) 9578 typeof isCustomComponentTag === 'boolean') { 9579 // Validate that the properties correspond to their expected values. 9580 var serverValue = void 0; 9581 var propertyInfo = getPropertyInfo(propKey); 9582 9583 if (suppressHydrationWarning) ; else if (propKey === SUPPRESS_CONTENT_EDITABLE_WARNING || propKey === SUPPRESS_HYDRATION_WARNING || // Controlled attributes are not validated 9584 // TODO: Only ignore them on controlled tags. 9585 propKey === 'value' || propKey === 'checked' || propKey === 'selected') ; else if (propKey === DANGEROUSLY_SET_INNER_HTML) { 9586 var serverHTML = domElement.innerHTML; 9587 var nextHtml = nextProp ? nextProp[HTML$1] : undefined; 9588 9589 if (nextHtml != null) { 9590 var expectedHTML = normalizeHTML(domElement, nextHtml); 9591 9592 if (expectedHTML !== serverHTML) { 9593 warnForPropDifference(propKey, serverHTML, expectedHTML); 9594 } 9595 } 9596 } else if (propKey === STYLE) { 9597 // $FlowFixMe - Should be inferred as not undefined. 9598 extraAttributeNames.delete(propKey); 9599 9600 if (canDiffStyleForHydrationWarning) { 9601 var expectedStyle = createDangerousStringForStyles(nextProp); 9602 serverValue = domElement.getAttribute('style'); 9603 9604 if (expectedStyle !== serverValue) { 9605 warnForPropDifference(propKey, serverValue, expectedStyle); 9606 } 9607 } 9608 } else if (isCustomComponentTag) { 9609 // $FlowFixMe - Should be inferred as not undefined. 9610 extraAttributeNames.delete(propKey.toLowerCase()); 9611 serverValue = getValueForAttribute(domElement, propKey, nextProp); 9612 9613 if (nextProp !== serverValue) { 9614 warnForPropDifference(propKey, serverValue, nextProp); 9615 } 9616 } else if (!shouldIgnoreAttribute(propKey, propertyInfo, isCustomComponentTag) && !shouldRemoveAttribute(propKey, nextProp, propertyInfo, isCustomComponentTag)) { 9617 var isMismatchDueToBadCasing = false; 9618 9619 if (propertyInfo !== null) { 9620 // $FlowFixMe - Should be inferred as not undefined. 9621 extraAttributeNames.delete(propertyInfo.attributeName); 9622 serverValue = getValueForProperty(domElement, propKey, nextProp, propertyInfo); 9623 } else { 9624 var ownNamespace = parentNamespace; 9625 9626 if (ownNamespace === HTML_NAMESPACE$1) { 9627 ownNamespace = getIntrinsicNamespace(tag); 9628 } 9629 9630 if (ownNamespace === HTML_NAMESPACE$1) { 9631 // $FlowFixMe - Should be inferred as not undefined. 9632 extraAttributeNames.delete(propKey.toLowerCase()); 9633 } else { 9634 var standardName = getPossibleStandardName(propKey); 9635 9636 if (standardName !== null && standardName !== propKey) { 9637 // If an SVG prop is supplied with bad casing, it will 9638 // be successfully parsed from HTML, but will produce a mismatch 9639 // (and would be incorrectly rendered on the client). 9640 // However, we already warn about bad casing elsewhere. 9641 // So we'll skip the misleading extra mismatch warning in this case. 9642 isMismatchDueToBadCasing = true; // $FlowFixMe - Should be inferred as not undefined. 9643 9644 extraAttributeNames.delete(standardName); 9645 } // $FlowFixMe - Should be inferred as not undefined. 9646 9647 9648 extraAttributeNames.delete(propKey); 9649 } 9650 9651 serverValue = getValueForAttribute(domElement, propKey, nextProp); 9652 } 9653 9654 if (nextProp !== serverValue && !isMismatchDueToBadCasing) { 9655 warnForPropDifference(propKey, serverValue, nextProp); 9656 } 9657 } 9658 } 9659 } 9660 9661 { 9662 // $FlowFixMe - Should be inferred as not undefined. 9663 if (extraAttributeNames.size > 0 && !suppressHydrationWarning) { 9664 // $FlowFixMe - Should be inferred as not undefined. 9665 warnForExtraAttributes(extraAttributeNames); 9666 } 9667 } 9668 9669 switch (tag) { 9670 case 'input': 9671 // TODO: Make sure we check if this is still unmounted or do any clean 9672 // up necessary since we never stop tracking anymore. 9673 track(domElement); 9674 postMountWrapper(domElement, rawProps, true); 9675 break; 9676 9677 case 'textarea': 9678 // TODO: Make sure we check if this is still unmounted or do any clean 9679 // up necessary since we never stop tracking anymore. 9680 track(domElement); 9681 postMountWrapper$3(domElement); 9682 break; 9683 9684 case 'select': 9685 case 'option': 9686 // For input and textarea we current always set the value property at 9687 // post mount to force it to diverge from attributes. However, for 9688 // option and select we don't quite do the same thing and select 9689 // is not resilient to the DOM state changing so we don't do that here. 9690 // TODO: Consider not doing this for input and textarea. 9691 break; 9692 9693 default: 9694 if (typeof rawProps.onClick === 'function') { 9695 // TODO: This cast may not be sound for SVG, MathML or custom elements. 9696 trapClickOnNonInteractiveElement(domElement); 9697 } 9698 9699 break; 9700 } 9701 9702 return updatePayload; 9703} 9704function diffHydratedText(textNode, text) { 9705 var isDifferent = textNode.nodeValue !== text; 9706 return isDifferent; 9707} 9708function warnForUnmatchedText(textNode, text) { 9709 { 9710 warnForTextDifference(textNode.nodeValue, text); 9711 } 9712} 9713function warnForDeletedHydratableElement(parentNode, child) { 9714 { 9715 if (didWarnInvalidHydration) { 9716 return; 9717 } 9718 9719 didWarnInvalidHydration = true; 9720 9721 error('Did not expect server HTML to contain a <%s> in <%s>.', child.nodeName.toLowerCase(), parentNode.nodeName.toLowerCase()); 9722 } 9723} 9724function warnForDeletedHydratableText(parentNode, child) { 9725 { 9726 if (didWarnInvalidHydration) { 9727 return; 9728 } 9729 9730 didWarnInvalidHydration = true; 9731 9732 error('Did not expect server HTML to contain the text node "%s" in <%s>.', child.nodeValue, parentNode.nodeName.toLowerCase()); 9733 } 9734} 9735function warnForInsertedHydratedElement(parentNode, tag, props) { 9736 { 9737 if (didWarnInvalidHydration) { 9738 return; 9739 } 9740 9741 didWarnInvalidHydration = true; 9742 9743 error('Expected server HTML to contain a matching <%s> in <%s>.', tag, parentNode.nodeName.toLowerCase()); 9744 } 9745} 9746function warnForInsertedHydratedText(parentNode, text) { 9747 { 9748 if (text === '') { 9749 // We expect to insert empty text nodes since they're not represented in 9750 // the HTML. 9751 // TODO: Remove this special case if we can just avoid inserting empty 9752 // text nodes. 9753 return; 9754 } 9755 9756 if (didWarnInvalidHydration) { 9757 return; 9758 } 9759 9760 didWarnInvalidHydration = true; 9761 9762 error('Expected server HTML to contain a matching text node for "%s" in <%s>.', text, parentNode.nodeName.toLowerCase()); 9763 } 9764} 9765function restoreControlledState$3(domElement, tag, props) { 9766 switch (tag) { 9767 case 'input': 9768 restoreControlledState(domElement, props); 9769 return; 9770 9771 case 'textarea': 9772 restoreControlledState$2(domElement, props); 9773 return; 9774 9775 case 'select': 9776 restoreControlledState$1(domElement, props); 9777 return; 9778 } 9779} 9780 9781var validateDOMNesting = function () {}; 9782 9783var updatedAncestorInfo = function () {}; 9784 9785{ 9786 // This validation code was written based on the HTML5 parsing spec: 9787 // https://html.spec.whatwg.org/multipage/syntax.html#has-an-element-in-scope 9788 // 9789 // Note: this does not catch all invalid nesting, nor does it try to (as it's 9790 // not clear what practical benefit doing so provides); instead, we warn only 9791 // for cases where the parser will give a parse tree differing from what React 9792 // intended. For example, <b><div></div></b> is invalid but we don't warn 9793 // because it still parses correctly; we do warn for other cases like nested 9794 // <p> tags where the beginning of the second element implicitly closes the 9795 // first, causing a confusing mess. 9796 // https://html.spec.whatwg.org/multipage/syntax.html#special 9797 var specialTags = ['address', 'applet', 'area', 'article', 'aside', 'base', 'basefont', 'bgsound', 'blockquote', 'body', 'br', 'button', 'caption', 'center', 'col', 'colgroup', 'dd', 'details', 'dir', 'div', 'dl', 'dt', 'embed', 'fieldset', 'figcaption', 'figure', 'footer', 'form', 'frame', 'frameset', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hgroup', 'hr', 'html', 'iframe', 'img', 'input', 'isindex', 'li', 'link', 'listing', 'main', 'marquee', 'menu', 'menuitem', 'meta', 'nav', 'noembed', 'noframes', 'noscript', 'object', 'ol', 'p', 'param', 'plaintext', 'pre', 'script', 'section', 'select', 'source', 'style', 'summary', 'table', 'tbody', 'td', 'template', 'textarea', 'tfoot', 'th', 'thead', 'title', 'tr', 'track', 'ul', 'wbr', 'xmp']; // https://html.spec.whatwg.org/multipage/syntax.html#has-an-element-in-scope 9798 9799 var inScopeTags = ['applet', 'caption', 'html', 'table', 'td', 'th', 'marquee', 'object', 'template', // https://html.spec.whatwg.org/multipage/syntax.html#html-integration-point 9800 // TODO: Distinguish by namespace here -- for <title>, including it here 9801 // errs on the side of fewer warnings 9802 'foreignObject', 'desc', 'title']; // https://html.spec.whatwg.org/multipage/syntax.html#has-an-element-in-button-scope 9803 9804 var buttonScopeTags = inScopeTags.concat(['button']); // https://html.spec.whatwg.org/multipage/syntax.html#generate-implied-end-tags 9805 9806 var impliedEndTags = ['dd', 'dt', 'li', 'option', 'optgroup', 'p', 'rp', 'rt']; 9807 var emptyAncestorInfo = { 9808 current: null, 9809 formTag: null, 9810 aTagInScope: null, 9811 buttonTagInScope: null, 9812 nobrTagInScope: null, 9813 pTagInButtonScope: null, 9814 listItemTagAutoclosing: null, 9815 dlItemTagAutoclosing: null 9816 }; 9817 9818 updatedAncestorInfo = function (oldInfo, tag) { 9819 var ancestorInfo = _assign({}, oldInfo || emptyAncestorInfo); 9820 9821 var info = { 9822 tag: tag 9823 }; 9824 9825 if (inScopeTags.indexOf(tag) !== -1) { 9826 ancestorInfo.aTagInScope = null; 9827 ancestorInfo.buttonTagInScope = null; 9828 ancestorInfo.nobrTagInScope = null; 9829 } 9830 9831 if (buttonScopeTags.indexOf(tag) !== -1) { 9832 ancestorInfo.pTagInButtonScope = null; 9833 } // See rules for 'li', 'dd', 'dt' start tags in 9834 // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inbody 9835 9836 9837 if (specialTags.indexOf(tag) !== -1 && tag !== 'address' && tag !== 'div' && tag !== 'p') { 9838 ancestorInfo.listItemTagAutoclosing = null; 9839 ancestorInfo.dlItemTagAutoclosing = null; 9840 } 9841 9842 ancestorInfo.current = info; 9843 9844 if (tag === 'form') { 9845 ancestorInfo.formTag = info; 9846 } 9847 9848 if (tag === 'a') { 9849 ancestorInfo.aTagInScope = info; 9850 } 9851 9852 if (tag === 'button') { 9853 ancestorInfo.buttonTagInScope = info; 9854 } 9855 9856 if (tag === 'nobr') { 9857 ancestorInfo.nobrTagInScope = info; 9858 } 9859 9860 if (tag === 'p') { 9861 ancestorInfo.pTagInButtonScope = info; 9862 } 9863 9864 if (tag === 'li') { 9865 ancestorInfo.listItemTagAutoclosing = info; 9866 } 9867 9868 if (tag === 'dd' || tag === 'dt') { 9869 ancestorInfo.dlItemTagAutoclosing = info; 9870 } 9871 9872 return ancestorInfo; 9873 }; 9874 /** 9875 * Returns whether 9876 */ 9877 9878 9879 var isTagValidWithParent = function (tag, parentTag) { 9880 // First, let's check if we're in an unusual parsing mode... 9881 switch (parentTag) { 9882 // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inselect 9883 case 'select': 9884 return tag === 'option' || tag === 'optgroup' || tag === '#text'; 9885 9886 case 'optgroup': 9887 return tag === 'option' || tag === '#text'; 9888 // Strictly speaking, seeing an <option> doesn't mean we're in a <select> 9889 // but 9890 9891 case 'option': 9892 return tag === '#text'; 9893 // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-intd 9894 // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-incaption 9895 // No special behavior since these rules fall back to "in body" mode for 9896 // all except special table nodes which cause bad parsing behavior anyway. 9897 // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-intr 9898 9899 case 'tr': 9900 return tag === 'th' || tag === 'td' || tag === 'style' || tag === 'script' || tag === 'template'; 9901 // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-intbody 9902 9903 case 'tbody': 9904 case 'thead': 9905 case 'tfoot': 9906 return tag === 'tr' || tag === 'style' || tag === 'script' || tag === 'template'; 9907 // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-incolgroup 9908 9909 case 'colgroup': 9910 return tag === 'col' || tag === 'template'; 9911 // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-intable 9912 9913 case 'table': 9914 return tag === 'caption' || tag === 'colgroup' || tag === 'tbody' || tag === 'tfoot' || tag === 'thead' || tag === 'style' || tag === 'script' || tag === 'template'; 9915 // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inhead 9916 9917 case 'head': 9918 return tag === 'base' || tag === 'basefont' || tag === 'bgsound' || tag === 'link' || tag === 'meta' || tag === 'title' || tag === 'noscript' || tag === 'noframes' || tag === 'style' || tag === 'script' || tag === 'template'; 9919 // https://html.spec.whatwg.org/multipage/semantics.html#the-html-element 9920 9921 case 'html': 9922 return tag === 'head' || tag === 'body' || tag === 'frameset'; 9923 9924 case 'frameset': 9925 return tag === 'frame'; 9926 9927 case '#document': 9928 return tag === 'html'; 9929 } // Probably in the "in body" parsing mode, so we outlaw only tag combos 9930 // where the parsing rules cause implicit opens or closes to be added. 9931 // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inbody 9932 9933 9934 switch (tag) { 9935 case 'h1': 9936 case 'h2': 9937 case 'h3': 9938 case 'h4': 9939 case 'h5': 9940 case 'h6': 9941 return parentTag !== 'h1' && parentTag !== 'h2' && parentTag !== 'h3' && parentTag !== 'h4' && parentTag !== 'h5' && parentTag !== 'h6'; 9942 9943 case 'rp': 9944 case 'rt': 9945 return impliedEndTags.indexOf(parentTag) === -1; 9946 9947 case 'body': 9948 case 'caption': 9949 case 'col': 9950 case 'colgroup': 9951 case 'frameset': 9952 case 'frame': 9953 case 'head': 9954 case 'html': 9955 case 'tbody': 9956 case 'td': 9957 case 'tfoot': 9958 case 'th': 9959 case 'thead': 9960 case 'tr': 9961 // These tags are only valid with a few parents that have special child 9962 // parsing rules -- if we're down here, then none of those matched and 9963 // so we allow it only if we don't know what the parent is, as all other 9964 // cases are invalid. 9965 return parentTag == null; 9966 } 9967 9968 return true; 9969 }; 9970 /** 9971 * Returns whether 9972 */ 9973 9974 9975 var findInvalidAncestorForTag = function (tag, ancestorInfo) { 9976 switch (tag) { 9977 case 'address': 9978 case 'article': 9979 case 'aside': 9980 case 'blockquote': 9981 case 'center': 9982 case 'details': 9983 case 'dialog': 9984 case 'dir': 9985 case 'div': 9986 case 'dl': 9987 case 'fieldset': 9988 case 'figcaption': 9989 case 'figure': 9990 case 'footer': 9991 case 'header': 9992 case 'hgroup': 9993 case 'main': 9994 case 'menu': 9995 case 'nav': 9996 case 'ol': 9997 case 'p': 9998 case 'section': 9999 case 'summary': 10000 case 'ul': 10001 case 'pre': 10002 case 'listing': 10003 case 'table': 10004 case 'hr': 10005 case 'xmp': 10006 case 'h1': 10007 case 'h2': 10008 case 'h3': 10009 case 'h4': 10010 case 'h5': 10011 case 'h6': 10012 return ancestorInfo.pTagInButtonScope; 10013 10014 case 'form': 10015 return ancestorInfo.formTag || ancestorInfo.pTagInButtonScope; 10016 10017 case 'li': 10018 return ancestorInfo.listItemTagAutoclosing; 10019 10020 case 'dd': 10021 case 'dt': 10022 return ancestorInfo.dlItemTagAutoclosing; 10023 10024 case 'button': 10025 return ancestorInfo.buttonTagInScope; 10026 10027 case 'a': 10028 // Spec says something about storing a list of markers, but it sounds 10029 // equivalent to this check. 10030 return ancestorInfo.aTagInScope; 10031 10032 case 'nobr': 10033 return ancestorInfo.nobrTagInScope; 10034 } 10035 10036 return null; 10037 }; 10038 10039 var didWarn$1 = {}; 10040 10041 validateDOMNesting = function (childTag, childText, ancestorInfo) { 10042 ancestorInfo = ancestorInfo || emptyAncestorInfo; 10043 var parentInfo = ancestorInfo.current; 10044 var parentTag = parentInfo && parentInfo.tag; 10045 10046 if (childText != null) { 10047 if (childTag != null) { 10048 error('validateDOMNesting: when childText is passed, childTag should be null'); 10049 } 10050 10051 childTag = '#text'; 10052 } 10053 10054 var invalidParent = isTagValidWithParent(childTag, parentTag) ? null : parentInfo; 10055 var invalidAncestor = invalidParent ? null : findInvalidAncestorForTag(childTag, ancestorInfo); 10056 var invalidParentOrAncestor = invalidParent || invalidAncestor; 10057 10058 if (!invalidParentOrAncestor) { 10059 return; 10060 } 10061 10062 var ancestorTag = invalidParentOrAncestor.tag; 10063 var warnKey = !!invalidParent + '|' + childTag + '|' + ancestorTag; 10064 10065 if (didWarn$1[warnKey]) { 10066 return; 10067 } 10068 10069 didWarn$1[warnKey] = true; 10070 var tagDisplayName = childTag; 10071 var whitespaceInfo = ''; 10072 10073 if (childTag === '#text') { 10074 if (/\S/.test(childText)) { 10075 tagDisplayName = 'Text nodes'; 10076 } else { 10077 tagDisplayName = 'Whitespace text nodes'; 10078 whitespaceInfo = " Make sure you don't have any extra whitespace between tags on " + 'each line of your source code.'; 10079 } 10080 } else { 10081 tagDisplayName = '<' + childTag + '>'; 10082 } 10083 10084 if (invalidParent) { 10085 var info = ''; 10086 10087 if (ancestorTag === 'table' && childTag === 'tr') { 10088 info += ' Add a <tbody>, <thead> or <tfoot> to your code to match the DOM tree generated by ' + 'the browser.'; 10089 } 10090 10091 error('validateDOMNesting(...): %s cannot appear as a child of <%s>.%s%s', tagDisplayName, ancestorTag, whitespaceInfo, info); 10092 } else { 10093 error('validateDOMNesting(...): %s cannot appear as a descendant of ' + '<%s>.', tagDisplayName, ancestorTag); 10094 } 10095 }; 10096} 10097 10098var SUPPRESS_HYDRATION_WARNING$1; 10099 10100{ 10101 SUPPRESS_HYDRATION_WARNING$1 = 'suppressHydrationWarning'; 10102} 10103 10104var SUSPENSE_START_DATA = '$'; 10105var SUSPENSE_END_DATA = '/$'; 10106var SUSPENSE_PENDING_START_DATA = '$?'; 10107var SUSPENSE_FALLBACK_START_DATA = '$!'; 10108var STYLE$1 = 'style'; 10109var eventsEnabled = null; 10110var selectionInformation = null; 10111 10112function shouldAutoFocusHostComponent(type, props) { 10113 switch (type) { 10114 case 'button': 10115 case 'input': 10116 case 'select': 10117 case 'textarea': 10118 return !!props.autoFocus; 10119 } 10120 10121 return false; 10122} 10123function getRootHostContext(rootContainerInstance) { 10124 var type; 10125 var namespace; 10126 var nodeType = rootContainerInstance.nodeType; 10127 10128 switch (nodeType) { 10129 case DOCUMENT_NODE: 10130 case DOCUMENT_FRAGMENT_NODE: 10131 { 10132 type = nodeType === DOCUMENT_NODE ? '#document' : '#fragment'; 10133 var root = rootContainerInstance.documentElement; 10134 namespace = root ? root.namespaceURI : getChildNamespace(null, ''); 10135 break; 10136 } 10137 10138 default: 10139 { 10140 var container = nodeType === COMMENT_NODE ? rootContainerInstance.parentNode : rootContainerInstance; 10141 var ownNamespace = container.namespaceURI || null; 10142 type = container.tagName; 10143 namespace = getChildNamespace(ownNamespace, type); 10144 break; 10145 } 10146 } 10147 10148 { 10149 var validatedTag = type.toLowerCase(); 10150 var ancestorInfo = updatedAncestorInfo(null, validatedTag); 10151 return { 10152 namespace: namespace, 10153 ancestorInfo: ancestorInfo 10154 }; 10155 } 10156} 10157function getChildHostContext(parentHostContext, type, rootContainerInstance) { 10158 { 10159 var parentHostContextDev = parentHostContext; 10160 var namespace = getChildNamespace(parentHostContextDev.namespace, type); 10161 var ancestorInfo = updatedAncestorInfo(parentHostContextDev.ancestorInfo, type); 10162 return { 10163 namespace: namespace, 10164 ancestorInfo: ancestorInfo 10165 }; 10166 } 10167} 10168function getPublicInstance(instance) { 10169 return instance; 10170} 10171function prepareForCommit(containerInfo) { 10172 eventsEnabled = isEnabled(); 10173 selectionInformation = getSelectionInformation(); 10174 var activeInstance = null; 10175 10176 setEnabled(false); 10177 return activeInstance; 10178} 10179function resetAfterCommit(containerInfo) { 10180 restoreSelection(selectionInformation); 10181 setEnabled(eventsEnabled); 10182 eventsEnabled = null; 10183 selectionInformation = null; 10184} 10185function createInstance(type, props, rootContainerInstance, hostContext, internalInstanceHandle) { 10186 var parentNamespace; 10187 10188 { 10189 // TODO: take namespace into account when validating. 10190 var hostContextDev = hostContext; 10191 validateDOMNesting(type, null, hostContextDev.ancestorInfo); 10192 10193 if (typeof props.children === 'string' || typeof props.children === 'number') { 10194 var string = '' + props.children; 10195 var ownAncestorInfo = updatedAncestorInfo(hostContextDev.ancestorInfo, type); 10196 validateDOMNesting(null, string, ownAncestorInfo); 10197 } 10198 10199 parentNamespace = hostContextDev.namespace; 10200 } 10201 10202 var domElement = createElement(type, props, rootContainerInstance, parentNamespace); 10203 precacheFiberNode(internalInstanceHandle, domElement); 10204 updateFiberProps(domElement, props); 10205 return domElement; 10206} 10207function appendInitialChild(parentInstance, child) { 10208 parentInstance.appendChild(child); 10209} 10210function finalizeInitialChildren(domElement, type, props, rootContainerInstance, hostContext) { 10211 setInitialProperties(domElement, type, props, rootContainerInstance); 10212 return shouldAutoFocusHostComponent(type, props); 10213} 10214function prepareUpdate(domElement, type, oldProps, newProps, rootContainerInstance, hostContext) { 10215 { 10216 var hostContextDev = hostContext; 10217 10218 if (typeof newProps.children !== typeof oldProps.children && (typeof newProps.children === 'string' || typeof newProps.children === 'number')) { 10219 var string = '' + newProps.children; 10220 var ownAncestorInfo = updatedAncestorInfo(hostContextDev.ancestorInfo, type); 10221 validateDOMNesting(null, string, ownAncestorInfo); 10222 } 10223 } 10224 10225 return diffProperties(domElement, type, oldProps, newProps); 10226} 10227function shouldSetTextContent(type, props) { 10228 return type === 'textarea' || type === 'option' || type === 'noscript' || typeof props.children === 'string' || typeof props.children === 'number' || typeof props.dangerouslySetInnerHTML === 'object' && props.dangerouslySetInnerHTML !== null && props.dangerouslySetInnerHTML.__html != null; 10229} 10230function createTextInstance(text, rootContainerInstance, hostContext, internalInstanceHandle) { 10231 { 10232 var hostContextDev = hostContext; 10233 validateDOMNesting(null, text, hostContextDev.ancestorInfo); 10234 } 10235 10236 var textNode = createTextNode(text, rootContainerInstance); 10237 precacheFiberNode(internalInstanceHandle, textNode); 10238 return textNode; 10239} 10240// if a component just imports ReactDOM (e.g. for findDOMNode). 10241// Some environments might not have setTimeout or clearTimeout. 10242 10243var scheduleTimeout = typeof setTimeout === 'function' ? setTimeout : undefined; 10244var cancelTimeout = typeof clearTimeout === 'function' ? clearTimeout : undefined; 10245var noTimeout = -1; // ------------------- 10246function commitMount(domElement, type, newProps, internalInstanceHandle) { 10247 // Despite the naming that might imply otherwise, this method only 10248 // fires if there is an `Update` effect scheduled during mounting. 10249 // This happens if `finalizeInitialChildren` returns `true` (which it 10250 // does to implement the `autoFocus` attribute on the client). But 10251 // there are also other cases when this might happen (such as patching 10252 // up text content during hydration mismatch). So we'll check this again. 10253 if (shouldAutoFocusHostComponent(type, newProps)) { 10254 domElement.focus(); 10255 } 10256} 10257function commitUpdate(domElement, updatePayload, type, oldProps, newProps, internalInstanceHandle) { 10258 // Update the props handle so that we know which props are the ones with 10259 // with current event handlers. 10260 updateFiberProps(domElement, newProps); // Apply the diff to the DOM node. 10261 10262 updateProperties(domElement, updatePayload, type, oldProps, newProps); 10263} 10264function resetTextContent(domElement) { 10265 setTextContent(domElement, ''); 10266} 10267function commitTextUpdate(textInstance, oldText, newText) { 10268 textInstance.nodeValue = newText; 10269} 10270function appendChild(parentInstance, child) { 10271 parentInstance.appendChild(child); 10272} 10273function appendChildToContainer(container, child) { 10274 var parentNode; 10275 10276 if (container.nodeType === COMMENT_NODE) { 10277 parentNode = container.parentNode; 10278 parentNode.insertBefore(child, container); 10279 } else { 10280 parentNode = container; 10281 parentNode.appendChild(child); 10282 } // This container might be used for a portal. 10283 // If something inside a portal is clicked, that click should bubble 10284 // through the React tree. However, on Mobile Safari the click would 10285 // never bubble through the *DOM* tree unless an ancestor with onclick 10286 // event exists. So we wouldn't see it and dispatch it. 10287 // This is why we ensure that non React root containers have inline onclick 10288 // defined. 10289 // https://github.com/facebook/react/issues/11918 10290 10291 10292 var reactRootContainer = container._reactRootContainer; 10293 10294 if ((reactRootContainer === null || reactRootContainer === undefined) && parentNode.onclick === null) { 10295 // TODO: This cast may not be sound for SVG, MathML or custom elements. 10296 trapClickOnNonInteractiveElement(parentNode); 10297 } 10298} 10299function insertBefore(parentInstance, child, beforeChild) { 10300 parentInstance.insertBefore(child, beforeChild); 10301} 10302function insertInContainerBefore(container, child, beforeChild) { 10303 if (container.nodeType === COMMENT_NODE) { 10304 container.parentNode.insertBefore(child, beforeChild); 10305 } else { 10306 container.insertBefore(child, beforeChild); 10307 } 10308} 10309 10310function removeChild(parentInstance, child) { 10311 parentInstance.removeChild(child); 10312} 10313function removeChildFromContainer(container, child) { 10314 if (container.nodeType === COMMENT_NODE) { 10315 container.parentNode.removeChild(child); 10316 } else { 10317 container.removeChild(child); 10318 } 10319} 10320function hideInstance(instance) { 10321 // TODO: Does this work for all element types? What about MathML? Should we 10322 // pass host context to this method? 10323 instance = instance; 10324 var style = instance.style; 10325 10326 if (typeof style.setProperty === 'function') { 10327 style.setProperty('display', 'none', 'important'); 10328 } else { 10329 style.display = 'none'; 10330 } 10331} 10332function hideTextInstance(textInstance) { 10333 textInstance.nodeValue = ''; 10334} 10335function unhideInstance(instance, props) { 10336 instance = instance; 10337 var styleProp = props[STYLE$1]; 10338 var display = styleProp !== undefined && styleProp !== null && styleProp.hasOwnProperty('display') ? styleProp.display : null; 10339 instance.style.display = dangerousStyleValue('display', display); 10340} 10341function unhideTextInstance(textInstance, text) { 10342 textInstance.nodeValue = text; 10343} 10344function clearContainer(container) { 10345 if (container.nodeType === ELEMENT_NODE) { 10346 container.textContent = ''; 10347 } else if (container.nodeType === DOCUMENT_NODE) { 10348 var body = container.body; 10349 10350 if (body != null) { 10351 body.textContent = ''; 10352 } 10353 } 10354} // ------------------- 10355function canHydrateInstance(instance, type, props) { 10356 if (instance.nodeType !== ELEMENT_NODE || type.toLowerCase() !== instance.nodeName.toLowerCase()) { 10357 return null; 10358 } // This has now been refined to an element node. 10359 10360 10361 return instance; 10362} 10363function canHydrateTextInstance(instance, text) { 10364 if (text === '' || instance.nodeType !== TEXT_NODE) { 10365 // Empty strings are not parsed by HTML so there won't be a correct match here. 10366 return null; 10367 } // This has now been refined to a text node. 10368 10369 10370 return instance; 10371} 10372function isSuspenseInstancePending(instance) { 10373 return instance.data === SUSPENSE_PENDING_START_DATA; 10374} 10375function isSuspenseInstanceFallback(instance) { 10376 return instance.data === SUSPENSE_FALLBACK_START_DATA; 10377} 10378 10379function getNextHydratable(node) { 10380 // Skip non-hydratable nodes. 10381 for (; node != null; node = node.nextSibling) { 10382 var nodeType = node.nodeType; 10383 10384 if (nodeType === ELEMENT_NODE || nodeType === TEXT_NODE) { 10385 break; 10386 } 10387 } 10388 10389 return node; 10390} 10391 10392function getNextHydratableSibling(instance) { 10393 return getNextHydratable(instance.nextSibling); 10394} 10395function getFirstHydratableChild(parentInstance) { 10396 return getNextHydratable(parentInstance.firstChild); 10397} 10398function hydrateInstance(instance, type, props, rootContainerInstance, hostContext, internalInstanceHandle) { 10399 precacheFiberNode(internalInstanceHandle, instance); // TODO: Possibly defer this until the commit phase where all the events 10400 // get attached. 10401 10402 updateFiberProps(instance, props); 10403 var parentNamespace; 10404 10405 { 10406 var hostContextDev = hostContext; 10407 parentNamespace = hostContextDev.namespace; 10408 } 10409 10410 return diffHydratedProperties(instance, type, props, parentNamespace); 10411} 10412function hydrateTextInstance(textInstance, text, internalInstanceHandle) { 10413 precacheFiberNode(internalInstanceHandle, textInstance); 10414 return diffHydratedText(textInstance, text); 10415} 10416function getNextHydratableInstanceAfterSuspenseInstance(suspenseInstance) { 10417 var node = suspenseInstance.nextSibling; // Skip past all nodes within this suspense boundary. 10418 // There might be nested nodes so we need to keep track of how 10419 // deep we are and only break out when we're back on top. 10420 10421 var depth = 0; 10422 10423 while (node) { 10424 if (node.nodeType === COMMENT_NODE) { 10425 var data = node.data; 10426 10427 if (data === SUSPENSE_END_DATA) { 10428 if (depth === 0) { 10429 return getNextHydratableSibling(node); 10430 } else { 10431 depth--; 10432 } 10433 } else if (data === SUSPENSE_START_DATA || data === SUSPENSE_FALLBACK_START_DATA || data === SUSPENSE_PENDING_START_DATA) { 10434 depth++; 10435 } 10436 } 10437 10438 node = node.nextSibling; 10439 } // TODO: Warn, we didn't find the end comment boundary. 10440 10441 10442 return null; 10443} // Returns the SuspenseInstance if this node is a direct child of a 10444// SuspenseInstance. I.e. if its previous sibling is a Comment with 10445// SUSPENSE_x_START_DATA. Otherwise, null. 10446 10447function getParentSuspenseInstance(targetInstance) { 10448 var node = targetInstance.previousSibling; // Skip past all nodes within this suspense boundary. 10449 // There might be nested nodes so we need to keep track of how 10450 // deep we are and only break out when we're back on top. 10451 10452 var depth = 0; 10453 10454 while (node) { 10455 if (node.nodeType === COMMENT_NODE) { 10456 var data = node.data; 10457 10458 if (data === SUSPENSE_START_DATA || data === SUSPENSE_FALLBACK_START_DATA || data === SUSPENSE_PENDING_START_DATA) { 10459 if (depth === 0) { 10460 return node; 10461 } else { 10462 depth--; 10463 } 10464 } else if (data === SUSPENSE_END_DATA) { 10465 depth++; 10466 } 10467 } 10468 10469 node = node.previousSibling; 10470 } 10471 10472 return null; 10473} 10474function commitHydratedContainer(container) { 10475 // Retry if any event replaying was blocked on this. 10476 retryIfBlockedOn(container); 10477} 10478function commitHydratedSuspenseInstance(suspenseInstance) { 10479 // Retry if any event replaying was blocked on this. 10480 retryIfBlockedOn(suspenseInstance); 10481} 10482function didNotMatchHydratedContainerTextInstance(parentContainer, textInstance, text) { 10483 { 10484 warnForUnmatchedText(textInstance, text); 10485 } 10486} 10487function didNotMatchHydratedTextInstance(parentType, parentProps, parentInstance, textInstance, text) { 10488 if ( parentProps[SUPPRESS_HYDRATION_WARNING$1] !== true) { 10489 warnForUnmatchedText(textInstance, text); 10490 } 10491} 10492function didNotHydrateContainerInstance(parentContainer, instance) { 10493 { 10494 if (instance.nodeType === ELEMENT_NODE) { 10495 warnForDeletedHydratableElement(parentContainer, instance); 10496 } else if (instance.nodeType === COMMENT_NODE) ; else { 10497 warnForDeletedHydratableText(parentContainer, instance); 10498 } 10499 } 10500} 10501function didNotHydrateInstance(parentType, parentProps, parentInstance, instance) { 10502 if ( parentProps[SUPPRESS_HYDRATION_WARNING$1] !== true) { 10503 if (instance.nodeType === ELEMENT_NODE) { 10504 warnForDeletedHydratableElement(parentInstance, instance); 10505 } else if (instance.nodeType === COMMENT_NODE) ; else { 10506 warnForDeletedHydratableText(parentInstance, instance); 10507 } 10508 } 10509} 10510function didNotFindHydratableContainerInstance(parentContainer, type, props) { 10511 { 10512 warnForInsertedHydratedElement(parentContainer, type); 10513 } 10514} 10515function didNotFindHydratableContainerTextInstance(parentContainer, text) { 10516 { 10517 warnForInsertedHydratedText(parentContainer, text); 10518 } 10519} 10520function didNotFindHydratableInstance(parentType, parentProps, parentInstance, type, props) { 10521 if ( parentProps[SUPPRESS_HYDRATION_WARNING$1] !== true) { 10522 warnForInsertedHydratedElement(parentInstance, type); 10523 } 10524} 10525function didNotFindHydratableTextInstance(parentType, parentProps, parentInstance, text) { 10526 if ( parentProps[SUPPRESS_HYDRATION_WARNING$1] !== true) { 10527 warnForInsertedHydratedText(parentInstance, text); 10528 } 10529} 10530function didNotFindHydratableSuspenseInstance(parentType, parentProps, parentInstance) { 10531 if ( parentProps[SUPPRESS_HYDRATION_WARNING$1] !== true) ; 10532} 10533var clientId = 0; 10534function makeClientIdInDEV(warnOnAccessInDEV) { 10535 var id = 'r:' + (clientId++).toString(36); 10536 return { 10537 toString: function () { 10538 warnOnAccessInDEV(); 10539 return id; 10540 }, 10541 valueOf: function () { 10542 warnOnAccessInDEV(); 10543 return id; 10544 } 10545 }; 10546} 10547function isOpaqueHydratingObject(value) { 10548 return value !== null && typeof value === 'object' && value.$$typeof === REACT_OPAQUE_ID_TYPE; 10549} 10550function makeOpaqueHydratingObject(attemptToReadValue) { 10551 return { 10552 $$typeof: REACT_OPAQUE_ID_TYPE, 10553 toString: attemptToReadValue, 10554 valueOf: attemptToReadValue 10555 }; 10556} 10557function preparePortalMount(portalInstance) { 10558 { 10559 listenToAllSupportedEvents(portalInstance); 10560 } 10561} 10562 10563var randomKey = Math.random().toString(36).slice(2); 10564var internalInstanceKey = '__reactFiber$' + randomKey; 10565var internalPropsKey = '__reactProps$' + randomKey; 10566var internalContainerInstanceKey = '__reactContainer$' + randomKey; 10567var internalEventHandlersKey = '__reactEvents$' + randomKey; 10568function precacheFiberNode(hostInst, node) { 10569 node[internalInstanceKey] = hostInst; 10570} 10571function markContainerAsRoot(hostRoot, node) { 10572 node[internalContainerInstanceKey] = hostRoot; 10573} 10574function unmarkContainerAsRoot(node) { 10575 node[internalContainerInstanceKey] = null; 10576} 10577function isContainerMarkedAsRoot(node) { 10578 return !!node[internalContainerInstanceKey]; 10579} // Given a DOM node, return the closest HostComponent or HostText fiber ancestor. 10580// If the target node is part of a hydrated or not yet rendered subtree, then 10581// this may also return a SuspenseComponent or HostRoot to indicate that. 10582// Conceptually the HostRoot fiber is a child of the Container node. So if you 10583// pass the Container node as the targetNode, you will not actually get the 10584// HostRoot back. To get to the HostRoot, you need to pass a child of it. 10585// The same thing applies to Suspense boundaries. 10586 10587function getClosestInstanceFromNode(targetNode) { 10588 var targetInst = targetNode[internalInstanceKey]; 10589 10590 if (targetInst) { 10591 // Don't return HostRoot or SuspenseComponent here. 10592 return targetInst; 10593 } // If the direct event target isn't a React owned DOM node, we need to look 10594 // to see if one of its parents is a React owned DOM node. 10595 10596 10597 var parentNode = targetNode.parentNode; 10598 10599 while (parentNode) { 10600 // We'll check if this is a container root that could include 10601 // React nodes in the future. We need to check this first because 10602 // if we're a child of a dehydrated container, we need to first 10603 // find that inner container before moving on to finding the parent 10604 // instance. Note that we don't check this field on the targetNode 10605 // itself because the fibers are conceptually between the container 10606 // node and the first child. It isn't surrounding the container node. 10607 // If it's not a container, we check if it's an instance. 10608 targetInst = parentNode[internalContainerInstanceKey] || parentNode[internalInstanceKey]; 10609 10610 if (targetInst) { 10611 // Since this wasn't the direct target of the event, we might have 10612 // stepped past dehydrated DOM nodes to get here. However they could 10613 // also have been non-React nodes. We need to answer which one. 10614 // If we the instance doesn't have any children, then there can't be 10615 // a nested suspense boundary within it. So we can use this as a fast 10616 // bailout. Most of the time, when people add non-React children to 10617 // the tree, it is using a ref to a child-less DOM node. 10618 // Normally we'd only need to check one of the fibers because if it 10619 // has ever gone from having children to deleting them or vice versa 10620 // it would have deleted the dehydrated boundary nested inside already. 10621 // However, since the HostRoot starts out with an alternate it might 10622 // have one on the alternate so we need to check in case this was a 10623 // root. 10624 var alternate = targetInst.alternate; 10625 10626 if (targetInst.child !== null || alternate !== null && alternate.child !== null) { 10627 // Next we need to figure out if the node that skipped past is 10628 // nested within a dehydrated boundary and if so, which one. 10629 var suspenseInstance = getParentSuspenseInstance(targetNode); 10630 10631 while (suspenseInstance !== null) { 10632 // We found a suspense instance. That means that we haven't 10633 // hydrated it yet. Even though we leave the comments in the 10634 // DOM after hydrating, and there are boundaries in the DOM 10635 // that could already be hydrated, we wouldn't have found them 10636 // through this pass since if the target is hydrated it would 10637 // have had an internalInstanceKey on it. 10638 // Let's get the fiber associated with the SuspenseComponent 10639 // as the deepest instance. 10640 var targetSuspenseInst = suspenseInstance[internalInstanceKey]; 10641 10642 if (targetSuspenseInst) { 10643 return targetSuspenseInst; 10644 } // If we don't find a Fiber on the comment, it might be because 10645 // we haven't gotten to hydrate it yet. There might still be a 10646 // parent boundary that hasn't above this one so we need to find 10647 // the outer most that is known. 10648 10649 10650 suspenseInstance = getParentSuspenseInstance(suspenseInstance); // If we don't find one, then that should mean that the parent 10651 // host component also hasn't hydrated yet. We can return it 10652 // below since it will bail out on the isMounted check later. 10653 } 10654 } 10655 10656 return targetInst; 10657 } 10658 10659 targetNode = parentNode; 10660 parentNode = targetNode.parentNode; 10661 } 10662 10663 return null; 10664} 10665/** 10666 * Given a DOM node, return the ReactDOMComponent or ReactDOMTextComponent 10667 * instance, or null if the node was not rendered by this React. 10668 */ 10669 10670function getInstanceFromNode(node) { 10671 var inst = node[internalInstanceKey] || node[internalContainerInstanceKey]; 10672 10673 if (inst) { 10674 if (inst.tag === HostComponent || inst.tag === HostText || inst.tag === SuspenseComponent || inst.tag === HostRoot) { 10675 return inst; 10676 } else { 10677 return null; 10678 } 10679 } 10680 10681 return null; 10682} 10683/** 10684 * Given a ReactDOMComponent or ReactDOMTextComponent, return the corresponding 10685 * DOM node. 10686 */ 10687 10688function getNodeFromInstance(inst) { 10689 if (inst.tag === HostComponent || inst.tag === HostText) { 10690 // In Fiber this, is just the state node right now. We assume it will be 10691 // a host component or host text. 10692 return inst.stateNode; 10693 } // Without this first invariant, passing a non-DOM-component triggers the next 10694 // invariant for a missing parent, which is super confusing. 10695 10696 10697 { 10698 { 10699 throw Error( "getNodeFromInstance: Invalid argument." ); 10700 } 10701 } 10702} 10703function getFiberCurrentPropsFromNode(node) { 10704 return node[internalPropsKey] || null; 10705} 10706function updateFiberProps(node, props) { 10707 node[internalPropsKey] = props; 10708} 10709function getEventListenerSet(node) { 10710 var elementListenerSet = node[internalEventHandlersKey]; 10711 10712 if (elementListenerSet === undefined) { 10713 elementListenerSet = node[internalEventHandlersKey] = new Set(); 10714 } 10715 10716 return elementListenerSet; 10717} 10718 10719var loggedTypeFailures = {}; 10720var ReactDebugCurrentFrame$1 = ReactSharedInternals.ReactDebugCurrentFrame; 10721 10722function setCurrentlyValidatingElement(element) { 10723 { 10724 if (element) { 10725 var owner = element._owner; 10726 var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null); 10727 ReactDebugCurrentFrame$1.setExtraStackFrame(stack); 10728 } else { 10729 ReactDebugCurrentFrame$1.setExtraStackFrame(null); 10730 } 10731 } 10732} 10733 10734function checkPropTypes(typeSpecs, values, location, componentName, element) { 10735 { 10736 // $FlowFixMe This is okay but Flow doesn't know it. 10737 var has = Function.call.bind(Object.prototype.hasOwnProperty); 10738 10739 for (var typeSpecName in typeSpecs) { 10740 if (has(typeSpecs, typeSpecName)) { 10741 var error$1 = void 0; // Prop type validation may throw. In case they do, we don't want to 10742 // fail the render phase where it didn't fail before. So we log it. 10743 // After these have been cleaned up, we'll let them throw. 10744 10745 try { 10746 // This is intentionally an invariant that gets caught. It's the same 10747 // behavior as without this statement except with a better message. 10748 if (typeof typeSpecs[typeSpecName] !== 'function') { 10749 var err = Error((componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' + 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.' + 'This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.'); 10750 err.name = 'Invariant Violation'; 10751 throw err; 10752 } 10753 10754 error$1 = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED'); 10755 } catch (ex) { 10756 error$1 = ex; 10757 } 10758 10759 if (error$1 && !(error$1 instanceof Error)) { 10760 setCurrentlyValidatingElement(element); 10761 10762 error('%s: type specification of %s' + ' `%s` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a %s. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).', componentName || 'React class', location, typeSpecName, typeof error$1); 10763 10764 setCurrentlyValidatingElement(null); 10765 } 10766 10767 if (error$1 instanceof Error && !(error$1.message in loggedTypeFailures)) { 10768 // Only monitor this failure once because there tends to be a lot of the 10769 // same error. 10770 loggedTypeFailures[error$1.message] = true; 10771 setCurrentlyValidatingElement(element); 10772 10773 error('Failed %s type: %s', location, error$1.message); 10774 10775 setCurrentlyValidatingElement(null); 10776 } 10777 } 10778 } 10779 } 10780} 10781 10782var valueStack = []; 10783var fiberStack; 10784 10785{ 10786 fiberStack = []; 10787} 10788 10789var index = -1; 10790 10791function createCursor(defaultValue) { 10792 return { 10793 current: defaultValue 10794 }; 10795} 10796 10797function pop(cursor, fiber) { 10798 if (index < 0) { 10799 { 10800 error('Unexpected pop.'); 10801 } 10802 10803 return; 10804 } 10805 10806 { 10807 if (fiber !== fiberStack[index]) { 10808 error('Unexpected Fiber popped.'); 10809 } 10810 } 10811 10812 cursor.current = valueStack[index]; 10813 valueStack[index] = null; 10814 10815 { 10816 fiberStack[index] = null; 10817 } 10818 10819 index--; 10820} 10821 10822function push(cursor, value, fiber) { 10823 index++; 10824 valueStack[index] = cursor.current; 10825 10826 { 10827 fiberStack[index] = fiber; 10828 } 10829 10830 cursor.current = value; 10831} 10832 10833var warnedAboutMissingGetChildContext; 10834 10835{ 10836 warnedAboutMissingGetChildContext = {}; 10837} 10838 10839var emptyContextObject = {}; 10840 10841{ 10842 Object.freeze(emptyContextObject); 10843} // A cursor to the current merged context object on the stack. 10844 10845 10846var contextStackCursor = createCursor(emptyContextObject); // A cursor to a boolean indicating whether the context has changed. 10847 10848var didPerformWorkStackCursor = createCursor(false); // Keep track of the previous context object that was on the stack. 10849// We use this to get access to the parent context after we have already 10850// pushed the next context provider, and now need to merge their contexts. 10851 10852var previousContext = emptyContextObject; 10853 10854function getUnmaskedContext(workInProgress, Component, didPushOwnContextIfProvider) { 10855 { 10856 if (didPushOwnContextIfProvider && isContextProvider(Component)) { 10857 // If the fiber is a context provider itself, when we read its context 10858 // we may have already pushed its own child context on the stack. A context 10859 // provider should not "see" its own child context. Therefore we read the 10860 // previous (parent) context instead for a context provider. 10861 return previousContext; 10862 } 10863 10864 return contextStackCursor.current; 10865 } 10866} 10867 10868function cacheContext(workInProgress, unmaskedContext, maskedContext) { 10869 { 10870 var instance = workInProgress.stateNode; 10871 instance.__reactInternalMemoizedUnmaskedChildContext = unmaskedContext; 10872 instance.__reactInternalMemoizedMaskedChildContext = maskedContext; 10873 } 10874} 10875 10876function getMaskedContext(workInProgress, unmaskedContext) { 10877 { 10878 var type = workInProgress.type; 10879 var contextTypes = type.contextTypes; 10880 10881 if (!contextTypes) { 10882 return emptyContextObject; 10883 } // Avoid recreating masked context unless unmasked context has changed. 10884 // Failing to do this will result in unnecessary calls to componentWillReceiveProps. 10885 // This may trigger infinite loops if componentWillReceiveProps calls setState. 10886 10887 10888 var instance = workInProgress.stateNode; 10889 10890 if (instance && instance.__reactInternalMemoizedUnmaskedChildContext === unmaskedContext) { 10891 return instance.__reactInternalMemoizedMaskedChildContext; 10892 } 10893 10894 var context = {}; 10895 10896 for (var key in contextTypes) { 10897 context[key] = unmaskedContext[key]; 10898 } 10899 10900 { 10901 var name = getComponentName(type) || 'Unknown'; 10902 checkPropTypes(contextTypes, context, 'context', name); 10903 } // Cache unmasked context so we can avoid recreating masked context unless necessary. 10904 // Context is created before the class component is instantiated so check for instance. 10905 10906 10907 if (instance) { 10908 cacheContext(workInProgress, unmaskedContext, context); 10909 } 10910 10911 return context; 10912 } 10913} 10914 10915function hasContextChanged() { 10916 { 10917 return didPerformWorkStackCursor.current; 10918 } 10919} 10920 10921function isContextProvider(type) { 10922 { 10923 var childContextTypes = type.childContextTypes; 10924 return childContextTypes !== null && childContextTypes !== undefined; 10925 } 10926} 10927 10928function popContext(fiber) { 10929 { 10930 pop(didPerformWorkStackCursor, fiber); 10931 pop(contextStackCursor, fiber); 10932 } 10933} 10934 10935function popTopLevelContextObject(fiber) { 10936 { 10937 pop(didPerformWorkStackCursor, fiber); 10938 pop(contextStackCursor, fiber); 10939 } 10940} 10941 10942function pushTopLevelContextObject(fiber, context, didChange) { 10943 { 10944 if (!(contextStackCursor.current === emptyContextObject)) { 10945 { 10946 throw Error( "Unexpected context found on stack. This error is likely caused by a bug in React. Please file an issue." ); 10947 } 10948 } 10949 10950 push(contextStackCursor, context, fiber); 10951 push(didPerformWorkStackCursor, didChange, fiber); 10952 } 10953} 10954 10955function processChildContext(fiber, type, parentContext) { 10956 { 10957 var instance = fiber.stateNode; 10958 var childContextTypes = type.childContextTypes; // TODO (bvaughn) Replace this behavior with an invariant() in the future. 10959 // It has only been added in Fiber to match the (unintentional) behavior in Stack. 10960 10961 if (typeof instance.getChildContext !== 'function') { 10962 { 10963 var componentName = getComponentName(type) || 'Unknown'; 10964 10965 if (!warnedAboutMissingGetChildContext[componentName]) { 10966 warnedAboutMissingGetChildContext[componentName] = true; 10967 10968 error('%s.childContextTypes is specified but there is no getChildContext() method ' + 'on the instance. You can either define getChildContext() on %s or remove ' + 'childContextTypes from it.', componentName, componentName); 10969 } 10970 } 10971 10972 return parentContext; 10973 } 10974 10975 var childContext = instance.getChildContext(); 10976 10977 for (var contextKey in childContext) { 10978 if (!(contextKey in childContextTypes)) { 10979 { 10980 throw Error( (getComponentName(type) || 'Unknown') + ".getChildContext(): key \"" + contextKey + "\" is not defined in childContextTypes." ); 10981 } 10982 } 10983 } 10984 10985 { 10986 var name = getComponentName(type) || 'Unknown'; 10987 checkPropTypes(childContextTypes, childContext, 'child context', name); 10988 } 10989 10990 return _assign({}, parentContext, childContext); 10991 } 10992} 10993 10994function pushContextProvider(workInProgress) { 10995 { 10996 var instance = workInProgress.stateNode; // We push the context as early as possible to ensure stack integrity. 10997 // If the instance does not exist yet, we will push null at first, 10998 // and replace it on the stack later when invalidating the context. 10999 11000 var memoizedMergedChildContext = instance && instance.__reactInternalMemoizedMergedChildContext || emptyContextObject; // Remember the parent context so we can merge with it later. 11001 // Inherit the parent's did-perform-work value to avoid inadvertently blocking updates. 11002 11003 previousContext = contextStackCursor.current; 11004 push(contextStackCursor, memoizedMergedChildContext, workInProgress); 11005 push(didPerformWorkStackCursor, didPerformWorkStackCursor.current, workInProgress); 11006 return true; 11007 } 11008} 11009 11010function invalidateContextProvider(workInProgress, type, didChange) { 11011 { 11012 var instance = workInProgress.stateNode; 11013 11014 if (!instance) { 11015 { 11016 throw Error( "Expected to have an instance by this point. This error is likely caused by a bug in React. Please file an issue." ); 11017 } 11018 } 11019 11020 if (didChange) { 11021 // Merge parent and own context. 11022 // Skip this if we're not updating due to sCU. 11023 // This avoids unnecessarily recomputing memoized values. 11024 var mergedContext = processChildContext(workInProgress, type, previousContext); 11025 instance.__reactInternalMemoizedMergedChildContext = mergedContext; // Replace the old (or empty) context with the new one. 11026 // It is important to unwind the context in the reverse order. 11027 11028 pop(didPerformWorkStackCursor, workInProgress); 11029 pop(contextStackCursor, workInProgress); // Now push the new context and mark that it has changed. 11030 11031 push(contextStackCursor, mergedContext, workInProgress); 11032 push(didPerformWorkStackCursor, didChange, workInProgress); 11033 } else { 11034 pop(didPerformWorkStackCursor, workInProgress); 11035 push(didPerformWorkStackCursor, didChange, workInProgress); 11036 } 11037 } 11038} 11039 11040function findCurrentUnmaskedContext(fiber) { 11041 { 11042 // Currently this is only used with renderSubtreeIntoContainer; not sure if it 11043 // makes sense elsewhere 11044 if (!(isFiberMounted(fiber) && fiber.tag === ClassComponent)) { 11045 { 11046 throw Error( "Expected subtree parent to be a mounted class component. This error is likely caused by a bug in React. Please file an issue." ); 11047 } 11048 } 11049 11050 var node = fiber; 11051 11052 do { 11053 switch (node.tag) { 11054 case HostRoot: 11055 return node.stateNode.context; 11056 11057 case ClassComponent: 11058 { 11059 var Component = node.type; 11060 11061 if (isContextProvider(Component)) { 11062 return node.stateNode.__reactInternalMemoizedMergedChildContext; 11063 } 11064 11065 break; 11066 } 11067 } 11068 11069 node = node.return; 11070 } while (node !== null); 11071 11072 { 11073 { 11074 throw Error( "Found unexpected detached subtree parent. This error is likely caused by a bug in React. Please file an issue." ); 11075 } 11076 } 11077 } 11078} 11079 11080var LegacyRoot = 0; 11081var BlockingRoot = 1; 11082var ConcurrentRoot = 2; 11083 11084var rendererID = null; 11085var injectedHook = null; 11086var hasLoggedError = false; 11087var isDevToolsPresent = typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined'; 11088function injectInternals(internals) { 11089 if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ === 'undefined') { 11090 // No DevTools 11091 return false; 11092 } 11093 11094 var hook = __REACT_DEVTOOLS_GLOBAL_HOOK__; 11095 11096 if (hook.isDisabled) { 11097 // This isn't a real property on the hook, but it can be set to opt out 11098 // of DevTools integration and associated warnings and logs. 11099 // https://github.com/facebook/react/issues/3877 11100 return true; 11101 } 11102 11103 if (!hook.supportsFiber) { 11104 { 11105 error('The installed version of React DevTools is too old and will not work ' + 'with the current version of React. Please update React DevTools. ' + 'https://reactjs.org/link/react-devtools'); 11106 } // DevTools exists, even though it doesn't support Fiber. 11107 11108 11109 return true; 11110 } 11111 11112 try { 11113 rendererID = hook.inject(internals); // We have successfully injected, so now it is safe to set up hooks. 11114 11115 injectedHook = hook; 11116 } catch (err) { 11117 // Catch all errors because it is unsafe to throw during initialization. 11118 { 11119 error('React instrumentation encountered an error: %s.', err); 11120 } 11121 } // DevTools exists 11122 11123 11124 return true; 11125} 11126function onScheduleRoot(root, children) { 11127 { 11128 if (injectedHook && typeof injectedHook.onScheduleFiberRoot === 'function') { 11129 try { 11130 injectedHook.onScheduleFiberRoot(rendererID, root, children); 11131 } catch (err) { 11132 if ( !hasLoggedError) { 11133 hasLoggedError = true; 11134 11135 error('React instrumentation encountered an error: %s', err); 11136 } 11137 } 11138 } 11139 } 11140} 11141function onCommitRoot(root, priorityLevel) { 11142 if (injectedHook && typeof injectedHook.onCommitFiberRoot === 'function') { 11143 try { 11144 var didError = (root.current.flags & DidCapture) === DidCapture; 11145 11146 if (enableProfilerTimer) { 11147 injectedHook.onCommitFiberRoot(rendererID, root, priorityLevel, didError); 11148 } else { 11149 injectedHook.onCommitFiberRoot(rendererID, root, undefined, didError); 11150 } 11151 } catch (err) { 11152 { 11153 if (!hasLoggedError) { 11154 hasLoggedError = true; 11155 11156 error('React instrumentation encountered an error: %s', err); 11157 } 11158 } 11159 } 11160 } 11161} 11162function onCommitUnmount(fiber) { 11163 if (injectedHook && typeof injectedHook.onCommitFiberUnmount === 'function') { 11164 try { 11165 injectedHook.onCommitFiberUnmount(rendererID, fiber); 11166 } catch (err) { 11167 { 11168 if (!hasLoggedError) { 11169 hasLoggedError = true; 11170 11171 error('React instrumentation encountered an error: %s', err); 11172 } 11173 } 11174 } 11175 } 11176} 11177 11178var Scheduler_runWithPriority = Scheduler.unstable_runWithPriority, 11179 Scheduler_scheduleCallback = Scheduler.unstable_scheduleCallback, 11180 Scheduler_cancelCallback = Scheduler.unstable_cancelCallback, 11181 Scheduler_shouldYield = Scheduler.unstable_shouldYield, 11182 Scheduler_requestPaint = Scheduler.unstable_requestPaint, 11183 Scheduler_now$1 = Scheduler.unstable_now, 11184 Scheduler_getCurrentPriorityLevel = Scheduler.unstable_getCurrentPriorityLevel, 11185 Scheduler_ImmediatePriority = Scheduler.unstable_ImmediatePriority, 11186 Scheduler_UserBlockingPriority = Scheduler.unstable_UserBlockingPriority, 11187 Scheduler_NormalPriority = Scheduler.unstable_NormalPriority, 11188 Scheduler_LowPriority = Scheduler.unstable_LowPriority, 11189 Scheduler_IdlePriority = Scheduler.unstable_IdlePriority; 11190 11191{ 11192 // Provide explicit error message when production+profiling bundle of e.g. 11193 // react-dom is used with production (non-profiling) bundle of 11194 // scheduler/tracing 11195 if (!(tracing.__interactionsRef != null && tracing.__interactionsRef.current != null)) { 11196 { 11197 throw Error( "It is not supported to run the profiling version of a renderer (for example, `react-dom/profiling`) without also replacing the `scheduler/tracing` module with `scheduler/tracing-profiling`. Your bundler might have a setting for aliasing both modules. Learn more at https://reactjs.org/link/profiling" ); 11198 } 11199 } 11200} 11201 11202var fakeCallbackNode = {}; // Except for NoPriority, these correspond to Scheduler priorities. We use 11203// ascending numbers so we can compare them like numbers. They start at 90 to 11204// avoid clashing with Scheduler's priorities. 11205 11206var ImmediatePriority$1 = 99; 11207var UserBlockingPriority$2 = 98; 11208var NormalPriority$1 = 97; 11209var LowPriority$1 = 96; 11210var IdlePriority$1 = 95; // NoPriority is the absence of priority. Also React-only. 11211 11212var NoPriority$1 = 90; 11213var shouldYield = Scheduler_shouldYield; 11214var requestPaint = // Fall back gracefully if we're running an older version of Scheduler. 11215Scheduler_requestPaint !== undefined ? Scheduler_requestPaint : function () {}; 11216var syncQueue = null; 11217var immediateQueueCallbackNode = null; 11218var isFlushingSyncQueue = false; 11219var initialTimeMs$1 = Scheduler_now$1(); // If the initial timestamp is reasonably small, use Scheduler's `now` directly. 11220// This will be the case for modern browsers that support `performance.now`. In 11221// older browsers, Scheduler falls back to `Date.now`, which returns a Unix 11222// timestamp. In that case, subtract the module initialization time to simulate 11223// the behavior of performance.now and keep our times small enough to fit 11224// within 32 bits. 11225// TODO: Consider lifting this into Scheduler. 11226 11227var now = initialTimeMs$1 < 10000 ? Scheduler_now$1 : function () { 11228 return Scheduler_now$1() - initialTimeMs$1; 11229}; 11230function getCurrentPriorityLevel() { 11231 switch (Scheduler_getCurrentPriorityLevel()) { 11232 case Scheduler_ImmediatePriority: 11233 return ImmediatePriority$1; 11234 11235 case Scheduler_UserBlockingPriority: 11236 return UserBlockingPriority$2; 11237 11238 case Scheduler_NormalPriority: 11239 return NormalPriority$1; 11240 11241 case Scheduler_LowPriority: 11242 return LowPriority$1; 11243 11244 case Scheduler_IdlePriority: 11245 return IdlePriority$1; 11246 11247 default: 11248 { 11249 { 11250 throw Error( "Unknown priority level." ); 11251 } 11252 } 11253 11254 } 11255} 11256 11257function reactPriorityToSchedulerPriority(reactPriorityLevel) { 11258 switch (reactPriorityLevel) { 11259 case ImmediatePriority$1: 11260 return Scheduler_ImmediatePriority; 11261 11262 case UserBlockingPriority$2: 11263 return Scheduler_UserBlockingPriority; 11264 11265 case NormalPriority$1: 11266 return Scheduler_NormalPriority; 11267 11268 case LowPriority$1: 11269 return Scheduler_LowPriority; 11270 11271 case IdlePriority$1: 11272 return Scheduler_IdlePriority; 11273 11274 default: 11275 { 11276 { 11277 throw Error( "Unknown priority level." ); 11278 } 11279 } 11280 11281 } 11282} 11283 11284function runWithPriority$1(reactPriorityLevel, fn) { 11285 var priorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel); 11286 return Scheduler_runWithPriority(priorityLevel, fn); 11287} 11288function scheduleCallback(reactPriorityLevel, callback, options) { 11289 var priorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel); 11290 return Scheduler_scheduleCallback(priorityLevel, callback, options); 11291} 11292function scheduleSyncCallback(callback) { 11293 // Push this callback into an internal queue. We'll flush these either in 11294 // the next tick, or earlier if something calls `flushSyncCallbackQueue`. 11295 if (syncQueue === null) { 11296 syncQueue = [callback]; // Flush the queue in the next tick, at the earliest. 11297 11298 immediateQueueCallbackNode = Scheduler_scheduleCallback(Scheduler_ImmediatePriority, flushSyncCallbackQueueImpl); 11299 } else { 11300 // Push onto existing queue. Don't need to schedule a callback because 11301 // we already scheduled one when we created the queue. 11302 syncQueue.push(callback); 11303 } 11304 11305 return fakeCallbackNode; 11306} 11307function cancelCallback(callbackNode) { 11308 if (callbackNode !== fakeCallbackNode) { 11309 Scheduler_cancelCallback(callbackNode); 11310 } 11311} 11312function flushSyncCallbackQueue() { 11313 if (immediateQueueCallbackNode !== null) { 11314 var node = immediateQueueCallbackNode; 11315 immediateQueueCallbackNode = null; 11316 Scheduler_cancelCallback(node); 11317 } 11318 11319 flushSyncCallbackQueueImpl(); 11320} 11321 11322function flushSyncCallbackQueueImpl() { 11323 if (!isFlushingSyncQueue && syncQueue !== null) { 11324 // Prevent re-entrancy. 11325 isFlushingSyncQueue = true; 11326 var i = 0; 11327 11328 { 11329 try { 11330 var _isSync2 = true; 11331 var _queue = syncQueue; 11332 runWithPriority$1(ImmediatePriority$1, function () { 11333 for (; i < _queue.length; i++) { 11334 var callback = _queue[i]; 11335 11336 do { 11337 callback = callback(_isSync2); 11338 } while (callback !== null); 11339 } 11340 }); 11341 syncQueue = null; 11342 } catch (error) { 11343 // If something throws, leave the remaining callbacks on the queue. 11344 if (syncQueue !== null) { 11345 syncQueue = syncQueue.slice(i + 1); 11346 } // Resume flushing in the next tick 11347 11348 11349 Scheduler_scheduleCallback(Scheduler_ImmediatePriority, flushSyncCallbackQueue); 11350 throw error; 11351 } finally { 11352 isFlushingSyncQueue = false; 11353 } 11354 } 11355 } 11356} 11357 11358// TODO: this is special because it gets imported during build. 11359var ReactVersion = '17.0.1'; 11360 11361var NoMode = 0; 11362var StrictMode = 1; // TODO: Remove BlockingMode and ConcurrentMode by reading from the root 11363// tag instead 11364 11365var BlockingMode = 2; 11366var ConcurrentMode = 4; 11367var ProfileMode = 8; 11368var DebugTracingMode = 16; 11369 11370var ReactCurrentBatchConfig = ReactSharedInternals.ReactCurrentBatchConfig; 11371var NoTransition = 0; 11372function requestCurrentTransition() { 11373 return ReactCurrentBatchConfig.transition; 11374} 11375 11376var ReactStrictModeWarnings = { 11377 recordUnsafeLifecycleWarnings: function (fiber, instance) {}, 11378 flushPendingUnsafeLifecycleWarnings: function () {}, 11379 recordLegacyContextWarning: function (fiber, instance) {}, 11380 flushLegacyContextWarning: function () {}, 11381 discardPendingWarnings: function () {} 11382}; 11383 11384{ 11385 var findStrictRoot = function (fiber) { 11386 var maybeStrictRoot = null; 11387 var node = fiber; 11388 11389 while (node !== null) { 11390 if (node.mode & StrictMode) { 11391 maybeStrictRoot = node; 11392 } 11393 11394 node = node.return; 11395 } 11396 11397 return maybeStrictRoot; 11398 }; 11399 11400 var setToSortedString = function (set) { 11401 var array = []; 11402 set.forEach(function (value) { 11403 array.push(value); 11404 }); 11405 return array.sort().join(', '); 11406 }; 11407 11408 var pendingComponentWillMountWarnings = []; 11409 var pendingUNSAFE_ComponentWillMountWarnings = []; 11410 var pendingComponentWillReceivePropsWarnings = []; 11411 var pendingUNSAFE_ComponentWillReceivePropsWarnings = []; 11412 var pendingComponentWillUpdateWarnings = []; 11413 var pendingUNSAFE_ComponentWillUpdateWarnings = []; // Tracks components we have already warned about. 11414 11415 var didWarnAboutUnsafeLifecycles = new Set(); 11416 11417 ReactStrictModeWarnings.recordUnsafeLifecycleWarnings = function (fiber, instance) { 11418 // Dedup strategy: Warn once per component. 11419 if (didWarnAboutUnsafeLifecycles.has(fiber.type)) { 11420 return; 11421 } 11422 11423 if (typeof instance.componentWillMount === 'function' && // Don't warn about react-lifecycles-compat polyfilled components. 11424 instance.componentWillMount.__suppressDeprecationWarning !== true) { 11425 pendingComponentWillMountWarnings.push(fiber); 11426 } 11427 11428 if (fiber.mode & StrictMode && typeof instance.UNSAFE_componentWillMount === 'function') { 11429 pendingUNSAFE_ComponentWillMountWarnings.push(fiber); 11430 } 11431 11432 if (typeof instance.componentWillReceiveProps === 'function' && instance.componentWillReceiveProps.__suppressDeprecationWarning !== true) { 11433 pendingComponentWillReceivePropsWarnings.push(fiber); 11434 } 11435 11436 if (fiber.mode & StrictMode && typeof instance.UNSAFE_componentWillReceiveProps === 'function') { 11437 pendingUNSAFE_ComponentWillReceivePropsWarnings.push(fiber); 11438 } 11439 11440 if (typeof instance.componentWillUpdate === 'function' && instance.componentWillUpdate.__suppressDeprecationWarning !== true) { 11441 pendingComponentWillUpdateWarnings.push(fiber); 11442 } 11443 11444 if (fiber.mode & StrictMode && typeof instance.UNSAFE_componentWillUpdate === 'function') { 11445 pendingUNSAFE_ComponentWillUpdateWarnings.push(fiber); 11446 } 11447 }; 11448 11449 ReactStrictModeWarnings.flushPendingUnsafeLifecycleWarnings = function () { 11450 // We do an initial pass to gather component names 11451 var componentWillMountUniqueNames = new Set(); 11452 11453 if (pendingComponentWillMountWarnings.length > 0) { 11454 pendingComponentWillMountWarnings.forEach(function (fiber) { 11455 componentWillMountUniqueNames.add(getComponentName(fiber.type) || 'Component'); 11456 didWarnAboutUnsafeLifecycles.add(fiber.type); 11457 }); 11458 pendingComponentWillMountWarnings = []; 11459 } 11460 11461 var UNSAFE_componentWillMountUniqueNames = new Set(); 11462 11463 if (pendingUNSAFE_ComponentWillMountWarnings.length > 0) { 11464 pendingUNSAFE_ComponentWillMountWarnings.forEach(function (fiber) { 11465 UNSAFE_componentWillMountUniqueNames.add(getComponentName(fiber.type) || 'Component'); 11466 didWarnAboutUnsafeLifecycles.add(fiber.type); 11467 }); 11468 pendingUNSAFE_ComponentWillMountWarnings = []; 11469 } 11470 11471 var componentWillReceivePropsUniqueNames = new Set(); 11472 11473 if (pendingComponentWillReceivePropsWarnings.length > 0) { 11474 pendingComponentWillReceivePropsWarnings.forEach(function (fiber) { 11475 componentWillReceivePropsUniqueNames.add(getComponentName(fiber.type) || 'Component'); 11476 didWarnAboutUnsafeLifecycles.add(fiber.type); 11477 }); 11478 pendingComponentWillReceivePropsWarnings = []; 11479 } 11480 11481 var UNSAFE_componentWillReceivePropsUniqueNames = new Set(); 11482 11483 if (pendingUNSAFE_ComponentWillReceivePropsWarnings.length > 0) { 11484 pendingUNSAFE_ComponentWillReceivePropsWarnings.forEach(function (fiber) { 11485 UNSAFE_componentWillReceivePropsUniqueNames.add(getComponentName(fiber.type) || 'Component'); 11486 didWarnAboutUnsafeLifecycles.add(fiber.type); 11487 }); 11488 pendingUNSAFE_ComponentWillReceivePropsWarnings = []; 11489 } 11490 11491 var componentWillUpdateUniqueNames = new Set(); 11492 11493 if (pendingComponentWillUpdateWarnings.length > 0) { 11494 pendingComponentWillUpdateWarnings.forEach(function (fiber) { 11495 componentWillUpdateUniqueNames.add(getComponentName(fiber.type) || 'Component'); 11496 didWarnAboutUnsafeLifecycles.add(fiber.type); 11497 }); 11498 pendingComponentWillUpdateWarnings = []; 11499 } 11500 11501 var UNSAFE_componentWillUpdateUniqueNames = new Set(); 11502 11503 if (pendingUNSAFE_ComponentWillUpdateWarnings.length > 0) { 11504 pendingUNSAFE_ComponentWillUpdateWarnings.forEach(function (fiber) { 11505 UNSAFE_componentWillUpdateUniqueNames.add(getComponentName(fiber.type) || 'Component'); 11506 didWarnAboutUnsafeLifecycles.add(fiber.type); 11507 }); 11508 pendingUNSAFE_ComponentWillUpdateWarnings = []; 11509 } // Finally, we flush all the warnings 11510 // UNSAFE_ ones before the deprecated ones, since they'll be 'louder' 11511 11512 11513 if (UNSAFE_componentWillMountUniqueNames.size > 0) { 11514 var sortedNames = setToSortedString(UNSAFE_componentWillMountUniqueNames); 11515 11516 error('Using UNSAFE_componentWillMount in strict mode is not recommended and may indicate bugs in your code. ' + 'See https://reactjs.org/link/unsafe-component-lifecycles for details.\n\n' + '* Move code with side effects to componentDidMount, and set initial state in the constructor.\n' + '\nPlease update the following components: %s', sortedNames); 11517 } 11518 11519 if (UNSAFE_componentWillReceivePropsUniqueNames.size > 0) { 11520 var _sortedNames = setToSortedString(UNSAFE_componentWillReceivePropsUniqueNames); 11521 11522 error('Using UNSAFE_componentWillReceiveProps in strict mode is not recommended ' + 'and may indicate bugs in your code. ' + 'See https://reactjs.org/link/unsafe-component-lifecycles for details.\n\n' + '* Move data fetching code or side effects to componentDidUpdate.\n' + "* If you're updating state whenever props change, " + 'refactor your code to use memoization techniques or move it to ' + 'static getDerivedStateFromProps. Learn more at: https://reactjs.org/link/derived-state\n' + '\nPlease update the following components: %s', _sortedNames); 11523 } 11524 11525 if (UNSAFE_componentWillUpdateUniqueNames.size > 0) { 11526 var _sortedNames2 = setToSortedString(UNSAFE_componentWillUpdateUniqueNames); 11527 11528 error('Using UNSAFE_componentWillUpdate in strict mode is not recommended ' + 'and may indicate bugs in your code. ' + 'See https://reactjs.org/link/unsafe-component-lifecycles for details.\n\n' + '* Move data fetching code or side effects to componentDidUpdate.\n' + '\nPlease update the following components: %s', _sortedNames2); 11529 } 11530 11531 if (componentWillMountUniqueNames.size > 0) { 11532 var _sortedNames3 = setToSortedString(componentWillMountUniqueNames); 11533 11534 warn('componentWillMount has been renamed, and is not recommended for use. ' + 'See https://reactjs.org/link/unsafe-component-lifecycles for details.\n\n' + '* Move code with side effects to componentDidMount, and set initial state in the constructor.\n' + '* Rename componentWillMount to UNSAFE_componentWillMount to suppress ' + 'this warning in non-strict mode. In React 18.x, only the UNSAFE_ name will work. ' + 'To rename all deprecated lifecycles to their new names, you can run ' + '`npx react-codemod rename-unsafe-lifecycles` in your project source folder.\n' + '\nPlease update the following components: %s', _sortedNames3); 11535 } 11536 11537 if (componentWillReceivePropsUniqueNames.size > 0) { 11538 var _sortedNames4 = setToSortedString(componentWillReceivePropsUniqueNames); 11539 11540 warn('componentWillReceiveProps has been renamed, and is not recommended for use. ' + 'See https://reactjs.org/link/unsafe-component-lifecycles for details.\n\n' + '* Move data fetching code or side effects to componentDidUpdate.\n' + "* If you're updating state whenever props change, refactor your " + 'code to use memoization techniques or move it to ' + 'static getDerivedStateFromProps. Learn more at: https://reactjs.org/link/derived-state\n' + '* Rename componentWillReceiveProps to UNSAFE_componentWillReceiveProps to suppress ' + 'this warning in non-strict mode. In React 18.x, only the UNSAFE_ name will work. ' + 'To rename all deprecated lifecycles to their new names, you can run ' + '`npx react-codemod rename-unsafe-lifecycles` in your project source folder.\n' + '\nPlease update the following components: %s', _sortedNames4); 11541 } 11542 11543 if (componentWillUpdateUniqueNames.size > 0) { 11544 var _sortedNames5 = setToSortedString(componentWillUpdateUniqueNames); 11545 11546 warn('componentWillUpdate has been renamed, and is not recommended for use. ' + 'See https://reactjs.org/link/unsafe-component-lifecycles for details.\n\n' + '* Move data fetching code or side effects to componentDidUpdate.\n' + '* Rename componentWillUpdate to UNSAFE_componentWillUpdate to suppress ' + 'this warning in non-strict mode. In React 18.x, only the UNSAFE_ name will work. ' + 'To rename all deprecated lifecycles to their new names, you can run ' + '`npx react-codemod rename-unsafe-lifecycles` in your project source folder.\n' + '\nPlease update the following components: %s', _sortedNames5); 11547 } 11548 }; 11549 11550 var pendingLegacyContextWarning = new Map(); // Tracks components we have already warned about. 11551 11552 var didWarnAboutLegacyContext = new Set(); 11553 11554 ReactStrictModeWarnings.recordLegacyContextWarning = function (fiber, instance) { 11555 var strictRoot = findStrictRoot(fiber); 11556 11557 if (strictRoot === null) { 11558 error('Expected to find a StrictMode component in a strict mode tree. ' + 'This error is likely caused by a bug in React. Please file an issue.'); 11559 11560 return; 11561 } // Dedup strategy: Warn once per component. 11562 11563 11564 if (didWarnAboutLegacyContext.has(fiber.type)) { 11565 return; 11566 } 11567 11568 var warningsForRoot = pendingLegacyContextWarning.get(strictRoot); 11569 11570 if (fiber.type.contextTypes != null || fiber.type.childContextTypes != null || instance !== null && typeof instance.getChildContext === 'function') { 11571 if (warningsForRoot === undefined) { 11572 warningsForRoot = []; 11573 pendingLegacyContextWarning.set(strictRoot, warningsForRoot); 11574 } 11575 11576 warningsForRoot.push(fiber); 11577 } 11578 }; 11579 11580 ReactStrictModeWarnings.flushLegacyContextWarning = function () { 11581 pendingLegacyContextWarning.forEach(function (fiberArray, strictRoot) { 11582 if (fiberArray.length === 0) { 11583 return; 11584 } 11585 11586 var firstFiber = fiberArray[0]; 11587 var uniqueNames = new Set(); 11588 fiberArray.forEach(function (fiber) { 11589 uniqueNames.add(getComponentName(fiber.type) || 'Component'); 11590 didWarnAboutLegacyContext.add(fiber.type); 11591 }); 11592 var sortedNames = setToSortedString(uniqueNames); 11593 11594 try { 11595 setCurrentFiber(firstFiber); 11596 11597 error('Legacy context API has been detected within a strict-mode tree.' + '\n\nThe old API will be supported in all 16.x releases, but applications ' + 'using it should migrate to the new version.' + '\n\nPlease update the following components: %s' + '\n\nLearn more about this warning here: https://reactjs.org/link/legacy-context', sortedNames); 11598 } finally { 11599 resetCurrentFiber(); 11600 } 11601 }); 11602 }; 11603 11604 ReactStrictModeWarnings.discardPendingWarnings = function () { 11605 pendingComponentWillMountWarnings = []; 11606 pendingUNSAFE_ComponentWillMountWarnings = []; 11607 pendingComponentWillReceivePropsWarnings = []; 11608 pendingUNSAFE_ComponentWillReceivePropsWarnings = []; 11609 pendingComponentWillUpdateWarnings = []; 11610 pendingUNSAFE_ComponentWillUpdateWarnings = []; 11611 pendingLegacyContextWarning = new Map(); 11612 }; 11613} 11614 11615function resolveDefaultProps(Component, baseProps) { 11616 if (Component && Component.defaultProps) { 11617 // Resolve default props. Taken from ReactElement 11618 var props = _assign({}, baseProps); 11619 11620 var defaultProps = Component.defaultProps; 11621 11622 for (var propName in defaultProps) { 11623 if (props[propName] === undefined) { 11624 props[propName] = defaultProps[propName]; 11625 } 11626 } 11627 11628 return props; 11629 } 11630 11631 return baseProps; 11632} 11633 11634// Max 31 bit integer. The max integer size in V8 for 32-bit systems. 11635// Math.pow(2, 30) - 1 11636// 0b111111111111111111111111111111 11637var MAX_SIGNED_31_BIT_INT = 1073741823; 11638 11639var valueCursor = createCursor(null); 11640var rendererSigil; 11641 11642{ 11643 // Use this to detect multiple renderers using the same context 11644 rendererSigil = {}; 11645} 11646 11647var currentlyRenderingFiber = null; 11648var lastContextDependency = null; 11649var lastContextWithAllBitsObserved = null; 11650var isDisallowedContextReadInDEV = false; 11651function resetContextDependencies() { 11652 // This is called right before React yields execution, to ensure `readContext` 11653 // cannot be called outside the render phase. 11654 currentlyRenderingFiber = null; 11655 lastContextDependency = null; 11656 lastContextWithAllBitsObserved = null; 11657 11658 { 11659 isDisallowedContextReadInDEV = false; 11660 } 11661} 11662function enterDisallowedContextReadInDEV() { 11663 { 11664 isDisallowedContextReadInDEV = true; 11665 } 11666} 11667function exitDisallowedContextReadInDEV() { 11668 { 11669 isDisallowedContextReadInDEV = false; 11670 } 11671} 11672function pushProvider(providerFiber, nextValue) { 11673 var context = providerFiber.type._context; 11674 11675 { 11676 push(valueCursor, context._currentValue, providerFiber); 11677 context._currentValue = nextValue; 11678 11679 { 11680 if (context._currentRenderer !== undefined && context._currentRenderer !== null && context._currentRenderer !== rendererSigil) { 11681 error('Detected multiple renderers concurrently rendering the ' + 'same context provider. This is currently unsupported.'); 11682 } 11683 11684 context._currentRenderer = rendererSigil; 11685 } 11686 } 11687} 11688function popProvider(providerFiber) { 11689 var currentValue = valueCursor.current; 11690 pop(valueCursor, providerFiber); 11691 var context = providerFiber.type._context; 11692 11693 { 11694 context._currentValue = currentValue; 11695 } 11696} 11697function calculateChangedBits(context, newValue, oldValue) { 11698 if (objectIs(oldValue, newValue)) { 11699 // No change 11700 return 0; 11701 } else { 11702 var changedBits = typeof context._calculateChangedBits === 'function' ? context._calculateChangedBits(oldValue, newValue) : MAX_SIGNED_31_BIT_INT; 11703 11704 { 11705 if ((changedBits & MAX_SIGNED_31_BIT_INT) !== changedBits) { 11706 error('calculateChangedBits: Expected the return value to be a ' + '31-bit integer. Instead received: %s', changedBits); 11707 } 11708 } 11709 11710 return changedBits | 0; 11711 } 11712} 11713function scheduleWorkOnParentPath(parent, renderLanes) { 11714 // Update the child lanes of all the ancestors, including the alternates. 11715 var node = parent; 11716 11717 while (node !== null) { 11718 var alternate = node.alternate; 11719 11720 if (!isSubsetOfLanes(node.childLanes, renderLanes)) { 11721 node.childLanes = mergeLanes(node.childLanes, renderLanes); 11722 11723 if (alternate !== null) { 11724 alternate.childLanes = mergeLanes(alternate.childLanes, renderLanes); 11725 } 11726 } else if (alternate !== null && !isSubsetOfLanes(alternate.childLanes, renderLanes)) { 11727 alternate.childLanes = mergeLanes(alternate.childLanes, renderLanes); 11728 } else { 11729 // Neither alternate was updated, which means the rest of the 11730 // ancestor path already has sufficient priority. 11731 break; 11732 } 11733 11734 node = node.return; 11735 } 11736} 11737function propagateContextChange(workInProgress, context, changedBits, renderLanes) { 11738 var fiber = workInProgress.child; 11739 11740 if (fiber !== null) { 11741 // Set the return pointer of the child to the work-in-progress fiber. 11742 fiber.return = workInProgress; 11743 } 11744 11745 while (fiber !== null) { 11746 var nextFiber = void 0; // Visit this fiber. 11747 11748 var list = fiber.dependencies; 11749 11750 if (list !== null) { 11751 nextFiber = fiber.child; 11752 var dependency = list.firstContext; 11753 11754 while (dependency !== null) { 11755 // Check if the context matches. 11756 if (dependency.context === context && (dependency.observedBits & changedBits) !== 0) { 11757 // Match! Schedule an update on this fiber. 11758 if (fiber.tag === ClassComponent) { 11759 // Schedule a force update on the work-in-progress. 11760 var update = createUpdate(NoTimestamp, pickArbitraryLane(renderLanes)); 11761 update.tag = ForceUpdate; // TODO: Because we don't have a work-in-progress, this will add the 11762 // update to the current fiber, too, which means it will persist even if 11763 // this render is thrown away. Since it's a race condition, not sure it's 11764 // worth fixing. 11765 11766 enqueueUpdate(fiber, update); 11767 } 11768 11769 fiber.lanes = mergeLanes(fiber.lanes, renderLanes); 11770 var alternate = fiber.alternate; 11771 11772 if (alternate !== null) { 11773 alternate.lanes = mergeLanes(alternate.lanes, renderLanes); 11774 } 11775 11776 scheduleWorkOnParentPath(fiber.return, renderLanes); // Mark the updated lanes on the list, too. 11777 11778 list.lanes = mergeLanes(list.lanes, renderLanes); // Since we already found a match, we can stop traversing the 11779 // dependency list. 11780 11781 break; 11782 } 11783 11784 dependency = dependency.next; 11785 } 11786 } else if (fiber.tag === ContextProvider) { 11787 // Don't scan deeper if this is a matching provider 11788 nextFiber = fiber.type === workInProgress.type ? null : fiber.child; 11789 } else { 11790 // Traverse down. 11791 nextFiber = fiber.child; 11792 } 11793 11794 if (nextFiber !== null) { 11795 // Set the return pointer of the child to the work-in-progress fiber. 11796 nextFiber.return = fiber; 11797 } else { 11798 // No child. Traverse to next sibling. 11799 nextFiber = fiber; 11800 11801 while (nextFiber !== null) { 11802 if (nextFiber === workInProgress) { 11803 // We're back to the root of this subtree. Exit. 11804 nextFiber = null; 11805 break; 11806 } 11807 11808 var sibling = nextFiber.sibling; 11809 11810 if (sibling !== null) { 11811 // Set the return pointer of the sibling to the work-in-progress fiber. 11812 sibling.return = nextFiber.return; 11813 nextFiber = sibling; 11814 break; 11815 } // No more siblings. Traverse up. 11816 11817 11818 nextFiber = nextFiber.return; 11819 } 11820 } 11821 11822 fiber = nextFiber; 11823 } 11824} 11825function prepareToReadContext(workInProgress, renderLanes) { 11826 currentlyRenderingFiber = workInProgress; 11827 lastContextDependency = null; 11828 lastContextWithAllBitsObserved = null; 11829 var dependencies = workInProgress.dependencies; 11830 11831 if (dependencies !== null) { 11832 var firstContext = dependencies.firstContext; 11833 11834 if (firstContext !== null) { 11835 if (includesSomeLane(dependencies.lanes, renderLanes)) { 11836 // Context list has a pending update. Mark that this fiber performed work. 11837 markWorkInProgressReceivedUpdate(); 11838 } // Reset the work-in-progress list 11839 11840 11841 dependencies.firstContext = null; 11842 } 11843 } 11844} 11845function readContext(context, observedBits) { 11846 { 11847 // This warning would fire if you read context inside a Hook like useMemo. 11848 // Unlike the class check below, it's not enforced in production for perf. 11849 if (isDisallowedContextReadInDEV) { 11850 error('Context can only be read while React is rendering. ' + 'In classes, you can read it in the render method or getDerivedStateFromProps. ' + 'In function components, you can read it directly in the function body, but not ' + 'inside Hooks like useReducer() or useMemo().'); 11851 } 11852 } 11853 11854 if (lastContextWithAllBitsObserved === context) ; else if (observedBits === false || observedBits === 0) ; else { 11855 var resolvedObservedBits; // Avoid deopting on observable arguments or heterogeneous types. 11856 11857 if (typeof observedBits !== 'number' || observedBits === MAX_SIGNED_31_BIT_INT) { 11858 // Observe all updates. 11859 lastContextWithAllBitsObserved = context; 11860 resolvedObservedBits = MAX_SIGNED_31_BIT_INT; 11861 } else { 11862 resolvedObservedBits = observedBits; 11863 } 11864 11865 var contextItem = { 11866 context: context, 11867 observedBits: resolvedObservedBits, 11868 next: null 11869 }; 11870 11871 if (lastContextDependency === null) { 11872 if (!(currentlyRenderingFiber !== null)) { 11873 { 11874 throw Error( "Context can only be read while React is rendering. In classes, you can read it in the render method or getDerivedStateFromProps. In function components, you can read it directly in the function body, but not inside Hooks like useReducer() or useMemo()." ); 11875 } 11876 } // This is the first dependency for this component. Create a new list. 11877 11878 11879 lastContextDependency = contextItem; 11880 currentlyRenderingFiber.dependencies = { 11881 lanes: NoLanes, 11882 firstContext: contextItem, 11883 responders: null 11884 }; 11885 } else { 11886 // Append a new context item. 11887 lastContextDependency = lastContextDependency.next = contextItem; 11888 } 11889 } 11890 11891 return context._currentValue ; 11892} 11893 11894var UpdateState = 0; 11895var ReplaceState = 1; 11896var ForceUpdate = 2; 11897var CaptureUpdate = 3; // Global state that is reset at the beginning of calling `processUpdateQueue`. 11898// It should only be read right after calling `processUpdateQueue`, via 11899// `checkHasForceUpdateAfterProcessing`. 11900 11901var hasForceUpdate = false; 11902var didWarnUpdateInsideUpdate; 11903var currentlyProcessingQueue; 11904 11905{ 11906 didWarnUpdateInsideUpdate = false; 11907 currentlyProcessingQueue = null; 11908} 11909 11910function initializeUpdateQueue(fiber) { 11911 var queue = { 11912 baseState: fiber.memoizedState, 11913 firstBaseUpdate: null, 11914 lastBaseUpdate: null, 11915 shared: { 11916 pending: null 11917 }, 11918 effects: null 11919 }; 11920 fiber.updateQueue = queue; 11921} 11922function cloneUpdateQueue(current, workInProgress) { 11923 // Clone the update queue from current. Unless it's already a clone. 11924 var queue = workInProgress.updateQueue; 11925 var currentQueue = current.updateQueue; 11926 11927 if (queue === currentQueue) { 11928 var clone = { 11929 baseState: currentQueue.baseState, 11930 firstBaseUpdate: currentQueue.firstBaseUpdate, 11931 lastBaseUpdate: currentQueue.lastBaseUpdate, 11932 shared: currentQueue.shared, 11933 effects: currentQueue.effects 11934 }; 11935 workInProgress.updateQueue = clone; 11936 } 11937} 11938function createUpdate(eventTime, lane) { 11939 var update = { 11940 eventTime: eventTime, 11941 lane: lane, 11942 tag: UpdateState, 11943 payload: null, 11944 callback: null, 11945 next: null 11946 }; 11947 return update; 11948} 11949function enqueueUpdate(fiber, update) { 11950 var updateQueue = fiber.updateQueue; 11951 11952 if (updateQueue === null) { 11953 // Only occurs if the fiber has been unmounted. 11954 return; 11955 } 11956 11957 var sharedQueue = updateQueue.shared; 11958 var pending = sharedQueue.pending; 11959 11960 if (pending === null) { 11961 // This is the first update. Create a circular list. 11962 update.next = update; 11963 } else { 11964 update.next = pending.next; 11965 pending.next = update; 11966 } 11967 11968 sharedQueue.pending = update; 11969 11970 { 11971 if (currentlyProcessingQueue === sharedQueue && !didWarnUpdateInsideUpdate) { 11972 error('An update (setState, replaceState, or forceUpdate) was scheduled ' + 'from inside an update function. Update functions should be pure, ' + 'with zero side-effects. Consider using componentDidUpdate or a ' + 'callback.'); 11973 11974 didWarnUpdateInsideUpdate = true; 11975 } 11976 } 11977} 11978function enqueueCapturedUpdate(workInProgress, capturedUpdate) { 11979 // Captured updates are updates that are thrown by a child during the render 11980 // phase. They should be discarded if the render is aborted. Therefore, 11981 // we should only put them on the work-in-progress queue, not the current one. 11982 var queue = workInProgress.updateQueue; // Check if the work-in-progress queue is a clone. 11983 11984 var current = workInProgress.alternate; 11985 11986 if (current !== null) { 11987 var currentQueue = current.updateQueue; 11988 11989 if (queue === currentQueue) { 11990 // The work-in-progress queue is the same as current. This happens when 11991 // we bail out on a parent fiber that then captures an error thrown by 11992 // a child. Since we want to append the update only to the work-in 11993 // -progress queue, we need to clone the updates. We usually clone during 11994 // processUpdateQueue, but that didn't happen in this case because we 11995 // skipped over the parent when we bailed out. 11996 var newFirst = null; 11997 var newLast = null; 11998 var firstBaseUpdate = queue.firstBaseUpdate; 11999 12000 if (firstBaseUpdate !== null) { 12001 // Loop through the updates and clone them. 12002 var update = firstBaseUpdate; 12003 12004 do { 12005 var clone = { 12006 eventTime: update.eventTime, 12007 lane: update.lane, 12008 tag: update.tag, 12009 payload: update.payload, 12010 callback: update.callback, 12011 next: null 12012 }; 12013 12014 if (newLast === null) { 12015 newFirst = newLast = clone; 12016 } else { 12017 newLast.next = clone; 12018 newLast = clone; 12019 } 12020 12021 update = update.next; 12022 } while (update !== null); // Append the captured update the end of the cloned list. 12023 12024 12025 if (newLast === null) { 12026 newFirst = newLast = capturedUpdate; 12027 } else { 12028 newLast.next = capturedUpdate; 12029 newLast = capturedUpdate; 12030 } 12031 } else { 12032 // There are no base updates. 12033 newFirst = newLast = capturedUpdate; 12034 } 12035 12036 queue = { 12037 baseState: currentQueue.baseState, 12038 firstBaseUpdate: newFirst, 12039 lastBaseUpdate: newLast, 12040 shared: currentQueue.shared, 12041 effects: currentQueue.effects 12042 }; 12043 workInProgress.updateQueue = queue; 12044 return; 12045 } 12046 } // Append the update to the end of the list. 12047 12048 12049 var lastBaseUpdate = queue.lastBaseUpdate; 12050 12051 if (lastBaseUpdate === null) { 12052 queue.firstBaseUpdate = capturedUpdate; 12053 } else { 12054 lastBaseUpdate.next = capturedUpdate; 12055 } 12056 12057 queue.lastBaseUpdate = capturedUpdate; 12058} 12059 12060function getStateFromUpdate(workInProgress, queue, update, prevState, nextProps, instance) { 12061 switch (update.tag) { 12062 case ReplaceState: 12063 { 12064 var payload = update.payload; 12065 12066 if (typeof payload === 'function') { 12067 // Updater function 12068 { 12069 enterDisallowedContextReadInDEV(); 12070 } 12071 12072 var nextState = payload.call(instance, prevState, nextProps); 12073 12074 { 12075 if ( workInProgress.mode & StrictMode) { 12076 disableLogs(); 12077 12078 try { 12079 payload.call(instance, prevState, nextProps); 12080 } finally { 12081 reenableLogs(); 12082 } 12083 } 12084 12085 exitDisallowedContextReadInDEV(); 12086 } 12087 12088 return nextState; 12089 } // State object 12090 12091 12092 return payload; 12093 } 12094 12095 case CaptureUpdate: 12096 { 12097 workInProgress.flags = workInProgress.flags & ~ShouldCapture | DidCapture; 12098 } 12099 // Intentional fallthrough 12100 12101 case UpdateState: 12102 { 12103 var _payload = update.payload; 12104 var partialState; 12105 12106 if (typeof _payload === 'function') { 12107 // Updater function 12108 { 12109 enterDisallowedContextReadInDEV(); 12110 } 12111 12112 partialState = _payload.call(instance, prevState, nextProps); 12113 12114 { 12115 if ( workInProgress.mode & StrictMode) { 12116 disableLogs(); 12117 12118 try { 12119 _payload.call(instance, prevState, nextProps); 12120 } finally { 12121 reenableLogs(); 12122 } 12123 } 12124 12125 exitDisallowedContextReadInDEV(); 12126 } 12127 } else { 12128 // Partial state object 12129 partialState = _payload; 12130 } 12131 12132 if (partialState === null || partialState === undefined) { 12133 // Null and undefined are treated as no-ops. 12134 return prevState; 12135 } // Merge the partial state and the previous state. 12136 12137 12138 return _assign({}, prevState, partialState); 12139 } 12140 12141 case ForceUpdate: 12142 { 12143 hasForceUpdate = true; 12144 return prevState; 12145 } 12146 } 12147 12148 return prevState; 12149} 12150 12151function processUpdateQueue(workInProgress, props, instance, renderLanes) { 12152 // This is always non-null on a ClassComponent or HostRoot 12153 var queue = workInProgress.updateQueue; 12154 hasForceUpdate = false; 12155 12156 { 12157 currentlyProcessingQueue = queue.shared; 12158 } 12159 12160 var firstBaseUpdate = queue.firstBaseUpdate; 12161 var lastBaseUpdate = queue.lastBaseUpdate; // Check if there are pending updates. If so, transfer them to the base queue. 12162 12163 var pendingQueue = queue.shared.pending; 12164 12165 if (pendingQueue !== null) { 12166 queue.shared.pending = null; // The pending queue is circular. Disconnect the pointer between first 12167 // and last so that it's non-circular. 12168 12169 var lastPendingUpdate = pendingQueue; 12170 var firstPendingUpdate = lastPendingUpdate.next; 12171 lastPendingUpdate.next = null; // Append pending updates to base queue 12172 12173 if (lastBaseUpdate === null) { 12174 firstBaseUpdate = firstPendingUpdate; 12175 } else { 12176 lastBaseUpdate.next = firstPendingUpdate; 12177 } 12178 12179 lastBaseUpdate = lastPendingUpdate; // If there's a current queue, and it's different from the base queue, then 12180 // we need to transfer the updates to that queue, too. Because the base 12181 // queue is a singly-linked list with no cycles, we can append to both 12182 // lists and take advantage of structural sharing. 12183 // TODO: Pass `current` as argument 12184 12185 var current = workInProgress.alternate; 12186 12187 if (current !== null) { 12188 // This is always non-null on a ClassComponent or HostRoot 12189 var currentQueue = current.updateQueue; 12190 var currentLastBaseUpdate = currentQueue.lastBaseUpdate; 12191 12192 if (currentLastBaseUpdate !== lastBaseUpdate) { 12193 if (currentLastBaseUpdate === null) { 12194 currentQueue.firstBaseUpdate = firstPendingUpdate; 12195 } else { 12196 currentLastBaseUpdate.next = firstPendingUpdate; 12197 } 12198 12199 currentQueue.lastBaseUpdate = lastPendingUpdate; 12200 } 12201 } 12202 } // These values may change as we process the queue. 12203 12204 12205 if (firstBaseUpdate !== null) { 12206 // Iterate through the list of updates to compute the result. 12207 var newState = queue.baseState; // TODO: Don't need to accumulate this. Instead, we can remove renderLanes 12208 // from the original lanes. 12209 12210 var newLanes = NoLanes; 12211 var newBaseState = null; 12212 var newFirstBaseUpdate = null; 12213 var newLastBaseUpdate = null; 12214 var update = firstBaseUpdate; 12215 12216 do { 12217 var updateLane = update.lane; 12218 var updateEventTime = update.eventTime; 12219 12220 if (!isSubsetOfLanes(renderLanes, updateLane)) { 12221 // Priority is insufficient. Skip this update. If this is the first 12222 // skipped update, the previous update/state is the new base 12223 // update/state. 12224 var clone = { 12225 eventTime: updateEventTime, 12226 lane: updateLane, 12227 tag: update.tag, 12228 payload: update.payload, 12229 callback: update.callback, 12230 next: null 12231 }; 12232 12233 if (newLastBaseUpdate === null) { 12234 newFirstBaseUpdate = newLastBaseUpdate = clone; 12235 newBaseState = newState; 12236 } else { 12237 newLastBaseUpdate = newLastBaseUpdate.next = clone; 12238 } // Update the remaining priority in the queue. 12239 12240 12241 newLanes = mergeLanes(newLanes, updateLane); 12242 } else { 12243 // This update does have sufficient priority. 12244 if (newLastBaseUpdate !== null) { 12245 var _clone = { 12246 eventTime: updateEventTime, 12247 // This update is going to be committed so we never want uncommit 12248 // it. Using NoLane works because 0 is a subset of all bitmasks, so 12249 // this will never be skipped by the check above. 12250 lane: NoLane, 12251 tag: update.tag, 12252 payload: update.payload, 12253 callback: update.callback, 12254 next: null 12255 }; 12256 newLastBaseUpdate = newLastBaseUpdate.next = _clone; 12257 } // Process this update. 12258 12259 12260 newState = getStateFromUpdate(workInProgress, queue, update, newState, props, instance); 12261 var callback = update.callback; 12262 12263 if (callback !== null) { 12264 workInProgress.flags |= Callback; 12265 var effects = queue.effects; 12266 12267 if (effects === null) { 12268 queue.effects = [update]; 12269 } else { 12270 effects.push(update); 12271 } 12272 } 12273 } 12274 12275 update = update.next; 12276 12277 if (update === null) { 12278 pendingQueue = queue.shared.pending; 12279 12280 if (pendingQueue === null) { 12281 break; 12282 } else { 12283 // An update was scheduled from inside a reducer. Add the new 12284 // pending updates to the end of the list and keep processing. 12285 var _lastPendingUpdate = pendingQueue; // Intentionally unsound. Pending updates form a circular list, but we 12286 // unravel them when transferring them to the base queue. 12287 12288 var _firstPendingUpdate = _lastPendingUpdate.next; 12289 _lastPendingUpdate.next = null; 12290 update = _firstPendingUpdate; 12291 queue.lastBaseUpdate = _lastPendingUpdate; 12292 queue.shared.pending = null; 12293 } 12294 } 12295 } while (true); 12296 12297 if (newLastBaseUpdate === null) { 12298 newBaseState = newState; 12299 } 12300 12301 queue.baseState = newBaseState; 12302 queue.firstBaseUpdate = newFirstBaseUpdate; 12303 queue.lastBaseUpdate = newLastBaseUpdate; // Set the remaining expiration time to be whatever is remaining in the queue. 12304 // This should be fine because the only two other things that contribute to 12305 // expiration time are props and context. We're already in the middle of the 12306 // begin phase by the time we start processing the queue, so we've already 12307 // dealt with the props. Context in components that specify 12308 // shouldComponentUpdate is tricky; but we'll have to account for 12309 // that regardless. 12310 12311 markSkippedUpdateLanes(newLanes); 12312 workInProgress.lanes = newLanes; 12313 workInProgress.memoizedState = newState; 12314 } 12315 12316 { 12317 currentlyProcessingQueue = null; 12318 } 12319} 12320 12321function callCallback(callback, context) { 12322 if (!(typeof callback === 'function')) { 12323 { 12324 throw Error( "Invalid argument passed as callback. Expected a function. Instead received: " + callback ); 12325 } 12326 } 12327 12328 callback.call(context); 12329} 12330 12331function resetHasForceUpdateBeforeProcessing() { 12332 hasForceUpdate = false; 12333} 12334function checkHasForceUpdateAfterProcessing() { 12335 return hasForceUpdate; 12336} 12337function commitUpdateQueue(finishedWork, finishedQueue, instance) { 12338 // Commit the effects 12339 var effects = finishedQueue.effects; 12340 finishedQueue.effects = null; 12341 12342 if (effects !== null) { 12343 for (var i = 0; i < effects.length; i++) { 12344 var effect = effects[i]; 12345 var callback = effect.callback; 12346 12347 if (callback !== null) { 12348 effect.callback = null; 12349 callCallback(callback, instance); 12350 } 12351 } 12352 } 12353} 12354 12355var fakeInternalInstance = {}; 12356var isArray = Array.isArray; // React.Component uses a shared frozen object by default. 12357// We'll use it to determine whether we need to initialize legacy refs. 12358 12359var emptyRefsObject = new React.Component().refs; 12360var didWarnAboutStateAssignmentForComponent; 12361var didWarnAboutUninitializedState; 12362var didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate; 12363var didWarnAboutLegacyLifecyclesAndDerivedState; 12364var didWarnAboutUndefinedDerivedState; 12365var warnOnUndefinedDerivedState; 12366var warnOnInvalidCallback; 12367var didWarnAboutDirectlyAssigningPropsToState; 12368var didWarnAboutContextTypeAndContextTypes; 12369var didWarnAboutInvalidateContextType; 12370 12371{ 12372 didWarnAboutStateAssignmentForComponent = new Set(); 12373 didWarnAboutUninitializedState = new Set(); 12374 didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate = new Set(); 12375 didWarnAboutLegacyLifecyclesAndDerivedState = new Set(); 12376 didWarnAboutDirectlyAssigningPropsToState = new Set(); 12377 didWarnAboutUndefinedDerivedState = new Set(); 12378 didWarnAboutContextTypeAndContextTypes = new Set(); 12379 didWarnAboutInvalidateContextType = new Set(); 12380 var didWarnOnInvalidCallback = new Set(); 12381 12382 warnOnInvalidCallback = function (callback, callerName) { 12383 if (callback === null || typeof callback === 'function') { 12384 return; 12385 } 12386 12387 var key = callerName + '_' + callback; 12388 12389 if (!didWarnOnInvalidCallback.has(key)) { 12390 didWarnOnInvalidCallback.add(key); 12391 12392 error('%s(...): Expected the last optional `callback` argument to be a ' + 'function. Instead received: %s.', callerName, callback); 12393 } 12394 }; 12395 12396 warnOnUndefinedDerivedState = function (type, partialState) { 12397 if (partialState === undefined) { 12398 var componentName = getComponentName(type) || 'Component'; 12399 12400 if (!didWarnAboutUndefinedDerivedState.has(componentName)) { 12401 didWarnAboutUndefinedDerivedState.add(componentName); 12402 12403 error('%s.getDerivedStateFromProps(): A valid state object (or null) must be returned. ' + 'You have returned undefined.', componentName); 12404 } 12405 } 12406 }; // This is so gross but it's at least non-critical and can be removed if 12407 // it causes problems. This is meant to give a nicer error message for 12408 // ReactDOM15.unstable_renderSubtreeIntoContainer(reactDOM16Component, 12409 // ...)) which otherwise throws a "_processChildContext is not a function" 12410 // exception. 12411 12412 12413 Object.defineProperty(fakeInternalInstance, '_processChildContext', { 12414 enumerable: false, 12415 value: function () { 12416 { 12417 { 12418 throw Error( "_processChildContext is not available in React 16+. This likely means you have multiple copies of React and are attempting to nest a React 15 tree inside a React 16 tree using unstable_renderSubtreeIntoContainer, which isn't supported. Try to make sure you have only one copy of React (and ideally, switch to ReactDOM.createPortal)." ); 12419 } 12420 } 12421 } 12422 }); 12423 Object.freeze(fakeInternalInstance); 12424} 12425 12426function applyDerivedStateFromProps(workInProgress, ctor, getDerivedStateFromProps, nextProps) { 12427 var prevState = workInProgress.memoizedState; 12428 12429 { 12430 if ( workInProgress.mode & StrictMode) { 12431 disableLogs(); 12432 12433 try { 12434 // Invoke the function an extra time to help detect side-effects. 12435 getDerivedStateFromProps(nextProps, prevState); 12436 } finally { 12437 reenableLogs(); 12438 } 12439 } 12440 } 12441 12442 var partialState = getDerivedStateFromProps(nextProps, prevState); 12443 12444 { 12445 warnOnUndefinedDerivedState(ctor, partialState); 12446 } // Merge the partial state and the previous state. 12447 12448 12449 var memoizedState = partialState === null || partialState === undefined ? prevState : _assign({}, prevState, partialState); 12450 workInProgress.memoizedState = memoizedState; // Once the update queue is empty, persist the derived state onto the 12451 // base state. 12452 12453 if (workInProgress.lanes === NoLanes) { 12454 // Queue is always non-null for classes 12455 var updateQueue = workInProgress.updateQueue; 12456 updateQueue.baseState = memoizedState; 12457 } 12458} 12459var classComponentUpdater = { 12460 isMounted: isMounted, 12461 enqueueSetState: function (inst, payload, callback) { 12462 var fiber = get(inst); 12463 var eventTime = requestEventTime(); 12464 var lane = requestUpdateLane(fiber); 12465 var update = createUpdate(eventTime, lane); 12466 update.payload = payload; 12467 12468 if (callback !== undefined && callback !== null) { 12469 { 12470 warnOnInvalidCallback(callback, 'setState'); 12471 } 12472 12473 update.callback = callback; 12474 } 12475 12476 enqueueUpdate(fiber, update); 12477 scheduleUpdateOnFiber(fiber, lane, eventTime); 12478 }, 12479 enqueueReplaceState: function (inst, payload, callback) { 12480 var fiber = get(inst); 12481 var eventTime = requestEventTime(); 12482 var lane = requestUpdateLane(fiber); 12483 var update = createUpdate(eventTime, lane); 12484 update.tag = ReplaceState; 12485 update.payload = payload; 12486 12487 if (callback !== undefined && callback !== null) { 12488 { 12489 warnOnInvalidCallback(callback, 'replaceState'); 12490 } 12491 12492 update.callback = callback; 12493 } 12494 12495 enqueueUpdate(fiber, update); 12496 scheduleUpdateOnFiber(fiber, lane, eventTime); 12497 }, 12498 enqueueForceUpdate: function (inst, callback) { 12499 var fiber = get(inst); 12500 var eventTime = requestEventTime(); 12501 var lane = requestUpdateLane(fiber); 12502 var update = createUpdate(eventTime, lane); 12503 update.tag = ForceUpdate; 12504 12505 if (callback !== undefined && callback !== null) { 12506 { 12507 warnOnInvalidCallback(callback, 'forceUpdate'); 12508 } 12509 12510 update.callback = callback; 12511 } 12512 12513 enqueueUpdate(fiber, update); 12514 scheduleUpdateOnFiber(fiber, lane, eventTime); 12515 } 12516}; 12517 12518function checkShouldComponentUpdate(workInProgress, ctor, oldProps, newProps, oldState, newState, nextContext) { 12519 var instance = workInProgress.stateNode; 12520 12521 if (typeof instance.shouldComponentUpdate === 'function') { 12522 { 12523 if ( workInProgress.mode & StrictMode) { 12524 disableLogs(); 12525 12526 try { 12527 // Invoke the function an extra time to help detect side-effects. 12528 instance.shouldComponentUpdate(newProps, newState, nextContext); 12529 } finally { 12530 reenableLogs(); 12531 } 12532 } 12533 } 12534 12535 var shouldUpdate = instance.shouldComponentUpdate(newProps, newState, nextContext); 12536 12537 { 12538 if (shouldUpdate === undefined) { 12539 error('%s.shouldComponentUpdate(): Returned undefined instead of a ' + 'boolean value. Make sure to return true or false.', getComponentName(ctor) || 'Component'); 12540 } 12541 } 12542 12543 return shouldUpdate; 12544 } 12545 12546 if (ctor.prototype && ctor.prototype.isPureReactComponent) { 12547 return !shallowEqual(oldProps, newProps) || !shallowEqual(oldState, newState); 12548 } 12549 12550 return true; 12551} 12552 12553function checkClassInstance(workInProgress, ctor, newProps) { 12554 var instance = workInProgress.stateNode; 12555 12556 { 12557 var name = getComponentName(ctor) || 'Component'; 12558 var renderPresent = instance.render; 12559 12560 if (!renderPresent) { 12561 if (ctor.prototype && typeof ctor.prototype.render === 'function') { 12562 error('%s(...): No `render` method found on the returned component ' + 'instance: did you accidentally return an object from the constructor?', name); 12563 } else { 12564 error('%s(...): No `render` method found on the returned component ' + 'instance: you may have forgotten to define `render`.', name); 12565 } 12566 } 12567 12568 if (instance.getInitialState && !instance.getInitialState.isReactClassApproved && !instance.state) { 12569 error('getInitialState was defined on %s, a plain JavaScript class. ' + 'This is only supported for classes created using React.createClass. ' + 'Did you mean to define a state property instead?', name); 12570 } 12571 12572 if (instance.getDefaultProps && !instance.getDefaultProps.isReactClassApproved) { 12573 error('getDefaultProps was defined on %s, a plain JavaScript class. ' + 'This is only supported for classes created using React.createClass. ' + 'Use a static property to define defaultProps instead.', name); 12574 } 12575 12576 if (instance.propTypes) { 12577 error('propTypes was defined as an instance property on %s. Use a static ' + 'property to define propTypes instead.', name); 12578 } 12579 12580 if (instance.contextType) { 12581 error('contextType was defined as an instance property on %s. Use a static ' + 'property to define contextType instead.', name); 12582 } 12583 12584 { 12585 if (instance.contextTypes) { 12586 error('contextTypes was defined as an instance property on %s. Use a static ' + 'property to define contextTypes instead.', name); 12587 } 12588 12589 if (ctor.contextType && ctor.contextTypes && !didWarnAboutContextTypeAndContextTypes.has(ctor)) { 12590 didWarnAboutContextTypeAndContextTypes.add(ctor); 12591 12592 error('%s declares both contextTypes and contextType static properties. ' + 'The legacy contextTypes property will be ignored.', name); 12593 } 12594 } 12595 12596 if (typeof instance.componentShouldUpdate === 'function') { 12597 error('%s has a method called ' + 'componentShouldUpdate(). Did you mean shouldComponentUpdate()? ' + 'The name is phrased as a question because the function is ' + 'expected to return a value.', name); 12598 } 12599 12600 if (ctor.prototype && ctor.prototype.isPureReactComponent && typeof instance.shouldComponentUpdate !== 'undefined') { 12601 error('%s has a method called shouldComponentUpdate(). ' + 'shouldComponentUpdate should not be used when extending React.PureComponent. ' + 'Please extend React.Component if shouldComponentUpdate is used.', getComponentName(ctor) || 'A pure component'); 12602 } 12603 12604 if (typeof instance.componentDidUnmount === 'function') { 12605 error('%s has a method called ' + 'componentDidUnmount(). But there is no such lifecycle method. ' + 'Did you mean componentWillUnmount()?', name); 12606 } 12607 12608 if (typeof instance.componentDidReceiveProps === 'function') { 12609 error('%s has a method called ' + 'componentDidReceiveProps(). But there is no such lifecycle method. ' + 'If you meant to update the state in response to changing props, ' + 'use componentWillReceiveProps(). If you meant to fetch data or ' + 'run side-effects or mutations after React has updated the UI, use componentDidUpdate().', name); 12610 } 12611 12612 if (typeof instance.componentWillRecieveProps === 'function') { 12613 error('%s has a method called ' + 'componentWillRecieveProps(). Did you mean componentWillReceiveProps()?', name); 12614 } 12615 12616 if (typeof instance.UNSAFE_componentWillRecieveProps === 'function') { 12617 error('%s has a method called ' + 'UNSAFE_componentWillRecieveProps(). Did you mean UNSAFE_componentWillReceiveProps()?', name); 12618 } 12619 12620 var hasMutatedProps = instance.props !== newProps; 12621 12622 if (instance.props !== undefined && hasMutatedProps) { 12623 error('%s(...): When calling super() in `%s`, make sure to pass ' + "up the same props that your component's constructor was passed.", name, name); 12624 } 12625 12626 if (instance.defaultProps) { 12627 error('Setting defaultProps as an instance property on %s is not supported and will be ignored.' + ' Instead, define defaultProps as a static property on %s.', name, name); 12628 } 12629 12630 if (typeof instance.getSnapshotBeforeUpdate === 'function' && typeof instance.componentDidUpdate !== 'function' && !didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate.has(ctor)) { 12631 didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate.add(ctor); 12632 12633 error('%s: getSnapshotBeforeUpdate() should be used with componentDidUpdate(). ' + 'This component defines getSnapshotBeforeUpdate() only.', getComponentName(ctor)); 12634 } 12635 12636 if (typeof instance.getDerivedStateFromProps === 'function') { 12637 error('%s: getDerivedStateFromProps() is defined as an instance method ' + 'and will be ignored. Instead, declare it as a static method.', name); 12638 } 12639 12640 if (typeof instance.getDerivedStateFromError === 'function') { 12641 error('%s: getDerivedStateFromError() is defined as an instance method ' + 'and will be ignored. Instead, declare it as a static method.', name); 12642 } 12643 12644 if (typeof ctor.getSnapshotBeforeUpdate === 'function') { 12645 error('%s: getSnapshotBeforeUpdate() is defined as a static method ' + 'and will be ignored. Instead, declare it as an instance method.', name); 12646 } 12647 12648 var _state = instance.state; 12649 12650 if (_state && (typeof _state !== 'object' || isArray(_state))) { 12651 error('%s.state: must be set to an object or null', name); 12652 } 12653 12654 if (typeof instance.getChildContext === 'function' && typeof ctor.childContextTypes !== 'object') { 12655 error('%s.getChildContext(): childContextTypes must be defined in order to ' + 'use getChildContext().', name); 12656 } 12657 } 12658} 12659 12660function adoptClassInstance(workInProgress, instance) { 12661 instance.updater = classComponentUpdater; 12662 workInProgress.stateNode = instance; // The instance needs access to the fiber so that it can schedule updates 12663 12664 set(instance, workInProgress); 12665 12666 { 12667 instance._reactInternalInstance = fakeInternalInstance; 12668 } 12669} 12670 12671function constructClassInstance(workInProgress, ctor, props) { 12672 var isLegacyContextConsumer = false; 12673 var unmaskedContext = emptyContextObject; 12674 var context = emptyContextObject; 12675 var contextType = ctor.contextType; 12676 12677 { 12678 if ('contextType' in ctor) { 12679 var isValid = // Allow null for conditional declaration 12680 contextType === null || contextType !== undefined && contextType.$$typeof === REACT_CONTEXT_TYPE && contextType._context === undefined; // Not a <Context.Consumer> 12681 12682 if (!isValid && !didWarnAboutInvalidateContextType.has(ctor)) { 12683 didWarnAboutInvalidateContextType.add(ctor); 12684 var addendum = ''; 12685 12686 if (contextType === undefined) { 12687 addendum = ' However, it is set to undefined. ' + 'This can be caused by a typo or by mixing up named and default imports. ' + 'This can also happen due to a circular dependency, so ' + 'try moving the createContext() call to a separate file.'; 12688 } else if (typeof contextType !== 'object') { 12689 addendum = ' However, it is set to a ' + typeof contextType + '.'; 12690 } else if (contextType.$$typeof === REACT_PROVIDER_TYPE) { 12691 addendum = ' Did you accidentally pass the Context.Provider instead?'; 12692 } else if (contextType._context !== undefined) { 12693 // <Context.Consumer> 12694 addendum = ' Did you accidentally pass the Context.Consumer instead?'; 12695 } else { 12696 addendum = ' However, it is set to an object with keys {' + Object.keys(contextType).join(', ') + '}.'; 12697 } 12698 12699 error('%s defines an invalid contextType. ' + 'contextType should point to the Context object returned by React.createContext().%s', getComponentName(ctor) || 'Component', addendum); 12700 } 12701 } 12702 } 12703 12704 if (typeof contextType === 'object' && contextType !== null) { 12705 context = readContext(contextType); 12706 } else { 12707 unmaskedContext = getUnmaskedContext(workInProgress, ctor, true); 12708 var contextTypes = ctor.contextTypes; 12709 isLegacyContextConsumer = contextTypes !== null && contextTypes !== undefined; 12710 context = isLegacyContextConsumer ? getMaskedContext(workInProgress, unmaskedContext) : emptyContextObject; 12711 } // Instantiate twice to help detect side-effects. 12712 12713 12714 { 12715 if ( workInProgress.mode & StrictMode) { 12716 disableLogs(); 12717 12718 try { 12719 new ctor(props, context); // eslint-disable-line no-new 12720 } finally { 12721 reenableLogs(); 12722 } 12723 } 12724 } 12725 12726 var instance = new ctor(props, context); 12727 var state = workInProgress.memoizedState = instance.state !== null && instance.state !== undefined ? instance.state : null; 12728 adoptClassInstance(workInProgress, instance); 12729 12730 { 12731 if (typeof ctor.getDerivedStateFromProps === 'function' && state === null) { 12732 var componentName = getComponentName(ctor) || 'Component'; 12733 12734 if (!didWarnAboutUninitializedState.has(componentName)) { 12735 didWarnAboutUninitializedState.add(componentName); 12736 12737 error('`%s` uses `getDerivedStateFromProps` but its initial state is ' + '%s. This is not recommended. Instead, define the initial state by ' + 'assigning an object to `this.state` in the constructor of `%s`. ' + 'This ensures that `getDerivedStateFromProps` arguments have a consistent shape.', componentName, instance.state === null ? 'null' : 'undefined', componentName); 12738 } 12739 } // If new component APIs are defined, "unsafe" lifecycles won't be called. 12740 // Warn about these lifecycles if they are present. 12741 // Don't warn about react-lifecycles-compat polyfilled methods though. 12742 12743 12744 if (typeof ctor.getDerivedStateFromProps === 'function' || typeof instance.getSnapshotBeforeUpdate === 'function') { 12745 var foundWillMountName = null; 12746 var foundWillReceivePropsName = null; 12747 var foundWillUpdateName = null; 12748 12749 if (typeof instance.componentWillMount === 'function' && instance.componentWillMount.__suppressDeprecationWarning !== true) { 12750 foundWillMountName = 'componentWillMount'; 12751 } else if (typeof instance.UNSAFE_componentWillMount === 'function') { 12752 foundWillMountName = 'UNSAFE_componentWillMount'; 12753 } 12754 12755 if (typeof instance.componentWillReceiveProps === 'function' && instance.componentWillReceiveProps.__suppressDeprecationWarning !== true) { 12756 foundWillReceivePropsName = 'componentWillReceiveProps'; 12757 } else if (typeof instance.UNSAFE_componentWillReceiveProps === 'function') { 12758 foundWillReceivePropsName = 'UNSAFE_componentWillReceiveProps'; 12759 } 12760 12761 if (typeof instance.componentWillUpdate === 'function' && instance.componentWillUpdate.__suppressDeprecationWarning !== true) { 12762 foundWillUpdateName = 'componentWillUpdate'; 12763 } else if (typeof instance.UNSAFE_componentWillUpdate === 'function') { 12764 foundWillUpdateName = 'UNSAFE_componentWillUpdate'; 12765 } 12766 12767 if (foundWillMountName !== null || foundWillReceivePropsName !== null || foundWillUpdateName !== null) { 12768 var _componentName = getComponentName(ctor) || 'Component'; 12769 12770 var newApiName = typeof ctor.getDerivedStateFromProps === 'function' ? 'getDerivedStateFromProps()' : 'getSnapshotBeforeUpdate()'; 12771 12772 if (!didWarnAboutLegacyLifecyclesAndDerivedState.has(_componentName)) { 12773 didWarnAboutLegacyLifecyclesAndDerivedState.add(_componentName); 12774 12775 error('Unsafe legacy lifecycles will not be called for components using new component APIs.\n\n' + '%s uses %s but also contains the following legacy lifecycles:%s%s%s\n\n' + 'The above lifecycles should be removed. Learn more about this warning here:\n' + 'https://reactjs.org/link/unsafe-component-lifecycles', _componentName, newApiName, foundWillMountName !== null ? "\n " + foundWillMountName : '', foundWillReceivePropsName !== null ? "\n " + foundWillReceivePropsName : '', foundWillUpdateName !== null ? "\n " + foundWillUpdateName : ''); 12776 } 12777 } 12778 } 12779 } // Cache unmasked context so we can avoid recreating masked context unless necessary. 12780 // ReactFiberContext usually updates this cache but can't for newly-created instances. 12781 12782 12783 if (isLegacyContextConsumer) { 12784 cacheContext(workInProgress, unmaskedContext, context); 12785 } 12786 12787 return instance; 12788} 12789 12790function callComponentWillMount(workInProgress, instance) { 12791 var oldState = instance.state; 12792 12793 if (typeof instance.componentWillMount === 'function') { 12794 instance.componentWillMount(); 12795 } 12796 12797 if (typeof instance.UNSAFE_componentWillMount === 'function') { 12798 instance.UNSAFE_componentWillMount(); 12799 } 12800 12801 if (oldState !== instance.state) { 12802 { 12803 error('%s.componentWillMount(): Assigning directly to this.state is ' + "deprecated (except inside a component's " + 'constructor). Use setState instead.', getComponentName(workInProgress.type) || 'Component'); 12804 } 12805 12806 classComponentUpdater.enqueueReplaceState(instance, instance.state, null); 12807 } 12808} 12809 12810function callComponentWillReceiveProps(workInProgress, instance, newProps, nextContext) { 12811 var oldState = instance.state; 12812 12813 if (typeof instance.componentWillReceiveProps === 'function') { 12814 instance.componentWillReceiveProps(newProps, nextContext); 12815 } 12816 12817 if (typeof instance.UNSAFE_componentWillReceiveProps === 'function') { 12818 instance.UNSAFE_componentWillReceiveProps(newProps, nextContext); 12819 } 12820 12821 if (instance.state !== oldState) { 12822 { 12823 var componentName = getComponentName(workInProgress.type) || 'Component'; 12824 12825 if (!didWarnAboutStateAssignmentForComponent.has(componentName)) { 12826 didWarnAboutStateAssignmentForComponent.add(componentName); 12827 12828 error('%s.componentWillReceiveProps(): Assigning directly to ' + "this.state is deprecated (except inside a component's " + 'constructor). Use setState instead.', componentName); 12829 } 12830 } 12831 12832 classComponentUpdater.enqueueReplaceState(instance, instance.state, null); 12833 } 12834} // Invokes the mount life-cycles on a previously never rendered instance. 12835 12836 12837function mountClassInstance(workInProgress, ctor, newProps, renderLanes) { 12838 { 12839 checkClassInstance(workInProgress, ctor, newProps); 12840 } 12841 12842 var instance = workInProgress.stateNode; 12843 instance.props = newProps; 12844 instance.state = workInProgress.memoizedState; 12845 instance.refs = emptyRefsObject; 12846 initializeUpdateQueue(workInProgress); 12847 var contextType = ctor.contextType; 12848 12849 if (typeof contextType === 'object' && contextType !== null) { 12850 instance.context = readContext(contextType); 12851 } else { 12852 var unmaskedContext = getUnmaskedContext(workInProgress, ctor, true); 12853 instance.context = getMaskedContext(workInProgress, unmaskedContext); 12854 } 12855 12856 { 12857 if (instance.state === newProps) { 12858 var componentName = getComponentName(ctor) || 'Component'; 12859 12860 if (!didWarnAboutDirectlyAssigningPropsToState.has(componentName)) { 12861 didWarnAboutDirectlyAssigningPropsToState.add(componentName); 12862 12863 error('%s: It is not recommended to assign props directly to state ' + "because updates to props won't be reflected in state. " + 'In most cases, it is better to use props directly.', componentName); 12864 } 12865 } 12866 12867 if (workInProgress.mode & StrictMode) { 12868 ReactStrictModeWarnings.recordLegacyContextWarning(workInProgress, instance); 12869 } 12870 12871 { 12872 ReactStrictModeWarnings.recordUnsafeLifecycleWarnings(workInProgress, instance); 12873 } 12874 } 12875 12876 processUpdateQueue(workInProgress, newProps, instance, renderLanes); 12877 instance.state = workInProgress.memoizedState; 12878 var getDerivedStateFromProps = ctor.getDerivedStateFromProps; 12879 12880 if (typeof getDerivedStateFromProps === 'function') { 12881 applyDerivedStateFromProps(workInProgress, ctor, getDerivedStateFromProps, newProps); 12882 instance.state = workInProgress.memoizedState; 12883 } // In order to support react-lifecycles-compat polyfilled components, 12884 // Unsafe lifecycles should not be invoked for components using the new APIs. 12885 12886 12887 if (typeof ctor.getDerivedStateFromProps !== 'function' && typeof instance.getSnapshotBeforeUpdate !== 'function' && (typeof instance.UNSAFE_componentWillMount === 'function' || typeof instance.componentWillMount === 'function')) { 12888 callComponentWillMount(workInProgress, instance); // If we had additional state updates during this life-cycle, let's 12889 // process them now. 12890 12891 processUpdateQueue(workInProgress, newProps, instance, renderLanes); 12892 instance.state = workInProgress.memoizedState; 12893 } 12894 12895 if (typeof instance.componentDidMount === 'function') { 12896 workInProgress.flags |= Update; 12897 } 12898} 12899 12900function resumeMountClassInstance(workInProgress, ctor, newProps, renderLanes) { 12901 var instance = workInProgress.stateNode; 12902 var oldProps = workInProgress.memoizedProps; 12903 instance.props = oldProps; 12904 var oldContext = instance.context; 12905 var contextType = ctor.contextType; 12906 var nextContext = emptyContextObject; 12907 12908 if (typeof contextType === 'object' && contextType !== null) { 12909 nextContext = readContext(contextType); 12910 } else { 12911 var nextLegacyUnmaskedContext = getUnmaskedContext(workInProgress, ctor, true); 12912 nextContext = getMaskedContext(workInProgress, nextLegacyUnmaskedContext); 12913 } 12914 12915 var getDerivedStateFromProps = ctor.getDerivedStateFromProps; 12916 var hasNewLifecycles = typeof getDerivedStateFromProps === 'function' || typeof instance.getSnapshotBeforeUpdate === 'function'; // Note: During these life-cycles, instance.props/instance.state are what 12917 // ever the previously attempted to render - not the "current". However, 12918 // during componentDidUpdate we pass the "current" props. 12919 // In order to support react-lifecycles-compat polyfilled components, 12920 // Unsafe lifecycles should not be invoked for components using the new APIs. 12921 12922 if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillReceiveProps === 'function' || typeof instance.componentWillReceiveProps === 'function')) { 12923 if (oldProps !== newProps || oldContext !== nextContext) { 12924 callComponentWillReceiveProps(workInProgress, instance, newProps, nextContext); 12925 } 12926 } 12927 12928 resetHasForceUpdateBeforeProcessing(); 12929 var oldState = workInProgress.memoizedState; 12930 var newState = instance.state = oldState; 12931 processUpdateQueue(workInProgress, newProps, instance, renderLanes); 12932 newState = workInProgress.memoizedState; 12933 12934 if (oldProps === newProps && oldState === newState && !hasContextChanged() && !checkHasForceUpdateAfterProcessing()) { 12935 // If an update was already in progress, we should schedule an Update 12936 // effect even though we're bailing out, so that cWU/cDU are called. 12937 if (typeof instance.componentDidMount === 'function') { 12938 workInProgress.flags |= Update; 12939 } 12940 12941 return false; 12942 } 12943 12944 if (typeof getDerivedStateFromProps === 'function') { 12945 applyDerivedStateFromProps(workInProgress, ctor, getDerivedStateFromProps, newProps); 12946 newState = workInProgress.memoizedState; 12947 } 12948 12949 var shouldUpdate = checkHasForceUpdateAfterProcessing() || checkShouldComponentUpdate(workInProgress, ctor, oldProps, newProps, oldState, newState, nextContext); 12950 12951 if (shouldUpdate) { 12952 // In order to support react-lifecycles-compat polyfilled components, 12953 // Unsafe lifecycles should not be invoked for components using the new APIs. 12954 if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillMount === 'function' || typeof instance.componentWillMount === 'function')) { 12955 if (typeof instance.componentWillMount === 'function') { 12956 instance.componentWillMount(); 12957 } 12958 12959 if (typeof instance.UNSAFE_componentWillMount === 'function') { 12960 instance.UNSAFE_componentWillMount(); 12961 } 12962 } 12963 12964 if (typeof instance.componentDidMount === 'function') { 12965 workInProgress.flags |= Update; 12966 } 12967 } else { 12968 // If an update was already in progress, we should schedule an Update 12969 // effect even though we're bailing out, so that cWU/cDU are called. 12970 if (typeof instance.componentDidMount === 'function') { 12971 workInProgress.flags |= Update; 12972 } // If shouldComponentUpdate returned false, we should still update the 12973 // memoized state to indicate that this work can be reused. 12974 12975 12976 workInProgress.memoizedProps = newProps; 12977 workInProgress.memoizedState = newState; 12978 } // Update the existing instance's state, props, and context pointers even 12979 // if shouldComponentUpdate returns false. 12980 12981 12982 instance.props = newProps; 12983 instance.state = newState; 12984 instance.context = nextContext; 12985 return shouldUpdate; 12986} // Invokes the update life-cycles and returns false if it shouldn't rerender. 12987 12988 12989function updateClassInstance(current, workInProgress, ctor, newProps, renderLanes) { 12990 var instance = workInProgress.stateNode; 12991 cloneUpdateQueue(current, workInProgress); 12992 var unresolvedOldProps = workInProgress.memoizedProps; 12993 var oldProps = workInProgress.type === workInProgress.elementType ? unresolvedOldProps : resolveDefaultProps(workInProgress.type, unresolvedOldProps); 12994 instance.props = oldProps; 12995 var unresolvedNewProps = workInProgress.pendingProps; 12996 var oldContext = instance.context; 12997 var contextType = ctor.contextType; 12998 var nextContext = emptyContextObject; 12999 13000 if (typeof contextType === 'object' && contextType !== null) { 13001 nextContext = readContext(contextType); 13002 } else { 13003 var nextUnmaskedContext = getUnmaskedContext(workInProgress, ctor, true); 13004 nextContext = getMaskedContext(workInProgress, nextUnmaskedContext); 13005 } 13006 13007 var getDerivedStateFromProps = ctor.getDerivedStateFromProps; 13008 var hasNewLifecycles = typeof getDerivedStateFromProps === 'function' || typeof instance.getSnapshotBeforeUpdate === 'function'; // Note: During these life-cycles, instance.props/instance.state are what 13009 // ever the previously attempted to render - not the "current". However, 13010 // during componentDidUpdate we pass the "current" props. 13011 // In order to support react-lifecycles-compat polyfilled components, 13012 // Unsafe lifecycles should not be invoked for components using the new APIs. 13013 13014 if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillReceiveProps === 'function' || typeof instance.componentWillReceiveProps === 'function')) { 13015 if (unresolvedOldProps !== unresolvedNewProps || oldContext !== nextContext) { 13016 callComponentWillReceiveProps(workInProgress, instance, newProps, nextContext); 13017 } 13018 } 13019 13020 resetHasForceUpdateBeforeProcessing(); 13021 var oldState = workInProgress.memoizedState; 13022 var newState = instance.state = oldState; 13023 processUpdateQueue(workInProgress, newProps, instance, renderLanes); 13024 newState = workInProgress.memoizedState; 13025 13026 if (unresolvedOldProps === unresolvedNewProps && oldState === newState && !hasContextChanged() && !checkHasForceUpdateAfterProcessing()) { 13027 // If an update was already in progress, we should schedule an Update 13028 // effect even though we're bailing out, so that cWU/cDU are called. 13029 if (typeof instance.componentDidUpdate === 'function') { 13030 if (unresolvedOldProps !== current.memoizedProps || oldState !== current.memoizedState) { 13031 workInProgress.flags |= Update; 13032 } 13033 } 13034 13035 if (typeof instance.getSnapshotBeforeUpdate === 'function') { 13036 if (unresolvedOldProps !== current.memoizedProps || oldState !== current.memoizedState) { 13037 workInProgress.flags |= Snapshot; 13038 } 13039 } 13040 13041 return false; 13042 } 13043 13044 if (typeof getDerivedStateFromProps === 'function') { 13045 applyDerivedStateFromProps(workInProgress, ctor, getDerivedStateFromProps, newProps); 13046 newState = workInProgress.memoizedState; 13047 } 13048 13049 var shouldUpdate = checkHasForceUpdateAfterProcessing() || checkShouldComponentUpdate(workInProgress, ctor, oldProps, newProps, oldState, newState, nextContext); 13050 13051 if (shouldUpdate) { 13052 // In order to support react-lifecycles-compat polyfilled components, 13053 // Unsafe lifecycles should not be invoked for components using the new APIs. 13054 if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillUpdate === 'function' || typeof instance.componentWillUpdate === 'function')) { 13055 if (typeof instance.componentWillUpdate === 'function') { 13056 instance.componentWillUpdate(newProps, newState, nextContext); 13057 } 13058 13059 if (typeof instance.UNSAFE_componentWillUpdate === 'function') { 13060 instance.UNSAFE_componentWillUpdate(newProps, newState, nextContext); 13061 } 13062 } 13063 13064 if (typeof instance.componentDidUpdate === 'function') { 13065 workInProgress.flags |= Update; 13066 } 13067 13068 if (typeof instance.getSnapshotBeforeUpdate === 'function') { 13069 workInProgress.flags |= Snapshot; 13070 } 13071 } else { 13072 // If an update was already in progress, we should schedule an Update 13073 // effect even though we're bailing out, so that cWU/cDU are called. 13074 if (typeof instance.componentDidUpdate === 'function') { 13075 if (unresolvedOldProps !== current.memoizedProps || oldState !== current.memoizedState) { 13076 workInProgress.flags |= Update; 13077 } 13078 } 13079 13080 if (typeof instance.getSnapshotBeforeUpdate === 'function') { 13081 if (unresolvedOldProps !== current.memoizedProps || oldState !== current.memoizedState) { 13082 workInProgress.flags |= Snapshot; 13083 } 13084 } // If shouldComponentUpdate returned false, we should still update the 13085 // memoized props/state to indicate that this work can be reused. 13086 13087 13088 workInProgress.memoizedProps = newProps; 13089 workInProgress.memoizedState = newState; 13090 } // Update the existing instance's state, props, and context pointers even 13091 // if shouldComponentUpdate returns false. 13092 13093 13094 instance.props = newProps; 13095 instance.state = newState; 13096 instance.context = nextContext; 13097 return shouldUpdate; 13098} 13099 13100var didWarnAboutMaps; 13101var didWarnAboutGenerators; 13102var didWarnAboutStringRefs; 13103var ownerHasKeyUseWarning; 13104var ownerHasFunctionTypeWarning; 13105 13106var warnForMissingKey = function (child, returnFiber) {}; 13107 13108{ 13109 didWarnAboutMaps = false; 13110 didWarnAboutGenerators = false; 13111 didWarnAboutStringRefs = {}; 13112 /** 13113 * Warn if there's no key explicitly set on dynamic arrays of children or 13114 * object keys are not valid. This allows us to keep track of children between 13115 * updates. 13116 */ 13117 13118 ownerHasKeyUseWarning = {}; 13119 ownerHasFunctionTypeWarning = {}; 13120 13121 warnForMissingKey = function (child, returnFiber) { 13122 if (child === null || typeof child !== 'object') { 13123 return; 13124 } 13125 13126 if (!child._store || child._store.validated || child.key != null) { 13127 return; 13128 } 13129 13130 if (!(typeof child._store === 'object')) { 13131 { 13132 throw Error( "React Component in warnForMissingKey should have a _store. This error is likely caused by a bug in React. Please file an issue." ); 13133 } 13134 } 13135 13136 child._store.validated = true; 13137 var componentName = getComponentName(returnFiber.type) || 'Component'; 13138 13139 if (ownerHasKeyUseWarning[componentName]) { 13140 return; 13141 } 13142 13143 ownerHasKeyUseWarning[componentName] = true; 13144 13145 error('Each child in a list should have a unique ' + '"key" prop. See https://reactjs.org/link/warning-keys for ' + 'more information.'); 13146 }; 13147} 13148 13149var isArray$1 = Array.isArray; 13150 13151function coerceRef(returnFiber, current, element) { 13152 var mixedRef = element.ref; 13153 13154 if (mixedRef !== null && typeof mixedRef !== 'function' && typeof mixedRef !== 'object') { 13155 { 13156 // TODO: Clean this up once we turn on the string ref warning for 13157 // everyone, because the strict mode case will no longer be relevant 13158 if ((returnFiber.mode & StrictMode || warnAboutStringRefs) && // We warn in ReactElement.js if owner and self are equal for string refs 13159 // because these cannot be automatically converted to an arrow function 13160 // using a codemod. Therefore, we don't have to warn about string refs again. 13161 !(element._owner && element._self && element._owner.stateNode !== element._self)) { 13162 var componentName = getComponentName(returnFiber.type) || 'Component'; 13163 13164 if (!didWarnAboutStringRefs[componentName]) { 13165 { 13166 error('A string ref, "%s", has been found within a strict mode tree. ' + 'String refs are a source of potential bugs and should be avoided. ' + 'We recommend using useRef() or createRef() instead. ' + 'Learn more about using refs safely here: ' + 'https://reactjs.org/link/strict-mode-string-ref', mixedRef); 13167 } 13168 13169 didWarnAboutStringRefs[componentName] = true; 13170 } 13171 } 13172 } 13173 13174 if (element._owner) { 13175 var owner = element._owner; 13176 var inst; 13177 13178 if (owner) { 13179 var ownerFiber = owner; 13180 13181 if (!(ownerFiber.tag === ClassComponent)) { 13182 { 13183 throw Error( "Function components cannot have string refs. We recommend using useRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref" ); 13184 } 13185 } 13186 13187 inst = ownerFiber.stateNode; 13188 } 13189 13190 if (!inst) { 13191 { 13192 throw Error( "Missing owner for string ref " + mixedRef + ". This error is likely caused by a bug in React. Please file an issue." ); 13193 } 13194 } 13195 13196 var stringRef = '' + mixedRef; // Check if previous string ref matches new string ref 13197 13198 if (current !== null && current.ref !== null && typeof current.ref === 'function' && current.ref._stringRef === stringRef) { 13199 return current.ref; 13200 } 13201 13202 var ref = function (value) { 13203 var refs = inst.refs; 13204 13205 if (refs === emptyRefsObject) { 13206 // This is a lazy pooled frozen object, so we need to initialize. 13207 refs = inst.refs = {}; 13208 } 13209 13210 if (value === null) { 13211 delete refs[stringRef]; 13212 } else { 13213 refs[stringRef] = value; 13214 } 13215 }; 13216 13217 ref._stringRef = stringRef; 13218 return ref; 13219 } else { 13220 if (!(typeof mixedRef === 'string')) { 13221 { 13222 throw Error( "Expected ref to be a function, a string, an object returned by React.createRef(), or null." ); 13223 } 13224 } 13225 13226 if (!element._owner) { 13227 { 13228 throw Error( "Element ref was specified as a string (" + mixedRef + ") but no owner was set. This could happen for one of the following reasons:\n1. You may be adding a ref to a function component\n2. You may be adding a ref to a component that was not created inside a component's render method\n3. You have multiple copies of React loaded\nSee https://reactjs.org/link/refs-must-have-owner for more information." ); 13229 } 13230 } 13231 } 13232 } 13233 13234 return mixedRef; 13235} 13236 13237function throwOnInvalidObjectType(returnFiber, newChild) { 13238 if (returnFiber.type !== 'textarea') { 13239 { 13240 { 13241 throw Error( "Objects are not valid as a React child (found: " + (Object.prototype.toString.call(newChild) === '[object Object]' ? 'object with keys {' + Object.keys(newChild).join(', ') + '}' : newChild) + "). If you meant to render a collection of children, use an array instead." ); 13242 } 13243 } 13244 } 13245} 13246 13247function warnOnFunctionType(returnFiber) { 13248 { 13249 var componentName = getComponentName(returnFiber.type) || 'Component'; 13250 13251 if (ownerHasFunctionTypeWarning[componentName]) { 13252 return; 13253 } 13254 13255 ownerHasFunctionTypeWarning[componentName] = true; 13256 13257 error('Functions are not valid as a React child. This may happen if ' + 'you return a Component instead of <Component /> from render. ' + 'Or maybe you meant to call this function rather than return it.'); 13258 } 13259} // We avoid inlining this to avoid potential deopts from using try/catch. 13260// to be able to optimize each path individually by branching early. This needs 13261// a compiler or we can do it manually. Helpers that don't need this branching 13262// live outside of this function. 13263 13264 13265function ChildReconciler(shouldTrackSideEffects) { 13266 function deleteChild(returnFiber, childToDelete) { 13267 if (!shouldTrackSideEffects) { 13268 // Noop. 13269 return; 13270 } // Deletions are added in reversed order so we add it to the front. 13271 // At this point, the return fiber's effect list is empty except for 13272 // deletions, so we can just append the deletion to the list. The remaining 13273 // effects aren't added until the complete phase. Once we implement 13274 // resuming, this may not be true. 13275 13276 13277 var last = returnFiber.lastEffect; 13278 13279 if (last !== null) { 13280 last.nextEffect = childToDelete; 13281 returnFiber.lastEffect = childToDelete; 13282 } else { 13283 returnFiber.firstEffect = returnFiber.lastEffect = childToDelete; 13284 } 13285 13286 childToDelete.nextEffect = null; 13287 childToDelete.flags = Deletion; 13288 } 13289 13290 function deleteRemainingChildren(returnFiber, currentFirstChild) { 13291 if (!shouldTrackSideEffects) { 13292 // Noop. 13293 return null; 13294 } // TODO: For the shouldClone case, this could be micro-optimized a bit by 13295 // assuming that after the first child we've already added everything. 13296 13297 13298 var childToDelete = currentFirstChild; 13299 13300 while (childToDelete !== null) { 13301 deleteChild(returnFiber, childToDelete); 13302 childToDelete = childToDelete.sibling; 13303 } 13304 13305 return null; 13306 } 13307 13308 function mapRemainingChildren(returnFiber, currentFirstChild) { 13309 // Add the remaining children to a temporary map so that we can find them by 13310 // keys quickly. Implicit (null) keys get added to this set with their index 13311 // instead. 13312 var existingChildren = new Map(); 13313 var existingChild = currentFirstChild; 13314 13315 while (existingChild !== null) { 13316 if (existingChild.key !== null) { 13317 existingChildren.set(existingChild.key, existingChild); 13318 } else { 13319 existingChildren.set(existingChild.index, existingChild); 13320 } 13321 13322 existingChild = existingChild.sibling; 13323 } 13324 13325 return existingChildren; 13326 } 13327 13328 function useFiber(fiber, pendingProps) { 13329 // We currently set sibling to null and index to 0 here because it is easy 13330 // to forget to do before returning it. E.g. for the single child case. 13331 var clone = createWorkInProgress(fiber, pendingProps); 13332 clone.index = 0; 13333 clone.sibling = null; 13334 return clone; 13335 } 13336 13337 function placeChild(newFiber, lastPlacedIndex, newIndex) { 13338 newFiber.index = newIndex; 13339 13340 if (!shouldTrackSideEffects) { 13341 // Noop. 13342 return lastPlacedIndex; 13343 } 13344 13345 var current = newFiber.alternate; 13346 13347 if (current !== null) { 13348 var oldIndex = current.index; 13349 13350 if (oldIndex < lastPlacedIndex) { 13351 // This is a move. 13352 newFiber.flags = Placement; 13353 return lastPlacedIndex; 13354 } else { 13355 // This item can stay in place. 13356 return oldIndex; 13357 } 13358 } else { 13359 // This is an insertion. 13360 newFiber.flags = Placement; 13361 return lastPlacedIndex; 13362 } 13363 } 13364 13365 function placeSingleChild(newFiber) { 13366 // This is simpler for the single child case. We only need to do a 13367 // placement for inserting new children. 13368 if (shouldTrackSideEffects && newFiber.alternate === null) { 13369 newFiber.flags = Placement; 13370 } 13371 13372 return newFiber; 13373 } 13374 13375 function updateTextNode(returnFiber, current, textContent, lanes) { 13376 if (current === null || current.tag !== HostText) { 13377 // Insert 13378 var created = createFiberFromText(textContent, returnFiber.mode, lanes); 13379 created.return = returnFiber; 13380 return created; 13381 } else { 13382 // Update 13383 var existing = useFiber(current, textContent); 13384 existing.return = returnFiber; 13385 return existing; 13386 } 13387 } 13388 13389 function updateElement(returnFiber, current, element, lanes) { 13390 if (current !== null) { 13391 if (current.elementType === element.type || ( // Keep this check inline so it only runs on the false path: 13392 isCompatibleFamilyForHotReloading(current, element) )) { 13393 // Move based on index 13394 var existing = useFiber(current, element.props); 13395 existing.ref = coerceRef(returnFiber, current, element); 13396 existing.return = returnFiber; 13397 13398 { 13399 existing._debugSource = element._source; 13400 existing._debugOwner = element._owner; 13401 } 13402 13403 return existing; 13404 } 13405 } // Insert 13406 13407 13408 var created = createFiberFromElement(element, returnFiber.mode, lanes); 13409 created.ref = coerceRef(returnFiber, current, element); 13410 created.return = returnFiber; 13411 return created; 13412 } 13413 13414 function updatePortal(returnFiber, current, portal, lanes) { 13415 if (current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.implementation) { 13416 // Insert 13417 var created = createFiberFromPortal(portal, returnFiber.mode, lanes); 13418 created.return = returnFiber; 13419 return created; 13420 } else { 13421 // Update 13422 var existing = useFiber(current, portal.children || []); 13423 existing.return = returnFiber; 13424 return existing; 13425 } 13426 } 13427 13428 function updateFragment(returnFiber, current, fragment, lanes, key) { 13429 if (current === null || current.tag !== Fragment) { 13430 // Insert 13431 var created = createFiberFromFragment(fragment, returnFiber.mode, lanes, key); 13432 created.return = returnFiber; 13433 return created; 13434 } else { 13435 // Update 13436 var existing = useFiber(current, fragment); 13437 existing.return = returnFiber; 13438 return existing; 13439 } 13440 } 13441 13442 function createChild(returnFiber, newChild, lanes) { 13443 if (typeof newChild === 'string' || typeof newChild === 'number') { 13444 // Text nodes don't have keys. If the previous node is implicitly keyed 13445 // we can continue to replace it without aborting even if it is not a text 13446 // node. 13447 var created = createFiberFromText('' + newChild, returnFiber.mode, lanes); 13448 created.return = returnFiber; 13449 return created; 13450 } 13451 13452 if (typeof newChild === 'object' && newChild !== null) { 13453 switch (newChild.$$typeof) { 13454 case REACT_ELEMENT_TYPE: 13455 { 13456 var _created = createFiberFromElement(newChild, returnFiber.mode, lanes); 13457 13458 _created.ref = coerceRef(returnFiber, null, newChild); 13459 _created.return = returnFiber; 13460 return _created; 13461 } 13462 13463 case REACT_PORTAL_TYPE: 13464 { 13465 var _created2 = createFiberFromPortal(newChild, returnFiber.mode, lanes); 13466 13467 _created2.return = returnFiber; 13468 return _created2; 13469 } 13470 } 13471 13472 if (isArray$1(newChild) || getIteratorFn(newChild)) { 13473 var _created3 = createFiberFromFragment(newChild, returnFiber.mode, lanes, null); 13474 13475 _created3.return = returnFiber; 13476 return _created3; 13477 } 13478 13479 throwOnInvalidObjectType(returnFiber, newChild); 13480 } 13481 13482 { 13483 if (typeof newChild === 'function') { 13484 warnOnFunctionType(returnFiber); 13485 } 13486 } 13487 13488 return null; 13489 } 13490 13491 function updateSlot(returnFiber, oldFiber, newChild, lanes) { 13492 // Update the fiber if the keys match, otherwise return null. 13493 var key = oldFiber !== null ? oldFiber.key : null; 13494 13495 if (typeof newChild === 'string' || typeof newChild === 'number') { 13496 // Text nodes don't have keys. If the previous node is implicitly keyed 13497 // we can continue to replace it without aborting even if it is not a text 13498 // node. 13499 if (key !== null) { 13500 return null; 13501 } 13502 13503 return updateTextNode(returnFiber, oldFiber, '' + newChild, lanes); 13504 } 13505 13506 if (typeof newChild === 'object' && newChild !== null) { 13507 switch (newChild.$$typeof) { 13508 case REACT_ELEMENT_TYPE: 13509 { 13510 if (newChild.key === key) { 13511 if (newChild.type === REACT_FRAGMENT_TYPE) { 13512 return updateFragment(returnFiber, oldFiber, newChild.props.children, lanes, key); 13513 } 13514 13515 return updateElement(returnFiber, oldFiber, newChild, lanes); 13516 } else { 13517 return null; 13518 } 13519 } 13520 13521 case REACT_PORTAL_TYPE: 13522 { 13523 if (newChild.key === key) { 13524 return updatePortal(returnFiber, oldFiber, newChild, lanes); 13525 } else { 13526 return null; 13527 } 13528 } 13529 } 13530 13531 if (isArray$1(newChild) || getIteratorFn(newChild)) { 13532 if (key !== null) { 13533 return null; 13534 } 13535 13536 return updateFragment(returnFiber, oldFiber, newChild, lanes, null); 13537 } 13538 13539 throwOnInvalidObjectType(returnFiber, newChild); 13540 } 13541 13542 { 13543 if (typeof newChild === 'function') { 13544 warnOnFunctionType(returnFiber); 13545 } 13546 } 13547 13548 return null; 13549 } 13550 13551 function updateFromMap(existingChildren, returnFiber, newIdx, newChild, lanes) { 13552 if (typeof newChild === 'string' || typeof newChild === 'number') { 13553 // Text nodes don't have keys, so we neither have to check the old nor 13554 // new node for the key. If both are text nodes, they match. 13555 var matchedFiber = existingChildren.get(newIdx) || null; 13556 return updateTextNode(returnFiber, matchedFiber, '' + newChild, lanes); 13557 } 13558 13559 if (typeof newChild === 'object' && newChild !== null) { 13560 switch (newChild.$$typeof) { 13561 case REACT_ELEMENT_TYPE: 13562 { 13563 var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null; 13564 13565 if (newChild.type === REACT_FRAGMENT_TYPE) { 13566 return updateFragment(returnFiber, _matchedFiber, newChild.props.children, lanes, newChild.key); 13567 } 13568 13569 return updateElement(returnFiber, _matchedFiber, newChild, lanes); 13570 } 13571 13572 case REACT_PORTAL_TYPE: 13573 { 13574 var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null; 13575 13576 return updatePortal(returnFiber, _matchedFiber2, newChild, lanes); 13577 } 13578 13579 } 13580 13581 if (isArray$1(newChild) || getIteratorFn(newChild)) { 13582 var _matchedFiber3 = existingChildren.get(newIdx) || null; 13583 13584 return updateFragment(returnFiber, _matchedFiber3, newChild, lanes, null); 13585 } 13586 13587 throwOnInvalidObjectType(returnFiber, newChild); 13588 } 13589 13590 { 13591 if (typeof newChild === 'function') { 13592 warnOnFunctionType(returnFiber); 13593 } 13594 } 13595 13596 return null; 13597 } 13598 /** 13599 * Warns if there is a duplicate or missing key 13600 */ 13601 13602 13603 function warnOnInvalidKey(child, knownKeys, returnFiber) { 13604 { 13605 if (typeof child !== 'object' || child === null) { 13606 return knownKeys; 13607 } 13608 13609 switch (child.$$typeof) { 13610 case REACT_ELEMENT_TYPE: 13611 case REACT_PORTAL_TYPE: 13612 warnForMissingKey(child, returnFiber); 13613 var key = child.key; 13614 13615 if (typeof key !== 'string') { 13616 break; 13617 } 13618 13619 if (knownKeys === null) { 13620 knownKeys = new Set(); 13621 knownKeys.add(key); 13622 break; 13623 } 13624 13625 if (!knownKeys.has(key)) { 13626 knownKeys.add(key); 13627 break; 13628 } 13629 13630 error('Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.', key); 13631 13632 break; 13633 } 13634 } 13635 13636 return knownKeys; 13637 } 13638 13639 function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, lanes) { 13640 // This algorithm can't optimize by searching from both ends since we 13641 // don't have backpointers on fibers. I'm trying to see how far we can get 13642 // with that model. If it ends up not being worth the tradeoffs, we can 13643 // add it later. 13644 // Even with a two ended optimization, we'd want to optimize for the case 13645 // where there are few changes and brute force the comparison instead of 13646 // going for the Map. It'd like to explore hitting that path first in 13647 // forward-only mode and only go for the Map once we notice that we need 13648 // lots of look ahead. This doesn't handle reversal as well as two ended 13649 // search but that's unusual. Besides, for the two ended optimization to 13650 // work on Iterables, we'd need to copy the whole set. 13651 // In this first iteration, we'll just live with hitting the bad case 13652 // (adding everything to a Map) in for every insert/move. 13653 // If you change this code, also update reconcileChildrenIterator() which 13654 // uses the same algorithm. 13655 { 13656 // First, validate keys. 13657 var knownKeys = null; 13658 13659 for (var i = 0; i < newChildren.length; i++) { 13660 var child = newChildren[i]; 13661 knownKeys = warnOnInvalidKey(child, knownKeys, returnFiber); 13662 } 13663 } 13664 13665 var resultingFirstChild = null; 13666 var previousNewFiber = null; 13667 var oldFiber = currentFirstChild; 13668 var lastPlacedIndex = 0; 13669 var newIdx = 0; 13670 var nextOldFiber = null; 13671 13672 for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) { 13673 if (oldFiber.index > newIdx) { 13674 nextOldFiber = oldFiber; 13675 oldFiber = null; 13676 } else { 13677 nextOldFiber = oldFiber.sibling; 13678 } 13679 13680 var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], lanes); 13681 13682 if (newFiber === null) { 13683 // TODO: This breaks on empty slots like null children. That's 13684 // unfortunate because it triggers the slow path all the time. We need 13685 // a better way to communicate whether this was a miss or null, 13686 // boolean, undefined, etc. 13687 if (oldFiber === null) { 13688 oldFiber = nextOldFiber; 13689 } 13690 13691 break; 13692 } 13693 13694 if (shouldTrackSideEffects) { 13695 if (oldFiber && newFiber.alternate === null) { 13696 // We matched the slot, but we didn't reuse the existing fiber, so we 13697 // need to delete the existing child. 13698 deleteChild(returnFiber, oldFiber); 13699 } 13700 } 13701 13702 lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx); 13703 13704 if (previousNewFiber === null) { 13705 // TODO: Move out of the loop. This only happens for the first run. 13706 resultingFirstChild = newFiber; 13707 } else { 13708 // TODO: Defer siblings if we're not at the right index for this slot. 13709 // I.e. if we had null values before, then we want to defer this 13710 // for each null value. However, we also don't want to call updateSlot 13711 // with the previous one. 13712 previousNewFiber.sibling = newFiber; 13713 } 13714 13715 previousNewFiber = newFiber; 13716 oldFiber = nextOldFiber; 13717 } 13718 13719 if (newIdx === newChildren.length) { 13720 // We've reached the end of the new children. We can delete the rest. 13721 deleteRemainingChildren(returnFiber, oldFiber); 13722 return resultingFirstChild; 13723 } 13724 13725 if (oldFiber === null) { 13726 // If we don't have any more existing children we can choose a fast path 13727 // since the rest will all be insertions. 13728 for (; newIdx < newChildren.length; newIdx++) { 13729 var _newFiber = createChild(returnFiber, newChildren[newIdx], lanes); 13730 13731 if (_newFiber === null) { 13732 continue; 13733 } 13734 13735 lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx); 13736 13737 if (previousNewFiber === null) { 13738 // TODO: Move out of the loop. This only happens for the first run. 13739 resultingFirstChild = _newFiber; 13740 } else { 13741 previousNewFiber.sibling = _newFiber; 13742 } 13743 13744 previousNewFiber = _newFiber; 13745 } 13746 13747 return resultingFirstChild; 13748 } // Add all children to a key map for quick lookups. 13749 13750 13751 var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves. 13752 13753 for (; newIdx < newChildren.length; newIdx++) { 13754 var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], lanes); 13755 13756 if (_newFiber2 !== null) { 13757 if (shouldTrackSideEffects) { 13758 if (_newFiber2.alternate !== null) { 13759 // The new fiber is a work in progress, but if there exists a 13760 // current, that means that we reused the fiber. We need to delete 13761 // it from the child list so that we don't add it to the deletion 13762 // list. 13763 existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key); 13764 } 13765 } 13766 13767 lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx); 13768 13769 if (previousNewFiber === null) { 13770 resultingFirstChild = _newFiber2; 13771 } else { 13772 previousNewFiber.sibling = _newFiber2; 13773 } 13774 13775 previousNewFiber = _newFiber2; 13776 } 13777 } 13778 13779 if (shouldTrackSideEffects) { 13780 // Any existing children that weren't consumed above were deleted. We need 13781 // to add them to the deletion list. 13782 existingChildren.forEach(function (child) { 13783 return deleteChild(returnFiber, child); 13784 }); 13785 } 13786 13787 return resultingFirstChild; 13788 } 13789 13790 function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, lanes) { 13791 // This is the same implementation as reconcileChildrenArray(), 13792 // but using the iterator instead. 13793 var iteratorFn = getIteratorFn(newChildrenIterable); 13794 13795 if (!(typeof iteratorFn === 'function')) { 13796 { 13797 throw Error( "An object is not an iterable. This error is likely caused by a bug in React. Please file an issue." ); 13798 } 13799 } 13800 13801 { 13802 // We don't support rendering Generators because it's a mutation. 13803 // See https://github.com/facebook/react/issues/12995 13804 if (typeof Symbol === 'function' && // $FlowFixMe Flow doesn't know about toStringTag 13805 newChildrenIterable[Symbol.toStringTag] === 'Generator') { 13806 if (!didWarnAboutGenerators) { 13807 error('Using Generators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. Keep in mind ' + 'you might need to polyfill these features for older browsers.'); 13808 } 13809 13810 didWarnAboutGenerators = true; 13811 } // Warn about using Maps as children 13812 13813 13814 if (newChildrenIterable.entries === iteratorFn) { 13815 if (!didWarnAboutMaps) { 13816 error('Using Maps as children is not supported. ' + 'Use an array of keyed ReactElements instead.'); 13817 } 13818 13819 didWarnAboutMaps = true; 13820 } // First, validate keys. 13821 // We'll get a different iterator later for the main pass. 13822 13823 13824 var _newChildren = iteratorFn.call(newChildrenIterable); 13825 13826 if (_newChildren) { 13827 var knownKeys = null; 13828 13829 var _step = _newChildren.next(); 13830 13831 for (; !_step.done; _step = _newChildren.next()) { 13832 var child = _step.value; 13833 knownKeys = warnOnInvalidKey(child, knownKeys, returnFiber); 13834 } 13835 } 13836 } 13837 13838 var newChildren = iteratorFn.call(newChildrenIterable); 13839 13840 if (!(newChildren != null)) { 13841 { 13842 throw Error( "An iterable object provided no iterator." ); 13843 } 13844 } 13845 13846 var resultingFirstChild = null; 13847 var previousNewFiber = null; 13848 var oldFiber = currentFirstChild; 13849 var lastPlacedIndex = 0; 13850 var newIdx = 0; 13851 var nextOldFiber = null; 13852 var step = newChildren.next(); 13853 13854 for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) { 13855 if (oldFiber.index > newIdx) { 13856 nextOldFiber = oldFiber; 13857 oldFiber = null; 13858 } else { 13859 nextOldFiber = oldFiber.sibling; 13860 } 13861 13862 var newFiber = updateSlot(returnFiber, oldFiber, step.value, lanes); 13863 13864 if (newFiber === null) { 13865 // TODO: This breaks on empty slots like null children. That's 13866 // unfortunate because it triggers the slow path all the time. We need 13867 // a better way to communicate whether this was a miss or null, 13868 // boolean, undefined, etc. 13869 if (oldFiber === null) { 13870 oldFiber = nextOldFiber; 13871 } 13872 13873 break; 13874 } 13875 13876 if (shouldTrackSideEffects) { 13877 if (oldFiber && newFiber.alternate === null) { 13878 // We matched the slot, but we didn't reuse the existing fiber, so we 13879 // need to delete the existing child. 13880 deleteChild(returnFiber, oldFiber); 13881 } 13882 } 13883 13884 lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx); 13885 13886 if (previousNewFiber === null) { 13887 // TODO: Move out of the loop. This only happens for the first run. 13888 resultingFirstChild = newFiber; 13889 } else { 13890 // TODO: Defer siblings if we're not at the right index for this slot. 13891 // I.e. if we had null values before, then we want to defer this 13892 // for each null value. However, we also don't want to call updateSlot 13893 // with the previous one. 13894 previousNewFiber.sibling = newFiber; 13895 } 13896 13897 previousNewFiber = newFiber; 13898 oldFiber = nextOldFiber; 13899 } 13900 13901 if (step.done) { 13902 // We've reached the end of the new children. We can delete the rest. 13903 deleteRemainingChildren(returnFiber, oldFiber); 13904 return resultingFirstChild; 13905 } 13906 13907 if (oldFiber === null) { 13908 // If we don't have any more existing children we can choose a fast path 13909 // since the rest will all be insertions. 13910 for (; !step.done; newIdx++, step = newChildren.next()) { 13911 var _newFiber3 = createChild(returnFiber, step.value, lanes); 13912 13913 if (_newFiber3 === null) { 13914 continue; 13915 } 13916 13917 lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx); 13918 13919 if (previousNewFiber === null) { 13920 // TODO: Move out of the loop. This only happens for the first run. 13921 resultingFirstChild = _newFiber3; 13922 } else { 13923 previousNewFiber.sibling = _newFiber3; 13924 } 13925 13926 previousNewFiber = _newFiber3; 13927 } 13928 13929 return resultingFirstChild; 13930 } // Add all children to a key map for quick lookups. 13931 13932 13933 var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves. 13934 13935 for (; !step.done; newIdx++, step = newChildren.next()) { 13936 var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, lanes); 13937 13938 if (_newFiber4 !== null) { 13939 if (shouldTrackSideEffects) { 13940 if (_newFiber4.alternate !== null) { 13941 // The new fiber is a work in progress, but if there exists a 13942 // current, that means that we reused the fiber. We need to delete 13943 // it from the child list so that we don't add it to the deletion 13944 // list. 13945 existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key); 13946 } 13947 } 13948 13949 lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx); 13950 13951 if (previousNewFiber === null) { 13952 resultingFirstChild = _newFiber4; 13953 } else { 13954 previousNewFiber.sibling = _newFiber4; 13955 } 13956 13957 previousNewFiber = _newFiber4; 13958 } 13959 } 13960 13961 if (shouldTrackSideEffects) { 13962 // Any existing children that weren't consumed above were deleted. We need 13963 // to add them to the deletion list. 13964 existingChildren.forEach(function (child) { 13965 return deleteChild(returnFiber, child); 13966 }); 13967 } 13968 13969 return resultingFirstChild; 13970 } 13971 13972 function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, lanes) { 13973 // There's no need to check for keys on text nodes since we don't have a 13974 // way to define them. 13975 if (currentFirstChild !== null && currentFirstChild.tag === HostText) { 13976 // We already have an existing node so let's just update it and delete 13977 // the rest. 13978 deleteRemainingChildren(returnFiber, currentFirstChild.sibling); 13979 var existing = useFiber(currentFirstChild, textContent); 13980 existing.return = returnFiber; 13981 return existing; 13982 } // The existing first child is not a text node so we need to create one 13983 // and delete the existing ones. 13984 13985 13986 deleteRemainingChildren(returnFiber, currentFirstChild); 13987 var created = createFiberFromText(textContent, returnFiber.mode, lanes); 13988 created.return = returnFiber; 13989 return created; 13990 } 13991 13992 function reconcileSingleElement(returnFiber, currentFirstChild, element, lanes) { 13993 var key = element.key; 13994 var child = currentFirstChild; 13995 13996 while (child !== null) { 13997 // TODO: If key === null and child.key === null, then this only applies to 13998 // the first item in the list. 13999 if (child.key === key) { 14000 switch (child.tag) { 14001 case Fragment: 14002 { 14003 if (element.type === REACT_FRAGMENT_TYPE) { 14004 deleteRemainingChildren(returnFiber, child.sibling); 14005 var existing = useFiber(child, element.props.children); 14006 existing.return = returnFiber; 14007 14008 { 14009 existing._debugSource = element._source; 14010 existing._debugOwner = element._owner; 14011 } 14012 14013 return existing; 14014 } 14015 14016 break; 14017 } 14018 14019 case Block: 14020 14021 // We intentionally fallthrough here if enableBlocksAPI is not on. 14022 // eslint-disable-next-lined no-fallthrough 14023 14024 default: 14025 { 14026 if (child.elementType === element.type || ( // Keep this check inline so it only runs on the false path: 14027 isCompatibleFamilyForHotReloading(child, element) )) { 14028 deleteRemainingChildren(returnFiber, child.sibling); 14029 14030 var _existing3 = useFiber(child, element.props); 14031 14032 _existing3.ref = coerceRef(returnFiber, child, element); 14033 _existing3.return = returnFiber; 14034 14035 { 14036 _existing3._debugSource = element._source; 14037 _existing3._debugOwner = element._owner; 14038 } 14039 14040 return _existing3; 14041 } 14042 14043 break; 14044 } 14045 } // Didn't match. 14046 14047 14048 deleteRemainingChildren(returnFiber, child); 14049 break; 14050 } else { 14051 deleteChild(returnFiber, child); 14052 } 14053 14054 child = child.sibling; 14055 } 14056 14057 if (element.type === REACT_FRAGMENT_TYPE) { 14058 var created = createFiberFromFragment(element.props.children, returnFiber.mode, lanes, element.key); 14059 created.return = returnFiber; 14060 return created; 14061 } else { 14062 var _created4 = createFiberFromElement(element, returnFiber.mode, lanes); 14063 14064 _created4.ref = coerceRef(returnFiber, currentFirstChild, element); 14065 _created4.return = returnFiber; 14066 return _created4; 14067 } 14068 } 14069 14070 function reconcileSinglePortal(returnFiber, currentFirstChild, portal, lanes) { 14071 var key = portal.key; 14072 var child = currentFirstChild; 14073 14074 while (child !== null) { 14075 // TODO: If key === null and child.key === null, then this only applies to 14076 // the first item in the list. 14077 if (child.key === key) { 14078 if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) { 14079 deleteRemainingChildren(returnFiber, child.sibling); 14080 var existing = useFiber(child, portal.children || []); 14081 existing.return = returnFiber; 14082 return existing; 14083 } else { 14084 deleteRemainingChildren(returnFiber, child); 14085 break; 14086 } 14087 } else { 14088 deleteChild(returnFiber, child); 14089 } 14090 14091 child = child.sibling; 14092 } 14093 14094 var created = createFiberFromPortal(portal, returnFiber.mode, lanes); 14095 created.return = returnFiber; 14096 return created; 14097 } // This API will tag the children with the side-effect of the reconciliation 14098 // itself. They will be added to the side-effect list as we pass through the 14099 // children and the parent. 14100 14101 14102 function reconcileChildFibers(returnFiber, currentFirstChild, newChild, lanes) { 14103 // This function is not recursive. 14104 // If the top level item is an array, we treat it as a set of children, 14105 // not as a fragment. Nested arrays on the other hand will be treated as 14106 // fragment nodes. Recursion happens at the normal flow. 14107 // Handle top level unkeyed fragments as if they were arrays. 14108 // This leads to an ambiguity between <>{[...]}</> and <>...</>. 14109 // We treat the ambiguous cases above the same. 14110 var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null; 14111 14112 if (isUnkeyedTopLevelFragment) { 14113 newChild = newChild.props.children; 14114 } // Handle object types 14115 14116 14117 var isObject = typeof newChild === 'object' && newChild !== null; 14118 14119 if (isObject) { 14120 switch (newChild.$$typeof) { 14121 case REACT_ELEMENT_TYPE: 14122 return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, lanes)); 14123 14124 case REACT_PORTAL_TYPE: 14125 return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, lanes)); 14126 14127 } 14128 } 14129 14130 if (typeof newChild === 'string' || typeof newChild === 'number') { 14131 return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, lanes)); 14132 } 14133 14134 if (isArray$1(newChild)) { 14135 return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, lanes); 14136 } 14137 14138 if (getIteratorFn(newChild)) { 14139 return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, lanes); 14140 } 14141 14142 if (isObject) { 14143 throwOnInvalidObjectType(returnFiber, newChild); 14144 } 14145 14146 { 14147 if (typeof newChild === 'function') { 14148 warnOnFunctionType(returnFiber); 14149 } 14150 } 14151 14152 if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) { 14153 // If the new child is undefined, and the return fiber is a composite 14154 // component, throw an error. If Fiber return types are disabled, 14155 // we already threw above. 14156 switch (returnFiber.tag) { 14157 case ClassComponent: 14158 { 14159 { 14160 var instance = returnFiber.stateNode; 14161 14162 if (instance.render._isMockFunction) { 14163 // We allow auto-mocks to proceed as if they're returning null. 14164 break; 14165 } 14166 } 14167 } 14168 // Intentionally fall through to the next case, which handles both 14169 // functions and classes 14170 // eslint-disable-next-lined no-fallthrough 14171 14172 case Block: 14173 case FunctionComponent: 14174 case ForwardRef: 14175 case SimpleMemoComponent: 14176 { 14177 { 14178 { 14179 throw Error( (getComponentName(returnFiber.type) || 'Component') + "(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null." ); 14180 } 14181 } 14182 } 14183 } 14184 } // Remaining cases are all treated as empty. 14185 14186 14187 return deleteRemainingChildren(returnFiber, currentFirstChild); 14188 } 14189 14190 return reconcileChildFibers; 14191} 14192 14193var reconcileChildFibers = ChildReconciler(true); 14194var mountChildFibers = ChildReconciler(false); 14195function cloneChildFibers(current, workInProgress) { 14196 if (!(current === null || workInProgress.child === current.child)) { 14197 { 14198 throw Error( "Resuming work not yet implemented." ); 14199 } 14200 } 14201 14202 if (workInProgress.child === null) { 14203 return; 14204 } 14205 14206 var currentChild = workInProgress.child; 14207 var newChild = createWorkInProgress(currentChild, currentChild.pendingProps); 14208 workInProgress.child = newChild; 14209 newChild.return = workInProgress; 14210 14211 while (currentChild.sibling !== null) { 14212 currentChild = currentChild.sibling; 14213 newChild = newChild.sibling = createWorkInProgress(currentChild, currentChild.pendingProps); 14214 newChild.return = workInProgress; 14215 } 14216 14217 newChild.sibling = null; 14218} // Reset a workInProgress child set to prepare it for a second pass. 14219 14220function resetChildFibers(workInProgress, lanes) { 14221 var child = workInProgress.child; 14222 14223 while (child !== null) { 14224 resetWorkInProgress(child, lanes); 14225 child = child.sibling; 14226 } 14227} 14228 14229var NO_CONTEXT = {}; 14230var contextStackCursor$1 = createCursor(NO_CONTEXT); 14231var contextFiberStackCursor = createCursor(NO_CONTEXT); 14232var rootInstanceStackCursor = createCursor(NO_CONTEXT); 14233 14234function requiredContext(c) { 14235 if (!(c !== NO_CONTEXT)) { 14236 { 14237 throw Error( "Expected host context to exist. This error is likely caused by a bug in React. Please file an issue." ); 14238 } 14239 } 14240 14241 return c; 14242} 14243 14244function getRootHostContainer() { 14245 var rootInstance = requiredContext(rootInstanceStackCursor.current); 14246 return rootInstance; 14247} 14248 14249function pushHostContainer(fiber, nextRootInstance) { 14250 // Push current root instance onto the stack; 14251 // This allows us to reset root when portals are popped. 14252 push(rootInstanceStackCursor, nextRootInstance, fiber); // Track the context and the Fiber that provided it. 14253 // This enables us to pop only Fibers that provide unique contexts. 14254 14255 push(contextFiberStackCursor, fiber, fiber); // Finally, we need to push the host context to the stack. 14256 // However, we can't just call getRootHostContext() and push it because 14257 // we'd have a different number of entries on the stack depending on 14258 // whether getRootHostContext() throws somewhere in renderer code or not. 14259 // So we push an empty value first. This lets us safely unwind on errors. 14260 14261 push(contextStackCursor$1, NO_CONTEXT, fiber); 14262 var nextRootContext = getRootHostContext(nextRootInstance); // Now that we know this function doesn't throw, replace it. 14263 14264 pop(contextStackCursor$1, fiber); 14265 push(contextStackCursor$1, nextRootContext, fiber); 14266} 14267 14268function popHostContainer(fiber) { 14269 pop(contextStackCursor$1, fiber); 14270 pop(contextFiberStackCursor, fiber); 14271 pop(rootInstanceStackCursor, fiber); 14272} 14273 14274function getHostContext() { 14275 var context = requiredContext(contextStackCursor$1.current); 14276 return context; 14277} 14278 14279function pushHostContext(fiber) { 14280 var rootInstance = requiredContext(rootInstanceStackCursor.current); 14281 var context = requiredContext(contextStackCursor$1.current); 14282 var nextContext = getChildHostContext(context, fiber.type); // Don't push this Fiber's context unless it's unique. 14283 14284 if (context === nextContext) { 14285 return; 14286 } // Track the context and the Fiber that provided it. 14287 // This enables us to pop only Fibers that provide unique contexts. 14288 14289 14290 push(contextFiberStackCursor, fiber, fiber); 14291 push(contextStackCursor$1, nextContext, fiber); 14292} 14293 14294function popHostContext(fiber) { 14295 // Do not pop unless this Fiber provided the current context. 14296 // pushHostContext() only pushes Fibers that provide unique contexts. 14297 if (contextFiberStackCursor.current !== fiber) { 14298 return; 14299 } 14300 14301 pop(contextStackCursor$1, fiber); 14302 pop(contextFiberStackCursor, fiber); 14303} 14304 14305var DefaultSuspenseContext = 0; // The Suspense Context is split into two parts. The lower bits is 14306// inherited deeply down the subtree. The upper bits only affect 14307// this immediate suspense boundary and gets reset each new 14308// boundary or suspense list. 14309 14310var SubtreeSuspenseContextMask = 1; // Subtree Flags: 14311// InvisibleParentSuspenseContext indicates that one of our parent Suspense 14312// boundaries is not currently showing visible main content. 14313// Either because it is already showing a fallback or is not mounted at all. 14314// We can use this to determine if it is desirable to trigger a fallback at 14315// the parent. If not, then we might need to trigger undesirable boundaries 14316// and/or suspend the commit to avoid hiding the parent content. 14317 14318var InvisibleParentSuspenseContext = 1; // Shallow Flags: 14319// ForceSuspenseFallback can be used by SuspenseList to force newly added 14320// items into their fallback state during one of the render passes. 14321 14322var ForceSuspenseFallback = 2; 14323var suspenseStackCursor = createCursor(DefaultSuspenseContext); 14324function hasSuspenseContext(parentContext, flag) { 14325 return (parentContext & flag) !== 0; 14326} 14327function setDefaultShallowSuspenseContext(parentContext) { 14328 return parentContext & SubtreeSuspenseContextMask; 14329} 14330function setShallowSuspenseContext(parentContext, shallowContext) { 14331 return parentContext & SubtreeSuspenseContextMask | shallowContext; 14332} 14333function addSubtreeSuspenseContext(parentContext, subtreeContext) { 14334 return parentContext | subtreeContext; 14335} 14336function pushSuspenseContext(fiber, newContext) { 14337 push(suspenseStackCursor, newContext, fiber); 14338} 14339function popSuspenseContext(fiber) { 14340 pop(suspenseStackCursor, fiber); 14341} 14342 14343function shouldCaptureSuspense(workInProgress, hasInvisibleParent) { 14344 // If it was the primary children that just suspended, capture and render the 14345 // fallback. Otherwise, don't capture and bubble to the next boundary. 14346 var nextState = workInProgress.memoizedState; 14347 14348 if (nextState !== null) { 14349 if (nextState.dehydrated !== null) { 14350 // A dehydrated boundary always captures. 14351 return true; 14352 } 14353 14354 return false; 14355 } 14356 14357 var props = workInProgress.memoizedProps; // In order to capture, the Suspense component must have a fallback prop. 14358 14359 if (props.fallback === undefined) { 14360 return false; 14361 } // Regular boundaries always capture. 14362 14363 14364 if (props.unstable_avoidThisFallback !== true) { 14365 return true; 14366 } // If it's a boundary we should avoid, then we prefer to bubble up to the 14367 // parent boundary if it is currently invisible. 14368 14369 14370 if (hasInvisibleParent) { 14371 return false; 14372 } // If the parent is not able to handle it, we must handle it. 14373 14374 14375 return true; 14376} 14377function findFirstSuspended(row) { 14378 var node = row; 14379 14380 while (node !== null) { 14381 if (node.tag === SuspenseComponent) { 14382 var state = node.memoizedState; 14383 14384 if (state !== null) { 14385 var dehydrated = state.dehydrated; 14386 14387 if (dehydrated === null || isSuspenseInstancePending(dehydrated) || isSuspenseInstanceFallback(dehydrated)) { 14388 return node; 14389 } 14390 } 14391 } else if (node.tag === SuspenseListComponent && // revealOrder undefined can't be trusted because it don't 14392 // keep track of whether it suspended or not. 14393 node.memoizedProps.revealOrder !== undefined) { 14394 var didSuspend = (node.flags & DidCapture) !== NoFlags; 14395 14396 if (didSuspend) { 14397 return node; 14398 } 14399 } else if (node.child !== null) { 14400 node.child.return = node; 14401 node = node.child; 14402 continue; 14403 } 14404 14405 if (node === row) { 14406 return null; 14407 } 14408 14409 while (node.sibling === null) { 14410 if (node.return === null || node.return === row) { 14411 return null; 14412 } 14413 14414 node = node.return; 14415 } 14416 14417 node.sibling.return = node.return; 14418 node = node.sibling; 14419 } 14420 14421 return null; 14422} 14423 14424var NoFlags$1 = 14425/* */ 144260; // Represents whether effect should fire. 14427 14428var HasEffect = 14429/* */ 144301; // Represents the phase in which the effect (not the clean-up) fires. 14431 14432var Layout = 14433/* */ 144342; 14435var Passive$1 = 14436/* */ 144374; 14438 14439// This may have been an insertion or a hydration. 14440 14441var hydrationParentFiber = null; 14442var nextHydratableInstance = null; 14443var isHydrating = false; 14444 14445function enterHydrationState(fiber) { 14446 14447 var parentInstance = fiber.stateNode.containerInfo; 14448 nextHydratableInstance = getFirstHydratableChild(parentInstance); 14449 hydrationParentFiber = fiber; 14450 isHydrating = true; 14451 return true; 14452} 14453 14454function deleteHydratableInstance(returnFiber, instance) { 14455 { 14456 switch (returnFiber.tag) { 14457 case HostRoot: 14458 didNotHydrateContainerInstance(returnFiber.stateNode.containerInfo, instance); 14459 break; 14460 14461 case HostComponent: 14462 didNotHydrateInstance(returnFiber.type, returnFiber.memoizedProps, returnFiber.stateNode, instance); 14463 break; 14464 } 14465 } 14466 14467 var childToDelete = createFiberFromHostInstanceForDeletion(); 14468 childToDelete.stateNode = instance; 14469 childToDelete.return = returnFiber; 14470 childToDelete.flags = Deletion; // This might seem like it belongs on progressedFirstDeletion. However, 14471 // these children are not part of the reconciliation list of children. 14472 // Even if we abort and rereconcile the children, that will try to hydrate 14473 // again and the nodes are still in the host tree so these will be 14474 // recreated. 14475 14476 if (returnFiber.lastEffect !== null) { 14477 returnFiber.lastEffect.nextEffect = childToDelete; 14478 returnFiber.lastEffect = childToDelete; 14479 } else { 14480 returnFiber.firstEffect = returnFiber.lastEffect = childToDelete; 14481 } 14482} 14483 14484function insertNonHydratedInstance(returnFiber, fiber) { 14485 fiber.flags = fiber.flags & ~Hydrating | Placement; 14486 14487 { 14488 switch (returnFiber.tag) { 14489 case HostRoot: 14490 { 14491 var parentContainer = returnFiber.stateNode.containerInfo; 14492 14493 switch (fiber.tag) { 14494 case HostComponent: 14495 var type = fiber.type; 14496 var props = fiber.pendingProps; 14497 didNotFindHydratableContainerInstance(parentContainer, type); 14498 break; 14499 14500 case HostText: 14501 var text = fiber.pendingProps; 14502 didNotFindHydratableContainerTextInstance(parentContainer, text); 14503 break; 14504 } 14505 14506 break; 14507 } 14508 14509 case HostComponent: 14510 { 14511 var parentType = returnFiber.type; 14512 var parentProps = returnFiber.memoizedProps; 14513 var parentInstance = returnFiber.stateNode; 14514 14515 switch (fiber.tag) { 14516 case HostComponent: 14517 var _type = fiber.type; 14518 var _props = fiber.pendingProps; 14519 didNotFindHydratableInstance(parentType, parentProps, parentInstance, _type); 14520 break; 14521 14522 case HostText: 14523 var _text = fiber.pendingProps; 14524 didNotFindHydratableTextInstance(parentType, parentProps, parentInstance, _text); 14525 break; 14526 14527 case SuspenseComponent: 14528 didNotFindHydratableSuspenseInstance(parentType, parentProps); 14529 break; 14530 } 14531 14532 break; 14533 } 14534 14535 default: 14536 return; 14537 } 14538 } 14539} 14540 14541function tryHydrate(fiber, nextInstance) { 14542 switch (fiber.tag) { 14543 case HostComponent: 14544 { 14545 var type = fiber.type; 14546 var props = fiber.pendingProps; 14547 var instance = canHydrateInstance(nextInstance, type); 14548 14549 if (instance !== null) { 14550 fiber.stateNode = instance; 14551 return true; 14552 } 14553 14554 return false; 14555 } 14556 14557 case HostText: 14558 { 14559 var text = fiber.pendingProps; 14560 var textInstance = canHydrateTextInstance(nextInstance, text); 14561 14562 if (textInstance !== null) { 14563 fiber.stateNode = textInstance; 14564 return true; 14565 } 14566 14567 return false; 14568 } 14569 14570 case SuspenseComponent: 14571 { 14572 14573 return false; 14574 } 14575 14576 default: 14577 return false; 14578 } 14579} 14580 14581function tryToClaimNextHydratableInstance(fiber) { 14582 if (!isHydrating) { 14583 return; 14584 } 14585 14586 var nextInstance = nextHydratableInstance; 14587 14588 if (!nextInstance) { 14589 // Nothing to hydrate. Make it an insertion. 14590 insertNonHydratedInstance(hydrationParentFiber, fiber); 14591 isHydrating = false; 14592 hydrationParentFiber = fiber; 14593 return; 14594 } 14595 14596 var firstAttemptedInstance = nextInstance; 14597 14598 if (!tryHydrate(fiber, nextInstance)) { 14599 // If we can't hydrate this instance let's try the next one. 14600 // We use this as a heuristic. It's based on intuition and not data so it 14601 // might be flawed or unnecessary. 14602 nextInstance = getNextHydratableSibling(firstAttemptedInstance); 14603 14604 if (!nextInstance || !tryHydrate(fiber, nextInstance)) { 14605 // Nothing to hydrate. Make it an insertion. 14606 insertNonHydratedInstance(hydrationParentFiber, fiber); 14607 isHydrating = false; 14608 hydrationParentFiber = fiber; 14609 return; 14610 } // We matched the next one, we'll now assume that the first one was 14611 // superfluous and we'll delete it. Since we can't eagerly delete it 14612 // we'll have to schedule a deletion. To do that, this node needs a dummy 14613 // fiber associated with it. 14614 14615 14616 deleteHydratableInstance(hydrationParentFiber, firstAttemptedInstance); 14617 } 14618 14619 hydrationParentFiber = fiber; 14620 nextHydratableInstance = getFirstHydratableChild(nextInstance); 14621} 14622 14623function prepareToHydrateHostInstance(fiber, rootContainerInstance, hostContext) { 14624 14625 var instance = fiber.stateNode; 14626 var updatePayload = hydrateInstance(instance, fiber.type, fiber.memoizedProps, rootContainerInstance, hostContext, fiber); // TODO: Type this specific to this type of component. 14627 14628 fiber.updateQueue = updatePayload; // If the update payload indicates that there is a change or if there 14629 // is a new ref we mark this as an update. 14630 14631 if (updatePayload !== null) { 14632 return true; 14633 } 14634 14635 return false; 14636} 14637 14638function prepareToHydrateHostTextInstance(fiber) { 14639 14640 var textInstance = fiber.stateNode; 14641 var textContent = fiber.memoizedProps; 14642 var shouldUpdate = hydrateTextInstance(textInstance, textContent, fiber); 14643 14644 { 14645 if (shouldUpdate) { 14646 // We assume that prepareToHydrateHostTextInstance is called in a context where the 14647 // hydration parent is the parent host component of this host text. 14648 var returnFiber = hydrationParentFiber; 14649 14650 if (returnFiber !== null) { 14651 switch (returnFiber.tag) { 14652 case HostRoot: 14653 { 14654 var parentContainer = returnFiber.stateNode.containerInfo; 14655 didNotMatchHydratedContainerTextInstance(parentContainer, textInstance, textContent); 14656 break; 14657 } 14658 14659 case HostComponent: 14660 { 14661 var parentType = returnFiber.type; 14662 var parentProps = returnFiber.memoizedProps; 14663 var parentInstance = returnFiber.stateNode; 14664 didNotMatchHydratedTextInstance(parentType, parentProps, parentInstance, textInstance, textContent); 14665 break; 14666 } 14667 } 14668 } 14669 } 14670 } 14671 14672 return shouldUpdate; 14673} 14674 14675function skipPastDehydratedSuspenseInstance(fiber) { 14676 14677 var suspenseState = fiber.memoizedState; 14678 var suspenseInstance = suspenseState !== null ? suspenseState.dehydrated : null; 14679 14680 if (!suspenseInstance) { 14681 { 14682 throw Error( "Expected to have a hydrated suspense instance. This error is likely caused by a bug in React. Please file an issue." ); 14683 } 14684 } 14685 14686 return getNextHydratableInstanceAfterSuspenseInstance(suspenseInstance); 14687} 14688 14689function popToNextHostParent(fiber) { 14690 var parent = fiber.return; 14691 14692 while (parent !== null && parent.tag !== HostComponent && parent.tag !== HostRoot && parent.tag !== SuspenseComponent) { 14693 parent = parent.return; 14694 } 14695 14696 hydrationParentFiber = parent; 14697} 14698 14699function popHydrationState(fiber) { 14700 14701 if (fiber !== hydrationParentFiber) { 14702 // We're deeper than the current hydration context, inside an inserted 14703 // tree. 14704 return false; 14705 } 14706 14707 if (!isHydrating) { 14708 // If we're not currently hydrating but we're in a hydration context, then 14709 // we were an insertion and now need to pop up reenter hydration of our 14710 // siblings. 14711 popToNextHostParent(fiber); 14712 isHydrating = true; 14713 return false; 14714 } 14715 14716 var type = fiber.type; // If we have any remaining hydratable nodes, we need to delete them now. 14717 // We only do this deeper than head and body since they tend to have random 14718 // other nodes in them. We also ignore components with pure text content in 14719 // side of them. 14720 // TODO: Better heuristic. 14721 14722 if (fiber.tag !== HostComponent || type !== 'head' && type !== 'body' && !shouldSetTextContent(type, fiber.memoizedProps)) { 14723 var nextInstance = nextHydratableInstance; 14724 14725 while (nextInstance) { 14726 deleteHydratableInstance(fiber, nextInstance); 14727 nextInstance = getNextHydratableSibling(nextInstance); 14728 } 14729 } 14730 14731 popToNextHostParent(fiber); 14732 14733 if (fiber.tag === SuspenseComponent) { 14734 nextHydratableInstance = skipPastDehydratedSuspenseInstance(fiber); 14735 } else { 14736 nextHydratableInstance = hydrationParentFiber ? getNextHydratableSibling(fiber.stateNode) : null; 14737 } 14738 14739 return true; 14740} 14741 14742function resetHydrationState() { 14743 14744 hydrationParentFiber = null; 14745 nextHydratableInstance = null; 14746 isHydrating = false; 14747} 14748 14749function getIsHydrating() { 14750 return isHydrating; 14751} 14752 14753// and should be reset before starting a new render. 14754// This tracks which mutable sources need to be reset after a render. 14755 14756var workInProgressSources = []; 14757var rendererSigil$1; 14758 14759{ 14760 // Used to detect multiple renderers using the same mutable source. 14761 rendererSigil$1 = {}; 14762} 14763 14764function markSourceAsDirty(mutableSource) { 14765 workInProgressSources.push(mutableSource); 14766} 14767function resetWorkInProgressVersions() { 14768 for (var i = 0; i < workInProgressSources.length; i++) { 14769 var mutableSource = workInProgressSources[i]; 14770 14771 { 14772 mutableSource._workInProgressVersionPrimary = null; 14773 } 14774 } 14775 14776 workInProgressSources.length = 0; 14777} 14778function getWorkInProgressVersion(mutableSource) { 14779 { 14780 return mutableSource._workInProgressVersionPrimary; 14781 } 14782} 14783function setWorkInProgressVersion(mutableSource, version) { 14784 { 14785 mutableSource._workInProgressVersionPrimary = version; 14786 } 14787 14788 workInProgressSources.push(mutableSource); 14789} 14790function warnAboutMultipleRenderersDEV(mutableSource) { 14791 { 14792 { 14793 if (mutableSource._currentPrimaryRenderer == null) { 14794 mutableSource._currentPrimaryRenderer = rendererSigil$1; 14795 } else if (mutableSource._currentPrimaryRenderer !== rendererSigil$1) { 14796 error('Detected multiple renderers concurrently rendering the ' + 'same mutable source. This is currently unsupported.'); 14797 } 14798 } 14799 } 14800} // Eager reads the version of a mutable source and stores it on the root. 14801 14802var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher, 14803 ReactCurrentBatchConfig$1 = ReactSharedInternals.ReactCurrentBatchConfig; 14804var didWarnAboutMismatchedHooksForComponent; 14805var didWarnAboutUseOpaqueIdentifier; 14806 14807{ 14808 didWarnAboutUseOpaqueIdentifier = {}; 14809 didWarnAboutMismatchedHooksForComponent = new Set(); 14810} 14811 14812// These are set right before calling the component. 14813var renderLanes = NoLanes; // The work-in-progress fiber. I've named it differently to distinguish it from 14814// the work-in-progress hook. 14815 14816var currentlyRenderingFiber$1 = null; // Hooks are stored as a linked list on the fiber's memoizedState field. The 14817// current hook list is the list that belongs to the current fiber. The 14818// work-in-progress hook list is a new list that will be added to the 14819// work-in-progress fiber. 14820 14821var currentHook = null; 14822var workInProgressHook = null; // Whether an update was scheduled at any point during the render phase. This 14823// does not get reset if we do another render pass; only when we're completely 14824// finished evaluating this component. This is an optimization so we know 14825// whether we need to clear render phase updates after a throw. 14826 14827var didScheduleRenderPhaseUpdate = false; // Where an update was scheduled only during the current render pass. This 14828// gets reset after each attempt. 14829// TODO: Maybe there's some way to consolidate this with 14830// `didScheduleRenderPhaseUpdate`. Or with `numberOfReRenders`. 14831 14832var didScheduleRenderPhaseUpdateDuringThisPass = false; 14833var RE_RENDER_LIMIT = 25; // In DEV, this is the name of the currently executing primitive hook 14834 14835var currentHookNameInDev = null; // In DEV, this list ensures that hooks are called in the same order between renders. 14836// The list stores the order of hooks used during the initial render (mount). 14837// Subsequent renders (updates) reference this list. 14838 14839var hookTypesDev = null; 14840var hookTypesUpdateIndexDev = -1; // In DEV, this tracks whether currently rendering component needs to ignore 14841// the dependencies for Hooks that need them (e.g. useEffect or useMemo). 14842// When true, such Hooks will always be "remounted". Only used during hot reload. 14843 14844var ignorePreviousDependencies = false; 14845 14846function mountHookTypesDev() { 14847 { 14848 var hookName = currentHookNameInDev; 14849 14850 if (hookTypesDev === null) { 14851 hookTypesDev = [hookName]; 14852 } else { 14853 hookTypesDev.push(hookName); 14854 } 14855 } 14856} 14857 14858function updateHookTypesDev() { 14859 { 14860 var hookName = currentHookNameInDev; 14861 14862 if (hookTypesDev !== null) { 14863 hookTypesUpdateIndexDev++; 14864 14865 if (hookTypesDev[hookTypesUpdateIndexDev] !== hookName) { 14866 warnOnHookMismatchInDev(hookName); 14867 } 14868 } 14869 } 14870} 14871 14872function checkDepsAreArrayDev(deps) { 14873 { 14874 if (deps !== undefined && deps !== null && !Array.isArray(deps)) { 14875 // Verify deps, but only on mount to avoid extra checks. 14876 // It's unlikely their type would change as usually you define them inline. 14877 error('%s received a final argument that is not an array (instead, received `%s`). When ' + 'specified, the final argument must be an array.', currentHookNameInDev, typeof deps); 14878 } 14879 } 14880} 14881 14882function warnOnHookMismatchInDev(currentHookName) { 14883 { 14884 var componentName = getComponentName(currentlyRenderingFiber$1.type); 14885 14886 if (!didWarnAboutMismatchedHooksForComponent.has(componentName)) { 14887 didWarnAboutMismatchedHooksForComponent.add(componentName); 14888 14889 if (hookTypesDev !== null) { 14890 var table = ''; 14891 var secondColumnStart = 30; 14892 14893 for (var i = 0; i <= hookTypesUpdateIndexDev; i++) { 14894 var oldHookName = hookTypesDev[i]; 14895 var newHookName = i === hookTypesUpdateIndexDev ? currentHookName : oldHookName; 14896 var row = i + 1 + ". " + oldHookName; // Extra space so second column lines up 14897 // lol @ IE not supporting String#repeat 14898 14899 while (row.length < secondColumnStart) { 14900 row += ' '; 14901 } 14902 14903 row += newHookName + '\n'; 14904 table += row; 14905 } 14906 14907 error('React has detected a change in the order of Hooks called by %s. ' + 'This will lead to bugs and errors if not fixed. ' + 'For more information, read the Rules of Hooks: https://reactjs.org/link/rules-of-hooks\n\n' + ' Previous render Next render\n' + ' ------------------------------------------------------\n' + '%s' + ' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n', componentName, table); 14908 } 14909 } 14910 } 14911} 14912 14913function throwInvalidHookError() { 14914 { 14915 { 14916 throw Error( "Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem." ); 14917 } 14918 } 14919} 14920 14921function areHookInputsEqual(nextDeps, prevDeps) { 14922 { 14923 if (ignorePreviousDependencies) { 14924 // Only true when this component is being hot reloaded. 14925 return false; 14926 } 14927 } 14928 14929 if (prevDeps === null) { 14930 { 14931 error('%s received a final argument during this render, but not during ' + 'the previous render. Even though the final argument is optional, ' + 'its type cannot change between renders.', currentHookNameInDev); 14932 } 14933 14934 return false; 14935 } 14936 14937 { 14938 // Don't bother comparing lengths in prod because these arrays should be 14939 // passed inline. 14940 if (nextDeps.length !== prevDeps.length) { 14941 error('The final argument passed to %s changed size between renders. The ' + 'order and size of this array must remain constant.\n\n' + 'Previous: %s\n' + 'Incoming: %s', currentHookNameInDev, "[" + prevDeps.join(', ') + "]", "[" + nextDeps.join(', ') + "]"); 14942 } 14943 } 14944 14945 for (var i = 0; i < prevDeps.length && i < nextDeps.length; i++) { 14946 if (objectIs(nextDeps[i], prevDeps[i])) { 14947 continue; 14948 } 14949 14950 return false; 14951 } 14952 14953 return true; 14954} 14955 14956function renderWithHooks(current, workInProgress, Component, props, secondArg, nextRenderLanes) { 14957 renderLanes = nextRenderLanes; 14958 currentlyRenderingFiber$1 = workInProgress; 14959 14960 { 14961 hookTypesDev = current !== null ? current._debugHookTypes : null; 14962 hookTypesUpdateIndexDev = -1; // Used for hot reloading: 14963 14964 ignorePreviousDependencies = current !== null && current.type !== workInProgress.type; 14965 } 14966 14967 workInProgress.memoizedState = null; 14968 workInProgress.updateQueue = null; 14969 workInProgress.lanes = NoLanes; // The following should have already been reset 14970 // currentHook = null; 14971 // workInProgressHook = null; 14972 // didScheduleRenderPhaseUpdate = false; 14973 // TODO Warn if no hooks are used at all during mount, then some are used during update. 14974 // Currently we will identify the update render as a mount because memoizedState === null. 14975 // This is tricky because it's valid for certain types of components (e.g. React.lazy) 14976 // Using memoizedState to differentiate between mount/update only works if at least one stateful hook is used. 14977 // Non-stateful hooks (e.g. context) don't get added to memoizedState, 14978 // so memoizedState would be null during updates and mounts. 14979 14980 { 14981 if (current !== null && current.memoizedState !== null) { 14982 ReactCurrentDispatcher$1.current = HooksDispatcherOnUpdateInDEV; 14983 } else if (hookTypesDev !== null) { 14984 // This dispatcher handles an edge case where a component is updating, 14985 // but no stateful hooks have been used. 14986 // We want to match the production code behavior (which will use HooksDispatcherOnMount), 14987 // but with the extra DEV validation to ensure hooks ordering hasn't changed. 14988 // This dispatcher does that. 14989 ReactCurrentDispatcher$1.current = HooksDispatcherOnMountWithHookTypesInDEV; 14990 } else { 14991 ReactCurrentDispatcher$1.current = HooksDispatcherOnMountInDEV; 14992 } 14993 } 14994 14995 var children = Component(props, secondArg); // Check if there was a render phase update 14996 14997 if (didScheduleRenderPhaseUpdateDuringThisPass) { 14998 // Keep rendering in a loop for as long as render phase updates continue to 14999 // be scheduled. Use a counter to prevent infinite loops. 15000 var numberOfReRenders = 0; 15001 15002 do { 15003 didScheduleRenderPhaseUpdateDuringThisPass = false; 15004 15005 if (!(numberOfReRenders < RE_RENDER_LIMIT)) { 15006 { 15007 throw Error( "Too many re-renders. React limits the number of renders to prevent an infinite loop." ); 15008 } 15009 } 15010 15011 numberOfReRenders += 1; 15012 15013 { 15014 // Even when hot reloading, allow dependencies to stabilize 15015 // after first render to prevent infinite render phase updates. 15016 ignorePreviousDependencies = false; 15017 } // Start over from the beginning of the list 15018 15019 15020 currentHook = null; 15021 workInProgressHook = null; 15022 workInProgress.updateQueue = null; 15023 15024 { 15025 // Also validate hook order for cascading updates. 15026 hookTypesUpdateIndexDev = -1; 15027 } 15028 15029 ReactCurrentDispatcher$1.current = HooksDispatcherOnRerenderInDEV ; 15030 children = Component(props, secondArg); 15031 } while (didScheduleRenderPhaseUpdateDuringThisPass); 15032 } // We can assume the previous dispatcher is always this one, since we set it 15033 // at the beginning of the render phase and there's no re-entrancy. 15034 15035 15036 ReactCurrentDispatcher$1.current = ContextOnlyDispatcher; 15037 15038 { 15039 workInProgress._debugHookTypes = hookTypesDev; 15040 } // This check uses currentHook so that it works the same in DEV and prod bundles. 15041 // hookTypesDev could catch more cases (e.g. context) but only in DEV bundles. 15042 15043 15044 var didRenderTooFewHooks = currentHook !== null && currentHook.next !== null; 15045 renderLanes = NoLanes; 15046 currentlyRenderingFiber$1 = null; 15047 currentHook = null; 15048 workInProgressHook = null; 15049 15050 { 15051 currentHookNameInDev = null; 15052 hookTypesDev = null; 15053 hookTypesUpdateIndexDev = -1; 15054 } 15055 15056 didScheduleRenderPhaseUpdate = false; 15057 15058 if (!!didRenderTooFewHooks) { 15059 { 15060 throw Error( "Rendered fewer hooks than expected. This may be caused by an accidental early return statement." ); 15061 } 15062 } 15063 15064 return children; 15065} 15066function bailoutHooks(current, workInProgress, lanes) { 15067 workInProgress.updateQueue = current.updateQueue; 15068 workInProgress.flags &= ~(Passive | Update); 15069 current.lanes = removeLanes(current.lanes, lanes); 15070} 15071function resetHooksAfterThrow() { 15072 // We can assume the previous dispatcher is always this one, since we set it 15073 // at the beginning of the render phase and there's no re-entrancy. 15074 ReactCurrentDispatcher$1.current = ContextOnlyDispatcher; 15075 15076 if (didScheduleRenderPhaseUpdate) { 15077 // There were render phase updates. These are only valid for this render 15078 // phase, which we are now aborting. Remove the updates from the queues so 15079 // they do not persist to the next render. Do not remove updates from hooks 15080 // that weren't processed. 15081 // 15082 // Only reset the updates from the queue if it has a clone. If it does 15083 // not have a clone, that means it wasn't processed, and the updates were 15084 // scheduled before we entered the render phase. 15085 var hook = currentlyRenderingFiber$1.memoizedState; 15086 15087 while (hook !== null) { 15088 var queue = hook.queue; 15089 15090 if (queue !== null) { 15091 queue.pending = null; 15092 } 15093 15094 hook = hook.next; 15095 } 15096 15097 didScheduleRenderPhaseUpdate = false; 15098 } 15099 15100 renderLanes = NoLanes; 15101 currentlyRenderingFiber$1 = null; 15102 currentHook = null; 15103 workInProgressHook = null; 15104 15105 { 15106 hookTypesDev = null; 15107 hookTypesUpdateIndexDev = -1; 15108 currentHookNameInDev = null; 15109 isUpdatingOpaqueValueInRenderPhase = false; 15110 } 15111 15112 didScheduleRenderPhaseUpdateDuringThisPass = false; 15113} 15114 15115function mountWorkInProgressHook() { 15116 var hook = { 15117 memoizedState: null, 15118 baseState: null, 15119 baseQueue: null, 15120 queue: null, 15121 next: null 15122 }; 15123 15124 if (workInProgressHook === null) { 15125 // This is the first hook in the list 15126 currentlyRenderingFiber$1.memoizedState = workInProgressHook = hook; 15127 } else { 15128 // Append to the end of the list 15129 workInProgressHook = workInProgressHook.next = hook; 15130 } 15131 15132 return workInProgressHook; 15133} 15134 15135function updateWorkInProgressHook() { 15136 // This function is used both for updates and for re-renders triggered by a 15137 // render phase update. It assumes there is either a current hook we can 15138 // clone, or a work-in-progress hook from a previous render pass that we can 15139 // use as a base. When we reach the end of the base list, we must switch to 15140 // the dispatcher used for mounts. 15141 var nextCurrentHook; 15142 15143 if (currentHook === null) { 15144 var current = currentlyRenderingFiber$1.alternate; 15145 15146 if (current !== null) { 15147 nextCurrentHook = current.memoizedState; 15148 } else { 15149 nextCurrentHook = null; 15150 } 15151 } else { 15152 nextCurrentHook = currentHook.next; 15153 } 15154 15155 var nextWorkInProgressHook; 15156 15157 if (workInProgressHook === null) { 15158 nextWorkInProgressHook = currentlyRenderingFiber$1.memoizedState; 15159 } else { 15160 nextWorkInProgressHook = workInProgressHook.next; 15161 } 15162 15163 if (nextWorkInProgressHook !== null) { 15164 // There's already a work-in-progress. Reuse it. 15165 workInProgressHook = nextWorkInProgressHook; 15166 nextWorkInProgressHook = workInProgressHook.next; 15167 currentHook = nextCurrentHook; 15168 } else { 15169 // Clone from the current hook. 15170 if (!(nextCurrentHook !== null)) { 15171 { 15172 throw Error( "Rendered more hooks than during the previous render." ); 15173 } 15174 } 15175 15176 currentHook = nextCurrentHook; 15177 var newHook = { 15178 memoizedState: currentHook.memoizedState, 15179 baseState: currentHook.baseState, 15180 baseQueue: currentHook.baseQueue, 15181 queue: currentHook.queue, 15182 next: null 15183 }; 15184 15185 if (workInProgressHook === null) { 15186 // This is the first hook in the list. 15187 currentlyRenderingFiber$1.memoizedState = workInProgressHook = newHook; 15188 } else { 15189 // Append to the end of the list. 15190 workInProgressHook = workInProgressHook.next = newHook; 15191 } 15192 } 15193 15194 return workInProgressHook; 15195} 15196 15197function createFunctionComponentUpdateQueue() { 15198 return { 15199 lastEffect: null 15200 }; 15201} 15202 15203function basicStateReducer(state, action) { 15204 // $FlowFixMe: Flow doesn't like mixed types 15205 return typeof action === 'function' ? action(state) : action; 15206} 15207 15208function mountReducer(reducer, initialArg, init) { 15209 var hook = mountWorkInProgressHook(); 15210 var initialState; 15211 15212 if (init !== undefined) { 15213 initialState = init(initialArg); 15214 } else { 15215 initialState = initialArg; 15216 } 15217 15218 hook.memoizedState = hook.baseState = initialState; 15219 var queue = hook.queue = { 15220 pending: null, 15221 dispatch: null, 15222 lastRenderedReducer: reducer, 15223 lastRenderedState: initialState 15224 }; 15225 var dispatch = queue.dispatch = dispatchAction.bind(null, currentlyRenderingFiber$1, queue); 15226 return [hook.memoizedState, dispatch]; 15227} 15228 15229function updateReducer(reducer, initialArg, init) { 15230 var hook = updateWorkInProgressHook(); 15231 var queue = hook.queue; 15232 15233 if (!(queue !== null)) { 15234 { 15235 throw Error( "Should have a queue. This is likely a bug in React. Please file an issue." ); 15236 } 15237 } 15238 15239 queue.lastRenderedReducer = reducer; 15240 var current = currentHook; // The last rebase update that is NOT part of the base state. 15241 15242 var baseQueue = current.baseQueue; // The last pending update that hasn't been processed yet. 15243 15244 var pendingQueue = queue.pending; 15245 15246 if (pendingQueue !== null) { 15247 // We have new updates that haven't been processed yet. 15248 // We'll add them to the base queue. 15249 if (baseQueue !== null) { 15250 // Merge the pending queue and the base queue. 15251 var baseFirst = baseQueue.next; 15252 var pendingFirst = pendingQueue.next; 15253 baseQueue.next = pendingFirst; 15254 pendingQueue.next = baseFirst; 15255 } 15256 15257 { 15258 if (current.baseQueue !== baseQueue) { 15259 // Internal invariant that should never happen, but feasibly could in 15260 // the future if we implement resuming, or some form of that. 15261 error('Internal error: Expected work-in-progress queue to be a clone. ' + 'This is a bug in React.'); 15262 } 15263 } 15264 15265 current.baseQueue = baseQueue = pendingQueue; 15266 queue.pending = null; 15267 } 15268 15269 if (baseQueue !== null) { 15270 // We have a queue to process. 15271 var first = baseQueue.next; 15272 var newState = current.baseState; 15273 var newBaseState = null; 15274 var newBaseQueueFirst = null; 15275 var newBaseQueueLast = null; 15276 var update = first; 15277 15278 do { 15279 var updateLane = update.lane; 15280 15281 if (!isSubsetOfLanes(renderLanes, updateLane)) { 15282 // Priority is insufficient. Skip this update. If this is the first 15283 // skipped update, the previous update/state is the new base 15284 // update/state. 15285 var clone = { 15286 lane: updateLane, 15287 action: update.action, 15288 eagerReducer: update.eagerReducer, 15289 eagerState: update.eagerState, 15290 next: null 15291 }; 15292 15293 if (newBaseQueueLast === null) { 15294 newBaseQueueFirst = newBaseQueueLast = clone; 15295 newBaseState = newState; 15296 } else { 15297 newBaseQueueLast = newBaseQueueLast.next = clone; 15298 } // Update the remaining priority in the queue. 15299 // TODO: Don't need to accumulate this. Instead, we can remove 15300 // renderLanes from the original lanes. 15301 15302 15303 currentlyRenderingFiber$1.lanes = mergeLanes(currentlyRenderingFiber$1.lanes, updateLane); 15304 markSkippedUpdateLanes(updateLane); 15305 } else { 15306 // This update does have sufficient priority. 15307 if (newBaseQueueLast !== null) { 15308 var _clone = { 15309 // This update is going to be committed so we never want uncommit 15310 // it. Using NoLane works because 0 is a subset of all bitmasks, so 15311 // this will never be skipped by the check above. 15312 lane: NoLane, 15313 action: update.action, 15314 eagerReducer: update.eagerReducer, 15315 eagerState: update.eagerState, 15316 next: null 15317 }; 15318 newBaseQueueLast = newBaseQueueLast.next = _clone; 15319 } // Process this update. 15320 15321 15322 if (update.eagerReducer === reducer) { 15323 // If this update was processed eagerly, and its reducer matches the 15324 // current reducer, we can use the eagerly computed state. 15325 newState = update.eagerState; 15326 } else { 15327 var action = update.action; 15328 newState = reducer(newState, action); 15329 } 15330 } 15331 15332 update = update.next; 15333 } while (update !== null && update !== first); 15334 15335 if (newBaseQueueLast === null) { 15336 newBaseState = newState; 15337 } else { 15338 newBaseQueueLast.next = newBaseQueueFirst; 15339 } // Mark that the fiber performed work, but only if the new state is 15340 // different from the current state. 15341 15342 15343 if (!objectIs(newState, hook.memoizedState)) { 15344 markWorkInProgressReceivedUpdate(); 15345 } 15346 15347 hook.memoizedState = newState; 15348 hook.baseState = newBaseState; 15349 hook.baseQueue = newBaseQueueLast; 15350 queue.lastRenderedState = newState; 15351 } 15352 15353 var dispatch = queue.dispatch; 15354 return [hook.memoizedState, dispatch]; 15355} 15356 15357function rerenderReducer(reducer, initialArg, init) { 15358 var hook = updateWorkInProgressHook(); 15359 var queue = hook.queue; 15360 15361 if (!(queue !== null)) { 15362 { 15363 throw Error( "Should have a queue. This is likely a bug in React. Please file an issue." ); 15364 } 15365 } 15366 15367 queue.lastRenderedReducer = reducer; // This is a re-render. Apply the new render phase updates to the previous 15368 // work-in-progress hook. 15369 15370 var dispatch = queue.dispatch; 15371 var lastRenderPhaseUpdate = queue.pending; 15372 var newState = hook.memoizedState; 15373 15374 if (lastRenderPhaseUpdate !== null) { 15375 // The queue doesn't persist past this render pass. 15376 queue.pending = null; 15377 var firstRenderPhaseUpdate = lastRenderPhaseUpdate.next; 15378 var update = firstRenderPhaseUpdate; 15379 15380 do { 15381 // Process this render phase update. We don't have to check the 15382 // priority because it will always be the same as the current 15383 // render's. 15384 var action = update.action; 15385 newState = reducer(newState, action); 15386 update = update.next; 15387 } while (update !== firstRenderPhaseUpdate); // Mark that the fiber performed work, but only if the new state is 15388 // different from the current state. 15389 15390 15391 if (!objectIs(newState, hook.memoizedState)) { 15392 markWorkInProgressReceivedUpdate(); 15393 } 15394 15395 hook.memoizedState = newState; // Don't persist the state accumulated from the render phase updates to 15396 // the base state unless the queue is empty. 15397 // TODO: Not sure if this is the desired semantics, but it's what we 15398 // do for gDSFP. I can't remember why. 15399 15400 if (hook.baseQueue === null) { 15401 hook.baseState = newState; 15402 } 15403 15404 queue.lastRenderedState = newState; 15405 } 15406 15407 return [newState, dispatch]; 15408} 15409 15410function readFromUnsubcribedMutableSource(root, source, getSnapshot) { 15411 { 15412 warnAboutMultipleRenderersDEV(source); 15413 } 15414 15415 var getVersion = source._getVersion; 15416 var version = getVersion(source._source); // Is it safe for this component to read from this source during the current render? 15417 15418 var isSafeToReadFromSource = false; // Check the version first. 15419 // If this render has already been started with a specific version, 15420 // we can use it alone to determine if we can safely read from the source. 15421 15422 var currentRenderVersion = getWorkInProgressVersion(source); 15423 15424 if (currentRenderVersion !== null) { 15425 // It's safe to read if the store hasn't been mutated since the last time 15426 // we read something. 15427 isSafeToReadFromSource = currentRenderVersion === version; 15428 } else { 15429 // If there's no version, then this is the first time we've read from the 15430 // source during the current render pass, so we need to do a bit more work. 15431 // What we need to determine is if there are any hooks that already 15432 // subscribed to the source, and if so, whether there are any pending 15433 // mutations that haven't been synchronized yet. 15434 // 15435 // If there are no pending mutations, then `root.mutableReadLanes` will be 15436 // empty, and we know we can safely read. 15437 // 15438 // If there *are* pending mutations, we may still be able to safely read 15439 // if the currently rendering lanes are inclusive of the pending mutation 15440 // lanes, since that guarantees that the value we're about to read from 15441 // the source is consistent with the values that we read during the most 15442 // recent mutation. 15443 isSafeToReadFromSource = isSubsetOfLanes(renderLanes, root.mutableReadLanes); 15444 15445 if (isSafeToReadFromSource) { 15446 // If it's safe to read from this source during the current render, 15447 // store the version in case other components read from it. 15448 // A changed version number will let those components know to throw and restart the render. 15449 setWorkInProgressVersion(source, version); 15450 } 15451 } 15452 15453 if (isSafeToReadFromSource) { 15454 var snapshot = getSnapshot(source._source); 15455 15456 { 15457 if (typeof snapshot === 'function') { 15458 error('Mutable source should not return a function as the snapshot value. ' + 'Functions may close over mutable values and cause tearing.'); 15459 } 15460 } 15461 15462 return snapshot; 15463 } else { 15464 // This handles the special case of a mutable source being shared between renderers. 15465 // In that case, if the source is mutated between the first and second renderer, 15466 // The second renderer don't know that it needs to reset the WIP version during unwind, 15467 // (because the hook only marks sources as dirty if it's written to their WIP version). 15468 // That would cause this tear check to throw again and eventually be visible to the user. 15469 // We can avoid this infinite loop by explicitly marking the source as dirty. 15470 // 15471 // This can lead to tearing in the first renderer when it resumes, 15472 // but there's nothing we can do about that (short of throwing here and refusing to continue the render). 15473 markSourceAsDirty(source); 15474 15475 { 15476 { 15477 throw Error( "Cannot read from mutable source during the current render without tearing. This is a bug in React. Please file an issue." ); 15478 } 15479 } 15480 } 15481} 15482 15483function useMutableSource(hook, source, getSnapshot, subscribe) { 15484 var root = getWorkInProgressRoot(); 15485 15486 if (!(root !== null)) { 15487 { 15488 throw Error( "Expected a work-in-progress root. This is a bug in React. Please file an issue." ); 15489 } 15490 } 15491 15492 var getVersion = source._getVersion; 15493 var version = getVersion(source._source); 15494 var dispatcher = ReactCurrentDispatcher$1.current; // eslint-disable-next-line prefer-const 15495 15496 var _dispatcher$useState = dispatcher.useState(function () { 15497 return readFromUnsubcribedMutableSource(root, source, getSnapshot); 15498 }), 15499 currentSnapshot = _dispatcher$useState[0], 15500 setSnapshot = _dispatcher$useState[1]; 15501 15502 var snapshot = currentSnapshot; // Grab a handle to the state hook as well. 15503 // We use it to clear the pending update queue if we have a new source. 15504 15505 var stateHook = workInProgressHook; 15506 var memoizedState = hook.memoizedState; 15507 var refs = memoizedState.refs; 15508 var prevGetSnapshot = refs.getSnapshot; 15509 var prevSource = memoizedState.source; 15510 var prevSubscribe = memoizedState.subscribe; 15511 var fiber = currentlyRenderingFiber$1; 15512 hook.memoizedState = { 15513 refs: refs, 15514 source: source, 15515 subscribe: subscribe 15516 }; // Sync the values needed by our subscription handler after each commit. 15517 15518 dispatcher.useEffect(function () { 15519 refs.getSnapshot = getSnapshot; // Normally the dispatch function for a state hook never changes, 15520 // but this hook recreates the queue in certain cases to avoid updates from stale sources. 15521 // handleChange() below needs to reference the dispatch function without re-subscribing, 15522 // so we use a ref to ensure that it always has the latest version. 15523 15524 refs.setSnapshot = setSnapshot; // Check for a possible change between when we last rendered now. 15525 15526 var maybeNewVersion = getVersion(source._source); 15527 15528 if (!objectIs(version, maybeNewVersion)) { 15529 var maybeNewSnapshot = getSnapshot(source._source); 15530 15531 { 15532 if (typeof maybeNewSnapshot === 'function') { 15533 error('Mutable source should not return a function as the snapshot value. ' + 'Functions may close over mutable values and cause tearing.'); 15534 } 15535 } 15536 15537 if (!objectIs(snapshot, maybeNewSnapshot)) { 15538 setSnapshot(maybeNewSnapshot); 15539 var lane = requestUpdateLane(fiber); 15540 markRootMutableRead(root, lane); 15541 } // If the source mutated between render and now, 15542 // there may be state updates already scheduled from the old source. 15543 // Entangle the updates so that they render in the same batch. 15544 15545 15546 markRootEntangled(root, root.mutableReadLanes); 15547 } 15548 }, [getSnapshot, source, subscribe]); // If we got a new source or subscribe function, re-subscribe in a passive effect. 15549 15550 dispatcher.useEffect(function () { 15551 var handleChange = function () { 15552 var latestGetSnapshot = refs.getSnapshot; 15553 var latestSetSnapshot = refs.setSnapshot; 15554 15555 try { 15556 latestSetSnapshot(latestGetSnapshot(source._source)); // Record a pending mutable source update with the same expiration time. 15557 15558 var lane = requestUpdateLane(fiber); 15559 markRootMutableRead(root, lane); 15560 } catch (error) { 15561 // A selector might throw after a source mutation. 15562 // e.g. it might try to read from a part of the store that no longer exists. 15563 // In this case we should still schedule an update with React. 15564 // Worst case the selector will throw again and then an error boundary will handle it. 15565 latestSetSnapshot(function () { 15566 throw error; 15567 }); 15568 } 15569 }; 15570 15571 var unsubscribe = subscribe(source._source, handleChange); 15572 15573 { 15574 if (typeof unsubscribe !== 'function') { 15575 error('Mutable source subscribe function must return an unsubscribe function.'); 15576 } 15577 } 15578 15579 return unsubscribe; 15580 }, [source, subscribe]); // If any of the inputs to useMutableSource change, reading is potentially unsafe. 15581 // 15582 // If either the source or the subscription have changed we can't can't trust the update queue. 15583 // Maybe the source changed in a way that the old subscription ignored but the new one depends on. 15584 // 15585 // If the getSnapshot function changed, we also shouldn't rely on the update queue. 15586 // It's possible that the underlying source was mutated between the when the last "change" event fired, 15587 // and when the current render (with the new getSnapshot function) is processed. 15588 // 15589 // In both cases, we need to throw away pending updates (since they are no longer relevant) 15590 // and treat reading from the source as we do in the mount case. 15591 15592 if (!objectIs(prevGetSnapshot, getSnapshot) || !objectIs(prevSource, source) || !objectIs(prevSubscribe, subscribe)) { 15593 // Create a new queue and setState method, 15594 // So if there are interleaved updates, they get pushed to the older queue. 15595 // When this becomes current, the previous queue and dispatch method will be discarded, 15596 // including any interleaving updates that occur. 15597 var newQueue = { 15598 pending: null, 15599 dispatch: null, 15600 lastRenderedReducer: basicStateReducer, 15601 lastRenderedState: snapshot 15602 }; 15603 newQueue.dispatch = setSnapshot = dispatchAction.bind(null, currentlyRenderingFiber$1, newQueue); 15604 stateHook.queue = newQueue; 15605 stateHook.baseQueue = null; 15606 snapshot = readFromUnsubcribedMutableSource(root, source, getSnapshot); 15607 stateHook.memoizedState = stateHook.baseState = snapshot; 15608 } 15609 15610 return snapshot; 15611} 15612 15613function mountMutableSource(source, getSnapshot, subscribe) { 15614 var hook = mountWorkInProgressHook(); 15615 hook.memoizedState = { 15616 refs: { 15617 getSnapshot: getSnapshot, 15618 setSnapshot: null 15619 }, 15620 source: source, 15621 subscribe: subscribe 15622 }; 15623 return useMutableSource(hook, source, getSnapshot, subscribe); 15624} 15625 15626function updateMutableSource(source, getSnapshot, subscribe) { 15627 var hook = updateWorkInProgressHook(); 15628 return useMutableSource(hook, source, getSnapshot, subscribe); 15629} 15630 15631function mountState(initialState) { 15632 var hook = mountWorkInProgressHook(); 15633 15634 if (typeof initialState === 'function') { 15635 // $FlowFixMe: Flow doesn't like mixed types 15636 initialState = initialState(); 15637 } 15638 15639 hook.memoizedState = hook.baseState = initialState; 15640 var queue = hook.queue = { 15641 pending: null, 15642 dispatch: null, 15643 lastRenderedReducer: basicStateReducer, 15644 lastRenderedState: initialState 15645 }; 15646 var dispatch = queue.dispatch = dispatchAction.bind(null, currentlyRenderingFiber$1, queue); 15647 return [hook.memoizedState, dispatch]; 15648} 15649 15650function updateState(initialState) { 15651 return updateReducer(basicStateReducer); 15652} 15653 15654function rerenderState(initialState) { 15655 return rerenderReducer(basicStateReducer); 15656} 15657 15658function pushEffect(tag, create, destroy, deps) { 15659 var effect = { 15660 tag: tag, 15661 create: create, 15662 destroy: destroy, 15663 deps: deps, 15664 // Circular 15665 next: null 15666 }; 15667 var componentUpdateQueue = currentlyRenderingFiber$1.updateQueue; 15668 15669 if (componentUpdateQueue === null) { 15670 componentUpdateQueue = createFunctionComponentUpdateQueue(); 15671 currentlyRenderingFiber$1.updateQueue = componentUpdateQueue; 15672 componentUpdateQueue.lastEffect = effect.next = effect; 15673 } else { 15674 var lastEffect = componentUpdateQueue.lastEffect; 15675 15676 if (lastEffect === null) { 15677 componentUpdateQueue.lastEffect = effect.next = effect; 15678 } else { 15679 var firstEffect = lastEffect.next; 15680 lastEffect.next = effect; 15681 effect.next = firstEffect; 15682 componentUpdateQueue.lastEffect = effect; 15683 } 15684 } 15685 15686 return effect; 15687} 15688 15689function mountRef(initialValue) { 15690 var hook = mountWorkInProgressHook(); 15691 var ref = { 15692 current: initialValue 15693 }; 15694 15695 { 15696 Object.seal(ref); 15697 } 15698 15699 hook.memoizedState = ref; 15700 return ref; 15701} 15702 15703function updateRef(initialValue) { 15704 var hook = updateWorkInProgressHook(); 15705 return hook.memoizedState; 15706} 15707 15708function mountEffectImpl(fiberFlags, hookFlags, create, deps) { 15709 var hook = mountWorkInProgressHook(); 15710 var nextDeps = deps === undefined ? null : deps; 15711 currentlyRenderingFiber$1.flags |= fiberFlags; 15712 hook.memoizedState = pushEffect(HasEffect | hookFlags, create, undefined, nextDeps); 15713} 15714 15715function updateEffectImpl(fiberFlags, hookFlags, create, deps) { 15716 var hook = updateWorkInProgressHook(); 15717 var nextDeps = deps === undefined ? null : deps; 15718 var destroy = undefined; 15719 15720 if (currentHook !== null) { 15721 var prevEffect = currentHook.memoizedState; 15722 destroy = prevEffect.destroy; 15723 15724 if (nextDeps !== null) { 15725 var prevDeps = prevEffect.deps; 15726 15727 if (areHookInputsEqual(nextDeps, prevDeps)) { 15728 pushEffect(hookFlags, create, destroy, nextDeps); 15729 return; 15730 } 15731 } 15732 } 15733 15734 currentlyRenderingFiber$1.flags |= fiberFlags; 15735 hook.memoizedState = pushEffect(HasEffect | hookFlags, create, destroy, nextDeps); 15736} 15737 15738function mountEffect(create, deps) { 15739 { 15740 // $FlowExpectedError - jest isn't a global, and isn't recognized outside of tests 15741 if ('undefined' !== typeof jest) { 15742 warnIfNotCurrentlyActingEffectsInDEV(currentlyRenderingFiber$1); 15743 } 15744 } 15745 15746 return mountEffectImpl(Update | Passive, Passive$1, create, deps); 15747} 15748 15749function updateEffect(create, deps) { 15750 { 15751 // $FlowExpectedError - jest isn't a global, and isn't recognized outside of tests 15752 if ('undefined' !== typeof jest) { 15753 warnIfNotCurrentlyActingEffectsInDEV(currentlyRenderingFiber$1); 15754 } 15755 } 15756 15757 return updateEffectImpl(Update | Passive, Passive$1, create, deps); 15758} 15759 15760function mountLayoutEffect(create, deps) { 15761 return mountEffectImpl(Update, Layout, create, deps); 15762} 15763 15764function updateLayoutEffect(create, deps) { 15765 return updateEffectImpl(Update, Layout, create, deps); 15766} 15767 15768function imperativeHandleEffect(create, ref) { 15769 if (typeof ref === 'function') { 15770 var refCallback = ref; 15771 15772 var _inst = create(); 15773 15774 refCallback(_inst); 15775 return function () { 15776 refCallback(null); 15777 }; 15778 } else if (ref !== null && ref !== undefined) { 15779 var refObject = ref; 15780 15781 { 15782 if (!refObject.hasOwnProperty('current')) { 15783 error('Expected useImperativeHandle() first argument to either be a ' + 'ref callback or React.createRef() object. Instead received: %s.', 'an object with keys {' + Object.keys(refObject).join(', ') + '}'); 15784 } 15785 } 15786 15787 var _inst2 = create(); 15788 15789 refObject.current = _inst2; 15790 return function () { 15791 refObject.current = null; 15792 }; 15793 } 15794} 15795 15796function mountImperativeHandle(ref, create, deps) { 15797 { 15798 if (typeof create !== 'function') { 15799 error('Expected useImperativeHandle() second argument to be a function ' + 'that creates a handle. Instead received: %s.', create !== null ? typeof create : 'null'); 15800 } 15801 } // TODO: If deps are provided, should we skip comparing the ref itself? 15802 15803 15804 var effectDeps = deps !== null && deps !== undefined ? deps.concat([ref]) : null; 15805 return mountEffectImpl(Update, Layout, imperativeHandleEffect.bind(null, create, ref), effectDeps); 15806} 15807 15808function updateImperativeHandle(ref, create, deps) { 15809 { 15810 if (typeof create !== 'function') { 15811 error('Expected useImperativeHandle() second argument to be a function ' + 'that creates a handle. Instead received: %s.', create !== null ? typeof create : 'null'); 15812 } 15813 } // TODO: If deps are provided, should we skip comparing the ref itself? 15814 15815 15816 var effectDeps = deps !== null && deps !== undefined ? deps.concat([ref]) : null; 15817 return updateEffectImpl(Update, Layout, imperativeHandleEffect.bind(null, create, ref), effectDeps); 15818} 15819 15820function mountDebugValue(value, formatterFn) {// This hook is normally a no-op. 15821 // The react-debug-hooks package injects its own implementation 15822 // so that e.g. DevTools can display custom hook values. 15823} 15824 15825var updateDebugValue = mountDebugValue; 15826 15827function mountCallback(callback, deps) { 15828 var hook = mountWorkInProgressHook(); 15829 var nextDeps = deps === undefined ? null : deps; 15830 hook.memoizedState = [callback, nextDeps]; 15831 return callback; 15832} 15833 15834function updateCallback(callback, deps) { 15835 var hook = updateWorkInProgressHook(); 15836 var nextDeps = deps === undefined ? null : deps; 15837 var prevState = hook.memoizedState; 15838 15839 if (prevState !== null) { 15840 if (nextDeps !== null) { 15841 var prevDeps = prevState[1]; 15842 15843 if (areHookInputsEqual(nextDeps, prevDeps)) { 15844 return prevState[0]; 15845 } 15846 } 15847 } 15848 15849 hook.memoizedState = [callback, nextDeps]; 15850 return callback; 15851} 15852 15853function mountMemo(nextCreate, deps) { 15854 var hook = mountWorkInProgressHook(); 15855 var nextDeps = deps === undefined ? null : deps; 15856 var nextValue = nextCreate(); 15857 hook.memoizedState = [nextValue, nextDeps]; 15858 return nextValue; 15859} 15860 15861function updateMemo(nextCreate, deps) { 15862 var hook = updateWorkInProgressHook(); 15863 var nextDeps = deps === undefined ? null : deps; 15864 var prevState = hook.memoizedState; 15865 15866 if (prevState !== null) { 15867 // Assume these are defined. If they're not, areHookInputsEqual will warn. 15868 if (nextDeps !== null) { 15869 var prevDeps = prevState[1]; 15870 15871 if (areHookInputsEqual(nextDeps, prevDeps)) { 15872 return prevState[0]; 15873 } 15874 } 15875 } 15876 15877 var nextValue = nextCreate(); 15878 hook.memoizedState = [nextValue, nextDeps]; 15879 return nextValue; 15880} 15881 15882function mountDeferredValue(value) { 15883 var _mountState = mountState(value), 15884 prevValue = _mountState[0], 15885 setValue = _mountState[1]; 15886 15887 mountEffect(function () { 15888 var prevTransition = ReactCurrentBatchConfig$1.transition; 15889 ReactCurrentBatchConfig$1.transition = 1; 15890 15891 try { 15892 setValue(value); 15893 } finally { 15894 ReactCurrentBatchConfig$1.transition = prevTransition; 15895 } 15896 }, [value]); 15897 return prevValue; 15898} 15899 15900function updateDeferredValue(value) { 15901 var _updateState = updateState(), 15902 prevValue = _updateState[0], 15903 setValue = _updateState[1]; 15904 15905 updateEffect(function () { 15906 var prevTransition = ReactCurrentBatchConfig$1.transition; 15907 ReactCurrentBatchConfig$1.transition = 1; 15908 15909 try { 15910 setValue(value); 15911 } finally { 15912 ReactCurrentBatchConfig$1.transition = prevTransition; 15913 } 15914 }, [value]); 15915 return prevValue; 15916} 15917 15918function rerenderDeferredValue(value) { 15919 var _rerenderState = rerenderState(), 15920 prevValue = _rerenderState[0], 15921 setValue = _rerenderState[1]; 15922 15923 updateEffect(function () { 15924 var prevTransition = ReactCurrentBatchConfig$1.transition; 15925 ReactCurrentBatchConfig$1.transition = 1; 15926 15927 try { 15928 setValue(value); 15929 } finally { 15930 ReactCurrentBatchConfig$1.transition = prevTransition; 15931 } 15932 }, [value]); 15933 return prevValue; 15934} 15935 15936function startTransition(setPending, callback) { 15937 var priorityLevel = getCurrentPriorityLevel(); 15938 15939 { 15940 runWithPriority$1(priorityLevel < UserBlockingPriority$2 ? UserBlockingPriority$2 : priorityLevel, function () { 15941 setPending(true); 15942 }); 15943 runWithPriority$1(priorityLevel > NormalPriority$1 ? NormalPriority$1 : priorityLevel, function () { 15944 var prevTransition = ReactCurrentBatchConfig$1.transition; 15945 ReactCurrentBatchConfig$1.transition = 1; 15946 15947 try { 15948 setPending(false); 15949 callback(); 15950 } finally { 15951 ReactCurrentBatchConfig$1.transition = prevTransition; 15952 } 15953 }); 15954 } 15955} 15956 15957function mountTransition() { 15958 var _mountState2 = mountState(false), 15959 isPending = _mountState2[0], 15960 setPending = _mountState2[1]; // The `start` method can be stored on a ref, since `setPending` 15961 // never changes. 15962 15963 15964 var start = startTransition.bind(null, setPending); 15965 mountRef(start); 15966 return [start, isPending]; 15967} 15968 15969function updateTransition() { 15970 var _updateState2 = updateState(), 15971 isPending = _updateState2[0]; 15972 15973 var startRef = updateRef(); 15974 var start = startRef.current; 15975 return [start, isPending]; 15976} 15977 15978function rerenderTransition() { 15979 var _rerenderState2 = rerenderState(), 15980 isPending = _rerenderState2[0]; 15981 15982 var startRef = updateRef(); 15983 var start = startRef.current; 15984 return [start, isPending]; 15985} 15986 15987var isUpdatingOpaqueValueInRenderPhase = false; 15988function getIsUpdatingOpaqueValueInRenderPhaseInDEV() { 15989 { 15990 return isUpdatingOpaqueValueInRenderPhase; 15991 } 15992} 15993 15994function warnOnOpaqueIdentifierAccessInDEV(fiber) { 15995 { 15996 // TODO: Should warn in effects and callbacks, too 15997 var name = getComponentName(fiber.type) || 'Unknown'; 15998 15999 if (getIsRendering() && !didWarnAboutUseOpaqueIdentifier[name]) { 16000 error('The object passed back from useOpaqueIdentifier is meant to be ' + 'passed through to attributes only. Do not read the ' + 'value directly.'); 16001 16002 didWarnAboutUseOpaqueIdentifier[name] = true; 16003 } 16004 } 16005} 16006 16007function mountOpaqueIdentifier() { 16008 var makeId = makeClientIdInDEV.bind(null, warnOnOpaqueIdentifierAccessInDEV.bind(null, currentlyRenderingFiber$1)) ; 16009 16010 if (getIsHydrating()) { 16011 var didUpgrade = false; 16012 var fiber = currentlyRenderingFiber$1; 16013 16014 var readValue = function () { 16015 if (!didUpgrade) { 16016 // Only upgrade once. This works even inside the render phase because 16017 // the update is added to a shared queue, which outlasts the 16018 // in-progress render. 16019 didUpgrade = true; 16020 16021 { 16022 isUpdatingOpaqueValueInRenderPhase = true; 16023 setId(makeId()); 16024 isUpdatingOpaqueValueInRenderPhase = false; 16025 warnOnOpaqueIdentifierAccessInDEV(fiber); 16026 } 16027 } 16028 16029 { 16030 { 16031 throw Error( "The object passed back from useOpaqueIdentifier is meant to be passed through to attributes only. Do not read the value directly." ); 16032 } 16033 } 16034 }; 16035 16036 var id = makeOpaqueHydratingObject(readValue); 16037 var setId = mountState(id)[1]; 16038 16039 if ((currentlyRenderingFiber$1.mode & BlockingMode) === NoMode) { 16040 currentlyRenderingFiber$1.flags |= Update | Passive; 16041 pushEffect(HasEffect | Passive$1, function () { 16042 setId(makeId()); 16043 }, undefined, null); 16044 } 16045 16046 return id; 16047 } else { 16048 var _id = makeId(); 16049 16050 mountState(_id); 16051 return _id; 16052 } 16053} 16054 16055function updateOpaqueIdentifier() { 16056 var id = updateState()[0]; 16057 return id; 16058} 16059 16060function rerenderOpaqueIdentifier() { 16061 var id = rerenderState()[0]; 16062 return id; 16063} 16064 16065function dispatchAction(fiber, queue, action) { 16066 { 16067 if (typeof arguments[3] === 'function') { 16068 error("State updates from the useState() and useReducer() Hooks don't support the " + 'second callback argument. To execute a side effect after ' + 'rendering, declare it in the component body with useEffect().'); 16069 } 16070 } 16071 16072 var eventTime = requestEventTime(); 16073 var lane = requestUpdateLane(fiber); 16074 var update = { 16075 lane: lane, 16076 action: action, 16077 eagerReducer: null, 16078 eagerState: null, 16079 next: null 16080 }; // Append the update to the end of the list. 16081 16082 var pending = queue.pending; 16083 16084 if (pending === null) { 16085 // This is the first update. Create a circular list. 16086 update.next = update; 16087 } else { 16088 update.next = pending.next; 16089 pending.next = update; 16090 } 16091 16092 queue.pending = update; 16093 var alternate = fiber.alternate; 16094 16095 if (fiber === currentlyRenderingFiber$1 || alternate !== null && alternate === currentlyRenderingFiber$1) { 16096 // This is a render phase update. Stash it in a lazily-created map of 16097 // queue -> linked list of updates. After this render pass, we'll restart 16098 // and apply the stashed updates on top of the work-in-progress hook. 16099 didScheduleRenderPhaseUpdateDuringThisPass = didScheduleRenderPhaseUpdate = true; 16100 } else { 16101 if (fiber.lanes === NoLanes && (alternate === null || alternate.lanes === NoLanes)) { 16102 // The queue is currently empty, which means we can eagerly compute the 16103 // next state before entering the render phase. If the new state is the 16104 // same as the current state, we may be able to bail out entirely. 16105 var lastRenderedReducer = queue.lastRenderedReducer; 16106 16107 if (lastRenderedReducer !== null) { 16108 var prevDispatcher; 16109 16110 { 16111 prevDispatcher = ReactCurrentDispatcher$1.current; 16112 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; 16113 } 16114 16115 try { 16116 var currentState = queue.lastRenderedState; 16117 var eagerState = lastRenderedReducer(currentState, action); // Stash the eagerly computed state, and the reducer used to compute 16118 // it, on the update object. If the reducer hasn't changed by the 16119 // time we enter the render phase, then the eager state can be used 16120 // without calling the reducer again. 16121 16122 update.eagerReducer = lastRenderedReducer; 16123 update.eagerState = eagerState; 16124 16125 if (objectIs(eagerState, currentState)) { 16126 // Fast path. We can bail out without scheduling React to re-render. 16127 // It's still possible that we'll need to rebase this update later, 16128 // if the component re-renders for a different reason and by that 16129 // time the reducer has changed. 16130 return; 16131 } 16132 } catch (error) {// Suppress the error. It will throw again in the render phase. 16133 } finally { 16134 { 16135 ReactCurrentDispatcher$1.current = prevDispatcher; 16136 } 16137 } 16138 } 16139 } 16140 16141 { 16142 // $FlowExpectedError - jest isn't a global, and isn't recognized outside of tests 16143 if ('undefined' !== typeof jest) { 16144 warnIfNotScopedWithMatchingAct(fiber); 16145 warnIfNotCurrentlyActingUpdatesInDev(fiber); 16146 } 16147 } 16148 16149 scheduleUpdateOnFiber(fiber, lane, eventTime); 16150 } 16151} 16152 16153var ContextOnlyDispatcher = { 16154 readContext: readContext, 16155 useCallback: throwInvalidHookError, 16156 useContext: throwInvalidHookError, 16157 useEffect: throwInvalidHookError, 16158 useImperativeHandle: throwInvalidHookError, 16159 useLayoutEffect: throwInvalidHookError, 16160 useMemo: throwInvalidHookError, 16161 useReducer: throwInvalidHookError, 16162 useRef: throwInvalidHookError, 16163 useState: throwInvalidHookError, 16164 useDebugValue: throwInvalidHookError, 16165 useDeferredValue: throwInvalidHookError, 16166 useTransition: throwInvalidHookError, 16167 useMutableSource: throwInvalidHookError, 16168 useOpaqueIdentifier: throwInvalidHookError, 16169 unstable_isNewReconciler: enableNewReconciler 16170}; 16171var HooksDispatcherOnMountInDEV = null; 16172var HooksDispatcherOnMountWithHookTypesInDEV = null; 16173var HooksDispatcherOnUpdateInDEV = null; 16174var HooksDispatcherOnRerenderInDEV = null; 16175var InvalidNestedHooksDispatcherOnMountInDEV = null; 16176var InvalidNestedHooksDispatcherOnUpdateInDEV = null; 16177var InvalidNestedHooksDispatcherOnRerenderInDEV = null; 16178 16179{ 16180 var warnInvalidContextAccess = function () { 16181 error('Context can only be read while React is rendering. ' + 'In classes, you can read it in the render method or getDerivedStateFromProps. ' + 'In function components, you can read it directly in the function body, but not ' + 'inside Hooks like useReducer() or useMemo().'); 16182 }; 16183 16184 var warnInvalidHookAccess = function () { 16185 error('Do not call Hooks inside useEffect(...), useMemo(...), or other built-in Hooks. ' + 'You can only call Hooks at the top level of your React function. ' + 'For more information, see ' + 'https://reactjs.org/link/rules-of-hooks'); 16186 }; 16187 16188 HooksDispatcherOnMountInDEV = { 16189 readContext: function (context, observedBits) { 16190 return readContext(context, observedBits); 16191 }, 16192 useCallback: function (callback, deps) { 16193 currentHookNameInDev = 'useCallback'; 16194 mountHookTypesDev(); 16195 checkDepsAreArrayDev(deps); 16196 return mountCallback(callback, deps); 16197 }, 16198 useContext: function (context, observedBits) { 16199 currentHookNameInDev = 'useContext'; 16200 mountHookTypesDev(); 16201 return readContext(context, observedBits); 16202 }, 16203 useEffect: function (create, deps) { 16204 currentHookNameInDev = 'useEffect'; 16205 mountHookTypesDev(); 16206 checkDepsAreArrayDev(deps); 16207 return mountEffect(create, deps); 16208 }, 16209 useImperativeHandle: function (ref, create, deps) { 16210 currentHookNameInDev = 'useImperativeHandle'; 16211 mountHookTypesDev(); 16212 checkDepsAreArrayDev(deps); 16213 return mountImperativeHandle(ref, create, deps); 16214 }, 16215 useLayoutEffect: function (create, deps) { 16216 currentHookNameInDev = 'useLayoutEffect'; 16217 mountHookTypesDev(); 16218 checkDepsAreArrayDev(deps); 16219 return mountLayoutEffect(create, deps); 16220 }, 16221 useMemo: function (create, deps) { 16222 currentHookNameInDev = 'useMemo'; 16223 mountHookTypesDev(); 16224 checkDepsAreArrayDev(deps); 16225 var prevDispatcher = ReactCurrentDispatcher$1.current; 16226 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; 16227 16228 try { 16229 return mountMemo(create, deps); 16230 } finally { 16231 ReactCurrentDispatcher$1.current = prevDispatcher; 16232 } 16233 }, 16234 useReducer: function (reducer, initialArg, init) { 16235 currentHookNameInDev = 'useReducer'; 16236 mountHookTypesDev(); 16237 var prevDispatcher = ReactCurrentDispatcher$1.current; 16238 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; 16239 16240 try { 16241 return mountReducer(reducer, initialArg, init); 16242 } finally { 16243 ReactCurrentDispatcher$1.current = prevDispatcher; 16244 } 16245 }, 16246 useRef: function (initialValue) { 16247 currentHookNameInDev = 'useRef'; 16248 mountHookTypesDev(); 16249 return mountRef(initialValue); 16250 }, 16251 useState: function (initialState) { 16252 currentHookNameInDev = 'useState'; 16253 mountHookTypesDev(); 16254 var prevDispatcher = ReactCurrentDispatcher$1.current; 16255 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; 16256 16257 try { 16258 return mountState(initialState); 16259 } finally { 16260 ReactCurrentDispatcher$1.current = prevDispatcher; 16261 } 16262 }, 16263 useDebugValue: function (value, formatterFn) { 16264 currentHookNameInDev = 'useDebugValue'; 16265 mountHookTypesDev(); 16266 return mountDebugValue(); 16267 }, 16268 useDeferredValue: function (value) { 16269 currentHookNameInDev = 'useDeferredValue'; 16270 mountHookTypesDev(); 16271 return mountDeferredValue(value); 16272 }, 16273 useTransition: function () { 16274 currentHookNameInDev = 'useTransition'; 16275 mountHookTypesDev(); 16276 return mountTransition(); 16277 }, 16278 useMutableSource: function (source, getSnapshot, subscribe) { 16279 currentHookNameInDev = 'useMutableSource'; 16280 mountHookTypesDev(); 16281 return mountMutableSource(source, getSnapshot, subscribe); 16282 }, 16283 useOpaqueIdentifier: function () { 16284 currentHookNameInDev = 'useOpaqueIdentifier'; 16285 mountHookTypesDev(); 16286 return mountOpaqueIdentifier(); 16287 }, 16288 unstable_isNewReconciler: enableNewReconciler 16289 }; 16290 HooksDispatcherOnMountWithHookTypesInDEV = { 16291 readContext: function (context, observedBits) { 16292 return readContext(context, observedBits); 16293 }, 16294 useCallback: function (callback, deps) { 16295 currentHookNameInDev = 'useCallback'; 16296 updateHookTypesDev(); 16297 return mountCallback(callback, deps); 16298 }, 16299 useContext: function (context, observedBits) { 16300 currentHookNameInDev = 'useContext'; 16301 updateHookTypesDev(); 16302 return readContext(context, observedBits); 16303 }, 16304 useEffect: function (create, deps) { 16305 currentHookNameInDev = 'useEffect'; 16306 updateHookTypesDev(); 16307 return mountEffect(create, deps); 16308 }, 16309 useImperativeHandle: function (ref, create, deps) { 16310 currentHookNameInDev = 'useImperativeHandle'; 16311 updateHookTypesDev(); 16312 return mountImperativeHandle(ref, create, deps); 16313 }, 16314 useLayoutEffect: function (create, deps) { 16315 currentHookNameInDev = 'useLayoutEffect'; 16316 updateHookTypesDev(); 16317 return mountLayoutEffect(create, deps); 16318 }, 16319 useMemo: function (create, deps) { 16320 currentHookNameInDev = 'useMemo'; 16321 updateHookTypesDev(); 16322 var prevDispatcher = ReactCurrentDispatcher$1.current; 16323 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; 16324 16325 try { 16326 return mountMemo(create, deps); 16327 } finally { 16328 ReactCurrentDispatcher$1.current = prevDispatcher; 16329 } 16330 }, 16331 useReducer: function (reducer, initialArg, init) { 16332 currentHookNameInDev = 'useReducer'; 16333 updateHookTypesDev(); 16334 var prevDispatcher = ReactCurrentDispatcher$1.current; 16335 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; 16336 16337 try { 16338 return mountReducer(reducer, initialArg, init); 16339 } finally { 16340 ReactCurrentDispatcher$1.current = prevDispatcher; 16341 } 16342 }, 16343 useRef: function (initialValue) { 16344 currentHookNameInDev = 'useRef'; 16345 updateHookTypesDev(); 16346 return mountRef(initialValue); 16347 }, 16348 useState: function (initialState) { 16349 currentHookNameInDev = 'useState'; 16350 updateHookTypesDev(); 16351 var prevDispatcher = ReactCurrentDispatcher$1.current; 16352 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; 16353 16354 try { 16355 return mountState(initialState); 16356 } finally { 16357 ReactCurrentDispatcher$1.current = prevDispatcher; 16358 } 16359 }, 16360 useDebugValue: function (value, formatterFn) { 16361 currentHookNameInDev = 'useDebugValue'; 16362 updateHookTypesDev(); 16363 return mountDebugValue(); 16364 }, 16365 useDeferredValue: function (value) { 16366 currentHookNameInDev = 'useDeferredValue'; 16367 updateHookTypesDev(); 16368 return mountDeferredValue(value); 16369 }, 16370 useTransition: function () { 16371 currentHookNameInDev = 'useTransition'; 16372 updateHookTypesDev(); 16373 return mountTransition(); 16374 }, 16375 useMutableSource: function (source, getSnapshot, subscribe) { 16376 currentHookNameInDev = 'useMutableSource'; 16377 updateHookTypesDev(); 16378 return mountMutableSource(source, getSnapshot, subscribe); 16379 }, 16380 useOpaqueIdentifier: function () { 16381 currentHookNameInDev = 'useOpaqueIdentifier'; 16382 updateHookTypesDev(); 16383 return mountOpaqueIdentifier(); 16384 }, 16385 unstable_isNewReconciler: enableNewReconciler 16386 }; 16387 HooksDispatcherOnUpdateInDEV = { 16388 readContext: function (context, observedBits) { 16389 return readContext(context, observedBits); 16390 }, 16391 useCallback: function (callback, deps) { 16392 currentHookNameInDev = 'useCallback'; 16393 updateHookTypesDev(); 16394 return updateCallback(callback, deps); 16395 }, 16396 useContext: function (context, observedBits) { 16397 currentHookNameInDev = 'useContext'; 16398 updateHookTypesDev(); 16399 return readContext(context, observedBits); 16400 }, 16401 useEffect: function (create, deps) { 16402 currentHookNameInDev = 'useEffect'; 16403 updateHookTypesDev(); 16404 return updateEffect(create, deps); 16405 }, 16406 useImperativeHandle: function (ref, create, deps) { 16407 currentHookNameInDev = 'useImperativeHandle'; 16408 updateHookTypesDev(); 16409 return updateImperativeHandle(ref, create, deps); 16410 }, 16411 useLayoutEffect: function (create, deps) { 16412 currentHookNameInDev = 'useLayoutEffect'; 16413 updateHookTypesDev(); 16414 return updateLayoutEffect(create, deps); 16415 }, 16416 useMemo: function (create, deps) { 16417 currentHookNameInDev = 'useMemo'; 16418 updateHookTypesDev(); 16419 var prevDispatcher = ReactCurrentDispatcher$1.current; 16420 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; 16421 16422 try { 16423 return updateMemo(create, deps); 16424 } finally { 16425 ReactCurrentDispatcher$1.current = prevDispatcher; 16426 } 16427 }, 16428 useReducer: function (reducer, initialArg, init) { 16429 currentHookNameInDev = 'useReducer'; 16430 updateHookTypesDev(); 16431 var prevDispatcher = ReactCurrentDispatcher$1.current; 16432 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; 16433 16434 try { 16435 return updateReducer(reducer, initialArg, init); 16436 } finally { 16437 ReactCurrentDispatcher$1.current = prevDispatcher; 16438 } 16439 }, 16440 useRef: function (initialValue) { 16441 currentHookNameInDev = 'useRef'; 16442 updateHookTypesDev(); 16443 return updateRef(); 16444 }, 16445 useState: function (initialState) { 16446 currentHookNameInDev = 'useState'; 16447 updateHookTypesDev(); 16448 var prevDispatcher = ReactCurrentDispatcher$1.current; 16449 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; 16450 16451 try { 16452 return updateState(initialState); 16453 } finally { 16454 ReactCurrentDispatcher$1.current = prevDispatcher; 16455 } 16456 }, 16457 useDebugValue: function (value, formatterFn) { 16458 currentHookNameInDev = 'useDebugValue'; 16459 updateHookTypesDev(); 16460 return updateDebugValue(); 16461 }, 16462 useDeferredValue: function (value) { 16463 currentHookNameInDev = 'useDeferredValue'; 16464 updateHookTypesDev(); 16465 return updateDeferredValue(value); 16466 }, 16467 useTransition: function () { 16468 currentHookNameInDev = 'useTransition'; 16469 updateHookTypesDev(); 16470 return updateTransition(); 16471 }, 16472 useMutableSource: function (source, getSnapshot, subscribe) { 16473 currentHookNameInDev = 'useMutableSource'; 16474 updateHookTypesDev(); 16475 return updateMutableSource(source, getSnapshot, subscribe); 16476 }, 16477 useOpaqueIdentifier: function () { 16478 currentHookNameInDev = 'useOpaqueIdentifier'; 16479 updateHookTypesDev(); 16480 return updateOpaqueIdentifier(); 16481 }, 16482 unstable_isNewReconciler: enableNewReconciler 16483 }; 16484 HooksDispatcherOnRerenderInDEV = { 16485 readContext: function (context, observedBits) { 16486 return readContext(context, observedBits); 16487 }, 16488 useCallback: function (callback, deps) { 16489 currentHookNameInDev = 'useCallback'; 16490 updateHookTypesDev(); 16491 return updateCallback(callback, deps); 16492 }, 16493 useContext: function (context, observedBits) { 16494 currentHookNameInDev = 'useContext'; 16495 updateHookTypesDev(); 16496 return readContext(context, observedBits); 16497 }, 16498 useEffect: function (create, deps) { 16499 currentHookNameInDev = 'useEffect'; 16500 updateHookTypesDev(); 16501 return updateEffect(create, deps); 16502 }, 16503 useImperativeHandle: function (ref, create, deps) { 16504 currentHookNameInDev = 'useImperativeHandle'; 16505 updateHookTypesDev(); 16506 return updateImperativeHandle(ref, create, deps); 16507 }, 16508 useLayoutEffect: function (create, deps) { 16509 currentHookNameInDev = 'useLayoutEffect'; 16510 updateHookTypesDev(); 16511 return updateLayoutEffect(create, deps); 16512 }, 16513 useMemo: function (create, deps) { 16514 currentHookNameInDev = 'useMemo'; 16515 updateHookTypesDev(); 16516 var prevDispatcher = ReactCurrentDispatcher$1.current; 16517 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnRerenderInDEV; 16518 16519 try { 16520 return updateMemo(create, deps); 16521 } finally { 16522 ReactCurrentDispatcher$1.current = prevDispatcher; 16523 } 16524 }, 16525 useReducer: function (reducer, initialArg, init) { 16526 currentHookNameInDev = 'useReducer'; 16527 updateHookTypesDev(); 16528 var prevDispatcher = ReactCurrentDispatcher$1.current; 16529 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnRerenderInDEV; 16530 16531 try { 16532 return rerenderReducer(reducer, initialArg, init); 16533 } finally { 16534 ReactCurrentDispatcher$1.current = prevDispatcher; 16535 } 16536 }, 16537 useRef: function (initialValue) { 16538 currentHookNameInDev = 'useRef'; 16539 updateHookTypesDev(); 16540 return updateRef(); 16541 }, 16542 useState: function (initialState) { 16543 currentHookNameInDev = 'useState'; 16544 updateHookTypesDev(); 16545 var prevDispatcher = ReactCurrentDispatcher$1.current; 16546 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnRerenderInDEV; 16547 16548 try { 16549 return rerenderState(initialState); 16550 } finally { 16551 ReactCurrentDispatcher$1.current = prevDispatcher; 16552 } 16553 }, 16554 useDebugValue: function (value, formatterFn) { 16555 currentHookNameInDev = 'useDebugValue'; 16556 updateHookTypesDev(); 16557 return updateDebugValue(); 16558 }, 16559 useDeferredValue: function (value) { 16560 currentHookNameInDev = 'useDeferredValue'; 16561 updateHookTypesDev(); 16562 return rerenderDeferredValue(value); 16563 }, 16564 useTransition: function () { 16565 currentHookNameInDev = 'useTransition'; 16566 updateHookTypesDev(); 16567 return rerenderTransition(); 16568 }, 16569 useMutableSource: function (source, getSnapshot, subscribe) { 16570 currentHookNameInDev = 'useMutableSource'; 16571 updateHookTypesDev(); 16572 return updateMutableSource(source, getSnapshot, subscribe); 16573 }, 16574 useOpaqueIdentifier: function () { 16575 currentHookNameInDev = 'useOpaqueIdentifier'; 16576 updateHookTypesDev(); 16577 return rerenderOpaqueIdentifier(); 16578 }, 16579 unstable_isNewReconciler: enableNewReconciler 16580 }; 16581 InvalidNestedHooksDispatcherOnMountInDEV = { 16582 readContext: function (context, observedBits) { 16583 warnInvalidContextAccess(); 16584 return readContext(context, observedBits); 16585 }, 16586 useCallback: function (callback, deps) { 16587 currentHookNameInDev = 'useCallback'; 16588 warnInvalidHookAccess(); 16589 mountHookTypesDev(); 16590 return mountCallback(callback, deps); 16591 }, 16592 useContext: function (context, observedBits) { 16593 currentHookNameInDev = 'useContext'; 16594 warnInvalidHookAccess(); 16595 mountHookTypesDev(); 16596 return readContext(context, observedBits); 16597 }, 16598 useEffect: function (create, deps) { 16599 currentHookNameInDev = 'useEffect'; 16600 warnInvalidHookAccess(); 16601 mountHookTypesDev(); 16602 return mountEffect(create, deps); 16603 }, 16604 useImperativeHandle: function (ref, create, deps) { 16605 currentHookNameInDev = 'useImperativeHandle'; 16606 warnInvalidHookAccess(); 16607 mountHookTypesDev(); 16608 return mountImperativeHandle(ref, create, deps); 16609 }, 16610 useLayoutEffect: function (create, deps) { 16611 currentHookNameInDev = 'useLayoutEffect'; 16612 warnInvalidHookAccess(); 16613 mountHookTypesDev(); 16614 return mountLayoutEffect(create, deps); 16615 }, 16616 useMemo: function (create, deps) { 16617 currentHookNameInDev = 'useMemo'; 16618 warnInvalidHookAccess(); 16619 mountHookTypesDev(); 16620 var prevDispatcher = ReactCurrentDispatcher$1.current; 16621 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; 16622 16623 try { 16624 return mountMemo(create, deps); 16625 } finally { 16626 ReactCurrentDispatcher$1.current = prevDispatcher; 16627 } 16628 }, 16629 useReducer: function (reducer, initialArg, init) { 16630 currentHookNameInDev = 'useReducer'; 16631 warnInvalidHookAccess(); 16632 mountHookTypesDev(); 16633 var prevDispatcher = ReactCurrentDispatcher$1.current; 16634 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; 16635 16636 try { 16637 return mountReducer(reducer, initialArg, init); 16638 } finally { 16639 ReactCurrentDispatcher$1.current = prevDispatcher; 16640 } 16641 }, 16642 useRef: function (initialValue) { 16643 currentHookNameInDev = 'useRef'; 16644 warnInvalidHookAccess(); 16645 mountHookTypesDev(); 16646 return mountRef(initialValue); 16647 }, 16648 useState: function (initialState) { 16649 currentHookNameInDev = 'useState'; 16650 warnInvalidHookAccess(); 16651 mountHookTypesDev(); 16652 var prevDispatcher = ReactCurrentDispatcher$1.current; 16653 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; 16654 16655 try { 16656 return mountState(initialState); 16657 } finally { 16658 ReactCurrentDispatcher$1.current = prevDispatcher; 16659 } 16660 }, 16661 useDebugValue: function (value, formatterFn) { 16662 currentHookNameInDev = 'useDebugValue'; 16663 warnInvalidHookAccess(); 16664 mountHookTypesDev(); 16665 return mountDebugValue(); 16666 }, 16667 useDeferredValue: function (value) { 16668 currentHookNameInDev = 'useDeferredValue'; 16669 warnInvalidHookAccess(); 16670 mountHookTypesDev(); 16671 return mountDeferredValue(value); 16672 }, 16673 useTransition: function () { 16674 currentHookNameInDev = 'useTransition'; 16675 warnInvalidHookAccess(); 16676 mountHookTypesDev(); 16677 return mountTransition(); 16678 }, 16679 useMutableSource: function (source, getSnapshot, subscribe) { 16680 currentHookNameInDev = 'useMutableSource'; 16681 warnInvalidHookAccess(); 16682 mountHookTypesDev(); 16683 return mountMutableSource(source, getSnapshot, subscribe); 16684 }, 16685 useOpaqueIdentifier: function () { 16686 currentHookNameInDev = 'useOpaqueIdentifier'; 16687 warnInvalidHookAccess(); 16688 mountHookTypesDev(); 16689 return mountOpaqueIdentifier(); 16690 }, 16691 unstable_isNewReconciler: enableNewReconciler 16692 }; 16693 InvalidNestedHooksDispatcherOnUpdateInDEV = { 16694 readContext: function (context, observedBits) { 16695 warnInvalidContextAccess(); 16696 return readContext(context, observedBits); 16697 }, 16698 useCallback: function (callback, deps) { 16699 currentHookNameInDev = 'useCallback'; 16700 warnInvalidHookAccess(); 16701 updateHookTypesDev(); 16702 return updateCallback(callback, deps); 16703 }, 16704 useContext: function (context, observedBits) { 16705 currentHookNameInDev = 'useContext'; 16706 warnInvalidHookAccess(); 16707 updateHookTypesDev(); 16708 return readContext(context, observedBits); 16709 }, 16710 useEffect: function (create, deps) { 16711 currentHookNameInDev = 'useEffect'; 16712 warnInvalidHookAccess(); 16713 updateHookTypesDev(); 16714 return updateEffect(create, deps); 16715 }, 16716 useImperativeHandle: function (ref, create, deps) { 16717 currentHookNameInDev = 'useImperativeHandle'; 16718 warnInvalidHookAccess(); 16719 updateHookTypesDev(); 16720 return updateImperativeHandle(ref, create, deps); 16721 }, 16722 useLayoutEffect: function (create, deps) { 16723 currentHookNameInDev = 'useLayoutEffect'; 16724 warnInvalidHookAccess(); 16725 updateHookTypesDev(); 16726 return updateLayoutEffect(create, deps); 16727 }, 16728 useMemo: function (create, deps) { 16729 currentHookNameInDev = 'useMemo'; 16730 warnInvalidHookAccess(); 16731 updateHookTypesDev(); 16732 var prevDispatcher = ReactCurrentDispatcher$1.current; 16733 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; 16734 16735 try { 16736 return updateMemo(create, deps); 16737 } finally { 16738 ReactCurrentDispatcher$1.current = prevDispatcher; 16739 } 16740 }, 16741 useReducer: function (reducer, initialArg, init) { 16742 currentHookNameInDev = 'useReducer'; 16743 warnInvalidHookAccess(); 16744 updateHookTypesDev(); 16745 var prevDispatcher = ReactCurrentDispatcher$1.current; 16746 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; 16747 16748 try { 16749 return updateReducer(reducer, initialArg, init); 16750 } finally { 16751 ReactCurrentDispatcher$1.current = prevDispatcher; 16752 } 16753 }, 16754 useRef: function (initialValue) { 16755 currentHookNameInDev = 'useRef'; 16756 warnInvalidHookAccess(); 16757 updateHookTypesDev(); 16758 return updateRef(); 16759 }, 16760 useState: function (initialState) { 16761 currentHookNameInDev = 'useState'; 16762 warnInvalidHookAccess(); 16763 updateHookTypesDev(); 16764 var prevDispatcher = ReactCurrentDispatcher$1.current; 16765 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; 16766 16767 try { 16768 return updateState(initialState); 16769 } finally { 16770 ReactCurrentDispatcher$1.current = prevDispatcher; 16771 } 16772 }, 16773 useDebugValue: function (value, formatterFn) { 16774 currentHookNameInDev = 'useDebugValue'; 16775 warnInvalidHookAccess(); 16776 updateHookTypesDev(); 16777 return updateDebugValue(); 16778 }, 16779 useDeferredValue: function (value) { 16780 currentHookNameInDev = 'useDeferredValue'; 16781 warnInvalidHookAccess(); 16782 updateHookTypesDev(); 16783 return updateDeferredValue(value); 16784 }, 16785 useTransition: function () { 16786 currentHookNameInDev = 'useTransition'; 16787 warnInvalidHookAccess(); 16788 updateHookTypesDev(); 16789 return updateTransition(); 16790 }, 16791 useMutableSource: function (source, getSnapshot, subscribe) { 16792 currentHookNameInDev = 'useMutableSource'; 16793 warnInvalidHookAccess(); 16794 updateHookTypesDev(); 16795 return updateMutableSource(source, getSnapshot, subscribe); 16796 }, 16797 useOpaqueIdentifier: function () { 16798 currentHookNameInDev = 'useOpaqueIdentifier'; 16799 warnInvalidHookAccess(); 16800 updateHookTypesDev(); 16801 return updateOpaqueIdentifier(); 16802 }, 16803 unstable_isNewReconciler: enableNewReconciler 16804 }; 16805 InvalidNestedHooksDispatcherOnRerenderInDEV = { 16806 readContext: function (context, observedBits) { 16807 warnInvalidContextAccess(); 16808 return readContext(context, observedBits); 16809 }, 16810 useCallback: function (callback, deps) { 16811 currentHookNameInDev = 'useCallback'; 16812 warnInvalidHookAccess(); 16813 updateHookTypesDev(); 16814 return updateCallback(callback, deps); 16815 }, 16816 useContext: function (context, observedBits) { 16817 currentHookNameInDev = 'useContext'; 16818 warnInvalidHookAccess(); 16819 updateHookTypesDev(); 16820 return readContext(context, observedBits); 16821 }, 16822 useEffect: function (create, deps) { 16823 currentHookNameInDev = 'useEffect'; 16824 warnInvalidHookAccess(); 16825 updateHookTypesDev(); 16826 return updateEffect(create, deps); 16827 }, 16828 useImperativeHandle: function (ref, create, deps) { 16829 currentHookNameInDev = 'useImperativeHandle'; 16830 warnInvalidHookAccess(); 16831 updateHookTypesDev(); 16832 return updateImperativeHandle(ref, create, deps); 16833 }, 16834 useLayoutEffect: function (create, deps) { 16835 currentHookNameInDev = 'useLayoutEffect'; 16836 warnInvalidHookAccess(); 16837 updateHookTypesDev(); 16838 return updateLayoutEffect(create, deps); 16839 }, 16840 useMemo: function (create, deps) { 16841 currentHookNameInDev = 'useMemo'; 16842 warnInvalidHookAccess(); 16843 updateHookTypesDev(); 16844 var prevDispatcher = ReactCurrentDispatcher$1.current; 16845 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; 16846 16847 try { 16848 return updateMemo(create, deps); 16849 } finally { 16850 ReactCurrentDispatcher$1.current = prevDispatcher; 16851 } 16852 }, 16853 useReducer: function (reducer, initialArg, init) { 16854 currentHookNameInDev = 'useReducer'; 16855 warnInvalidHookAccess(); 16856 updateHookTypesDev(); 16857 var prevDispatcher = ReactCurrentDispatcher$1.current; 16858 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; 16859 16860 try { 16861 return rerenderReducer(reducer, initialArg, init); 16862 } finally { 16863 ReactCurrentDispatcher$1.current = prevDispatcher; 16864 } 16865 }, 16866 useRef: function (initialValue) { 16867 currentHookNameInDev = 'useRef'; 16868 warnInvalidHookAccess(); 16869 updateHookTypesDev(); 16870 return updateRef(); 16871 }, 16872 useState: function (initialState) { 16873 currentHookNameInDev = 'useState'; 16874 warnInvalidHookAccess(); 16875 updateHookTypesDev(); 16876 var prevDispatcher = ReactCurrentDispatcher$1.current; 16877 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; 16878 16879 try { 16880 return rerenderState(initialState); 16881 } finally { 16882 ReactCurrentDispatcher$1.current = prevDispatcher; 16883 } 16884 }, 16885 useDebugValue: function (value, formatterFn) { 16886 currentHookNameInDev = 'useDebugValue'; 16887 warnInvalidHookAccess(); 16888 updateHookTypesDev(); 16889 return updateDebugValue(); 16890 }, 16891 useDeferredValue: function (value) { 16892 currentHookNameInDev = 'useDeferredValue'; 16893 warnInvalidHookAccess(); 16894 updateHookTypesDev(); 16895 return rerenderDeferredValue(value); 16896 }, 16897 useTransition: function () { 16898 currentHookNameInDev = 'useTransition'; 16899 warnInvalidHookAccess(); 16900 updateHookTypesDev(); 16901 return rerenderTransition(); 16902 }, 16903 useMutableSource: function (source, getSnapshot, subscribe) { 16904 currentHookNameInDev = 'useMutableSource'; 16905 warnInvalidHookAccess(); 16906 updateHookTypesDev(); 16907 return updateMutableSource(source, getSnapshot, subscribe); 16908 }, 16909 useOpaqueIdentifier: function () { 16910 currentHookNameInDev = 'useOpaqueIdentifier'; 16911 warnInvalidHookAccess(); 16912 updateHookTypesDev(); 16913 return rerenderOpaqueIdentifier(); 16914 }, 16915 unstable_isNewReconciler: enableNewReconciler 16916 }; 16917} 16918 16919var now$1 = Scheduler.unstable_now; 16920var commitTime = 0; 16921var profilerStartTime = -1; 16922 16923function getCommitTime() { 16924 return commitTime; 16925} 16926 16927function recordCommitTime() { 16928 16929 commitTime = now$1(); 16930} 16931 16932function startProfilerTimer(fiber) { 16933 16934 profilerStartTime = now$1(); 16935 16936 if (fiber.actualStartTime < 0) { 16937 fiber.actualStartTime = now$1(); 16938 } 16939} 16940 16941function stopProfilerTimerIfRunning(fiber) { 16942 16943 profilerStartTime = -1; 16944} 16945 16946function stopProfilerTimerIfRunningAndRecordDelta(fiber, overrideBaseTime) { 16947 16948 if (profilerStartTime >= 0) { 16949 var elapsedTime = now$1() - profilerStartTime; 16950 fiber.actualDuration += elapsedTime; 16951 16952 if (overrideBaseTime) { 16953 fiber.selfBaseDuration = elapsedTime; 16954 } 16955 16956 profilerStartTime = -1; 16957 } 16958} 16959 16960function transferActualDuration(fiber) { 16961 // Transfer time spent rendering these children so we don't lose it 16962 // after we rerender. This is used as a helper in special cases 16963 // where we should count the work of multiple passes. 16964 var child = fiber.child; 16965 16966 while (child) { 16967 fiber.actualDuration += child.actualDuration; 16968 child = child.sibling; 16969 } 16970} 16971 16972var ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner; 16973var didReceiveUpdate = false; 16974var didWarnAboutBadClass; 16975var didWarnAboutModulePatternComponent; 16976var didWarnAboutContextTypeOnFunctionComponent; 16977var didWarnAboutGetDerivedStateOnFunctionComponent; 16978var didWarnAboutFunctionRefs; 16979var didWarnAboutReassigningProps; 16980var didWarnAboutRevealOrder; 16981var didWarnAboutTailOptions; 16982 16983{ 16984 didWarnAboutBadClass = {}; 16985 didWarnAboutModulePatternComponent = {}; 16986 didWarnAboutContextTypeOnFunctionComponent = {}; 16987 didWarnAboutGetDerivedStateOnFunctionComponent = {}; 16988 didWarnAboutFunctionRefs = {}; 16989 didWarnAboutReassigningProps = false; 16990 didWarnAboutRevealOrder = {}; 16991 didWarnAboutTailOptions = {}; 16992} 16993 16994function reconcileChildren(current, workInProgress, nextChildren, renderLanes) { 16995 if (current === null) { 16996 // If this is a fresh new component that hasn't been rendered yet, we 16997 // won't update its child set by applying minimal side-effects. Instead, 16998 // we will add them all to the child before it gets rendered. That means 16999 // we can optimize this reconciliation pass by not tracking side-effects. 17000 workInProgress.child = mountChildFibers(workInProgress, null, nextChildren, renderLanes); 17001 } else { 17002 // If the current child is the same as the work in progress, it means that 17003 // we haven't yet started any work on these children. Therefore, we use 17004 // the clone algorithm to create a copy of all the current children. 17005 // If we had any progressed work already, that is invalid at this point so 17006 // let's throw it out. 17007 workInProgress.child = reconcileChildFibers(workInProgress, current.child, nextChildren, renderLanes); 17008 } 17009} 17010 17011function forceUnmountCurrentAndReconcile(current, workInProgress, nextChildren, renderLanes) { 17012 // This function is fork of reconcileChildren. It's used in cases where we 17013 // want to reconcile without matching against the existing set. This has the 17014 // effect of all current children being unmounted; even if the type and key 17015 // are the same, the old child is unmounted and a new child is created. 17016 // 17017 // To do this, we're going to go through the reconcile algorithm twice. In 17018 // the first pass, we schedule a deletion for all the current children by 17019 // passing null. 17020 workInProgress.child = reconcileChildFibers(workInProgress, current.child, null, renderLanes); // In the second pass, we mount the new children. The trick here is that we 17021 // pass null in place of where we usually pass the current child set. This has 17022 // the effect of remounting all children regardless of whether their 17023 // identities match. 17024 17025 workInProgress.child = reconcileChildFibers(workInProgress, null, nextChildren, renderLanes); 17026} 17027 17028function updateForwardRef(current, workInProgress, Component, nextProps, renderLanes) { 17029 // TODO: current can be non-null here even if the component 17030 // hasn't yet mounted. This happens after the first render suspends. 17031 // We'll need to figure out if this is fine or can cause issues. 17032 { 17033 if (workInProgress.type !== workInProgress.elementType) { 17034 // Lazy component props can't be validated in createElement 17035 // because they're only guaranteed to be resolved here. 17036 var innerPropTypes = Component.propTypes; 17037 17038 if (innerPropTypes) { 17039 checkPropTypes(innerPropTypes, nextProps, // Resolved props 17040 'prop', getComponentName(Component)); 17041 } 17042 } 17043 } 17044 17045 var render = Component.render; 17046 var ref = workInProgress.ref; // The rest is a fork of updateFunctionComponent 17047 17048 var nextChildren; 17049 prepareToReadContext(workInProgress, renderLanes); 17050 17051 { 17052 ReactCurrentOwner$1.current = workInProgress; 17053 setIsRendering(true); 17054 nextChildren = renderWithHooks(current, workInProgress, render, nextProps, ref, renderLanes); 17055 17056 if ( workInProgress.mode & StrictMode) { 17057 disableLogs(); 17058 17059 try { 17060 nextChildren = renderWithHooks(current, workInProgress, render, nextProps, ref, renderLanes); 17061 } finally { 17062 reenableLogs(); 17063 } 17064 } 17065 17066 setIsRendering(false); 17067 } 17068 17069 if (current !== null && !didReceiveUpdate) { 17070 bailoutHooks(current, workInProgress, renderLanes); 17071 return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); 17072 } // React DevTools reads this flag. 17073 17074 17075 workInProgress.flags |= PerformedWork; 17076 reconcileChildren(current, workInProgress, nextChildren, renderLanes); 17077 return workInProgress.child; 17078} 17079 17080function updateMemoComponent(current, workInProgress, Component, nextProps, updateLanes, renderLanes) { 17081 if (current === null) { 17082 var type = Component.type; 17083 17084 if (isSimpleFunctionComponent(type) && Component.compare === null && // SimpleMemoComponent codepath doesn't resolve outer props either. 17085 Component.defaultProps === undefined) { 17086 var resolvedType = type; 17087 17088 { 17089 resolvedType = resolveFunctionForHotReloading(type); 17090 } // If this is a plain function component without default props, 17091 // and with only the default shallow comparison, we upgrade it 17092 // to a SimpleMemoComponent to allow fast path updates. 17093 17094 17095 workInProgress.tag = SimpleMemoComponent; 17096 workInProgress.type = resolvedType; 17097 17098 { 17099 validateFunctionComponentInDev(workInProgress, type); 17100 } 17101 17102 return updateSimpleMemoComponent(current, workInProgress, resolvedType, nextProps, updateLanes, renderLanes); 17103 } 17104 17105 { 17106 var innerPropTypes = type.propTypes; 17107 17108 if (innerPropTypes) { 17109 // Inner memo component props aren't currently validated in createElement. 17110 // We could move it there, but we'd still need this for lazy code path. 17111 checkPropTypes(innerPropTypes, nextProps, // Resolved props 17112 'prop', getComponentName(type)); 17113 } 17114 } 17115 17116 var child = createFiberFromTypeAndProps(Component.type, null, nextProps, workInProgress, workInProgress.mode, renderLanes); 17117 child.ref = workInProgress.ref; 17118 child.return = workInProgress; 17119 workInProgress.child = child; 17120 return child; 17121 } 17122 17123 { 17124 var _type = Component.type; 17125 var _innerPropTypes = _type.propTypes; 17126 17127 if (_innerPropTypes) { 17128 // Inner memo component props aren't currently validated in createElement. 17129 // We could move it there, but we'd still need this for lazy code path. 17130 checkPropTypes(_innerPropTypes, nextProps, // Resolved props 17131 'prop', getComponentName(_type)); 17132 } 17133 } 17134 17135 var currentChild = current.child; // This is always exactly one child 17136 17137 if (!includesSomeLane(updateLanes, renderLanes)) { 17138 // This will be the props with resolved defaultProps, 17139 // unlike current.memoizedProps which will be the unresolved ones. 17140 var prevProps = currentChild.memoizedProps; // Default to shallow comparison 17141 17142 var compare = Component.compare; 17143 compare = compare !== null ? compare : shallowEqual; 17144 17145 if (compare(prevProps, nextProps) && current.ref === workInProgress.ref) { 17146 return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); 17147 } 17148 } // React DevTools reads this flag. 17149 17150 17151 workInProgress.flags |= PerformedWork; 17152 var newChild = createWorkInProgress(currentChild, nextProps); 17153 newChild.ref = workInProgress.ref; 17154 newChild.return = workInProgress; 17155 workInProgress.child = newChild; 17156 return newChild; 17157} 17158 17159function updateSimpleMemoComponent(current, workInProgress, Component, nextProps, updateLanes, renderLanes) { 17160 // TODO: current can be non-null here even if the component 17161 // hasn't yet mounted. This happens when the inner render suspends. 17162 // We'll need to figure out if this is fine or can cause issues. 17163 { 17164 if (workInProgress.type !== workInProgress.elementType) { 17165 // Lazy component props can't be validated in createElement 17166 // because they're only guaranteed to be resolved here. 17167 var outerMemoType = workInProgress.elementType; 17168 17169 if (outerMemoType.$$typeof === REACT_LAZY_TYPE) { 17170 // We warn when you define propTypes on lazy() 17171 // so let's just skip over it to find memo() outer wrapper. 17172 // Inner props for memo are validated later. 17173 var lazyComponent = outerMemoType; 17174 var payload = lazyComponent._payload; 17175 var init = lazyComponent._init; 17176 17177 try { 17178 outerMemoType = init(payload); 17179 } catch (x) { 17180 outerMemoType = null; 17181 } // Inner propTypes will be validated in the function component path. 17182 17183 17184 var outerPropTypes = outerMemoType && outerMemoType.propTypes; 17185 17186 if (outerPropTypes) { 17187 checkPropTypes(outerPropTypes, nextProps, // Resolved (SimpleMemoComponent has no defaultProps) 17188 'prop', getComponentName(outerMemoType)); 17189 } 17190 } 17191 } 17192 } 17193 17194 if (current !== null) { 17195 var prevProps = current.memoizedProps; 17196 17197 if (shallowEqual(prevProps, nextProps) && current.ref === workInProgress.ref && ( // Prevent bailout if the implementation changed due to hot reload. 17198 workInProgress.type === current.type )) { 17199 didReceiveUpdate = false; 17200 17201 if (!includesSomeLane(renderLanes, updateLanes)) { 17202 // The pending lanes were cleared at the beginning of beginWork. We're 17203 // about to bail out, but there might be other lanes that weren't 17204 // included in the current render. Usually, the priority level of the 17205 // remaining updates is accumlated during the evaluation of the 17206 // component (i.e. when processing the update queue). But since since 17207 // we're bailing out early *without* evaluating the component, we need 17208 // to account for it here, too. Reset to the value of the current fiber. 17209 // NOTE: This only applies to SimpleMemoComponent, not MemoComponent, 17210 // because a MemoComponent fiber does not have hooks or an update queue; 17211 // rather, it wraps around an inner component, which may or may not 17212 // contains hooks. 17213 // TODO: Move the reset at in beginWork out of the common path so that 17214 // this is no longer necessary. 17215 workInProgress.lanes = current.lanes; 17216 return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); 17217 } else if ((current.flags & ForceUpdateForLegacySuspense) !== NoFlags) { 17218 // This is a special case that only exists for legacy mode. 17219 // See https://github.com/facebook/react/pull/19216. 17220 didReceiveUpdate = true; 17221 } 17222 } 17223 } 17224 17225 return updateFunctionComponent(current, workInProgress, Component, nextProps, renderLanes); 17226} 17227 17228function updateOffscreenComponent(current, workInProgress, renderLanes) { 17229 var nextProps = workInProgress.pendingProps; 17230 var nextChildren = nextProps.children; 17231 var prevState = current !== null ? current.memoizedState : null; 17232 17233 if (nextProps.mode === 'hidden' || nextProps.mode === 'unstable-defer-without-hiding') { 17234 if ((workInProgress.mode & ConcurrentMode) === NoMode) { 17235 // In legacy sync mode, don't defer the subtree. Render it now. 17236 // TODO: Figure out what we should do in Blocking mode. 17237 var nextState = { 17238 baseLanes: NoLanes 17239 }; 17240 workInProgress.memoizedState = nextState; 17241 pushRenderLanes(workInProgress, renderLanes); 17242 } else if (!includesSomeLane(renderLanes, OffscreenLane)) { 17243 var nextBaseLanes; 17244 17245 if (prevState !== null) { 17246 var prevBaseLanes = prevState.baseLanes; 17247 nextBaseLanes = mergeLanes(prevBaseLanes, renderLanes); 17248 } else { 17249 nextBaseLanes = renderLanes; 17250 } // Schedule this fiber to re-render at offscreen priority. Then bailout. 17251 17252 17253 { 17254 markSpawnedWork(OffscreenLane); 17255 } 17256 17257 workInProgress.lanes = workInProgress.childLanes = laneToLanes(OffscreenLane); 17258 var _nextState = { 17259 baseLanes: nextBaseLanes 17260 }; 17261 workInProgress.memoizedState = _nextState; // We're about to bail out, but we need to push this to the stack anyway 17262 // to avoid a push/pop misalignment. 17263 17264 pushRenderLanes(workInProgress, nextBaseLanes); 17265 return null; 17266 } else { 17267 // Rendering at offscreen, so we can clear the base lanes. 17268 var _nextState2 = { 17269 baseLanes: NoLanes 17270 }; 17271 workInProgress.memoizedState = _nextState2; // Push the lanes that were skipped when we bailed out. 17272 17273 var subtreeRenderLanes = prevState !== null ? prevState.baseLanes : renderLanes; 17274 pushRenderLanes(workInProgress, subtreeRenderLanes); 17275 } 17276 } else { 17277 var _subtreeRenderLanes; 17278 17279 if (prevState !== null) { 17280 _subtreeRenderLanes = mergeLanes(prevState.baseLanes, renderLanes); // Since we're not hidden anymore, reset the state 17281 17282 workInProgress.memoizedState = null; 17283 } else { 17284 // We weren't previously hidden, and we still aren't, so there's nothing 17285 // special to do. Need to push to the stack regardless, though, to avoid 17286 // a push/pop misalignment. 17287 _subtreeRenderLanes = renderLanes; 17288 } 17289 17290 pushRenderLanes(workInProgress, _subtreeRenderLanes); 17291 } 17292 17293 reconcileChildren(current, workInProgress, nextChildren, renderLanes); 17294 return workInProgress.child; 17295} // Note: These happen to have identical begin phases, for now. We shouldn't hold 17296// ourselves to this constraint, though. If the behavior diverges, we should 17297// fork the function. 17298 17299 17300var updateLegacyHiddenComponent = updateOffscreenComponent; 17301 17302function updateFragment(current, workInProgress, renderLanes) { 17303 var nextChildren = workInProgress.pendingProps; 17304 reconcileChildren(current, workInProgress, nextChildren, renderLanes); 17305 return workInProgress.child; 17306} 17307 17308function updateMode(current, workInProgress, renderLanes) { 17309 var nextChildren = workInProgress.pendingProps.children; 17310 reconcileChildren(current, workInProgress, nextChildren, renderLanes); 17311 return workInProgress.child; 17312} 17313 17314function updateProfiler(current, workInProgress, renderLanes) { 17315 { 17316 workInProgress.flags |= Update; // Reset effect durations for the next eventual effect phase. 17317 // These are reset during render to allow the DevTools commit hook a chance to read them, 17318 17319 var stateNode = workInProgress.stateNode; 17320 stateNode.effectDuration = 0; 17321 stateNode.passiveEffectDuration = 0; 17322 } 17323 17324 var nextProps = workInProgress.pendingProps; 17325 var nextChildren = nextProps.children; 17326 reconcileChildren(current, workInProgress, nextChildren, renderLanes); 17327 return workInProgress.child; 17328} 17329 17330function markRef(current, workInProgress) { 17331 var ref = workInProgress.ref; 17332 17333 if (current === null && ref !== null || current !== null && current.ref !== ref) { 17334 // Schedule a Ref effect 17335 workInProgress.flags |= Ref; 17336 } 17337} 17338 17339function updateFunctionComponent(current, workInProgress, Component, nextProps, renderLanes) { 17340 { 17341 if (workInProgress.type !== workInProgress.elementType) { 17342 // Lazy component props can't be validated in createElement 17343 // because they're only guaranteed to be resolved here. 17344 var innerPropTypes = Component.propTypes; 17345 17346 if (innerPropTypes) { 17347 checkPropTypes(innerPropTypes, nextProps, // Resolved props 17348 'prop', getComponentName(Component)); 17349 } 17350 } 17351 } 17352 17353 var context; 17354 17355 { 17356 var unmaskedContext = getUnmaskedContext(workInProgress, Component, true); 17357 context = getMaskedContext(workInProgress, unmaskedContext); 17358 } 17359 17360 var nextChildren; 17361 prepareToReadContext(workInProgress, renderLanes); 17362 17363 { 17364 ReactCurrentOwner$1.current = workInProgress; 17365 setIsRendering(true); 17366 nextChildren = renderWithHooks(current, workInProgress, Component, nextProps, context, renderLanes); 17367 17368 if ( workInProgress.mode & StrictMode) { 17369 disableLogs(); 17370 17371 try { 17372 nextChildren = renderWithHooks(current, workInProgress, Component, nextProps, context, renderLanes); 17373 } finally { 17374 reenableLogs(); 17375 } 17376 } 17377 17378 setIsRendering(false); 17379 } 17380 17381 if (current !== null && !didReceiveUpdate) { 17382 bailoutHooks(current, workInProgress, renderLanes); 17383 return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); 17384 } // React DevTools reads this flag. 17385 17386 17387 workInProgress.flags |= PerformedWork; 17388 reconcileChildren(current, workInProgress, nextChildren, renderLanes); 17389 return workInProgress.child; 17390} 17391 17392function updateClassComponent(current, workInProgress, Component, nextProps, renderLanes) { 17393 { 17394 if (workInProgress.type !== workInProgress.elementType) { 17395 // Lazy component props can't be validated in createElement 17396 // because they're only guaranteed to be resolved here. 17397 var innerPropTypes = Component.propTypes; 17398 17399 if (innerPropTypes) { 17400 checkPropTypes(innerPropTypes, nextProps, // Resolved props 17401 'prop', getComponentName(Component)); 17402 } 17403 } 17404 } // Push context providers early to prevent context stack mismatches. 17405 // During mounting we don't know the child context yet as the instance doesn't exist. 17406 // We will invalidate the child context in finishClassComponent() right after rendering. 17407 17408 17409 var hasContext; 17410 17411 if (isContextProvider(Component)) { 17412 hasContext = true; 17413 pushContextProvider(workInProgress); 17414 } else { 17415 hasContext = false; 17416 } 17417 17418 prepareToReadContext(workInProgress, renderLanes); 17419 var instance = workInProgress.stateNode; 17420 var shouldUpdate; 17421 17422 if (instance === null) { 17423 if (current !== null) { 17424 // A class component without an instance only mounts if it suspended 17425 // inside a non-concurrent tree, in an inconsistent state. We want to 17426 // treat it like a new mount, even though an empty version of it already 17427 // committed. Disconnect the alternate pointers. 17428 current.alternate = null; 17429 workInProgress.alternate = null; // Since this is conceptually a new fiber, schedule a Placement effect 17430 17431 workInProgress.flags |= Placement; 17432 } // In the initial pass we might need to construct the instance. 17433 17434 17435 constructClassInstance(workInProgress, Component, nextProps); 17436 mountClassInstance(workInProgress, Component, nextProps, renderLanes); 17437 shouldUpdate = true; 17438 } else if (current === null) { 17439 // In a resume, we'll already have an instance we can reuse. 17440 shouldUpdate = resumeMountClassInstance(workInProgress, Component, nextProps, renderLanes); 17441 } else { 17442 shouldUpdate = updateClassInstance(current, workInProgress, Component, nextProps, renderLanes); 17443 } 17444 17445 var nextUnitOfWork = finishClassComponent(current, workInProgress, Component, shouldUpdate, hasContext, renderLanes); 17446 17447 { 17448 var inst = workInProgress.stateNode; 17449 17450 if (shouldUpdate && inst.props !== nextProps) { 17451 if (!didWarnAboutReassigningProps) { 17452 error('It looks like %s is reassigning its own `this.props` while rendering. ' + 'This is not supported and can lead to confusing bugs.', getComponentName(workInProgress.type) || 'a component'); 17453 } 17454 17455 didWarnAboutReassigningProps = true; 17456 } 17457 } 17458 17459 return nextUnitOfWork; 17460} 17461 17462function finishClassComponent(current, workInProgress, Component, shouldUpdate, hasContext, renderLanes) { 17463 // Refs should update even if shouldComponentUpdate returns false 17464 markRef(current, workInProgress); 17465 var didCaptureError = (workInProgress.flags & DidCapture) !== NoFlags; 17466 17467 if (!shouldUpdate && !didCaptureError) { 17468 // Context providers should defer to sCU for rendering 17469 if (hasContext) { 17470 invalidateContextProvider(workInProgress, Component, false); 17471 } 17472 17473 return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); 17474 } 17475 17476 var instance = workInProgress.stateNode; // Rerender 17477 17478 ReactCurrentOwner$1.current = workInProgress; 17479 var nextChildren; 17480 17481 if (didCaptureError && typeof Component.getDerivedStateFromError !== 'function') { 17482 // If we captured an error, but getDerivedStateFromError is not defined, 17483 // unmount all the children. componentDidCatch will schedule an update to 17484 // re-render a fallback. This is temporary until we migrate everyone to 17485 // the new API. 17486 // TODO: Warn in a future release. 17487 nextChildren = null; 17488 17489 { 17490 stopProfilerTimerIfRunning(); 17491 } 17492 } else { 17493 { 17494 setIsRendering(true); 17495 nextChildren = instance.render(); 17496 17497 if ( workInProgress.mode & StrictMode) { 17498 disableLogs(); 17499 17500 try { 17501 instance.render(); 17502 } finally { 17503 reenableLogs(); 17504 } 17505 } 17506 17507 setIsRendering(false); 17508 } 17509 } // React DevTools reads this flag. 17510 17511 17512 workInProgress.flags |= PerformedWork; 17513 17514 if (current !== null && didCaptureError) { 17515 // If we're recovering from an error, reconcile without reusing any of 17516 // the existing children. Conceptually, the normal children and the children 17517 // that are shown on error are two different sets, so we shouldn't reuse 17518 // normal children even if their identities match. 17519 forceUnmountCurrentAndReconcile(current, workInProgress, nextChildren, renderLanes); 17520 } else { 17521 reconcileChildren(current, workInProgress, nextChildren, renderLanes); 17522 } // Memoize state using the values we just used to render. 17523 // TODO: Restructure so we never read values from the instance. 17524 17525 17526 workInProgress.memoizedState = instance.state; // The context might have changed so we need to recalculate it. 17527 17528 if (hasContext) { 17529 invalidateContextProvider(workInProgress, Component, true); 17530 } 17531 17532 return workInProgress.child; 17533} 17534 17535function pushHostRootContext(workInProgress) { 17536 var root = workInProgress.stateNode; 17537 17538 if (root.pendingContext) { 17539 pushTopLevelContextObject(workInProgress, root.pendingContext, root.pendingContext !== root.context); 17540 } else if (root.context) { 17541 // Should always be set 17542 pushTopLevelContextObject(workInProgress, root.context, false); 17543 } 17544 17545 pushHostContainer(workInProgress, root.containerInfo); 17546} 17547 17548function updateHostRoot(current, workInProgress, renderLanes) { 17549 pushHostRootContext(workInProgress); 17550 var updateQueue = workInProgress.updateQueue; 17551 17552 if (!(current !== null && updateQueue !== null)) { 17553 { 17554 throw Error( "If the root does not have an updateQueue, we should have already bailed out. This error is likely caused by a bug in React. Please file an issue." ); 17555 } 17556 } 17557 17558 var nextProps = workInProgress.pendingProps; 17559 var prevState = workInProgress.memoizedState; 17560 var prevChildren = prevState !== null ? prevState.element : null; 17561 cloneUpdateQueue(current, workInProgress); 17562 processUpdateQueue(workInProgress, nextProps, null, renderLanes); 17563 var nextState = workInProgress.memoizedState; // Caution: React DevTools currently depends on this property 17564 // being called "element". 17565 17566 var nextChildren = nextState.element; 17567 17568 if (nextChildren === prevChildren) { 17569 resetHydrationState(); 17570 return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); 17571 } 17572 17573 var root = workInProgress.stateNode; 17574 17575 if (root.hydrate && enterHydrationState(workInProgress)) { 17576 // If we don't have any current children this might be the first pass. 17577 // We always try to hydrate. If this isn't a hydration pass there won't 17578 // be any children to hydrate which is effectively the same thing as 17579 // not hydrating. 17580 { 17581 var mutableSourceEagerHydrationData = root.mutableSourceEagerHydrationData; 17582 17583 if (mutableSourceEagerHydrationData != null) { 17584 for (var i = 0; i < mutableSourceEagerHydrationData.length; i += 2) { 17585 var mutableSource = mutableSourceEagerHydrationData[i]; 17586 var version = mutableSourceEagerHydrationData[i + 1]; 17587 setWorkInProgressVersion(mutableSource, version); 17588 } 17589 } 17590 } 17591 17592 var child = mountChildFibers(workInProgress, null, nextChildren, renderLanes); 17593 workInProgress.child = child; 17594 var node = child; 17595 17596 while (node) { 17597 // Mark each child as hydrating. This is a fast path to know whether this 17598 // tree is part of a hydrating tree. This is used to determine if a child 17599 // node has fully mounted yet, and for scheduling event replaying. 17600 // Conceptually this is similar to Placement in that a new subtree is 17601 // inserted into the React tree here. It just happens to not need DOM 17602 // mutations because it already exists. 17603 node.flags = node.flags & ~Placement | Hydrating; 17604 node = node.sibling; 17605 } 17606 } else { 17607 // Otherwise reset hydration state in case we aborted and resumed another 17608 // root. 17609 reconcileChildren(current, workInProgress, nextChildren, renderLanes); 17610 resetHydrationState(); 17611 } 17612 17613 return workInProgress.child; 17614} 17615 17616function updateHostComponent(current, workInProgress, renderLanes) { 17617 pushHostContext(workInProgress); 17618 17619 if (current === null) { 17620 tryToClaimNextHydratableInstance(workInProgress); 17621 } 17622 17623 var type = workInProgress.type; 17624 var nextProps = workInProgress.pendingProps; 17625 var prevProps = current !== null ? current.memoizedProps : null; 17626 var nextChildren = nextProps.children; 17627 var isDirectTextChild = shouldSetTextContent(type, nextProps); 17628 17629 if (isDirectTextChild) { 17630 // We special case a direct text child of a host node. This is a common 17631 // case. We won't handle it as a reified child. We will instead handle 17632 // this in the host environment that also has access to this prop. That 17633 // avoids allocating another HostText fiber and traversing it. 17634 nextChildren = null; 17635 } else if (prevProps !== null && shouldSetTextContent(type, prevProps)) { 17636 // If we're switching from a direct text child to a normal child, or to 17637 // empty, we need to schedule the text content to be reset. 17638 workInProgress.flags |= ContentReset; 17639 } 17640 17641 markRef(current, workInProgress); 17642 reconcileChildren(current, workInProgress, nextChildren, renderLanes); 17643 return workInProgress.child; 17644} 17645 17646function updateHostText(current, workInProgress) { 17647 if (current === null) { 17648 tryToClaimNextHydratableInstance(workInProgress); 17649 } // Nothing to do here. This is terminal. We'll do the completion step 17650 // immediately after. 17651 17652 17653 return null; 17654} 17655 17656function mountLazyComponent(_current, workInProgress, elementType, updateLanes, renderLanes) { 17657 if (_current !== null) { 17658 // A lazy component only mounts if it suspended inside a non- 17659 // concurrent tree, in an inconsistent state. We want to treat it like 17660 // a new mount, even though an empty version of it already committed. 17661 // Disconnect the alternate pointers. 17662 _current.alternate = null; 17663 workInProgress.alternate = null; // Since this is conceptually a new fiber, schedule a Placement effect 17664 17665 workInProgress.flags |= Placement; 17666 } 17667 17668 var props = workInProgress.pendingProps; 17669 var lazyComponent = elementType; 17670 var payload = lazyComponent._payload; 17671 var init = lazyComponent._init; 17672 var Component = init(payload); // Store the unwrapped component in the type. 17673 17674 workInProgress.type = Component; 17675 var resolvedTag = workInProgress.tag = resolveLazyComponentTag(Component); 17676 var resolvedProps = resolveDefaultProps(Component, props); 17677 var child; 17678 17679 switch (resolvedTag) { 17680 case FunctionComponent: 17681 { 17682 { 17683 validateFunctionComponentInDev(workInProgress, Component); 17684 workInProgress.type = Component = resolveFunctionForHotReloading(Component); 17685 } 17686 17687 child = updateFunctionComponent(null, workInProgress, Component, resolvedProps, renderLanes); 17688 return child; 17689 } 17690 17691 case ClassComponent: 17692 { 17693 { 17694 workInProgress.type = Component = resolveClassForHotReloading(Component); 17695 } 17696 17697 child = updateClassComponent(null, workInProgress, Component, resolvedProps, renderLanes); 17698 return child; 17699 } 17700 17701 case ForwardRef: 17702 { 17703 { 17704 workInProgress.type = Component = resolveForwardRefForHotReloading(Component); 17705 } 17706 17707 child = updateForwardRef(null, workInProgress, Component, resolvedProps, renderLanes); 17708 return child; 17709 } 17710 17711 case MemoComponent: 17712 { 17713 { 17714 if (workInProgress.type !== workInProgress.elementType) { 17715 var outerPropTypes = Component.propTypes; 17716 17717 if (outerPropTypes) { 17718 checkPropTypes(outerPropTypes, resolvedProps, // Resolved for outer only 17719 'prop', getComponentName(Component)); 17720 } 17721 } 17722 } 17723 17724 child = updateMemoComponent(null, workInProgress, Component, resolveDefaultProps(Component.type, resolvedProps), // The inner type can have defaults too 17725 updateLanes, renderLanes); 17726 return child; 17727 } 17728 } 17729 17730 var hint = ''; 17731 17732 { 17733 if (Component !== null && typeof Component === 'object' && Component.$$typeof === REACT_LAZY_TYPE) { 17734 hint = ' Did you wrap a component in React.lazy() more than once?'; 17735 } 17736 } // This message intentionally doesn't mention ForwardRef or MemoComponent 17737 // because the fact that it's a separate type of work is an 17738 // implementation detail. 17739 17740 17741 { 17742 { 17743 throw Error( "Element type is invalid. Received a promise that resolves to: " + Component + ". Lazy element type must resolve to a class or function." + hint ); 17744 } 17745 } 17746} 17747 17748function mountIncompleteClassComponent(_current, workInProgress, Component, nextProps, renderLanes) { 17749 if (_current !== null) { 17750 // An incomplete component only mounts if it suspended inside a non- 17751 // concurrent tree, in an inconsistent state. We want to treat it like 17752 // a new mount, even though an empty version of it already committed. 17753 // Disconnect the alternate pointers. 17754 _current.alternate = null; 17755 workInProgress.alternate = null; // Since this is conceptually a new fiber, schedule a Placement effect 17756 17757 workInProgress.flags |= Placement; 17758 } // Promote the fiber to a class and try rendering again. 17759 17760 17761 workInProgress.tag = ClassComponent; // The rest of this function is a fork of `updateClassComponent` 17762 // Push context providers early to prevent context stack mismatches. 17763 // During mounting we don't know the child context yet as the instance doesn't exist. 17764 // We will invalidate the child context in finishClassComponent() right after rendering. 17765 17766 var hasContext; 17767 17768 if (isContextProvider(Component)) { 17769 hasContext = true; 17770 pushContextProvider(workInProgress); 17771 } else { 17772 hasContext = false; 17773 } 17774 17775 prepareToReadContext(workInProgress, renderLanes); 17776 constructClassInstance(workInProgress, Component, nextProps); 17777 mountClassInstance(workInProgress, Component, nextProps, renderLanes); 17778 return finishClassComponent(null, workInProgress, Component, true, hasContext, renderLanes); 17779} 17780 17781function mountIndeterminateComponent(_current, workInProgress, Component, renderLanes) { 17782 if (_current !== null) { 17783 // An indeterminate component only mounts if it suspended inside a non- 17784 // concurrent tree, in an inconsistent state. We want to treat it like 17785 // a new mount, even though an empty version of it already committed. 17786 // Disconnect the alternate pointers. 17787 _current.alternate = null; 17788 workInProgress.alternate = null; // Since this is conceptually a new fiber, schedule a Placement effect 17789 17790 workInProgress.flags |= Placement; 17791 } 17792 17793 var props = workInProgress.pendingProps; 17794 var context; 17795 17796 { 17797 var unmaskedContext = getUnmaskedContext(workInProgress, Component, false); 17798 context = getMaskedContext(workInProgress, unmaskedContext); 17799 } 17800 17801 prepareToReadContext(workInProgress, renderLanes); 17802 var value; 17803 17804 { 17805 if (Component.prototype && typeof Component.prototype.render === 'function') { 17806 var componentName = getComponentName(Component) || 'Unknown'; 17807 17808 if (!didWarnAboutBadClass[componentName]) { 17809 error("The <%s /> component appears to have a render method, but doesn't extend React.Component. " + 'This is likely to cause errors. Change %s to extend React.Component instead.', componentName, componentName); 17810 17811 didWarnAboutBadClass[componentName] = true; 17812 } 17813 } 17814 17815 if (workInProgress.mode & StrictMode) { 17816 ReactStrictModeWarnings.recordLegacyContextWarning(workInProgress, null); 17817 } 17818 17819 setIsRendering(true); 17820 ReactCurrentOwner$1.current = workInProgress; 17821 value = renderWithHooks(null, workInProgress, Component, props, context, renderLanes); 17822 setIsRendering(false); 17823 } // React DevTools reads this flag. 17824 17825 17826 workInProgress.flags |= PerformedWork; 17827 17828 { 17829 // Support for module components is deprecated and is removed behind a flag. 17830 // Whether or not it would crash later, we want to show a good message in DEV first. 17831 if (typeof value === 'object' && value !== null && typeof value.render === 'function' && value.$$typeof === undefined) { 17832 var _componentName = getComponentName(Component) || 'Unknown'; 17833 17834 if (!didWarnAboutModulePatternComponent[_componentName]) { 17835 error('The <%s /> component appears to be a function component that returns a class instance. ' + 'Change %s to a class that extends React.Component instead. ' + "If you can't use a class try assigning the prototype on the function as a workaround. " + "`%s.prototype = React.Component.prototype`. Don't use an arrow function since it " + 'cannot be called with `new` by React.', _componentName, _componentName, _componentName); 17836 17837 didWarnAboutModulePatternComponent[_componentName] = true; 17838 } 17839 } 17840 } 17841 17842 if ( // Run these checks in production only if the flag is off. 17843 // Eventually we'll delete this branch altogether. 17844 typeof value === 'object' && value !== null && typeof value.render === 'function' && value.$$typeof === undefined) { 17845 { 17846 var _componentName2 = getComponentName(Component) || 'Unknown'; 17847 17848 if (!didWarnAboutModulePatternComponent[_componentName2]) { 17849 error('The <%s /> component appears to be a function component that returns a class instance. ' + 'Change %s to a class that extends React.Component instead. ' + "If you can't use a class try assigning the prototype on the function as a workaround. " + "`%s.prototype = React.Component.prototype`. Don't use an arrow function since it " + 'cannot be called with `new` by React.', _componentName2, _componentName2, _componentName2); 17850 17851 didWarnAboutModulePatternComponent[_componentName2] = true; 17852 } 17853 } // Proceed under the assumption that this is a class instance 17854 17855 17856 workInProgress.tag = ClassComponent; // Throw out any hooks that were used. 17857 17858 workInProgress.memoizedState = null; 17859 workInProgress.updateQueue = null; // Push context providers early to prevent context stack mismatches. 17860 // During mounting we don't know the child context yet as the instance doesn't exist. 17861 // We will invalidate the child context in finishClassComponent() right after rendering. 17862 17863 var hasContext = false; 17864 17865 if (isContextProvider(Component)) { 17866 hasContext = true; 17867 pushContextProvider(workInProgress); 17868 } else { 17869 hasContext = false; 17870 } 17871 17872 workInProgress.memoizedState = value.state !== null && value.state !== undefined ? value.state : null; 17873 initializeUpdateQueue(workInProgress); 17874 var getDerivedStateFromProps = Component.getDerivedStateFromProps; 17875 17876 if (typeof getDerivedStateFromProps === 'function') { 17877 applyDerivedStateFromProps(workInProgress, Component, getDerivedStateFromProps, props); 17878 } 17879 17880 adoptClassInstance(workInProgress, value); 17881 mountClassInstance(workInProgress, Component, props, renderLanes); 17882 return finishClassComponent(null, workInProgress, Component, true, hasContext, renderLanes); 17883 } else { 17884 // Proceed under the assumption that this is a function component 17885 workInProgress.tag = FunctionComponent; 17886 17887 { 17888 17889 if ( workInProgress.mode & StrictMode) { 17890 disableLogs(); 17891 17892 try { 17893 value = renderWithHooks(null, workInProgress, Component, props, context, renderLanes); 17894 } finally { 17895 reenableLogs(); 17896 } 17897 } 17898 } 17899 17900 reconcileChildren(null, workInProgress, value, renderLanes); 17901 17902 { 17903 validateFunctionComponentInDev(workInProgress, Component); 17904 } 17905 17906 return workInProgress.child; 17907 } 17908} 17909 17910function validateFunctionComponentInDev(workInProgress, Component) { 17911 { 17912 if (Component) { 17913 if (Component.childContextTypes) { 17914 error('%s(...): childContextTypes cannot be defined on a function component.', Component.displayName || Component.name || 'Component'); 17915 } 17916 } 17917 17918 if (workInProgress.ref !== null) { 17919 var info = ''; 17920 var ownerName = getCurrentFiberOwnerNameInDevOrNull(); 17921 17922 if (ownerName) { 17923 info += '\n\nCheck the render method of `' + ownerName + '`.'; 17924 } 17925 17926 var warningKey = ownerName || workInProgress._debugID || ''; 17927 var debugSource = workInProgress._debugSource; 17928 17929 if (debugSource) { 17930 warningKey = debugSource.fileName + ':' + debugSource.lineNumber; 17931 } 17932 17933 if (!didWarnAboutFunctionRefs[warningKey]) { 17934 didWarnAboutFunctionRefs[warningKey] = true; 17935 17936 error('Function components cannot be given refs. ' + 'Attempts to access this ref will fail. ' + 'Did you mean to use React.forwardRef()?%s', info); 17937 } 17938 } 17939 17940 if (typeof Component.getDerivedStateFromProps === 'function') { 17941 var _componentName3 = getComponentName(Component) || 'Unknown'; 17942 17943 if (!didWarnAboutGetDerivedStateOnFunctionComponent[_componentName3]) { 17944 error('%s: Function components do not support getDerivedStateFromProps.', _componentName3); 17945 17946 didWarnAboutGetDerivedStateOnFunctionComponent[_componentName3] = true; 17947 } 17948 } 17949 17950 if (typeof Component.contextType === 'object' && Component.contextType !== null) { 17951 var _componentName4 = getComponentName(Component) || 'Unknown'; 17952 17953 if (!didWarnAboutContextTypeOnFunctionComponent[_componentName4]) { 17954 error('%s: Function components do not support contextType.', _componentName4); 17955 17956 didWarnAboutContextTypeOnFunctionComponent[_componentName4] = true; 17957 } 17958 } 17959 } 17960} 17961 17962var SUSPENDED_MARKER = { 17963 dehydrated: null, 17964 retryLane: NoLane 17965}; 17966 17967function mountSuspenseOffscreenState(renderLanes) { 17968 return { 17969 baseLanes: renderLanes 17970 }; 17971} 17972 17973function updateSuspenseOffscreenState(prevOffscreenState, renderLanes) { 17974 return { 17975 baseLanes: mergeLanes(prevOffscreenState.baseLanes, renderLanes) 17976 }; 17977} // TODO: Probably should inline this back 17978 17979 17980function shouldRemainOnFallback(suspenseContext, current, workInProgress, renderLanes) { 17981 // If we're already showing a fallback, there are cases where we need to 17982 // remain on that fallback regardless of whether the content has resolved. 17983 // For example, SuspenseList coordinates when nested content appears. 17984 if (current !== null) { 17985 var suspenseState = current.memoizedState; 17986 17987 if (suspenseState === null) { 17988 // Currently showing content. Don't hide it, even if ForceSuspenseFallack 17989 // is true. More precise name might be "ForceRemainSuspenseFallback". 17990 // Note: This is a factoring smell. Can't remain on a fallback if there's 17991 // no fallback to remain on. 17992 return false; 17993 } 17994 } // Not currently showing content. Consult the Suspense context. 17995 17996 17997 return hasSuspenseContext(suspenseContext, ForceSuspenseFallback); 17998} 17999 18000function getRemainingWorkInPrimaryTree(current, renderLanes) { 18001 // TODO: Should not remove render lanes that were pinged during this render 18002 return removeLanes(current.childLanes, renderLanes); 18003} 18004 18005function updateSuspenseComponent(current, workInProgress, renderLanes) { 18006 var nextProps = workInProgress.pendingProps; // This is used by DevTools to force a boundary to suspend. 18007 18008 { 18009 if (shouldSuspend(workInProgress)) { 18010 workInProgress.flags |= DidCapture; 18011 } 18012 } 18013 18014 var suspenseContext = suspenseStackCursor.current; 18015 var showFallback = false; 18016 var didSuspend = (workInProgress.flags & DidCapture) !== NoFlags; 18017 18018 if (didSuspend || shouldRemainOnFallback(suspenseContext, current)) { 18019 // Something in this boundary's subtree already suspended. Switch to 18020 // rendering the fallback children. 18021 showFallback = true; 18022 workInProgress.flags &= ~DidCapture; 18023 } else { 18024 // Attempting the main content 18025 if (current === null || current.memoizedState !== null) { 18026 // This is a new mount or this boundary is already showing a fallback state. 18027 // Mark this subtree context as having at least one invisible parent that could 18028 // handle the fallback state. 18029 // Boundaries without fallbacks or should be avoided are not considered since 18030 // they cannot handle preferred fallback states. 18031 if (nextProps.fallback !== undefined && nextProps.unstable_avoidThisFallback !== true) { 18032 suspenseContext = addSubtreeSuspenseContext(suspenseContext, InvisibleParentSuspenseContext); 18033 } 18034 } 18035 } 18036 18037 suspenseContext = setDefaultShallowSuspenseContext(suspenseContext); 18038 pushSuspenseContext(workInProgress, suspenseContext); // OK, the next part is confusing. We're about to reconcile the Suspense 18039 // boundary's children. This involves some custom reconcilation logic. Two 18040 // main reasons this is so complicated. 18041 // 18042 // First, Legacy Mode has different semantics for backwards compatibility. The 18043 // primary tree will commit in an inconsistent state, so when we do the 18044 // second pass to render the fallback, we do some exceedingly, uh, clever 18045 // hacks to make that not totally break. Like transferring effects and 18046 // deletions from hidden tree. In Concurrent Mode, it's much simpler, 18047 // because we bailout on the primary tree completely and leave it in its old 18048 // state, no effects. Same as what we do for Offscreen (except that 18049 // Offscreen doesn't have the first render pass). 18050 // 18051 // Second is hydration. During hydration, the Suspense fiber has a slightly 18052 // different layout, where the child points to a dehydrated fragment, which 18053 // contains the DOM rendered by the server. 18054 // 18055 // Third, even if you set all that aside, Suspense is like error boundaries in 18056 // that we first we try to render one tree, and if that fails, we render again 18057 // and switch to a different tree. Like a try/catch block. So we have to track 18058 // which branch we're currently rendering. Ideally we would model this using 18059 // a stack. 18060 18061 if (current === null) { 18062 // Initial mount 18063 // If we're currently hydrating, try to hydrate this boundary. 18064 // But only if this has a fallback. 18065 if (nextProps.fallback !== undefined) { 18066 tryToClaimNextHydratableInstance(workInProgress); // This could've been a dehydrated suspense component. 18067 } 18068 18069 var nextPrimaryChildren = nextProps.children; 18070 var nextFallbackChildren = nextProps.fallback; 18071 18072 if (showFallback) { 18073 var fallbackFragment = mountSuspenseFallbackChildren(workInProgress, nextPrimaryChildren, nextFallbackChildren, renderLanes); 18074 var primaryChildFragment = workInProgress.child; 18075 primaryChildFragment.memoizedState = mountSuspenseOffscreenState(renderLanes); 18076 workInProgress.memoizedState = SUSPENDED_MARKER; 18077 return fallbackFragment; 18078 } else if (typeof nextProps.unstable_expectedLoadTime === 'number') { 18079 // This is a CPU-bound tree. Skip this tree and show a placeholder to 18080 // unblock the surrounding content. Then immediately retry after the 18081 // initial commit. 18082 var _fallbackFragment = mountSuspenseFallbackChildren(workInProgress, nextPrimaryChildren, nextFallbackChildren, renderLanes); 18083 18084 var _primaryChildFragment = workInProgress.child; 18085 _primaryChildFragment.memoizedState = mountSuspenseOffscreenState(renderLanes); 18086 workInProgress.memoizedState = SUSPENDED_MARKER; // Since nothing actually suspended, there will nothing to ping this to 18087 // get it started back up to attempt the next item. While in terms of 18088 // priority this work has the same priority as this current render, it's 18089 // not part of the same transition once the transition has committed. If 18090 // it's sync, we still want to yield so that it can be painted. 18091 // Conceptually, this is really the same as pinging. We can use any 18092 // RetryLane even if it's the one currently rendering since we're leaving 18093 // it behind on this node. 18094 18095 workInProgress.lanes = SomeRetryLane; 18096 18097 { 18098 markSpawnedWork(SomeRetryLane); 18099 } 18100 18101 return _fallbackFragment; 18102 } else { 18103 return mountSuspensePrimaryChildren(workInProgress, nextPrimaryChildren, renderLanes); 18104 } 18105 } else { 18106 // This is an update. 18107 // If the current fiber has a SuspenseState, that means it's already showing 18108 // a fallback. 18109 var prevState = current.memoizedState; 18110 18111 if (prevState !== null) { 18112 18113 if (showFallback) { 18114 var _nextFallbackChildren2 = nextProps.fallback; 18115 var _nextPrimaryChildren2 = nextProps.children; 18116 18117 var _fallbackChildFragment = updateSuspenseFallbackChildren(current, workInProgress, _nextPrimaryChildren2, _nextFallbackChildren2, renderLanes); 18118 18119 var _primaryChildFragment3 = workInProgress.child; 18120 var prevOffscreenState = current.child.memoizedState; 18121 _primaryChildFragment3.memoizedState = prevOffscreenState === null ? mountSuspenseOffscreenState(renderLanes) : updateSuspenseOffscreenState(prevOffscreenState, renderLanes); 18122 _primaryChildFragment3.childLanes = getRemainingWorkInPrimaryTree(current, renderLanes); 18123 workInProgress.memoizedState = SUSPENDED_MARKER; 18124 return _fallbackChildFragment; 18125 } else { 18126 var _nextPrimaryChildren3 = nextProps.children; 18127 18128 var _primaryChildFragment4 = updateSuspensePrimaryChildren(current, workInProgress, _nextPrimaryChildren3, renderLanes); 18129 18130 workInProgress.memoizedState = null; 18131 return _primaryChildFragment4; 18132 } 18133 } else { 18134 // The current tree is not already showing a fallback. 18135 if (showFallback) { 18136 // Timed out. 18137 var _nextFallbackChildren3 = nextProps.fallback; 18138 var _nextPrimaryChildren4 = nextProps.children; 18139 18140 var _fallbackChildFragment2 = updateSuspenseFallbackChildren(current, workInProgress, _nextPrimaryChildren4, _nextFallbackChildren3, renderLanes); 18141 18142 var _primaryChildFragment5 = workInProgress.child; 18143 var _prevOffscreenState = current.child.memoizedState; 18144 _primaryChildFragment5.memoizedState = _prevOffscreenState === null ? mountSuspenseOffscreenState(renderLanes) : updateSuspenseOffscreenState(_prevOffscreenState, renderLanes); 18145 _primaryChildFragment5.childLanes = getRemainingWorkInPrimaryTree(current, renderLanes); // Skip the primary children, and continue working on the 18146 // fallback children. 18147 18148 workInProgress.memoizedState = SUSPENDED_MARKER; 18149 return _fallbackChildFragment2; 18150 } else { 18151 // Still haven't timed out. Continue rendering the children, like we 18152 // normally do. 18153 var _nextPrimaryChildren5 = nextProps.children; 18154 18155 var _primaryChildFragment6 = updateSuspensePrimaryChildren(current, workInProgress, _nextPrimaryChildren5, renderLanes); 18156 18157 workInProgress.memoizedState = null; 18158 return _primaryChildFragment6; 18159 } 18160 } 18161 } 18162} 18163 18164function mountSuspensePrimaryChildren(workInProgress, primaryChildren, renderLanes) { 18165 var mode = workInProgress.mode; 18166 var primaryChildProps = { 18167 mode: 'visible', 18168 children: primaryChildren 18169 }; 18170 var primaryChildFragment = createFiberFromOffscreen(primaryChildProps, mode, renderLanes, null); 18171 primaryChildFragment.return = workInProgress; 18172 workInProgress.child = primaryChildFragment; 18173 return primaryChildFragment; 18174} 18175 18176function mountSuspenseFallbackChildren(workInProgress, primaryChildren, fallbackChildren, renderLanes) { 18177 var mode = workInProgress.mode; 18178 var progressedPrimaryFragment = workInProgress.child; 18179 var primaryChildProps = { 18180 mode: 'hidden', 18181 children: primaryChildren 18182 }; 18183 var primaryChildFragment; 18184 var fallbackChildFragment; 18185 18186 if ((mode & BlockingMode) === NoMode && progressedPrimaryFragment !== null) { 18187 // In legacy mode, we commit the primary tree as if it successfully 18188 // completed, even though it's in an inconsistent state. 18189 primaryChildFragment = progressedPrimaryFragment; 18190 primaryChildFragment.childLanes = NoLanes; 18191 primaryChildFragment.pendingProps = primaryChildProps; 18192 18193 if ( workInProgress.mode & ProfileMode) { 18194 // Reset the durations from the first pass so they aren't included in the 18195 // final amounts. This seems counterintuitive, since we're intentionally 18196 // not measuring part of the render phase, but this makes it match what we 18197 // do in Concurrent Mode. 18198 primaryChildFragment.actualDuration = 0; 18199 primaryChildFragment.actualStartTime = -1; 18200 primaryChildFragment.selfBaseDuration = 0; 18201 primaryChildFragment.treeBaseDuration = 0; 18202 } 18203 18204 fallbackChildFragment = createFiberFromFragment(fallbackChildren, mode, renderLanes, null); 18205 } else { 18206 primaryChildFragment = createFiberFromOffscreen(primaryChildProps, mode, NoLanes, null); 18207 fallbackChildFragment = createFiberFromFragment(fallbackChildren, mode, renderLanes, null); 18208 } 18209 18210 primaryChildFragment.return = workInProgress; 18211 fallbackChildFragment.return = workInProgress; 18212 primaryChildFragment.sibling = fallbackChildFragment; 18213 workInProgress.child = primaryChildFragment; 18214 return fallbackChildFragment; 18215} 18216 18217function createWorkInProgressOffscreenFiber(current, offscreenProps) { 18218 // The props argument to `createWorkInProgress` is `any` typed, so we use this 18219 // wrapper function to constrain it. 18220 return createWorkInProgress(current, offscreenProps); 18221} 18222 18223function updateSuspensePrimaryChildren(current, workInProgress, primaryChildren, renderLanes) { 18224 var currentPrimaryChildFragment = current.child; 18225 var currentFallbackChildFragment = currentPrimaryChildFragment.sibling; 18226 var primaryChildFragment = createWorkInProgressOffscreenFiber(currentPrimaryChildFragment, { 18227 mode: 'visible', 18228 children: primaryChildren 18229 }); 18230 18231 if ((workInProgress.mode & BlockingMode) === NoMode) { 18232 primaryChildFragment.lanes = renderLanes; 18233 } 18234 18235 primaryChildFragment.return = workInProgress; 18236 primaryChildFragment.sibling = null; 18237 18238 if (currentFallbackChildFragment !== null) { 18239 // Delete the fallback child fragment 18240 currentFallbackChildFragment.nextEffect = null; 18241 currentFallbackChildFragment.flags = Deletion; 18242 workInProgress.firstEffect = workInProgress.lastEffect = currentFallbackChildFragment; 18243 } 18244 18245 workInProgress.child = primaryChildFragment; 18246 return primaryChildFragment; 18247} 18248 18249function updateSuspenseFallbackChildren(current, workInProgress, primaryChildren, fallbackChildren, renderLanes) { 18250 var mode = workInProgress.mode; 18251 var currentPrimaryChildFragment = current.child; 18252 var currentFallbackChildFragment = currentPrimaryChildFragment.sibling; 18253 var primaryChildProps = { 18254 mode: 'hidden', 18255 children: primaryChildren 18256 }; 18257 var primaryChildFragment; 18258 18259 if ( // In legacy mode, we commit the primary tree as if it successfully 18260 // completed, even though it's in an inconsistent state. 18261 (mode & BlockingMode) === NoMode && // Make sure we're on the second pass, i.e. the primary child fragment was 18262 // already cloned. In legacy mode, the only case where this isn't true is 18263 // when DevTools forces us to display a fallback; we skip the first render 18264 // pass entirely and go straight to rendering the fallback. (In Concurrent 18265 // Mode, SuspenseList can also trigger this scenario, but this is a legacy- 18266 // only codepath.) 18267 workInProgress.child !== currentPrimaryChildFragment) { 18268 var progressedPrimaryFragment = workInProgress.child; 18269 primaryChildFragment = progressedPrimaryFragment; 18270 primaryChildFragment.childLanes = NoLanes; 18271 primaryChildFragment.pendingProps = primaryChildProps; 18272 18273 if ( workInProgress.mode & ProfileMode) { 18274 // Reset the durations from the first pass so they aren't included in the 18275 // final amounts. This seems counterintuitive, since we're intentionally 18276 // not measuring part of the render phase, but this makes it match what we 18277 // do in Concurrent Mode. 18278 primaryChildFragment.actualDuration = 0; 18279 primaryChildFragment.actualStartTime = -1; 18280 primaryChildFragment.selfBaseDuration = currentPrimaryChildFragment.selfBaseDuration; 18281 primaryChildFragment.treeBaseDuration = currentPrimaryChildFragment.treeBaseDuration; 18282 } // The fallback fiber was added as a deletion effect during the first pass. 18283 // However, since we're going to remain on the fallback, we no longer want 18284 // to delete it. So we need to remove it from the list. Deletions are stored 18285 // on the same list as effects. We want to keep the effects from the primary 18286 // tree. So we copy the primary child fragment's effect list, which does not 18287 // include the fallback deletion effect. 18288 18289 18290 var progressedLastEffect = primaryChildFragment.lastEffect; 18291 18292 if (progressedLastEffect !== null) { 18293 workInProgress.firstEffect = primaryChildFragment.firstEffect; 18294 workInProgress.lastEffect = progressedLastEffect; 18295 progressedLastEffect.nextEffect = null; 18296 } else { 18297 // TODO: Reset this somewhere else? Lol legacy mode is so weird. 18298 workInProgress.firstEffect = workInProgress.lastEffect = null; 18299 } 18300 } else { 18301 primaryChildFragment = createWorkInProgressOffscreenFiber(currentPrimaryChildFragment, primaryChildProps); 18302 } 18303 18304 var fallbackChildFragment; 18305 18306 if (currentFallbackChildFragment !== null) { 18307 fallbackChildFragment = createWorkInProgress(currentFallbackChildFragment, fallbackChildren); 18308 } else { 18309 fallbackChildFragment = createFiberFromFragment(fallbackChildren, mode, renderLanes, null); // Needs a placement effect because the parent (the Suspense boundary) already 18310 // mounted but this is a new fiber. 18311 18312 fallbackChildFragment.flags |= Placement; 18313 } 18314 18315 fallbackChildFragment.return = workInProgress; 18316 primaryChildFragment.return = workInProgress; 18317 primaryChildFragment.sibling = fallbackChildFragment; 18318 workInProgress.child = primaryChildFragment; 18319 return fallbackChildFragment; 18320} 18321 18322function scheduleWorkOnFiber(fiber, renderLanes) { 18323 fiber.lanes = mergeLanes(fiber.lanes, renderLanes); 18324 var alternate = fiber.alternate; 18325 18326 if (alternate !== null) { 18327 alternate.lanes = mergeLanes(alternate.lanes, renderLanes); 18328 } 18329 18330 scheduleWorkOnParentPath(fiber.return, renderLanes); 18331} 18332 18333function propagateSuspenseContextChange(workInProgress, firstChild, renderLanes) { 18334 // Mark any Suspense boundaries with fallbacks as having work to do. 18335 // If they were previously forced into fallbacks, they may now be able 18336 // to unblock. 18337 var node = firstChild; 18338 18339 while (node !== null) { 18340 if (node.tag === SuspenseComponent) { 18341 var state = node.memoizedState; 18342 18343 if (state !== null) { 18344 scheduleWorkOnFiber(node, renderLanes); 18345 } 18346 } else if (node.tag === SuspenseListComponent) { 18347 // If the tail is hidden there might not be an Suspense boundaries 18348 // to schedule work on. In this case we have to schedule it on the 18349 // list itself. 18350 // We don't have to traverse to the children of the list since 18351 // the list will propagate the change when it rerenders. 18352 scheduleWorkOnFiber(node, renderLanes); 18353 } else if (node.child !== null) { 18354 node.child.return = node; 18355 node = node.child; 18356 continue; 18357 } 18358 18359 if (node === workInProgress) { 18360 return; 18361 } 18362 18363 while (node.sibling === null) { 18364 if (node.return === null || node.return === workInProgress) { 18365 return; 18366 } 18367 18368 node = node.return; 18369 } 18370 18371 node.sibling.return = node.return; 18372 node = node.sibling; 18373 } 18374} 18375 18376function findLastContentRow(firstChild) { 18377 // This is going to find the last row among these children that is already 18378 // showing content on the screen, as opposed to being in fallback state or 18379 // new. If a row has multiple Suspense boundaries, any of them being in the 18380 // fallback state, counts as the whole row being in a fallback state. 18381 // Note that the "rows" will be workInProgress, but any nested children 18382 // will still be current since we haven't rendered them yet. The mounted 18383 // order may not be the same as the new order. We use the new order. 18384 var row = firstChild; 18385 var lastContentRow = null; 18386 18387 while (row !== null) { 18388 var currentRow = row.alternate; // New rows can't be content rows. 18389 18390 if (currentRow !== null && findFirstSuspended(currentRow) === null) { 18391 lastContentRow = row; 18392 } 18393 18394 row = row.sibling; 18395 } 18396 18397 return lastContentRow; 18398} 18399 18400function validateRevealOrder(revealOrder) { 18401 { 18402 if (revealOrder !== undefined && revealOrder !== 'forwards' && revealOrder !== 'backwards' && revealOrder !== 'together' && !didWarnAboutRevealOrder[revealOrder]) { 18403 didWarnAboutRevealOrder[revealOrder] = true; 18404 18405 if (typeof revealOrder === 'string') { 18406 switch (revealOrder.toLowerCase()) { 18407 case 'together': 18408 case 'forwards': 18409 case 'backwards': 18410 { 18411 error('"%s" is not a valid value for revealOrder on <SuspenseList />. ' + 'Use lowercase "%s" instead.', revealOrder, revealOrder.toLowerCase()); 18412 18413 break; 18414 } 18415 18416 case 'forward': 18417 case 'backward': 18418 { 18419 error('"%s" is not a valid value for revealOrder on <SuspenseList />. ' + 'React uses the -s suffix in the spelling. Use "%ss" instead.', revealOrder, revealOrder.toLowerCase()); 18420 18421 break; 18422 } 18423 18424 default: 18425 error('"%s" is not a supported revealOrder on <SuspenseList />. ' + 'Did you mean "together", "forwards" or "backwards"?', revealOrder); 18426 18427 break; 18428 } 18429 } else { 18430 error('%s is not a supported value for revealOrder on <SuspenseList />. ' + 'Did you mean "together", "forwards" or "backwards"?', revealOrder); 18431 } 18432 } 18433 } 18434} 18435 18436function validateTailOptions(tailMode, revealOrder) { 18437 { 18438 if (tailMode !== undefined && !didWarnAboutTailOptions[tailMode]) { 18439 if (tailMode !== 'collapsed' && tailMode !== 'hidden') { 18440 didWarnAboutTailOptions[tailMode] = true; 18441 18442 error('"%s" is not a supported value for tail on <SuspenseList />. ' + 'Did you mean "collapsed" or "hidden"?', tailMode); 18443 } else if (revealOrder !== 'forwards' && revealOrder !== 'backwards') { 18444 didWarnAboutTailOptions[tailMode] = true; 18445 18446 error('<SuspenseList tail="%s" /> is only valid if revealOrder is ' + '"forwards" or "backwards". ' + 'Did you mean to specify revealOrder="forwards"?', tailMode); 18447 } 18448 } 18449 } 18450} 18451 18452function validateSuspenseListNestedChild(childSlot, index) { 18453 { 18454 var isArray = Array.isArray(childSlot); 18455 var isIterable = !isArray && typeof getIteratorFn(childSlot) === 'function'; 18456 18457 if (isArray || isIterable) { 18458 var type = isArray ? 'array' : 'iterable'; 18459 18460 error('A nested %s was passed to row #%s in <SuspenseList />. Wrap it in ' + 'an additional SuspenseList to configure its revealOrder: ' + '<SuspenseList revealOrder=...> ... ' + '<SuspenseList revealOrder=...>{%s}</SuspenseList> ... ' + '</SuspenseList>', type, index, type); 18461 18462 return false; 18463 } 18464 } 18465 18466 return true; 18467} 18468 18469function validateSuspenseListChildren(children, revealOrder) { 18470 { 18471 if ((revealOrder === 'forwards' || revealOrder === 'backwards') && children !== undefined && children !== null && children !== false) { 18472 if (Array.isArray(children)) { 18473 for (var i = 0; i < children.length; i++) { 18474 if (!validateSuspenseListNestedChild(children[i], i)) { 18475 return; 18476 } 18477 } 18478 } else { 18479 var iteratorFn = getIteratorFn(children); 18480 18481 if (typeof iteratorFn === 'function') { 18482 var childrenIterator = iteratorFn.call(children); 18483 18484 if (childrenIterator) { 18485 var step = childrenIterator.next(); 18486 var _i = 0; 18487 18488 for (; !step.done; step = childrenIterator.next()) { 18489 if (!validateSuspenseListNestedChild(step.value, _i)) { 18490 return; 18491 } 18492 18493 _i++; 18494 } 18495 } 18496 } else { 18497 error('A single row was passed to a <SuspenseList revealOrder="%s" />. ' + 'This is not useful since it needs multiple rows. ' + 'Did you mean to pass multiple children or an array?', revealOrder); 18498 } 18499 } 18500 } 18501 } 18502} 18503 18504function initSuspenseListRenderState(workInProgress, isBackwards, tail, lastContentRow, tailMode, lastEffectBeforeRendering) { 18505 var renderState = workInProgress.memoizedState; 18506 18507 if (renderState === null) { 18508 workInProgress.memoizedState = { 18509 isBackwards: isBackwards, 18510 rendering: null, 18511 renderingStartTime: 0, 18512 last: lastContentRow, 18513 tail: tail, 18514 tailMode: tailMode, 18515 lastEffect: lastEffectBeforeRendering 18516 }; 18517 } else { 18518 // We can reuse the existing object from previous renders. 18519 renderState.isBackwards = isBackwards; 18520 renderState.rendering = null; 18521 renderState.renderingStartTime = 0; 18522 renderState.last = lastContentRow; 18523 renderState.tail = tail; 18524 renderState.tailMode = tailMode; 18525 renderState.lastEffect = lastEffectBeforeRendering; 18526 } 18527} // This can end up rendering this component multiple passes. 18528// The first pass splits the children fibers into two sets. A head and tail. 18529// We first render the head. If anything is in fallback state, we do another 18530// pass through beginWork to rerender all children (including the tail) with 18531// the force suspend context. If the first render didn't have anything in 18532// in fallback state. Then we render each row in the tail one-by-one. 18533// That happens in the completeWork phase without going back to beginWork. 18534 18535 18536function updateSuspenseListComponent(current, workInProgress, renderLanes) { 18537 var nextProps = workInProgress.pendingProps; 18538 var revealOrder = nextProps.revealOrder; 18539 var tailMode = nextProps.tail; 18540 var newChildren = nextProps.children; 18541 validateRevealOrder(revealOrder); 18542 validateTailOptions(tailMode, revealOrder); 18543 validateSuspenseListChildren(newChildren, revealOrder); 18544 reconcileChildren(current, workInProgress, newChildren, renderLanes); 18545 var suspenseContext = suspenseStackCursor.current; 18546 var shouldForceFallback = hasSuspenseContext(suspenseContext, ForceSuspenseFallback); 18547 18548 if (shouldForceFallback) { 18549 suspenseContext = setShallowSuspenseContext(suspenseContext, ForceSuspenseFallback); 18550 workInProgress.flags |= DidCapture; 18551 } else { 18552 var didSuspendBefore = current !== null && (current.flags & DidCapture) !== NoFlags; 18553 18554 if (didSuspendBefore) { 18555 // If we previously forced a fallback, we need to schedule work 18556 // on any nested boundaries to let them know to try to render 18557 // again. This is the same as context updating. 18558 propagateSuspenseContextChange(workInProgress, workInProgress.child, renderLanes); 18559 } 18560 18561 suspenseContext = setDefaultShallowSuspenseContext(suspenseContext); 18562 } 18563 18564 pushSuspenseContext(workInProgress, suspenseContext); 18565 18566 if ((workInProgress.mode & BlockingMode) === NoMode) { 18567 // In legacy mode, SuspenseList doesn't work so we just 18568 // use make it a noop by treating it as the default revealOrder. 18569 workInProgress.memoizedState = null; 18570 } else { 18571 switch (revealOrder) { 18572 case 'forwards': 18573 { 18574 var lastContentRow = findLastContentRow(workInProgress.child); 18575 var tail; 18576 18577 if (lastContentRow === null) { 18578 // The whole list is part of the tail. 18579 // TODO: We could fast path by just rendering the tail now. 18580 tail = workInProgress.child; 18581 workInProgress.child = null; 18582 } else { 18583 // Disconnect the tail rows after the content row. 18584 // We're going to render them separately later. 18585 tail = lastContentRow.sibling; 18586 lastContentRow.sibling = null; 18587 } 18588 18589 initSuspenseListRenderState(workInProgress, false, // isBackwards 18590 tail, lastContentRow, tailMode, workInProgress.lastEffect); 18591 break; 18592 } 18593 18594 case 'backwards': 18595 { 18596 // We're going to find the first row that has existing content. 18597 // At the same time we're going to reverse the list of everything 18598 // we pass in the meantime. That's going to be our tail in reverse 18599 // order. 18600 var _tail = null; 18601 var row = workInProgress.child; 18602 workInProgress.child = null; 18603 18604 while (row !== null) { 18605 var currentRow = row.alternate; // New rows can't be content rows. 18606 18607 if (currentRow !== null && findFirstSuspended(currentRow) === null) { 18608 // This is the beginning of the main content. 18609 workInProgress.child = row; 18610 break; 18611 } 18612 18613 var nextRow = row.sibling; 18614 row.sibling = _tail; 18615 _tail = row; 18616 row = nextRow; 18617 } // TODO: If workInProgress.child is null, we can continue on the tail immediately. 18618 18619 18620 initSuspenseListRenderState(workInProgress, true, // isBackwards 18621 _tail, null, // last 18622 tailMode, workInProgress.lastEffect); 18623 break; 18624 } 18625 18626 case 'together': 18627 { 18628 initSuspenseListRenderState(workInProgress, false, // isBackwards 18629 null, // tail 18630 null, // last 18631 undefined, workInProgress.lastEffect); 18632 break; 18633 } 18634 18635 default: 18636 { 18637 // The default reveal order is the same as not having 18638 // a boundary. 18639 workInProgress.memoizedState = null; 18640 } 18641 } 18642 } 18643 18644 return workInProgress.child; 18645} 18646 18647function updatePortalComponent(current, workInProgress, renderLanes) { 18648 pushHostContainer(workInProgress, workInProgress.stateNode.containerInfo); 18649 var nextChildren = workInProgress.pendingProps; 18650 18651 if (current === null) { 18652 // Portals are special because we don't append the children during mount 18653 // but at commit. Therefore we need to track insertions which the normal 18654 // flow doesn't do during mount. This doesn't happen at the root because 18655 // the root always starts with a "current" with a null child. 18656 // TODO: Consider unifying this with how the root works. 18657 workInProgress.child = reconcileChildFibers(workInProgress, null, nextChildren, renderLanes); 18658 } else { 18659 reconcileChildren(current, workInProgress, nextChildren, renderLanes); 18660 } 18661 18662 return workInProgress.child; 18663} 18664 18665var hasWarnedAboutUsingNoValuePropOnContextProvider = false; 18666 18667function updateContextProvider(current, workInProgress, renderLanes) { 18668 var providerType = workInProgress.type; 18669 var context = providerType._context; 18670 var newProps = workInProgress.pendingProps; 18671 var oldProps = workInProgress.memoizedProps; 18672 var newValue = newProps.value; 18673 18674 { 18675 if (!('value' in newProps)) { 18676 if (!hasWarnedAboutUsingNoValuePropOnContextProvider) { 18677 hasWarnedAboutUsingNoValuePropOnContextProvider = true; 18678 18679 error('The `value` prop is required for the `<Context.Provider>`. Did you misspell it or forget to pass it?'); 18680 } 18681 } 18682 18683 var providerPropTypes = workInProgress.type.propTypes; 18684 18685 if (providerPropTypes) { 18686 checkPropTypes(providerPropTypes, newProps, 'prop', 'Context.Provider'); 18687 } 18688 } 18689 18690 pushProvider(workInProgress, newValue); 18691 18692 if (oldProps !== null) { 18693 var oldValue = oldProps.value; 18694 var changedBits = calculateChangedBits(context, newValue, oldValue); 18695 18696 if (changedBits === 0) { 18697 // No change. Bailout early if children are the same. 18698 if (oldProps.children === newProps.children && !hasContextChanged()) { 18699 return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); 18700 } 18701 } else { 18702 // The context value changed. Search for matching consumers and schedule 18703 // them to update. 18704 propagateContextChange(workInProgress, context, changedBits, renderLanes); 18705 } 18706 } 18707 18708 var newChildren = newProps.children; 18709 reconcileChildren(current, workInProgress, newChildren, renderLanes); 18710 return workInProgress.child; 18711} 18712 18713var hasWarnedAboutUsingContextAsConsumer = false; 18714 18715function updateContextConsumer(current, workInProgress, renderLanes) { 18716 var context = workInProgress.type; // The logic below for Context differs depending on PROD or DEV mode. In 18717 // DEV mode, we create a separate object for Context.Consumer that acts 18718 // like a proxy to Context. This proxy object adds unnecessary code in PROD 18719 // so we use the old behaviour (Context.Consumer references Context) to 18720 // reduce size and overhead. The separate object references context via 18721 // a property called "_context", which also gives us the ability to check 18722 // in DEV mode if this property exists or not and warn if it does not. 18723 18724 { 18725 if (context._context === undefined) { 18726 // This may be because it's a Context (rather than a Consumer). 18727 // Or it may be because it's older React where they're the same thing. 18728 // We only want to warn if we're sure it's a new React. 18729 if (context !== context.Consumer) { 18730 if (!hasWarnedAboutUsingContextAsConsumer) { 18731 hasWarnedAboutUsingContextAsConsumer = true; 18732 18733 error('Rendering <Context> directly is not supported and will be removed in ' + 'a future major release. Did you mean to render <Context.Consumer> instead?'); 18734 } 18735 } 18736 } else { 18737 context = context._context; 18738 } 18739 } 18740 18741 var newProps = workInProgress.pendingProps; 18742 var render = newProps.children; 18743 18744 { 18745 if (typeof render !== 'function') { 18746 error('A context consumer was rendered with multiple children, or a child ' + "that isn't a function. A context consumer expects a single child " + 'that is a function. If you did pass a function, make sure there ' + 'is no trailing or leading whitespace around it.'); 18747 } 18748 } 18749 18750 prepareToReadContext(workInProgress, renderLanes); 18751 var newValue = readContext(context, newProps.unstable_observedBits); 18752 var newChildren; 18753 18754 { 18755 ReactCurrentOwner$1.current = workInProgress; 18756 setIsRendering(true); 18757 newChildren = render(newValue); 18758 setIsRendering(false); 18759 } // React DevTools reads this flag. 18760 18761 18762 workInProgress.flags |= PerformedWork; 18763 reconcileChildren(current, workInProgress, newChildren, renderLanes); 18764 return workInProgress.child; 18765} 18766 18767function markWorkInProgressReceivedUpdate() { 18768 didReceiveUpdate = true; 18769} 18770 18771function bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) { 18772 if (current !== null) { 18773 // Reuse previous dependencies 18774 workInProgress.dependencies = current.dependencies; 18775 } 18776 18777 { 18778 // Don't update "base" render times for bailouts. 18779 stopProfilerTimerIfRunning(); 18780 } 18781 18782 markSkippedUpdateLanes(workInProgress.lanes); // Check if the children have any pending work. 18783 18784 if (!includesSomeLane(renderLanes, workInProgress.childLanes)) { 18785 // The children don't have any work either. We can skip them. 18786 // TODO: Once we add back resuming, we should check if the children are 18787 // a work-in-progress set. If so, we need to transfer their effects. 18788 return null; 18789 } else { 18790 // This fiber doesn't have work, but its subtree does. Clone the child 18791 // fibers and continue. 18792 cloneChildFibers(current, workInProgress); 18793 return workInProgress.child; 18794 } 18795} 18796 18797function remountFiber(current, oldWorkInProgress, newWorkInProgress) { 18798 { 18799 var returnFiber = oldWorkInProgress.return; 18800 18801 if (returnFiber === null) { 18802 throw new Error('Cannot swap the root fiber.'); 18803 } // Disconnect from the old current. 18804 // It will get deleted. 18805 18806 18807 current.alternate = null; 18808 oldWorkInProgress.alternate = null; // Connect to the new tree. 18809 18810 newWorkInProgress.index = oldWorkInProgress.index; 18811 newWorkInProgress.sibling = oldWorkInProgress.sibling; 18812 newWorkInProgress.return = oldWorkInProgress.return; 18813 newWorkInProgress.ref = oldWorkInProgress.ref; // Replace the child/sibling pointers above it. 18814 18815 if (oldWorkInProgress === returnFiber.child) { 18816 returnFiber.child = newWorkInProgress; 18817 } else { 18818 var prevSibling = returnFiber.child; 18819 18820 if (prevSibling === null) { 18821 throw new Error('Expected parent to have a child.'); 18822 } 18823 18824 while (prevSibling.sibling !== oldWorkInProgress) { 18825 prevSibling = prevSibling.sibling; 18826 18827 if (prevSibling === null) { 18828 throw new Error('Expected to find the previous sibling.'); 18829 } 18830 } 18831 18832 prevSibling.sibling = newWorkInProgress; 18833 } // Delete the old fiber and place the new one. 18834 // Since the old fiber is disconnected, we have to schedule it manually. 18835 18836 18837 var last = returnFiber.lastEffect; 18838 18839 if (last !== null) { 18840 last.nextEffect = current; 18841 returnFiber.lastEffect = current; 18842 } else { 18843 returnFiber.firstEffect = returnFiber.lastEffect = current; 18844 } 18845 18846 current.nextEffect = null; 18847 current.flags = Deletion; 18848 newWorkInProgress.flags |= Placement; // Restart work from the new fiber. 18849 18850 return newWorkInProgress; 18851 } 18852} 18853 18854function beginWork(current, workInProgress, renderLanes) { 18855 var updateLanes = workInProgress.lanes; 18856 18857 { 18858 if (workInProgress._debugNeedsRemount && current !== null) { 18859 // This will restart the begin phase with a new fiber. 18860 return remountFiber(current, workInProgress, createFiberFromTypeAndProps(workInProgress.type, workInProgress.key, workInProgress.pendingProps, workInProgress._debugOwner || null, workInProgress.mode, workInProgress.lanes)); 18861 } 18862 } 18863 18864 if (current !== null) { 18865 var oldProps = current.memoizedProps; 18866 var newProps = workInProgress.pendingProps; 18867 18868 if (oldProps !== newProps || hasContextChanged() || ( // Force a re-render if the implementation changed due to hot reload: 18869 workInProgress.type !== current.type )) { 18870 // If props or context changed, mark the fiber as having performed work. 18871 // This may be unset if the props are determined to be equal later (memo). 18872 didReceiveUpdate = true; 18873 } else if (!includesSomeLane(renderLanes, updateLanes)) { 18874 didReceiveUpdate = false; // This fiber does not have any pending work. Bailout without entering 18875 // the begin phase. There's still some bookkeeping we that needs to be done 18876 // in this optimized path, mostly pushing stuff onto the stack. 18877 18878 switch (workInProgress.tag) { 18879 case HostRoot: 18880 pushHostRootContext(workInProgress); 18881 resetHydrationState(); 18882 break; 18883 18884 case HostComponent: 18885 pushHostContext(workInProgress); 18886 break; 18887 18888 case ClassComponent: 18889 { 18890 var Component = workInProgress.type; 18891 18892 if (isContextProvider(Component)) { 18893 pushContextProvider(workInProgress); 18894 } 18895 18896 break; 18897 } 18898 18899 case HostPortal: 18900 pushHostContainer(workInProgress, workInProgress.stateNode.containerInfo); 18901 break; 18902 18903 case ContextProvider: 18904 { 18905 var newValue = workInProgress.memoizedProps.value; 18906 pushProvider(workInProgress, newValue); 18907 break; 18908 } 18909 18910 case Profiler: 18911 { 18912 // Profiler should only call onRender when one of its descendants actually rendered. 18913 var hasChildWork = includesSomeLane(renderLanes, workInProgress.childLanes); 18914 18915 if (hasChildWork) { 18916 workInProgress.flags |= Update; 18917 } // Reset effect durations for the next eventual effect phase. 18918 // These are reset during render to allow the DevTools commit hook a chance to read them, 18919 18920 18921 var stateNode = workInProgress.stateNode; 18922 stateNode.effectDuration = 0; 18923 stateNode.passiveEffectDuration = 0; 18924 } 18925 18926 break; 18927 18928 case SuspenseComponent: 18929 { 18930 var state = workInProgress.memoizedState; 18931 18932 if (state !== null) { 18933 // whether to retry the primary children, or to skip over it and 18934 // go straight to the fallback. Check the priority of the primary 18935 // child fragment. 18936 18937 18938 var primaryChildFragment = workInProgress.child; 18939 var primaryChildLanes = primaryChildFragment.childLanes; 18940 18941 if (includesSomeLane(renderLanes, primaryChildLanes)) { 18942 // The primary children have pending work. Use the normal path 18943 // to attempt to render the primary children again. 18944 return updateSuspenseComponent(current, workInProgress, renderLanes); 18945 } else { 18946 // The primary child fragment does not have pending work marked 18947 // on it 18948 pushSuspenseContext(workInProgress, setDefaultShallowSuspenseContext(suspenseStackCursor.current)); // The primary children do not have pending work with sufficient 18949 // priority. Bailout. 18950 18951 var child = bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); 18952 18953 if (child !== null) { 18954 // The fallback children have pending work. Skip over the 18955 // primary children and work on the fallback. 18956 return child.sibling; 18957 } else { 18958 return null; 18959 } 18960 } 18961 } else { 18962 pushSuspenseContext(workInProgress, setDefaultShallowSuspenseContext(suspenseStackCursor.current)); 18963 } 18964 18965 break; 18966 } 18967 18968 case SuspenseListComponent: 18969 { 18970 var didSuspendBefore = (current.flags & DidCapture) !== NoFlags; 18971 18972 var _hasChildWork = includesSomeLane(renderLanes, workInProgress.childLanes); 18973 18974 if (didSuspendBefore) { 18975 if (_hasChildWork) { 18976 // If something was in fallback state last time, and we have all the 18977 // same children then we're still in progressive loading state. 18978 // Something might get unblocked by state updates or retries in the 18979 // tree which will affect the tail. So we need to use the normal 18980 // path to compute the correct tail. 18981 return updateSuspenseListComponent(current, workInProgress, renderLanes); 18982 } // If none of the children had any work, that means that none of 18983 // them got retried so they'll still be blocked in the same way 18984 // as before. We can fast bail out. 18985 18986 18987 workInProgress.flags |= DidCapture; 18988 } // If nothing suspended before and we're rendering the same children, 18989 // then the tail doesn't matter. Anything new that suspends will work 18990 // in the "together" mode, so we can continue from the state we had. 18991 18992 18993 var renderState = workInProgress.memoizedState; 18994 18995 if (renderState !== null) { 18996 // Reset to the "together" mode in case we've started a different 18997 // update in the past but didn't complete it. 18998 renderState.rendering = null; 18999 renderState.tail = null; 19000 renderState.lastEffect = null; 19001 } 19002 19003 pushSuspenseContext(workInProgress, suspenseStackCursor.current); 19004 19005 if (_hasChildWork) { 19006 break; 19007 } else { 19008 // If none of the children had any work, that means that none of 19009 // them got retried so they'll still be blocked in the same way 19010 // as before. We can fast bail out. 19011 return null; 19012 } 19013 } 19014 19015 case OffscreenComponent: 19016 case LegacyHiddenComponent: 19017 { 19018 // Need to check if the tree still needs to be deferred. This is 19019 // almost identical to the logic used in the normal update path, 19020 // so we'll just enter that. The only difference is we'll bail out 19021 // at the next level instead of this one, because the child props 19022 // have not changed. Which is fine. 19023 // TODO: Probably should refactor `beginWork` to split the bailout 19024 // path from the normal path. I'm tempted to do a labeled break here 19025 // but I won't :) 19026 workInProgress.lanes = NoLanes; 19027 return updateOffscreenComponent(current, workInProgress, renderLanes); 19028 } 19029 } 19030 19031 return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); 19032 } else { 19033 if ((current.flags & ForceUpdateForLegacySuspense) !== NoFlags) { 19034 // This is a special case that only exists for legacy mode. 19035 // See https://github.com/facebook/react/pull/19216. 19036 didReceiveUpdate = true; 19037 } else { 19038 // An update was scheduled on this fiber, but there are no new props 19039 // nor legacy context. Set this to false. If an update queue or context 19040 // consumer produces a changed value, it will set this to true. Otherwise, 19041 // the component will assume the children have not changed and bail out. 19042 didReceiveUpdate = false; 19043 } 19044 } 19045 } else { 19046 didReceiveUpdate = false; 19047 } // Before entering the begin phase, clear pending update priority. 19048 // TODO: This assumes that we're about to evaluate the component and process 19049 // the update queue. However, there's an exception: SimpleMemoComponent 19050 // sometimes bails out later in the begin phase. This indicates that we should 19051 // move this assignment out of the common path and into each branch. 19052 19053 19054 workInProgress.lanes = NoLanes; 19055 19056 switch (workInProgress.tag) { 19057 case IndeterminateComponent: 19058 { 19059 return mountIndeterminateComponent(current, workInProgress, workInProgress.type, renderLanes); 19060 } 19061 19062 case LazyComponent: 19063 { 19064 var elementType = workInProgress.elementType; 19065 return mountLazyComponent(current, workInProgress, elementType, updateLanes, renderLanes); 19066 } 19067 19068 case FunctionComponent: 19069 { 19070 var _Component = workInProgress.type; 19071 var unresolvedProps = workInProgress.pendingProps; 19072 var resolvedProps = workInProgress.elementType === _Component ? unresolvedProps : resolveDefaultProps(_Component, unresolvedProps); 19073 return updateFunctionComponent(current, workInProgress, _Component, resolvedProps, renderLanes); 19074 } 19075 19076 case ClassComponent: 19077 { 19078 var _Component2 = workInProgress.type; 19079 var _unresolvedProps = workInProgress.pendingProps; 19080 19081 var _resolvedProps = workInProgress.elementType === _Component2 ? _unresolvedProps : resolveDefaultProps(_Component2, _unresolvedProps); 19082 19083 return updateClassComponent(current, workInProgress, _Component2, _resolvedProps, renderLanes); 19084 } 19085 19086 case HostRoot: 19087 return updateHostRoot(current, workInProgress, renderLanes); 19088 19089 case HostComponent: 19090 return updateHostComponent(current, workInProgress, renderLanes); 19091 19092 case HostText: 19093 return updateHostText(current, workInProgress); 19094 19095 case SuspenseComponent: 19096 return updateSuspenseComponent(current, workInProgress, renderLanes); 19097 19098 case HostPortal: 19099 return updatePortalComponent(current, workInProgress, renderLanes); 19100 19101 case ForwardRef: 19102 { 19103 var type = workInProgress.type; 19104 var _unresolvedProps2 = workInProgress.pendingProps; 19105 19106 var _resolvedProps2 = workInProgress.elementType === type ? _unresolvedProps2 : resolveDefaultProps(type, _unresolvedProps2); 19107 19108 return updateForwardRef(current, workInProgress, type, _resolvedProps2, renderLanes); 19109 } 19110 19111 case Fragment: 19112 return updateFragment(current, workInProgress, renderLanes); 19113 19114 case Mode: 19115 return updateMode(current, workInProgress, renderLanes); 19116 19117 case Profiler: 19118 return updateProfiler(current, workInProgress, renderLanes); 19119 19120 case ContextProvider: 19121 return updateContextProvider(current, workInProgress, renderLanes); 19122 19123 case ContextConsumer: 19124 return updateContextConsumer(current, workInProgress, renderLanes); 19125 19126 case MemoComponent: 19127 { 19128 var _type2 = workInProgress.type; 19129 var _unresolvedProps3 = workInProgress.pendingProps; // Resolve outer props first, then resolve inner props. 19130 19131 var _resolvedProps3 = resolveDefaultProps(_type2, _unresolvedProps3); 19132 19133 { 19134 if (workInProgress.type !== workInProgress.elementType) { 19135 var outerPropTypes = _type2.propTypes; 19136 19137 if (outerPropTypes) { 19138 checkPropTypes(outerPropTypes, _resolvedProps3, // Resolved for outer only 19139 'prop', getComponentName(_type2)); 19140 } 19141 } 19142 } 19143 19144 _resolvedProps3 = resolveDefaultProps(_type2.type, _resolvedProps3); 19145 return updateMemoComponent(current, workInProgress, _type2, _resolvedProps3, updateLanes, renderLanes); 19146 } 19147 19148 case SimpleMemoComponent: 19149 { 19150 return updateSimpleMemoComponent(current, workInProgress, workInProgress.type, workInProgress.pendingProps, updateLanes, renderLanes); 19151 } 19152 19153 case IncompleteClassComponent: 19154 { 19155 var _Component3 = workInProgress.type; 19156 var _unresolvedProps4 = workInProgress.pendingProps; 19157 19158 var _resolvedProps4 = workInProgress.elementType === _Component3 ? _unresolvedProps4 : resolveDefaultProps(_Component3, _unresolvedProps4); 19159 19160 return mountIncompleteClassComponent(current, workInProgress, _Component3, _resolvedProps4, renderLanes); 19161 } 19162 19163 case SuspenseListComponent: 19164 { 19165 return updateSuspenseListComponent(current, workInProgress, renderLanes); 19166 } 19167 19168 case FundamentalComponent: 19169 { 19170 19171 break; 19172 } 19173 19174 case ScopeComponent: 19175 { 19176 19177 break; 19178 } 19179 19180 case Block: 19181 { 19182 19183 break; 19184 } 19185 19186 case OffscreenComponent: 19187 { 19188 return updateOffscreenComponent(current, workInProgress, renderLanes); 19189 } 19190 19191 case LegacyHiddenComponent: 19192 { 19193 return updateLegacyHiddenComponent(current, workInProgress, renderLanes); 19194 } 19195 } 19196 19197 { 19198 { 19199 throw Error( "Unknown unit of work tag (" + workInProgress.tag + "). This error is likely caused by a bug in React. Please file an issue." ); 19200 } 19201 } 19202} 19203 19204function markUpdate(workInProgress) { 19205 // Tag the fiber with an update effect. This turns a Placement into 19206 // a PlacementAndUpdate. 19207 workInProgress.flags |= Update; 19208} 19209 19210function markRef$1(workInProgress) { 19211 workInProgress.flags |= Ref; 19212} 19213 19214var appendAllChildren; 19215var updateHostContainer; 19216var updateHostComponent$1; 19217var updateHostText$1; 19218 19219{ 19220 // Mutation mode 19221 appendAllChildren = function (parent, workInProgress, needsVisibilityToggle, isHidden) { 19222 // We only have the top Fiber that was created but we need recurse down its 19223 // children to find all the terminal nodes. 19224 var node = workInProgress.child; 19225 19226 while (node !== null) { 19227 if (node.tag === HostComponent || node.tag === HostText) { 19228 appendInitialChild(parent, node.stateNode); 19229 } else if (node.tag === HostPortal) ; else if (node.child !== null) { 19230 node.child.return = node; 19231 node = node.child; 19232 continue; 19233 } 19234 19235 if (node === workInProgress) { 19236 return; 19237 } 19238 19239 while (node.sibling === null) { 19240 if (node.return === null || node.return === workInProgress) { 19241 return; 19242 } 19243 19244 node = node.return; 19245 } 19246 19247 node.sibling.return = node.return; 19248 node = node.sibling; 19249 } 19250 }; 19251 19252 updateHostContainer = function (workInProgress) {// Noop 19253 }; 19254 19255 updateHostComponent$1 = function (current, workInProgress, type, newProps, rootContainerInstance) { 19256 // If we have an alternate, that means this is an update and we need to 19257 // schedule a side-effect to do the updates. 19258 var oldProps = current.memoizedProps; 19259 19260 if (oldProps === newProps) { 19261 // In mutation mode, this is sufficient for a bailout because 19262 // we won't touch this node even if children changed. 19263 return; 19264 } // If we get updated because one of our children updated, we don't 19265 // have newProps so we'll have to reuse them. 19266 // TODO: Split the update API as separate for the props vs. children. 19267 // Even better would be if children weren't special cased at all tho. 19268 19269 19270 var instance = workInProgress.stateNode; 19271 var currentHostContext = getHostContext(); // TODO: Experiencing an error where oldProps is null. Suggests a host 19272 // component is hitting the resume path. Figure out why. Possibly 19273 // related to `hidden`. 19274 19275 var updatePayload = prepareUpdate(instance, type, oldProps, newProps, rootContainerInstance, currentHostContext); // TODO: Type this specific to this type of component. 19276 19277 workInProgress.updateQueue = updatePayload; // If the update payload indicates that there is a change or if there 19278 // is a new ref we mark this as an update. All the work is done in commitWork. 19279 19280 if (updatePayload) { 19281 markUpdate(workInProgress); 19282 } 19283 }; 19284 19285 updateHostText$1 = function (current, workInProgress, oldText, newText) { 19286 // If the text differs, mark it as an update. All the work in done in commitWork. 19287 if (oldText !== newText) { 19288 markUpdate(workInProgress); 19289 } 19290 }; 19291} 19292 19293function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) { 19294 if (getIsHydrating()) { 19295 // If we're hydrating, we should consume as many items as we can 19296 // so we don't leave any behind. 19297 return; 19298 } 19299 19300 switch (renderState.tailMode) { 19301 case 'hidden': 19302 { 19303 // Any insertions at the end of the tail list after this point 19304 // should be invisible. If there are already mounted boundaries 19305 // anything before them are not considered for collapsing. 19306 // Therefore we need to go through the whole tail to find if 19307 // there are any. 19308 var tailNode = renderState.tail; 19309 var lastTailNode = null; 19310 19311 while (tailNode !== null) { 19312 if (tailNode.alternate !== null) { 19313 lastTailNode = tailNode; 19314 } 19315 19316 tailNode = tailNode.sibling; 19317 } // Next we're simply going to delete all insertions after the 19318 // last rendered item. 19319 19320 19321 if (lastTailNode === null) { 19322 // All remaining items in the tail are insertions. 19323 renderState.tail = null; 19324 } else { 19325 // Detach the insertion after the last node that was already 19326 // inserted. 19327 lastTailNode.sibling = null; 19328 } 19329 19330 break; 19331 } 19332 19333 case 'collapsed': 19334 { 19335 // Any insertions at the end of the tail list after this point 19336 // should be invisible. If there are already mounted boundaries 19337 // anything before them are not considered for collapsing. 19338 // Therefore we need to go through the whole tail to find if 19339 // there are any. 19340 var _tailNode = renderState.tail; 19341 var _lastTailNode = null; 19342 19343 while (_tailNode !== null) { 19344 if (_tailNode.alternate !== null) { 19345 _lastTailNode = _tailNode; 19346 } 19347 19348 _tailNode = _tailNode.sibling; 19349 } // Next we're simply going to delete all insertions after the 19350 // last rendered item. 19351 19352 19353 if (_lastTailNode === null) { 19354 // All remaining items in the tail are insertions. 19355 if (!hasRenderedATailFallback && renderState.tail !== null) { 19356 // We suspended during the head. We want to show at least one 19357 // row at the tail. So we'll keep on and cut off the rest. 19358 renderState.tail.sibling = null; 19359 } else { 19360 renderState.tail = null; 19361 } 19362 } else { 19363 // Detach the insertion after the last node that was already 19364 // inserted. 19365 _lastTailNode.sibling = null; 19366 } 19367 19368 break; 19369 } 19370 } 19371} 19372 19373function completeWork(current, workInProgress, renderLanes) { 19374 var newProps = workInProgress.pendingProps; 19375 19376 switch (workInProgress.tag) { 19377 case IndeterminateComponent: 19378 case LazyComponent: 19379 case SimpleMemoComponent: 19380 case FunctionComponent: 19381 case ForwardRef: 19382 case Fragment: 19383 case Mode: 19384 case Profiler: 19385 case ContextConsumer: 19386 case MemoComponent: 19387 return null; 19388 19389 case ClassComponent: 19390 { 19391 var Component = workInProgress.type; 19392 19393 if (isContextProvider(Component)) { 19394 popContext(workInProgress); 19395 } 19396 19397 return null; 19398 } 19399 19400 case HostRoot: 19401 { 19402 popHostContainer(workInProgress); 19403 popTopLevelContextObject(workInProgress); 19404 resetWorkInProgressVersions(); 19405 var fiberRoot = workInProgress.stateNode; 19406 19407 if (fiberRoot.pendingContext) { 19408 fiberRoot.context = fiberRoot.pendingContext; 19409 fiberRoot.pendingContext = null; 19410 } 19411 19412 if (current === null || current.child === null) { 19413 // If we hydrated, pop so that we can delete any remaining children 19414 // that weren't hydrated. 19415 var wasHydrated = popHydrationState(workInProgress); 19416 19417 if (wasHydrated) { 19418 // If we hydrated, then we'll need to schedule an update for 19419 // the commit side-effects on the root. 19420 markUpdate(workInProgress); 19421 } else if (!fiberRoot.hydrate) { 19422 // Schedule an effect to clear this container at the start of the next commit. 19423 // This handles the case of React rendering into a container with previous children. 19424 // It's also safe to do for updates too, because current.child would only be null 19425 // if the previous render was null (so the the container would already be empty). 19426 workInProgress.flags |= Snapshot; 19427 } 19428 } 19429 19430 updateHostContainer(workInProgress); 19431 return null; 19432 } 19433 19434 case HostComponent: 19435 { 19436 popHostContext(workInProgress); 19437 var rootContainerInstance = getRootHostContainer(); 19438 var type = workInProgress.type; 19439 19440 if (current !== null && workInProgress.stateNode != null) { 19441 updateHostComponent$1(current, workInProgress, type, newProps, rootContainerInstance); 19442 19443 if (current.ref !== workInProgress.ref) { 19444 markRef$1(workInProgress); 19445 } 19446 } else { 19447 if (!newProps) { 19448 if (!(workInProgress.stateNode !== null)) { 19449 { 19450 throw Error( "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue." ); 19451 } 19452 } // This can happen when we abort work. 19453 19454 19455 return null; 19456 } 19457 19458 var currentHostContext = getHostContext(); // TODO: Move createInstance to beginWork and keep it on a context 19459 // "stack" as the parent. Then append children as we go in beginWork 19460 // or completeWork depending on whether we want to add them top->down or 19461 // bottom->up. Top->down is faster in IE11. 19462 19463 var _wasHydrated = popHydrationState(workInProgress); 19464 19465 if (_wasHydrated) { 19466 // TODO: Move this and createInstance step into the beginPhase 19467 // to consolidate. 19468 if (prepareToHydrateHostInstance(workInProgress, rootContainerInstance, currentHostContext)) { 19469 // If changes to the hydrated node need to be applied at the 19470 // commit-phase we mark this as such. 19471 markUpdate(workInProgress); 19472 } 19473 } else { 19474 var instance = createInstance(type, newProps, rootContainerInstance, currentHostContext, workInProgress); 19475 appendAllChildren(instance, workInProgress, false, false); 19476 workInProgress.stateNode = instance; // Certain renderers require commit-time effects for initial mount. 19477 // (eg DOM renderer supports auto-focus for certain elements). 19478 // Make sure such renderers get scheduled for later work. 19479 19480 if (finalizeInitialChildren(instance, type, newProps, rootContainerInstance)) { 19481 markUpdate(workInProgress); 19482 } 19483 } 19484 19485 if (workInProgress.ref !== null) { 19486 // If there is a ref on a host node we need to schedule a callback 19487 markRef$1(workInProgress); 19488 } 19489 } 19490 19491 return null; 19492 } 19493 19494 case HostText: 19495 { 19496 var newText = newProps; 19497 19498 if (current && workInProgress.stateNode != null) { 19499 var oldText = current.memoizedProps; // If we have an alternate, that means this is an update and we need 19500 // to schedule a side-effect to do the updates. 19501 19502 updateHostText$1(current, workInProgress, oldText, newText); 19503 } else { 19504 if (typeof newText !== 'string') { 19505 if (!(workInProgress.stateNode !== null)) { 19506 { 19507 throw Error( "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue." ); 19508 } 19509 } // This can happen when we abort work. 19510 19511 } 19512 19513 var _rootContainerInstance = getRootHostContainer(); 19514 19515 var _currentHostContext = getHostContext(); 19516 19517 var _wasHydrated2 = popHydrationState(workInProgress); 19518 19519 if (_wasHydrated2) { 19520 if (prepareToHydrateHostTextInstance(workInProgress)) { 19521 markUpdate(workInProgress); 19522 } 19523 } else { 19524 workInProgress.stateNode = createTextInstance(newText, _rootContainerInstance, _currentHostContext, workInProgress); 19525 } 19526 } 19527 19528 return null; 19529 } 19530 19531 case SuspenseComponent: 19532 { 19533 popSuspenseContext(workInProgress); 19534 var nextState = workInProgress.memoizedState; 19535 19536 if ((workInProgress.flags & DidCapture) !== NoFlags) { 19537 // Something suspended. Re-render with the fallback children. 19538 workInProgress.lanes = renderLanes; // Do not reset the effect list. 19539 19540 if ( (workInProgress.mode & ProfileMode) !== NoMode) { 19541 transferActualDuration(workInProgress); 19542 } 19543 19544 return workInProgress; 19545 } 19546 19547 var nextDidTimeout = nextState !== null; 19548 var prevDidTimeout = false; 19549 19550 if (current === null) { 19551 if (workInProgress.memoizedProps.fallback !== undefined) { 19552 popHydrationState(workInProgress); 19553 } 19554 } else { 19555 var prevState = current.memoizedState; 19556 prevDidTimeout = prevState !== null; 19557 } 19558 19559 if (nextDidTimeout && !prevDidTimeout) { 19560 // If this subtreee is running in blocking mode we can suspend, 19561 // otherwise we won't suspend. 19562 // TODO: This will still suspend a synchronous tree if anything 19563 // in the concurrent tree already suspended during this render. 19564 // This is a known bug. 19565 if ((workInProgress.mode & BlockingMode) !== NoMode) { 19566 // TODO: Move this back to throwException because this is too late 19567 // if this is a large tree which is common for initial loads. We 19568 // don't know if we should restart a render or not until we get 19569 // this marker, and this is too late. 19570 // If this render already had a ping or lower pri updates, 19571 // and this is the first time we know we're going to suspend we 19572 // should be able to immediately restart from within throwException. 19573 var hasInvisibleChildContext = current === null && workInProgress.memoizedProps.unstable_avoidThisFallback !== true; 19574 19575 if (hasInvisibleChildContext || hasSuspenseContext(suspenseStackCursor.current, InvisibleParentSuspenseContext)) { 19576 // If this was in an invisible tree or a new render, then showing 19577 // this boundary is ok. 19578 renderDidSuspend(); 19579 } else { 19580 // Otherwise, we're going to have to hide content so we should 19581 // suspend for longer if possible. 19582 renderDidSuspendDelayIfPossible(); 19583 } 19584 } 19585 } 19586 19587 { 19588 // TODO: Only schedule updates if these values are non equal, i.e. it changed. 19589 if (nextDidTimeout || prevDidTimeout) { 19590 // If this boundary just timed out, schedule an effect to attach a 19591 // retry listener to the promise. This flag is also used to hide the 19592 // primary children. In mutation mode, we also need the flag to 19593 // *unhide* children that were previously hidden, so check if this 19594 // is currently timed out, too. 19595 workInProgress.flags |= Update; 19596 } 19597 } 19598 19599 return null; 19600 } 19601 19602 case HostPortal: 19603 popHostContainer(workInProgress); 19604 updateHostContainer(workInProgress); 19605 19606 if (current === null) { 19607 preparePortalMount(workInProgress.stateNode.containerInfo); 19608 } 19609 19610 return null; 19611 19612 case ContextProvider: 19613 // Pop provider fiber 19614 popProvider(workInProgress); 19615 return null; 19616 19617 case IncompleteClassComponent: 19618 { 19619 // Same as class component case. I put it down here so that the tags are 19620 // sequential to ensure this switch is compiled to a jump table. 19621 var _Component = workInProgress.type; 19622 19623 if (isContextProvider(_Component)) { 19624 popContext(workInProgress); 19625 } 19626 19627 return null; 19628 } 19629 19630 case SuspenseListComponent: 19631 { 19632 popSuspenseContext(workInProgress); 19633 var renderState = workInProgress.memoizedState; 19634 19635 if (renderState === null) { 19636 // We're running in the default, "independent" mode. 19637 // We don't do anything in this mode. 19638 return null; 19639 } 19640 19641 var didSuspendAlready = (workInProgress.flags & DidCapture) !== NoFlags; 19642 var renderedTail = renderState.rendering; 19643 19644 if (renderedTail === null) { 19645 // We just rendered the head. 19646 if (!didSuspendAlready) { 19647 // This is the first pass. We need to figure out if anything is still 19648 // suspended in the rendered set. 19649 // If new content unsuspended, but there's still some content that 19650 // didn't. Then we need to do a second pass that forces everything 19651 // to keep showing their fallbacks. 19652 // We might be suspended if something in this render pass suspended, or 19653 // something in the previous committed pass suspended. Otherwise, 19654 // there's no chance so we can skip the expensive call to 19655 // findFirstSuspended. 19656 var cannotBeSuspended = renderHasNotSuspendedYet() && (current === null || (current.flags & DidCapture) === NoFlags); 19657 19658 if (!cannotBeSuspended) { 19659 var row = workInProgress.child; 19660 19661 while (row !== null) { 19662 var suspended = findFirstSuspended(row); 19663 19664 if (suspended !== null) { 19665 didSuspendAlready = true; 19666 workInProgress.flags |= DidCapture; 19667 cutOffTailIfNeeded(renderState, false); // If this is a newly suspended tree, it might not get committed as 19668 // part of the second pass. In that case nothing will subscribe to 19669 // its thennables. Instead, we'll transfer its thennables to the 19670 // SuspenseList so that it can retry if they resolve. 19671 // There might be multiple of these in the list but since we're 19672 // going to wait for all of them anyway, it doesn't really matter 19673 // which ones gets to ping. In theory we could get clever and keep 19674 // track of how many dependencies remain but it gets tricky because 19675 // in the meantime, we can add/remove/change items and dependencies. 19676 // We might bail out of the loop before finding any but that 19677 // doesn't matter since that means that the other boundaries that 19678 // we did find already has their listeners attached. 19679 19680 var newThennables = suspended.updateQueue; 19681 19682 if (newThennables !== null) { 19683 workInProgress.updateQueue = newThennables; 19684 workInProgress.flags |= Update; 19685 } // Rerender the whole list, but this time, we'll force fallbacks 19686 // to stay in place. 19687 // Reset the effect list before doing the second pass since that's now invalid. 19688 19689 19690 if (renderState.lastEffect === null) { 19691 workInProgress.firstEffect = null; 19692 } 19693 19694 workInProgress.lastEffect = renderState.lastEffect; // Reset the child fibers to their original state. 19695 19696 resetChildFibers(workInProgress, renderLanes); // Set up the Suspense Context to force suspense and immediately 19697 // rerender the children. 19698 19699 pushSuspenseContext(workInProgress, setShallowSuspenseContext(suspenseStackCursor.current, ForceSuspenseFallback)); 19700 return workInProgress.child; 19701 } 19702 19703 row = row.sibling; 19704 } 19705 } 19706 19707 if (renderState.tail !== null && now() > getRenderTargetTime()) { 19708 // We have already passed our CPU deadline but we still have rows 19709 // left in the tail. We'll just give up further attempts to render 19710 // the main content and only render fallbacks. 19711 workInProgress.flags |= DidCapture; 19712 didSuspendAlready = true; 19713 cutOffTailIfNeeded(renderState, false); // Since nothing actually suspended, there will nothing to ping this 19714 // to get it started back up to attempt the next item. While in terms 19715 // of priority this work has the same priority as this current render, 19716 // it's not part of the same transition once the transition has 19717 // committed. If it's sync, we still want to yield so that it can be 19718 // painted. Conceptually, this is really the same as pinging. 19719 // We can use any RetryLane even if it's the one currently rendering 19720 // since we're leaving it behind on this node. 19721 19722 workInProgress.lanes = SomeRetryLane; 19723 19724 { 19725 markSpawnedWork(SomeRetryLane); 19726 } 19727 } 19728 } else { 19729 cutOffTailIfNeeded(renderState, false); 19730 } // Next we're going to render the tail. 19731 19732 } else { 19733 // Append the rendered row to the child list. 19734 if (!didSuspendAlready) { 19735 var _suspended = findFirstSuspended(renderedTail); 19736 19737 if (_suspended !== null) { 19738 workInProgress.flags |= DidCapture; 19739 didSuspendAlready = true; // Ensure we transfer the update queue to the parent so that it doesn't 19740 // get lost if this row ends up dropped during a second pass. 19741 19742 var _newThennables = _suspended.updateQueue; 19743 19744 if (_newThennables !== null) { 19745 workInProgress.updateQueue = _newThennables; 19746 workInProgress.flags |= Update; 19747 } 19748 19749 cutOffTailIfNeeded(renderState, true); // This might have been modified. 19750 19751 if (renderState.tail === null && renderState.tailMode === 'hidden' && !renderedTail.alternate && !getIsHydrating() // We don't cut it if we're hydrating. 19752 ) { 19753 // We need to delete the row we just rendered. 19754 // Reset the effect list to what it was before we rendered this 19755 // child. The nested children have already appended themselves. 19756 var lastEffect = workInProgress.lastEffect = renderState.lastEffect; // Remove any effects that were appended after this point. 19757 19758 if (lastEffect !== null) { 19759 lastEffect.nextEffect = null; 19760 } // We're done. 19761 19762 19763 return null; 19764 } 19765 } else if ( // The time it took to render last row is greater than the remaining 19766 // time we have to render. So rendering one more row would likely 19767 // exceed it. 19768 now() * 2 - renderState.renderingStartTime > getRenderTargetTime() && renderLanes !== OffscreenLane) { 19769 // We have now passed our CPU deadline and we'll just give up further 19770 // attempts to render the main content and only render fallbacks. 19771 // The assumption is that this is usually faster. 19772 workInProgress.flags |= DidCapture; 19773 didSuspendAlready = true; 19774 cutOffTailIfNeeded(renderState, false); // Since nothing actually suspended, there will nothing to ping this 19775 // to get it started back up to attempt the next item. While in terms 19776 // of priority this work has the same priority as this current render, 19777 // it's not part of the same transition once the transition has 19778 // committed. If it's sync, we still want to yield so that it can be 19779 // painted. Conceptually, this is really the same as pinging. 19780 // We can use any RetryLane even if it's the one currently rendering 19781 // since we're leaving it behind on this node. 19782 19783 workInProgress.lanes = SomeRetryLane; 19784 19785 { 19786 markSpawnedWork(SomeRetryLane); 19787 } 19788 } 19789 } 19790 19791 if (renderState.isBackwards) { 19792 // The effect list of the backwards tail will have been added 19793 // to the end. This breaks the guarantee that life-cycles fire in 19794 // sibling order but that isn't a strong guarantee promised by React. 19795 // Especially since these might also just pop in during future commits. 19796 // Append to the beginning of the list. 19797 renderedTail.sibling = workInProgress.child; 19798 workInProgress.child = renderedTail; 19799 } else { 19800 var previousSibling = renderState.last; 19801 19802 if (previousSibling !== null) { 19803 previousSibling.sibling = renderedTail; 19804 } else { 19805 workInProgress.child = renderedTail; 19806 } 19807 19808 renderState.last = renderedTail; 19809 } 19810 } 19811 19812 if (renderState.tail !== null) { 19813 // We still have tail rows to render. 19814 // Pop a row. 19815 var next = renderState.tail; 19816 renderState.rendering = next; 19817 renderState.tail = next.sibling; 19818 renderState.lastEffect = workInProgress.lastEffect; 19819 renderState.renderingStartTime = now(); 19820 next.sibling = null; // Restore the context. 19821 // TODO: We can probably just avoid popping it instead and only 19822 // setting it the first time we go from not suspended to suspended. 19823 19824 var suspenseContext = suspenseStackCursor.current; 19825 19826 if (didSuspendAlready) { 19827 suspenseContext = setShallowSuspenseContext(suspenseContext, ForceSuspenseFallback); 19828 } else { 19829 suspenseContext = setDefaultShallowSuspenseContext(suspenseContext); 19830 } 19831 19832 pushSuspenseContext(workInProgress, suspenseContext); // Do a pass over the next row. 19833 19834 return next; 19835 } 19836 19837 return null; 19838 } 19839 19840 case FundamentalComponent: 19841 { 19842 19843 break; 19844 } 19845 19846 case ScopeComponent: 19847 { 19848 19849 break; 19850 } 19851 19852 case Block: 19853 19854 break; 19855 19856 case OffscreenComponent: 19857 case LegacyHiddenComponent: 19858 { 19859 popRenderLanes(workInProgress); 19860 19861 if (current !== null) { 19862 var _nextState = workInProgress.memoizedState; 19863 var _prevState = current.memoizedState; 19864 var prevIsHidden = _prevState !== null; 19865 var nextIsHidden = _nextState !== null; 19866 19867 if (prevIsHidden !== nextIsHidden && newProps.mode !== 'unstable-defer-without-hiding') { 19868 workInProgress.flags |= Update; 19869 } 19870 } 19871 19872 return null; 19873 } 19874 } 19875 19876 { 19877 { 19878 throw Error( "Unknown unit of work tag (" + workInProgress.tag + "). This error is likely caused by a bug in React. Please file an issue." ); 19879 } 19880 } 19881} 19882 19883function unwindWork(workInProgress, renderLanes) { 19884 switch (workInProgress.tag) { 19885 case ClassComponent: 19886 { 19887 var Component = workInProgress.type; 19888 19889 if (isContextProvider(Component)) { 19890 popContext(workInProgress); 19891 } 19892 19893 var flags = workInProgress.flags; 19894 19895 if (flags & ShouldCapture) { 19896 workInProgress.flags = flags & ~ShouldCapture | DidCapture; 19897 19898 if ( (workInProgress.mode & ProfileMode) !== NoMode) { 19899 transferActualDuration(workInProgress); 19900 } 19901 19902 return workInProgress; 19903 } 19904 19905 return null; 19906 } 19907 19908 case HostRoot: 19909 { 19910 popHostContainer(workInProgress); 19911 popTopLevelContextObject(workInProgress); 19912 resetWorkInProgressVersions(); 19913 var _flags = workInProgress.flags; 19914 19915 if (!((_flags & DidCapture) === NoFlags)) { 19916 { 19917 throw Error( "The root failed to unmount after an error. This is likely a bug in React. Please file an issue." ); 19918 } 19919 } 19920 19921 workInProgress.flags = _flags & ~ShouldCapture | DidCapture; 19922 return workInProgress; 19923 } 19924 19925 case HostComponent: 19926 { 19927 // TODO: popHydrationState 19928 popHostContext(workInProgress); 19929 return null; 19930 } 19931 19932 case SuspenseComponent: 19933 { 19934 popSuspenseContext(workInProgress); 19935 19936 var _flags2 = workInProgress.flags; 19937 19938 if (_flags2 & ShouldCapture) { 19939 workInProgress.flags = _flags2 & ~ShouldCapture | DidCapture; // Captured a suspense effect. Re-render the boundary. 19940 19941 if ( (workInProgress.mode & ProfileMode) !== NoMode) { 19942 transferActualDuration(workInProgress); 19943 } 19944 19945 return workInProgress; 19946 } 19947 19948 return null; 19949 } 19950 19951 case SuspenseListComponent: 19952 { 19953 popSuspenseContext(workInProgress); // SuspenseList doesn't actually catch anything. It should've been 19954 // caught by a nested boundary. If not, it should bubble through. 19955 19956 return null; 19957 } 19958 19959 case HostPortal: 19960 popHostContainer(workInProgress); 19961 return null; 19962 19963 case ContextProvider: 19964 popProvider(workInProgress); 19965 return null; 19966 19967 case OffscreenComponent: 19968 case LegacyHiddenComponent: 19969 popRenderLanes(workInProgress); 19970 return null; 19971 19972 default: 19973 return null; 19974 } 19975} 19976 19977function unwindInterruptedWork(interruptedWork) { 19978 switch (interruptedWork.tag) { 19979 case ClassComponent: 19980 { 19981 var childContextTypes = interruptedWork.type.childContextTypes; 19982 19983 if (childContextTypes !== null && childContextTypes !== undefined) { 19984 popContext(interruptedWork); 19985 } 19986 19987 break; 19988 } 19989 19990 case HostRoot: 19991 { 19992 popHostContainer(interruptedWork); 19993 popTopLevelContextObject(interruptedWork); 19994 resetWorkInProgressVersions(); 19995 break; 19996 } 19997 19998 case HostComponent: 19999 { 20000 popHostContext(interruptedWork); 20001 break; 20002 } 20003 20004 case HostPortal: 20005 popHostContainer(interruptedWork); 20006 break; 20007 20008 case SuspenseComponent: 20009 popSuspenseContext(interruptedWork); 20010 break; 20011 20012 case SuspenseListComponent: 20013 popSuspenseContext(interruptedWork); 20014 break; 20015 20016 case ContextProvider: 20017 popProvider(interruptedWork); 20018 break; 20019 20020 case OffscreenComponent: 20021 case LegacyHiddenComponent: 20022 popRenderLanes(interruptedWork); 20023 break; 20024 } 20025} 20026 20027function createCapturedValue(value, source) { 20028 // If the value is an error, call this function immediately after it is thrown 20029 // so the stack is accurate. 20030 return { 20031 value: value, 20032 source: source, 20033 stack: getStackByFiberInDevAndProd(source) 20034 }; 20035} 20036 20037// This module is forked in different environments. 20038// By default, return `true` to log errors to the console. 20039// Forks can return `false` if this isn't desirable. 20040function showErrorDialog(boundary, errorInfo) { 20041 return true; 20042} 20043 20044function logCapturedError(boundary, errorInfo) { 20045 try { 20046 var logError = showErrorDialog(boundary, errorInfo); // Allow injected showErrorDialog() to prevent default console.error logging. 20047 // This enables renderers like ReactNative to better manage redbox behavior. 20048 20049 if (logError === false) { 20050 return; 20051 } 20052 20053 var error = errorInfo.value; 20054 20055 if (true) { 20056 var source = errorInfo.source; 20057 var stack = errorInfo.stack; 20058 var componentStack = stack !== null ? stack : ''; // Browsers support silencing uncaught errors by calling 20059 // `preventDefault()` in window `error` handler. 20060 // We record this information as an expando on the error. 20061 20062 if (error != null && error._suppressLogging) { 20063 if (boundary.tag === ClassComponent) { 20064 // The error is recoverable and was silenced. 20065 // Ignore it and don't print the stack addendum. 20066 // This is handy for testing error boundaries without noise. 20067 return; 20068 } // The error is fatal. Since the silencing might have 20069 // been accidental, we'll surface it anyway. 20070 // However, the browser would have silenced the original error 20071 // so we'll print it first, and then print the stack addendum. 20072 20073 20074 console['error'](error); // Don't transform to our wrapper 20075 // For a more detailed description of this block, see: 20076 // https://github.com/facebook/react/pull/13384 20077 } 20078 20079 var componentName = source ? getComponentName(source.type) : null; 20080 var componentNameMessage = componentName ? "The above error occurred in the <" + componentName + "> component:" : 'The above error occurred in one of your React components:'; 20081 var errorBoundaryMessage; 20082 var errorBoundaryName = getComponentName(boundary.type); 20083 20084 if (errorBoundaryName) { 20085 errorBoundaryMessage = "React will try to recreate this component tree from scratch " + ("using the error boundary you provided, " + errorBoundaryName + "."); 20086 } else { 20087 errorBoundaryMessage = 'Consider adding an error boundary to your tree to customize error handling behavior.\n' + 'Visit https://reactjs.org/link/error-boundaries to learn more about error boundaries.'; 20088 } 20089 20090 var combinedMessage = componentNameMessage + "\n" + componentStack + "\n\n" + ("" + errorBoundaryMessage); // In development, we provide our own message with just the component stack. 20091 // We don't include the original error message and JS stack because the browser 20092 // has already printed it. Even if the application swallows the error, it is still 20093 // displayed by the browser thanks to the DEV-only fake event trick in ReactErrorUtils. 20094 20095 console['error'](combinedMessage); // Don't transform to our wrapper 20096 } else {} 20097 } catch (e) { 20098 // This method must not throw, or React internal state will get messed up. 20099 // If console.error is overridden, or logCapturedError() shows a dialog that throws, 20100 // we want to report this error outside of the normal stack as a last resort. 20101 // https://github.com/facebook/react/issues/13188 20102 setTimeout(function () { 20103 throw e; 20104 }); 20105 } 20106} 20107 20108var PossiblyWeakMap$1 = typeof WeakMap === 'function' ? WeakMap : Map; 20109 20110function createRootErrorUpdate(fiber, errorInfo, lane) { 20111 var update = createUpdate(NoTimestamp, lane); // Unmount the root by rendering null. 20112 20113 update.tag = CaptureUpdate; // Caution: React DevTools currently depends on this property 20114 // being called "element". 20115 20116 update.payload = { 20117 element: null 20118 }; 20119 var error = errorInfo.value; 20120 20121 update.callback = function () { 20122 onUncaughtError(error); 20123 logCapturedError(fiber, errorInfo); 20124 }; 20125 20126 return update; 20127} 20128 20129function createClassErrorUpdate(fiber, errorInfo, lane) { 20130 var update = createUpdate(NoTimestamp, lane); 20131 update.tag = CaptureUpdate; 20132 var getDerivedStateFromError = fiber.type.getDerivedStateFromError; 20133 20134 if (typeof getDerivedStateFromError === 'function') { 20135 var error$1 = errorInfo.value; 20136 20137 update.payload = function () { 20138 logCapturedError(fiber, errorInfo); 20139 return getDerivedStateFromError(error$1); 20140 }; 20141 } 20142 20143 var inst = fiber.stateNode; 20144 20145 if (inst !== null && typeof inst.componentDidCatch === 'function') { 20146 update.callback = function callback() { 20147 { 20148 markFailedErrorBoundaryForHotReloading(fiber); 20149 } 20150 20151 if (typeof getDerivedStateFromError !== 'function') { 20152 // To preserve the preexisting retry behavior of error boundaries, 20153 // we keep track of which ones already failed during this batch. 20154 // This gets reset before we yield back to the browser. 20155 // TODO: Warn in strict mode if getDerivedStateFromError is 20156 // not defined. 20157 markLegacyErrorBoundaryAsFailed(this); // Only log here if componentDidCatch is the only error boundary method defined 20158 20159 logCapturedError(fiber, errorInfo); 20160 } 20161 20162 var error$1 = errorInfo.value; 20163 var stack = errorInfo.stack; 20164 this.componentDidCatch(error$1, { 20165 componentStack: stack !== null ? stack : '' 20166 }); 20167 20168 { 20169 if (typeof getDerivedStateFromError !== 'function') { 20170 // If componentDidCatch is the only error boundary method defined, 20171 // then it needs to call setState to recover from errors. 20172 // If no state update is scheduled then the boundary will swallow the error. 20173 if (!includesSomeLane(fiber.lanes, SyncLane)) { 20174 error('%s: Error boundaries should implement getDerivedStateFromError(). ' + 'In that method, return a state update to display an error message or fallback UI.', getComponentName(fiber.type) || 'Unknown'); 20175 } 20176 } 20177 } 20178 }; 20179 } else { 20180 update.callback = function () { 20181 markFailedErrorBoundaryForHotReloading(fiber); 20182 }; 20183 } 20184 20185 return update; 20186} 20187 20188function attachPingListener(root, wakeable, lanes) { 20189 // Attach a listener to the promise to "ping" the root and retry. But only if 20190 // one does not already exist for the lanes we're currently rendering (which 20191 // acts like a "thread ID" here). 20192 var pingCache = root.pingCache; 20193 var threadIDs; 20194 20195 if (pingCache === null) { 20196 pingCache = root.pingCache = new PossiblyWeakMap$1(); 20197 threadIDs = new Set(); 20198 pingCache.set(wakeable, threadIDs); 20199 } else { 20200 threadIDs = pingCache.get(wakeable); 20201 20202 if (threadIDs === undefined) { 20203 threadIDs = new Set(); 20204 pingCache.set(wakeable, threadIDs); 20205 } 20206 } 20207 20208 if (!threadIDs.has(lanes)) { 20209 // Memoize using the thread ID to prevent redundant listeners. 20210 threadIDs.add(lanes); 20211 var ping = pingSuspendedRoot.bind(null, root, wakeable, lanes); 20212 wakeable.then(ping, ping); 20213 } 20214} 20215 20216function throwException(root, returnFiber, sourceFiber, value, rootRenderLanes) { 20217 // The source fiber did not complete. 20218 sourceFiber.flags |= Incomplete; // Its effect list is no longer valid. 20219 20220 sourceFiber.firstEffect = sourceFiber.lastEffect = null; 20221 20222 if (value !== null && typeof value === 'object' && typeof value.then === 'function') { 20223 // This is a wakeable. 20224 var wakeable = value; 20225 20226 if ((sourceFiber.mode & BlockingMode) === NoMode) { 20227 // Reset the memoizedState to what it was before we attempted 20228 // to render it. 20229 var currentSource = sourceFiber.alternate; 20230 20231 if (currentSource) { 20232 sourceFiber.updateQueue = currentSource.updateQueue; 20233 sourceFiber.memoizedState = currentSource.memoizedState; 20234 sourceFiber.lanes = currentSource.lanes; 20235 } else { 20236 sourceFiber.updateQueue = null; 20237 sourceFiber.memoizedState = null; 20238 } 20239 } 20240 20241 var hasInvisibleParentBoundary = hasSuspenseContext(suspenseStackCursor.current, InvisibleParentSuspenseContext); // Schedule the nearest Suspense to re-render the timed out view. 20242 20243 var _workInProgress = returnFiber; 20244 20245 do { 20246 if (_workInProgress.tag === SuspenseComponent && shouldCaptureSuspense(_workInProgress, hasInvisibleParentBoundary)) { 20247 // Found the nearest boundary. 20248 // Stash the promise on the boundary fiber. If the boundary times out, we'll 20249 // attach another listener to flip the boundary back to its normal state. 20250 var wakeables = _workInProgress.updateQueue; 20251 20252 if (wakeables === null) { 20253 var updateQueue = new Set(); 20254 updateQueue.add(wakeable); 20255 _workInProgress.updateQueue = updateQueue; 20256 } else { 20257 wakeables.add(wakeable); 20258 } // If the boundary is outside of blocking mode, we should *not* 20259 // suspend the commit. Pretend as if the suspended component rendered 20260 // null and keep rendering. In the commit phase, we'll schedule a 20261 // subsequent synchronous update to re-render the Suspense. 20262 // 20263 // Note: It doesn't matter whether the component that suspended was 20264 // inside a blocking mode tree. If the Suspense is outside of it, we 20265 // should *not* suspend the commit. 20266 20267 20268 if ((_workInProgress.mode & BlockingMode) === NoMode) { 20269 _workInProgress.flags |= DidCapture; 20270 sourceFiber.flags |= ForceUpdateForLegacySuspense; // We're going to commit this fiber even though it didn't complete. 20271 // But we shouldn't call any lifecycle methods or callbacks. Remove 20272 // all lifecycle effect tags. 20273 20274 sourceFiber.flags &= ~(LifecycleEffectMask | Incomplete); 20275 20276 if (sourceFiber.tag === ClassComponent) { 20277 var currentSourceFiber = sourceFiber.alternate; 20278 20279 if (currentSourceFiber === null) { 20280 // This is a new mount. Change the tag so it's not mistaken for a 20281 // completed class component. For example, we should not call 20282 // componentWillUnmount if it is deleted. 20283 sourceFiber.tag = IncompleteClassComponent; 20284 } else { 20285 // When we try rendering again, we should not reuse the current fiber, 20286 // since it's known to be in an inconsistent state. Use a force update to 20287 // prevent a bail out. 20288 var update = createUpdate(NoTimestamp, SyncLane); 20289 update.tag = ForceUpdate; 20290 enqueueUpdate(sourceFiber, update); 20291 } 20292 } // The source fiber did not complete. Mark it with Sync priority to 20293 // indicate that it still has pending work. 20294 20295 20296 sourceFiber.lanes = mergeLanes(sourceFiber.lanes, SyncLane); // Exit without suspending. 20297 20298 return; 20299 } // Confirmed that the boundary is in a concurrent mode tree. Continue 20300 // with the normal suspend path. 20301 // 20302 // After this we'll use a set of heuristics to determine whether this 20303 // render pass will run to completion or restart or "suspend" the commit. 20304 // The actual logic for this is spread out in different places. 20305 // 20306 // This first principle is that if we're going to suspend when we complete 20307 // a root, then we should also restart if we get an update or ping that 20308 // might unsuspend it, and vice versa. The only reason to suspend is 20309 // because you think you might want to restart before committing. However, 20310 // it doesn't make sense to restart only while in the period we're suspended. 20311 // 20312 // Restarting too aggressively is also not good because it starves out any 20313 // intermediate loading state. So we use heuristics to determine when. 20314 // Suspense Heuristics 20315 // 20316 // If nothing threw a Promise or all the same fallbacks are already showing, 20317 // then don't suspend/restart. 20318 // 20319 // If this is an initial render of a new tree of Suspense boundaries and 20320 // those trigger a fallback, then don't suspend/restart. We want to ensure 20321 // that we can show the initial loading state as quickly as possible. 20322 // 20323 // If we hit a "Delayed" case, such as when we'd switch from content back into 20324 // a fallback, then we should always suspend/restart. Transitions apply 20325 // to this case. If none is defined, JND is used instead. 20326 // 20327 // If we're already showing a fallback and it gets "retried", allowing us to show 20328 // another level, but there's still an inner boundary that would show a fallback, 20329 // then we suspend/restart for 500ms since the last time we showed a fallback 20330 // anywhere in the tree. This effectively throttles progressive loading into a 20331 // consistent train of commits. This also gives us an opportunity to restart to 20332 // get to the completed state slightly earlier. 20333 // 20334 // If there's ambiguity due to batching it's resolved in preference of: 20335 // 1) "delayed", 2) "initial render", 3) "retry". 20336 // 20337 // We want to ensure that a "busy" state doesn't get force committed. We want to 20338 // ensure that new initial loading states can commit as soon as possible. 20339 20340 20341 attachPingListener(root, wakeable, rootRenderLanes); 20342 _workInProgress.flags |= ShouldCapture; 20343 _workInProgress.lanes = rootRenderLanes; 20344 return; 20345 } // This boundary already captured during this render. Continue to the next 20346 // boundary. 20347 20348 20349 _workInProgress = _workInProgress.return; 20350 } while (_workInProgress !== null); // No boundary was found. Fallthrough to error mode. 20351 // TODO: Use invariant so the message is stripped in prod? 20352 20353 20354 value = new Error((getComponentName(sourceFiber.type) || 'A React component') + ' suspended while rendering, but no fallback UI was specified.\n' + '\n' + 'Add a <Suspense fallback=...> component higher in the tree to ' + 'provide a loading indicator or placeholder to display.'); 20355 } // We didn't find a boundary that could handle this type of exception. Start 20356 // over and traverse parent path again, this time treating the exception 20357 // as an error. 20358 20359 20360 renderDidError(); 20361 value = createCapturedValue(value, sourceFiber); 20362 var workInProgress = returnFiber; 20363 20364 do { 20365 switch (workInProgress.tag) { 20366 case HostRoot: 20367 { 20368 var _errorInfo = value; 20369 workInProgress.flags |= ShouldCapture; 20370 var lane = pickArbitraryLane(rootRenderLanes); 20371 workInProgress.lanes = mergeLanes(workInProgress.lanes, lane); 20372 20373 var _update = createRootErrorUpdate(workInProgress, _errorInfo, lane); 20374 20375 enqueueCapturedUpdate(workInProgress, _update); 20376 return; 20377 } 20378 20379 case ClassComponent: 20380 // Capture and retry 20381 var errorInfo = value; 20382 var ctor = workInProgress.type; 20383 var instance = workInProgress.stateNode; 20384 20385 if ((workInProgress.flags & DidCapture) === NoFlags && (typeof ctor.getDerivedStateFromError === 'function' || instance !== null && typeof instance.componentDidCatch === 'function' && !isAlreadyFailedLegacyErrorBoundary(instance))) { 20386 workInProgress.flags |= ShouldCapture; 20387 20388 var _lane = pickArbitraryLane(rootRenderLanes); 20389 20390 workInProgress.lanes = mergeLanes(workInProgress.lanes, _lane); // Schedule the error boundary to re-render using updated state 20391 20392 var _update2 = createClassErrorUpdate(workInProgress, errorInfo, _lane); 20393 20394 enqueueCapturedUpdate(workInProgress, _update2); 20395 return; 20396 } 20397 20398 break; 20399 } 20400 20401 workInProgress = workInProgress.return; 20402 } while (workInProgress !== null); 20403} 20404 20405var didWarnAboutUndefinedSnapshotBeforeUpdate = null; 20406 20407{ 20408 didWarnAboutUndefinedSnapshotBeforeUpdate = new Set(); 20409} 20410 20411var PossiblyWeakSet = typeof WeakSet === 'function' ? WeakSet : Set; 20412 20413var callComponentWillUnmountWithTimer = function (current, instance) { 20414 instance.props = current.memoizedProps; 20415 instance.state = current.memoizedState; 20416 20417 { 20418 instance.componentWillUnmount(); 20419 } 20420}; // Capture errors so they don't interrupt unmounting. 20421 20422 20423function safelyCallComponentWillUnmount(current, instance) { 20424 { 20425 invokeGuardedCallback(null, callComponentWillUnmountWithTimer, null, current, instance); 20426 20427 if (hasCaughtError()) { 20428 var unmountError = clearCaughtError(); 20429 captureCommitPhaseError(current, unmountError); 20430 } 20431 } 20432} 20433 20434function safelyDetachRef(current) { 20435 var ref = current.ref; 20436 20437 if (ref !== null) { 20438 if (typeof ref === 'function') { 20439 { 20440 invokeGuardedCallback(null, ref, null, null); 20441 20442 if (hasCaughtError()) { 20443 var refError = clearCaughtError(); 20444 captureCommitPhaseError(current, refError); 20445 } 20446 } 20447 } else { 20448 ref.current = null; 20449 } 20450 } 20451} 20452 20453function safelyCallDestroy(current, destroy) { 20454 { 20455 invokeGuardedCallback(null, destroy, null); 20456 20457 if (hasCaughtError()) { 20458 var error = clearCaughtError(); 20459 captureCommitPhaseError(current, error); 20460 } 20461 } 20462} 20463 20464function commitBeforeMutationLifeCycles(current, finishedWork) { 20465 switch (finishedWork.tag) { 20466 case FunctionComponent: 20467 case ForwardRef: 20468 case SimpleMemoComponent: 20469 case Block: 20470 { 20471 return; 20472 } 20473 20474 case ClassComponent: 20475 { 20476 if (finishedWork.flags & Snapshot) { 20477 if (current !== null) { 20478 var prevProps = current.memoizedProps; 20479 var prevState = current.memoizedState; 20480 var instance = finishedWork.stateNode; // We could update instance props and state here, 20481 // but instead we rely on them being set during last render. 20482 // TODO: revisit this when we implement resuming. 20483 20484 { 20485 if (finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps) { 20486 if (instance.props !== finishedWork.memoizedProps) { 20487 error('Expected %s props to match memoized props before ' + 'getSnapshotBeforeUpdate. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.props`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance'); 20488 } 20489 20490 if (instance.state !== finishedWork.memoizedState) { 20491 error('Expected %s state to match memoized state before ' + 'getSnapshotBeforeUpdate. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.state`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance'); 20492 } 20493 } 20494 } 20495 20496 var snapshot = instance.getSnapshotBeforeUpdate(finishedWork.elementType === finishedWork.type ? prevProps : resolveDefaultProps(finishedWork.type, prevProps), prevState); 20497 20498 { 20499 var didWarnSet = didWarnAboutUndefinedSnapshotBeforeUpdate; 20500 20501 if (snapshot === undefined && !didWarnSet.has(finishedWork.type)) { 20502 didWarnSet.add(finishedWork.type); 20503 20504 error('%s.getSnapshotBeforeUpdate(): A snapshot value (or null) ' + 'must be returned. You have returned undefined.', getComponentName(finishedWork.type)); 20505 } 20506 } 20507 20508 instance.__reactInternalSnapshotBeforeUpdate = snapshot; 20509 } 20510 } 20511 20512 return; 20513 } 20514 20515 case HostRoot: 20516 { 20517 { 20518 if (finishedWork.flags & Snapshot) { 20519 var root = finishedWork.stateNode; 20520 clearContainer(root.containerInfo); 20521 } 20522 } 20523 20524 return; 20525 } 20526 20527 case HostComponent: 20528 case HostText: 20529 case HostPortal: 20530 case IncompleteClassComponent: 20531 // Nothing to do for these component types 20532 return; 20533 } 20534 20535 { 20536 { 20537 throw Error( "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." ); 20538 } 20539 } 20540} 20541 20542function commitHookEffectListUnmount(tag, finishedWork) { 20543 var updateQueue = finishedWork.updateQueue; 20544 var lastEffect = updateQueue !== null ? updateQueue.lastEffect : null; 20545 20546 if (lastEffect !== null) { 20547 var firstEffect = lastEffect.next; 20548 var effect = firstEffect; 20549 20550 do { 20551 if ((effect.tag & tag) === tag) { 20552 // Unmount 20553 var destroy = effect.destroy; 20554 effect.destroy = undefined; 20555 20556 if (destroy !== undefined) { 20557 destroy(); 20558 } 20559 } 20560 20561 effect = effect.next; 20562 } while (effect !== firstEffect); 20563 } 20564} 20565 20566function commitHookEffectListMount(tag, finishedWork) { 20567 var updateQueue = finishedWork.updateQueue; 20568 var lastEffect = updateQueue !== null ? updateQueue.lastEffect : null; 20569 20570 if (lastEffect !== null) { 20571 var firstEffect = lastEffect.next; 20572 var effect = firstEffect; 20573 20574 do { 20575 if ((effect.tag & tag) === tag) { 20576 // Mount 20577 var create = effect.create; 20578 effect.destroy = create(); 20579 20580 { 20581 var destroy = effect.destroy; 20582 20583 if (destroy !== undefined && typeof destroy !== 'function') { 20584 var addendum = void 0; 20585 20586 if (destroy === null) { 20587 addendum = ' You returned null. If your effect does not require clean ' + 'up, return undefined (or nothing).'; 20588 } else if (typeof destroy.then === 'function') { 20589 addendum = '\n\nIt looks like you wrote useEffect(async () => ...) or returned a Promise. ' + 'Instead, write the async function inside your effect ' + 'and call it immediately:\n\n' + 'useEffect(() => {\n' + ' async function fetchData() {\n' + ' // You can await here\n' + ' const response = await MyAPI.getData(someId);\n' + ' // ...\n' + ' }\n' + ' fetchData();\n' + "}, [someId]); // Or [] if effect doesn't need props or state\n\n" + 'Learn more about data fetching with Hooks: https://reactjs.org/link/hooks-data-fetching'; 20590 } else { 20591 addendum = ' You returned: ' + destroy; 20592 } 20593 20594 error('An effect function must not return anything besides a function, ' + 'which is used for clean-up.%s', addendum); 20595 } 20596 } 20597 } 20598 20599 effect = effect.next; 20600 } while (effect !== firstEffect); 20601 } 20602} 20603 20604function schedulePassiveEffects(finishedWork) { 20605 var updateQueue = finishedWork.updateQueue; 20606 var lastEffect = updateQueue !== null ? updateQueue.lastEffect : null; 20607 20608 if (lastEffect !== null) { 20609 var firstEffect = lastEffect.next; 20610 var effect = firstEffect; 20611 20612 do { 20613 var _effect = effect, 20614 next = _effect.next, 20615 tag = _effect.tag; 20616 20617 if ((tag & Passive$1) !== NoFlags$1 && (tag & HasEffect) !== NoFlags$1) { 20618 enqueuePendingPassiveHookEffectUnmount(finishedWork, effect); 20619 enqueuePendingPassiveHookEffectMount(finishedWork, effect); 20620 } 20621 20622 effect = next; 20623 } while (effect !== firstEffect); 20624 } 20625} 20626 20627function commitLifeCycles(finishedRoot, current, finishedWork, committedLanes) { 20628 switch (finishedWork.tag) { 20629 case FunctionComponent: 20630 case ForwardRef: 20631 case SimpleMemoComponent: 20632 case Block: 20633 { 20634 // At this point layout effects have already been destroyed (during mutation phase). 20635 // This is done to prevent sibling component effects from interfering with each other, 20636 // e.g. a destroy function in one component should never override a ref set 20637 // by a create function in another component during the same commit. 20638 { 20639 commitHookEffectListMount(Layout | HasEffect, finishedWork); 20640 } 20641 20642 schedulePassiveEffects(finishedWork); 20643 return; 20644 } 20645 20646 case ClassComponent: 20647 { 20648 var instance = finishedWork.stateNode; 20649 20650 if (finishedWork.flags & Update) { 20651 if (current === null) { 20652 // We could update instance props and state here, 20653 // but instead we rely on them being set during last render. 20654 // TODO: revisit this when we implement resuming. 20655 { 20656 if (finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps) { 20657 if (instance.props !== finishedWork.memoizedProps) { 20658 error('Expected %s props to match memoized props before ' + 'componentDidMount. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.props`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance'); 20659 } 20660 20661 if (instance.state !== finishedWork.memoizedState) { 20662 error('Expected %s state to match memoized state before ' + 'componentDidMount. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.state`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance'); 20663 } 20664 } 20665 } 20666 20667 { 20668 instance.componentDidMount(); 20669 } 20670 } else { 20671 var prevProps = finishedWork.elementType === finishedWork.type ? current.memoizedProps : resolveDefaultProps(finishedWork.type, current.memoizedProps); 20672 var prevState = current.memoizedState; // We could update instance props and state here, 20673 // but instead we rely on them being set during last render. 20674 // TODO: revisit this when we implement resuming. 20675 20676 { 20677 if (finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps) { 20678 if (instance.props !== finishedWork.memoizedProps) { 20679 error('Expected %s props to match memoized props before ' + 'componentDidUpdate. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.props`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance'); 20680 } 20681 20682 if (instance.state !== finishedWork.memoizedState) { 20683 error('Expected %s state to match memoized state before ' + 'componentDidUpdate. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.state`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance'); 20684 } 20685 } 20686 } 20687 20688 { 20689 instance.componentDidUpdate(prevProps, prevState, instance.__reactInternalSnapshotBeforeUpdate); 20690 } 20691 } 20692 } // TODO: I think this is now always non-null by the time it reaches the 20693 // commit phase. Consider removing the type check. 20694 20695 20696 var updateQueue = finishedWork.updateQueue; 20697 20698 if (updateQueue !== null) { 20699 { 20700 if (finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps) { 20701 if (instance.props !== finishedWork.memoizedProps) { 20702 error('Expected %s props to match memoized props before ' + 'processing the update queue. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.props`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance'); 20703 } 20704 20705 if (instance.state !== finishedWork.memoizedState) { 20706 error('Expected %s state to match memoized state before ' + 'processing the update queue. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.state`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance'); 20707 } 20708 } 20709 } // We could update instance props and state here, 20710 // but instead we rely on them being set during last render. 20711 // TODO: revisit this when we implement resuming. 20712 20713 20714 commitUpdateQueue(finishedWork, updateQueue, instance); 20715 } 20716 20717 return; 20718 } 20719 20720 case HostRoot: 20721 { 20722 // TODO: I think this is now always non-null by the time it reaches the 20723 // commit phase. Consider removing the type check. 20724 var _updateQueue = finishedWork.updateQueue; 20725 20726 if (_updateQueue !== null) { 20727 var _instance = null; 20728 20729 if (finishedWork.child !== null) { 20730 switch (finishedWork.child.tag) { 20731 case HostComponent: 20732 _instance = getPublicInstance(finishedWork.child.stateNode); 20733 break; 20734 20735 case ClassComponent: 20736 _instance = finishedWork.child.stateNode; 20737 break; 20738 } 20739 } 20740 20741 commitUpdateQueue(finishedWork, _updateQueue, _instance); 20742 } 20743 20744 return; 20745 } 20746 20747 case HostComponent: 20748 { 20749 var _instance2 = finishedWork.stateNode; // Renderers may schedule work to be done after host components are mounted 20750 // (eg DOM renderer may schedule auto-focus for inputs and form controls). 20751 // These effects should only be committed when components are first mounted, 20752 // aka when there is no current/alternate. 20753 20754 if (current === null && finishedWork.flags & Update) { 20755 var type = finishedWork.type; 20756 var props = finishedWork.memoizedProps; 20757 commitMount(_instance2, type, props); 20758 } 20759 20760 return; 20761 } 20762 20763 case HostText: 20764 { 20765 // We have no life-cycles associated with text. 20766 return; 20767 } 20768 20769 case HostPortal: 20770 { 20771 // We have no life-cycles associated with portals. 20772 return; 20773 } 20774 20775 case Profiler: 20776 { 20777 { 20778 var _finishedWork$memoize2 = finishedWork.memoizedProps, 20779 onCommit = _finishedWork$memoize2.onCommit, 20780 onRender = _finishedWork$memoize2.onRender; 20781 var effectDuration = finishedWork.stateNode.effectDuration; 20782 var commitTime = getCommitTime(); 20783 20784 if (typeof onRender === 'function') { 20785 { 20786 onRender(finishedWork.memoizedProps.id, current === null ? 'mount' : 'update', finishedWork.actualDuration, finishedWork.treeBaseDuration, finishedWork.actualStartTime, commitTime, finishedRoot.memoizedInteractions); 20787 } 20788 } 20789 } 20790 20791 return; 20792 } 20793 20794 case SuspenseComponent: 20795 { 20796 commitSuspenseHydrationCallbacks(finishedRoot, finishedWork); 20797 return; 20798 } 20799 20800 case SuspenseListComponent: 20801 case IncompleteClassComponent: 20802 case FundamentalComponent: 20803 case ScopeComponent: 20804 case OffscreenComponent: 20805 case LegacyHiddenComponent: 20806 return; 20807 } 20808 20809 { 20810 { 20811 throw Error( "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." ); 20812 } 20813 } 20814} 20815 20816function hideOrUnhideAllChildren(finishedWork, isHidden) { 20817 { 20818 // We only have the top Fiber that was inserted but we need to recurse down its 20819 // children to find all the terminal nodes. 20820 var node = finishedWork; 20821 20822 while (true) { 20823 if (node.tag === HostComponent) { 20824 var instance = node.stateNode; 20825 20826 if (isHidden) { 20827 hideInstance(instance); 20828 } else { 20829 unhideInstance(node.stateNode, node.memoizedProps); 20830 } 20831 } else if (node.tag === HostText) { 20832 var _instance3 = node.stateNode; 20833 20834 if (isHidden) { 20835 hideTextInstance(_instance3); 20836 } else { 20837 unhideTextInstance(_instance3, node.memoizedProps); 20838 } 20839 } else if ((node.tag === OffscreenComponent || node.tag === LegacyHiddenComponent) && node.memoizedState !== null && node !== finishedWork) ; else if (node.child !== null) { 20840 node.child.return = node; 20841 node = node.child; 20842 continue; 20843 } 20844 20845 if (node === finishedWork) { 20846 return; 20847 } 20848 20849 while (node.sibling === null) { 20850 if (node.return === null || node.return === finishedWork) { 20851 return; 20852 } 20853 20854 node = node.return; 20855 } 20856 20857 node.sibling.return = node.return; 20858 node = node.sibling; 20859 } 20860 } 20861} 20862 20863function commitAttachRef(finishedWork) { 20864 var ref = finishedWork.ref; 20865 20866 if (ref !== null) { 20867 var instance = finishedWork.stateNode; 20868 var instanceToUse; 20869 20870 switch (finishedWork.tag) { 20871 case HostComponent: 20872 instanceToUse = getPublicInstance(instance); 20873 break; 20874 20875 default: 20876 instanceToUse = instance; 20877 } // Moved outside to ensure DCE works with this flag 20878 20879 if (typeof ref === 'function') { 20880 ref(instanceToUse); 20881 } else { 20882 { 20883 if (!ref.hasOwnProperty('current')) { 20884 error('Unexpected ref object provided for %s. ' + 'Use either a ref-setter function or React.createRef().', getComponentName(finishedWork.type)); 20885 } 20886 } 20887 20888 ref.current = instanceToUse; 20889 } 20890 } 20891} 20892 20893function commitDetachRef(current) { 20894 var currentRef = current.ref; 20895 20896 if (currentRef !== null) { 20897 if (typeof currentRef === 'function') { 20898 currentRef(null); 20899 } else { 20900 currentRef.current = null; 20901 } 20902 } 20903} // User-originating errors (lifecycles and refs) should not interrupt 20904// deletion, so don't let them throw. Host-originating errors should 20905// interrupt deletion, so it's okay 20906 20907 20908function commitUnmount(finishedRoot, current, renderPriorityLevel) { 20909 onCommitUnmount(current); 20910 20911 switch (current.tag) { 20912 case FunctionComponent: 20913 case ForwardRef: 20914 case MemoComponent: 20915 case SimpleMemoComponent: 20916 case Block: 20917 { 20918 var updateQueue = current.updateQueue; 20919 20920 if (updateQueue !== null) { 20921 var lastEffect = updateQueue.lastEffect; 20922 20923 if (lastEffect !== null) { 20924 var firstEffect = lastEffect.next; 20925 var effect = firstEffect; 20926 20927 do { 20928 var _effect2 = effect, 20929 destroy = _effect2.destroy, 20930 tag = _effect2.tag; 20931 20932 if (destroy !== undefined) { 20933 if ((tag & Passive$1) !== NoFlags$1) { 20934 enqueuePendingPassiveHookEffectUnmount(current, effect); 20935 } else { 20936 { 20937 safelyCallDestroy(current, destroy); 20938 } 20939 } 20940 } 20941 20942 effect = effect.next; 20943 } while (effect !== firstEffect); 20944 } 20945 } 20946 20947 return; 20948 } 20949 20950 case ClassComponent: 20951 { 20952 safelyDetachRef(current); 20953 var instance = current.stateNode; 20954 20955 if (typeof instance.componentWillUnmount === 'function') { 20956 safelyCallComponentWillUnmount(current, instance); 20957 } 20958 20959 return; 20960 } 20961 20962 case HostComponent: 20963 { 20964 safelyDetachRef(current); 20965 return; 20966 } 20967 20968 case HostPortal: 20969 { 20970 // TODO: this is recursive. 20971 // We are also not using this parent because 20972 // the portal will get pushed immediately. 20973 { 20974 unmountHostComponents(finishedRoot, current); 20975 } 20976 20977 return; 20978 } 20979 20980 case FundamentalComponent: 20981 { 20982 20983 return; 20984 } 20985 20986 case DehydratedFragment: 20987 { 20988 20989 return; 20990 } 20991 20992 case ScopeComponent: 20993 { 20994 20995 return; 20996 } 20997 } 20998} 20999 21000function commitNestedUnmounts(finishedRoot, root, renderPriorityLevel) { 21001 // While we're inside a removed host node we don't want to call 21002 // removeChild on the inner nodes because they're removed by the top 21003 // call anyway. We also want to call componentWillUnmount on all 21004 // composites before this host node is removed from the tree. Therefore 21005 // we do an inner loop while we're still inside the host node. 21006 var node = root; 21007 21008 while (true) { 21009 commitUnmount(finishedRoot, node); // Visit children because they may contain more composite or host nodes. 21010 // Skip portals because commitUnmount() currently visits them recursively. 21011 21012 if (node.child !== null && ( // If we use mutation we drill down into portals using commitUnmount above. 21013 // If we don't use mutation we drill down into portals here instead. 21014 node.tag !== HostPortal)) { 21015 node.child.return = node; 21016 node = node.child; 21017 continue; 21018 } 21019 21020 if (node === root) { 21021 return; 21022 } 21023 21024 while (node.sibling === null) { 21025 if (node.return === null || node.return === root) { 21026 return; 21027 } 21028 21029 node = node.return; 21030 } 21031 21032 node.sibling.return = node.return; 21033 node = node.sibling; 21034 } 21035} 21036 21037function detachFiberMutation(fiber) { 21038 // Cut off the return pointers to disconnect it from the tree. Ideally, we 21039 // should clear the child pointer of the parent alternate to let this 21040 // get GC:ed but we don't know which for sure which parent is the current 21041 // one so we'll settle for GC:ing the subtree of this child. This child 21042 // itself will be GC:ed when the parent updates the next time. 21043 // Note: we cannot null out sibling here, otherwise it can cause issues 21044 // with findDOMNode and how it requires the sibling field to carry out 21045 // traversal in a later effect. See PR #16820. We now clear the sibling 21046 // field after effects, see: detachFiberAfterEffects. 21047 // 21048 // Don't disconnect stateNode now; it will be detached in detachFiberAfterEffects. 21049 // It may be required if the current component is an error boundary, 21050 // and one of its descendants throws while unmounting a passive effect. 21051 fiber.alternate = null; 21052 fiber.child = null; 21053 fiber.dependencies = null; 21054 fiber.firstEffect = null; 21055 fiber.lastEffect = null; 21056 fiber.memoizedProps = null; 21057 fiber.memoizedState = null; 21058 fiber.pendingProps = null; 21059 fiber.return = null; 21060 fiber.updateQueue = null; 21061 21062 { 21063 fiber._debugOwner = null; 21064 } 21065} 21066 21067function getHostParentFiber(fiber) { 21068 var parent = fiber.return; 21069 21070 while (parent !== null) { 21071 if (isHostParent(parent)) { 21072 return parent; 21073 } 21074 21075 parent = parent.return; 21076 } 21077 21078 { 21079 { 21080 throw Error( "Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue." ); 21081 } 21082 } 21083} 21084 21085function isHostParent(fiber) { 21086 return fiber.tag === HostComponent || fiber.tag === HostRoot || fiber.tag === HostPortal; 21087} 21088 21089function getHostSibling(fiber) { 21090 // We're going to search forward into the tree until we find a sibling host 21091 // node. Unfortunately, if multiple insertions are done in a row we have to 21092 // search past them. This leads to exponential search for the next sibling. 21093 // TODO: Find a more efficient way to do this. 21094 var node = fiber; 21095 21096 siblings: while (true) { 21097 // If we didn't find anything, let's try the next sibling. 21098 while (node.sibling === null) { 21099 if (node.return === null || isHostParent(node.return)) { 21100 // If we pop out of the root or hit the parent the fiber we are the 21101 // last sibling. 21102 return null; 21103 } 21104 21105 node = node.return; 21106 } 21107 21108 node.sibling.return = node.return; 21109 node = node.sibling; 21110 21111 while (node.tag !== HostComponent && node.tag !== HostText && node.tag !== DehydratedFragment) { 21112 // If it is not host node and, we might have a host node inside it. 21113 // Try to search down until we find one. 21114 if (node.flags & Placement) { 21115 // If we don't have a child, try the siblings instead. 21116 continue siblings; 21117 } // If we don't have a child, try the siblings instead. 21118 // We also skip portals because they are not part of this host tree. 21119 21120 21121 if (node.child === null || node.tag === HostPortal) { 21122 continue siblings; 21123 } else { 21124 node.child.return = node; 21125 node = node.child; 21126 } 21127 } // Check if this host node is stable or about to be placed. 21128 21129 21130 if (!(node.flags & Placement)) { 21131 // Found it! 21132 return node.stateNode; 21133 } 21134 } 21135} 21136 21137function commitPlacement(finishedWork) { 21138 21139 21140 var parentFiber = getHostParentFiber(finishedWork); // Note: these two variables *must* always be updated together. 21141 21142 var parent; 21143 var isContainer; 21144 var parentStateNode = parentFiber.stateNode; 21145 21146 switch (parentFiber.tag) { 21147 case HostComponent: 21148 parent = parentStateNode; 21149 isContainer = false; 21150 break; 21151 21152 case HostRoot: 21153 parent = parentStateNode.containerInfo; 21154 isContainer = true; 21155 break; 21156 21157 case HostPortal: 21158 parent = parentStateNode.containerInfo; 21159 isContainer = true; 21160 break; 21161 21162 case FundamentalComponent: 21163 21164 // eslint-disable-next-line-no-fallthrough 21165 21166 default: 21167 { 21168 { 21169 throw Error( "Invalid host parent fiber. This error is likely caused by a bug in React. Please file an issue." ); 21170 } 21171 } 21172 21173 } 21174 21175 if (parentFiber.flags & ContentReset) { 21176 // Reset the text content of the parent before doing any insertions 21177 resetTextContent(parent); // Clear ContentReset from the effect tag 21178 21179 parentFiber.flags &= ~ContentReset; 21180 } 21181 21182 var before = getHostSibling(finishedWork); // We only have the top Fiber that was inserted but we need to recurse down its 21183 // children to find all the terminal nodes. 21184 21185 if (isContainer) { 21186 insertOrAppendPlacementNodeIntoContainer(finishedWork, before, parent); 21187 } else { 21188 insertOrAppendPlacementNode(finishedWork, before, parent); 21189 } 21190} 21191 21192function insertOrAppendPlacementNodeIntoContainer(node, before, parent) { 21193 var tag = node.tag; 21194 var isHost = tag === HostComponent || tag === HostText; 21195 21196 if (isHost || enableFundamentalAPI ) { 21197 var stateNode = isHost ? node.stateNode : node.stateNode.instance; 21198 21199 if (before) { 21200 insertInContainerBefore(parent, stateNode, before); 21201 } else { 21202 appendChildToContainer(parent, stateNode); 21203 } 21204 } else if (tag === HostPortal) ; else { 21205 var child = node.child; 21206 21207 if (child !== null) { 21208 insertOrAppendPlacementNodeIntoContainer(child, before, parent); 21209 var sibling = child.sibling; 21210 21211 while (sibling !== null) { 21212 insertOrAppendPlacementNodeIntoContainer(sibling, before, parent); 21213 sibling = sibling.sibling; 21214 } 21215 } 21216 } 21217} 21218 21219function insertOrAppendPlacementNode(node, before, parent) { 21220 var tag = node.tag; 21221 var isHost = tag === HostComponent || tag === HostText; 21222 21223 if (isHost || enableFundamentalAPI ) { 21224 var stateNode = isHost ? node.stateNode : node.stateNode.instance; 21225 21226 if (before) { 21227 insertBefore(parent, stateNode, before); 21228 } else { 21229 appendChild(parent, stateNode); 21230 } 21231 } else if (tag === HostPortal) ; else { 21232 var child = node.child; 21233 21234 if (child !== null) { 21235 insertOrAppendPlacementNode(child, before, parent); 21236 var sibling = child.sibling; 21237 21238 while (sibling !== null) { 21239 insertOrAppendPlacementNode(sibling, before, parent); 21240 sibling = sibling.sibling; 21241 } 21242 } 21243 } 21244} 21245 21246function unmountHostComponents(finishedRoot, current, renderPriorityLevel) { 21247 // We only have the top Fiber that was deleted but we need to recurse down its 21248 // children to find all the terminal nodes. 21249 var node = current; // Each iteration, currentParent is populated with node's host parent if not 21250 // currentParentIsValid. 21251 21252 var currentParentIsValid = false; // Note: these two variables *must* always be updated together. 21253 21254 var currentParent; 21255 var currentParentIsContainer; 21256 21257 while (true) { 21258 if (!currentParentIsValid) { 21259 var parent = node.return; 21260 21261 findParent: while (true) { 21262 if (!(parent !== null)) { 21263 { 21264 throw Error( "Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue." ); 21265 } 21266 } 21267 21268 var parentStateNode = parent.stateNode; 21269 21270 switch (parent.tag) { 21271 case HostComponent: 21272 currentParent = parentStateNode; 21273 currentParentIsContainer = false; 21274 break findParent; 21275 21276 case HostRoot: 21277 currentParent = parentStateNode.containerInfo; 21278 currentParentIsContainer = true; 21279 break findParent; 21280 21281 case HostPortal: 21282 currentParent = parentStateNode.containerInfo; 21283 currentParentIsContainer = true; 21284 break findParent; 21285 21286 } 21287 21288 parent = parent.return; 21289 } 21290 21291 currentParentIsValid = true; 21292 } 21293 21294 if (node.tag === HostComponent || node.tag === HostText) { 21295 commitNestedUnmounts(finishedRoot, node); // After all the children have unmounted, it is now safe to remove the 21296 // node from the tree. 21297 21298 if (currentParentIsContainer) { 21299 removeChildFromContainer(currentParent, node.stateNode); 21300 } else { 21301 removeChild(currentParent, node.stateNode); 21302 } // Don't visit children because we already visited them. 21303 21304 } else if (node.tag === HostPortal) { 21305 if (node.child !== null) { 21306 // When we go into a portal, it becomes the parent to remove from. 21307 // We will reassign it back when we pop the portal on the way up. 21308 currentParent = node.stateNode.containerInfo; 21309 currentParentIsContainer = true; // Visit children because portals might contain host components. 21310 21311 node.child.return = node; 21312 node = node.child; 21313 continue; 21314 } 21315 } else { 21316 commitUnmount(finishedRoot, node); // Visit children because we may find more host components below. 21317 21318 if (node.child !== null) { 21319 node.child.return = node; 21320 node = node.child; 21321 continue; 21322 } 21323 } 21324 21325 if (node === current) { 21326 return; 21327 } 21328 21329 while (node.sibling === null) { 21330 if (node.return === null || node.return === current) { 21331 return; 21332 } 21333 21334 node = node.return; 21335 21336 if (node.tag === HostPortal) { 21337 // When we go out of the portal, we need to restore the parent. 21338 // Since we don't keep a stack of them, we will search for it. 21339 currentParentIsValid = false; 21340 } 21341 } 21342 21343 node.sibling.return = node.return; 21344 node = node.sibling; 21345 } 21346} 21347 21348function commitDeletion(finishedRoot, current, renderPriorityLevel) { 21349 { 21350 // Recursively delete all host nodes from the parent. 21351 // Detach refs and call componentWillUnmount() on the whole subtree. 21352 unmountHostComponents(finishedRoot, current); 21353 } 21354 21355 var alternate = current.alternate; 21356 detachFiberMutation(current); 21357 21358 if (alternate !== null) { 21359 detachFiberMutation(alternate); 21360 } 21361} 21362 21363function commitWork(current, finishedWork) { 21364 21365 switch (finishedWork.tag) { 21366 case FunctionComponent: 21367 case ForwardRef: 21368 case MemoComponent: 21369 case SimpleMemoComponent: 21370 case Block: 21371 { 21372 // Layout effects are destroyed during the mutation phase so that all 21373 // destroy functions for all fibers are called before any create functions. 21374 // This prevents sibling component effects from interfering with each other, 21375 // e.g. a destroy function in one component should never override a ref set 21376 // by a create function in another component during the same commit. 21377 { 21378 commitHookEffectListUnmount(Layout | HasEffect, finishedWork); 21379 } 21380 21381 return; 21382 } 21383 21384 case ClassComponent: 21385 { 21386 return; 21387 } 21388 21389 case HostComponent: 21390 { 21391 var instance = finishedWork.stateNode; 21392 21393 if (instance != null) { 21394 // Commit the work prepared earlier. 21395 var newProps = finishedWork.memoizedProps; // For hydration we reuse the update path but we treat the oldProps 21396 // as the newProps. The updatePayload will contain the real change in 21397 // this case. 21398 21399 var oldProps = current !== null ? current.memoizedProps : newProps; 21400 var type = finishedWork.type; // TODO: Type the updateQueue to be specific to host components. 21401 21402 var updatePayload = finishedWork.updateQueue; 21403 finishedWork.updateQueue = null; 21404 21405 if (updatePayload !== null) { 21406 commitUpdate(instance, updatePayload, type, oldProps, newProps); 21407 } 21408 } 21409 21410 return; 21411 } 21412 21413 case HostText: 21414 { 21415 if (!(finishedWork.stateNode !== null)) { 21416 { 21417 throw Error( "This should have a text node initialized. This error is likely caused by a bug in React. Please file an issue." ); 21418 } 21419 } 21420 21421 var textInstance = finishedWork.stateNode; 21422 var newText = finishedWork.memoizedProps; // For hydration we reuse the update path but we treat the oldProps 21423 // as the newProps. The updatePayload will contain the real change in 21424 // this case. 21425 21426 var oldText = current !== null ? current.memoizedProps : newText; 21427 commitTextUpdate(textInstance, oldText, newText); 21428 return; 21429 } 21430 21431 case HostRoot: 21432 { 21433 { 21434 var _root = finishedWork.stateNode; 21435 21436 if (_root.hydrate) { 21437 // We've just hydrated. No need to hydrate again. 21438 _root.hydrate = false; 21439 commitHydratedContainer(_root.containerInfo); 21440 } 21441 } 21442 21443 return; 21444 } 21445 21446 case Profiler: 21447 { 21448 return; 21449 } 21450 21451 case SuspenseComponent: 21452 { 21453 commitSuspenseComponent(finishedWork); 21454 attachSuspenseRetryListeners(finishedWork); 21455 return; 21456 } 21457 21458 case SuspenseListComponent: 21459 { 21460 attachSuspenseRetryListeners(finishedWork); 21461 return; 21462 } 21463 21464 case IncompleteClassComponent: 21465 { 21466 return; 21467 } 21468 21469 case FundamentalComponent: 21470 { 21471 21472 break; 21473 } 21474 21475 case ScopeComponent: 21476 { 21477 21478 break; 21479 } 21480 21481 case OffscreenComponent: 21482 case LegacyHiddenComponent: 21483 { 21484 var newState = finishedWork.memoizedState; 21485 var isHidden = newState !== null; 21486 hideOrUnhideAllChildren(finishedWork, isHidden); 21487 return; 21488 } 21489 } 21490 21491 { 21492 { 21493 throw Error( "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." ); 21494 } 21495 } 21496} 21497 21498function commitSuspenseComponent(finishedWork) { 21499 var newState = finishedWork.memoizedState; 21500 21501 if (newState !== null) { 21502 markCommitTimeOfFallback(); 21503 21504 { 21505 // Hide the Offscreen component that contains the primary children. TODO: 21506 // Ideally, this effect would have been scheduled on the Offscreen fiber 21507 // itself. That's how unhiding works: the Offscreen component schedules an 21508 // effect on itself. However, in this case, the component didn't complete, 21509 // so the fiber was never added to the effect list in the normal path. We 21510 // could have appended it to the effect list in the Suspense component's 21511 // second pass, but doing it this way is less complicated. This would be 21512 // simpler if we got rid of the effect list and traversed the tree, like 21513 // we're planning to do. 21514 var primaryChildParent = finishedWork.child; 21515 hideOrUnhideAllChildren(primaryChildParent, true); 21516 } 21517 } 21518} 21519 21520function commitSuspenseHydrationCallbacks(finishedRoot, finishedWork) { 21521 21522 var newState = finishedWork.memoizedState; 21523 21524 if (newState === null) { 21525 var current = finishedWork.alternate; 21526 21527 if (current !== null) { 21528 var prevState = current.memoizedState; 21529 21530 if (prevState !== null) { 21531 var suspenseInstance = prevState.dehydrated; 21532 21533 if (suspenseInstance !== null) { 21534 commitHydratedSuspenseInstance(suspenseInstance); 21535 } 21536 } 21537 } 21538 } 21539} 21540 21541function attachSuspenseRetryListeners(finishedWork) { 21542 // If this boundary just timed out, then it will have a set of wakeables. 21543 // For each wakeable, attach a listener so that when it resolves, React 21544 // attempts to re-render the boundary in the primary (pre-timeout) state. 21545 var wakeables = finishedWork.updateQueue; 21546 21547 if (wakeables !== null) { 21548 finishedWork.updateQueue = null; 21549 var retryCache = finishedWork.stateNode; 21550 21551 if (retryCache === null) { 21552 retryCache = finishedWork.stateNode = new PossiblyWeakSet(); 21553 } 21554 21555 wakeables.forEach(function (wakeable) { 21556 // Memoize using the boundary fiber to prevent redundant listeners. 21557 var retry = resolveRetryWakeable.bind(null, finishedWork, wakeable); 21558 21559 if (!retryCache.has(wakeable)) { 21560 { 21561 if (wakeable.__reactDoNotTraceInteractions !== true) { 21562 retry = tracing.unstable_wrap(retry); 21563 } 21564 } 21565 21566 retryCache.add(wakeable); 21567 wakeable.then(retry, retry); 21568 } 21569 }); 21570 } 21571} // This function detects when a Suspense boundary goes from visible to hidden. 21572// It returns false if the boundary is already hidden. 21573// TODO: Use an effect tag. 21574 21575 21576function isSuspenseBoundaryBeingHidden(current, finishedWork) { 21577 if (current !== null) { 21578 var oldState = current.memoizedState; 21579 21580 if (oldState === null || oldState.dehydrated !== null) { 21581 var newState = finishedWork.memoizedState; 21582 return newState !== null && newState.dehydrated === null; 21583 } 21584 } 21585 21586 return false; 21587} 21588 21589function commitResetTextContent(current) { 21590 21591 resetTextContent(current.stateNode); 21592} 21593 21594var COMPONENT_TYPE = 0; 21595var HAS_PSEUDO_CLASS_TYPE = 1; 21596var ROLE_TYPE = 2; 21597var TEST_NAME_TYPE = 3; 21598var TEXT_TYPE = 4; 21599 21600if (typeof Symbol === 'function' && Symbol.for) { 21601 var symbolFor$1 = Symbol.for; 21602 COMPONENT_TYPE = symbolFor$1('selector.component'); 21603 HAS_PSEUDO_CLASS_TYPE = symbolFor$1('selector.has_pseudo_class'); 21604 ROLE_TYPE = symbolFor$1('selector.role'); 21605 TEST_NAME_TYPE = symbolFor$1('selector.test_id'); 21606 TEXT_TYPE = symbolFor$1('selector.text'); 21607} 21608var commitHooks = []; 21609function onCommitRoot$1() { 21610 { 21611 commitHooks.forEach(function (commitHook) { 21612 return commitHook(); 21613 }); 21614 } 21615} 21616 21617var ceil = Math.ceil; 21618var ReactCurrentDispatcher$2 = ReactSharedInternals.ReactCurrentDispatcher, 21619 ReactCurrentOwner$2 = ReactSharedInternals.ReactCurrentOwner, 21620 IsSomeRendererActing = ReactSharedInternals.IsSomeRendererActing; 21621var NoContext = 21622/* */ 216230; 21624var BatchedContext = 21625/* */ 216261; 21627var EventContext = 21628/* */ 216292; 21630var DiscreteEventContext = 21631/* */ 216324; 21633var LegacyUnbatchedContext = 21634/* */ 216358; 21636var RenderContext = 21637/* */ 2163816; 21639var CommitContext = 21640/* */ 2164132; 21642var RetryAfterError = 21643/* */ 2164464; 21645var RootIncomplete = 0; 21646var RootFatalErrored = 1; 21647var RootErrored = 2; 21648var RootSuspended = 3; 21649var RootSuspendedWithDelay = 4; 21650var RootCompleted = 5; // Describes where we are in the React execution stack 21651 21652var executionContext = NoContext; // The root we're working on 21653 21654var workInProgressRoot = null; // The fiber we're working on 21655 21656var workInProgress = null; // The lanes we're rendering 21657 21658var workInProgressRootRenderLanes = NoLanes; // Stack that allows components to change the render lanes for its subtree 21659// This is a superset of the lanes we started working on at the root. The only 21660// case where it's different from `workInProgressRootRenderLanes` is when we 21661// enter a subtree that is hidden and needs to be unhidden: Suspense and 21662// Offscreen component. 21663// 21664// Most things in the work loop should deal with workInProgressRootRenderLanes. 21665// Most things in begin/complete phases should deal with subtreeRenderLanes. 21666 21667var subtreeRenderLanes = NoLanes; 21668var subtreeRenderLanesCursor = createCursor(NoLanes); // Whether to root completed, errored, suspended, etc. 21669 21670var workInProgressRootExitStatus = RootIncomplete; // A fatal error, if one is thrown 21671 21672var workInProgressRootFatalError = null; // "Included" lanes refer to lanes that were worked on during this render. It's 21673// slightly different than `renderLanes` because `renderLanes` can change as you 21674// enter and exit an Offscreen tree. This value is the combination of all render 21675// lanes for the entire render phase. 21676 21677var workInProgressRootIncludedLanes = NoLanes; // The work left over by components that were visited during this render. Only 21678// includes unprocessed updates, not work in bailed out children. 21679 21680var workInProgressRootSkippedLanes = NoLanes; // Lanes that were updated (in an interleaved event) during this render. 21681 21682var workInProgressRootUpdatedLanes = NoLanes; // Lanes that were pinged (in an interleaved event) during this render. 21683 21684var workInProgressRootPingedLanes = NoLanes; 21685var mostRecentlyUpdatedRoot = null; // The most recent time we committed a fallback. This lets us ensure a train 21686// model where we don't commit new loading states in too quick succession. 21687 21688var globalMostRecentFallbackTime = 0; 21689var FALLBACK_THROTTLE_MS = 500; // The absolute time for when we should start giving up on rendering 21690// more and prefer CPU suspense heuristics instead. 21691 21692var workInProgressRootRenderTargetTime = Infinity; // How long a render is supposed to take before we start following CPU 21693// suspense heuristics and opt out of rendering more content. 21694 21695var RENDER_TIMEOUT_MS = 500; 21696 21697function resetRenderTimer() { 21698 workInProgressRootRenderTargetTime = now() + RENDER_TIMEOUT_MS; 21699} 21700 21701function getRenderTargetTime() { 21702 return workInProgressRootRenderTargetTime; 21703} 21704var nextEffect = null; 21705var hasUncaughtError = false; 21706var firstUncaughtError = null; 21707var legacyErrorBoundariesThatAlreadyFailed = null; 21708var rootDoesHavePassiveEffects = false; 21709var rootWithPendingPassiveEffects = null; 21710var pendingPassiveEffectsRenderPriority = NoPriority$1; 21711var pendingPassiveEffectsLanes = NoLanes; 21712var pendingPassiveHookEffectsMount = []; 21713var pendingPassiveHookEffectsUnmount = []; 21714var rootsWithPendingDiscreteUpdates = null; // Use these to prevent an infinite loop of nested updates 21715 21716var NESTED_UPDATE_LIMIT = 50; 21717var nestedUpdateCount = 0; 21718var rootWithNestedUpdates = null; 21719var NESTED_PASSIVE_UPDATE_LIMIT = 50; 21720var nestedPassiveUpdateCount = 0; // Marks the need to reschedule pending interactions at these lanes 21721// during the commit phase. This enables them to be traced across components 21722// that spawn new work during render. E.g. hidden boundaries, suspended SSR 21723// hydration or SuspenseList. 21724// TODO: Can use a bitmask instead of an array 21725 21726var spawnedWorkDuringRender = null; // If two updates are scheduled within the same event, we should treat their 21727// event times as simultaneous, even if the actual clock time has advanced 21728// between the first and second call. 21729 21730var currentEventTime = NoTimestamp; 21731var currentEventWipLanes = NoLanes; 21732var currentEventPendingLanes = NoLanes; // Dev only flag that tracks if passive effects are currently being flushed. 21733// We warn about state updates for unmounted components differently in this case. 21734 21735var isFlushingPassiveEffects = false; 21736var focusedInstanceHandle = null; 21737var shouldFireAfterActiveInstanceBlur = false; 21738function getWorkInProgressRoot() { 21739 return workInProgressRoot; 21740} 21741function requestEventTime() { 21742 if ((executionContext & (RenderContext | CommitContext)) !== NoContext) { 21743 // We're inside React, so it's fine to read the actual time. 21744 return now(); 21745 } // We're not inside React, so we may be in the middle of a browser event. 21746 21747 21748 if (currentEventTime !== NoTimestamp) { 21749 // Use the same start time for all updates until we enter React again. 21750 return currentEventTime; 21751 } // This is the first update since React yielded. Compute a new start time. 21752 21753 21754 currentEventTime = now(); 21755 return currentEventTime; 21756} 21757function requestUpdateLane(fiber) { 21758 // Special cases 21759 var mode = fiber.mode; 21760 21761 if ((mode & BlockingMode) === NoMode) { 21762 return SyncLane; 21763 } else if ((mode & ConcurrentMode) === NoMode) { 21764 return getCurrentPriorityLevel() === ImmediatePriority$1 ? SyncLane : SyncBatchedLane; 21765 } // The algorithm for assigning an update to a lane should be stable for all 21766 // updates at the same priority within the same event. To do this, the inputs 21767 // to the algorithm must be the same. For example, we use the `renderLanes` 21768 // to avoid choosing a lane that is already in the middle of rendering. 21769 // 21770 // However, the "included" lanes could be mutated in between updates in the 21771 // same event, like if you perform an update inside `flushSync`. Or any other 21772 // code path that might call `prepareFreshStack`. 21773 // 21774 // The trick we use is to cache the first of each of these inputs within an 21775 // event. Then reset the cached values once we can be sure the event is over. 21776 // Our heuristic for that is whenever we enter a concurrent work loop. 21777 // 21778 // We'll do the same for `currentEventPendingLanes` below. 21779 21780 21781 if (currentEventWipLanes === NoLanes) { 21782 currentEventWipLanes = workInProgressRootIncludedLanes; 21783 } 21784 21785 var isTransition = requestCurrentTransition() !== NoTransition; 21786 21787 if (isTransition) { 21788 if (currentEventPendingLanes !== NoLanes) { 21789 currentEventPendingLanes = mostRecentlyUpdatedRoot !== null ? mostRecentlyUpdatedRoot.pendingLanes : NoLanes; 21790 } 21791 21792 return findTransitionLane(currentEventWipLanes, currentEventPendingLanes); 21793 } // TODO: Remove this dependency on the Scheduler priority. 21794 // To do that, we're replacing it with an update lane priority. 21795 21796 21797 var schedulerPriority = getCurrentPriorityLevel(); // The old behavior was using the priority level of the Scheduler. 21798 // This couples React to the Scheduler internals, so we're replacing it 21799 // with the currentUpdateLanePriority above. As an example of how this 21800 // could be problematic, if we're not inside `Scheduler.runWithPriority`, 21801 // then we'll get the priority of the current running Scheduler task, 21802 // which is probably not what we want. 21803 21804 var lane; 21805 21806 if ( // TODO: Temporary. We're removing the concept of discrete updates. 21807 (executionContext & DiscreteEventContext) !== NoContext && schedulerPriority === UserBlockingPriority$2) { 21808 lane = findUpdateLane(InputDiscreteLanePriority, currentEventWipLanes); 21809 } else { 21810 var schedulerLanePriority = schedulerPriorityToLanePriority(schedulerPriority); 21811 21812 lane = findUpdateLane(schedulerLanePriority, currentEventWipLanes); 21813 } 21814 21815 return lane; 21816} 21817 21818function requestRetryLane(fiber) { 21819 // This is a fork of `requestUpdateLane` designed specifically for Suspense 21820 // "retries" — a special update that attempts to flip a Suspense boundary 21821 // from its placeholder state to its primary/resolved state. 21822 // Special cases 21823 var mode = fiber.mode; 21824 21825 if ((mode & BlockingMode) === NoMode) { 21826 return SyncLane; 21827 } else if ((mode & ConcurrentMode) === NoMode) { 21828 return getCurrentPriorityLevel() === ImmediatePriority$1 ? SyncLane : SyncBatchedLane; 21829 } // See `requestUpdateLane` for explanation of `currentEventWipLanes` 21830 21831 21832 if (currentEventWipLanes === NoLanes) { 21833 currentEventWipLanes = workInProgressRootIncludedLanes; 21834 } 21835 21836 return findRetryLane(currentEventWipLanes); 21837} 21838 21839function scheduleUpdateOnFiber(fiber, lane, eventTime) { 21840 checkForNestedUpdates(); 21841 warnAboutRenderPhaseUpdatesInDEV(fiber); 21842 var root = markUpdateLaneFromFiberToRoot(fiber, lane); 21843 21844 if (root === null) { 21845 warnAboutUpdateOnUnmountedFiberInDEV(fiber); 21846 return null; 21847 } // Mark that the root has a pending update. 21848 21849 21850 markRootUpdated(root, lane, eventTime); 21851 21852 if (root === workInProgressRoot) { 21853 // Received an update to a tree that's in the middle of rendering. Mark 21854 // that there was an interleaved update work on this root. Unless the 21855 // `deferRenderPhaseUpdateToNextBatch` flag is off and this is a render 21856 // phase update. In that case, we don't treat render phase updates as if 21857 // they were interleaved, for backwards compat reasons. 21858 { 21859 workInProgressRootUpdatedLanes = mergeLanes(workInProgressRootUpdatedLanes, lane); 21860 } 21861 21862 if (workInProgressRootExitStatus === RootSuspendedWithDelay) { 21863 // The root already suspended with a delay, which means this render 21864 // definitely won't finish. Since we have a new update, let's mark it as 21865 // suspended now, right before marking the incoming update. This has the 21866 // effect of interrupting the current render and switching to the update. 21867 // TODO: Make sure this doesn't override pings that happen while we've 21868 // already started rendering. 21869 markRootSuspended$1(root, workInProgressRootRenderLanes); 21870 } 21871 } // TODO: requestUpdateLanePriority also reads the priority. Pass the 21872 // priority as an argument to that function and this one. 21873 21874 21875 var priorityLevel = getCurrentPriorityLevel(); 21876 21877 if (lane === SyncLane) { 21878 if ( // Check if we're inside unbatchedUpdates 21879 (executionContext & LegacyUnbatchedContext) !== NoContext && // Check if we're not already rendering 21880 (executionContext & (RenderContext | CommitContext)) === NoContext) { 21881 // Register pending interactions on the root to avoid losing traced interaction data. 21882 schedulePendingInteractions(root, lane); // This is a legacy edge case. The initial mount of a ReactDOM.render-ed 21883 // root inside of batchedUpdates should be synchronous, but layout updates 21884 // should be deferred until the end of the batch. 21885 21886 performSyncWorkOnRoot(root); 21887 } else { 21888 ensureRootIsScheduled(root, eventTime); 21889 schedulePendingInteractions(root, lane); 21890 21891 if (executionContext === NoContext) { 21892 // Flush the synchronous work now, unless we're already working or inside 21893 // a batch. This is intentionally inside scheduleUpdateOnFiber instead of 21894 // scheduleCallbackForFiber to preserve the ability to schedule a callback 21895 // without immediately flushing it. We only do this for user-initiated 21896 // updates, to preserve historical behavior of legacy mode. 21897 resetRenderTimer(); 21898 flushSyncCallbackQueue(); 21899 } 21900 } 21901 } else { 21902 // Schedule a discrete update but only if it's not Sync. 21903 if ((executionContext & DiscreteEventContext) !== NoContext && ( // Only updates at user-blocking priority or greater are considered 21904 // discrete, even inside a discrete event. 21905 priorityLevel === UserBlockingPriority$2 || priorityLevel === ImmediatePriority$1)) { 21906 // This is the result of a discrete event. Track the lowest priority 21907 // discrete update per root so we can flush them early, if needed. 21908 if (rootsWithPendingDiscreteUpdates === null) { 21909 rootsWithPendingDiscreteUpdates = new Set([root]); 21910 } else { 21911 rootsWithPendingDiscreteUpdates.add(root); 21912 } 21913 } // Schedule other updates after in case the callback is sync. 21914 21915 21916 ensureRootIsScheduled(root, eventTime); 21917 schedulePendingInteractions(root, lane); 21918 } // We use this when assigning a lane for a transition inside 21919 // `requestUpdateLane`. We assume it's the same as the root being updated, 21920 // since in the common case of a single root app it probably is. If it's not 21921 // the same root, then it's not a huge deal, we just might batch more stuff 21922 // together more than necessary. 21923 21924 21925 mostRecentlyUpdatedRoot = root; 21926} // This is split into a separate function so we can mark a fiber with pending 21927// work without treating it as a typical update that originates from an event; 21928// e.g. retrying a Suspense boundary isn't an update, but it does schedule work 21929// on a fiber. 21930 21931function markUpdateLaneFromFiberToRoot(sourceFiber, lane) { 21932 // Update the source fiber's lanes 21933 sourceFiber.lanes = mergeLanes(sourceFiber.lanes, lane); 21934 var alternate = sourceFiber.alternate; 21935 21936 if (alternate !== null) { 21937 alternate.lanes = mergeLanes(alternate.lanes, lane); 21938 } 21939 21940 { 21941 if (alternate === null && (sourceFiber.flags & (Placement | Hydrating)) !== NoFlags) { 21942 warnAboutUpdateOnNotYetMountedFiberInDEV(sourceFiber); 21943 } 21944 } // Walk the parent path to the root and update the child expiration time. 21945 21946 21947 var node = sourceFiber; 21948 var parent = sourceFiber.return; 21949 21950 while (parent !== null) { 21951 parent.childLanes = mergeLanes(parent.childLanes, lane); 21952 alternate = parent.alternate; 21953 21954 if (alternate !== null) { 21955 alternate.childLanes = mergeLanes(alternate.childLanes, lane); 21956 } else { 21957 { 21958 if ((parent.flags & (Placement | Hydrating)) !== NoFlags) { 21959 warnAboutUpdateOnNotYetMountedFiberInDEV(sourceFiber); 21960 } 21961 } 21962 } 21963 21964 node = parent; 21965 parent = parent.return; 21966 } 21967 21968 if (node.tag === HostRoot) { 21969 var root = node.stateNode; 21970 return root; 21971 } else { 21972 return null; 21973 } 21974} // Use this function to schedule a task for a root. There's only one task per 21975// root; if a task was already scheduled, we'll check to make sure the priority 21976// of the existing task is the same as the priority of the next level that the 21977// root has work on. This function is called on every update, and right before 21978// exiting a task. 21979 21980 21981function ensureRootIsScheduled(root, currentTime) { 21982 var existingCallbackNode = root.callbackNode; // Check if any lanes are being starved by other work. If so, mark them as 21983 // expired so we know to work on those next. 21984 21985 markStarvedLanesAsExpired(root, currentTime); // Determine the next lanes to work on, and their priority. 21986 21987 var nextLanes = getNextLanes(root, root === workInProgressRoot ? workInProgressRootRenderLanes : NoLanes); // This returns the priority level computed during the `getNextLanes` call. 21988 21989 var newCallbackPriority = returnNextLanesPriority(); 21990 21991 if (nextLanes === NoLanes) { 21992 // Special case: There's nothing to work on. 21993 if (existingCallbackNode !== null) { 21994 cancelCallback(existingCallbackNode); 21995 root.callbackNode = null; 21996 root.callbackPriority = NoLanePriority; 21997 } 21998 21999 return; 22000 } // Check if there's an existing task. We may be able to reuse it. 22001 22002 22003 if (existingCallbackNode !== null) { 22004 var existingCallbackPriority = root.callbackPriority; 22005 22006 if (existingCallbackPriority === newCallbackPriority) { 22007 // The priority hasn't changed. We can reuse the existing task. Exit. 22008 return; 22009 } // The priority changed. Cancel the existing callback. We'll schedule a new 22010 // one below. 22011 22012 22013 cancelCallback(existingCallbackNode); 22014 } // Schedule a new callback. 22015 22016 22017 var newCallbackNode; 22018 22019 if (newCallbackPriority === SyncLanePriority) { 22020 // Special case: Sync React callbacks are scheduled on a special 22021 // internal queue 22022 newCallbackNode = scheduleSyncCallback(performSyncWorkOnRoot.bind(null, root)); 22023 } else if (newCallbackPriority === SyncBatchedLanePriority) { 22024 newCallbackNode = scheduleCallback(ImmediatePriority$1, performSyncWorkOnRoot.bind(null, root)); 22025 } else { 22026 var schedulerPriorityLevel = lanePriorityToSchedulerPriority(newCallbackPriority); 22027 newCallbackNode = scheduleCallback(schedulerPriorityLevel, performConcurrentWorkOnRoot.bind(null, root)); 22028 } 22029 22030 root.callbackPriority = newCallbackPriority; 22031 root.callbackNode = newCallbackNode; 22032} // This is the entry point for every concurrent task, i.e. anything that 22033// goes through Scheduler. 22034 22035 22036function performConcurrentWorkOnRoot(root) { 22037 // Since we know we're in a React event, we can clear the current 22038 // event time. The next update will compute a new event time. 22039 currentEventTime = NoTimestamp; 22040 currentEventWipLanes = NoLanes; 22041 currentEventPendingLanes = NoLanes; 22042 22043 if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) { 22044 { 22045 throw Error( "Should not already be working." ); 22046 } 22047 } // Flush any pending passive effects before deciding which lanes to work on, 22048 // in case they schedule additional work. 22049 22050 22051 var originalCallbackNode = root.callbackNode; 22052 var didFlushPassiveEffects = flushPassiveEffects(); 22053 22054 if (didFlushPassiveEffects) { 22055 // Something in the passive effect phase may have canceled the current task. 22056 // Check if the task node for this root was changed. 22057 if (root.callbackNode !== originalCallbackNode) { 22058 // The current task was canceled. Exit. We don't need to call 22059 // `ensureRootIsScheduled` because the check above implies either that 22060 // there's a new task, or that there's no remaining work on this root. 22061 return null; 22062 } 22063 } // Determine the next expiration time to work on, using the fields stored 22064 // on the root. 22065 22066 22067 var lanes = getNextLanes(root, root === workInProgressRoot ? workInProgressRootRenderLanes : NoLanes); 22068 22069 if (lanes === NoLanes) { 22070 // Defensive coding. This is never expected to happen. 22071 return null; 22072 } 22073 22074 var exitStatus = renderRootConcurrent(root, lanes); 22075 22076 if (includesSomeLane(workInProgressRootIncludedLanes, workInProgressRootUpdatedLanes)) { 22077 // The render included lanes that were updated during the render phase. 22078 // For example, when unhiding a hidden tree, we include all the lanes 22079 // that were previously skipped when the tree was hidden. That set of 22080 // lanes is a superset of the lanes we started rendering with. 22081 // 22082 // So we'll throw out the current work and restart. 22083 prepareFreshStack(root, NoLanes); 22084 } else if (exitStatus !== RootIncomplete) { 22085 if (exitStatus === RootErrored) { 22086 executionContext |= RetryAfterError; // If an error occurred during hydration, 22087 // discard server response and fall back to client side render. 22088 22089 if (root.hydrate) { 22090 root.hydrate = false; 22091 clearContainer(root.containerInfo); 22092 } // If something threw an error, try rendering one more time. We'll render 22093 // synchronously to block concurrent data mutations, and we'll includes 22094 // all pending updates are included. If it still fails after the second 22095 // attempt, we'll give up and commit the resulting tree. 22096 22097 22098 lanes = getLanesToRetrySynchronouslyOnError(root); 22099 22100 if (lanes !== NoLanes) { 22101 exitStatus = renderRootSync(root, lanes); 22102 } 22103 } 22104 22105 if (exitStatus === RootFatalErrored) { 22106 var fatalError = workInProgressRootFatalError; 22107 prepareFreshStack(root, NoLanes); 22108 markRootSuspended$1(root, lanes); 22109 ensureRootIsScheduled(root, now()); 22110 throw fatalError; 22111 } // We now have a consistent tree. The next step is either to commit it, 22112 // or, if something suspended, wait to commit it after a timeout. 22113 22114 22115 var finishedWork = root.current.alternate; 22116 root.finishedWork = finishedWork; 22117 root.finishedLanes = lanes; 22118 finishConcurrentRender(root, exitStatus, lanes); 22119 } 22120 22121 ensureRootIsScheduled(root, now()); 22122 22123 if (root.callbackNode === originalCallbackNode) { 22124 // The task node scheduled for this root is the same one that's 22125 // currently executed. Need to return a continuation. 22126 return performConcurrentWorkOnRoot.bind(null, root); 22127 } 22128 22129 return null; 22130} 22131 22132function finishConcurrentRender(root, exitStatus, lanes) { 22133 switch (exitStatus) { 22134 case RootIncomplete: 22135 case RootFatalErrored: 22136 { 22137 { 22138 { 22139 throw Error( "Root did not complete. This is a bug in React." ); 22140 } 22141 } 22142 } 22143 // Flow knows about invariant, so it complains if I add a break 22144 // statement, but eslint doesn't know about invariant, so it complains 22145 // if I do. eslint-disable-next-line no-fallthrough 22146 22147 case RootErrored: 22148 { 22149 // We should have already attempted to retry this tree. If we reached 22150 // this point, it errored again. Commit it. 22151 commitRoot(root); 22152 break; 22153 } 22154 22155 case RootSuspended: 22156 { 22157 markRootSuspended$1(root, lanes); // We have an acceptable loading state. We need to figure out if we 22158 // should immediately commit it or wait a bit. 22159 22160 if (includesOnlyRetries(lanes) && // do not delay if we're inside an act() scope 22161 !shouldForceFlushFallbacksInDEV()) { 22162 // This render only included retries, no updates. Throttle committing 22163 // retries so that we don't show too many loading states too quickly. 22164 var msUntilTimeout = globalMostRecentFallbackTime + FALLBACK_THROTTLE_MS - now(); // Don't bother with a very short suspense time. 22165 22166 if (msUntilTimeout > 10) { 22167 var nextLanes = getNextLanes(root, NoLanes); 22168 22169 if (nextLanes !== NoLanes) { 22170 // There's additional work on this root. 22171 break; 22172 } 22173 22174 var suspendedLanes = root.suspendedLanes; 22175 22176 if (!isSubsetOfLanes(suspendedLanes, lanes)) { 22177 // We should prefer to render the fallback of at the last 22178 // suspended level. Ping the last suspended level to try 22179 // rendering it again. 22180 // FIXME: What if the suspended lanes are Idle? Should not restart. 22181 var eventTime = requestEventTime(); 22182 markRootPinged(root, suspendedLanes); 22183 break; 22184 } // The render is suspended, it hasn't timed out, and there's no 22185 // lower priority work to do. Instead of committing the fallback 22186 // immediately, wait for more data to arrive. 22187 22188 22189 root.timeoutHandle = scheduleTimeout(commitRoot.bind(null, root), msUntilTimeout); 22190 break; 22191 } 22192 } // The work expired. Commit immediately. 22193 22194 22195 commitRoot(root); 22196 break; 22197 } 22198 22199 case RootSuspendedWithDelay: 22200 { 22201 markRootSuspended$1(root, lanes); 22202 22203 if (includesOnlyTransitions(lanes)) { 22204 // This is a transition, so we should exit without committing a 22205 // placeholder and without scheduling a timeout. Delay indefinitely 22206 // until we receive more data. 22207 break; 22208 } 22209 22210 if (!shouldForceFlushFallbacksInDEV()) { 22211 // This is not a transition, but we did trigger an avoided state. 22212 // Schedule a placeholder to display after a short delay, using the Just 22213 // Noticeable Difference. 22214 // TODO: Is the JND optimization worth the added complexity? If this is 22215 // the only reason we track the event time, then probably not. 22216 // Consider removing. 22217 var mostRecentEventTime = getMostRecentEventTime(root, lanes); 22218 var eventTimeMs = mostRecentEventTime; 22219 var timeElapsedMs = now() - eventTimeMs; 22220 22221 var _msUntilTimeout = jnd(timeElapsedMs) - timeElapsedMs; // Don't bother with a very short suspense time. 22222 22223 22224 if (_msUntilTimeout > 10) { 22225 // Instead of committing the fallback immediately, wait for more data 22226 // to arrive. 22227 root.timeoutHandle = scheduleTimeout(commitRoot.bind(null, root), _msUntilTimeout); 22228 break; 22229 } 22230 } // Commit the placeholder. 22231 22232 22233 commitRoot(root); 22234 break; 22235 } 22236 22237 case RootCompleted: 22238 { 22239 // The work completed. Ready to commit. 22240 commitRoot(root); 22241 break; 22242 } 22243 22244 default: 22245 { 22246 { 22247 { 22248 throw Error( "Unknown root exit status." ); 22249 } 22250 } 22251 } 22252 } 22253} 22254 22255function markRootSuspended$1(root, suspendedLanes) { 22256 // When suspending, we should always exclude lanes that were pinged or (more 22257 // rarely, since we try to avoid it) updated during the render phase. 22258 // TODO: Lol maybe there's a better way to factor this besides this 22259 // obnoxiously named function :) 22260 suspendedLanes = removeLanes(suspendedLanes, workInProgressRootPingedLanes); 22261 suspendedLanes = removeLanes(suspendedLanes, workInProgressRootUpdatedLanes); 22262 markRootSuspended(root, suspendedLanes); 22263} // This is the entry point for synchronous tasks that don't go 22264// through Scheduler 22265 22266 22267function performSyncWorkOnRoot(root) { 22268 if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) { 22269 { 22270 throw Error( "Should not already be working." ); 22271 } 22272 } 22273 22274 flushPassiveEffects(); 22275 var lanes; 22276 var exitStatus; 22277 22278 if (root === workInProgressRoot && includesSomeLane(root.expiredLanes, workInProgressRootRenderLanes)) { 22279 // There's a partial tree, and at least one of its lanes has expired. Finish 22280 // rendering it before rendering the rest of the expired work. 22281 lanes = workInProgressRootRenderLanes; 22282 exitStatus = renderRootSync(root, lanes); 22283 22284 if (includesSomeLane(workInProgressRootIncludedLanes, workInProgressRootUpdatedLanes)) { 22285 // The render included lanes that were updated during the render phase. 22286 // For example, when unhiding a hidden tree, we include all the lanes 22287 // that were previously skipped when the tree was hidden. That set of 22288 // lanes is a superset of the lanes we started rendering with. 22289 // 22290 // Note that this only happens when part of the tree is rendered 22291 // concurrently. If the whole tree is rendered synchronously, then there 22292 // are no interleaved events. 22293 lanes = getNextLanes(root, lanes); 22294 exitStatus = renderRootSync(root, lanes); 22295 } 22296 } else { 22297 lanes = getNextLanes(root, NoLanes); 22298 exitStatus = renderRootSync(root, lanes); 22299 } 22300 22301 if (root.tag !== LegacyRoot && exitStatus === RootErrored) { 22302 executionContext |= RetryAfterError; // If an error occurred during hydration, 22303 // discard server response and fall back to client side render. 22304 22305 if (root.hydrate) { 22306 root.hydrate = false; 22307 clearContainer(root.containerInfo); 22308 } // If something threw an error, try rendering one more time. We'll render 22309 // synchronously to block concurrent data mutations, and we'll includes 22310 // all pending updates are included. If it still fails after the second 22311 // attempt, we'll give up and commit the resulting tree. 22312 22313 22314 lanes = getLanesToRetrySynchronouslyOnError(root); 22315 22316 if (lanes !== NoLanes) { 22317 exitStatus = renderRootSync(root, lanes); 22318 } 22319 } 22320 22321 if (exitStatus === RootFatalErrored) { 22322 var fatalError = workInProgressRootFatalError; 22323 prepareFreshStack(root, NoLanes); 22324 markRootSuspended$1(root, lanes); 22325 ensureRootIsScheduled(root, now()); 22326 throw fatalError; 22327 } // We now have a consistent tree. Because this is a sync render, we 22328 // will commit it even if something suspended. 22329 22330 22331 var finishedWork = root.current.alternate; 22332 root.finishedWork = finishedWork; 22333 root.finishedLanes = lanes; 22334 commitRoot(root); // Before exiting, make sure there's a callback scheduled for the next 22335 // pending level. 22336 22337 ensureRootIsScheduled(root, now()); 22338 return null; 22339} 22340function flushDiscreteUpdates() { 22341 // TODO: Should be able to flush inside batchedUpdates, but not inside `act`. 22342 // However, `act` uses `batchedUpdates`, so there's no way to distinguish 22343 // those two cases. Need to fix this before exposing flushDiscreteUpdates 22344 // as a public API. 22345 if ((executionContext & (BatchedContext | RenderContext | CommitContext)) !== NoContext) { 22346 { 22347 if ((executionContext & RenderContext) !== NoContext) { 22348 error('unstable_flushDiscreteUpdates: Cannot flush updates when React is ' + 'already rendering.'); 22349 } 22350 } // We're already rendering, so we can't synchronously flush pending work. 22351 // This is probably a nested event dispatch triggered by a lifecycle/effect, 22352 // like `el.focus()`. Exit. 22353 22354 22355 return; 22356 } 22357 22358 flushPendingDiscreteUpdates(); // If the discrete updates scheduled passive effects, flush them now so that 22359 // they fire before the next serial event. 22360 22361 flushPassiveEffects(); 22362} 22363 22364function flushPendingDiscreteUpdates() { 22365 if (rootsWithPendingDiscreteUpdates !== null) { 22366 // For each root with pending discrete updates, schedule a callback to 22367 // immediately flush them. 22368 var roots = rootsWithPendingDiscreteUpdates; 22369 rootsWithPendingDiscreteUpdates = null; 22370 roots.forEach(function (root) { 22371 markDiscreteUpdatesExpired(root); 22372 ensureRootIsScheduled(root, now()); 22373 }); 22374 } // Now flush the immediate queue. 22375 22376 22377 flushSyncCallbackQueue(); 22378} 22379 22380function batchedUpdates$1(fn, a) { 22381 var prevExecutionContext = executionContext; 22382 executionContext |= BatchedContext; 22383 22384 try { 22385 return fn(a); 22386 } finally { 22387 executionContext = prevExecutionContext; 22388 22389 if (executionContext === NoContext) { 22390 // Flush the immediate callbacks that were scheduled during this batch 22391 resetRenderTimer(); 22392 flushSyncCallbackQueue(); 22393 } 22394 } 22395} 22396function batchedEventUpdates$1(fn, a) { 22397 var prevExecutionContext = executionContext; 22398 executionContext |= EventContext; 22399 22400 try { 22401 return fn(a); 22402 } finally { 22403 executionContext = prevExecutionContext; 22404 22405 if (executionContext === NoContext) { 22406 // Flush the immediate callbacks that were scheduled during this batch 22407 resetRenderTimer(); 22408 flushSyncCallbackQueue(); 22409 } 22410 } 22411} 22412function discreteUpdates$1(fn, a, b, c, d) { 22413 var prevExecutionContext = executionContext; 22414 executionContext |= DiscreteEventContext; 22415 22416 { 22417 try { 22418 return runWithPriority$1(UserBlockingPriority$2, fn.bind(null, a, b, c, d)); 22419 } finally { 22420 executionContext = prevExecutionContext; 22421 22422 if (executionContext === NoContext) { 22423 // Flush the immediate callbacks that were scheduled during this batch 22424 resetRenderTimer(); 22425 flushSyncCallbackQueue(); 22426 } 22427 } 22428 } 22429} 22430function unbatchedUpdates(fn, a) { 22431 var prevExecutionContext = executionContext; 22432 executionContext &= ~BatchedContext; 22433 executionContext |= LegacyUnbatchedContext; 22434 22435 try { 22436 return fn(a); 22437 } finally { 22438 executionContext = prevExecutionContext; 22439 22440 if (executionContext === NoContext) { 22441 // Flush the immediate callbacks that were scheduled during this batch 22442 resetRenderTimer(); 22443 flushSyncCallbackQueue(); 22444 } 22445 } 22446} 22447function flushSync(fn, a) { 22448 var prevExecutionContext = executionContext; 22449 22450 if ((prevExecutionContext & (RenderContext | CommitContext)) !== NoContext) { 22451 { 22452 error('flushSync was called from inside a lifecycle method. React cannot ' + 'flush when React is already rendering. Consider moving this call to ' + 'a scheduler task or micro task.'); 22453 } 22454 22455 return fn(a); 22456 } 22457 22458 executionContext |= BatchedContext; 22459 22460 { 22461 try { 22462 if (fn) { 22463 return runWithPriority$1(ImmediatePriority$1, fn.bind(null, a)); 22464 } else { 22465 return undefined; 22466 } 22467 } finally { 22468 executionContext = prevExecutionContext; // Flush the immediate callbacks that were scheduled during this batch. 22469 // Note that this will happen even if batchedUpdates is higher up 22470 // the stack. 22471 22472 flushSyncCallbackQueue(); 22473 } 22474 } 22475} 22476function pushRenderLanes(fiber, lanes) { 22477 push(subtreeRenderLanesCursor, subtreeRenderLanes, fiber); 22478 subtreeRenderLanes = mergeLanes(subtreeRenderLanes, lanes); 22479 workInProgressRootIncludedLanes = mergeLanes(workInProgressRootIncludedLanes, lanes); 22480} 22481function popRenderLanes(fiber) { 22482 subtreeRenderLanes = subtreeRenderLanesCursor.current; 22483 pop(subtreeRenderLanesCursor, fiber); 22484} 22485 22486function prepareFreshStack(root, lanes) { 22487 root.finishedWork = null; 22488 root.finishedLanes = NoLanes; 22489 var timeoutHandle = root.timeoutHandle; 22490 22491 if (timeoutHandle !== noTimeout) { 22492 // The root previous suspended and scheduled a timeout to commit a fallback 22493 // state. Now that we have additional work, cancel the timeout. 22494 root.timeoutHandle = noTimeout; // $FlowFixMe Complains noTimeout is not a TimeoutID, despite the check above 22495 22496 cancelTimeout(timeoutHandle); 22497 } 22498 22499 if (workInProgress !== null) { 22500 var interruptedWork = workInProgress.return; 22501 22502 while (interruptedWork !== null) { 22503 unwindInterruptedWork(interruptedWork); 22504 interruptedWork = interruptedWork.return; 22505 } 22506 } 22507 22508 workInProgressRoot = root; 22509 workInProgress = createWorkInProgress(root.current, null); 22510 workInProgressRootRenderLanes = subtreeRenderLanes = workInProgressRootIncludedLanes = lanes; 22511 workInProgressRootExitStatus = RootIncomplete; 22512 workInProgressRootFatalError = null; 22513 workInProgressRootSkippedLanes = NoLanes; 22514 workInProgressRootUpdatedLanes = NoLanes; 22515 workInProgressRootPingedLanes = NoLanes; 22516 22517 { 22518 spawnedWorkDuringRender = null; 22519 } 22520 22521 { 22522 ReactStrictModeWarnings.discardPendingWarnings(); 22523 } 22524} 22525 22526function handleError(root, thrownValue) { 22527 do { 22528 var erroredWork = workInProgress; 22529 22530 try { 22531 // Reset module-level state that was set during the render phase. 22532 resetContextDependencies(); 22533 resetHooksAfterThrow(); 22534 resetCurrentFiber(); // TODO: I found and added this missing line while investigating a 22535 // separate issue. Write a regression test using string refs. 22536 22537 ReactCurrentOwner$2.current = null; 22538 22539 if (erroredWork === null || erroredWork.return === null) { 22540 // Expected to be working on a non-root fiber. This is a fatal error 22541 // because there's no ancestor that can handle it; the root is 22542 // supposed to capture all errors that weren't caught by an error 22543 // boundary. 22544 workInProgressRootExitStatus = RootFatalErrored; 22545 workInProgressRootFatalError = thrownValue; // Set `workInProgress` to null. This represents advancing to the next 22546 // sibling, or the parent if there are no siblings. But since the root 22547 // has no siblings nor a parent, we set it to null. Usually this is 22548 // handled by `completeUnitOfWork` or `unwindWork`, but since we're 22549 // intentionally not calling those, we need set it here. 22550 // TODO: Consider calling `unwindWork` to pop the contexts. 22551 22552 workInProgress = null; 22553 return; 22554 } 22555 22556 if (enableProfilerTimer && erroredWork.mode & ProfileMode) { 22557 // Record the time spent rendering before an error was thrown. This 22558 // avoids inaccurate Profiler durations in the case of a 22559 // suspended render. 22560 stopProfilerTimerIfRunningAndRecordDelta(erroredWork, true); 22561 } 22562 22563 throwException(root, erroredWork.return, erroredWork, thrownValue, workInProgressRootRenderLanes); 22564 completeUnitOfWork(erroredWork); 22565 } catch (yetAnotherThrownValue) { 22566 // Something in the return path also threw. 22567 thrownValue = yetAnotherThrownValue; 22568 22569 if (workInProgress === erroredWork && erroredWork !== null) { 22570 // If this boundary has already errored, then we had trouble processing 22571 // the error. Bubble it to the next boundary. 22572 erroredWork = erroredWork.return; 22573 workInProgress = erroredWork; 22574 } else { 22575 erroredWork = workInProgress; 22576 } 22577 22578 continue; 22579 } // Return to the normal work loop. 22580 22581 22582 return; 22583 } while (true); 22584} 22585 22586function pushDispatcher() { 22587 var prevDispatcher = ReactCurrentDispatcher$2.current; 22588 ReactCurrentDispatcher$2.current = ContextOnlyDispatcher; 22589 22590 if (prevDispatcher === null) { 22591 // The React isomorphic package does not include a default dispatcher. 22592 // Instead the first renderer will lazily attach one, in order to give 22593 // nicer error messages. 22594 return ContextOnlyDispatcher; 22595 } else { 22596 return prevDispatcher; 22597 } 22598} 22599 22600function popDispatcher(prevDispatcher) { 22601 ReactCurrentDispatcher$2.current = prevDispatcher; 22602} 22603 22604function pushInteractions(root) { 22605 { 22606 var prevInteractions = tracing.__interactionsRef.current; 22607 tracing.__interactionsRef.current = root.memoizedInteractions; 22608 return prevInteractions; 22609 } 22610} 22611 22612function popInteractions(prevInteractions) { 22613 { 22614 tracing.__interactionsRef.current = prevInteractions; 22615 } 22616} 22617 22618function markCommitTimeOfFallback() { 22619 globalMostRecentFallbackTime = now(); 22620} 22621function markSkippedUpdateLanes(lane) { 22622 workInProgressRootSkippedLanes = mergeLanes(lane, workInProgressRootSkippedLanes); 22623} 22624function renderDidSuspend() { 22625 if (workInProgressRootExitStatus === RootIncomplete) { 22626 workInProgressRootExitStatus = RootSuspended; 22627 } 22628} 22629function renderDidSuspendDelayIfPossible() { 22630 if (workInProgressRootExitStatus === RootIncomplete || workInProgressRootExitStatus === RootSuspended) { 22631 workInProgressRootExitStatus = RootSuspendedWithDelay; 22632 } // Check if there are updates that we skipped tree that might have unblocked 22633 // this render. 22634 22635 22636 if (workInProgressRoot !== null && (includesNonIdleWork(workInProgressRootSkippedLanes) || includesNonIdleWork(workInProgressRootUpdatedLanes))) { 22637 // Mark the current render as suspended so that we switch to working on 22638 // the updates that were skipped. Usually we only suspend at the end of 22639 // the render phase. 22640 // TODO: We should probably always mark the root as suspended immediately 22641 // (inside this function), since by suspending at the end of the render 22642 // phase introduces a potential mistake where we suspend lanes that were 22643 // pinged or updated while we were rendering. 22644 markRootSuspended$1(workInProgressRoot, workInProgressRootRenderLanes); 22645 } 22646} 22647function renderDidError() { 22648 if (workInProgressRootExitStatus !== RootCompleted) { 22649 workInProgressRootExitStatus = RootErrored; 22650 } 22651} // Called during render to determine if anything has suspended. 22652// Returns false if we're not sure. 22653 22654function renderHasNotSuspendedYet() { 22655 // If something errored or completed, we can't really be sure, 22656 // so those are false. 22657 return workInProgressRootExitStatus === RootIncomplete; 22658} 22659 22660function renderRootSync(root, lanes) { 22661 var prevExecutionContext = executionContext; 22662 executionContext |= RenderContext; 22663 var prevDispatcher = pushDispatcher(); // If the root or lanes have changed, throw out the existing stack 22664 // and prepare a fresh one. Otherwise we'll continue where we left off. 22665 22666 if (workInProgressRoot !== root || workInProgressRootRenderLanes !== lanes) { 22667 prepareFreshStack(root, lanes); 22668 startWorkOnPendingInteractions(root, lanes); 22669 } 22670 22671 var prevInteractions = pushInteractions(root); 22672 22673 do { 22674 try { 22675 workLoopSync(); 22676 break; 22677 } catch (thrownValue) { 22678 handleError(root, thrownValue); 22679 } 22680 } while (true); 22681 22682 resetContextDependencies(); 22683 22684 { 22685 popInteractions(prevInteractions); 22686 } 22687 22688 executionContext = prevExecutionContext; 22689 popDispatcher(prevDispatcher); 22690 22691 if (workInProgress !== null) { 22692 // This is a sync render, so we should have finished the whole tree. 22693 { 22694 { 22695 throw Error( "Cannot commit an incomplete root. This error is likely caused by a bug in React. Please file an issue." ); 22696 } 22697 } 22698 } 22699 22700 22701 workInProgressRoot = null; 22702 workInProgressRootRenderLanes = NoLanes; 22703 return workInProgressRootExitStatus; 22704} // The work loop is an extremely hot path. Tell Closure not to inline it. 22705 22706/** @noinline */ 22707 22708 22709function workLoopSync() { 22710 // Already timed out, so perform work without checking if we need to yield. 22711 while (workInProgress !== null) { 22712 performUnitOfWork(workInProgress); 22713 } 22714} 22715 22716function renderRootConcurrent(root, lanes) { 22717 var prevExecutionContext = executionContext; 22718 executionContext |= RenderContext; 22719 var prevDispatcher = pushDispatcher(); // If the root or lanes have changed, throw out the existing stack 22720 // and prepare a fresh one. Otherwise we'll continue where we left off. 22721 22722 if (workInProgressRoot !== root || workInProgressRootRenderLanes !== lanes) { 22723 resetRenderTimer(); 22724 prepareFreshStack(root, lanes); 22725 startWorkOnPendingInteractions(root, lanes); 22726 } 22727 22728 var prevInteractions = pushInteractions(root); 22729 22730 do { 22731 try { 22732 workLoopConcurrent(); 22733 break; 22734 } catch (thrownValue) { 22735 handleError(root, thrownValue); 22736 } 22737 } while (true); 22738 22739 resetContextDependencies(); 22740 22741 { 22742 popInteractions(prevInteractions); 22743 } 22744 22745 popDispatcher(prevDispatcher); 22746 executionContext = prevExecutionContext; 22747 22748 22749 if (workInProgress !== null) { 22750 22751 return RootIncomplete; 22752 } else { 22753 22754 22755 workInProgressRoot = null; 22756 workInProgressRootRenderLanes = NoLanes; // Return the final exit status. 22757 22758 return workInProgressRootExitStatus; 22759 } 22760} 22761/** @noinline */ 22762 22763 22764function workLoopConcurrent() { 22765 // Perform work until Scheduler asks us to yield 22766 while (workInProgress !== null && !shouldYield()) { 22767 performUnitOfWork(workInProgress); 22768 } 22769} 22770 22771function performUnitOfWork(unitOfWork) { 22772 // The current, flushed, state of this fiber is the alternate. Ideally 22773 // nothing should rely on this, but relying on it here means that we don't 22774 // need an additional field on the work in progress. 22775 var current = unitOfWork.alternate; 22776 setCurrentFiber(unitOfWork); 22777 var next; 22778 22779 if ( (unitOfWork.mode & ProfileMode) !== NoMode) { 22780 startProfilerTimer(unitOfWork); 22781 next = beginWork$1(current, unitOfWork, subtreeRenderLanes); 22782 stopProfilerTimerIfRunningAndRecordDelta(unitOfWork, true); 22783 } else { 22784 next = beginWork$1(current, unitOfWork, subtreeRenderLanes); 22785 } 22786 22787 resetCurrentFiber(); 22788 unitOfWork.memoizedProps = unitOfWork.pendingProps; 22789 22790 if (next === null) { 22791 // If this doesn't spawn new work, complete the current work. 22792 completeUnitOfWork(unitOfWork); 22793 } else { 22794 workInProgress = next; 22795 } 22796 22797 ReactCurrentOwner$2.current = null; 22798} 22799 22800function completeUnitOfWork(unitOfWork) { 22801 // Attempt to complete the current unit of work, then move to the next 22802 // sibling. If there are no more siblings, return to the parent fiber. 22803 var completedWork = unitOfWork; 22804 22805 do { 22806 // The current, flushed, state of this fiber is the alternate. Ideally 22807 // nothing should rely on this, but relying on it here means that we don't 22808 // need an additional field on the work in progress. 22809 var current = completedWork.alternate; 22810 var returnFiber = completedWork.return; // Check if the work completed or if something threw. 22811 22812 if ((completedWork.flags & Incomplete) === NoFlags) { 22813 setCurrentFiber(completedWork); 22814 var next = void 0; 22815 22816 if ( (completedWork.mode & ProfileMode) === NoMode) { 22817 next = completeWork(current, completedWork, subtreeRenderLanes); 22818 } else { 22819 startProfilerTimer(completedWork); 22820 next = completeWork(current, completedWork, subtreeRenderLanes); // Update render duration assuming we didn't error. 22821 22822 stopProfilerTimerIfRunningAndRecordDelta(completedWork, false); 22823 } 22824 22825 resetCurrentFiber(); 22826 22827 if (next !== null) { 22828 // Completing this fiber spawned new work. Work on that next. 22829 workInProgress = next; 22830 return; 22831 } 22832 22833 resetChildLanes(completedWork); 22834 22835 if (returnFiber !== null && // Do not append effects to parents if a sibling failed to complete 22836 (returnFiber.flags & Incomplete) === NoFlags) { 22837 // Append all the effects of the subtree and this fiber onto the effect 22838 // list of the parent. The completion order of the children affects the 22839 // side-effect order. 22840 if (returnFiber.firstEffect === null) { 22841 returnFiber.firstEffect = completedWork.firstEffect; 22842 } 22843 22844 if (completedWork.lastEffect !== null) { 22845 if (returnFiber.lastEffect !== null) { 22846 returnFiber.lastEffect.nextEffect = completedWork.firstEffect; 22847 } 22848 22849 returnFiber.lastEffect = completedWork.lastEffect; 22850 } // If this fiber had side-effects, we append it AFTER the children's 22851 // side-effects. We can perform certain side-effects earlier if needed, 22852 // by doing multiple passes over the effect list. We don't want to 22853 // schedule our own side-effect on our own list because if end up 22854 // reusing children we'll schedule this effect onto itself since we're 22855 // at the end. 22856 22857 22858 var flags = completedWork.flags; // Skip both NoWork and PerformedWork tags when creating the effect 22859 // list. PerformedWork effect is read by React DevTools but shouldn't be 22860 // committed. 22861 22862 if (flags > PerformedWork) { 22863 if (returnFiber.lastEffect !== null) { 22864 returnFiber.lastEffect.nextEffect = completedWork; 22865 } else { 22866 returnFiber.firstEffect = completedWork; 22867 } 22868 22869 returnFiber.lastEffect = completedWork; 22870 } 22871 } 22872 } else { 22873 // This fiber did not complete because something threw. Pop values off 22874 // the stack without entering the complete phase. If this is a boundary, 22875 // capture values if possible. 22876 var _next = unwindWork(completedWork); // Because this fiber did not complete, don't reset its expiration time. 22877 22878 22879 if (_next !== null) { 22880 // If completing this work spawned new work, do that next. We'll come 22881 // back here again. 22882 // Since we're restarting, remove anything that is not a host effect 22883 // from the effect tag. 22884 _next.flags &= HostEffectMask; 22885 workInProgress = _next; 22886 return; 22887 } 22888 22889 if ( (completedWork.mode & ProfileMode) !== NoMode) { 22890 // Record the render duration for the fiber that errored. 22891 stopProfilerTimerIfRunningAndRecordDelta(completedWork, false); // Include the time spent working on failed children before continuing. 22892 22893 var actualDuration = completedWork.actualDuration; 22894 var child = completedWork.child; 22895 22896 while (child !== null) { 22897 actualDuration += child.actualDuration; 22898 child = child.sibling; 22899 } 22900 22901 completedWork.actualDuration = actualDuration; 22902 } 22903 22904 if (returnFiber !== null) { 22905 // Mark the parent fiber as incomplete and clear its effect list. 22906 returnFiber.firstEffect = returnFiber.lastEffect = null; 22907 returnFiber.flags |= Incomplete; 22908 } 22909 } 22910 22911 var siblingFiber = completedWork.sibling; 22912 22913 if (siblingFiber !== null) { 22914 // If there is more work to do in this returnFiber, do that next. 22915 workInProgress = siblingFiber; 22916 return; 22917 } // Otherwise, return to the parent 22918 22919 22920 completedWork = returnFiber; // Update the next thing we're working on in case something throws. 22921 22922 workInProgress = completedWork; 22923 } while (completedWork !== null); // We've reached the root. 22924 22925 22926 if (workInProgressRootExitStatus === RootIncomplete) { 22927 workInProgressRootExitStatus = RootCompleted; 22928 } 22929} 22930 22931function resetChildLanes(completedWork) { 22932 if ( // TODO: Move this check out of the hot path by moving `resetChildLanes` 22933 // to switch statement in `completeWork`. 22934 (completedWork.tag === LegacyHiddenComponent || completedWork.tag === OffscreenComponent) && completedWork.memoizedState !== null && !includesSomeLane(subtreeRenderLanes, OffscreenLane) && (completedWork.mode & ConcurrentMode) !== NoLanes) { 22935 // The children of this component are hidden. Don't bubble their 22936 // expiration times. 22937 return; 22938 } 22939 22940 var newChildLanes = NoLanes; // Bubble up the earliest expiration time. 22941 22942 if ( (completedWork.mode & ProfileMode) !== NoMode) { 22943 // In profiling mode, resetChildExpirationTime is also used to reset 22944 // profiler durations. 22945 var actualDuration = completedWork.actualDuration; 22946 var treeBaseDuration = completedWork.selfBaseDuration; // When a fiber is cloned, its actualDuration is reset to 0. This value will 22947 // only be updated if work is done on the fiber (i.e. it doesn't bailout). 22948 // When work is done, it should bubble to the parent's actualDuration. If 22949 // the fiber has not been cloned though, (meaning no work was done), then 22950 // this value will reflect the amount of time spent working on a previous 22951 // render. In that case it should not bubble. We determine whether it was 22952 // cloned by comparing the child pointer. 22953 22954 var shouldBubbleActualDurations = completedWork.alternate === null || completedWork.child !== completedWork.alternate.child; 22955 var child = completedWork.child; 22956 22957 while (child !== null) { 22958 newChildLanes = mergeLanes(newChildLanes, mergeLanes(child.lanes, child.childLanes)); 22959 22960 if (shouldBubbleActualDurations) { 22961 actualDuration += child.actualDuration; 22962 } 22963 22964 treeBaseDuration += child.treeBaseDuration; 22965 child = child.sibling; 22966 } 22967 22968 var isTimedOutSuspense = completedWork.tag === SuspenseComponent && completedWork.memoizedState !== null; 22969 22970 if (isTimedOutSuspense) { 22971 // Don't count time spent in a timed out Suspense subtree as part of the base duration. 22972 var primaryChildFragment = completedWork.child; 22973 22974 if (primaryChildFragment !== null) { 22975 treeBaseDuration -= primaryChildFragment.treeBaseDuration; 22976 } 22977 } 22978 22979 completedWork.actualDuration = actualDuration; 22980 completedWork.treeBaseDuration = treeBaseDuration; 22981 } else { 22982 var _child = completedWork.child; 22983 22984 while (_child !== null) { 22985 newChildLanes = mergeLanes(newChildLanes, mergeLanes(_child.lanes, _child.childLanes)); 22986 _child = _child.sibling; 22987 } 22988 } 22989 22990 completedWork.childLanes = newChildLanes; 22991} 22992 22993function commitRoot(root) { 22994 var renderPriorityLevel = getCurrentPriorityLevel(); 22995 runWithPriority$1(ImmediatePriority$1, commitRootImpl.bind(null, root, renderPriorityLevel)); 22996 return null; 22997} 22998 22999function commitRootImpl(root, renderPriorityLevel) { 23000 do { 23001 // `flushPassiveEffects` will call `flushSyncUpdateQueue` at the end, which 23002 // means `flushPassiveEffects` will sometimes result in additional 23003 // passive effects. So we need to keep flushing in a loop until there are 23004 // no more pending effects. 23005 // TODO: Might be better if `flushPassiveEffects` did not automatically 23006 // flush synchronous work at the end, to avoid factoring hazards like this. 23007 flushPassiveEffects(); 23008 } while (rootWithPendingPassiveEffects !== null); 23009 23010 flushRenderPhaseStrictModeWarningsInDEV(); 23011 23012 if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) { 23013 { 23014 throw Error( "Should not already be working." ); 23015 } 23016 } 23017 23018 var finishedWork = root.finishedWork; 23019 var lanes = root.finishedLanes; 23020 23021 if (finishedWork === null) { 23022 23023 return null; 23024 } 23025 23026 root.finishedWork = null; 23027 root.finishedLanes = NoLanes; 23028 23029 if (!(finishedWork !== root.current)) { 23030 { 23031 throw Error( "Cannot commit the same tree as before. This error is likely caused by a bug in React. Please file an issue." ); 23032 } 23033 } // commitRoot never returns a continuation; it always finishes synchronously. 23034 // So we can clear these now to allow a new callback to be scheduled. 23035 23036 23037 root.callbackNode = null; // Update the first and last pending times on this root. The new first 23038 // pending time is whatever is left on the root fiber. 23039 23040 var remainingLanes = mergeLanes(finishedWork.lanes, finishedWork.childLanes); 23041 markRootFinished(root, remainingLanes); // Clear already finished discrete updates in case that a later call of 23042 // `flushDiscreteUpdates` starts a useless render pass which may cancels 23043 // a scheduled timeout. 23044 23045 if (rootsWithPendingDiscreteUpdates !== null) { 23046 if (!hasDiscreteLanes(remainingLanes) && rootsWithPendingDiscreteUpdates.has(root)) { 23047 rootsWithPendingDiscreteUpdates.delete(root); 23048 } 23049 } 23050 23051 if (root === workInProgressRoot) { 23052 // We can reset these now that they are finished. 23053 workInProgressRoot = null; 23054 workInProgress = null; 23055 workInProgressRootRenderLanes = NoLanes; 23056 } // Get the list of effects. 23057 23058 23059 var firstEffect; 23060 23061 if (finishedWork.flags > PerformedWork) { 23062 // A fiber's effect list consists only of its children, not itself. So if 23063 // the root has an effect, we need to add it to the end of the list. The 23064 // resulting list is the set that would belong to the root's parent, if it 23065 // had one; that is, all the effects in the tree including the root. 23066 if (finishedWork.lastEffect !== null) { 23067 finishedWork.lastEffect.nextEffect = finishedWork; 23068 firstEffect = finishedWork.firstEffect; 23069 } else { 23070 firstEffect = finishedWork; 23071 } 23072 } else { 23073 // There is no effect on the root. 23074 firstEffect = finishedWork.firstEffect; 23075 } 23076 23077 if (firstEffect !== null) { 23078 23079 var prevExecutionContext = executionContext; 23080 executionContext |= CommitContext; 23081 var prevInteractions = pushInteractions(root); // Reset this to null before calling lifecycles 23082 23083 ReactCurrentOwner$2.current = null; // The commit phase is broken into several sub-phases. We do a separate pass 23084 // of the effect list for each phase: all mutation effects come before all 23085 // layout effects, and so on. 23086 // The first phase a "before mutation" phase. We use this phase to read the 23087 // state of the host tree right before we mutate it. This is where 23088 // getSnapshotBeforeUpdate is called. 23089 23090 focusedInstanceHandle = prepareForCommit(root.containerInfo); 23091 shouldFireAfterActiveInstanceBlur = false; 23092 nextEffect = firstEffect; 23093 23094 do { 23095 { 23096 invokeGuardedCallback(null, commitBeforeMutationEffects, null); 23097 23098 if (hasCaughtError()) { 23099 if (!(nextEffect !== null)) { 23100 { 23101 throw Error( "Should be working on an effect." ); 23102 } 23103 } 23104 23105 var error = clearCaughtError(); 23106 captureCommitPhaseError(nextEffect, error); 23107 nextEffect = nextEffect.nextEffect; 23108 } 23109 } 23110 } while (nextEffect !== null); // We no longer need to track the active instance fiber 23111 23112 23113 focusedInstanceHandle = null; 23114 23115 { 23116 // Mark the current commit time to be shared by all Profilers in this 23117 // batch. This enables them to be grouped later. 23118 recordCommitTime(); 23119 } // The next phase is the mutation phase, where we mutate the host tree. 23120 23121 23122 nextEffect = firstEffect; 23123 23124 do { 23125 { 23126 invokeGuardedCallback(null, commitMutationEffects, null, root, renderPriorityLevel); 23127 23128 if (hasCaughtError()) { 23129 if (!(nextEffect !== null)) { 23130 { 23131 throw Error( "Should be working on an effect." ); 23132 } 23133 } 23134 23135 var _error = clearCaughtError(); 23136 23137 captureCommitPhaseError(nextEffect, _error); 23138 nextEffect = nextEffect.nextEffect; 23139 } 23140 } 23141 } while (nextEffect !== null); 23142 23143 resetAfterCommit(root.containerInfo); // The work-in-progress tree is now the current tree. This must come after 23144 // the mutation phase, so that the previous tree is still current during 23145 // componentWillUnmount, but before the layout phase, so that the finished 23146 // work is current during componentDidMount/Update. 23147 23148 root.current = finishedWork; // The next phase is the layout phase, where we call effects that read 23149 // the host tree after it's been mutated. The idiomatic use case for this is 23150 // layout, but class component lifecycles also fire here for legacy reasons. 23151 23152 nextEffect = firstEffect; 23153 23154 do { 23155 { 23156 invokeGuardedCallback(null, commitLayoutEffects, null, root, lanes); 23157 23158 if (hasCaughtError()) { 23159 if (!(nextEffect !== null)) { 23160 { 23161 throw Error( "Should be working on an effect." ); 23162 } 23163 } 23164 23165 var _error2 = clearCaughtError(); 23166 23167 captureCommitPhaseError(nextEffect, _error2); 23168 nextEffect = nextEffect.nextEffect; 23169 } 23170 } 23171 } while (nextEffect !== null); 23172 23173 nextEffect = null; // Tell Scheduler to yield at the end of the frame, so the browser has an 23174 // opportunity to paint. 23175 23176 requestPaint(); 23177 23178 { 23179 popInteractions(prevInteractions); 23180 } 23181 23182 executionContext = prevExecutionContext; 23183 } else { 23184 // No effects. 23185 root.current = finishedWork; // Measure these anyway so the flamegraph explicitly shows that there were 23186 // no effects. 23187 // TODO: Maybe there's a better way to report this. 23188 23189 { 23190 recordCommitTime(); 23191 } 23192 } 23193 23194 var rootDidHavePassiveEffects = rootDoesHavePassiveEffects; 23195 23196 if (rootDoesHavePassiveEffects) { 23197 // This commit has passive effects. Stash a reference to them. But don't 23198 // schedule a callback until after flushing layout work. 23199 rootDoesHavePassiveEffects = false; 23200 rootWithPendingPassiveEffects = root; 23201 pendingPassiveEffectsLanes = lanes; 23202 pendingPassiveEffectsRenderPriority = renderPriorityLevel; 23203 } else { 23204 // We are done with the effect chain at this point so let's clear the 23205 // nextEffect pointers to assist with GC. If we have passive effects, we'll 23206 // clear this in flushPassiveEffects. 23207 nextEffect = firstEffect; 23208 23209 while (nextEffect !== null) { 23210 var nextNextEffect = nextEffect.nextEffect; 23211 nextEffect.nextEffect = null; 23212 23213 if (nextEffect.flags & Deletion) { 23214 detachFiberAfterEffects(nextEffect); 23215 } 23216 23217 nextEffect = nextNextEffect; 23218 } 23219 } // Read this again, since an effect might have updated it 23220 23221 23222 remainingLanes = root.pendingLanes; // Check if there's remaining work on this root 23223 23224 if (remainingLanes !== NoLanes) { 23225 { 23226 if (spawnedWorkDuringRender !== null) { 23227 var expirationTimes = spawnedWorkDuringRender; 23228 spawnedWorkDuringRender = null; 23229 23230 for (var i = 0; i < expirationTimes.length; i++) { 23231 scheduleInteractions(root, expirationTimes[i], root.memoizedInteractions); 23232 } 23233 } 23234 23235 schedulePendingInteractions(root, remainingLanes); 23236 } 23237 } else { 23238 // If there's no remaining work, we can clear the set of already failed 23239 // error boundaries. 23240 legacyErrorBoundariesThatAlreadyFailed = null; 23241 } 23242 23243 { 23244 if (!rootDidHavePassiveEffects) { 23245 // If there are no passive effects, then we can complete the pending interactions. 23246 // Otherwise, we'll wait until after the passive effects are flushed. 23247 // Wait to do this until after remaining work has been scheduled, 23248 // so that we don't prematurely signal complete for interactions when there's e.g. hidden work. 23249 finishPendingInteractions(root, lanes); 23250 } 23251 } 23252 23253 if (remainingLanes === SyncLane) { 23254 // Count the number of times the root synchronously re-renders without 23255 // finishing. If there are too many, it indicates an infinite update loop. 23256 if (root === rootWithNestedUpdates) { 23257 nestedUpdateCount++; 23258 } else { 23259 nestedUpdateCount = 0; 23260 rootWithNestedUpdates = root; 23261 } 23262 } else { 23263 nestedUpdateCount = 0; 23264 } 23265 23266 onCommitRoot(finishedWork.stateNode, renderPriorityLevel); 23267 23268 { 23269 onCommitRoot$1(); 23270 } // Always call this before exiting `commitRoot`, to ensure that any 23271 // additional work on this root is scheduled. 23272 23273 23274 ensureRootIsScheduled(root, now()); 23275 23276 if (hasUncaughtError) { 23277 hasUncaughtError = false; 23278 var _error3 = firstUncaughtError; 23279 firstUncaughtError = null; 23280 throw _error3; 23281 } 23282 23283 if ((executionContext & LegacyUnbatchedContext) !== NoContext) { 23284 // a ReactDOM.render-ed root inside of batchedUpdates. The commit fired 23285 // synchronously, but layout updates should be deferred until the end 23286 // of the batch. 23287 23288 23289 return null; 23290 } // If layout work was scheduled, flush it now. 23291 23292 23293 flushSyncCallbackQueue(); 23294 23295 return null; 23296} 23297 23298function commitBeforeMutationEffects() { 23299 while (nextEffect !== null) { 23300 var current = nextEffect.alternate; 23301 23302 if (!shouldFireAfterActiveInstanceBlur && focusedInstanceHandle !== null) { 23303 if ((nextEffect.flags & Deletion) !== NoFlags) { 23304 if (doesFiberContain(nextEffect, focusedInstanceHandle)) { 23305 shouldFireAfterActiveInstanceBlur = true; 23306 } 23307 } else { 23308 // TODO: Move this out of the hot path using a dedicated effect tag. 23309 if (nextEffect.tag === SuspenseComponent && isSuspenseBoundaryBeingHidden(current, nextEffect) && doesFiberContain(nextEffect, focusedInstanceHandle)) { 23310 shouldFireAfterActiveInstanceBlur = true; 23311 } 23312 } 23313 } 23314 23315 var flags = nextEffect.flags; 23316 23317 if ((flags & Snapshot) !== NoFlags) { 23318 setCurrentFiber(nextEffect); 23319 commitBeforeMutationLifeCycles(current, nextEffect); 23320 resetCurrentFiber(); 23321 } 23322 23323 if ((flags & Passive) !== NoFlags) { 23324 // If there are passive effects, schedule a callback to flush at 23325 // the earliest opportunity. 23326 if (!rootDoesHavePassiveEffects) { 23327 rootDoesHavePassiveEffects = true; 23328 scheduleCallback(NormalPriority$1, function () { 23329 flushPassiveEffects(); 23330 return null; 23331 }); 23332 } 23333 } 23334 23335 nextEffect = nextEffect.nextEffect; 23336 } 23337} 23338 23339function commitMutationEffects(root, renderPriorityLevel) { 23340 // TODO: Should probably move the bulk of this function to commitWork. 23341 while (nextEffect !== null) { 23342 setCurrentFiber(nextEffect); 23343 var flags = nextEffect.flags; 23344 23345 if (flags & ContentReset) { 23346 commitResetTextContent(nextEffect); 23347 } 23348 23349 if (flags & Ref) { 23350 var current = nextEffect.alternate; 23351 23352 if (current !== null) { 23353 commitDetachRef(current); 23354 } 23355 } // The following switch statement is only concerned about placement, 23356 // updates, and deletions. To avoid needing to add a case for every possible 23357 // bitmap value, we remove the secondary effects from the effect tag and 23358 // switch on that value. 23359 23360 23361 var primaryFlags = flags & (Placement | Update | Deletion | Hydrating); 23362 23363 switch (primaryFlags) { 23364 case Placement: 23365 { 23366 commitPlacement(nextEffect); // Clear the "placement" from effect tag so that we know that this is 23367 // inserted, before any life-cycles like componentDidMount gets called. 23368 // TODO: findDOMNode doesn't rely on this any more but isMounted does 23369 // and isMounted is deprecated anyway so we should be able to kill this. 23370 23371 nextEffect.flags &= ~Placement; 23372 break; 23373 } 23374 23375 case PlacementAndUpdate: 23376 { 23377 // Placement 23378 commitPlacement(nextEffect); // Clear the "placement" from effect tag so that we know that this is 23379 // inserted, before any life-cycles like componentDidMount gets called. 23380 23381 nextEffect.flags &= ~Placement; // Update 23382 23383 var _current = nextEffect.alternate; 23384 commitWork(_current, nextEffect); 23385 break; 23386 } 23387 23388 case Hydrating: 23389 { 23390 nextEffect.flags &= ~Hydrating; 23391 break; 23392 } 23393 23394 case HydratingAndUpdate: 23395 { 23396 nextEffect.flags &= ~Hydrating; // Update 23397 23398 var _current2 = nextEffect.alternate; 23399 commitWork(_current2, nextEffect); 23400 break; 23401 } 23402 23403 case Update: 23404 { 23405 var _current3 = nextEffect.alternate; 23406 commitWork(_current3, nextEffect); 23407 break; 23408 } 23409 23410 case Deletion: 23411 { 23412 commitDeletion(root, nextEffect); 23413 break; 23414 } 23415 } 23416 23417 resetCurrentFiber(); 23418 nextEffect = nextEffect.nextEffect; 23419 } 23420} 23421 23422function commitLayoutEffects(root, committedLanes) { 23423 23424 23425 while (nextEffect !== null) { 23426 setCurrentFiber(nextEffect); 23427 var flags = nextEffect.flags; 23428 23429 if (flags & (Update | Callback)) { 23430 var current = nextEffect.alternate; 23431 commitLifeCycles(root, current, nextEffect); 23432 } 23433 23434 { 23435 if (flags & Ref) { 23436 commitAttachRef(nextEffect); 23437 } 23438 } 23439 23440 resetCurrentFiber(); 23441 nextEffect = nextEffect.nextEffect; 23442 } 23443} 23444 23445function flushPassiveEffects() { 23446 // Returns whether passive effects were flushed. 23447 if (pendingPassiveEffectsRenderPriority !== NoPriority$1) { 23448 var priorityLevel = pendingPassiveEffectsRenderPriority > NormalPriority$1 ? NormalPriority$1 : pendingPassiveEffectsRenderPriority; 23449 pendingPassiveEffectsRenderPriority = NoPriority$1; 23450 23451 { 23452 return runWithPriority$1(priorityLevel, flushPassiveEffectsImpl); 23453 } 23454 } 23455 23456 return false; 23457} 23458function enqueuePendingPassiveHookEffectMount(fiber, effect) { 23459 pendingPassiveHookEffectsMount.push(effect, fiber); 23460 23461 if (!rootDoesHavePassiveEffects) { 23462 rootDoesHavePassiveEffects = true; 23463 scheduleCallback(NormalPriority$1, function () { 23464 flushPassiveEffects(); 23465 return null; 23466 }); 23467 } 23468} 23469function enqueuePendingPassiveHookEffectUnmount(fiber, effect) { 23470 pendingPassiveHookEffectsUnmount.push(effect, fiber); 23471 23472 { 23473 fiber.flags |= PassiveUnmountPendingDev; 23474 var alternate = fiber.alternate; 23475 23476 if (alternate !== null) { 23477 alternate.flags |= PassiveUnmountPendingDev; 23478 } 23479 } 23480 23481 if (!rootDoesHavePassiveEffects) { 23482 rootDoesHavePassiveEffects = true; 23483 scheduleCallback(NormalPriority$1, function () { 23484 flushPassiveEffects(); 23485 return null; 23486 }); 23487 } 23488} 23489 23490function invokePassiveEffectCreate(effect) { 23491 var create = effect.create; 23492 effect.destroy = create(); 23493} 23494 23495function flushPassiveEffectsImpl() { 23496 if (rootWithPendingPassiveEffects === null) { 23497 return false; 23498 } 23499 23500 var root = rootWithPendingPassiveEffects; 23501 var lanes = pendingPassiveEffectsLanes; 23502 rootWithPendingPassiveEffects = null; 23503 pendingPassiveEffectsLanes = NoLanes; 23504 23505 if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) { 23506 { 23507 throw Error( "Cannot flush passive effects while already rendering." ); 23508 } 23509 } 23510 23511 { 23512 isFlushingPassiveEffects = true; 23513 } 23514 23515 var prevExecutionContext = executionContext; 23516 executionContext |= CommitContext; 23517 var prevInteractions = pushInteractions(root); // It's important that ALL pending passive effect destroy functions are called 23518 // before ANY passive effect create functions are called. 23519 // Otherwise effects in sibling components might interfere with each other. 23520 // e.g. a destroy function in one component may unintentionally override a ref 23521 // value set by a create function in another component. 23522 // Layout effects have the same constraint. 23523 // First pass: Destroy stale passive effects. 23524 23525 var unmountEffects = pendingPassiveHookEffectsUnmount; 23526 pendingPassiveHookEffectsUnmount = []; 23527 23528 for (var i = 0; i < unmountEffects.length; i += 2) { 23529 var _effect = unmountEffects[i]; 23530 var fiber = unmountEffects[i + 1]; 23531 var destroy = _effect.destroy; 23532 _effect.destroy = undefined; 23533 23534 { 23535 fiber.flags &= ~PassiveUnmountPendingDev; 23536 var alternate = fiber.alternate; 23537 23538 if (alternate !== null) { 23539 alternate.flags &= ~PassiveUnmountPendingDev; 23540 } 23541 } 23542 23543 if (typeof destroy === 'function') { 23544 { 23545 setCurrentFiber(fiber); 23546 23547 { 23548 invokeGuardedCallback(null, destroy, null); 23549 } 23550 23551 if (hasCaughtError()) { 23552 if (!(fiber !== null)) { 23553 { 23554 throw Error( "Should be working on an effect." ); 23555 } 23556 } 23557 23558 var error = clearCaughtError(); 23559 captureCommitPhaseError(fiber, error); 23560 } 23561 23562 resetCurrentFiber(); 23563 } 23564 } 23565 } // Second pass: Create new passive effects. 23566 23567 23568 var mountEffects = pendingPassiveHookEffectsMount; 23569 pendingPassiveHookEffectsMount = []; 23570 23571 for (var _i = 0; _i < mountEffects.length; _i += 2) { 23572 var _effect2 = mountEffects[_i]; 23573 var _fiber = mountEffects[_i + 1]; 23574 23575 { 23576 setCurrentFiber(_fiber); 23577 23578 { 23579 invokeGuardedCallback(null, invokePassiveEffectCreate, null, _effect2); 23580 } 23581 23582 if (hasCaughtError()) { 23583 if (!(_fiber !== null)) { 23584 { 23585 throw Error( "Should be working on an effect." ); 23586 } 23587 } 23588 23589 var _error4 = clearCaughtError(); 23590 23591 captureCommitPhaseError(_fiber, _error4); 23592 } 23593 23594 resetCurrentFiber(); 23595 } 23596 } // Note: This currently assumes there are no passive effects on the root fiber 23597 // because the root is not part of its own effect list. 23598 // This could change in the future. 23599 23600 23601 var effect = root.current.firstEffect; 23602 23603 while (effect !== null) { 23604 var nextNextEffect = effect.nextEffect; // Remove nextEffect pointer to assist GC 23605 23606 effect.nextEffect = null; 23607 23608 if (effect.flags & Deletion) { 23609 detachFiberAfterEffects(effect); 23610 } 23611 23612 effect = nextNextEffect; 23613 } 23614 23615 { 23616 popInteractions(prevInteractions); 23617 finishPendingInteractions(root, lanes); 23618 } 23619 23620 { 23621 isFlushingPassiveEffects = false; 23622 } 23623 23624 executionContext = prevExecutionContext; 23625 flushSyncCallbackQueue(); // If additional passive effects were scheduled, increment a counter. If this 23626 // exceeds the limit, we'll fire a warning. 23627 23628 nestedPassiveUpdateCount = rootWithPendingPassiveEffects === null ? 0 : nestedPassiveUpdateCount + 1; 23629 return true; 23630} 23631 23632function isAlreadyFailedLegacyErrorBoundary(instance) { 23633 return legacyErrorBoundariesThatAlreadyFailed !== null && legacyErrorBoundariesThatAlreadyFailed.has(instance); 23634} 23635function markLegacyErrorBoundaryAsFailed(instance) { 23636 if (legacyErrorBoundariesThatAlreadyFailed === null) { 23637 legacyErrorBoundariesThatAlreadyFailed = new Set([instance]); 23638 } else { 23639 legacyErrorBoundariesThatAlreadyFailed.add(instance); 23640 } 23641} 23642 23643function prepareToThrowUncaughtError(error) { 23644 if (!hasUncaughtError) { 23645 hasUncaughtError = true; 23646 firstUncaughtError = error; 23647 } 23648} 23649 23650var onUncaughtError = prepareToThrowUncaughtError; 23651 23652function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error) { 23653 var errorInfo = createCapturedValue(error, sourceFiber); 23654 var update = createRootErrorUpdate(rootFiber, errorInfo, SyncLane); 23655 enqueueUpdate(rootFiber, update); 23656 var eventTime = requestEventTime(); 23657 var root = markUpdateLaneFromFiberToRoot(rootFiber, SyncLane); 23658 23659 if (root !== null) { 23660 markRootUpdated(root, SyncLane, eventTime); 23661 ensureRootIsScheduled(root, eventTime); 23662 schedulePendingInteractions(root, SyncLane); 23663 } 23664} 23665 23666function captureCommitPhaseError(sourceFiber, error) { 23667 if (sourceFiber.tag === HostRoot) { 23668 // Error was thrown at the root. There is no parent, so the root 23669 // itself should capture it. 23670 captureCommitPhaseErrorOnRoot(sourceFiber, sourceFiber, error); 23671 return; 23672 } 23673 23674 var fiber = sourceFiber.return; 23675 23676 while (fiber !== null) { 23677 if (fiber.tag === HostRoot) { 23678 captureCommitPhaseErrorOnRoot(fiber, sourceFiber, error); 23679 return; 23680 } else if (fiber.tag === ClassComponent) { 23681 var ctor = fiber.type; 23682 var instance = fiber.stateNode; 23683 23684 if (typeof ctor.getDerivedStateFromError === 'function' || typeof instance.componentDidCatch === 'function' && !isAlreadyFailedLegacyErrorBoundary(instance)) { 23685 var errorInfo = createCapturedValue(error, sourceFiber); 23686 var update = createClassErrorUpdate(fiber, errorInfo, SyncLane); 23687 enqueueUpdate(fiber, update); 23688 var eventTime = requestEventTime(); 23689 var root = markUpdateLaneFromFiberToRoot(fiber, SyncLane); 23690 23691 if (root !== null) { 23692 markRootUpdated(root, SyncLane, eventTime); 23693 ensureRootIsScheduled(root, eventTime); 23694 schedulePendingInteractions(root, SyncLane); 23695 } else { 23696 // This component has already been unmounted. 23697 // We can't schedule any follow up work for the root because the fiber is already unmounted, 23698 // but we can still call the log-only boundary so the error isn't swallowed. 23699 // 23700 // TODO This is only a temporary bandaid for the old reconciler fork. 23701 // We can delete this special case once the new fork is merged. 23702 if (typeof instance.componentDidCatch === 'function' && !isAlreadyFailedLegacyErrorBoundary(instance)) { 23703 try { 23704 instance.componentDidCatch(error, errorInfo); 23705 } catch (errorToIgnore) {// TODO Ignore this error? Rethrow it? 23706 // This is kind of an edge case. 23707 } 23708 } 23709 } 23710 23711 return; 23712 } 23713 } 23714 23715 fiber = fiber.return; 23716 } 23717} 23718function pingSuspendedRoot(root, wakeable, pingedLanes) { 23719 var pingCache = root.pingCache; 23720 23721 if (pingCache !== null) { 23722 // The wakeable resolved, so we no longer need to memoize, because it will 23723 // never be thrown again. 23724 pingCache.delete(wakeable); 23725 } 23726 23727 var eventTime = requestEventTime(); 23728 markRootPinged(root, pingedLanes); 23729 23730 if (workInProgressRoot === root && isSubsetOfLanes(workInProgressRootRenderLanes, pingedLanes)) { 23731 // Received a ping at the same priority level at which we're currently 23732 // rendering. We might want to restart this render. This should mirror 23733 // the logic of whether or not a root suspends once it completes. 23734 // TODO: If we're rendering sync either due to Sync, Batched or expired, 23735 // we should probably never restart. 23736 // If we're suspended with delay, or if it's a retry, we'll always suspend 23737 // so we can always restart. 23738 if (workInProgressRootExitStatus === RootSuspendedWithDelay || workInProgressRootExitStatus === RootSuspended && includesOnlyRetries(workInProgressRootRenderLanes) && now() - globalMostRecentFallbackTime < FALLBACK_THROTTLE_MS) { 23739 // Restart from the root. 23740 prepareFreshStack(root, NoLanes); 23741 } else { 23742 // Even though we can't restart right now, we might get an 23743 // opportunity later. So we mark this render as having a ping. 23744 workInProgressRootPingedLanes = mergeLanes(workInProgressRootPingedLanes, pingedLanes); 23745 } 23746 } 23747 23748 ensureRootIsScheduled(root, eventTime); 23749 schedulePendingInteractions(root, pingedLanes); 23750} 23751 23752function retryTimedOutBoundary(boundaryFiber, retryLane) { 23753 // The boundary fiber (a Suspense component or SuspenseList component) 23754 // previously was rendered in its fallback state. One of the promises that 23755 // suspended it has resolved, which means at least part of the tree was 23756 // likely unblocked. Try rendering again, at a new expiration time. 23757 if (retryLane === NoLane) { 23758 retryLane = requestRetryLane(boundaryFiber); 23759 } // TODO: Special case idle priority? 23760 23761 23762 var eventTime = requestEventTime(); 23763 var root = markUpdateLaneFromFiberToRoot(boundaryFiber, retryLane); 23764 23765 if (root !== null) { 23766 markRootUpdated(root, retryLane, eventTime); 23767 ensureRootIsScheduled(root, eventTime); 23768 schedulePendingInteractions(root, retryLane); 23769 } 23770} 23771function resolveRetryWakeable(boundaryFiber, wakeable) { 23772 var retryLane = NoLane; // Default 23773 23774 var retryCache; 23775 23776 { 23777 retryCache = boundaryFiber.stateNode; 23778 } 23779 23780 if (retryCache !== null) { 23781 // The wakeable resolved, so we no longer need to memoize, because it will 23782 // never be thrown again. 23783 retryCache.delete(wakeable); 23784 } 23785 23786 retryTimedOutBoundary(boundaryFiber, retryLane); 23787} // Computes the next Just Noticeable Difference (JND) boundary. 23788// The theory is that a person can't tell the difference between small differences in time. 23789// Therefore, if we wait a bit longer than necessary that won't translate to a noticeable 23790// difference in the experience. However, waiting for longer might mean that we can avoid 23791// showing an intermediate loading state. The longer we have already waited, the harder it 23792// is to tell small differences in time. Therefore, the longer we've already waited, 23793// the longer we can wait additionally. At some point we have to give up though. 23794// We pick a train model where the next boundary commits at a consistent schedule. 23795// These particular numbers are vague estimates. We expect to adjust them based on research. 23796 23797function jnd(timeElapsed) { 23798 return timeElapsed < 120 ? 120 : timeElapsed < 480 ? 480 : timeElapsed < 1080 ? 1080 : timeElapsed < 1920 ? 1920 : timeElapsed < 3000 ? 3000 : timeElapsed < 4320 ? 4320 : ceil(timeElapsed / 1960) * 1960; 23799} 23800 23801function checkForNestedUpdates() { 23802 if (nestedUpdateCount > NESTED_UPDATE_LIMIT) { 23803 nestedUpdateCount = 0; 23804 rootWithNestedUpdates = null; 23805 23806 { 23807 { 23808 throw Error( "Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops." ); 23809 } 23810 } 23811 } 23812 23813 { 23814 if (nestedPassiveUpdateCount > NESTED_PASSIVE_UPDATE_LIMIT) { 23815 nestedPassiveUpdateCount = 0; 23816 23817 error('Maximum update depth exceeded. This can happen when a component ' + "calls setState inside useEffect, but useEffect either doesn't " + 'have a dependency array, or one of the dependencies changes on ' + 'every render.'); 23818 } 23819 } 23820} 23821 23822function flushRenderPhaseStrictModeWarningsInDEV() { 23823 { 23824 ReactStrictModeWarnings.flushLegacyContextWarning(); 23825 23826 { 23827 ReactStrictModeWarnings.flushPendingUnsafeLifecycleWarnings(); 23828 } 23829 } 23830} 23831 23832var didWarnStateUpdateForNotYetMountedComponent = null; 23833 23834function warnAboutUpdateOnNotYetMountedFiberInDEV(fiber) { 23835 { 23836 if ((executionContext & RenderContext) !== NoContext) { 23837 // We let the other warning about render phase updates deal with this one. 23838 return; 23839 } 23840 23841 if (!(fiber.mode & (BlockingMode | ConcurrentMode))) { 23842 return; 23843 } 23844 23845 var tag = fiber.tag; 23846 23847 if (tag !== IndeterminateComponent && tag !== HostRoot && tag !== ClassComponent && tag !== FunctionComponent && tag !== ForwardRef && tag !== MemoComponent && tag !== SimpleMemoComponent && tag !== Block) { 23848 // Only warn for user-defined components, not internal ones like Suspense. 23849 return; 23850 } // We show the whole stack but dedupe on the top component's name because 23851 // the problematic code almost always lies inside that component. 23852 23853 23854 var componentName = getComponentName(fiber.type) || 'ReactComponent'; 23855 23856 if (didWarnStateUpdateForNotYetMountedComponent !== null) { 23857 if (didWarnStateUpdateForNotYetMountedComponent.has(componentName)) { 23858 return; 23859 } 23860 23861 didWarnStateUpdateForNotYetMountedComponent.add(componentName); 23862 } else { 23863 didWarnStateUpdateForNotYetMountedComponent = new Set([componentName]); 23864 } 23865 23866 var previousFiber = current; 23867 23868 try { 23869 setCurrentFiber(fiber); 23870 23871 error("Can't perform a React state update on a component that hasn't mounted yet. " + 'This indicates that you have a side-effect in your render function that ' + 'asynchronously later calls tries to update the component. Move this work to ' + 'useEffect instead.'); 23872 } finally { 23873 if (previousFiber) { 23874 setCurrentFiber(fiber); 23875 } else { 23876 resetCurrentFiber(); 23877 } 23878 } 23879 } 23880} 23881 23882var didWarnStateUpdateForUnmountedComponent = null; 23883 23884function warnAboutUpdateOnUnmountedFiberInDEV(fiber) { 23885 { 23886 var tag = fiber.tag; 23887 23888 if (tag !== HostRoot && tag !== ClassComponent && tag !== FunctionComponent && tag !== ForwardRef && tag !== MemoComponent && tag !== SimpleMemoComponent && tag !== Block) { 23889 // Only warn for user-defined components, not internal ones like Suspense. 23890 return; 23891 } // If there are pending passive effects unmounts for this Fiber, 23892 // we can assume that they would have prevented this update. 23893 23894 23895 if ((fiber.flags & PassiveUnmountPendingDev) !== NoFlags) { 23896 return; 23897 } // We show the whole stack but dedupe on the top component's name because 23898 // the problematic code almost always lies inside that component. 23899 23900 23901 var componentName = getComponentName(fiber.type) || 'ReactComponent'; 23902 23903 if (didWarnStateUpdateForUnmountedComponent !== null) { 23904 if (didWarnStateUpdateForUnmountedComponent.has(componentName)) { 23905 return; 23906 } 23907 23908 didWarnStateUpdateForUnmountedComponent.add(componentName); 23909 } else { 23910 didWarnStateUpdateForUnmountedComponent = new Set([componentName]); 23911 } 23912 23913 if (isFlushingPassiveEffects) ; else { 23914 var previousFiber = current; 23915 23916 try { 23917 setCurrentFiber(fiber); 23918 23919 error("Can't perform a React state update on an unmounted component. This " + 'is a no-op, but it indicates a memory leak in your application. To ' + 'fix, cancel all subscriptions and asynchronous tasks in %s.', tag === ClassComponent ? 'the componentWillUnmount method' : 'a useEffect cleanup function'); 23920 } finally { 23921 if (previousFiber) { 23922 setCurrentFiber(fiber); 23923 } else { 23924 resetCurrentFiber(); 23925 } 23926 } 23927 } 23928 } 23929} 23930 23931var beginWork$1; 23932 23933{ 23934 var dummyFiber = null; 23935 23936 beginWork$1 = function (current, unitOfWork, lanes) { 23937 // If a component throws an error, we replay it again in a synchronously 23938 // dispatched event, so that the debugger will treat it as an uncaught 23939 // error See ReactErrorUtils for more information. 23940 // Before entering the begin phase, copy the work-in-progress onto a dummy 23941 // fiber. If beginWork throws, we'll use this to reset the state. 23942 var originalWorkInProgressCopy = assignFiberPropertiesInDEV(dummyFiber, unitOfWork); 23943 23944 try { 23945 return beginWork(current, unitOfWork, lanes); 23946 } catch (originalError) { 23947 if (originalError !== null && typeof originalError === 'object' && typeof originalError.then === 'function') { 23948 // Don't replay promises. Treat everything else like an error. 23949 throw originalError; 23950 } // Keep this code in sync with handleError; any changes here must have 23951 // corresponding changes there. 23952 23953 23954 resetContextDependencies(); 23955 resetHooksAfterThrow(); // Don't reset current debug fiber, since we're about to work on the 23956 // same fiber again. 23957 // Unwind the failed stack frame 23958 23959 unwindInterruptedWork(unitOfWork); // Restore the original properties of the fiber. 23960 23961 assignFiberPropertiesInDEV(unitOfWork, originalWorkInProgressCopy); 23962 23963 if ( unitOfWork.mode & ProfileMode) { 23964 // Reset the profiler timer. 23965 startProfilerTimer(unitOfWork); 23966 } // Run beginWork again. 23967 23968 23969 invokeGuardedCallback(null, beginWork, null, current, unitOfWork, lanes); 23970 23971 if (hasCaughtError()) { 23972 var replayError = clearCaughtError(); // `invokeGuardedCallback` sometimes sets an expando `_suppressLogging`. 23973 // Rethrow this error instead of the original one. 23974 23975 throw replayError; 23976 } else { 23977 // This branch is reachable if the render phase is impure. 23978 throw originalError; 23979 } 23980 } 23981 }; 23982} 23983 23984var didWarnAboutUpdateInRender = false; 23985var didWarnAboutUpdateInRenderForAnotherComponent; 23986 23987{ 23988 didWarnAboutUpdateInRenderForAnotherComponent = new Set(); 23989} 23990 23991function warnAboutRenderPhaseUpdatesInDEV(fiber) { 23992 { 23993 if (isRendering && (executionContext & RenderContext) !== NoContext && !getIsUpdatingOpaqueValueInRenderPhaseInDEV()) { 23994 switch (fiber.tag) { 23995 case FunctionComponent: 23996 case ForwardRef: 23997 case SimpleMemoComponent: 23998 { 23999 var renderingComponentName = workInProgress && getComponentName(workInProgress.type) || 'Unknown'; // Dedupe by the rendering component because it's the one that needs to be fixed. 24000 24001 var dedupeKey = renderingComponentName; 24002 24003 if (!didWarnAboutUpdateInRenderForAnotherComponent.has(dedupeKey)) { 24004 didWarnAboutUpdateInRenderForAnotherComponent.add(dedupeKey); 24005 var setStateComponentName = getComponentName(fiber.type) || 'Unknown'; 24006 24007 error('Cannot update a component (`%s`) while rendering a ' + 'different component (`%s`). To locate the bad setState() call inside `%s`, ' + 'follow the stack trace as described in https://reactjs.org/link/setstate-in-render', setStateComponentName, renderingComponentName, renderingComponentName); 24008 } 24009 24010 break; 24011 } 24012 24013 case ClassComponent: 24014 { 24015 if (!didWarnAboutUpdateInRender) { 24016 error('Cannot update during an existing state transition (such as ' + 'within `render`). Render methods should be a pure ' + 'function of props and state.'); 24017 24018 didWarnAboutUpdateInRender = true; 24019 } 24020 24021 break; 24022 } 24023 } 24024 } 24025 } 24026} // a 'shared' variable that changes when act() opens/closes in tests. 24027 24028 24029var IsThisRendererActing = { 24030 current: false 24031}; 24032function warnIfNotScopedWithMatchingAct(fiber) { 24033 { 24034 if ( IsSomeRendererActing.current === true && IsThisRendererActing.current !== true) { 24035 var previousFiber = current; 24036 24037 try { 24038 setCurrentFiber(fiber); 24039 24040 error("It looks like you're using the wrong act() around your test interactions.\n" + 'Be sure to use the matching version of act() corresponding to your renderer:\n\n' + '// for react-dom:\n' + // Break up imports to avoid accidentally parsing them as dependencies. 24041 'import {act} fr' + "om 'react-dom/test-utils';\n" + '// ...\n' + 'act(() => ...);\n\n' + '// for react-test-renderer:\n' + // Break up imports to avoid accidentally parsing them as dependencies. 24042 'import TestRenderer fr' + "om react-test-renderer';\n" + 'const {act} = TestRenderer;\n' + '// ...\n' + 'act(() => ...);'); 24043 } finally { 24044 if (previousFiber) { 24045 setCurrentFiber(fiber); 24046 } else { 24047 resetCurrentFiber(); 24048 } 24049 } 24050 } 24051 } 24052} 24053function warnIfNotCurrentlyActingEffectsInDEV(fiber) { 24054 { 24055 if ( (fiber.mode & StrictMode) !== NoMode && IsSomeRendererActing.current === false && IsThisRendererActing.current === false) { 24056 error('An update to %s ran an effect, but was not wrapped in act(...).\n\n' + 'When testing, code that causes React state updates should be ' + 'wrapped into act(...):\n\n' + 'act(() => {\n' + ' /* fire events that update state */\n' + '});\n' + '/* assert on the output */\n\n' + "This ensures that you're testing the behavior the user would see " + 'in the browser.' + ' Learn more at https://reactjs.org/link/wrap-tests-with-act', getComponentName(fiber.type)); 24057 } 24058 } 24059} 24060 24061function warnIfNotCurrentlyActingUpdatesInDEV(fiber) { 24062 { 24063 if ( executionContext === NoContext && IsSomeRendererActing.current === false && IsThisRendererActing.current === false) { 24064 var previousFiber = current; 24065 24066 try { 24067 setCurrentFiber(fiber); 24068 24069 error('An update to %s inside a test was not wrapped in act(...).\n\n' + 'When testing, code that causes React state updates should be ' + 'wrapped into act(...):\n\n' + 'act(() => {\n' + ' /* fire events that update state */\n' + '});\n' + '/* assert on the output */\n\n' + "This ensures that you're testing the behavior the user would see " + 'in the browser.' + ' Learn more at https://reactjs.org/link/wrap-tests-with-act', getComponentName(fiber.type)); 24070 } finally { 24071 if (previousFiber) { 24072 setCurrentFiber(fiber); 24073 } else { 24074 resetCurrentFiber(); 24075 } 24076 } 24077 } 24078 } 24079} 24080 24081var warnIfNotCurrentlyActingUpdatesInDev = warnIfNotCurrentlyActingUpdatesInDEV; // In tests, we want to enforce a mocked scheduler. 24082 24083var didWarnAboutUnmockedScheduler = false; // TODO Before we release concurrent mode, revisit this and decide whether a mocked 24084// scheduler is the actual recommendation. The alternative could be a testing build, 24085// a new lib, or whatever; we dunno just yet. This message is for early adopters 24086// to get their tests right. 24087 24088function warnIfUnmockedScheduler(fiber) { 24089 { 24090 if (didWarnAboutUnmockedScheduler === false && Scheduler.unstable_flushAllWithoutAsserting === undefined) { 24091 if (fiber.mode & BlockingMode || fiber.mode & ConcurrentMode) { 24092 didWarnAboutUnmockedScheduler = true; 24093 24094 error('In Concurrent or Sync modes, the "scheduler" module needs to be mocked ' + 'to guarantee consistent behaviour across tests and browsers. ' + 'For example, with jest: \n' + // Break up requires to avoid accidentally parsing them as dependencies. 24095 "jest.mock('scheduler', () => require" + "('scheduler/unstable_mock'));\n\n" + 'For more info, visit https://reactjs.org/link/mock-scheduler'); 24096 } 24097 } 24098 } 24099} 24100 24101function computeThreadID(root, lane) { 24102 // Interaction threads are unique per root and expiration time. 24103 // NOTE: Intentionally unsound cast. All that matters is that it's a number 24104 // and it represents a batch of work. Could make a helper function instead, 24105 // but meh this is fine for now. 24106 return lane * 1000 + root.interactionThreadID; 24107} 24108 24109function markSpawnedWork(lane) { 24110 24111 if (spawnedWorkDuringRender === null) { 24112 spawnedWorkDuringRender = [lane]; 24113 } else { 24114 spawnedWorkDuringRender.push(lane); 24115 } 24116} 24117 24118function scheduleInteractions(root, lane, interactions) { 24119 24120 if (interactions.size > 0) { 24121 var pendingInteractionMap = root.pendingInteractionMap; 24122 var pendingInteractions = pendingInteractionMap.get(lane); 24123 24124 if (pendingInteractions != null) { 24125 interactions.forEach(function (interaction) { 24126 if (!pendingInteractions.has(interaction)) { 24127 // Update the pending async work count for previously unscheduled interaction. 24128 interaction.__count++; 24129 } 24130 24131 pendingInteractions.add(interaction); 24132 }); 24133 } else { 24134 pendingInteractionMap.set(lane, new Set(interactions)); // Update the pending async work count for the current interactions. 24135 24136 interactions.forEach(function (interaction) { 24137 interaction.__count++; 24138 }); 24139 } 24140 24141 var subscriber = tracing.__subscriberRef.current; 24142 24143 if (subscriber !== null) { 24144 var threadID = computeThreadID(root, lane); 24145 subscriber.onWorkScheduled(interactions, threadID); 24146 } 24147 } 24148} 24149 24150function schedulePendingInteractions(root, lane) { 24151 24152 scheduleInteractions(root, lane, tracing.__interactionsRef.current); 24153} 24154 24155function startWorkOnPendingInteractions(root, lanes) { 24156 // we can accurately attribute time spent working on it, And so that cascading 24157 // work triggered during the render phase will be associated with it. 24158 24159 24160 var interactions = new Set(); 24161 root.pendingInteractionMap.forEach(function (scheduledInteractions, scheduledLane) { 24162 if (includesSomeLane(lanes, scheduledLane)) { 24163 scheduledInteractions.forEach(function (interaction) { 24164 return interactions.add(interaction); 24165 }); 24166 } 24167 }); // Store the current set of interactions on the FiberRoot for a few reasons: 24168 // We can re-use it in hot functions like performConcurrentWorkOnRoot() 24169 // without having to recalculate it. We will also use it in commitWork() to 24170 // pass to any Profiler onRender() hooks. This also provides DevTools with a 24171 // way to access it when the onCommitRoot() hook is called. 24172 24173 root.memoizedInteractions = interactions; 24174 24175 if (interactions.size > 0) { 24176 var subscriber = tracing.__subscriberRef.current; 24177 24178 if (subscriber !== null) { 24179 var threadID = computeThreadID(root, lanes); 24180 24181 try { 24182 subscriber.onWorkStarted(interactions, threadID); 24183 } catch (error) { 24184 // If the subscriber throws, rethrow it in a separate task 24185 scheduleCallback(ImmediatePriority$1, function () { 24186 throw error; 24187 }); 24188 } 24189 } 24190 } 24191} 24192 24193function finishPendingInteractions(root, committedLanes) { 24194 24195 var remainingLanesAfterCommit = root.pendingLanes; 24196 var subscriber; 24197 24198 try { 24199 subscriber = tracing.__subscriberRef.current; 24200 24201 if (subscriber !== null && root.memoizedInteractions.size > 0) { 24202 // FIXME: More than one lane can finish in a single commit. 24203 var threadID = computeThreadID(root, committedLanes); 24204 subscriber.onWorkStopped(root.memoizedInteractions, threadID); 24205 } 24206 } catch (error) { 24207 // If the subscriber throws, rethrow it in a separate task 24208 scheduleCallback(ImmediatePriority$1, function () { 24209 throw error; 24210 }); 24211 } finally { 24212 // Clear completed interactions from the pending Map. 24213 // Unless the render was suspended or cascading work was scheduled, 24214 // In which case– leave pending interactions until the subsequent render. 24215 var pendingInteractionMap = root.pendingInteractionMap; 24216 pendingInteractionMap.forEach(function (scheduledInteractions, lane) { 24217 // Only decrement the pending interaction count if we're done. 24218 // If there's still work at the current priority, 24219 // That indicates that we are waiting for suspense data. 24220 if (!includesSomeLane(remainingLanesAfterCommit, lane)) { 24221 pendingInteractionMap.delete(lane); 24222 scheduledInteractions.forEach(function (interaction) { 24223 interaction.__count--; 24224 24225 if (subscriber !== null && interaction.__count === 0) { 24226 try { 24227 subscriber.onInteractionScheduledWorkCompleted(interaction); 24228 } catch (error) { 24229 // If the subscriber throws, rethrow it in a separate task 24230 scheduleCallback(ImmediatePriority$1, function () { 24231 throw error; 24232 }); 24233 } 24234 } 24235 }); 24236 } 24237 }); 24238 } 24239} // `act` testing API 24240 24241function shouldForceFlushFallbacksInDEV() { 24242 // Never force flush in production. This function should get stripped out. 24243 return actingUpdatesScopeDepth > 0; 24244} 24245// so we can tell if any async act() calls try to run in parallel. 24246 24247 24248var actingUpdatesScopeDepth = 0; 24249 24250function detachFiberAfterEffects(fiber) { 24251 fiber.sibling = null; 24252 fiber.stateNode = null; 24253} 24254 24255var resolveFamily = null; // $FlowFixMe Flow gets confused by a WeakSet feature check below. 24256 24257var failedBoundaries = null; 24258var setRefreshHandler = function (handler) { 24259 { 24260 resolveFamily = handler; 24261 } 24262}; 24263function resolveFunctionForHotReloading(type) { 24264 { 24265 if (resolveFamily === null) { 24266 // Hot reloading is disabled. 24267 return type; 24268 } 24269 24270 var family = resolveFamily(type); 24271 24272 if (family === undefined) { 24273 return type; 24274 } // Use the latest known implementation. 24275 24276 24277 return family.current; 24278 } 24279} 24280function resolveClassForHotReloading(type) { 24281 // No implementation differences. 24282 return resolveFunctionForHotReloading(type); 24283} 24284function resolveForwardRefForHotReloading(type) { 24285 { 24286 if (resolveFamily === null) { 24287 // Hot reloading is disabled. 24288 return type; 24289 } 24290 24291 var family = resolveFamily(type); 24292 24293 if (family === undefined) { 24294 // Check if we're dealing with a real forwardRef. Don't want to crash early. 24295 if (type !== null && type !== undefined && typeof type.render === 'function') { 24296 // ForwardRef is special because its resolved .type is an object, 24297 // but it's possible that we only have its inner render function in the map. 24298 // If that inner render function is different, we'll build a new forwardRef type. 24299 var currentRender = resolveFunctionForHotReloading(type.render); 24300 24301 if (type.render !== currentRender) { 24302 var syntheticType = { 24303 $$typeof: REACT_FORWARD_REF_TYPE, 24304 render: currentRender 24305 }; 24306 24307 if (type.displayName !== undefined) { 24308 syntheticType.displayName = type.displayName; 24309 } 24310 24311 return syntheticType; 24312 } 24313 } 24314 24315 return type; 24316 } // Use the latest known implementation. 24317 24318 24319 return family.current; 24320 } 24321} 24322function isCompatibleFamilyForHotReloading(fiber, element) { 24323 { 24324 if (resolveFamily === null) { 24325 // Hot reloading is disabled. 24326 return false; 24327 } 24328 24329 var prevType = fiber.elementType; 24330 var nextType = element.type; // If we got here, we know types aren't === equal. 24331 24332 var needsCompareFamilies = false; 24333 var $$typeofNextType = typeof nextType === 'object' && nextType !== null ? nextType.$$typeof : null; 24334 24335 switch (fiber.tag) { 24336 case ClassComponent: 24337 { 24338 if (typeof nextType === 'function') { 24339 needsCompareFamilies = true; 24340 } 24341 24342 break; 24343 } 24344 24345 case FunctionComponent: 24346 { 24347 if (typeof nextType === 'function') { 24348 needsCompareFamilies = true; 24349 } else if ($$typeofNextType === REACT_LAZY_TYPE) { 24350 // We don't know the inner type yet. 24351 // We're going to assume that the lazy inner type is stable, 24352 // and so it is sufficient to avoid reconciling it away. 24353 // We're not going to unwrap or actually use the new lazy type. 24354 needsCompareFamilies = true; 24355 } 24356 24357 break; 24358 } 24359 24360 case ForwardRef: 24361 { 24362 if ($$typeofNextType === REACT_FORWARD_REF_TYPE) { 24363 needsCompareFamilies = true; 24364 } else if ($$typeofNextType === REACT_LAZY_TYPE) { 24365 needsCompareFamilies = true; 24366 } 24367 24368 break; 24369 } 24370 24371 case MemoComponent: 24372 case SimpleMemoComponent: 24373 { 24374 if ($$typeofNextType === REACT_MEMO_TYPE) { 24375 // TODO: if it was but can no longer be simple, 24376 // we shouldn't set this. 24377 needsCompareFamilies = true; 24378 } else if ($$typeofNextType === REACT_LAZY_TYPE) { 24379 needsCompareFamilies = true; 24380 } 24381 24382 break; 24383 } 24384 24385 default: 24386 return false; 24387 } // Check if both types have a family and it's the same one. 24388 24389 24390 if (needsCompareFamilies) { 24391 // Note: memo() and forwardRef() we'll compare outer rather than inner type. 24392 // This means both of them need to be registered to preserve state. 24393 // If we unwrapped and compared the inner types for wrappers instead, 24394 // then we would risk falsely saying two separate memo(Foo) 24395 // calls are equivalent because they wrap the same Foo function. 24396 var prevFamily = resolveFamily(prevType); 24397 24398 if (prevFamily !== undefined && prevFamily === resolveFamily(nextType)) { 24399 return true; 24400 } 24401 } 24402 24403 return false; 24404 } 24405} 24406function markFailedErrorBoundaryForHotReloading(fiber) { 24407 { 24408 if (resolveFamily === null) { 24409 // Hot reloading is disabled. 24410 return; 24411 } 24412 24413 if (typeof WeakSet !== 'function') { 24414 return; 24415 } 24416 24417 if (failedBoundaries === null) { 24418 failedBoundaries = new WeakSet(); 24419 } 24420 24421 failedBoundaries.add(fiber); 24422 } 24423} 24424var scheduleRefresh = function (root, update) { 24425 { 24426 if (resolveFamily === null) { 24427 // Hot reloading is disabled. 24428 return; 24429 } 24430 24431 var staleFamilies = update.staleFamilies, 24432 updatedFamilies = update.updatedFamilies; 24433 flushPassiveEffects(); 24434 flushSync(function () { 24435 scheduleFibersWithFamiliesRecursively(root.current, updatedFamilies, staleFamilies); 24436 }); 24437 } 24438}; 24439var scheduleRoot = function (root, element) { 24440 { 24441 if (root.context !== emptyContextObject) { 24442 // Super edge case: root has a legacy _renderSubtree context 24443 // but we don't know the parentComponent so we can't pass it. 24444 // Just ignore. We'll delete this with _renderSubtree code path later. 24445 return; 24446 } 24447 24448 flushPassiveEffects(); 24449 flushSync(function () { 24450 updateContainer(element, root, null, null); 24451 }); 24452 } 24453}; 24454 24455function scheduleFibersWithFamiliesRecursively(fiber, updatedFamilies, staleFamilies) { 24456 { 24457 var alternate = fiber.alternate, 24458 child = fiber.child, 24459 sibling = fiber.sibling, 24460 tag = fiber.tag, 24461 type = fiber.type; 24462 var candidateType = null; 24463 24464 switch (tag) { 24465 case FunctionComponent: 24466 case SimpleMemoComponent: 24467 case ClassComponent: 24468 candidateType = type; 24469 break; 24470 24471 case ForwardRef: 24472 candidateType = type.render; 24473 break; 24474 } 24475 24476 if (resolveFamily === null) { 24477 throw new Error('Expected resolveFamily to be set during hot reload.'); 24478 } 24479 24480 var needsRender = false; 24481 var needsRemount = false; 24482 24483 if (candidateType !== null) { 24484 var family = resolveFamily(candidateType); 24485 24486 if (family !== undefined) { 24487 if (staleFamilies.has(family)) { 24488 needsRemount = true; 24489 } else if (updatedFamilies.has(family)) { 24490 if (tag === ClassComponent) { 24491 needsRemount = true; 24492 } else { 24493 needsRender = true; 24494 } 24495 } 24496 } 24497 } 24498 24499 if (failedBoundaries !== null) { 24500 if (failedBoundaries.has(fiber) || alternate !== null && failedBoundaries.has(alternate)) { 24501 needsRemount = true; 24502 } 24503 } 24504 24505 if (needsRemount) { 24506 fiber._debugNeedsRemount = true; 24507 } 24508 24509 if (needsRemount || needsRender) { 24510 scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp); 24511 } 24512 24513 if (child !== null && !needsRemount) { 24514 scheduleFibersWithFamiliesRecursively(child, updatedFamilies, staleFamilies); 24515 } 24516 24517 if (sibling !== null) { 24518 scheduleFibersWithFamiliesRecursively(sibling, updatedFamilies, staleFamilies); 24519 } 24520 } 24521} 24522 24523var findHostInstancesForRefresh = function (root, families) { 24524 { 24525 var hostInstances = new Set(); 24526 var types = new Set(families.map(function (family) { 24527 return family.current; 24528 })); 24529 findHostInstancesForMatchingFibersRecursively(root.current, types, hostInstances); 24530 return hostInstances; 24531 } 24532}; 24533 24534function findHostInstancesForMatchingFibersRecursively(fiber, types, hostInstances) { 24535 { 24536 var child = fiber.child, 24537 sibling = fiber.sibling, 24538 tag = fiber.tag, 24539 type = fiber.type; 24540 var candidateType = null; 24541 24542 switch (tag) { 24543 case FunctionComponent: 24544 case SimpleMemoComponent: 24545 case ClassComponent: 24546 candidateType = type; 24547 break; 24548 24549 case ForwardRef: 24550 candidateType = type.render; 24551 break; 24552 } 24553 24554 var didMatch = false; 24555 24556 if (candidateType !== null) { 24557 if (types.has(candidateType)) { 24558 didMatch = true; 24559 } 24560 } 24561 24562 if (didMatch) { 24563 // We have a match. This only drills down to the closest host components. 24564 // There's no need to search deeper because for the purpose of giving 24565 // visual feedback, "flashing" outermost parent rectangles is sufficient. 24566 findHostInstancesForFiberShallowly(fiber, hostInstances); 24567 } else { 24568 // If there's no match, maybe there will be one further down in the child tree. 24569 if (child !== null) { 24570 findHostInstancesForMatchingFibersRecursively(child, types, hostInstances); 24571 } 24572 } 24573 24574 if (sibling !== null) { 24575 findHostInstancesForMatchingFibersRecursively(sibling, types, hostInstances); 24576 } 24577 } 24578} 24579 24580function findHostInstancesForFiberShallowly(fiber, hostInstances) { 24581 { 24582 var foundHostInstances = findChildHostInstancesForFiberShallowly(fiber, hostInstances); 24583 24584 if (foundHostInstances) { 24585 return; 24586 } // If we didn't find any host children, fallback to closest host parent. 24587 24588 24589 var node = fiber; 24590 24591 while (true) { 24592 switch (node.tag) { 24593 case HostComponent: 24594 hostInstances.add(node.stateNode); 24595 return; 24596 24597 case HostPortal: 24598 hostInstances.add(node.stateNode.containerInfo); 24599 return; 24600 24601 case HostRoot: 24602 hostInstances.add(node.stateNode.containerInfo); 24603 return; 24604 } 24605 24606 if (node.return === null) { 24607 throw new Error('Expected to reach root first.'); 24608 } 24609 24610 node = node.return; 24611 } 24612 } 24613} 24614 24615function findChildHostInstancesForFiberShallowly(fiber, hostInstances) { 24616 { 24617 var node = fiber; 24618 var foundHostInstances = false; 24619 24620 while (true) { 24621 if (node.tag === HostComponent) { 24622 // We got a match. 24623 foundHostInstances = true; 24624 hostInstances.add(node.stateNode); // There may still be more, so keep searching. 24625 } else if (node.child !== null) { 24626 node.child.return = node; 24627 node = node.child; 24628 continue; 24629 } 24630 24631 if (node === fiber) { 24632 return foundHostInstances; 24633 } 24634 24635 while (node.sibling === null) { 24636 if (node.return === null || node.return === fiber) { 24637 return foundHostInstances; 24638 } 24639 24640 node = node.return; 24641 } 24642 24643 node.sibling.return = node.return; 24644 node = node.sibling; 24645 } 24646 } 24647 24648 return false; 24649} 24650 24651var hasBadMapPolyfill; 24652 24653{ 24654 hasBadMapPolyfill = false; 24655 24656 try { 24657 var nonExtensibleObject = Object.preventExtensions({}); 24658 /* eslint-disable no-new */ 24659 24660 new Map([[nonExtensibleObject, null]]); 24661 new Set([nonExtensibleObject]); 24662 /* eslint-enable no-new */ 24663 } catch (e) { 24664 // TODO: Consider warning about bad polyfills 24665 hasBadMapPolyfill = true; 24666 } 24667} 24668 24669var debugCounter = 1; 24670 24671function FiberNode(tag, pendingProps, key, mode) { 24672 // Instance 24673 this.tag = tag; 24674 this.key = key; 24675 this.elementType = null; 24676 this.type = null; 24677 this.stateNode = null; // Fiber 24678 24679 this.return = null; 24680 this.child = null; 24681 this.sibling = null; 24682 this.index = 0; 24683 this.ref = null; 24684 this.pendingProps = pendingProps; 24685 this.memoizedProps = null; 24686 this.updateQueue = null; 24687 this.memoizedState = null; 24688 this.dependencies = null; 24689 this.mode = mode; // Effects 24690 24691 this.flags = NoFlags; 24692 this.nextEffect = null; 24693 this.firstEffect = null; 24694 this.lastEffect = null; 24695 this.lanes = NoLanes; 24696 this.childLanes = NoLanes; 24697 this.alternate = null; 24698 24699 { 24700 // Note: The following is done to avoid a v8 performance cliff. 24701 // 24702 // Initializing the fields below to smis and later updating them with 24703 // double values will cause Fibers to end up having separate shapes. 24704 // This behavior/bug has something to do with Object.preventExtension(). 24705 // Fortunately this only impacts DEV builds. 24706 // Unfortunately it makes React unusably slow for some applications. 24707 // To work around this, initialize the fields below with doubles. 24708 // 24709 // Learn more about this here: 24710 // https://github.com/facebook/react/issues/14365 24711 // https://bugs.chromium.org/p/v8/issues/detail?id=8538 24712 this.actualDuration = Number.NaN; 24713 this.actualStartTime = Number.NaN; 24714 this.selfBaseDuration = Number.NaN; 24715 this.treeBaseDuration = Number.NaN; // It's okay to replace the initial doubles with smis after initialization. 24716 // This won't trigger the performance cliff mentioned above, 24717 // and it simplifies other profiler code (including DevTools). 24718 24719 this.actualDuration = 0; 24720 this.actualStartTime = -1; 24721 this.selfBaseDuration = 0; 24722 this.treeBaseDuration = 0; 24723 } 24724 24725 { 24726 // This isn't directly used but is handy for debugging internals: 24727 this._debugID = debugCounter++; 24728 this._debugSource = null; 24729 this._debugOwner = null; 24730 this._debugNeedsRemount = false; 24731 this._debugHookTypes = null; 24732 24733 if (!hasBadMapPolyfill && typeof Object.preventExtensions === 'function') { 24734 Object.preventExtensions(this); 24735 } 24736 } 24737} // This is a constructor function, rather than a POJO constructor, still 24738// please ensure we do the following: 24739// 1) Nobody should add any instance methods on this. Instance methods can be 24740// more difficult to predict when they get optimized and they are almost 24741// never inlined properly in static compilers. 24742// 2) Nobody should rely on `instanceof Fiber` for type testing. We should 24743// always know when it is a fiber. 24744// 3) We might want to experiment with using numeric keys since they are easier 24745// to optimize in a non-JIT environment. 24746// 4) We can easily go from a constructor to a createFiber object literal if that 24747// is faster. 24748// 5) It should be easy to port this to a C struct and keep a C implementation 24749// compatible. 24750 24751 24752var createFiber = function (tag, pendingProps, key, mode) { 24753 // $FlowFixMe: the shapes are exact here but Flow doesn't like constructors 24754 return new FiberNode(tag, pendingProps, key, mode); 24755}; 24756 24757function shouldConstruct$1(Component) { 24758 var prototype = Component.prototype; 24759 return !!(prototype && prototype.isReactComponent); 24760} 24761 24762function isSimpleFunctionComponent(type) { 24763 return typeof type === 'function' && !shouldConstruct$1(type) && type.defaultProps === undefined; 24764} 24765function resolveLazyComponentTag(Component) { 24766 if (typeof Component === 'function') { 24767 return shouldConstruct$1(Component) ? ClassComponent : FunctionComponent; 24768 } else if (Component !== undefined && Component !== null) { 24769 var $$typeof = Component.$$typeof; 24770 24771 if ($$typeof === REACT_FORWARD_REF_TYPE) { 24772 return ForwardRef; 24773 } 24774 24775 if ($$typeof === REACT_MEMO_TYPE) { 24776 return MemoComponent; 24777 } 24778 } 24779 24780 return IndeterminateComponent; 24781} // This is used to create an alternate fiber to do work on. 24782 24783function createWorkInProgress(current, pendingProps) { 24784 var workInProgress = current.alternate; 24785 24786 if (workInProgress === null) { 24787 // We use a double buffering pooling technique because we know that we'll 24788 // only ever need at most two versions of a tree. We pool the "other" unused 24789 // node that we're free to reuse. This is lazily created to avoid allocating 24790 // extra objects for things that are never updated. It also allow us to 24791 // reclaim the extra memory if needed. 24792 workInProgress = createFiber(current.tag, pendingProps, current.key, current.mode); 24793 workInProgress.elementType = current.elementType; 24794 workInProgress.type = current.type; 24795 workInProgress.stateNode = current.stateNode; 24796 24797 { 24798 // DEV-only fields 24799 workInProgress._debugID = current._debugID; 24800 workInProgress._debugSource = current._debugSource; 24801 workInProgress._debugOwner = current._debugOwner; 24802 workInProgress._debugHookTypes = current._debugHookTypes; 24803 } 24804 24805 workInProgress.alternate = current; 24806 current.alternate = workInProgress; 24807 } else { 24808 workInProgress.pendingProps = pendingProps; // Needed because Blocks store data on type. 24809 24810 workInProgress.type = current.type; // We already have an alternate. 24811 // Reset the effect tag. 24812 24813 workInProgress.flags = NoFlags; // The effect list is no longer valid. 24814 24815 workInProgress.nextEffect = null; 24816 workInProgress.firstEffect = null; 24817 workInProgress.lastEffect = null; 24818 24819 { 24820 // We intentionally reset, rather than copy, actualDuration & actualStartTime. 24821 // This prevents time from endlessly accumulating in new commits. 24822 // This has the downside of resetting values for different priority renders, 24823 // But works for yielding (the common case) and should support resuming. 24824 workInProgress.actualDuration = 0; 24825 workInProgress.actualStartTime = -1; 24826 } 24827 } 24828 24829 workInProgress.childLanes = current.childLanes; 24830 workInProgress.lanes = current.lanes; 24831 workInProgress.child = current.child; 24832 workInProgress.memoizedProps = current.memoizedProps; 24833 workInProgress.memoizedState = current.memoizedState; 24834 workInProgress.updateQueue = current.updateQueue; // Clone the dependencies object. This is mutated during the render phase, so 24835 // it cannot be shared with the current fiber. 24836 24837 var currentDependencies = current.dependencies; 24838 workInProgress.dependencies = currentDependencies === null ? null : { 24839 lanes: currentDependencies.lanes, 24840 firstContext: currentDependencies.firstContext 24841 }; // These will be overridden during the parent's reconciliation 24842 24843 workInProgress.sibling = current.sibling; 24844 workInProgress.index = current.index; 24845 workInProgress.ref = current.ref; 24846 24847 { 24848 workInProgress.selfBaseDuration = current.selfBaseDuration; 24849 workInProgress.treeBaseDuration = current.treeBaseDuration; 24850 } 24851 24852 { 24853 workInProgress._debugNeedsRemount = current._debugNeedsRemount; 24854 24855 switch (workInProgress.tag) { 24856 case IndeterminateComponent: 24857 case FunctionComponent: 24858 case SimpleMemoComponent: 24859 workInProgress.type = resolveFunctionForHotReloading(current.type); 24860 break; 24861 24862 case ClassComponent: 24863 workInProgress.type = resolveClassForHotReloading(current.type); 24864 break; 24865 24866 case ForwardRef: 24867 workInProgress.type = resolveForwardRefForHotReloading(current.type); 24868 break; 24869 } 24870 } 24871 24872 return workInProgress; 24873} // Used to reuse a Fiber for a second pass. 24874 24875function resetWorkInProgress(workInProgress, renderLanes) { 24876 // This resets the Fiber to what createFiber or createWorkInProgress would 24877 // have set the values to before during the first pass. Ideally this wouldn't 24878 // be necessary but unfortunately many code paths reads from the workInProgress 24879 // when they should be reading from current and writing to workInProgress. 24880 // We assume pendingProps, index, key, ref, return are still untouched to 24881 // avoid doing another reconciliation. 24882 // Reset the effect tag but keep any Placement tags, since that's something 24883 // that child fiber is setting, not the reconciliation. 24884 workInProgress.flags &= Placement; // The effect list is no longer valid. 24885 24886 workInProgress.nextEffect = null; 24887 workInProgress.firstEffect = null; 24888 workInProgress.lastEffect = null; 24889 var current = workInProgress.alternate; 24890 24891 if (current === null) { 24892 // Reset to createFiber's initial values. 24893 workInProgress.childLanes = NoLanes; 24894 workInProgress.lanes = renderLanes; 24895 workInProgress.child = null; 24896 workInProgress.memoizedProps = null; 24897 workInProgress.memoizedState = null; 24898 workInProgress.updateQueue = null; 24899 workInProgress.dependencies = null; 24900 workInProgress.stateNode = null; 24901 24902 { 24903 // Note: We don't reset the actualTime counts. It's useful to accumulate 24904 // actual time across multiple render passes. 24905 workInProgress.selfBaseDuration = 0; 24906 workInProgress.treeBaseDuration = 0; 24907 } 24908 } else { 24909 // Reset to the cloned values that createWorkInProgress would've. 24910 workInProgress.childLanes = current.childLanes; 24911 workInProgress.lanes = current.lanes; 24912 workInProgress.child = current.child; 24913 workInProgress.memoizedProps = current.memoizedProps; 24914 workInProgress.memoizedState = current.memoizedState; 24915 workInProgress.updateQueue = current.updateQueue; // Needed because Blocks store data on type. 24916 24917 workInProgress.type = current.type; // Clone the dependencies object. This is mutated during the render phase, so 24918 // it cannot be shared with the current fiber. 24919 24920 var currentDependencies = current.dependencies; 24921 workInProgress.dependencies = currentDependencies === null ? null : { 24922 lanes: currentDependencies.lanes, 24923 firstContext: currentDependencies.firstContext 24924 }; 24925 24926 { 24927 // Note: We don't reset the actualTime counts. It's useful to accumulate 24928 // actual time across multiple render passes. 24929 workInProgress.selfBaseDuration = current.selfBaseDuration; 24930 workInProgress.treeBaseDuration = current.treeBaseDuration; 24931 } 24932 } 24933 24934 return workInProgress; 24935} 24936function createHostRootFiber(tag) { 24937 var mode; 24938 24939 if (tag === ConcurrentRoot) { 24940 mode = ConcurrentMode | BlockingMode | StrictMode; 24941 } else if (tag === BlockingRoot) { 24942 mode = BlockingMode | StrictMode; 24943 } else { 24944 mode = NoMode; 24945 } 24946 24947 if ( isDevToolsPresent) { 24948 // Always collect profile timings when DevTools are present. 24949 // This enables DevTools to start capturing timing at any point– 24950 // Without some nodes in the tree having empty base times. 24951 mode |= ProfileMode; 24952 } 24953 24954 return createFiber(HostRoot, null, null, mode); 24955} 24956function createFiberFromTypeAndProps(type, // React$ElementType 24957key, pendingProps, owner, mode, lanes) { 24958 var fiberTag = IndeterminateComponent; // The resolved type is set if we know what the final type will be. I.e. it's not lazy. 24959 24960 var resolvedType = type; 24961 24962 if (typeof type === 'function') { 24963 if (shouldConstruct$1(type)) { 24964 fiberTag = ClassComponent; 24965 24966 { 24967 resolvedType = resolveClassForHotReloading(resolvedType); 24968 } 24969 } else { 24970 { 24971 resolvedType = resolveFunctionForHotReloading(resolvedType); 24972 } 24973 } 24974 } else if (typeof type === 'string') { 24975 fiberTag = HostComponent; 24976 } else { 24977 getTag: switch (type) { 24978 case REACT_FRAGMENT_TYPE: 24979 return createFiberFromFragment(pendingProps.children, mode, lanes, key); 24980 24981 case REACT_DEBUG_TRACING_MODE_TYPE: 24982 fiberTag = Mode; 24983 mode |= DebugTracingMode; 24984 break; 24985 24986 case REACT_STRICT_MODE_TYPE: 24987 fiberTag = Mode; 24988 mode |= StrictMode; 24989 break; 24990 24991 case REACT_PROFILER_TYPE: 24992 return createFiberFromProfiler(pendingProps, mode, lanes, key); 24993 24994 case REACT_SUSPENSE_TYPE: 24995 return createFiberFromSuspense(pendingProps, mode, lanes, key); 24996 24997 case REACT_SUSPENSE_LIST_TYPE: 24998 return createFiberFromSuspenseList(pendingProps, mode, lanes, key); 24999 25000 case REACT_OFFSCREEN_TYPE: 25001 return createFiberFromOffscreen(pendingProps, mode, lanes, key); 25002 25003 case REACT_LEGACY_HIDDEN_TYPE: 25004 return createFiberFromLegacyHidden(pendingProps, mode, lanes, key); 25005 25006 case REACT_SCOPE_TYPE: 25007 25008 // eslint-disable-next-line no-fallthrough 25009 25010 default: 25011 { 25012 if (typeof type === 'object' && type !== null) { 25013 switch (type.$$typeof) { 25014 case REACT_PROVIDER_TYPE: 25015 fiberTag = ContextProvider; 25016 break getTag; 25017 25018 case REACT_CONTEXT_TYPE: 25019 // This is a consumer 25020 fiberTag = ContextConsumer; 25021 break getTag; 25022 25023 case REACT_FORWARD_REF_TYPE: 25024 fiberTag = ForwardRef; 25025 25026 { 25027 resolvedType = resolveForwardRefForHotReloading(resolvedType); 25028 } 25029 25030 break getTag; 25031 25032 case REACT_MEMO_TYPE: 25033 fiberTag = MemoComponent; 25034 break getTag; 25035 25036 case REACT_LAZY_TYPE: 25037 fiberTag = LazyComponent; 25038 resolvedType = null; 25039 break getTag; 25040 25041 case REACT_BLOCK_TYPE: 25042 fiberTag = Block; 25043 break getTag; 25044 } 25045 } 25046 25047 var info = ''; 25048 25049 { 25050 if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) { 25051 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.'; 25052 } 25053 25054 var ownerName = owner ? getComponentName(owner.type) : null; 25055 25056 if (ownerName) { 25057 info += '\n\nCheck the render method of `' + ownerName + '`.'; 25058 } 25059 } 25060 25061 { 25062 { 25063 throw Error( "Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: " + (type == null ? type : typeof type) + "." + info ); 25064 } 25065 } 25066 } 25067 } 25068 } 25069 25070 var fiber = createFiber(fiberTag, pendingProps, key, mode); 25071 fiber.elementType = type; 25072 fiber.type = resolvedType; 25073 fiber.lanes = lanes; 25074 25075 { 25076 fiber._debugOwner = owner; 25077 } 25078 25079 return fiber; 25080} 25081function createFiberFromElement(element, mode, lanes) { 25082 var owner = null; 25083 25084 { 25085 owner = element._owner; 25086 } 25087 25088 var type = element.type; 25089 var key = element.key; 25090 var pendingProps = element.props; 25091 var fiber = createFiberFromTypeAndProps(type, key, pendingProps, owner, mode, lanes); 25092 25093 { 25094 fiber._debugSource = element._source; 25095 fiber._debugOwner = element._owner; 25096 } 25097 25098 return fiber; 25099} 25100function createFiberFromFragment(elements, mode, lanes, key) { 25101 var fiber = createFiber(Fragment, elements, key, mode); 25102 fiber.lanes = lanes; 25103 return fiber; 25104} 25105 25106function createFiberFromProfiler(pendingProps, mode, lanes, key) { 25107 { 25108 if (typeof pendingProps.id !== 'string') { 25109 error('Profiler must specify an "id" as a prop'); 25110 } 25111 } 25112 25113 var fiber = createFiber(Profiler, pendingProps, key, mode | ProfileMode); // TODO: The Profiler fiber shouldn't have a type. It has a tag. 25114 25115 fiber.elementType = REACT_PROFILER_TYPE; 25116 fiber.type = REACT_PROFILER_TYPE; 25117 fiber.lanes = lanes; 25118 25119 { 25120 fiber.stateNode = { 25121 effectDuration: 0, 25122 passiveEffectDuration: 0 25123 }; 25124 } 25125 25126 return fiber; 25127} 25128 25129function createFiberFromSuspense(pendingProps, mode, lanes, key) { 25130 var fiber = createFiber(SuspenseComponent, pendingProps, key, mode); // TODO: The SuspenseComponent fiber shouldn't have a type. It has a tag. 25131 // This needs to be fixed in getComponentName so that it relies on the tag 25132 // instead. 25133 25134 fiber.type = REACT_SUSPENSE_TYPE; 25135 fiber.elementType = REACT_SUSPENSE_TYPE; 25136 fiber.lanes = lanes; 25137 return fiber; 25138} 25139function createFiberFromSuspenseList(pendingProps, mode, lanes, key) { 25140 var fiber = createFiber(SuspenseListComponent, pendingProps, key, mode); 25141 25142 { 25143 // TODO: The SuspenseListComponent fiber shouldn't have a type. It has a tag. 25144 // This needs to be fixed in getComponentName so that it relies on the tag 25145 // instead. 25146 fiber.type = REACT_SUSPENSE_LIST_TYPE; 25147 } 25148 25149 fiber.elementType = REACT_SUSPENSE_LIST_TYPE; 25150 fiber.lanes = lanes; 25151 return fiber; 25152} 25153function createFiberFromOffscreen(pendingProps, mode, lanes, key) { 25154 var fiber = createFiber(OffscreenComponent, pendingProps, key, mode); // TODO: The OffscreenComponent fiber shouldn't have a type. It has a tag. 25155 // This needs to be fixed in getComponentName so that it relies on the tag 25156 // instead. 25157 25158 { 25159 fiber.type = REACT_OFFSCREEN_TYPE; 25160 } 25161 25162 fiber.elementType = REACT_OFFSCREEN_TYPE; 25163 fiber.lanes = lanes; 25164 return fiber; 25165} 25166function createFiberFromLegacyHidden(pendingProps, mode, lanes, key) { 25167 var fiber = createFiber(LegacyHiddenComponent, pendingProps, key, mode); // TODO: The LegacyHidden fiber shouldn't have a type. It has a tag. 25168 // This needs to be fixed in getComponentName so that it relies on the tag 25169 // instead. 25170 25171 { 25172 fiber.type = REACT_LEGACY_HIDDEN_TYPE; 25173 } 25174 25175 fiber.elementType = REACT_LEGACY_HIDDEN_TYPE; 25176 fiber.lanes = lanes; 25177 return fiber; 25178} 25179function createFiberFromText(content, mode, lanes) { 25180 var fiber = createFiber(HostText, content, null, mode); 25181 fiber.lanes = lanes; 25182 return fiber; 25183} 25184function createFiberFromHostInstanceForDeletion() { 25185 var fiber = createFiber(HostComponent, null, null, NoMode); // TODO: These should not need a type. 25186 25187 fiber.elementType = 'DELETED'; 25188 fiber.type = 'DELETED'; 25189 return fiber; 25190} 25191function createFiberFromPortal(portal, mode, lanes) { 25192 var pendingProps = portal.children !== null ? portal.children : []; 25193 var fiber = createFiber(HostPortal, pendingProps, portal.key, mode); 25194 fiber.lanes = lanes; 25195 fiber.stateNode = { 25196 containerInfo: portal.containerInfo, 25197 pendingChildren: null, 25198 // Used by persistent updates 25199 implementation: portal.implementation 25200 }; 25201 return fiber; 25202} // Used for stashing WIP properties to replay failed work in DEV. 25203 25204function assignFiberPropertiesInDEV(target, source) { 25205 if (target === null) { 25206 // This Fiber's initial properties will always be overwritten. 25207 // We only use a Fiber to ensure the same hidden class so DEV isn't slow. 25208 target = createFiber(IndeterminateComponent, null, null, NoMode); 25209 } // This is intentionally written as a list of all properties. 25210 // We tried to use Object.assign() instead but this is called in 25211 // the hottest path, and Object.assign() was too slow: 25212 // https://github.com/facebook/react/issues/12502 25213 // This code is DEV-only so size is not a concern. 25214 25215 25216 target.tag = source.tag; 25217 target.key = source.key; 25218 target.elementType = source.elementType; 25219 target.type = source.type; 25220 target.stateNode = source.stateNode; 25221 target.return = source.return; 25222 target.child = source.child; 25223 target.sibling = source.sibling; 25224 target.index = source.index; 25225 target.ref = source.ref; 25226 target.pendingProps = source.pendingProps; 25227 target.memoizedProps = source.memoizedProps; 25228 target.updateQueue = source.updateQueue; 25229 target.memoizedState = source.memoizedState; 25230 target.dependencies = source.dependencies; 25231 target.mode = source.mode; 25232 target.flags = source.flags; 25233 target.nextEffect = source.nextEffect; 25234 target.firstEffect = source.firstEffect; 25235 target.lastEffect = source.lastEffect; 25236 target.lanes = source.lanes; 25237 target.childLanes = source.childLanes; 25238 target.alternate = source.alternate; 25239 25240 { 25241 target.actualDuration = source.actualDuration; 25242 target.actualStartTime = source.actualStartTime; 25243 target.selfBaseDuration = source.selfBaseDuration; 25244 target.treeBaseDuration = source.treeBaseDuration; 25245 } 25246 25247 target._debugID = source._debugID; 25248 target._debugSource = source._debugSource; 25249 target._debugOwner = source._debugOwner; 25250 target._debugNeedsRemount = source._debugNeedsRemount; 25251 target._debugHookTypes = source._debugHookTypes; 25252 return target; 25253} 25254 25255function FiberRootNode(containerInfo, tag, hydrate) { 25256 this.tag = tag; 25257 this.containerInfo = containerInfo; 25258 this.pendingChildren = null; 25259 this.current = null; 25260 this.pingCache = null; 25261 this.finishedWork = null; 25262 this.timeoutHandle = noTimeout; 25263 this.context = null; 25264 this.pendingContext = null; 25265 this.hydrate = hydrate; 25266 this.callbackNode = null; 25267 this.callbackPriority = NoLanePriority; 25268 this.eventTimes = createLaneMap(NoLanes); 25269 this.expirationTimes = createLaneMap(NoTimestamp); 25270 this.pendingLanes = NoLanes; 25271 this.suspendedLanes = NoLanes; 25272 this.pingedLanes = NoLanes; 25273 this.expiredLanes = NoLanes; 25274 this.mutableReadLanes = NoLanes; 25275 this.finishedLanes = NoLanes; 25276 this.entangledLanes = NoLanes; 25277 this.entanglements = createLaneMap(NoLanes); 25278 25279 { 25280 this.mutableSourceEagerHydrationData = null; 25281 } 25282 25283 { 25284 this.interactionThreadID = tracing.unstable_getThreadID(); 25285 this.memoizedInteractions = new Set(); 25286 this.pendingInteractionMap = new Map(); 25287 } 25288 25289 { 25290 switch (tag) { 25291 case BlockingRoot: 25292 this._debugRootType = 'createBlockingRoot()'; 25293 break; 25294 25295 case ConcurrentRoot: 25296 this._debugRootType = 'createRoot()'; 25297 break; 25298 25299 case LegacyRoot: 25300 this._debugRootType = 'createLegacyRoot()'; 25301 break; 25302 } 25303 } 25304} 25305 25306function createFiberRoot(containerInfo, tag, hydrate, hydrationCallbacks) { 25307 var root = new FiberRootNode(containerInfo, tag, hydrate); 25308 // stateNode is any. 25309 25310 25311 var uninitializedFiber = createHostRootFiber(tag); 25312 root.current = uninitializedFiber; 25313 uninitializedFiber.stateNode = root; 25314 initializeUpdateQueue(uninitializedFiber); 25315 return root; 25316} 25317 25318// This ensures that the version used for server rendering matches the one 25319// that is eventually read during hydration. 25320// If they don't match there's a potential tear and a full deopt render is required. 25321 25322function registerMutableSourceForHydration(root, mutableSource) { 25323 var getVersion = mutableSource._getVersion; 25324 var version = getVersion(mutableSource._source); // TODO Clear this data once all pending hydration work is finished. 25325 // Retaining it forever may interfere with GC. 25326 25327 if (root.mutableSourceEagerHydrationData == null) { 25328 root.mutableSourceEagerHydrationData = [mutableSource, version]; 25329 } else { 25330 root.mutableSourceEagerHydrationData.push(mutableSource, version); 25331 } 25332} 25333 25334function createPortal(children, containerInfo, // TODO: figure out the API for cross-renderer implementation. 25335implementation) { 25336 var key = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null; 25337 return { 25338 // This tag allow us to uniquely identify this as a React Portal 25339 $$typeof: REACT_PORTAL_TYPE, 25340 key: key == null ? null : '' + key, 25341 children: children, 25342 containerInfo: containerInfo, 25343 implementation: implementation 25344 }; 25345} 25346 25347var didWarnAboutNestedUpdates; 25348var didWarnAboutFindNodeInStrictMode; 25349 25350{ 25351 didWarnAboutNestedUpdates = false; 25352 didWarnAboutFindNodeInStrictMode = {}; 25353} 25354 25355function getContextForSubtree(parentComponent) { 25356 if (!parentComponent) { 25357 return emptyContextObject; 25358 } 25359 25360 var fiber = get(parentComponent); 25361 var parentContext = findCurrentUnmaskedContext(fiber); 25362 25363 if (fiber.tag === ClassComponent) { 25364 var Component = fiber.type; 25365 25366 if (isContextProvider(Component)) { 25367 return processChildContext(fiber, Component, parentContext); 25368 } 25369 } 25370 25371 return parentContext; 25372} 25373 25374function findHostInstanceWithWarning(component, methodName) { 25375 { 25376 var fiber = get(component); 25377 25378 if (fiber === undefined) { 25379 if (typeof component.render === 'function') { 25380 { 25381 { 25382 throw Error( "Unable to find node on an unmounted component." ); 25383 } 25384 } 25385 } else { 25386 { 25387 { 25388 throw Error( "Argument appears to not be a ReactComponent. Keys: " + Object.keys(component) ); 25389 } 25390 } 25391 } 25392 } 25393 25394 var hostFiber = findCurrentHostFiber(fiber); 25395 25396 if (hostFiber === null) { 25397 return null; 25398 } 25399 25400 if (hostFiber.mode & StrictMode) { 25401 var componentName = getComponentName(fiber.type) || 'Component'; 25402 25403 if (!didWarnAboutFindNodeInStrictMode[componentName]) { 25404 didWarnAboutFindNodeInStrictMode[componentName] = true; 25405 var previousFiber = current; 25406 25407 try { 25408 setCurrentFiber(hostFiber); 25409 25410 if (fiber.mode & StrictMode) { 25411 error('%s is deprecated in StrictMode. ' + '%s was passed an instance of %s which is inside StrictMode. ' + 'Instead, add a ref directly to the element you want to reference. ' + 'Learn more about using refs safely here: ' + 'https://reactjs.org/link/strict-mode-find-node', methodName, methodName, componentName); 25412 } else { 25413 error('%s is deprecated in StrictMode. ' + '%s was passed an instance of %s which renders StrictMode children. ' + 'Instead, add a ref directly to the element you want to reference. ' + 'Learn more about using refs safely here: ' + 'https://reactjs.org/link/strict-mode-find-node', methodName, methodName, componentName); 25414 } 25415 } finally { 25416 // Ideally this should reset to previous but this shouldn't be called in 25417 // render and there's another warning for that anyway. 25418 if (previousFiber) { 25419 setCurrentFiber(previousFiber); 25420 } else { 25421 resetCurrentFiber(); 25422 } 25423 } 25424 } 25425 } 25426 25427 return hostFiber.stateNode; 25428 } 25429} 25430 25431function createContainer(containerInfo, tag, hydrate, hydrationCallbacks) { 25432 return createFiberRoot(containerInfo, tag, hydrate); 25433} 25434function updateContainer(element, container, parentComponent, callback) { 25435 { 25436 onScheduleRoot(container, element); 25437 } 25438 25439 var current$1 = container.current; 25440 var eventTime = requestEventTime(); 25441 25442 { 25443 // $FlowExpectedError - jest isn't a global, and isn't recognized outside of tests 25444 if ('undefined' !== typeof jest) { 25445 warnIfUnmockedScheduler(current$1); 25446 warnIfNotScopedWithMatchingAct(current$1); 25447 } 25448 } 25449 25450 var lane = requestUpdateLane(current$1); 25451 25452 var context = getContextForSubtree(parentComponent); 25453 25454 if (container.context === null) { 25455 container.context = context; 25456 } else { 25457 container.pendingContext = context; 25458 } 25459 25460 { 25461 if (isRendering && current !== null && !didWarnAboutNestedUpdates) { 25462 didWarnAboutNestedUpdates = true; 25463 25464 error('Render methods should be a pure function of props and state; ' + 'triggering nested component updates from render is not allowed. ' + 'If necessary, trigger nested updates in componentDidUpdate.\n\n' + 'Check the render method of %s.', getComponentName(current.type) || 'Unknown'); 25465 } 25466 } 25467 25468 var update = createUpdate(eventTime, lane); // Caution: React DevTools currently depends on this property 25469 // being called "element". 25470 25471 update.payload = { 25472 element: element 25473 }; 25474 callback = callback === undefined ? null : callback; 25475 25476 if (callback !== null) { 25477 { 25478 if (typeof callback !== 'function') { 25479 error('render(...): Expected the last optional `callback` argument to be a ' + 'function. Instead received: %s.', callback); 25480 } 25481 } 25482 25483 update.callback = callback; 25484 } 25485 25486 enqueueUpdate(current$1, update); 25487 scheduleUpdateOnFiber(current$1, lane, eventTime); 25488 return lane; 25489} 25490function getPublicRootInstance(container) { 25491 var containerFiber = container.current; 25492 25493 if (!containerFiber.child) { 25494 return null; 25495 } 25496 25497 switch (containerFiber.child.tag) { 25498 case HostComponent: 25499 return getPublicInstance(containerFiber.child.stateNode); 25500 25501 default: 25502 return containerFiber.child.stateNode; 25503 } 25504} 25505 25506function markRetryLaneImpl(fiber, retryLane) { 25507 var suspenseState = fiber.memoizedState; 25508 25509 if (suspenseState !== null && suspenseState.dehydrated !== null) { 25510 suspenseState.retryLane = higherPriorityLane(suspenseState.retryLane, retryLane); 25511 } 25512} // Increases the priority of thennables when they resolve within this boundary. 25513 25514 25515function markRetryLaneIfNotHydrated(fiber, retryLane) { 25516 markRetryLaneImpl(fiber, retryLane); 25517 var alternate = fiber.alternate; 25518 25519 if (alternate) { 25520 markRetryLaneImpl(alternate, retryLane); 25521 } 25522} 25523 25524function attemptUserBlockingHydration$1(fiber) { 25525 if (fiber.tag !== SuspenseComponent) { 25526 // We ignore HostRoots here because we can't increase 25527 // their priority and they should not suspend on I/O, 25528 // since you have to wrap anything that might suspend in 25529 // Suspense. 25530 return; 25531 } 25532 25533 var eventTime = requestEventTime(); 25534 var lane = InputDiscreteHydrationLane; 25535 scheduleUpdateOnFiber(fiber, lane, eventTime); 25536 markRetryLaneIfNotHydrated(fiber, lane); 25537} 25538function attemptContinuousHydration$1(fiber) { 25539 if (fiber.tag !== SuspenseComponent) { 25540 // We ignore HostRoots here because we can't increase 25541 // their priority and they should not suspend on I/O, 25542 // since you have to wrap anything that might suspend in 25543 // Suspense. 25544 return; 25545 } 25546 25547 var eventTime = requestEventTime(); 25548 var lane = SelectiveHydrationLane; 25549 scheduleUpdateOnFiber(fiber, lane, eventTime); 25550 markRetryLaneIfNotHydrated(fiber, lane); 25551} 25552function attemptHydrationAtCurrentPriority$1(fiber) { 25553 if (fiber.tag !== SuspenseComponent) { 25554 // We ignore HostRoots here because we can't increase 25555 // their priority other than synchronously flush it. 25556 return; 25557 } 25558 25559 var eventTime = requestEventTime(); 25560 var lane = requestUpdateLane(fiber); 25561 scheduleUpdateOnFiber(fiber, lane, eventTime); 25562 markRetryLaneIfNotHydrated(fiber, lane); 25563} 25564function runWithPriority$2(priority, fn) { 25565 25566 try { 25567 setCurrentUpdateLanePriority(priority); 25568 return fn(); 25569 } finally { 25570 } 25571} 25572function findHostInstanceWithNoPortals(fiber) { 25573 var hostFiber = findCurrentHostFiberWithNoPortals(fiber); 25574 25575 if (hostFiber === null) { 25576 return null; 25577 } 25578 25579 if (hostFiber.tag === FundamentalComponent) { 25580 return hostFiber.stateNode.instance; 25581 } 25582 25583 return hostFiber.stateNode; 25584} 25585 25586var shouldSuspendImpl = function (fiber) { 25587 return false; 25588}; 25589 25590function shouldSuspend(fiber) { 25591 return shouldSuspendImpl(fiber); 25592} 25593var overrideHookState = null; 25594var overrideHookStateDeletePath = null; 25595var overrideHookStateRenamePath = null; 25596var overrideProps = null; 25597var overridePropsDeletePath = null; 25598var overridePropsRenamePath = null; 25599var scheduleUpdate = null; 25600var setSuspenseHandler = null; 25601 25602{ 25603 var copyWithDeleteImpl = function (obj, path, index) { 25604 var key = path[index]; 25605 var updated = Array.isArray(obj) ? obj.slice() : _assign({}, obj); 25606 25607 if (index + 1 === path.length) { 25608 if (Array.isArray(updated)) { 25609 updated.splice(key, 1); 25610 } else { 25611 delete updated[key]; 25612 } 25613 25614 return updated; 25615 } // $FlowFixMe number or string is fine here 25616 25617 25618 updated[key] = copyWithDeleteImpl(obj[key], path, index + 1); 25619 return updated; 25620 }; 25621 25622 var copyWithDelete = function (obj, path) { 25623 return copyWithDeleteImpl(obj, path, 0); 25624 }; 25625 25626 var copyWithRenameImpl = function (obj, oldPath, newPath, index) { 25627 var oldKey = oldPath[index]; 25628 var updated = Array.isArray(obj) ? obj.slice() : _assign({}, obj); 25629 25630 if (index + 1 === oldPath.length) { 25631 var newKey = newPath[index]; // $FlowFixMe number or string is fine here 25632 25633 updated[newKey] = updated[oldKey]; 25634 25635 if (Array.isArray(updated)) { 25636 updated.splice(oldKey, 1); 25637 } else { 25638 delete updated[oldKey]; 25639 } 25640 } else { 25641 // $FlowFixMe number or string is fine here 25642 updated[oldKey] = copyWithRenameImpl( // $FlowFixMe number or string is fine here 25643 obj[oldKey], oldPath, newPath, index + 1); 25644 } 25645 25646 return updated; 25647 }; 25648 25649 var copyWithRename = function (obj, oldPath, newPath) { 25650 if (oldPath.length !== newPath.length) { 25651 warn('copyWithRename() expects paths of the same length'); 25652 25653 return; 25654 } else { 25655 for (var i = 0; i < newPath.length - 1; i++) { 25656 if (oldPath[i] !== newPath[i]) { 25657 warn('copyWithRename() expects paths to be the same except for the deepest key'); 25658 25659 return; 25660 } 25661 } 25662 } 25663 25664 return copyWithRenameImpl(obj, oldPath, newPath, 0); 25665 }; 25666 25667 var copyWithSetImpl = function (obj, path, index, value) { 25668 if (index >= path.length) { 25669 return value; 25670 } 25671 25672 var key = path[index]; 25673 var updated = Array.isArray(obj) ? obj.slice() : _assign({}, obj); // $FlowFixMe number or string is fine here 25674 25675 updated[key] = copyWithSetImpl(obj[key], path, index + 1, value); 25676 return updated; 25677 }; 25678 25679 var copyWithSet = function (obj, path, value) { 25680 return copyWithSetImpl(obj, path, 0, value); 25681 }; 25682 25683 var findHook = function (fiber, id) { 25684 // For now, the "id" of stateful hooks is just the stateful hook index. 25685 // This may change in the future with e.g. nested hooks. 25686 var currentHook = fiber.memoizedState; 25687 25688 while (currentHook !== null && id > 0) { 25689 currentHook = currentHook.next; 25690 id--; 25691 } 25692 25693 return currentHook; 25694 }; // Support DevTools editable values for useState and useReducer. 25695 25696 25697 overrideHookState = function (fiber, id, path, value) { 25698 var hook = findHook(fiber, id); 25699 25700 if (hook !== null) { 25701 var newState = copyWithSet(hook.memoizedState, path, value); 25702 hook.memoizedState = newState; 25703 hook.baseState = newState; // We aren't actually adding an update to the queue, 25704 // because there is no update we can add for useReducer hooks that won't trigger an error. 25705 // (There's no appropriate action type for DevTools overrides.) 25706 // As a result though, React will see the scheduled update as a noop and bailout. 25707 // Shallow cloning props works as a workaround for now to bypass the bailout check. 25708 25709 fiber.memoizedProps = _assign({}, fiber.memoizedProps); 25710 scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp); 25711 } 25712 }; 25713 25714 overrideHookStateDeletePath = function (fiber, id, path) { 25715 var hook = findHook(fiber, id); 25716 25717 if (hook !== null) { 25718 var newState = copyWithDelete(hook.memoizedState, path); 25719 hook.memoizedState = newState; 25720 hook.baseState = newState; // We aren't actually adding an update to the queue, 25721 // because there is no update we can add for useReducer hooks that won't trigger an error. 25722 // (There's no appropriate action type for DevTools overrides.) 25723 // As a result though, React will see the scheduled update as a noop and bailout. 25724 // Shallow cloning props works as a workaround for now to bypass the bailout check. 25725 25726 fiber.memoizedProps = _assign({}, fiber.memoizedProps); 25727 scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp); 25728 } 25729 }; 25730 25731 overrideHookStateRenamePath = function (fiber, id, oldPath, newPath) { 25732 var hook = findHook(fiber, id); 25733 25734 if (hook !== null) { 25735 var newState = copyWithRename(hook.memoizedState, oldPath, newPath); 25736 hook.memoizedState = newState; 25737 hook.baseState = newState; // We aren't actually adding an update to the queue, 25738 // because there is no update we can add for useReducer hooks that won't trigger an error. 25739 // (There's no appropriate action type for DevTools overrides.) 25740 // As a result though, React will see the scheduled update as a noop and bailout. 25741 // Shallow cloning props works as a workaround for now to bypass the bailout check. 25742 25743 fiber.memoizedProps = _assign({}, fiber.memoizedProps); 25744 scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp); 25745 } 25746 }; // Support DevTools props for function components, forwardRef, memo, host components, etc. 25747 25748 25749 overrideProps = function (fiber, path, value) { 25750 fiber.pendingProps = copyWithSet(fiber.memoizedProps, path, value); 25751 25752 if (fiber.alternate) { 25753 fiber.alternate.pendingProps = fiber.pendingProps; 25754 } 25755 25756 scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp); 25757 }; 25758 25759 overridePropsDeletePath = function (fiber, path) { 25760 fiber.pendingProps = copyWithDelete(fiber.memoizedProps, path); 25761 25762 if (fiber.alternate) { 25763 fiber.alternate.pendingProps = fiber.pendingProps; 25764 } 25765 25766 scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp); 25767 }; 25768 25769 overridePropsRenamePath = function (fiber, oldPath, newPath) { 25770 fiber.pendingProps = copyWithRename(fiber.memoizedProps, oldPath, newPath); 25771 25772 if (fiber.alternate) { 25773 fiber.alternate.pendingProps = fiber.pendingProps; 25774 } 25775 25776 scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp); 25777 }; 25778 25779 scheduleUpdate = function (fiber) { 25780 scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp); 25781 }; 25782 25783 setSuspenseHandler = function (newShouldSuspendImpl) { 25784 shouldSuspendImpl = newShouldSuspendImpl; 25785 }; 25786} 25787 25788function findHostInstanceByFiber(fiber) { 25789 var hostFiber = findCurrentHostFiber(fiber); 25790 25791 if (hostFiber === null) { 25792 return null; 25793 } 25794 25795 return hostFiber.stateNode; 25796} 25797 25798function emptyFindFiberByHostInstance(instance) { 25799 return null; 25800} 25801 25802function getCurrentFiberForDevTools() { 25803 return current; 25804} 25805 25806function injectIntoDevTools(devToolsConfig) { 25807 var findFiberByHostInstance = devToolsConfig.findFiberByHostInstance; 25808 var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher; 25809 return injectInternals({ 25810 bundleType: devToolsConfig.bundleType, 25811 version: devToolsConfig.version, 25812 rendererPackageName: devToolsConfig.rendererPackageName, 25813 rendererConfig: devToolsConfig.rendererConfig, 25814 overrideHookState: overrideHookState, 25815 overrideHookStateDeletePath: overrideHookStateDeletePath, 25816 overrideHookStateRenamePath: overrideHookStateRenamePath, 25817 overrideProps: overrideProps, 25818 overridePropsDeletePath: overridePropsDeletePath, 25819 overridePropsRenamePath: overridePropsRenamePath, 25820 setSuspenseHandler: setSuspenseHandler, 25821 scheduleUpdate: scheduleUpdate, 25822 currentDispatcherRef: ReactCurrentDispatcher, 25823 findHostInstanceByFiber: findHostInstanceByFiber, 25824 findFiberByHostInstance: findFiberByHostInstance || emptyFindFiberByHostInstance, 25825 // React Refresh 25826 findHostInstancesForRefresh: findHostInstancesForRefresh , 25827 scheduleRefresh: scheduleRefresh , 25828 scheduleRoot: scheduleRoot , 25829 setRefreshHandler: setRefreshHandler , 25830 // Enables DevTools to append owner stacks to error messages in DEV mode. 25831 getCurrentFiber: getCurrentFiberForDevTools 25832 }); 25833} 25834 25835function ReactDOMRoot(container, options) { 25836 this._internalRoot = createRootImpl(container, ConcurrentRoot, options); 25837} 25838 25839function ReactDOMBlockingRoot(container, tag, options) { 25840 this._internalRoot = createRootImpl(container, tag, options); 25841} 25842 25843ReactDOMRoot.prototype.render = ReactDOMBlockingRoot.prototype.render = function (children) { 25844 var root = this._internalRoot; 25845 25846 { 25847 if (typeof arguments[1] === 'function') { 25848 error('render(...): does not support the second callback argument. ' + 'To execute a side effect after rendering, declare it in a component body with useEffect().'); 25849 } 25850 25851 var container = root.containerInfo; 25852 25853 if (container.nodeType !== COMMENT_NODE) { 25854 var hostInstance = findHostInstanceWithNoPortals(root.current); 25855 25856 if (hostInstance) { 25857 if (hostInstance.parentNode !== container) { 25858 error('render(...): It looks like the React-rendered content of the ' + 'root container was removed without using React. This is not ' + 'supported and will cause errors. Instead, call ' + "root.unmount() to empty a root's container."); 25859 } 25860 } 25861 } 25862 } 25863 25864 updateContainer(children, root, null, null); 25865}; 25866 25867ReactDOMRoot.prototype.unmount = ReactDOMBlockingRoot.prototype.unmount = function () { 25868 { 25869 if (typeof arguments[0] === 'function') { 25870 error('unmount(...): does not support a callback argument. ' + 'To execute a side effect after rendering, declare it in a component body with useEffect().'); 25871 } 25872 } 25873 25874 var root = this._internalRoot; 25875 var container = root.containerInfo; 25876 updateContainer(null, root, null, function () { 25877 unmarkContainerAsRoot(container); 25878 }); 25879}; 25880 25881function createRootImpl(container, tag, options) { 25882 // Tag is either LegacyRoot or Concurrent Root 25883 var hydrate = options != null && options.hydrate === true; 25884 var hydrationCallbacks = options != null && options.hydrationOptions || null; 25885 var mutableSources = options != null && options.hydrationOptions != null && options.hydrationOptions.mutableSources || null; 25886 var root = createContainer(container, tag, hydrate); 25887 markContainerAsRoot(root.current, container); 25888 var containerNodeType = container.nodeType; 25889 25890 { 25891 var rootContainerElement = container.nodeType === COMMENT_NODE ? container.parentNode : container; 25892 listenToAllSupportedEvents(rootContainerElement); 25893 } 25894 25895 if (mutableSources) { 25896 for (var i = 0; i < mutableSources.length; i++) { 25897 var mutableSource = mutableSources[i]; 25898 registerMutableSourceForHydration(root, mutableSource); 25899 } 25900 } 25901 25902 return root; 25903} 25904function createLegacyRoot(container, options) { 25905 return new ReactDOMBlockingRoot(container, LegacyRoot, options); 25906} 25907function isValidContainer(node) { 25908 return !!(node && (node.nodeType === ELEMENT_NODE || node.nodeType === DOCUMENT_NODE || node.nodeType === DOCUMENT_FRAGMENT_NODE || node.nodeType === COMMENT_NODE && node.nodeValue === ' react-mount-point-unstable ')); 25909} 25910 25911var ReactCurrentOwner$3 = ReactSharedInternals.ReactCurrentOwner; 25912var topLevelUpdateWarnings; 25913var warnedAboutHydrateAPI = false; 25914 25915{ 25916 topLevelUpdateWarnings = function (container) { 25917 if (container._reactRootContainer && container.nodeType !== COMMENT_NODE) { 25918 var hostInstance = findHostInstanceWithNoPortals(container._reactRootContainer._internalRoot.current); 25919 25920 if (hostInstance) { 25921 if (hostInstance.parentNode !== container) { 25922 error('render(...): It looks like the React-rendered content of this ' + 'container was removed without using React. This is not ' + 'supported and will cause errors. Instead, call ' + 'ReactDOM.unmountComponentAtNode to empty a container.'); 25923 } 25924 } 25925 } 25926 25927 var isRootRenderedBySomeReact = !!container._reactRootContainer; 25928 var rootEl = getReactRootElementInContainer(container); 25929 var hasNonRootReactChild = !!(rootEl && getInstanceFromNode(rootEl)); 25930 25931 if (hasNonRootReactChild && !isRootRenderedBySomeReact) { 25932 error('render(...): Replacing React-rendered children with a new root ' + 'component. If you intended to update the children of this node, ' + 'you should instead have the existing children update their state ' + 'and render the new components instead of calling ReactDOM.render.'); 25933 } 25934 25935 if (container.nodeType === ELEMENT_NODE && container.tagName && container.tagName.toUpperCase() === 'BODY') { 25936 error('render(): Rendering components directly into document.body is ' + 'discouraged, since its children are often manipulated by third-party ' + 'scripts and browser extensions. This may lead to subtle ' + 'reconciliation issues. Try rendering into a container element created ' + 'for your app.'); 25937 } 25938 }; 25939} 25940 25941function getReactRootElementInContainer(container) { 25942 if (!container) { 25943 return null; 25944 } 25945 25946 if (container.nodeType === DOCUMENT_NODE) { 25947 return container.documentElement; 25948 } else { 25949 return container.firstChild; 25950 } 25951} 25952 25953function shouldHydrateDueToLegacyHeuristic(container) { 25954 var rootElement = getReactRootElementInContainer(container); 25955 return !!(rootElement && rootElement.nodeType === ELEMENT_NODE && rootElement.hasAttribute(ROOT_ATTRIBUTE_NAME)); 25956} 25957 25958function legacyCreateRootFromDOMContainer(container, forceHydrate) { 25959 var shouldHydrate = forceHydrate || shouldHydrateDueToLegacyHeuristic(container); // First clear any existing content. 25960 25961 if (!shouldHydrate) { 25962 var warned = false; 25963 var rootSibling; 25964 25965 while (rootSibling = container.lastChild) { 25966 { 25967 if (!warned && rootSibling.nodeType === ELEMENT_NODE && rootSibling.hasAttribute(ROOT_ATTRIBUTE_NAME)) { 25968 warned = true; 25969 25970 error('render(): Target node has markup rendered by React, but there ' + 'are unrelated nodes as well. This is most commonly caused by ' + 'white-space inserted around server-rendered markup.'); 25971 } 25972 } 25973 25974 container.removeChild(rootSibling); 25975 } 25976 } 25977 25978 { 25979 if (shouldHydrate && !forceHydrate && !warnedAboutHydrateAPI) { 25980 warnedAboutHydrateAPI = true; 25981 25982 warn('render(): Calling ReactDOM.render() to hydrate server-rendered markup ' + 'will stop working in React v18. Replace the ReactDOM.render() call ' + 'with ReactDOM.hydrate() if you want React to attach to the server HTML.'); 25983 } 25984 } 25985 25986 return createLegacyRoot(container, shouldHydrate ? { 25987 hydrate: true 25988 } : undefined); 25989} 25990 25991function warnOnInvalidCallback$1(callback, callerName) { 25992 { 25993 if (callback !== null && typeof callback !== 'function') { 25994 error('%s(...): Expected the last optional `callback` argument to be a ' + 'function. Instead received: %s.', callerName, callback); 25995 } 25996 } 25997} 25998 25999function legacyRenderSubtreeIntoContainer(parentComponent, children, container, forceHydrate, callback) { 26000 { 26001 topLevelUpdateWarnings(container); 26002 warnOnInvalidCallback$1(callback === undefined ? null : callback, 'render'); 26003 } // TODO: Without `any` type, Flow says "Property cannot be accessed on any 26004 // member of intersection type." Whyyyyyy. 26005 26006 26007 var root = container._reactRootContainer; 26008 var fiberRoot; 26009 26010 if (!root) { 26011 // Initial mount 26012 root = container._reactRootContainer = legacyCreateRootFromDOMContainer(container, forceHydrate); 26013 fiberRoot = root._internalRoot; 26014 26015 if (typeof callback === 'function') { 26016 var originalCallback = callback; 26017 26018 callback = function () { 26019 var instance = getPublicRootInstance(fiberRoot); 26020 originalCallback.call(instance); 26021 }; 26022 } // Initial mount should not be batched. 26023 26024 26025 unbatchedUpdates(function () { 26026 updateContainer(children, fiberRoot, parentComponent, callback); 26027 }); 26028 } else { 26029 fiberRoot = root._internalRoot; 26030 26031 if (typeof callback === 'function') { 26032 var _originalCallback = callback; 26033 26034 callback = function () { 26035 var instance = getPublicRootInstance(fiberRoot); 26036 26037 _originalCallback.call(instance); 26038 }; 26039 } // Update 26040 26041 26042 updateContainer(children, fiberRoot, parentComponent, callback); 26043 } 26044 26045 return getPublicRootInstance(fiberRoot); 26046} 26047 26048function findDOMNode(componentOrElement) { 26049 { 26050 var owner = ReactCurrentOwner$3.current; 26051 26052 if (owner !== null && owner.stateNode !== null) { 26053 var warnedAboutRefsInRender = owner.stateNode._warnedAboutRefsInRender; 26054 26055 if (!warnedAboutRefsInRender) { 26056 error('%s is accessing findDOMNode inside its render(). ' + 'render() should be a pure function of props and state. It should ' + 'never access something that requires stale data from the previous ' + 'render, such as refs. Move this logic to componentDidMount and ' + 'componentDidUpdate instead.', getComponentName(owner.type) || 'A component'); 26057 } 26058 26059 owner.stateNode._warnedAboutRefsInRender = true; 26060 } 26061 } 26062 26063 if (componentOrElement == null) { 26064 return null; 26065 } 26066 26067 if (componentOrElement.nodeType === ELEMENT_NODE) { 26068 return componentOrElement; 26069 } 26070 26071 { 26072 return findHostInstanceWithWarning(componentOrElement, 'findDOMNode'); 26073 } 26074} 26075function hydrate(element, container, callback) { 26076 if (!isValidContainer(container)) { 26077 { 26078 throw Error( "Target container is not a DOM element." ); 26079 } 26080 } 26081 26082 { 26083 var isModernRoot = isContainerMarkedAsRoot(container) && container._reactRootContainer === undefined; 26084 26085 if (isModernRoot) { 26086 error('You are calling ReactDOM.hydrate() on a container that was previously ' + 'passed to ReactDOM.createRoot(). This is not supported. ' + 'Did you mean to call createRoot(container, {hydrate: true}).render(element)?'); 26087 } 26088 } // TODO: throw or warn if we couldn't hydrate? 26089 26090 26091 return legacyRenderSubtreeIntoContainer(null, element, container, true, callback); 26092} 26093function render(element, container, callback) { 26094 if (!isValidContainer(container)) { 26095 { 26096 throw Error( "Target container is not a DOM element." ); 26097 } 26098 } 26099 26100 { 26101 var isModernRoot = isContainerMarkedAsRoot(container) && container._reactRootContainer === undefined; 26102 26103 if (isModernRoot) { 26104 error('You are calling ReactDOM.render() on a container that was previously ' + 'passed to ReactDOM.createRoot(). This is not supported. ' + 'Did you mean to call root.render(element)?'); 26105 } 26106 } 26107 26108 return legacyRenderSubtreeIntoContainer(null, element, container, false, callback); 26109} 26110function unstable_renderSubtreeIntoContainer(parentComponent, element, containerNode, callback) { 26111 if (!isValidContainer(containerNode)) { 26112 { 26113 throw Error( "Target container is not a DOM element." ); 26114 } 26115 } 26116 26117 if (!(parentComponent != null && has(parentComponent))) { 26118 { 26119 throw Error( "parentComponent must be a valid React Component" ); 26120 } 26121 } 26122 26123 return legacyRenderSubtreeIntoContainer(parentComponent, element, containerNode, false, callback); 26124} 26125function unmountComponentAtNode(container) { 26126 if (!isValidContainer(container)) { 26127 { 26128 throw Error( "unmountComponentAtNode(...): Target container is not a DOM element." ); 26129 } 26130 } 26131 26132 { 26133 var isModernRoot = isContainerMarkedAsRoot(container) && container._reactRootContainer === undefined; 26134 26135 if (isModernRoot) { 26136 error('You are calling ReactDOM.unmountComponentAtNode() on a container that was previously ' + 'passed to ReactDOM.createRoot(). This is not supported. Did you mean to call root.unmount()?'); 26137 } 26138 } 26139 26140 if (container._reactRootContainer) { 26141 { 26142 var rootEl = getReactRootElementInContainer(container); 26143 var renderedByDifferentReact = rootEl && !getInstanceFromNode(rootEl); 26144 26145 if (renderedByDifferentReact) { 26146 error("unmountComponentAtNode(): The node you're attempting to unmount " + 'was rendered by another copy of React.'); 26147 } 26148 } // Unmount should not be batched. 26149 26150 26151 unbatchedUpdates(function () { 26152 legacyRenderSubtreeIntoContainer(null, null, container, false, function () { 26153 // $FlowFixMe This should probably use `delete container._reactRootContainer` 26154 container._reactRootContainer = null; 26155 unmarkContainerAsRoot(container); 26156 }); 26157 }); // If you call unmountComponentAtNode twice in quick succession, you'll 26158 // get `true` twice. That's probably fine? 26159 26160 return true; 26161 } else { 26162 { 26163 var _rootEl = getReactRootElementInContainer(container); 26164 26165 var hasNonRootReactChild = !!(_rootEl && getInstanceFromNode(_rootEl)); // Check if the container itself is a React root node. 26166 26167 var isContainerReactRoot = container.nodeType === ELEMENT_NODE && isValidContainer(container.parentNode) && !!container.parentNode._reactRootContainer; 26168 26169 if (hasNonRootReactChild) { 26170 error("unmountComponentAtNode(): The node you're attempting to unmount " + 'was rendered by React and is not a top-level container. %s', isContainerReactRoot ? 'You may have accidentally passed in a React root node instead ' + 'of its container.' : 'Instead, have the parent component update its state and ' + 'rerender in order to remove this component.'); 26171 } 26172 } 26173 26174 return false; 26175 } 26176} 26177 26178setAttemptUserBlockingHydration(attemptUserBlockingHydration$1); 26179setAttemptContinuousHydration(attemptContinuousHydration$1); 26180setAttemptHydrationAtCurrentPriority(attemptHydrationAtCurrentPriority$1); 26181setAttemptHydrationAtPriority(runWithPriority$2); 26182var didWarnAboutUnstableCreatePortal = false; 26183 26184{ 26185 if (typeof Map !== 'function' || // $FlowIssue Flow incorrectly thinks Map has no prototype 26186 Map.prototype == null || typeof Map.prototype.forEach !== 'function' || typeof Set !== 'function' || // $FlowIssue Flow incorrectly thinks Set has no prototype 26187 Set.prototype == null || typeof Set.prototype.clear !== 'function' || typeof Set.prototype.forEach !== 'function') { 26188 error('React depends on Map and Set built-in types. Make sure that you load a ' + 'polyfill in older browsers. https://reactjs.org/link/react-polyfills'); 26189 } 26190} 26191 26192setRestoreImplementation(restoreControlledState$3); 26193setBatchingImplementation(batchedUpdates$1, discreteUpdates$1, flushDiscreteUpdates, batchedEventUpdates$1); 26194 26195function createPortal$1(children, container) { 26196 var key = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; 26197 26198 if (!isValidContainer(container)) { 26199 { 26200 throw Error( "Target container is not a DOM element." ); 26201 } 26202 } // TODO: pass ReactDOM portal implementation as third argument 26203 // $FlowFixMe The Flow type is opaque but there's no way to actually create it. 26204 26205 26206 return createPortal(children, container, null, key); 26207} 26208 26209function renderSubtreeIntoContainer(parentComponent, element, containerNode, callback) { 26210 26211 return unstable_renderSubtreeIntoContainer(parentComponent, element, containerNode, callback); 26212} 26213 26214function unstable_createPortal(children, container) { 26215 var key = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; 26216 26217 { 26218 if (!didWarnAboutUnstableCreatePortal) { 26219 didWarnAboutUnstableCreatePortal = true; 26220 26221 warn('The ReactDOM.unstable_createPortal() alias has been deprecated, ' + 'and will be removed in React 18+. Update your code to use ' + 'ReactDOM.createPortal() instead. It has the exact same API, ' + 'but without the "unstable_" prefix.'); 26222 } 26223 } 26224 26225 return createPortal$1(children, container, key); 26226} 26227 26228var Internals = { 26229 // Keep in sync with ReactTestUtils.js, and ReactTestUtilsAct.js. 26230 // This is an array for better minification. 26231 Events: [getInstanceFromNode, getNodeFromInstance, getFiberCurrentPropsFromNode, enqueueStateRestore, restoreStateIfNeeded, flushPassiveEffects, // TODO: This is related to `act`, not events. Move to separate key? 26232 IsThisRendererActing] 26233}; 26234var foundDevTools = injectIntoDevTools({ 26235 findFiberByHostInstance: getClosestInstanceFromNode, 26236 bundleType: 1 , 26237 version: ReactVersion, 26238 rendererPackageName: 'react-dom' 26239}); 26240 26241{ 26242 if (!foundDevTools && canUseDOM && window.top === window.self) { 26243 // If we're in Chrome or Firefox, provide a download link if not installed. 26244 if (navigator.userAgent.indexOf('Chrome') > -1 && navigator.userAgent.indexOf('Edge') === -1 || navigator.userAgent.indexOf('Firefox') > -1) { 26245 var protocol = window.location.protocol; // Don't warn in exotic cases like chrome-extension://. 26246 26247 if (/^(https?|file):$/.test(protocol)) { 26248 // eslint-disable-next-line react-internal/no-production-logging 26249 console.info('%cDownload the React DevTools ' + 'for a better development experience: ' + 'https://reactjs.org/link/react-devtools' + (protocol === 'file:' ? '\nYou might need to use a local HTTP server (instead of file://): ' + 'https://reactjs.org/link/react-devtools-faq' : ''), 'font-weight:bold'); 26250 } 26251 } 26252 } 26253} 26254 26255exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = Internals; 26256exports.createPortal = createPortal$1; 26257exports.findDOMNode = findDOMNode; 26258exports.flushSync = flushSync; 26259exports.hydrate = hydrate; 26260exports.render = render; 26261exports.unmountComponentAtNode = unmountComponentAtNode; 26262exports.unstable_batchedUpdates = batchedUpdates$1; 26263exports.unstable_createPortal = unstable_createPortal; 26264exports.unstable_renderSubtreeIntoContainer = renderSubtreeIntoContainer; 26265exports.version = ReactVersion; 26266 })(); 26267} 26268 26269 26270/***/ }), 26271
vendor: 1,938 bytes, lines 26272-26315
26272/***/ "./.yarn/__virtual__/react-dom-virtual-fc19a1cf20/0/cache/react-dom-npm-17.0.1-588d0088ca-baaeb735ad.zip/node_modules/react-dom/index.js": 26273/*!***********************************************************************************************************************************************!*\ 26274 !*** ./.yarn/__virtual__/react-dom-virtual-fc19a1cf20/0/cache/react-dom-npm-17.0.1-588d0088ca-baaeb735ad.zip/node_modules/react-dom/index.js ***! 26275 \***********************************************************************************************************************************************/ 26276/***/ ((module, __unused_webpack_exports, __webpack_require__) => { 26277 26278"use strict"; 26279 26280 26281function checkDCE() { 26282 /* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */ 26283 if ( 26284 typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ === 'undefined' || 26285 typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE !== 'function' 26286 ) { 26287 return; 26288 } 26289 if (true) { 26290 // This branch is unreachable because this function is only called 26291 // in production, but the condition is true only in development. 26292 // Therefore if the branch is still here, dead code elimination wasn't 26293 // properly applied. 26294 // Don't change the message. React DevTools relies on it. Also make sure 26295 // this message doesn't occur elsewhere in this function, or it will cause 26296 // a false positive. 26297 throw new Error('^_^'); 26298 } 26299 try { 26300 // Verify that the code above has been dead code eliminated (DCE'd). 26301 __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(checkDCE); 26302 } catch (err) { 26303 // DevTools shouldn't crash React, no matter what. 26304 // We should still report in case we break this code. 26305 console.error(err); 26306 } 26307} 26308 26309if (false) {} else { 26310 module.exports = __webpack_require__(/*! ./cjs/react-dom.development.js */ "./.yarn/__virtual__/react-dom-virtual-fc19a1cf20/0/cache/react-dom-npm-17.0.1-588d0088ca-baaeb735ad.zip/node_modules/react-dom/cjs/react-dom.development.js"); 26311} 26312 26313 26314/***/ }), 26315
vendor: 6,860 bytes, lines 26316-26511
26316/***/ "./.yarn/__virtual__/react-error-boundary-virtual-1d3c98507c/0/cache/react-error-boundary-npm-3.1.4-2310dba89e-7418637bf3.zip/node_modules/react-error-boundary/dist/react-error-boundary.umd.js": 26317/*!*******************************************************************************************************************************************************************************************************!*\ 26318 !*** ./.yarn/__virtual__/react-error-boundary-virtual-1d3c98507c/0/cache/react-error-boundary-npm-3.1.4-2310dba89e-7418637bf3.zip/node_modules/react-error-boundary/dist/react-error-boundary.umd.js ***! 26319 \*******************************************************************************************************************************************************************************************************/ 26320/***/ (function(__unused_webpack_module, exports, __webpack_require__) { 26321 26322(function (global, factory) { 26323 true ? factory(exports, __webpack_require__(/*! react */ "./.yarn/cache/react-npm-17.0.1-98658812fc-23ada2f8fe.zip/node_modules/react/index.js")) : 26324 0; 26325})(this, (function (exports, React) { 'use strict'; 26326 26327 function _interopNamespace(e) { 26328 if (e && e.__esModule) return e; 26329 var n = Object.create(null); 26330 if (e) { 26331 Object.keys(e).forEach(function (k) { 26332 if (k !== 'default') { 26333 var d = Object.getOwnPropertyDescriptor(e, k); 26334 Object.defineProperty(n, k, d.get ? d : { 26335 enumerable: true, 26336 get: function () { return e[k]; } 26337 }); 26338 } 26339 }); 26340 } 26341 n["default"] = e; 26342 return Object.freeze(n); 26343 } 26344 26345 var React__namespace = /*#__PURE__*/_interopNamespace(React); 26346 26347 function _setPrototypeOf(o, p) { 26348 _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { 26349 o.__proto__ = p; 26350 return o; 26351 }; 26352 26353 return _setPrototypeOf(o, p); 26354 } 26355 26356 function _inheritsLoose(subClass, superClass) { 26357 subClass.prototype = Object.create(superClass.prototype); 26358 subClass.prototype.constructor = subClass; 26359 _setPrototypeOf(subClass, superClass); 26360 } 26361 26362 var changedArray = function changedArray(a, b) { 26363 if (a === void 0) { 26364 a = []; 26365 } 26366 26367 if (b === void 0) { 26368 b = []; 26369 } 26370 26371 return a.length !== b.length || a.some(function (item, index) { 26372 return !Object.is(item, b[index]); 26373 }); 26374 }; 26375 26376 var initialState = { 26377 error: null 26378 }; 26379 26380 var ErrorBoundary = /*#__PURE__*/function (_React$Component) { 26381 _inheritsLoose(ErrorBoundary, _React$Component); 26382 26383 function ErrorBoundary() { 26384 var _this; 26385 26386 for (var _len = arguments.length, _args = new Array(_len), _key = 0; _key < _len; _key++) { 26387 _args[_key] = arguments[_key]; 26388 } 26389 26390 _this = _React$Component.call.apply(_React$Component, [this].concat(_args)) || this; 26391 _this.state = initialState; 26392 26393 _this.resetErrorBoundary = function () { 26394 var _this$props; 26395 26396 for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { 26397 args[_key2] = arguments[_key2]; 26398 } 26399 26400 _this.props.onReset == null ? void 0 : (_this$props = _this.props).onReset.apply(_this$props, args); 26401 26402 _this.reset(); 26403 }; 26404 26405 return _this; 26406 } 26407 26408 ErrorBoundary.getDerivedStateFromError = function getDerivedStateFromError(error) { 26409 return { 26410 error: error 26411 }; 26412 }; 26413 26414 var _proto = ErrorBoundary.prototype; 26415 26416 _proto.reset = function reset() { 26417 this.setState(initialState); 26418 }; 26419 26420 _proto.componentDidCatch = function componentDidCatch(error, info) { 26421 var _this$props$onError, _this$props2; 26422 26423 (_this$props$onError = (_this$props2 = this.props).onError) == null ? void 0 : _this$props$onError.call(_this$props2, error, info); 26424 }; 26425 26426 _proto.componentDidUpdate = function componentDidUpdate(prevProps, prevState) { 26427 var error = this.state.error; 26428 var resetKeys = this.props.resetKeys; // There's an edge case where if the thing that triggered the error 26429 // happens to *also* be in the resetKeys array, we'd end up resetting 26430 // the error boundary immediately. This would likely trigger a second 26431 // error to be thrown. 26432 // So we make sure that we don't check the resetKeys on the first call 26433 // of cDU after the error is set 26434 26435 if (error !== null && prevState.error !== null && changedArray(prevProps.resetKeys, resetKeys)) { 26436 var _this$props$onResetKe, _this$props3; 26437 26438 (_this$props$onResetKe = (_this$props3 = this.props).onResetKeysChange) == null ? void 0 : _this$props$onResetKe.call(_this$props3, prevProps.resetKeys, resetKeys); 26439 this.reset(); 26440 } 26441 }; 26442 26443 _proto.render = function render() { 26444 var error = this.state.error; 26445 var _this$props4 = this.props, 26446 fallbackRender = _this$props4.fallbackRender, 26447 FallbackComponent = _this$props4.FallbackComponent, 26448 fallback = _this$props4.fallback; 26449 26450 if (error !== null) { 26451 var _props = { 26452 error: error, 26453 resetErrorBoundary: this.resetErrorBoundary 26454 }; 26455 26456 if ( /*#__PURE__*/React__namespace.isValidElement(fallback)) { 26457 return fallback; 26458 } else if (typeof fallbackRender === 'function') { 26459 return fallbackRender(_props); 26460 } else if (FallbackComponent) { 26461 return /*#__PURE__*/React__namespace.createElement(FallbackComponent, _props); 26462 } else { 26463 throw new Error('react-error-boundary requires either a fallback, fallbackRender, or FallbackComponent prop'); 26464 } 26465 } 26466 26467 return this.props.children; 26468 }; 26469 26470 return ErrorBoundary; 26471 }(React__namespace.Component); 26472 26473 function withErrorBoundary(Component, errorBoundaryProps) { 26474 var Wrapped = function Wrapped(props) { 26475 return /*#__PURE__*/React__namespace.createElement(ErrorBoundary, errorBoundaryProps, /*#__PURE__*/React__namespace.createElement(Component, props)); 26476 }; // Format for display in DevTools 26477 26478 26479 var name = Component.displayName || Component.name || 'Unknown'; 26480 Wrapped.displayName = "withErrorBoundary(" + name + ")"; 26481 return Wrapped; 26482 } 26483 26484 function useErrorHandler(givenError) { 26485 var _React$useState = React__namespace.useState(null), 26486 error = _React$useState[0], 26487 setError = _React$useState[1]; 26488 26489 if (givenError != null) throw givenError; 26490 if (error != null) throw error; 26491 return setError; 26492 } 26493 /* 26494 eslint 26495 @typescript-eslint/sort-type-union-intersection-members: "off", 26496 @typescript-eslint/no-throw-literal: "off", 26497 @typescript-eslint/prefer-nullish-coalescing: "off" 26498 */ 26499 26500 exports.ErrorBoundary = ErrorBoundary; 26501 exports.useErrorHandler = useErrorHandler; 26502 exports.withErrorBoundary = withErrorBoundary; 26503 26504 Object.defineProperty(exports, '__esModule', { value: true }); 26505 26506})); 26507//# sourceMappingURL=react-error-boundary.umd.js.map 26508 26509 26510/***/ }), 26511
vendor: 4,014 bytes, lines 26512-26611
26512/***/ "./.yarn/__virtual__/react-query-virtual-cd72c42dd3/0/cache/react-query-npm-3.12.0-415d3b7722-bd1075ac15.zip/node_modules/react-query/es/core/focusManager.js": 26513/*!********************************************************************************************************************************************************************!*\ 26514 !*** ./.yarn/__virtual__/react-query-virtual-cd72c42dd3/0/cache/react-query-npm-3.12.0-415d3b7722-bd1075ac15.zip/node_modules/react-query/es/core/focusManager.js ***! 26515 \********************************************************************************************************************************************************************/ 26516/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { 26517 26518"use strict"; 26519__webpack_require__.r(__webpack_exports__); 26520/* harmony export */ __webpack_require__.d(__webpack_exports__, { 26521/* harmony export */ "focusManager": () => (/* binding */ focusManager) 26522/* harmony export */ }); 26523/* harmony import */ var _babel_runtime_helpers_esm_inheritsLoose__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @babel/runtime/helpers/esm/inheritsLoose */ "./.yarn/cache/@babel-runtime-npm-7.18.9-28ca6b5f61-254985e146.zip/node_modules/@babel/runtime/helpers/esm/inheritsLoose.js"); 26524/* harmony import */ var _subscribable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./subscribable */ "./.yarn/__virtual__/react-query-virtual-cd72c42dd3/0/cache/react-query-npm-3.12.0-415d3b7722-bd1075ac15.zip/node_modules/react-query/es/core/subscribable.js"); 26525/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./utils */ "./.yarn/__virtual__/react-query-virtual-cd72c42dd3/0/cache/react-query-npm-3.12.0-415d3b7722-bd1075ac15.zip/node_modules/react-query/es/core/utils.js"); 26526 26527 26528 26529 26530var FocusManager = /*#__PURE__*/function (_Subscribable) { 26531 (0,_babel_runtime_helpers_esm_inheritsLoose__WEBPACK_IMPORTED_MODULE_0__["default"])(FocusManager, _Subscribable); 26532 26533 function FocusManager() { 26534 return _Subscribable.apply(this, arguments) || this; 26535 } 26536 26537 var _proto = FocusManager.prototype; 26538 26539 _proto.onSubscribe = function onSubscribe() { 26540 if (!this.removeEventListener) { 26541 this.setDefaultEventListener(); 26542 } 26543 }; 26544 26545 _proto.setEventListener = function setEventListener(setup) { 26546 var _this = this; 26547 26548 if (this.removeEventListener) { 26549 this.removeEventListener(); 26550 } 26551 26552 this.removeEventListener = setup(function (focused) { 26553 if (typeof focused === 'boolean') { 26554 _this.setFocused(focused); 26555 } else { 26556 _this.onFocus(); 26557 } 26558 }); 26559 }; 26560 26561 _proto.setFocused = function setFocused(focused) { 26562 this.focused = focused; 26563 26564 if (focused) { 26565 this.onFocus(); 26566 } 26567 }; 26568 26569 _proto.onFocus = function onFocus() { 26570 this.listeners.forEach(function (listener) { 26571 listener(); 26572 }); 26573 }; 26574 26575 _proto.isFocused = function isFocused() { 26576 if (typeof this.focused === 'boolean') { 26577 return this.focused; 26578 } // document global can be unavailable in react native 26579 26580 26581 if (typeof document === 'undefined') { 26582 return true; 26583 } 26584 26585 return [undefined, 'visible', 'prerender'].includes(document.visibilityState); 26586 }; 26587 26588 _proto.setDefaultEventListener = function setDefaultEventListener() { 26589 var _window; 26590 26591 if (!_utils__WEBPACK_IMPORTED_MODULE_1__.isServer && ((_window = window) == null ? void 0 : _window.addEventListener)) { 26592 this.setEventListener(function (onFocus) { 26593 // Listen to visibillitychange and focus 26594 window.addEventListener('visibilitychange', onFocus, false); 26595 window.addEventListener('focus', onFocus, false); 26596 return function () { 26597 // Be sure to unsubscribe if a new handler is set 26598 window.removeEventListener('visibilitychange', onFocus); 26599 window.removeEventListener('focus', onFocus); 26600 }; 26601 }); 26602 } 26603 }; 26604 26605 return FocusManager; 26606}(_subscribable__WEBPACK_IMPORTED_MODULE_2__.Subscribable); 26607 26608var focusManager = new FocusManager(); 26609 26610/***/ }), 26611
vendor: 6,854 bytes, lines 26612-26764
26612/***/ "./.yarn/__virtual__/react-query-virtual-cd72c42dd3/0/cache/react-query-npm-3.12.0-415d3b7722-bd1075ac15.zip/node_modules/react-query/es/core/infiniteQueryBehavior.js": 26613/*!*****************************************************************************************************************************************************************************!*\ 26614 !*** ./.yarn/__virtual__/react-query-virtual-cd72c42dd3/0/cache/react-query-npm-3.12.0-415d3b7722-bd1075ac15.zip/node_modules/react-query/es/core/infiniteQueryBehavior.js ***! 26615 \*****************************************************************************************************************************************************************************/ 26616/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { 26617 26618"use strict"; 26619__webpack_require__.r(__webpack_exports__); 26620/* harmony export */ __webpack_require__.d(__webpack_exports__, { 26621/* harmony export */ "getNextPageParam": () => (/* binding */ getNextPageParam), 26622/* harmony export */ "getPreviousPageParam": () => (/* binding */ getPreviousPageParam), 26623/* harmony export */ "hasNextPage": () => (/* binding */ hasNextPage), 26624/* harmony export */ "hasPreviousPage": () => (/* binding */ hasPreviousPage), 26625/* harmony export */ "infiniteQueryBehavior": () => (/* binding */ infiniteQueryBehavior) 26626/* harmony export */ }); 26627/* harmony import */ var _retryer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./retryer */ "./.yarn/__virtual__/react-query-virtual-cd72c42dd3/0/cache/react-query-npm-3.12.0-415d3b7722-bd1075ac15.zip/node_modules/react-query/es/core/retryer.js"); 26628 26629function infiniteQueryBehavior() { 26630 return { 26631 onFetch: function onFetch(context) { 26632 context.fetchFn = function () { 26633 var _context$fetchOptions, _context$fetchOptions2, _context$state$data, _context$state$data2; 26634 26635 var fetchMore = (_context$fetchOptions = context.fetchOptions) == null ? void 0 : (_context$fetchOptions2 = _context$fetchOptions.meta) == null ? void 0 : _context$fetchOptions2.fetchMore; 26636 var pageParam = fetchMore == null ? void 0 : fetchMore.pageParam; 26637 var isFetchingNextPage = (fetchMore == null ? void 0 : fetchMore.direction) === 'forward'; 26638 var isFetchingPreviousPage = (fetchMore == null ? void 0 : fetchMore.direction) === 'backward'; 26639 var oldPages = ((_context$state$data = context.state.data) == null ? void 0 : _context$state$data.pages) || []; 26640 var oldPageParams = ((_context$state$data2 = context.state.data) == null ? void 0 : _context$state$data2.pageParams) || []; 26641 var newPageParams = oldPageParams; 26642 var cancelled = false; // Get query function 26643 26644 var queryFn = context.options.queryFn || function () { 26645 return Promise.reject('Missing queryFn'); 26646 }; // Create function to fetch a page 26647 26648 26649 var fetchPage = function fetchPage(pages, manual, param, previous) { 26650 if (cancelled) { 26651 return Promise.reject('Cancelled'); 26652 } 26653 26654 if (typeof param === 'undefined' && !manual && pages.length) { 26655 return Promise.resolve(pages); 26656 } 26657 26658 var queryFnContext = { 26659 queryKey: context.queryKey, 26660 pageParam: param 26661 }; 26662 var queryFnResult = queryFn(queryFnContext); 26663 var promise = Promise.resolve(queryFnResult).then(function (page) { 26664 newPageParams = previous ? [param].concat(newPageParams) : [].concat(newPageParams, [param]); 26665 return previous ? [page].concat(pages) : [].concat(pages, [page]); 26666 }); 26667 26668 if ((0,_retryer__WEBPACK_IMPORTED_MODULE_0__.isCancelable)(queryFnResult)) { 26669 var promiseAsAny = promise; 26670 promiseAsAny.cancel = queryFnResult.cancel; 26671 } 26672 26673 return promise; 26674 }; 26675 26676 var promise; // Fetch first page? 26677 26678 if (!oldPages.length) { 26679 promise = fetchPage([]); 26680 } // Fetch next page? 26681 else if (isFetchingNextPage) { 26682 var manual = typeof pageParam !== 'undefined'; 26683 var param = manual ? pageParam : getNextPageParam(context.options, oldPages); 26684 promise = fetchPage(oldPages, manual, param); 26685 } // Fetch previous page? 26686 else if (isFetchingPreviousPage) { 26687 var _manual = typeof pageParam !== 'undefined'; 26688 26689 var _param = _manual ? pageParam : getPreviousPageParam(context.options, oldPages); 26690 26691 promise = fetchPage(oldPages, _manual, _param, true); 26692 } // Refetch pages 26693 else { 26694 (function () { 26695 newPageParams = []; 26696 var manual = typeof context.options.getNextPageParam === 'undefined'; // Fetch first page 26697 26698 promise = fetchPage([], manual, oldPageParams[0]); // Fetch remaining pages 26699 26700 var _loop = function _loop(i) { 26701 promise = promise.then(function (pages) { 26702 var param = manual ? oldPageParams[i] : getNextPageParam(context.options, pages); 26703 return fetchPage(pages, manual, param); 26704 }); 26705 }; 26706 26707 for (var i = 1; i < oldPages.length; i++) { 26708 _loop(i); 26709 } 26710 })(); 26711 } 26712 26713 var finalPromise = promise.then(function (pages) { 26714 return { 26715 pages: pages, 26716 pageParams: newPageParams 26717 }; 26718 }); 26719 var finalPromiseAsAny = finalPromise; 26720 26721 finalPromiseAsAny.cancel = function () { 26722 cancelled = true; 26723 26724 if ((0,_retryer__WEBPACK_IMPORTED_MODULE_0__.isCancelable)(promise)) { 26725 promise.cancel(); 26726 } 26727 }; 26728 26729 return finalPromise; 26730 }; 26731 } 26732 }; 26733} 26734function getNextPageParam(options, pages) { 26735 return options.getNextPageParam == null ? void 0 : options.getNextPageParam(pages[pages.length - 1], pages); 26736} 26737function getPreviousPageParam(options, pages) { 26738 return options.getPreviousPageParam == null ? void 0 : options.getPreviousPageParam(pages[0], pages); 26739} 26740/** 26741 * Checks if there is a next page. 26742 * Returns `undefined` if it cannot be determined. 26743 */ 26744 26745function hasNextPage(options, pages) { 26746 if (options.getNextPageParam && Array.isArray(pages)) { 26747 var nextPageParam = getNextPageParam(options, pages); 26748 return typeof nextPageParam !== 'undefined' && nextPageParam !== null && nextPageParam !== false; 26749 } 26750} 26751/** 26752 * Checks if there is a previous page. 26753 * Returns `undefined` if it cannot be determined. 26754 */ 26755 26756function hasPreviousPage(options, pages) { 26757 if (options.getPreviousPageParam && Array.isArray(pages)) { 26758 var previousPageParam = getPreviousPageParam(options, pages); 26759 return typeof previousPageParam !== 'undefined' && previousPageParam !== null && previousPageParam !== false; 26760 } 26761} 26762 26763/***/ }), 26764
vendor: 1,582 bytes, lines 26765-26794
26765/***/ "./.yarn/__virtual__/react-query-virtual-cd72c42dd3/0/cache/react-query-npm-3.12.0-415d3b7722-bd1075ac15.zip/node_modules/react-query/es/core/logger.js": 26766/*!**************************************************************************************************************************************************************!*\ 26767 !*** ./.yarn/__virtual__/react-query-virtual-cd72c42dd3/0/cache/react-query-npm-3.12.0-415d3b7722-bd1075ac15.zip/node_modules/react-query/es/core/logger.js ***! 26768 \**************************************************************************************************************************************************************/ 26769/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { 26770 26771"use strict"; 26772__webpack_require__.r(__webpack_exports__); 26773/* harmony export */ __webpack_require__.d(__webpack_exports__, { 26774/* harmony export */ "getLogger": () => (/* binding */ getLogger), 26775/* harmony export */ "setLogger": () => (/* binding */ setLogger) 26776/* harmony export */ }); 26777/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils */ "./.yarn/__virtual__/react-query-virtual-cd72c42dd3/0/cache/react-query-npm-3.12.0-415d3b7722-bd1075ac15.zip/node_modules/react-query/es/core/utils.js"); 26778 // TYPES 26779 26780// FUNCTIONS 26781var logger = console || { 26782 error: _utils__WEBPACK_IMPORTED_MODULE_0__.noop, 26783 warn: _utils__WEBPACK_IMPORTED_MODULE_0__.noop, 26784 log: _utils__WEBPACK_IMPORTED_MODULE_0__.noop 26785}; 26786function getLogger() { 26787 return logger; 26788} 26789function setLogger(newLogger) { 26790 logger = newLogger; 26791} 26792 26793/***/ }), 26794
vendor: 8,809 bytes, lines 26795-27043
26795/***/ "./.yarn/__virtual__/react-query-virtual-cd72c42dd3/0/cache/react-query-npm-3.12.0-415d3b7722-bd1075ac15.zip/node_modules/react-query/es/core/mutation.js": 26796/*!****************************************************************************************************************************************************************!*\ 26797 !*** ./.yarn/__virtual__/react-query-virtual-cd72c42dd3/0/cache/react-query-npm-3.12.0-415d3b7722-bd1075ac15.zip/node_modules/react-query/es/core/mutation.js ***! 26798 \****************************************************************************************************************************************************************/ 26799/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { 26800 26801"use strict"; 26802__webpack_require__.r(__webpack_exports__); 26803/* harmony export */ __webpack_require__.d(__webpack_exports__, { 26804/* harmony export */ "Mutation": () => (/* binding */ Mutation), 26805/* harmony export */ "getDefaultState": () => (/* binding */ getDefaultState) 26806/* harmony export */ }); 26807/* harmony import */ var _babel_runtime_helpers_esm_extends__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @babel/runtime/helpers/esm/extends */ "./.yarn/cache/@babel-runtime-npm-7.18.9-28ca6b5f61-254985e146.zip/node_modules/@babel/runtime/helpers/esm/extends.js"); 26808/* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./logger */ "./.yarn/__virtual__/react-query-virtual-cd72c42dd3/0/cache/react-query-npm-3.12.0-415d3b7722-bd1075ac15.zip/node_modules/react-query/es/core/logger.js"); 26809/* harmony import */ var _notifyManager__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./notifyManager */ "./.yarn/__virtual__/react-query-virtual-cd72c42dd3/0/cache/react-query-npm-3.12.0-415d3b7722-bd1075ac15.zip/node_modules/react-query/es/core/notifyManager.js"); 26810/* harmony import */ var _retryer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./retryer */ "./.yarn/__virtual__/react-query-virtual-cd72c42dd3/0/cache/react-query-npm-3.12.0-415d3b7722-bd1075ac15.zip/node_modules/react-query/es/core/retryer.js"); 26811/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./utils */ "./.yarn/__virtual__/react-query-virtual-cd72c42dd3/0/cache/react-query-npm-3.12.0-415d3b7722-bd1075ac15.zip/node_modules/react-query/es/core/utils.js"); 26812 26813 26814 26815 26816 // TYPES 26817 26818// CLASS 26819var Mutation = /*#__PURE__*/function () { 26820 function Mutation(config) { 26821 this.options = (0,_babel_runtime_helpers_esm_extends__WEBPACK_IMPORTED_MODULE_0__["default"])({}, config.defaultOptions, config.options); 26822 this.mutationId = config.mutationId; 26823 this.mutationCache = config.mutationCache; 26824 this.observers = []; 26825 this.state = config.state || getDefaultState(); 26826 } 26827 26828 var _proto = Mutation.prototype; 26829 26830 _proto.setState = function setState(state) { 26831 this.dispatch({ 26832 type: 'setState', 26833 state: state 26834 }); 26835 }; 26836 26837 _proto.addObserver = function addObserver(observer) { 26838 if (this.observers.indexOf(observer) === -1) { 26839 this.observers.push(observer); 26840 } 26841 }; 26842 26843 _proto.removeObserver = function removeObserver(observer) { 26844 this.observers = this.observers.filter(function (x) { 26845 return x !== observer; 26846 }); 26847 }; 26848 26849 _proto.cancel = function cancel() { 26850 if (this.retryer) { 26851 this.retryer.cancel(); 26852 return this.retryer.promise.then(_utils__WEBPACK_IMPORTED_MODULE_1__.noop).catch(_utils__WEBPACK_IMPORTED_MODULE_1__.noop); 26853 } 26854 26855 return Promise.resolve(); 26856 }; 26857 26858 _proto.continue = function _continue() { 26859 if (this.retryer) { 26860 this.retryer.continue(); 26861 return this.retryer.promise; 26862 } 26863 26864 return this.execute(); 26865 }; 26866 26867 _proto.execute = function execute() { 26868 var _this = this; 26869 26870 var data; 26871 var restored = this.state.status === 'loading'; 26872 var promise = Promise.resolve(); 26873 26874 if (!restored) { 26875 this.dispatch({ 26876 type: 'loading', 26877 variables: this.options.variables 26878 }); 26879 promise = promise.then(function () { 26880 return _this.options.onMutate == null ? void 0 : _this.options.onMutate(_this.state.variables); 26881 }).then(function (context) { 26882 if (context !== _this.state.context) { 26883 _this.dispatch({ 26884 type: 'loading', 26885 context: context, 26886 variables: _this.state.variables 26887 }); 26888 } 26889 }); 26890 } 26891 26892 return promise.then(function () { 26893 return _this.executeMutation(); 26894 }).then(function (result) { 26895 data = result; 26896 }).then(function () { 26897 return _this.options.onSuccess == null ? void 0 : _this.options.onSuccess(data, _this.state.variables, _this.state.context); 26898 }).then(function () { 26899 return _this.options.onSettled == null ? void 0 : _this.options.onSettled(data, null, _this.state.variables, _this.state.context); 26900 }).then(function () { 26901 _this.dispatch({ 26902 type: 'success', 26903 data: data 26904 }); 26905 26906 return data; 26907 }).catch(function (error) { 26908 // Notify cache callback 26909 if (_this.mutationCache.config.onError) { 26910 _this.mutationCache.config.onError(error, _this.state.variables, _this.state.context, _this); 26911 } // Log error 26912 26913 26914 (0,_logger__WEBPACK_IMPORTED_MODULE_2__.getLogger)().error(error); 26915 return Promise.resolve().then(function () { 26916 return _this.options.onError == null ? void 0 : _this.options.onError(error, _this.state.variables, _this.state.context); 26917 }).then(function () { 26918 return _this.options.onSettled == null ? void 0 : _this.options.onSettled(undefined, error, _this.state.variables, _this.state.context); 26919 }).then(function () { 26920 _this.dispatch({ 26921 type: 'error', 26922 error: error 26923 }); 26924 26925 throw error; 26926 }); 26927 }); 26928 }; 26929 26930 _proto.executeMutation = function executeMutation() { 26931 var _this2 = this, 26932 _this$options$retry; 26933 26934 this.retryer = new _retryer__WEBPACK_IMPORTED_MODULE_3__.Retryer({ 26935 fn: function fn() { 26936 if (!_this2.options.mutationFn) { 26937 return Promise.reject('No mutationFn found'); 26938 } 26939 26940 return _this2.options.mutationFn(_this2.state.variables); 26941 }, 26942 onFail: function onFail() { 26943 _this2.dispatch({ 26944 type: 'failed' 26945 }); 26946 }, 26947 onPause: function onPause() { 26948 _this2.dispatch({ 26949 type: 'pause' 26950 }); 26951 }, 26952 onContinue: function onContinue() { 26953 _this2.dispatch({ 26954 type: 'continue' 26955 }); 26956 }, 26957 retry: (_this$options$retry = this.options.retry) != null ? _this$options$retry : 0, 26958 retryDelay: this.options.retryDelay 26959 }); 26960 return this.retryer.promise; 26961 }; 26962 26963 _proto.dispatch = function dispatch(action) { 26964 var _this3 = this; 26965 26966 this.state = reducer(this.state, action); 26967 _notifyManager__WEBPACK_IMPORTED_MODULE_4__.notifyManager.batch(function () { 26968 _this3.observers.forEach(function (observer) { 26969 observer.onMutationUpdate(action); 26970 }); 26971 26972 _this3.mutationCache.notify(_this3); 26973 }); 26974 }; 26975 26976 return Mutation; 26977}(); 26978function getDefaultState() { 26979 return { 26980 context: undefined, 26981 data: undefined, 26982 error: null, 26983 failureCount: 0, 26984 isPaused: false, 26985 status: 'idle', 26986 variables: undefined 26987 }; 26988} 26989 26990function reducer(state, action) { 26991 switch (action.type) { 26992 case 'failed': 26993 return (0,_babel_runtime_helpers_esm_extends__WEBPACK_IMPORTED_MODULE_0__["default"])({}, state, { 26994 failureCount: state.failureCount + 1 26995 }); 26996 26997 case 'pause': 26998 return (0,_babel_runtime_helpers_esm_extends__WEBPACK_IMPORTED_MODULE_0__["default"])({}, state, { 26999 isPaused: true 27000 }); 27001 27002 case 'continue': 27003 return (0,_babel_runtime_helpers_esm_extends__WEBPACK_IMPORTED_MODULE_0__["default"])({}, state, { 27004 isPaused: false 27005 }); 27006 27007 case 'loading': 27008 return (0,_babel_runtime_helpers_esm_extends__WEBPACK_IMPORTED_MODULE_0__["default"])({}, state, { 27009 context: action.context, 27010 data: undefined, 27011 error: null, 27012 isPaused: false, 27013 status: 'loading', 27014 variables: action.variables 27015 }); 27016 27017 case 'success': 27018 return (0,_babel_runtime_helpers_esm_extends__WEBPACK_IMPORTED_MODULE_0__["default"])({}, state, { 27019 data: action.data, 27020 error: null, 27021 status: 'success', 27022 isPaused: false 27023 }); 27024 27025 case 'error': 27026 return (0,_babel_runtime_helpers_esm_extends__WEBPACK_IMPORTED_MODULE_0__["default"])({}, state, { 27027 data: undefined, 27028 error: action.error, 27029 failureCount: state.failureCount + 1, 27030 isPaused: false, 27031 status: 'error' 27032 }); 27033 27034 case 'setState': 27035 return (0,_babel_runtime_helpers_esm_extends__WEBPACK_IMPORTED_MODULE_0__["default"])({}, state, action.state); 27036 27037 default: 27038 return state; 27039 } 27040} 27041 27042/***/ }), 27043
vendor: 4,873 bytes, lines 27044-27156
27044/***/ "./.yarn/__virtual__/react-query-virtual-cd72c42dd3/0/cache/react-query-npm-3.12.0-415d3b7722-bd1075ac15.zip/node_modules/react-query/es/core/mutationCache.js": 27045/*!*********************************************************************************************************************************************************************!*\ 27046 !*** ./.yarn/__virtual__/react-query-virtual-cd72c42dd3/0/cache/react-query-npm-3.12.0-415d3b7722-bd1075ac15.zip/node_modules/react-query/es/core/mutationCache.js ***! 27047 \*********************************************************************************************************************************************************************/ 27048/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { 27049 27050"use strict"; 27051__webpack_require__.r(__webpack_exports__); 27052/* harmony export */ __webpack_require__.d(__webpack_exports__, { 27053/* harmony export */ "MutationCache": () => (/* binding */ MutationCache) 27054/* harmony export */ }); 27055/* harmony import */ var _babel_runtime_helpers_esm_inheritsLoose__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @babel/runtime/helpers/esm/inheritsLoose */ "./.yarn/cache/@babel-runtime-npm-7.18.9-28ca6b5f61-254985e146.zip/node_modules/@babel/runtime/helpers/esm/inheritsLoose.js"); 27056/* harmony import */ var _notifyManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./notifyManager */ "./.yarn/__virtual__/react-query-virtual-cd72c42dd3/0/cache/react-query-npm-3.12.0-415d3b7722-bd1075ac15.zip/node_modules/react-query/es/core/notifyManager.js"); 27057/* harmony import */ var _mutation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./mutation */ "./.yarn/__virtual__/react-query-virtual-cd72c42dd3/0/cache/react-query-npm-3.12.0-415d3b7722-bd1075ac15.zip/node_modules/react-query/es/core/mutation.js"); 27058/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./utils */ "./.yarn/__virtual__/react-query-virtual-cd72c42dd3/0/cache/react-query-npm-3.12.0-415d3b7722-bd1075ac15.zip/node_modules/react-query/es/core/utils.js"); 27059/* harmony import */ var _subscribable__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./subscribable */ "./.yarn/__virtual__/react-query-virtual-cd72c42dd3/0/cache/react-query-npm-3.12.0-415d3b7722-bd1075ac15.zip/node_modules/react-query/es/core/subscribable.js"); 27060 27061 27062 27063 27064 // TYPES 27065 27066// CLASS 27067var MutationCache = /*#__PURE__*/function (_Subscribable) { 27068 (0,_babel_runtime_helpers_esm_inheritsLoose__WEBPACK_IMPORTED_MODULE_0__["default"])(MutationCache, _Subscribable); 27069 27070 function MutationCache(config) { 27071 var _this; 27072 27073 _this = _Subscribable.call(this) || this; 27074 _this.config = config || {}; 27075 _this.mutations = []; 27076 _this.mutationId = 0; 27077 return _this; 27078 } 27079 27080 var _proto = MutationCache.prototype; 27081 27082 _proto.build = function build(client, options, state) { 27083 var mutation = new _mutation__WEBPACK_IMPORTED_MODULE_1__.Mutation({ 27084 mutationCache: this, 27085 mutationId: ++this.mutationId, 27086 options: client.defaultMutationOptions(options), 27087 state: state, 27088 defaultOptions: options.mutationKey ? client.getMutationDefaults(options.mutationKey) : undefined 27089 }); 27090 this.add(mutation); 27091 return mutation; 27092 }; 27093 27094 _proto.add = function add(mutation) { 27095 this.mutations.push(mutation); 27096 this.notify(mutation); 27097 }; 27098 27099 _proto.remove = function remove(mutation) { 27100 this.mutations = this.mutations.filter(function (x) { 27101 return x !== mutation; 27102 }); 27103 mutation.cancel(); 27104 this.notify(mutation); 27105 }; 27106 27107 _proto.clear = function clear() { 27108 var _this2 = this; 27109 27110 _notifyManager__WEBPACK_IMPORTED_MODULE_2__.notifyManager.batch(function () { 27111 _this2.mutations.forEach(function (mutation) { 27112 _this2.remove(mutation); 27113 }); 27114 }); 27115 }; 27116 27117 _proto.getAll = function getAll() { 27118 return this.mutations; 27119 }; 27120 27121 _proto.notify = function notify(mutation) { 27122 var _this3 = this; 27123 27124 _notifyManager__WEBPACK_IMPORTED_MODULE_2__.notifyManager.batch(function () { 27125 _this3.listeners.forEach(function (listener) { 27126 listener(mutation); 27127 }); 27128 }); 27129 }; 27130 27131 _proto.onFocus = function onFocus() { 27132 this.resumePausedMutations(); 27133 }; 27134 27135 _proto.onOnline = function onOnline() { 27136 this.resumePausedMutations(); 27137 }; 27138 27139 _proto.resumePausedMutations = function resumePausedMutations() { 27140 var pausedMutations = this.mutations.filter(function (x) { 27141 return x.state.isPaused; 27142 }); 27143 return _notifyManager__WEBPACK_IMPORTED_MODULE_2__.notifyManager.batch(function () { 27144 return pausedMutations.reduce(function (promise, mutation) { 27145 return promise.then(function () { 27146 return mutation.continue().catch(_utils__WEBPACK_IMPORTED_MODULE_3__.noop); 27147 }); 27148 }, Promise.resolve()); 27149 }); 27150 }; 27151 27152 return MutationCache; 27153}(_subscribable__WEBPACK_IMPORTED_MODULE_4__.Subscribable); 27154 27155/***/ }), 27156
vendor: 3,525 bytes, lines 27157-27272
27157/***/ "./.yarn/__virtual__/react-query-virtual-cd72c42dd3/0/cache/react-query-npm-3.12.0-415d3b7722-bd1075ac15.zip/node_modules/react-query/es/core/notifyManager.js": 27158/*!*********************************************************************************************************************************************************************!*\ 27159 !*** ./.yarn/__virtual__/react-query-virtual-cd72c42dd3/0/cache/react-query-npm-3.12.0-415d3b7722-bd1075ac15.zip/node_modules/react-query/es/core/notifyManager.js ***! 27160 \*********************************************************************************************************************************************************************/ 27161/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { 27162 27163"use strict"; 27164__webpack_require__.r(__webpack_exports__); 27165/* harmony export */ __webpack_require__.d(__webpack_exports__, { 27166/* harmony export */ "notifyManager": () => (/* binding */ notifyManager) 27167/* harmony export */ }); 27168/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils */ "./.yarn/__virtual__/react-query-virtual-cd72c42dd3/0/cache/react-query-npm-3.12.0-415d3b7722-bd1075ac15.zip/node_modules/react-query/es/core/utils.js"); 27169 // TYPES 27170 27171// CLASS 27172var NotifyManager = /*#__PURE__*/function () { 27173 function NotifyManager() { 27174 this.queue = []; 27175 this.transactions = 0; 27176 27177 this.notifyFn = function (callback) { 27178 callback(); 27179 }; 27180 27181 this.batchNotifyFn = function (callback) { 27182 callback(); 27183 }; 27184 } 27185 27186 var _proto = NotifyManager.prototype; 27187 27188 _proto.batch = function batch(callback) { 27189 this.transactions++; 27190 var result = callback(); 27191 this.transactions--; 27192 27193 if (!this.transactions) { 27194 this.flush(); 27195 } 27196 27197 return result; 27198 }; 27199 27200 _proto.schedule = function schedule(callback) { 27201 var _this = this; 27202 27203 if (this.transactions) { 27204 this.queue.push(callback); 27205 } else { 27206 (0,_utils__WEBPACK_IMPORTED_MODULE_0__.scheduleMicrotask)(function () { 27207 _this.notifyFn(callback); 27208 }); 27209 } 27210 } 27211 /** 27212 * All calls to the wrapped function will be batched. 27213 */ 27214 ; 27215 27216 _proto.batchCalls = function batchCalls(callback) { 27217 var _this2 = this; 27218 27219 return function () { 27220 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { 27221 args[_key] = arguments[_key]; 27222 } 27223 27224 _this2.schedule(function () { 27225 callback.apply(void 0, args); 27226 }); 27227 }; 27228 }; 27229 27230 _proto.flush = function flush() { 27231 var _this3 = this; 27232 27233 var queue = this.queue; 27234 this.queue = []; 27235 27236 if (queue.length) { 27237 (0,_utils__WEBPACK_IMPORTED_MODULE_0__.scheduleMicrotask)(function () { 27238 _this3.batchNotifyFn(function () { 27239 queue.forEach(function (callback) { 27240 _this3.notifyFn(callback); 27241 }); 27242 }); 27243 }); 27244 } 27245 } 27246 /** 27247 * Use this method to set a custom notify function. 27248 * This can be used to for example wrap notifications with `React.act` while running tests. 27249 */ 27250 ; 27251 27252 _proto.setNotifyFunction = function setNotifyFunction(fn) { 27253 this.notifyFn = fn; 27254 } 27255 /** 27256 * Use this method to set a custom function to batch notifications together into a single tick. 27257 * By default React Query will use the batch function provided by ReactDOM or React Native. 27258 */ 27259 ; 27260 27261 _proto.setBatchNotifyFunction = function setBatchNotifyFunction(fn) { 27262 this.batchNotifyFn = fn; 27263 }; 27264 27265 return NotifyManager; 27266}(); // SINGLETON 27267 27268 27269var notifyManager = new NotifyManager(); 27270 27271/***/ }), 27272
vendor: 3,920 bytes, lines 27273-27371
27273/***/ "./.yarn/__virtual__/react-query-virtual-cd72c42dd3/0/cache/react-query-npm-3.12.0-415d3b7722-bd1075ac15.zip/node_modules/react-query/es/core/onlineManager.js": 27274/*!*********************************************************************************************************************************************************************!*\ 27275 !*** ./.yarn/__virtual__/react-query-virtual-cd72c42dd3/0/cache/react-query-npm-3.12.0-415d3b7722-bd1075ac15.zip/node_modules/react-query/es/core/onlineManager.js ***! 27276 \*********************************************************************************************************************************************************************/ 27277/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { 27278 27279"use strict"; 27280__webpack_require__.r(__webpack_exports__); 27281/* harmony export */ __webpack_require__.d(__webpack_exports__, { 27282/* harmony export */ "onlineManager": () => (/* binding */ onlineManager) 27283/* harmony export */ }); 27284/* harmony import */ var _babel_runtime_helpers_esm_inheritsLoose__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @babel/runtime/helpers/esm/inheritsLoose */ "./.yarn/cache/@babel-runtime-npm-7.18.9-28ca6b5f61-254985e146.zip/node_modules/@babel/runtime/helpers/esm/inheritsLoose.js"); 27285/* harmony import */ var _subscribable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./subscribable */ "./.yarn/__virtual__/react-query-virtual-cd72c42dd3/0/cache/react-query-npm-3.12.0-415d3b7722-bd1075ac15.zip/node_modules/react-query/es/core/subscribable.js"); 27286/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./utils */ "./.yarn/__virtual__/react-query-virtual-cd72c42dd3/0/cache/react-query-npm-3.12.0-415d3b7722-bd1075ac15.zip/node_modules/react-query/es/core/utils.js"); 27287 27288 27289 27290 27291var OnlineManager = /*#__PURE__*/function (_Subscribable) { 27292 (0,_babel_runtime_helpers_esm_inheritsLoose__WEBPACK_IMPORTED_MODULE_0__["default"])(OnlineManager, _Subscribable); 27293 27294 function OnlineManager() { 27295 return _Subscribable.apply(this, arguments) || this; 27296 } 27297 27298 var _proto = OnlineManager.prototype; 27299 27300 _proto.onSubscribe = function onSubscribe() { 27301 if (!this.removeEventListener) { 27302 this.setDefaultEventListener(); 27303 } 27304 }; 27305 27306 _proto.setEventListener = function setEventListener(setup) { 27307 var _this = this; 27308 27309 if (this.removeEventListener) { 27310 this.removeEventListener(); 27311 } 27312 27313 this.removeEventListener = setup(function (online) { 27314 if (typeof online === 'boolean') { 27315 _this.setOnline(online); 27316 } else { 27317 _this.onOnline(); 27318 } 27319 }); 27320 }; 27321 27322 _proto.setOnline = function setOnline(online) { 27323 this.online = online; 27324 27325 if (online) { 27326 this.onOnline(); 27327 } 27328 }; 27329 27330 _proto.onOnline = function onOnline() { 27331 this.listeners.forEach(function (listener) { 27332 listener(); 27333 }); 27334 }; 27335 27336 _proto.isOnline = function isOnline() { 27337 if (typeof this.online === 'boolean') { 27338 return this.online; 27339 } 27340 27341 if (typeof navigator === 'undefined' || typeof navigator.onLine === 'undefined') { 27342 return true; 27343 } 27344 27345 return navigator.onLine; 27346 }; 27347 27348 _proto.setDefaultEventListener = function setDefaultEventListener() { 27349 var _window; 27350 27351 if (!_utils__WEBPACK_IMPORTED_MODULE_1__.isServer && ((_window = window) == null ? void 0 : _window.addEventListener)) { 27352 this.setEventListener(function (onOnline) { 27353 // Listen to online 27354 window.addEventListener('online', onOnline, false); 27355 window.addEventListener('offline', onOnline, false); 27356 return function () { 27357 // Be sure to unsubscribe if a new handler is set 27358 window.removeEventListener('online', onOnline); 27359 window.removeEventListener('offline', onOnline); 27360 }; 27361 }); 27362 } 27363 }; 27364 27365 return OnlineManager; 27366}(_subscribable__WEBPACK_IMPORTED_MODULE_2__.Subscribable); 27367 27368var onlineManager = new OnlineManager(); 27369 27370/***/ }), 27371
vendor: 16,301 bytes, lines 27372-27847
27372/***/ "./.yarn/__virtual__/react-query-virtual-cd72c42dd3/0/cache/react-query-npm-3.12.0-415d3b7722-bd1075ac15.zip/node_modules/react-query/es/core/query.js": 27373/*!*************************************************************************************************************************************************************!*\ 27374 !*** ./.yarn/__virtual__/react-query-virtual-cd72c42dd3/0/cache/react-query-npm-3.12.0-415d3b7722-bd1075ac15.zip/node_modules/react-query/es/core/query.js ***! 27375 \*************************************************************************************************************************************************************/ 27376/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { 27377 27378"use strict"; 27379__webpack_require__.r(__webpack_exports__); 27380/* harmony export */ __webpack_require__.d(__webpack_exports__, { 27381/* harmony export */ "Query": () => (/* binding */ Query) 27382/* harmony export */ }); 27383/* harmony import */ var _babel_runtime_helpers_esm_extends__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @babel/runtime/helpers/esm/extends */ "./.yarn/cache/@babel-runtime-npm-7.18.9-28ca6b5f61-254985e146.zip/node_modules/@babel/runtime/helpers/esm/extends.js"); 27384/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./utils */ "./.yarn/__virtual__/react-query-virtual-cd72c42dd3/0/cache/react-query-npm-3.12.0-415d3b7722-bd1075ac15.zip/node_modules/react-query/es/core/utils.js"); 27385/* harmony import */ var _notifyManager__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./notifyManager */ "./.yarn/__virtual__/react-query-virtual-cd72c42dd3/0/cache/react-query-npm-3.12.0-415d3b7722-bd1075ac15.zip/node_modules/react-query/es/core/notifyManager.js"); 27386/* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./logger */ "./.yarn/__virtual__/react-query-virtual-cd72c42dd3/0/cache/react-query-npm-3.12.0-415d3b7722-bd1075ac15.zip/node_modules/react-query/es/core/logger.js"); 27387/* harmony import */ var _retryer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./retryer */ "./.yarn/__virtual__/react-query-virtual-cd72c42dd3/0/cache/react-query-npm-3.12.0-415d3b7722-bd1075ac15.zip/node_modules/react-query/es/core/retryer.js"); 27388 27389 27390 27391 27392 // TYPES 27393 27394// CLASS 27395var Query = /*#__PURE__*/function () { 27396 function Query(config) { 27397 this.defaultOptions = config.defaultOptions; 27398 this.setOptions(config.options); 27399 this.observers = []; 27400 this.cache = config.cache; 27401 this.queryKey = config.queryKey; 27402 this.queryHash = config.queryHash; 27403 this.initialState = config.state || this.getDefaultState(this.options); 27404 this.state = this.initialState; 27405 this.scheduleGc(); 27406 } 27407 27408 var _proto = Query.prototype; 27409 27410 _proto.setOptions = function setOptions(options) { 27411 var _this$options$cacheTi; 27412 27413 this.options = (0,_babel_runtime_helpers_esm_extends__WEBPACK_IMPORTED_MODULE_0__["default"])({}, this.defaultOptions, options); // Default to 5 minutes if not cache time is set 27414 27415 this.cacheTime = Math.max(this.cacheTime || 0, (_this$options$cacheTi = this.options.cacheTime) != null ? _this$options$cacheTi : 5 * 60 * 1000); 27416 }; 27417 27418 _proto.setDefaultOptions = function setDefaultOptions(options) { 27419 this.defaultOptions = options; 27420 }; 27421 27422 _proto.scheduleGc = function scheduleGc() { 27423 var _this = this; 27424 27425 this.clearGcTimeout(); 27426 27427 if ((0,_utils__WEBPACK_IMPORTED_MODULE_1__.isValidTimeout)(this.cacheTime)) { 27428 this.gcTimeout = setTimeout(function () { 27429 _this.optionalRemove(); 27430 }, this.cacheTime); 27431 } 27432 }; 27433 27434 _proto.clearGcTimeout = function clearGcTimeout() { 27435 clearTimeout(this.gcTimeout); 27436 this.gcTimeout = undefined; 27437 }; 27438 27439 _proto.optionalRemove = function optionalRemove() { 27440 if (!this.observers.length && !this.state.isFetching) { 27441 this.cache.remove(this); 27442 } 27443 }; 27444 27445 _proto.setData = function setData(updater, options) { 27446 var _this$options$isDataE, _this$options; 27447 27448 var prevData = this.state.data; // Get the new data 27449 27450 var data = (0,_utils__WEBPACK_IMPORTED_MODULE_1__.functionalUpdate)(updater, prevData); // Use prev data if an isDataEqual function is defined and returns `true` 27451 27452 if ((_this$options$isDataE = (_this$options = this.options).isDataEqual) == null ? void 0 : _this$options$isDataE.call(_this$options, prevData, data)) { 27453 data = prevData; 27454 } else if (this.options.structuralSharing !== false) { 27455 // Structurally share data between prev and new data if needed 27456 data = (0,_utils__WEBPACK_IMPORTED_MODULE_1__.replaceEqualDeep)(prevData, data); 27457 } // Set data and mark it as cached 27458 27459 27460 this.dispatch({ 27461 data: data, 27462 type: 'success', 27463 dataUpdatedAt: options == null ? void 0 : options.updatedAt 27464 }); 27465 return data; 27466 }; 27467 27468 _proto.setState = function setState(state, setStateOptions) { 27469 this.dispatch({ 27470 type: 'setState', 27471 state: state, 27472 setStateOptions: setStateOptions 27473 }); 27474 }; 27475 27476 _proto.cancel = function cancel(options) { 27477 var _this$retryer; 27478 27479 var promise = this.promise; 27480 (_this$retryer = this.retryer) == null ? void 0 : _this$retryer.cancel(options); 27481 return promise ? promise.then(_utils__WEBPACK_IMPORTED_MODULE_1__.noop).catch(_utils__WEBPACK_IMPORTED_MODULE_1__.noop) : Promise.resolve(); 27482 }; 27483 27484 _proto.destroy = function destroy() { 27485 this.clearGcTimeout(); 27486 this.cancel({ 27487 silent: true 27488 }); 27489 }; 27490 27491 _proto.reset = function reset() { 27492 this.destroy(); 27493 this.setState(this.initialState); 27494 }; 27495 27496 _proto.isActive = function isActive() { 27497 return this.observers.some(function (observer) { 27498 return observer.options.enabled !== false; 27499 }); 27500 }; 27501 27502 _proto.isFetching = function isFetching() { 27503 return this.state.isFetching; 27504 }; 27505 27506 _proto.isStale = function isStale() { 27507 return this.state.isInvalidated || !this.state.dataUpdatedAt || this.observers.some(function (observer) { 27508 return observer.getCurrentResult().isStale; 27509 }); 27510 }; 27511 27512 _proto.isStaleByTime = function isStaleByTime(staleTime) { 27513 if (staleTime === void 0) { 27514 staleTime = 0; 27515 } 27516 27517 return this.state.isInvalidated || !this.state.dataUpdatedAt || !(0,_utils__WEBPACK_IMPORTED_MODULE_1__.timeUntilStale)(this.state.dataUpdatedAt, staleTime); 27518 }; 27519 27520 _proto.onFocus = function onFocus() { 27521 var _this$retryer2; 27522 27523 var observer = this.observers.find(function (x) { 27524 return x.shouldFetchOnWindowFocus(); 27525 }); 27526 27527 if (observer) { 27528 observer.refetch(); 27529 } // Continue fetch if currently paused 27530 27531 27532 (_this$retryer2 = this.retryer) == null ? void 0 : _this$retryer2.continue(); 27533 }; 27534 27535 _proto.onOnline = function onOnline() { 27536 var _this$retryer3; 27537 27538 var observer = this.observers.find(function (x) { 27539 return x.shouldFetchOnReconnect(); 27540 }); 27541 27542 if (observer) { 27543 observer.refetch(); 27544 } // Continue fetch if currently paused 27545 27546 27547 (_this$retryer3 = this.retryer) == null ? void 0 : _this$retryer3.continue(); 27548 }; 27549 27550 _proto.addObserver = function addObserver(observer) { 27551 if (this.observers.indexOf(observer) === -1) { 27552 this.observers.push(observer); // Stop the query from being garbage collected 27553 27554 this.clearGcTimeout(); 27555 this.cache.notify({ 27556 type: 'observerAdded', 27557 query: this, 27558 observer: observer 27559 }); 27560 } 27561 }; 27562 27563 _proto.removeObserver = function removeObserver(observer) { 27564 if (this.observers.indexOf(observer) !== -1) { 27565 this.observers = this.observers.filter(function (x) { 27566 return x !== observer; 27567 }); 27568 27569 if (!this.observers.length) { 27570 // If the transport layer does not support cancellation 27571 // we'll let the query continue so the result can be cached 27572 if (this.retryer) { 27573 if (this.retryer.isTransportCancelable) { 27574 this.retryer.cancel({ 27575 revert: true 27576 }); 27577 } else { 27578 this.retryer.cancelRetry(); 27579 } 27580 } 27581 27582 if (this.cacheTime) { 27583 this.scheduleGc(); 27584 } else { 27585 this.cache.remove(this); 27586 } 27587 } 27588 27589 this.cache.notify({ 27590 type: 'observerRemoved', 27591 query: this, 27592 observer: observer 27593 }); 27594 } 27595 }; 27596 27597 _proto.invalidate = function invalidate() { 27598 if (!this.state.isInvalidated) { 27599 this.dispatch({ 27600 type: 'invalidate' 27601 }); 27602 } 27603 }; 27604 27605 _proto.fetch = function fetch(options, fetchOptions) { 27606 var _this2 = this, 27607 _this$options$behavio, 27608 _context$fetchOptions; 27609 27610 if (this.state.isFetching) { 27611 if (this.state.dataUpdatedAt && (fetchOptions == null ? void 0 : fetchOptions.cancelRefetch)) { 27612 // Silently cancel current fetch if the user wants to cancel refetches 27613 this.cancel({ 27614 silent: true 27615 }); 27616 } else if (this.promise) { 27617 // Return current promise if we are already fetching 27618 return this.promise; 27619 } 27620 } // Update config if passed, otherwise the config from the last execution is used 27621 27622 27623 if (options) { 27624 this.setOptions(options); 27625 } // Use the options from the first observer with a query function if no function is found. 27626 // This can happen when the query is hydrated or created with setQueryData. 27627 27628 27629 if (!this.options.queryFn) { 27630 var observer = this.observers.find(function (x) { 27631 return x.options.queryFn; 27632 }); 27633 27634 if (observer) { 27635 this.setOptions(observer.options); 27636 } 27637 } // Create query function context 27638 27639 27640 var queryKey = (0,_utils__WEBPACK_IMPORTED_MODULE_1__.ensureArray)(this.queryKey); 27641 var queryFnContext = { 27642 queryKey: queryKey, 27643 pageParam: undefined 27644 }; // Create fetch function 27645 27646 var fetchFn = function fetchFn() { 27647 return _this2.options.queryFn ? _this2.options.queryFn(queryFnContext) : Promise.reject('Missing queryFn'); 27648 }; // Trigger behavior hook 27649 27650 27651 var context = { 27652 fetchOptions: fetchOptions, 27653 options: this.options, 27654 queryKey: queryKey, 27655 state: this.state, 27656 fetchFn: fetchFn 27657 }; 27658 27659 if ((_this$options$behavio = this.options.behavior) == null ? void 0 : _this$options$behavio.onFetch) { 27660 var _this$options$behavio2; 27661 27662 (_this$options$behavio2 = this.options.behavior) == null ? void 0 : _this$options$behavio2.onFetch(context); 27663 } // Store state in case the current fetch needs to be reverted 27664 27665 27666 this.revertState = this.state; // Set to fetching state if not already in it 27667 27668 if (!this.state.isFetching || this.state.fetchMeta !== ((_context$fetchOptions = context.fetchOptions) == null ? void 0 : _context$fetchOptions.meta)) { 27669 var _context$fetchOptions2; 27670 27671 this.dispatch({ 27672 type: 'fetch', 27673 meta: (_context$fetchOptions2 = context.fetchOptions) == null ? void 0 : _context$fetchOptions2.meta 27674 }); 27675 } // Try to fetch the data 27676 27677 27678 this.retryer = new _retryer__WEBPACK_IMPORTED_MODULE_2__.Retryer({ 27679 fn: context.fetchFn, 27680 onSuccess: function onSuccess(data) { 27681 _this2.setData(data); // Remove query after fetching if cache time is 0 27682 27683 27684 if (_this2.cacheTime === 0) { 27685 _this2.optionalRemove(); 27686 } 27687 }, 27688 onError: function onError(error) { 27689 // Optimistically update state if needed 27690 if (!((0,_retryer__WEBPACK_IMPORTED_MODULE_2__.isCancelledError)(error) && error.silent)) { 27691 _this2.dispatch({ 27692 type: 'error', 27693 error: error 27694 }); 27695 } 27696 27697 if (!(0,_retryer__WEBPACK_IMPORTED_MODULE_2__.isCancelledError)(error)) { 27698 // Notify cache callback 27699 if (_this2.cache.config.onError) { 27700 _this2.cache.config.onError(error, _this2); 27701 } // Log error 27702 27703 27704 (0,_logger__WEBPACK_IMPORTED_MODULE_3__.getLogger)().error(error); 27705 } // Remove query after fetching if cache time is 0 27706 27707 27708 if (_this2.cacheTime === 0) { 27709 _this2.optionalRemove(); 27710 } 27711 }, 27712 onFail: function onFail() { 27713 _this2.dispatch({ 27714 type: 'failed' 27715 }); 27716 }, 27717 onPause: function onPause() { 27718 _this2.dispatch({ 27719 type: 'pause' 27720 }); 27721 }, 27722 onContinue: function onContinue() { 27723 _this2.dispatch({ 27724 type: 'continue' 27725 }); 27726 }, 27727 retry: context.options.retry, 27728 retryDelay: context.options.retryDelay 27729 }); 27730 this.promise = this.retryer.promise; 27731 return this.promise; 27732 }; 27733 27734 _proto.dispatch = function dispatch(action) { 27735 var _this3 = this; 27736 27737 this.state = this.reducer(this.state, action); 27738 _notifyManager__WEBPACK_IMPORTED_MODULE_4__.notifyManager.batch(function () { 27739 _this3.observers.forEach(function (observer) { 27740 observer.onQueryUpdate(action); 27741 }); 27742 27743 _this3.cache.notify({ 27744 query: _this3, 27745 type: 'queryUpdated', 27746 action: action 27747 }); 27748 }); 27749 }; 27750 27751 _proto.getDefaultState = function getDefaultState(options) { 27752 var data = typeof options.initialData === 'function' ? options.initialData() : options.initialData; 27753 var hasInitialData = typeof options.initialData !== 'undefined'; 27754 var initialDataUpdatedAt = hasInitialData ? typeof options.initialDataUpdatedAt === 'function' ? options.initialDataUpdatedAt() : options.initialDataUpdatedAt : 0; 27755 var hasData = typeof data !== 'undefined'; 27756 return { 27757 data: data, 27758 dataUpdateCount: 0, 27759 dataUpdatedAt: hasData ? initialDataUpdatedAt != null ? initialDataUpdatedAt : Date.now() : 0, 27760 error: null, 27761 errorUpdateCount: 0, 27762 errorUpdatedAt: 0, 27763 fetchFailureCount: 0, 27764 fetchMeta: null, 27765 isFetching: false, 27766 isInvalidated: false, 27767 isPaused: false, 27768 status: hasData ? 'success' : 'idle' 27769 }; 27770 }; 27771 27772 _proto.reducer = function reducer(state, action) { 27773 var _action$meta, _action$dataUpdatedAt; 27774 27775 switch (action.type) { 27776 case 'failed': 27777 return (0,_babel_runtime_helpers_esm_extends__WEBPACK_IMPORTED_MODULE_0__["default"])({}, state, { 27778 fetchFailureCount: state.fetchFailureCount + 1 27779 }); 27780 27781 case 'pause': 27782 return (0,_babel_runtime_helpers_esm_extends__WEBPACK_IMPORTED_MODULE_0__["default"])({}, state, { 27783 isPaused: true 27784 }); 27785 27786 case 'continue': 27787 return (0,_babel_runtime_helpers_esm_extends__WEBPACK_IMPORTED_MODULE_0__["default"])({}, state, { 27788 isPaused: false 27789 }); 27790 27791 case 'fetch': 27792 return (0,_babel_runtime_helpers_esm_extends__WEBPACK_IMPORTED_MODULE_0__["default"])({}, state, { 27793 fetchFailureCount: 0, 27794 fetchMeta: (_action$meta = action.meta) != null ? _action$meta : null, 27795 isFetching: true, 27796 isPaused: false, 27797 status: !state.dataUpdatedAt ? 'loading' : state.status 27798 }); 27799 27800 case 'success': 27801 return (0,_babel_runtime_helpers_esm_extends__WEBPACK_IMPORTED_MODULE_0__["default"])({}, state, { 27802 data: action.data, 27803 dataUpdateCount: state.dataUpdateCount + 1, 27804 dataUpdatedAt: (_action$dataUpdatedAt = action.dataUpdatedAt) != null ? _action$dataUpdatedAt : Date.now(), 27805 error: null, 27806 fetchFailureCount: 0, 27807 isFetching: false, 27808 isInvalidated: false, 27809 isPaused: false, 27810 status: 'success' 27811 }); 27812 27813 case 'error': 27814 var error = action.error; 27815 27816 if ((0,_retryer__WEBPACK_IMPORTED_MODULE_2__.isCancelledError)(error) && error.revert && this.revertState) { 27817 return (0,_babel_runtime_helpers_esm_extends__WEBPACK_IMPORTED_MODULE_0__["default"])({}, this.revertState); 27818 } 27819 27820 return (0,_babel_runtime_helpers_esm_extends__WEBPACK_IMPORTED_MODULE_0__["default"])({}, state, { 27821 error: error, 27822 errorUpdateCount: state.errorUpdateCount + 1, 27823 errorUpdatedAt: Date.now(), 27824 fetchFailureCount: state.fetchFailureCount + 1, 27825 isFetching: false, 27826 isPaused: false, 27827 status: 'error' 27828 }); 27829 27830 case 'invalidate': 27831 return (0,_babel_runtime_helpers_esm_extends__WEBPACK_IMPORTED_MODULE_0__["default"])({}, state, { 27832 isInvalidated: true 27833 }); 27834 27835 case 'setState': 27836 return (0,_babel_runtime_helpers_esm_extends__WEBPACK_IMPORTED_MODULE_0__["default"])({}, state, action.state); 27837 27838 default: 27839 return state; 27840 } 27841 }; 27842 27843 return Query; 27844}(); 27845 27846/***/ }), 27847
vendor: 6,104 bytes, lines 27848-28012
27848/***/ "./.yarn/__virtual__/react-query-virtual-cd72c42dd3/0/cache/react-query-npm-3.12.0-415d3b7722-bd1075ac15.zip/node_modules/react-query/es/core/queryCache.js": 27849/*!******************************************************************************************************************************************************************!*\ 27850 !*** ./.yarn/__virtual__/react-query-virtual-cd72c42dd3/0/cache/react-query-npm-3.12.0-415d3b7722-bd1075ac15.zip/node_modules/react-query/es/core/queryCache.js ***! 27851 \******************************************************************************************************************************************************************/ 27852/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { 27853 27854"use strict"; 27855__webpack_require__.r(__webpack_exports__); 27856/* harmony export */ __webpack_require__.d(__webpack_exports__, { 27857/* harmony export */ "QueryCache": () => (/* binding */ QueryCache) 27858/* harmony export */ }); 27859/* harmony import */ var _babel_runtime_helpers_esm_inheritsLoose__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @babel/runtime/helpers/esm/inheritsLoose */ "./.yarn/cache/@babel-runtime-npm-7.18.9-28ca6b5f61-254985e146.zip/node_modules/@babel/runtime/helpers/esm/inheritsLoose.js"); 27860/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./utils */ "./.yarn/__virtual__/react-query-virtual-cd72c42dd3/0/cache/react-query-npm-3.12.0-415d3b7722-bd1075ac15.zip/node_modules/react-query/es/core/utils.js"); 27861/* harmony import */ var _query__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./query */ "./.yarn/__virtual__/react-query-virtual-cd72c42dd3/0/cache/react-query-npm-3.12.0-415d3b7722-bd1075ac15.zip/node_modules/react-query/es/core/query.js"); 27862/* harmony import */ var _notifyManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./notifyManager */ "./.yarn/__virtual__/react-query-virtual-cd72c42dd3/0/cache/react-query-npm-3.12.0-415d3b7722-bd1075ac15.zip/node_modules/react-query/es/core/notifyManager.js"); 27863/* harmony import */ var _subscribable__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./subscribable */ "./.yarn/__virtual__/react-query-virtual-cd72c42dd3/0/cache/react-query-npm-3.12.0-415d3b7722-bd1075ac15.zip/node_modules/react-query/es/core/subscribable.js"); 27864 27865 27866 27867 27868 27869// CLASS 27870var QueryCache = /*#__PURE__*/function (_Subscribable) { 27871 (0,_babel_runtime_helpers_esm_inheritsLoose__WEBPACK_IMPORTED_MODULE_0__["default"])(QueryCache, _Subscribable); 27872 27873 function QueryCache(config) { 27874 var _this; 27875 27876 _this = _Subscribable.call(this) || this; 27877 _this.config = config || {}; 27878 _this.queries = []; 27879 _this.queriesMap = {}; 27880 return _this; 27881 } 27882 27883 var _proto = QueryCache.prototype; 27884 27885 _proto.build = function build(client, options, state) { 27886 var _options$queryHash; 27887 27888 var queryKey = options.queryKey; 27889 var queryHash = (_options$queryHash = options.queryHash) != null ? _options$queryHash : (0,_utils__WEBPACK_IMPORTED_MODULE_1__.hashQueryKeyByOptions)(queryKey, options); 27890 var query = this.get(queryHash); 27891 27892 if (!query) { 27893 query = new _query__WEBPACK_IMPORTED_MODULE_2__.Query({ 27894 cache: this, 27895 queryKey: queryKey, 27896 queryHash: queryHash, 27897 options: client.defaultQueryOptions(options), 27898 state: state, 27899 defaultOptions: client.getQueryDefaults(queryKey) 27900 }); 27901 this.add(query); 27902 } 27903 27904 return query; 27905 }; 27906 27907 _proto.add = function add(query) { 27908 if (!this.queriesMap[query.queryHash]) { 27909 this.queriesMap[query.queryHash] = query; 27910 this.queries.push(query); 27911 this.notify({ 27912 type: 'queryAdded', 27913 query: query 27914 }); 27915 } 27916 }; 27917 27918 _proto.remove = function remove(query) { 27919 var queryInMap = this.queriesMap[query.queryHash]; 27920 27921 if (queryInMap) { 27922 query.destroy(); 27923 this.queries = this.queries.filter(function (x) { 27924 return x !== query; 27925 }); 27926 27927 if (queryInMap === query) { 27928 delete this.queriesMap[query.queryHash]; 27929 } 27930 27931 this.notify({ 27932 type: 'queryRemoved', 27933 query: query 27934 }); 27935 } 27936 }; 27937 27938 _proto.clear = function clear() { 27939 var _this2 = this; 27940 27941 _notifyManager__WEBPACK_IMPORTED_MODULE_3__.notifyManager.batch(function () { 27942 _this2.queries.forEach(function (query) { 27943 _this2.remove(query); 27944 }); 27945 }); 27946 }; 27947 27948 _proto.get = function get(queryHash) { 27949 return this.queriesMap[queryHash]; 27950 }; 27951 27952 _proto.getAll = function getAll() { 27953 return this.queries; 27954 }; 27955 27956 _proto.find = function find(arg1, arg2) { 27957 var _parseFilterArgs = (0,_utils__WEBPACK_IMPORTED_MODULE_1__.parseFilterArgs)(arg1, arg2), 27958 filters = _parseFilterArgs[0]; 27959 27960 if (typeof filters.exact === 'undefined') { 27961 filters.exact = true; 27962 } 27963 27964 return this.queries.find(function (query) { 27965 return (0,_utils__WEBPACK_IMPORTED_MODULE_1__.matchQuery)(filters, query); 27966 }); 27967 }; 27968 27969 _proto.findAll = function findAll(arg1, arg2) { 27970 var _parseFilterArgs2 = (0,_utils__WEBPACK_IMPORTED_MODULE_1__.parseFilterArgs)(arg1, arg2), 27971 filters = _parseFilterArgs2[0]; 27972 27973 return filters ? this.queries.filter(function (query) { 27974 return (0,_utils__WEBPACK_IMPORTED_MODULE_1__.matchQuery)(filters, query); 27975 }) : this.queries; 27976 }; 27977 27978 _proto.notify = function notify(event) { 27979 var _this3 = this; 27980 27981 _notifyManager__WEBPACK_IMPORTED_MODULE_3__.notifyManager.batch(function () { 27982 _this3.listeners.forEach(function (listener) { 27983 listener(event); 27984 }); 27985 }); 27986 }; 27987 27988 _proto.onFocus = function onFocus() { 27989 var _this4 = this; 27990 27991 _notifyManager__WEBPACK_IMPORTED_MODULE_3__.notifyManager.batch(function () { 27992 _this4.queries.forEach(function (query) { 27993 query.onFocus(); 27994 }); 27995 }); 27996 }; 27997 27998 _proto.onOnline = function onOnline() { 27999 var _this5 = this; 28000 28001 _notifyManager__WEBPACK_IMPORTED_MODULE_3__.notifyManager.batch(function () { 28002 _this5.queries.forEach(function (query) { 28003 query.onOnline(); 28004 }); 28005 }); 28006 }; 28007 28008 return QueryCache; 28009}(_subscribable__WEBPACK_IMPORTED_MODULE_4__.Subscribable); 28010 28011/***/ }), 28012
vendor: 15,073 bytes, lines 28013-28352
28013/***/ "./.yarn/__virtual__/react-query-virtual-cd72c42dd3/0/cache/react-query-npm-3.12.0-415d3b7722-bd1075ac15.zip/node_modules/react-query/es/core/queryClient.js": 28014/*!*******************************************************************************************************************************************************************!*\ 28015 !*** ./.yarn/__virtual__/react-query-virtual-cd72c42dd3/0/cache/react-query-npm-3.12.0-415d3b7722-bd1075ac15.zip/node_modules/react-query/es/core/queryClient.js ***! 28016 \*******************************************************************************************************************************************************************/ 28017/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { 28018 28019"use strict"; 28020__webpack_require__.r(__webpack_exports__); 28021/* harmony export */ __webpack_require__.d(__webpack_exports__, { 28022/* harmony export */ "QueryClient": () => (/* binding */ QueryClient) 28023/* harmony export */ }); 28024/* harmony import */ var _babel_runtime_helpers_esm_extends__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @babel/runtime/helpers/esm/extends */ "./.yarn/cache/@babel-runtime-npm-7.18.9-28ca6b5f61-254985e146.zip/node_modules/@babel/runtime/helpers/esm/extends.js"); 28025/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./utils */ "./.yarn/__virtual__/react-query-virtual-cd72c42dd3/0/cache/react-query-npm-3.12.0-415d3b7722-bd1075ac15.zip/node_modules/react-query/es/core/utils.js"); 28026/* harmony import */ var _queryCache__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./queryCache */ "./.yarn/__virtual__/react-query-virtual-cd72c42dd3/0/cache/react-query-npm-3.12.0-415d3b7722-bd1075ac15.zip/node_modules/react-query/es/core/queryCache.js"); 28027/* harmony import */ var _mutationCache__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./mutationCache */ "./.yarn/__virtual__/react-query-virtual-cd72c42dd3/0/cache/react-query-npm-3.12.0-415d3b7722-bd1075ac15.zip/node_modules/react-query/es/core/mutationCache.js"); 28028/* harmony import */ var _focusManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./focusManager */ "./.yarn/__virtual__/react-query-virtual-cd72c42dd3/0/cache/react-query-npm-3.12.0-415d3b7722-bd1075ac15.zip/node_modules/react-query/es/core/focusManager.js"); 28029/* harmony import */ var _onlineManager__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./onlineManager */ "./.yarn/__virtual__/react-query-virtual-cd72c42dd3/0/cache/react-query-npm-3.12.0-415d3b7722-bd1075ac15.zip/node_modules/react-query/es/core/onlineManager.js"); 28030/* harmony import */ var _notifyManager__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./notifyManager */ "./.yarn/__virtual__/react-query-virtual-cd72c42dd3/0/cache/react-query-npm-3.12.0-415d3b7722-bd1075ac15.zip/node_modules/react-query/es/core/notifyManager.js"); 28031/* harmony import */ var _infiniteQueryBehavior__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./infiniteQueryBehavior */ "./.yarn/__virtual__/react-query-virtual-cd72c42dd3/0/cache/react-query-npm-3.12.0-415d3b7722-bd1075ac15.zip/node_modules/react-query/es/core/infiniteQueryBehavior.js"); 28032 28033 28034 28035 28036 28037 28038 28039 // TYPES 28040 28041// CLASS 28042var QueryClient = /*#__PURE__*/function () { 28043 function QueryClient(config) { 28044 if (config === void 0) { 28045 config = {}; 28046 } 28047 28048 this.queryCache = config.queryCache || new _queryCache__WEBPACK_IMPORTED_MODULE_1__.QueryCache(); 28049 this.mutationCache = config.mutationCache || new _mutationCache__WEBPACK_IMPORTED_MODULE_2__.MutationCache(); 28050 this.defaultOptions = config.defaultOptions || {}; 28051 this.queryDefaults = []; 28052 this.mutationDefaults = []; 28053 } 28054 28055 var _proto = QueryClient.prototype; 28056 28057 _proto.mount = function mount() { 28058 var _this = this; 28059 28060 this.unsubscribeFocus = _focusManager__WEBPACK_IMPORTED_MODULE_3__.focusManager.subscribe(function () { 28061 if (_focusManager__WEBPACK_IMPORTED_MODULE_3__.focusManager.isFocused() && _onlineManager__WEBPACK_IMPORTED_MODULE_4__.onlineManager.isOnline()) { 28062 _this.mutationCache.onFocus(); 28063 28064 _this.queryCache.onFocus(); 28065 } 28066 }); 28067 this.unsubscribeOnline = _onlineManager__WEBPACK_IMPORTED_MODULE_4__.onlineManager.subscribe(function () { 28068 if (_focusManager__WEBPACK_IMPORTED_MODULE_3__.focusManager.isFocused() && _onlineManager__WEBPACK_IMPORTED_MODULE_4__.onlineManager.isOnline()) { 28069 _this.mutationCache.onOnline(); 28070 28071 _this.queryCache.onOnline(); 28072 } 28073 }); 28074 }; 28075 28076 _proto.unmount = function unmount() { 28077 var _this$unsubscribeFocu, _this$unsubscribeOnli; 28078 28079 (_this$unsubscribeFocu = this.unsubscribeFocus) == null ? void 0 : _this$unsubscribeFocu.call(this); 28080 (_this$unsubscribeOnli = this.unsubscribeOnline) == null ? void 0 : _this$unsubscribeOnli.call(this); 28081 }; 28082 28083 _proto.isFetching = function isFetching(arg1, arg2) { 28084 var _parseFilterArgs = (0,_utils__WEBPACK_IMPORTED_MODULE_5__.parseFilterArgs)(arg1, arg2), 28085 filters = _parseFilterArgs[0]; 28086 28087 filters.fetching = true; 28088 return this.queryCache.findAll(filters).length; 28089 }; 28090 28091 _proto.getQueryData = function getQueryData(queryKey, filters) { 28092 var _this$queryCache$find; 28093 28094 return (_this$queryCache$find = this.queryCache.find(queryKey, filters)) == null ? void 0 : _this$queryCache$find.state.data; 28095 }; 28096 28097 _proto.setQueryData = function setQueryData(queryKey, updater, options) { 28098 var parsedOptions = (0,_utils__WEBPACK_IMPORTED_MODULE_5__.parseQueryArgs)(queryKey); 28099 var defaultedOptions = this.defaultQueryOptions(parsedOptions); 28100 return this.queryCache.build(this, defaultedOptions).setData(updater, options); 28101 }; 28102 28103 _proto.getQueryState = function getQueryState(queryKey, filters) { 28104 var _this$queryCache$find2; 28105 28106 return (_this$queryCache$find2 = this.queryCache.find(queryKey, filters)) == null ? void 0 : _this$queryCache$find2.state; 28107 }; 28108 28109 _proto.removeQueries = function removeQueries(arg1, arg2) { 28110 var _parseFilterArgs2 = (0,_utils__WEBPACK_IMPORTED_MODULE_5__.parseFilterArgs)(arg1, arg2), 28111 filters = _parseFilterArgs2[0]; 28112 28113 var queryCache = this.queryCache; 28114 _notifyManager__WEBPACK_IMPORTED_MODULE_6__.notifyManager.batch(function () { 28115 queryCache.findAll(filters).forEach(function (query) { 28116 queryCache.remove(query); 28117 }); 28118 }); 28119 }; 28120 28121 _proto.resetQueries = function resetQueries(arg1, arg2, arg3) { 28122 var _this2 = this; 28123 28124 var _parseFilterArgs3 = (0,_utils__WEBPACK_IMPORTED_MODULE_5__.parseFilterArgs)(arg1, arg2, arg3), 28125 filters = _parseFilterArgs3[0], 28126 options = _parseFilterArgs3[1]; 28127 28128 var queryCache = this.queryCache; 28129 28130 var refetchFilters = (0,_babel_runtime_helpers_esm_extends__WEBPACK_IMPORTED_MODULE_0__["default"])({}, filters, { 28131 active: true 28132 }); 28133 28134 return _notifyManager__WEBPACK_IMPORTED_MODULE_6__.notifyManager.batch(function () { 28135 queryCache.findAll(filters).forEach(function (query) { 28136 query.reset(); 28137 }); 28138 return _this2.refetchQueries(refetchFilters, options); 28139 }); 28140 }; 28141 28142 _proto.cancelQueries = function cancelQueries(arg1, arg2, arg3) { 28143 var _this3 = this; 28144 28145 var _parseFilterArgs4 = (0,_utils__WEBPACK_IMPORTED_MODULE_5__.parseFilterArgs)(arg1, arg2, arg3), 28146 filters = _parseFilterArgs4[0], 28147 _parseFilterArgs4$ = _parseFilterArgs4[1], 28148 cancelOptions = _parseFilterArgs4$ === void 0 ? {} : _parseFilterArgs4$; 28149 28150 if (typeof cancelOptions.revert === 'undefined') { 28151 cancelOptions.revert = true; 28152 } 28153 28154 var promises = _notifyManager__WEBPACK_IMPORTED_MODULE_6__.notifyManager.batch(function () { 28155 return _this3.queryCache.findAll(filters).map(function (query) { 28156 return query.cancel(cancelOptions); 28157 }); 28158 }); 28159 return Promise.all(promises).then(_utils__WEBPACK_IMPORTED_MODULE_5__.noop).catch(_utils__WEBPACK_IMPORTED_MODULE_5__.noop); 28160 }; 28161 28162 _proto.invalidateQueries = function invalidateQueries(arg1, arg2, arg3) { 28163 var _filters$refetchActiv, 28164 _filters$refetchInact, 28165 _this4 = this; 28166 28167 var _parseFilterArgs5 = (0,_utils__WEBPACK_IMPORTED_MODULE_5__.parseFilterArgs)(arg1, arg2, arg3), 28168 filters = _parseFilterArgs5[0], 28169 options = _parseFilterArgs5[1]; 28170 28171 var refetchFilters = (0,_babel_runtime_helpers_esm_extends__WEBPACK_IMPORTED_MODULE_0__["default"])({}, filters, { 28172 active: (_filters$refetchActiv = filters.refetchActive) != null ? _filters$refetchActiv : true, 28173 inactive: (_filters$refetchInact = filters.refetchInactive) != null ? _filters$refetchInact : false 28174 }); 28175 28176 return _notifyManager__WEBPACK_IMPORTED_MODULE_6__.notifyManager.batch(function () { 28177 _this4.queryCache.findAll(filters).forEach(function (query) { 28178 query.invalidate(); 28179 }); 28180 28181 return _this4.refetchQueries(refetchFilters, options); 28182 }); 28183 }; 28184 28185 _proto.refetchQueries = function refetchQueries(arg1, arg2, arg3) { 28186 var _this5 = this; 28187 28188 var _parseFilterArgs6 = (0,_utils__WEBPACK_IMPORTED_MODULE_5__.parseFilterArgs)(arg1, arg2, arg3), 28189 filters = _parseFilterArgs6[0], 28190 options = _parseFilterArgs6[1]; 28191 28192 var promises = _notifyManager__WEBPACK_IMPORTED_MODULE_6__.notifyManager.batch(function () { 28193 return _this5.queryCache.findAll(filters).map(function (query) { 28194 return query.fetch(); 28195 }); 28196 }); 28197 var promise = Promise.all(promises).then(_utils__WEBPACK_IMPORTED_MODULE_5__.noop); 28198 28199 if (!(options == null ? void 0 : options.throwOnError)) { 28200 promise = promise.catch(_utils__WEBPACK_IMPORTED_MODULE_5__.noop); 28201 } 28202 28203 return promise; 28204 }; 28205 28206 _proto.fetchQuery = function fetchQuery(arg1, arg2, arg3) { 28207 var parsedOptions = (0,_utils__WEBPACK_IMPORTED_MODULE_5__.parseQueryArgs)(arg1, arg2, arg3); 28208 var defaultedOptions = this.defaultQueryOptions(parsedOptions); // https://github.com/tannerlinsley/react-query/issues/652 28209 28210 if (typeof defaultedOptions.retry === 'undefined') { 28211 defaultedOptions.retry = false; 28212 } 28213 28214 var query = this.queryCache.build(this, defaultedOptions); 28215 return query.isStaleByTime(defaultedOptions.staleTime) ? query.fetch(defaultedOptions) : Promise.resolve(query.state.data); 28216 }; 28217 28218 _proto.prefetchQuery = function prefetchQuery(arg1, arg2, arg3) { 28219 return this.fetchQuery(arg1, arg2, arg3).then(_utils__WEBPACK_IMPORTED_MODULE_5__.noop).catch(_utils__WEBPACK_IMPORTED_MODULE_5__.noop); 28220 }; 28221 28222 _proto.fetchInfiniteQuery = function fetchInfiniteQuery(arg1, arg2, arg3) { 28223 var parsedOptions = (0,_utils__WEBPACK_IMPORTED_MODULE_5__.parseQueryArgs)(arg1, arg2, arg3); 28224 parsedOptions.behavior = (0,_infiniteQueryBehavior__WEBPACK_IMPORTED_MODULE_7__.infiniteQueryBehavior)(); 28225 return this.fetchQuery(parsedOptions); 28226 }; 28227 28228 _proto.prefetchInfiniteQuery = function prefetchInfiniteQuery(arg1, arg2, arg3) { 28229 return this.fetchInfiniteQuery(arg1, arg2, arg3).then(_utils__WEBPACK_IMPORTED_MODULE_5__.noop).catch(_utils__WEBPACK_IMPORTED_MODULE_5__.noop); 28230 }; 28231 28232 _proto.cancelMutations = function cancelMutations() { 28233 var _this6 = this; 28234 28235 var promises = _notifyManager__WEBPACK_IMPORTED_MODULE_6__.notifyManager.batch(function () { 28236 return _this6.mutationCache.getAll().map(function (mutation) { 28237 return mutation.cancel(); 28238 }); 28239 }); 28240 return Promise.all(promises).then(_utils__WEBPACK_IMPORTED_MODULE_5__.noop).catch(_utils__WEBPACK_IMPORTED_MODULE_5__.noop); 28241 }; 28242 28243 _proto.resumePausedMutations = function resumePausedMutations() { 28244 return this.getMutationCache().resumePausedMutations(); 28245 }; 28246 28247 _proto.executeMutation = function executeMutation(options) { 28248 return this.mutationCache.build(this, options).execute(); 28249 }; 28250 28251 _proto.getQueryCache = function getQueryCache() { 28252 return this.queryCache; 28253 }; 28254 28255 _proto.getMutationCache = function getMutationCache() { 28256 return this.mutationCache; 28257 }; 28258 28259 _proto.getDefaultOptions = function getDefaultOptions() { 28260 return this.defaultOptions; 28261 }; 28262 28263 _proto.setDefaultOptions = function setDefaultOptions(options) { 28264 this.defaultOptions = options; 28265 }; 28266 28267 _proto.setQueryDefaults = function setQueryDefaults(queryKey, options) { 28268 var result = this.queryDefaults.find(function (x) { 28269 return (0,_utils__WEBPACK_IMPORTED_MODULE_5__.hashQueryKey)(queryKey) === (0,_utils__WEBPACK_IMPORTED_MODULE_5__.hashQueryKey)(x.queryKey); 28270 }); 28271 28272 if (result) { 28273 result.defaultOptions = options; 28274 } else { 28275 this.queryDefaults.push({ 28276 queryKey: queryKey, 28277 defaultOptions: options 28278 }); 28279 } 28280 }; 28281 28282 _proto.getQueryDefaults = function getQueryDefaults(queryKey) { 28283 var _this$queryDefaults$f; 28284 28285 return queryKey ? (_this$queryDefaults$f = this.queryDefaults.find(function (x) { 28286 return (0,_utils__WEBPACK_IMPORTED_MODULE_5__.partialMatchKey)(queryKey, x.queryKey); 28287 })) == null ? void 0 : _this$queryDefaults$f.defaultOptions : undefined; 28288 }; 28289 28290 _proto.setMutationDefaults = function setMutationDefaults(mutationKey, options) { 28291 var result = this.mutationDefaults.find(function (x) { 28292 return (0,_utils__WEBPACK_IMPORTED_MODULE_5__.hashQueryKey)(mutationKey) === (0,_utils__WEBPACK_IMPORTED_MODULE_5__.hashQueryKey)(x.mutationKey); 28293 }); 28294 28295 if (result) { 28296 result.defaultOptions = options; 28297 } else { 28298 this.mutationDefaults.push({ 28299 mutationKey: mutationKey, 28300 defaultOptions: options 28301 }); 28302 } 28303 }; 28304 28305 _proto.getMutationDefaults = function getMutationDefaults(mutationKey) { 28306 var _this$mutationDefault; 28307 28308 return mutationKey ? (_this$mutationDefault = this.mutationDefaults.find(function (x) { 28309 return (0,_utils__WEBPACK_IMPORTED_MODULE_5__.partialMatchKey)(mutationKey, x.mutationKey); 28310 })) == null ? void 0 : _this$mutationDefault.defaultOptions : undefined; 28311 }; 28312 28313 _proto.defaultQueryOptions = function defaultQueryOptions(options) { 28314 if (options == null ? void 0 : options._defaulted) { 28315 return options; 28316 } 28317 28318 var defaultedOptions = (0,_babel_runtime_helpers_esm_extends__WEBPACK_IMPORTED_MODULE_0__["default"])({}, this.defaultOptions.queries, this.getQueryDefaults(options == null ? void 0 : options.queryKey), options, { 28319 _defaulted: true 28320 }); 28321 28322 if (!defaultedOptions.queryHash && defaultedOptions.queryKey) { 28323 defaultedOptions.queryHash = (0,_utils__WEBPACK_IMPORTED_MODULE_5__.hashQueryKeyByOptions)(defaultedOptions.queryKey, defaultedOptions); 28324 } 28325 28326 return defaultedOptions; 28327 }; 28328 28329 _proto.defaultQueryObserverOptions = function defaultQueryObserverOptions(options) { 28330 return this.defaultQueryOptions(options); 28331 }; 28332 28333 _proto.defaultMutationOptions = function defaultMutationOptions(options) { 28334 if (options == null ? void 0 : options._defaulted) { 28335 return options; 28336 } 28337 28338 return (0,_babel_runtime_helpers_esm_extends__WEBPACK_IMPORTED_MODULE_0__["default"])({}, this.defaultOptions.mutations, this.getMutationDefaults(options == null ? void 0 : options.mutationKey), options, { 28339 _defaulted: true 28340 }); 28341 }; 28342 28343 _proto.clear = function clear() { 28344 this.queryCache.clear(); 28345 this.mutationCache.clear(); 28346 }; 28347 28348 return QueryClient; 28349}(); 28350 28351/***/ }), 28352
vendor: 6,391 bytes, lines 28353-28523
28353/***/ "./.yarn/__virtual__/react-query-virtual-cd72c42dd3/0/cache/react-query-npm-3.12.0-415d3b7722-bd1075ac15.zip/node_modules/react-query/es/core/retryer.js": 28354/*!***************************************************************************************************************************************************************!*\ 28355 !*** ./.yarn/__virtual__/react-query-virtual-cd72c42dd3/0/cache/react-query-npm-3.12.0-415d3b7722-bd1075ac15.zip/node_modules/react-query/es/core/retryer.js ***! 28356 \***************************************************************************************************************************************************************/ 28357/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { 28358 28359"use strict"; 28360__webpack_require__.r(__webpack_exports__); 28361/* harmony export */ __webpack_require__.d(__webpack_exports__, { 28362/* harmony export */ "CancelledError": () => (/* binding */ CancelledError), 28363/* harmony export */ "Retryer": () => (/* binding */ Retryer), 28364/* harmony export */ "isCancelable": () => (/* binding */ isCancelable), 28365/* harmony export */ "isCancelledError": () => (/* binding */ isCancelledError) 28366/* harmony export */ }); 28367/* harmony import */ var _focusManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./focusManager */ "./.yarn/__virtual__/react-query-virtual-cd72c42dd3/0/cache/react-query-npm-3.12.0-415d3b7722-bd1075ac15.zip/node_modules/react-query/es/core/focusManager.js"); 28368/* harmony import */ var _onlineManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./onlineManager */ "./.yarn/__virtual__/react-query-virtual-cd72c42dd3/0/cache/react-query-npm-3.12.0-415d3b7722-bd1075ac15.zip/node_modules/react-query/es/core/onlineManager.js"); 28369/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils */ "./.yarn/__virtual__/react-query-virtual-cd72c42dd3/0/cache/react-query-npm-3.12.0-415d3b7722-bd1075ac15.zip/node_modules/react-query/es/core/utils.js"); 28370 28371 28372 // TYPES 28373 28374function defaultRetryDelay(failureCount) { 28375 return Math.min(1000 * Math.pow(2, failureCount), 30000); 28376} 28377 28378function isCancelable(value) { 28379 return typeof (value == null ? void 0 : value.cancel) === 'function'; 28380} 28381var CancelledError = function CancelledError(options) { 28382 this.revert = options == null ? void 0 : options.revert; 28383 this.silent = options == null ? void 0 : options.silent; 28384}; 28385function isCancelledError(value) { 28386 return value instanceof CancelledError; 28387} // CLASS 28388 28389var Retryer = function Retryer(config) { 28390 var _this = this; 28391 28392 var cancelRetry = false; 28393 var cancelFn; 28394 var continueFn; 28395 var promiseResolve; 28396 var promiseReject; 28397 28398 this.cancel = function (cancelOptions) { 28399 return cancelFn == null ? void 0 : cancelFn(cancelOptions); 28400 }; 28401 28402 this.cancelRetry = function () { 28403 cancelRetry = true; 28404 }; 28405 28406 this.continue = function () { 28407 return continueFn == null ? void 0 : continueFn(); 28408 }; 28409 28410 this.failureCount = 0; 28411 this.isPaused = false; 28412 this.isResolved = false; 28413 this.isTransportCancelable = false; 28414 this.promise = new Promise(function (outerResolve, outerReject) { 28415 promiseResolve = outerResolve; 28416 promiseReject = outerReject; 28417 }); 28418 28419 var resolve = function resolve(value) { 28420 if (!_this.isResolved) { 28421 _this.isResolved = true; 28422 config.onSuccess == null ? void 0 : config.onSuccess(value); 28423 continueFn == null ? void 0 : continueFn(); 28424 promiseResolve(value); 28425 } 28426 }; 28427 28428 var reject = function reject(value) { 28429 if (!_this.isResolved) { 28430 _this.isResolved = true; 28431 config.onError == null ? void 0 : config.onError(value); 28432 continueFn == null ? void 0 : continueFn(); 28433 promiseReject(value); 28434 } 28435 }; 28436 28437 var pause = function pause() { 28438 return new Promise(function (continueResolve) { 28439 continueFn = continueResolve; 28440 _this.isPaused = true; 28441 config.onPause == null ? void 0 : config.onPause(); 28442 }).then(function () { 28443 continueFn = undefined; 28444 _this.isPaused = false; 28445 config.onContinue == null ? void 0 : config.onContinue(); 28446 }); 28447 }; // Create loop function 28448 28449 28450 var run = function run() { 28451 // Do nothing if already resolved 28452 if (_this.isResolved) { 28453 return; 28454 } 28455 28456 var promiseOrValue; // Execute query 28457 28458 try { 28459 promiseOrValue = config.fn(); 28460 } catch (error) { 28461 promiseOrValue = Promise.reject(error); 28462 } // Create callback to cancel this fetch 28463 28464 28465 cancelFn = function cancelFn(cancelOptions) { 28466 if (!_this.isResolved) { 28467 reject(new CancelledError(cancelOptions)); // Cancel transport if supported 28468 28469 if (isCancelable(promiseOrValue)) { 28470 try { 28471 promiseOrValue.cancel(); 28472 } catch (_unused) {} 28473 } 28474 } 28475 }; // Check if the transport layer support cancellation 28476 28477 28478 _this.isTransportCancelable = isCancelable(promiseOrValue); 28479 Promise.resolve(promiseOrValue).then(resolve).catch(function (error) { 28480 var _config$retry, _config$retryDelay; 28481 28482 // Stop if the fetch is already resolved 28483 if (_this.isResolved) { 28484 return; 28485 } // Do we need to retry the request? 28486 28487 28488 var retry = (_config$retry = config.retry) != null ? _config$retry : 3; 28489 var retryDelay = (_config$retryDelay = config.retryDelay) != null ? _config$retryDelay : defaultRetryDelay; 28490 var delay = typeof retryDelay === 'function' ? retryDelay(_this.failureCount, error) : retryDelay; 28491 var shouldRetry = retry === true || typeof retry === 'number' && _this.failureCount < retry || typeof retry === 'function' && retry(_this.failureCount, error); 28492 28493 if (cancelRetry || !shouldRetry) { 28494 // We are done if the query does not need to be retried 28495 reject(error); 28496 return; 28497 } 28498 28499 _this.failureCount++; // Notify on fail 28500 28501 config.onFail == null ? void 0 : config.onFail(_this.failureCount, error); // Delay 28502 28503 (0,_utils__WEBPACK_IMPORTED_MODULE_0__.sleep)(delay) // Pause if the document is not visible or when the device is offline 28504 .then(function () { 28505 if (!_focusManager__WEBPACK_IMPORTED_MODULE_1__.focusManager.isFocused() || !_onlineManager__WEBPACK_IMPORTED_MODULE_2__.onlineManager.isOnline()) { 28506 return pause(); 28507 } 28508 }).then(function () { 28509 if (cancelRetry) { 28510 reject(error); 28511 } else { 28512 run(); 28513 } 28514 }); 28515 }); 28516 }; // Start loop 28517 28518 28519 run(); 28520}; 28521 28522/***/ }), 28523
vendor: 1,777 bytes, lines 28524-28574
28524/***/ "./.yarn/__virtual__/react-query-virtual-cd72c42dd3/0/cache/react-query-npm-3.12.0-415d3b7722-bd1075ac15.zip/node_modules/react-query/es/core/subscribable.js": 28525/*!********************************************************************************************************************************************************************!*\ 28526 !*** ./.yarn/__virtual__/react-query-virtual-cd72c42dd3/0/cache/react-query-npm-3.12.0-415d3b7722-bd1075ac15.zip/node_modules/react-query/es/core/subscribable.js ***! 28527 \********************************************************************************************************************************************************************/ 28528/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { 28529 28530"use strict"; 28531__webpack_require__.r(__webpack_exports__); 28532/* harmony export */ __webpack_require__.d(__webpack_exports__, { 28533/* harmony export */ "Subscribable": () => (/* binding */ Subscribable) 28534/* harmony export */ }); 28535var Subscribable = /*#__PURE__*/function () { 28536 function Subscribable() { 28537 this.listeners = []; 28538 } 28539 28540 var _proto = Subscribable.prototype; 28541 28542 _proto.subscribe = function subscribe(listener) { 28543 var _this = this; 28544 28545 var callback = listener || function () { 28546 return undefined; 28547 }; 28548 28549 this.listeners.push(callback); 28550 this.onSubscribe(); 28551 return function () { 28552 _this.listeners = _this.listeners.filter(function (x) { 28553 return x !== callback; 28554 }); 28555 28556 _this.onUnsubscribe(); 28557 }; 28558 }; 28559 28560 _proto.hasListeners = function hasListeners() { 28561 return this.listeners.length > 0; 28562 }; 28563 28564 _proto.onSubscribe = function onSubscribe() {// Do nothing 28565 }; 28566 28567 _proto.onUnsubscribe = function onUnsubscribe() {// Do nothing 28568 }; 28569 28570 return Subscribable; 28571}(); 28572 28573/***/ }), 28574
vendor: 9,669 bytes, lines 28575-28888
28575/***/ "./.yarn/__virtual__/react-query-virtual-cd72c42dd3/0/cache/react-query-npm-3.12.0-415d3b7722-bd1075ac15.zip/node_modules/react-query/es/core/utils.js": 28576/*!*************************************************************************************************************************************************************!*\ 28577 !*** ./.yarn/__virtual__/react-query-virtual-cd72c42dd3/0/cache/react-query-npm-3.12.0-415d3b7722-bd1075ac15.zip/node_modules/react-query/es/core/utils.js ***! 28578 \*************************************************************************************************************************************************************/ 28579/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { 28580 28581"use strict"; 28582__webpack_require__.r(__webpack_exports__); 28583/* harmony export */ __webpack_require__.d(__webpack_exports__, { 28584/* harmony export */ "difference": () => (/* binding */ difference), 28585/* harmony export */ "ensureArray": () => (/* binding */ ensureArray), 28586/* harmony export */ "functionalUpdate": () => (/* binding */ functionalUpdate), 28587/* harmony export */ "hashQueryKey": () => (/* binding */ hashQueryKey), 28588/* harmony export */ "hashQueryKeyByOptions": () => (/* binding */ hashQueryKeyByOptions), 28589/* harmony export */ "isError": () => (/* binding */ isError), 28590/* harmony export */ "isPlainObject": () => (/* binding */ isPlainObject), 28591/* harmony export */ "isQueryKey": () => (/* binding */ isQueryKey), 28592/* harmony export */ "isServer": () => (/* binding */ isServer), 28593/* harmony export */ "isValidTimeout": () => (/* binding */ isValidTimeout), 28594/* harmony export */ "matchQuery": () => (/* binding */ matchQuery), 28595/* harmony export */ "noop": () => (/* binding */ noop), 28596/* harmony export */ "parseFilterArgs": () => (/* binding */ parseFilterArgs), 28597/* harmony export */ "parseMutationArgs": () => (/* binding */ parseMutationArgs), 28598/* harmony export */ "parseQueryArgs": () => (/* binding */ parseQueryArgs), 28599/* harmony export */ "partialDeepEqual": () => (/* binding */ partialDeepEqual), 28600/* harmony export */ "partialMatchKey": () => (/* binding */ partialMatchKey), 28601/* harmony export */ "replaceAt": () => (/* binding */ replaceAt), 28602/* harmony export */ "replaceEqualDeep": () => (/* binding */ replaceEqualDeep), 28603/* harmony export */ "scheduleMicrotask": () => (/* binding */ scheduleMicrotask), 28604/* harmony export */ "shallowEqualObjects": () => (/* binding */ shallowEqualObjects), 28605/* harmony export */ "sleep": () => (/* binding */ sleep), 28606/* harmony export */ "stableValueHash": () => (/* binding */ stableValueHash), 28607/* harmony export */ "timeUntilStale": () => (/* binding */ timeUntilStale) 28608/* harmony export */ }); 28609/* harmony import */ var _babel_runtime_helpers_esm_extends__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @babel/runtime/helpers/esm/extends */ "./.yarn/cache/@babel-runtime-npm-7.18.9-28ca6b5f61-254985e146.zip/node_modules/@babel/runtime/helpers/esm/extends.js"); 28610 28611// TYPES 28612// UTILS 28613var isServer = typeof window === 'undefined'; 28614function noop() { 28615 return undefined; 28616} 28617function functionalUpdate(updater, input) { 28618 return typeof updater === 'function' ? updater(input) : updater; 28619} 28620function isValidTimeout(value) { 28621 return typeof value === 'number' && value >= 0 && value !== Infinity; 28622} 28623function ensureArray(value) { 28624 return Array.isArray(value) ? value : [value]; 28625} 28626function difference(array1, array2) { 28627 return array1.filter(function (x) { 28628 return array2.indexOf(x) === -1; 28629 }); 28630} 28631function replaceAt(array, index, value) { 28632 var copy = array.slice(0); 28633 copy[index] = value; 28634 return copy; 28635} 28636function timeUntilStale(updatedAt, staleTime) { 28637 return Math.max(updatedAt + (staleTime || 0) - Date.now(), 0); 28638} 28639function parseQueryArgs(arg1, arg2, arg3) { 28640 if (!isQueryKey(arg1)) { 28641 return arg1; 28642 } 28643 28644 if (typeof arg2 === 'function') { 28645 return (0,_babel_runtime_helpers_esm_extends__WEBPACK_IMPORTED_MODULE_0__["default"])({}, arg3, { 28646 queryKey: arg1, 28647 queryFn: arg2 28648 }); 28649 } 28650 28651 return (0,_babel_runtime_helpers_esm_extends__WEBPACK_IMPORTED_MODULE_0__["default"])({}, arg2, { 28652 queryKey: arg1 28653 }); 28654} 28655function parseMutationArgs(arg1, arg2, arg3) { 28656 if (isQueryKey(arg1)) { 28657 if (typeof arg2 === 'function') { 28658 return (0,_babel_runtime_helpers_esm_extends__WEBPACK_IMPORTED_MODULE_0__["default"])({}, arg3, { 28659 mutationKey: arg1, 28660 mutationFn: arg2 28661 }); 28662 } 28663 28664 return (0,_babel_runtime_helpers_esm_extends__WEBPACK_IMPORTED_MODULE_0__["default"])({}, arg2, { 28665 mutationKey: arg1 28666 }); 28667 } 28668 28669 if (typeof arg1 === 'function') { 28670 return (0,_babel_runtime_helpers_esm_extends__WEBPACK_IMPORTED_MODULE_0__["default"])({}, arg2, { 28671 mutationFn: arg1 28672 }); 28673 } 28674 28675 return (0,_babel_runtime_helpers_esm_extends__WEBPACK_IMPORTED_MODULE_0__["default"])({}, arg1); 28676} 28677function parseFilterArgs(arg1, arg2, arg3) { 28678 return isQueryKey(arg1) ? [(0,_babel_runtime_helpers_esm_extends__WEBPACK_IMPORTED_MODULE_0__["default"])({}, arg2, { 28679 queryKey: arg1 28680 }), arg3] : [arg1 || {}, arg2]; 28681} 28682function matchQuery(filters, query) { 28683 var active = filters.active, 28684 exact = filters.exact, 28685 fetching = filters.fetching, 28686 inactive = filters.inactive, 28687 predicate = filters.predicate, 28688 queryKey = filters.queryKey, 28689 stale = filters.stale; 28690 28691 if (isQueryKey(queryKey)) { 28692 if (exact) { 28693 if (query.queryHash !== hashQueryKeyByOptions(queryKey, query.options)) { 28694 return false; 28695 } 28696 } else if (!partialMatchKey(query.queryKey, queryKey)) { 28697 return false; 28698 } 28699 } 28700 28701 var isActive; 28702 28703 if (inactive === false || active && !inactive) { 28704 isActive = true; 28705 } else if (active === false || inactive && !active) { 28706 isActive = false; 28707 } 28708 28709 if (typeof isActive === 'boolean' && query.isActive() !== isActive) { 28710 return false; 28711 } 28712 28713 if (typeof stale === 'boolean' && query.isStale() !== stale) { 28714 return false; 28715 } 28716 28717 if (typeof fetching === 'boolean' && query.isFetching() !== fetching) { 28718 return false; 28719 } 28720 28721 if (predicate && !predicate(query)) { 28722 return false; 28723 } 28724 28725 return true; 28726} 28727function hashQueryKeyByOptions(queryKey, options) { 28728 var hashFn = (options == null ? void 0 : options.queryKeyHashFn) || hashQueryKey; 28729 return hashFn(queryKey); 28730} 28731/** 28732 * Default query keys hash function. 28733 */ 28734 28735function hashQueryKey(queryKey) { 28736 var asArray = Array.isArray(queryKey) ? queryKey : [queryKey]; 28737 return stableValueHash(asArray); 28738} 28739/** 28740 * Hashes the value into a stable hash. 28741 */ 28742 28743function stableValueHash(value) { 28744 return JSON.stringify(value, function (_, val) { 28745 return isPlainObject(val) ? Object.keys(val).sort().reduce(function (result, key) { 28746 result[key] = val[key]; 28747 return result; 28748 }, {}) : val; 28749 }); 28750} 28751/** 28752 * Checks if key `b` partially matches with key `a`. 28753 */ 28754 28755function partialMatchKey(a, b) { 28756 return partialDeepEqual(ensureArray(a), ensureArray(b)); 28757} 28758/** 28759 * Checks if `b` partially matches with `a`. 28760 */ 28761 28762function partialDeepEqual(a, b) { 28763 if (a === b) { 28764 return true; 28765 } 28766 28767 if (typeof a !== typeof b) { 28768 return false; 28769 } 28770 28771 if (a && b && typeof a === 'object' && typeof b === 'object') { 28772 return !Object.keys(b).some(function (key) { 28773 return !partialDeepEqual(a[key], b[key]); 28774 }); 28775 } 28776 28777 return false; 28778} 28779/** 28780 * This function returns `a` if `b` is deeply equal. 28781 * If not, it will replace any deeply equal children of `b` with those of `a`. 28782 * This can be used for structural sharing between JSON values for example. 28783 */ 28784 28785function replaceEqualDeep(a, b) { 28786 if (a === b) { 28787 return a; 28788 } 28789 28790 var array = Array.isArray(a) && Array.isArray(b); 28791 28792 if (array || isPlainObject(a) && isPlainObject(b)) { 28793 var aSize = array ? a.length : Object.keys(a).length; 28794 var bItems = array ? b : Object.keys(b); 28795 var bSize = bItems.length; 28796 var copy = array ? [] : {}; 28797 var equalItems = 0; 28798 28799 for (var i = 0; i < bSize; i++) { 28800 var key = array ? i : bItems[i]; 28801 copy[key] = replaceEqualDeep(a[key], b[key]); 28802 28803 if (copy[key] === a[key]) { 28804 equalItems++; 28805 } 28806 } 28807 28808 return aSize === bSize && equalItems === aSize ? a : copy; 28809 } 28810 28811 return b; 28812} 28813/** 28814 * Shallow compare objects. Only works with objects that always have the same properties. 28815 */ 28816 28817function shallowEqualObjects(a, b) { 28818 if (a && !b || b && !a) { 28819 return false; 28820 } 28821 28822 for (var key in a) { 28823 if (a[key] !== b[key]) { 28824 return false; 28825 } 28826 } 28827 28828 return true; 28829} // Copied from: https://github.com/jonschlinkert/is-plain-object 28830 28831function isPlainObject(o) { 28832 if (!hasObjectPrototype(o)) { 28833 return false; 28834 } // If has modified constructor 28835 28836 28837 var ctor = o.constructor; 28838 28839 if (typeof ctor === 'undefined') { 28840 return true; 28841 } // If has modified prototype 28842 28843 28844 var prot = ctor.prototype; 28845 28846 if (!hasObjectPrototype(prot)) { 28847 return false; 28848 } // If constructor does not have an Object-specific method 28849 28850 28851 if (!prot.hasOwnProperty('isPrototypeOf')) { 28852 return false; 28853 } // Most likely a plain Object 28854 28855 28856 return true; 28857} 28858 28859function hasObjectPrototype(o) { 28860 return Object.prototype.toString.call(o) === '[object Object]'; 28861} 28862 28863function isQueryKey(value) { 28864 return typeof value === 'string' || Array.isArray(value); 28865} 28866function isError(value) { 28867 return value instanceof Error; 28868} 28869function sleep(timeout) { 28870 return new Promise(function (resolve) { 28871 setTimeout(resolve, timeout); 28872 }); 28873} 28874/** 28875 * Schedules a microtask. 28876 * This can be useful to schedule state updates after rendering. 28877 */ 28878 28879function scheduleMicrotask(callback) { 28880 Promise.resolve().then(callback).catch(function (error) { 28881 return setTimeout(function () { 28882 throw error; 28883 }); 28884 }); 28885} 28886 28887/***/ }), 28888
28889/***/ "./scripts/libraries/utils.js": 28890/*!************************************!*\ 28891 !*** ./scripts/libraries/utils.js ***! 28892 \************************************/ 28893/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { 28894 28895"use strict"; 28896__webpack_require__.r(__webpack_exports__); 28897/* harmony export */ __webpack_require__.d(__webpack_exports__, { 28898/* harmony export */ "Warn": () => (/* binding */ Warn), 28899/* harmony export */ "domIsReady": () => (/* binding */ domIsReady), 28900/* harmony export */ "watchAddedNodes": () => (/* binding */ watchAddedNodes) 28901/* harmony export */ }); 28902function Warn(...args) { 28903 window.console && window.console.warn(...args); 28904} 28905const watchAddedNodes = async (callback, querySelector, immediate = true) => { 28906 const throttle = await __webpack_require__.e(/*! import() */ "scripts_libraries__utilities_throttle_js").then(__webpack_require__.bind(__webpack_require__, /*! ./_utilities/throttle */ "./scripts/libraries/_utilities/throttle.js")); 28907 if (!callback || typeof callback !== "function") 28908 throw new Error("callback must be a function"); 28909 if (!querySelector) 28910 throw new Error("querySelector must have a value"); 28911 if (immediate) { 28912 const initialElements = Array.from(document.querySelectorAll(querySelector)); 28913 callback(initialElements); 28914 } 28915 const observer = new MutationObserver((mutationsList) => { 28916 let elements = []; 28917 const debouncedClbk = throttle.debounce( 28918 () => { 28919 callback(elements); 28920 }, 28921 250, 28922 false 28923 ); 28924 for (const mutation of mutationsList) { 28925 if (mutation.type === "childList") { 28926 const nodes = Array.from(mutation.addedNodes).filter((node) => node.nodeType === 1); 28927 const selfNodes = nodes.filter( 28928 (node) => !querySelector || node.matches(querySelector) 28929 ); 28930 const innerNodes = nodes.filter( 28931 (node) => querySelector && node.querySelector(querySelector) 28932 ).map((node) => Array.from(node.querySelectorAll(querySelector))).reduce((a, b) => a.concat(b), []); 28933 elements = [...elements, ...selfNodes, ...innerNodes]; 28934 } 28935 } 28936 if (elements && elements.length) { 28937 debouncedClbk(); 28938 } 28939 }); 28940 observer.observe(document, { 28941 childList: true, 28942 subtree: true 28943 }); 28944 return observer; 28945}; 28946const domIsReady = () => new Promise((resolve) => { 28947 if (document.readyState === "complete" || document.readyState === "interactive") { 28948 resolve(); 28949 } 28950 if (!document.attachEvent || typeof document.attachEvent === "undefined") { 28951 document.addEventListener("DOMContentLoaded", () => { 28952 resolve(); 28953 }); 28954 document.addEventListener("readystatechange", () => { 28955 if (document.readyState === "complete" || document.readyState === "interactive") { 28956 resolve(); 28957 } 28958 }); 28959 } else { 28960 document.attachEvent("onreadystatechange", () => { 28961 if (document.readyState === "complete" || document.readyState === "interactive") { 28962 resolve(); 28963 } 28964 }); 28965 } 28966}); 28967 28968 28969/***/ }), 28970
28971/***/ "./scripts/react/renderer.js": 28972/*!***********************************!*\ 28973 !*** ./scripts/react/renderer.js ***! 28974 \***********************************/ 28975/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { 28976 28977"use strict"; 28978__webpack_require__.r(__webpack_exports__); 28979/* harmony export */ __webpack_require__.d(__webpack_exports__, { 28980/* harmony export */ "ReactRenderer": () => (/* binding */ ReactRenderer), 28981/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) 28982/* harmony export */ }); 28983/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./.yarn/cache/react-npm-17.0.1-98658812fc-23ada2f8fe.zip/node_modules/react/index.js"); 28984/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react-dom */ "./.yarn/__virtual__/react-dom-virtual-fc19a1cf20/0/cache/react-dom-npm-17.0.1-588d0088ca-baaeb735ad.zip/node_modules/react-dom/index.js"); 28985/* harmony import */ var react_error_boundary__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! react-error-boundary */ "./.yarn/__virtual__/react-error-boundary-virtual-1d3c98507c/0/cache/react-error-boundary-npm-3.1.4-2310dba89e-7418637bf3.zip/node_modules/react-error-boundary/dist/react-error-boundary.umd.js"); 28986/* harmony import */ var react_error_boundary__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(react_error_boundary__WEBPACK_IMPORTED_MODULE_3__); 28987/* harmony import */ var react_query__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! react-query */ "./.yarn/__virtual__/react-query-virtual-cd72c42dd3/0/cache/react-query-npm-3.12.0-415d3b7722-bd1075ac15.zip/node_modules/react-query/es/core/queryClient.js"); 28988/* harmony import */ var _libraries_utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../libraries/utils */ "./scripts/libraries/utils.js"); 28989 28990 28991 28992 28993 28994 28995 28996class ReactRenderer { 28997 constructor() { 28998 this.init(); 28999 } 29000 init() { 29001 document.addEventListener("DOMContentLoaded", async () => { 29002 const reactRoot = this.createReactRoot(); 29003 const queryClient = this.createQueryClient(); 29004 const queryParams = this.getQueryParams(); 29005 const { enablehtmloptions } = queryParams || {}; 29006 const enableHTMLOptions = enablehtmloptions?.[0]; 29007 const ReactApp = await react__WEBPACK_IMPORTED_MODULE_0__.lazy( 29008 () => Promise.all(/*! import() */[__webpack_require__.e("vendors-_yarn_cache_date-fns-npm-2_29_2-da48c27e93-0ac440a105_zip_node_modules_date-fns_esm_d-0ea603"), __webpack_require__.e("vendors-_yarn___virtual___react-query-virtual-cd72c42dd3_0_cache_react-query-npm-3_12_0-415d3-d91854"), __webpack_require__.e("vendors-_yarn_cache_lodash-npm-4_17_21-6382451519-c08619c038_zip_node_modules_lodash_lodash_js"), __webpack_require__.e("vendors-_yarn_cache_prop-types-npm-15_8_1-17c71ee7ee-7d959caec0_zip_node_modules_prop-types_i-a0703c"), __webpack_require__.e("vendors-_yarn___virtual___react-intersection-observer-virtual-72f1bbc67d_0_cache_react-inters-a195ee"), __webpack_require__.e("vendors-_yarn___virtual___reach-utils-virtual-74f68e3a54_0_cache_reach-utils-npm-0_12_1-e1f5f-6f7acd"), __webpack_require__.e("vendors-_yarn___virtual___reach-dialog-virtual-a52501f8b5_0_cache_reach-dialog-npm-0_12_1-9bc-4a590f"), __webpack_require__.e("vendors-_yarn_cache_date-fns-npm-2_29_2-da48c27e93-0ac440a105_zip_node_modules_date-fns_esm_p-de25fc"), __webpack_require__.e("vendors-_yarn___virtual___react-spring-web-virtual-9322263b63_0_cache_react-spring-web-npm-9_-0e67f4"), __webpack_require__.e("vendors-_yarn_cache_brightcove-player-loader-npm-1_8_0-fa9f4ca49e-095bc1a3b4_zip_node_modules-c02406"), __webpack_require__.e("vendors-_yarn_unplugged_styled-components-virtual-66ed2408f5_node_modules_styled-components_d-701d97"), __webpack_require__.e("vendors-_yarn___virtual___react-i18next-virtual-c6e07a7a20_0_cache_react-i18next-npm-11_18_5--932d77"), __webpack_require__.e("scripts_react_shared_utils_js"), __webpack_require__.e("scripts_libraries__modules_tracking_snowplow_snowplowEventTrackers_js-scripts_libraries__modu-33d9b7"), __webpack_require__.e("scripts_libraries__modules_tracking_helpers_js-scripts_react_mls-lineups_utils_js-scripts_rea-57bac3"), __webpack_require__.e("scripts_react_mls-match-summary_utils_js"), __webpack_require__.e("scripts_react_brightcove-video-playlist_components_RequiredAuthModal_index_js-scripts_react_b-787aa5"), __webpack_require__.e("scripts_react_brightcove-video-playlist_main_js"), __webpack_require__.e("scripts_react_shared_components_BlockHeader_index_js-scripts_react_shared_hooks_useModalOptio-8af23e"), __webpack_require__.e("scripts_react_mls-horizontal-scoreboard_utils_js"), __webpack_require__.e("scripts_react_mls-match-list_components_MatchModal_MatchModal_js"), __webpack_require__.e("scripts_react_shared_components_Picture_index_js-scripts_react_shared_containers_ReactApp_index_js")]).then(__webpack_require__.bind(__webpack_require__, /*! ../react/shared/containers/ReactApp */ "./scripts/react/shared/containers/ReactApp/index.js")) 29009 ); 29010 const ReactModule = await react__WEBPACK_IMPORTED_MODULE_0__.lazy(() => __webpack_require__.e(/*! import() */ "scripts_react_ReactModule_js").then(__webpack_require__.bind(__webpack_require__, /*! ./ReactModule */ "./scripts/react/ReactModule.js"))); 29011 await (0,_libraries_utils__WEBPACK_IMPORTED_MODULE_2__.watchAddedNodes)((elements) => { 29012 (0,react_dom__WEBPACK_IMPORTED_MODULE_1__.render)(
29013 /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement( 29014 react_error_boundary__WEBPACK_IMPORTED_MODULE_3__.ErrorBoundary, 29015 { 29016 fallbackRender: ({ error }) => /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { style: { display: "none" } }, /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement("pre", null, error.message)) 29017 }, 29018 /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement(react__WEBPACK_IMPORTED_MODULE_0__.Suspense, { fallback: null }, /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement(ReactApp, { queryClient, queryParams }, elements.map((el, index) => { 29019 const name = el.dataset.react; 29020 return /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement( 29021 react_error_boundary__WEBPACK_IMPORTED_MODULE_3__.ErrorBoundary, 29022 { 29023 key: `${name}-${index}`, 29024 fallbackRender: () => { 29025 return (0,react_dom__WEBPACK_IMPORTED_MODULE_1__.createPortal)(
29026 /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { className: "d3-react-error" }, "Component was not loaded! Please try reloading the page"), 29027 el 29028 ); 29029 } 29030 }, 29031 /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement( 29032 ReactModule, 29033 { 29034 el, 29035 name, 29036 enableHTMLOptions 29037 } 29038 ) 29039 ); 29040 }))) 29041 ), 29042 reactRoot 29043 ); 29044 }, "[data-react]"); 29045 }); 29046 } 29047 createReactRoot() { 29048 const root = document.createElement("div"); 29049 root.id = "react-root"; 29050 document.body.append(root); 29051 return root; 29052 } 29053 getQueryParams() { 29054 const getParametersFromURL = () => { 29055 const re = /(?:\?|&(?:amp;)?|#)([^=&#]+)(?:=?([^&#]*))/g, params = {}, url = document.location.href, decode = (s) => decodeURIComponent(s.replace(/\+/g, " ")); 29056 let match; 29057 while (match = re.exec(url)) { 29058 if (!params[decode(match[1])]) { 29059 params[decode(match[1])] = []; 29060 } 29061 params[decode(match[1])].push(decode(match[2])); 29062 } 29063 return params; 29064 }; 29065 return getParametersFromURL(); 29066 } 29067 createQueryClient() { 29068 const queryClient = new react_query__WEBPACK_IMPORTED_MODULE_4__.QueryClient({ 29069 defaultOptions: { 29070 queries: { 29071 refetchOnWindowFocus: false, 29072 refetchIntervalInBackground: true 29073 } 29074 } 29075 }); 29076 return queryClient; 29077 } 29078 /** 29079 * Get ReactRenderer singlethon 29080 * @param {Window} win - the window instance 29081 * @returns {ReactRenderer} The ReactRenderer singlethon 29082 */ 29083 static getInstance(win = window) { 29084 win.D3 = win.D3 || {}; 29085 win.D3.reactRenderer = win.D3.reactRenderer || new ReactRenderer(); 29086 return win.D3.reactRenderer; 29087 } 29088} 29089const reactRendererInstance = ReactRenderer.getInstance(); 29090/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (reactRendererInstance); 29091 29092 29093/***/ }), 29094
vendor: 2,591 bytes, lines 29095-29195
29095/***/ "./.yarn/cache/object-assign-npm-4.1.1-1004ad6dec-fcc6e4ea8c.zip/node_modules/object-assign/index.js": 29096/*!***********************************************************************************************************!*\ 29097 !*** ./.yarn/cache/object-assign-npm-4.1.1-1004ad6dec-fcc6e4ea8c.zip/node_modules/object-assign/index.js ***! 29098 \***********************************************************************************************************/ 29099/***/ ((module) => { 29100 29101"use strict"; 29102/* 29103object-assign 29104(c) Sindre Sorhus 29105@license MIT 29106*/ 29107 29108 29109/* eslint-disable no-unused-vars */ 29110var getOwnPropertySymbols = Object.getOwnPropertySymbols; 29111var hasOwnProperty = Object.prototype.hasOwnProperty; 29112var propIsEnumerable = Object.prototype.propertyIsEnumerable; 29113 29114function toObject(val) { 29115 if (val === null || val === undefined) { 29116 throw new TypeError('Object.assign cannot be called with null or undefined'); 29117 } 29118 29119 return Object(val); 29120} 29121 29122function shouldUseNative() { 29123 try { 29124 if (!Object.assign) { 29125 return false; 29126 } 29127 29128 // Detect buggy property enumeration order in older V8 versions. 29129 29130 // https://bugs.chromium.org/p/v8/issues/detail?id=4118 29131 var test1 = new String('abc'); // eslint-disable-line no-new-wrappers 29132 test1[5] = 'de'; 29133 if (Object.getOwnPropertyNames(test1)[0] === '5') { 29134 return false; 29135 } 29136 29137 // https://bugs.chromium.org/p/v8/issues/detail?id=3056 29138 var test2 = {}; 29139 for (var i = 0; i < 10; i++) { 29140 test2['_' + String.fromCharCode(i)] = i; 29141 } 29142 var order2 = Object.getOwnPropertyNames(test2).map(function (n) { 29143 return test2[n]; 29144 }); 29145 if (order2.join('') !== '0123456789') { 29146 return false; 29147 } 29148 29149 // https://bugs.chromium.org/p/v8/issues/detail?id=3056 29150 var test3 = {}; 29151 'abcdefghijklmnopqrst'.split('').forEach(function (letter) { 29152 test3[letter] = letter; 29153 }); 29154 if (Object.keys(Object.assign({}, test3)).join('') !== 29155 'abcdefghijklmnopqrst') { 29156 return false; 29157 } 29158 29159 return true; 29160 } catch (err) { 29161 // We don't expect any of the above to throw, but better to be safe. 29162 return false; 29163 } 29164} 29165 29166module.exports = shouldUseNative() ? Object.assign : function (target, source) { 29167 var from; 29168 var to = toObject(target); 29169 var symbols; 29170 29171 for (var s = 1; s < arguments.length; s++) { 29172 from = Object(arguments[s]); 29173 29174 for (var key in from) { 29175 if (hasOwnProperty.call(from, key)) { 29176 to[key] = from[key]; 29177 } 29178 } 29179 29180 if (getOwnPropertySymbols) { 29181 symbols = getOwnPropertySymbols(from); 29182 for (var i = 0; i < symbols.length; i++) { 29183 if (propIsEnumerable.call(from, symbols[i])) { 29184 to[symbols[i]] = from[symbols[i]]; 29185 } 29186 } 29187 } 29188 } 29189 29190 return to; 29191}; 29192 29193 29194/***/ }), 29195
vendor: 72,761 bytes, lines 29196-31539
29196/***/ "./.yarn/cache/react-npm-17.0.1-98658812fc-23ada2f8fe.zip/node_modules/react/cjs/react.development.js": 29197/*!************************************************************************************************************!*\ 29198 !*** ./.yarn/cache/react-npm-17.0.1-98658812fc-23ada2f8fe.zip/node_modules/react/cjs/react.development.js ***! 29199 \************************************************************************************************************/ 29200/***/ ((__unused_webpack_module, exports, __webpack_require__) => { 29201 29202"use strict"; 29203/** @license React v17.0.1 29204 * react.development.js 29205 * 29206 * Copyright (c) Facebook, Inc. and its affiliates. 29207 * 29208 * This source code is licensed under the MIT license found in the 29209 * LICENSE file in the root directory of this source tree. 29210 */ 29211 29212 29213 29214if (true) { 29215 (function() { 29216'use strict'; 29217 29218var _assign = __webpack_require__(/*! object-assign */ "./.yarn/cache/object-assign-npm-4.1.1-1004ad6dec-fcc6e4ea8c.zip/node_modules/object-assign/index.js"); 29219 29220// TODO: this is special because it gets imported during build. 29221var ReactVersion = '17.0.1'; 29222 29223// ATTENTION 29224// When adding new symbols to this file, 29225// Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols' 29226// The Symbol used to tag the ReactElement-like types. If there is no native Symbol 29227// nor polyfill, then a plain number is used for performance. 29228var REACT_ELEMENT_TYPE = 0xeac7; 29229var REACT_PORTAL_TYPE = 0xeaca; 29230exports.Fragment = 0xeacb; 29231exports.StrictMode = 0xeacc; 29232exports.Profiler = 0xead2; 29233var REACT_PROVIDER_TYPE = 0xeacd; 29234var REACT_CONTEXT_TYPE = 0xeace; 29235var REACT_FORWARD_REF_TYPE = 0xead0; 29236exports.Suspense = 0xead1; 29237var REACT_SUSPENSE_LIST_TYPE = 0xead8; 29238var REACT_MEMO_TYPE = 0xead3; 29239var REACT_LAZY_TYPE = 0xead4; 29240var REACT_BLOCK_TYPE = 0xead9; 29241var REACT_SERVER_BLOCK_TYPE = 0xeada; 29242var REACT_FUNDAMENTAL_TYPE = 0xead5; 29243var REACT_SCOPE_TYPE = 0xead7; 29244var REACT_OPAQUE_ID_TYPE = 0xeae0; 29245var REACT_DEBUG_TRACING_MODE_TYPE = 0xeae1; 29246var REACT_OFFSCREEN_TYPE = 0xeae2; 29247var REACT_LEGACY_HIDDEN_TYPE = 0xeae3; 29248 29249if (typeof Symbol === 'function' && Symbol.for) { 29250 var symbolFor = Symbol.for; 29251 REACT_ELEMENT_TYPE = symbolFor('react.element'); 29252 REACT_PORTAL_TYPE = symbolFor('react.portal'); 29253 exports.Fragment = symbolFor('react.fragment'); 29254 exports.StrictMode = symbolFor('react.strict_mode'); 29255 exports.Profiler = symbolFor('react.profiler'); 29256 REACT_PROVIDER_TYPE = symbolFor('react.provider'); 29257 REACT_CONTEXT_TYPE = symbolFor('react.context'); 29258 REACT_FORWARD_REF_TYPE = symbolFor('react.forward_ref'); 29259 exports.Suspense = symbolFor('react.suspense'); 29260 REACT_SUSPENSE_LIST_TYPE = symbolFor('react.suspense_list'); 29261 REACT_MEMO_TYPE = symbolFor('react.memo'); 29262 REACT_LAZY_TYPE = symbolFor('react.lazy'); 29263 REACT_BLOCK_TYPE = symbolFor('react.block'); 29264 REACT_SERVER_BLOCK_TYPE = symbolFor('react.server.block'); 29265 REACT_FUNDAMENTAL_TYPE = symbolFor('react.fundamental'); 29266 REACT_SCOPE_TYPE = symbolFor('react.scope'); 29267 REACT_OPAQUE_ID_TYPE = symbolFor('react.opaque.id'); 29268 REACT_DEBUG_TRACING_MODE_TYPE = symbolFor('react.debug_trace_mode'); 29269 REACT_OFFSCREEN_TYPE = symbolFor('react.offscreen'); 29270 REACT_LEGACY_HIDDEN_TYPE = symbolFor('react.legacy_hidden'); 29271} 29272 29273var MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator; 29274var FAUX_ITERATOR_SYMBOL = '@@iterator'; 29275function getIteratorFn(maybeIterable) { 29276 if (maybeIterable === null || typeof maybeIterable !== 'object') { 29277 return null; 29278 } 29279 29280 var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]; 29281 29282 if (typeof maybeIterator === 'function') { 29283 return maybeIterator; 29284 } 29285 29286 return null; 29287} 29288 29289/** 29290 * Keeps track of the current dispatcher. 29291 */ 29292var ReactCurrentDispatcher = { 29293 /** 29294 * @internal 29295 * @type {ReactComponent} 29296 */ 29297 current: null 29298}; 29299 29300/** 29301 * Keeps track of the current batch's configuration such as how long an update 29302 * should suspend for if it needs to. 29303 */ 29304var ReactCurrentBatchConfig = { 29305 transition: 0 29306}; 29307 29308/** 29309 * Keeps track of the current owner. 29310 * 29311 * The current owner is the component who should own any components that are 29312 * currently being constructed. 29313 */ 29314var ReactCurrentOwner = { 29315 /** 29316 * @internal 29317 * @type {ReactComponent} 29318 */ 29319 current: null 29320}; 29321 29322var ReactDebugCurrentFrame = {}; 29323var currentExtraStackFrame = null; 29324function setExtraStackFrame(stack) { 29325 { 29326 currentExtraStackFrame = stack; 29327 } 29328} 29329 29330{ 29331 ReactDebugCurrentFrame.setExtraStackFrame = function (stack) { 29332 { 29333 currentExtraStackFrame = stack; 29334 } 29335 }; // Stack implementation injected by the current renderer. 29336 29337 29338 ReactDebugCurrentFrame.getCurrentStack = null; 29339 29340 ReactDebugCurrentFrame.getStackAddendum = function () { 29341 var stack = ''; // Add an extra top frame while an element is being validated 29342 29343 if (currentExtraStackFrame) { 29344 stack += currentExtraStackFrame; 29345 } // Delegate to the injected renderer-specific implementation 29346 29347 29348 var impl = ReactDebugCurrentFrame.getCurrentStack; 29349 29350 if (impl) { 29351 stack += impl() || ''; 29352 } 29353 29354 return stack; 29355 }; 29356} 29357 29358/** 29359 * Used by act() to track whether you're inside an act() scope. 29360 */ 29361var IsSomeRendererActing = { 29362 current: false 29363}; 29364 29365var ReactSharedInternals = { 29366 ReactCurrentDispatcher: ReactCurrentDispatcher, 29367 ReactCurrentBatchConfig: ReactCurrentBatchConfig, 29368 ReactCurrentOwner: ReactCurrentOwner, 29369 IsSomeRendererActing: IsSomeRendererActing, 29370 // Used by renderers to avoid bundling object-assign twice in UMD bundles: 29371 assign: _assign 29372}; 29373 29374{ 29375 ReactSharedInternals.ReactDebugCurrentFrame = ReactDebugCurrentFrame; 29376} 29377 29378// by calls to these methods by a Babel plugin. 29379// 29380// In PROD (or in packages without access to React internals), 29381// they are left as they are instead. 29382 29383function warn(format) { 29384 { 29385 for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { 29386 args[_key - 1] = arguments[_key]; 29387 } 29388 29389 printWarning('warn', format, args); 29390 } 29391} 29392function error(format) { 29393 { 29394 for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { 29395 args[_key2 - 1] = arguments[_key2]; 29396 } 29397 29398 printWarning('error', format, args); 29399 } 29400} 29401 29402function printWarning(level, format, args) { 29403 // When changing this logic, you might want to also 29404 // update consoleWithStackDev.www.js as well. 29405 { 29406 var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; 29407 var stack = ReactDebugCurrentFrame.getStackAddendum(); 29408 29409 if (stack !== '') { 29410 format += '%s'; 29411 args = args.concat([stack]); 29412 } 29413 29414 var argsWithFormat = args.map(function (item) { 29415 return '' + item; 29416 }); // Careful: RN currently depends on this prefix 29417 29418 argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it 29419 // breaks IE9: https://github.com/facebook/react/issues/13610 29420 // eslint-disable-next-line react-internal/no-production-logging 29421 29422 Function.prototype.apply.call(console[level], console, argsWithFormat); 29423 } 29424} 29425 29426var didWarnStateUpdateForUnmountedComponent = {}; 29427 29428function warnNoop(publicInstance, callerName) { 29429 { 29430 var _constructor = publicInstance.constructor; 29431 var componentName = _constructor && (_constructor.displayName || _constructor.name) || 'ReactClass'; 29432 var warningKey = componentName + "." + callerName; 29433 29434 if (didWarnStateUpdateForUnmountedComponent[warningKey]) { 29435 return; 29436 } 29437 29438 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); 29439 29440 didWarnStateUpdateForUnmountedComponent[warningKey] = true; 29441 } 29442} 29443/** 29444 * This is the abstract API for an update queue. 29445 */ 29446 29447 29448var ReactNoopUpdateQueue = { 29449 /** 29450 * Checks whether or not this composite component is mounted. 29451 * @param {ReactClass} publicInstance The instance we want to test. 29452 * @return {boolean} True if mounted, false otherwise. 29453 * @protected 29454 * @final 29455 */ 29456 isMounted: function (publicInstance) { 29457 return false; 29458 }, 29459 29460 /** 29461 * Forces an update. This should only be invoked when it is known with 29462 * certainty that we are **not** in a DOM transaction. 29463 * 29464 * You may want to call this when you know that some deeper aspect of the 29465 * component's state has changed but `setState` was not called. 29466 * 29467 * This will not invoke `shouldComponentUpdate`, but it will invoke 29468 * `componentWillUpdate` and `componentDidUpdate`. 29469 * 29470 * @param {ReactClass} publicInstance The instance that should rerender. 29471 * @param {?function} callback Called after component is updated. 29472 * @param {?string} callerName name of the calling function in the public API. 29473 * @internal 29474 */ 29475 enqueueForceUpdate: function (publicInstance, callback, callerName) { 29476 warnNoop(publicInstance, 'forceUpdate'); 29477 }, 29478 29479 /** 29480 * Replaces all of the state. Always use this or `setState` to mutate state. 29481 * You should treat `this.state` as immutable. 29482 * 29483 * There is no guarantee that `this.state` will be immediately updated, so 29484 * accessing `this.state` after calling this method may return the old value. 29485 * 29486 * @param {ReactClass} publicInstance The instance that should rerender. 29487 * @param {object} completeState Next state. 29488 * @param {?function} callback Called after component is updated. 29489 * @param {?string} callerName name of the calling function in the public API. 29490 * @internal 29491 */ 29492 enqueueReplaceState: function (publicInstance, completeState, callback, callerName) { 29493 warnNoop(publicInstance, 'replaceState'); 29494 }, 29495 29496 /** 29497 * Sets a subset of the state. This only exists because _pendingState is 29498 * internal. This provides a merging strategy that is not available to deep 29499 * properties which is confusing. TODO: Expose pendingState or don't use it 29500 * during the merge. 29501 * 29502 * @param {ReactClass} publicInstance The instance that should rerender. 29503 * @param {object} partialState Next partial state to be merged with state. 29504 * @param {?function} callback Called after component is updated. 29505 * @param {?string} Name of the calling function in the public API. 29506 * @internal 29507 */ 29508 enqueueSetState: function (publicInstance, partialState, callback, callerName) { 29509 warnNoop(publicInstance, 'setState'); 29510 } 29511}; 29512 29513var emptyObject = {}; 29514 29515{ 29516 Object.freeze(emptyObject); 29517} 29518/** 29519 * Base class helpers for the updating state of a component. 29520 */ 29521 29522 29523function Component(props, context, updater) { 29524 this.props = props; 29525 this.context = context; // If a component has string refs, we will assign a different object later. 29526 29527 this.refs = emptyObject; // We initialize the default updater but the real one gets injected by the 29528 // renderer. 29529 29530 this.updater = updater || ReactNoopUpdateQueue; 29531} 29532 29533Component.prototype.isReactComponent = {}; 29534/** 29535 * Sets a subset of the state. Always use this to mutate 29536 * state. You should treat `this.state` as immutable. 29537 * 29538 * There is no guarantee that `this.state` will be immediately updated, so 29539 * accessing `this.state` after calling this method may return the old value. 29540 * 29541 * There is no guarantee that calls to `setState` will run synchronously, 29542 * as they may eventually be batched together. You can provide an optional 29543 * callback that will be executed when the call to setState is actually 29544 * completed. 29545 * 29546 * When a function is provided to setState, it will be called at some point in 29547 * the future (not synchronously). It will be called with the up to date 29548 * component arguments (state, props, context). These values can be different 29549 * from this.* because your function may be called after receiveProps but before 29550 * shouldComponentUpdate, and this new state, props, and context will not yet be 29551 * assigned to this. 29552 * 29553 * @param {object|function} partialState Next partial state or function to 29554 * produce next partial state to be merged with current state. 29555 * @param {?function} callback Called after state is updated. 29556 * @final 29557 * @protected 29558 */ 29559 29560Component.prototype.setState = function (partialState, callback) { 29561 if (!(typeof partialState === 'object' || typeof partialState === 'function' || partialState == null)) { 29562 { 29563 throw Error( "setState(...): takes an object of state variables to update or a function which returns an object of state variables." ); 29564 } 29565 } 29566 29567 this.updater.enqueueSetState(this, partialState, callback, 'setState'); 29568}; 29569/** 29570 * Forces an update. This should only be invoked when it is known with 29571 * certainty that we are **not** in a DOM transaction. 29572 * 29573 * You may want to call this when you know that some deeper aspect of the 29574 * component's state has changed but `setState` was not called. 29575 * 29576 * This will not invoke `shouldComponentUpdate`, but it will invoke 29577 * `componentWillUpdate` and `componentDidUpdate`. 29578 * 29579 * @param {?function} callback Called after update is complete. 29580 * @final 29581 * @protected 29582 */ 29583 29584 29585Component.prototype.forceUpdate = function (callback) { 29586 this.updater.enqueueForceUpdate(this, callback, 'forceUpdate'); 29587}; 29588/** 29589 * Deprecated APIs. These APIs used to exist on classic React classes but since 29590 * we would like to deprecate them, we're not going to move them over to this 29591 * modern base class. Instead, we define a getter that warns if it's accessed. 29592 */ 29593 29594 29595{ 29596 var deprecatedAPIs = { 29597 isMounted: ['isMounted', 'Instead, make sure to clean up subscriptions and pending requests in ' + 'componentWillUnmount to prevent memory leaks.'], 29598 replaceState: ['replaceState', 'Refactor your code to use setState instead (see ' + 'https://github.com/facebook/react/issues/3236).'] 29599 }; 29600 29601 var defineDeprecationWarning = function (methodName, info) { 29602 Object.defineProperty(Component.prototype, methodName, { 29603 get: function () { 29604 warn('%s(...) is deprecated in plain JavaScript React classes. %s', info[0], info[1]); 29605 29606 return undefined; 29607 } 29608 }); 29609 }; 29610 29611 for (var fnName in deprecatedAPIs) { 29612 if (deprecatedAPIs.hasOwnProperty(fnName)) { 29613 defineDeprecationWarning(fnName, deprecatedAPIs[fnName]); 29614 } 29615 } 29616} 29617 29618function ComponentDummy() {} 29619 29620ComponentDummy.prototype = Component.prototype; 29621/** 29622 * Convenience component with default shallow equality check for sCU. 29623 */ 29624 29625function PureComponent(props, context, updater) { 29626 this.props = props; 29627 this.context = context; // If a component has string refs, we will assign a different object later. 29628 29629 this.refs = emptyObject; 29630 this.updater = updater || ReactNoopUpdateQueue; 29631} 29632 29633var pureComponentPrototype = PureComponent.prototype = new ComponentDummy(); 29634pureComponentPrototype.constructor = PureComponent; // Avoid an extra prototype jump for these methods. 29635 29636_assign(pureComponentPrototype, Component.prototype); 29637 29638pureComponentPrototype.isPureReactComponent = true; 29639 29640// an immutable object with a single mutable value 29641function createRef() { 29642 var refObject = { 29643 current: null 29644 }; 29645 29646 { 29647 Object.seal(refObject); 29648 } 29649 29650 return refObject; 29651} 29652 29653function getWrappedName(outerType, innerType, wrapperName) { 29654 var functionName = innerType.displayName || innerType.name || ''; 29655 return outerType.displayName || (functionName !== '' ? wrapperName + "(" + functionName + ")" : wrapperName); 29656} 29657 29658function getContextName(type) { 29659 return type.displayName || 'Context'; 29660} 29661 29662function getComponentName(type) { 29663 if (type == null) { 29664 // Host root, text node or just invalid type. 29665 return null; 29666 } 29667 29668 { 29669 if (typeof type.tag === 'number') { 29670 error('Received an unexpected object in getComponentName(). ' + 'This is likely a bug in React. Please file an issue.'); 29671 } 29672 } 29673 29674 if (typeof type === 'function') { 29675 return type.displayName || type.name || null; 29676 } 29677 29678 if (typeof type === 'string') { 29679 return type; 29680 } 29681 29682 switch (type) { 29683 case exports.Fragment: 29684 return 'Fragment'; 29685 29686 case REACT_PORTAL_TYPE: 29687 return 'Portal'; 29688 29689 case exports.Profiler: 29690 return 'Profiler'; 29691 29692 case exports.StrictMode: 29693 return 'StrictMode'; 29694 29695 case exports.Suspense: 29696 return 'Suspense'; 29697 29698 case REACT_SUSPENSE_LIST_TYPE: 29699 return 'SuspenseList'; 29700 } 29701 29702 if (typeof type === 'object') { 29703 switch (type.$$typeof) { 29704 case REACT_CONTEXT_TYPE: 29705 var context = type; 29706 return getContextName(context) + '.Consumer'; 29707 29708 case REACT_PROVIDER_TYPE: 29709 var provider = type; 29710 return getContextName(provider._context) + '.Provider'; 29711 29712 case REACT_FORWARD_REF_TYPE: 29713 return getWrappedName(type, type.render, 'ForwardRef'); 29714 29715 case REACT_MEMO_TYPE: 29716 return getComponentName(type.type); 29717 29718 case REACT_BLOCK_TYPE: 29719 return getComponentName(type._render); 29720 29721 case REACT_LAZY_TYPE: 29722 { 29723 var lazyComponent = type; 29724 var payload = lazyComponent._payload; 29725 var init = lazyComponent._init; 29726 29727 try { 29728 return getComponentName(init(payload)); 29729 } catch (x) { 29730 return null; 29731 } 29732 } 29733 } 29734 } 29735 29736 return null; 29737} 29738 29739var hasOwnProperty = Object.prototype.hasOwnProperty; 29740var RESERVED_PROPS = { 29741 key: true, 29742 ref: true, 29743 __self: true, 29744 __source: true 29745}; 29746var specialPropKeyWarningShown, specialPropRefWarningShown, didWarnAboutStringRefs; 29747 29748{ 29749 didWarnAboutStringRefs = {}; 29750} 29751 29752function hasValidRef(config) { 29753 { 29754 if (hasOwnProperty.call(config, 'ref')) { 29755 var getter = Object.getOwnPropertyDescriptor(config, 'ref').get; 29756 29757 if (getter && getter.isReactWarning) { 29758 return false; 29759 } 29760 } 29761 } 29762 29763 return config.ref !== undefined; 29764} 29765 29766function hasValidKey(config) { 29767 { 29768 if (hasOwnProperty.call(config, 'key')) { 29769 var getter = Object.getOwnPropertyDescriptor(config, 'key').get; 29770 29771 if (getter && getter.isReactWarning) { 29772 return false; 29773 } 29774 } 29775 } 29776 29777 return config.key !== undefined; 29778} 29779 29780function defineKeyPropWarningGetter(props, displayName) { 29781 var warnAboutAccessingKey = function () { 29782 { 29783 if (!specialPropKeyWarningShown) { 29784 specialPropKeyWarningShown = true; 29785 29786 error('%s: `key` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://reactjs.org/link/special-props)', displayName); 29787 } 29788 } 29789 }; 29790 29791 warnAboutAccessingKey.isReactWarning = true; 29792 Object.defineProperty(props, 'key', { 29793 get: warnAboutAccessingKey, 29794 configurable: true 29795 }); 29796} 29797 29798function defineRefPropWarningGetter(props, displayName) { 29799 var warnAboutAccessingRef = function () { 29800 { 29801 if (!specialPropRefWarningShown) { 29802 specialPropRefWarningShown = true; 29803 29804 error('%s: `ref` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://reactjs.org/link/special-props)', displayName); 29805 } 29806 } 29807 }; 29808 29809 warnAboutAccessingRef.isReactWarning = true; 29810 Object.defineProperty(props, 'ref', { 29811 get: warnAboutAccessingRef, 29812 configurable: true 29813 }); 29814} 29815 29816function warnIfStringRefCannotBeAutoConverted(config) { 29817 { 29818 if (typeof config.ref === 'string' && ReactCurrentOwner.current && config.__self && ReactCurrentOwner.current.stateNode !== config.__self) { 29819 var componentName = getComponentName(ReactCurrentOwner.current.type); 29820 29821 if (!didWarnAboutStringRefs[componentName]) { 29822 error('Component "%s" contains the string ref "%s". ' + 'Support for string refs will be removed in a future major release. ' + 'This case cannot be automatically converted to an arrow function. ' + 'We ask you to manually fix this case by using useRef() or createRef() instead. ' + 'Learn more about using refs safely here: ' + 'https://reactjs.org/link/strict-mode-string-ref', componentName, config.ref); 29823 29824 didWarnAboutStringRefs[componentName] = true; 29825 } 29826 } 29827 } 29828} 29829/** 29830 * Factory method to create a new React element. This no longer adheres to 29831 * the class pattern, so do not use new to call it. Also, instanceof check 29832 * will not work. Instead test $$typeof field against Symbol.for('react.element') to check 29833 * if something is a React Element. 29834 * 29835 * @param {*} type 29836 * @param {*} props 29837 * @param {*} key 29838 * @param {string|object} ref 29839 * @param {*} owner 29840 * @param {*} self A *temporary* helper to detect places where `this` is 29841 * different from the `owner` when React.createElement is called, so that we 29842 * can warn. We want to get rid of owner and replace string `ref`s with arrow 29843 * functions, and as long as `this` and owner are the same, there will be no 29844 * change in behavior. 29845 * @param {*} source An annotation object (added by a transpiler or otherwise) 29846 * indicating filename, line number, and/or other information. 29847 * @internal 29848 */ 29849 29850 29851var ReactElement = function (type, key, ref, self, source, owner, props) { 29852 var element = { 29853 // This tag allows us to uniquely identify this as a React Element 29854 $$typeof: REACT_ELEMENT_TYPE, 29855 // Built-in properties that belong on the element 29856 type: type, 29857 key: key, 29858 ref: ref, 29859 props: props, 29860 // Record the component responsible for creating this element. 29861 _owner: owner 29862 }; 29863 29864 { 29865 // The validation flag is currently mutative. We put it on 29866 // an external backing store so that we can freeze the whole object. 29867 // This can be replaced with a WeakMap once they are implemented in 29868 // commonly used development environments. 29869 element._store = {}; // To make comparing ReactElements easier for testing purposes, we make 29870 // the validation flag non-enumerable (where possible, which should 29871 // include every environment we run tests in), so the test framework 29872 // ignores it. 29873 29874 Object.defineProperty(element._store, 'validated', { 29875 configurable: false, 29876 enumerable: false, 29877 writable: true, 29878 value: false 29879 }); // self and source are DEV only properties. 29880 29881 Object.defineProperty(element, '_self', { 29882 configurable: false, 29883 enumerable: false, 29884 writable: false, 29885 value: self 29886 }); // Two elements created in two different places should be considered 29887 // equal for testing purposes and therefore we hide it from enumeration. 29888 29889 Object.defineProperty(element, '_source', { 29890 configurable: false, 29891 enumerable: false, 29892 writable: false, 29893 value: source 29894 }); 29895 29896 if (Object.freeze) { 29897 Object.freeze(element.props); 29898 Object.freeze(element); 29899 } 29900 } 29901 29902 return element; 29903}; 29904/** 29905 * Create and return a new ReactElement of the given type. 29906 * See https://reactjs.org/docs/react-api.html#createelement 29907 */ 29908 29909function createElement(type, config, children) { 29910 var propName; // Reserved names are extracted 29911 29912 var props = {}; 29913 var key = null; 29914 var ref = null; 29915 var self = null; 29916 var source = null; 29917 29918 if (config != null) { 29919 if (hasValidRef(config)) { 29920 ref = config.ref; 29921 29922 { 29923 warnIfStringRefCannotBeAutoConverted(config); 29924 } 29925 } 29926 29927 if (hasValidKey(config)) { 29928 key = '' + config.key; 29929 } 29930 29931 self = config.__self === undefined ? null : config.__self; 29932 source = config.__source === undefined ? null : config.__source; // Remaining properties are added to a new props object 29933 29934 for (propName in config) { 29935 if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) { 29936 props[propName] = config[propName]; 29937 } 29938 } 29939 } // Children can be more than one argument, and those are transferred onto 29940 // the newly allocated props object. 29941 29942 29943 var childrenLength = arguments.length - 2; 29944 29945 if (childrenLength === 1) { 29946 props.children = children; 29947 } else if (childrenLength > 1) { 29948 var childArray = Array(childrenLength); 29949 29950 for (var i = 0; i < childrenLength; i++) { 29951 childArray[i] = arguments[i + 2]; 29952 } 29953 29954 { 29955 if (Object.freeze) { 29956 Object.freeze(childArray); 29957 } 29958 } 29959 29960 props.children = childArray; 29961 } // Resolve default props 29962 29963 29964 if (type && type.defaultProps) { 29965 var defaultProps = type.defaultProps; 29966 29967 for (propName in defaultProps) { 29968 if (props[propName] === undefined) { 29969 props[propName] = defaultProps[propName]; 29970 } 29971 } 29972 } 29973 29974 { 29975 if (key || ref) { 29976 var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type; 29977 29978 if (key) { 29979 defineKeyPropWarningGetter(props, displayName); 29980 } 29981 29982 if (ref) { 29983 defineRefPropWarningGetter(props, displayName); 29984 } 29985 } 29986 } 29987 29988 return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props); 29989} 29990function cloneAndReplaceKey(oldElement, newKey) { 29991 var newElement = ReactElement(oldElement.type, newKey, oldElement.ref, oldElement._self, oldElement._source, oldElement._owner, oldElement.props); 29992 return newElement; 29993} 29994/** 29995 * Clone and return a new ReactElement using element as the starting point. 29996 * See https://reactjs.org/docs/react-api.html#cloneelement 29997 */ 29998 29999function cloneElement(element, config, children) { 30000 if (!!(element === null || element === undefined)) { 30001 { 30002 throw Error( "React.cloneElement(...): The argument must be a React element, but you passed " + element + "." ); 30003 } 30004 } 30005 30006 var propName; // Original props are copied 30007 30008 var props = _assign({}, element.props); // Reserved names are extracted 30009 30010 30011 var key = element.key; 30012 var ref = element.ref; // Self is preserved since the owner is preserved. 30013 30014 var self = element._self; // Source is preserved since cloneElement is unlikely to be targeted by a 30015 // transpiler, and the original source is probably a better indicator of the 30016 // true owner. 30017 30018 var source = element._source; // Owner will be preserved, unless ref is overridden 30019 30020 var owner = element._owner; 30021 30022 if (config != null) { 30023 if (hasValidRef(config)) { 30024 // Silently steal the ref from the parent. 30025 ref = config.ref; 30026 owner = ReactCurrentOwner.current; 30027 } 30028 30029 if (hasValidKey(config)) { 30030 key = '' + config.key; 30031 } // Remaining properties override existing props 30032 30033 30034 var defaultProps; 30035 30036 if (element.type && element.type.defaultProps) { 30037 defaultProps = element.type.defaultProps; 30038 } 30039 30040 for (propName in config) { 30041 if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) { 30042 if (config[propName] === undefined && defaultProps !== undefined) { 30043 // Resolve default props 30044 props[propName] = defaultProps[propName]; 30045 } else { 30046 props[propName] = config[propName]; 30047 } 30048 } 30049 } 30050 } // Children can be more than one argument, and those are transferred onto 30051 // the newly allocated props object. 30052 30053 30054 var childrenLength = arguments.length - 2; 30055 30056 if (childrenLength === 1) { 30057 props.children = children; 30058 } else if (childrenLength > 1) { 30059 var childArray = Array(childrenLength); 30060 30061 for (var i = 0; i < childrenLength; i++) { 30062 childArray[i] = arguments[i + 2]; 30063 } 30064 30065 props.children = childArray; 30066 } 30067 30068 return ReactElement(element.type, key, ref, self, source, owner, props); 30069} 30070/** 30071 * Verifies the object is a ReactElement. 30072 * See https://reactjs.org/docs/react-api.html#isvalidelement 30073 * @param {?object} object 30074 * @return {boolean} True if `object` is a ReactElement. 30075 * @final 30076 */ 30077 30078function isValidElement(object) { 30079 return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE; 30080} 30081 30082var SEPARATOR = '.'; 30083var SUBSEPARATOR = ':'; 30084/** 30085 * Escape and wrap key so it is safe to use as a reactid 30086 * 30087 * @param {string} key to be escaped. 30088 * @return {string} the escaped key. 30089 */ 30090 30091function escape(key) { 30092 var escapeRegex = /[=:]/g; 30093 var escaperLookup = { 30094 '=': '=0', 30095 ':': '=2' 30096 }; 30097 var escapedString = key.replace(escapeRegex, function (match) { 30098 return escaperLookup[match]; 30099 }); 30100 return '$' + escapedString; 30101} 30102/** 30103 * TODO: Test that a single child and an array with one item have the same key 30104 * pattern. 30105 */ 30106 30107 30108var didWarnAboutMaps = false; 30109var userProvidedKeyEscapeRegex = /\/+/g; 30110 30111function escapeUserProvidedKey(text) { 30112 return text.replace(userProvidedKeyEscapeRegex, '$&/'); 30113} 30114/** 30115 * Generate a key string that identifies a element within a set. 30116 * 30117 * @param {*} element A element that could contain a manual key. 30118 * @param {number} index Index that is used if a manual key is not provided. 30119 * @return {string} 30120 */ 30121 30122 30123function getElementKey(element, index) { 30124 // Do some typechecking here since we call this blindly. We want to ensure 30125 // that we don't block potential future ES APIs. 30126 if (typeof element === 'object' && element !== null && element.key != null) { 30127 // Explicit key 30128 return escape('' + element.key); 30129 } // Implicit key determined by the index in the set 30130 30131 30132 return index.toString(36); 30133} 30134 30135function mapIntoArray(children, array, escapedPrefix, nameSoFar, callback) { 30136 var type = typeof children; 30137 30138 if (type === 'undefined' || type === 'boolean') { 30139 // All of the above are perceived as null. 30140 children = null; 30141 } 30142 30143 var invokeCallback = false; 30144 30145 if (children === null) { 30146 invokeCallback = true; 30147 } else { 30148 switch (type) { 30149 case 'string': 30150 case 'number': 30151 invokeCallback = true; 30152 break; 30153 30154 case 'object': 30155 switch (children.$$typeof) { 30156 case REACT_ELEMENT_TYPE: 30157 case REACT_PORTAL_TYPE: 30158 invokeCallback = true; 30159 } 30160 30161 } 30162 } 30163 30164 if (invokeCallback) { 30165 var _child = children; 30166 var mappedChild = callback(_child); // If it's the only child, treat the name as if it was wrapped in an array 30167 // so that it's consistent if the number of children grows: 30168 30169 var childKey = nameSoFar === '' ? SEPARATOR + getElementKey(_child, 0) : nameSoFar; 30170 30171 if (Array.isArray(mappedChild)) { 30172 var escapedChildKey = ''; 30173 30174 if (childKey != null) { 30175 escapedChildKey = escapeUserProvidedKey(childKey) + '/'; 30176 } 30177 30178 mapIntoArray(mappedChild, array, escapedChildKey, '', function (c) { 30179 return c; 30180 }); 30181 } else if (mappedChild != null) { 30182 if (isValidElement(mappedChild)) { 30183 mappedChild = cloneAndReplaceKey(mappedChild, // Keep both the (mapped) and old keys if they differ, just as 30184 // traverseAllChildren used to do for objects as children 30185 escapedPrefix + ( // $FlowFixMe Flow incorrectly thinks React.Portal doesn't have a key 30186 mappedChild.key && (!_child || _child.key !== mappedChild.key) ? // $FlowFixMe Flow incorrectly thinks existing element's key can be a number 30187 escapeUserProvidedKey('' + mappedChild.key) + '/' : '') + childKey); 30188 } 30189 30190 array.push(mappedChild); 30191 } 30192 30193 return 1; 30194 } 30195 30196 var child; 30197 var nextName; 30198 var subtreeCount = 0; // Count of children found in the current subtree. 30199 30200 var nextNamePrefix = nameSoFar === '' ? SEPARATOR : nameSoFar + SUBSEPARATOR; 30201 30202 if (Array.isArray(children)) { 30203 for (var i = 0; i < children.length; i++) { 30204 child = children[i]; 30205 nextName = nextNamePrefix + getElementKey(child, i); 30206 subtreeCount += mapIntoArray(child, array, escapedPrefix, nextName, callback); 30207 } 30208 } else { 30209 var iteratorFn = getIteratorFn(children); 30210 30211 if (typeof iteratorFn === 'function') { 30212 var iterableChildren = children; 30213 30214 { 30215 // Warn about using Maps as children 30216 if (iteratorFn === iterableChildren.entries) { 30217 if (!didWarnAboutMaps) { 30218 warn('Using Maps as children is not supported. ' + 'Use an array of keyed ReactElements instead.'); 30219 } 30220 30221 didWarnAboutMaps = true; 30222 } 30223 } 30224 30225 var iterator = iteratorFn.call(iterableChildren); 30226 var step; 30227 var ii = 0; 30228 30229 while (!(step = iterator.next()).done) { 30230 child = step.value; 30231 nextName = nextNamePrefix + getElementKey(child, ii++); 30232 subtreeCount += mapIntoArray(child, array, escapedPrefix, nextName, callback); 30233 } 30234 } else if (type === 'object') { 30235 var childrenString = '' + children; 30236 30237 { 30238 { 30239 throw Error( "Objects are not valid as a React child (found: " + (childrenString === '[object Object]' ? 'object with keys {' + Object.keys(children).join(', ') + '}' : childrenString) + "). If you meant to render a collection of children, use an array instead." ); 30240 } 30241 } 30242 } 30243 } 30244 30245 return subtreeCount; 30246} 30247 30248/** 30249 * Maps children that are typically specified as `props.children`. 30250 * 30251 * See https://reactjs.org/docs/react-api.html#reactchildrenmap 30252 * 30253 * The provided mapFunction(child, index) will be called for each 30254 * leaf child. 30255 * 30256 * @param {?*} children Children tree container. 30257 * @param {function(*, int)} func The map function. 30258 * @param {*} context Context for mapFunction. 30259 * @return {object} Object containing the ordered map of results. 30260 */ 30261function mapChildren(children, func, context) { 30262 if (children == null) { 30263 return children; 30264 } 30265 30266 var result = []; 30267 var count = 0; 30268 mapIntoArray(children, result, '', '', function (child) { 30269 return func.call(context, child, count++); 30270 }); 30271 return result; 30272} 30273/** 30274 * Count the number of children that are typically specified as 30275 * `props.children`. 30276 * 30277 * See https://reactjs.org/docs/react-api.html#reactchildrencount 30278 * 30279 * @param {?*} children Children tree container. 30280 * @return {number} The number of children. 30281 */ 30282 30283 30284function countChildren(children) { 30285 var n = 0; 30286 mapChildren(children, function () { 30287 n++; // Don't return anything 30288 }); 30289 return n; 30290} 30291 30292/** 30293 * Iterates through children that are typically specified as `props.children`. 30294 * 30295 * See https://reactjs.org/docs/react-api.html#reactchildrenforeach 30296 * 30297 * The provided forEachFunc(child, index) will be called for each 30298 * leaf child. 30299 * 30300 * @param {?*} children Children tree container. 30301 * @param {function(*, int)} forEachFunc 30302 * @param {*} forEachContext Context for forEachContext. 30303 */ 30304function forEachChildren(children, forEachFunc, forEachContext) { 30305 mapChildren(children, function () { 30306 forEachFunc.apply(this, arguments); // Don't return anything. 30307 }, forEachContext); 30308} 30309/** 30310 * Flatten a children object (typically specified as `props.children`) and 30311 * return an array with appropriately re-keyed children. 30312 * 30313 * See https://reactjs.org/docs/react-api.html#reactchildrentoarray 30314 */ 30315 30316 30317function toArray(children) { 30318 return mapChildren(children, function (child) { 30319 return child; 30320 }) || []; 30321} 30322/** 30323 * Returns the first child in a collection of children and verifies that there 30324 * is only one child in the collection. 30325 * 30326 * See https://reactjs.org/docs/react-api.html#reactchildrenonly 30327 * 30328 * The current implementation of this function assumes that a single child gets 30329 * passed without a wrapper, but the purpose of this helper function is to 30330 * abstract away the particular structure of children. 30331 * 30332 * @param {?object} children Child collection structure. 30333 * @return {ReactElement} The first and only `ReactElement` contained in the 30334 * structure. 30335 */ 30336 30337 30338function onlyChild(children) { 30339 if (!isValidElement(children)) { 30340 { 30341 throw Error( "React.Children.only expected to receive a single React element child." ); 30342 } 30343 } 30344 30345 return children; 30346} 30347 30348function createContext(defaultValue, calculateChangedBits) { 30349 if (calculateChangedBits === undefined) { 30350 calculateChangedBits = null; 30351 } else { 30352 { 30353 if (calculateChangedBits !== null && typeof calculateChangedBits !== 'function') { 30354 error('createContext: Expected the optional second argument to be a ' + 'function. Instead received: %s', calculateChangedBits); 30355 } 30356 } 30357 } 30358 30359 var context = { 30360 $$typeof: REACT_CONTEXT_TYPE, 30361 _calculateChangedBits: calculateChangedBits, 30362 // As a workaround to support multiple concurrent renderers, we categorize 30363 // some renderers as primary and others as secondary. We only expect 30364 // there to be two concurrent renderers at most: React Native (primary) and 30365 // Fabric (secondary); React DOM (primary) and React ART (secondary). 30366 // Secondary renderers store their context values on separate fields. 30367 _currentValue: defaultValue, 30368 _currentValue2: defaultValue, 30369 // Used to track how many concurrent renderers this context currently 30370 // supports within in a single renderer. Such as parallel server rendering. 30371 _threadCount: 0, 30372 // These are circular 30373 Provider: null, 30374 Consumer: null 30375 }; 30376 context.Provider = { 30377 $$typeof: REACT_PROVIDER_TYPE, 30378 _context: context 30379 }; 30380 var hasWarnedAboutUsingNestedContextConsumers = false; 30381 var hasWarnedAboutUsingConsumerProvider = false; 30382 var hasWarnedAboutDisplayNameOnConsumer = false; 30383 30384 { 30385 // A separate object, but proxies back to the original context object for 30386 // backwards compatibility. It has a different $$typeof, so we can properly 30387 // warn for the incorrect usage of Context as a Consumer. 30388 var Consumer = { 30389 $$typeof: REACT_CONTEXT_TYPE, 30390 _context: context, 30391 _calculateChangedBits: context._calculateChangedBits 30392 }; // $FlowFixMe: Flow complains about not setting a value, which is intentional here 30393 30394 Object.defineProperties(Consumer, { 30395 Provider: { 30396 get: function () { 30397 if (!hasWarnedAboutUsingConsumerProvider) { 30398 hasWarnedAboutUsingConsumerProvider = true; 30399 30400 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?'); 30401 } 30402 30403 return context.Provider; 30404 }, 30405 set: function (_Provider) { 30406 context.Provider = _Provider; 30407 } 30408 }, 30409 _currentValue: { 30410 get: function () { 30411 return context._currentValue; 30412 }, 30413 set: function (_currentValue) { 30414 context._currentValue = _currentValue; 30415 } 30416 }, 30417 _currentValue2: { 30418 get: function () { 30419 return context._currentValue2; 30420 }, 30421 set: function (_currentValue2) { 30422 context._currentValue2 = _currentValue2; 30423 } 30424 }, 30425 _threadCount: { 30426 get: function () { 30427 return context._threadCount; 30428 }, 30429 set: function (_threadCount) { 30430 context._threadCount = _threadCount; 30431 } 30432 }, 30433 Consumer: { 30434 get: function () { 30435 if (!hasWarnedAboutUsingNestedContextConsumers) { 30436 hasWarnedAboutUsingNestedContextConsumers = true; 30437 30438 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?'); 30439 } 30440 30441 return context.Consumer; 30442 } 30443 }, 30444 displayName: { 30445 get: function () { 30446 return context.displayName; 30447 }, 30448 set: function (displayName) { 30449 if (!hasWarnedAboutDisplayNameOnConsumer) { 30450 warn('Setting `displayName` on Context.Consumer has no effect. ' + "You should set it directly on the context with Context.displayName = '%s'.", displayName); 30451 30452 hasWarnedAboutDisplayNameOnConsumer = true; 30453 } 30454 } 30455 } 30456 }); // $FlowFixMe: Flow complains about missing properties because it doesn't understand defineProperty 30457 30458 context.Consumer = Consumer; 30459 } 30460 30461 { 30462 context._currentRenderer = null; 30463 context._currentRenderer2 = null; 30464 } 30465 30466 return context; 30467} 30468 30469var Uninitialized = -1; 30470var Pending = 0; 30471var Resolved = 1; 30472var Rejected = 2; 30473 30474function lazyInitializer(payload) { 30475 if (payload._status === Uninitialized) { 30476 var ctor = payload._result; 30477 var thenable = ctor(); // Transition to the next state. 30478 30479 var pending = payload; 30480 pending._status = Pending; 30481 pending._result = thenable; 30482 thenable.then(function (moduleObject) { 30483 if (payload._status === Pending) { 30484 var defaultExport = moduleObject.default; 30485 30486 { 30487 if (defaultExport === undefined) { 30488 error('lazy: Expected the result of a dynamic import() call. ' + 'Instead received: %s\n\nYour code should look like: \n ' + // Break up imports to avoid accidentally parsing them as dependencies. 30489 'const MyComponent = lazy(() => imp' + "ort('./MyComponent'))", moduleObject); 30490 } 30491 } // Transition to the next state. 30492 30493 30494 var resolved = payload; 30495 resolved._status = Resolved; 30496 resolved._result = defaultExport; 30497 } 30498 }, function (error) { 30499 if (payload._status === Pending) { 30500 // Transition to the next state. 30501 var rejected = payload; 30502 rejected._status = Rejected; 30503 rejected._result = error; 30504 } 30505 }); 30506 } 30507 30508 if (payload._status === Resolved) { 30509 return payload._result; 30510 } else { 30511 throw payload._result; 30512 } 30513} 30514 30515function lazy(ctor) { 30516 var payload = { 30517 // We use these fields to store the result. 30518 _status: -1, 30519 _result: ctor 30520 }; 30521 var lazyType = { 30522 $$typeof: REACT_LAZY_TYPE, 30523 _payload: payload, 30524 _init: lazyInitializer 30525 }; 30526 30527 { 30528 // In production, this would just set it on the object. 30529 var defaultProps; 30530 var propTypes; // $FlowFixMe 30531 30532 Object.defineProperties(lazyType, { 30533 defaultProps: { 30534 configurable: true, 30535 get: function () { 30536 return defaultProps; 30537 }, 30538 set: function (newDefaultProps) { 30539 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.'); 30540 30541 defaultProps = newDefaultProps; // Match production behavior more closely: 30542 // $FlowFixMe 30543 30544 Object.defineProperty(lazyType, 'defaultProps', { 30545 enumerable: true 30546 }); 30547 } 30548 }, 30549 propTypes: { 30550 configurable: true, 30551 get: function () { 30552 return propTypes; 30553 }, 30554 set: function (newPropTypes) { 30555 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.'); 30556 30557 propTypes = newPropTypes; // Match production behavior more closely: 30558 // $FlowFixMe 30559 30560 Object.defineProperty(lazyType, 'propTypes', { 30561 enumerable: true 30562 }); 30563 } 30564 } 30565 }); 30566 } 30567 30568 return lazyType; 30569} 30570 30571function forwardRef(render) { 30572 { 30573 if (render != null && render.$$typeof === REACT_MEMO_TYPE) { 30574 error('forwardRef requires a render function but received a `memo` ' + 'component. Instead of forwardRef(memo(...)), use ' + 'memo(forwardRef(...)).'); 30575 } else if (typeof render !== 'function') { 30576 error('forwardRef requires a render function but was given %s.', render === null ? 'null' : typeof render); 30577 } else { 30578 if (render.length !== 0 && render.length !== 2) { 30579 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.'); 30580 } 30581 } 30582 30583 if (render != null) { 30584 if (render.defaultProps != null || render.propTypes != null) { 30585 error('forwardRef render functions do not support propTypes or defaultProps. ' + 'Did you accidentally pass a React component?'); 30586 } 30587 } 30588 } 30589 30590 var elementType = { 30591 $$typeof: REACT_FORWARD_REF_TYPE, 30592 render: render 30593 }; 30594 30595 { 30596 var ownName; 30597 Object.defineProperty(elementType, 'displayName', { 30598 enumerable: false, 30599 configurable: true, 30600 get: function () { 30601 return ownName; 30602 }, 30603 set: function (name) { 30604 ownName = name; 30605 30606 if (render.displayName == null) { 30607 render.displayName = name; 30608 } 30609 } 30610 }); 30611 } 30612 30613 return elementType; 30614} 30615 30616// Filter certain DOM attributes (e.g. src, href) if their values are empty strings. 30617 30618var enableScopeAPI = false; // Experimental Create Event Handle API. 30619 30620function isValidElementType(type) { 30621 if (typeof type === 'string' || typeof type === 'function') { 30622 return true; 30623 } // Note: typeof might be other than 'symbol' or 'number' (e.g. if it's a polyfill). 30624 30625 30626 if (type === exports.Fragment || type === exports.Profiler || type === REACT_DEBUG_TRACING_MODE_TYPE || type === exports.StrictMode || type === exports.Suspense || type === REACT_SUSPENSE_LIST_TYPE || type === REACT_LEGACY_HIDDEN_TYPE || enableScopeAPI ) { 30627 return true; 30628 } 30629 30630 if (typeof type === 'object' && type !== null) { 30631 if (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_BLOCK_TYPE || type[0] === REACT_SERVER_BLOCK_TYPE) { 30632 return true; 30633 } 30634 } 30635 30636 return false; 30637} 30638 30639function memo(type, compare) { 30640 { 30641 if (!isValidElementType(type)) { 30642 error('memo: The first argument must be a component. Instead ' + 'received: %s', type === null ? 'null' : typeof type); 30643 } 30644 } 30645 30646 var elementType = { 30647 $$typeof: REACT_MEMO_TYPE, 30648 type: type, 30649 compare: compare === undefined ? null : compare 30650 }; 30651 30652 { 30653 var ownName; 30654 Object.defineProperty(elementType, 'displayName', { 30655 enumerable: false, 30656 configurable: true, 30657 get: function () { 30658 return ownName; 30659 }, 30660 set: function (name) { 30661 ownName = name; 30662 30663 if (type.displayName == null) { 30664 type.displayName = name; 30665 } 30666 } 30667 }); 30668 } 30669 30670 return elementType; 30671} 30672 30673function resolveDispatcher() { 30674 var dispatcher = ReactCurrentDispatcher.current; 30675 30676 if (!(dispatcher !== null)) { 30677 { 30678 throw Error( "Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem." ); 30679 } 30680 } 30681 30682 return dispatcher; 30683} 30684 30685function useContext(Context, unstable_observedBits) { 30686 var dispatcher = resolveDispatcher(); 30687 30688 { 30689 if (unstable_observedBits !== undefined) { 30690 error('useContext() second argument is reserved for future ' + 'use in React. Passing it is not supported. ' + 'You passed: %s.%s', unstable_observedBits, typeof unstable_observedBits === 'number' && Array.isArray(arguments[2]) ? '\n\nDid you call array.map(useContext)? ' + 'Calling Hooks inside a loop is not supported. ' + 'Learn more at https://reactjs.org/link/rules-of-hooks' : ''); 30691 } // TODO: add a more generic warning for invalid values. 30692 30693 30694 if (Context._context !== undefined) { 30695 var realContext = Context._context; // Don't deduplicate because this legitimately causes bugs 30696 // and nobody should be using this in existing code. 30697 30698 if (realContext.Consumer === Context) { 30699 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?'); 30700 } else if (realContext.Provider === Context) { 30701 error('Calling useContext(Context.Provider) is not supported. ' + 'Did you mean to call useContext(Context) instead?'); 30702 } 30703 } 30704 } 30705 30706 return dispatcher.useContext(Context, unstable_observedBits); 30707} 30708function useState(initialState) { 30709 var dispatcher = resolveDispatcher(); 30710 return dispatcher.useState(initialState); 30711} 30712function useReducer(reducer, initialArg, init) { 30713 var dispatcher = resolveDispatcher(); 30714 return dispatcher.useReducer(reducer, initialArg, init); 30715} 30716function useRef(initialValue) { 30717 var dispatcher = resolveDispatcher(); 30718 return dispatcher.useRef(initialValue); 30719} 30720function useEffect(create, deps) { 30721 var dispatcher = resolveDispatcher(); 30722 return dispatcher.useEffect(create, deps); 30723} 30724function useLayoutEffect(create, deps) { 30725 var dispatcher = resolveDispatcher(); 30726 return dispatcher.useLayoutEffect(create, deps); 30727} 30728function useCallback(callback, deps) { 30729 var dispatcher = resolveDispatcher(); 30730 return dispatcher.useCallback(callback, deps); 30731} 30732function useMemo(create, deps) { 30733 var dispatcher = resolveDispatcher(); 30734 return dispatcher.useMemo(create, deps); 30735} 30736function useImperativeHandle(ref, create, deps) { 30737 var dispatcher = resolveDispatcher(); 30738 return dispatcher.useImperativeHandle(ref, create, deps); 30739} 30740function useDebugValue(value, formatterFn) { 30741 { 30742 var dispatcher = resolveDispatcher(); 30743 return dispatcher.useDebugValue(value, formatterFn); 30744 } 30745} 30746 30747// Helpers to patch console.logs to avoid logging during side-effect free 30748// replaying on render function. This currently only patches the object 30749// lazily which won't cover if the log function was extracted eagerly. 30750// We could also eagerly patch the method. 30751var disabledDepth = 0; 30752var prevLog; 30753var prevInfo; 30754var prevWarn; 30755var prevError; 30756var prevGroup; 30757var prevGroupCollapsed; 30758var prevGroupEnd; 30759 30760function disabledLog() {} 30761 30762disabledLog.__reactDisabledLog = true; 30763function disableLogs() { 30764 { 30765 if (disabledDepth === 0) { 30766 /* eslint-disable react-internal/no-production-logging */ 30767 prevLog = console.log; 30768 prevInfo = console.info; 30769 prevWarn = console.warn; 30770 prevError = console.error; 30771 prevGroup = console.group; 30772 prevGroupCollapsed = console.groupCollapsed; 30773 prevGroupEnd = console.groupEnd; // https://github.com/facebook/react/issues/19099 30774 30775 var props = { 30776 configurable: true, 30777 enumerable: true, 30778 value: disabledLog, 30779 writable: true 30780 }; // $FlowFixMe Flow thinks console is immutable. 30781 30782 Object.defineProperties(console, { 30783 info: props, 30784 log: props, 30785 warn: props, 30786 error: props, 30787 group: props, 30788 groupCollapsed: props, 30789 groupEnd: props 30790 }); 30791 /* eslint-enable react-internal/no-production-logging */ 30792 } 30793 30794 disabledDepth++; 30795 } 30796} 30797function reenableLogs() { 30798 { 30799 disabledDepth--; 30800 30801 if (disabledDepth === 0) { 30802 /* eslint-disable react-internal/no-production-logging */ 30803 var props = { 30804 configurable: true, 30805 enumerable: true, 30806 writable: true 30807 }; // $FlowFixMe Flow thinks console is immutable. 30808 30809 Object.defineProperties(console, { 30810 log: _assign({}, props, { 30811 value: prevLog 30812 }), 30813 info: _assign({}, props, { 30814 value: prevInfo 30815 }), 30816 warn: _assign({}, props, { 30817 value: prevWarn 30818 }), 30819 error: _assign({}, props, { 30820 value: prevError 30821 }), 30822 group: _assign({}, props, { 30823 value: prevGroup 30824 }), 30825 groupCollapsed: _assign({}, props, { 30826 value: prevGroupCollapsed 30827 }), 30828 groupEnd: _assign({}, props, { 30829 value: prevGroupEnd 30830 }) 30831 }); 30832 /* eslint-enable react-internal/no-production-logging */ 30833 } 30834 30835 if (disabledDepth < 0) { 30836 error('disabledDepth fell below zero. ' + 'This is a bug in React. Please file an issue.'); 30837 } 30838 } 30839} 30840 30841var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher; 30842var prefix; 30843function describeBuiltInComponentFrame(name, source, ownerFn) { 30844 { 30845 if (prefix === undefined) { 30846 // Extract the VM specific prefix used by each line. 30847 try { 30848 throw Error(); 30849 } catch (x) { 30850 var match = x.stack.trim().match(/\n( *(at )?)/); 30851 prefix = match && match[1] || ''; 30852 } 30853 } // We use the prefix to ensure our stacks line up with native stack frames. 30854 30855 30856 return '\n' + prefix + name; 30857 } 30858} 30859var reentry = false; 30860var componentFrameCache; 30861 30862{ 30863 var PossiblyWeakMap = typeof WeakMap === 'function' ? WeakMap : Map; 30864 componentFrameCache = new PossiblyWeakMap(); 30865} 30866 30867function describeNativeComponentFrame(fn, construct) { 30868 // If something asked for a stack inside a fake render, it should get ignored. 30869 if (!fn || reentry) { 30870 return ''; 30871 } 30872 30873 { 30874 var frame = componentFrameCache.get(fn); 30875 30876 if (frame !== undefined) { 30877 return frame; 30878 } 30879 } 30880 30881 var control; 30882 reentry = true; 30883 var previousPrepareStackTrace = Error.prepareStackTrace; // $FlowFixMe It does accept undefined. 30884 30885 Error.prepareStackTrace = undefined; 30886 var previousDispatcher; 30887 30888 { 30889 previousDispatcher = ReactCurrentDispatcher$1.current; // Set the dispatcher in DEV because this might be call in the render function 30890 // for warnings. 30891 30892 ReactCurrentDispatcher$1.current = null; 30893 disableLogs(); 30894 } 30895 30896 try { 30897 // This should throw. 30898 if (construct) { 30899 // Something should be setting the props in the constructor. 30900 var Fake = function () { 30901 throw Error(); 30902 }; // $FlowFixMe 30903 30904 30905 Object.defineProperty(Fake.prototype, 'props', { 30906 set: function () { 30907 // We use a throwing setter instead of frozen or non-writable props 30908 // because that won't throw in a non-strict mode function. 30909 throw Error(); 30910 } 30911 }); 30912 30913 if (typeof Reflect === 'object' && Reflect.construct) { 30914 // We construct a different control for this case to include any extra 30915 // frames added by the construct call. 30916 try { 30917 Reflect.construct(Fake, []); 30918 } catch (x) { 30919 control = x; 30920 } 30921 30922 Reflect.construct(fn, [], Fake); 30923 } else { 30924 try { 30925 Fake.call(); 30926 } catch (x) { 30927 control = x; 30928 } 30929 30930 fn.call(Fake.prototype); 30931 } 30932 } else { 30933 try { 30934 throw Error(); 30935 } catch (x) { 30936 control = x; 30937 } 30938 30939 fn(); 30940 } 30941 } catch (sample) { 30942 // This is inlined manually because closure doesn't do it for us. 30943 if (sample && control && typeof sample.stack === 'string') { 30944 // This extracts the first frame from the sample that isn't also in the control. 30945 // Skipping one frame that we assume is the frame that calls the two. 30946 var sampleLines = sample.stack.split('\n'); 30947 var controlLines = control.stack.split('\n'); 30948 var s = sampleLines.length - 1; 30949 var c = controlLines.length - 1; 30950 30951 while (s >= 1 && c >= 0 && sampleLines[s] !== controlLines[c]) { 30952 // We expect at least one stack frame to be shared. 30953 // Typically this will be the root most one. However, stack frames may be 30954 // cut off due to maximum stack limits. In this case, one maybe cut off 30955 // earlier than the other. We assume that the sample is longer or the same 30956 // and there for cut off earlier. So we should find the root most frame in 30957 // the sample somewhere in the control. 30958 c--; 30959 } 30960 30961 for (; s >= 1 && c >= 0; s--, c--) { 30962 // Next we find the first one that isn't the same which should be the 30963 // frame that called our sample function and the control. 30964 if (sampleLines[s] !== controlLines[c]) { 30965 // In V8, the first line is describing the message but other VMs don't. 30966 // If we're about to return the first line, and the control is also on the same 30967 // line, that's a pretty good indicator that our sample threw at same line as 30968 // the control. I.e. before we entered the sample frame. So we ignore this result. 30969 // This can happen if you passed a class to function component, or non-function. 30970 if (s !== 1 || c !== 1) { 30971 do { 30972 s--; 30973 c--; // We may still have similar intermediate frames from the construct call. 30974 // The next one that isn't the same should be our match though. 30975 30976 if (c < 0 || sampleLines[s] !== controlLines[c]) { 30977 // V8 adds a "new" prefix for native classes. Let's remove it to make it prettier. 30978 var _frame = '\n' + sampleLines[s].replace(' at new ', ' at '); 30979 30980 { 30981 if (typeof fn === 'function') { 30982 componentFrameCache.set(fn, _frame); 30983 } 30984 } // Return the line we found. 30985 30986 30987 return _frame; 30988 } 30989 } while (s >= 1 && c >= 0); 30990 } 30991 30992 break; 30993 } 30994 } 30995 } 30996 } finally { 30997 reentry = false; 30998 30999 { 31000 ReactCurrentDispatcher$1.current = previousDispatcher; 31001 reenableLogs(); 31002 } 31003 31004 Error.prepareStackTrace = previousPrepareStackTrace; 31005 } // Fallback to just using the name if we couldn't make it throw. 31006 31007 31008 var name = fn ? fn.displayName || fn.name : ''; 31009 var syntheticFrame = name ? describeBuiltInComponentFrame(name) : ''; 31010 31011 { 31012 if (typeof fn === 'function') { 31013 componentFrameCache.set(fn, syntheticFrame); 31014 } 31015 } 31016 31017 return syntheticFrame; 31018} 31019function describeFunctionComponentFrame(fn, source, ownerFn) { 31020 { 31021 return describeNativeComponentFrame(fn, false); 31022 } 31023} 31024 31025function shouldConstruct(Component) { 31026 var prototype = Component.prototype; 31027 return !!(prototype && prototype.isReactComponent); 31028} 31029 31030function describeUnknownElementTypeFrameInDEV(type, source, ownerFn) { 31031 31032 if (type == null) { 31033 return ''; 31034 } 31035 31036 if (typeof type === 'function') { 31037 { 31038 return describeNativeComponentFrame(type, shouldConstruct(type)); 31039 } 31040 } 31041 31042 if (typeof type === 'string') { 31043 return describeBuiltInComponentFrame(type); 31044 } 31045 31046 switch (type) { 31047 case exports.Suspense: 31048 return describeBuiltInComponentFrame('Suspense'); 31049 31050 case REACT_SUSPENSE_LIST_TYPE: 31051 return describeBuiltInComponentFrame('SuspenseList'); 31052 } 31053 31054 if (typeof type === 'object') { 31055 switch (type.$$typeof) { 31056 case REACT_FORWARD_REF_TYPE: 31057 return describeFunctionComponentFrame(type.render); 31058 31059 case REACT_MEMO_TYPE: 31060 // Memo may contain any component type so we recursively resolve it. 31061 return describeUnknownElementTypeFrameInDEV(type.type, source, ownerFn); 31062 31063 case REACT_BLOCK_TYPE: 31064 return describeFunctionComponentFrame(type._render); 31065 31066 case REACT_LAZY_TYPE: 31067 { 31068 var lazyComponent = type; 31069 var payload = lazyComponent._payload; 31070 var init = lazyComponent._init; 31071 31072 try { 31073 // Lazy may contain any component type so we recursively resolve it. 31074 return describeUnknownElementTypeFrameInDEV(init(payload), source, ownerFn); 31075 } catch (x) {} 31076 } 31077 } 31078 } 31079 31080 return ''; 31081} 31082 31083var loggedTypeFailures = {}; 31084var ReactDebugCurrentFrame$1 = ReactSharedInternals.ReactDebugCurrentFrame; 31085 31086function setCurrentlyValidatingElement(element) { 31087 { 31088 if (element) { 31089 var owner = element._owner; 31090 var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null); 31091 ReactDebugCurrentFrame$1.setExtraStackFrame(stack); 31092 } else { 31093 ReactDebugCurrentFrame$1.setExtraStackFrame(null); 31094 } 31095 } 31096} 31097 31098function checkPropTypes(typeSpecs, values, location, componentName, element) { 31099 { 31100 // $FlowFixMe This is okay but Flow doesn't know it. 31101 var has = Function.call.bind(Object.prototype.hasOwnProperty); 31102 31103 for (var typeSpecName in typeSpecs) { 31104 if (has(typeSpecs, typeSpecName)) { 31105 var error$1 = void 0; // Prop type validation may throw. In case they do, we don't want to 31106 // fail the render phase where it didn't fail before. So we log it. 31107 // After these have been cleaned up, we'll let them throw. 31108 31109 try { 31110 // This is intentionally an invariant that gets caught. It's the same 31111 // behavior as without this statement except with a better message. 31112 if (typeof typeSpecs[typeSpecName] !== 'function') { 31113 var err = Error((componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' + 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.' + 'This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.'); 31114 err.name = 'Invariant Violation'; 31115 throw err; 31116 } 31117 31118 error$1 = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED'); 31119 } catch (ex) { 31120 error$1 = ex; 31121 } 31122 31123 if (error$1 && !(error$1 instanceof Error)) { 31124 setCurrentlyValidatingElement(element); 31125 31126 error('%s: type specification of %s' + ' `%s` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a %s. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).', componentName || 'React class', location, typeSpecName, typeof error$1); 31127 31128 setCurrentlyValidatingElement(null); 31129 } 31130 31131 if (error$1 instanceof Error && !(error$1.message in loggedTypeFailures)) { 31132 // Only monitor this failure once because there tends to be a lot of the 31133 // same error. 31134 loggedTypeFailures[error$1.message] = true; 31135 setCurrentlyValidatingElement(element); 31136 31137 error('Failed %s type: %s', location, error$1.message); 31138 31139 setCurrentlyValidatingElement(null); 31140 } 31141 } 31142 } 31143 } 31144} 31145 31146function setCurrentlyValidatingElement$1(element) { 31147 { 31148 if (element) { 31149 var owner = element._owner; 31150 var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null); 31151 setExtraStackFrame(stack); 31152 } else { 31153 setExtraStackFrame(null); 31154 } 31155 } 31156} 31157 31158var propTypesMisspellWarningShown; 31159 31160{ 31161 propTypesMisspellWarningShown = false; 31162} 31163 31164function getDeclarationErrorAddendum() { 31165 if (ReactCurrentOwner.current) { 31166 var name = getComponentName(ReactCurrentOwner.current.type); 31167 31168 if (name) { 31169 return '\n\nCheck the render method of `' + name + '`.'; 31170 } 31171 } 31172 31173 return ''; 31174} 31175 31176function getSourceInfoErrorAddendum(source) { 31177 if (source !== undefined) { 31178 var fileName = source.fileName.replace(/^.*[\\\/]/, ''); 31179 var lineNumber = source.lineNumber; 31180 return '\n\nCheck your code at ' + fileName + ':' + lineNumber + '.'; 31181 } 31182 31183 return ''; 31184} 31185 31186function getSourceInfoErrorAddendumForProps(elementProps) { 31187 if (elementProps !== null && elementProps !== undefined) { 31188 return getSourceInfoErrorAddendum(elementProps.__source); 31189 } 31190 31191 return ''; 31192} 31193/** 31194 * Warn if there's no key explicitly set on dynamic arrays of children or 31195 * object keys are not valid. This allows us to keep track of children between 31196 * updates. 31197 */ 31198 31199 31200var ownerHasKeyUseWarning = {}; 31201 31202function getCurrentComponentErrorInfo(parentType) { 31203 var info = getDeclarationErrorAddendum(); 31204 31205 if (!info) { 31206 var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name; 31207 31208 if (parentName) { 31209 info = "\n\nCheck the top-level render call using <" + parentName + ">."; 31210 } 31211 } 31212 31213 return info; 31214} 31215/** 31216 * Warn if the element doesn't have an explicit key assigned to it. 31217 * This element is in an array. The array could grow and shrink or be 31218 * reordered. All children that haven't already been validated are required to 31219 * have a "key" property assigned to it. Error statuses are cached so a warning 31220 * will only be shown once. 31221 * 31222 * @internal 31223 * @param {ReactElement} element Element that requires a key. 31224 * @param {*} parentType element's parent's type. 31225 */ 31226 31227 31228function validateExplicitKey(element, parentType) { 31229 if (!element._store || element._store.validated || element.key != null) { 31230 return; 31231 } 31232 31233 element._store.validated = true; 31234 var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType); 31235 31236 if (ownerHasKeyUseWarning[currentComponentErrorInfo]) { 31237 return; 31238 } 31239 31240 ownerHasKeyUseWarning[currentComponentErrorInfo] = true; // Usually the current owner is the offender, but if it accepts children as a 31241 // property, it may be the creator of the child that's responsible for 31242 // assigning it a key. 31243 31244 var childOwner = ''; 31245 31246 if (element && element._owner && element._owner !== ReactCurrentOwner.current) { 31247 // Give the component that originally created this child. 31248 childOwner = " It was passed a child from " + getComponentName(element._owner.type) + "."; 31249 } 31250 31251 { 31252 setCurrentlyValidatingElement$1(element); 31253 31254 error('Each child in a list should have a unique "key" prop.' + '%s%s See https://reactjs.org/link/warning-keys for more information.', currentComponentErrorInfo, childOwner); 31255 31256 setCurrentlyValidatingElement$1(null); 31257 } 31258} 31259/** 31260 * Ensure that every element either is passed in a static location, in an 31261 * array with an explicit keys property defined, or in an object literal 31262 * with valid key property. 31263 * 31264 * @internal 31265 * @param {ReactNode} node Statically passed child of any type. 31266 * @param {*} parentType node's parent's type. 31267 */ 31268 31269 31270function validateChildKeys(node, parentType) { 31271 if (typeof node !== 'object') { 31272 return; 31273 } 31274 31275 if (Array.isArray(node)) { 31276 for (var i = 0; i < node.length; i++) { 31277 var child = node[i]; 31278 31279 if (isValidElement(child)) { 31280 validateExplicitKey(child, parentType); 31281 } 31282 } 31283 } else if (isValidElement(node)) { 31284 // This element was passed in a valid location. 31285 if (node._store) { 31286 node._store.validated = true; 31287 } 31288 } else if (node) { 31289 var iteratorFn = getIteratorFn(node); 31290 31291 if (typeof iteratorFn === 'function') { 31292 // Entry iterators used to provide implicit keys, 31293 // but now we print a separate warning for them later. 31294 if (iteratorFn !== node.entries) { 31295 var iterator = iteratorFn.call(node); 31296 var step; 31297 31298 while (!(step = iterator.next()).done) { 31299 if (isValidElement(step.value)) { 31300 validateExplicitKey(step.value, parentType); 31301 } 31302 } 31303 } 31304 } 31305 } 31306} 31307/** 31308 * Given an element, validate that its props follow the propTypes definition, 31309 * provided by the type. 31310 * 31311 * @param {ReactElement} element 31312 */ 31313 31314 31315function validatePropTypes(element) { 31316 { 31317 var type = element.type; 31318 31319 if (type === null || type === undefined || typeof type === 'string') { 31320 return; 31321 } 31322 31323 var propTypes; 31324 31325 if (typeof type === 'function') { 31326 propTypes = type.propTypes; 31327 } else if (typeof type === 'object' && (type.$$typeof === REACT_FORWARD_REF_TYPE || // Note: Memo only checks outer props here. 31328 // Inner props are checked in the reconciler. 31329 type.$$typeof === REACT_MEMO_TYPE)) { 31330 propTypes = type.propTypes; 31331 } else { 31332 return; 31333 } 31334 31335 if (propTypes) { 31336 // Intentionally inside to avoid triggering lazy initializers: 31337 var name = getComponentName(type); 31338 checkPropTypes(propTypes, element.props, 'prop', name, element); 31339 } else if (type.PropTypes !== undefined && !propTypesMisspellWarningShown) { 31340 propTypesMisspellWarningShown = true; // Intentionally inside to avoid triggering lazy initializers: 31341 31342 var _name = getComponentName(type); 31343 31344 error('Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?', _name || 'Unknown'); 31345 } 31346 31347 if (typeof type.getDefaultProps === 'function' && !type.getDefaultProps.isReactClassApproved) { 31348 error('getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.'); 31349 } 31350 } 31351} 31352/** 31353 * Given a fragment, validate that it can only be provided with fragment props 31354 * @param {ReactElement} fragment 31355 */ 31356 31357 31358function validateFragmentProps(fragment) { 31359 { 31360 var keys = Object.keys(fragment.props); 31361 31362 for (var i = 0; i < keys.length; i++) { 31363 var key = keys[i]; 31364 31365 if (key !== 'children' && key !== 'key') { 31366 setCurrentlyValidatingElement$1(fragment); 31367 31368 error('Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', key); 31369 31370 setCurrentlyValidatingElement$1(null); 31371 break; 31372 } 31373 } 31374 31375 if (fragment.ref !== null) { 31376 setCurrentlyValidatingElement$1(fragment); 31377 31378 error('Invalid attribute `ref` supplied to `React.Fragment`.'); 31379 31380 setCurrentlyValidatingElement$1(null); 31381 } 31382 } 31383} 31384function createElementWithValidation(type, props, children) { 31385 var validType = isValidElementType(type); // We warn in this case but don't throw. We expect the element creation to 31386 // succeed and there will likely be errors in render. 31387 31388 if (!validType) { 31389 var info = ''; 31390 31391 if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) { 31392 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."; 31393 } 31394 31395 var sourceInfo = getSourceInfoErrorAddendumForProps(props); 31396 31397 if (sourceInfo) { 31398 info += sourceInfo; 31399 } else { 31400 info += getDeclarationErrorAddendum(); 31401 } 31402 31403 var typeString; 31404 31405 if (type === null) { 31406 typeString = 'null'; 31407 } else if (Array.isArray(type)) { 31408 typeString = 'array'; 31409 } else if (type !== undefined && type.$$typeof === REACT_ELEMENT_TYPE) { 31410 typeString = "<" + (getComponentName(type.type) || 'Unknown') + " />"; 31411 info = ' Did you accidentally export a JSX literal instead of a component?'; 31412 } else { 31413 typeString = typeof type; 31414 } 31415 31416 { 31417 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); 31418 } 31419 } 31420 31421 var element = createElement.apply(this, arguments); // The result can be nullish if a mock or a custom function is used. 31422 // TODO: Drop this when these are no longer allowed as the type argument. 31423 31424 if (element == null) { 31425 return element; 31426 } // Skip key warning if the type isn't valid since our key validation logic 31427 // doesn't expect a non-string/function type and can throw confusing errors. 31428 // We don't want exception behavior to differ between dev and prod. 31429 // (Rendering will throw with a helpful message and as soon as the type is 31430 // fixed, the key warnings will appear.) 31431 31432 31433 if (validType) { 31434 for (var i = 2; i < arguments.length; i++) { 31435 validateChildKeys(arguments[i], type); 31436 } 31437 } 31438 31439 if (type === exports.Fragment) { 31440 validateFragmentProps(element); 31441 } else { 31442 validatePropTypes(element); 31443 } 31444 31445 return element; 31446} 31447var didWarnAboutDeprecatedCreateFactory = false; 31448function createFactoryWithValidation(type) { 31449 var validatedFactory = createElementWithValidation.bind(null, type); 31450 validatedFactory.type = type; 31451 31452 { 31453 if (!didWarnAboutDeprecatedCreateFactory) { 31454 didWarnAboutDeprecatedCreateFactory = true; 31455 31456 warn('React.createFactory() is deprecated and will be removed in ' + 'a future major release. Consider using JSX ' + 'or use React.createElement() directly instead.'); 31457 } // Legacy hook: remove it 31458 31459 31460 Object.defineProperty(validatedFactory, 'type', { 31461 enumerable: false, 31462 get: function () { 31463 warn('Factory.type is deprecated. Access the class directly ' + 'before passing it to createFactory.'); 31464 31465 Object.defineProperty(this, 'type', { 31466 value: type 31467 }); 31468 return type; 31469 } 31470 }); 31471 } 31472 31473 return validatedFactory; 31474} 31475function cloneElementWithValidation(element, props, children) { 31476 var newElement = cloneElement.apply(this, arguments); 31477 31478 for (var i = 2; i < arguments.length; i++) { 31479 validateChildKeys(arguments[i], newElement.type); 31480 } 31481 31482 validatePropTypes(newElement); 31483 return newElement; 31484} 31485 31486{ 31487 31488 try { 31489 var frozenObject = Object.freeze({}); 31490 /* eslint-disable no-new */ 31491 31492 new Map([[frozenObject, null]]); 31493 new Set([frozenObject]); 31494 /* eslint-enable no-new */ 31495 } catch (e) { 31496 } 31497} 31498 31499var createElement$1 = createElementWithValidation ; 31500var cloneElement$1 = cloneElementWithValidation ; 31501var createFactory = createFactoryWithValidation ; 31502var Children = { 31503 map: mapChildren, 31504 forEach: forEachChildren, 31505 count: countChildren, 31506 toArray: toArray, 31507 only: onlyChild 31508}; 31509 31510exports.Children = Children; 31511exports.Component = Component; 31512exports.PureComponent = PureComponent; 31513exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = ReactSharedInternals; 31514exports.cloneElement = cloneElement$1; 31515exports.createContext = createContext; 31516exports.createElement = createElement$1; 31517exports.createFactory = createFactory; 31518exports.createRef = createRef; 31519exports.forwardRef = forwardRef; 31520exports.isValidElement = isValidElement; 31521exports.lazy = lazy; 31522exports.memo = memo; 31523exports.useCallback = useCallback; 31524exports.useContext = useContext; 31525exports.useDebugValue = useDebugValue; 31526exports.useEffect = useEffect; 31527exports.useImperativeHandle = useImperativeHandle; 31528exports.useLayoutEffect = useLayoutEffect; 31529exports.useMemo = useMemo; 31530exports.useReducer = useReducer; 31531exports.useRef = useRef; 31532exports.useState = useState; 31533exports.version = ReactVersion; 31534 })(); 31535} 31536 31537 31538/***/ }), 31539
vendor: 686 bytes, lines 31540-31555
31540/***/ "./.yarn/cache/react-npm-17.0.1-98658812fc-23ada2f8fe.zip/node_modules/react/index.js": 31541/*!********************************************************************************************!*\ 31542 !*** ./.yarn/cache/react-npm-17.0.1-98658812fc-23ada2f8fe.zip/node_modules/react/index.js ***! 31543 \********************************************************************************************/ 31544/***/ ((module, __unused_webpack_exports, __webpack_require__) => { 31545 31546"use strict"; 31547 31548 31549if (false) {} else { 31550 module.exports = __webpack_require__(/*! ./cjs/react.development.js */ "./.yarn/cache/react-npm-17.0.1-98658812fc-23ada2f8fe.zip/node_modules/react/cjs/react.development.js"); 31551} 31552 31553 31554/***/ }), 31555
vendor: 9,561 bytes, lines 31556-31913
31556/***/ "./.yarn/cache/scheduler-npm-0.20.2-90beaecfba-898917fa47.zip/node_modules/scheduler/cjs/scheduler-tracing.development.js": 31557/*!********************************************************************************************************************************!*\ 31558 !*** ./.yarn/cache/scheduler-npm-0.20.2-90beaecfba-898917fa47.zip/node_modules/scheduler/cjs/scheduler-tracing.development.js ***! 31559 \********************************************************************************************************************************/ 31560/***/ ((__unused_webpack_module, exports) => { 31561 31562"use strict"; 31563/** @license React v0.20.2 31564 * scheduler-tracing.development.js 31565 * 31566 * Copyright (c) Facebook, Inc. and its affiliates. 31567 * 31568 * This source code is licensed under the MIT license found in the 31569 * LICENSE file in the root directory of this source tree. 31570 */ 31571 31572 31573 31574if (true) { 31575 (function() { 31576'use strict'; 31577 31578var DEFAULT_THREAD_ID = 0; // Counters used to generate unique IDs. 31579 31580var interactionIDCounter = 0; 31581var threadIDCounter = 0; // Set of currently traced interactions. 31582// Interactions "stack"– 31583// Meaning that newly traced interactions are appended to the previously active set. 31584// When an interaction goes out of scope, the previous set (if any) is restored. 31585 31586exports.__interactionsRef = null; // Listener(s) to notify when interactions begin and end. 31587 31588exports.__subscriberRef = null; 31589 31590{ 31591 exports.__interactionsRef = { 31592 current: new Set() 31593 }; 31594 exports.__subscriberRef = { 31595 current: null 31596 }; 31597} 31598function unstable_clear(callback) { 31599 31600 var prevInteractions = exports.__interactionsRef.current; 31601 exports.__interactionsRef.current = new Set(); 31602 31603 try { 31604 return callback(); 31605 } finally { 31606 exports.__interactionsRef.current = prevInteractions; 31607 } 31608} 31609function unstable_getCurrent() { 31610 { 31611 return exports.__interactionsRef.current; 31612 } 31613} 31614function unstable_getThreadID() { 31615 return ++threadIDCounter; 31616} 31617function unstable_trace(name, timestamp, callback) { 31618 var threadID = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : DEFAULT_THREAD_ID; 31619 31620 var interaction = { 31621 __count: 1, 31622 id: interactionIDCounter++, 31623 name: name, 31624 timestamp: timestamp 31625 }; 31626 var prevInteractions = exports.__interactionsRef.current; // Traced interactions should stack/accumulate. 31627 // To do that, clone the current interactions. 31628 // The previous set will be restored upon completion. 31629 31630 var interactions = new Set(prevInteractions); 31631 interactions.add(interaction); 31632 exports.__interactionsRef.current = interactions; 31633 var subscriber = exports.__subscriberRef.current; 31634 var returnValue; 31635 31636 try { 31637 if (subscriber !== null) { 31638 subscriber.onInteractionTraced(interaction); 31639 } 31640 } finally { 31641 try { 31642 if (subscriber !== null) { 31643 subscriber.onWorkStarted(interactions, threadID); 31644 } 31645 } finally { 31646 try { 31647 returnValue = callback(); 31648 } finally { 31649 exports.__interactionsRef.current = prevInteractions; 31650 31651 try { 31652 if (subscriber !== null) { 31653 subscriber.onWorkStopped(interactions, threadID); 31654 } 31655 } finally { 31656 interaction.__count--; // If no async work was scheduled for this interaction, 31657 // Notify subscribers that it's completed. 31658 31659 if (subscriber !== null && interaction.__count === 0) { 31660 subscriber.onInteractionScheduledWorkCompleted(interaction); 31661 } 31662 } 31663 } 31664 } 31665 } 31666 31667 return returnValue; 31668} 31669function unstable_wrap(callback) { 31670 var threadID = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_THREAD_ID; 31671 31672 var wrappedInteractions = exports.__interactionsRef.current; 31673 var subscriber = exports.__subscriberRef.current; 31674 31675 if (subscriber !== null) { 31676 subscriber.onWorkScheduled(wrappedInteractions, threadID); 31677 } // Update the pending async work count for the current interactions. 31678 // Update after calling subscribers in case of error. 31679 31680 31681 wrappedInteractions.forEach(function (interaction) { 31682 interaction.__count++; 31683 }); 31684 var hasRun = false; 31685 31686 function wrapped() { 31687 var prevInteractions = exports.__interactionsRef.current; 31688 exports.__interactionsRef.current = wrappedInteractions; 31689 subscriber = exports.__subscriberRef.current; 31690 31691 try { 31692 var returnValue; 31693 31694 try { 31695 if (subscriber !== null) { 31696 subscriber.onWorkStarted(wrappedInteractions, threadID); 31697 } 31698 } finally { 31699 try { 31700 returnValue = callback.apply(undefined, arguments); 31701 } finally { 31702 exports.__interactionsRef.current = prevInteractions; 31703 31704 if (subscriber !== null) { 31705 subscriber.onWorkStopped(wrappedInteractions, threadID); 31706 } 31707 } 31708 } 31709 31710 return returnValue; 31711 } finally { 31712 if (!hasRun) { 31713 // We only expect a wrapped function to be executed once, 31714 // But in the event that it's executed more than once– 31715 // Only decrement the outstanding interaction counts once. 31716 hasRun = true; // Update pending async counts for all wrapped interactions. 31717 // If this was the last scheduled async work for any of them, 31718 // Mark them as completed. 31719 31720 wrappedInteractions.forEach(function (interaction) { 31721 interaction.__count--; 31722 31723 if (subscriber !== null && interaction.__count === 0) { 31724 subscriber.onInteractionScheduledWorkCompleted(interaction); 31725 } 31726 }); 31727 } 31728 } 31729 } 31730 31731 wrapped.cancel = function cancel() { 31732 subscriber = exports.__subscriberRef.current; 31733 31734 try { 31735 if (subscriber !== null) { 31736 subscriber.onWorkCanceled(wrappedInteractions, threadID); 31737 } 31738 } finally { 31739 // Update pending async counts for all wrapped interactions. 31740 // If this was the last scheduled async work for any of them, 31741 // Mark them as completed. 31742 wrappedInteractions.forEach(function (interaction) { 31743 interaction.__count--; 31744 31745 if (subscriber && interaction.__count === 0) { 31746 subscriber.onInteractionScheduledWorkCompleted(interaction); 31747 } 31748 }); 31749 } 31750 }; 31751 31752 return wrapped; 31753} 31754 31755var subscribers = null; 31756 31757{ 31758 subscribers = new Set(); 31759} 31760 31761function unstable_subscribe(subscriber) { 31762 { 31763 subscribers.add(subscriber); 31764 31765 if (subscribers.size === 1) { 31766 exports.__subscriberRef.current = { 31767 onInteractionScheduledWorkCompleted: onInteractionScheduledWorkCompleted, 31768 onInteractionTraced: onInteractionTraced, 31769 onWorkCanceled: onWorkCanceled, 31770 onWorkScheduled: onWorkScheduled, 31771 onWorkStarted: onWorkStarted, 31772 onWorkStopped: onWorkStopped 31773 }; 31774 } 31775 } 31776} 31777function unstable_unsubscribe(subscriber) { 31778 { 31779 subscribers.delete(subscriber); 31780 31781 if (subscribers.size === 0) { 31782 exports.__subscriberRef.current = null; 31783 } 31784 } 31785} 31786 31787function onInteractionTraced(interaction) { 31788 var didCatchError = false; 31789 var caughtError = null; 31790 subscribers.forEach(function (subscriber) { 31791 try { 31792 subscriber.onInteractionTraced(interaction); 31793 } catch (error) { 31794 if (!didCatchError) { 31795 didCatchError = true; 31796 caughtError = error; 31797 } 31798 } 31799 }); 31800 31801 if (didCatchError) { 31802 throw caughtError; 31803 } 31804} 31805 31806function onInteractionScheduledWorkCompleted(interaction) { 31807 var didCatchError = false; 31808 var caughtError = null; 31809 subscribers.forEach(function (subscriber) { 31810 try { 31811 subscriber.onInteractionScheduledWorkCompleted(interaction); 31812 } catch (error) { 31813 if (!didCatchError) { 31814 didCatchError = true; 31815 caughtError = error; 31816 } 31817 } 31818 }); 31819 31820 if (didCatchError) { 31821 throw caughtError; 31822 } 31823} 31824 31825function onWorkScheduled(interactions, threadID) { 31826 var didCatchError = false; 31827 var caughtError = null; 31828 subscribers.forEach(function (subscriber) { 31829 try { 31830 subscriber.onWorkScheduled(interactions, threadID); 31831 } catch (error) { 31832 if (!didCatchError) { 31833 didCatchError = true; 31834 caughtError = error; 31835 } 31836 } 31837 }); 31838 31839 if (didCatchError) { 31840 throw caughtError; 31841 } 31842} 31843 31844function onWorkStarted(interactions, threadID) { 31845 var didCatchError = false; 31846 var caughtError = null; 31847 subscribers.forEach(function (subscriber) { 31848 try { 31849 subscriber.onWorkStarted(interactions, threadID); 31850 } catch (error) { 31851 if (!didCatchError) { 31852 didCatchError = true; 31853 caughtError = error; 31854 } 31855 } 31856 }); 31857 31858 if (didCatchError) { 31859 throw caughtError; 31860 } 31861} 31862 31863function onWorkStopped(interactions, threadID) { 31864 var didCatchError = false; 31865 var caughtError = null; 31866 subscribers.forEach(function (subscriber) { 31867 try { 31868 subscriber.onWorkStopped(interactions, threadID); 31869 } catch (error) { 31870 if (!didCatchError) { 31871 didCatchError = true; 31872 caughtError = error; 31873 } 31874 } 31875 }); 31876 31877 if (didCatchError) { 31878 throw caughtError; 31879 } 31880} 31881 31882function onWorkCanceled(interactions, threadID) { 31883 var didCatchError = false; 31884 var caughtError = null; 31885 subscribers.forEach(function (subscriber) { 31886 try { 31887 subscriber.onWorkCanceled(interactions, threadID); 31888 } catch (error) { 31889 if (!didCatchError) { 31890 didCatchError = true; 31891 caughtError = error; 31892 } 31893 } 31894 }); 31895 31896 if (didCatchError) { 31897 throw caughtError; 31898 } 31899} 31900 31901exports.unstable_clear = unstable_clear; 31902exports.unstable_getCurrent = unstable_getCurrent; 31903exports.unstable_getThreadID = unstable_getThreadID; 31904exports.unstable_subscribe = unstable_subscribe; 31905exports.unstable_trace = unstable_trace; 31906exports.unstable_unsubscribe = unstable_unsubscribe; 31907exports.unstable_wrap = unstable_wrap; 31908 })(); 31909} 31910 31911 31912/***/ }), 31913
vendor: 18,091 bytes, lines 31914-32570
31914/***/ "./.yarn/cache/scheduler-npm-0.20.2-90beaecfba-898917fa47.zip/node_modules/scheduler/cjs/scheduler.development.js": 31915/*!************************************************************************************************************************!*\ 31916 !*** ./.yarn/cache/scheduler-npm-0.20.2-90beaecfba-898917fa47.zip/node_modules/scheduler/cjs/scheduler.development.js ***! 31917 \************************************************************************************************************************/ 31918/***/ ((__unused_webpack_module, exports) => { 31919 31920"use strict"; 31921/** @license React v0.20.2 31922 * scheduler.development.js 31923 * 31924 * Copyright (c) Facebook, Inc. and its affiliates. 31925 * 31926 * This source code is licensed under the MIT license found in the 31927 * LICENSE file in the root directory of this source tree. 31928 */ 31929 31930 31931 31932if (true) { 31933 (function() { 31934'use strict'; 31935 31936var enableSchedulerDebugging = false; 31937var enableProfiling = false; 31938 31939var requestHostCallback; 31940var requestHostTimeout; 31941var cancelHostTimeout; 31942var requestPaint; 31943var hasPerformanceNow = typeof performance === 'object' && typeof performance.now === 'function'; 31944 31945if (hasPerformanceNow) { 31946 var localPerformance = performance; 31947 31948 exports.unstable_now = function () { 31949 return localPerformance.now(); 31950 }; 31951} else { 31952 var localDate = Date; 31953 var initialTime = localDate.now(); 31954 31955 exports.unstable_now = function () { 31956 return localDate.now() - initialTime; 31957 }; 31958} 31959 31960if ( // If Scheduler runs in a non-DOM environment, it falls back to a naive 31961// implementation using setTimeout. 31962typeof window === 'undefined' || // Check if MessageChannel is supported, too. 31963typeof MessageChannel !== 'function') { 31964 // If this accidentally gets imported in a non-browser environment, e.g. JavaScriptCore, 31965 // fallback to a naive implementation. 31966 var _callback = null; 31967 var _timeoutID = null; 31968 31969 var _flushCallback = function () { 31970 if (_callback !== null) { 31971 try { 31972 var currentTime = exports.unstable_now(); 31973 var hasRemainingTime = true; 31974 31975 _callback(hasRemainingTime, currentTime); 31976 31977 _callback = null; 31978 } catch (e) { 31979 setTimeout(_flushCallback, 0); 31980 throw e; 31981 } 31982 } 31983 }; 31984 31985 requestHostCallback = function (cb) { 31986 if (_callback !== null) { 31987 // Protect against re-entrancy. 31988 setTimeout(requestHostCallback, 0, cb); 31989 } else { 31990 _callback = cb; 31991 setTimeout(_flushCallback, 0); 31992 } 31993 }; 31994 31995 requestHostTimeout = function (cb, ms) { 31996 _timeoutID = setTimeout(cb, ms); 31997 }; 31998 31999 cancelHostTimeout = function () { 32000 clearTimeout(_timeoutID); 32001 }; 32002 32003 exports.unstable_shouldYield = function () { 32004 return false; 32005 }; 32006 32007 requestPaint = exports.unstable_forceFrameRate = function () {}; 32008} else { 32009 // Capture local references to native APIs, in case a polyfill overrides them. 32010 var _setTimeout = window.setTimeout; 32011 var _clearTimeout = window.clearTimeout; 32012 32013 if (typeof console !== 'undefined') { 32014 // TODO: Scheduler no longer requires these methods to be polyfilled. But 32015 // maybe we want to continue warning if they don't exist, to preserve the 32016 // option to rely on it in the future? 32017 var requestAnimationFrame = window.requestAnimationFrame; 32018 var cancelAnimationFrame = window.cancelAnimationFrame; 32019 32020 if (typeof requestAnimationFrame !== 'function') { 32021 // Using console['error'] to evade Babel and ESLint 32022 console['error']("This browser doesn't support requestAnimationFrame. " + 'Make sure that you load a ' + 'polyfill in older browsers. https://reactjs.org/link/react-polyfills'); 32023 } 32024 32025 if (typeof cancelAnimationFrame !== 'function') { 32026 // Using console['error'] to evade Babel and ESLint 32027 console['error']("This browser doesn't support cancelAnimationFrame. " + 'Make sure that you load a ' + 'polyfill in older browsers. https://reactjs.org/link/react-polyfills'); 32028 } 32029 } 32030 32031 var isMessageLoopRunning = false; 32032 var scheduledHostCallback = null; 32033 var taskTimeoutID = -1; // Scheduler periodically yields in case there is other work on the main 32034 // thread, like user events. By default, it yields multiple times per frame. 32035 // It does not attempt to align with frame boundaries, since most tasks don't 32036 // need to be frame aligned; for those that do, use requestAnimationFrame. 32037 32038 var yieldInterval = 5; 32039 var deadline = 0; // TODO: Make this configurable 32040 32041 { 32042 // `isInputPending` is not available. Since we have no way of knowing if 32043 // there's pending input, always yield at the end of the frame. 32044 exports.unstable_shouldYield = function () { 32045 return exports.unstable_now() >= deadline; 32046 }; // Since we yield every frame regardless, `requestPaint` has no effect. 32047 32048 32049 requestPaint = function () {}; 32050 } 32051 32052 exports.unstable_forceFrameRate = function (fps) { 32053 if (fps < 0 || fps > 125) { 32054 // Using console['error'] to evade Babel and ESLint 32055 console['error']('forceFrameRate takes a positive int between 0 and 125, ' + 'forcing frame rates higher than 125 fps is not supported'); 32056 return; 32057 } 32058 32059 if (fps > 0) { 32060 yieldInterval = Math.floor(1000 / fps); 32061 } else { 32062 // reset the framerate 32063 yieldInterval = 5; 32064 } 32065 }; 32066 32067 var performWorkUntilDeadline = function () { 32068 if (scheduledHostCallback !== null) { 32069 var currentTime = exports.unstable_now(); // Yield after `yieldInterval` ms, regardless of where we are in the vsync 32070 // cycle. This means there's always time remaining at the beginning of 32071 // the message event. 32072 32073 deadline = currentTime + yieldInterval; 32074 var hasTimeRemaining = true; 32075 32076 try { 32077 var hasMoreWork = scheduledHostCallback(hasTimeRemaining, currentTime); 32078 32079 if (!hasMoreWork) { 32080 isMessageLoopRunning = false; 32081 scheduledHostCallback = null; 32082 } else { 32083 // If there's more work, schedule the next message event at the end 32084 // of the preceding one. 32085 port.postMessage(null); 32086 } 32087 } catch (error) { 32088 // If a scheduler task throws, exit the current browser task so the 32089 // error can be observed. 32090 port.postMessage(null); 32091 throw error; 32092 } 32093 } else { 32094 isMessageLoopRunning = false; 32095 } // Yielding to the browser will give it a chance to paint, so we can 32096 }; 32097 32098 var channel = new MessageChannel(); 32099 var port = channel.port2; 32100 channel.port1.onmessage = performWorkUntilDeadline; 32101 32102 requestHostCallback = function (callback) { 32103 scheduledHostCallback = callback; 32104 32105 if (!isMessageLoopRunning) { 32106 isMessageLoopRunning = true; 32107 port.postMessage(null); 32108 } 32109 }; 32110 32111 requestHostTimeout = function (callback, ms) { 32112 taskTimeoutID = _setTimeout(function () { 32113 callback(exports.unstable_now()); 32114 }, ms); 32115 }; 32116 32117 cancelHostTimeout = function () { 32118 _clearTimeout(taskTimeoutID); 32119 32120 taskTimeoutID = -1; 32121 }; 32122} 32123 32124function push(heap, node) { 32125 var index = heap.length; 32126 heap.push(node); 32127 siftUp(heap, node, index); 32128} 32129function peek(heap) { 32130 var first = heap[0]; 32131 return first === undefined ? null : first; 32132} 32133function pop(heap) { 32134 var first = heap[0]; 32135 32136 if (first !== undefined) { 32137 var last = heap.pop(); 32138 32139 if (last !== first) { 32140 heap[0] = last; 32141 siftDown(heap, last, 0); 32142 } 32143 32144 return first; 32145 } else { 32146 return null; 32147 } 32148} 32149 32150function siftUp(heap, node, i) { 32151 var index = i; 32152 32153 while (true) { 32154 var parentIndex = index - 1 >>> 1; 32155 var parent = heap[parentIndex]; 32156 32157 if (parent !== undefined && compare(parent, node) > 0) { 32158 // The parent is larger. Swap positions. 32159 heap[parentIndex] = node; 32160 heap[index] = parent; 32161 index = parentIndex; 32162 } else { 32163 // The parent is smaller. Exit. 32164 return; 32165 } 32166 } 32167} 32168 32169function siftDown(heap, node, i) { 32170 var index = i; 32171 var length = heap.length; 32172 32173 while (index < length) { 32174 var leftIndex = (index + 1) * 2 - 1; 32175 var left = heap[leftIndex]; 32176 var rightIndex = leftIndex + 1; 32177 var right = heap[rightIndex]; // If the left or right node is smaller, swap with the smaller of those. 32178 32179 if (left !== undefined && compare(left, node) < 0) { 32180 if (right !== undefined && compare(right, left) < 0) { 32181 heap[index] = right; 32182 heap[rightIndex] = node; 32183 index = rightIndex; 32184 } else { 32185 heap[index] = left; 32186 heap[leftIndex] = node; 32187 index = leftIndex; 32188 } 32189 } else if (right !== undefined && compare(right, node) < 0) { 32190 heap[index] = right; 32191 heap[rightIndex] = node; 32192 index = rightIndex; 32193 } else { 32194 // Neither child is smaller. Exit. 32195 return; 32196 } 32197 } 32198} 32199 32200function compare(a, b) { 32201 // Compare sort index first, then task id. 32202 var diff = a.sortIndex - b.sortIndex; 32203 return diff !== 0 ? diff : a.id - b.id; 32204} 32205 32206// TODO: Use symbols? 32207var ImmediatePriority = 1; 32208var UserBlockingPriority = 2; 32209var NormalPriority = 3; 32210var LowPriority = 4; 32211var IdlePriority = 5; 32212 32213function markTaskErrored(task, ms) { 32214} 32215 32216/* eslint-disable no-var */ 32217// Math.pow(2, 30) - 1 32218// 0b111111111111111111111111111111 32219 32220var maxSigned31BitInt = 1073741823; // Times out immediately 32221 32222var IMMEDIATE_PRIORITY_TIMEOUT = -1; // Eventually times out 32223 32224var USER_BLOCKING_PRIORITY_TIMEOUT = 250; 32225var NORMAL_PRIORITY_TIMEOUT = 5000; 32226var LOW_PRIORITY_TIMEOUT = 10000; // Never times out 32227 32228var IDLE_PRIORITY_TIMEOUT = maxSigned31BitInt; // Tasks are stored on a min heap 32229 32230var taskQueue = []; 32231var timerQueue = []; // Incrementing id counter. Used to maintain insertion order. 32232 32233var taskIdCounter = 1; // Pausing the scheduler is useful for debugging. 32234var currentTask = null; 32235var currentPriorityLevel = NormalPriority; // This is set while performing work, to prevent re-entrancy. 32236 32237var isPerformingWork = false; 32238var isHostCallbackScheduled = false; 32239var isHostTimeoutScheduled = false; 32240 32241function advanceTimers(currentTime) { 32242 // Check for tasks that are no longer delayed and add them to the queue. 32243 var timer = peek(timerQueue); 32244 32245 while (timer !== null) { 32246 if (timer.callback === null) { 32247 // Timer was cancelled. 32248 pop(timerQueue); 32249 } else if (timer.startTime <= currentTime) { 32250 // Timer fired. Transfer to the task queue. 32251 pop(timerQueue); 32252 timer.sortIndex = timer.expirationTime; 32253 push(taskQueue, timer); 32254 } else { 32255 // Remaining timers are pending. 32256 return; 32257 } 32258 32259 timer = peek(timerQueue); 32260 } 32261} 32262 32263function handleTimeout(currentTime) { 32264 isHostTimeoutScheduled = false; 32265 advanceTimers(currentTime); 32266 32267 if (!isHostCallbackScheduled) { 32268 if (peek(taskQueue) !== null) { 32269 isHostCallbackScheduled = true; 32270 requestHostCallback(flushWork); 32271 } else { 32272 var firstTimer = peek(timerQueue); 32273 32274 if (firstTimer !== null) { 32275 requestHostTimeout(handleTimeout, firstTimer.startTime - currentTime); 32276 } 32277 } 32278 } 32279} 32280 32281function flushWork(hasTimeRemaining, initialTime) { 32282 32283 32284 isHostCallbackScheduled = false; 32285 32286 if (isHostTimeoutScheduled) { 32287 // We scheduled a timeout but it's no longer needed. Cancel it. 32288 isHostTimeoutScheduled = false; 32289 cancelHostTimeout(); 32290 } 32291 32292 isPerformingWork = true; 32293 var previousPriorityLevel = currentPriorityLevel; 32294 32295 try { 32296 if (enableProfiling) { 32297 try { 32298 return workLoop(hasTimeRemaining, initialTime); 32299 } catch (error) { 32300 if (currentTask !== null) { 32301 var currentTime = exports.unstable_now(); 32302 markTaskErrored(currentTask, currentTime); 32303 currentTask.isQueued = false; 32304 } 32305 32306 throw error; 32307 } 32308 } else { 32309 // No catch in prod code path. 32310 return workLoop(hasTimeRemaining, initialTime); 32311 } 32312 } finally { 32313 currentTask = null; 32314 currentPriorityLevel = previousPriorityLevel; 32315 isPerformingWork = false; 32316 } 32317} 32318 32319function workLoop(hasTimeRemaining, initialTime) { 32320 var currentTime = initialTime; 32321 advanceTimers(currentTime); 32322 currentTask = peek(taskQueue); 32323 32324 while (currentTask !== null && !(enableSchedulerDebugging )) { 32325 if (currentTask.expirationTime > currentTime && (!hasTimeRemaining || exports.unstable_shouldYield())) { 32326 // This currentTask hasn't expired, and we've reached the deadline. 32327 break; 32328 } 32329 32330 var callback = currentTask.callback; 32331 32332 if (typeof callback === 'function') { 32333 currentTask.callback = null; 32334 currentPriorityLevel = currentTask.priorityLevel; 32335 var didUserCallbackTimeout = currentTask.expirationTime <= currentTime; 32336 32337 var continuationCallback = callback(didUserCallbackTimeout); 32338 currentTime = exports.unstable_now(); 32339 32340 if (typeof continuationCallback === 'function') { 32341 currentTask.callback = continuationCallback; 32342 } else { 32343 32344 if (currentTask === peek(taskQueue)) { 32345 pop(taskQueue); 32346 } 32347 } 32348 32349 advanceTimers(currentTime); 32350 } else { 32351 pop(taskQueue); 32352 } 32353 32354 currentTask = peek(taskQueue); 32355 } // Return whether there's additional work 32356 32357 32358 if (currentTask !== null) { 32359 return true; 32360 } else { 32361 var firstTimer = peek(timerQueue); 32362 32363 if (firstTimer !== null) { 32364 requestHostTimeout(handleTimeout, firstTimer.startTime - currentTime); 32365 } 32366 32367 return false; 32368 } 32369} 32370 32371function unstable_runWithPriority(priorityLevel, eventHandler) { 32372 switch (priorityLevel) { 32373 case ImmediatePriority: 32374 case UserBlockingPriority: 32375 case NormalPriority: 32376 case LowPriority: 32377 case IdlePriority: 32378 break; 32379 32380 default: 32381 priorityLevel = NormalPriority; 32382 } 32383 32384 var previousPriorityLevel = currentPriorityLevel; 32385 currentPriorityLevel = priorityLevel; 32386 32387 try { 32388 return eventHandler(); 32389 } finally { 32390 currentPriorityLevel = previousPriorityLevel; 32391 } 32392} 32393 32394function unstable_next(eventHandler) { 32395 var priorityLevel; 32396 32397 switch (currentPriorityLevel) { 32398 case ImmediatePriority: 32399 case UserBlockingPriority: 32400 case NormalPriority: 32401 // Shift down to normal priority 32402 priorityLevel = NormalPriority; 32403 break; 32404 32405 default: 32406 // Anything lower than normal priority should remain at the current level. 32407 priorityLevel = currentPriorityLevel; 32408 break; 32409 } 32410 32411 var previousPriorityLevel = currentPriorityLevel; 32412 currentPriorityLevel = priorityLevel; 32413 32414 try { 32415 return eventHandler(); 32416 } finally { 32417 currentPriorityLevel = previousPriorityLevel; 32418 } 32419} 32420 32421function unstable_wrapCallback(callback) { 32422 var parentPriorityLevel = currentPriorityLevel; 32423 return function () { 32424 // This is a fork of runWithPriority, inlined for performance. 32425 var previousPriorityLevel = currentPriorityLevel; 32426 currentPriorityLevel = parentPriorityLevel; 32427 32428 try { 32429 return callback.apply(this, arguments); 32430 } finally { 32431 currentPriorityLevel = previousPriorityLevel; 32432 } 32433 }; 32434} 32435 32436function unstable_scheduleCallback(priorityLevel, callback, options) { 32437 var currentTime = exports.unstable_now(); 32438 var startTime; 32439 32440 if (typeof options === 'object' && options !== null) { 32441 var delay = options.delay; 32442 32443 if (typeof delay === 'number' && delay > 0) { 32444 startTime = currentTime + delay; 32445 } else { 32446 startTime = currentTime; 32447 } 32448 } else { 32449 startTime = currentTime; 32450 } 32451 32452 var timeout; 32453 32454 switch (priorityLevel) { 32455 case ImmediatePriority: 32456 timeout = IMMEDIATE_PRIORITY_TIMEOUT; 32457 break; 32458 32459 case UserBlockingPriority: 32460 timeout = USER_BLOCKING_PRIORITY_TIMEOUT; 32461 break; 32462 32463 case IdlePriority: 32464 timeout = IDLE_PRIORITY_TIMEOUT; 32465 break; 32466 32467 case LowPriority: 32468 timeout = LOW_PRIORITY_TIMEOUT; 32469 break; 32470 32471 case NormalPriority: 32472 default: 32473 timeout = NORMAL_PRIORITY_TIMEOUT; 32474 break; 32475 } 32476 32477 var expirationTime = startTime + timeout; 32478 var newTask = { 32479 id: taskIdCounter++, 32480 callback: callback, 32481 priorityLevel: priorityLevel, 32482 startTime: startTime, 32483 expirationTime: expirationTime, 32484 sortIndex: -1 32485 }; 32486 32487 if (startTime > currentTime) { 32488 // This is a delayed task. 32489 newTask.sortIndex = startTime; 32490 push(timerQueue, newTask); 32491 32492 if (peek(taskQueue) === null && newTask === peek(timerQueue)) { 32493 // All tasks are delayed, and this is the task with the earliest delay. 32494 if (isHostTimeoutScheduled) { 32495 // Cancel an existing timeout. 32496 cancelHostTimeout(); 32497 } else { 32498 isHostTimeoutScheduled = true; 32499 } // Schedule a timeout. 32500 32501 32502 requestHostTimeout(handleTimeout, startTime - currentTime); 32503 } 32504 } else { 32505 newTask.sortIndex = expirationTime; 32506 push(taskQueue, newTask); 32507 // wait until the next time we yield. 32508 32509 32510 if (!isHostCallbackScheduled && !isPerformingWork) { 32511 isHostCallbackScheduled = true; 32512 requestHostCallback(flushWork); 32513 } 32514 } 32515 32516 return newTask; 32517} 32518 32519function unstable_pauseExecution() { 32520} 32521 32522function unstable_continueExecution() { 32523 32524 if (!isHostCallbackScheduled && !isPerformingWork) { 32525 isHostCallbackScheduled = true; 32526 requestHostCallback(flushWork); 32527 } 32528} 32529 32530function unstable_getFirstCallbackNode() { 32531 return peek(taskQueue); 32532} 32533 32534function unstable_cancelCallback(task) { 32535 // remove from the queue because you can't remove arbitrary nodes from an 32536 // array based heap, only the first one.) 32537 32538 32539 task.callback = null; 32540} 32541 32542function unstable_getCurrentPriorityLevel() { 32543 return currentPriorityLevel; 32544} 32545 32546var unstable_requestPaint = requestPaint; 32547var unstable_Profiling = null; 32548 32549exports.unstable_IdlePriority = IdlePriority; 32550exports.unstable_ImmediatePriority = ImmediatePriority; 32551exports.unstable_LowPriority = LowPriority; 32552exports.unstable_NormalPriority = NormalPriority; 32553exports.unstable_Profiling = unstable_Profiling; 32554exports.unstable_UserBlockingPriority = UserBlockingPriority; 32555exports.unstable_cancelCallback = unstable_cancelCallback; 32556exports.unstable_continueExecution = unstable_continueExecution; 32557exports.unstable_getCurrentPriorityLevel = unstable_getCurrentPriorityLevel; 32558exports.unstable_getFirstCallbackNode = unstable_getFirstCallbackNode; 32559exports.unstable_next = unstable_next; 32560exports.unstable_pauseExecution = unstable_pauseExecution; 32561exports.unstable_requestPaint = unstable_requestPaint; 32562exports.unstable_runWithPriority = unstable_runWithPriority; 32563exports.unstable_scheduleCallback = unstable_scheduleCallback; 32564exports.unstable_wrapCallback = unstable_wrapCallback; 32565 })(); 32566} 32567 32568 32569/***/ }), 32570
vendor: 734 bytes, lines 32571-32586
32571/***/ "./.yarn/cache/scheduler-npm-0.20.2-90beaecfba-898917fa47.zip/node_modules/scheduler/index.js": 32572/*!****************************************************************************************************!*\ 32573 !*** ./.yarn/cache/scheduler-npm-0.20.2-90beaecfba-898917fa47.zip/node_modules/scheduler/index.js ***! 32574 \****************************************************************************************************/ 32575/***/ ((module, __unused_webpack_exports, __webpack_require__) => { 32576 32577"use strict"; 32578 32579 32580if (false) {} else { 32581 module.exports = __webpack_require__(/*! ./cjs/scheduler.development.js */ "./.yarn/cache/scheduler-npm-0.20.2-90beaecfba-898917fa47.zip/node_modules/scheduler/cjs/scheduler.development.js"); 32582} 32583 32584 32585/***/ }), 32586
vendor: 758 bytes, lines 32587-32602
32587/***/ "./.yarn/cache/scheduler-npm-0.20.2-90beaecfba-898917fa47.zip/node_modules/scheduler/tracing.js": 32588/*!******************************************************************************************************!*\ 32589 !*** ./.yarn/cache/scheduler-npm-0.20.2-90beaecfba-898917fa47.zip/node_modules/scheduler/tracing.js ***! 32590 \******************************************************************************************************/ 32591/***/ ((module, __unused_webpack_exports, __webpack_require__) => { 32592 32593"use strict"; 32594 32595 32596if (false) {} else { 32597 module.exports = __webpack_require__(/*! ./cjs/scheduler-tracing.development.js */ "./.yarn/cache/scheduler-npm-0.20.2-90beaecfba-898917fa47.zip/node_modules/scheduler/cjs/scheduler-tracing.development.js"); 32598} 32599 32600 32601/***/ }), 32602
vendor: 1,238 bytes, lines 32603-32632
32603/***/ "./.yarn/cache/@babel-runtime-npm-7.18.9-28ca6b5f61-254985e146.zip/node_modules/@babel/runtime/helpers/esm/extends.js": 32604/*!****************************************************************************************************************************!*\ 32605 !*** ./.yarn/cache/@babel-runtime-npm-7.18.9-28ca6b5f61-254985e146.zip/node_modules/@babel/runtime/helpers/esm/extends.js ***! 32606 \****************************************************************************************************************************/ 32607/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { 32608 32609"use strict"; 32610__webpack_require__.r(__webpack_exports__); 32611/* harmony export */ __webpack_require__.d(__webpack_exports__, { 32612/* harmony export */ "default": () => (/* binding */ _extends) 32613/* harmony export */ }); 32614function _extends() { 32615 _extends = Object.assign ? Object.assign.bind() : function (target) { 32616 for (var i = 1; i < arguments.length; i++) { 32617 var source = arguments[i]; 32618 32619 for (var key in source) { 32620 if (Object.prototype.hasOwnProperty.call(source, key)) { 32621 target[key] = source[key]; 32622 } 32623 } 32624 } 32625 32626 return target; 32627 }; 32628 return _extends.apply(this, arguments); 32629} 32630 32631/***/ }), 32632
vendor: 1,358 bytes, lines 32633-32653
32633/***/ "./.yarn/cache/@babel-runtime-npm-7.18.9-28ca6b5f61-254985e146.zip/node_modules/@babel/runtime/helpers/esm/inheritsLoose.js": 32634/*!**********************************************************************************************************************************!*\ 32635 !*** ./.yarn/cache/@babel-runtime-npm-7.18.9-28ca6b5f61-254985e146.zip/node_modules/@babel/runtime/helpers/esm/inheritsLoose.js ***! 32636 \**********************************************************************************************************************************/ 32637/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { 32638 32639"use strict"; 32640__webpack_require__.r(__webpack_exports__); 32641/* harmony export */ __webpack_require__.d(__webpack_exports__, { 32642/* harmony export */ "default": () => (/* binding */ _inheritsLoose) 32643/* harmony export */ }); 32644/* harmony import */ var _setPrototypeOf_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./setPrototypeOf.js */ "./.yarn/cache/@babel-runtime-npm-7.18.9-28ca6b5f61-254985e146.zip/node_modules/@babel/runtime/helpers/esm/setPrototypeOf.js"); 32645 32646function _inheritsLoose(subClass, superClass) { 32647 subClass.prototype = Object.create(superClass.prototype); 32648 subClass.prototype.constructor = subClass; 32649 (0,_setPrototypeOf_js__WEBPACK_IMPORTED_MODULE_0__["default"])(subClass, superClass); 32650} 32651 32652/***/ }), 32653
vendor: 1,081 bytes, lines 32654-32673
32654/***/ "./.yarn/cache/@babel-runtime-npm-7.18.9-28ca6b5f61-254985e146.zip/node_modules/@babel/runtime/helpers/esm/setPrototypeOf.js": 32655/*!***********************************************************************************************************************************!*\ 32656 !*** ./.yarn/cache/@babel-runtime-npm-7.18.9-28ca6b5f61-254985e146.zip/node_modules/@babel/runtime/helpers/esm/setPrototypeOf.js ***! 32657 \***********************************************************************************************************************************/ 32658/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { 32659 32660"use strict"; 32661__webpack_require__.r(__webpack_exports__); 32662/* harmony export */ __webpack_require__.d(__webpack_exports__, { 32663/* harmony export */ "default": () => (/* binding */ _setPrototypeOf) 32664/* harmony export */ }); 32665function _setPrototypeOf(o, p) { 32666 _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { 32667 o.__proto__ = p; 32668 return o; 32669 }; 32670 return _setPrototypeOf(o, p); 32671} 32672 32673/***/ })
32673 32674 32675/******/ }); 32676/************************************************************************/ 32677/******/ // The module cache 32678/******/ var __webpack_module_cache__ = {}; 32679/******/ 32680/******/ // The require function 32681/******/ function __webpack_require__(moduleId) { 32682/******/ // Check if module is in cache 32683/******/ var cachedModule = __webpack_module_cache__[moduleId]; 32684/******/ if (cachedModule !== undefined) { 32685/******/ return cachedModule.exports; 32686/******/ } 32687/******/ // Create a new module (and put it into the cache) 32688/******/ var module = __webpack_module_cache__[moduleId] = { 32689/******/ id: moduleId, 32690/******/ loaded: false, 32691/******/ exports: {} 32692/******/ }; 32693/******/ 32694/******/ // Execute the module function 32695/******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__); 32696/******/ 32697/******/ // Flag the module as loaded 32698/******/ module.loaded = true; 32699/******/ 32700/******/ // Return the exports of the module 32701/******/ return module.exports; 32702/******/ } 32703/******/ 32704/******/ // expose the modules object (__webpack_modules__) 32705/******/ __webpack_require__.m = __webpack_modules__; 32706/******/ 32707/************************************************************************/ 32708/******/ /* webpack/runtime/compat get default export */ 32709/******/ (() => { 32710/******/ // getDefaultExport function for compatibility with non-harmony modules 32711/******/ __webpack_require__.n = (module) => { 32712/******/ var getter = module && module.__esModule ? 32713/******/ () => (module['default']) : 32714/******/ () => (module); 32715/******/ __webpack_require__.d(getter, { a: getter }); 32716/******/ return getter; 32717/******/ }; 32718/******/ })(); 32719/******/ 32720/******/ /* webpack/runtime/create fake namespace object */ 32721/******/ (() => { 32722/******/ var getProto = Object.getPrototypeOf ? (obj) => (Object.getPrototypeOf(obj)) : (obj) => (obj.__proto__); 32723/******/ var leafPrototypes; 32724/******/ // create a fake namespace object 32725/******/ // mode & 1: value is a module id, require it 32726/******/ // mode & 2: merge all properties of value into the ns 32727/******/ // mode & 4: return value when already ns object 32728/******/ // mode & 16: return value when it's Promise-like 32729/******/ // mode & 8|1: behave like require 32730/******/ __webpack_require__.t = function(value, mode) { 32731/******/ if(mode & 1) value = this(value); 32732/******/ if(mode & 8) return value; 32733/******/ if(typeof value === 'object' && value) { 32734/******/ if((mode & 4) && value.__esModule) return value; 32735/******/ if((mode & 16) && typeof value.then === 'function') return value; 32736/******/ } 32737/******/ var ns = Object.create(null); 32738/******/ __webpack_require__.r(ns); 32739/******/ var def = {}; 32740/******/ leafPrototypes = leafPrototypes || [null, getProto({}), getProto([]), getProto(getProto)]; 32741/******/ for(var current = mode & 2 && value; typeof current == 'object' && !~leafPrototypes.indexOf(current); current = getProto(current)) { 32742/******/ Object.getOwnPropertyNames(current).forEach((key) => (def[key] = () => (value[key]))); 32743/******/ } 32744/******/ def['default'] = () => (value); 32745/******/ __webpack_require__.d(ns, def); 32746/******/ return ns; 32747/******/ }; 32748/******/ })(); 32749/******/ 32750/******/ /* webpack/runtime/define property getters */ 32751/******/ (() => { 32752/******/ // define getter functions for harmony exports 32753/******/ __webpack_require__.d = (exports, definition) => { 32754/******/ for(var key in definition) { 32755/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { 32756/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); 32757/******/ } 32758/******/ } 32759/******/ }; 32760/******/ })(); 32761/******/ 32762/******/ /* webpack/runtime/ensure chunk */ 32763/******/ (() => { 32764/******/ __webpack_require__.f = {}; 32765/******/ // This file contains only the entry chunk. 32766/******/ // The chunk loading function for additional chunks 32767/******/ __webpack_require__.e = (chunkId) => { 32768/******/ return Promise.all(Object.keys(__webpack_require__.f).reduce((promises, key) => { 32769/******/ __webpack_require__.f[key](chunkId, promises); 32770/******/ return promises; 32771/******/ }, [])); 32772/******/ }; 32773/******/ })(); 32774/******/ 32775/******/ /* webpack/runtime/get javascript chunk filename */ 32776/******/ (() => { 32777/******/ // This function allow to reference async chunks 32778/******/ __webpack_require__.u = (chunkId) => { 32779/******/ // return url for filenames based on template 32780/******/ return "js/" + chunkId + ".js?_t=" + {"vendors-_yarn_cache_date-fns-npm-2_29_2-da48c27e93-0ac440a105_zip_node_modules_date-fns_esm_d-0ea603":"d55e7a9a24c5388cb46f","vendors-_yarn___virtual___react-query-virtual-cd72c42dd3_0_cache_react-query-npm-3_12_0-415d3-d91854":"3f02d902950501ed569f","vendors-_yarn_cache_lodash-npm-4_17_21-6382451519-c08619c038_zip_node_modules_lodash_lodash_js":"0b045822d29665d4728e","vendors-_yarn_cache_prop-types-npm-15_8_1-17c
3278071ee7ee-7d959caec0_zip_node_modules_prop-types_i-a0703c":"43efee1d60c099ab9911","vendors-_yarn___virtual___react-intersection-observer-virtual-72f1bbc67d_0_cache_react-inters-a195ee":"37d292de66fbbda9762f","vendors-_yarn___virtual___reach-utils-virtual-74f68e3a54_0_cache_reach-utils-npm-0_12_1-e1f5f-6f7acd":"7176a067129f4aaa2ca2","vendors-_yarn___virtual___reach-dialog-virtual-a52501f8b5_0_cache_reach-dialog-npm-0_12_1-9bc-4a590f":"80a1d82192dc204c2f87","vendors-_yarn_cache_date-fns-npm-2_29_2-da48c27e93-0ac440a105_zip_node_modules_date-fns_esm_p-de25fc":"b1d79b5a3793ba04f62e","vendors-_yarn___virtual___react-spring-web-virtual-9322263b63_0_cache_react-spring-web-npm-9_-0e67f4":"7543911396d8e756dc0f","vendors-_yarn_cache_brightcove-player-loader-npm-1_8_0-fa9f4ca49e-095bc1a3b4_zip_node_modules-c02406":"66d5a7e5e4f9faba0ba5","vendors-_yarn_unplugged_styled-components-virtual-66ed2408f5_node_modules_styled-components_d-701d97":"649fbb0e561f233f764f","vendors-_yarn___virtual___react-i18next-virtual-c6e07a7a20_0_cache_react-i18next-npm-11_18_5--932d77":"c2908f51ff3a6a5f0ac5","scripts_react_shared_utils_js":"0d3e45d8658f182aaf9f","scripts_libraries__modules_tracking_snowplow_snowplowEventTrackers_js-scripts_libraries__modu-33d9b7":"0f53d29a227a435a6649","scripts_libraries__modules_tracking_helpers_js-scripts_react_mls-lineups_utils_js-scripts_rea-57bac3":"d310558ac7dfbd65e70c","scripts_react_mls-match-summary_utils_js":"e0959f386b8ae886eb09","scripts_react_brightcove-video-playlist_components_RequiredAuthModal_index_js-scripts_react_b-787aa5":"c394c10a96c2dd6cb063","scripts_react_brightcove-video-playlist_main_js":"4adf3a8d344a4dd101a7","scripts_react_shared_components_BlockHeader_index_js-scripts_react_shared_hooks_useModalOptio-8af23e":"736e65271b0788a287ac","scripts_react_mls-horizontal-scoreboard_utils_js":"54d60eff112578385d14","scripts_react_mls-match-list_components_MatchModal_MatchModal_js":"e094a7f90f70974c0171","scripts_react_shared_components_Picture_index_js-scripts_react_shared_containers_ReactApp_index_js":"5e47bd4b4d392d36a504","scripts_react_ReactModule_js":"b396a8a79d90477aaebe","scripts_libraries__utilities_throttle_js":"02e070e7633d527613c2","react/brightcove-single-video-app":"8b590d62057487213fab","react/brightcove-video-playlist-app":"2817e0d7352fdf5da9e7","vendors-_yarn___virtual___react-tooltip-virtual-de828cbeb9_0_cache_react-tooltip-npm-4_2_21-3-4fcc45":"5d4e9007bf4028284a1b","vendors-_yarn___virtual___react-table-virtual-d5cfe500dd_0_cache_react-table-npm-7_8_0-61488a-e7ba1f":"e1421420d27df9d79408","scripts_react_shared_components_Table_utils_js":"092718646bb894dc3d83","react/mls-active-roster-app":"0e3b3623f297b8e4f7e3","react/mls-audi-goal-drive-progress-app":"ace6b9c5f831bd8d9d1a","scripts_react_mls-match-list_components_MatchDataLayer_index_js":"a43b534879a0cdfa7016","scripts_react_shared_components_ClubV2_index_js-scripts_react_shared_components_ExplainerBar_-54d4e6":"3cb83bd4d8818d4d87df","scripts_react_mls-brackets_utils_js":"0df56bde3292c03d2d7a","react/mls-brackets-app":"18a1bc22cf6fe54e3d9c","vendors-_yarn_unplugged_swiper-npm-8_3_2-1fc49d1c17_node_modules_swiper_core_core_js-_yarn_un-112bef":"0f3436864a3fd8e597cf","vendors-_yarn_unplugged_swiper-npm-8_3_2-1fc49d1c17_node_modules_swiper_react_swiper-react_js":"5a9c9b7327f54468aa3d","vendors-_yarn___virtual___react-collapsed-virtual-7bd2784b8b_0_cache_react-collapsed-npm-4_2_-8d3cef":"8fd8ec10cd4cd3713ba4","scripts_react_mls-match-hub-ai-match-recap_main_js":"c54ff7cd7ae2b7444108","react/mls-carousel-vertical-cards-app":"a815e3c3dc6fea2926a2","vendors-_yarn___virtual___headlessui-react-virtual-0b43e27b1c_0_cache_headlessui-react-npm-0_-562ff4":"13b290aa758876668b0f","scripts_react_shared_components_Dropdown_index_js-scripts_react_shared_components_ErrorDispla-6f9d10":"d1b3615e727cc86c868d","scripts_react_shared_components_ButtonGroup_index_js-scripts_react_shared_components_StatsSid-d2d56f":"6b0b3f08661cca31c91b","react/mls-club-stats-app":"1ce0728f8f76204c3138","vendors-_yarn___virtual___react-countdown-virtual-5faac023a0_0_cache_react-countdown-npm-2_3_-00f028":"bc738b45892eb3e35a84","react/mls-countdown-clock-app":"afdcff26837df6f107e4","react/mls-expected-goals-app":"97ec468958ed63a39898","vendors-_yarn___virtual___react-container-query-virtual-74c6cb2fce_0_cache_react-container-qu-4a8258":"5391f0f9d6d7f99849c1","vendors-_yarn_cache_date-fns-npm-2_29_2-da48c27e93-0ac440a105_zip_node_modules_date-fns_esm_g-8ade291":"759e78a22b98e2f24db2","scripts_libraries__modules_tracking_snowplow_trackMatchInteraction_js-scripts_react_shared_co-a03d52":"3101be64d5d596b4fa0d","scripts_react_mls-featured-match-v2_utils_js-scripts_react_mls-vert
32780ical-scoreboard_utils_js-s-fcd5a0":"0f86bee864985be76dd6","scripts_react_shared_components_SponsorV2_SponsorV2_js-scripts_react_shared_components_Ticket-6aa567":"e99f86e6f29d5472eab5","scripts_react_shared_svg_AppleTVSeasonPass_AppleTVSeasonPass_js":"34f9fbec20167788c749","react/mls-featured-match-v2-app":"344f1412a889b2523c01","vendors-_yarn___virtual___react-markdown-virtual-ac9a42a0c7_0_cache_react-markdown-npm-5_0_3--93fcb7":"752dd943a056a4689fc7","scripts_react_mls-match-list_components_MatchScoreBox_index_js-scripts_react_mls-match-list_c-ee880e":"34b6b0a23823779fb9ed","scripts_react_mls-match-list_components_ClubSeparator_index_js-scripts_react_mls-match-list_c-b34b2f":"3815cab346d759fe99ba","react/mls-featured-match-app":"b50f43f10d7e845cc3c8","vendors-_yarn_cache_date-fns-npm-2_29_2-da48c27e93-0ac440a105_zip_node_modules_date-fns_esm_g-452e28":"c96a4bb098c3a29696ff","scripts_react_shared_components_EmptyState_index_js-scripts_react_shared_components_Skeleton_-7bbf3a":"63c9e7ca58b49dac17aa","scripts_react_mls-match-list_v2_MatchBroadcaster_MatchBroadcaster_js-scripts_react_mls-match--829a0e":"e2b2a7dfb57e00422be3","react/mls-horizontal-scoreboard-app":"c26dbc73fee58e6fc832","scripts_react_mls-leader-card_main_js":"c36331f180e4371adeff","react/mls-leader-card-app":"5d832a419ce5d6e694d0","react/mls-lineups-app":"b058d99a4877428722ad","react/mls-match-facts-app":"022acae32d251fdc14ae","scripts_react_mls-match-feed_utils_js-scripts_react_mls-match-summary_components_CommentaryBl-7a5481":"392235b094fe5451dcd9","react/mls-match-feed-app":"406e4fa0062994c2e681","react/mls-match-hub-ai-match-recap-app":"b1747ef1531bdca21f5b","react/mls-match-hub-broadcasters-app":"cf4289f561c7898235fe","react/mls-match-hub-club-websites-app":"4fa93d97847d2c0db825","react/mls-match-hub-content-carousel-app":"5c91d0716a206ff4570e","react/mls-match-hub-header-app":"a91886a5b80844a499cf","react/mls-match-hub-navigation-app":"d6531a0fc38402832939","react/mls-match-hub-player-stats-app":"b7e90553989db7fb27b2","react/mls-match-hub-stats-toggle-app":"cf59bcee65963dc02c6b","react/mls-match-hub-top-leaders-app":"71cc3db853e33e8e939e","react/mls-match-hub-v2-app":"bd61fa24b397b8f4625f","vendors-_yarn___virtual___datepicker-react-hooks-virtual-4a8a3bb069_0_cache_datepicker-react--20d764":"389e0c2fe7954d3b9e22","react/mls-match-list-app":"16fcbc3a5f52b3c5fcaa","react/mls-match-odds-tabs-app":"ecfbd24616009965a3bf","react/mls-match-odds-app":"0317d1e5bf4fc967790b","react/mls-match-summary-app":"d26e063a2c9f117143eb","vendors-_yarn_cache_egjs-react-flicking-npm-3_8_3-d39f7fa6d1-4f25037a6a_zip_node_modules_egjs-26cb6f":"b9d0d7e1da5f2ffc91c6","react/mls-need-to-know-app":"eec6907013ac4836d94a","react/mls-passing-breakdown-app":"665526f844e4108e883d","react/mls-player-stats-app":"dfe750f70995051c3f28","react/mls-players-career-stats-app":"c24dbbc0a41df8028ddf","react/mls-players-hub-roster-app":"94665601c4b8c0ac0d65","react/mls-players-match-log-app":"af2313476e2187d7d1b0","react/mls-players-roster-composition-app":"e9f5c367d7e9e44ac39a","react/mls-possession-app":"e2abaa7e0cd4e42b5f8c","react/mls-previous-matches-app":"bfaf1b6baf998166ef26","vendors-_yarn_cache_date-fns-npm-2_29_2-da48c27e93-0ac440a105_zip_node_modules_date-fns_esm_g-8ade290":"70a66bdb59d960b8bd97","react/mls-priority-match-app":"666b2ffcb6279910201d","react/mls-rivalry-scoreboard-app":"da5dfb8d70a7a17771ee","react/mls-scoreboard-app":"180b687e7c092eef9720","react/mls-season-stat-leaders-app":"51f089ab0c8eaf91e77b","react/mls-shooting-breakdown-app":"318afb9848a08ffbf67e","react/mls-standings-form-guide-wrapper-app":"1c724db8a3e180d920ef","react/mls-standings-form-guide-app":"e94cf3d82f19cb5749ce","react/mls-standings-app":"f88aa8e78b9322cd3235","vendors-_yarn___virtual___reach-tabs-virtual-b9916299e2_0_cache_reach-tabs-npm-0_12_1-9ee506b-9c49e0":"47f296b9080c5f59c420","react/mls-stats-comparison-app":"8c96b7406ffb8fe83191","react/mls-superdraft-app":"d3111ae1efba5ed39084","react/mls-ticketing-block-app":"9e1871c6c11dfac026ed","react/mls-vertical-scoreboard-app":"74eb834604cddc18facb","scripts_react_shared_svg_index_js":"8d8bbc13ecad57a36581","scripts_react_shared_svg_AppleTVIcon_AppleTVIcon_js":"fa2158067142918808db","scripts_react_shared_svg_AppleTVPlusIcon_AppleTVPlusIcon_js":"182bacf27f036da97d40","scripts_react_shared_svg_AttendanceIcon_index_js":"045ca8210f0d49f9ca87","scripts_react_shared_svg_AttendanceIcon_AttendanceIcon_js":"4621795a4d8fcf768468","scripts_react_shared_svg_BroadcastIcon_index_js":"4f32efdf01acc4dd4111","scripts_react_shared_svg_BroadcastIcon_BroadcastIcon_js":"54b43a43020ad50ca57f","scripts_react_shared_svg_BroadcastersIcon_index_js":"61da7fe8a1c871df2b7b","scripts_react_shared_svg_BroadcastersIcon_BroadcastersIcon_js":"64e043b90826be443dd5","scripts_react_shared_svg_CalendarIcon_index_js":"e13a449e6e923d711b27","scripts_react_shared_svg_CalendarIcon_CalendarIcon_js":"49af1bcbbca234be1ef4","scripts_react_shared_svg_CheckIcon_index_js":"f3799595c6ffd3e95003","scripts_react_shared_svg_CheckIcon_CheckIcon_js":"b7e619f1fa125d5fa791","scripts_react_shared_svg_CityIcon_index_js":"d82d5d73cc6181cd4686","scripts_react_shared_svg_CityIcon_CityIcon_js":"03d5477c60d190e84656","scripts_react_shared_svg_CloseIcon_index_js":"f9cc8d518ef57d28f024","scripts_react_shared_svg_CloseIcon_CloseIcon_js":"ddad7b75423c6b04dea6","scripts_react_shared_svg_CrossbarIcon_index_js":"c50c225977a13f14175e","scripts_react_shared_svg_CrossbarIcon_CrossbarIcon_js":"1d57c82e897dc127d9b5","scripts_react_shared_svg_ExpandIcon_index_js":"2261b905d01b080a9369","scripts_react_shared_svg_ExpandIcon_ExpandIcon_js":"117ae2fd3d951b9587ef","scripts_react_shared_svg_ExternalLinkIcon_
32780index_js":"5b1f6a5fa354c48082fa","scripts_react_shared_svg_ExternalLinkIcon_ExternalLinkIcon_js":"c1add21f993acaf2983a","scripts_react_shared_svg_ExternalLinkIconV2_index_js":"e35c0bb6aec3af6276a1","scripts_react_shared_svg_ExternalLinkIconV2_ExternalLinkIconV2_js":"5d1809b9a610e8b97354","scripts_react_shared_svg_ExternalTicketsIcon_ExternalTicketsIcon_js":"aaf3b31912daf2e0f7a4","scripts_react_shared_svg_Field_index_js":"9f53290ac8fa6e973733","scripts_react_shared_svg_Field_Field_js":"39dcb790f2482d3895e3","scripts_react_shared_svg_FilledPlayIcon_index_js":"05e3f9555d671bb6fcda","scripts_react_shared_svg_FilledPlayIcon_FilledPlayIcon_js":"2b430c26c2d266c2ec0f","scripts_react_shared_svg_GoalIcon_index_js":"7dd054fb40631a199e63","scripts_react_shared_svg_GoalIcon_GoalIcon_js":"cc4de5a0196f8b195b04","scripts_react_shared_svg_IndicatorDown_index_js":"d0a330f17d244a790143","scripts_react_shared_svg_IndicatorDown_IndicatorDown_js":"78c8d27a18fe25016b87","scripts_react_shared_svg_IndicatorUp_index_js":"9e55bab59a13d93bbc2
vendor: 7,221 bytes, lines 32780-32832
327806","scripts_react_shared_svg_IndicatorUp_IndicatorUp_js":"b34d162c033c031dc512","scripts_react_shared_svg_InjuryIcon_index_js":"cb6742bfe51da2b8f14c","scripts_react_shared_svg_InjuryIcon_InjuryIcon_js":"df1c8e2799dc2d4000d0","scripts_react_shared_svg_LeftArrowIcon_LeftArrowIcon_js":"ca3c59c1cd79812b055d","scripts_react_shared_svg_LiveStandingsIcon_index_js":"1b2ad26febfd8ededa34","scripts_react_shared_svg_LiveStandingsIcon_LiveStandingsIcon_js":"535915eb6b854dd2af9f","scripts_react_shared_svg_LocationPinIcon_index_js":"2b313656f4ee52952d77","scripts_react_shared_svg_LocationPinIcon_LocationPinIcon_js":"c6dc2f8110ad87db1a47","scripts_react_shared_svg_LockIcon_index_js":"8212a87c9f42dae40ca3","scripts_react_shared_svg_LockIcon_LockIcon_js":"fbcad540dd4f98622e10","scripts_react_shared_svg_LockIconOutline_index_js":"363da98464b031f13877","scripts_react_shared_svg_LockIconOutline_LockIconOutline_js":"bc3e2efff1b12de3ff37","scripts_react_shared_svg_MgmIcon_index_js":"6ead34a8f954e88d185f","scripts_react_shared_svg_MgmIcon_MgmIcon_js":"7de5a00be26a0098aa0b","scripts_react_shared_svg_MissIcon_index_js":"df3eadc787fddbd2ffab","scripts_react_shared_svg_MissIcon_MissIcon_js":"073b612c1a4f6a06bbc1","scripts_react_shared_svg_OfficialIcon_index_js":"486abffe5293b8d06812","scripts_react_shared_svg_OfficialIcon_OfficialIcon_js":"df5dbc53899ad6be1d88","scripts_react_shared_svg_OwnGoalIcon_index_js":"716b9d3c21e15e0134a7","scripts_react_shared_svg_OwnGoalIcon_OwnGoalIcon_js":"92b07181302bda8efae2","scripts_react_shared_svg_PenaltyCardIcon_index_js":"62baaf2d40b07d4bcb9c","scripts_react_shared_svg_PenaltyCardIcon_PenaltyCardIcon_js":"84d567c5fd1981cddc6a","scripts_react_shared_svg_PenaltyIcon_index_js":"1c977c3e9f3fe879696a","scripts_react_shared_svg_PenaltyIcon_PenaltyIcon_js":"06d83f61917a22ca65f5","scripts_react_shared_svg_PenaltyKickAwardedIcon_index_js":"881e57e5572eb56338d8","scripts_react_shared_svg_PenaltyKickAwardedIcon_PenaltyKickAwardedIcon_js":"6b247627c76a783031eb","scripts_react_shared_svg_PenaltyMissIcon_index_js":"09440d6bb03b817a7aa7","scripts_react_shared_svg_PenaltyMissIcon_PenaltyMissIcon_js":"6942f62256849efde984","scripts_react_shared_svg_PlayCircleIcon_index_js":"2644f99dc7d9e2c216cf","scripts_react_shared_svg_PlayCircleIcon_PlayCircleIcon_js":"f64ccc3f6151006dbd9a","scripts_react_shared_svg_PlayDirectionIcon_index_js":"e2d1369d1abf64685d6e","scripts_react_shared_svg_PlayDirectionIcon_PlayDirectionIcon_js":"a9deb8d90bdec08fcc0f","scripts_react_shared_svg_PlayIcon_index_js":"ef7b04ce9d76c115f3ba","scripts_react_shared_svg_PlayIcon_PlayIcon_js":"d25487ad1b389737e9be","scripts_react_shared_svg_ReminderIcon_index_js":"1e37fabe202f5950e26d","scripts_react_shared_svg_ReminderIcon_ReminderIcon_js":"6ec065b094cbb1e3caed","scripts_react_shared_svg_ReplayIcon_index_js":"7b307ac9a184875050d2","scripts_react_shared_svg_ReplayIcon_ReplayIcon_js":"ab8f8db33b1ef262fecf","scripts_react_shared_svg_RightArrowIcon_RightArrowIcon_js":"3ee6fa313dcdbece26ee","scripts_react_shared_svg_RightIcon_index_js":"19a2a2eafcfdc6dc2c43","scripts_react_shared_svg_RightIcon_RightIcon_js":"fc0f2d7ccfba9e8a952a","scripts_react_shared_svg_SaveIcon_index_js":"0604363857aff49aada9","scripts_react_shared_svg_SaveIcon_SaveIcon_js":"2c93a1d7336c4258a7bd","scripts_react_shared_svg_SecondYellowCardIcon_index_js":"74d0287dad15c39348ae","scripts_react_shared_svg_SecondYellowCardIcon_SecondYellowCardIcon_js":"597da55fd0445797c9fb","scripts_react_shared_svg_ShotIcon_index_js":"3a1ed70a8536acd0cfcb","scripts_react_shared_svg_ShotIcon_ShotIcon_js":"fa360a0f1e6b9f9c8951","scripts_react_shared_svg_ShotMap_index_js":"373faf842eb294a03411","scripts_react_shared_svg_ShotMap_ShotMap_js":"5b79a45e7702e01424a7","scripts_react_shared_svg_StadiumIcon_index_js":"209205b6d1eeaf30b071","scripts_react_shared_svg_StadiumIcon_StadiumIcon_js":"c112a958ebfd1d884aed","scripts_react_shared_svg_StatChartSvg_index_js":"e5f205076a94be241bec","scripts_react_shared_svg_StatChartSvg_StatChartSvg_js":"1e97fe7b30e9c8698d3e","scripts_react_shared_svg_SubstitutionIcon_index_js":"42984996cbeeccd5e9a4","scripts_react_shared_svg_SubstitutionIcon_SubstitutionIcon_js":"17ba53251be7a78b78f1","scripts_react_shared_svg_Svg_js":"8a3d4deb9a6bd8de2fd2","scripts_react_shared_svg_TVIcon_TVIcon_js":"254a9d40be1397d07464","scripts_react_shared_svg_TicketIcon_index_js":"c44b9fa8391fa1c8e606","scripts_react_shared_svg_TicketIcon_TicketIcon_js":"54153d7121ecb70524a7","scripts_react_shared_svg_TicketIconV2_TicketIconV2_js":"9f8e89dea3c7ff48601b","scripts_react_shared_svg_TicketmasterIcon_index_js":"fabace7cb5a37493a6e5","scripts_react_shared_svg_TicketmasterIcon_TicketmasterIcon_js":"698ea10499e19b547481","scripts_react_shared_svg_TimerIcon_index_js":"e3c4f397718520438750","scripts_react_shared_svg_TimerIcon_TimerIcon_js":"1ed12e846f72c6f9bad9","scripts_react_shared_svg_TrendingArrowIcon_index_js":"83a65dd60f80beb8ae6d","scripts_react_shared_svg_TrendingArrowIcon_TrendingArrowIcon_js":"12d3eecfd836a20aa0e1","scripts_react_shared_svg_WeatherIcon_index_js":"6f8933e129dd9929e96d","scripts_react_shared_svg_WeatherIcon_WeatherIcon_js":"463e2111788b17eef952"}[chunkId] + ""; 32781/******/ }; 32782/******/ })(); 32783/******/ 32784/******/ /* webpack/runtime/global */ 32785/******/ (() => { 32786/******/ __webpack_require__.g = (function() { 32787/******/ if (typeof globalThis === 'object') return globalThis; 32788/******/ try { 32789/******/ return this || new Function('return this')(); 32790/******/ } catch (e) { 32791/******/ if (typeof window === 'object') return window; 32792/******/ } 32793/******/ })(); 32794/******/ })(); 32795/******/ 32796/******/ /* webpack/runtime/hasOwnProperty shorthand */ 32797/******/ (() => { 32798/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) 32799/******/ })(); 32800/******/ 32801/******/ /* webpack/runtime/load script */ 32802/******/ (() => { 32803/******/ var inProgress = {}; 32804/******/ var dataWebpackPrefix = "@mlssoccer/netcore:"; 32805/******/ // loadScript function to load a script via script tag 32806/******/ __webpack_require__.l = (url, done, key, chunkId) => { 32807/******/ if(inProgress[url]) { inProgress[url].push(done); return; } 32808/******/ var script, needAttach; 32809/******/ if(key !== undefined) { 32810/******/ var scripts = document.getElementsByTagName("script"); 32811/******/ for(var i = 0; i < scripts.length; i++) { 32812/******/ var s = scripts[i]; 32813/******/ if(s.getAttribute("src") == url || s.getAttribute("data-webpack") == dataWebpackPrefix + key) { script = s; break; } 32814/******/ } 32815/******/ } 32816/******/ if(!script) { 32817/******/ needAttach = true; 32818/******/ script = document.createElement('script'); 32819/******/ 32820/******/ script.charset = 'utf-8'; 32821/******/ script.timeout = 120; 32822/******/ if (__webpack_require__.nc) { 32823/******/ script.setAttribute("nonce", __webpack_require__.nc); 32824/******/ } 32825/******/ script.setAttribute("data-webpack", dataWebpackPrefix + key); 32826/******/ script.src = url; 32827/******/ } 32828/******/ inProgress[url] = [done]; 32829/******/ var onScriptComplete = (prev, event) => { 32830/******/ // avoid mem leaks in IE. 32831/******/ script.onerror = script.onload = null; 32832/******/ clearTimeout(timeout);
vendor: 4,201 bytes, lines 32833-32930
32833/******/ var doneFns = inProgress[url]; 32834/******/ delete inProgress[url]; 32835/******/ script.parentNode && script.parentNode.removeChild(script); 32836/******/ doneFns && doneFns.forEach((fn) => (fn(event))); 32837/******/ if(prev) return prev(event); 32838/******/ } 32839/******/ ; 32840/******/ var timeout = setTimeout(onScriptComplete.bind(null, undefined, { type: 'timeout', target: script }), 120000); 32841/******/ script.onerror = onScriptComplete.bind(null, script.onerror); 32842/******/ script.onload = onScriptComplete.bind(null, script.onload); 32843/******/ needAttach && document.head.appendChild(script); 32844/******/ }; 32845/******/ })(); 32846/******/ 32847/******/ /* webpack/runtime/make namespace object */ 32848/******/ (() => { 32849/******/ // define __esModule on exports 32850/******/ __webpack_require__.r = (exports) => { 32851/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { 32852/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); 32853/******/ } 32854/******/ Object.defineProperty(exports, '__esModule', { value: true }); 32855/******/ }; 32856/******/ })(); 32857/******/ 32858/******/ /* webpack/runtime/node module decorator */ 32859/******/ (() => { 32860/******/ __webpack_require__.nmd = (module) => { 32861/******/ module.paths = []; 32862/******/ if (!module.children) module.children = []; 32863/******/ return module; 32864/******/ }; 32865/******/ })(); 32866/******/ 32867/******/ /* webpack/runtime/publicPath */ 32868/******/ (() => { 32869/******/ __webpack_require__.p = "/assets/"; 32870/******/ })(); 32871/******/ 32872/******/ /* webpack/runtime/jsonp chunk loading */ 32873/******/ (() => { 32874/******/ // no baseURI 32875/******/ 32876/******/ // object to store loaded and loading chunks 32877/******/ // undefined = chunk not loaded, null = chunk preloaded/prefetched 32878/******/ // [resolve, reject, Promise] = chunk loading, 0 = chunk loaded 32879/******/ var installedChunks = { 32880/******/ "reactinit": 0 32881/******/ }; 32882/******/ 32883/******/ __webpack_require__.f.j = (chunkId, promises) => { 32884/******/ // JSONP chunk loading for javascript 32885/******/ var installedChunkData = __webpack_require__.o(installedChunks, chunkId) ? installedChunks[chunkId] : undefined; 32886/******/ if(installedChunkData !== 0) { // 0 means "already installed". 32887/******/ 32888/******/ // a Promise means "currently loading". 32889/******/ if(installedChunkData) { 32890/******/ promises.push(installedChunkData[2]); 32891/******/ } else { 32892/******/ if(true) { // all chunks have JS 32893/******/ // setup Promise in chunk cache 32894/******/ var promise = new Promise((resolve, reject) => (installedChunkData = installedChunks[chunkId] = [resolve, reject])); 32895/******/ promises.push(installedChunkData[2] = promise); 32896/******/ 32897/******/ // start chunk loading 32898/******/ var url = __webpack_require__.p + __webpack_require__.u(chunkId); 32899/******/ // create error before stack unwound to get useful stacktrace later 32900/******/ var error = new Error(); 32901/******/ var loadingEnded = (event) => { 32902/******/ if(__webpack_require__.o(installedChunks, chunkId)) { 32903/******/ installedChunkData = installedChunks[chunkId]; 32904/******/ if(installedChunkData !== 0) installedChunks[chunkId] = undefined; 32905/******/ if(installedChunkData) { 32906/******/ var errorType = event && (event.type === 'load' ? 'missing' : event.type); 32907/******/ var realSrc = event && event.target && event.target.src; 32908/******/ error.message = 'Loading chunk ' + chunkId + ' failed.\n(' + errorType + ': ' + realSrc + ')'; 32909/******/ error.name = 'ChunkLoadError'; 32910/******/ error.type = errorType; 32911/******/ error.request = realSrc; 32912/******/ installedChunkData[1](error); 32913/******/ } 32914/******/ } 32915/******/ }; 32916/******/ __webpack_require__.l(url, loadingEnded, "chunk-" + chunkId, chunkId); 32917/******/ } else installedChunks[chunkId] = 0; 32918/******/ } 32919/******/ } 32920/******/ }; 32921/******/ 32922/******/ // no prefetching 32923/******/ 32924/******/ // no preloaded 32925/******/ 32926/******/ // no HMR 32927/******/ 32928/******/ // no HMR manifest 32929/******/ 32930/******/ // no on chunks loaded
vendor: 2,286 bytes, lines 32931-32987
32931/******/ 32932/******/ // install a JSONP callback for chunk loading 32933/******/ var webpackJsonpCallback = (parentChunkLoadingFunction, data) => { 32934/******/ var [chunkIds, moreModules, runtime] = data; 32935/******/ // add "moreModules" to the modules object, 32936/******/ // then flag all "chunkIds" as loaded and fire callback 32937/******/ var moduleId, chunkId, i = 0; 32938/******/ if(chunkIds.some((id) => (installedChunks[id] !== 0))) { 32939/******/ for(moduleId in moreModules) { 32940/******/ if(__webpack_require__.o(moreModules, moduleId)) { 32941/******/ __webpack_require__.m[moduleId] = moreModules[moduleId]; 32942/******/ } 32943/******/ } 32944/******/ if(runtime) var result = runtime(__webpack_require__); 32945/******/ } 32946/******/ if(parentChunkLoadingFunction) parentChunkLoadingFunction(data); 32947/******/ for(;i < chunkIds.length; i++) { 32948/******/ chunkId = chunkIds[i]; 32949/******/ if(__webpack_require__.o(installedChunks, chunkId) && installedChunks[chunkId]) { 32950/******/ installedChunks[chunkId][0](); 32951/******/ } 32952/******/ installedChunks[chunkId] = 0; 32953/******/ } 32954/******/ 32955/******/ } 32956/******/ 32957/******/ var chunkLoadingGlobal = self["webpackChunk_mlssoccer_netcore"] = self["webpackChunk_mlssoccer_netcore"] || []; 32958/******/ chunkLoadingGlobal.forEach(webpackJsonpCallback.bind(null, 0)); 32959/******/ chunkLoadingGlobal.push = webpackJsonpCallback.bind(null, chunkLoadingGlobal.push.bind(chunkLoadingGlobal)); 32960/******/ })(); 32961/******/ 32962/******/ /* webpack/runtime/nonce */ 32963/******/ (() => { 32964/******/ __webpack_require__.nc = undefined; 32965/******/ })(); 32966/******/ 32967/************************************************************************/ 32968var __webpack_exports__ = {}; 32969// This entry need to be wrapped in an IIFE because it need to be in strict mode. 32970(() => { 32971"use strict"; 32972/*!**************************************!*\ 32973 !*** ./scripts/bundles/reactinit.js ***! 32974 \**************************************/ 32975__webpack_require__.r(__webpack_exports__); 32976/* harmony import */ var _react_renderer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../react/renderer */ "./scripts/react/renderer.js"); 32977window.process = { 32978 cwd: () => "", 32979 env: { NODE_ENV: "development" } 32980}; 32981 32982 32983})(); 32984 32985/******/ })() 32986; 32987//# sourceMappingURL=reactinit.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.