vendor: 78 bytes, lines 1-3
1/******/ (() => { // webpackBootstrap 2/******/ var __webpack_modules__ = ({ 3
vendor: 342 bytes, lines 4-13
4/***/ "./node_modules/axios/index.js": 5/*!*************************************!*\ 6 !*** ./node_modules/axios/index.js ***! 7 \*************************************/ 8/***/ ((module, __unused_webpack_exports, __webpack_require__) => { 9 10module.exports = __webpack_require__(/*! ./lib/axios */ "./node_modules/axios/lib/axios.js"); 11 12/***/ }), 13
vendor: 6,671 bytes, lines 14-203
14/***/ "./node_modules/axios/lib/adapters/xhr.js": 15/*!************************************************!*\ 16 !*** ./node_modules/axios/lib/adapters/xhr.js ***! 17 \************************************************/ 18/***/ ((module, __unused_webpack_exports, __webpack_require__) => { 19 20"use strict"; 21 22 23var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js"); 24var settle = __webpack_require__(/*! ./../core/settle */ "./node_modules/axios/lib/core/settle.js"); 25var cookies = __webpack_require__(/*! ./../helpers/cookies */ "./node_modules/axios/lib/helpers/cookies.js"); 26var buildURL = __webpack_require__(/*! ./../helpers/buildURL */ "./node_modules/axios/lib/helpers/buildURL.js"); 27var buildFullPath = __webpack_require__(/*! ../core/buildFullPath */ "./node_modules/axios/lib/core/buildFullPath.js"); 28var parseHeaders = __webpack_require__(/*! ./../helpers/parseHeaders */ "./node_modules/axios/lib/helpers/parseHeaders.js"); 29var isURLSameOrigin = __webpack_require__(/*! ./../helpers/isURLSameOrigin */ "./node_modules/axios/lib/helpers/isURLSameOrigin.js"); 30var createError = __webpack_require__(/*! ../core/createError */ "./node_modules/axios/lib/core/createError.js"); 31 32module.exports = function xhrAdapter(config) { 33 return new Promise(function dispatchXhrRequest(resolve, reject) { 34 var requestData = config.data; 35 var requestHeaders = config.headers; 36 37 if (utils.isFormData(requestData)) { 38 delete requestHeaders['Content-Type']; // Let the browser set it 39 } 40 41 var request = new XMLHttpRequest(); 42 43 // HTTP basic authentication 44 if (config.auth) { 45 var username = config.auth.username || ''; 46 var password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : ''; 47 requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password); 48 } 49 50 var fullPath = buildFullPath(config.baseURL, config.url); 51 request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true); 52 53 // Set the request timeout in MS 54 request.timeout = config.timeout; 55 56 // Listen for ready state 57 request.onreadystatechange = function handleLoad() { 58 if (!request || request.readyState !== 4) { 59 return; 60 } 61 62 // The request errored out and we didn't get a response, this will be 63 // handled by onerror instead 64 // With one exception: request that using file: protocol, most browsers 65 // will return status as 0 even though it's a successful request 66 if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) { 67 return; 68 } 69 70 // Prepare the response 71 var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null; 72 var responseData = !config.responseType || config.responseType === 'text' ? request.responseText : request.response; 73 var response = { 74 data: responseData, 75 status: request.status, 76 statusText: request.statusText, 77 headers: responseHeaders, 78 config: config, 79 request: request 80 }; 81 82 settle(resolve, reject, response); 83 84 // Clean up request 85 request = null; 86 }; 87 88 // Handle browser request cancellation (as opposed to a manual cancellation) 89 request.onabort = function handleAbort() { 90 if (!request) { 91 return; 92 } 93 94 reject(createError('Request aborted', config, 'ECONNABORTED', request)); 95 96 // Clean up request 97 request = null; 98 }; 99 100 // Handle low level network errors 101 request.onerror = function handleError() { 102 // Real errors are hidden from us by the browser 103 // onerror should only fire if it's a network error 104 reject(createError('Network Error', config, null, request)); 105 106 // Clean up request 107 request = null; 108 }; 109 110 // Handle timeout 111 request.ontimeout = function handleTimeout() { 112 var timeoutErrorMessage = 'timeout of ' + config.timeout + 'ms exceeded'; 113 if (config.timeoutErrorMessage) { 114 timeoutErrorMessage = config.timeoutErrorMessage; 115 } 116 reject(createError(timeoutErrorMessage, config, 'ECONNABORTED', 117 request)); 118 119 // Clean up request 120 request = null; 121 }; 122 123 // Add xsrf header 124 // This is only done if running in a standard browser environment. 125 // Specifically not if we're in a web worker, or react-native. 126 if (utils.isStandardBrowserEnv()) { 127 // Add xsrf header 128 var xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath)) && config.xsrfCookieName ? 129 cookies.read(config.xsrfCookieName) : 130 undefined; 131 132 if (xsrfValue) { 133 requestHeaders[config.xsrfHeaderName] = xsrfValue; 134 } 135 } 136 137 // Add headers to the request 138 if ('setRequestHeader' in request) { 139 utils.forEach(requestHeaders, function setRequestHeader(val, key) { 140 if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') { 141 // Remove Content-Type if data is undefined 142 delete requestHeaders[key]; 143 } else { 144 // Otherwise add header to the request 145 request.setRequestHeader(key, val); 146 } 147 }); 148 } 149 150 // Add withCredentials to request if needed 151 if (!utils.isUndefined(config.withCredentials)) { 152 request.withCredentials = !!config.withCredentials; 153 } 154 155 // Add responseType to request if needed 156 if (config.responseType) { 157 try { 158 request.responseType = config.responseType; 159 } catch (e) { 160 // Expected DOMException thrown by browsers not compatible XMLHttpRequest Level 2. 161 // But, this can be suppressed for 'json' type as it can be parsed by default 'transformResponse' function. 162 if (config.responseType !== 'json') { 163 throw e; 164 } 165 } 166 } 167 168 // Handle progress if needed 169 if (typeof config.onDownloadProgress === 'function') { 170 request.addEventListener('progress', config.onDownloadProgress); 171 } 172 173 // Not all browsers support upload events 174 if (typeof config.onUploadProgress === 'function' && request.upload) { 175 request.upload.addEventListener('progress', config.onUploadProgress); 176 } 177 178 if (config.cancelToken) { 179 // Handle cancellation 180 config.cancelToken.promise.then(function onCanceled(cancel) { 181 if (!request) { 182 return; 183 } 184 185 request.abort(); 186 reject(cancel); 187 // Clean up request 188 request = null; 189 }); 190 } 191 192 if (!requestData) { 193 requestData = null; 194 } 195 196 // Send the request 197 request.send(requestData); 198 }); 199}; 200 201 202/***/ }), 203
vendor: 2,380 bytes, lines 204-270
204/***/ "./node_modules/axios/lib/axios.js": 205/*!*****************************************!*\ 206 !*** ./node_modules/axios/lib/axios.js ***! 207 \*****************************************/ 208/***/ ((module, __unused_webpack_exports, __webpack_require__) => { 209 210"use strict"; 211 212 213var utils = __webpack_require__(/*! ./utils */ "./node_modules/axios/lib/utils.js"); 214var bind = __webpack_require__(/*! ./helpers/bind */ "./node_modules/axios/lib/helpers/bind.js"); 215var Axios = __webpack_require__(/*! ./core/Axios */ "./node_modules/axios/lib/core/Axios.js"); 216var mergeConfig = __webpack_require__(/*! ./core/mergeConfig */ "./node_modules/axios/lib/core/mergeConfig.js"); 217var defaults = __webpack_require__(/*! ./defaults */ "./node_modules/axios/lib/defaults.js"); 218 219/** 220 * Create an instance of Axios 221 * 222 * @param {Object} defaultConfig The default config for the instance 223 * @return {Axios} A new instance of Axios 224 */ 225function createInstance(defaultConfig) { 226 var context = new Axios(defaultConfig); 227 var instance = bind(Axios.prototype.request, context); 228 229 // Copy axios.prototype to instance 230 utils.extend(instance, Axios.prototype, context); 231 232 // Copy context to instance 233 utils.extend(instance, context); 234 235 return instance; 236} 237 238// Create the default instance to be exported 239var axios = createInstance(defaults); 240 241// Expose Axios class to allow class inheritance 242axios.Axios = Axios; 243 244// Factory for creating new instances 245axios.create = function create(instanceConfig) { 246 return createInstance(mergeConfig(axios.defaults, instanceConfig)); 247}; 248 249// Expose Cancel & CancelToken 250axios.Cancel = __webpack_require__(/*! ./cancel/Cancel */ "./node_modules/axios/lib/cancel/Cancel.js"); 251axios.CancelToken = __webpack_require__(/*! ./cancel/CancelToken */ "./node_modules/axios/lib/cancel/CancelToken.js"); 252axios.isCancel = __webpack_require__(/*! ./cancel/isCancel */ "./node_modules/axios/lib/cancel/isCancel.js"); 253 254// Expose all/spread 255axios.all = function all(promises) { 256 return Promise.all(promises); 257}; 258axios.spread = __webpack_require__(/*! ./helpers/spread */ "./node_modules/axios/lib/helpers/spread.js"); 259 260// Expose isAxiosError 261axios.isAxiosError = __webpack_require__(/*! ./helpers/isAxiosError */ "./node_modules/axios/lib/helpers/isAxiosError.js"); 262 263module.exports = axios; 264 265// Allow use of default import syntax in TypeScript 266module.exports.default = axios; 267 268 269/***/ }), 270
vendor: 636 bytes, lines 271-300
271/***/ "./node_modules/axios/lib/cancel/Cancel.js": 272/*!*************************************************!*\ 273 !*** ./node_modules/axios/lib/cancel/Cancel.js ***! 274 \*************************************************/ 275/***/ ((module) => { 276 277"use strict"; 278 279 280/** 281 * A `Cancel` is an object that is thrown when an operation is canceled. 282 * 283 * @class 284 * @param {string=} message The message. 285 */ 286function Cancel(message) { 287 this.message = message; 288} 289 290Cancel.prototype.toString = function toString() { 291 return 'Cancel' + (this.message ? ': ' + this.message : ''); 292}; 293 294Cancel.prototype.__CANCEL__ = true; 295 296module.exports = Cancel; 297 298 299/***/ }), 300
vendor: 1,619 bytes, lines 301-368
301/***/ "./node_modules/axios/lib/cancel/CancelToken.js": 302/*!******************************************************!*\ 303 !*** ./node_modules/axios/lib/cancel/CancelToken.js ***! 304 \******************************************************/ 305/***/ ((module, __unused_webpack_exports, __webpack_require__) => { 306 307"use strict"; 308 309 310var Cancel = __webpack_require__(/*! ./Cancel */ "./node_modules/axios/lib/cancel/Cancel.js"); 311 312/** 313 * A `CancelToken` is an object that can be used to request cancellation of an operation. 314 * 315 * @class 316 * @param {Function} executor The executor function. 317 */ 318function CancelToken(executor) { 319 if (typeof executor !== 'function') { 320 throw new TypeError('executor must be a function.'); 321 } 322 323 var resolvePromise; 324 this.promise = new Promise(function promiseExecutor(resolve) { 325 resolvePromise = resolve; 326 }); 327 328 var token = this; 329 executor(function cancel(message) { 330 if (token.reason) { 331 // Cancellation has already been requested 332 return; 333 } 334 335 token.reason = new Cancel(message); 336 resolvePromise(token.reason); 337 }); 338} 339 340/** 341 * Throws a `Cancel` if cancellation has been requested. 342 */ 343CancelToken.prototype.throwIfRequested = function throwIfRequested() { 344 if (this.reason) { 345 throw this.reason; 346 } 347}; 348 349/** 350 * Returns an object that contains a new `CancelToken` and a function that, when called, 351 * cancels the `CancelToken`. 352 */ 353CancelToken.source = function source() { 354 var cancel; 355 var token = new CancelToken(function executor(c) { 356 cancel = c; 357 }); 358 return { 359 token: token, 360 cancel: cancel 361 }; 362}; 363 364module.exports = CancelToken; 365 366 367/***/ }), 368
vendor: 361 bytes, lines 369-384
369/***/ "./node_modules/axios/lib/cancel/isCancel.js": 370/*!***************************************************!*\ 371 !*** ./node_modules/axios/lib/cancel/isCancel.js ***! 372 \***************************************************/ 373/***/ ((module) => { 374 375"use strict"; 376 377 378module.exports = function isCancel(value) { 379 return !!(value && value.__CANCEL__); 380}; 381 382 383/***/ }), 384
vendor: 3,254 bytes, lines 385-490
385/***/ "./node_modules/axios/lib/core/Axios.js": 386/*!**********************************************!*\ 387 !*** ./node_modules/axios/lib/core/Axios.js ***! 388 \**********************************************/ 389/***/ ((module, __unused_webpack_exports, __webpack_require__) => { 390 391"use strict"; 392 393 394var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js"); 395var buildURL = __webpack_require__(/*! ../helpers/buildURL */ "./node_modules/axios/lib/helpers/buildURL.js"); 396var InterceptorManager = __webpack_require__(/*! ./InterceptorManager */ "./node_modules/axios/lib/core/InterceptorManager.js"); 397var dispatchRequest = __webpack_require__(/*! ./dispatchRequest */ "./node_modules/axios/lib/core/dispatchRequest.js"); 398var mergeConfig = __webpack_require__(/*! ./mergeConfig */ "./node_modules/axios/lib/core/mergeConfig.js"); 399 400/** 401 * Create a new instance of Axios 402 * 403 * @param {Object} instanceConfig The default config for the instance 404 */ 405function Axios(instanceConfig) { 406 this.defaults = instanceConfig; 407 this.interceptors = { 408 request: new InterceptorManager(), 409 response: new InterceptorManager() 410 }; 411} 412 413/** 414 * Dispatch a request 415 * 416 * @param {Object} config The config specific for this request (merged with this.defaults) 417 */ 418Axios.prototype.request = function request(config) { 419 /*eslint no-param-reassign:0*/ 420 // Allow for axios('example/url'[, config]) a la fetch API 421 if (typeof config === 'string') { 422 config = arguments[1] || {}; 423 config.url = arguments[0]; 424 } else { 425 config = config || {}; 426 } 427 428 config = mergeConfig(this.defaults, config); 429 430 // Set config.method 431 if (config.method) { 432 config.method = config.method.toLowerCase(); 433 } else if (this.defaults.method) { 434 config.method = this.defaults.method.toLowerCase(); 435 } else { 436 config.method = 'get'; 437 } 438 439 // Hook up interceptors middleware 440 var chain = [dispatchRequest, undefined]; 441 var promise = Promise.resolve(config); 442 443 this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) { 444 chain.unshift(interceptor.fulfilled, interceptor.rejected); 445 }); 446 447 this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) { 448 chain.push(interceptor.fulfilled, interceptor.rejected); 449 }); 450 451 while (chain.length) { 452 promise = promise.then(chain.shift(), chain.shift()); 453 } 454 455 return promise; 456}; 457 458Axios.prototype.getUri = function getUri(config) { 459 config = mergeConfig(this.defaults, config); 460 return buildURL(config.url, config.params, config.paramsSerializer).replace(/^\?/, ''); 461}; 462 463// Provide aliases for supported request methods 464utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) { 465 /*eslint func-names:0*/ 466 Axios.prototype[method] = function(url, config) { 467 return this.request(mergeConfig(config || {}, { 468 method: method, 469 url: url, 470 data: (config || {}).data 471 })); 472 }; 473}); 474 475utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) { 476 /*eslint func-names:0*/ 477 Axios.prototype[method] = function(url, data, config) { 478 return this.request(mergeConfig(config || {}, { 479 method: method, 480 url: url, 481 data: data 482 })); 483 }; 484}); 485 486module.exports = Axios; 487 488 489/***/ }), 490
vendor: 1,642 bytes, lines 491-553
491/***/ "./node_modules/axios/lib/core/InterceptorManager.js": 492/*!***********************************************************!*\ 493 !*** ./node_modules/axios/lib/core/InterceptorManager.js ***! 494 \***********************************************************/ 495/***/ ((module, __unused_webpack_exports, __webpack_require__) => { 496 497"use strict"; 498 499 500var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js"); 501 502function InterceptorManager() { 503 this.handlers = []; 504} 505 506/** 507 * Add a new interceptor to the stack 508 * 509 * @param {Function} fulfilled The function to handle `then` for a `Promise` 510 * @param {Function} rejected The function to handle `reject` for a `Promise` 511 * 512 * @return {Number} An ID used to remove interceptor later 513 */ 514InterceptorManager.prototype.use = function use(fulfilled, rejected) { 515 this.handlers.push({ 516 fulfilled: fulfilled, 517 rejected: rejected 518 }); 519 return this.handlers.length - 1; 520}; 521 522/** 523 * Remove an interceptor from the stack 524 * 525 * @param {Number} id The ID that was returned by `use` 526 */ 527InterceptorManager.prototype.eject = function eject(id) { 528 if (this.handlers[id]) { 529 this.handlers[id] = null; 530 } 531}; 532 533/** 534 * Iterate over all the registered interceptors 535 * 536 * This method is particularly useful for skipping over any 537 * interceptors that may have become `null` calling `eject`. 538 * 539 * @param {Function} fn The function to call for each interceptor 540 */ 541InterceptorManager.prototype.forEach = function forEach(fn) { 542 utils.forEach(this.handlers, function forEachHandler(h) { 543 if (h !== null) { 544 fn(h); 545 } 546 }); 547}; 548 549module.exports = InterceptorManager; 550 551 552/***/ }), 553
vendor: 1,149 bytes, lines 554-584
554/***/ "./node_modules/axios/lib/core/buildFullPath.js": 555/*!******************************************************!*\ 556 !*** ./node_modules/axios/lib/core/buildFullPath.js ***! 557 \******************************************************/ 558/***/ ((module, __unused_webpack_exports, __webpack_require__) => { 559 560"use strict"; 561 562 563var isAbsoluteURL = __webpack_require__(/*! ../helpers/isAbsoluteURL */ "./node_modules/axios/lib/helpers/isAbsoluteURL.js"); 564var combineURLs = __webpack_require__(/*! ../helpers/combineURLs */ "./node_modules/axios/lib/helpers/combineURLs.js"); 565 566/** 567 * Creates a new URL by combining the baseURL with the requestedURL, 568 * only when the requestedURL is not already an absolute URL. 569 * If the requestURL is absolute, this function returns the requestedURL untouched. 570 * 571 * @param {string} baseURL The base URL 572 * @param {string} requestedURL Absolute or relative URL to combine 573 * @returns {string} The combined full path 574 */ 575module.exports = function buildFullPath(baseURL, requestedURL) { 576 if (baseURL && !isAbsoluteURL(requestedURL)) { 577 return combineURLs(baseURL, requestedURL); 578 } 579 return requestedURL; 580}; 581 582 583/***/ }), 584
vendor: 1,000 bytes, lines 585-613
585/***/ "./node_modules/axios/lib/core/createError.js": 586/*!****************************************************!*\ 587 !*** ./node_modules/axios/lib/core/createError.js ***! 588 \****************************************************/ 589/***/ ((module, __unused_webpack_exports, __webpack_require__) => { 590 591"use strict"; 592 593 594var enhanceError = __webpack_require__(/*! ./enhanceError */ "./node_modules/axios/lib/core/enhanceError.js"); 595 596/** 597 * Create an Error with the specified message, config, error code, request and response. 598 * 599 * @param {string} message The error message. 600 * @param {Object} config The config. 601 * @param {string} [code] The error code (for example, 'ECONNABORTED'). 602 * @param {Object} [request] The request. 603 * @param {Object} [response] The response. 604 * @returns {Error} The created error. 605 */ 606module.exports = function createError(message, config, code, request, response) { 607 var error = new Error(message); 608 return enhanceError(error, config, code, request, response); 609}; 610 611 612/***/ }), 613
vendor: 2,498 bytes, lines 614-703
614/***/ "./node_modules/axios/lib/core/dispatchRequest.js": 615/*!********************************************************!*\ 616 !*** ./node_modules/axios/lib/core/dispatchRequest.js ***! 617 \********************************************************/ 618/***/ ((module, __unused_webpack_exports, __webpack_require__) => { 619 620"use strict"; 621 622 623var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js"); 624var transformData = __webpack_require__(/*! ./transformData */ "./node_modules/axios/lib/core/transformData.js"); 625var isCancel = __webpack_require__(/*! ../cancel/isCancel */ "./node_modules/axios/lib/cancel/isCancel.js"); 626var defaults = __webpack_require__(/*! ../defaults */ "./node_modules/axios/lib/defaults.js"); 627 628/** 629 * Throws a `Cancel` if cancellation has been requested. 630 */ 631function throwIfCancellationRequested(config) { 632 if (config.cancelToken) { 633 config.cancelToken.throwIfRequested(); 634 } 635} 636 637/** 638 * Dispatch a request to the server using the configured adapter. 639 * 640 * @param {object} config The config that is to be used for the request 641 * @returns {Promise} The Promise to be fulfilled 642 */ 643module.exports = function dispatchRequest(config) { 644 throwIfCancellationRequested(config); 645 646 // Ensure headers exist 647 config.headers = config.headers || {}; 648 649 // Transform request data 650 config.data = transformData( 651 config.data, 652 config.headers, 653 config.transformRequest 654 ); 655 656 // Flatten headers 657 config.headers = utils.merge( 658 config.headers.common || {}, 659 config.headers[config.method] || {}, 660 config.headers 661 ); 662 663 utils.forEach( 664 ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'], 665 function cleanHeaderConfig(method) { 666 delete config.headers[method]; 667 } 668 ); 669 670 var adapter = config.adapter || defaults.adapter; 671 672 return adapter(config).then(function onAdapterResolution(response) { 673 throwIfCancellationRequested(config); 674 675 // Transform response data 676 response.data = transformData( 677 response.data, 678 response.headers, 679 config.transformResponse 680 ); 681 682 return response; 683 }, function onAdapterRejection(reason) { 684 if (!isCancel(reason)) { 685 throwIfCancellationRequested(config); 686 687 // Transform response data 688 if (reason && reason.response) { 689 reason.response.data = transformData( 690 reason.response.data, 691 reason.response.headers, 692 config.transformResponse 693 ); 694 } 695 } 696 697 return Promise.reject(reason); 698 }); 699}; 700 701 702/***/ }), 703
vendor: 1,316 bytes, lines 704-756
704/***/ "./node_modules/axios/lib/core/enhanceError.js": 705/*!*****************************************************!*\ 706 !*** ./node_modules/axios/lib/core/enhanceError.js ***! 707 \*****************************************************/ 708/***/ ((module) => { 709 710"use strict"; 711 712 713/** 714 * Update an Error with the specified config, error code, and response. 715 * 716 * @param {Error} error The error to update. 717 * @param {Object} config The config. 718 * @param {string} [code] The error code (for example, 'ECONNABORTED'). 719 * @param {Object} [request] The request. 720 * @param {Object} [response] The response. 721 * @returns {Error} The error. 722 */ 723module.exports = function enhanceError(error, config, code, request, response) { 724 error.config = config; 725 if (code) { 726 error.code = code; 727 } 728 729 error.request = request; 730 error.response = response; 731 error.isAxiosError = true; 732 733 error.toJSON = function toJSON() { 734 return { 735 // Standard 736 message: this.message, 737 name: this.name, 738 // Microsoft 739 description: this.description, 740 number: this.number, 741 // Mozilla 742 fileName: this.fileName, 743 lineNumber: this.lineNumber, 744 columnNumber: this.columnNumber, 745 stack: this.stack, 746 // Axios 747 config: this.config, 748 code: this.code 749 }; 750 }; 751 return error; 752}; 753 754 755/***/ }), 756
vendor: 3,258 bytes, lines 757-854
757/***/ "./node_modules/axios/lib/core/mergeConfig.js": 758/*!****************************************************!*\ 759 !*** ./node_modules/axios/lib/core/mergeConfig.js ***! 760 \****************************************************/ 761/***/ ((module, __unused_webpack_exports, __webpack_require__) => { 762 763"use strict"; 764 765 766var utils = __webpack_require__(/*! ../utils */ "./node_modules/axios/lib/utils.js"); 767 768/** 769 * Config-specific merge-function which creates a new config-object 770 * by merging two configuration objects together. 771 * 772 * @param {Object} config1 773 * @param {Object} config2 774 * @returns {Object} New object resulting from merging config2 to config1 775 */ 776module.exports = function mergeConfig(config1, config2) { 777 // eslint-disable-next-line no-param-reassign 778 config2 = config2 || {}; 779 var config = {}; 780 781 var valueFromConfig2Keys = ['url', 'method', 'data']; 782 var mergeDeepPropertiesKeys = ['headers', 'auth', 'proxy', 'params']; 783 var defaultToConfig2Keys = [ 784 'baseURL', 'transformRequest', 'transformResponse', 'paramsSerializer', 785 'timeout', 'timeoutMessage', 'withCredentials', 'adapter', 'responseType', 'xsrfCookieName', 786 'xsrfHeaderName', 'onUploadProgress', 'onDownloadProgress', 'decompress', 787 'maxContentLength', 'maxBodyLength', 'maxRedirects', 'transport', 'httpAgent', 788 'httpsAgent', 'cancelToken', 'socketPath', 'responseEncoding' 789 ]; 790 var directMergeKeys = ['validateStatus']; 791 792 function getMergedValue(target, source) { 793 if (utils.isPlainObject(target) && utils.isPlainObject(source)) { 794 return utils.merge(target, source); 795 } else if (utils.isPlainObject(source)) { 796 return utils.merge({}, source); 797 } else if (utils.isArray(source)) { 798 return source.slice(); 799 } 800 return source; 801 } 802 803 function mergeDeepProperties(prop) { 804 if (!utils.isUndefined(config2[prop])) { 805 config[prop] = getMergedValue(config1[prop], config2[prop]); 806 } else if (!utils.isUndefined(config1[prop])) { 807 config[prop] = getMergedValue(undefined, config1[prop]); 808 } 809 } 810 811 utils.forEach(valueFromConfig2Keys, function valueFromConfig2(prop) { 812 if (!utils.isUndefined(config2[prop])) { 813 config[prop] = getMergedValue(undefined, config2[prop]); 814 } 815 }); 816 817 utils.forEach(mergeDeepPropertiesKeys, mergeDeepProperties); 818 819 utils.forEach(defaultToConfig2Keys, function defaultToConfig2(prop) { 820 if (!utils.isUndefined(config2[prop])) { 821 config[prop] = getMergedValue(undefined, config2[prop]); 822 } else if (!utils.isUndefined(config1[prop])) { 823 config[prop] = getMergedValue(undefined, config1[prop]); 824 } 825 }); 826 827 utils.forEach(directMergeKeys, function merge(prop) { 828 if (prop in config2) { 829 config[prop] = getMergedValue(config1[prop], config2[prop]); 830 } else if (prop in config1) { 831 config[prop] = getMergedValue(undefined, config1[prop]); 832 } 833 }); 834 835 var axiosKeys = valueFromConfig2Keys 836 .concat(mergeDeepPropertiesKeys) 837 .concat(defaultToConfig2Keys) 838 .concat(directMergeKeys); 839 840 var otherKeys = Object 841 .keys(config1) 842 .concat(Object.keys(config2)) 843 .filter(function filterAxiosKeys(key) { 844 return axiosKeys.indexOf(key) === -1; 845 }); 846 847 utils.forEach(otherKeys, mergeDeepProperties); 848 849 return config; 850}; 851 852 853/***/ }), 854
vendor: 1,060 bytes, lines 855-890
855/***/ "./node_modules/axios/lib/core/settle.js": 856/*!***********************************************!*\ 857 !*** ./node_modules/axios/lib/core/settle.js ***! 858 \***********************************************/ 859/***/ ((module, __unused_webpack_exports, __webpack_require__) => { 860 861"use strict"; 862 863 864var createError = __webpack_require__(/*! ./createError */ "./node_modules/axios/lib/core/createError.js"); 865 866/** 867 * Resolve or reject a Promise based on response status. 868 * 869 * @param {Function} resolve A function that resolves the promise. 870 * @param {Function} reject A function that rejects the promise. 871 * @param {object} response The response. 872 */ 873module.exports = function settle(resolve, reject, response) { 874 var validateStatus = response.config.validateStatus; 875 if (!response.status || !validateStatus || validateStatus(response.status)) { 876 resolve(response); 877 } else { 878 reject(createError( 879 'Request failed with status code ' + response.status, 880 response.config, 881 null, 882 response.request, 883 response 884 )); 885 } 886}; 887 888 889/***/ }), 890
vendor: 921 bytes, lines 891-921
891/***/ "./node_modules/axios/lib/core/transformData.js": 892/*!******************************************************!*\ 893 !*** ./node_modules/axios/lib/core/transformData.js ***! 894 \******************************************************/ 895/***/ ((module, __unused_webpack_exports, __webpack_require__) => { 896 897"use strict"; 898 899 900var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js"); 901 902/** 903 * Transform the data for a request or a response 904 * 905 * @param {Object|String} data The data to be transformed 906 * @param {Array} headers The headers for the request or response 907 * @param {Array|Function} fns A single function or Array of functions 908 * @returns {*} The resulting transformed data 909 */ 910module.exports = function transformData(data, headers, fns) { 911 /*eslint no-param-reassign:0*/ 912 utils.forEach(fns, function transform(fn) { 913 data = fn(data, headers); 914 }); 915 916 return data; 917}; 918 919 920/***/ }), 921
vendor: 3,210 bytes, lines 922-1031
922/***/ "./node_modules/axios/lib/defaults.js": 923/*!********************************************!*\ 924 !*** ./node_modules/axios/lib/defaults.js ***! 925 \********************************************/ 926/***/ ((module, __unused_webpack_exports, __webpack_require__) => { 927 928"use strict"; 929/* provided dependency */ var process = __webpack_require__(/*! process/browser */ "./node_modules/process/browser.js"); 930 931 932var utils = __webpack_require__(/*! ./utils */ "./node_modules/axios/lib/utils.js"); 933var normalizeHeaderName = __webpack_require__(/*! ./helpers/normalizeHeaderName */ "./node_modules/axios/lib/helpers/normalizeHeaderName.js"); 934 935var DEFAULT_CONTENT_TYPE = { 936 'Content-Type': 'application/x-www-form-urlencoded' 937}; 938 939function setContentTypeIfUnset(headers, value) { 940 if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) { 941 headers['Content-Type'] = value; 942 } 943} 944 945function getDefaultAdapter() { 946 var adapter; 947 if (typeof XMLHttpRequest !== 'undefined') { 948 // For browsers use XHR adapter 949 adapter = __webpack_require__(/*! ./adapters/xhr */ "./node_modules/axios/lib/adapters/xhr.js"); 950 } else if (typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]') { 951 // For node use HTTP adapter 952 adapter = __webpack_require__(/*! ./adapters/http */ "./node_modules/axios/lib/adapters/xhr.js"); 953 } 954 return adapter; 955} 956 957var defaults = { 958 adapter: getDefaultAdapter(), 959 960 transformRequest: [function transformRequest(data, headers) { 961 normalizeHeaderName(headers, 'Accept'); 962 normalizeHeaderName(headers, 'Content-Type'); 963 if (utils.isFormData(data) || 964 utils.isArrayBuffer(data) || 965 utils.isBuffer(data) || 966 utils.isStream(data) || 967 utils.isFile(data) || 968 utils.isBlob(data) 969 ) { 970 return data; 971 } 972 if (utils.isArrayBufferView(data)) { 973 return data.buffer; 974 } 975 if (utils.isURLSearchParams(data)) { 976 setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8'); 977 return data.toString(); 978 } 979 if (utils.isObject(data)) { 980 setContentTypeIfUnset(headers, 'application/json;charset=utf-8'); 981 return JSON.stringify(data); 982 } 983 return data; 984 }], 985 986 transformResponse: [function transformResponse(data) { 987 /*eslint no-param-reassign:0*/ 988 if (typeof data === 'string') { 989 try { 990 data = JSON.parse(data); 991 } catch (e) { /* Ignore */ } 992 } 993 return data; 994 }], 995 996 /** 997 * A timeout in milliseconds to abort a request. If set to 0 (default) a 998 * timeout is not created. 999 */ 1000 timeout: 0, 1001 1002 xsrfCookieName: 'XSRF-TOKEN', 1003 xsrfHeaderName: 'X-XSRF-TOKEN', 1004 1005 maxContentLength: -1, 1006 maxBodyLength: -1, 1007 1008 validateStatus: function validateStatus(status) { 1009 return status >= 200 && status < 300; 1010 } 1011}; 1012 1013defaults.headers = { 1014 common: { 1015 'Accept': 'application/json, text/plain, */*' 1016 } 1017}; 1018 1019utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) { 1020 defaults.headers[method] = {}; 1021}); 1022 1023utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) { 1024 defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE); 1025}); 1026 1027module.exports = defaults; 1028 1029 1030/***/ }), 1031
vendor: 503 bytes, lines 1032-1053
1032/***/ "./node_modules/axios/lib/helpers/bind.js": 1033/*!************************************************!*\ 1034 !*** ./node_modules/axios/lib/helpers/bind.js ***! 1035 \************************************************/ 1036/***/ ((module) => { 1037 1038"use strict"; 1039 1040 1041module.exports = function bind(fn, thisArg) { 1042 return function wrap() { 1043 var args = new Array(arguments.length); 1044 for (var i = 0; i < args.length; i++) { 1045 args[i] = arguments[i]; 1046 } 1047 return fn.apply(thisArg, args); 1048 }; 1049}; 1050 1051 1052/***/ }), 1053
vendor: 2,007 bytes, lines 1054-1134
1054/***/ "./node_modules/axios/lib/helpers/buildURL.js": 1055/*!****************************************************!*\ 1056 !*** ./node_modules/axios/lib/helpers/buildURL.js ***! 1057 \****************************************************/ 1058/***/ ((module, __unused_webpack_exports, __webpack_require__) => { 1059 1060"use strict"; 1061 1062 1063var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js"); 1064 1065function encode(val) { 1066 return encodeURIComponent(val). 1067 replace(/%3A/gi, ':'). 1068 replace(/%24/g, '$'). 1069 replace(/%2C/gi, ','). 1070 replace(/%20/g, '+'). 1071 replace(/%5B/gi, '['). 1072 replace(/%5D/gi, ']'); 1073} 1074 1075/** 1076 * Build a URL by appending params to the end 1077 * 1078 * @param {string} url The base of the url (e.g., http://www.google.com) 1079 * @param {object} [params] The params to be appended 1080 * @returns {string} The formatted url 1081 */ 1082module.exports = function buildURL(url, params, paramsSerializer) { 1083 /*eslint no-param-reassign:0*/ 1084 if (!params) { 1085 return url; 1086 } 1087 1088 var serializedParams; 1089 if (paramsSerializer) { 1090 serializedParams = paramsSerializer(params); 1091 } else if (utils.isURLSearchParams(params)) { 1092 serializedParams = params.toString(); 1093 } else { 1094 var parts = []; 1095 1096 utils.forEach(params, function serialize(val, key) { 1097 if (val === null || typeof val === 'undefined') { 1098 return; 1099 } 1100 1101 if (utils.isArray(val)) { 1102 key = key + '[]'; 1103 } else { 1104 val = [val]; 1105 } 1106 1107 utils.forEach(val, function parseValue(v) { 1108 if (utils.isDate(v)) { 1109 v = v.toISOString(); 1110 } else if (utils.isObject(v)) { 1111 v = JSON.stringify(v); 1112 } 1113 parts.push(encode(key) + '=' + encode(v)); 1114 }); 1115 }); 1116 1117 serializedParams = parts.join('&'); 1118 } 1119 1120 if (serializedParams) { 1121 var hashmarkIndex = url.indexOf('#'); 1122 if (hashmarkIndex !== -1) { 1123 url = url.slice(0, hashmarkIndex); 1124 } 1125 1126 url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams; 1127 } 1128 1129 return url; 1130}; 1131 1132 1133/***/ }), 1134
vendor: 655 bytes, lines 1135-1159
1135/***/ "./node_modules/axios/lib/helpers/combineURLs.js": 1136/*!*******************************************************!*\ 1137 !*** ./node_modules/axios/lib/helpers/combineURLs.js ***! 1138 \*******************************************************/ 1139/***/ ((module) => { 1140 1141"use strict"; 1142 1143 1144/** 1145 * Creates a new URL by combining the specified URLs 1146 * 1147 * @param {string} baseURL The base URL 1148 * @param {string} relativeURL The relative URL 1149 * @returns {string} The combined URL 1150 */ 1151module.exports = function combineURLs(baseURL, relativeURL) { 1152 return relativeURL 1153 ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '') 1154 : baseURL; 1155}; 1156 1157 1158/***/ }), 1159
vendor: 1,794 bytes, lines 1160-1223
1160/***/ "./node_modules/axios/lib/helpers/cookies.js": 1161/*!***************************************************!*\ 1162 !*** ./node_modules/axios/lib/helpers/cookies.js ***! 1163 \***************************************************/ 1164/***/ ((module, __unused_webpack_exports, __webpack_require__) => { 1165 1166"use strict"; 1167 1168 1169var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js"); 1170 1171module.exports = ( 1172 utils.isStandardBrowserEnv() ? 1173 1174 // Standard browser envs support document.cookie 1175 (function standardBrowserEnv() { 1176 return { 1177 write: function write(name, value, expires, path, domain, secure) { 1178 var cookie = []; 1179 cookie.push(name + '=' + encodeURIComponent(value)); 1180 1181 if (utils.isNumber(expires)) { 1182 cookie.push('expires=' + new Date(expires).toGMTString()); 1183 } 1184 1185 if (utils.isString(path)) { 1186 cookie.push('path=' + path); 1187 } 1188 1189 if (utils.isString(domain)) { 1190 cookie.push('domain=' + domain); 1191 } 1192 1193 if (secure === true) { 1194 cookie.push('secure'); 1195 } 1196 1197 document.cookie = cookie.join('; '); 1198 }, 1199 1200 read: function read(name) { 1201 var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)')); 1202 return (match ? decodeURIComponent(match[3]) : null); 1203 }, 1204 1205 remove: function remove(name) { 1206 this.write(name, '', Date.now() - 86400000); 1207 } 1208 }; 1209 })() : 1210 1211 // Non standard browser env (web workers, react-native) lack needed support. 1212 (function nonStandardBrowserEnv() { 1213 return { 1214 write: function write() {}, 1215 read: function read() { return null; }, 1216 remove: function remove() {} 1217 }; 1218 })() 1219); 1220 1221 1222/***/ }), 1223
vendor: 846 bytes, lines 1224-1248
1224/***/ "./node_modules/axios/lib/helpers/isAbsoluteURL.js": 1225/*!*********************************************************!*\ 1226 !*** ./node_modules/axios/lib/helpers/isAbsoluteURL.js ***! 1227 \*********************************************************/ 1228/***/ ((module) => { 1229 1230"use strict"; 1231 1232 1233/** 1234 * Determines whether the specified URL is absolute 1235 * 1236 * @param {string} url The URL to test 1237 * @returns {boolean} True if the specified URL is absolute, otherwise false 1238 */ 1239module.exports = function isAbsoluteURL(url) { 1240 // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL). 1241 // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed 1242 // by any combination of letters, digits, plus, period, or hyphen. 1243 return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(url); 1244}; 1245 1246 1247/***/ }), 1248
vendor: 622 bytes, lines 1249-1270
1249/***/ "./node_modules/axios/lib/helpers/isAxiosError.js": 1250/*!********************************************************!*\ 1251 !*** ./node_modules/axios/lib/helpers/isAxiosError.js ***! 1252 \********************************************************/ 1253/***/ ((module) => { 1254 1255"use strict"; 1256 1257 1258/** 1259 * Determines whether the payload is an error thrown by Axios 1260 * 1261 * @param {*} payload The value to test 1262 * @returns {boolean} True if the payload is an error thrown by Axios, otherwise false 1263 */ 1264module.exports = function isAxiosError(payload) { 1265 return (typeof payload === 'object') && (payload.isAxiosError === true); 1266}; 1267 1268 1269/***/ }), 1270
vendor: 2,696 bytes, lines 1271-1349
1271/***/ "./node_modules/axios/lib/helpers/isURLSameOrigin.js": 1272/*!***********************************************************!*\ 1273 !*** ./node_modules/axios/lib/helpers/isURLSameOrigin.js ***! 1274 \***********************************************************/ 1275/***/ ((module, __unused_webpack_exports, __webpack_require__) => { 1276 1277"use strict"; 1278 1279 1280var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js"); 1281 1282module.exports = ( 1283 utils.isStandardBrowserEnv() ? 1284 1285 // Standard browser envs have full support of the APIs needed to test 1286 // whether the request URL is of the same origin as current location. 1287 (function standardBrowserEnv() { 1288 var msie = /(msie|trident)/i.test(navigator.userAgent); 1289 var urlParsingNode = document.createElement('a'); 1290 var originURL; 1291 1292 /** 1293 * Parse a URL to discover it's components 1294 * 1295 * @param {String} url The URL to be parsed 1296 * @returns {Object} 1297 */ 1298 function resolveURL(url) { 1299 var href = url; 1300 1301 if (msie) { 1302 // IE needs attribute set twice to normalize properties 1303 urlParsingNode.setAttribute('href', href); 1304 href = urlParsingNode.href; 1305 } 1306 1307 urlParsingNode.setAttribute('href', href); 1308 1309 // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils 1310 return { 1311 href: urlParsingNode.href, 1312 protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '', 1313 host: urlParsingNode.host, 1314 search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '', 1315 hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '', 1316 hostname: urlParsingNode.hostname, 1317 port: urlParsingNode.port, 1318 pathname: (urlParsingNode.pathname.charAt(0) === '/') ? 1319 urlParsingNode.pathname : 1320 '/' + urlParsingNode.pathname 1321 }; 1322 } 1323 1324 originURL = resolveURL(window.location.href); 1325 1326 /** 1327 * Determine if a URL shares the same origin as the current location 1328 * 1329 * @param {String} requestURL The URL to test 1330 * @returns {boolean} True if URL shares the same origin, otherwise false 1331 */ 1332 return function isURLSameOrigin(requestURL) { 1333 var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL; 1334 return (parsed.protocol === originURL.protocol && 1335 parsed.host === originURL.host); 1336 }; 1337 })() : 1338 1339 // Non standard browser envs (web workers, react-native) lack needed support. 1340 (function nonStandardBrowserEnv() { 1341 return function isURLSameOrigin() { 1342 return true; 1343 }; 1344 })() 1345); 1346 1347 1348/***/ }), 1349
vendor: 764 bytes, lines 1350-1372
1350/***/ "./node_modules/axios/lib/helpers/normalizeHeaderName.js": 1351/*!***************************************************************!*\ 1352 !*** ./node_modules/axios/lib/helpers/normalizeHeaderName.js ***! 1353 \***************************************************************/ 1354/***/ ((module, __unused_webpack_exports, __webpack_require__) => { 1355 1356"use strict"; 1357 1358 1359var utils = __webpack_require__(/*! ../utils */ "./node_modules/axios/lib/utils.js"); 1360 1361module.exports = function normalizeHeaderName(headers, normalizedName) { 1362 utils.forEach(headers, function processHeader(value, name) { 1363 if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) { 1364 headers[normalizedName] = value; 1365 delete headers[name]; 1366 } 1367 }); 1368}; 1369 1370 1371/***/ }), 1372
vendor: 1,772 bytes, lines 1373-1436
1373/***/ "./node_modules/axios/lib/helpers/parseHeaders.js": 1374/*!********************************************************!*\ 1375 !*** ./node_modules/axios/lib/helpers/parseHeaders.js ***! 1376 \********************************************************/ 1377/***/ ((module, __unused_webpack_exports, __webpack_require__) => { 1378 1379"use strict"; 1380 1381 1382var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js"); 1383 1384// Headers whose duplicates are ignored by node 1385// c.f. https://nodejs.org/api/http.html#http_message_headers 1386var ignoreDuplicateOf = [ 1387 'age', 'authorization', 'content-length', 'content-type', 'etag', 1388 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since', 1389 'last-modified', 'location', 'max-forwards', 'proxy-authorization', 1390 'referer', 'retry-after', 'user-agent' 1391]; 1392 1393/** 1394 * Parse headers into an object 1395 * 1396 * ``` 1397 * Date: Wed, 27 Aug 2014 08:58:49 GMT 1398 * Content-Type: application/json 1399 * Connection: keep-alive 1400 * Transfer-Encoding: chunked 1401 * ``` 1402 * 1403 * @param {String} headers Headers needing to be parsed 1404 * @returns {Object} Headers parsed into an object 1405 */ 1406module.exports = function parseHeaders(headers) { 1407 var parsed = {}; 1408 var key; 1409 var val; 1410 var i; 1411 1412 if (!headers) { return parsed; } 1413 1414 utils.forEach(headers.split('\n'), function parser(line) { 1415 i = line.indexOf(':'); 1416 key = utils.trim(line.substr(0, i)).toLowerCase(); 1417 val = utils.trim(line.substr(i + 1)); 1418 1419 if (key) { 1420 if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) { 1421 return; 1422 } 1423 if (key === 'set-cookie') { 1424 parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]); 1425 } else { 1426 parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val; 1427 } 1428 } 1429 }); 1430 1431 return parsed; 1432}; 1433 1434 1435/***/ }), 1436
vendor: 819 bytes, lines 1437-1474
1437/***/ "./node_modules/axios/lib/helpers/spread.js": 1438/*!**************************************************!*\ 1439 !*** ./node_modules/axios/lib/helpers/spread.js ***! 1440 \**************************************************/ 1441/***/ ((module) => { 1442 1443"use strict"; 1444 1445 1446/** 1447 * Syntactic sugar for invoking a function and expanding an array for arguments. 1448 * 1449 * Common use case would be to use `Function.prototype.apply`. 1450 * 1451 * ```js 1452 * function f(x, y, z) {} 1453 * var args = [1, 2, 3]; 1454 * f.apply(null, args); 1455 * ``` 1456 * 1457 * With `spread` this example can be re-written. 1458 * 1459 * ```js 1460 * spread(function(x, y, z) {})([1, 2, 3]); 1461 * ``` 1462 * 1463 * @param {Function} callback 1464 * @returns {Function} 1465 */ 1466module.exports = function spread(callback) { 1467 return function wrap(arr) { 1468 return callback.apply(null, arr); 1469 }; 1470}; 1471 1472 1473/***/ }), 1474
vendor: 9,273 bytes, lines 1475-1836
1475/***/ "./node_modules/axios/lib/utils.js": 1476/*!*****************************************!*\ 1477 !*** ./node_modules/axios/lib/utils.js ***! 1478 \*****************************************/ 1479/***/ ((module, __unused_webpack_exports, __webpack_require__) => { 1480 1481"use strict"; 1482 1483 1484var bind = __webpack_require__(/*! ./helpers/bind */ "./node_modules/axios/lib/helpers/bind.js"); 1485 1486/*global toString:true*/ 1487 1488// utils is a library of generic helper functions non-specific to axios 1489 1490var toString = Object.prototype.toString; 1491 1492/** 1493 * Determine if a value is an Array 1494 * 1495 * @param {Object} val The value to test 1496 * @returns {boolean} True if value is an Array, otherwise false 1497 */ 1498function isArray(val) { 1499 return toString.call(val) === '[object Array]'; 1500} 1501 1502/** 1503 * Determine if a value is undefined 1504 * 1505 * @param {Object} val The value to test 1506 * @returns {boolean} True if the value is undefined, otherwise false 1507 */ 1508function isUndefined(val) { 1509 return typeof val === 'undefined'; 1510} 1511 1512/** 1513 * Determine if a value is a Buffer 1514 * 1515 * @param {Object} val The value to test 1516 * @returns {boolean} True if value is a Buffer, otherwise false 1517 */ 1518function isBuffer(val) { 1519 return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor) 1520 && typeof val.constructor.isBuffer === 'function' && val.constructor.isBuffer(val); 1521} 1522 1523/** 1524 * Determine if a value is an ArrayBuffer 1525 * 1526 * @param {Object} val The value to test 1527 * @returns {boolean} True if value is an ArrayBuffer, otherwise false 1528 */ 1529function isArrayBuffer(val) { 1530 return toString.call(val) === '[object ArrayBuffer]'; 1531} 1532 1533/** 1534 * Determine if a value is a FormData 1535 * 1536 * @param {Object} val The value to test 1537 * @returns {boolean} True if value is an FormData, otherwise false 1538 */ 1539function isFormData(val) { 1540 return (typeof FormData !== 'undefined') && (val instanceof FormData); 1541} 1542 1543/** 1544 * Determine if a value is a view on an ArrayBuffer 1545 * 1546 * @param {Object} val The value to test 1547 * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false 1548 */ 1549function isArrayBufferView(val) { 1550 var result; 1551 if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) { 1552 result = ArrayBuffer.isView(val); 1553 } else { 1554 result = (val) && (val.buffer) && (val.buffer instanceof ArrayBuffer); 1555 } 1556 return result; 1557} 1558 1559/** 1560 * Determine if a value is a String 1561 * 1562 * @param {Object} val The value to test 1563 * @returns {boolean} True if value is a String, otherwise false 1564 */ 1565function isString(val) { 1566 return typeof val === 'string'; 1567} 1568 1569/** 1570 * Determine if a value is a Number 1571 * 1572 * @param {Object} val The value to test 1573 * @returns {boolean} True if value is a Number, otherwise false 1574 */ 1575function isNumber(val) { 1576 return typeof val === 'number'; 1577} 1578 1579/** 1580 * Determine if a value is an Object 1581 * 1582 * @param {Object} val The value to test 1583 * @returns {boolean} True if value is an Object, otherwise false 1584 */ 1585function isObject(val) { 1586 return val !== null && typeof val === 'object'; 1587} 1588 1589/** 1590 * Determine if a value is a plain Object 1591 * 1592 * @param {Object} val The value to test 1593 * @return {boolean} True if value is a plain Object, otherwise false 1594 */ 1595function isPlainObject(val) { 1596 if (toString.call(val) !== '[object Object]') { 1597 return false; 1598 } 1599 1600 var prototype = Object.getPrototypeOf(val); 1601 return prototype === null || prototype === Object.prototype; 1602} 1603 1604/** 1605 * Determine if a value is a Date 1606 * 1607 * @param {Object} val The value to test 1608 * @returns {boolean} True if value is a Date, otherwise false 1609 */ 1610function isDate(val) { 1611 return toString.call(val) === '[object Date]'; 1612} 1613 1614/** 1615 * Determine if a value is a File 1616 * 1617 * @param {Object} val The value to test 1618 * @returns {boolean} True if value is a File, otherwise false 1619 */ 1620function isFile(val) { 1621 return toString.call(val) === '[object File]'; 1622} 1623 1624/** 1625 * Determine if a value is a Blob 1626 * 1627 * @param {Object} val The value to test 1628 * @returns {boolean} True if value is a Blob, otherwise false 1629 */ 1630function isBlob(val) { 1631 return toString.call(val) === '[object Blob]'; 1632} 1633 1634/** 1635 * Determine if a value is a Function 1636 * 1637 * @param {Object} val The value to test 1638 * @returns {boolean} True if value is a Function, otherwise false 1639 */ 1640function isFunction(val) { 1641 return toString.call(val) === '[object Function]'; 1642} 1643 1644/** 1645 * Determine if a value is a Stream 1646 * 1647 * @param {Object} val The value to test 1648 * @returns {boolean} True if value is a Stream, otherwise false 1649 */ 1650function isStream(val) { 1651 return isObject(val) && isFunction(val.pipe); 1652} 1653 1654/** 1655 * Determine if a value is a URLSearchParams object 1656 * 1657 * @param {Object} val The value to test 1658 * @returns {boolean} True if value is a URLSearchParams object, otherwise false 1659 */ 1660function isURLSearchParams(val) { 1661 return typeof URLSearchParams !== 'undefined' && val instanceof URLSearchParams; 1662} 1663 1664/** 1665 * Trim excess whitespace off the beginning and end of a string 1666 * 1667 * @param {String} str The String to trim 1668 * @returns {String} The String freed of excess whitespace 1669 */ 1670function trim(str) { 1671 return str.replace(/^\s*/, '').replace(/\s*$/, ''); 1672} 1673 1674/** 1675 * Determine if we're running in a standard browser environment 1676 * 1677 * This allows axios to run in a web worker, and react-native. 1678 * Both environments support XMLHttpRequest, but not fully standard globals. 1679 * 1680 * web workers: 1681 * typeof window -> undefined 1682 * typeof document -> undefined 1683 * 1684 * react-native: 1685 * navigator.product -> 'ReactNative' 1686 * nativescript 1687 * navigator.product -> 'NativeScript' or 'NS' 1688 */ 1689function isStandardBrowserEnv() { 1690 if (typeof navigator !== 'undefined' && (navigator.product === 'ReactNative' || 1691 navigator.product === 'NativeScript' || 1692 navigator.product === 'NS')) { 1693 return false; 1694 } 1695 return ( 1696 typeof window !== 'undefined' && 1697 typeof document !== 'undefined' 1698 ); 1699} 1700 1701/** 1702 * Iterate over an Array or an Object invoking a function for each item. 1703 * 1704 * If `obj` is an Array callback will be called passing 1705 * the value, index, and complete array for each item. 1706 * 1707 * If 'obj' is an Object callback will be called passing 1708 * the value, key, and complete object for each property. 1709 * 1710 * @param {Object|Array} obj The object to iterate 1711 * @param {Function} fn The callback to invoke for each item 1712 */ 1713function forEach(obj, fn) { 1714 // Don't bother if no value provided 1715 if (obj === null || typeof obj === 'undefined') { 1716 return; 1717 } 1718 1719 // Force an array if not already something iterable 1720 if (typeof obj !== 'object') { 1721 /*eslint no-param-reassign:0*/ 1722 obj = [obj]; 1723 } 1724 1725 if (isArray(obj)) { 1726 // Iterate over array values 1727 for (var i = 0, l = obj.length; i < l; i++) { 1728 fn.call(null, obj[i], i, obj); 1729 } 1730 } else { 1731 // Iterate over object keys 1732 for (var key in obj) { 1733 if (Object.prototype.hasOwnProperty.call(obj, key)) { 1734 fn.call(null, obj[key], key, obj); 1735 } 1736 } 1737 } 1738} 1739 1740/** 1741 * Accepts varargs expecting each argument to be an object, then 1742 * immutably merges the properties of each object and returns result. 1743 * 1744 * When multiple objects contain the same key the later object in 1745 * the arguments list will take precedence. 1746 * 1747 * Example: 1748 * 1749 * ```js 1750 * var result = merge({foo: 123}, {foo: 456}); 1751 * console.log(result.foo); // outputs 456 1752 * ``` 1753 * 1754 * @param {Object} obj1 Object to merge 1755 * @returns {Object} Result of all merge properties 1756 */ 1757function merge(/* obj1, obj2, obj3, ... */) { 1758 var result = {}; 1759 function assignValue(val, key) { 1760 if (isPlainObject(result[key]) && isPlainObject(val)) { 1761 result[key] = merge(result[key], val); 1762 } else if (isPlainObject(val)) { 1763 result[key] = merge({}, val); 1764 } else if (isArray(val)) { 1765 result[key] = val.slice(); 1766 } else { 1767 result[key] = val; 1768 } 1769 } 1770 1771 for (var i = 0, l = arguments.length; i < l; i++) { 1772 forEach(arguments[i], assignValue); 1773 } 1774 return result; 1775} 1776 1777/** 1778 * Extends object a by mutably adding to it the properties of object b. 1779 * 1780 * @param {Object} a The object to be extended 1781 * @param {Object} b The object to copy properties from 1782 * @param {Object} thisArg The object to bind function to 1783 * @return {Object} The resulting value of object a 1784 */ 1785function extend(a, b, thisArg) { 1786 forEach(b, function assignValue(val, key) { 1787 if (thisArg && typeof val === 'function') { 1788 a[key] = bind(val, thisArg); 1789 } else { 1790 a[key] = val; 1791 } 1792 }); 1793 return a; 1794} 1795 1796/** 1797 * Remove byte order marker. This catches EF BB BF (the UTF-8 BOM) 1798 * 1799 * @param {string} content with BOM 1800 * @return {string} content value without BOM 1801 */ 1802function stripBOM(content) { 1803 if (content.charCodeAt(0) === 0xFEFF) { 1804 content = content.slice(1); 1805 } 1806 return content; 1807} 1808 1809module.exports = { 1810 isArray: isArray, 1811 isArrayBuffer: isArrayBuffer, 1812 isBuffer: isBuffer, 1813 isFormData: isFormData, 1814 isArrayBufferView: isArrayBufferView, 1815 isString: isString, 1816 isNumber: isNumber, 1817 isObject: isObject, 1818 isPlainObject: isPlainObject, 1819 isUndefined: isUndefined, 1820 isDate: isDate, 1821 isFile: isFile, 1822 isBlob: isBlob, 1823 isFunction: isFunction, 1824 isStream: isStream, 1825 isURLSearchParams: isURLSearchParams, 1826 isStandardBrowserEnv: isStandardBrowserEnv, 1827 forEach: forEach, 1828 merge: merge, 1829 extend: extend, 1830 trim: trim, 1831 stripBOM: stripBOM 1832}; 1833 1834 1835/***/ }), 1836
1837/***/ "./src/App.js": 1838/*!********************!*\ 1839 !*** ./src/App.js ***! 1840 \********************/ 1841/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { 1842 1843"use strict"; 1844__webpack_require__.r(__webpack_exports__); 1845/* harmony export */ __webpack_require__.d(__webpack_exports__, { 1846/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) 1847/* harmony export */ }); 1848/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); 1849/* harmony import */ var axios__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! axios */ "./node_modules/axios/index.js"); 1850/* harmony import */ var axios__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(axios__WEBPACK_IMPORTED_MODULE_1__); 1851/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! react/jsx-runtime */ "./node_modules/react/jsx-runtime.js"); 1852function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } 1853 1854function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 1855 1856function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } 1857 1858function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } 1859 1860function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } 1861 1862function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } 1863 1864function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } 1865 1866function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); } 1867 1868function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } 1869 1870function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } 1871 1872function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } 1873 1874 1875 1876 1877 1878 1879var App = /*#__PURE__*/function (_Component) { 1880 _inherits(App, _Component); 1881 1882 var _super = _createSuper(App); 1883 1884 function App(props) { 1885 var _this; 1886 1887 _classCallCheck(this, App); 1888 1889 _this = _super.call(this, props); 1890 _this.state = { 1891 parentList: [], 1892 childrenList: [], 1893 currentParent: {}, 1894 currentChild: {}, 1895 haveChildren: false, 1896 currentDescription: "", 1897 currentLinkUrl: "", 1898 currentLinkText: "", 1899 block_config: drupalSettings.blockConfig 1900 }; 1901 _this.handleChange = _this.handleChange.bind(_assertThisInitialized(_this)); 1902 return _this; 1903 } 1904 1905 _createClass(App, [{ 1906 key: "componentDidMount", 1907 value: function componentDidMount() { 1908 var _this2 = this; 1909 1910 axios__WEBPACK_IMPORTED_MODULE_1___default().get("/how_do_i/list").then(function (res) { 1911 var list = res.data; 1912 1913 _this2.setState({ 1914 parentList: list 1915 }); 1916 1917 _this2.refreshItems(list); 1918 }); 1919 } 1920 }, { 1921 key: "refreshItems", 1922 value: function refreshItems(list) { 1923 if (list.length > 0) { 1924 var parent = list[0]; 1925 var haveChildren = !!parent.children.length; 1926 1927 if (haveChildren) { 1928 var child = parent.children[0]; 1929 this.setState({ 1930 currentParent: parent, 1931 childrenList: parent.children, 1932 currentChild: child, 1933 haveChildren: true, 1934 currentDescription: child.description, 1935 currentLinkUrl: child.action_link_url, 1936 currentLinkText: child.action_link_text 1937 }); 1938 } else { 1939 this.setState({ 1940 currentParent: parent, 1941 haveChildren: false, 1942 currentDescription: parent.description, 1943 currentLinkUrl: parent.action_link_url, 1944 currentLinkText: parent.action_link_text 1945 }); 1946 } 1947 } 1948 } 1949 }, { 1950 key: "handleChange", 1951 value: function handleChange(event) { 1952 switch (event.target.id) { 1953 case 'action1': 1954 { 1955 var parentId = event.target.value; 1956 var parentObject = this.state.parentList.find(function (parent) { 1957 return parent.tid === parentId; 1958 }); 1959 var haveChildren = !!parentObject.children.length; 1960 1961 if (haveChildren) { 1962 var child = parentObject.children[0]; 1963 this.setState({ 1964 currentParent: parentObject, 1965 childrenList: parentObject.children, 1966 currentChild: child, 1967 haveChildren: true, 1968 currentDescription: child.description, 1969 currentLinkUrl: child.action_link_url, 1970 currentLinkText: child.action_link_text 1971 }); 1972 } else { 1973 this.setState({ 1974 currentParent: parentObject, 1975 currentDescription: parentObject.description, 1976 haveChildren: false, 1977 currentLinkUrl: parentObject.action_link_url, 1978 currentLinkText: parentObject.action_link_text 1979 }); 1980 } 1981 } 1982 break; 1983 1984 case 'action2': 1985 { 1986 var childId = event.target.value; 1987 var childObject = this.state.childrenList.find(function (child) { 1988 return child.tid === childId; 1989 }); 1990 this.setState({ 1991 currentChild: childObject, 1992 currentDescription: childObject.description, 1993 currentLinkUrl: childObject.action_link_url, 1994 currentLinkText: childObject.action_link_text 1995 }); 1996 } 1997 break; 1998 1999 default: 2000 break; 2001 } 2002 } 2003 }, { 2004 key: "render", 2005 value: function render() { 2006 var block_config = this.state.block_config; 2007 var haveChildren = this.state.haveChildren; 2008 var horizontalLayout = block_config.block_layout === "0"; 2009 2010 if (horizontalLayout) { 2011 return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsxs)("div", { 2012 className: "howdoi", 2013 children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsx)("div", { 2014 className: "howdoi__title", 2015 children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsxs)("h2", {
2016 children: [block_config.block_title, /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsx)("i", { 2017 className: block_config.block_icon 2018 })] 2019 }) 2020 }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsxs)("div", { 2021 className: "howdoi__wrapper", 2022 children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsxs)("div", { 2023 className: "howdoi__actions", 2024 children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsxs)("div", { 2025 className: "action", 2026 children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsx)("span", { 2027 className: "step-counter", 2028 children: "1" 2029 }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsx)("label", { 2030 htmlFor: "action1", 2031 children: this.state.currentParent.action_label 2032 }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsx)("select", { 2033 name: "action1", 2034 id: "action1", 2035 value: this.state.currentParent.tid, 2036 onChange: this.handleChange, 2037 children: this.state.parentList.map(function (parent) { 2038 return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsx)("option", { 2039 value: parent.tid, 2040 children: parent.name 2041 }, parent.tid); 2042 }) 2043 })] 2044 }), haveChildren && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsxs)("div", { 2045 className: "action", 2046 children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsx)("span", { 2047 className: "step-counter", 2048 children: "2" 2049 }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsx)("label", { 2050 htmlFor: "action2", 2051 children: this.state.currentChild.action_label 2052 }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsx)("select", { 2053 name: "action2", 2054 id: "action2", 2055 value: this.state.currentChild.tid, 2056 onChange: this.handleChange, 2057 children: this.state.childrenList.map(function (child) { 2058 return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsx)("option", { 2059 value: child.tid, 2060 children: child.name 2061 }, child.tid); 2062 }) 2063 })] 2064 })] 2065 }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsxs)("div", { 2066 className: "howdoi__description", 2067 children: [haveChildren && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsx)("span", { 2068 className: "step-counter", 2069 children: "3" 2070 }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsx)("p", { 2071 children: this.state.currentDescription 2072 })] 2073 }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsx)("div", { 2074 className: "howdoi__link", 2075 children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsx)("a", { 2076 href: this.state.currentLinkUrl, 2077 className: "button", 2078 children: this.state.currentLinkText 2079 }) 2080 })] 2081 })] 2082 }); 2083 } else { 2084 return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsxs)("div", { 2085 className: "howdoi horizontal", 2086 children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsx)("div", { 2087 className: "howdoi__title", 2088 children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsxs)("h2", {
2089 children: [block_config.block_title, /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsx)("i", { 2090 className: block_config.block_icon 2091 })] 2092 }) 2093 }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsxs)("div", { 2094 className: "howdoi__wrapper", 2095 children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsxs)("div", { 2096 className: "howdoi__actions", 2097 children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsxs)("div", { 2098 className: "action", 2099 children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsx)("span", { 2100 className: "step-counter", 2101 children: "1" 2102 }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsx)("label", { 2103 htmlFor: "action1", 2104 children: this.state.currentParent.action_label 2105 }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsx)("select", { 2106 name: "action1", 2107 id: "action1", 2108 value: this.state.currentParent.tid, 2109 onChange: this.handleChange, 2110 children: this.state.parentList.map(function (parent) { 2111 return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsx)("option", { 2112 value: parent.tid, 2113 children: parent.name 2114 }, parent.tid); 2115 }) 2116 })] 2117 }), haveChildren && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsxs)("div", { 2118 className: "action", 2119 children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsx)("span", { 2120 className: "step-counter", 2121 children: "2" 2122 }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsx)("label", { 2123 htmlFor: "action2", 2124 children: this.state.currentChild.action_label 2125 }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsx)("select", { 2126 name: "action2", 2127 id: "action2", 2128 value: this.state.currentChild.tid, 2129 onChange: this.handleChange, 2130 children: this.state.childrenList.map(function (child) { 2131 return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsx)("option", { 2132 value: child.tid, 2133 children: child.name 2134 }, child.tid); 2135 }) 2136 })] 2137 })] 2138 }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsxs)("div", { 2139 className: "howdoi__cta", 2140 children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsxs)("div", { 2141 className: "howdoi__description", 2142 children: [haveChildren && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsx)("span", { 2143 className: "step-counter", 2144 children: "3" 2145 }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsx)("p", { 2146 children: this.state.currentDescription 2147 })] 2148 }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsx)("div", { 2149 className: "howdoi__link", 2150 children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsx)("a", { 2151 href: this.state.currentLinkUrl, 2152 className: "button", 2153 children: this.state.currentLinkText 2154 }) 2155 })] 2156 })] 2157 })] 2158 }); 2159 } 2160 } 2161 }]); 2162 2163 return App; 2164}(react__WEBPACK_IMPORTED_MODULE_0__.Component); 2165 2166/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (App); 2167 2168/***/ }), 2169
2170/***/ "./src/index.js": 2171/*!**********************!*\ 2172 !*** ./src/index.js ***! 2173 \**********************/ 2174/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { 2175 2176"use strict"; 2177__webpack_require__.r(__webpack_exports__); 2178/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js"); 2179/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react-dom */ "./node_modules/react-dom/index.js"); 2180/* harmony import */ var _App__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./App */ "./src/App.js"); 2181/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! react/jsx-runtime */ "./node_modules/react/jsx-runtime.js"); 2182 2183 2184 2185 2186react_dom__WEBPACK_IMPORTED_MODULE_1__.render( /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsx)(_App__WEBPACK_IMPORTED_MODULE_2__.default, {}), document.getElementById('howdoi-root')); 2187 2188/***/ }), 2189
2190/***/ "./src/app.scss": 2191/*!**********************!*\ 2192 !*** ./src/app.scss ***! 2193 \**********************/ 2194/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { 2195 2196"use strict"; 2197__webpack_require__.r(__webpack_exports__); 2198// extracted by mini-css-extract-plugin 2199 2200 2201/***/ }), 2202
vendor: 2,343 bytes, lines 2203-2303
2203/***/ "./node_modules/object-assign/index.js": 2204/*!*********************************************!*\ 2205 !*** ./node_modules/object-assign/index.js ***! 2206 \*********************************************/ 2207/***/ ((module) => { 2208 2209"use strict"; 2210/* 2211object-assign 2212(c) Sindre Sorhus 2213@license MIT 2214*/ 2215 2216 2217/* eslint-disable no-unused-vars */ 2218var getOwnPropertySymbols = Object.getOwnPropertySymbols; 2219var hasOwnProperty = Object.prototype.hasOwnProperty; 2220var propIsEnumerable = Object.prototype.propertyIsEnumerable; 2221 2222function toObject(val) { 2223 if (val === null || val === undefined) { 2224 throw new TypeError('Object.assign cannot be called with null or undefined'); 2225 } 2226 2227 return Object(val); 2228} 2229 2230function shouldUseNative() { 2231 try { 2232 if (!Object.assign) { 2233 return false; 2234 } 2235 2236 // Detect buggy property enumeration order in older V8 versions. 2237 2238 // https://bugs.chromium.org/p/v8/issues/detail?id=4118 2239 var test1 = new String('abc'); // eslint-disable-line no-new-wrappers 2240 test1[5] = 'de'; 2241 if (Object.getOwnPropertyNames(test1)[0] === '5') { 2242 return false; 2243 } 2244 2245 // https://bugs.chromium.org/p/v8/issues/detail?id=3056 2246 var test2 = {}; 2247 for (var i = 0; i < 10; i++) { 2248 test2['_' + String.fromCharCode(i)] = i; 2249 } 2250 var order2 = Object.getOwnPropertyNames(test2).map(function (n) { 2251 return test2[n]; 2252 }); 2253 if (order2.join('') !== '0123456789') { 2254 return false; 2255 } 2256 2257 // https://bugs.chromium.org/p/v8/issues/detail?id=3056 2258 var test3 = {}; 2259 'abcdefghijklmnopqrst'.split('').forEach(function (letter) { 2260 test3[letter] = letter; 2261 }); 2262 if (Object.keys(Object.assign({}, test3)).join('') !== 2263 'abcdefghijklmnopqrst') { 2264 return false; 2265 } 2266 2267 return true; 2268 } catch (err) { 2269 // We don't expect any of the above to throw, but better to be safe. 2270 return false; 2271 } 2272} 2273 2274module.exports = shouldUseNative() ? Object.assign : function (target, source) { 2275 var from; 2276 var to = toObject(target); 2277 var symbols; 2278 2279 for (var s = 1; s < arguments.length; s++) { 2280 from = Object(arguments[s]); 2281 2282 for (var key in from) { 2283 if (hasOwnProperty.call(from, key)) { 2284 to[key] = from[key]; 2285 } 2286 } 2287 2288 if (getOwnPropertySymbols) { 2289 symbols = getOwnPropertySymbols(from); 2290 for (var i = 0; i < symbols.length; i++) { 2291 if (propIsEnumerable.call(from, symbols[i])) { 2292 to[symbols[i]] = from[symbols[i]]; 2293 } 2294 } 2295 } 2296 } 2297 2298 return to; 2299}; 2300 2301 2302/***/ }), 2303
vendor: 5,636 bytes, lines 2304-2497
2304/***/ "./node_modules/process/browser.js": 2305/*!*****************************************!*\ 2306 !*** ./node_modules/process/browser.js ***! 2307 \*****************************************/ 2308/***/ ((module) => { 2309 2310// shim for using process in browser 2311var process = module.exports = {}; 2312 2313// cached from whatever global is present so that test runners that stub it 2314// don't break things. But we need to wrap it in a try catch in case it is 2315// wrapped in strict mode code which doesn't define any globals. It's inside a 2316// function because try/catches deoptimize in certain engines. 2317 2318var cachedSetTimeout; 2319var cachedClearTimeout; 2320 2321function defaultSetTimout() { 2322 throw new Error('setTimeout has not been defined'); 2323} 2324function defaultClearTimeout () { 2325 throw new Error('clearTimeout has not been defined'); 2326} 2327(function () { 2328 try { 2329 if (typeof setTimeout === 'function') { 2330 cachedSetTimeout = setTimeout; 2331 } else { 2332 cachedSetTimeout = defaultSetTimout; 2333 } 2334 } catch (e) { 2335 cachedSetTimeout = defaultSetTimout; 2336 } 2337 try { 2338 if (typeof clearTimeout === 'function') { 2339 cachedClearTimeout = clearTimeout; 2340 } else { 2341 cachedClearTimeout = defaultClearTimeout; 2342 } 2343 } catch (e) { 2344 cachedClearTimeout = defaultClearTimeout; 2345 } 2346} ()) 2347function runTimeout(fun) { 2348 if (cachedSetTimeout === setTimeout) { 2349 //normal enviroments in sane situations 2350 return setTimeout(fun, 0); 2351 } 2352 // if setTimeout wasn't available but was latter defined 2353 if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { 2354 cachedSetTimeout = setTimeout; 2355 return setTimeout(fun, 0); 2356 } 2357 try { 2358 // when when somebody has screwed with setTimeout but no I.E. maddness 2359 return cachedSetTimeout(fun, 0); 2360 } catch(e){ 2361 try { 2362 // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally 2363 return cachedSetTimeout.call(null, fun, 0); 2364 } catch(e){ 2365 // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error 2366 return cachedSetTimeout.call(this, fun, 0); 2367 } 2368 } 2369 2370 2371} 2372function runClearTimeout(marker) { 2373 if (cachedClearTimeout === clearTimeout) { 2374 //normal enviroments in sane situations 2375 return clearTimeout(marker); 2376 } 2377 // if clearTimeout wasn't available but was latter defined 2378 if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { 2379 cachedClearTimeout = clearTimeout; 2380 return clearTimeout(marker); 2381 } 2382 try { 2383 // when when somebody has screwed with setTimeout but no I.E. maddness 2384 return cachedClearTimeout(marker); 2385 } catch (e){ 2386 try { 2387 // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally 2388 return cachedClearTimeout.call(null, marker); 2389 } catch (e){ 2390 // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error. 2391 // Some versions of I.E. have different rules for clearTimeout vs setTimeout 2392 return cachedClearTimeout.call(this, marker); 2393 } 2394 } 2395 2396 2397 2398} 2399var queue = []; 2400var draining = false; 2401var currentQueue; 2402var queueIndex = -1; 2403 2404function cleanUpNextTick() { 2405 if (!draining || !currentQueue) { 2406 return; 2407 } 2408 draining = false; 2409 if (currentQueue.length) { 2410 queue = currentQueue.concat(queue); 2411 } else { 2412 queueIndex = -1; 2413 } 2414 if (queue.length) { 2415 drainQueue(); 2416 } 2417} 2418 2419function drainQueue() { 2420 if (draining) { 2421 return; 2422 } 2423 var timeout = runTimeout(cleanUpNextTick); 2424 draining = true; 2425 2426 var len = queue.length; 2427 while(len) { 2428 currentQueue = queue; 2429 queue = []; 2430 while (++queueIndex < len) { 2431 if (currentQueue) { 2432 currentQueue[queueIndex].run(); 2433 } 2434 } 2435 queueIndex = -1; 2436 len = queue.length; 2437 } 2438 currentQueue = null; 2439 draining = false; 2440 runClearTimeout(timeout); 2441} 2442 2443process.nextTick = function (fun) { 2444 var args = new Array(arguments.length - 1); 2445 if (arguments.length > 1) { 2446 for (var i = 1; i < arguments.length; i++) { 2447 args[i - 1] = arguments[i]; 2448 } 2449 } 2450 queue.push(new Item(fun, args)); 2451 if (queue.length === 1 && !draining) { 2452 runTimeout(drainQueue); 2453 } 2454}; 2455 2456// v8 likes predictible objects 2457function Item(fun, array) { 2458 this.fun = fun; 2459 this.array = array; 2460} 2461Item.prototype.run = function () { 2462 this.fun.apply(null, this.array); 2463}; 2464process.title = 'browser'; 2465process.browser = true; 2466process.env = {}; 2467process.argv = []; 2468process.version = ''; // empty string to avoid regexp issues 2469process.versions = {}; 2470 2471function noop() {} 2472 2473process.on = noop; 2474process.addListener = noop; 2475process.once = noop; 2476process.off = noop; 2477process.removeListener = noop; 2478process.removeAllListeners = noop; 2479process.emit = noop; 2480process.prependListener = noop; 2481process.prependOnceListener = noop; 2482 2483process.listeners = function (name) { return [] } 2484 2485process.binding = function (name) { 2486 throw new Error('process.binding is not supported'); 2487}; 2488 2489process.cwd = function () { return '/' }; 2490process.chdir = function (dir) { 2491 throw new Error('process.chdir is not supported'); 2492}; 2493process.umask = function() { return 0; }; 2494 2495 2496/***/ }), 2497
vendor: 894,764 bytes, lines 2498-28765
2498/***/ "./node_modules/react-dom/cjs/react-dom.development.js": 2499/*!*************************************************************!*\ 2500 !*** ./node_modules/react-dom/cjs/react-dom.development.js ***! 2501 \*************************************************************/ 2502/***/ ((__unused_webpack_module, exports, __webpack_require__) => { 2503 2504"use strict"; 2505/** @license React v17.0.2 2506 * react-dom.development.js 2507 * 2508 * Copyright (c) Facebook, Inc. and its affiliates. 2509 * 2510 * This source code is licensed under the MIT license found in the 2511 * LICENSE file in the root directory of this source tree. 2512 */ 2513 2514 2515 2516if (true) { 2517 (function() { 2518'use strict'; 2519 2520var React = __webpack_require__(/*! react */ "./node_modules/react/index.js"); 2521var _assign = __webpack_require__(/*! object-assign */ "./node_modules/object-assign/index.js"); 2522var Scheduler = __webpack_require__(/*! scheduler */ "./node_modules/scheduler/index.js"); 2523var tracing = __webpack_require__(/*! scheduler/tracing */ "./node_modules/scheduler/tracing.js"); 2524 2525var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; 2526 2527// by calls to these methods by a Babel plugin. 2528// 2529// In PROD (or in packages without access to React internals), 2530// they are left as they are instead. 2531 2532function warn(format) { 2533 { 2534 for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { 2535 args[_key - 1] = arguments[_key]; 2536 } 2537 2538 printWarning('warn', format, args); 2539 } 2540} 2541function error(format) { 2542 { 2543 for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { 2544 args[_key2 - 1] = arguments[_key2]; 2545 } 2546 2547 printWarning('error', format, args); 2548 } 2549} 2550 2551function printWarning(level, format, args) { 2552 // When changing this logic, you might want to also 2553 // update consoleWithStackDev.www.js as well. 2554 { 2555 var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; 2556 var stack = ReactDebugCurrentFrame.getStackAddendum(); 2557 2558 if (stack !== '') { 2559 format += '%s'; 2560 args = args.concat([stack]); 2561 } 2562 2563 var argsWithFormat = args.map(function (item) { 2564 return '' + item; 2565 }); // Careful: RN currently depends on this prefix 2566 2567 argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it 2568 // breaks IE9: https://github.com/facebook/react/issues/13610 2569 // eslint-disable-next-line react-internal/no-production-logging 2570 2571 Function.prototype.apply.call(console[level], console, argsWithFormat); 2572 } 2573} 2574 2575if (!React) { 2576 { 2577 throw Error( "ReactDOM was loaded before React. Make sure you load the React package before loading ReactDOM." ); 2578 } 2579} 2580 2581var FunctionComponent = 0; 2582var ClassComponent = 1; 2583var IndeterminateComponent = 2; // Before we know whether it is function or class 2584 2585var HostRoot = 3; // Root of a host tree. Could be nested inside another node. 2586 2587var HostPortal = 4; // A subtree. Could be an entry point to a different renderer. 2588 2589var HostComponent = 5; 2590var HostText = 6; 2591var Fragment = 7; 2592var Mode = 8; 2593var ContextConsumer = 9; 2594var ContextProvider = 10; 2595var ForwardRef = 11; 2596var Profiler = 12; 2597var SuspenseComponent = 13; 2598var MemoComponent = 14; 2599var SimpleMemoComponent = 15; 2600var LazyComponent = 16; 2601var IncompleteClassComponent = 17; 2602var DehydratedFragment = 18; 2603var SuspenseListComponent = 19; 2604var FundamentalComponent = 20; 2605var ScopeComponent = 21; 2606var Block = 22; 2607var OffscreenComponent = 23; 2608var LegacyHiddenComponent = 24; 2609 2610// Filter certain DOM attributes (e.g. src, href) if their values are empty strings. 2611 2612var enableProfilerTimer = true; // Record durations for commit and passive effects phases. 2613 2614var enableFundamentalAPI = false; // Experimental Scope support. 2615var enableNewReconciler = false; // Errors that are thrown while unmounting (or after in the case of passive effects) 2616var warnAboutStringRefs = false; 2617 2618var allNativeEvents = new Set(); 2619/** 2620 * Mapping from registration name to event name 2621 */ 2622 2623 2624var registrationNameDependencies = {}; 2625/** 2626 * Mapping from lowercase registration names to the properly cased version, 2627 * used to warn in the case of missing event handlers. Available 2628 * only in true. 2629 * @type {Object} 2630 */ 2631 2632var possibleRegistrationNames = {} ; // Trust the developer to only use possibleRegistrationNames in true 2633 2634function registerTwoPhaseEvent(registrationName, dependencies) { 2635 registerDirectEvent(registrationName, dependencies); 2636 registerDirectEvent(registrationName + 'Capture', dependencies); 2637} 2638function registerDirectEvent(registrationName, dependencies) { 2639 { 2640 if (registrationNameDependencies[registrationName]) { 2641 error('EventRegistry: More than one plugin attempted to publish the same ' + 'registration name, `%s`.', registrationName); 2642 } 2643 } 2644 2645 registrationNameDependencies[registrationName] = dependencies; 2646 2647 { 2648 var lowerCasedName = registrationName.toLowerCase(); 2649 possibleRegistrationNames[lowerCasedName] = registrationName; 2650 2651 if (registrationName === 'onDoubleClick') { 2652 possibleRegistrationNames.ondblclick = registrationName; 2653 } 2654 } 2655 2656 for (var i = 0; i < dependencies.length; i++) { 2657 allNativeEvents.add(dependencies[i]); 2658 } 2659} 2660 2661var canUseDOM = !!(typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined'); 2662 2663// A reserved attribute. 2664// It is handled by React separately and shouldn't be written to the DOM. 2665var RESERVED = 0; // A simple string attribute. 2666// Attributes that aren't in the filter are presumed to have this type. 2667 2668var STRING = 1; // A string attribute that accepts booleans in React. In HTML, these are called 2669// "enumerated" attributes with "true" and "false" as possible values. 2670// When true, it should be set to a "true" string. 2671// When false, it should be set to a "false" string. 2672 2673var BOOLEANISH_STRING = 2; // A real boolean attribute. 2674// When true, it should be present (set either to an empty string or its name). 2675// When false, it should be omitted. 2676 2677var BOOLEAN = 3; // An attribute that can be used as a flag as well as with a value. 2678// When true, it should be present (set either to an empty string or its name). 2679// When false, it should be omitted. 2680// For any other value, should be present with that value. 2681 2682var OVERLOADED_BOOLEAN = 4; // An attribute that must be numeric or parse as a numeric. 2683// When falsy, it should be removed. 2684 2685var NUMERIC = 5; // An attribute that must be positive numeric or parse as a positive numeric. 2686// When falsy, it should be removed. 2687 2688var POSITIVE_NUMERIC = 6; 2689 2690/* eslint-disable max-len */ 2691var 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"; 2692/* eslint-enable max-len */ 2693 2694var ATTRIBUTE_NAME_CHAR = ATTRIBUTE_NAME_START_CHAR + "\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040"; 2695var ROOT_ATTRIBUTE_NAME = 'data-reactroot'; 2696var VALID_ATTRIBUTE_NAME_REGEX = new RegExp('^[' + ATTRIBUTE_NAME_START_CHAR + '][' + ATTRIBUTE_NAME_CHAR + ']*$'); 2697var hasOwnProperty = Object.prototype.hasOwnProperty; 2698var illegalAttributeNameCache = {}; 2699var validatedAttributeNameCache = {}; 2700function isAttributeNameSafe(attributeName) { 2701 if (hasOwnProperty.call(validatedAttributeNameCache, attributeName)) { 2702 return true; 2703 } 2704 2705 if (hasOwnProperty.call(illegalAttributeNameCache, attributeName)) { 2706 return false; 2707 } 2708 2709 if (VALID_ATTRIBUTE_NAME_REGEX.test(attributeName)) { 2710 validatedAttributeNameCache[attributeName] = true; 2711 return true; 2712 } 2713 2714 illegalAttributeNameCache[attributeName] = true; 2715 2716 { 2717 error('Invalid attribute name: `%s`', attributeName); 2718 } 2719 2720 return false; 2721} 2722function shouldIgnoreAttribute(name, propertyInfo, isCustomComponentTag) { 2723 if (propertyInfo !== null) { 2724 return propertyInfo.type === RESERVED; 2725 } 2726 2727 if (isCustomComponentTag) { 2728 return false; 2729 } 2730 2731 if (name.length > 2 && (name[0] === 'o' || name[0] === 'O') && (name[1] === 'n' || name[1] === 'N')) { 2732 return true; 2733 } 2734 2735 return false; 2736} 2737function shouldRemoveAttributeWithWarning(name, value, propertyInfo, isCustomComponentTag) { 2738 if (propertyInfo !== null && propertyInfo.type === RESERVED) { 2739 return false; 2740 } 2741 2742 switch (typeof value) { 2743 case 'function': // $FlowIssue symbol is perfectly valid here 2744 2745 case 'symbol': 2746 // eslint-disable-line 2747 return true; 2748 2749 case 'boolean': 2750 { 2751 if (isCustomComponentTag) { 2752 return false; 2753 } 2754 2755 if (propertyInfo !== null) { 2756 return !propertyInfo.acceptsBooleans; 2757 } else { 2758 var prefix = name.toLowerCase().slice(0, 5); 2759 return prefix !== 'data-' && prefix !== 'aria-'; 2760 } 2761 } 2762 2763 default: 2764 return false; 2765 } 2766} 2767function shouldRemoveAttribute(name, value, propertyInfo, isCustomComponentTag) { 2768 if (value === null || typeof value === 'undefined') { 2769 return true; 2770 } 2771 2772 if (shouldRemoveAttributeWithWarning(name, value, propertyInfo, isCustomComponentTag)) { 2773 return true; 2774 } 2775 2776 if (isCustomComponentTag) { 2777 return false; 2778 } 2779 2780 if (propertyInfo !== null) { 2781 2782 switch (propertyInfo.type) { 2783 case BOOLEAN: 2784 return !value; 2785 2786 case OVERLOADED_BOOLEAN: 2787 return value === false; 2788 2789 case NUMERIC: 2790 return isNaN(value); 2791 2792 case POSITIVE_NUMERIC: 2793 return isNaN(value) || value < 1; 2794 } 2795 } 2796 2797 return false; 2798} 2799function getPropertyInfo(name) { 2800 return properties.hasOwnProperty(name) ? properties[name] : null; 2801} 2802 2803function PropertyInfoRecord(name, type, mustUseProperty, attributeName, attributeNamespace, sanitizeURL, removeEmptyString) { 2804 this.acceptsBooleans = type === BOOLEANISH_STRING || type === BOOLEAN || type === OVERLOADED_BOOLEAN; 2805 this.attributeName = attributeName; 2806 this.attributeNamespace = attributeNamespace; 2807 this.mustUseProperty = mustUseProperty; 2808 this.propertyName = name; 2809 this.type = type; 2810 this.sanitizeURL = sanitizeURL; 2811 this.removeEmptyString = removeEmptyString; 2812} // When adding attributes to this list, be sure to also add them to 2813// the `possibleStandardNames` module to ensure casing and incorrect 2814// name warnings. 2815 2816 2817var properties = {}; // These props are reserved by React. They shouldn't be written to the DOM. 2818 2819var reservedProps = ['children', 'dangerouslySetInnerHTML', // TODO: This prevents the assignment of defaultValue to regular 2820// elements (not just inputs). Now that ReactDOMInput assigns to the 2821// defaultValue property -- do we need this? 2822'defaultValue', 'defaultChecked', 'innerHTML', 'suppressContentEditableWarning', 'suppressHydrationWarning', 'style']; 2823reservedProps.forEach(function (name) { 2824 properties[name] = new PropertyInfoRecord(name, RESERVED, false, // mustUseProperty 2825 name, // attributeName 2826 null, // attributeNamespace 2827 false, // sanitizeURL 2828 false); 2829}); // A few React string attributes have a different name. 2830// This is a mapping from React prop names to the attribute names. 2831 2832[['acceptCharset', 'accept-charset'], ['className', 'class'], ['htmlFor', 'for'], ['httpEquiv', 'http-equiv']].forEach(function (_ref) { 2833 var name = _ref[0], 2834 attributeName = _ref[1]; 2835 properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty 2836 attributeName, // attributeName 2837 null, // attributeNamespace 2838 false, // sanitizeURL 2839 false); 2840}); // These are "enumerated" HTML attributes that accept "true" and "false". 2841// In React, we let users pass `true` and `false` even though technically 2842// these aren't boolean attributes (they are coerced to strings). 2843 2844['contentEditable', 'draggable', 'spellCheck', 'value'].forEach(function (name) { 2845 properties[name] = new PropertyInfoRecord(name, BOOLEANISH_STRING, false, // mustUseProperty 2846 name.toLowerCase(), // attributeName 2847 null, // attributeNamespace 2848 false, // sanitizeURL 2849 false); 2850}); // These are "enumerated" SVG attributes that accept "true" and "false". 2851// In React, we let users pass `true` and `false` even though technically 2852// these aren't boolean attributes (they are coerced to strings). 2853// Since these are SVG attributes, their attribute names are case-sensitive. 2854 2855['autoReverse', 'externalResourcesRequired', 'focusable', 'preserveAlpha'].forEach(function (name) { 2856 properties[name] = new PropertyInfoRecord(name, BOOLEANISH_STRING, false, // mustUseProperty 2857 name, // attributeName 2858 null, // attributeNamespace 2859 false, // sanitizeURL 2860 false); 2861}); // These are HTML boolean attributes. 2862 2863['allowFullScreen', 'async', // Note: there is a special case that prevents it from being written to the DOM 2864// on the client side because the browsers are inconsistent. Instead we call focus(). 2865'autoFocus', 'autoPlay', 'controls', 'default', 'defer', 'disabled', 'disablePictureInPicture', 'disableRemotePlayback', 'formNoValidate', 'hidden', 'loop', 'noModule', 'noValidate', 'open', 'playsInline', 'readOnly', 'required', 'reversed', 'scoped', 'seamless', // Microdata 2866'itemScope'].forEach(function (name) { 2867 properties[name] = new PropertyInfoRecord(name, BOOLEAN, false, // mustUseProperty 2868 name.toLowerCase(), // attributeName 2869 null, // attributeNamespace 2870 false, // sanitizeURL 2871 false); 2872}); // These are the few React props that we set as DOM properties 2873// rather than attributes. These are all booleans. 2874 2875['checked', // Note: `option.selected` is not updated if `select.multiple` is 2876// disabled with `removeAttribute`. We have special logic for handling this. 2877'multiple', 'muted', 'selected' // NOTE: if you add a camelCased prop to this list, 2878// you'll need to set attributeName to name.toLowerCase() 2879// instead in the assignment below. 2880].forEach(function (name) { 2881 properties[name] = new PropertyInfoRecord(name, BOOLEAN, true, // mustUseProperty 2882 name, // attributeName 2883 null, // attributeNamespace 2884 false, // sanitizeURL 2885 false); 2886}); // These are HTML attributes that are "overloaded booleans": they behave like 2887// booleans, but can also accept a string value. 2888 2889['capture', 'download' // NOTE: if you add a camelCased prop to this list, 2890// you'll need to set attributeName to name.toLowerCase() 2891// instead in the assignment below. 2892].forEach(function (name) { 2893 properties[name] = new PropertyInfoRecord(name, OVERLOADED_BOOLEAN, false, // mustUseProperty 2894 name, // attributeName 2895 null, // attributeNamespace 2896 false, // sanitizeURL 2897 false); 2898}); // These are HTML attributes that must be positive numbers. 2899 2900['cols', 'rows', 'size', 'span' // NOTE: if you add a camelCased prop to this list, 2901// you'll need to set attributeName to name.toLowerCase() 2902// instead in the assignment below. 2903].forEach(function (name) { 2904 properties[name] = new PropertyInfoRecord(name, POSITIVE_NUMERIC, false, // mustUseProperty 2905 name, // attributeName 2906 null, // attributeNamespace 2907 false, // sanitizeURL 2908 false); 2909}); // These are HTML attributes that must be numbers. 2910 2911['rowSpan', 'start'].forEach(function (name) { 2912 properties[name] = new PropertyInfoRecord(name, NUMERIC, false, // mustUseProperty 2913 name.toLowerCase(), // attributeName 2914 null, // attributeNamespace 2915 false, // sanitizeURL 2916 false); 2917}); 2918var CAMELIZE = /[\-\:]([a-z])/g; 2919 2920var capitalize = function (token) { 2921 return token[1].toUpperCase(); 2922}; // This is a list of all SVG attributes that need special casing, namespacing, 2923// or boolean value assignment. Regular attributes that just accept strings 2924// and have the same names are omitted, just like in the HTML attribute filter. 2925// Some of these attributes can be hard to find. This list was created by 2926// scraping the MDN documentation. 2927 2928 2929['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, 2930// you'll need to set attributeName to name.toLowerCase() 2931// instead in the assignment below. 2932].forEach(function (attributeName) { 2933 var name = attributeName.replace(CAMELIZE, capitalize); 2934 properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty 2935 attributeName, null, // attributeNamespace 2936 false, // sanitizeURL 2937 false); 2938}); // String SVG attributes with the xlink namespace. 2939 2940['xlink:actuate', 'xlink:arcrole', 'xlink:role', 'xlink:show', 'xlink:title', 'xlink:type' // NOTE: if you add a camelCased prop to this list, 2941// you'll need to set attributeName to name.toLowerCase() 2942// instead in the assignment below. 2943].forEach(function (attributeName) { 2944 var name = attributeName.replace(CAMELIZE, capitalize); 2945 properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty 2946 attributeName, 'http://www.w3.org/1999/xlink', false, // sanitizeURL 2947 false); 2948}); // String SVG attributes with the xml namespace. 2949 2950['xml:base', 'xml:lang', 'xml:space' // NOTE: if you add a camelCased prop to this list, 2951// you'll need to set attributeName to name.toLowerCase() 2952// instead in the assignment below. 2953].forEach(function (attributeName) { 2954 var name = attributeName.replace(CAMELIZE, capitalize); 2955 properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty 2956 attributeName, 'http://www.w3.org/XML/1998/namespace', false, // sanitizeURL 2957 false); 2958}); // These attribute exists both in HTML and SVG. 2959// The attribute name is case-sensitive in SVG so we can't just use 2960// the React name like we do for attributes that exist only in HTML. 2961 2962['tabIndex', 'crossOrigin'].forEach(function (attributeName) { 2963 properties[attributeName] = new PropertyInfoRecord(attributeName, STRING, false, // mustUseProperty 2964 attributeName.toLowerCase(), // attributeName 2965 null, // attributeNamespace 2966 false, // sanitizeURL 2967 false); 2968}); // These attributes accept URLs. These must not allow javascript: URLS. 2969// These will also need to accept Trusted Types object in the future. 2970 2971var xlinkHref = 'xlinkHref'; 2972properties[xlinkHref] = new PropertyInfoRecord('xlinkHref', STRING, false, // mustUseProperty 2973'xlink:href', 'http://www.w3.org/1999/xlink', true, // sanitizeURL 2974false); 2975['src', 'href', 'action', 'formAction'].forEach(function (attributeName) { 2976 properties[attributeName] = new PropertyInfoRecord(attributeName, STRING, false, // mustUseProperty 2977 attributeName.toLowerCase(), // attributeName 2978 null, // attributeNamespace 2979 true, // sanitizeURL 2980 true); 2981}); 2982 2983// and any newline or tab are filtered out as if they're not part of the URL. 2984// https://url.spec.whatwg.org/#url-parsing 2985// Tab or newline are defined as \r\n\t: 2986// https://infra.spec.whatwg.org/#ascii-tab-or-newline 2987// A C0 control is a code point in the range \u0000 NULL to \u001F 2988// INFORMATION SEPARATOR ONE, inclusive: 2989// https://infra.spec.whatwg.org/#c0-control-or-space 2990 2991/* eslint-disable max-len */ 2992 2993var 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; 2994var didWarn = false; 2995 2996function sanitizeURL(url) { 2997 { 2998 if (!didWarn && isJavaScriptProtocol.test(url)) { 2999 didWarn = true; 3000 3001 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)); 3002 } 3003 } 3004} 3005 3006/** 3007 * Get the value for a property on a node. Only used in DEV for SSR validation. 3008 * The "expected" argument is used as a hint of what the expected value is. 3009 * Some properties have multiple equivalent values. 3010 */ 3011function getValueForProperty(node, name, expected, propertyInfo) { 3012 { 3013 if (propertyInfo.mustUseProperty) { 3014 var propertyName = propertyInfo.propertyName; 3015 return node[propertyName]; 3016 } else { 3017 if ( propertyInfo.sanitizeURL) { 3018 // If we haven't fully disabled javascript: URLs, and if 3019 // the hydration is successful of a javascript: URL, we 3020 // still want to warn on the client. 3021 sanitizeURL('' + expected); 3022 } 3023 3024 var attributeName = propertyInfo.attributeName; 3025 var stringValue = null; 3026 3027 if (propertyInfo.type === OVERLOADED_BOOLEAN) { 3028 if (node.hasAttribute(attributeName)) { 3029 var value = node.getAttribute(attributeName); 3030 3031 if (value === '') { 3032 return true; 3033 } 3034 3035 if (shouldRemoveAttribute(name, expected, propertyInfo, false)) { 3036 return value; 3037 } 3038 3039 if (value === '' + expected) { 3040 return expected; 3041 } 3042 3043 return value; 3044 } 3045 } else if (node.hasAttribute(attributeName)) { 3046 if (shouldRemoveAttribute(name, expected, propertyInfo, false)) { 3047 // We had an attribute but shouldn't have had one, so read it 3048 // for the error message. 3049 return node.getAttribute(attributeName); 3050 } 3051 3052 if (propertyInfo.type === BOOLEAN) { 3053 // If this was a boolean, it doesn't matter what the value is 3054 // the fact that we have it is the same as the expected. 3055 return expected; 3056 } // Even if this property uses a namespace we use getAttribute 3057 // because we assume its namespaced name is the same as our config. 3058 // To use getAttributeNS we need the local name which we don't have 3059 // in our config atm. 3060 3061 3062 stringValue = node.getAttribute(attributeName); 3063 } 3064 3065 if (shouldRemoveAttribute(name, expected, propertyInfo, false)) { 3066 return stringValue === null ? expected : stringValue; 3067 } else if (stringValue === '' + expected) { 3068 return expected; 3069 } else { 3070 return stringValue; 3071 } 3072 } 3073 } 3074} 3075/** 3076 * Get the value for a attribute on a node. Only used in DEV for SSR validation. 3077 * The third argument is used as a hint of what the expected value is. Some 3078 * attributes have multiple equivalent values. 3079 */ 3080 3081function getValueForAttribute(node, name, expected) { 3082 { 3083 if (!isAttributeNameSafe(name)) { 3084 return; 3085 } // If the object is an opaque reference ID, it's expected that 3086 // the next prop is different than the server value, so just return 3087 // expected 3088 3089 3090 if (isOpaqueHydratingObject(expected)) { 3091 return expected; 3092 } 3093 3094 if (!node.hasAttribute(name)) { 3095 return expected === undefined ? undefined : null; 3096 } 3097 3098 var value = node.getAttribute(name); 3099 3100 if (value === '' + expected) { 3101 return expected; 3102 } 3103 3104 return value; 3105 } 3106} 3107/** 3108 * Sets the value for a property on a node. 3109 * 3110 * @param {DOMElement} node 3111 * @param {string} name 3112 * @param {*} value 3113 */ 3114 3115function setValueForProperty(node, name, value, isCustomComponentTag) { 3116 var propertyInfo = getPropertyInfo(name); 3117 3118 if (shouldIgnoreAttribute(name, propertyInfo, isCustomComponentTag)) { 3119 return; 3120 } 3121 3122 if (shouldRemoveAttribute(name, value, propertyInfo, isCustomComponentTag)) { 3123 value = null; 3124 } // If the prop isn't in the special list, treat it as a simple attribute. 3125 3126 3127 if (isCustomComponentTag || propertyInfo === null) { 3128 if (isAttributeNameSafe(name)) { 3129 var _attributeName = name; 3130 3131 if (value === null) { 3132 node.removeAttribute(_attributeName); 3133 } else { 3134 node.setAttribute(_attributeName, '' + value); 3135 } 3136 } 3137 3138 return; 3139 } 3140 3141 var mustUseProperty = propertyInfo.mustUseProperty; 3142 3143 if (mustUseProperty) { 3144 var propertyName = propertyInfo.propertyName; 3145 3146 if (value === null) { 3147 var type = propertyInfo.type; 3148 node[propertyName] = type === BOOLEAN ? false : ''; 3149 } else { 3150 // Contrary to `setAttribute`, object properties are properly 3151 // `toString`ed by IE8/9. 3152 node[propertyName] = value; 3153 } 3154 3155 return; 3156 } // The rest are treated as attributes with special cases. 3157 3158 3159 var attributeName = propertyInfo.attributeName, 3160 attributeNamespace = propertyInfo.attributeNamespace; 3161 3162 if (value === null) { 3163 node.removeAttribute(attributeName); 3164 } else { 3165 var _type = propertyInfo.type; 3166 var attributeValue; 3167 3168 if (_type === BOOLEAN || _type === OVERLOADED_BOOLEAN && value === true) { 3169 // If attribute type is boolean, we know for sure it won't be an execution sink 3170 // and we won't require Trusted Type here. 3171 attributeValue = ''; 3172 } else { 3173 // `setAttribute` with objects becomes only `[object]` in IE8/9, 3174 // ('' + value) makes it output the correct toString()-value. 3175 { 3176 attributeValue = '' + value; 3177 } 3178 3179 if (propertyInfo.sanitizeURL) { 3180 sanitizeURL(attributeValue.toString()); 3181 } 3182 } 3183 3184 if (attributeNamespace) { 3185 node.setAttributeNS(attributeNamespace, attributeName, attributeValue); 3186 } else { 3187 node.setAttribute(attributeName, attributeValue); 3188 } 3189 } 3190} 3191 3192// ATTENTION 3193// When adding new symbols to this file, 3194// Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols' 3195// The Symbol used to tag the ReactElement-like types. If there is no native Symbol 3196// nor polyfill, then a plain number is used for performance. 3197var REACT_ELEMENT_TYPE = 0xeac7; 3198var REACT_PORTAL_TYPE = 0xeaca; 3199var REACT_FRAGMENT_TYPE = 0xeacb; 3200var REACT_STRICT_MODE_TYPE = 0xeacc; 3201var REACT_PROFILER_TYPE = 0xead2; 3202var REACT_PROVIDER_TYPE = 0xeacd; 3203var REACT_CONTEXT_TYPE = 0xeace; 3204var REACT_FORWARD_REF_TYPE = 0xead0; 3205var REACT_SUSPENSE_TYPE = 0xead1; 3206var REACT_SUSPENSE_LIST_TYPE = 0xead8; 3207var REACT_MEMO_TYPE = 0xead3; 3208var REACT_LAZY_TYPE = 0xead4; 3209var REACT_BLOCK_TYPE = 0xead9; 3210var REACT_SERVER_BLOCK_TYPE = 0xeada; 3211var REACT_FUNDAMENTAL_TYPE = 0xead5; 3212var REACT_SCOPE_TYPE = 0xead7; 3213var REACT_OPAQUE_ID_TYPE = 0xeae0; 3214var REACT_DEBUG_TRACING_MODE_TYPE = 0xeae1; 3215var REACT_OFFSCREEN_TYPE = 0xeae2; 3216var REACT_LEGACY_HIDDEN_TYPE = 0xeae3; 3217 3218if (typeof Symbol === 'function' && Symbol.for) { 3219 var symbolFor = Symbol.for; 3220 REACT_ELEMENT_TYPE = symbolFor('react.element'); 3221 REACT_PORTAL_TYPE = symbolFor('react.portal'); 3222 REACT_FRAGMENT_TYPE = symbolFor('react.fragment'); 3223 REACT_STRICT_MODE_TYPE = symbolFor('react.strict_mode'); 3224 REACT_PROFILER_TYPE = symbolFor('react.profiler'); 3225 REACT_PROVIDER_TYPE = symbolFor('react.provider'); 3226 REACT_CONTEXT_TYPE = symbolFor('react.context'); 3227 REACT_FORWARD_REF_TYPE = symbolFor('react.forward_ref'); 3228 REACT_SUSPENSE_TYPE = symbolFor('react.suspense'); 3229 REACT_SUSPENSE_LIST_TYPE = symbolFor('react.suspense_list'); 3230 REACT_MEMO_TYPE = symbolFor('react.memo'); 3231 REACT_LAZY_TYPE = symbolFor('react.lazy'); 3232 REACT_BLOCK_TYPE = symbolFor('react.block'); 3233 REACT_SERVER_BLOCK_TYPE = symbolFor('react.server.block'); 3234 REACT_FUNDAMENTAL_TYPE = symbolFor('react.fundamental'); 3235 REACT_SCOPE_TYPE = symbolFor('react.scope'); 3236 REACT_OPAQUE_ID_TYPE = symbolFor('react.opaque.id'); 3237 REACT_DEBUG_TRACING_MODE_TYPE = symbolFor('react.debug_trace_mode'); 3238 REACT_OFFSCREEN_TYPE = symbolFor('react.offscreen'); 3239 REACT_LEGACY_HIDDEN_TYPE = symbolFor('react.legacy_hidden'); 3240} 3241 3242var MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator; 3243var FAUX_ITERATOR_SYMBOL = '@@iterator'; 3244function getIteratorFn(maybeIterable) { 3245 if (maybeIterable === null || typeof maybeIterable !== 'object') { 3246 return null; 3247 } 3248 3249 var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]; 3250 3251 if (typeof maybeIterator === 'function') { 3252 return maybeIterator; 3253 } 3254 3255 return null; 3256} 3257 3258// Helpers to patch console.logs to avoid logging during side-effect free 3259// replaying on render function. This currently only patches the object 3260// lazily which won't cover if the log function was extracted eagerly. 3261// We could also eagerly patch the method. 3262var disabledDepth = 0; 3263var prevLog; 3264var prevInfo; 3265var prevWarn; 3266var prevError; 3267var prevGroup; 3268var prevGroupCollapsed; 3269var prevGroupEnd; 3270 3271function disabledLog() {} 3272 3273disabledLog.__reactDisabledLog = true; 3274function disableLogs() { 3275 { 3276 if (disabledDepth === 0) { 3277 /* eslint-disable react-internal/no-production-logging */ 3278 prevLog = console.log; 3279 prevInfo = console.info; 3280 prevWarn = console.warn; 3281 prevError = console.error; 3282 prevGroup = console.group; 3283 prevGroupCollapsed = console.groupCollapsed; 3284 prevGroupEnd = console.groupEnd; // https://github.com/facebook/react/issues/19099 3285 3286 var props = { 3287 configurable: true, 3288 enumerable: true, 3289 value: disabledLog, 3290 writable: true 3291 }; // $FlowFixMe Flow thinks console is immutable. 3292 3293 Object.defineProperties(console, { 3294 info: props, 3295 log: props, 3296 warn: props, 3297 error: props, 3298 group: props, 3299 groupCollapsed: props, 3300 groupEnd: props 3301 }); 3302 /* eslint-enable react-internal/no-production-logging */ 3303 } 3304 3305 disabledDepth++; 3306 } 3307} 3308function reenableLogs() { 3309 { 3310 disabledDepth--; 3311 3312 if (disabledDepth === 0) { 3313 /* eslint-disable react-internal/no-production-logging */ 3314 var props = { 3315 configurable: true, 3316 enumerable: true, 3317 writable: true 3318 }; // $FlowFixMe Flow thinks console is immutable. 3319 3320 Object.defineProperties(console, { 3321 log: _assign({}, props, { 3322 value: prevLog 3323 }), 3324 info: _assign({}, props, { 3325 value: prevInfo 3326 }), 3327 warn: _assign({}, props, { 3328 value: prevWarn 3329 }), 3330 error: _assign({}, props, { 3331 value: prevError 3332 }), 3333 group: _assign({}, props, { 3334 value: prevGroup 3335 }), 3336 groupCollapsed: _assign({}, props, { 3337 value: prevGroupCollapsed 3338 }), 3339 groupEnd: _assign({}, props, { 3340 value: prevGroupEnd 3341 }) 3342 }); 3343 /* eslint-enable react-internal/no-production-logging */ 3344 } 3345 3346 if (disabledDepth < 0) { 3347 error('disabledDepth fell below zero. ' + 'This is a bug in React. Please file an issue.'); 3348 } 3349 } 3350} 3351 3352var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher; 3353var prefix; 3354function describeBuiltInComponentFrame(name, source, ownerFn) { 3355 { 3356 if (prefix === undefined) { 3357 // Extract the VM specific prefix used by each line. 3358 try { 3359 throw Error(); 3360 } catch (x) { 3361 var match = x.stack.trim().match(/\n( *(at )?)/); 3362 prefix = match && match[1] || ''; 3363 } 3364 } // We use the prefix to ensure our stacks line up with native stack frames. 3365 3366 3367 return '\n' + prefix + name; 3368 } 3369} 3370var reentry = false; 3371var componentFrameCache; 3372 3373{ 3374 var PossiblyWeakMap = typeof WeakMap === 'function' ? WeakMap : Map; 3375 componentFrameCache = new PossiblyWeakMap(); 3376} 3377 3378function describeNativeComponentFrame(fn, construct) { 3379 // If something asked for a stack inside a fake render, it should get ignored. 3380 if (!fn || reentry) { 3381 return ''; 3382 } 3383 3384 { 3385 var frame = componentFrameCache.get(fn); 3386 3387 if (frame !== undefined) { 3388 return frame; 3389 } 3390 } 3391 3392 var control; 3393 reentry = true; 3394 var previousPrepareStackTrace = Error.prepareStackTrace; // $FlowFixMe It does accept undefined. 3395 3396 Error.prepareStackTrace = undefined; 3397 var previousDispatcher; 3398 3399 { 3400 previousDispatcher = ReactCurrentDispatcher.current; // Set the dispatcher in DEV because this might be call in the render function 3401 // for warnings. 3402 3403 ReactCurrentDispatcher.current = null; 3404 disableLogs(); 3405 } 3406 3407 try { 3408 // This should throw. 3409 if (construct) { 3410 // Something should be setting the props in the constructor. 3411 var Fake = function () { 3412 throw Error(); 3413 }; // $FlowFixMe 3414 3415 3416 Object.defineProperty(Fake.prototype, 'props', { 3417 set: function () { 3418 // We use a throwing setter instead of frozen or non-writable props 3419 // because that won't throw in a non-strict mode function. 3420 throw Error(); 3421 } 3422 }); 3423 3424 if (typeof Reflect === 'object' && Reflect.construct) { 3425 // We construct a different control for this case to include any extra 3426 // frames added by the construct call. 3427 try { 3428 Reflect.construct(Fake, []); 3429 } catch (x) { 3430 control = x; 3431 } 3432 3433 Reflect.construct(fn, [], Fake); 3434 } else { 3435 try { 3436 Fake.call(); 3437 } catch (x) { 3438 control = x; 3439 } 3440 3441 fn.call(Fake.prototype); 3442 } 3443 } else { 3444 try { 3445 throw Error(); 3446 } catch (x) { 3447 control = x; 3448 } 3449 3450 fn(); 3451 } 3452 } catch (sample) { 3453 // This is inlined manually because closure doesn't do it for us. 3454 if (sample && control && typeof sample.stack === 'string') { 3455 // This extracts the first frame from the sample that isn't also in the control. 3456 // Skipping one frame that we assume is the frame that calls the two. 3457 var sampleLines = sample.stack.split('\n'); 3458 var controlLines = control.stack.split('\n'); 3459 var s = sampleLines.length - 1; 3460 var c = controlLines.length - 1; 3461 3462 while (s >= 1 && c >= 0 && sampleLines[s] !== controlLines[c]) { 3463 // We expect at least one stack frame to be shared. 3464 // Typically this will be the root most one. However, stack frames may be 3465 // cut off due to maximum stack limits. In this case, one maybe cut off 3466 // earlier than the other. We assume that the sample is longer or the same 3467 // and there for cut off earlier. So we should find the root most frame in 3468 // the sample somewhere in the control. 3469 c--; 3470 } 3471 3472 for (; s >= 1 && c >= 0; s--, c--) { 3473 // Next we find the first one that isn't the same which should be the 3474 // frame that called our sample function and the control. 3475 if (sampleLines[s] !== controlLines[c]) { 3476 // In V8, the first line is describing the message but other VMs don't. 3477 // If we're about to return the first line, and the control is also on the same 3478 // line, that's a pretty good indicator that our sample threw at same line as 3479 // the control. I.e. before we entered the sample frame. So we ignore this result. 3480 // This can happen if you passed a class to function component, or non-function. 3481 if (s !== 1 || c !== 1) { 3482 do { 3483 s--; 3484 c--; // We may still have similar intermediate frames from the construct call. 3485 // The next one that isn't the same should be our match though. 3486 3487 if (c < 0 || sampleLines[s] !== controlLines[c]) { 3488 // V8 adds a "new" prefix for native classes. Let's remove it to make it prettier. 3489 var _frame = '\n' + sampleLines[s].replace(' at new ', ' at '); 3490 3491 { 3492 if (typeof fn === 'function') { 3493 componentFrameCache.set(fn, _frame); 3494 } 3495 } // Return the line we found. 3496 3497 3498 return _frame; 3499 } 3500 } while (s >= 1 && c >= 0); 3501 } 3502 3503 break; 3504 } 3505 } 3506 } 3507 } finally { 3508 reentry = false; 3509 3510 { 3511 ReactCurrentDispatcher.current = previousDispatcher; 3512 reenableLogs(); 3513 } 3514 3515 Error.prepareStackTrace = previousPrepareStackTrace; 3516 } // Fallback to just using the name if we couldn't make it throw. 3517 3518 3519 var name = fn ? fn.displayName || fn.name : ''; 3520 var syntheticFrame = name ? describeBuiltInComponentFrame(name) : ''; 3521 3522 { 3523 if (typeof fn === 'function') { 3524 componentFrameCache.set(fn, syntheticFrame); 3525 } 3526 } 3527 3528 return syntheticFrame; 3529} 3530 3531function describeClassComponentFrame(ctor, source, ownerFn) { 3532 { 3533 return describeNativeComponentFrame(ctor, true); 3534 } 3535} 3536function describeFunctionComponentFrame(fn, source, ownerFn) { 3537 { 3538 return describeNativeComponentFrame(fn, false); 3539 } 3540} 3541 3542function shouldConstruct(Component) { 3543 var prototype = Component.prototype; 3544 return !!(prototype && prototype.isReactComponent); 3545} 3546 3547function describeUnknownElementTypeFrameInDEV(type, source, ownerFn) { 3548 3549 if (type == null) { 3550 return ''; 3551 } 3552 3553 if (typeof type === 'function') { 3554 { 3555 return describeNativeComponentFrame(type, shouldConstruct(type)); 3556 } 3557 } 3558 3559 if (typeof type === 'string') { 3560 return describeBuiltInComponentFrame(type); 3561 } 3562 3563 switch (type) { 3564 case REACT_SUSPENSE_TYPE: 3565 return describeBuiltInComponentFrame('Suspense'); 3566 3567 case REACT_SUSPENSE_LIST_TYPE: 3568 return describeBuiltInComponentFrame('SuspenseList'); 3569 } 3570 3571 if (typeof type === 'object') { 3572 switch (type.$$typeof) { 3573 case REACT_FORWARD_REF_TYPE: 3574 return describeFunctionComponentFrame(type.render); 3575 3576 case REACT_MEMO_TYPE: 3577 // Memo may contain any component type so we recursively resolve it. 3578 return describeUnknownElementTypeFrameInDEV(type.type, source, ownerFn); 3579 3580 case REACT_BLOCK_TYPE: 3581 return describeFunctionComponentFrame(type._render); 3582 3583 case REACT_LAZY_TYPE: 3584 { 3585 var lazyComponent = type; 3586 var payload = lazyComponent._payload; 3587 var init = lazyComponent._init; 3588 3589 try { 3590 // Lazy may contain any component type so we recursively resolve it. 3591 return describeUnknownElementTypeFrameInDEV(init(payload), source, ownerFn); 3592 } catch (x) {} 3593 } 3594 } 3595 } 3596 3597 return ''; 3598} 3599 3600function describeFiber(fiber) { 3601 var owner = fiber._debugOwner ? fiber._debugOwner.type : null ; 3602 var source = fiber._debugSource ; 3603 3604 switch (fiber.tag) { 3605 case HostComponent: 3606 return describeBuiltInComponentFrame(fiber.type); 3607 3608 case LazyComponent: 3609 return describeBuiltInComponentFrame('Lazy'); 3610 3611 case SuspenseComponent: 3612 return describeBuiltInComponentFrame('Suspense'); 3613 3614 case SuspenseListComponent: 3615 return describeBuiltInComponentFrame('SuspenseList'); 3616 3617 case FunctionComponent: 3618 case IndeterminateComponent: 3619 case SimpleMemoComponent: 3620 return describeFunctionComponentFrame(fiber.type); 3621 3622 case ForwardRef: 3623 return describeFunctionComponentFrame(fiber.type.render); 3624 3625 case Block: 3626 return describeFunctionComponentFrame(fiber.type._render); 3627 3628 case ClassComponent: 3629 return describeClassComponentFrame(fiber.type); 3630 3631 default: 3632 return ''; 3633 } 3634} 3635 3636function getStackByFiberInDevAndProd(workInProgress) { 3637 try { 3638 var info = ''; 3639 var node = workInProgress; 3640 3641 do { 3642 info += describeFiber(node); 3643 node = node.return; 3644 } while (node); 3645 3646 return info; 3647 } catch (x) { 3648 return '\nError generating stack: ' + x.message + '\n' + x.stack; 3649 } 3650} 3651 3652function getWrappedName(outerType, innerType, wrapperName) { 3653 var functionName = innerType.displayName || innerType.name || ''; 3654 return outerType.displayName || (functionName !== '' ? wrapperName + "(" + functionName + ")" : wrapperName); 3655} 3656 3657function getContextName(type) { 3658 return type.displayName || 'Context'; 3659} 3660 3661function getComponentName(type) { 3662 if (type == null) { 3663 // Host root, text node or just invalid type. 3664 return null; 3665 } 3666 3667 { 3668 if (typeof type.tag === 'number') { 3669 error('Received an unexpected object in getComponentName(). ' + 'This is likely a bug in React. Please file an issue.'); 3670 } 3671 } 3672 3673 if (typeof type === 'function') { 3674 return type.displayName || type.name || null; 3675 } 3676 3677 if (typeof type === 'string') { 3678 return type; 3679 } 3680 3681 switch (type) { 3682 case REACT_FRAGMENT_TYPE: 3683 return 'Fragment'; 3684 3685 case REACT_PORTAL_TYPE: 3686 return 'Portal'; 3687 3688 case REACT_PROFILER_TYPE: 3689 return 'Profiler'; 3690 3691 case REACT_STRICT_MODE_TYPE: 3692 return 'StrictMode'; 3693 3694 case REACT_SUSPENSE_TYPE: 3695 return 'Suspense'; 3696 3697 case REACT_SUSPENSE_LIST_TYPE: 3698 return 'SuspenseList'; 3699 } 3700 3701 if (typeof type === 'object') { 3702 switch (type.$$typeof) { 3703 case REACT_CONTEXT_TYPE: 3704 var context = type; 3705 return getContextName(context) + '.Consumer'; 3706 3707 case REACT_PROVIDER_TYPE: 3708 var provider = type; 3709 return getContextName(provider._context) + '.Provider'; 3710 3711 case REACT_FORWARD_REF_TYPE: 3712 return getWrappedName(type, type.render, 'ForwardRef'); 3713 3714 case REACT_MEMO_TYPE: 3715 return getComponentName(type.type); 3716 3717 case REACT_BLOCK_TYPE: 3718 return getComponentName(type._render); 3719 3720 case REACT_LAZY_TYPE: 3721 { 3722 var lazyComponent = type; 3723 var payload = lazyComponent._payload; 3724 var init = lazyComponent._init; 3725 3726 try { 3727 return getComponentName(init(payload)); 3728 } catch (x) { 3729 return null; 3730 } 3731 } 3732 } 3733 } 3734 3735 return null; 3736} 3737 3738var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; 3739var current = null; 3740var isRendering = false; 3741function getCurrentFiberOwnerNameInDevOrNull() { 3742 { 3743 if (current === null) { 3744 return null; 3745 } 3746 3747 var owner = current._debugOwner; 3748 3749 if (owner !== null && typeof owner !== 'undefined') { 3750 return getComponentName(owner.type); 3751 } 3752 } 3753 3754 return null; 3755} 3756 3757function getCurrentFiberStackInDev() { 3758 { 3759 if (current === null) { 3760 return ''; 3761 } // Safe because if current fiber exists, we are reconciling, 3762 // and it is guaranteed to be the work-in-progress version. 3763 3764 3765 return getStackByFiberInDevAndProd(current); 3766 } 3767} 3768 3769function resetCurrentFiber() { 3770 { 3771 ReactDebugCurrentFrame.getCurrentStack = null; 3772 current = null; 3773 isRendering = false; 3774 } 3775} 3776function setCurrentFiber(fiber) { 3777 { 3778 ReactDebugCurrentFrame.getCurrentStack = getCurrentFiberStackInDev; 3779 current = fiber; 3780 isRendering = false; 3781 } 3782} 3783function setIsRendering(rendering) { 3784 { 3785 isRendering = rendering; 3786 } 3787} 3788function getIsRendering() { 3789 { 3790 return isRendering; 3791 } 3792} 3793 3794// Flow does not allow string concatenation of most non-string types. To work 3795// around this limitation, we use an opaque type that can only be obtained by 3796// passing the value through getToStringValue first. 3797function toString(value) { 3798 return '' + value; 3799} 3800function getToStringValue(value) { 3801 switch (typeof value) { 3802 case 'boolean': 3803 case 'number': 3804 case 'object': 3805 case 'string': 3806 case 'undefined': 3807 return value; 3808 3809 default: 3810 // function, symbol are assigned as empty strings 3811 return ''; 3812 } 3813} 3814 3815var hasReadOnlyValue = { 3816 button: true, 3817 checkbox: true, 3818 image: true, 3819 hidden: true, 3820 radio: true, 3821 reset: true, 3822 submit: true 3823}; 3824function checkControlledValueProps(tagName, props) { 3825 { 3826 if (!(hasReadOnlyValue[props.type] || props.onChange || props.onInput || props.readOnly || props.disabled || props.value == null)) { 3827 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`.'); 3828 } 3829 3830 if (!(props.onChange || props.readOnly || props.disabled || props.checked == null)) { 3831 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`.'); 3832 } 3833 } 3834} 3835 3836function isCheckable(elem) { 3837 var type = elem.type; 3838 var nodeName = elem.nodeName; 3839 return nodeName && nodeName.toLowerCase() === 'input' && (type === 'checkbox' || type === 'radio'); 3840} 3841 3842function getTracker(node) { 3843 return node._valueTracker; 3844} 3845 3846function detachTracker(node) { 3847 node._valueTracker = null; 3848} 3849 3850function getValueFromNode(node) { 3851 var value = ''; 3852 3853 if (!node) { 3854 return value; 3855 } 3856 3857 if (isCheckable(node)) { 3858 value = node.checked ? 'true' : 'false'; 3859 } else { 3860 value = node.value; 3861 } 3862 3863 return value; 3864} 3865 3866function trackValueOnNode(node) { 3867 var valueField = isCheckable(node) ? 'checked' : 'value'; 3868 var descriptor = Object.getOwnPropertyDescriptor(node.constructor.prototype, valueField); 3869 var currentValue = '' + node[valueField]; // if someone has already defined a value or Safari, then bail 3870 // and don't track value will cause over reporting of changes, 3871 // but it's better then a hard failure 3872 // (needed for certain tests that spyOn input values and Safari) 3873 3874 if (node.hasOwnProperty(valueField) || typeof descriptor === 'undefined' || typeof descriptor.get !== 'function' || typeof descriptor.set !== 'function') { 3875 return; 3876 } 3877 3878 var get = descriptor.get, 3879 set = descriptor.set; 3880 Object.defineProperty(node, valueField, { 3881 configurable: true, 3882 get: function () { 3883 return get.call(this); 3884 }, 3885 set: function (value) { 3886 currentValue = '' + value; 3887 set.call(this, value); 3888 } 3889 }); // We could've passed this the first time 3890 // but it triggers a bug in IE11 and Edge 14/15. 3891 // Calling defineProperty() again should be equivalent. 3892 // https://github.com/facebook/react/issues/11768 3893 3894 Object.defineProperty(node, valueField, { 3895 enumerable: descriptor.enumerable 3896 }); 3897 var tracker = { 3898 getValue: function () { 3899 return currentValue; 3900 }, 3901 setValue: function (value) { 3902 currentValue = '' + value; 3903 }, 3904 stopTracking: function () { 3905 detachTracker(node); 3906 delete node[valueField]; 3907 } 3908 }; 3909 return tracker; 3910} 3911 3912function track(node) { 3913 if (getTracker(node)) { 3914 return; 3915 } // TODO: Once it's just Fiber we can move this to node._wrapperState 3916 3917 3918 node._valueTracker = trackValueOnNode(node); 3919} 3920function updateValueIfChanged(node) { 3921 if (!node) { 3922 return false; 3923 } 3924 3925 var tracker = getTracker(node); // if there is no tracker at this point it's unlikely 3926 // that trying again will succeed 3927 3928 if (!tracker) { 3929 return true; 3930 } 3931 3932 var lastValue = tracker.getValue(); 3933 var nextValue = getValueFromNode(node); 3934 3935 if (nextValue !== lastValue) { 3936 tracker.setValue(nextValue); 3937 return true; 3938 } 3939 3940 return false; 3941} 3942 3943function getActiveElement(doc) { 3944 doc = doc || (typeof document !== 'undefined' ? document : undefined); 3945 3946 if (typeof doc === 'undefined') { 3947 return null; 3948 } 3949 3950 try { 3951 return doc.activeElement || doc.body; 3952 } catch (e) { 3953 return doc.body; 3954 } 3955} 3956 3957var didWarnValueDefaultValue = false; 3958var didWarnCheckedDefaultChecked = false; 3959var didWarnControlledToUncontrolled = false; 3960var didWarnUncontrolledToControlled = false; 3961 3962function isControlled(props) { 3963 var usesChecked = props.type === 'checkbox' || props.type === 'radio'; 3964 return usesChecked ? props.checked != null : props.value != null; 3965} 3966/** 3967 * Implements an <input> host component that allows setting these optional 3968 * props: `checked`, `value`, `defaultChecked`, and `defaultValue`. 3969 * 3970 * If `checked` or `value` are not supplied (or null/undefined), user actions 3971 * that affect the checked state or value will trigger updates to the element. 3972 * 3973 * If they are supplied (and not null/undefined), the rendered element will not 3974 * trigger updates to the element. Instead, the props must change in order for 3975 * the rendered element to be updated. 3976 * 3977 * The rendered element will be initialized as unchecked (or `defaultChecked`) 3978 * with an empty value (or `defaultValue`). 3979 * 3980 * See http://www.w3.org/TR/2012/WD-html5-20121025/the-input-element.html 3981 */ 3982 3983 3984function getHostProps(element, props) { 3985 var node = element; 3986 var checked = props.checked; 3987 3988 var hostProps = _assign({}, props, { 3989 defaultChecked: undefined, 3990 defaultValue: undefined, 3991 value: undefined, 3992 checked: checked != null ? checked : node._wrapperState.initialChecked 3993 }); 3994 3995 return hostProps; 3996} 3997function initWrapperState(element, props) { 3998 { 3999 checkControlledValueProps('input', props); 4000 4001 if (props.checked !== undefined && props.defaultChecked !== undefined && !didWarnCheckedDefaultChecked) { 4002 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); 4003 4004 didWarnCheckedDefaultChecked = true; 4005 } 4006 4007 if (props.value !== undefined && props.defaultValue !== undefined && !didWarnValueDefaultValue) { 4008 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); 4009 4010 didWarnValueDefaultValue = true; 4011 } 4012 } 4013 4014 var node = element; 4015 var defaultValue = props.defaultValue == null ? '' : props.defaultValue; 4016 node._wrapperState = { 4017 initialChecked: props.checked != null ? props.checked : props.defaultChecked, 4018 initialValue: getToStringValue(props.value != null ? props.value : defaultValue), 4019 controlled: isControlled(props) 4020 }; 4021} 4022function updateChecked(element, props) { 4023 var node = element; 4024 var checked = props.checked; 4025 4026 if (checked != null) { 4027 setValueForProperty(node, 'checked', checked, false); 4028 } 4029} 4030function updateWrapper(element, props) { 4031 var node = element; 4032 4033 { 4034 var controlled = isControlled(props); 4035 4036 if (!node._wrapperState.controlled && controlled && !didWarnUncontrolledToControlled) { 4037 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'); 4038 4039 didWarnUncontrolledToControlled = true; 4040 } 4041 4042 if (node._wrapperState.controlled && !controlled && !didWarnControlledToUncontrolled) { 4043 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'); 4044 4045 didWarnControlledToUncontrolled = true; 4046 } 4047 } 4048 4049 updateChecked(element, props); 4050 var value = getToStringValue(props.value); 4051 var type = props.type; 4052 4053 if (value != null) { 4054 if (type === 'number') { 4055 if (value === 0 && node.value === '' || // We explicitly want to coerce to number here if possible. 4056 // eslint-disable-next-line 4057 node.value != value) { 4058 node.value = toString(value); 4059 } 4060 } else if (node.value !== toString(value)) { 4061 node.value = toString(value); 4062 } 4063 } else if (type === 'submit' || type === 'reset') { 4064 // Submit/reset inputs need the attribute removed completely to avoid 4065 // blank-text buttons. 4066 node.removeAttribute('value'); 4067 return; 4068 } 4069 4070 { 4071 // When syncing the value attribute, the value comes from a cascade of 4072 // properties: 4073 // 1. The value React property 4074 // 2. The defaultValue React property 4075 // 3. Otherwise there should be no change 4076 if (props.hasOwnProperty('value')) { 4077 setDefaultValue(node, props.type, value); 4078 } else if (props.hasOwnProperty('defaultValue')) { 4079 setDefaultValue(node, props.type, getToStringValue(props.defaultValue)); 4080 } 4081 } 4082 4083 { 4084 // When syncing the checked attribute, it only changes when it needs 4085 // to be removed, such as transitioning from a checkbox into a text input 4086 if (props.checked == null && props.defaultChecked != null) { 4087 node.defaultChecked = !!props.defaultChecked; 4088 } 4089 } 4090} 4091function postMountWrapper(element, props, isHydrating) { 4092 var node = element; // Do not assign value if it is already set. This prevents user text input 4093 // from being lost during SSR hydration. 4094 4095 if (props.hasOwnProperty('value') || props.hasOwnProperty('defaultValue')) { 4096 var type = props.type; 4097 var isButton = type === 'submit' || type === 'reset'; // Avoid setting value attribute on submit/reset inputs as it overrides the 4098 // default value provided by the browser. See: #12872 4099 4100 if (isButton && (props.value === undefined || props.value === null)) { 4101 return; 4102 } 4103 4104 var initialValue = toString(node._wrapperState.initialValue); // Do not assign value if it is already set. This prevents user text input 4105 // from being lost during SSR hydration. 4106 4107 if (!isHydrating) { 4108 { 4109 // When syncing the value attribute, the value property should use 4110 // the wrapperState._initialValue property. This uses: 4111 // 4112 // 1. The value React property when present 4113 // 2. The defaultValue React property when present 4114 // 3. An empty string 4115 if (initialValue !== node.value) { 4116 node.value = initialValue; 4117 } 4118 } 4119 } 4120 4121 { 4122 // Otherwise, the value attribute is synchronized to the property, 4123 // so we assign defaultValue to the same thing as the value property 4124 // assignment step above. 4125 node.defaultValue = initialValue; 4126 } 4127 } // Normally, we'd just do `node.checked = node.checked` upon initial mount, less this bug 4128 // this is needed to work around a chrome bug where setting defaultChecked 4129 // will sometimes influence the value of checked (even after detachment). 4130 // Reference: https://bugs.chromium.org/p/chromium/issues/detail?id=608416 4131 // We need to temporarily unset name to avoid disrupting radio button groups. 4132 4133 4134 var name = node.name; 4135 4136 if (name !== '') { 4137 node.name = ''; 4138 } 4139 4140 { 4141 // When syncing the checked attribute, both the checked property and 4142 // attribute are assigned at the same time using defaultChecked. This uses: 4143 // 4144 // 1. The checked React property when present 4145 // 2. The defaultChecked React property when present 4146 // 3. Otherwise, false 4147 node.defaultChecked = !node.defaultChecked; 4148 node.defaultChecked = !!node._wrapperState.initialChecked; 4149 } 4150 4151 if (name !== '') { 4152 node.name = name; 4153 } 4154} 4155function restoreControlledState(element, props) { 4156 var node = element; 4157 updateWrapper(node, props); 4158 updateNamedCousins(node, props); 4159} 4160 4161function updateNamedCousins(rootNode, props) { 4162 var name = props.name; 4163 4164 if (props.type === 'radio' && name != null) { 4165 var queryRoot = rootNode; 4166 4167 while (queryRoot.parentNode) { 4168 queryRoot = queryRoot.parentNode; 4169 } // If `rootNode.form` was non-null, then we could try `form.elements`, 4170 // but that sometimes behaves strangely in IE8. We could also try using 4171 // `form.getElementsByName`, but that will only return direct children 4172 // and won't include inputs that use the HTML5 `form=` attribute. Since 4173 // the input might not even be in a form. It might not even be in the 4174 // document. Let's just use the local `querySelectorAll` to ensure we don't 4175 // miss anything. 4176 4177 4178 var group = queryRoot.querySelectorAll('input[name=' + JSON.stringify('' + name) + '][type="radio"]'); 4179 4180 for (var i = 0; i < group.length; i++) { 4181 var otherNode = group[i]; 4182 4183 if (otherNode === rootNode || otherNode.form !== rootNode.form) { 4184 continue; 4185 } // This will throw if radio buttons rendered by different copies of React 4186 // and the same name are rendered into the same form (same as #1939). 4187 // That's probably okay; we don't support it just as we don't support 4188 // mixing React radio buttons with non-React ones. 4189 4190 4191 var otherProps = getFiberCurrentPropsFromNode(otherNode); 4192 4193 if (!otherProps) { 4194 { 4195 throw Error( "ReactDOMInput: Mixing React and non-React radio inputs with the same `name` is not supported." ); 4196 } 4197 } // We need update the tracked value on the named cousin since the value 4198 // was changed but the input saw no event or value set 4199 4200 4201 updateValueIfChanged(otherNode); // If this is a controlled radio button group, forcing the input that 4202 // was previously checked to update will cause it to be come re-checked 4203 // as appropriate. 4204 4205 updateWrapper(otherNode, otherProps); 4206 } 4207 } 4208} // In Chrome, assigning defaultValue to certain input types triggers input validation. 4209// For number inputs, the display value loses trailing decimal points. For email inputs, 4210// Chrome raises "The specified value <x> is not a valid email address". 4211// 4212// Here we check to see if the defaultValue has actually changed, avoiding these problems 4213// when the user is inputting text 4214// 4215// https://github.com/facebook/react/issues/7253 4216 4217 4218function setDefaultValue(node, type, value) { 4219 if ( // Focused number inputs synchronize on blur. See ChangeEventPlugin.js 4220 type !== 'number' || getActiveElement(node.ownerDocument) !== node) { 4221 if (value == null) { 4222 node.defaultValue = toString(node._wrapperState.initialValue); 4223 } else if (node.defaultValue !== toString(value)) { 4224 node.defaultValue = toString(value); 4225 } 4226 } 4227} 4228 4229var didWarnSelectedSetOnOption = false; 4230var didWarnInvalidChild = false; 4231 4232function flattenChildren(children) { 4233 var content = ''; // Flatten children. We'll warn if they are invalid 4234 // during validateProps() which runs for hydration too. 4235 // Note that this would throw on non-element objects. 4236 // Elements are stringified (which is normally irrelevant 4237 // but matters for <fbt>). 4238 4239 React.Children.forEach(children, function (child) { 4240 if (child == null) { 4241 return; 4242 } 4243 4244 content += child; // Note: we don't warn about invalid children here. 4245 // Instead, this is done separately below so that 4246 // it happens during the hydration code path too. 4247 }); 4248 return content; 4249} 4250/** 4251 * Implements an <option> host component that warns when `selected` is set. 4252 */ 4253 4254 4255function validateProps(element, props) { 4256 { 4257 // This mirrors the code path above, but runs for hydration too. 4258 // Warn about invalid children here so that client and hydration are consistent. 4259 // TODO: this seems like it could cause a DEV-only throw for hydration 4260 // if children contains a non-element object. We should try to avoid that. 4261 if (typeof props.children === 'object' && props.children !== null) { 4262 React.Children.forEach(props.children, function (child) { 4263 if (child == null) { 4264 return; 4265 } 4266 4267 if (typeof child === 'string' || typeof child === 'number') { 4268 return; 4269 } 4270 4271 if (typeof child.type !== 'string') { 4272 return; 4273 } 4274 4275 if (!didWarnInvalidChild) { 4276 didWarnInvalidChild = true; 4277 4278 error('Only strings and numbers are supported as <option> children.'); 4279 } 4280 }); 4281 } // TODO: Remove support for `selected` in <option>. 4282 4283 4284 if (props.selected != null && !didWarnSelectedSetOnOption) { 4285 error('Use the `defaultValue` or `value` props on <select> instead of ' + 'setting `selected` on <option>.'); 4286 4287 didWarnSelectedSetOnOption = true; 4288 } 4289 } 4290} 4291function postMountWrapper$1(element, props) { 4292 // value="" should make a value attribute (#6219) 4293 if (props.value != null) { 4294 element.setAttribute('value', toString(getToStringValue(props.value))); 4295 } 4296} 4297function getHostProps$1(element, props) { 4298 var hostProps = _assign({ 4299 children: undefined 4300 }, props); 4301 4302 var content = flattenChildren(props.children); 4303 4304 if (content) { 4305 hostProps.children = content; 4306 } 4307 4308 return hostProps; 4309} 4310 4311var didWarnValueDefaultValue$1; 4312 4313{ 4314 didWarnValueDefaultValue$1 = false; 4315} 4316 4317function getDeclarationErrorAddendum() { 4318 var ownerName = getCurrentFiberOwnerNameInDevOrNull(); 4319 4320 if (ownerName) { 4321 return '\n\nCheck the render method of `' + ownerName + '`.'; 4322 } 4323 4324 return ''; 4325} 4326 4327var valuePropNames = ['value', 'defaultValue']; 4328/** 4329 * Validation function for `value` and `defaultValue`. 4330 */ 4331 4332function checkSelectPropTypes(props) { 4333 { 4334 checkControlledValueProps('select', props); 4335 4336 for (var i = 0; i < valuePropNames.length; i++) { 4337 var propName = valuePropNames[i]; 4338 4339 if (props[propName] == null) { 4340 continue; 4341 } 4342 4343 var isArray = Array.isArray(props[propName]); 4344 4345 if (props.multiple && !isArray) { 4346 error('The `%s` prop supplied to <select> must be an array if ' + '`multiple` is true.%s', propName, getDeclarationErrorAddendum()); 4347 } else if (!props.multiple && isArray) { 4348 error('The `%s` prop supplied to <select> must be a scalar ' + 'value if `multiple` is false.%s', propName, getDeclarationErrorAddendum()); 4349 } 4350 } 4351 } 4352} 4353 4354function updateOptions(node, multiple, propValue, setDefaultSelected) { 4355 var options = node.options; 4356 4357 if (multiple) { 4358 var selectedValues = propValue; 4359 var selectedValue = {}; 4360 4361 for (var i = 0; i < selectedValues.length; i++) { 4362 // Prefix to avoid chaos with special keys. 4363 selectedValue['$' + selectedValues[i]] = true; 4364 } 4365 4366 for (var _i = 0; _i < options.length; _i++) { 4367 var selected = selectedValue.hasOwnProperty('$' + options[_i].value); 4368 4369 if (options[_i].selected !== selected) { 4370 options[_i].selected = selected; 4371 } 4372 4373 if (selected && setDefaultSelected) { 4374 options[_i].defaultSelected = true; 4375 } 4376 } 4377 } else { 4378 // Do not set `select.value` as exact behavior isn't consistent across all 4379 // browsers for all cases. 4380 var _selectedValue = toString(getToStringValue(propValue)); 4381 4382 var defaultSelected = null; 4383 4384 for (var _i2 = 0; _i2 < options.length; _i2++) { 4385 if (options[_i2].value === _selectedValue) { 4386 options[_i2].selected = true; 4387 4388 if (setDefaultSelected) { 4389 options[_i2].defaultSelected = true; 4390 } 4391 4392 return; 4393 } 4394 4395 if (defaultSelected === null && !options[_i2].disabled) { 4396 defaultSelected = options[_i2]; 4397 } 4398 } 4399 4400 if (defaultSelected !== null) { 4401 defaultSelected.selected = true; 4402 } 4403 } 4404} 4405/** 4406 * Implements a <select> host component that allows optionally setting the 4407 * props `value` and `defaultValue`. If `multiple` is false, the prop must be a 4408 * stringable. If `multiple` is true, the prop must be an array of stringables. 4409 * 4410 * If `value` is not supplied (or null/undefined), user actions that change the 4411 * selected option will trigger updates to the rendered options. 4412 * 4413 * If it is supplied (and not null/undefined), the rendered options will not 4414 * update in response to user actions. Instead, the `value` prop must change in 4415 * order for the rendered options to update. 4416 * 4417 * If `defaultValue` is provided, any options with the supplied values will be 4418 * selected. 4419 */ 4420 4421 4422function getHostProps$2(element, props) { 4423 return _assign({}, props, { 4424 value: undefined 4425 }); 4426} 4427function initWrapperState$1(element, props) { 4428 var node = element; 4429 4430 { 4431 checkSelectPropTypes(props); 4432 } 4433 4434 node._wrapperState = { 4435 wasMultiple: !!props.multiple 4436 }; 4437 4438 { 4439 if (props.value !== undefined && props.defaultValue !== undefined && !didWarnValueDefaultValue$1) { 4440 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'); 4441 4442 didWarnValueDefaultValue$1 = true; 4443 } 4444 } 4445} 4446function postMountWrapper$2(element, props) { 4447 var node = element; 4448 node.multiple = !!props.multiple; 4449 var value = props.value; 4450 4451 if (value != null) { 4452 updateOptions(node, !!props.multiple, value, false); 4453 } else if (props.defaultValue != null) { 4454 updateOptions(node, !!props.multiple, props.defaultValue, true); 4455 } 4456} 4457function postUpdateWrapper(element, props) { 4458 var node = element; 4459 var wasMultiple = node._wrapperState.wasMultiple; 4460 node._wrapperState.wasMultiple = !!props.multiple; 4461 var value = props.value; 4462 4463 if (value != null) { 4464 updateOptions(node, !!props.multiple, value, false); 4465 } else if (wasMultiple !== !!props.multiple) { 4466 // For simplicity, reapply `defaultValue` if `multiple` is toggled. 4467 if (props.defaultValue != null) { 4468 updateOptions(node, !!props.multiple, props.defaultValue, true); 4469 } else { 4470 // Revert the select back to its default unselected state. 4471 updateOptions(node, !!props.multiple, props.multiple ? [] : '', false); 4472 } 4473 } 4474} 4475function restoreControlledState$1(element, props) { 4476 var node = element; 4477 var value = props.value; 4478 4479 if (value != null) { 4480 updateOptions(node, !!props.multiple, value, false); 4481 } 4482} 4483 4484var didWarnValDefaultVal = false; 4485 4486/** 4487 * Implements a <textarea> host component that allows setting `value`, and 4488 * `defaultValue`. This differs from the traditional DOM API because value is 4489 * usually set as PCDATA children. 4490 * 4491 * If `value` is not supplied (or null/undefined), user actions that affect the 4492 * value will trigger updates to the element. 4493 * 4494 * If `value` is supplied (and not null/undefined), the rendered element will 4495 * not trigger updates to the element. Instead, the `value` prop must change in 4496 * order for the rendered element to be updated. 4497 * 4498 * The rendered element will be initialized with an empty value, the prop 4499 * `defaultValue` if specified, or the children content (deprecated). 4500 */ 4501function getHostProps$3(element, props) { 4502 var node = element; 4503 4504 if (!(props.dangerouslySetInnerHTML == null)) { 4505 { 4506 throw Error( "`dangerouslySetInnerHTML` does not make sense on <textarea>." ); 4507 } 4508 } // Always set children to the same thing. In IE9, the selection range will 4509 // get reset if `textContent` is mutated. We could add a check in setTextContent 4510 // to only set the value if/when the value differs from the node value (which would 4511 // completely solve this IE9 bug), but Sebastian+Sophie seemed to like this 4512 // solution. The value can be a boolean or object so that's why it's forced 4513 // to be a string. 4514 4515 4516 var hostProps = _assign({}, props, { 4517 value: undefined, 4518 defaultValue: undefined, 4519 children: toString(node._wrapperState.initialValue) 4520 }); 4521 4522 return hostProps; 4523} 4524function initWrapperState$2(element, props) { 4525 var node = element; 4526 4527 { 4528 checkControlledValueProps('textarea', props); 4529 4530 if (props.value !== undefined && props.defaultValue !== undefined && !didWarnValDefaultVal) { 4531 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'); 4532 4533 didWarnValDefaultVal = true; 4534 } 4535 } 4536 4537 var initialValue = props.value; // Only bother fetching default value if we're going to use it 4538 4539 if (initialValue == null) { 4540 var children = props.children, 4541 defaultValue = props.defaultValue; 4542 4543 if (children != null) { 4544 { 4545 error('Use the `defaultValue` or `value` props instead of setting ' + 'children on <textarea>.'); 4546 } 4547 4548 { 4549 if (!(defaultValue == null)) { 4550 { 4551 throw Error( "If you supply `defaultValue` on a <textarea>, do not pass children." ); 4552 } 4553 } 4554 4555 if (Array.isArray(children)) { 4556 if (!(children.length <= 1)) { 4557 { 4558 throw Error( "<textarea> can only have at most one child." ); 4559 } 4560 } 4561 4562 children = children[0]; 4563 } 4564 4565 defaultValue = children; 4566 } 4567 } 4568 4569 if (defaultValue == null) { 4570 defaultValue = ''; 4571 } 4572 4573 initialValue = defaultValue; 4574 } 4575 4576 node._wrapperState = { 4577 initialValue: getToStringValue(initialValue) 4578 }; 4579} 4580function updateWrapper$1(element, props) { 4581 var node = element; 4582 var value = getToStringValue(props.value); 4583 var defaultValue = getToStringValue(props.defaultValue); 4584 4585 if (value != null) { 4586 // Cast `value` to a string to ensure the value is set correctly. While 4587 // browsers typically do this as necessary, jsdom doesn't. 4588 var newValue = toString(value); // To avoid side effects (such as losing text selection), only set value if changed 4589 4590 if (newValue !== node.value) { 4591 node.value = newValue; 4592 } 4593 4594 if (props.defaultValue == null && node.defaultValue !== newValue) { 4595 node.defaultValue = newValue; 4596 } 4597 } 4598 4599 if (defaultValue != null) { 4600 node.defaultValue = toString(defaultValue); 4601 } 4602} 4603function postMountWrapper$3(element, props) { 4604 var node = element; // This is in postMount because we need access to the DOM node, which is not 4605 // available until after the component has mounted. 4606 4607 var textContent = node.textContent; // Only set node.value if textContent is equal to the expected 4608 // initial value. In IE10/IE11 there is a bug where the placeholder attribute 4609 // will populate textContent as well. 4610 // https://developer.microsoft.com/microsoft-edge/platform/issues/101525/ 4611 4612 if (textContent === node._wrapperState.initialValue) { 4613 if (textContent !== '' && textContent !== null) { 4614 node.value = textContent; 4615 } 4616 } 4617} 4618function restoreControlledState$2(element, props) { 4619 // DOM component is still mounted; update 4620 updateWrapper$1(element, props); 4621} 4622 4623var HTML_NAMESPACE = 'http://www.w3.org/1999/xhtml'; 4624var MATH_NAMESPACE = 'http://www.w3.org/1998/Math/MathML'; 4625var SVG_NAMESPACE = 'http://www.w3.org/2000/svg'; 4626var Namespaces = { 4627 html: HTML_NAMESPACE, 4628 mathml: MATH_NAMESPACE, 4629 svg: SVG_NAMESPACE 4630}; // Assumes there is no parent namespace. 4631 4632function getIntrinsicNamespace(type) { 4633 switch (type) { 4634 case 'svg': 4635 return SVG_NAMESPACE; 4636 4637 case 'math': 4638 return MATH_NAMESPACE; 4639 4640 default: 4641 return HTML_NAMESPACE; 4642 } 4643} 4644function getChildNamespace(parentNamespace, type) { 4645 if (parentNamespace == null || parentNamespace === HTML_NAMESPACE) { 4646 // No (or default) parent namespace: potential entry point. 4647 return getIntrinsicNamespace(type); 4648 } 4649 4650 if (parentNamespace === SVG_NAMESPACE && type === 'foreignObject') { 4651 // We're leaving SVG. 4652 return HTML_NAMESPACE; 4653 } // By default, pass namespace below. 4654 4655 4656 return parentNamespace; 4657} 4658 4659/* globals MSApp */ 4660 4661/** 4662 * Create a function which has 'unsafe' privileges (required by windows8 apps) 4663 */ 4664var createMicrosoftUnsafeLocalFunction = function (func) { 4665 if (typeof MSApp !== 'undefined' && MSApp.execUnsafeLocalFunction) { 4666 return function (arg0, arg1, arg2, arg3) { 4667 MSApp.execUnsafeLocalFunction(function () { 4668 return func(arg0, arg1, arg2, arg3); 4669 }); 4670 }; 4671 } else { 4672 return func; 4673 } 4674}; 4675 4676var reusableSVGContainer; 4677/** 4678 * Set the innerHTML property of a node 4679 * 4680 * @param {DOMElement} node 4681 * @param {string} html 4682 * @internal 4683 */ 4684 4685var setInnerHTML = createMicrosoftUnsafeLocalFunction(function (node, html) { 4686 if (node.namespaceURI === Namespaces.svg) { 4687 4688 if (!('innerHTML' in node)) { 4689 // IE does not have innerHTML for SVG nodes, so instead we inject the 4690 // new markup in a temp node and then move the child nodes across into 4691 // the target node 4692 reusableSVGContainer = reusableSVGContainer || document.createElement('div'); 4693 reusableSVGContainer.innerHTML = '<svg>' + html.valueOf().toString() + '</svg>'; 4694 var svgNode = reusableSVGContainer.firstChild; 4695 4696 while (node.firstChild) { 4697 node.removeChild(node.firstChild); 4698 } 4699 4700 while (svgNode.firstChild) { 4701 node.appendChild(svgNode.firstChild); 4702 } 4703 4704 return; 4705 } 4706 } 4707 4708 node.innerHTML = html; 4709}); 4710 4711/** 4712 * HTML nodeType values that represent the type of the node 4713 */ 4714var ELEMENT_NODE = 1; 4715var TEXT_NODE = 3; 4716var COMMENT_NODE = 8; 4717var DOCUMENT_NODE = 9; 4718var DOCUMENT_FRAGMENT_NODE = 11; 4719 4720/** 4721 * Set the textContent property of a node. For text updates, it's faster 4722 * to set the `nodeValue` of the Text node directly instead of using 4723 * `.textContent` which will remove the existing node and create a new one. 4724 * 4725 * @param {DOMElement} node 4726 * @param {string} text 4727 * @internal 4728 */ 4729 4730var setTextContent = function (node, text) { 4731 if (text) { 4732 var firstChild = node.firstChild; 4733 4734 if (firstChild && firstChild === node.lastChild && firstChild.nodeType === TEXT_NODE) { 4735 firstChild.nodeValue = text; 4736 return; 4737 } 4738 } 4739 4740 node.textContent = text; 4741}; 4742 4743// List derived from Gecko source code: 4744// https://github.com/mozilla/gecko-dev/blob/4e638efc71/layout/style/test/property_database.js 4745var shorthandToLonghand = { 4746 animation: ['animationDelay', 'animationDirection', 'animationDuration', 'animationFillMode', 'animationIterationCount', 'animationName', 'animationPlayState', 'animationTimingFunction'], 4747 background: ['backgroundAttachment', 'backgroundClip', 'backgroundColor', 'backgroundImage', 'backgroundOrigin', 'backgroundPositionX', 'backgroundPositionY', 'backgroundRepeat', 'backgroundSize'], 4748 backgroundPosition: ['backgroundPositionX', 'backgroundPositionY'], 4749 border: ['borderBottomColor', 'borderBottomStyle', 'borderBottomWidth', 'borderImageOutset', 'borderImageRepeat', 'borderImageSlice', 'borderImageSource', 'borderImageWidth', 'borderLeftColor', 'borderLeftStyle', 'borderLeftWidth', 'borderRightColor', 'borderRightStyle', 'borderRightWidth', 'borderTopColor', 'borderTopStyle', 'borderTopWidth'], 4750 borderBlockEnd: ['borderBlockEndColor', 'borderBlockEndStyle', 'borderBlockEndWidth'], 4751 borderBlockStart: ['borderBlockStartColor', 'borderBlockStartStyle', 'borderBlockStartWidth'], 4752 borderBottom: ['borderBottomColor', 'borderBottomStyle', 'borderBottomWidth'], 4753 borderColor: ['borderBottomColor', 'borderLeftColor', 'borderRightColor', 'borderTopColor'], 4754 borderImage: ['borderImageOutset', 'borderImageRepeat', 'borderImageSlice', 'borderImageSource', 'borderImageWidth'], 4755 borderInlineEnd: ['borderInlineEndColor', 'borderInlineEndStyle', 'borderInlineEndWidth'], 4756 borderInlineStart: ['borderInlineStartColor', 'borderInlineStartStyle', 'borderInlineStartWidth'], 4757 borderLeft: ['borderLeftColor', 'borderLeftStyle', 'borderLeftWidth'], 4758 borderRadius: ['borderBottomLeftRadius', 'borderBottomRightRadius', 'borderTopLeftRadius', 'borderTopRightRadius'], 4759 borderRight: ['borderRightColor', 'borderRightStyle', 'borderRightWidth'], 4760 borderStyle: ['borderBottomStyle', 'borderLeftStyle', 'borderRightStyle', 'borderTopStyle'], 4761 borderTop: ['borderTopColor', 'borderTopStyle', 'borderTopWidth'], 4762 borderWidth: ['borderBottomWidth', 'borderLeftWidth', 'borderRightWidth', 'borderTopWidth'], 4763 columnRule: ['columnRuleColor', 'columnRuleStyle', 'columnRuleWidth'], 4764 columns: ['columnCount', 'columnWidth'], 4765 flex: ['flexBasis', 'flexGrow', 'flexShrink'], 4766 flexFlow: ['flexDirection', 'flexWrap'], 4767 font: ['fontFamily', 'fontFeatureSettings', 'fontKerning', 'fontLanguageOverride', 'fontSize', 'fontSizeAdjust', 'fontStretch', 'fontStyle', 'fontVariant', 'fontVariantAlternates', 'fontVariantCaps', 'fontVariantEastAsian', 'fontVariantLigatures', 'fontVariantNumeric', 'fontVariantPosition', 'fontWeight', 'lineHeight'], 4768 fontVariant: ['fontVariantAlternates', 'fontVariantCaps', 'fontVariantEastAsian', 'fontVariantLigatures', 'fontVariantNumeric', 'fontVariantPosition'], 4769 gap: ['columnGap', 'rowGap'], 4770 grid: ['gridAutoColumns', 'gridAutoFlow', 'gridAutoRows', 'gridTemplateAreas', 'gridTemplateColumns', 'gridTemplateRows'], 4771 gridArea: ['gridColumnEnd', 'gridColumnStart', 'gridRowEnd', 'gridRowStart'], 4772 gridColumn: ['gridColumnEnd', 'gridColumnStart'], 4773 gridColumnGap: ['columnGap'], 4774 gridGap: ['columnGap', 'rowGap'], 4775 gridRow: ['gridRowEnd', 'gridRowStart'], 4776 gridRowGap: ['rowGap'], 4777 gridTemplate: ['gridTemplateAreas', 'gridTemplateColumns', 'gridTemplateRows'], 4778 listStyle: ['listStyleImage', 'listStylePosition', 'listStyleType'], 4779 margin: ['marginBottom', 'marginLeft', 'marginRight', 'marginTop'], 4780 marker: ['markerEnd', 'markerMid', 'markerStart'], 4781 mask: ['maskClip', 'maskComposite', 'maskImage', 'maskMode', 'maskOrigin', 'maskPositionX', 'maskPositionY', 'maskRepeat', 'maskSize'], 4782 maskPosition: ['maskPositionX', 'maskPositionY'], 4783 outline: ['outlineColor', 'outlineStyle', 'outlineWidth'], 4784 overflow: ['overflowX', 'overflowY'], 4785 padding: ['paddingBottom', 'paddingLeft', 'paddingRight', 'paddingTop'], 4786 placeContent: ['alignContent', 'justifyContent'], 4787 placeItems: ['alignItems', 'justifyItems'], 4788 placeSelf: ['alignSelf', 'justifySelf'], 4789 textDecoration: ['textDecorationColor', 'textDecorationLine', 'textDecorationStyle'], 4790 textEmphasis: ['textEmphasisColor', 'textEmphasisStyle'], 4791 transition: ['transitionDelay', 'transitionDuration', 'transitionProperty', 'transitionTimingFunction'], 4792 wordWrap: ['overflowWrap'] 4793}; 4794 4795/** 4796 * CSS properties which accept numbers but are not in units of "px". 4797 */ 4798var isUnitlessNumber = { 4799 animationIterationCount: true, 4800 borderImageOutset: true, 4801 borderImageSlice: true, 4802 borderImageWidth: true, 4803 boxFlex: true, 4804 boxFlexGroup: true, 4805 boxOrdinalGroup: true, 4806 columnCount: true, 4807 columns: true, 4808 flex: true, 4809 flexGrow: true, 4810 flexPositive: true, 4811 flexShrink: true, 4812 flexNegative: true, 4813 flexOrder: true, 4814 gridArea: true, 4815 gridRow: true, 4816 gridRowEnd: true, 4817 gridRowSpan: true, 4818 gridRowStart: true, 4819 gridColumn: true, 4820 gridColumnEnd: true, 4821 gridColumnSpan: true, 4822 gridColumnStart: true, 4823 fontWeight: true, 4824 lineClamp: true, 4825 lineHeight: true, 4826 opacity: true, 4827 order: true, 4828 orphans: true, 4829 tabSize: true, 4830 widows: true, 4831 zIndex: true, 4832 zoom: true, 4833 // SVG-related properties 4834 fillOpacity: true, 4835 floodOpacity: true, 4836 stopOpacity: true, 4837 strokeDasharray: true, 4838 strokeDashoffset: true, 4839 strokeMiterlimit: true, 4840 strokeOpacity: true, 4841 strokeWidth: true 4842}; 4843/** 4844 * @param {string} prefix vendor-specific prefix, eg: Webkit 4845 * @param {string} key style name, eg: transitionDuration 4846 * @return {string} style name prefixed with `prefix`, properly camelCased, eg: 4847 * WebkitTransitionDuration 4848 */ 4849 4850function prefixKey(prefix, key) { 4851 return prefix + key.charAt(0).toUpperCase() + key.substring(1); 4852} 4853/** 4854 * Support style names that may come passed in prefixed by adding permutations 4855 * of vendor prefixes. 4856 */ 4857 4858 4859var prefixes = ['Webkit', 'ms', 'Moz', 'O']; // Using Object.keys here, or else the vanilla for-in loop makes IE8 go into an 4860// infinite loop, because it iterates over the newly added props too. 4861 4862Object.keys(isUnitlessNumber).forEach(function (prop) { 4863 prefixes.forEach(function (prefix) { 4864 isUnitlessNumber[prefixKey(prefix, prop)] = isUnitlessNumber[prop]; 4865 }); 4866}); 4867 4868/** 4869 * Convert a value into the proper css writable value. The style name `name` 4870 * should be logical (no hyphens), as specified 4871 * in `CSSProperty.isUnitlessNumber`. 4872 * 4873 * @param {string} name CSS property name such as `topMargin`. 4874 * @param {*} value CSS property value such as `10px`. 4875 * @return {string} Normalized style value with dimensions applied. 4876 */ 4877 4878function dangerousStyleValue(name, value, isCustomProperty) { 4879 // Note that we've removed escapeTextForBrowser() calls here since the 4880 // whole string will be escaped when the attribute is injected into 4881 // the markup. If you provide unsafe user data here they can inject 4882 // arbitrary CSS which may be problematic (I couldn't repro this): 4883 // https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet 4884 // http://www.thespanner.co.uk/2007/11/26/ultimate-xss-css-injection/ 4885 // This is not an XSS hole but instead a potential CSS injection issue 4886 // which has lead to a greater discussion about how we're going to 4887 // trust URLs moving forward. See #2115901 4888 var isEmpty = value == null || typeof value === 'boolean' || value === ''; 4889 4890 if (isEmpty) { 4891 return ''; 4892 } 4893 4894 if (!isCustomProperty && typeof value === 'number' && value !== 0 && !(isUnitlessNumber.hasOwnProperty(name) && isUnitlessNumber[name])) { 4895 return value + 'px'; // Presumes implicit 'px' suffix for unitless numbers 4896 } 4897 4898 return ('' + value).trim(); 4899} 4900 4901var uppercasePattern = /([A-Z])/g; 4902var msPattern = /^ms-/; 4903/** 4904 * Hyphenates a camelcased CSS property name, for example: 4905 * 4906 * > hyphenateStyleName('backgroundColor') 4907 * < "background-color" 4908 * > hyphenateStyleName('MozTransition') 4909 * < "-moz-transition" 4910 * > hyphenateStyleName('msTransition') 4911 * < "-ms-transition" 4912 * 4913 * As Modernizr suggests (http://modernizr.com/docs/#prefixed), an `ms` prefix 4914 * is converted to `-ms-`. 4915 */ 4916 4917function hyphenateStyleName(name) { 4918 return name.replace(uppercasePattern, '-$1').toLowerCase().replace(msPattern, '-ms-'); 4919} 4920 4921var warnValidStyle = function () {}; 4922 4923{ 4924 // 'msTransform' is correct, but the other prefixes should be capitalized 4925 var badVendoredStyleNamePattern = /^(?:webkit|moz|o)[A-Z]/; 4926 var msPattern$1 = /^-ms-/; 4927 var hyphenPattern = /-(.)/g; // style values shouldn't contain a semicolon 4928 4929 var badStyleValueWithSemicolonPattern = /;\s*$/; 4930 var warnedStyleNames = {}; 4931 var warnedStyleValues = {}; 4932 var warnedForNaNValue = false; 4933 var warnedForInfinityValue = false; 4934 4935 var camelize = function (string) { 4936 return string.replace(hyphenPattern, function (_, character) { 4937 return character.toUpperCase(); 4938 }); 4939 }; 4940 4941 var warnHyphenatedStyleName = function (name) { 4942 if (warnedStyleNames.hasOwnProperty(name) && warnedStyleNames[name]) { 4943 return; 4944 } 4945 4946 warnedStyleNames[name] = true; 4947 4948 error('Unsupported style property %s. Did you mean %s?', name, // As Andi Smith suggests 4949 // (http://www.andismith.com/blog/2012/02/modernizr-prefixed/), an `-ms` prefix 4950 // is converted to lowercase `ms`. 4951 camelize(name.replace(msPattern$1, 'ms-'))); 4952 }; 4953 4954 var warnBadVendoredStyleName = function (name) { 4955 if (warnedStyleNames.hasOwnProperty(name) && warnedStyleNames[name]) { 4956 return; 4957 } 4958 4959 warnedStyleNames[name] = true; 4960 4961 error('Unsupported vendor-prefixed style property %s. Did you mean %s?', name, name.charAt(0).toUpperCase() + name.slice(1)); 4962 }; 4963 4964 var warnStyleValueWithSemicolon = function (name, value) { 4965 if (warnedStyleValues.hasOwnProperty(value) && warnedStyleValues[value]) { 4966 return; 4967 } 4968 4969 warnedStyleValues[value] = true; 4970 4971 error("Style property values shouldn't contain a semicolon. " + 'Try "%s: %s" instead.', name, value.replace(badStyleValueWithSemicolonPattern, '')); 4972 }; 4973 4974 var warnStyleValueIsNaN = function (name, value) { 4975 if (warnedForNaNValue) { 4976 return; 4977 } 4978 4979 warnedForNaNValue = true; 4980 4981 error('`NaN` is an invalid value for the `%s` css style property.', name); 4982 }; 4983 4984 var warnStyleValueIsInfinity = function (name, value) { 4985 if (warnedForInfinityValue) { 4986 return; 4987 } 4988 4989 warnedForInfinityValue = true; 4990 4991 error('`Infinity` is an invalid value for the `%s` css style property.', name); 4992 }; 4993 4994 warnValidStyle = function (name, value) { 4995 if (name.indexOf('-') > -1) { 4996 warnHyphenatedStyleName(name); 4997 } else if (badVendoredStyleNamePattern.test(name)) { 4998 warnBadVendoredStyleName(name); 4999 } else if (badStyleValueWithSemicolonPattern.test(value)) { 5000 warnStyleValueWithSemicolon(name, value); 5001 } 5002 5003 if (typeof value === 'number') { 5004 if (isNaN(value)) { 5005 warnStyleValueIsNaN(name, value); 5006 } else if (!isFinite(value)) { 5007 warnStyleValueIsInfinity(name, value); 5008 } 5009 } 5010 }; 5011} 5012 5013var warnValidStyle$1 = warnValidStyle; 5014 5015/** 5016 * Operations for dealing with CSS properties. 5017 */ 5018 5019/** 5020 * This creates a string that is expected to be equivalent to the style 5021 * attribute generated by server-side rendering. It by-passes warnings and 5022 * security checks so it's not safe to use this value for anything other than 5023 * comparison. It is only used in DEV for SSR validation. 5024 */ 5025 5026function createDangerousStringForStyles(styles) { 5027 { 5028 var serialized = ''; 5029 var delimiter = ''; 5030 5031 for (var styleName in styles) { 5032 if (!styles.hasOwnProperty(styleName)) { 5033 continue; 5034 } 5035 5036 var styleValue = styles[styleName]; 5037 5038 if (styleValue != null) { 5039 var isCustomProperty = styleName.indexOf('--') === 0; 5040 serialized += delimiter + (isCustomProperty ? styleName : hyphenateStyleName(styleName)) + ':'; 5041 serialized += dangerousStyleValue(styleName, styleValue, isCustomProperty); 5042 delimiter = ';'; 5043 } 5044 } 5045 5046 return serialized || null; 5047 } 5048} 5049/** 5050 * Sets the value for multiple styles on a node. If a value is specified as 5051 * '' (empty string), the corresponding style property will be unset. 5052 * 5053 * @param {DOMElement} node 5054 * @param {object} styles 5055 */ 5056 5057function setValueForStyles(node, styles) { 5058 var style = node.style; 5059 5060 for (var styleName in styles) { 5061 if (!styles.hasOwnProperty(styleName)) { 5062 continue; 5063 } 5064 5065 var isCustomProperty = styleName.indexOf('--') === 0; 5066 5067 { 5068 if (!isCustomProperty) { 5069 warnValidStyle$1(styleName, styles[styleName]); 5070 } 5071 } 5072 5073 var styleValue = dangerousStyleValue(styleName, styles[styleName], isCustomProperty); 5074 5075 if (styleName === 'float') { 5076 styleName = 'cssFloat'; 5077 } 5078 5079 if (isCustomProperty) { 5080 style.setProperty(styleName, styleValue); 5081 } else { 5082 style[styleName] = styleValue; 5083 } 5084 } 5085} 5086 5087function isValueEmpty(value) { 5088 return value == null || typeof value === 'boolean' || value === ''; 5089} 5090/** 5091 * Given {color: 'red', overflow: 'hidden'} returns { 5092 * color: 'color', 5093 * overflowX: 'overflow', 5094 * overflowY: 'overflow', 5095 * }. This can be read as "the overflowY property was set by the overflow 5096 * shorthand". That is, the values are the property that each was derived from. 5097 */ 5098 5099 5100function expandShorthandMap(styles) { 5101 var expanded = {}; 5102 5103 for (var key in styles) { 5104 var longhands = shorthandToLonghand[key] || [key]; 5105 5106 for (var i = 0; i < longhands.length; i++) { 5107 expanded[longhands[i]] = key; 5108 } 5109 } 5110 5111 return expanded; 5112} 5113/** 5114 * When mixing shorthand and longhand property names, we warn during updates if 5115 * we expect an incorrect result to occur. In particular, we warn for: 5116 * 5117 * Updating a shorthand property (longhand gets overwritten): 5118 * {font: 'foo', fontVariant: 'bar'} -> {font: 'baz', fontVariant: 'bar'} 5119 * becomes .style.font = 'baz' 5120 * Removing a shorthand property (longhand gets lost too): 5121 * {font: 'foo', fontVariant: 'bar'} -> {fontVariant: 'bar'} 5122 * becomes .style.font = '' 5123 * Removing a longhand property (should revert to shorthand; doesn't): 5124 * {font: 'foo', fontVariant: 'bar'} -> {font: 'foo'} 5125 * becomes .style.fontVariant = '' 5126 */ 5127 5128 5129function validateShorthandPropertyCollisionInDev(styleUpdates, nextStyles) { 5130 { 5131 if (!nextStyles) { 5132 return; 5133 } 5134 5135 var expandedUpdates = expandShorthandMap(styleUpdates); 5136 var expandedStyles = expandShorthandMap(nextStyles); 5137 var warnedAbout = {}; 5138 5139 for (var key in expandedUpdates) { 5140 var originalKey = expandedUpdates[key]; 5141 var correctOriginalKey = expandedStyles[key]; 5142 5143 if (correctOriginalKey && originalKey !== correctOriginalKey) { 5144 var warningKey = originalKey + ',' + correctOriginalKey; 5145 5146 if (warnedAbout[warningKey]) { 5147 continue; 5148 } 5149 5150 warnedAbout[warningKey] = true; 5151 5152 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); 5153 } 5154 } 5155 } 5156} 5157 5158// For HTML, certain tags should omit their close tag. We keep a list for 5159// those special-case tags. 5160var omittedCloseTags = { 5161 area: true, 5162 base: true, 5163 br: true, 5164 col: true, 5165 embed: true, 5166 hr: true, 5167 img: true, 5168 input: true, 5169 keygen: true, 5170 link: true, 5171 meta: true, 5172 param: true, 5173 source: true, 5174 track: true, 5175 wbr: true // NOTE: menuitem's close tag should be omitted, but that causes problems. 5176 5177}; 5178 5179// `omittedCloseTags` except that `menuitem` should still have its closing tag. 5180 5181var voidElementTags = _assign({ 5182 menuitem: true 5183}, omittedCloseTags); 5184 5185var HTML = '__html'; 5186 5187function assertValidProps(tag, props) { 5188 if (!props) { 5189 return; 5190 } // Note the use of `==` which checks for null or undefined. 5191 5192 5193 if (voidElementTags[tag]) { 5194 if (!(props.children == null && props.dangerouslySetInnerHTML == null)) { 5195 { 5196 throw Error( tag + " is a void element tag and must neither have `children` nor use `dangerouslySetInnerHTML`." ); 5197 } 5198 } 5199 } 5200 5201 if (props.dangerouslySetInnerHTML != null) { 5202 if (!(props.children == null)) { 5203 { 5204 throw Error( "Can only set one of `children` or `props.dangerouslySetInnerHTML`." ); 5205 } 5206 } 5207 5208 if (!(typeof props.dangerouslySetInnerHTML === 'object' && HTML in props.dangerouslySetInnerHTML)) { 5209 { 5210 throw Error( "`props.dangerouslySetInnerHTML` must be in the form `{__html: ...}`. Please visit https://reactjs.org/link/dangerously-set-inner-html for more information." ); 5211 } 5212 } 5213 } 5214 5215 { 5216 if (!props.suppressContentEditableWarning && props.contentEditable && props.children != null) { 5217 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.'); 5218 } 5219 } 5220 5221 if (!(props.style == null || typeof props.style === 'object')) { 5222 { 5223 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." ); 5224 } 5225 } 5226} 5227 5228function isCustomComponent(tagName, props) { 5229 if (tagName.indexOf('-') === -1) { 5230 return typeof props.is === 'string'; 5231 } 5232 5233 switch (tagName) { 5234 // These are reserved SVG and MathML elements. 5235 // We don't mind this list too much because we expect it to never grow. 5236 // The alternative is to track the namespace in a few places which is convoluted. 5237 // https://w3c.github.io/webcomponents/spec/custom/#custom-elements-core-concepts 5238 case 'annotation-xml': 5239 case 'color-profile': 5240 case 'font-face': 5241 case 'font-face-src': 5242 case 'font-face-uri': 5243 case 'font-face-format': 5244 case 'font-face-name': 5245 case 'missing-glyph': 5246 return false; 5247 5248 default: 5249 return true; 5250 } 5251} 5252 5253// When adding attributes to the HTML or SVG allowed attribute list, be sure to 5254// also add them to this module to ensure casing and incorrect name 5255// warnings. 5256var possibleStandardNames = { 5257 // HTML 5258 accept: 'accept', 5259 acceptcharset: 'acceptCharset', 5260 'accept-charset': 'acceptCharset', 5261 accesskey: 'accessKey', 5262 action: 'action', 5263 allowfullscreen: 'allowFullScreen', 5264 alt: 'alt', 5265 as: 'as', 5266 async: 'async', 5267 autocapitalize: 'autoCapitalize', 5268 autocomplete: 'autoComplete', 5269 autocorrect: 'autoCorrect', 5270 autofocus: 'autoFocus', 5271 autoplay: 'autoPlay', 5272 autosave: 'autoSave', 5273 capture: 'capture', 5274 cellpadding: 'cellPadding', 5275 cellspacing: 'cellSpacing', 5276 challenge: 'challenge', 5277 charset: 'charSet', 5278 checked: 'checked', 5279 children: 'children', 5280 cite: 'cite', 5281 class: 'className', 5282 classid: 'classID', 5283 classname: 'className', 5284 cols: 'cols', 5285 colspan: 'colSpan', 5286 content: 'content', 5287 contenteditable: 'contentEditable', 5288 contextmenu: 'contextMenu', 5289 controls: 'controls', 5290 controlslist: 'controlsList', 5291 coords: 'coords', 5292 crossorigin: 'crossOrigin', 5293 dangerouslysetinnerhtml: 'dangerouslySetInnerHTML', 5294 data: 'data', 5295 datetime: 'dateTime', 5296 default: 'default', 5297 defaultchecked: 'defaultChecked', 5298 defaultvalue: 'defaultValue', 5299 defer: 'defer', 5300 dir: 'dir', 5301 disabled: 'disabled', 5302 disablepictureinpicture: 'disablePictureInPicture', 5303 disableremoteplayback: 'disableRemotePlayback', 5304 download: 'download', 5305 draggable: 'draggable', 5306 enctype: 'encType', 5307 enterkeyhint: 'enterKeyHint', 5308 for: 'htmlFor', 5309 form: 'form', 5310 formmethod: 'formMethod', 5311 formaction: 'formAction', 5312 formenctype: 'formEncType', 5313 formnovalidate: 'formNoValidate', 5314 formtarget: 'formTarget', 5315 frameborder: 'frameBorder', 5316 headers: 'headers', 5317 height: 'height', 5318 hidden: 'hidden', 5319 high: 'high', 5320 href: 'href', 5321 hreflang: 'hrefLang', 5322 htmlfor: 'htmlFor', 5323 httpequiv: 'httpEquiv', 5324 'http-equiv': 'httpEquiv', 5325 icon: 'icon', 5326 id: 'id', 5327 innerhtml: 'innerHTML', 5328 inputmode: 'inputMode', 5329 integrity: 'integrity', 5330 is: 'is', 5331 itemid: 'itemID', 5332 itemprop: 'itemProp', 5333 itemref: 'itemRef', 5334 itemscope: 'itemScope', 5335 itemtype: 'itemType', 5336 keyparams: 'keyParams', 5337 keytype: 'keyType', 5338 kind: 'kind', 5339 label: 'label', 5340 lang: 'lang', 5341 list: 'list', 5342 loop: 'loop', 5343 low: 'low', 5344 manifest: 'manifest', 5345 marginwidth: 'marginWidth', 5346 marginheight: 'marginHeight', 5347 max: 'max', 5348 maxlength: 'maxLength', 5349 media: 'media', 5350 mediagroup: 'mediaGroup', 5351 method: 'method', 5352 min: 'min', 5353 minlength: 'minLength', 5354 multiple: 'multiple', 5355 muted: 'muted', 5356 name: 'name', 5357 nomodule: 'noModule', 5358 nonce: 'nonce', 5359 novalidate: 'noValidate', 5360 open: 'open', 5361 optimum: 'optimum', 5362 pattern: 'pattern', 5363 placeholder: 'placeholder', 5364 playsinline: 'playsInline', 5365 poster: 'poster', 5366 preload: 'preload', 5367 profile: 'profile', 5368 radiogroup: 'radioGroup', 5369 readonly: 'readOnly', 5370 referrerpolicy: 'referrerPolicy', 5371 rel: 'rel', 5372 required: 'required', 5373 reversed: 'reversed', 5374 role: 'role', 5375 rows: 'rows', 5376 rowspan: 'rowSpan', 5377 sandbox: 'sandbox', 5378 scope: 'scope', 5379 scoped: 'scoped', 5380 scrolling: 'scrolling', 5381 seamless: 'seamless', 5382 selected: 'selected', 5383 shape: 'shape', 5384 size: 'size', 5385 sizes: 'sizes', 5386 span: 'span', 5387 spellcheck: 'spellCheck', 5388 src: 'src', 5389 srcdoc: 'srcDoc', 5390 srclang: 'srcLang', 5391 srcset: 'srcSet', 5392 start: 'start', 5393 step: 'step', 5394 style: 'style', 5395 summary: 'summary', 5396 tabindex: 'tabIndex', 5397 target: 'target', 5398 title: 'title', 5399 type: 'type', 5400 usemap: 'useMap', 5401 value: 'value', 5402 width: 'width', 5403 wmode: 'wmode', 5404 wrap: 'wrap', 5405 // SVG 5406 about: 'about', 5407 accentheight: 'accentHeight', 5408 'accent-height': 'accentHeight', 5409 accumulate: 'accumulate', 5410 additive: 'additive', 5411 alignmentbaseline: 'alignmentBaseline', 5412 'alignment-baseline': 'alignmentBaseline', 5413 allowreorder: 'allowReorder', 5414 alphabetic: 'alphabetic', 5415 amplitude: 'amplitude', 5416 arabicform: 'arabicForm', 5417 'arabic-form': 'arabicForm', 5418 ascent: 'ascent', 5419 attributename: 'attributeName', 5420 attributetype: 'attributeType', 5421 autoreverse: 'autoReverse', 5422 azimuth: 'azimuth', 5423 basefrequency: 'baseFrequency', 5424 baselineshift: 'baselineShift', 5425 'baseline-shift': 'baselineShift', 5426 baseprofile: 'baseProfile', 5427 bbox: 'bbox', 5428 begin: 'begin', 5429 bias: 'bias', 5430 by: 'by', 5431 calcmode: 'calcMode', 5432 capheight: 'capHeight', 5433 'cap-height': 'capHeight', 5434 clip: 'clip', 5435 clippath: 'clipPath', 5436 'clip-path': 'clipPath', 5437 clippathunits: 'clipPathUnits', 5438 cliprule: 'clipRule', 5439 'clip-rule': 'clipRule', 5440 color: 'color', 5441 colorinterpolation: 'colorInterpolation', 5442 'color-interpolation': 'colorInterpolation', 5443 colorinterpolationfilters: 'colorInterpolationFilters', 5444 'color-interpolation-filters': 'colorInterpolationFilters', 5445 colorprofile: 'colorProfile', 5446 'color-profile': 'colorProfile', 5447 colorrendering: 'colorRendering', 5448 'color-rendering': 'colorRendering', 5449 contentscripttype: 'contentScriptType', 5450 contentstyletype: 'contentStyleType', 5451 cursor: 'cursor', 5452 cx: 'cx', 5453 cy: 'cy', 5454 d: 'd', 5455 datatype: 'datatype', 5456 decelerate: 'decelerate', 5457 descent: 'descent', 5458 diffuseconstant: 'diffuseConstant', 5459 direction: 'direction', 5460 display: 'display', 5461 divisor: 'divisor', 5462 dominantbaseline: 'dominantBaseline', 5463 'dominant-baseline': 'dominantBaseline', 5464 dur: 'dur', 5465 dx: 'dx', 5466 dy: 'dy', 5467 edgemode: 'edgeMode', 5468 elevation: 'elevation', 5469 enablebackground: 'enableBackground', 5470 'enable-background': 'enableBackground', 5471 end: 'end', 5472 exponent: 'exponent', 5473 externalresourcesrequired: 'externalResourcesRequired', 5474 fill: 'fill', 5475 fillopacity: 'fillOpacity', 5476 'fill-opacity': 'fillOpacity', 5477 fillrule: 'fillRule', 5478 'fill-rule': 'fillRule', 5479 filter: 'filter', 5480 filterres: 'filterRes', 5481 filterunits: 'filterUnits', 5482 floodopacity: 'floodOpacity', 5483 'flood-opacity': 'floodOpacity', 5484 floodcolor: 'floodColor', 5485 'flood-color': 'floodColor', 5486 focusable: 'focusable', 5487 fontfamily: 'fontFamily', 5488 'font-family': 'fontFamily', 5489 fontsize: 'fontSize', 5490 'font-size': 'fontSize', 5491 fontsizeadjust: 'fontSizeAdjust', 5492 'font-size-adjust': 'fontSizeAdjust', 5493 fontstretch: 'fontStretch', 5494 'font-stretch': 'fontStretch', 5495 fontstyle: 'fontStyle', 5496 'font-style': 'fontStyle', 5497 fontvariant: 'fontVariant', 5498 'font-variant': 'fontVariant', 5499 fontweight: 'fontWeight', 5500 'font-weight': 'fontWeight', 5501 format: 'format', 5502 from: 'from', 5503 fx: 'fx', 5504 fy: 'fy', 5505 g1: 'g1', 5506 g2: 'g2', 5507 glyphname: 'glyphName', 5508 'glyph-name': 'glyphName', 5509 glyphorientationhorizontal: 'glyphOrientationHorizontal', 5510 'glyph-orientation-horizontal': 'glyphOrientationHorizontal', 5511 glyphorientationvertical: 'glyphOrientationVertical', 5512 'glyph-orientation-vertical': 'glyphOrientationVertical', 5513 glyphref: 'glyphRef', 5514 gradienttransform: 'gradientTransform', 5515 gradientunits: 'gradientUnits', 5516 hanging: 'hanging', 5517 horizadvx: 'horizAdvX', 5518 'horiz-adv-x': 'horizAdvX', 5519 horizoriginx: 'horizOriginX', 5520 'horiz-origin-x': 'horizOriginX', 5521 ideographic: 'ideographic', 5522 imagerendering: 'imageRendering', 5523 'image-rendering': 'imageRendering', 5524 in2: 'in2', 5525 in: 'in', 5526 inlist: 'inlist', 5527 intercept: 'intercept', 5528 k1: 'k1', 5529 k2: 'k2', 5530 k3: 'k3', 5531 k4: 'k4', 5532 k: 'k', 5533 kernelmatrix: 'kernelMatrix', 5534 kernelunitlength: 'kernelUnitLength', 5535 kerning: 'kerning', 5536 keypoints: 'keyPoints', 5537 keysplines: 'keySplines', 5538 keytimes: 'keyTimes', 5539 lengthadjust: 'lengthAdjust', 5540 letterspacing: 'letterSpacing', 5541 'letter-spacing': 'letterSpacing', 5542 lightingcolor: 'lightingColor', 5543 'lighting-color': 'lightingColor', 5544 limitingconeangle: 'limitingConeAngle', 5545 local: 'local', 5546 markerend: 'markerEnd', 5547 'marker-end': 'markerEnd', 5548 markerheight: 'markerHeight', 5549 markermid: 'markerMid', 5550 'marker-mid': 'markerMid', 5551 markerstart: 'markerStart', 5552 'marker-start': 'markerStart', 5553 markerunits: 'markerUnits', 5554 markerwidth: 'markerWidth', 5555 mask: 'mask', 5556 maskcontentunits: 'maskContentUnits', 5557 maskunits: 'maskUnits', 5558 mathematical: 'mathematical', 5559 mode: 'mode', 5560 numoctaves: 'numOctaves', 5561 offset: 'offset', 5562 opacity: 'opacity', 5563 operator: 'operator', 5564 order: 'order', 5565 orient: 'orient', 5566 orientation: 'orientation', 5567 origin: 'origin', 5568 overflow: 'overflow', 5569 overlineposition: 'overlinePosition', 5570 'overline-position': 'overlinePosition', 5571 overlinethickness: 'overlineThickness', 5572 'overline-thickness': 'overlineThickness', 5573 paintorder: 'paintOrder', 5574 'paint-order': 'paintOrder', 5575 panose1: 'panose1', 5576 'panose-1': 'panose1', 5577 pathlength: 'pathLength', 5578 patterncontentunits: 'patternContentUnits', 5579 patterntransform: 'patternTransform', 5580 patternunits: 'patternUnits', 5581 pointerevents: 'pointerEvents', 5582 'pointer-events': 'pointerEvents', 5583 points: 'points', 5584 pointsatx: 'pointsAtX', 5585 pointsaty: 'pointsAtY', 5586 pointsatz: 'pointsAtZ', 5587 prefix: 'prefix', 5588 preservealpha: 'preserveAlpha', 5589 preserveaspectratio: 'preserveAspectRatio', 5590 primitiveunits: 'primitiveUnits', 5591 property: 'property', 5592 r: 'r', 5593 radius: 'radius', 5594 refx: 'refX', 5595 refy: 'refY', 5596 renderingintent: 'renderingIntent', 5597 'rendering-intent': 'renderingIntent', 5598 repeatcount: 'repeatCount', 5599 repeatdur: 'repeatDur', 5600 requiredextensions: 'requiredExtensions', 5601 requiredfeatures: 'requiredFeatures', 5602 resource: 'resource', 5603 restart: 'restart', 5604 result: 'result', 5605 results: 'results', 5606 rotate: 'rotate', 5607 rx: 'rx', 5608 ry: 'ry', 5609 scale: 'scale', 5610 security: 'security', 5611 seed: 'seed', 5612 shaperendering: 'shapeRendering', 5613 'shape-rendering': 'shapeRendering', 5614 slope: 'slope', 5615 spacing: 'spacing', 5616 specularconstant: 'specularConstant', 5617 specularexponent: 'specularExponent', 5618 speed: 'speed', 5619 spreadmethod: 'spreadMethod', 5620 startoffset: 'startOffset', 5621 stddeviation: 'stdDeviation', 5622 stemh: 'stemh', 5623 stemv: 'stemv', 5624 stitchtiles: 'stitchTiles', 5625 stopcolor: 'stopColor', 5626 'stop-color': 'stopColor', 5627 stopopacity: 'stopOpacity', 5628 'stop-opacity': 'stopOpacity', 5629 strikethroughposition: 'strikethroughPosition', 5630 'strikethrough-position': 'strikethroughPosition', 5631 strikethroughthickness: 'strikethroughThickness', 5632 'strikethrough-thickness': 'strikethroughThickness', 5633 string: 'string', 5634 stroke: 'stroke', 5635 strokedasharray: 'strokeDasharray', 5636 'stroke-dasharray': 'strokeDasharray', 5637 strokedashoffset: 'strokeDashoffset', 5638 'stroke-dashoffset': 'strokeDashoffset', 5639 strokelinecap: 'strokeLinecap', 5640 'stroke-linecap': 'strokeLinecap', 5641 strokelinejoin: 'strokeLinejoin', 5642 'stroke-linejoin': 'strokeLinejoin', 5643 strokemiterlimit: 'strokeMiterlimit', 5644 'stroke-miterlimit': 'strokeMiterlimit', 5645 strokewidth: 'strokeWidth', 5646 'stroke-width': 'strokeWidth', 5647 strokeopacity: 'strokeOpacity', 5648 'stroke-opacity': 'strokeOpacity', 5649 suppresscontenteditablewarning: 'suppressContentEditableWarning', 5650 suppresshydrationwarning: 'suppressHydrationWarning', 5651 surfacescale: 'surfaceScale', 5652 systemlanguage: 'systemLanguage', 5653 tablevalues: 'tableValues', 5654 targetx: 'targetX', 5655 targety: 'targetY', 5656 textanchor: 'textAnchor', 5657 'text-anchor': 'textAnchor', 5658 textdecoration: 'textDecoration', 5659 'text-decoration': 'textDecoration', 5660 textlength: 'textLength', 5661 textrendering: 'textRendering', 5662 'text-rendering': 'textRendering', 5663 to: 'to', 5664 transform: 'transform', 5665 typeof: 'typeof', 5666 u1: 'u1', 5667 u2: 'u2', 5668 underlineposition: 'underlinePosition', 5669 'underline-position': 'underlinePosition', 5670 underlinethickness: 'underlineThickness', 5671 'underline-thickness': 'underlineThickness', 5672 unicode: 'unicode', 5673 unicodebidi: 'unicodeBidi', 5674 'unicode-bidi': 'unicodeBidi', 5675 unicoderange: 'unicodeRange', 5676 'unicode-range': 'unicodeRange', 5677 unitsperem: 'unitsPerEm', 5678 'units-per-em': 'unitsPerEm', 5679 unselectable: 'unselectable', 5680 valphabetic: 'vAlphabetic', 5681 'v-alphabetic': 'vAlphabetic', 5682 values: 'values', 5683 vectoreffect: 'vectorEffect', 5684 'vector-effect': 'vectorEffect', 5685 version: 'version', 5686 vertadvy: 'vertAdvY', 5687 'vert-adv-y': 'vertAdvY', 5688 vertoriginx: 'vertOriginX', 5689 'vert-origin-x': 'vertOriginX', 5690 vertoriginy: 'vertOriginY', 5691 'vert-origin-y': 'vertOriginY', 5692 vhanging: 'vHanging', 5693 'v-hanging': 'vHanging', 5694 videographic: 'vIdeographic', 5695 'v-ideographic': 'vIdeographic', 5696 viewbox: 'viewBox', 5697 viewtarget: 'viewTarget', 5698 visibility: 'visibility', 5699 vmathematical: 'vMathematical', 5700 'v-mathematical': 'vMathematical', 5701 vocab: 'vocab', 5702 widths: 'widths', 5703 wordspacing: 'wordSpacing', 5704 'word-spacing': 'wordSpacing', 5705 writingmode: 'writingMode', 5706 'writing-mode': 'writingMode', 5707 x1: 'x1', 5708 x2: 'x2', 5709 x: 'x', 5710 xchannelselector: 'xChannelSelector', 5711 xheight: 'xHeight', 5712 'x-height': 'xHeight', 5713 xlinkactuate: 'xlinkActuate', 5714 'xlink:actuate': 'xlinkActuate', 5715 xlinkarcrole: 'xlinkArcrole', 5716 'xlink:arcrole': 'xlinkArcrole', 5717 xlinkhref: 'xlinkHref', 5718 'xlink:href': 'xlinkHref', 5719 xlinkrole: 'xlinkRole', 5720 'xlink:role': 'xlinkRole', 5721 xlinkshow: 'xlinkShow', 5722 'xlink:show': 'xlinkShow', 5723 xlinktitle: 'xlinkTitle', 5724 'xlink:title': 'xlinkTitle', 5725 xlinktype: 'xlinkType', 5726 'xlink:type': 'xlinkType', 5727 xmlbase: 'xmlBase', 5728 'xml:base': 'xmlBase', 5729 xmllang: 'xmlLang', 5730 'xml:lang': 'xmlLang', 5731 xmlns: 'xmlns', 5732 'xml:space': 'xmlSpace', 5733 xmlnsxlink: 'xmlnsXlink', 5734 'xmlns:xlink': 'xmlnsXlink', 5735 xmlspace: 'xmlSpace', 5736 y1: 'y1', 5737 y2: 'y2', 5738 y: 'y', 5739 ychannelselector: 'yChannelSelector', 5740 z: 'z', 5741 zoomandpan: 'zoomAndPan' 5742}; 5743 5744var ariaProperties = { 5745 'aria-current': 0, 5746 // state 5747 'aria-details': 0, 5748 'aria-disabled': 0, 5749 // state 5750 'aria-hidden': 0, 5751 // state 5752 'aria-invalid': 0, 5753 // state 5754 'aria-keyshortcuts': 0, 5755 'aria-label': 0, 5756 'aria-roledescription': 0, 5757 // Widget Attributes 5758 'aria-autocomplete': 0, 5759 'aria-checked': 0, 5760 'aria-expanded': 0, 5761 'aria-haspopup': 0, 5762 'aria-level': 0, 5763 'aria-modal': 0, 5764 'aria-multiline': 0, 5765 'aria-multiselectable': 0, 5766 'aria-orientation': 0, 5767 'aria-placeholder': 0, 5768 'aria-pressed': 0, 5769 'aria-readonly': 0, 5770 'aria-required': 0, 5771 'aria-selected': 0, 5772 'aria-sort': 0, 5773 'aria-valuemax': 0, 5774 'aria-valuemin': 0, 5775 'aria-valuenow': 0, 5776 'aria-valuetext': 0, 5777 // Live Region Attributes 5778 'aria-atomic': 0, 5779 'aria-busy': 0, 5780 'aria-live': 0, 5781 'aria-relevant': 0, 5782 // Drag-and-Drop Attributes 5783 'aria-dropeffect': 0, 5784 'aria-grabbed': 0, 5785 // Relationship Attributes 5786 'aria-activedescendant': 0, 5787 'aria-colcount': 0, 5788 'aria-colindex': 0, 5789 'aria-colspan': 0, 5790 'aria-controls': 0, 5791 'aria-describedby': 0, 5792 'aria-errormessage': 0, 5793 'aria-flowto': 0, 5794 'aria-labelledby': 0, 5795 'aria-owns': 0, 5796 'aria-posinset': 0, 5797 'aria-rowcount': 0, 5798 'aria-rowindex': 0, 5799 'aria-rowspan': 0, 5800 'aria-setsize': 0 5801}; 5802 5803var warnedProperties = {}; 5804var rARIA = new RegExp('^(aria)-[' + ATTRIBUTE_NAME_CHAR + ']*$'); 5805var rARIACamel = new RegExp('^(aria)[A-Z][' + ATTRIBUTE_NAME_CHAR + ']*$'); 5806var hasOwnProperty$1 = Object.prototype.hasOwnProperty; 5807 5808function validateProperty(tagName, name) { 5809 { 5810 if (hasOwnProperty$1.call(warnedProperties, name) && warnedProperties[name]) { 5811 return true; 5812 } 5813 5814 if (rARIACamel.test(name)) { 5815 var ariaName = 'aria-' + name.slice(4).toLowerCase(); 5816 var correctName = ariaProperties.hasOwnProperty(ariaName) ? ariaName : null; // If this is an aria-* attribute, but is not listed in the known DOM 5817 // DOM properties, then it is an invalid aria-* attribute. 5818 5819 if (correctName == null) { 5820 error('Invalid ARIA attribute `%s`. ARIA attributes follow the pattern aria-* and must be lowercase.', name); 5821 5822 warnedProperties[name] = true; 5823 return true; 5824 } // aria-* attributes should be lowercase; suggest the lowercase version. 5825 5826 5827 if (name !== correctName) { 5828 error('Invalid ARIA attribute `%s`. Did you mean `%s`?', name, correctName); 5829 5830 warnedProperties[name] = true; 5831 return true; 5832 } 5833 } 5834 5835 if (rARIA.test(name)) { 5836 var lowerCasedName = name.toLowerCase(); 5837 var standardName = ariaProperties.hasOwnProperty(lowerCasedName) ? lowerCasedName : null; // If this is an aria-* attribute, but is not listed in the known DOM 5838 // DOM properties, then it is an invalid aria-* attribute. 5839 5840 if (standardName == null) { 5841 warnedProperties[name] = true; 5842 return false; 5843 } // aria-* attributes should be lowercase; suggest the lowercase version. 5844 5845 5846 if (name !== standardName) { 5847 error('Unknown ARIA attribute `%s`. Did you mean `%s`?', name, standardName); 5848 5849 warnedProperties[name] = true; 5850 return true; 5851 } 5852 } 5853 } 5854 5855 return true; 5856} 5857 5858function warnInvalidARIAProps(type, props) { 5859 { 5860 var invalidProps = []; 5861 5862 for (var key in props) { 5863 var isValid = validateProperty(type, key); 5864 5865 if (!isValid) { 5866 invalidProps.push(key); 5867 } 5868 } 5869 5870 var unknownPropString = invalidProps.map(function (prop) { 5871 return '`' + prop + '`'; 5872 }).join(', '); 5873 5874 if (invalidProps.length === 1) { 5875 error('Invalid aria prop %s on <%s> tag. ' + 'For details, see https://reactjs.org/link/invalid-aria-props', unknownPropString, type); 5876 } else if (invalidProps.length > 1) { 5877 error('Invalid aria props %s on <%s> tag. ' + 'For details, see https://reactjs.org/link/invalid-aria-props', unknownPropString, type); 5878 } 5879 } 5880} 5881 5882function validateProperties(type, props) { 5883 if (isCustomComponent(type, props)) { 5884 return; 5885 } 5886 5887 warnInvalidARIAProps(type, props); 5888} 5889 5890var didWarnValueNull = false; 5891function validateProperties$1(type, props) { 5892 { 5893 if (type !== 'input' && type !== 'textarea' && type !== 'select') { 5894 return; 5895 } 5896 5897 if (props != null && props.value === null && !didWarnValueNull) { 5898 didWarnValueNull = true; 5899 5900 if (type === 'select' && props.multiple) { 5901 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); 5902 } else { 5903 error('`value` prop on `%s` should not be null. ' + 'Consider using an empty string to clear the component or `undefined` ' + 'for uncontrolled components.', type); 5904 } 5905 } 5906 } 5907} 5908 5909var validateProperty$1 = function () {}; 5910 5911{ 5912 var warnedProperties$1 = {}; 5913 var _hasOwnProperty = Object.prototype.hasOwnProperty; 5914 var EVENT_NAME_REGEX = /^on./; 5915 var INVALID_EVENT_NAME_REGEX = /^on[^A-Z]/; 5916 var rARIA$1 = new RegExp('^(aria)-[' + ATTRIBUTE_NAME_CHAR + ']*$'); 5917 var rARIACamel$1 = new RegExp('^(aria)[A-Z][' + ATTRIBUTE_NAME_CHAR + ']*$'); 5918 5919 validateProperty$1 = function (tagName, name, value, eventRegistry) { 5920 if (_hasOwnProperty.call(warnedProperties$1, name) && warnedProperties$1[name]) { 5921 return true; 5922 } 5923 5924 var lowerCasedName = name.toLowerCase(); 5925 5926 if (lowerCasedName === 'onfocusin' || lowerCasedName === 'onfocusout') { 5927 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.'); 5928 5929 warnedProperties$1[name] = true; 5930 return true; 5931 } // We can't rely on the event system being injected on the server. 5932 5933 5934 if (eventRegistry != null) { 5935 var registrationNameDependencies = eventRegistry.registrationNameDependencies, 5936 possibleRegistrationNames = eventRegistry.possibleRegistrationNames; 5937 5938 if (registrationNameDependencies.hasOwnProperty(name)) { 5939 return true; 5940 } 5941 5942 var registrationName = possibleRegistrationNames.hasOwnProperty(lowerCasedName) ? possibleRegistrationNames[lowerCasedName] : null; 5943 5944 if (registrationName != null) { 5945 error('Invalid event handler property `%s`. Did you mean `%s`?', name, registrationName); 5946 5947 warnedProperties$1[name] = true; 5948 return true; 5949 } 5950 5951 if (EVENT_NAME_REGEX.test(name)) { 5952 error('Unknown event handler property `%s`. It will be ignored.', name); 5953 5954 warnedProperties$1[name] = true; 5955 return true; 5956 } 5957 } else if (EVENT_NAME_REGEX.test(name)) { 5958 // If no event plugins have been injected, we are in a server environment. 5959 // So we can't tell if the event name is correct for sure, but we can filter 5960 // out known bad ones like `onclick`. We can't suggest a specific replacement though. 5961 if (INVALID_EVENT_NAME_REGEX.test(name)) { 5962 error('Invalid event handler property `%s`. ' + 'React events use the camelCase naming convention, for example `onClick`.', name); 5963 } 5964 5965 warnedProperties$1[name] = true; 5966 return true; 5967 } // Let the ARIA attribute hook validate ARIA attributes 5968 5969 5970 if (rARIA$1.test(name) || rARIACamel$1.test(name)) { 5971 return true; 5972 } 5973 5974 if (lowerCasedName === 'innerhtml') { 5975 error('Directly setting property `innerHTML` is not permitted. ' + 'For more information, lookup documentation on `dangerouslySetInnerHTML`.'); 5976 5977 warnedProperties$1[name] = true; 5978 return true; 5979 } 5980 5981 if (lowerCasedName === 'aria') { 5982 error('The `aria` attribute is reserved for future use in React. ' + 'Pass individual `aria-` attributes instead.'); 5983 5984 warnedProperties$1[name] = true; 5985 return true; 5986 } 5987 5988 if (lowerCasedName === 'is' && value !== null && value !== undefined && typeof value !== 'string') { 5989 error('Received a `%s` for a string attribute `is`. If this is expected, cast ' + 'the value to a string.', typeof value); 5990 5991 warnedProperties$1[name] = true; 5992 return true; 5993 } 5994 5995 if (typeof value === 'number' && isNaN(value)) { 5996 error('Received NaN for the `%s` attribute. If this is expected, cast ' + 'the value to a string.', name); 5997 5998 warnedProperties$1[name] = true; 5999 return true; 6000 } 6001 6002 var propertyInfo = getPropertyInfo(name); 6003 var isReserved = propertyInfo !== null && propertyInfo.type === RESERVED; // Known attributes should match the casing specified in the property config. 6004 6005 if (possibleStandardNames.hasOwnProperty(lowerCasedName)) { 6006 var standardName = possibleStandardNames[lowerCasedName]; 6007 6008 if (standardName !== name) { 6009 error('Invalid DOM property `%s`. Did you mean `%s`?', name, standardName); 6010 6011 warnedProperties$1[name] = true; 6012 return true; 6013 } 6014 } else if (!isReserved && name !== lowerCasedName) { 6015 // Unknown attributes should have lowercase casing since that's how they 6016 // will be cased anyway with server rendering. 6017 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); 6018 6019 warnedProperties$1[name] = true; 6020 return true; 6021 } 6022 6023 if (typeof value === 'boolean' && shouldRemoveAttributeWithWarning(name, value, propertyInfo, false)) { 6024 if (value) { 6025 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); 6026 } else { 6027 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); 6028 } 6029 6030 warnedProperties$1[name] = true; 6031 return true; 6032 } // Now that we've validated casing, do not validate 6033 // data types for reserved props 6034 6035 6036 if (isReserved) { 6037 return true; 6038 } // Warn when a known attribute is a bad type 6039 6040 6041 if (shouldRemoveAttributeWithWarning(name, value, propertyInfo, false)) { 6042 warnedProperties$1[name] = true; 6043 return false; 6044 } // Warn when passing the strings 'false' or 'true' into a boolean prop 6045 6046 6047 if ((value === 'false' || value === 'true') && propertyInfo !== null && propertyInfo.type === BOOLEAN) { 6048 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); 6049 6050 warnedProperties$1[name] = true; 6051 return true; 6052 } 6053 6054 return true; 6055 }; 6056} 6057 6058var warnUnknownProperties = function (type, props, eventRegistry) { 6059 { 6060 var unknownProps = []; 6061 6062 for (var key in props) { 6063 var isValid = validateProperty$1(type, key, props[key], eventRegistry); 6064 6065 if (!isValid) { 6066 unknownProps.push(key); 6067 } 6068 } 6069 6070 var unknownPropString = unknownProps.map(function (prop) { 6071 return '`' + prop + '`'; 6072 }).join(', '); 6073 6074 if (unknownProps.length === 1) { 6075 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); 6076 } else if (unknownProps.length > 1) { 6077 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); 6078 } 6079 } 6080}; 6081 6082function validateProperties$2(type, props, eventRegistry) { 6083 if (isCustomComponent(type, props)) { 6084 return; 6085 } 6086 6087 warnUnknownProperties(type, props, eventRegistry); 6088} 6089 6090var IS_EVENT_HANDLE_NON_MANAGED_NODE = 1; 6091var IS_NON_DELEGATED = 1 << 1; 6092var IS_CAPTURE_PHASE = 1 << 2; 6093var IS_REPLAYED = 1 << 4; 6094// set to LEGACY_FB_SUPPORT. LEGACY_FB_SUPPORT only gets set when 6095// we call willDeferLaterForLegacyFBSupport, thus not bailing out 6096// will result in endless cycles like an infinite loop. 6097// We also don't want to defer during event replaying. 6098 6099var SHOULD_NOT_PROCESS_POLYFILL_EVENT_PLUGINS = IS_EVENT_HANDLE_NON_MANAGED_NODE | IS_NON_DELEGATED | IS_CAPTURE_PHASE; 6100 6101/** 6102 * Gets the target node from a native browser event by accounting for 6103 * inconsistencies in browser DOM APIs. 6104 * 6105 * @param {object} nativeEvent Native browser event. 6106 * @return {DOMEventTarget} Target node. 6107 */ 6108 6109function getEventTarget(nativeEvent) { 6110 // Fallback to nativeEvent.srcElement for IE9 6111 // https://github.com/facebook/react/issues/12506 6112 var target = nativeEvent.target || nativeEvent.srcElement || window; // Normalize SVG <use> element events #4963 6113 6114 if (target.correspondingUseElement) { 6115 target = target.correspondingUseElement; 6116 } // Safari may fire events on text nodes (Node.TEXT_NODE is 3). 6117 // @see http://www.quirksmode.org/js/events_properties.html 6118 6119 6120 return target.nodeType === TEXT_NODE ? target.parentNode : target; 6121} 6122 6123var restoreImpl = null; 6124var restoreTarget = null; 6125var restoreQueue = null; 6126 6127function restoreStateOfTarget(target) { 6128 // We perform this translation at the end of the event loop so that we 6129 // always receive the correct fiber here 6130 var internalInstance = getInstanceFromNode(target); 6131 6132 if (!internalInstance) { 6133 // Unmounted 6134 return; 6135 } 6136 6137 if (!(typeof restoreImpl === 'function')) { 6138 { 6139 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." ); 6140 } 6141 } 6142 6143 var stateNode = internalInstance.stateNode; // Guard against Fiber being unmounted. 6144 6145 if (stateNode) { 6146 var _props = getFiberCurrentPropsFromNode(stateNode); 6147 6148 restoreImpl(internalInstance.stateNode, internalInstance.type, _props); 6149 } 6150} 6151 6152function setRestoreImplementation(impl) { 6153 restoreImpl = impl; 6154} 6155function enqueueStateRestore(target) { 6156 if (restoreTarget) { 6157 if (restoreQueue) { 6158 restoreQueue.push(target); 6159 } else { 6160 restoreQueue = [target]; 6161 } 6162 } else { 6163 restoreTarget = target; 6164 } 6165} 6166function needsStateRestore() { 6167 return restoreTarget !== null || restoreQueue !== null; 6168} 6169function restoreStateIfNeeded() { 6170 if (!restoreTarget) { 6171 return; 6172 } 6173 6174 var target = restoreTarget; 6175 var queuedTargets = restoreQueue; 6176 restoreTarget = null; 6177 restoreQueue = null; 6178 restoreStateOfTarget(target); 6179 6180 if (queuedTargets) { 6181 for (var i = 0; i < queuedTargets.length; i++) { 6182 restoreStateOfTarget(queuedTargets[i]); 6183 } 6184 } 6185} 6186 6187// the renderer. Such as when we're dispatching events or if third party 6188// libraries need to call batchedUpdates. Eventually, this API will go away when 6189// everything is batched by default. We'll then have a similar API to opt-out of 6190// scheduled work and instead do synchronous work. 6191// Defaults 6192 6193var batchedUpdatesImpl = function (fn, bookkeeping) { 6194 return fn(bookkeeping); 6195}; 6196 6197var discreteUpdatesImpl = function (fn, a, b, c, d) { 6198 return fn(a, b, c, d); 6199}; 6200 6201var flushDiscreteUpdatesImpl = function () {}; 6202 6203var batchedEventUpdatesImpl = batchedUpdatesImpl; 6204var isInsideEventHandler = false; 6205var isBatchingEventUpdates = false; 6206 6207function finishEventHandler() { 6208 // Here we wait until all updates have propagated, which is important 6209 // when using controlled components within layers: 6210 // https://github.com/facebook/react/issues/1698 6211 // Then we restore state of any controlled component. 6212 var controlledComponentsHavePendingUpdates = needsStateRestore(); 6213 6214 if (controlledComponentsHavePendingUpdates) { 6215 // If a controlled event was fired, we may need to restore the state of 6216 // the DOM node back to the controlled value. This is necessary when React 6217 // bails out of the update without touching the DOM. 6218 flushDiscreteUpdatesImpl(); 6219 restoreStateIfNeeded(); 6220 } 6221} 6222 6223function batchedUpdates(fn, bookkeeping) { 6224 if (isInsideEventHandler) { 6225 // If we are currently inside another batch, we need to wait until it 6226 // fully completes before restoring state. 6227 return fn(bookkeeping); 6228 } 6229 6230 isInsideEventHandler = true; 6231 6232 try { 6233 return batchedUpdatesImpl(fn, bookkeeping); 6234 } finally { 6235 isInsideEventHandler = false; 6236 finishEventHandler(); 6237 } 6238} 6239function batchedEventUpdates(fn, a, b) { 6240 if (isBatchingEventUpdates) { 6241 // If we are currently inside another batch, we need to wait until it 6242 // fully completes before restoring state. 6243 return fn(a, b); 6244 } 6245 6246 isBatchingEventUpdates = true; 6247 6248 try { 6249 return batchedEventUpdatesImpl(fn, a, b); 6250 } finally { 6251 isBatchingEventUpdates = false; 6252 finishEventHandler(); 6253 } 6254} 6255function discreteUpdates(fn, a, b, c, d) { 6256 var prevIsInsideEventHandler = isInsideEventHandler; 6257 isInsideEventHandler = true; 6258 6259 try { 6260 return discreteUpdatesImpl(fn, a, b, c, d); 6261 } finally { 6262 isInsideEventHandler = prevIsInsideEventHandler; 6263 6264 if (!isInsideEventHandler) { 6265 finishEventHandler(); 6266 } 6267 } 6268} 6269function flushDiscreteUpdatesIfNeeded(timeStamp) { 6270 { 6271 if (!isInsideEventHandler) { 6272 flushDiscreteUpdatesImpl(); 6273 } 6274 } 6275} 6276function setBatchingImplementation(_batchedUpdatesImpl, _discreteUpdatesImpl, _flushDiscreteUpdatesImpl, _batchedEventUpdatesImpl) { 6277 batchedUpdatesImpl = _batchedUpdatesImpl; 6278 discreteUpdatesImpl = _discreteUpdatesImpl; 6279 flushDiscreteUpdatesImpl = _flushDiscreteUpdatesImpl; 6280 batchedEventUpdatesImpl = _batchedEventUpdatesImpl; 6281} 6282 6283function isInteractive(tag) { 6284 return tag === 'button' || tag === 'input' || tag === 'select' || tag === 'textarea'; 6285} 6286 6287function shouldPreventMouseEvent(name, type, props) { 6288 switch (name) { 6289 case 'onClick': 6290 case 'onClickCapture': 6291 case 'onDoubleClick': 6292 case 'onDoubleClickCapture': 6293 case 'onMouseDown': 6294 case 'onMouseDownCapture': 6295 case 'onMouseMove': 6296 case 'onMouseMoveCapture': 6297 case 'onMouseUp': 6298 case 'onMouseUpCapture': 6299 case 'onMouseEnter': 6300 return !!(props.disabled && isInteractive(type)); 6301 6302 default: 6303 return false; 6304 } 6305} 6306/** 6307 * @param {object} inst The instance, which is the source of events. 6308 * @param {string} registrationName Name of listener (e.g. `onClick`). 6309 * @return {?function} The stored callback. 6310 */ 6311 6312 6313function getListener(inst, registrationName) { 6314 var stateNode = inst.stateNode; 6315 6316 if (stateNode === null) { 6317 // Work in progress (ex: onload events in incremental mode). 6318 return null; 6319 } 6320 6321 var props = getFiberCurrentPropsFromNode(stateNode); 6322 6323 if (props === null) { 6324 // Work in progress. 6325 return null; 6326 } 6327 6328 var listener = props[registrationName]; 6329 6330 if (shouldPreventMouseEvent(registrationName, inst.type, props)) { 6331 return null; 6332 } 6333 6334 if (!(!listener || typeof listener === 'function')) { 6335 { 6336 throw Error( "Expected `" + registrationName + "` listener to be a function, instead got a value of `" + typeof listener + "` type." ); 6337 } 6338 } 6339 6340 return listener; 6341} 6342 6343var passiveBrowserEventsSupported = false; // Check if browser support events with passive listeners 6344// https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#Safely_detecting_option_support 6345 6346if (canUseDOM) { 6347 try { 6348 var options = {}; // $FlowFixMe: Ignore Flow complaining about needing a value 6349 6350 Object.defineProperty(options, 'passive', { 6351 get: function () { 6352 passiveBrowserEventsSupported = true; 6353 } 6354 }); 6355 window.addEventListener('test', options, options); 6356 window.removeEventListener('test', options, options); 6357 } catch (e) { 6358 passiveBrowserEventsSupported = false; 6359 } 6360} 6361 6362function invokeGuardedCallbackProd(name, func, context, a, b, c, d, e, f) { 6363 var funcArgs = Array.prototype.slice.call(arguments, 3); 6364 6365 try { 6366 func.apply(context, funcArgs); 6367 } catch (error) { 6368 this.onError(error); 6369 } 6370} 6371 6372var invokeGuardedCallbackImpl = invokeGuardedCallbackProd; 6373 6374{ 6375 // In DEV mode, we swap out invokeGuardedCallback for a special version 6376 // that plays more nicely with the browser's DevTools. The idea is to preserve 6377 // "Pause on exceptions" behavior. Because React wraps all user-provided 6378 // functions in invokeGuardedCallback, and the production version of 6379 // invokeGuardedCallback uses a try-catch, all user exceptions are treated 6380 // like caught exceptions, and the DevTools won't pause unless the developer 6381 // takes the extra step of enabling pause on caught exceptions. This is 6382 // unintuitive, though, because even though React has caught the error, from 6383 // the developer's perspective, the error is uncaught. 6384 // 6385 // To preserve the expected "Pause on exceptions" behavior, we don't use a 6386 // try-catch in DEV. Instead, we synchronously dispatch a fake event to a fake 6387 // DOM node, and call the user-provided callback from inside an event handler 6388 // for that fake event. If the callback throws, the error is "captured" using 6389 // a global event handler. But because the error happens in a different 6390 // event loop context, it does not interrupt the normal program flow. 6391 // Effectively, this gives us try-catch behavior without actually using 6392 // try-catch. Neat! 6393 // Check that the browser supports the APIs we need to implement our special 6394 // DEV version of invokeGuardedCallback 6395 if (typeof window !== 'undefined' && typeof window.dispatchEvent === 'function' && typeof document !== 'undefined' && typeof document.createEvent === 'function') { 6396 var fakeNode = document.createElement('react'); 6397 6398 invokeGuardedCallbackImpl = function invokeGuardedCallbackDev(name, func, context, a, b, c, d, e, f) { 6399 // If document doesn't exist we know for sure we will crash in this method 6400 // when we call document.createEvent(). However this can cause confusing 6401 // errors: https://github.com/facebookincubator/create-react-app/issues/3482 6402 // So we preemptively throw with a better message instead. 6403 if (!(typeof document !== 'undefined')) { 6404 { 6405 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." ); 6406 } 6407 } 6408 6409 var evt = document.createEvent('Event'); 6410 var didCall = false; // Keeps track of whether the user-provided callback threw an error. We 6411 // set this to true at the beginning, then set it to false right after 6412 // calling the function. If the function errors, `didError` will never be 6413 // set to false. This strategy works even if the browser is flaky and 6414 // fails to call our global error handler, because it doesn't rely on 6415 // the error event at all. 6416 6417 var didError = true; // Keeps track of the value of window.event so that we can reset it 6418 // during the callback to let user code access window.event in the 6419 // browsers that support it. 6420 6421 var windowEvent = window.event; // Keeps track of the descriptor of window.event to restore it after event 6422 // dispatching: https://github.com/facebook/react/issues/13688 6423 6424 var windowEventDescriptor = Object.getOwnPropertyDescriptor(window, 'event'); 6425 6426 function restoreAfterDispatch() { 6427 // We immediately remove the callback from event listeners so that 6428 // nested `invokeGuardedCallback` calls do not clash. Otherwise, a 6429 // nested call would trigger the fake event handlers of any call higher 6430 // in the stack. 6431 fakeNode.removeEventListener(evtType, callCallback, false); // We check for window.hasOwnProperty('event') to prevent the 6432 // window.event assignment in both IE <= 10 as they throw an error 6433 // "Member not found" in strict mode, and in Firefox which does not 6434 // support window.event. 6435 6436 if (typeof window.event !== 'undefined' && window.hasOwnProperty('event')) { 6437 window.event = windowEvent; 6438 } 6439 } // Create an event handler for our fake event. We will synchronously 6440 // dispatch our fake event using `dispatchEvent`. Inside the handler, we 6441 // call the user-provided callback. 6442 6443 6444 var funcArgs = Array.prototype.slice.call(arguments, 3); 6445 6446 function callCallback() { 6447 didCall = true; 6448 restoreAfterDispatch(); 6449 func.apply(context, funcArgs); 6450 didError = false; 6451 } // Create a global error event handler. We use this to capture the value 6452 // that was thrown. It's possible that this error handler will fire more 6453 // than once; for example, if non-React code also calls `dispatchEvent` 6454 // and a handler for that event throws. We should be resilient to most of 6455 // those cases. Even if our error event handler fires more than once, the 6456 // last error event is always used. If the callback actually does error, 6457 // we know that the last error event is the correct one, because it's not 6458 // possible for anything else to have happened in between our callback 6459 // erroring and the code that follows the `dispatchEvent` call below. If 6460 // the callback doesn't error, but the error event was fired, we know to 6461 // ignore it because `didError` will be false, as described above. 6462 6463 6464 var error; // Use this to track whether the error event is ever called. 6465 6466 var didSetError = false; 6467 var isCrossOriginError = false; 6468 6469 function handleWindowError(event) { 6470 error = event.error; 6471 didSetError = true; 6472 6473 if (error === null && event.colno === 0 && event.lineno === 0) { 6474 isCrossOriginError = true; 6475 } 6476 6477 if (event.defaultPrevented) { 6478 // Some other error handler has prevented default. 6479 // Browsers silence the error report if this happens. 6480 // We'll remember this to later decide whether to log it or not. 6481 if (error != null && typeof error === 'object') { 6482 try { 6483 error._suppressLogging = true; 6484 } catch (inner) {// Ignore. 6485 } 6486 } 6487 } 6488 } // Create a fake event type. 6489 6490 6491 var evtType = "react-" + (name ? name : 'invokeguardedcallback'); // Attach our event handlers 6492 6493 window.addEventListener('error', handleWindowError); 6494 fakeNode.addEventListener(evtType, callCallback, false); // Synchronously dispatch our fake event. If the user-provided function 6495 // errors, it will trigger our global error handler. 6496 6497 evt.initEvent(evtType, false, false); 6498 fakeNode.dispatchEvent(evt); 6499 6500 if (windowEventDescriptor) { 6501 Object.defineProperty(window, 'event', windowEventDescriptor); 6502 } 6503 6504 if (didCall && didError) { 6505 if (!didSetError) { 6506 // The callback errored, but the error event never fired. 6507 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.'); 6508 } else if (isCrossOriginError) { 6509 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.'); 6510 } 6511 6512 this.onError(error); 6513 } // Remove our event listeners 6514 6515 6516 window.removeEventListener('error', handleWindowError); 6517 6518 if (!didCall) { 6519 // Something went really wrong, and our event was not dispatched. 6520 // https://github.com/facebook/react/issues/16734 6521 // https://github.com/facebook/react/issues/16585 6522 // Fall back to the production implementation. 6523 restoreAfterDispatch(); 6524 return invokeGuardedCallbackProd.apply(this, arguments); 6525 } 6526 }; 6527 } 6528} 6529 6530var invokeGuardedCallbackImpl$1 = invokeGuardedCallbackImpl; 6531 6532var hasError = false; 6533var caughtError = null; // Used by event system to capture/rethrow the first error. 6534 6535var hasRethrowError = false; 6536var rethrowError = null; 6537var reporter = { 6538 onError: function (error) { 6539 hasError = true; 6540 caughtError = error; 6541 } 6542}; 6543/** 6544 * Call a function while guarding against errors that happens within it. 6545 * Returns an error if it throws, otherwise null. 6546 * 6547 * In production, this is implemented using a try-catch. The reason we don't 6548 * use a try-catch directly is so that we can swap out a different 6549 * implementation in DEV mode. 6550 * 6551 * @param {String} name of the guard to use for logging or debugging 6552 * @param {Function} func The function to invoke 6553 * @param {*} context The context to use when calling the function 6554 * @param {...*} args Arguments for function 6555 */ 6556 6557function invokeGuardedCallback(name, func, context, a, b, c, d, e, f) { 6558 hasError = false; 6559 caughtError = null; 6560 invokeGuardedCallbackImpl$1.apply(reporter, arguments); 6561} 6562/** 6563 * Same as invokeGuardedCallback, but instead of returning an error, it stores 6564 * it in a global so it can be rethrown by `rethrowCaughtError` later. 6565 * TODO: See if caughtError and rethrowError can be unified. 6566 * 6567 * @param {String} name of the guard to use for logging or debugging 6568 * @param {Function} func The function to invoke 6569 * @param {*} context The context to use when calling the function 6570 * @param {...*} args Arguments for function 6571 */ 6572 6573function invokeGuardedCallbackAndCatchFirstError(name, func, context, a, b, c, d, e, f) { 6574 invokeGuardedCallback.apply(this, arguments); 6575 6576 if (hasError) { 6577 var error = clearCaughtError(); 6578 6579 if (!hasRethrowError) { 6580 hasRethrowError = true; 6581 rethrowError = error; 6582 } 6583 } 6584} 6585/** 6586 * During execution of guarded functions we will capture the first error which 6587 * we will rethrow to be handled by the top level error handler. 6588 */ 6589 6590function rethrowCaughtError() { 6591 if (hasRethrowError) { 6592 var error = rethrowError; 6593 hasRethrowError = false; 6594 rethrowError = null; 6595 throw error; 6596 } 6597} 6598function hasCaughtError() { 6599 return hasError; 6600} 6601function clearCaughtError() { 6602 if (hasError) { 6603 var error = caughtError; 6604 hasError = false; 6605 caughtError = null; 6606 return error; 6607 } else { 6608 { 6609 { 6610 throw Error( "clearCaughtError was called but no error was captured. This error is likely caused by a bug in React. Please file an issue." ); 6611 } 6612 } 6613 } 6614} 6615 6616/** 6617 * `ReactInstanceMap` maintains a mapping from a public facing stateful 6618 * instance (key) and the internal representation (value). This allows public 6619 * methods to accept the user facing instance as an argument and map them back 6620 * to internal methods. 6621 * 6622 * Note that this module is currently shared and assumed to be stateless. 6623 * If this becomes an actual Map, that will break. 6624 */ 6625function get(key) { 6626 return key._reactInternals; 6627} 6628function has(key) { 6629 return key._reactInternals !== undefined; 6630} 6631function set(key, value) { 6632 key._reactInternals = value; 6633} 6634 6635// Don't change these two values. They're used by React Dev Tools. 6636var NoFlags = 6637/* */ 66380; 6639var PerformedWork = 6640/* */ 66411; // You can change the rest (and add more). 6642 6643var Placement = 6644/* */ 66452; 6646var Update = 6647/* */ 66484; 6649var PlacementAndUpdate = 6650/* */ 66516; 6652var Deletion = 6653/* */ 66548; 6655var ContentReset = 6656/* */ 665716; 6658var Callback = 6659/* */ 666032; 6661var DidCapture = 6662/* */ 666364; 6664var Ref = 6665/* */ 6666128; 6667var Snapshot = 6668/* */ 6669256; 6670var Passive = 6671/* */ 6672512; // TODO (effects) Remove this bit once the new reconciler is synced to the old. 6673 6674var PassiveUnmountPendingDev = 6675/* */ 66768192; 6677var Hydrating = 6678/* */ 66791024; 6680var HydratingAndUpdate = 6681/* */ 66821028; // Passive & Update & Callback & Ref & Snapshot 6683 6684var LifecycleEffectMask = 6685/* */ 6686932; // Union of all host effects 6687 6688var HostEffectMask = 6689/* */ 66902047; // These are not really side effects, but we still reuse this field. 6691 6692var Incomplete = 6693/* */ 66942048; 6695var ShouldCapture = 6696/* */ 66974096; 6698var ForceUpdateForLegacySuspense = 6699/* */ 670016384; // Static tags describe aspects of a fiber that are not specific to a render, 6701 6702var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner; 6703function getNearestMountedFiber(fiber) { 6704 var node = fiber; 6705 var nearestMounted = fiber; 6706 6707 if (!fiber.alternate) { 6708 // If there is no alternate, this might be a new tree that isn't inserted 6709 // yet. If it is, then it will have a pending insertion effect on it. 6710 var nextNode = node; 6711 6712 do { 6713 node = nextNode; 6714 6715 if ((node.flags & (Placement | Hydrating)) !== NoFlags) { 6716 // This is an insertion or in-progress hydration. The nearest possible 6717 // mounted fiber is the parent but we need to continue to figure out 6718 // if that one is still mounted. 6719 nearestMounted = node.return; 6720 } 6721 6722 nextNode = node.return; 6723 } while (nextNode); 6724 } else { 6725 while (node.return) { 6726 node = node.return; 6727 } 6728 } 6729 6730 if (node.tag === HostRoot) { 6731 // TODO: Check if this was a nested HostRoot when used with 6732 // renderContainerIntoSubtree. 6733 return nearestMounted; 6734 } // If we didn't hit the root, that means that we're in an disconnected tree 6735 // that has been unmounted. 6736 6737 6738 return null; 6739} 6740function getSuspenseInstanceFromFiber(fiber) { 6741 if (fiber.tag === SuspenseComponent) { 6742 var suspenseState = fiber.memoizedState; 6743 6744 if (suspenseState === null) { 6745 var current = fiber.alternate; 6746 6747 if (current !== null) { 6748 suspenseState = current.memoizedState; 6749 } 6750 } 6751 6752 if (suspenseState !== null) { 6753 return suspenseState.dehydrated; 6754 } 6755 } 6756 6757 return null; 6758} 6759function getContainerFromFiber(fiber) { 6760 return fiber.tag === HostRoot ? fiber.stateNode.containerInfo : null; 6761} 6762function isFiberMounted(fiber) { 6763 return getNearestMountedFiber(fiber) === fiber; 6764} 6765function isMounted(component) { 6766 { 6767 var owner = ReactCurrentOwner.current; 6768 6769 if (owner !== null && owner.tag === ClassComponent) { 6770 var ownerFiber = owner; 6771 var instance = ownerFiber.stateNode; 6772 6773 if (!instance._warnedAboutRefsInRender) { 6774 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'); 6775 } 6776 6777 instance._warnedAboutRefsInRender = true; 6778 } 6779 } 6780 6781 var fiber = get(component); 6782 6783 if (!fiber) { 6784 return false; 6785 } 6786 6787 return getNearestMountedFiber(fiber) === fiber; 6788} 6789 6790function assertIsMounted(fiber) { 6791 if (!(getNearestMountedFiber(fiber) === fiber)) { 6792 { 6793 throw Error( "Unable to find node on an unmounted component." ); 6794 } 6795 } 6796} 6797 6798function findCurrentFiberUsingSlowPath(fiber) { 6799 var alternate = fiber.alternate; 6800 6801 if (!alternate) { 6802 // If there is no alternate, then we only need to check if it is mounted. 6803 var nearestMounted = getNearestMountedFiber(fiber); 6804 6805 if (!(nearestMounted !== null)) { 6806 { 6807 throw Error( "Unable to find node on an unmounted component." ); 6808 } 6809 } 6810 6811 if (nearestMounted !== fiber) { 6812 return null; 6813 } 6814 6815 return fiber; 6816 } // If we have two possible branches, we'll walk backwards up to the root 6817 // to see what path the root points to. On the way we may hit one of the 6818 // special cases and we'll deal with them. 6819 6820 6821 var a = fiber; 6822 var b = alternate; 6823 6824 while (true) { 6825 var parentA = a.return; 6826 6827 if (parentA === null) { 6828 // We're at the root. 6829 break; 6830 } 6831 6832 var parentB = parentA.alternate; 6833 6834 if (parentB === null) { 6835 // There is no alternate. This is an unusual case. Currently, it only 6836 // happens when a Suspense component is hidden. An extra fragment fiber 6837 // is inserted in between the Suspense fiber and its children. Skip 6838 // over this extra fragment fiber and proceed to the next parent. 6839 var nextParent = parentA.return; 6840 6841 if (nextParent !== null) { 6842 a = b = nextParent; 6843 continue; 6844 } // If there's no parent, we're at the root. 6845 6846 6847 break; 6848 } // If both copies of the parent fiber point to the same child, we can 6849 // assume that the child is current. This happens when we bailout on low 6850 // priority: the bailed out fiber's child reuses the current child. 6851 6852 6853 if (parentA.child === parentB.child) { 6854 var child = parentA.child; 6855 6856 while (child) { 6857 if (child === a) { 6858 // We've determined that A is the current branch. 6859 assertIsMounted(parentA); 6860 return fiber; 6861 } 6862 6863 if (child === b) { 6864 // We've determined that B is the current branch. 6865 assertIsMounted(parentA); 6866 return alternate; 6867 } 6868 6869 child = child.sibling; 6870 } // We should never have an alternate for any mounting node. So the only 6871 // way this could possibly happen is if this was unmounted, if at all. 6872 6873 6874 { 6875 { 6876 throw Error( "Unable to find node on an unmounted component." ); 6877 } 6878 } 6879 } 6880 6881 if (a.return !== b.return) { 6882 // The return pointer of A and the return pointer of B point to different 6883 // fibers. We assume that return pointers never criss-cross, so A must 6884 // belong to the child set of A.return, and B must belong to the child 6885 // set of B.return. 6886 a = parentA; 6887 b = parentB; 6888 } else { 6889 // The return pointers point to the same fiber. We'll have to use the 6890 // default, slow path: scan the child sets of each parent alternate to see 6891 // which child belongs to which set. 6892 // 6893 // Search parent A's child set 6894 var didFindChild = false; 6895 var _child = parentA.child; 6896 6897 while (_child) { 6898 if (_child === a) { 6899 didFindChild = true; 6900 a = parentA; 6901 b = parentB; 6902 break; 6903 } 6904 6905 if (_child === b) { 6906 didFindChild = true; 6907 b = parentA; 6908 a = parentB; 6909 break; 6910 } 6911 6912 _child = _child.sibling; 6913 } 6914 6915 if (!didFindChild) { 6916 // Search parent B's child set 6917 _child = parentB.child; 6918 6919 while (_child) { 6920 if (_child === a) { 6921 didFindChild = true; 6922 a = parentB; 6923 b = parentA; 6924 break; 6925 } 6926 6927 if (_child === b) { 6928 didFindChild = true; 6929 b = parentB; 6930 a = parentA; 6931 break; 6932 } 6933 6934 _child = _child.sibling; 6935 } 6936 6937 if (!didFindChild) { 6938 { 6939 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." ); 6940 } 6941 } 6942 } 6943 } 6944 6945 if (!(a.alternate === b)) { 6946 { 6947 throw Error( "Return fibers should always be each others' alternates. This error is likely caused by a bug in React. Please file an issue." ); 6948 } 6949 } 6950 } // If the root is not a host container, we're in a disconnected tree. I.e. 6951 // unmounted. 6952 6953 6954 if (!(a.tag === HostRoot)) { 6955 { 6956 throw Error( "Unable to find node on an unmounted component." ); 6957 } 6958 } 6959 6960 if (a.stateNode.current === a) { 6961 // We've determined that A is the current branch. 6962 return fiber; 6963 } // Otherwise B has to be current branch. 6964 6965 6966 return alternate; 6967} 6968function findCurrentHostFiber(parent) { 6969 var currentParent = findCurrentFiberUsingSlowPath(parent); 6970 6971 if (!currentParent) { 6972 return null; 6973 } // Next we'll drill down this component to find the first HostComponent/Text. 6974 6975 6976 var node = currentParent; 6977 6978 while (true) { 6979 if (node.tag === HostComponent || node.tag === HostText) { 6980 return node; 6981 } else if (node.child) { 6982 node.child.return = node; 6983 node = node.child; 6984 continue; 6985 } 6986 6987 if (node === currentParent) { 6988 return null; 6989 } 6990 6991 while (!node.sibling) { 6992 if (!node.return || node.return === currentParent) { 6993 return null; 6994 } 6995 6996 node = node.return; 6997 } 6998 6999 node.sibling.return = node.return; 7000 node = node.sibling; 7001 } // Flow needs the return null here, but ESLint complains about it. 7002 // eslint-disable-next-line no-unreachable 7003 7004 7005 return null; 7006} 7007function findCurrentHostFiberWithNoPortals(parent) { 7008 var currentParent = findCurrentFiberUsingSlowPath(parent); 7009 7010 if (!currentParent) { 7011 return null; 7012 } // Next we'll drill down this component to find the first HostComponent/Text. 7013 7014 7015 var node = currentParent; 7016 7017 while (true) { 7018 if (node.tag === HostComponent || node.tag === HostText || enableFundamentalAPI ) { 7019 return node; 7020 } else if (node.child && node.tag !== HostPortal) { 7021 node.child.return = node; 7022 node = node.child; 7023 continue; 7024 } 7025 7026 if (node === currentParent) { 7027 return null; 7028 } 7029 7030 while (!node.sibling) { 7031 if (!node.return || node.return === currentParent) { 7032 return null; 7033 } 7034 7035 node = node.return; 7036 } 7037 7038 node.sibling.return = node.return; 7039 node = node.sibling; 7040 } // Flow needs the return null here, but ESLint complains about it. 7041 // eslint-disable-next-line no-unreachable 7042 7043 7044 return null; 7045} 7046function doesFiberContain(parentFiber, childFiber) { 7047 var node = childFiber; 7048 var parentFiberAlternate = parentFiber.alternate; 7049 7050 while (node !== null) { 7051 if (node === parentFiber || node === parentFiberAlternate) { 7052 return true; 7053 } 7054 7055 node = node.return; 7056 } 7057 7058 return false; 7059} 7060 7061var attemptUserBlockingHydration; 7062function setAttemptUserBlockingHydration(fn) { 7063 attemptUserBlockingHydration = fn; 7064} 7065var attemptContinuousHydration; 7066function setAttemptContinuousHydration(fn) { 7067 attemptContinuousHydration = fn; 7068} 7069var attemptHydrationAtCurrentPriority; 7070function setAttemptHydrationAtCurrentPriority(fn) { 7071 attemptHydrationAtCurrentPriority = fn; 7072} 7073var attemptHydrationAtPriority; 7074function setAttemptHydrationAtPriority(fn) { 7075 attemptHydrationAtPriority = fn; 7076} // TODO: Upgrade this definition once we're on a newer version of Flow that 7077var hasScheduledReplayAttempt = false; // The queue of discrete events to be replayed. 7078 7079var queuedDiscreteEvents = []; // Indicates if any continuous event targets are non-null for early bailout. 7080// if the last target was dehydrated. 7081 7082var queuedFocus = null; 7083var queuedDrag = null; 7084var queuedMouse = null; // For pointer events there can be one latest event per pointerId. 7085 7086var queuedPointers = new Map(); 7087var queuedPointerCaptures = new Map(); // We could consider replaying selectionchange and touchmoves too. 7088 7089var queuedExplicitHydrationTargets = []; 7090function hasQueuedDiscreteEvents() { 7091 return queuedDiscreteEvents.length > 0; 7092} 7093var discreteReplayableEvents = ['mousedown', 'mouseup', 'touchcancel', 'touchend', 'touchstart', 'auxclick', 'dblclick', 'pointercancel', 'pointerdown', 'pointerup', 'dragend', 'dragstart', 'drop', 'compositionend', 'compositionstart', 'keydown', 'keypress', 'keyup', 'input', 'textInput', // Intentionally camelCase 7094'copy', 'cut', 'paste', 'click', 'change', 'contextmenu', 'reset', 'submit']; 7095function isReplayableDiscreteEvent(eventType) { 7096 return discreteReplayableEvents.indexOf(eventType) > -1; 7097} 7098 7099function createQueuedReplayableEvent(blockedOn, domEventName, eventSystemFlags, targetContainer, nativeEvent) { 7100 return { 7101 blockedOn: blockedOn, 7102 domEventName: domEventName, 7103 eventSystemFlags: eventSystemFlags | IS_REPLAYED, 7104 nativeEvent: nativeEvent, 7105 targetContainers: [targetContainer] 7106 }; 7107} 7108 7109function queueDiscreteEvent(blockedOn, domEventName, eventSystemFlags, targetContainer, nativeEvent) { 7110 var queuedEvent = createQueuedReplayableEvent(blockedOn, domEventName, eventSystemFlags, targetContainer, nativeEvent); 7111 queuedDiscreteEvents.push(queuedEvent); 7112} // Resets the replaying for this type of continuous event to no event. 7113 7114function clearIfContinuousEvent(domEventName, nativeEvent) { 7115 switch (domEventName) { 7116 case 'focusin': 7117 case 'focusout': 7118 queuedFocus = null; 7119 break; 7120 7121 case 'dragenter': 7122 case 'dragleave': 7123 queuedDrag = null; 7124 break; 7125 7126 case 'mouseover': 7127 case 'mouseout': 7128 queuedMouse = null; 7129 break; 7130 7131 case 'pointerover': 7132 case 'pointerout': 7133 { 7134 var pointerId = nativeEvent.pointerId; 7135 queuedPointers.delete(pointerId); 7136 break; 7137 } 7138 7139 case 'gotpointercapture': 7140 case 'lostpointercapture': 7141 { 7142 var _pointerId = nativeEvent.pointerId; 7143 queuedPointerCaptures.delete(_pointerId); 7144 break; 7145 } 7146 } 7147} 7148 7149function accumulateOrCreateContinuousQueuedReplayableEvent(existingQueuedEvent, blockedOn, domEventName, eventSystemFlags, targetContainer, nativeEvent) { 7150 if (existingQueuedEvent === null || existingQueuedEvent.nativeEvent !== nativeEvent) { 7151 var queuedEvent = createQueuedReplayableEvent(blockedOn, domEventName, eventSystemFlags, targetContainer, nativeEvent); 7152 7153 if (blockedOn !== null) { 7154 var _fiber2 = getInstanceFromNode(blockedOn); 7155 7156 if (_fiber2 !== null) { 7157 // Attempt to increase the priority of this target. 7158 attemptContinuousHydration(_fiber2); 7159 } 7160 } 7161 7162 return queuedEvent; 7163 } // If we have already queued this exact event, then it's because 7164 // the different event systems have different DOM event listeners. 7165 // We can accumulate the flags, and the targetContainers, and 7166 // store a single event to be replayed. 7167 7168 7169 existingQueuedEvent.eventSystemFlags |= eventSystemFlags; 7170 var targetContainers = existingQueuedEvent.targetContainers; 7171 7172 if (targetContainer !== null && targetContainers.indexOf(targetContainer) === -1) { 7173 targetContainers.push(targetContainer); 7174 } 7175 7176 return existingQueuedEvent; 7177} 7178 7179function queueIfContinuousEvent(blockedOn, domEventName, eventSystemFlags, targetContainer, nativeEvent) { 7180 // These set relatedTarget to null because the replayed event will be treated as if we 7181 // moved from outside the window (no target) onto the target once it hydrates. 7182 // Instead of mutating we could clone the event. 7183 switch (domEventName) { 7184 case 'focusin': 7185 { 7186 var focusEvent = nativeEvent; 7187 queuedFocus = accumulateOrCreateContinuousQueuedReplayableEvent(queuedFocus, blockedOn, domEventName, eventSystemFlags, targetContainer, focusEvent); 7188 return true; 7189 } 7190 7191 case 'dragenter': 7192 { 7193 var dragEvent = nativeEvent; 7194 queuedDrag = accumulateOrCreateContinuousQueuedReplayableEvent(queuedDrag, blockedOn, domEventName, eventSystemFlags, targetContainer, dragEvent); 7195 return true; 7196 } 7197 7198 case 'mouseover': 7199 { 7200 var mouseEvent = nativeEvent; 7201 queuedMouse = accumulateOrCreateContinuousQueuedReplayableEvent(queuedMouse, blockedOn, domEventName, eventSystemFlags, targetContainer, mouseEvent); 7202 return true; 7203 } 7204 7205 case 'pointerover': 7206 { 7207 var pointerEvent = nativeEvent; 7208 var pointerId = pointerEvent.pointerId; 7209 queuedPointers.set(pointerId, accumulateOrCreateContinuousQueuedReplayableEvent(queuedPointers.get(pointerId) || null, blockedOn, domEventName, eventSystemFlags, targetContainer, pointerEvent)); 7210 return true; 7211 } 7212 7213 case 'gotpointercapture': 7214 { 7215 var _pointerEvent = nativeEvent; 7216 var _pointerId2 = _pointerEvent.pointerId; 7217 queuedPointerCaptures.set(_pointerId2, accumulateOrCreateContinuousQueuedReplayableEvent(queuedPointerCaptures.get(_pointerId2) || null, blockedOn, domEventName, eventSystemFlags, targetContainer, _pointerEvent)); 7218 return true; 7219 } 7220 } 7221 7222 return false; 7223} // Check if this target is unblocked. Returns true if it's unblocked. 7224 7225function attemptExplicitHydrationTarget(queuedTarget) { 7226 // TODO: This function shares a lot of logic with attemptToDispatchEvent. 7227 // Try to unify them. It's a bit tricky since it would require two return 7228 // values. 7229 var targetInst = getClosestInstanceFromNode(queuedTarget.target); 7230 7231 if (targetInst !== null) { 7232 var nearestMounted = getNearestMountedFiber(targetInst); 7233 7234 if (nearestMounted !== null) { 7235 var tag = nearestMounted.tag; 7236 7237 if (tag === SuspenseComponent) { 7238 var instance = getSuspenseInstanceFromFiber(nearestMounted); 7239 7240 if (instance !== null) { 7241 // We're blocked on hydrating this boundary. 7242 // Increase its priority. 7243 queuedTarget.blockedOn = instance; 7244 attemptHydrationAtPriority(queuedTarget.lanePriority, function () { 7245 Scheduler.unstable_runWithPriority(queuedTarget.priority, function () { 7246 attemptHydrationAtCurrentPriority(nearestMounted); 7247 }); 7248 }); 7249 return; 7250 } 7251 } else if (tag === HostRoot) { 7252 var root = nearestMounted.stateNode; 7253 7254 if (root.hydrate) { 7255 queuedTarget.blockedOn = getContainerFromFiber(nearestMounted); // We don't currently have a way to increase the priority of 7256 // a root other than sync. 7257 7258 return; 7259 } 7260 } 7261 } 7262 } 7263 7264 queuedTarget.blockedOn = null; 7265} 7266 7267function attemptReplayContinuousQueuedEvent(queuedEvent) { 7268 if (queuedEvent.blockedOn !== null) { 7269 return false; 7270 } 7271 7272 var targetContainers = queuedEvent.targetContainers; 7273 7274 while (targetContainers.length > 0) { 7275 var targetContainer = targetContainers[0]; 7276 var nextBlockedOn = attemptToDispatchEvent(queuedEvent.domEventName, queuedEvent.eventSystemFlags, targetContainer, queuedEvent.nativeEvent); 7277 7278 if (nextBlockedOn !== null) { 7279 // We're still blocked. Try again later. 7280 var _fiber3 = getInstanceFromNode(nextBlockedOn); 7281 7282 if (_fiber3 !== null) { 7283 attemptContinuousHydration(_fiber3); 7284 } 7285 7286 queuedEvent.blockedOn = nextBlockedOn; 7287 return false; 7288 } // This target container was successfully dispatched. Try the next. 7289 7290 7291 targetContainers.shift(); 7292 } 7293 7294 return true; 7295} 7296 7297function attemptReplayContinuousQueuedEventInMap(queuedEvent, key, map) { 7298 if (attemptReplayContinuousQueuedEvent(queuedEvent)) { 7299 map.delete(key); 7300 } 7301} 7302 7303function replayUnblockedEvents() { 7304 hasScheduledReplayAttempt = false; // First replay discrete events. 7305 7306 while (queuedDiscreteEvents.length > 0) { 7307 var nextDiscreteEvent = queuedDiscreteEvents[0]; 7308 7309 if (nextDiscreteEvent.blockedOn !== null) { 7310 // We're still blocked. 7311 // Increase the priority of this boundary to unblock 7312 // the next discrete event. 7313 var _fiber4 = getInstanceFromNode(nextDiscreteEvent.blockedOn); 7314 7315 if (_fiber4 !== null) { 7316 attemptUserBlockingHydration(_fiber4); 7317 } 7318 7319 break; 7320 } 7321 7322 var targetContainers = nextDiscreteEvent.targetContainers; 7323 7324 while (targetContainers.length > 0) { 7325 var targetContainer = targetContainers[0]; 7326 var nextBlockedOn = attemptToDispatchEvent(nextDiscreteEvent.domEventName, nextDiscreteEvent.eventSystemFlags, targetContainer, nextDiscreteEvent.nativeEvent); 7327 7328 if (nextBlockedOn !== null) { 7329 // We're still blocked. Try again later. 7330 nextDiscreteEvent.blockedOn = nextBlockedOn; 7331 break; 7332 } // This target container was successfully dispatched. Try the next. 7333 7334 7335 targetContainers.shift(); 7336 } 7337 7338 if (nextDiscreteEvent.blockedOn === null) { 7339 // We've successfully replayed the first event. Let's try the next one. 7340 queuedDiscreteEvents.shift(); 7341 } 7342 } // Next replay any continuous events. 7343 7344 7345 if (queuedFocus !== null && attemptReplayContinuousQueuedEvent(queuedFocus)) { 7346 queuedFocus = null; 7347 } 7348 7349 if (queuedDrag !== null && attemptReplayContinuousQueuedEvent(queuedDrag)) { 7350 queuedDrag = null; 7351 } 7352 7353 if (queuedMouse !== null && attemptReplayContinuousQueuedEvent(queuedMouse)) { 7354 queuedMouse = null; 7355 } 7356 7357 queuedPointers.forEach(attemptReplayContinuousQueuedEventInMap); 7358 queuedPointerCaptures.forEach(attemptReplayContinuousQueuedEventInMap); 7359} 7360 7361function scheduleCallbackIfUnblocked(queuedEvent, unblocked) { 7362 if (queuedEvent.blockedOn === unblocked) { 7363 queuedEvent.blockedOn = null; 7364 7365 if (!hasScheduledReplayAttempt) { 7366 hasScheduledReplayAttempt = true; // Schedule a callback to attempt replaying as many events as are 7367 // now unblocked. This first might not actually be unblocked yet. 7368 // We could check it early to avoid scheduling an unnecessary callback. 7369 7370 Scheduler.unstable_scheduleCallback(Scheduler.unstable_NormalPriority, replayUnblockedEvents); 7371 } 7372 } 7373} 7374 7375function retryIfBlockedOn(unblocked) { 7376 // Mark anything that was blocked on this as no longer blocked 7377 // and eligible for a replay. 7378 if (queuedDiscreteEvents.length > 0) { 7379 scheduleCallbackIfUnblocked(queuedDiscreteEvents[0], unblocked); // This is a exponential search for each boundary that commits. I think it's 7380 // worth it because we expect very few discrete events to queue up and once 7381 // we are actually fully unblocked it will be fast to replay them. 7382 7383 for (var i = 1; i < queuedDiscreteEvents.length; i++) { 7384 var queuedEvent = queuedDiscreteEvents[i]; 7385 7386 if (queuedEvent.blockedOn === unblocked) { 7387 queuedEvent.blockedOn = null; 7388 } 7389 } 7390 } 7391 7392 if (queuedFocus !== null) { 7393 scheduleCallbackIfUnblocked(queuedFocus, unblocked); 7394 } 7395 7396 if (queuedDrag !== null) { 7397 scheduleCallbackIfUnblocked(queuedDrag, unblocked); 7398 } 7399 7400 if (queuedMouse !== null) { 7401 scheduleCallbackIfUnblocked(queuedMouse, unblocked); 7402 } 7403 7404 var unblock = function (queuedEvent) { 7405 return scheduleCallbackIfUnblocked(queuedEvent, unblocked); 7406 }; 7407 7408 queuedPointers.forEach(unblock); 7409 queuedPointerCaptures.forEach(unblock); 7410 7411 for (var _i = 0; _i < queuedExplicitHydrationTargets.length; _i++) { 7412 var queuedTarget = queuedExplicitHydrationTargets[_i]; 7413 7414 if (queuedTarget.blockedOn === unblocked) { 7415 queuedTarget.blockedOn = null; 7416 } 7417 } 7418 7419 while (queuedExplicitHydrationTargets.length > 0) { 7420 var nextExplicitTarget = queuedExplicitHydrationTargets[0]; 7421 7422 if (nextExplicitTarget.blockedOn !== null) { 7423 // We're still blocked. 7424 break; 7425 } else { 7426 attemptExplicitHydrationTarget(nextExplicitTarget); 7427 7428 if (nextExplicitTarget.blockedOn === null) { 7429 // We're unblocked. 7430 queuedExplicitHydrationTargets.shift(); 7431 } 7432 } 7433 } 7434} 7435 7436var DiscreteEvent = 0; 7437var UserBlockingEvent = 1; 7438var ContinuousEvent = 2; 7439 7440/** 7441 * Generate a mapping of standard vendor prefixes using the defined style property and event name. 7442 * 7443 * @param {string} styleProp 7444 * @param {string} eventName 7445 * @returns {object} 7446 */ 7447 7448function makePrefixMap(styleProp, eventName) { 7449 var prefixes = {}; 7450 prefixes[styleProp.toLowerCase()] = eventName.toLowerCase(); 7451 prefixes['Webkit' + styleProp] = 'webkit' + eventName; 7452 prefixes['Moz' + styleProp] = 'moz' + eventName; 7453 return prefixes; 7454} 7455/** 7456 * A list of event names to a configurable list of vendor prefixes. 7457 */ 7458 7459 7460var vendorPrefixes = { 7461 animationend: makePrefixMap('Animation', 'AnimationEnd'), 7462 animationiteration: makePrefixMap('Animation', 'AnimationIteration'), 7463 animationstart: makePrefixMap('Animation', 'AnimationStart'), 7464 transitionend: makePrefixMap('Transition', 'TransitionEnd') 7465}; 7466/** 7467 * Event names that have already been detected and prefixed (if applicable). 7468 */ 7469 7470var prefixedEventNames = {}; 7471/** 7472 * Element to check for prefixes on. 7473 */ 7474 7475var style = {}; 7476/** 7477 * Bootstrap if a DOM exists. 7478 */ 7479 7480if (canUseDOM) { 7481 style = document.createElement('div').style; // On some platforms, in particular some releases of Android 4.x, 7482 // the un-prefixed "animation" and "transition" properties are defined on the 7483 // style object but the events that fire will still be prefixed, so we need 7484 // to check if the un-prefixed events are usable, and if not remove them from the map. 7485 7486 if (!('AnimationEvent' in window)) { 7487 delete vendorPrefixes.animationend.animation; 7488 delete vendorPrefixes.animationiteration.animation; 7489 delete vendorPrefixes.animationstart.animation; 7490 } // Same as above 7491 7492 7493 if (!('TransitionEvent' in window)) { 7494 delete vendorPrefixes.transitionend.transition; 7495 } 7496} 7497/** 7498 * Attempts to determine the correct vendor prefixed event name. 7499 * 7500 * @param {string} eventName 7501 * @returns {string} 7502 */ 7503 7504 7505function getVendorPrefixedEventName(eventName) { 7506 if (prefixedEventNames[eventName]) { 7507 return prefixedEventNames[eventName]; 7508 } else if (!vendorPrefixes[eventName]) { 7509 return eventName; 7510 } 7511 7512 var prefixMap = vendorPrefixes[eventName]; 7513 7514 for (var styleProp in prefixMap) { 7515 if (prefixMap.hasOwnProperty(styleProp) && styleProp in style) { 7516 return prefixedEventNames[eventName] = prefixMap[styleProp]; 7517 } 7518 } 7519 7520 return eventName; 7521} 7522 7523var ANIMATION_END = getVendorPrefixedEventName('animationend'); 7524var ANIMATION_ITERATION = getVendorPrefixedEventName('animationiteration'); 7525var ANIMATION_START = getVendorPrefixedEventName('animationstart'); 7526var TRANSITION_END = getVendorPrefixedEventName('transitionend'); 7527 7528var topLevelEventsToReactNames = new Map(); 7529var eventPriorities = new Map(); // We store most of the events in this module in pairs of two strings so we can re-use 7530// the code required to apply the same logic for event prioritization and that of the 7531// SimpleEventPlugin. This complicates things slightly, but the aim is to reduce code 7532// duplication (for which there would be quite a bit). For the events that are not needed 7533// for the SimpleEventPlugin (otherDiscreteEvents) we process them separately as an 7534// array of top level events. 7535// Lastly, we ignore prettier so we can keep the formatting sane. 7536// prettier-ignore 7537 7538var discreteEventPairsForSimpleEventPlugin = ['cancel', 'cancel', 'click', 'click', 'close', 'close', 'contextmenu', 'contextMenu', 'copy', 'copy', 'cut', 'cut', 'auxclick', 'auxClick', 'dblclick', 'doubleClick', // Careful! 7539'dragend', 'dragEnd', 'dragstart', 'dragStart', 'drop', 'drop', 'focusin', 'focus', // Careful! 7540'focusout', 'blur', // Careful! 7541'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']; 7542var otherDiscreteEvents = ['change', 'selectionchange', 'textInput', 'compositionstart', 'compositionend', 'compositionupdate']; 7543 7544 7545var 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 7546 7547var 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']; 7548/** 7549 * Turns 7550 * ['abort', ...] 7551 * 7552 * into 7553 * 7554 * topLevelEventsToReactNames = new Map([ 7555 * ['abort', 'onAbort'], 7556 * ]); 7557 * 7558 * and registers them. 7559 */ 7560 7561function registerSimplePluginEventsAndSetTheirPriorities(eventTypes, priority) { 7562 // As the event types are in pairs of two, we need to iterate 7563 // through in twos. The events are in pairs of two to save code 7564 // and improve init perf of processing this array, as it will 7565 // result in far fewer object allocations and property accesses 7566 // if we only use three arrays to process all the categories of 7567 // instead of tuples. 7568 for (var i = 0; i < eventTypes.length; i += 2) { 7569 var topEvent = eventTypes[i]; 7570 var event = eventTypes[i + 1]; 7571 var capitalizedEvent = event[0].toUpperCase() + event.slice(1); 7572 var reactName = 'on' + capitalizedEvent; 7573 eventPriorities.set(topEvent, priority); 7574 topLevelEventsToReactNames.set(topEvent, reactName); 7575 registerTwoPhaseEvent(reactName, [topEvent]); 7576 } 7577} 7578 7579function setEventPriorities(eventTypes, priority) { 7580 for (var i = 0; i < eventTypes.length; i++) { 7581 eventPriorities.set(eventTypes[i], priority); 7582 } 7583} 7584 7585function getEventPriorityForPluginSystem(domEventName) { 7586 var priority = eventPriorities.get(domEventName); // Default to a ContinuousEvent. Note: we might 7587 // want to warn if we can't detect the priority 7588 // for the event. 7589 7590 return priority === undefined ? ContinuousEvent : priority; 7591} 7592function registerSimpleEvents() { 7593 registerSimplePluginEventsAndSetTheirPriorities(discreteEventPairsForSimpleEventPlugin, DiscreteEvent); 7594 registerSimplePluginEventsAndSetTheirPriorities(userBlockingPairsForSimpleEventPlugin, UserBlockingEvent); 7595 registerSimplePluginEventsAndSetTheirPriorities(continuousPairsForSimpleEventPlugin, ContinuousEvent); 7596 setEventPriorities(otherDiscreteEvents, DiscreteEvent); 7597} 7598 7599var Scheduler_now = Scheduler.unstable_now; 7600 7601{ 7602 // Provide explicit error message when production+profiling bundle of e.g. 7603 // react-dom is used with production (non-profiling) bundle of 7604 // scheduler/tracing 7605 if (!(tracing.__interactionsRef != null && tracing.__interactionsRef.current != null)) { 7606 { 7607 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" ); 7608 } 7609 } 7610} 7611// ascending numbers so we can compare them like numbers. They start at 90 to 7612// avoid clashing with Scheduler's priorities. 7613 7614var ImmediatePriority = 99; 7615var UserBlockingPriority = 98; 7616var NormalPriority = 97; 7617var LowPriority = 96; 7618var IdlePriority = 95; // NoPriority is the absence of priority. Also React-only. 7619 7620var NoPriority = 90; 7621var initialTimeMs = Scheduler_now(); // If the initial timestamp is reasonably small, use Scheduler's `now` directly. 7622 7623var SyncLanePriority = 15; 7624var SyncBatchedLanePriority = 14; 7625var InputDiscreteHydrationLanePriority = 13; 7626var InputDiscreteLanePriority = 12; 7627var InputContinuousHydrationLanePriority = 11; 7628var InputContinuousLanePriority = 10; 7629var DefaultHydrationLanePriority = 9; 7630var DefaultLanePriority = 8; 7631var TransitionHydrationPriority = 7; 7632var TransitionPriority = 6; 7633var RetryLanePriority = 5; 7634var SelectiveHydrationLanePriority = 4; 7635var IdleHydrationLanePriority = 3; 7636var IdleLanePriority = 2; 7637var OffscreenLanePriority = 1; 7638var NoLanePriority = 0; 7639var TotalLanes = 31; 7640var NoLanes = 7641/* */ 76420; 7643var NoLane = 7644/* */ 76450; 7646var SyncLane = 7647/* */ 76481; 7649var SyncBatchedLane = 7650/* */ 76512; 7652var InputDiscreteHydrationLane = 7653/* */ 76544; 7655var InputDiscreteLanes = 7656/* */ 765724; 7658var InputContinuousHydrationLane = 7659/* */ 766032; 7661var InputContinuousLanes = 7662/* */ 7663192; 7664var DefaultHydrationLane = 7665/* */ 7666256; 7667var DefaultLanes = 7668/* */ 76693584; 7670var TransitionHydrationLane = 7671/* */ 76724096; 7673var TransitionLanes = 7674/* */ 76754186112; 7676var RetryLanes = 7677/* */ 767862914560; 7679var SomeRetryLane = 7680/* */ 768133554432; 7682var SelectiveHydrationLane = 7683/* */ 768467108864; 7685var NonIdleLanes = 7686/* */ 7687134217727; 7688var IdleHydrationLane = 7689/* */ 7690134217728; 7691var IdleLanes = 7692/* */ 7693805306368; 7694var OffscreenLane = 7695/* */ 76961073741824; 7697var NoTimestamp = -1; 7698function setCurrentUpdateLanePriority(newLanePriority) { 7699} // "Registers" used to "return" multiple values 7700// Used by getHighestPriorityLanes and getNextLanes: 7701 7702var return_highestLanePriority = DefaultLanePriority; 7703 7704function getHighestPriorityLanes(lanes) { 7705 if ((SyncLane & lanes) !== NoLanes) { 7706 return_highestLanePriority = SyncLanePriority; 7707 return SyncLane; 7708 } 7709 7710 if ((SyncBatchedLane & lanes) !== NoLanes) { 7711 return_highestLanePriority = SyncBatchedLanePriority; 7712 return SyncBatchedLane; 7713 } 7714 7715 if ((InputDiscreteHydrationLane & lanes) !== NoLanes) { 7716 return_highestLanePriority = InputDiscreteHydrationLanePriority; 7717 return InputDiscreteHydrationLane; 7718 } 7719 7720 var inputDiscreteLanes = InputDiscreteLanes & lanes; 7721 7722 if (inputDiscreteLanes !== NoLanes) { 7723 return_highestLanePriority = InputDiscreteLanePriority; 7724 return inputDiscreteLanes; 7725 } 7726 7727 if ((lanes & InputContinuousHydrationLane) !== NoLanes) { 7728 return_highestLanePriority = InputContinuousHydrationLanePriority; 7729 return InputContinuousHydrationLane; 7730 } 7731 7732 var inputContinuousLanes = InputContinuousLanes & lanes; 7733 7734 if (inputContinuousLanes !== NoLanes) { 7735 return_highestLanePriority = InputContinuousLanePriority; 7736 return inputContinuousLanes; 7737 } 7738 7739 if ((lanes & DefaultHydrationLane) !== NoLanes) { 7740 return_highestLanePriority = DefaultHydrationLanePriority; 7741 return DefaultHydrationLane; 7742 } 7743 7744 var defaultLanes = DefaultLanes & lanes; 7745 7746 if (defaultLanes !== NoLanes) { 7747 return_highestLanePriority = DefaultLanePriority; 7748 return defaultLanes; 7749 } 7750 7751 if ((lanes & TransitionHydrationLane) !== NoLanes) { 7752 return_highestLanePriority = TransitionHydrationPriority; 7753 return TransitionHydrationLane; 7754 } 7755 7756 var transitionLanes = TransitionLanes & lanes; 7757 7758 if (transitionLanes !== NoLanes) { 7759 return_highestLanePriority = TransitionPriority; 7760 return transitionLanes; 7761 } 7762 7763 var retryLanes = RetryLanes & lanes; 7764 7765 if (retryLanes !== NoLanes) { 7766 return_highestLanePriority = RetryLanePriority; 7767 return retryLanes; 7768 } 7769 7770 if (lanes & SelectiveHydrationLane) { 7771 return_highestLanePriority = SelectiveHydrationLanePriority; 7772 return SelectiveHydrationLane; 7773 } 7774 7775 if ((lanes & IdleHydrationLane) !== NoLanes) { 7776 return_highestLanePriority = IdleHydrationLanePriority; 7777 return IdleHydrationLane; 7778 } 7779 7780 var idleLanes = IdleLanes & lanes; 7781 7782 if (idleLanes !== NoLanes) { 7783 return_highestLanePriority = IdleLanePriority; 7784 return idleLanes; 7785 } 7786 7787 if ((OffscreenLane & lanes) !== NoLanes) { 7788 return_highestLanePriority = OffscreenLanePriority; 7789 return OffscreenLane; 7790 } 7791 7792 { 7793 error('Should have found matching lanes. This is a bug in React.'); 7794 } // This shouldn't be reachable, but as a fallback, return the entire bitmask. 7795 7796 7797 return_highestLanePriority = DefaultLanePriority; 7798 return lanes; 7799} 7800 7801function schedulerPriorityToLanePriority(schedulerPriorityLevel) { 7802 switch (schedulerPriorityLevel) { 7803 case ImmediatePriority: 7804 return SyncLanePriority; 7805 7806 case UserBlockingPriority: 7807 return InputContinuousLanePriority; 7808 7809 case NormalPriority: 7810 case LowPriority: 7811 // TODO: Handle LowSchedulerPriority, somehow. Maybe the same lane as hydration. 7812 return DefaultLanePriority; 7813 7814 case IdlePriority: 7815 return IdleLanePriority; 7816 7817 default: 7818 return NoLanePriority; 7819 } 7820} 7821function lanePriorityToSchedulerPriority(lanePriority) { 7822 switch (lanePriority) { 7823 case SyncLanePriority: 7824 case SyncBatchedLanePriority: 7825 return ImmediatePriority; 7826 7827 case InputDiscreteHydrationLanePriority: 7828 case InputDiscreteLanePriority: 7829 case InputContinuousHydrationLanePriority: 7830 case InputContinuousLanePriority: 7831 return UserBlockingPriority; 7832 7833 case DefaultHydrationLanePriority: 7834 case DefaultLanePriority: 7835 case TransitionHydrationPriority: 7836 case TransitionPriority: 7837 case SelectiveHydrationLanePriority: 7838 case RetryLanePriority: 7839 return NormalPriority; 7840 7841 case IdleHydrationLanePriority: 7842 case IdleLanePriority: 7843 case OffscreenLanePriority: 7844 return IdlePriority; 7845 7846 case NoLanePriority: 7847 return NoPriority; 7848 7849 default: 7850 { 7851 { 7852 throw Error( "Invalid update priority: " + lanePriority + ". This is a bug in React." ); 7853 } 7854 } 7855 7856 } 7857} 7858function getNextLanes(root, wipLanes) { 7859 // Early bailout if there's no pending work left. 7860 var pendingLanes = root.pendingLanes; 7861 7862 if (pendingLanes === NoLanes) { 7863 return_highestLanePriority = NoLanePriority; 7864 return NoLanes; 7865 } 7866 7867 var nextLanes = NoLanes; 7868 var nextLanePriority = NoLanePriority; 7869 var expiredLanes = root.expiredLanes; 7870 var suspendedLanes = root.suspendedLanes; 7871 var pingedLanes = root.pingedLanes; // Check if any work has expired. 7872 7873 if (expiredLanes !== NoLanes) { 7874 nextLanes = expiredLanes; 7875 nextLanePriority = return_highestLanePriority = SyncLanePriority; 7876 } else { 7877 // Do not work on any idle work until all the non-idle work has finished, 7878 // even if the work is suspended. 7879 var nonIdlePendingLanes = pendingLanes & NonIdleLanes; 7880 7881 if (nonIdlePendingLanes !== NoLanes) { 7882 var nonIdleUnblockedLanes = nonIdlePendingLanes & ~suspendedLanes; 7883 7884 if (nonIdleUnblockedLanes !== NoLanes) { 7885 nextLanes = getHighestPriorityLanes(nonIdleUnblockedLanes); 7886 nextLanePriority = return_highestLanePriority; 7887 } else { 7888 var nonIdlePingedLanes = nonIdlePendingLanes & pingedLanes; 7889 7890 if (nonIdlePingedLanes !== NoLanes) { 7891 nextLanes = getHighestPriorityLanes(nonIdlePingedLanes); 7892 nextLanePriority = return_highestLanePriority; 7893 } 7894 } 7895 } else { 7896 // The only remaining work is Idle. 7897 var unblockedLanes = pendingLanes & ~suspendedLanes; 7898 7899 if (unblockedLanes !== NoLanes) { 7900 nextLanes = getHighestPriorityLanes(unblockedLanes); 7901 nextLanePriority = return_highestLanePriority; 7902 } else { 7903 if (pingedLanes !== NoLanes) { 7904 nextLanes = getHighestPriorityLanes(pingedLanes); 7905 nextLanePriority = return_highestLanePriority; 7906 } 7907 } 7908 } 7909 } 7910 7911 if (nextLanes === NoLanes) { 7912 // This should only be reachable if we're suspended 7913 // TODO: Consider warning in this path if a fallback timer is not scheduled. 7914 return NoLanes; 7915 } // If there are higher priority lanes, we'll include them even if they 7916 // are suspended. 7917 7918 7919 nextLanes = pendingLanes & getEqualOrHigherPriorityLanes(nextLanes); // If we're already in the middle of a render, switching lanes will interrupt 7920 // it and we'll lose our progress. We should only do this if the new lanes are 7921 // higher priority. 7922 7923 if (wipLanes !== NoLanes && wipLanes !== nextLanes && // If we already suspended with a delay, then interrupting is fine. Don't 7924 // bother waiting until the root is complete. 7925 (wipLanes & suspendedLanes) === NoLanes) { 7926 getHighestPriorityLanes(wipLanes); 7927 var wipLanePriority = return_highestLanePriority; 7928 7929 if (nextLanePriority <= wipLanePriority) { 7930 return wipLanes; 7931 } else { 7932 return_highestLanePriority = nextLanePriority; 7933 } 7934 } // Check for entangled lanes and add them to the batch. 7935 // 7936 // A lane is said to be entangled with another when it's not allowed to render 7937 // in a batch that does not also include the other lane. Typically we do this 7938 // when multiple updates have the same source, and we only want to respond to 7939 // the most recent event from that source. 7940 // 7941 // Note that we apply entanglements *after* checking for partial work above. 7942 // This means that if a lane is entangled during an interleaved event while 7943 // it's already rendering, we won't interrupt it. This is intentional, since 7944 // entanglement is usually "best effort": we'll try our best to render the 7945 // lanes in the same batch, but it's not worth throwing out partially 7946 // completed work in order to do it. 7947 // 7948 // For those exceptions where entanglement is semantically important, like 7949 // useMutableSource, we should ensure that there is no partial work at the 7950 // time we apply the entanglement. 7951 7952 7953 var entangledLanes = root.entangledLanes; 7954 7955 if (entangledLanes !== NoLanes) { 7956 var entanglements = root.entanglements; 7957 var lanes = nextLanes & entangledLanes; 7958 7959 while (lanes > 0) { 7960 var index = pickArbitraryLaneIndex(lanes); 7961 var lane = 1 << index; 7962 nextLanes |= entanglements[index]; 7963 lanes &= ~lane; 7964 } 7965 } 7966 7967 return nextLanes; 7968} 7969function getMostRecentEventTime(root, lanes) { 7970 var eventTimes = root.eventTimes; 7971 var mostRecentEventTime = NoTimestamp; 7972 7973 while (lanes > 0) { 7974 var index = pickArbitraryLaneIndex(lanes); 7975 var lane = 1 << index; 7976 var eventTime = eventTimes[index]; 7977 7978 if (eventTime > mostRecentEventTime) { 7979 mostRecentEventTime = eventTime; 7980 } 7981 7982 lanes &= ~lane; 7983 } 7984 7985 return mostRecentEventTime; 7986} 7987 7988function computeExpirationTime(lane, currentTime) { 7989 // TODO: Expiration heuristic is constant per lane, so could use a map. 7990 getHighestPriorityLanes(lane); 7991 var priority = return_highestLanePriority; 7992 7993 if (priority >= InputContinuousLanePriority) { 7994 // User interactions should expire slightly more quickly. 7995 // 7996 // NOTE: This is set to the corresponding constant as in Scheduler.js. When 7997 // we made it larger, a product metric in www regressed, suggesting there's 7998 // a user interaction that's being starved by a series of synchronous 7999 // updates. If that theory is correct, the proper solution is to fix the 8000 // starvation. However, this scenario supports the idea that expiration 8001 // times are an important safeguard when starvation does happen. 8002 // 8003 // Also note that, in the case of user input specifically, this will soon no 8004 // longer be an issue because we plan to make user input synchronous by 8005 // default (until you enter `startTransition`, of course.) 8006 // 8007 // If weren't planning to make these updates synchronous soon anyway, I 8008 // would probably make this number a configurable parameter. 8009 return currentTime + 250; 8010 } else if (priority >= TransitionPriority) { 8011 return currentTime + 5000; 8012 } else { 8013 // Anything idle priority or lower should never expire. 8014 return NoTimestamp; 8015 } 8016} 8017 8018function markStarvedLanesAsExpired(root, currentTime) { 8019 // TODO: This gets called every time we yield. We can optimize by storing 8020 // the earliest expiration time on the root. Then use that to quickly bail out 8021 // of this function. 8022 var pendingLanes = root.pendingLanes; 8023 var suspendedLanes = root.suspendedLanes; 8024 var pingedLanes = root.pingedLanes; 8025 var expirationTimes = root.expirationTimes; // Iterate through the pending lanes and check if we've reached their 8026 // expiration time. If so, we'll assume the update is being starved and mark 8027 // it as expired to force it to finish. 8028 8029 var lanes = pendingLanes; 8030 8031 while (lanes > 0) { 8032 var index = pickArbitraryLaneIndex(lanes); 8033 var lane = 1 << index; 8034 var expirationTime = expirationTimes[index]; 8035 8036 if (expirationTime === NoTimestamp) { 8037 // Found a pending lane with no expiration time. If it's not suspended, or 8038 // if it's pinged, assume it's CPU-bound. Compute a new expiration time 8039 // using the current time. 8040 if ((lane & suspendedLanes) === NoLanes || (lane & pingedLanes) !== NoLanes) { 8041 // Assumes timestamps are monotonically increasing. 8042 expirationTimes[index] = computeExpirationTime(lane, currentTime); 8043 } 8044 } else if (expirationTime <= currentTime) { 8045 // This lane expired 8046 root.expiredLanes |= lane; 8047 } 8048 8049 lanes &= ~lane; 8050 } 8051} // This returns the highest priority pending lanes regardless of whether they 8052function getLanesToRetrySynchronouslyOnError(root) { 8053 var everythingButOffscreen = root.pendingLanes & ~OffscreenLane; 8054 8055 if (everythingButOffscreen !== NoLanes) { 8056 return everythingButOffscreen; 8057 } 8058 8059 if (everythingButOffscreen & OffscreenLane) { 8060 return OffscreenLane; 8061 } 8062 8063 return NoLanes; 8064} 8065function returnNextLanesPriority() { 8066 return return_highestLanePriority; 8067} 8068function includesNonIdleWork(lanes) { 8069 return (lanes & NonIdleLanes) !== NoLanes; 8070} 8071function includesOnlyRetries(lanes) { 8072 return (lanes & RetryLanes) === lanes; 8073} 8074function includesOnlyTransitions(lanes) { 8075 return (lanes & TransitionLanes) === lanes; 8076} // To ensure consistency across multiple updates in the same event, this should 8077// be a pure function, so that it always returns the same lane for given inputs. 8078 8079function findUpdateLane(lanePriority, wipLanes) { 8080 switch (lanePriority) { 8081 case NoLanePriority: 8082 break; 8083 8084 case SyncLanePriority: 8085 return SyncLane; 8086 8087 case SyncBatchedLanePriority: 8088 return SyncBatchedLane; 8089 8090 case InputDiscreteLanePriority: 8091 { 8092 var _lane = pickArbitraryLane(InputDiscreteLanes & ~wipLanes); 8093 8094 if (_lane === NoLane) { 8095 // Shift to the next priority level 8096 return findUpdateLane(InputContinuousLanePriority, wipLanes); 8097 } 8098 8099 return _lane; 8100 } 8101 8102 case InputContinuousLanePriority: 8103 { 8104 var _lane2 = pickArbitraryLane(InputContinuousLanes & ~wipLanes); 8105 8106 if (_lane2 === NoLane) { 8107 // Shift to the next priority level 8108 return findUpdateLane(DefaultLanePriority, wipLanes); 8109 } 8110 8111 return _lane2; 8112 } 8113 8114 case DefaultLanePriority: 8115 { 8116 var _lane3 = pickArbitraryLane(DefaultLanes & ~wipLanes); 8117 8118 if (_lane3 === NoLane) { 8119 // If all the default lanes are already being worked on, look for a 8120 // lane in the transition range. 8121 _lane3 = pickArbitraryLane(TransitionLanes & ~wipLanes); 8122 8123 if (_lane3 === NoLane) { 8124 // All the transition lanes are taken, too. This should be very 8125 // rare, but as a last resort, pick a default lane. This will have 8126 // the effect of interrupting the current work-in-progress render. 8127 _lane3 = pickArbitraryLane(DefaultLanes); 8128 } 8129 } 8130 8131 return _lane3; 8132 } 8133 8134 case TransitionPriority: // Should be handled by findTransitionLane instead 8135 8136 case RetryLanePriority: 8137 // Should be handled by findRetryLane instead 8138 break; 8139 8140 case IdleLanePriority: 8141 var lane = pickArbitraryLane(IdleLanes & ~wipLanes); 8142 8143 if (lane === NoLane) { 8144 lane = pickArbitraryLane(IdleLanes); 8145 } 8146 8147 return lane; 8148 } 8149 8150 { 8151 { 8152 throw Error( "Invalid update priority: " + lanePriority + ". This is a bug in React." ); 8153 } 8154 } 8155} // To ensure consistency across multiple updates in the same event, this should 8156// be pure function, so that it always returns the same lane for given inputs. 8157 8158function findTransitionLane(wipLanes, pendingLanes) { 8159 // First look for lanes that are completely unclaimed, i.e. have no 8160 // pending work. 8161 var lane = pickArbitraryLane(TransitionLanes & ~pendingLanes); 8162 8163 if (lane === NoLane) { 8164 // If all lanes have pending work, look for a lane that isn't currently 8165 // being worked on. 8166 lane = pickArbitraryLane(TransitionLanes & ~wipLanes); 8167 8168 if (lane === NoLane) { 8169 // If everything is being worked on, pick any lane. This has the 8170 // effect of interrupting the current work-in-progress. 8171 lane = pickArbitraryLane(TransitionLanes); 8172 } 8173 } 8174 8175 return lane; 8176} // To ensure consistency across multiple updates in the same event, this should 8177// be pure function, so that it always returns the same lane for given inputs. 8178 8179function findRetryLane(wipLanes) { 8180 // This is a fork of `findUpdateLane` designed specifically for Suspense 8181 // "retries" — a special update that attempts to flip a Suspense boundary 8182 // from its placeholder state to its primary/resolved state. 8183 var lane = pickArbitraryLane(RetryLanes & ~wipLanes); 8184 8185 if (lane === NoLane) { 8186 lane = pickArbitraryLane(RetryLanes); 8187 } 8188 8189 return lane; 8190} 8191 8192function getHighestPriorityLane(lanes) { 8193 return lanes & -lanes; 8194} 8195 8196function getLowestPriorityLane(lanes) { 8197 // This finds the most significant non-zero bit. 8198 var index = 31 - clz32(lanes); 8199 return index < 0 ? NoLanes : 1 << index; 8200} 8201 8202function getEqualOrHigherPriorityLanes(lanes) { 8203 return (getLowestPriorityLane(lanes) << 1) - 1; 8204} 8205 8206function pickArbitraryLane(lanes) { 8207 // This wrapper function gets inlined. Only exists so to communicate that it 8208 // doesn't matter which bit is selected; you can pick any bit without 8209 // affecting the algorithms where its used. Here I'm using 8210 // getHighestPriorityLane because it requires the fewest operations. 8211 return getHighestPriorityLane(lanes); 8212} 8213 8214function pickArbitraryLaneIndex(lanes) { 8215 return 31 - clz32(lanes); 8216} 8217 8218function laneToIndex(lane) { 8219 return pickArbitraryLaneIndex(lane); 8220} 8221 8222function includesSomeLane(a, b) { 8223 return (a & b) !== NoLanes; 8224} 8225function isSubsetOfLanes(set, subset) { 8226 return (set & subset) === subset; 8227} 8228function mergeLanes(a, b) { 8229 return a | b; 8230} 8231function removeLanes(set, subset) { 8232 return set & ~subset; 8233} // Seems redundant, but it changes the type from a single lane (used for 8234// updates) to a group of lanes (used for flushing work). 8235 8236function laneToLanes(lane) { 8237 return lane; 8238} 8239function higherPriorityLane(a, b) { 8240 // This works because the bit ranges decrease in priority as you go left. 8241 return a !== NoLane && a < b ? a : b; 8242} 8243function createLaneMap(initial) { 8244 // Intentionally pushing one by one. 8245 // https://v8.dev/blog/elements-kinds#avoid-creating-holes 8246 var laneMap = []; 8247 8248 for (var i = 0; i < TotalLanes; i++) { 8249 laneMap.push(initial); 8250 } 8251 8252 return laneMap; 8253} 8254function markRootUpdated(root, updateLane, eventTime) { 8255 root.pendingLanes |= updateLane; // TODO: Theoretically, any update to any lane can unblock any other lane. But 8256 // it's not practical to try every single possible combination. We need a 8257 // heuristic to decide which lanes to attempt to render, and in which batches. 8258 // For now, we use the same heuristic as in the old ExpirationTimes model: 8259 // retry any lane at equal or lower priority, but don't try updates at higher 8260 // priority without also including the lower priority updates. This works well 8261 // when considering updates across different priority levels, but isn't 8262 // sufficient for updates within the same priority, since we want to treat 8263 // those updates as parallel. 8264 // Unsuspend any update at equal or lower priority. 8265 8266 var higherPriorityLanes = updateLane - 1; // Turns 0b1000 into 0b0111 8267 8268 root.suspendedLanes &= higherPriorityLanes; 8269 root.pingedLanes &= higherPriorityLanes; 8270 var eventTimes = root.eventTimes; 8271 var index = laneToIndex(updateLane); // We can always overwrite an existing timestamp because we prefer the most 8272 // recent event, and we assume time is monotonically increasing. 8273 8274 eventTimes[index] = eventTime; 8275} 8276function markRootSuspended(root, suspendedLanes) { 8277 root.suspendedLanes |= suspendedLanes; 8278 root.pingedLanes &= ~suspendedLanes; // The suspended lanes are no longer CPU-bound. Clear their expiration times. 8279 8280 var expirationTimes = root.expirationTimes; 8281 var lanes = suspendedLanes; 8282 8283 while (lanes > 0) { 8284 var index = pickArbitraryLaneIndex(lanes); 8285 var lane = 1 << index; 8286 expirationTimes[index] = NoTimestamp; 8287 lanes &= ~lane; 8288 } 8289} 8290function markRootPinged(root, pingedLanes, eventTime) { 8291 root.pingedLanes |= root.suspendedLanes & pingedLanes; 8292} 8293function markDiscreteUpdatesExpired(root) { 8294 root.expiredLanes |= InputDiscreteLanes & root.pendingLanes; 8295} 8296function hasDiscreteLanes(lanes) { 8297 return (lanes & InputDiscreteLanes) !== NoLanes; 8298} 8299function markRootMutableRead(root, updateLane) { 8300 root.mutableReadLanes |= updateLane & root.pendingLanes; 8301} 8302function markRootFinished(root, remainingLanes) { 8303 var noLongerPendingLanes = root.pendingLanes & ~remainingLanes; 8304 root.pendingLanes = remainingLanes; // Let's try everything again 8305 8306 root.suspendedLanes = 0; 8307 root.pingedLanes = 0; 8308 root.expiredLanes &= remainingLanes; 8309 root.mutableReadLanes &= remainingLanes; 8310 root.entangledLanes &= remainingLanes; 8311 var entanglements = root.entanglements; 8312 var eventTimes = root.eventTimes; 8313 var expirationTimes = root.expirationTimes; // Clear the lanes that no longer have pending work 8314 8315 var lanes = noLongerPendingLanes; 8316 8317 while (lanes > 0) { 8318 var index = pickArbitraryLaneIndex(lanes); 8319 var lane = 1 << index; 8320 entanglements[index] = NoLanes; 8321 eventTimes[index] = NoTimestamp; 8322 expirationTimes[index] = NoTimestamp; 8323 lanes &= ~lane; 8324 } 8325} 8326function markRootEntangled(root, entangledLanes) { 8327 root.entangledLanes |= entangledLanes; 8328 var entanglements = root.entanglements; 8329 var lanes = entangledLanes; 8330 8331 while (lanes > 0) { 8332 var index = pickArbitraryLaneIndex(lanes); 8333 var lane = 1 << index; 8334 entanglements[index] |= entangledLanes; 8335 lanes &= ~lane; 8336 } 8337} 8338var clz32 = Math.clz32 ? Math.clz32 : clz32Fallback; // Count leading zeros. Only used on lanes, so assume input is an integer. 8339// Based on: 8340// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/clz32 8341 8342var log = Math.log; 8343var LN2 = Math.LN2; 8344 8345function clz32Fallback(lanes) { 8346 if (lanes === 0) { 8347 return 32; 8348 } 8349 8350 return 31 - (log(lanes) / LN2 | 0) | 0; 8351} 8352 8353// Intentionally not named imports because Rollup would use dynamic dispatch for 8354var UserBlockingPriority$1 = Scheduler.unstable_UserBlockingPriority, 8355 runWithPriority = Scheduler.unstable_runWithPriority; // TODO: can we stop exporting these? 8356 8357var _enabled = true; // This is exported in FB builds for use by legacy FB layer infra. 8358// We'd like to remove this but it's not clear if this is safe. 8359 8360function setEnabled(enabled) { 8361 _enabled = !!enabled; 8362} 8363function isEnabled() { 8364 return _enabled; 8365} 8366function createEventListenerWrapperWithPriority(targetContainer, domEventName, eventSystemFlags) { 8367 var eventPriority = getEventPriorityForPluginSystem(domEventName); 8368 var listenerWrapper; 8369 8370 switch (eventPriority) { 8371 case DiscreteEvent: 8372 listenerWrapper = dispatchDiscreteEvent; 8373 break; 8374 8375 case UserBlockingEvent: 8376 listenerWrapper = dispatchUserBlockingUpdate; 8377 break; 8378 8379 case ContinuousEvent: 8380 default: 8381 listenerWrapper = dispatchEvent; 8382 break; 8383 } 8384 8385 return listenerWrapper.bind(null, domEventName, eventSystemFlags, targetContainer); 8386} 8387 8388function dispatchDiscreteEvent(domEventName, eventSystemFlags, container, nativeEvent) { 8389 { 8390 flushDiscreteUpdatesIfNeeded(nativeEvent.timeStamp); 8391 } 8392 8393 discreteUpdates(dispatchEvent, domEventName, eventSystemFlags, container, nativeEvent); 8394} 8395 8396function dispatchUserBlockingUpdate(domEventName, eventSystemFlags, container, nativeEvent) { 8397 { 8398 runWithPriority(UserBlockingPriority$1, dispatchEvent.bind(null, domEventName, eventSystemFlags, container, nativeEvent)); 8399 } 8400} 8401 8402function dispatchEvent(domEventName, eventSystemFlags, targetContainer, nativeEvent) { 8403 if (!_enabled) { 8404 return; 8405 } 8406 8407 var allowReplay = true; 8408 8409 { 8410 // TODO: replaying capture phase events is currently broken 8411 // because we used to do it during top-level native bubble handlers 8412 // but now we use different bubble and capture handlers. 8413 // In eager mode, we attach capture listeners early, so we need 8414 // to filter them out until we fix the logic to handle them correctly. 8415 // This could've been outside the flag but I put it inside to reduce risk. 8416 allowReplay = (eventSystemFlags & IS_CAPTURE_PHASE) === 0; 8417 } 8418 8419 if (allowReplay && hasQueuedDiscreteEvents() && isReplayableDiscreteEvent(domEventName)) { 8420 // If we already have a queue of discrete events, and this is another discrete 8421 // event, then we can't dispatch it regardless of its target, since they 8422 // need to dispatch in order. 8423 queueDiscreteEvent(null, // Flags that we're not actually blocked on anything as far as we know. 8424 domEventName, eventSystemFlags, targetContainer, nativeEvent); 8425 return; 8426 } 8427 8428 var blockedOn = attemptToDispatchEvent(domEventName, eventSystemFlags, targetContainer, nativeEvent); 8429 8430 if (blockedOn === null) { 8431 // We successfully dispatched this event. 8432 if (allowReplay) { 8433 clearIfContinuousEvent(domEventName, nativeEvent); 8434 } 8435 8436 return; 8437 } 8438 8439 if (allowReplay) { 8440 if (isReplayableDiscreteEvent(domEventName)) { 8441 // This this to be replayed later once the target is available. 8442 queueDiscreteEvent(blockedOn, domEventName, eventSystemFlags, targetContainer, nativeEvent); 8443 return; 8444 } 8445 8446 if (queueIfContinuousEvent(blockedOn, domEventName, eventSystemFlags, targetContainer, nativeEvent)) { 8447 return; 8448 } // We need to clear only if we didn't queue because 8449 // queueing is accummulative. 8450 8451 8452 clearIfContinuousEvent(domEventName, nativeEvent); 8453 } // This is not replayable so we'll invoke it but without a target, 8454 // in case the event system needs to trace it. 8455 8456 8457 dispatchEventForPluginEventSystem(domEventName, eventSystemFlags, nativeEvent, null, targetContainer); 8458} // Attempt dispatching an event. Returns a SuspenseInstance or Container if it's blocked. 8459 8460function attemptToDispatchEvent(domEventName, eventSystemFlags, targetContainer, nativeEvent) { 8461 // TODO: Warn if _enabled is false. 8462 var nativeEventTarget = getEventTarget(nativeEvent); 8463 var targetInst = getClosestInstanceFromNode(nativeEventTarget); 8464 8465 if (targetInst !== null) { 8466 var nearestMounted = getNearestMountedFiber(targetInst); 8467 8468 if (nearestMounted === null) { 8469 // This tree has been unmounted already. Dispatch without a target. 8470 targetInst = null; 8471 } else { 8472 var tag = nearestMounted.tag; 8473 8474 if (tag === SuspenseComponent) { 8475 var instance = getSuspenseInstanceFromFiber(nearestMounted); 8476 8477 if (instance !== null) { 8478 // Queue the event to be replayed later. Abort dispatching since we 8479 // don't want this event dispatched twice through the event system. 8480 // TODO: If this is the first discrete event in the queue. Schedule an increased 8481 // priority for this boundary. 8482 return instance; 8483 } // This shouldn't happen, something went wrong but to avoid blocking 8484 // the whole system, dispatch the event without a target. 8485 // TODO: Warn. 8486 8487 8488 targetInst = null; 8489 } else if (tag === HostRoot) { 8490 var root = nearestMounted.stateNode; 8491 8492 if (root.hydrate) { 8493 // If this happens during a replay something went wrong and it might block 8494 // the whole system. 8495 return getContainerFromFiber(nearestMounted); 8496 } 8497 8498 targetInst = null; 8499 } else if (nearestMounted !== targetInst) { 8500 // If we get an event (ex: img onload) before committing that 8501 // component's mount, ignore it for now (that is, treat it as if it was an 8502 // event on a non-React tree). We might also consider queueing events and 8503 // dispatching them after the mount. 8504 targetInst = null; 8505 } 8506 } 8507 } 8508 8509 dispatchEventForPluginEventSystem(domEventName, eventSystemFlags, nativeEvent, targetInst, targetContainer); // We're not blocked on anything. 8510 8511 return null; 8512} 8513 8514function addEventBubbleListener(target, eventType, listener) { 8515 target.addEventListener(eventType, listener, false); 8516 return listener; 8517} 8518function addEventCaptureListener(target, eventType, listener) { 8519 target.addEventListener(eventType, listener, true); 8520 return listener; 8521} 8522function addEventCaptureListenerWithPassiveFlag(target, eventType, listener, passive) { 8523 target.addEventListener(eventType, listener, { 8524 capture: true, 8525 passive: passive 8526 }); 8527 return listener; 8528} 8529function addEventBubbleListenerWithPassiveFlag(target, eventType, listener, passive) { 8530 target.addEventListener(eventType, listener, { 8531 passive: passive 8532 }); 8533 return listener; 8534} 8535 8536/** 8537 * These variables store information about text content of a target node, 8538 * allowing comparison of content before and after a given event. 8539 * 8540 * Identify the node where selection currently begins, then observe 8541 * both its text content and its current position in the DOM. Since the 8542 * browser may natively replace the target node during composition, we can 8543 * use its position to find its replacement. 8544 * 8545 * 8546 */ 8547var root = null; 8548var startText = null; 8549var fallbackText = null; 8550function initialize(nativeEventTarget) { 8551 root = nativeEventTarget; 8552 startText = getText(); 8553 return true; 8554} 8555function reset() { 8556 root = null; 8557 startText = null; 8558 fallbackText = null; 8559} 8560function getData() { 8561 if (fallbackText) { 8562 return fallbackText; 8563 } 8564 8565 var start; 8566 var startValue = startText; 8567 var startLength = startValue.length; 8568 var end; 8569 var endValue = getText(); 8570 var endLength = endValue.length; 8571 8572 for (start = 0; start < startLength; start++) { 8573 if (startValue[start] !== endValue[start]) { 8574 break; 8575 } 8576 } 8577 8578 var minEnd = startLength - start; 8579 8580 for (end = 1; end <= minEnd; end++) { 8581 if (startValue[startLength - end] !== endValue[endLength - end]) { 8582 break; 8583 } 8584 } 8585 8586 var sliceTail = end > 1 ? 1 - end : undefined; 8587 fallbackText = endValue.slice(start, sliceTail); 8588 return fallbackText; 8589} 8590function getText() { 8591 if ('value' in root) { 8592 return root.value; 8593 } 8594 8595 return root.textContent; 8596} 8597 8598/** 8599 * `charCode` represents the actual "character code" and is safe to use with 8600 * `String.fromCharCode`. As such, only keys that correspond to printable 8601 * characters produce a valid `charCode`, the only exception to this is Enter. 8602 * The Tab-key is considered non-printable and does not have a `charCode`, 8603 * presumably because it does not produce a tab-character in browsers. 8604 * 8605 * @param {object} nativeEvent Native browser event. 8606 * @return {number} Normalized `charCode` property. 8607 */ 8608function getEventCharCode(nativeEvent) { 8609 var charCode; 8610 var keyCode = nativeEvent.keyCode; 8611 8612 if ('charCode' in nativeEvent) { 8613 charCode = nativeEvent.charCode; // FF does not set `charCode` for the Enter-key, check against `keyCode`. 8614 8615 if (charCode === 0 && keyCode === 13) { 8616 charCode = 13; 8617 } 8618 } else { 8619 // IE8 does not implement `charCode`, but `keyCode` has the correct value. 8620 charCode = keyCode; 8621 } // IE and Edge (on Windows) and Chrome / Safari (on Windows and Linux) 8622 // report Enter as charCode 10 when ctrl is pressed. 8623 8624 8625 if (charCode === 10) { 8626 charCode = 13; 8627 } // Some non-printable keys are reported in `charCode`/`keyCode`, discard them. 8628 // Must not discard the (non-)printable Enter-key. 8629 8630 8631 if (charCode >= 32 || charCode === 13) { 8632 return charCode; 8633 } 8634 8635 return 0; 8636} 8637 8638function functionThatReturnsTrue() { 8639 return true; 8640} 8641 8642function functionThatReturnsFalse() { 8643 return false; 8644} // This is intentionally a factory so that we have different returned constructors. 8645// If we had a single constructor, it would be megamorphic and engines would deopt. 8646 8647 8648function createSyntheticEvent(Interface) { 8649 /** 8650 * Synthetic events are dispatched by event plugins, typically in response to a 8651 * top-level event delegation handler. 8652 * 8653 * These systems should generally use pooling to reduce the frequency of garbage 8654 * collection. The system should check `isPersistent` to determine whether the 8655 * event should be released into the pool after being dispatched. Users that 8656 * need a persisted event should invoke `persist`. 8657 * 8658 * Synthetic events (and subclasses) implement the DOM Level 3 Events API by 8659 * normalizing browser quirks. Subclasses do not necessarily have to implement a 8660 * DOM interface; custom application-specific events can also subclass this. 8661 */ 8662 function SyntheticBaseEvent(reactName, reactEventType, targetInst, nativeEvent, nativeEventTarget) { 8663 this._reactName = reactName; 8664 this._targetInst = targetInst; 8665 this.type = reactEventType; 8666 this.nativeEvent = nativeEvent; 8667 this.target = nativeEventTarget; 8668 this.currentTarget = null; 8669 8670 for (var _propName in Interface) { 8671 if (!Interface.hasOwnProperty(_propName)) { 8672 continue; 8673 } 8674 8675 var normalize = Interface[_propName]; 8676 8677 if (normalize) { 8678 this[_propName] = normalize(nativeEvent); 8679 } else { 8680 this[_propName] = nativeEvent[_propName]; 8681 } 8682 } 8683 8684 var defaultPrevented = nativeEvent.defaultPrevented != null ? nativeEvent.defaultPrevented : nativeEvent.returnValue === false; 8685 8686 if (defaultPrevented) { 8687 this.isDefaultPrevented = functionThatReturnsTrue; 8688 } else { 8689 this.isDefaultPrevented = functionThatReturnsFalse; 8690 } 8691 8692 this.isPropagationStopped = functionThatReturnsFalse; 8693 return this; 8694 } 8695 8696 _assign(SyntheticBaseEvent.prototype, { 8697 preventDefault: function () { 8698 this.defaultPrevented = true; 8699 var event = this.nativeEvent; 8700 8701 if (!event) { 8702 return; 8703 } 8704 8705 if (event.preventDefault) { 8706 event.preventDefault(); // $FlowFixMe - flow is not aware of `unknown` in IE 8707 } else if (typeof event.returnValue !== 'unknown') { 8708 event.returnValue = false; 8709 } 8710 8711 this.isDefaultPrevented = functionThatReturnsTrue; 8712 }, 8713 stopPropagation: function () { 8714 var event = this.nativeEvent; 8715 8716 if (!event) { 8717 return; 8718 } 8719 8720 if (event.stopPropagation) { 8721 event.stopPropagation(); // $FlowFixMe - flow is not aware of `unknown` in IE 8722 } else if (typeof event.cancelBubble !== 'unknown') { 8723 // The ChangeEventPlugin registers a "propertychange" event for 8724 // IE. This event does not support bubbling or cancelling, and 8725 // any references to cancelBubble throw "Member not found". A 8726 // typeof check of "unknown" circumvents this issue (and is also 8727 // IE specific). 8728 event.cancelBubble = true; 8729 } 8730 8731 this.isPropagationStopped = functionThatReturnsTrue; 8732 }, 8733 8734 /** 8735 * We release all dispatched `SyntheticEvent`s after each event loop, adding 8736 * them back into the pool. This allows a way to hold onto a reference that 8737 * won't be added back into the pool. 8738 */ 8739 persist: function () {// Modern event system doesn't use pooling. 8740 }, 8741 8742 /** 8743 * Checks if this event should be released back into the pool. 8744 * 8745 * @return {boolean} True if this should not be released, false otherwise. 8746 */ 8747 isPersistent: functionThatReturnsTrue 8748 }); 8749 8750 return SyntheticBaseEvent; 8751} 8752/** 8753 * @interface Event 8754 * @see http://www.w3.org/TR/DOM-Level-3-Events/ 8755 */ 8756 8757 8758var EventInterface = { 8759 eventPhase: 0, 8760 bubbles: 0, 8761 cancelable: 0, 8762 timeStamp: function (event) { 8763 return event.timeStamp || Date.now(); 8764 }, 8765 defaultPrevented: 0, 8766 isTrusted: 0 8767}; 8768var SyntheticEvent = createSyntheticEvent(EventInterface); 8769 8770var UIEventInterface = _assign({}, EventInterface, { 8771 view: 0, 8772 detail: 0 8773}); 8774 8775var SyntheticUIEvent = createSyntheticEvent(UIEventInterface); 8776var lastMovementX; 8777var lastMovementY; 8778var lastMouseEvent; 8779 8780function updateMouseMovementPolyfillState(event) { 8781 if (event !== lastMouseEvent) { 8782 if (lastMouseEvent && event.type === 'mousemove') { 8783 lastMovementX = event.screenX - lastMouseEvent.screenX; 8784 lastMovementY = event.screenY - lastMouseEvent.screenY; 8785 } else { 8786 lastMovementX = 0; 8787 lastMovementY = 0; 8788 } 8789 8790 lastMouseEvent = event; 8791 } 8792} 8793/** 8794 * @interface MouseEvent 8795 * @see http://www.w3.org/TR/DOM-Level-3-Events/ 8796 */ 8797 8798 8799var MouseEventInterface = _assign({}, UIEventInterface, { 8800 screenX: 0, 8801 screenY: 0, 8802 clientX: 0, 8803 clientY: 0, 8804 pageX: 0, 8805 pageY: 0, 8806 ctrlKey: 0, 8807 shiftKey: 0, 8808 altKey: 0, 8809 metaKey: 0, 8810 getModifierState: getEventModifierState, 8811 button: 0, 8812 buttons: 0, 8813 relatedTarget: function (event) { 8814 if (event.relatedTarget === undefined) return event.fromElement === event.srcElement ? event.toElement : event.fromElement; 8815 return event.relatedTarget; 8816 }, 8817 movementX: function (event) { 8818 if ('movementX' in event) { 8819 return event.movementX; 8820 } 8821 8822 updateMouseMovementPolyfillState(event); 8823 return lastMovementX; 8824 }, 8825 movementY: function (event) { 8826 if ('movementY' in event) { 8827 return event.movementY; 8828 } // Don't need to call updateMouseMovementPolyfillState() here 8829 // because it's guaranteed to have already run when movementX 8830 // was copied. 8831 8832 8833 return lastMovementY; 8834 } 8835}); 8836 8837var SyntheticMouseEvent = createSyntheticEvent(MouseEventInterface); 8838/** 8839 * @interface DragEvent 8840 * @see http://www.w3.org/TR/DOM-Level-3-Events/ 8841 */ 8842 8843var DragEventInterface = _assign({}, MouseEventInterface, { 8844 dataTransfer: 0 8845}); 8846 8847var SyntheticDragEvent = createSyntheticEvent(DragEventInterface); 8848/** 8849 * @interface FocusEvent 8850 * @see http://www.w3.org/TR/DOM-Level-3-Events/ 8851 */ 8852 8853var FocusEventInterface = _assign({}, UIEventInterface, { 8854 relatedTarget: 0 8855}); 8856 8857var SyntheticFocusEvent = createSyntheticEvent(FocusEventInterface); 8858/** 8859 * @interface Event 8860 * @see http://www.w3.org/TR/css3-animations/#AnimationEvent-interface 8861 * @see https://developer.mozilla.org/en-US/docs/Web/API/AnimationEvent 8862 */ 8863 8864var AnimationEventInterface = _assign({}, EventInterface, { 8865 animationName: 0, 8866 elapsedTime: 0, 8867 pseudoElement: 0 8868}); 8869 8870var SyntheticAnimationEvent = createSyntheticEvent(AnimationEventInterface); 8871/** 8872 * @interface Event 8873 * @see http://www.w3.org/TR/clipboard-apis/ 8874 */ 8875 8876var ClipboardEventInterface = _assign({}, EventInterface, { 8877 clipboardData: function (event) { 8878 return 'clipboardData' in event ? event.clipboardData : window.clipboardData; 8879 } 8880}); 8881 8882var SyntheticClipboardEvent = createSyntheticEvent(ClipboardEventInterface); 8883/** 8884 * @interface Event 8885 * @see http://www.w3.org/TR/DOM-Level-3-Events/#events-compositionevents 8886 */ 8887 8888var CompositionEventInterface = _assign({}, EventInterface, { 8889 data: 0 8890}); 8891 8892var SyntheticCompositionEvent = createSyntheticEvent(CompositionEventInterface); 8893/** 8894 * @interface Event 8895 * @see http://www.w3.org/TR/2013/WD-DOM-Level-3-Events-20131105 8896 * /#events-inputevents 8897 */ 8898// Happens to share the same list for now. 8899 8900var SyntheticInputEvent = SyntheticCompositionEvent; 8901/** 8902 * Normalization of deprecated HTML5 `key` values 8903 * @see https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent#Key_names 8904 */ 8905 8906var normalizeKey = { 8907 Esc: 'Escape', 8908 Spacebar: ' ', 8909 Left: 'ArrowLeft', 8910 Up: 'ArrowUp', 8911 Right: 'ArrowRight', 8912 Down: 'ArrowDown', 8913 Del: 'Delete', 8914 Win: 'OS', 8915 Menu: 'ContextMenu', 8916 Apps: 'ContextMenu', 8917 Scroll: 'ScrollLock', 8918 MozPrintableKey: 'Unidentified' 8919}; 8920/** 8921 * Translation from legacy `keyCode` to HTML5 `key` 8922 * Only special keys supported, all others depend on keyboard layout or browser 8923 * @see https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent#Key_names 8924 */ 8925 8926var translateToKey = { 8927 '8': 'Backspace', 8928 '9': 'Tab', 8929 '12': 'Clear', 8930 '13': 'Enter', 8931 '16': 'Shift', 8932 '17': 'Control', 8933 '18': 'Alt', 8934 '19': 'Pause', 8935 '20': 'CapsLock', 8936 '27': 'Escape', 8937 '32': ' ', 8938 '33': 'PageUp', 8939 '34': 'PageDown', 8940 '35': 'End', 8941 '36': 'Home', 8942 '37': 'ArrowLeft', 8943 '38': 'ArrowUp', 8944 '39': 'ArrowRight', 8945 '40': 'ArrowDown', 8946 '45': 'Insert', 8947 '46': 'Delete', 8948 '112': 'F1', 8949 '113': 'F2', 8950 '114': 'F3', 8951 '115': 'F4', 8952 '116': 'F5', 8953 '117': 'F6', 8954 '118': 'F7', 8955 '119': 'F8', 8956 '120': 'F9', 8957 '121': 'F10', 8958 '122': 'F11', 8959 '123': 'F12', 8960 '144': 'NumLock', 8961 '145': 'ScrollLock', 8962 '224': 'Meta' 8963}; 8964/** 8965 * @param {object} nativeEvent Native browser event. 8966 * @return {string} Normalized `key` property. 8967 */ 8968 8969function getEventKey(nativeEvent) { 8970 if (nativeEvent.key) { 8971 // Normalize inconsistent values reported by browsers due to 8972 // implementations of a working draft specification. 8973 // FireFox implements `key` but returns `MozPrintableKey` for all 8974 // printable characters (normalized to `Unidentified`), ignore it. 8975 var key = normalizeKey[nativeEvent.key] || nativeEvent.key; 8976 8977 if (key !== 'Unidentified') { 8978 return key; 8979 } 8980 } // Browser does not implement `key`, polyfill as much of it as we can. 8981 8982 8983 if (nativeEvent.type === 'keypress') { 8984 var charCode = getEventCharCode(nativeEvent); // The enter-key is technically both printable and non-printable and can 8985 // thus be captured by `keypress`, no other non-printable key should. 8986 8987 return charCode === 13 ? 'Enter' : String.fromCharCode(charCode); 8988 } 8989 8990 if (nativeEvent.type === 'keydown' || nativeEvent.type === 'keyup') { 8991 // While user keyboard layout determines the actual meaning of each 8992 // `keyCode` value, almost all function keys have a universal value. 8993 return translateToKey[nativeEvent.keyCode] || 'Unidentified'; 8994 } 8995 8996 return ''; 8997} 8998/** 8999 * Translation from modifier key to the associated property in the event. 9000 * @see http://www.w3.org/TR/DOM-Level-3-Events/#keys-Modifiers 9001 */ 9002 9003 9004var modifierKeyToProp = { 9005 Alt: 'altKey', 9006 Control: 'ctrlKey', 9007 Meta: 'metaKey', 9008 Shift: 'shiftKey' 9009}; // Older browsers (Safari <= 10, iOS Safari <= 10.2) do not support 9010// getModifierState. If getModifierState is not supported, we map it to a set of 9011// modifier keys exposed by the event. In this case, Lock-keys are not supported. 9012 9013function modifierStateGetter(keyArg) { 9014 var syntheticEvent = this; 9015 var nativeEvent = syntheticEvent.nativeEvent; 9016 9017 if (nativeEvent.getModifierState) { 9018 return nativeEvent.getModifierState(keyArg); 9019 } 9020 9021 var keyProp = modifierKeyToProp[keyArg]; 9022 return keyProp ? !!nativeEvent[keyProp] : false; 9023} 9024 9025function getEventModifierState(nativeEvent) { 9026 return modifierStateGetter; 9027} 9028/** 9029 * @interface KeyboardEvent 9030 * @see http://www.w3.org/TR/DOM-Level-3-Events/ 9031 */ 9032 9033 9034var KeyboardEventInterface = _assign({}, UIEventInterface, { 9035 key: getEventKey, 9036 code: 0, 9037 location: 0, 9038 ctrlKey: 0, 9039 shiftKey: 0, 9040 altKey: 0, 9041 metaKey: 0, 9042 repeat: 0, 9043 locale: 0, 9044 getModifierState: getEventModifierState, 9045 // Legacy Interface 9046 charCode: function (event) { 9047 // `charCode` is the result of a KeyPress event and represents the value of 9048 // the actual printable character. 9049 // KeyPress is deprecated, but its replacement is not yet final and not 9050 // implemented in any major browser. Only KeyPress has charCode. 9051 if (event.type === 'keypress') { 9052 return getEventCharCode(event); 9053 } 9054 9055 return 0; 9056 }, 9057 keyCode: function (event) { 9058 // `keyCode` is the result of a KeyDown/Up event and represents the value of 9059 // physical keyboard key. 9060 // The actual meaning of the value depends on the users' keyboard layout 9061 // which cannot be detected. Assuming that it is a US keyboard layout 9062 // provides a surprisingly accurate mapping for US and European users. 9063 // Due to this, it is left to the user to implement at this time. 9064 if (event.type === 'keydown' || event.type === 'keyup') { 9065 return event.keyCode; 9066 } 9067 9068 return 0; 9069 }, 9070 which: function (event) { 9071 // `which` is an alias for either `keyCode` or `charCode` depending on the 9072 // type of the event. 9073 if (event.type === 'keypress') { 9074 return getEventCharCode(event); 9075 } 9076 9077 if (event.type === 'keydown' || event.type === 'keyup') { 9078 return event.keyCode; 9079 } 9080 9081 return 0; 9082 } 9083}); 9084 9085var SyntheticKeyboardEvent = createSyntheticEvent(KeyboardEventInterface); 9086/** 9087 * @interface PointerEvent 9088 * @see http://www.w3.org/TR/pointerevents/ 9089 */ 9090 9091var PointerEventInterface = _assign({}, MouseEventInterface, { 9092 pointerId: 0, 9093 width: 0, 9094 height: 0, 9095 pressure: 0, 9096 tangentialPressure: 0, 9097 tiltX: 0, 9098 tiltY: 0, 9099 twist: 0, 9100 pointerType: 0, 9101 isPrimary: 0 9102}); 9103 9104var SyntheticPointerEvent = createSyntheticEvent(PointerEventInterface); 9105/** 9106 * @interface TouchEvent 9107 * @see http://www.w3.org/TR/touch-events/ 9108 */ 9109 9110var TouchEventInterface = _assign({}, UIEventInterface, { 9111 touches: 0, 9112 targetTouches: 0, 9113 changedTouches: 0, 9114 altKey: 0, 9115 metaKey: 0, 9116 ctrlKey: 0, 9117 shiftKey: 0, 9118 getModifierState: getEventModifierState 9119}); 9120 9121var SyntheticTouchEvent = createSyntheticEvent(TouchEventInterface); 9122/** 9123 * @interface Event 9124 * @see http://www.w3.org/TR/2009/WD-css3-transitions-20090320/#transition-events- 9125 * @see https://developer.mozilla.org/en-US/docs/Web/API/TransitionEvent 9126 */ 9127 9128var TransitionEventInterface = _assign({}, EventInterface, { 9129 propertyName: 0, 9130 elapsedTime: 0, 9131 pseudoElement: 0 9132}); 9133 9134var SyntheticTransitionEvent = createSyntheticEvent(TransitionEventInterface); 9135/** 9136 * @interface WheelEvent 9137 * @see http://www.w3.org/TR/DOM-Level-3-Events/ 9138 */ 9139 9140var WheelEventInterface = _assign({}, MouseEventInterface, { 9141 deltaX: function (event) { 9142 return 'deltaX' in event ? event.deltaX : // Fallback to `wheelDeltaX` for Webkit and normalize (right is positive). 9143 'wheelDeltaX' in event ? -event.wheelDeltaX : 0; 9144 }, 9145 deltaY: function (event) { 9146 return 'deltaY' in event ? event.deltaY : // Fallback to `wheelDeltaY` for Webkit and normalize (down is positive). 9147 'wheelDeltaY' in event ? -event.wheelDeltaY : // Fallback to `wheelDelta` for IE<9 and normalize (down is positive). 9148 'wheelDelta' in event ? -event.wheelDelta : 0; 9149 }, 9150 deltaZ: 0, 9151 // Browsers without "deltaMode" is reporting in raw wheel delta where one 9152 // notch on the scroll is always +/- 120, roughly equivalent to pixels. 9153 // A good approximation of DOM_DELTA_LINE (1) is 5% of viewport size or 9154 // ~40 pixels, for DOM_DELTA_SCREEN (2) it is 87.5% of viewport size. 9155 deltaMode: 0 9156}); 9157 9158var SyntheticWheelEvent = createSyntheticEvent(WheelEventInterface); 9159 9160var END_KEYCODES = [9, 13, 27, 32]; // Tab, Return, Esc, Space 9161 9162var START_KEYCODE = 229; 9163var canUseCompositionEvent = canUseDOM && 'CompositionEvent' in window; 9164var documentMode = null; 9165 9166if (canUseDOM && 'documentMode' in document) { 9167 documentMode = document.documentMode; 9168} // Webkit offers a very useful `textInput` event that can be used to 9169// directly represent `beforeInput`. The IE `textinput` event is not as 9170// useful, so we don't use it. 9171 9172 9173var canUseTextInputEvent = canUseDOM && 'TextEvent' in window && !documentMode; // In IE9+, we have access to composition events, but the data supplied 9174// by the native compositionend event may be incorrect. Japanese ideographic 9175// spaces, for instance (\u3000) are not recorded correctly. 9176 9177var useFallbackCompositionData = canUseDOM && (!canUseCompositionEvent || documentMode && documentMode > 8 && documentMode <= 11); 9178var SPACEBAR_CODE = 32; 9179var SPACEBAR_CHAR = String.fromCharCode(SPACEBAR_CODE); 9180 9181function registerEvents() { 9182 registerTwoPhaseEvent('onBeforeInput', ['compositionend', 'keypress', 'textInput', 'paste']); 9183 registerTwoPhaseEvent('onCompositionEnd', ['compositionend', 'focusout', 'keydown', 'keypress', 'keyup', 'mousedown']); 9184 registerTwoPhaseEvent('onCompositionStart', ['compositionstart', 'focusout', 'keydown', 'keypress', 'keyup', 'mousedown']); 9185 registerTwoPhaseEvent('onCompositionUpdate', ['compositionupdate', 'focusout', 'keydown', 'keypress', 'keyup', 'mousedown']); 9186} // Track whether we've ever handled a keypress on the space key. 9187 9188 9189var hasSpaceKeypress = false; 9190/** 9191 * Return whether a native keypress event is assumed to be a command. 9192 * This is required because Firefox fires `keypress` events for key commands 9193 * (cut, copy, select-all, etc.) even though no character is inserted. 9194 */ 9195 9196function isKeypressCommand(nativeEvent) { 9197 return (nativeEvent.ctrlKey || nativeEvent.altKey || nativeEvent.metaKey) && // ctrlKey && altKey is equivalent to AltGr, and is not a command. 9198 !(nativeEvent.ctrlKey && nativeEvent.altKey); 9199} 9200/** 9201 * Translate native top level events into event types. 9202 */ 9203 9204 9205function getCompositionEventType(domEventName) { 9206 switch (domEventName) { 9207 case 'compositionstart': 9208 return 'onCompositionStart'; 9209 9210 case 'compositionend': 9211 return 'onCompositionEnd'; 9212 9213 case 'compositionupdate': 9214 return 'onCompositionUpdate'; 9215 } 9216} 9217/** 9218 * Does our fallback best-guess model think this event signifies that 9219 * composition has begun? 9220 */ 9221 9222 9223function isFallbackCompositionStart(domEventName, nativeEvent) { 9224 return domEventName === 'keydown' && nativeEvent.keyCode === START_KEYCODE; 9225} 9226/** 9227 * Does our fallback mode think that this event is the end of composition? 9228 */ 9229 9230 9231function isFallbackCompositionEnd(domEventName, nativeEvent) { 9232 switch (domEventName) { 9233 case 'keyup': 9234 // Command keys insert or clear IME input. 9235 return END_KEYCODES.indexOf(nativeEvent.keyCode) !== -1; 9236 9237 case 'keydown': 9238 // Expect IME keyCode on each keydown. If we get any other 9239 // code we must have exited earlier. 9240 return nativeEvent.keyCode !== START_KEYCODE; 9241 9242 case 'keypress': 9243 case 'mousedown': 9244 case 'focusout': 9245 // Events are not possible without cancelling IME. 9246 return true; 9247 9248 default: 9249 return false; 9250 } 9251} 9252/** 9253 * Google Input Tools provides composition data via a CustomEvent, 9254 * with the `data` property populated in the `detail` object. If this 9255 * is available on the event object, use it. If not, this is a plain 9256 * composition event and we have nothing special to extract. 9257 * 9258 * @param {object} nativeEvent 9259 * @return {?string} 9260 */ 9261 9262 9263function getDataFromCustomEvent(nativeEvent) { 9264 var detail = nativeEvent.detail; 9265 9266 if (typeof detail === 'object' && 'data' in detail) { 9267 return detail.data; 9268 } 9269 9270 return null; 9271} 9272/** 9273 * Check if a composition event was triggered by Korean IME. 9274 * Our fallback mode does not work well with IE's Korean IME, 9275 * so just use native composition events when Korean IME is used. 9276 * Although CompositionEvent.locale property is deprecated, 9277 * it is available in IE, where our fallback mode is enabled. 9278 * 9279 * @param {object} nativeEvent 9280 * @return {boolean} 9281 */ 9282 9283 9284function isUsingKoreanIME(nativeEvent) { 9285 return nativeEvent.locale === 'ko'; 9286} // Track the current IME composition status, if any. 9287 9288 9289var isComposing = false; 9290/** 9291 * @return {?object} A SyntheticCompositionEvent. 9292 */ 9293 9294function extractCompositionEvent(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget) { 9295 var eventType; 9296 var fallbackData; 9297 9298 if (canUseCompositionEvent) { 9299 eventType = getCompositionEventType(domEventName); 9300 } else if (!isComposing) { 9301 if (isFallbackCompositionStart(domEventName, nativeEvent)) { 9302 eventType = 'onCompositionStart'; 9303 } 9304 } else if (isFallbackCompositionEnd(domEventName, nativeEvent)) { 9305 eventType = 'onCompositionEnd'; 9306 } 9307 9308 if (!eventType) { 9309 return null; 9310 } 9311 9312 if (useFallbackCompositionData && !isUsingKoreanIME(nativeEvent)) { 9313 // The current composition is stored statically and must not be 9314 // overwritten while composition continues. 9315 if (!isComposing && eventType === 'onCompositionStart') { 9316 isComposing = initialize(nativeEventTarget); 9317 } else if (eventType === 'onCompositionEnd') { 9318 if (isComposing) { 9319 fallbackData = getData(); 9320 } 9321 } 9322 } 9323 9324 var listeners = accumulateTwoPhaseListeners(targetInst, eventType); 9325 9326 if (listeners.length > 0) { 9327 var event = new SyntheticCompositionEvent(eventType, domEventName, null, nativeEvent, nativeEventTarget); 9328 dispatchQueue.push({ 9329 event: event, 9330 listeners: listeners 9331 }); 9332 9333 if (fallbackData) { 9334 // Inject data generated from fallback path into the synthetic event. 9335 // This matches the property of native CompositionEventInterface. 9336 event.data = fallbackData; 9337 } else { 9338 var customData = getDataFromCustomEvent(nativeEvent); 9339 9340 if (customData !== null) { 9341 event.data = customData; 9342 } 9343 } 9344 } 9345} 9346 9347function getNativeBeforeInputChars(domEventName, nativeEvent) { 9348 switch (domEventName) { 9349 case 'compositionend': 9350 return getDataFromCustomEvent(nativeEvent); 9351 9352 case 'keypress': 9353 /** 9354 * If native `textInput` events are available, our goal is to make 9355 * use of them. However, there is a special case: the spacebar key. 9356 * In Webkit, preventing default on a spacebar `textInput` event 9357 * cancels character insertion, but it *also* causes the browser 9358 * to fall back to its default spacebar behavior of scrolling the 9359 * page. 9360 * 9361 * Tracking at: 9362 * https://code.google.com/p/chromium/issues/detail?id=355103 9363 * 9364 * To avoid this issue, use the keypress event as if no `textInput` 9365 * event is available. 9366 */ 9367 var which = nativeEvent.which; 9368 9369 if (which !== SPACEBAR_CODE) { 9370 return null; 9371 } 9372 9373 hasSpaceKeypress = true; 9374 return SPACEBAR_CHAR; 9375 9376 case 'textInput': 9377 // Record the characters to be added to the DOM. 9378 var chars = nativeEvent.data; // If it's a spacebar character, assume that we have already handled 9379 // it at the keypress level and bail immediately. Android Chrome 9380 // doesn't give us keycodes, so we need to ignore it. 9381 9382 if (chars === SPACEBAR_CHAR && hasSpaceKeypress) { 9383 return null; 9384 } 9385 9386 return chars; 9387 9388 default: 9389 // For other native event types, do nothing. 9390 return null; 9391 } 9392} 9393/** 9394 * For browsers that do not provide the `textInput` event, extract the 9395 * appropriate string to use for SyntheticInputEvent. 9396 */ 9397 9398 9399function getFallbackBeforeInputChars(domEventName, nativeEvent) { 9400 // If we are currently composing (IME) and using a fallback to do so, 9401 // try to extract the composed characters from the fallback object. 9402 // If composition event is available, we extract a string only at 9403 // compositionevent, otherwise extract it at fallback events. 9404 if (isComposing) { 9405 if (domEventName === 'compositionend' || !canUseCompositionEvent && isFallbackCompositionEnd(domEventName, nativeEvent)) { 9406 var chars = getData(); 9407 reset(); 9408 isComposing = false; 9409 return chars; 9410 } 9411 9412 return null; 9413 } 9414 9415 switch (domEventName) { 9416 case 'paste': 9417 // If a paste event occurs after a keypress, throw out the input 9418 // chars. Paste events should not lead to BeforeInput events. 9419 return null; 9420 9421 case 'keypress': 9422 /** 9423 * As of v27, Firefox may fire keypress events even when no character 9424 * will be inserted. A few possibilities: 9425 * 9426 * - `which` is `0`. Arrow keys, Esc key, etc. 9427 * 9428 * - `which` is the pressed key code, but no char is available. 9429 * Ex: 'AltGr + d` in Polish. There is no modified character for 9430 * this key combination and no character is inserted into the 9431 * document, but FF fires the keypress for char code `100` anyway. 9432 * No `input` event will occur. 9433 * 9434 * - `which` is the pressed key code, but a command combination is 9435 * being used. Ex: `Cmd+C`. No character is inserted, and no 9436 * `input` event will occur. 9437 */ 9438 if (!isKeypressCommand(nativeEvent)) { 9439 // IE fires the `keypress` event when a user types an emoji via 9440 // Touch keyboard of Windows. In such a case, the `char` property 9441 // holds an emoji character like `\uD83D\uDE0A`. Because its length 9442 // is 2, the property `which` does not represent an emoji correctly. 9443 // In such a case, we directly return the `char` property instead of 9444 // using `which`. 9445 if (nativeEvent.char && nativeEvent.char.length > 1) { 9446 return nativeEvent.char; 9447 } else if (nativeEvent.which) { 9448 return String.fromCharCode(nativeEvent.which); 9449 } 9450 } 9451 9452 return null; 9453 9454 case 'compositionend': 9455 return useFallbackCompositionData && !isUsingKoreanIME(nativeEvent) ? null : nativeEvent.data; 9456 9457 default: 9458 return null; 9459 } 9460} 9461/** 9462 * Extract a SyntheticInputEvent for `beforeInput`, based on either native 9463 * `textInput` or fallback behavior. 9464 * 9465 * @return {?object} A SyntheticInputEvent. 9466 */ 9467 9468 9469function extractBeforeInputEvent(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget) { 9470 var chars; 9471 9472 if (canUseTextInputEvent) { 9473 chars = getNativeBeforeInputChars(domEventName, nativeEvent); 9474 } else { 9475 chars = getFallbackBeforeInputChars(domEventName, nativeEvent); 9476 } // If no characters are being inserted, no BeforeInput event should 9477 // be fired. 9478 9479 9480 if (!chars) { 9481 return null; 9482 } 9483 9484 var listeners = accumulateTwoPhaseListeners(targetInst, 'onBeforeInput'); 9485 9486 if (listeners.length > 0) { 9487 var event = new SyntheticInputEvent('onBeforeInput', 'beforeinput', null, nativeEvent, nativeEventTarget); 9488 dispatchQueue.push({ 9489 event: event, 9490 listeners: listeners 9491 }); 9492 event.data = chars; 9493 } 9494} 9495/** 9496 * Create an `onBeforeInput` event to match 9497 * http://www.w3.org/TR/2013/WD-DOM-Level-3-Events-20131105/#events-inputevents. 9498 * 9499 * This event plugin is based on the native `textInput` event 9500 * available in Chrome, Safari, Opera, and IE. This event fires after 9501 * `onKeyPress` and `onCompositionEnd`, but before `onInput`. 9502 * 9503 * `beforeInput` is spec'd but not implemented in any browsers, and 9504 * the `input` event does not provide any useful information about what has 9505 * actually been added, contrary to the spec. Thus, `textInput` is the best 9506 * available event to identify the characters that have actually been inserted 9507 * into the target node. 9508 * 9509 * This plugin is also responsible for emitting `composition` events, thus 9510 * allowing us to share composition fallback code for both `beforeInput` and 9511 * `composition` event types. 9512 */ 9513 9514 9515function extractEvents(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags, targetContainer) { 9516 extractCompositionEvent(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget); 9517 extractBeforeInputEvent(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget); 9518} 9519 9520/** 9521 * @see http://www.whatwg.org/specs/web-apps/current-work/multipage/the-input-element.html#input-type-attr-summary 9522 */ 9523var supportedInputTypes = { 9524 color: true, 9525 date: true, 9526 datetime: true, 9527 'datetime-local': true, 9528 email: true, 9529 month: true, 9530 number: true, 9531 password: true, 9532 range: true, 9533 search: true, 9534 tel: true, 9535 text: true, 9536 time: true, 9537 url: true, 9538 week: true 9539}; 9540 9541function isTextInputElement(elem) { 9542 var nodeName = elem && elem.nodeName && elem.nodeName.toLowerCase(); 9543 9544 if (nodeName === 'input') { 9545 return !!supportedInputTypes[elem.type]; 9546 } 9547 9548 if (nodeName === 'textarea') { 9549 return true; 9550 } 9551 9552 return false; 9553} 9554 9555/** 9556 * Checks if an event is supported in the current execution environment. 9557 * 9558 * NOTE: This will not work correctly for non-generic events such as `change`, 9559 * `reset`, `load`, `error`, and `select`. 9560 * 9561 * Borrows from Modernizr. 9562 * 9563 * @param {string} eventNameSuffix Event name, e.g. "click". 9564 * @return {boolean} True if the event is supported. 9565 * @internal 9566 * @license Modernizr 3.0.0pre (Custom Build) | MIT 9567 */ 9568 9569function isEventSupported(eventNameSuffix) { 9570 if (!canUseDOM) { 9571 return false; 9572 } 9573 9574 var eventName = 'on' + eventNameSuffix; 9575 var isSupported = (eventName in document); 9576 9577 if (!isSupported) { 9578 var element = document.createElement('div'); 9579 element.setAttribute(eventName, 'return;'); 9580 isSupported = typeof element[eventName] === 'function'; 9581 } 9582 9583 return isSupported; 9584} 9585 9586function registerEvents$1() { 9587 registerTwoPhaseEvent('onChange', ['change', 'click', 'focusin', 'focusout', 'input', 'keydown', 'keyup', 'selectionchange']); 9588} 9589 9590function createAndAccumulateChangeEvent(dispatchQueue, inst, nativeEvent, target) { 9591 // Flag this event loop as needing state restore. 9592 enqueueStateRestore(target); 9593 var listeners = accumulateTwoPhaseListeners(inst, 'onChange'); 9594 9595 if (listeners.length > 0) { 9596 var event = new SyntheticEvent('onChange', 'change', null, nativeEvent, target); 9597 dispatchQueue.push({ 9598 event: event, 9599 listeners: listeners 9600 }); 9601 } 9602} 9603/** 9604 * For IE shims 9605 */ 9606 9607 9608var activeElement = null; 9609var activeElementInst = null; 9610/** 9611 * SECTION: handle `change` event 9612 */ 9613 9614function shouldUseChangeEvent(elem) { 9615 var nodeName = elem.nodeName && elem.nodeName.toLowerCase(); 9616 return nodeName === 'select' || nodeName === 'input' && elem.type === 'file'; 9617} 9618 9619function manualDispatchChangeEvent(nativeEvent) { 9620 var dispatchQueue = []; 9621 createAndAccumulateChangeEvent(dispatchQueue, activeElementInst, nativeEvent, getEventTarget(nativeEvent)); // If change and propertychange bubbled, we'd just bind to it like all the 9622 // other events and have it go through ReactBrowserEventEmitter. Since it 9623 // doesn't, we manually listen for the events and so we have to enqueue and 9624 // process the abstract event manually. 9625 // 9626 // Batching is necessary here in order to ensure that all event handlers run 9627 // before the next rerender (including event handlers attached to ancestor 9628 // elements instead of directly on the input). Without this, controlled 9629 // components don't work properly in conjunction with event bubbling because 9630 // the component is rerendered and the value reverted before all the event 9631 // handlers can run. See https://github.com/facebook/react/issues/708. 9632 9633 batchedUpdates(runEventInBatch, dispatchQueue); 9634} 9635 9636function runEventInBatch(dispatchQueue) { 9637 processDispatchQueue(dispatchQueue, 0); 9638} 9639 9640function getInstIfValueChanged(targetInst) { 9641 var targetNode = getNodeFromInstance(targetInst); 9642 9643 if (updateValueIfChanged(targetNode)) { 9644 return targetInst; 9645 } 9646} 9647 9648function getTargetInstForChangeEvent(domEventName, targetInst) { 9649 if (domEventName === 'change') { 9650 return targetInst; 9651 } 9652} 9653/** 9654 * SECTION: handle `input` event 9655 */ 9656 9657 9658var isInputEventSupported = false; 9659 9660if (canUseDOM) { 9661 // IE9 claims to support the input event but fails to trigger it when 9662 // deleting text, so we ignore its input events. 9663 isInputEventSupported = isEventSupported('input') && (!document.documentMode || document.documentMode > 9); 9664} 9665/** 9666 * (For IE <=9) Starts tracking propertychange events on the passed-in element 9667 * and override the value property so that we can distinguish user events from 9668 * value changes in JS. 9669 */ 9670 9671 9672function startWatchingForValueChange(target, targetInst) { 9673 activeElement = target; 9674 activeElementInst = targetInst; 9675 activeElement.attachEvent('onpropertychange', handlePropertyChange); 9676} 9677/** 9678 * (For IE <=9) Removes the event listeners from the currently-tracked element, 9679 * if any exists. 9680 */ 9681 9682 9683function stopWatchingForValueChange() { 9684 if (!activeElement) { 9685 return; 9686 } 9687 9688 activeElement.detachEvent('onpropertychange', handlePropertyChange); 9689 activeElement = null; 9690 activeElementInst = null; 9691} 9692/** 9693 * (For IE <=9) Handles a propertychange event, sending a `change` event if 9694 * the value of the active element has changed. 9695 */ 9696 9697 9698function handlePropertyChange(nativeEvent) { 9699 if (nativeEvent.propertyName !== 'value') { 9700 return; 9701 } 9702 9703 if (getInstIfValueChanged(activeElementInst)) { 9704 manualDispatchChangeEvent(nativeEvent); 9705 } 9706} 9707 9708function handleEventsForInputEventPolyfill(domEventName, target, targetInst) { 9709 if (domEventName === 'focusin') { 9710 // In IE9, propertychange fires for most input events but is buggy and 9711 // doesn't fire when text is deleted, but conveniently, selectionchange 9712 // appears to fire in all of the remaining cases so we catch those and 9713 // forward the event if the value has changed 9714 // In either case, we don't want to call the event handler if the value 9715 // is changed from JS so we redefine a setter for `.value` that updates 9716 // our activeElementValue variable, allowing us to ignore those changes 9717 // 9718 // stopWatching() should be a noop here but we call it just in case we 9719 // missed a blur event somehow. 9720 stopWatchingForValueChange(); 9721 startWatchingForValueChange(target, targetInst); 9722 } else if (domEventName === 'focusout') { 9723 stopWatchingForValueChange(); 9724 } 9725} // For IE8 and IE9. 9726 9727 9728function getTargetInstForInputEventPolyfill(domEventName, targetInst) { 9729 if (domEventName === 'selectionchange' || domEventName === 'keyup' || domEventName === 'keydown') { 9730 // On the selectionchange event, the target is just document which isn't 9731 // helpful for us so just check activeElement instead. 9732 // 9733 // 99% of the time, keydown and keyup aren't necessary. IE8 fails to fire 9734 // propertychange on the first input event after setting `value` from a 9735 // script and fires only keydown, keypress, keyup. Catching keyup usually 9736 // gets it and catching keydown lets us fire an event for the first 9737 // keystroke if user does a key repeat (it'll be a little delayed: right 9738 // before the second keystroke). Other input methods (e.g., paste) seem to 9739 // fire selectionchange normally. 9740 return getInstIfValueChanged(activeElementInst); 9741 } 9742} 9743/** 9744 * SECTION: handle `click` event 9745 */ 9746 9747 9748function shouldUseClickEvent(elem) { 9749 // Use the `click` event to detect changes to checkbox and radio inputs. 9750 // This approach works across all browsers, whereas `change` does not fire 9751 // until `blur` in IE8. 9752 var nodeName = elem.nodeName; 9753 return nodeName && nodeName.toLowerCase() === 'input' && (elem.type === 'checkbox' || elem.type === 'radio'); 9754} 9755 9756function getTargetInstForClickEvent(domEventName, targetInst) { 9757 if (domEventName === 'click') { 9758 return getInstIfValueChanged(targetInst); 9759 } 9760} 9761 9762function getTargetInstForInputOrChangeEvent(domEventName, targetInst) { 9763 if (domEventName === 'input' || domEventName === 'change') { 9764 return getInstIfValueChanged(targetInst); 9765 } 9766} 9767 9768function handleControlledInputBlur(node) { 9769 var state = node._wrapperState; 9770 9771 if (!state || !state.controlled || node.type !== 'number') { 9772 return; 9773 } 9774 9775 { 9776 // If controlled, assign the value attribute to the current value on blur 9777 setDefaultValue(node, 'number', node.value); 9778 } 9779} 9780/** 9781 * This plugin creates an `onChange` event that normalizes change events 9782 * across form elements. This event fires at a time when it's possible to 9783 * change the element's value without seeing a flicker. 9784 * 9785 * Supported elements are: 9786 * - input (see `isTextInputElement`) 9787 * - textarea 9788 * - select 9789 */ 9790 9791 9792function extractEvents$1(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags, targetContainer) { 9793 var targetNode = targetInst ? getNodeFromInstance(targetInst) : window; 9794 var getTargetInstFunc, handleEventFunc; 9795 9796 if (shouldUseChangeEvent(targetNode)) { 9797 getTargetInstFunc = getTargetInstForChangeEvent; 9798 } else if (isTextInputElement(targetNode)) { 9799 if (isInputEventSupported) { 9800 getTargetInstFunc = getTargetInstForInputOrChangeEvent; 9801 } else { 9802 getTargetInstFunc = getTargetInstForInputEventPolyfill; 9803 handleEventFunc = handleEventsForInputEventPolyfill; 9804 } 9805 } else if (shouldUseClickEvent(targetNode)) { 9806 getTargetInstFunc = getTargetInstForClickEvent; 9807 } 9808 9809 if (getTargetInstFunc) { 9810 var inst = getTargetInstFunc(domEventName, targetInst); 9811 9812 if (inst) { 9813 createAndAccumulateChangeEvent(dispatchQueue, inst, nativeEvent, nativeEventTarget); 9814 return; 9815 } 9816 } 9817 9818 if (handleEventFunc) { 9819 handleEventFunc(domEventName, targetNode, targetInst); 9820 } // When blurring, set the value attribute for number inputs 9821 9822 9823 if (domEventName === 'focusout') { 9824 handleControlledInputBlur(targetNode); 9825 } 9826} 9827 9828function registerEvents$2() { 9829 registerDirectEvent('onMouseEnter', ['mouseout', 'mouseover']); 9830 registerDirectEvent('onMouseLeave', ['mouseout', 'mouseover']); 9831 registerDirectEvent('onPointerEnter', ['pointerout', 'pointerover']); 9832 registerDirectEvent('onPointerLeave', ['pointerout', 'pointerover']); 9833} 9834/** 9835 * For almost every interaction we care about, there will be both a top-level 9836 * `mouseover` and `mouseout` event that occurs. Only use `mouseout` so that 9837 * we do not extract duplicate events. However, moving the mouse into the 9838 * browser from outside will not fire a `mouseout` event. In this case, we use 9839 * the `mouseover` top-level event. 9840 */ 9841 9842 9843function extractEvents$2(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags, targetContainer) { 9844 var isOverEvent = domEventName === 'mouseover' || domEventName === 'pointerover'; 9845 var isOutEvent = domEventName === 'mouseout' || domEventName === 'pointerout'; 9846 9847 if (isOverEvent && (eventSystemFlags & IS_REPLAYED) === 0) { 9848 // If this is an over event with a target, we might have already dispatched 9849 // the event in the out event of the other target. If this is replayed, 9850 // then it's because we couldn't dispatch against this target previously 9851 // so we have to do it now instead. 9852 var related = nativeEvent.relatedTarget || nativeEvent.fromElement; 9853 9854 if (related) { 9855 // If the related node is managed by React, we can assume that we have 9856 // already dispatched the corresponding events during its mouseout. 9857 if (getClosestInstanceFromNode(related) || isContainerMarkedAsRoot(related)) { 9858 return; 9859 } 9860 } 9861 } 9862 9863 if (!isOutEvent && !isOverEvent) { 9864 // Must not be a mouse or pointer in or out - ignoring. 9865 return; 9866 } 9867 9868 var win; // TODO: why is this nullable in the types but we read from it? 9869 9870 if (nativeEventTarget.window === nativeEventTarget) { 9871 // `nativeEventTarget` is probably a window object. 9872 win = nativeEventTarget; 9873 } else { 9874 // TODO: Figure out why `ownerDocument` is sometimes undefined in IE8. 9875 var doc = nativeEventTarget.ownerDocument; 9876 9877 if (doc) { 9878 win = doc.defaultView || doc.parentWindow; 9879 } else { 9880 win = window; 9881 } 9882 } 9883 9884 var from; 9885 var to; 9886 9887 if (isOutEvent) { 9888 var _related = nativeEvent.relatedTarget || nativeEvent.toElement; 9889 9890 from = targetInst; 9891 to = _related ? getClosestInstanceFromNode(_related) : null; 9892 9893 if (to !== null) { 9894 var nearestMounted = getNearestMountedFiber(to); 9895 9896 if (to !== nearestMounted || to.tag !== HostComponent && to.tag !== HostText) { 9897 to = null; 9898 } 9899 } 9900 } else { 9901 // Moving to a node from outside the window. 9902 from = null; 9903 to = targetInst; 9904 } 9905 9906 if (from === to) { 9907 // Nothing pertains to our managed components. 9908 return; 9909 } 9910 9911 var SyntheticEventCtor = SyntheticMouseEvent; 9912 var leaveEventType = 'onMouseLeave'; 9913 var enterEventType = 'onMouseEnter'; 9914 var eventTypePrefix = 'mouse'; 9915 9916 if (domEventName === 'pointerout' || domEventName === 'pointerover') { 9917 SyntheticEventCtor = SyntheticPointerEvent; 9918 leaveEventType = 'onPointerLeave'; 9919 enterEventType = 'onPointerEnter'; 9920 eventTypePrefix = 'pointer'; 9921 } 9922 9923 var fromNode = from == null ? win : getNodeFromInstance(from); 9924 var toNode = to == null ? win : getNodeFromInstance(to); 9925 var leave = new SyntheticEventCtor(leaveEventType, eventTypePrefix + 'leave', from, nativeEvent, nativeEventTarget); 9926 leave.target = fromNode; 9927 leave.relatedTarget = toNode; 9928 var enter = null; // We should only process this nativeEvent if we are processing 9929 // the first ancestor. Next time, we will ignore the event. 9930 9931 var nativeTargetInst = getClosestInstanceFromNode(nativeEventTarget); 9932 9933 if (nativeTargetInst === targetInst) { 9934 var enterEvent = new SyntheticEventCtor(enterEventType, eventTypePrefix + 'enter', to, nativeEvent, nativeEventTarget); 9935 enterEvent.target = toNode; 9936 enterEvent.relatedTarget = fromNode; 9937 enter = enterEvent; 9938 } 9939 9940 accumulateEnterLeaveTwoPhaseListeners(dispatchQueue, leave, enter, from, to); 9941} 9942 9943/** 9944 * inlined Object.is polyfill to avoid requiring consumers ship their own 9945 * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is 9946 */ 9947function is(x, y) { 9948 return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y // eslint-disable-line no-self-compare 9949 ; 9950} 9951 9952var objectIs = typeof Object.is === 'function' ? Object.is : is; 9953 9954var hasOwnProperty$2 = Object.prototype.hasOwnProperty; 9955/** 9956 * Performs equality by iterating through keys on an object and returning false 9957 * when any key has values which are not strictly equal between the arguments. 9958 * Returns true when the values of all keys are strictly equal. 9959 */ 9960 9961function shallowEqual(objA, objB) { 9962 if (objectIs(objA, objB)) { 9963 return true; 9964 } 9965 9966 if (typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null) { 9967 return false; 9968 } 9969 9970 var keysA = Object.keys(objA); 9971 var keysB = Object.keys(objB); 9972 9973 if (keysA.length !== keysB.length) { 9974 return false; 9975 } // Test for A's keys different from B. 9976 9977 9978 for (var i = 0; i < keysA.length; i++) { 9979 if (!hasOwnProperty$2.call(objB, keysA[i]) || !objectIs(objA[keysA[i]], objB[keysA[i]])) { 9980 return false; 9981 } 9982 } 9983 9984 return true; 9985} 9986 9987/** 9988 * Given any node return the first leaf node without children. 9989 * 9990 * @param {DOMElement|DOMTextNode} node 9991 * @return {DOMElement|DOMTextNode} 9992 */ 9993 9994function getLeafNode(node) { 9995 while (node && node.firstChild) { 9996 node = node.firstChild; 9997 } 9998 9999 return node; 10000} 10001/** 10002 * Get the next sibling within a container. This will walk up the 10003 * DOM if a node's siblings have been exhausted. 10004 * 10005 * @param {DOMElement|DOMTextNode} node 10006 * @return {?DOMElement|DOMTextNode} 10007 */ 10008 10009 10010function getSiblingNode(node) { 10011 while (node) { 10012 if (node.nextSibling) { 10013 return node.nextSibling; 10014 } 10015 10016 node = node.parentNode; 10017 } 10018} 10019/** 10020 * Get object describing the nodes which contain characters at offset. 10021 * 10022 * @param {DOMElement|DOMTextNode} root 10023 * @param {number} offset 10024 * @return {?object} 10025 */ 10026 10027 10028function getNodeForCharacterOffset(root, offset) { 10029 var node = getLeafNode(root); 10030 var nodeStart = 0; 10031 var nodeEnd = 0; 10032 10033 while (node) { 10034 if (node.nodeType === TEXT_NODE) { 10035 nodeEnd = nodeStart + node.textContent.length; 10036 10037 if (nodeStart <= offset && nodeEnd >= offset) { 10038 return { 10039 node: node, 10040 offset: offset - nodeStart 10041 }; 10042 } 10043 10044 nodeStart = nodeEnd; 10045 } 10046 10047 node = getLeafNode(getSiblingNode(node)); 10048 } 10049} 10050 10051/** 10052 * @param {DOMElement} outerNode 10053 * @return {?object} 10054 */ 10055 10056function getOffsets(outerNode) { 10057 var ownerDocument = outerNode.ownerDocument; 10058 var win = ownerDocument && ownerDocument.defaultView || window; 10059 var selection = win.getSelection && win.getSelection(); 10060 10061 if (!selection || selection.rangeCount === 0) { 10062 return null; 10063 } 10064 10065 var anchorNode = selection.anchorNode, 10066 anchorOffset = selection.anchorOffset, 10067 focusNode = selection.focusNode, 10068 focusOffset = selection.focusOffset; // In Firefox, anchorNode and focusNode can be "anonymous divs", e.g. the 10069 // up/down buttons on an <input type="number">. Anonymous divs do not seem to 10070 // expose properties, triggering a "Permission denied error" if any of its 10071 // properties are accessed. The only seemingly possible way to avoid erroring 10072 // is to access a property that typically works for non-anonymous divs and 10073 // catch any error that may otherwise arise. See 10074 // https://bugzilla.mozilla.org/show_bug.cgi?id=208427 10075 10076 try { 10077 /* eslint-disable no-unused-expressions */ 10078 anchorNode.nodeType; 10079 focusNode.nodeType; 10080 /* eslint-enable no-unused-expressions */ 10081 } catch (e) { 10082 return null; 10083 } 10084 10085 return getModernOffsetsFromPoints(outerNode, anchorNode, anchorOffset, focusNode, focusOffset); 10086} 10087/** 10088 * Returns {start, end} where `start` is the character/codepoint index of 10089 * (anchorNode, anchorOffset) within the textContent of `outerNode`, and 10090 * `end` is the index of (focusNode, focusOffset). 10091 * 10092 * Returns null if you pass in garbage input but we should probably just crash. 10093 * 10094 * Exported only for testing. 10095 */ 10096 10097function getModernOffsetsFromPoints(outerNode, anchorNode, anchorOffset, focusNode, focusOffset) { 10098 var length = 0; 10099 var start = -1; 10100 var end = -1; 10101 var indexWithinAnchor = 0; 10102 var indexWithinFocus = 0; 10103 var node = outerNode; 10104 var parentNode = null; 10105 10106 outer: while (true) { 10107 var next = null; 10108 10109 while (true) { 10110 if (node === anchorNode && (anchorOffset === 0 || node.nodeType === TEXT_NODE)) { 10111 start = length + anchorOffset; 10112 } 10113 10114 if (node === focusNode && (focusOffset === 0 || node.nodeType === TEXT_NODE)) { 10115 end = length + focusOffset; 10116 } 10117 10118 if (node.nodeType === TEXT_NODE) { 10119 length += node.nodeValue.length; 10120 } 10121 10122 if ((next = node.firstChild) === null) { 10123 break; 10124 } // Moving from `node` to its first child `next`. 10125 10126 10127 parentNode = node; 10128 node = next; 10129 } 10130 10131 while (true) { 10132 if (node === outerNode) { 10133 // If `outerNode` has children, this is always the second time visiting 10134 // it. If it has no children, this is still the first loop, and the only 10135 // valid selection is anchorNode and focusNode both equal to this node 10136 // and both offsets 0, in which case we will have handled above. 10137 break outer; 10138 } 10139 10140 if (parentNode === anchorNode && ++indexWithinAnchor === anchorOffset) { 10141 start = length; 10142 } 10143 10144 if (parentNode === focusNode && ++indexWithinFocus === focusOffset) { 10145 end = length; 10146 } 10147 10148 if ((next = node.nextSibling) !== null) { 10149 break; 10150 } 10151 10152 node = parentNode; 10153 parentNode = node.parentNode; 10154 } // Moving from `node` to its next sibling `next`. 10155 10156 10157 node = next; 10158 } 10159 10160 if (start === -1 || end === -1) { 10161 // This should never happen. (Would happen if the anchor/focus nodes aren't 10162 // actually inside the passed-in node.) 10163 return null; 10164 } 10165 10166 return { 10167 start: start, 10168 end: end 10169 }; 10170} 10171/** 10172 * In modern non-IE browsers, we can support both forward and backward 10173 * selections. 10174 * 10175 * Note: IE10+ supports the Selection object, but it does not support 10176 * the `extend` method, which means that even in modern IE, it's not possible 10177 * to programmatically create a backward selection. Thus, for all IE 10178 * versions, we use the old IE API to create our selections. 10179 * 10180 * @param {DOMElement|DOMTextNode} node 10181 * @param {object} offsets 10182 */ 10183 10184function setOffsets(node, offsets) { 10185 var doc = node.ownerDocument || document; 10186 var win = doc && doc.defaultView || window; // Edge fails with "Object expected" in some scenarios. 10187 // (For instance: TinyMCE editor used in a list component that supports pasting to add more, 10188 // fails when pasting 100+ items) 10189 10190 if (!win.getSelection) { 10191 return; 10192 } 10193 10194 var selection = win.getSelection(); 10195 var length = node.textContent.length; 10196 var start = Math.min(offsets.start, length); 10197 var end = offsets.end === undefined ? start : Math.min(offsets.end, length); // IE 11 uses modern selection, but doesn't support the extend method. 10198 // Flip backward selections, so we can set with a single range. 10199 10200 if (!selection.extend && start > end) { 10201 var temp = end; 10202 end = start; 10203 start = temp; 10204 } 10205 10206 var startMarker = getNodeForCharacterOffset(node, start); 10207 var endMarker = getNodeForCharacterOffset(node, end); 10208 10209 if (startMarker && endMarker) { 10210 if (selection.rangeCount === 1 && selection.anchorNode === startMarker.node && selection.anchorOffset === startMarker.offset && selection.focusNode === endMarker.node && selection.focusOffset === endMarker.offset) { 10211 return; 10212 } 10213 10214 var range = doc.createRange(); 10215 range.setStart(startMarker.node, startMarker.offset); 10216 selection.removeAllRanges(); 10217 10218 if (start > end) { 10219 selection.addRange(range); 10220 selection.extend(endMarker.node, endMarker.offset); 10221 } else { 10222 range.setEnd(endMarker.node, endMarker.offset); 10223 selection.addRange(range); 10224 } 10225 } 10226} 10227 10228function isTextNode(node) { 10229 return node && node.nodeType === TEXT_NODE; 10230} 10231 10232function containsNode(outerNode, innerNode) { 10233 if (!outerNode || !innerNode) { 10234 return false; 10235 } else if (outerNode === innerNode) { 10236 return true; 10237 } else if (isTextNode(outerNode)) { 10238 return false; 10239 } else if (isTextNode(innerNode)) { 10240 return containsNode(outerNode, innerNode.parentNode); 10241 } else if ('contains' in outerNode) { 10242 return outerNode.contains(innerNode); 10243 } else if (outerNode.compareDocumentPosition) { 10244 return !!(outerNode.compareDocumentPosition(innerNode) & 16); 10245 } else { 10246 return false; 10247 } 10248} 10249 10250function isInDocument(node) { 10251 return node && node.ownerDocument && containsNode(node.ownerDocument.documentElement, node); 10252} 10253 10254function isSameOriginFrame(iframe) { 10255 try { 10256 // Accessing the contentDocument of a HTMLIframeElement can cause the browser 10257 // to throw, e.g. if it has a cross-origin src attribute. 10258 // Safari will show an error in the console when the access results in "Blocked a frame with origin". e.g: 10259 // iframe.contentDocument.defaultView; 10260 // A safety way is to access one of the cross origin properties: Window or Location 10261 // Which might result in "SecurityError" DOM Exception and it is compatible to Safari. 10262 // https://html.spec.whatwg.org/multipage/browsers.html#integration-with-idl 10263 return typeof iframe.contentWindow.location.href === 'string'; 10264 } catch (err) { 10265 return false; 10266 } 10267} 10268 10269function getActiveElementDeep() { 10270 var win = window; 10271 var element = getActiveElement(); 10272 10273 while (element instanceof win.HTMLIFrameElement) { 10274 if (isSameOriginFrame(element)) { 10275 win = element.contentWindow; 10276 } else { 10277 return element; 10278 } 10279 10280 element = getActiveElement(win.document); 10281 } 10282 10283 return element; 10284} 10285/** 10286 * @ReactInputSelection: React input selection module. Based on Selection.js, 10287 * but modified to be suitable for react and has a couple of bug fixes (doesn't 10288 * assume buttons have range selections allowed). 10289 * Input selection module for React. 10290 */ 10291 10292/** 10293 * @hasSelectionCapabilities: we get the element types that support selection 10294 * from https://html.spec.whatwg.org/#do-not-apply, looking at `selectionStart` 10295 * and `selectionEnd` rows. 10296 */ 10297 10298 10299function hasSelectionCapabilities(elem) { 10300 var nodeName = elem && elem.nodeName && elem.nodeName.toLowerCase(); 10301 return nodeName && (nodeName === 'input' && (elem.type === 'text' || elem.type === 'search' || elem.type === 'tel' || elem.type === 'url' || elem.type === 'password') || nodeName === 'textarea' || elem.contentEditable === 'true'); 10302} 10303function getSelectionInformation() { 10304 var focusedElem = getActiveElementDeep(); 10305 return { 10306 focusedElem: focusedElem, 10307 selectionRange: hasSelectionCapabilities(focusedElem) ? getSelection(focusedElem) : null 10308 }; 10309} 10310/** 10311 * @restoreSelection: If any selection information was potentially lost, 10312 * restore it. This is useful when performing operations that could remove dom 10313 * nodes and place them back in, resulting in focus being lost. 10314 */ 10315 10316function restoreSelection(priorSelectionInformation) { 10317 var curFocusedElem = getActiveElementDeep(); 10318 var priorFocusedElem = priorSelectionInformation.focusedElem; 10319 var priorSelectionRange = priorSelectionInformation.selectionRange; 10320 10321 if (curFocusedElem !== priorFocusedElem && isInDocument(priorFocusedElem)) { 10322 if (priorSelectionRange !== null && hasSelectionCapabilities(priorFocusedElem)) { 10323 setSelection(priorFocusedElem, priorSelectionRange); 10324 } // Focusing a node can change the scroll position, which is undesirable 10325 10326 10327 var ancestors = []; 10328 var ancestor = priorFocusedElem; 10329 10330 while (ancestor = ancestor.parentNode) { 10331 if (ancestor.nodeType === ELEMENT_NODE) { 10332 ancestors.push({ 10333 element: ancestor, 10334 left: ancestor.scrollLeft, 10335 top: ancestor.scrollTop 10336 }); 10337 } 10338 } 10339 10340 if (typeof priorFocusedElem.focus === 'function') { 10341 priorFocusedElem.focus(); 10342 } 10343 10344 for (var i = 0; i < ancestors.length; i++) { 10345 var info = ancestors[i]; 10346 info.element.scrollLeft = info.left; 10347 info.element.scrollTop = info.top; 10348 } 10349 } 10350} 10351/** 10352 * @getSelection: Gets the selection bounds of a focused textarea, input or 10353 * contentEditable node. 10354 * -@input: Look up selection bounds of this input 10355 * -@return {start: selectionStart, end: selectionEnd} 10356 */ 10357 10358function getSelection(input) { 10359 var selection; 10360 10361 if ('selectionStart' in input) { 10362 // Modern browser with input or textarea. 10363 selection = { 10364 start: input.selectionStart, 10365 end: input.selectionEnd 10366 }; 10367 } else { 10368 // Content editable or old IE textarea. 10369 selection = getOffsets(input); 10370 } 10371 10372 return selection || { 10373 start: 0, 10374 end: 0 10375 }; 10376} 10377/** 10378 * @setSelection: Sets the selection bounds of a textarea or input and focuses 10379 * the input. 10380 * -@input Set selection bounds of this input or textarea 10381 * -@offsets Object of same form that is returned from get* 10382 */ 10383 10384function setSelection(input, offsets) { 10385 var start = offsets.start; 10386 var end = offsets.end; 10387 10388 if (end === undefined) { 10389 end = start; 10390 } 10391 10392 if ('selectionStart' in input) { 10393 input.selectionStart = start; 10394 input.selectionEnd = Math.min(end, input.value.length); 10395 } else { 10396 setOffsets(input, offsets); 10397 } 10398} 10399 10400var skipSelectionChangeEvent = canUseDOM && 'documentMode' in document && document.documentMode <= 11; 10401 10402function registerEvents$3() { 10403 registerTwoPhaseEvent('onSelect', ['focusout', 'contextmenu', 'dragend', 'focusin', 'keydown', 'keyup', 'mousedown', 'mouseup', 'selectionchange']); 10404} 10405 10406var activeElement$1 = null; 10407var activeElementInst$1 = null; 10408var lastSelection = null; 10409var mouseDown = false; 10410/** 10411 * Get an object which is a unique representation of the current selection. 10412 * 10413 * The return value will not be consistent across nodes or browsers, but 10414 * two identical selections on the same node will return identical objects. 10415 */ 10416 10417function getSelection$1(node) { 10418 if ('selectionStart' in node && hasSelectionCapabilities(node)) { 10419 return { 10420 start: node.selectionStart, 10421 end: node.selectionEnd 10422 }; 10423 } else { 10424 var win = node.ownerDocument && node.ownerDocument.defaultView || window; 10425 var selection = win.getSelection(); 10426 return { 10427 anchorNode: selection.anchorNode, 10428 anchorOffset: selection.anchorOffset, 10429 focusNode: selection.focusNode, 10430 focusOffset: selection.focusOffset 10431 }; 10432 } 10433} 10434/** 10435 * Get document associated with the event target. 10436 */ 10437 10438 10439function getEventTargetDocument(eventTarget) { 10440 return eventTarget.window === eventTarget ? eventTarget.document : eventTarget.nodeType === DOCUMENT_NODE ? eventTarget : eventTarget.ownerDocument; 10441} 10442/** 10443 * Poll selection to see whether it's changed. 10444 * 10445 * @param {object} nativeEvent 10446 * @param {object} nativeEventTarget 10447 * @return {?SyntheticEvent} 10448 */ 10449 10450 10451function constructSelectEvent(dispatchQueue, nativeEvent, nativeEventTarget) { 10452 // Ensure we have the right element, and that the user is not dragging a 10453 // selection (this matches native `select` event behavior). In HTML5, select 10454 // fires only on input and textarea thus if there's no focused element we 10455 // won't dispatch. 10456 var doc = getEventTargetDocument(nativeEventTarget); 10457 10458 if (mouseDown || activeElement$1 == null || activeElement$1 !== getActiveElement(doc)) { 10459 return; 10460 } // Only fire when selection has actually changed. 10461 10462 10463 var currentSelection = getSelection$1(activeElement$1); 10464 10465 if (!lastSelection || !shallowEqual(lastSelection, currentSelection)) { 10466 lastSelection = currentSelection; 10467 var listeners = accumulateTwoPhaseListeners(activeElementInst$1, 'onSelect'); 10468 10469 if (listeners.length > 0) { 10470 var event = new SyntheticEvent('onSelect', 'select', null, nativeEvent, nativeEventTarget); 10471 dispatchQueue.push({ 10472 event: event, 10473 listeners: listeners 10474 }); 10475 event.target = activeElement$1; 10476 } 10477 } 10478} 10479/** 10480 * This plugin creates an `onSelect` event that normalizes select events 10481 * across form elements. 10482 * 10483 * Supported elements are: 10484 * - input (see `isTextInputElement`) 10485 * - textarea 10486 * - contentEditable 10487 * 10488 * This differs from native browser implementations in the following ways: 10489 * - Fires on contentEditable fields as well as inputs. 10490 * - Fires for collapsed selection. 10491 * - Fires after user input. 10492 */ 10493 10494 10495function extractEvents$3(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags, targetContainer) { 10496 10497 var targetNode = targetInst ? getNodeFromInstance(targetInst) : window; 10498 10499 switch (domEventName) { 10500 // Track the input node that has focus. 10501 case 'focusin': 10502 if (isTextInputElement(targetNode) || targetNode.contentEditable === 'true') { 10503 activeElement$1 = targetNode; 10504 activeElementInst$1 = targetInst; 10505 lastSelection = null; 10506 } 10507 10508 break; 10509 10510 case 'focusout': 10511 activeElement$1 = null; 10512 activeElementInst$1 = null; 10513 lastSelection = null; 10514 break; 10515 // Don't fire the event while the user is dragging. This matches the 10516 // semantics of the native select event. 10517 10518 case 'mousedown': 10519 mouseDown = true; 10520 break; 10521 10522 case 'contextmenu': 10523 case 'mouseup': 10524 case 'dragend': 10525 mouseDown = false; 10526 constructSelectEvent(dispatchQueue, nativeEvent, nativeEventTarget); 10527 break; 10528 // Chrome and IE fire non-standard event when selection is changed (and 10529 // sometimes when it hasn't). IE's event fires out of order with respect 10530 // to key and input events on deletion, so we discard it. 10531 // 10532 // Firefox doesn't support selectionchange, so check selection status 10533 // after each key entry. The selection changes after keydown and before 10534 // keyup, but we check on keydown as well in the case of holding down a 10535 // key, when multiple keydown events are fired but only one keyup is. 10536 // This is also our approach for IE handling, for the reason above. 10537 10538 case 'selectionchange': 10539 if (skipSelectionChangeEvent) { 10540 break; 10541 } 10542 10543 // falls through 10544 10545 case 'keydown': 10546 case 'keyup': 10547 constructSelectEvent(dispatchQueue, nativeEvent, nativeEventTarget); 10548 } 10549} 10550 10551function extractEvents$4(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags, targetContainer) { 10552 var reactName = topLevelEventsToReactNames.get(domEventName); 10553 10554 if (reactName === undefined) { 10555 return; 10556 } 10557 10558 var SyntheticEventCtor = SyntheticEvent; 10559 var reactEventType = domEventName; 10560 10561 switch (domEventName) { 10562 case 'keypress': 10563 // Firefox creates a keypress event for function keys too. This removes 10564 // the unwanted keypress events. Enter is however both printable and 10565 // non-printable. One would expect Tab to be as well (but it isn't). 10566 if (getEventCharCode(nativeEvent) === 0) { 10567 return; 10568 } 10569 10570 /* falls through */ 10571 10572 case 'keydown': 10573 case 'keyup': 10574 SyntheticEventCtor = SyntheticKeyboardEvent; 10575 break; 10576 10577 case 'focusin': 10578 reactEventType = 'focus'; 10579 SyntheticEventCtor = SyntheticFocusEvent; 10580 break; 10581 10582 case 'focusout': 10583 reactEventType = 'blur'; 10584 SyntheticEventCtor = SyntheticFocusEvent; 10585 break; 10586 10587 case 'beforeblur': 10588 case 'afterblur': 10589 SyntheticEventCtor = SyntheticFocusEvent; 10590 break; 10591 10592 case 'click': 10593 // Firefox creates a click event on right mouse clicks. This removes the 10594 // unwanted click events. 10595 if (nativeEvent.button === 2) { 10596 return; 10597 } 10598 10599 /* falls through */ 10600 10601 case 'auxclick': 10602 case 'dblclick': 10603 case 'mousedown': 10604 case 'mousemove': 10605 case 'mouseup': // TODO: Disabled elements should not respond to mouse events 10606 10607 /* falls through */ 10608 10609 case 'mouseout': 10610 case 'mouseover': 10611 case 'contextmenu': 10612 SyntheticEventCtor = SyntheticMouseEvent; 10613 break; 10614 10615 case 'drag': 10616 case 'dragend': 10617 case 'dragenter': 10618 case 'dragexit': 10619 case 'dragleave': 10620 case 'dragover': 10621 case 'dragstart': 10622 case 'drop': 10623 SyntheticEventCtor = SyntheticDragEvent; 10624 break; 10625 10626 case 'touchcancel': 10627 case 'touchend': 10628 case 'touchmove': 10629 case 'touchstart': 10630 SyntheticEventCtor = SyntheticTouchEvent; 10631 break; 10632 10633 case ANIMATION_END: 10634 case ANIMATION_ITERATION: 10635 case ANIMATION_START: 10636 SyntheticEventCtor = SyntheticAnimationEvent; 10637 break; 10638 10639 case TRANSITION_END: 10640 SyntheticEventCtor = SyntheticTransitionEvent; 10641 break; 10642 10643 case 'scroll': 10644 SyntheticEventCtor = SyntheticUIEvent; 10645 break; 10646 10647 case 'wheel': 10648 SyntheticEventCtor = SyntheticWheelEvent; 10649 break; 10650 10651 case 'copy': 10652 case 'cut': 10653 case 'paste': 10654 SyntheticEventCtor = SyntheticClipboardEvent; 10655 break; 10656 10657 case 'gotpointercapture': 10658 case 'lostpointercapture': 10659 case 'pointercancel': 10660 case 'pointerdown': 10661 case 'pointermove': 10662 case 'pointerout': 10663 case 'pointerover': 10664 case 'pointerup': 10665 SyntheticEventCtor = SyntheticPointerEvent; 10666 break; 10667 } 10668 10669 var inCapturePhase = (eventSystemFlags & IS_CAPTURE_PHASE) !== 0; 10670 10671 { 10672 // Some events don't bubble in the browser. 10673 // In the past, React has always bubbled them, but this can be surprising. 10674 // We're going to try aligning closer to the browser behavior by not bubbling 10675 // them in React either. We'll start by not bubbling onScroll, and then expand. 10676 var accumulateTargetOnly = !inCapturePhase && // TODO: ideally, we'd eventually add all events from 10677 // nonDelegatedEvents list in DOMPluginEventSystem. 10678 // Then we can remove this special list. 10679 // This is a breaking change that can wait until React 18. 10680 domEventName === 'scroll'; 10681 10682 var _listeners = accumulateSinglePhaseListeners(targetInst, reactName, nativeEvent.type, inCapturePhase, accumulateTargetOnly); 10683 10684 if (_listeners.length > 0) { 10685 // Intentionally create event lazily. 10686 var _event = new SyntheticEventCtor(reactName, reactEventType, null, nativeEvent, nativeEventTarget); 10687 10688 dispatchQueue.push({ 10689 event: _event, 10690 listeners: _listeners 10691 }); 10692 } 10693 } 10694} 10695 10696// TODO: remove top-level side effect. 10697registerSimpleEvents(); 10698registerEvents$2(); 10699registerEvents$1(); 10700registerEvents$3(); 10701registerEvents(); 10702 10703function extractEvents$5(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags, targetContainer) { 10704 // TODO: we should remove the concept of a "SimpleEventPlugin". 10705 // This is the basic functionality of the event system. All 10706 // the other plugins are essentially polyfills. So the plugin 10707 // should probably be inlined somewhere and have its logic 10708 // be core the to event system. This would potentially allow 10709 // us to ship builds of React without the polyfilled plugins below. 10710 extractEvents$4(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags); 10711 var shouldProcessPolyfillPlugins = (eventSystemFlags & SHOULD_NOT_PROCESS_POLYFILL_EVENT_PLUGINS) === 0; // We don't process these events unless we are in the 10712 // event's native "bubble" phase, which means that we're 10713 // not in the capture phase. That's because we emulate 10714 // the capture phase here still. This is a trade-off, 10715 // because in an ideal world we would not emulate and use 10716 // the phases properly, like we do with the SimpleEvent 10717 // plugin. However, the plugins below either expect 10718 // emulation (EnterLeave) or use state localized to that 10719 // plugin (BeforeInput, Change, Select). The state in 10720 // these modules complicates things, as you'll essentially 10721 // get the case where the capture phase event might change 10722 // state, only for the following bubble event to come in 10723 // later and not trigger anything as the state now 10724 // invalidates the heuristics of the event plugin. We 10725 // could alter all these plugins to work in such ways, but 10726 // that might cause other unknown side-effects that we 10727 // can't forsee right now. 10728 10729 if (shouldProcessPolyfillPlugins) { 10730 extractEvents$2(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags); 10731 extractEvents$1(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget); 10732 extractEvents$3(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget); 10733 extractEvents(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget); 10734 } 10735} // List of events that need to be individually attached to media elements. 10736 10737 10738var 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 10739// set them on the actual target element itself. This is primarily 10740// because these events do not consistently bubble in the DOM. 10741 10742var nonDelegatedEvents = new Set(['cancel', 'close', 'invalid', 'load', 'scroll', 'toggle'].concat(mediaEventTypes)); 10743 10744function executeDispatch(event, listener, currentTarget) { 10745 var type = event.type || 'unknown-event'; 10746 event.currentTarget = currentTarget; 10747 invokeGuardedCallbackAndCatchFirstError(type, listener, undefined, event); 10748 event.currentTarget = null; 10749} 10750 10751function processDispatchQueueItemsInOrder(event, dispatchListeners, inCapturePhase) { 10752 var previousInstance; 10753 10754 if (inCapturePhase) { 10755 for (var i = dispatchListeners.length - 1; i >= 0; i--) { 10756 var _dispatchListeners$i = dispatchListeners[i], 10757 instance = _dispatchListeners$i.instance, 10758 currentTarget = _dispatchListeners$i.currentTarget, 10759 listener = _dispatchListeners$i.listener; 10760 10761 if (instance !== previousInstance && event.isPropagationStopped()) { 10762 return; 10763 } 10764 10765 executeDispatch(event, listener, currentTarget); 10766 previousInstance = instance; 10767 } 10768 } else { 10769 for (var _i = 0; _i < dispatchListeners.length; _i++) { 10770 var _dispatchListeners$_i = dispatchListeners[_i], 10771 _instance = _dispatchListeners$_i.instance, 10772 _currentTarget = _dispatchListeners$_i.currentTarget, 10773 _listener = _dispatchListeners$_i.listener; 10774 10775 if (_instance !== previousInstance && event.isPropagationStopped()) { 10776 return; 10777 } 10778 10779 executeDispatch(event, _listener, _currentTarget); 10780 previousInstance = _instance; 10781 } 10782 } 10783} 10784 10785function processDispatchQueue(dispatchQueue, eventSystemFlags) { 10786 var inCapturePhase = (eventSystemFlags & IS_CAPTURE_PHASE) !== 0; 10787 10788 for (var i = 0; i < dispatchQueue.length; i++) { 10789 var _dispatchQueue$i = dispatchQueue[i], 10790 event = _dispatchQueue$i.event, 10791 listeners = _dispatchQueue$i.listeners; 10792 processDispatchQueueItemsInOrder(event, listeners, inCapturePhase); // event system doesn't use pooling. 10793 } // This would be a good time to rethrow if any of the event handlers threw. 10794 10795 10796 rethrowCaughtError(); 10797} 10798 10799function dispatchEventsForPlugins(domEventName, eventSystemFlags, nativeEvent, targetInst, targetContainer) { 10800 var nativeEventTarget = getEventTarget(nativeEvent); 10801 var dispatchQueue = []; 10802 extractEvents$5(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags); 10803 processDispatchQueue(dispatchQueue, eventSystemFlags); 10804} 10805 10806function listenToNonDelegatedEvent(domEventName, targetElement) { 10807 var isCapturePhaseListener = false; 10808 var listenerSet = getEventListenerSet(targetElement); 10809 var listenerSetKey = getListenerSetKey(domEventName, isCapturePhaseListener); 10810 10811 if (!listenerSet.has(listenerSetKey)) { 10812 addTrappedEventListener(targetElement, domEventName, IS_NON_DELEGATED, isCapturePhaseListener); 10813 listenerSet.add(listenerSetKey); 10814 } 10815} 10816var listeningMarker = '_reactListening' + Math.random().toString(36).slice(2); 10817function listenToAllSupportedEvents(rootContainerElement) { 10818 { 10819 if (rootContainerElement[listeningMarker]) { 10820 // Performance optimization: don't iterate through events 10821 // for the same portal container or root node more than once. 10822 // TODO: once we remove the flag, we may be able to also 10823 // remove some of the bookkeeping maps used for laziness. 10824 return; 10825 } 10826 10827 rootContainerElement[listeningMarker] = true; 10828 allNativeEvents.forEach(function (domEventName) { 10829 if (!nonDelegatedEvents.has(domEventName)) { 10830 listenToNativeEvent(domEventName, false, rootContainerElement, null); 10831 } 10832 10833 listenToNativeEvent(domEventName, true, rootContainerElement, null); 10834 }); 10835 } 10836} 10837function listenToNativeEvent(domEventName, isCapturePhaseListener, rootContainerElement, targetElement) { 10838 var eventSystemFlags = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0; 10839 var target = rootContainerElement; // selectionchange needs to be attached to the document 10840 // otherwise it won't capture incoming events that are only 10841 // triggered on the document directly. 10842 10843 if (domEventName === 'selectionchange' && rootContainerElement.nodeType !== DOCUMENT_NODE) { 10844 target = rootContainerElement.ownerDocument; 10845 } // If the event can be delegated (or is capture phase), we can 10846 // register it to the root container. Otherwise, we should 10847 // register the event to the target element and mark it as 10848 // a non-delegated event. 10849 10850 10851 if (targetElement !== null && !isCapturePhaseListener && nonDelegatedEvents.has(domEventName)) { 10852 // For all non-delegated events, apart from scroll, we attach 10853 // their event listeners to the respective elements that their 10854 // events fire on. That means we can skip this step, as event 10855 // listener has already been added previously. However, we 10856 // special case the scroll event because the reality is that any 10857 // element can scroll. 10858 // TODO: ideally, we'd eventually apply the same logic to all 10859 // events from the nonDelegatedEvents list. Then we can remove 10860 // this special case and use the same logic for all events. 10861 if (domEventName !== 'scroll') { 10862 return; 10863 } 10864 10865 eventSystemFlags |= IS_NON_DELEGATED; 10866 target = targetElement; 10867 } 10868 10869 var listenerSet = getEventListenerSet(target); 10870 var listenerSetKey = getListenerSetKey(domEventName, isCapturePhaseListener); // If the listener entry is empty or we should upgrade, then 10871 // we need to trap an event listener onto the target. 10872 10873 if (!listenerSet.has(listenerSetKey)) { 10874 if (isCapturePhaseListener) { 10875 eventSystemFlags |= IS_CAPTURE_PHASE; 10876 } 10877 10878 addTrappedEventListener(target, domEventName, eventSystemFlags, isCapturePhaseListener); 10879 listenerSet.add(listenerSetKey); 10880 } 10881} 10882 10883function addTrappedEventListener(targetContainer, domEventName, eventSystemFlags, isCapturePhaseListener, isDeferredListenerForLegacyFBSupport) { 10884 var listener = createEventListenerWrapperWithPriority(targetContainer, domEventName, eventSystemFlags); // If passive option is not supported, then the event will be 10885 // active and not passive. 10886 10887 var isPassiveListener = undefined; 10888 10889 if (passiveBrowserEventsSupported) { 10890 // Browsers introduced an intervention, making these events 10891 // passive by default on document. React doesn't bind them 10892 // to document anymore, but changing this now would undo 10893 // the performance wins from the change. So we emulate 10894 // the existing behavior manually on the roots now. 10895 // https://github.com/facebook/react/issues/19651 10896 if (domEventName === 'touchstart' || domEventName === 'touchmove' || domEventName === 'wheel') { 10897 isPassiveListener = true; 10898 } 10899 } 10900 10901 targetContainer = targetContainer; 10902 var unsubscribeListener; // When legacyFBSupport is enabled, it's for when we 10903 10904 10905 if (isCapturePhaseListener) { 10906 if (isPassiveListener !== undefined) { 10907 unsubscribeListener = addEventCaptureListenerWithPassiveFlag(targetContainer, domEventName, listener, isPassiveListener); 10908 } else { 10909 unsubscribeListener = addEventCaptureListener(targetContainer, domEventName, listener); 10910 } 10911 } else { 10912 if (isPassiveListener !== undefined) { 10913 unsubscribeListener = addEventBubbleListenerWithPassiveFlag(targetContainer, domEventName, listener, isPassiveListener); 10914 } else { 10915 unsubscribeListener = addEventBubbleListener(targetContainer, domEventName, listener); 10916 } 10917 } 10918} 10919 10920function isMatchingRootContainer(grandContainer, targetContainer) { 10921 return grandContainer === targetContainer || grandContainer.nodeType === COMMENT_NODE && grandContainer.parentNode === targetContainer; 10922} 10923 10924function dispatchEventForPluginEventSystem(domEventName, eventSystemFlags, nativeEvent, targetInst, targetContainer) { 10925 var ancestorInst = targetInst; 10926 10927 if ((eventSystemFlags & IS_EVENT_HANDLE_NON_MANAGED_NODE) === 0 && (eventSystemFlags & IS_NON_DELEGATED) === 0) { 10928 var targetContainerNode = targetContainer; // If we are using the legacy FB support flag, we 10929 10930 if (targetInst !== null) { 10931 // The below logic attempts to work out if we need to change 10932 // the target fiber to a different ancestor. We had similar logic 10933 // in the legacy event system, except the big difference between 10934 // systems is that the modern event system now has an event listener 10935 // attached to each React Root and React Portal Root. Together, 10936 // the DOM nodes representing these roots are the "rootContainer". 10937 // To figure out which ancestor instance we should use, we traverse 10938 // up the fiber tree from the target instance and attempt to find 10939 // root boundaries that match that of our current "rootContainer". 10940 // If we find that "rootContainer", we find the parent fiber 10941 // sub-tree for that root and make that our ancestor instance. 10942 var node = targetInst; 10943 10944 mainLoop: while (true) { 10945 if (node === null) { 10946 return; 10947 } 10948 10949 var nodeTag = node.tag; 10950 10951 if (nodeTag === HostRoot || nodeTag === HostPortal) { 10952 var container = node.stateNode.containerInfo; 10953 10954 if (isMatchingRootContainer(container, targetContainerNode)) { 10955 break; 10956 } 10957 10958 if (nodeTag === HostPortal) { 10959 // The target is a portal, but it's not the rootContainer we're looking for. 10960 // Normally portals handle their own events all the way down to the root. 10961 // So we should be able to stop now. However, we don't know if this portal 10962 // was part of *our* root. 10963 var grandNode = node.return; 10964 10965 while (grandNode !== null) { 10966 var grandTag = grandNode.tag; 10967 10968 if (grandTag === HostRoot || grandTag === HostPortal) { 10969 var grandContainer = grandNode.stateNode.containerInfo; 10970 10971 if (isMatchingRootContainer(grandContainer, targetContainerNode)) { 10972 // This is the rootContainer we're looking for and we found it as 10973 // a parent of the Portal. That means we can ignore it because the 10974 // Portal will bubble through to us. 10975 return; 10976 } 10977 } 10978 10979 grandNode = grandNode.return; 10980 } 10981 } // Now we need to find it's corresponding host fiber in the other 10982 // tree. To do this we can use getClosestInstanceFromNode, but we 10983 // need to validate that the fiber is a host instance, otherwise 10984 // we need to traverse up through the DOM till we find the correct 10985 // node that is from the other tree. 10986 10987 10988 while (container !== null) { 10989 var parentNode = getClosestInstanceFromNode(container); 10990 10991 if (parentNode === null) { 10992 return; 10993 } 10994 10995 var parentTag = parentNode.tag; 10996 10997 if (parentTag === HostComponent || parentTag === HostText) { 10998 node = ancestorInst = parentNode; 10999 continue mainLoop; 11000 } 11001 11002 container = container.parentNode; 11003 } 11004 } 11005 11006 node = node.return; 11007 } 11008 } 11009 } 11010 11011 batchedEventUpdates(function () { 11012 return dispatchEventsForPlugins(domEventName, eventSystemFlags, nativeEvent, ancestorInst); 11013 }); 11014} 11015 11016function createDispatchListener(instance, listener, currentTarget) { 11017 return { 11018 instance: instance, 11019 listener: listener, 11020 currentTarget: currentTarget 11021 }; 11022} 11023 11024function accumulateSinglePhaseListeners(targetFiber, reactName, nativeEventType, inCapturePhase, accumulateTargetOnly) { 11025 var captureName = reactName !== null ? reactName + 'Capture' : null; 11026 var reactEventName = inCapturePhase ? captureName : reactName; 11027 var listeners = []; 11028 var instance = targetFiber; 11029 var lastHostComponent = null; // Accumulate all instances and listeners via the target -> root path. 11030 11031 while (instance !== null) { 11032 var _instance2 = instance, 11033 stateNode = _instance2.stateNode, 11034 tag = _instance2.tag; // Handle listeners that are on HostComponents (i.e. <div>) 11035 11036 if (tag === HostComponent && stateNode !== null) { 11037 lastHostComponent = stateNode; // createEventHandle listeners 11038 11039 11040 if (reactEventName !== null) { 11041 var listener = getListener(instance, reactEventName); 11042 11043 if (listener != null) { 11044 listeners.push(createDispatchListener(instance, listener, lastHostComponent)); 11045 } 11046 } 11047 } // If we are only accumulating events for the target, then we don't 11048 // continue to propagate through the React fiber tree to find other 11049 // listeners. 11050 11051 11052 if (accumulateTargetOnly) { 11053 break; 11054 } 11055 11056 instance = instance.return; 11057 } 11058 11059 return listeners; 11060} // We should only use this function for: 11061// - BeforeInputEventPlugin 11062// - ChangeEventPlugin 11063// - SelectEventPlugin 11064// This is because we only process these plugins 11065// in the bubble phase, so we need to accumulate two 11066// phase event listeners (via emulation). 11067 11068function accumulateTwoPhaseListeners(targetFiber, reactName) { 11069 var captureName = reactName + 'Capture'; 11070 var listeners = []; 11071 var instance = targetFiber; // Accumulate all instances and listeners via the target -> root path. 11072 11073 while (instance !== null) { 11074 var _instance3 = instance, 11075 stateNode = _instance3.stateNode, 11076 tag = _instance3.tag; // Handle listeners that are on HostComponents (i.e. <div>) 11077 11078 if (tag === HostComponent && stateNode !== null) { 11079 var currentTarget = stateNode; 11080 var captureListener = getListener(instance, captureName); 11081 11082 if (captureListener != null) { 11083 listeners.unshift(createDispatchListener(instance, captureListener, currentTarget)); 11084 } 11085 11086 var bubbleListener = getListener(instance, reactName); 11087 11088 if (bubbleListener != null) { 11089 listeners.push(createDispatchListener(instance, bubbleListener, currentTarget)); 11090 } 11091 } 11092 11093 instance = instance.return; 11094 } 11095 11096 return listeners; 11097} 11098 11099function getParent(inst) { 11100 if (inst === null) { 11101 return null; 11102 } 11103 11104 do { 11105 inst = inst.return; // TODO: If this is a HostRoot we might want to bail out. 11106 // That is depending on if we want nested subtrees (layers) to bubble 11107 // events to their parent. We could also go through parentNode on the 11108 // host node but that wouldn't work for React Native and doesn't let us 11109 // do the portal feature. 11110 } while (inst && inst.tag !== HostComponent); 11111 11112 if (inst) { 11113 return inst; 11114 } 11115 11116 return null; 11117} 11118/** 11119 * Return the lowest common ancestor of A and B, or null if they are in 11120 * different trees. 11121 */ 11122 11123 11124function getLowestCommonAncestor(instA, instB) { 11125 var nodeA = instA; 11126 var nodeB = instB; 11127 var depthA = 0; 11128 11129 for (var tempA = nodeA; tempA; tempA = getParent(tempA)) { 11130 depthA++; 11131 } 11132 11133 var depthB = 0; 11134 11135 for (var tempB = nodeB; tempB; tempB = getParent(tempB)) { 11136 depthB++; 11137 } // If A is deeper, crawl up. 11138 11139 11140 while (depthA - depthB > 0) { 11141 nodeA = getParent(nodeA); 11142 depthA--; 11143 } // If B is deeper, crawl up. 11144 11145 11146 while (depthB - depthA > 0) { 11147 nodeB = getParent(nodeB); 11148 depthB--; 11149 } // Walk in lockstep until we find a match. 11150 11151 11152 var depth = depthA; 11153 11154 while (depth--) { 11155 if (nodeA === nodeB || nodeB !== null && nodeA === nodeB.alternate) { 11156 return nodeA; 11157 } 11158 11159 nodeA = getParent(nodeA); 11160 nodeB = getParent(nodeB); 11161 } 11162 11163 return null; 11164} 11165 11166function accumulateEnterLeaveListenersForEvent(dispatchQueue, event, target, common, inCapturePhase) { 11167 var registrationName = event._reactName; 11168 var listeners = []; 11169 var instance = target; 11170 11171 while (instance !== null) { 11172 if (instance === common) { 11173 break; 11174 } 11175 11176 var _instance4 = instance, 11177 alternate = _instance4.alternate, 11178 stateNode = _instance4.stateNode, 11179 tag = _instance4.tag; 11180 11181 if (alternate !== null && alternate === common) { 11182 break; 11183 } 11184 11185 if (tag === HostComponent && stateNode !== null) { 11186 var currentTarget = stateNode; 11187 11188 if (inCapturePhase) { 11189 var captureListener = getListener(instance, registrationName); 11190 11191 if (captureListener != null) { 11192 listeners.unshift(createDispatchListener(instance, captureListener, currentTarget)); 11193 } 11194 } else if (!inCapturePhase) { 11195 var bubbleListener = getListener(instance, registrationName); 11196 11197 if (bubbleListener != null) { 11198 listeners.push(createDispatchListener(instance, bubbleListener, currentTarget)); 11199 } 11200 } 11201 } 11202 11203 instance = instance.return; 11204 } 11205 11206 if (listeners.length !== 0) { 11207 dispatchQueue.push({ 11208 event: event, 11209 listeners: listeners 11210 }); 11211 } 11212} // We should only use this function for: 11213// - EnterLeaveEventPlugin 11214// This is because we only process this plugin 11215// in the bubble phase, so we need to accumulate two 11216// phase event listeners. 11217 11218 11219function accumulateEnterLeaveTwoPhaseListeners(dispatchQueue, leaveEvent, enterEvent, from, to) { 11220 var common = from && to ? getLowestCommonAncestor(from, to) : null; 11221 11222 if (from !== null) { 11223 accumulateEnterLeaveListenersForEvent(dispatchQueue, leaveEvent, from, common, false); 11224 } 11225 11226 if (to !== null && enterEvent !== null) { 11227 accumulateEnterLeaveListenersForEvent(dispatchQueue, enterEvent, to, common, true); 11228 } 11229} 11230function getListenerSetKey(domEventName, capture) { 11231 return domEventName + "__" + (capture ? 'capture' : 'bubble'); 11232} 11233 11234var didWarnInvalidHydration = false; 11235var DANGEROUSLY_SET_INNER_HTML = 'dangerouslySetInnerHTML'; 11236var SUPPRESS_CONTENT_EDITABLE_WARNING = 'suppressContentEditableWarning'; 11237var SUPPRESS_HYDRATION_WARNING = 'suppressHydrationWarning'; 11238var AUTOFOCUS = 'autoFocus'; 11239var CHILDREN = 'children'; 11240var STYLE = 'style'; 11241var HTML$1 = '__html'; 11242var HTML_NAMESPACE$1 = Namespaces.html; 11243var warnedUnknownTags; 11244var suppressHydrationWarning; 11245var validatePropertiesInDevelopment; 11246var warnForTextDifference; 11247var warnForPropDifference; 11248var warnForExtraAttributes; 11249var warnForInvalidEventListener; 11250var canDiffStyleForHydrationWarning; 11251var normalizeMarkupForTextOrAttribute; 11252var normalizeHTML; 11253 11254{ 11255 warnedUnknownTags = { 11256 // There are working polyfills for <dialog>. Let people use it. 11257 dialog: true, 11258 // Electron ships a custom <webview> tag to display external web content in 11259 // an isolated frame and process. 11260 // This tag is not present in non Electron environments such as JSDom which 11261 // is often used for testing purposes. 11262 // @see https://electronjs.org/docs/api/webview-tag 11263 webview: true 11264 }; 11265 11266 validatePropertiesInDevelopment = function (type, props) { 11267 validateProperties(type, props); 11268 validateProperties$1(type, props); 11269 validateProperties$2(type, props, { 11270 registrationNameDependencies: registrationNameDependencies, 11271 possibleRegistrationNames: possibleRegistrationNames 11272 }); 11273 }; // IE 11 parses & normalizes the style attribute as opposed to other 11274 // browsers. It adds spaces and sorts the properties in some 11275 // non-alphabetical order. Handling that would require sorting CSS 11276 // properties in the client & server versions or applying 11277 // `expectedStyle` to a temporary DOM node to read its `style` attribute 11278 // normalized. Since it only affects IE, we're skipping style warnings 11279 // in that browser completely in favor of doing all that work. 11280 // See https://github.com/facebook/react/issues/11807 11281 11282 11283 canDiffStyleForHydrationWarning = canUseDOM && !document.documentMode; // HTML parsing normalizes CR and CRLF to LF. 11284 // It also can turn \u0000 into \uFFFD inside attributes. 11285 // https://www.w3.org/TR/html5/single-page.html#preprocessing-the-input-stream 11286 // If we have a mismatch, it might be caused by that. 11287 // We will still patch up in this case but not fire the warning. 11288 11289 var NORMALIZE_NEWLINES_REGEX = /\r\n?/g; 11290 var NORMALIZE_NULL_AND_REPLACEMENT_REGEX = /\u0000|\uFFFD/g; 11291 11292 normalizeMarkupForTextOrAttribute = function (markup) { 11293 var markupString = typeof markup === 'string' ? markup : '' + markup; 11294 return markupString.replace(NORMALIZE_NEWLINES_REGEX, '\n').replace(NORMALIZE_NULL_AND_REPLACEMENT_REGEX, ''); 11295 }; 11296 11297 warnForTextDifference = function (serverText, clientText) { 11298 if (didWarnInvalidHydration) { 11299 return; 11300 } 11301 11302 var normalizedClientText = normalizeMarkupForTextOrAttribute(clientText); 11303 var normalizedServerText = normalizeMarkupForTextOrAttribute(serverText); 11304 11305 if (normalizedServerText === normalizedClientText) { 11306 return; 11307 } 11308 11309 didWarnInvalidHydration = true; 11310 11311 error('Text content did not match. Server: "%s" Client: "%s"', normalizedServerText, normalizedClientText); 11312 }; 11313 11314 warnForPropDifference = function (propName, serverValue, clientValue) { 11315 if (didWarnInvalidHydration) { 11316 return; 11317 } 11318 11319 var normalizedClientValue = normalizeMarkupForTextOrAttribute(clientValue); 11320 var normalizedServerValue = normalizeMarkupForTextOrAttribute(serverValue); 11321 11322 if (normalizedServerValue === normalizedClientValue) { 11323 return; 11324 } 11325 11326 didWarnInvalidHydration = true; 11327 11328 error('Prop `%s` did not match. Server: %s Client: %s', propName, JSON.stringify(normalizedServerValue), JSON.stringify(normalizedClientValue)); 11329 }; 11330 11331 warnForExtraAttributes = function (attributeNames) { 11332 if (didWarnInvalidHydration) { 11333 return; 11334 } 11335 11336 didWarnInvalidHydration = true; 11337 var names = []; 11338 attributeNames.forEach(function (name) { 11339 names.push(name); 11340 }); 11341 11342 error('Extra attributes from the server: %s', names); 11343 }; 11344 11345 warnForInvalidEventListener = function (registrationName, listener) { 11346 if (listener === false) { 11347 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); 11348 } else { 11349 error('Expected `%s` listener to be a function, instead got a value of `%s` type.', registrationName, typeof listener); 11350 } 11351 }; // Parse the HTML and read it back to normalize the HTML string so that it 11352 // can be used for comparison. 11353 11354 11355 normalizeHTML = function (parent, html) { 11356 // We could have created a separate document here to avoid 11357 // re-initializing custom elements if they exist. But this breaks 11358 // how <noscript> is being handled. So we use the same document. 11359 // See the discussion in https://github.com/facebook/react/pull/11157. 11360 var testElement = parent.namespaceURI === HTML_NAMESPACE$1 ? parent.ownerDocument.createElement(parent.tagName) : parent.ownerDocument.createElementNS(parent.namespaceURI, parent.tagName); 11361 testElement.innerHTML = html; 11362 return testElement.innerHTML; 11363 }; 11364} 11365 11366function getOwnerDocumentFromRootContainer(rootContainerElement) { 11367 return rootContainerElement.nodeType === DOCUMENT_NODE ? rootContainerElement : rootContainerElement.ownerDocument; 11368} 11369 11370function noop() {} 11371 11372function trapClickOnNonInteractiveElement(node) { 11373 // Mobile Safari does not fire properly bubble click events on 11374 // non-interactive elements, which means delegated click listeners do not 11375 // fire. The workaround for this bug involves attaching an empty click 11376 // listener on the target node. 11377 // https://www.quirksmode.org/blog/archives/2010/09/click_event_del.html 11378 // Just set it using the onclick property so that we don't have to manage any 11379 // bookkeeping for it. Not sure if we need to clear it when the listener is 11380 // removed. 11381 // TODO: Only do this for the relevant Safaris maybe? 11382 node.onclick = noop; 11383} 11384 11385function setInitialDOMProperties(tag, domElement, rootContainerElement, nextProps, isCustomComponentTag) { 11386 for (var propKey in nextProps) { 11387 if (!nextProps.hasOwnProperty(propKey)) { 11388 continue; 11389 } 11390 11391 var nextProp = nextProps[propKey]; 11392 11393 if (propKey === STYLE) { 11394 { 11395 if (nextProp) { 11396 // Freeze the next style object so that we can assume it won't be 11397 // mutated. We have already warned for this in the past. 11398 Object.freeze(nextProp); 11399 } 11400 } // Relies on `updateStylesByID` not mutating `styleUpdates`. 11401 11402 11403 setValueForStyles(domElement, nextProp); 11404 } else if (propKey === DANGEROUSLY_SET_INNER_HTML) { 11405 var nextHtml = nextProp ? nextProp[HTML$1] : undefined; 11406 11407 if (nextHtml != null) { 11408 setInnerHTML(domElement, nextHtml); 11409 } 11410 } else if (propKey === CHILDREN) { 11411 if (typeof nextProp === 'string') { 11412 // Avoid setting initial textContent when the text is empty. In IE11 setting 11413 // textContent on a <textarea> will cause the placeholder to not 11414 // show within the <textarea> until it has been focused and blurred again. 11415 // https://github.com/facebook/react/issues/6731#issuecomment-254874553 11416 var canSetTextContent = tag !== 'textarea' || nextProp !== ''; 11417 11418 if (canSetTextContent) { 11419 setTextContent(domElement, nextProp); 11420 } 11421 } else if (typeof nextProp === 'number') { 11422 setTextContent(domElement, '' + nextProp); 11423 } 11424 } else if (propKey === SUPPRESS_CONTENT_EDITABLE_WARNING || propKey === SUPPRESS_HYDRATION_WARNING) ; else if (propKey === AUTOFOCUS) ; else if (registrationNameDependencies.hasOwnProperty(propKey)) { 11425 if (nextProp != null) { 11426 if ( typeof nextProp !== 'function') { 11427 warnForInvalidEventListener(propKey, nextProp); 11428 } 11429 11430 if (propKey === 'onScroll') { 11431 listenToNonDelegatedEvent('scroll', domElement); 11432 } 11433 } 11434 } else if (nextProp != null) { 11435 setValueForProperty(domElement, propKey, nextProp, isCustomComponentTag); 11436 } 11437 } 11438} 11439 11440function updateDOMProperties(domElement, updatePayload, wasCustomComponentTag, isCustomComponentTag) { 11441 // TODO: Handle wasCustomComponentTag 11442 for (var i = 0; i < updatePayload.length; i += 2) { 11443 var propKey = updatePayload[i]; 11444 var propValue = updatePayload[i + 1]; 11445 11446 if (propKey === STYLE) { 11447 setValueForStyles(domElement, propValue); 11448 } else if (propKey === DANGEROUSLY_SET_INNER_HTML) { 11449 setInnerHTML(domElement, propValue); 11450 } else if (propKey === CHILDREN) { 11451 setTextContent(domElement, propValue); 11452 } else { 11453 setValueForProperty(domElement, propKey, propValue, isCustomComponentTag); 11454 } 11455 } 11456} 11457 11458function createElement(type, props, rootContainerElement, parentNamespace) { 11459 var isCustomComponentTag; // We create tags in the namespace of their parent container, except HTML 11460 // tags get no namespace. 11461 11462 var ownerDocument = getOwnerDocumentFromRootContainer(rootContainerElement); 11463 var domElement; 11464 var namespaceURI = parentNamespace; 11465 11466 if (namespaceURI === HTML_NAMESPACE$1) { 11467 namespaceURI = getIntrinsicNamespace(type); 11468 } 11469 11470 if (namespaceURI === HTML_NAMESPACE$1) { 11471 { 11472 isCustomComponentTag = isCustomComponent(type, props); // Should this check be gated by parent namespace? Not sure we want to 11473 // allow <SVG> or <mATH>. 11474 11475 if (!isCustomComponentTag && type !== type.toLowerCase()) { 11476 error('<%s /> is using incorrect casing. ' + 'Use PascalCase for React components, ' + 'or lowercase for HTML elements.', type); 11477 } 11478 } 11479 11480 if (type === 'script') { 11481 // Create the script via .innerHTML so its "parser-inserted" flag is 11482 // set to true and it does not execute 11483 var div = ownerDocument.createElement('div'); 11484 11485 div.innerHTML = '<script><' + '/script>'; // eslint-disable-line 11486 // This is guaranteed to yield a script element. 11487 11488 var firstChild = div.firstChild; 11489 domElement = div.removeChild(firstChild); 11490 } else if (typeof props.is === 'string') { 11491 // $FlowIssue `createElement` should be updated for Web Components 11492 domElement = ownerDocument.createElement(type, { 11493 is: props.is 11494 }); 11495 } else { 11496 // Separate else branch instead of using `props.is || undefined` above because of a Firefox bug. 11497 // See discussion in https://github.com/facebook/react/pull/6896 11498 // and discussion in https://bugzilla.mozilla.org/show_bug.cgi?id=1276240 11499 domElement = ownerDocument.createElement(type); // Normally attributes are assigned in `setInitialDOMProperties`, however the `multiple` and `size` 11500 // attributes on `select`s needs to be added before `option`s are inserted. 11501 // This prevents: 11502 // - a bug where the `select` does not scroll to the correct option because singular 11503 // `select` elements automatically pick the first item #13222 11504 // - a bug where the `select` set the first item as selected despite the `size` attribute #14239 11505 // See https://github.com/facebook/react/issues/13222 11506 // and https://github.com/facebook/react/issues/14239 11507 11508 if (type === 'select') { 11509 var node = domElement; 11510 11511 if (props.multiple) { 11512 node.multiple = true; 11513 } else if (props.size) { 11514 // Setting a size greater than 1 causes a select to behave like `multiple=true`, where 11515 // it is possible that no option is selected. 11516 // 11517 // This is only necessary when a select in "single selection mode". 11518 node.size = props.size; 11519 } 11520 } 11521 } 11522 } else { 11523 domElement = ownerDocument.createElementNS(namespaceURI, type); 11524 } 11525 11526 { 11527 if (namespaceURI === HTML_NAMESPACE$1) { 11528 if (!isCustomComponentTag && Object.prototype.toString.call(domElement) === '[object HTMLUnknownElement]' && !Object.prototype.hasOwnProperty.call(warnedUnknownTags, type)) { 11529 warnedUnknownTags[type] = true; 11530 11531 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); 11532 } 11533 } 11534 } 11535 11536 return domElement; 11537} 11538function createTextNode(text, rootContainerElement) { 11539 return getOwnerDocumentFromRootContainer(rootContainerElement).createTextNode(text); 11540} 11541function setInitialProperties(domElement, tag, rawProps, rootContainerElement) { 11542 var isCustomComponentTag = isCustomComponent(tag, rawProps); 11543 11544 { 11545 validatePropertiesInDevelopment(tag, rawProps); 11546 } // TODO: Make sure that we check isMounted before firing any of these events. 11547 11548 11549 var props; 11550 11551 switch (tag) { 11552 case 'dialog': 11553 listenToNonDelegatedEvent('cancel', domElement); 11554 listenToNonDelegatedEvent('close', domElement); 11555 props = rawProps; 11556 break; 11557 11558 case 'iframe': 11559 case 'object': 11560 case 'embed': 11561 // We listen to this event in case to ensure emulated bubble 11562 // listeners still fire for the load event. 11563 listenToNonDelegatedEvent('load', domElement); 11564 props = rawProps; 11565 break; 11566 11567 case 'video': 11568 case 'audio': 11569 // We listen to these events in case to ensure emulated bubble 11570 // listeners still fire for all the media events. 11571 for (var i = 0; i < mediaEventTypes.length; i++) { 11572 listenToNonDelegatedEvent(mediaEventTypes[i], domElement); 11573 } 11574 11575 props = rawProps; 11576 break; 11577 11578 case 'source': 11579 // We listen to this event in case to ensure emulated bubble 11580 // listeners still fire for the error event. 11581 listenToNonDelegatedEvent('error', domElement); 11582 props = rawProps; 11583 break; 11584 11585 case 'img': 11586 case 'image': 11587 case 'link': 11588 // We listen to these events in case to ensure emulated bubble 11589 // listeners still fire for error and load events. 11590 listenToNonDelegatedEvent('error', domElement); 11591 listenToNonDelegatedEvent('load', domElement); 11592 props = rawProps; 11593 break; 11594 11595 case 'details': 11596 // We listen to this event in case to ensure emulated bubble 11597 // listeners still fire for the toggle event. 11598 listenToNonDelegatedEvent('toggle', domElement); 11599 props = rawProps; 11600 break; 11601 11602 case 'input': 11603 initWrapperState(domElement, rawProps); 11604 props = getHostProps(domElement, rawProps); // We listen to this event in case to ensure emulated bubble 11605 // listeners still fire for the invalid event. 11606 11607 listenToNonDelegatedEvent('invalid', domElement); 11608 11609 break; 11610 11611 case 'option': 11612 validateProps(domElement, rawProps); 11613 props = getHostProps$1(domElement, rawProps); 11614 break; 11615 11616 case 'select': 11617 initWrapperState$1(domElement, rawProps); 11618 props = getHostProps$2(domElement, rawProps); // We listen to this event in case to ensure emulated bubble 11619 // listeners still fire for the invalid event. 11620 11621 listenToNonDelegatedEvent('invalid', domElement); 11622 11623 break; 11624 11625 case 'textarea': 11626 initWrapperState$2(domElement, rawProps); 11627 props = getHostProps$3(domElement, rawProps); // We listen to this event in case to ensure emulated bubble 11628 // listeners still fire for the invalid event. 11629 11630 listenToNonDelegatedEvent('invalid', domElement); 11631 11632 break; 11633 11634 default: 11635 props = rawProps; 11636 } 11637 11638 assertValidProps(tag, props); 11639 setInitialDOMProperties(tag, domElement, rootContainerElement, props, isCustomComponentTag); 11640 11641 switch (tag) { 11642 case 'input': 11643 // TODO: Make sure we check if this is still unmounted or do any clean 11644 // up necessary since we never stop tracking anymore. 11645 track(domElement); 11646 postMountWrapper(domElement, rawProps, false); 11647 break; 11648 11649 case 'textarea': 11650 // TODO: Make sure we check if this is still unmounted or do any clean 11651 // up necessary since we never stop tracking anymore. 11652 track(domElement); 11653 postMountWrapper$3(domElement); 11654 break; 11655 11656 case 'option': 11657 postMountWrapper$1(domElement, rawProps); 11658 break; 11659 11660 case 'select': 11661 postMountWrapper$2(domElement, rawProps); 11662 break; 11663 11664 default: 11665 if (typeof props.onClick === 'function') { 11666 // TODO: This cast may not be sound for SVG, MathML or custom elements. 11667 trapClickOnNonInteractiveElement(domElement); 11668 } 11669 11670 break; 11671 } 11672} // Calculate the diff between the two objects. 11673 11674function diffProperties(domElement, tag, lastRawProps, nextRawProps, rootContainerElement) { 11675 { 11676 validatePropertiesInDevelopment(tag, nextRawProps); 11677 } 11678 11679 var updatePayload = null; 11680 var lastProps; 11681 var nextProps; 11682 11683 switch (tag) { 11684 case 'input': 11685 lastProps = getHostProps(domElement, lastRawProps); 11686 nextProps = getHostProps(domElement, nextRawProps); 11687 updatePayload = []; 11688 break; 11689 11690 case 'option': 11691 lastProps = getHostProps$1(domElement, lastRawProps); 11692 nextProps = getHostProps$1(domElement, nextRawProps); 11693 updatePayload = []; 11694 break; 11695 11696 case 'select': 11697 lastProps = getHostProps$2(domElement, lastRawProps); 11698 nextProps = getHostProps$2(domElement, nextRawProps); 11699 updatePayload = []; 11700 break; 11701 11702 case 'textarea': 11703 lastProps = getHostProps$3(domElement, lastRawProps); 11704 nextProps = getHostProps$3(domElement, nextRawProps); 11705 updatePayload = []; 11706 break; 11707 11708 default: 11709 lastProps = lastRawProps; 11710 nextProps = nextRawProps; 11711 11712 if (typeof lastProps.onClick !== 'function' && typeof nextProps.onClick === 'function') { 11713 // TODO: This cast may not be sound for SVG, MathML or custom elements. 11714 trapClickOnNonInteractiveElement(domElement); 11715 } 11716 11717 break; 11718 } 11719 11720 assertValidProps(tag, nextProps); 11721 var propKey; 11722 var styleName; 11723 var styleUpdates = null; 11724 11725 for (propKey in lastProps) { 11726 if (nextProps.hasOwnProperty(propKey) || !lastProps.hasOwnProperty(propKey) || lastProps[propKey] == null) { 11727 continue; 11728 } 11729 11730 if (propKey === STYLE) { 11731 var lastStyle = lastProps[propKey]; 11732 11733 for (styleName in lastStyle) { 11734 if (lastStyle.hasOwnProperty(styleName)) { 11735 if (!styleUpdates) { 11736 styleUpdates = {}; 11737 } 11738 11739 styleUpdates[styleName] = ''; 11740 } 11741 } 11742 } 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)) { 11743 // This is a special case. If any listener updates we need to ensure 11744 // that the "current" fiber pointer gets updated so we need a commit 11745 // to update this element. 11746 if (!updatePayload) { 11747 updatePayload = []; 11748 } 11749 } else { 11750 // For all other deleted properties we add it to the queue. We use 11751 // the allowed property list in the commit phase instead. 11752 (updatePayload = updatePayload || []).push(propKey, null); 11753 } 11754 } 11755 11756 for (propKey in nextProps) { 11757 var nextProp = nextProps[propKey]; 11758 var lastProp = lastProps != null ? lastProps[propKey] : undefined; 11759 11760 if (!nextProps.hasOwnProperty(propKey) || nextProp === lastProp || nextProp == null && lastProp == null) { 11761 continue; 11762 } 11763 11764 if (propKey === STYLE) { 11765 { 11766 if (nextProp) { 11767 // Freeze the next style object so that we can assume it won't be 11768 // mutated. We have already warned for this in the past. 11769 Object.freeze(nextProp); 11770 } 11771 } 11772 11773 if (lastProp) { 11774 // Unset styles on `lastProp` but not on `nextProp`. 11775 for (styleName in lastProp) { 11776 if (lastProp.hasOwnProperty(styleName) && (!nextProp || !nextProp.hasOwnProperty(styleName))) { 11777 if (!styleUpdates) { 11778 styleUpdates = {}; 11779 } 11780 11781 styleUpdates[styleName] = ''; 11782 } 11783 } // Update styles that changed since `lastProp`. 11784 11785 11786 for (styleName in nextProp) { 11787 if (nextProp.hasOwnProperty(styleName) && lastProp[styleName] !== nextProp[styleName]) { 11788 if (!styleUpdates) { 11789 styleUpdates = {}; 11790 } 11791 11792 styleUpdates[styleName] = nextProp[styleName]; 11793 } 11794 } 11795 } else { 11796 // Relies on `updateStylesByID` not mutating `styleUpdates`. 11797 if (!styleUpdates) { 11798 if (!updatePayload) { 11799 updatePayload = []; 11800 } 11801 11802 updatePayload.push(propKey, styleUpdates); 11803 } 11804 11805 styleUpdates = nextProp; 11806 } 11807 } else if (propKey === DANGEROUSLY_SET_INNER_HTML) { 11808 var nextHtml = nextProp ? nextProp[HTML$1] : undefined; 11809 var lastHtml = lastProp ? lastProp[HTML$1] : undefined; 11810 11811 if (nextHtml != null) { 11812 if (lastHtml !== nextHtml) { 11813 (updatePayload = updatePayload || []).push(propKey, nextHtml); 11814 } 11815 } 11816 } else if (propKey === CHILDREN) { 11817 if (typeof nextProp === 'string' || typeof nextProp === 'number') { 11818 (updatePayload = updatePayload || []).push(propKey, '' + nextProp); 11819 } 11820 } else if (propKey === SUPPRESS_CONTENT_EDITABLE_WARNING || propKey === SUPPRESS_HYDRATION_WARNING) ; else if (registrationNameDependencies.hasOwnProperty(propKey)) { 11821 if (nextProp != null) { 11822 // We eagerly listen to this even though we haven't committed yet. 11823 if ( typeof nextProp !== 'function') { 11824 warnForInvalidEventListener(propKey, nextProp); 11825 } 11826 11827 if (propKey === 'onScroll') { 11828 listenToNonDelegatedEvent('scroll', domElement); 11829 } 11830 } 11831 11832 if (!updatePayload && lastProp !== nextProp) { 11833 // This is a special case. If any listener updates we need to ensure 11834 // that the "current" props pointer gets updated so we need a commit 11835 // to update this element. 11836 updatePayload = []; 11837 } 11838 } else if (typeof nextProp === 'object' && nextProp !== null && nextProp.$$typeof === REACT_OPAQUE_ID_TYPE) { 11839 // If we encounter useOpaqueReference's opaque object, this means we are hydrating. 11840 // In this case, call the opaque object's toString function which generates a new client 11841 // ID so client and server IDs match and throws to rerender. 11842 nextProp.toString(); 11843 } else { 11844 // For any other property we always add it to the queue and then we 11845 // filter it out using the allowed property list during the commit. 11846 (updatePayload = updatePayload || []).push(propKey, nextProp); 11847 } 11848 } 11849 11850 if (styleUpdates) { 11851 { 11852 validateShorthandPropertyCollisionInDev(styleUpdates, nextProps[STYLE]); 11853 } 11854 11855 (updatePayload = updatePayload || []).push(STYLE, styleUpdates); 11856 } 11857 11858 return updatePayload; 11859} // Apply the diff. 11860 11861function updateProperties(domElement, updatePayload, tag, lastRawProps, nextRawProps) { 11862 // Update checked *before* name. 11863 // In the middle of an update, it is possible to have multiple checked. 11864 // When a checked radio tries to change name, browser makes another radio's checked false. 11865 if (tag === 'input' && nextRawProps.type === 'radio' && nextRawProps.name != null) { 11866 updateChecked(domElement, nextRawProps); 11867 } 11868 11869 var wasCustomComponentTag = isCustomComponent(tag, lastRawProps); 11870 var isCustomComponentTag = isCustomComponent(tag, nextRawProps); // Apply the diff. 11871 11872 updateDOMProperties(domElement, updatePayload, wasCustomComponentTag, isCustomComponentTag); // TODO: Ensure that an update gets scheduled if any of the special props 11873 // changed. 11874 11875 switch (tag) { 11876 case 'input': 11877 // Update the wrapper around inputs *after* updating props. This has to 11878 // happen after `updateDOMProperties`. Otherwise HTML5 input validations 11879 // raise warnings and prevent the new value from being assigned. 11880 updateWrapper(domElement, nextRawProps); 11881 break; 11882 11883 case 'textarea': 11884 updateWrapper$1(domElement, nextRawProps); 11885 break; 11886 11887 case 'select': 11888 // <select> value update needs to occur after <option> children 11889 // reconciliation 11890 postUpdateWrapper(domElement, nextRawProps); 11891 break; 11892 } 11893} 11894 11895function getPossibleStandardName(propName) { 11896 { 11897 var lowerCasedName = propName.toLowerCase(); 11898 11899 if (!possibleStandardNames.hasOwnProperty(lowerCasedName)) { 11900 return null; 11901 } 11902 11903 return possibleStandardNames[lowerCasedName] || null; 11904 } 11905} 11906 11907function diffHydratedProperties(domElement, tag, rawProps, parentNamespace, rootContainerElement) { 11908 var isCustomComponentTag; 11909 var extraAttributeNames; 11910 11911 { 11912 suppressHydrationWarning = rawProps[SUPPRESS_HYDRATION_WARNING] === true; 11913 isCustomComponentTag = isCustomComponent(tag, rawProps); 11914 validatePropertiesInDevelopment(tag, rawProps); 11915 } // TODO: Make sure that we check isMounted before firing any of these events. 11916 11917 11918 switch (tag) { 11919 case 'dialog': 11920 listenToNonDelegatedEvent('cancel', domElement); 11921 listenToNonDelegatedEvent('close', domElement); 11922 break; 11923 11924 case 'iframe': 11925 case 'object': 11926 case 'embed': 11927 // We listen to this event in case to ensure emulated bubble 11928 // listeners still fire for the load event. 11929 listenToNonDelegatedEvent('load', domElement); 11930 break; 11931 11932 case 'video': 11933 case 'audio': 11934 // We listen to these events in case to ensure emulated bubble 11935 // listeners still fire for all the media events. 11936 for (var i = 0; i < mediaEventTypes.length; i++) { 11937 listenToNonDelegatedEvent(mediaEventTypes[i], domElement); 11938 } 11939 11940 break; 11941 11942 case 'source': 11943 // We listen to this event in case to ensure emulated bubble 11944 // listeners still fire for the error event. 11945 listenToNonDelegatedEvent('error', domElement); 11946 break; 11947 11948 case 'img': 11949 case 'image': 11950 case 'link': 11951 // We listen to these events in case to ensure emulated bubble 11952 // listeners still fire for error and load events. 11953 listenToNonDelegatedEvent('error', domElement); 11954 listenToNonDelegatedEvent('load', domElement); 11955 break; 11956 11957 case 'details': 11958 // We listen to this event in case to ensure emulated bubble 11959 // listeners still fire for the toggle event. 11960 listenToNonDelegatedEvent('toggle', domElement); 11961 break; 11962 11963 case 'input': 11964 initWrapperState(domElement, rawProps); // We listen to this event in case to ensure emulated bubble 11965 // listeners still fire for the invalid event. 11966 11967 listenToNonDelegatedEvent('invalid', domElement); 11968 11969 break; 11970 11971 case 'option': 11972 validateProps(domElement, rawProps); 11973 break; 11974 11975 case 'select': 11976 initWrapperState$1(domElement, rawProps); // We listen to this event in case to ensure emulated bubble 11977 // listeners still fire for the invalid event. 11978 11979 listenToNonDelegatedEvent('invalid', domElement); 11980 11981 break; 11982 11983 case 'textarea': 11984 initWrapperState$2(domElement, rawProps); // We listen to this event in case to ensure emulated bubble 11985 // listeners still fire for the invalid event. 11986 11987 listenToNonDelegatedEvent('invalid', domElement); 11988 11989 break; 11990 } 11991 11992 assertValidProps(tag, rawProps); 11993 11994 { 11995 extraAttributeNames = new Set(); 11996 var attributes = domElement.attributes; 11997 11998 for (var _i = 0; _i < attributes.length; _i++) { 11999 var name = attributes[_i].name.toLowerCase(); 12000 12001 switch (name) { 12002 // Built-in SSR attribute is allowed 12003 case 'data-reactroot': 12004 break; 12005 // Controlled attributes are not validated 12006 // TODO: Only ignore them on controlled tags. 12007 12008 case 'value': 12009 break; 12010 12011 case 'checked': 12012 break; 12013 12014 case 'selected': 12015 break; 12016 12017 default: 12018 // Intentionally use the original name. 12019 // See discussion in https://github.com/facebook/react/pull/10676. 12020 extraAttributeNames.add(attributes[_i].name); 12021 } 12022 } 12023 } 12024 12025 var updatePayload = null; 12026 12027 for (var propKey in rawProps) { 12028 if (!rawProps.hasOwnProperty(propKey)) { 12029 continue; 12030 } 12031 12032 var nextProp = rawProps[propKey]; 12033 12034 if (propKey === CHILDREN) { 12035 // For text content children we compare against textContent. This 12036 // might match additional HTML that is hidden when we read it using 12037 // textContent. E.g. "foo" will match "f<span>oo</span>" but that still 12038 // satisfies our requirement. Our requirement is not to produce perfect 12039 // HTML and attributes. Ideally we should preserve structure but it's 12040 // ok not to if the visible content is still enough to indicate what 12041 // even listeners these nodes might be wired up to. 12042 // TODO: Warn if there is more than a single textNode as a child. 12043 // TODO: Should we use domElement.firstChild.nodeValue to compare? 12044 if (typeof nextProp === 'string') { 12045 if (domElement.textContent !== nextProp) { 12046 if ( !suppressHydrationWarning) { 12047 warnForTextDifference(domElement.textContent, nextProp); 12048 } 12049 12050 updatePayload = [CHILDREN, nextProp]; 12051 } 12052 } else if (typeof nextProp === 'number') { 12053 if (domElement.textContent !== '' + nextProp) { 12054 if ( !suppressHydrationWarning) { 12055 warnForTextDifference(domElement.textContent, nextProp); 12056 } 12057 12058 updatePayload = [CHILDREN, '' + nextProp]; 12059 } 12060 } 12061 } else if (registrationNameDependencies.hasOwnProperty(propKey)) { 12062 if (nextProp != null) { 12063 if ( typeof nextProp !== 'function') { 12064 warnForInvalidEventListener(propKey, nextProp); 12065 } 12066 12067 if (propKey === 'onScroll') { 12068 listenToNonDelegatedEvent('scroll', domElement); 12069 } 12070 } 12071 } else if ( // Convince Flow we've calculated it (it's DEV-only in this method.) 12072 typeof isCustomComponentTag === 'boolean') { 12073 // Validate that the properties correspond to their expected values. 12074 var serverValue = void 0; 12075 var propertyInfo = getPropertyInfo(propKey); 12076 12077 if (suppressHydrationWarning) ; else if (propKey === SUPPRESS_CONTENT_EDITABLE_WARNING || propKey === SUPPRESS_HYDRATION_WARNING || // Controlled attributes are not validated 12078 // TODO: Only ignore them on controlled tags. 12079 propKey === 'value' || propKey === 'checked' || propKey === 'selected') ; else if (propKey === DANGEROUSLY_SET_INNER_HTML) { 12080 var serverHTML = domElement.innerHTML; 12081 var nextHtml = nextProp ? nextProp[HTML$1] : undefined; 12082 12083 if (nextHtml != null) { 12084 var expectedHTML = normalizeHTML(domElement, nextHtml); 12085 12086 if (expectedHTML !== serverHTML) { 12087 warnForPropDifference(propKey, serverHTML, expectedHTML); 12088 } 12089 } 12090 } else if (propKey === STYLE) { 12091 // $FlowFixMe - Should be inferred as not undefined. 12092 extraAttributeNames.delete(propKey); 12093 12094 if (canDiffStyleForHydrationWarning) { 12095 var expectedStyle = createDangerousStringForStyles(nextProp); 12096 serverValue = domElement.getAttribute('style'); 12097 12098 if (expectedStyle !== serverValue) { 12099 warnForPropDifference(propKey, serverValue, expectedStyle); 12100 } 12101 } 12102 } else if (isCustomComponentTag) { 12103 // $FlowFixMe - Should be inferred as not undefined. 12104 extraAttributeNames.delete(propKey.toLowerCase()); 12105 serverValue = getValueForAttribute(domElement, propKey, nextProp); 12106 12107 if (nextProp !== serverValue) { 12108 warnForPropDifference(propKey, serverValue, nextProp); 12109 } 12110 } else if (!shouldIgnoreAttribute(propKey, propertyInfo, isCustomComponentTag) && !shouldRemoveAttribute(propKey, nextProp, propertyInfo, isCustomComponentTag)) { 12111 var isMismatchDueToBadCasing = false; 12112 12113 if (propertyInfo !== null) { 12114 // $FlowFixMe - Should be inferred as not undefined. 12115 extraAttributeNames.delete(propertyInfo.attributeName); 12116 serverValue = getValueForProperty(domElement, propKey, nextProp, propertyInfo); 12117 } else { 12118 var ownNamespace = parentNamespace; 12119 12120 if (ownNamespace === HTML_NAMESPACE$1) { 12121 ownNamespace = getIntrinsicNamespace(tag); 12122 } 12123 12124 if (ownNamespace === HTML_NAMESPACE$1) { 12125 // $FlowFixMe - Should be inferred as not undefined. 12126 extraAttributeNames.delete(propKey.toLowerCase()); 12127 } else { 12128 var standardName = getPossibleStandardName(propKey); 12129 12130 if (standardName !== null && standardName !== propKey) { 12131 // If an SVG prop is supplied with bad casing, it will 12132 // be successfully parsed from HTML, but will produce a mismatch 12133 // (and would be incorrectly rendered on the client). 12134 // However, we already warn about bad casing elsewhere. 12135 // So we'll skip the misleading extra mismatch warning in this case. 12136 isMismatchDueToBadCasing = true; // $FlowFixMe - Should be inferred as not undefined. 12137 12138 extraAttributeNames.delete(standardName); 12139 } // $FlowFixMe - Should be inferred as not undefined. 12140 12141 12142 extraAttributeNames.delete(propKey); 12143 } 12144 12145 serverValue = getValueForAttribute(domElement, propKey, nextProp); 12146 } 12147 12148 if (nextProp !== serverValue && !isMismatchDueToBadCasing) { 12149 warnForPropDifference(propKey, serverValue, nextProp); 12150 } 12151 } 12152 } 12153 } 12154 12155 { 12156 // $FlowFixMe - Should be inferred as not undefined. 12157 if (extraAttributeNames.size > 0 && !suppressHydrationWarning) { 12158 // $FlowFixMe - Should be inferred as not undefined. 12159 warnForExtraAttributes(extraAttributeNames); 12160 } 12161 } 12162 12163 switch (tag) { 12164 case 'input': 12165 // TODO: Make sure we check if this is still unmounted or do any clean 12166 // up necessary since we never stop tracking anymore. 12167 track(domElement); 12168 postMountWrapper(domElement, rawProps, true); 12169 break; 12170 12171 case 'textarea': 12172 // TODO: Make sure we check if this is still unmounted or do any clean 12173 // up necessary since we never stop tracking anymore. 12174 track(domElement); 12175 postMountWrapper$3(domElement); 12176 break; 12177 12178 case 'select': 12179 case 'option': 12180 // For input and textarea we current always set the value property at 12181 // post mount to force it to diverge from attributes. However, for 12182 // option and select we don't quite do the same thing and select 12183 // is not resilient to the DOM state changing so we don't do that here. 12184 // TODO: Consider not doing this for input and textarea. 12185 break; 12186 12187 default: 12188 if (typeof rawProps.onClick === 'function') { 12189 // TODO: This cast may not be sound for SVG, MathML or custom elements. 12190 trapClickOnNonInteractiveElement(domElement); 12191 } 12192 12193 break; 12194 } 12195 12196 return updatePayload; 12197} 12198function diffHydratedText(textNode, text) { 12199 var isDifferent = textNode.nodeValue !== text; 12200 return isDifferent; 12201} 12202function warnForUnmatchedText(textNode, text) { 12203 { 12204 warnForTextDifference(textNode.nodeValue, text); 12205 } 12206} 12207function warnForDeletedHydratableElement(parentNode, child) { 12208 { 12209 if (didWarnInvalidHydration) { 12210 return; 12211 } 12212 12213 didWarnInvalidHydration = true; 12214 12215 error('Did not expect server HTML to contain a <%s> in <%s>.', child.nodeName.toLowerCase(), parentNode.nodeName.toLowerCase()); 12216 } 12217} 12218function warnForDeletedHydratableText(parentNode, child) { 12219 { 12220 if (didWarnInvalidHydration) { 12221 return; 12222 } 12223 12224 didWarnInvalidHydration = true; 12225 12226 error('Did not expect server HTML to contain the text node "%s" in <%s>.', child.nodeValue, parentNode.nodeName.toLowerCase()); 12227 } 12228} 12229function warnForInsertedHydratedElement(parentNode, tag, props) { 12230 { 12231 if (didWarnInvalidHydration) { 12232 return; 12233 } 12234 12235 didWarnInvalidHydration = true; 12236 12237 error('Expected server HTML to contain a matching <%s> in <%s>.', tag, parentNode.nodeName.toLowerCase()); 12238 } 12239} 12240function warnForInsertedHydratedText(parentNode, text) { 12241 { 12242 if (text === '') { 12243 // We expect to insert empty text nodes since they're not represented in 12244 // the HTML. 12245 // TODO: Remove this special case if we can just avoid inserting empty 12246 // text nodes. 12247 return; 12248 } 12249 12250 if (didWarnInvalidHydration) { 12251 return; 12252 } 12253 12254 didWarnInvalidHydration = true; 12255 12256 error('Expected server HTML to contain a matching text node for "%s" in <%s>.', text, parentNode.nodeName.toLowerCase()); 12257 } 12258} 12259function restoreControlledState$3(domElement, tag, props) { 12260 switch (tag) { 12261 case 'input': 12262 restoreControlledState(domElement, props); 12263 return; 12264 12265 case 'textarea': 12266 restoreControlledState$2(domElement, props); 12267 return; 12268 12269 case 'select': 12270 restoreControlledState$1(domElement, props); 12271 return; 12272 } 12273} 12274 12275var validateDOMNesting = function () {}; 12276 12277var updatedAncestorInfo = function () {}; 12278 12279{ 12280 // This validation code was written based on the HTML5 parsing spec: 12281 // https://html.spec.whatwg.org/multipage/syntax.html#has-an-element-in-scope 12282 // 12283 // Note: this does not catch all invalid nesting, nor does it try to (as it's 12284 // not clear what practical benefit doing so provides); instead, we warn only 12285 // for cases where the parser will give a parse tree differing from what React 12286 // intended. For example, <b><div></div></b> is invalid but we don't warn 12287 // because it still parses correctly; we do warn for other cases like nested 12288 // <p> tags where the beginning of the second element implicitly closes the 12289 // first, causing a confusing mess. 12290 // https://html.spec.whatwg.org/multipage/syntax.html#special 12291 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 12292 12293 var inScopeTags = ['applet', 'caption', 'html', 'table', 'td', 'th', 'marquee', 'object', 'template', // https://html.spec.whatwg.org/multipage/syntax.html#html-integration-point 12294 // TODO: Distinguish by namespace here -- for <title>, including it here 12295 // errs on the side of fewer warnings 12296 'foreignObject', 'desc', 'title']; // https://html.spec.whatwg.org/multipage/syntax.html#has-an-element-in-button-scope 12297 12298 var buttonScopeTags = inScopeTags.concat(['button']); // https://html.spec.whatwg.org/multipage/syntax.html#generate-implied-end-tags 12299 12300 var impliedEndTags = ['dd', 'dt', 'li', 'option', 'optgroup', 'p', 'rp', 'rt']; 12301 var emptyAncestorInfo = { 12302 current: null, 12303 formTag: null, 12304 aTagInScope: null, 12305 buttonTagInScope: null, 12306 nobrTagInScope: null, 12307 pTagInButtonScope: null, 12308 listItemTagAutoclosing: null, 12309 dlItemTagAutoclosing: null 12310 }; 12311 12312 updatedAncestorInfo = function (oldInfo, tag) { 12313 var ancestorInfo = _assign({}, oldInfo || emptyAncestorInfo); 12314 12315 var info = { 12316 tag: tag 12317 }; 12318 12319 if (inScopeTags.indexOf(tag) !== -1) { 12320 ancestorInfo.aTagInScope = null; 12321 ancestorInfo.buttonTagInScope = null; 12322 ancestorInfo.nobrTagInScope = null; 12323 } 12324 12325 if (buttonScopeTags.indexOf(tag) !== -1) { 12326 ancestorInfo.pTagInButtonScope = null; 12327 } // See rules for 'li', 'dd', 'dt' start tags in 12328 // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inbody 12329 12330 12331 if (specialTags.indexOf(tag) !== -1 && tag !== 'address' && tag !== 'div' && tag !== 'p') { 12332 ancestorInfo.listItemTagAutoclosing = null; 12333 ancestorInfo.dlItemTagAutoclosing = null; 12334 } 12335 12336 ancestorInfo.current = info; 12337 12338 if (tag === 'form') { 12339 ancestorInfo.formTag = info; 12340 } 12341 12342 if (tag === 'a') { 12343 ancestorInfo.aTagInScope = info; 12344 } 12345 12346 if (tag === 'button') { 12347 ancestorInfo.buttonTagInScope = info; 12348 } 12349 12350 if (tag === 'nobr') { 12351 ancestorInfo.nobrTagInScope = info; 12352 } 12353 12354 if (tag === 'p') { 12355 ancestorInfo.pTagInButtonScope = info; 12356 } 12357 12358 if (tag === 'li') { 12359 ancestorInfo.listItemTagAutoclosing = info; 12360 } 12361 12362 if (tag === 'dd' || tag === 'dt') { 12363 ancestorInfo.dlItemTagAutoclosing = info; 12364 } 12365 12366 return ancestorInfo; 12367 }; 12368 /** 12369 * Returns whether 12370 */ 12371 12372 12373 var isTagValidWithParent = function (tag, parentTag) { 12374 // First, let's check if we're in an unusual parsing mode... 12375 switch (parentTag) { 12376 // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inselect 12377 case 'select': 12378 return tag === 'option' || tag === 'optgroup' || tag === '#text'; 12379 12380 case 'optgroup': 12381 return tag === 'option' || tag === '#text'; 12382 // Strictly speaking, seeing an <option> doesn't mean we're in a <select> 12383 // but 12384 12385 case 'option': 12386 return tag === '#text'; 12387 // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-intd 12388 // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-incaption 12389 // No special behavior since these rules fall back to "in body" mode for 12390 // all except special table nodes which cause bad parsing behavior anyway. 12391 // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-intr 12392 12393 case 'tr': 12394 return tag === 'th' || tag === 'td' || tag === 'style' || tag === 'script' || tag === 'template'; 12395 // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-intbody 12396 12397 case 'tbody': 12398 case 'thead': 12399 case 'tfoot': 12400 return tag === 'tr' || tag === 'style' || tag === 'script' || tag === 'template'; 12401 // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-incolgroup 12402 12403 case 'colgroup': 12404 return tag === 'col' || tag === 'template'; 12405 // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-intable 12406 12407 case 'table': 12408 return tag === 'caption' || tag === 'colgroup' || tag === 'tbody' || tag === 'tfoot' || tag === 'thead' || tag === 'style' || tag === 'script' || tag === 'template'; 12409 // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inhead 12410 12411 case 'head': 12412 return tag === 'base' || tag === 'basefont' || tag === 'bgsound' || tag === 'link' || tag === 'meta' || tag === 'title' || tag === 'noscript' || tag === 'noframes' || tag === 'style' || tag === 'script' || tag === 'template'; 12413 // https://html.spec.whatwg.org/multipage/semantics.html#the-html-element 12414 12415 case 'html': 12416 return tag === 'head' || tag === 'body' || tag === 'frameset'; 12417 12418 case 'frameset': 12419 return tag === 'frame'; 12420 12421 case '#document': 12422 return tag === 'html'; 12423 } // Probably in the "in body" parsing mode, so we outlaw only tag combos 12424 // where the parsing rules cause implicit opens or closes to be added. 12425 // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inbody 12426 12427 12428 switch (tag) { 12429 case 'h1': 12430 case 'h2': 12431 case 'h3': 12432 case 'h4': 12433 case 'h5': 12434 case 'h6': 12435 return parentTag !== 'h1' && parentTag !== 'h2' && parentTag !== 'h3' && parentTag !== 'h4' && parentTag !== 'h5' && parentTag !== 'h6'; 12436 12437 case 'rp': 12438 case 'rt': 12439 return impliedEndTags.indexOf(parentTag) === -1; 12440 12441 case 'body': 12442 case 'caption': 12443 case 'col': 12444 case 'colgroup': 12445 case 'frameset': 12446 case 'frame': 12447 case 'head': 12448 case 'html': 12449 case 'tbody': 12450 case 'td': 12451 case 'tfoot': 12452 case 'th': 12453 case 'thead': 12454 case 'tr': 12455 // These tags are only valid with a few parents that have special child 12456 // parsing rules -- if we're down here, then none of those matched and 12457 // so we allow it only if we don't know what the parent is, as all other 12458 // cases are invalid. 12459 return parentTag == null; 12460 } 12461 12462 return true; 12463 }; 12464 /** 12465 * Returns whether 12466 */ 12467 12468 12469 var findInvalidAncestorForTag = function (tag, ancestorInfo) { 12470 switch (tag) { 12471 case 'address': 12472 case 'article': 12473 case 'aside': 12474 case 'blockquote': 12475 case 'center': 12476 case 'details': 12477 case 'dialog': 12478 case 'dir': 12479 case 'div': 12480 case 'dl': 12481 case 'fieldset': 12482 case 'figcaption': 12483 case 'figure': 12484 case 'footer': 12485 case 'header': 12486 case 'hgroup': 12487 case 'main': 12488 case 'menu': 12489 case 'nav': 12490 case 'ol': 12491 case 'p': 12492 case 'section': 12493 case 'summary': 12494 case 'ul': 12495 case 'pre': 12496 case 'listing': 12497 case 'table': 12498 case 'hr': 12499 case 'xmp': 12500 case 'h1': 12501 case 'h2': 12502 case 'h3': 12503 case 'h4': 12504 case 'h5': 12505 case 'h6': 12506 return ancestorInfo.pTagInButtonScope; 12507 12508 case 'form': 12509 return ancestorInfo.formTag || ancestorInfo.pTagInButtonScope; 12510 12511 case 'li': 12512 return ancestorInfo.listItemTagAutoclosing; 12513 12514 case 'dd': 12515 case 'dt': 12516 return ancestorInfo.dlItemTagAutoclosing; 12517 12518 case 'button': 12519 return ancestorInfo.buttonTagInScope; 12520 12521 case 'a': 12522 // Spec says something about storing a list of markers, but it sounds 12523 // equivalent to this check. 12524 return ancestorInfo.aTagInScope; 12525 12526 case 'nobr': 12527 return ancestorInfo.nobrTagInScope; 12528 } 12529 12530 return null; 12531 }; 12532 12533 var didWarn$1 = {}; 12534 12535 validateDOMNesting = function (childTag, childText, ancestorInfo) { 12536 ancestorInfo = ancestorInfo || emptyAncestorInfo; 12537 var parentInfo = ancestorInfo.current; 12538 var parentTag = parentInfo && parentInfo.tag; 12539 12540 if (childText != null) { 12541 if (childTag != null) { 12542 error('validateDOMNesting: when childText is passed, childTag should be null'); 12543 } 12544 12545 childTag = '#text'; 12546 } 12547 12548 var invalidParent = isTagValidWithParent(childTag, parentTag) ? null : parentInfo; 12549 var invalidAncestor = invalidParent ? null : findInvalidAncestorForTag(childTag, ancestorInfo); 12550 var invalidParentOrAncestor = invalidParent || invalidAncestor; 12551 12552 if (!invalidParentOrAncestor) { 12553 return; 12554 } 12555 12556 var ancestorTag = invalidParentOrAncestor.tag; 12557 var warnKey = !!invalidParent + '|' + childTag + '|' + ancestorTag; 12558 12559 if (didWarn$1[warnKey]) { 12560 return; 12561 } 12562 12563 didWarn$1[warnKey] = true; 12564 var tagDisplayName = childTag; 12565 var whitespaceInfo = ''; 12566 12567 if (childTag === '#text') { 12568 if (/\S/.test(childText)) { 12569 tagDisplayName = 'Text nodes'; 12570 } else { 12571 tagDisplayName = 'Whitespace text nodes'; 12572 whitespaceInfo = " Make sure you don't have any extra whitespace between tags on " + 'each line of your source code.'; 12573 } 12574 } else { 12575 tagDisplayName = '<' + childTag + '>'; 12576 } 12577 12578 if (invalidParent) { 12579 var info = ''; 12580 12581 if (ancestorTag === 'table' && childTag === 'tr') { 12582 info += ' Add a <tbody>, <thead> or <tfoot> to your code to match the DOM tree generated by ' + 'the browser.'; 12583 } 12584 12585 error('validateDOMNesting(...): %s cannot appear as a child of <%s>.%s%s', tagDisplayName, ancestorTag, whitespaceInfo, info); 12586 } else { 12587 error('validateDOMNesting(...): %s cannot appear as a descendant of ' + '<%s>.', tagDisplayName, ancestorTag); 12588 } 12589 }; 12590} 12591 12592var SUPPRESS_HYDRATION_WARNING$1; 12593 12594{ 12595 SUPPRESS_HYDRATION_WARNING$1 = 'suppressHydrationWarning'; 12596} 12597 12598var SUSPENSE_START_DATA = '$'; 12599var SUSPENSE_END_DATA = '/$'; 12600var SUSPENSE_PENDING_START_DATA = '$?'; 12601var SUSPENSE_FALLBACK_START_DATA = '$!'; 12602var STYLE$1 = 'style'; 12603var eventsEnabled = null; 12604var selectionInformation = null; 12605 12606function shouldAutoFocusHostComponent(type, props) { 12607 switch (type) { 12608 case 'button': 12609 case 'input': 12610 case 'select': 12611 case 'textarea': 12612 return !!props.autoFocus; 12613 } 12614 12615 return false; 12616} 12617function getRootHostContext(rootContainerInstance) { 12618 var type; 12619 var namespace; 12620 var nodeType = rootContainerInstance.nodeType; 12621 12622 switch (nodeType) { 12623 case DOCUMENT_NODE: 12624 case DOCUMENT_FRAGMENT_NODE: 12625 { 12626 type = nodeType === DOCUMENT_NODE ? '#document' : '#fragment'; 12627 var root = rootContainerInstance.documentElement; 12628 namespace = root ? root.namespaceURI : getChildNamespace(null, ''); 12629 break; 12630 } 12631 12632 default: 12633 { 12634 var container = nodeType === COMMENT_NODE ? rootContainerInstance.parentNode : rootContainerInstance; 12635 var ownNamespace = container.namespaceURI || null; 12636 type = container.tagName; 12637 namespace = getChildNamespace(ownNamespace, type); 12638 break; 12639 } 12640 } 12641 12642 { 12643 var validatedTag = type.toLowerCase(); 12644 var ancestorInfo = updatedAncestorInfo(null, validatedTag); 12645 return { 12646 namespace: namespace, 12647 ancestorInfo: ancestorInfo 12648 }; 12649 } 12650} 12651function getChildHostContext(parentHostContext, type, rootContainerInstance) { 12652 { 12653 var parentHostContextDev = parentHostContext; 12654 var namespace = getChildNamespace(parentHostContextDev.namespace, type); 12655 var ancestorInfo = updatedAncestorInfo(parentHostContextDev.ancestorInfo, type); 12656 return { 12657 namespace: namespace, 12658 ancestorInfo: ancestorInfo 12659 }; 12660 } 12661} 12662function getPublicInstance(instance) { 12663 return instance; 12664} 12665function prepareForCommit(containerInfo) { 12666 eventsEnabled = isEnabled(); 12667 selectionInformation = getSelectionInformation(); 12668 var activeInstance = null; 12669 12670 setEnabled(false); 12671 return activeInstance; 12672} 12673function resetAfterCommit(containerInfo) { 12674 restoreSelection(selectionInformation); 12675 setEnabled(eventsEnabled); 12676 eventsEnabled = null; 12677 selectionInformation = null; 12678} 12679function createInstance(type, props, rootContainerInstance, hostContext, internalInstanceHandle) { 12680 var parentNamespace; 12681 12682 { 12683 // TODO: take namespace into account when validating. 12684 var hostContextDev = hostContext; 12685 validateDOMNesting(type, null, hostContextDev.ancestorInfo); 12686 12687 if (typeof props.children === 'string' || typeof props.children === 'number') { 12688 var string = '' + props.children; 12689 var ownAncestorInfo = updatedAncestorInfo(hostContextDev.ancestorInfo, type); 12690 validateDOMNesting(null, string, ownAncestorInfo); 12691 } 12692 12693 parentNamespace = hostContextDev.namespace; 12694 } 12695 12696 var domElement = createElement(type, props, rootContainerInstance, parentNamespace); 12697 precacheFiberNode(internalInstanceHandle, domElement); 12698 updateFiberProps(domElement, props); 12699 return domElement; 12700} 12701function appendInitialChild(parentInstance, child) { 12702 parentInstance.appendChild(child); 12703} 12704function finalizeInitialChildren(domElement, type, props, rootContainerInstance, hostContext) { 12705 setInitialProperties(domElement, type, props, rootContainerInstance); 12706 return shouldAutoFocusHostComponent(type, props); 12707} 12708function prepareUpdate(domElement, type, oldProps, newProps, rootContainerInstance, hostContext) { 12709 { 12710 var hostContextDev = hostContext; 12711 12712 if (typeof newProps.children !== typeof oldProps.children && (typeof newProps.children === 'string' || typeof newProps.children === 'number')) { 12713 var string = '' + newProps.children; 12714 var ownAncestorInfo = updatedAncestorInfo(hostContextDev.ancestorInfo, type); 12715 validateDOMNesting(null, string, ownAncestorInfo); 12716 } 12717 } 12718 12719 return diffProperties(domElement, type, oldProps, newProps); 12720} 12721function shouldSetTextContent(type, props) { 12722 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; 12723} 12724function createTextInstance(text, rootContainerInstance, hostContext, internalInstanceHandle) { 12725 { 12726 var hostContextDev = hostContext; 12727 validateDOMNesting(null, text, hostContextDev.ancestorInfo); 12728 } 12729 12730 var textNode = createTextNode(text, rootContainerInstance); 12731 precacheFiberNode(internalInstanceHandle, textNode); 12732 return textNode; 12733} 12734// if a component just imports ReactDOM (e.g. for findDOMNode). 12735// Some environments might not have setTimeout or clearTimeout. 12736 12737var scheduleTimeout = typeof setTimeout === 'function' ? setTimeout : undefined; 12738var cancelTimeout = typeof clearTimeout === 'function' ? clearTimeout : undefined; 12739var noTimeout = -1; // ------------------- 12740function commitMount(domElement, type, newProps, internalInstanceHandle) { 12741 // Despite the naming that might imply otherwise, this method only 12742 // fires if there is an `Update` effect scheduled during mounting. 12743 // This happens if `finalizeInitialChildren` returns `true` (which it 12744 // does to implement the `autoFocus` attribute on the client). But 12745 // there are also other cases when this might happen (such as patching 12746 // up text content during hydration mismatch). So we'll check this again. 12747 if (shouldAutoFocusHostComponent(type, newProps)) { 12748 domElement.focus(); 12749 } 12750} 12751function commitUpdate(domElement, updatePayload, type, oldProps, newProps, internalInstanceHandle) { 12752 // Update the props handle so that we know which props are the ones with 12753 // with current event handlers. 12754 updateFiberProps(domElement, newProps); // Apply the diff to the DOM node. 12755 12756 updateProperties(domElement, updatePayload, type, oldProps, newProps); 12757} 12758function resetTextContent(domElement) { 12759 setTextContent(domElement, ''); 12760} 12761function commitTextUpdate(textInstance, oldText, newText) { 12762 textInstance.nodeValue = newText; 12763} 12764function appendChild(parentInstance, child) { 12765 parentInstance.appendChild(child); 12766} 12767function appendChildToContainer(container, child) { 12768 var parentNode; 12769 12770 if (container.nodeType === COMMENT_NODE) { 12771 parentNode = container.parentNode; 12772 parentNode.insertBefore(child, container); 12773 } else { 12774 parentNode = container; 12775 parentNode.appendChild(child); 12776 } // This container might be used for a portal. 12777 // If something inside a portal is clicked, that click should bubble 12778 // through the React tree. However, on Mobile Safari the click would 12779 // never bubble through the *DOM* tree unless an ancestor with onclick 12780 // event exists. So we wouldn't see it and dispatch it. 12781 // This is why we ensure that non React root containers have inline onclick 12782 // defined. 12783 // https://github.com/facebook/react/issues/11918 12784 12785 12786 var reactRootContainer = container._reactRootContainer; 12787 12788 if ((reactRootContainer === null || reactRootContainer === undefined) && parentNode.onclick === null) { 12789 // TODO: This cast may not be sound for SVG, MathML or custom elements. 12790 trapClickOnNonInteractiveElement(parentNode); 12791 } 12792} 12793function insertBefore(parentInstance, child, beforeChild) { 12794 parentInstance.insertBefore(child, beforeChild); 12795} 12796function insertInContainerBefore(container, child, beforeChild) { 12797 if (container.nodeType === COMMENT_NODE) { 12798 container.parentNode.insertBefore(child, beforeChild); 12799 } else { 12800 container.insertBefore(child, beforeChild); 12801 } 12802} 12803 12804function removeChild(parentInstance, child) { 12805 parentInstance.removeChild(child); 12806} 12807function removeChildFromContainer(container, child) { 12808 if (container.nodeType === COMMENT_NODE) { 12809 container.parentNode.removeChild(child); 12810 } else { 12811 container.removeChild(child); 12812 } 12813} 12814function hideInstance(instance) { 12815 // TODO: Does this work for all element types? What about MathML? Should we 12816 // pass host context to this method? 12817 instance = instance; 12818 var style = instance.style; 12819 12820 if (typeof style.setProperty === 'function') { 12821 style.setProperty('display', 'none', 'important'); 12822 } else { 12823 style.display = 'none'; 12824 } 12825} 12826function hideTextInstance(textInstance) { 12827 textInstance.nodeValue = ''; 12828} 12829function unhideInstance(instance, props) { 12830 instance = instance; 12831 var styleProp = props[STYLE$1]; 12832 var display = styleProp !== undefined && styleProp !== null && styleProp.hasOwnProperty('display') ? styleProp.display : null; 12833 instance.style.display = dangerousStyleValue('display', display); 12834} 12835function unhideTextInstance(textInstance, text) { 12836 textInstance.nodeValue = text; 12837} 12838function clearContainer(container) { 12839 if (container.nodeType === ELEMENT_NODE) { 12840 container.textContent = ''; 12841 } else if (container.nodeType === DOCUMENT_NODE) { 12842 var body = container.body; 12843 12844 if (body != null) { 12845 body.textContent = ''; 12846 } 12847 } 12848} // ------------------- 12849function canHydrateInstance(instance, type, props) { 12850 if (instance.nodeType !== ELEMENT_NODE || type.toLowerCase() !== instance.nodeName.toLowerCase()) { 12851 return null; 12852 } // This has now been refined to an element node. 12853 12854 12855 return instance; 12856} 12857function canHydrateTextInstance(instance, text) { 12858 if (text === '' || instance.nodeType !== TEXT_NODE) { 12859 // Empty strings are not parsed by HTML so there won't be a correct match here. 12860 return null; 12861 } // This has now been refined to a text node. 12862 12863 12864 return instance; 12865} 12866function isSuspenseInstancePending(instance) { 12867 return instance.data === SUSPENSE_PENDING_START_DATA; 12868} 12869function isSuspenseInstanceFallback(instance) { 12870 return instance.data === SUSPENSE_FALLBACK_START_DATA; 12871} 12872 12873function getNextHydratable(node) { 12874 // Skip non-hydratable nodes. 12875 for (; node != null; node = node.nextSibling) { 12876 var nodeType = node.nodeType; 12877 12878 if (nodeType === ELEMENT_NODE || nodeType === TEXT_NODE) { 12879 break; 12880 } 12881 } 12882 12883 return node; 12884} 12885 12886function getNextHydratableSibling(instance) { 12887 return getNextHydratable(instance.nextSibling); 12888} 12889function getFirstHydratableChild(parentInstance) { 12890 return getNextHydratable(parentInstance.firstChild); 12891} 12892function hydrateInstance(instance, type, props, rootContainerInstance, hostContext, internalInstanceHandle) { 12893 precacheFiberNode(internalInstanceHandle, instance); // TODO: Possibly defer this until the commit phase where all the events 12894 // get attached. 12895 12896 updateFiberProps(instance, props); 12897 var parentNamespace; 12898 12899 { 12900 var hostContextDev = hostContext; 12901 parentNamespace = hostContextDev.namespace; 12902 } 12903 12904 return diffHydratedProperties(instance, type, props, parentNamespace); 12905} 12906function hydrateTextInstance(textInstance, text, internalInstanceHandle) { 12907 precacheFiberNode(internalInstanceHandle, textInstance); 12908 return diffHydratedText(textInstance, text); 12909} 12910function getNextHydratableInstanceAfterSuspenseInstance(suspenseInstance) { 12911 var node = suspenseInstance.nextSibling; // Skip past all nodes within this suspense boundary. 12912 // There might be nested nodes so we need to keep track of how 12913 // deep we are and only break out when we're back on top. 12914 12915 var depth = 0; 12916 12917 while (node) { 12918 if (node.nodeType === COMMENT_NODE) { 12919 var data = node.data; 12920 12921 if (data === SUSPENSE_END_DATA) { 12922 if (depth === 0) { 12923 return getNextHydratableSibling(node); 12924 } else { 12925 depth--; 12926 } 12927 } else if (data === SUSPENSE_START_DATA || data === SUSPENSE_FALLBACK_START_DATA || data === SUSPENSE_PENDING_START_DATA) { 12928 depth++; 12929 } 12930 } 12931 12932 node = node.nextSibling; 12933 } // TODO: Warn, we didn't find the end comment boundary. 12934 12935 12936 return null; 12937} // Returns the SuspenseInstance if this node is a direct child of a 12938// SuspenseInstance. I.e. if its previous sibling is a Comment with 12939// SUSPENSE_x_START_DATA. Otherwise, null. 12940 12941function getParentSuspenseInstance(targetInstance) { 12942 var node = targetInstance.previousSibling; // Skip past all nodes within this suspense boundary. 12943 // There might be nested nodes so we need to keep track of how 12944 // deep we are and only break out when we're back on top. 12945 12946 var depth = 0; 12947 12948 while (node) { 12949 if (node.nodeType === COMMENT_NODE) { 12950 var data = node.data; 12951 12952 if (data === SUSPENSE_START_DATA || data === SUSPENSE_FALLBACK_START_DATA || data === SUSPENSE_PENDING_START_DATA) { 12953 if (depth === 0) { 12954 return node; 12955 } else { 12956 depth--; 12957 } 12958 } else if (data === SUSPENSE_END_DATA) { 12959 depth++; 12960 } 12961 } 12962 12963 node = node.previousSibling; 12964 } 12965 12966 return null; 12967} 12968function commitHydratedContainer(container) { 12969 // Retry if any event replaying was blocked on this. 12970 retryIfBlockedOn(container); 12971} 12972function commitHydratedSuspenseInstance(suspenseInstance) { 12973 // Retry if any event replaying was blocked on this. 12974 retryIfBlockedOn(suspenseInstance); 12975} 12976function didNotMatchHydratedContainerTextInstance(parentContainer, textInstance, text) { 12977 { 12978 warnForUnmatchedText(textInstance, text); 12979 } 12980} 12981function didNotMatchHydratedTextInstance(parentType, parentProps, parentInstance, textInstance, text) { 12982 if ( parentProps[SUPPRESS_HYDRATION_WARNING$1] !== true) { 12983 warnForUnmatchedText(textInstance, text); 12984 } 12985} 12986function didNotHydrateContainerInstance(parentContainer, instance) { 12987 { 12988 if (instance.nodeType === ELEMENT_NODE) { 12989 warnForDeletedHydratableElement(parentContainer, instance); 12990 } else if (instance.nodeType === COMMENT_NODE) ; else { 12991 warnForDeletedHydratableText(parentContainer, instance); 12992 } 12993 } 12994} 12995function didNotHydrateInstance(parentType, parentProps, parentInstance, instance) { 12996 if ( parentProps[SUPPRESS_HYDRATION_WARNING$1] !== true) { 12997 if (instance.nodeType === ELEMENT_NODE) { 12998 warnForDeletedHydratableElement(parentInstance, instance); 12999 } else if (instance.nodeType === COMMENT_NODE) ; else { 13000 warnForDeletedHydratableText(parentInstance, instance); 13001 } 13002 } 13003} 13004function didNotFindHydratableContainerInstance(parentContainer, type, props) { 13005 { 13006 warnForInsertedHydratedElement(parentContainer, type); 13007 } 13008} 13009function didNotFindHydratableContainerTextInstance(parentContainer, text) { 13010 { 13011 warnForInsertedHydratedText(parentContainer, text); 13012 } 13013} 13014function didNotFindHydratableInstance(parentType, parentProps, parentInstance, type, props) { 13015 if ( parentProps[SUPPRESS_HYDRATION_WARNING$1] !== true) { 13016 warnForInsertedHydratedElement(parentInstance, type); 13017 } 13018} 13019function didNotFindHydratableTextInstance(parentType, parentProps, parentInstance, text) { 13020 if ( parentProps[SUPPRESS_HYDRATION_WARNING$1] !== true) { 13021 warnForInsertedHydratedText(parentInstance, text); 13022 } 13023} 13024function didNotFindHydratableSuspenseInstance(parentType, parentProps, parentInstance) { 13025 if ( parentProps[SUPPRESS_HYDRATION_WARNING$1] !== true) ; 13026} 13027var clientId = 0; 13028function makeClientIdInDEV(warnOnAccessInDEV) { 13029 var id = 'r:' + (clientId++).toString(36); 13030 return { 13031 toString: function () { 13032 warnOnAccessInDEV(); 13033 return id; 13034 }, 13035 valueOf: function () { 13036 warnOnAccessInDEV(); 13037 return id; 13038 } 13039 }; 13040} 13041function isOpaqueHydratingObject(value) { 13042 return value !== null && typeof value === 'object' && value.$$typeof === REACT_OPAQUE_ID_TYPE; 13043} 13044function makeOpaqueHydratingObject(attemptToReadValue) { 13045 return { 13046 $$typeof: REACT_OPAQUE_ID_TYPE, 13047 toString: attemptToReadValue, 13048 valueOf: attemptToReadValue 13049 }; 13050} 13051function preparePortalMount(portalInstance) { 13052 { 13053 listenToAllSupportedEvents(portalInstance); 13054 } 13055} 13056 13057var randomKey = Math.random().toString(36).slice(2); 13058var internalInstanceKey = '__reactFiber$' + randomKey; 13059var internalPropsKey = '__reactProps$' + randomKey; 13060var internalContainerInstanceKey = '__reactContainer$' + randomKey; 13061var internalEventHandlersKey = '__reactEvents$' + randomKey; 13062function precacheFiberNode(hostInst, node) { 13063 node[internalInstanceKey] = hostInst; 13064} 13065function markContainerAsRoot(hostRoot, node) { 13066 node[internalContainerInstanceKey] = hostRoot; 13067} 13068function unmarkContainerAsRoot(node) { 13069 node[internalContainerInstanceKey] = null; 13070} 13071function isContainerMarkedAsRoot(node) { 13072 return !!node[internalContainerInstanceKey]; 13073} // Given a DOM node, return the closest HostComponent or HostText fiber ancestor. 13074// If the target node is part of a hydrated or not yet rendered subtree, then 13075// this may also return a SuspenseComponent or HostRoot to indicate that. 13076// Conceptually the HostRoot fiber is a child of the Container node. So if you 13077// pass the Container node as the targetNode, you will not actually get the 13078// HostRoot back. To get to the HostRoot, you need to pass a child of it. 13079// The same thing applies to Suspense boundaries. 13080 13081function getClosestInstanceFromNode(targetNode) { 13082 var targetInst = targetNode[internalInstanceKey]; 13083 13084 if (targetInst) { 13085 // Don't return HostRoot or SuspenseComponent here. 13086 return targetInst; 13087 } // If the direct event target isn't a React owned DOM node, we need to look 13088 // to see if one of its parents is a React owned DOM node. 13089 13090 13091 var parentNode = targetNode.parentNode; 13092 13093 while (parentNode) { 13094 // We'll check if this is a container root that could include 13095 // React nodes in the future. We need to check this first because 13096 // if we're a child of a dehydrated container, we need to first 13097 // find that inner container before moving on to finding the parent 13098 // instance. Note that we don't check this field on the targetNode 13099 // itself because the fibers are conceptually between the container 13100 // node and the first child. It isn't surrounding the container node. 13101 // If it's not a container, we check if it's an instance. 13102 targetInst = parentNode[internalContainerInstanceKey] || parentNode[internalInstanceKey]; 13103 13104 if (targetInst) { 13105 // Since this wasn't the direct target of the event, we might have 13106 // stepped past dehydrated DOM nodes to get here. However they could 13107 // also have been non-React nodes. We need to answer which one. 13108 // If we the instance doesn't have any children, then there can't be 13109 // a nested suspense boundary within it. So we can use this as a fast 13110 // bailout. Most of the time, when people add non-React children to 13111 // the tree, it is using a ref to a child-less DOM node. 13112 // Normally we'd only need to check one of the fibers because if it 13113 // has ever gone from having children to deleting them or vice versa 13114 // it would have deleted the dehydrated boundary nested inside already. 13115 // However, since the HostRoot starts out with an alternate it might 13116 // have one on the alternate so we need to check in case this was a 13117 // root. 13118 var alternate = targetInst.alternate; 13119 13120 if (targetInst.child !== null || alternate !== null && alternate.child !== null) { 13121 // Next we need to figure out if the node that skipped past is 13122 // nested within a dehydrated boundary and if so, which one. 13123 var suspenseInstance = getParentSuspenseInstance(targetNode); 13124 13125 while (suspenseInstance !== null) { 13126 // We found a suspense instance. That means that we haven't 13127 // hydrated it yet. Even though we leave the comments in the 13128 // DOM after hydrating, and there are boundaries in the DOM 13129 // that could already be hydrated, we wouldn't have found them 13130 // through this pass since if the target is hydrated it would 13131 // have had an internalInstanceKey on it. 13132 // Let's get the fiber associated with the SuspenseComponent 13133 // as the deepest instance. 13134 var targetSuspenseInst = suspenseInstance[internalInstanceKey]; 13135 13136 if (targetSuspenseInst) { 13137 return targetSuspenseInst; 13138 } // If we don't find a Fiber on the comment, it might be because 13139 // we haven't gotten to hydrate it yet. There might still be a 13140 // parent boundary that hasn't above this one so we need to find 13141 // the outer most that is known. 13142 13143 13144 suspenseInstance = getParentSuspenseInstance(suspenseInstance); // If we don't find one, then that should mean that the parent 13145 // host component also hasn't hydrated yet. We can return it 13146 // below since it will bail out on the isMounted check later. 13147 } 13148 } 13149 13150 return targetInst; 13151 } 13152 13153 targetNode = parentNode; 13154 parentNode = targetNode.parentNode; 13155 } 13156 13157 return null; 13158} 13159/** 13160 * Given a DOM node, return the ReactDOMComponent or ReactDOMTextComponent 13161 * instance, or null if the node was not rendered by this React. 13162 */ 13163 13164function getInstanceFromNode(node) { 13165 var inst = node[internalInstanceKey] || node[internalContainerInstanceKey]; 13166 13167 if (inst) { 13168 if (inst.tag === HostComponent || inst.tag === HostText || inst.tag === SuspenseComponent || inst.tag === HostRoot) { 13169 return inst; 13170 } else { 13171 return null; 13172 } 13173 } 13174 13175 return null; 13176} 13177/** 13178 * Given a ReactDOMComponent or ReactDOMTextComponent, return the corresponding 13179 * DOM node. 13180 */ 13181 13182function getNodeFromInstance(inst) { 13183 if (inst.tag === HostComponent || inst.tag === HostText) { 13184 // In Fiber this, is just the state node right now. We assume it will be 13185 // a host component or host text. 13186 return inst.stateNode; 13187 } // Without this first invariant, passing a non-DOM-component triggers the next 13188 // invariant for a missing parent, which is super confusing. 13189 13190 13191 { 13192 { 13193 throw Error( "getNodeFromInstance: Invalid argument." ); 13194 } 13195 } 13196} 13197function getFiberCurrentPropsFromNode(node) { 13198 return node[internalPropsKey] || null; 13199} 13200function updateFiberProps(node, props) { 13201 node[internalPropsKey] = props; 13202} 13203function getEventListenerSet(node) { 13204 var elementListenerSet = node[internalEventHandlersKey]; 13205 13206 if (elementListenerSet === undefined) { 13207 elementListenerSet = node[internalEventHandlersKey] = new Set(); 13208 } 13209 13210 return elementListenerSet; 13211} 13212 13213var loggedTypeFailures = {}; 13214var ReactDebugCurrentFrame$1 = ReactSharedInternals.ReactDebugCurrentFrame; 13215 13216function setCurrentlyValidatingElement(element) { 13217 { 13218 if (element) { 13219 var owner = element._owner; 13220 var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null); 13221 ReactDebugCurrentFrame$1.setExtraStackFrame(stack); 13222 } else { 13223 ReactDebugCurrentFrame$1.setExtraStackFrame(null); 13224 } 13225 } 13226} 13227 13228function checkPropTypes(typeSpecs, values, location, componentName, element) { 13229 { 13230 // $FlowFixMe This is okay but Flow doesn't know it. 13231 var has = Function.call.bind(Object.prototype.hasOwnProperty); 13232 13233 for (var typeSpecName in typeSpecs) { 13234 if (has(typeSpecs, typeSpecName)) { 13235 var error$1 = void 0; // Prop type validation may throw. In case they do, we don't want to 13236 // fail the render phase where it didn't fail before. So we log it. 13237 // After these have been cleaned up, we'll let them throw. 13238 13239 try { 13240 // This is intentionally an invariant that gets caught. It's the same 13241 // behavior as without this statement except with a better message. 13242 if (typeof typeSpecs[typeSpecName] !== 'function') { 13243 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`.'); 13244 err.name = 'Invariant Violation'; 13245 throw err; 13246 } 13247 13248 error$1 = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED'); 13249 } catch (ex) { 13250 error$1 = ex; 13251 } 13252 13253 if (error$1 && !(error$1 instanceof Error)) { 13254 setCurrentlyValidatingElement(element); 13255 13256 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); 13257 13258 setCurrentlyValidatingElement(null); 13259 } 13260 13261 if (error$1 instanceof Error && !(error$1.message in loggedTypeFailures)) { 13262 // Only monitor this failure once because there tends to be a lot of the 13263 // same error. 13264 loggedTypeFailures[error$1.message] = true; 13265 setCurrentlyValidatingElement(element); 13266 13267 error('Failed %s type: %s', location, error$1.message); 13268 13269 setCurrentlyValidatingElement(null); 13270 } 13271 } 13272 } 13273 } 13274} 13275 13276var valueStack = []; 13277var fiberStack; 13278 13279{ 13280 fiberStack = []; 13281} 13282 13283var index = -1; 13284 13285function createCursor(defaultValue) { 13286 return { 13287 current: defaultValue 13288 }; 13289} 13290 13291function pop(cursor, fiber) { 13292 if (index < 0) { 13293 { 13294 error('Unexpected pop.'); 13295 } 13296 13297 return; 13298 } 13299 13300 { 13301 if (fiber !== fiberStack[index]) { 13302 error('Unexpected Fiber popped.'); 13303 } 13304 } 13305 13306 cursor.current = valueStack[index]; 13307 valueStack[index] = null; 13308 13309 { 13310 fiberStack[index] = null; 13311 } 13312 13313 index--; 13314} 13315 13316function push(cursor, value, fiber) { 13317 index++; 13318 valueStack[index] = cursor.current; 13319 13320 { 13321 fiberStack[index] = fiber; 13322 } 13323 13324 cursor.current = value; 13325} 13326 13327var warnedAboutMissingGetChildContext; 13328 13329{ 13330 warnedAboutMissingGetChildContext = {}; 13331} 13332 13333var emptyContextObject = {}; 13334 13335{ 13336 Object.freeze(emptyContextObject); 13337} // A cursor to the current merged context object on the stack. 13338 13339 13340var contextStackCursor = createCursor(emptyContextObject); // A cursor to a boolean indicating whether the context has changed. 13341 13342var didPerformWorkStackCursor = createCursor(false); // Keep track of the previous context object that was on the stack. 13343// We use this to get access to the parent context after we have already 13344// pushed the next context provider, and now need to merge their contexts. 13345 13346var previousContext = emptyContextObject; 13347 13348function getUnmaskedContext(workInProgress, Component, didPushOwnContextIfProvider) { 13349 { 13350 if (didPushOwnContextIfProvider && isContextProvider(Component)) { 13351 // If the fiber is a context provider itself, when we read its context 13352 // we may have already pushed its own child context on the stack. A context 13353 // provider should not "see" its own child context. Therefore we read the 13354 // previous (parent) context instead for a context provider. 13355 return previousContext; 13356 } 13357 13358 return contextStackCursor.current; 13359 } 13360} 13361 13362function cacheContext(workInProgress, unmaskedContext, maskedContext) { 13363 { 13364 var instance = workInProgress.stateNode; 13365 instance.__reactInternalMemoizedUnmaskedChildContext = unmaskedContext; 13366 instance.__reactInternalMemoizedMaskedChildContext = maskedContext; 13367 } 13368} 13369 13370function getMaskedContext(workInProgress, unmaskedContext) { 13371 { 13372 var type = workInProgress.type; 13373 var contextTypes = type.contextTypes; 13374 13375 if (!contextTypes) { 13376 return emptyContextObject; 13377 } // Avoid recreating masked context unless unmasked context has changed. 13378 // Failing to do this will result in unnecessary calls to componentWillReceiveProps. 13379 // This may trigger infinite loops if componentWillReceiveProps calls setState. 13380 13381 13382 var instance = workInProgress.stateNode; 13383 13384 if (instance && instance.__reactInternalMemoizedUnmaskedChildContext === unmaskedContext) { 13385 return instance.__reactInternalMemoizedMaskedChildContext; 13386 } 13387 13388 var context = {}; 13389 13390 for (var key in contextTypes) { 13391 context[key] = unmaskedContext[key]; 13392 } 13393 13394 { 13395 var name = getComponentName(type) || 'Unknown'; 13396 checkPropTypes(contextTypes, context, 'context', name); 13397 } // Cache unmasked context so we can avoid recreating masked context unless necessary. 13398 // Context is created before the class component is instantiated so check for instance. 13399 13400 13401 if (instance) { 13402 cacheContext(workInProgress, unmaskedContext, context); 13403 } 13404 13405 return context; 13406 } 13407} 13408 13409function hasContextChanged() { 13410 { 13411 return didPerformWorkStackCursor.current; 13412 } 13413} 13414 13415function isContextProvider(type) { 13416 { 13417 var childContextTypes = type.childContextTypes; 13418 return childContextTypes !== null && childContextTypes !== undefined; 13419 } 13420} 13421 13422function popContext(fiber) { 13423 { 13424 pop(didPerformWorkStackCursor, fiber); 13425 pop(contextStackCursor, fiber); 13426 } 13427} 13428 13429function popTopLevelContextObject(fiber) { 13430 { 13431 pop(didPerformWorkStackCursor, fiber); 13432 pop(contextStackCursor, fiber); 13433 } 13434} 13435 13436function pushTopLevelContextObject(fiber, context, didChange) { 13437 { 13438 if (!(contextStackCursor.current === emptyContextObject)) { 13439 { 13440 throw Error( "Unexpected context found on stack. This error is likely caused by a bug in React. Please file an issue." ); 13441 } 13442 } 13443 13444 push(contextStackCursor, context, fiber); 13445 push(didPerformWorkStackCursor, didChange, fiber); 13446 } 13447} 13448 13449function processChildContext(fiber, type, parentContext) { 13450 { 13451 var instance = fiber.stateNode; 13452 var childContextTypes = type.childContextTypes; // TODO (bvaughn) Replace this behavior with an invariant() in the future. 13453 // It has only been added in Fiber to match the (unintentional) behavior in Stack. 13454 13455 if (typeof instance.getChildContext !== 'function') { 13456 { 13457 var componentName = getComponentName(type) || 'Unknown'; 13458 13459 if (!warnedAboutMissingGetChildContext[componentName]) { 13460 warnedAboutMissingGetChildContext[componentName] = true; 13461 13462 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); 13463 } 13464 } 13465 13466 return parentContext; 13467 } 13468 13469 var childContext = instance.getChildContext(); 13470 13471 for (var contextKey in childContext) { 13472 if (!(contextKey in childContextTypes)) { 13473 { 13474 throw Error( (getComponentName(type) || 'Unknown') + ".getChildContext(): key \"" + contextKey + "\" is not defined in childContextTypes." ); 13475 } 13476 } 13477 } 13478 13479 { 13480 var name = getComponentName(type) || 'Unknown'; 13481 checkPropTypes(childContextTypes, childContext, 'child context', name); 13482 } 13483 13484 return _assign({}, parentContext, childContext); 13485 } 13486} 13487 13488function pushContextProvider(workInProgress) { 13489 { 13490 var instance = workInProgress.stateNode; // We push the context as early as possible to ensure stack integrity. 13491 // If the instance does not exist yet, we will push null at first, 13492 // and replace it on the stack later when invalidating the context. 13493 13494 var memoizedMergedChildContext = instance && instance.__reactInternalMemoizedMergedChildContext || emptyContextObject; // Remember the parent context so we can merge with it later. 13495 // Inherit the parent's did-perform-work value to avoid inadvertently blocking updates. 13496 13497 previousContext = contextStackCursor.current; 13498 push(contextStackCursor, memoizedMergedChildContext, workInProgress); 13499 push(didPerformWorkStackCursor, didPerformWorkStackCursor.current, workInProgress); 13500 return true; 13501 } 13502} 13503 13504function invalidateContextProvider(workInProgress, type, didChange) { 13505 { 13506 var instance = workInProgress.stateNode; 13507 13508 if (!instance) { 13509 { 13510 throw Error( "Expected to have an instance by this point. This error is likely caused by a bug in React. Please file an issue." ); 13511 } 13512 } 13513 13514 if (didChange) { 13515 // Merge parent and own context. 13516 // Skip this if we're not updating due to sCU. 13517 // This avoids unnecessarily recomputing memoized values. 13518 var mergedContext = processChildContext(workInProgress, type, previousContext); 13519 instance.__reactInternalMemoizedMergedChildContext = mergedContext; // Replace the old (or empty) context with the new one. 13520 // It is important to unwind the context in the reverse order. 13521 13522 pop(didPerformWorkStackCursor, workInProgress); 13523 pop(contextStackCursor, workInProgress); // Now push the new context and mark that it has changed. 13524 13525 push(contextStackCursor, mergedContext, workInProgress); 13526 push(didPerformWorkStackCursor, didChange, workInProgress); 13527 } else { 13528 pop(didPerformWorkStackCursor, workInProgress); 13529 push(didPerformWorkStackCursor, didChange, workInProgress); 13530 } 13531 } 13532} 13533 13534function findCurrentUnmaskedContext(fiber) { 13535 { 13536 // Currently this is only used with renderSubtreeIntoContainer; not sure if it 13537 // makes sense elsewhere 13538 if (!(isFiberMounted(fiber) && fiber.tag === ClassComponent)) { 13539 { 13540 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." ); 13541 } 13542 } 13543 13544 var node = fiber; 13545 13546 do { 13547 switch (node.tag) { 13548 case HostRoot: 13549 return node.stateNode.context; 13550 13551 case ClassComponent: 13552 { 13553 var Component = node.type; 13554 13555 if (isContextProvider(Component)) { 13556 return node.stateNode.__reactInternalMemoizedMergedChildContext; 13557 } 13558 13559 break; 13560 } 13561 } 13562 13563 node = node.return; 13564 } while (node !== null); 13565 13566 { 13567 { 13568 throw Error( "Found unexpected detached subtree parent. This error is likely caused by a bug in React. Please file an issue." ); 13569 } 13570 } 13571 } 13572} 13573 13574var LegacyRoot = 0; 13575var BlockingRoot = 1; 13576var ConcurrentRoot = 2; 13577 13578var rendererID = null; 13579var injectedHook = null; 13580var hasLoggedError = false; 13581var isDevToolsPresent = typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined'; 13582function injectInternals(internals) { 13583 if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ === 'undefined') { 13584 // No DevTools 13585 return false; 13586 } 13587 13588 var hook = __REACT_DEVTOOLS_GLOBAL_HOOK__; 13589 13590 if (hook.isDisabled) { 13591 // This isn't a real property on the hook, but it can be set to opt out 13592 // of DevTools integration and associated warnings and logs. 13593 // https://github.com/facebook/react/issues/3877 13594 return true; 13595 } 13596 13597 if (!hook.supportsFiber) { 13598 { 13599 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'); 13600 } // DevTools exists, even though it doesn't support Fiber. 13601 13602 13603 return true; 13604 } 13605 13606 try { 13607 rendererID = hook.inject(internals); // We have successfully injected, so now it is safe to set up hooks. 13608 13609 injectedHook = hook; 13610 } catch (err) { 13611 // Catch all errors because it is unsafe to throw during initialization. 13612 { 13613 error('React instrumentation encountered an error: %s.', err); 13614 } 13615 } // DevTools exists 13616 13617 13618 return true; 13619} 13620function onScheduleRoot(root, children) { 13621 { 13622 if (injectedHook && typeof injectedHook.onScheduleFiberRoot === 'function') { 13623 try { 13624 injectedHook.onScheduleFiberRoot(rendererID, root, children); 13625 } catch (err) { 13626 if ( !hasLoggedError) { 13627 hasLoggedError = true; 13628 13629 error('React instrumentation encountered an error: %s', err); 13630 } 13631 } 13632 } 13633 } 13634} 13635function onCommitRoot(root, priorityLevel) { 13636 if (injectedHook && typeof injectedHook.onCommitFiberRoot === 'function') { 13637 try { 13638 var didError = (root.current.flags & DidCapture) === DidCapture; 13639 13640 if (enableProfilerTimer) { 13641 injectedHook.onCommitFiberRoot(rendererID, root, priorityLevel, didError); 13642 } else { 13643 injectedHook.onCommitFiberRoot(rendererID, root, undefined, didError); 13644 } 13645 } catch (err) { 13646 { 13647 if (!hasLoggedError) { 13648 hasLoggedError = true; 13649 13650 error('React instrumentation encountered an error: %s', err); 13651 } 13652 } 13653 } 13654 } 13655} 13656function onCommitUnmount(fiber) { 13657 if (injectedHook && typeof injectedHook.onCommitFiberUnmount === 'function') { 13658 try { 13659 injectedHook.onCommitFiberUnmount(rendererID, fiber); 13660 } catch (err) { 13661 { 13662 if (!hasLoggedError) { 13663 hasLoggedError = true; 13664 13665 error('React instrumentation encountered an error: %s', err); 13666 } 13667 } 13668 } 13669 } 13670} 13671 13672var Scheduler_runWithPriority = Scheduler.unstable_runWithPriority, 13673 Scheduler_scheduleCallback = Scheduler.unstable_scheduleCallback, 13674 Scheduler_cancelCallback = Scheduler.unstable_cancelCallback, 13675 Scheduler_shouldYield = Scheduler.unstable_shouldYield, 13676 Scheduler_requestPaint = Scheduler.unstable_requestPaint, 13677 Scheduler_now$1 = Scheduler.unstable_now, 13678 Scheduler_getCurrentPriorityLevel = Scheduler.unstable_getCurrentPriorityLevel, 13679 Scheduler_ImmediatePriority = Scheduler.unstable_ImmediatePriority, 13680 Scheduler_UserBlockingPriority = Scheduler.unstable_UserBlockingPriority, 13681 Scheduler_NormalPriority = Scheduler.unstable_NormalPriority, 13682 Scheduler_LowPriority = Scheduler.unstable_LowPriority, 13683 Scheduler_IdlePriority = Scheduler.unstable_IdlePriority; 13684 13685{ 13686 // Provide explicit error message when production+profiling bundle of e.g. 13687 // react-dom is used with production (non-profiling) bundle of 13688 // scheduler/tracing 13689 if (!(tracing.__interactionsRef != null && tracing.__interactionsRef.current != null)) { 13690 { 13691 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" ); 13692 } 13693 } 13694} 13695 13696var fakeCallbackNode = {}; // Except for NoPriority, these correspond to Scheduler priorities. We use 13697// ascending numbers so we can compare them like numbers. They start at 90 to 13698// avoid clashing with Scheduler's priorities. 13699 13700var ImmediatePriority$1 = 99; 13701var UserBlockingPriority$2 = 98; 13702var NormalPriority$1 = 97; 13703var LowPriority$1 = 96; 13704var IdlePriority$1 = 95; // NoPriority is the absence of priority. Also React-only. 13705 13706var NoPriority$1 = 90; 13707var shouldYield = Scheduler_shouldYield; 13708var requestPaint = // Fall back gracefully if we're running an older version of Scheduler. 13709Scheduler_requestPaint !== undefined ? Scheduler_requestPaint : function () {}; 13710var syncQueue = null; 13711var immediateQueueCallbackNode = null; 13712var isFlushingSyncQueue = false; 13713var initialTimeMs$1 = Scheduler_now$1(); // If the initial timestamp is reasonably small, use Scheduler's `now` directly. 13714// This will be the case for modern browsers that support `performance.now`. In 13715// older browsers, Scheduler falls back to `Date.now`, which returns a Unix 13716// timestamp. In that case, subtract the module initialization time to simulate 13717// the behavior of performance.now and keep our times small enough to fit 13718// within 32 bits. 13719// TODO: Consider lifting this into Scheduler. 13720 13721var now = initialTimeMs$1 < 10000 ? Scheduler_now$1 : function () { 13722 return Scheduler_now$1() - initialTimeMs$1; 13723}; 13724function getCurrentPriorityLevel() { 13725 switch (Scheduler_getCurrentPriorityLevel()) { 13726 case Scheduler_ImmediatePriority: 13727 return ImmediatePriority$1; 13728 13729 case Scheduler_UserBlockingPriority: 13730 return UserBlockingPriority$2; 13731 13732 case Scheduler_NormalPriority: 13733 return NormalPriority$1; 13734 13735 case Scheduler_LowPriority: 13736 return LowPriority$1; 13737 13738 case Scheduler_IdlePriority: 13739 return IdlePriority$1; 13740 13741 default: 13742 { 13743 { 13744 throw Error( "Unknown priority level." ); 13745 } 13746 } 13747 13748 } 13749} 13750 13751function reactPriorityToSchedulerPriority(reactPriorityLevel) { 13752 switch (reactPriorityLevel) { 13753 case ImmediatePriority$1: 13754 return Scheduler_ImmediatePriority; 13755 13756 case UserBlockingPriority$2: 13757 return Scheduler_UserBlockingPriority; 13758 13759 case NormalPriority$1: 13760 return Scheduler_NormalPriority; 13761 13762 case LowPriority$1: 13763 return Scheduler_LowPriority; 13764 13765 case IdlePriority$1: 13766 return Scheduler_IdlePriority; 13767 13768 default: 13769 { 13770 { 13771 throw Error( "Unknown priority level." ); 13772 } 13773 } 13774 13775 } 13776} 13777 13778function runWithPriority$1(reactPriorityLevel, fn) { 13779 var priorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel); 13780 return Scheduler_runWithPriority(priorityLevel, fn); 13781} 13782function scheduleCallback(reactPriorityLevel, callback, options) { 13783 var priorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel); 13784 return Scheduler_scheduleCallback(priorityLevel, callback, options); 13785} 13786function scheduleSyncCallback(callback) { 13787 // Push this callback into an internal queue. We'll flush these either in 13788 // the next tick, or earlier if something calls `flushSyncCallbackQueue`. 13789 if (syncQueue === null) { 13790 syncQueue = [callback]; // Flush the queue in the next tick, at the earliest. 13791 13792 immediateQueueCallbackNode = Scheduler_scheduleCallback(Scheduler_ImmediatePriority, flushSyncCallbackQueueImpl); 13793 } else { 13794 // Push onto existing queue. Don't need to schedule a callback because 13795 // we already scheduled one when we created the queue. 13796 syncQueue.push(callback); 13797 } 13798 13799 return fakeCallbackNode; 13800} 13801function cancelCallback(callbackNode) { 13802 if (callbackNode !== fakeCallbackNode) { 13803 Scheduler_cancelCallback(callbackNode); 13804 } 13805} 13806function flushSyncCallbackQueue() { 13807 if (immediateQueueCallbackNode !== null) { 13808 var node = immediateQueueCallbackNode; 13809 immediateQueueCallbackNode = null; 13810 Scheduler_cancelCallback(node); 13811 } 13812 13813 flushSyncCallbackQueueImpl(); 13814} 13815 13816function flushSyncCallbackQueueImpl() { 13817 if (!isFlushingSyncQueue && syncQueue !== null) { 13818 // Prevent re-entrancy. 13819 isFlushingSyncQueue = true; 13820 var i = 0; 13821 13822 { 13823 try { 13824 var _isSync2 = true; 13825 var _queue = syncQueue; 13826 runWithPriority$1(ImmediatePriority$1, function () { 13827 for (; i < _queue.length; i++) { 13828 var callback = _queue[i]; 13829 13830 do { 13831 callback = callback(_isSync2); 13832 } while (callback !== null); 13833 } 13834 }); 13835 syncQueue = null; 13836 } catch (error) { 13837 // If something throws, leave the remaining callbacks on the queue. 13838 if (syncQueue !== null) { 13839 syncQueue = syncQueue.slice(i + 1); 13840 } // Resume flushing in the next tick 13841 13842 13843 Scheduler_scheduleCallback(Scheduler_ImmediatePriority, flushSyncCallbackQueue); 13844 throw error; 13845 } finally { 13846 isFlushingSyncQueue = false; 13847 } 13848 } 13849 } 13850} 13851 13852// TODO: this is special because it gets imported during build. 13853var ReactVersion = '17.0.2'; 13854 13855var NoMode = 0; 13856var StrictMode = 1; // TODO: Remove BlockingMode and ConcurrentMode by reading from the root 13857// tag instead 13858 13859var BlockingMode = 2; 13860var ConcurrentMode = 4; 13861var ProfileMode = 8; 13862var DebugTracingMode = 16; 13863 13864var ReactCurrentBatchConfig = ReactSharedInternals.ReactCurrentBatchConfig; 13865var NoTransition = 0; 13866function requestCurrentTransition() { 13867 return ReactCurrentBatchConfig.transition; 13868} 13869 13870var ReactStrictModeWarnings = { 13871 recordUnsafeLifecycleWarnings: function (fiber, instance) {}, 13872 flushPendingUnsafeLifecycleWarnings: function () {}, 13873 recordLegacyContextWarning: function (fiber, instance) {}, 13874 flushLegacyContextWarning: function () {}, 13875 discardPendingWarnings: function () {} 13876}; 13877 13878{ 13879 var findStrictRoot = function (fiber) { 13880 var maybeStrictRoot = null; 13881 var node = fiber; 13882 13883 while (node !== null) { 13884 if (node.mode & StrictMode) { 13885 maybeStrictRoot = node; 13886 } 13887 13888 node = node.return; 13889 } 13890 13891 return maybeStrictRoot; 13892 }; 13893 13894 var setToSortedString = function (set) { 13895 var array = []; 13896 set.forEach(function (value) { 13897 array.push(value); 13898 }); 13899 return array.sort().join(', '); 13900 }; 13901 13902 var pendingComponentWillMountWarnings = []; 13903 var pendingUNSAFE_ComponentWillMountWarnings = []; 13904 var pendingComponentWillReceivePropsWarnings = []; 13905 var pendingUNSAFE_ComponentWillReceivePropsWarnings = []; 13906 var pendingComponentWillUpdateWarnings = []; 13907 var pendingUNSAFE_ComponentWillUpdateWarnings = []; // Tracks components we have already warned about. 13908 13909 var didWarnAboutUnsafeLifecycles = new Set(); 13910 13911 ReactStrictModeWarnings.recordUnsafeLifecycleWarnings = function (fiber, instance) { 13912 // Dedup strategy: Warn once per component. 13913 if (didWarnAboutUnsafeLifecycles.has(fiber.type)) { 13914 return; 13915 } 13916 13917 if (typeof instance.componentWillMount === 'function' && // Don't warn about react-lifecycles-compat polyfilled components. 13918 instance.componentWillMount.__suppressDeprecationWarning !== true) { 13919 pendingComponentWillMountWarnings.push(fiber); 13920 } 13921 13922 if (fiber.mode & StrictMode && typeof instance.UNSAFE_componentWillMount === 'function') { 13923 pendingUNSAFE_ComponentWillMountWarnings.push(fiber); 13924 } 13925 13926 if (typeof instance.componentWillReceiveProps === 'function' && instance.componentWillReceiveProps.__suppressDeprecationWarning !== true) { 13927 pendingComponentWillReceivePropsWarnings.push(fiber); 13928 } 13929 13930 if (fiber.mode & StrictMode && typeof instance.UNSAFE_componentWillReceiveProps === 'function') { 13931 pendingUNSAFE_ComponentWillReceivePropsWarnings.push(fiber); 13932 } 13933 13934 if (typeof instance.componentWillUpdate === 'function' && instance.componentWillUpdate.__suppressDeprecationWarning !== true) { 13935 pendingComponentWillUpdateWarnings.push(fiber); 13936 } 13937 13938 if (fiber.mode & StrictMode && typeof instance.UNSAFE_componentWillUpdate === 'function') { 13939 pendingUNSAFE_ComponentWillUpdateWarnings.push(fiber); 13940 } 13941 }; 13942 13943 ReactStrictModeWarnings.flushPendingUnsafeLifecycleWarnings = function () { 13944 // We do an initial pass to gather component names 13945 var componentWillMountUniqueNames = new Set(); 13946 13947 if (pendingComponentWillMountWarnings.length > 0) { 13948 pendingComponentWillMountWarnings.forEach(function (fiber) { 13949 componentWillMountUniqueNames.add(getComponentName(fiber.type) || 'Component'); 13950 didWarnAboutUnsafeLifecycles.add(fiber.type); 13951 }); 13952 pendingComponentWillMountWarnings = []; 13953 } 13954 13955 var UNSAFE_componentWillMountUniqueNames = new Set(); 13956 13957 if (pendingUNSAFE_ComponentWillMountWarnings.length > 0) { 13958 pendingUNSAFE_ComponentWillMountWarnings.forEach(function (fiber) { 13959 UNSAFE_componentWillMountUniqueNames.add(getComponentName(fiber.type) || 'Component'); 13960 didWarnAboutUnsafeLifecycles.add(fiber.type); 13961 }); 13962 pendingUNSAFE_ComponentWillMountWarnings = []; 13963 } 13964 13965 var componentWillReceivePropsUniqueNames = new Set(); 13966 13967 if (pendingComponentWillReceivePropsWarnings.length > 0) { 13968 pendingComponentWillReceivePropsWarnings.forEach(function (fiber) { 13969 componentWillReceivePropsUniqueNames.add(getComponentName(fiber.type) || 'Component'); 13970 didWarnAboutUnsafeLifecycles.add(fiber.type); 13971 }); 13972 pendingComponentWillReceivePropsWarnings = []; 13973 } 13974 13975 var UNSAFE_componentWillReceivePropsUniqueNames = new Set(); 13976 13977 if (pendingUNSAFE_ComponentWillReceivePropsWarnings.length > 0) { 13978 pendingUNSAFE_ComponentWillReceivePropsWarnings.forEach(function (fiber) { 13979 UNSAFE_componentWillReceivePropsUniqueNames.add(getComponentName(fiber.type) || 'Component'); 13980 didWarnAboutUnsafeLifecycles.add(fiber.type); 13981 }); 13982 pendingUNSAFE_ComponentWillReceivePropsWarnings = []; 13983 } 13984 13985 var componentWillUpdateUniqueNames = new Set(); 13986 13987 if (pendingComponentWillUpdateWarnings.length > 0) { 13988 pendingComponentWillUpdateWarnings.forEach(function (fiber) { 13989 componentWillUpdateUniqueNames.add(getComponentName(fiber.type) || 'Component'); 13990 didWarnAboutUnsafeLifecycles.add(fiber.type); 13991 }); 13992 pendingComponentWillUpdateWarnings = []; 13993 } 13994 13995 var UNSAFE_componentWillUpdateUniqueNames = new Set(); 13996 13997 if (pendingUNSAFE_ComponentWillUpdateWarnings.length > 0) { 13998 pendingUNSAFE_ComponentWillUpdateWarnings.forEach(function (fiber) { 13999 UNSAFE_componentWillUpdateUniqueNames.add(getComponentName(fiber.type) || 'Component'); 14000 didWarnAboutUnsafeLifecycles.add(fiber.type); 14001 }); 14002 pendingUNSAFE_ComponentWillUpdateWarnings = []; 14003 } // Finally, we flush all the warnings 14004 // UNSAFE_ ones before the deprecated ones, since they'll be 'louder' 14005 14006 14007 if (UNSAFE_componentWillMountUniqueNames.size > 0) { 14008 var sortedNames = setToSortedString(UNSAFE_componentWillMountUniqueNames); 14009 14010 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); 14011 } 14012 14013 if (UNSAFE_componentWillReceivePropsUniqueNames.size > 0) { 14014 var _sortedNames = setToSortedString(UNSAFE_componentWillReceivePropsUniqueNames); 14015 14016 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); 14017 } 14018 14019 if (UNSAFE_componentWillUpdateUniqueNames.size > 0) { 14020 var _sortedNames2 = setToSortedString(UNSAFE_componentWillUpdateUniqueNames); 14021 14022 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); 14023 } 14024 14025 if (componentWillMountUniqueNames.size > 0) { 14026 var _sortedNames3 = setToSortedString(componentWillMountUniqueNames); 14027 14028 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); 14029 } 14030 14031 if (componentWillReceivePropsUniqueNames.size > 0) { 14032 var _sortedNames4 = setToSortedString(componentWillReceivePropsUniqueNames); 14033 14034 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); 14035 } 14036 14037 if (componentWillUpdateUniqueNames.size > 0) { 14038 var _sortedNames5 = setToSortedString(componentWillUpdateUniqueNames); 14039 14040 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); 14041 } 14042 }; 14043 14044 var pendingLegacyContextWarning = new Map(); // Tracks components we have already warned about. 14045 14046 var didWarnAboutLegacyContext = new Set(); 14047 14048 ReactStrictModeWarnings.recordLegacyContextWarning = function (fiber, instance) { 14049 var strictRoot = findStrictRoot(fiber); 14050 14051 if (strictRoot === null) { 14052 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.'); 14053 14054 return; 14055 } // Dedup strategy: Warn once per component. 14056 14057 14058 if (didWarnAboutLegacyContext.has(fiber.type)) { 14059 return; 14060 } 14061 14062 var warningsForRoot = pendingLegacyContextWarning.get(strictRoot); 14063 14064 if (fiber.type.contextTypes != null || fiber.type.childContextTypes != null || instance !== null && typeof instance.getChildContext === 'function') { 14065 if (warningsForRoot === undefined) { 14066 warningsForRoot = []; 14067 pendingLegacyContextWarning.set(strictRoot, warningsForRoot); 14068 } 14069 14070 warningsForRoot.push(fiber); 14071 } 14072 }; 14073 14074 ReactStrictModeWarnings.flushLegacyContextWarning = function () { 14075 pendingLegacyContextWarning.forEach(function (fiberArray, strictRoot) { 14076 if (fiberArray.length === 0) { 14077 return; 14078 } 14079 14080 var firstFiber = fiberArray[0]; 14081 var uniqueNames = new Set(); 14082 fiberArray.forEach(function (fiber) { 14083 uniqueNames.add(getComponentName(fiber.type) || 'Component'); 14084 didWarnAboutLegacyContext.add(fiber.type); 14085 }); 14086 var sortedNames = setToSortedString(uniqueNames); 14087 14088 try { 14089 setCurrentFiber(firstFiber); 14090 14091 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); 14092 } finally { 14093 resetCurrentFiber(); 14094 } 14095 }); 14096 }; 14097 14098 ReactStrictModeWarnings.discardPendingWarnings = function () { 14099 pendingComponentWillMountWarnings = []; 14100 pendingUNSAFE_ComponentWillMountWarnings = []; 14101 pendingComponentWillReceivePropsWarnings = []; 14102 pendingUNSAFE_ComponentWillReceivePropsWarnings = []; 14103 pendingComponentWillUpdateWarnings = []; 14104 pendingUNSAFE_ComponentWillUpdateWarnings = []; 14105 pendingLegacyContextWarning = new Map(); 14106 }; 14107} 14108 14109function resolveDefaultProps(Component, baseProps) { 14110 if (Component && Component.defaultProps) { 14111 // Resolve default props. Taken from ReactElement 14112 var props = _assign({}, baseProps); 14113 14114 var defaultProps = Component.defaultProps; 14115 14116 for (var propName in defaultProps) { 14117 if (props[propName] === undefined) { 14118 props[propName] = defaultProps[propName]; 14119 } 14120 } 14121 14122 return props; 14123 } 14124 14125 return baseProps; 14126} 14127 14128// Max 31 bit integer. The max integer size in V8 for 32-bit systems. 14129// Math.pow(2, 30) - 1 14130// 0b111111111111111111111111111111 14131var MAX_SIGNED_31_BIT_INT = 1073741823; 14132 14133var valueCursor = createCursor(null); 14134var rendererSigil; 14135 14136{ 14137 // Use this to detect multiple renderers using the same context 14138 rendererSigil = {}; 14139} 14140 14141var currentlyRenderingFiber = null; 14142var lastContextDependency = null; 14143var lastContextWithAllBitsObserved = null; 14144var isDisallowedContextReadInDEV = false; 14145function resetContextDependencies() { 14146 // This is called right before React yields execution, to ensure `readContext` 14147 // cannot be called outside the render phase. 14148 currentlyRenderingFiber = null; 14149 lastContextDependency = null; 14150 lastContextWithAllBitsObserved = null; 14151 14152 { 14153 isDisallowedContextReadInDEV = false; 14154 } 14155} 14156function enterDisallowedContextReadInDEV() { 14157 { 14158 isDisallowedContextReadInDEV = true; 14159 } 14160} 14161function exitDisallowedContextReadInDEV() { 14162 { 14163 isDisallowedContextReadInDEV = false; 14164 } 14165} 14166function pushProvider(providerFiber, nextValue) { 14167 var context = providerFiber.type._context; 14168 14169 { 14170 push(valueCursor, context._currentValue, providerFiber); 14171 context._currentValue = nextValue; 14172 14173 { 14174 if (context._currentRenderer !== undefined && context._currentRenderer !== null && context._currentRenderer !== rendererSigil) { 14175 error('Detected multiple renderers concurrently rendering the ' + 'same context provider. This is currently unsupported.'); 14176 } 14177 14178 context._currentRenderer = rendererSigil; 14179 } 14180 } 14181} 14182function popProvider(providerFiber) { 14183 var currentValue = valueCursor.current; 14184 pop(valueCursor, providerFiber); 14185 var context = providerFiber.type._context; 14186 14187 { 14188 context._currentValue = currentValue; 14189 } 14190} 14191function calculateChangedBits(context, newValue, oldValue) { 14192 if (objectIs(oldValue, newValue)) { 14193 // No change 14194 return 0; 14195 } else { 14196 var changedBits = typeof context._calculateChangedBits === 'function' ? context._calculateChangedBits(oldValue, newValue) : MAX_SIGNED_31_BIT_INT; 14197 14198 { 14199 if ((changedBits & MAX_SIGNED_31_BIT_INT) !== changedBits) { 14200 error('calculateChangedBits: Expected the return value to be a ' + '31-bit integer. Instead received: %s', changedBits); 14201 } 14202 } 14203 14204 return changedBits | 0; 14205 } 14206} 14207function scheduleWorkOnParentPath(parent, renderLanes) { 14208 // Update the child lanes of all the ancestors, including the alternates. 14209 var node = parent; 14210 14211 while (node !== null) { 14212 var alternate = node.alternate; 14213 14214 if (!isSubsetOfLanes(node.childLanes, renderLanes)) { 14215 node.childLanes = mergeLanes(node.childLanes, renderLanes); 14216 14217 if (alternate !== null) { 14218 alternate.childLanes = mergeLanes(alternate.childLanes, renderLanes); 14219 } 14220 } else if (alternate !== null && !isSubsetOfLanes(alternate.childLanes, renderLanes)) { 14221 alternate.childLanes = mergeLanes(alternate.childLanes, renderLanes); 14222 } else { 14223 // Neither alternate was updated, which means the rest of the 14224 // ancestor path already has sufficient priority. 14225 break; 14226 } 14227 14228 node = node.return; 14229 } 14230} 14231function propagateContextChange(workInProgress, context, changedBits, renderLanes) { 14232 var fiber = workInProgress.child; 14233 14234 if (fiber !== null) { 14235 // Set the return pointer of the child to the work-in-progress fiber. 14236 fiber.return = workInProgress; 14237 } 14238 14239 while (fiber !== null) { 14240 var nextFiber = void 0; // Visit this fiber. 14241 14242 var list = fiber.dependencies; 14243 14244 if (list !== null) { 14245 nextFiber = fiber.child; 14246 var dependency = list.firstContext; 14247 14248 while (dependency !== null) { 14249 // Check if the context matches. 14250 if (dependency.context === context && (dependency.observedBits & changedBits) !== 0) { 14251 // Match! Schedule an update on this fiber. 14252 if (fiber.tag === ClassComponent) { 14253 // Schedule a force update on the work-in-progress. 14254 var update = createUpdate(NoTimestamp, pickArbitraryLane(renderLanes)); 14255 update.tag = ForceUpdate; // TODO: Because we don't have a work-in-progress, this will add the 14256 // update to the current fiber, too, which means it will persist even if 14257 // this render is thrown away. Since it's a race condition, not sure it's 14258 // worth fixing. 14259 14260 enqueueUpdate(fiber, update); 14261 } 14262 14263 fiber.lanes = mergeLanes(fiber.lanes, renderLanes); 14264 var alternate = fiber.alternate; 14265 14266 if (alternate !== null) { 14267 alternate.lanes = mergeLanes(alternate.lanes, renderLanes); 14268 } 14269 14270 scheduleWorkOnParentPath(fiber.return, renderLanes); // Mark the updated lanes on the list, too. 14271 14272 list.lanes = mergeLanes(list.lanes, renderLanes); // Since we already found a match, we can stop traversing the 14273 // dependency list. 14274 14275 break; 14276 } 14277 14278 dependency = dependency.next; 14279 } 14280 } else if (fiber.tag === ContextProvider) { 14281 // Don't scan deeper if this is a matching provider 14282 nextFiber = fiber.type === workInProgress.type ? null : fiber.child; 14283 } else { 14284 // Traverse down. 14285 nextFiber = fiber.child; 14286 } 14287 14288 if (nextFiber !== null) { 14289 // Set the return pointer of the child to the work-in-progress fiber. 14290 nextFiber.return = fiber; 14291 } else { 14292 // No child. Traverse to next sibling. 14293 nextFiber = fiber; 14294 14295 while (nextFiber !== null) { 14296 if (nextFiber === workInProgress) { 14297 // We're back to the root of this subtree. Exit. 14298 nextFiber = null; 14299 break; 14300 } 14301 14302 var sibling = nextFiber.sibling; 14303 14304 if (sibling !== null) { 14305 // Set the return pointer of the sibling to the work-in-progress fiber. 14306 sibling.return = nextFiber.return; 14307 nextFiber = sibling; 14308 break; 14309 } // No more siblings. Traverse up. 14310 14311 14312 nextFiber = nextFiber.return; 14313 } 14314 } 14315 14316 fiber = nextFiber; 14317 } 14318} 14319function prepareToReadContext(workInProgress, renderLanes) { 14320 currentlyRenderingFiber = workInProgress; 14321 lastContextDependency = null; 14322 lastContextWithAllBitsObserved = null; 14323 var dependencies = workInProgress.dependencies; 14324 14325 if (dependencies !== null) { 14326 var firstContext = dependencies.firstContext; 14327 14328 if (firstContext !== null) { 14329 if (includesSomeLane(dependencies.lanes, renderLanes)) { 14330 // Context list has a pending update. Mark that this fiber performed work. 14331 markWorkInProgressReceivedUpdate(); 14332 } // Reset the work-in-progress list 14333 14334 14335 dependencies.firstContext = null; 14336 } 14337 } 14338} 14339function readContext(context, observedBits) { 14340 { 14341 // This warning would fire if you read context inside a Hook like useMemo. 14342 // Unlike the class check below, it's not enforced in production for perf. 14343 if (isDisallowedContextReadInDEV) { 14344 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().'); 14345 } 14346 } 14347 14348 if (lastContextWithAllBitsObserved === context) ; else if (observedBits === false || observedBits === 0) ; else { 14349 var resolvedObservedBits; // Avoid deopting on observable arguments or heterogeneous types. 14350 14351 if (typeof observedBits !== 'number' || observedBits === MAX_SIGNED_31_BIT_INT) { 14352 // Observe all updates. 14353 lastContextWithAllBitsObserved = context; 14354 resolvedObservedBits = MAX_SIGNED_31_BIT_INT; 14355 } else { 14356 resolvedObservedBits = observedBits; 14357 } 14358 14359 var contextItem = { 14360 context: context, 14361 observedBits: resolvedObservedBits, 14362 next: null 14363 }; 14364 14365 if (lastContextDependency === null) { 14366 if (!(currentlyRenderingFiber !== null)) { 14367 { 14368 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()." ); 14369 } 14370 } // This is the first dependency for this component. Create a new list. 14371 14372 14373 lastContextDependency = contextItem; 14374 currentlyRenderingFiber.dependencies = { 14375 lanes: NoLanes, 14376 firstContext: contextItem, 14377 responders: null 14378 }; 14379 } else { 14380 // Append a new context item. 14381 lastContextDependency = lastContextDependency.next = contextItem; 14382 } 14383 } 14384 14385 return context._currentValue ; 14386} 14387 14388var UpdateState = 0; 14389var ReplaceState = 1; 14390var ForceUpdate = 2; 14391var CaptureUpdate = 3; // Global state that is reset at the beginning of calling `processUpdateQueue`. 14392// It should only be read right after calling `processUpdateQueue`, via 14393// `checkHasForceUpdateAfterProcessing`. 14394 14395var hasForceUpdate = false; 14396var didWarnUpdateInsideUpdate; 14397var currentlyProcessingQueue; 14398 14399{ 14400 didWarnUpdateInsideUpdate = false; 14401 currentlyProcessingQueue = null; 14402} 14403 14404function initializeUpdateQueue(fiber) { 14405 var queue = { 14406 baseState: fiber.memoizedState, 14407 firstBaseUpdate: null, 14408 lastBaseUpdate: null, 14409 shared: { 14410 pending: null 14411 }, 14412 effects: null 14413 }; 14414 fiber.updateQueue = queue; 14415} 14416function cloneUpdateQueue(current, workInProgress) { 14417 // Clone the update queue from current. Unless it's already a clone. 14418 var queue = workInProgress.updateQueue; 14419 var currentQueue = current.updateQueue; 14420 14421 if (queue === currentQueue) { 14422 var clone = { 14423 baseState: currentQueue.baseState, 14424 firstBaseUpdate: currentQueue.firstBaseUpdate, 14425 lastBaseUpdate: currentQueue.lastBaseUpdate, 14426 shared: currentQueue.shared, 14427 effects: currentQueue.effects 14428 }; 14429 workInProgress.updateQueue = clone; 14430 } 14431} 14432function createUpdate(eventTime, lane) { 14433 var update = { 14434 eventTime: eventTime, 14435 lane: lane, 14436 tag: UpdateState, 14437 payload: null, 14438 callback: null, 14439 next: null 14440 }; 14441 return update; 14442} 14443function enqueueUpdate(fiber, update) { 14444 var updateQueue = fiber.updateQueue; 14445 14446 if (updateQueue === null) { 14447 // Only occurs if the fiber has been unmounted. 14448 return; 14449 } 14450 14451 var sharedQueue = updateQueue.shared; 14452 var pending = sharedQueue.pending; 14453 14454 if (pending === null) { 14455 // This is the first update. Create a circular list. 14456 update.next = update; 14457 } else { 14458 update.next = pending.next; 14459 pending.next = update; 14460 } 14461 14462 sharedQueue.pending = update; 14463 14464 { 14465 if (currentlyProcessingQueue === sharedQueue && !didWarnUpdateInsideUpdate) { 14466 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.'); 14467 14468 didWarnUpdateInsideUpdate = true; 14469 } 14470 } 14471} 14472function enqueueCapturedUpdate(workInProgress, capturedUpdate) { 14473 // Captured updates are updates that are thrown by a child during the render 14474 // phase. They should be discarded if the render is aborted. Therefore, 14475 // we should only put them on the work-in-progress queue, not the current one. 14476 var queue = workInProgress.updateQueue; // Check if the work-in-progress queue is a clone. 14477 14478 var current = workInProgress.alternate; 14479 14480 if (current !== null) { 14481 var currentQueue = current.updateQueue; 14482 14483 if (queue === currentQueue) { 14484 // The work-in-progress queue is the same as current. This happens when 14485 // we bail out on a parent fiber that then captures an error thrown by 14486 // a child. Since we want to append the update only to the work-in 14487 // -progress queue, we need to clone the updates. We usually clone during 14488 // processUpdateQueue, but that didn't happen in this case because we 14489 // skipped over the parent when we bailed out. 14490 var newFirst = null; 14491 var newLast = null; 14492 var firstBaseUpdate = queue.firstBaseUpdate; 14493 14494 if (firstBaseUpdate !== null) { 14495 // Loop through the updates and clone them. 14496 var update = firstBaseUpdate; 14497 14498 do { 14499 var clone = { 14500 eventTime: update.eventTime, 14501 lane: update.lane, 14502 tag: update.tag, 14503 payload: update.payload, 14504 callback: update.callback, 14505 next: null 14506 }; 14507 14508 if (newLast === null) { 14509 newFirst = newLast = clone; 14510 } else { 14511 newLast.next = clone; 14512 newLast = clone; 14513 } 14514 14515 update = update.next; 14516 } while (update !== null); // Append the captured update the end of the cloned list. 14517 14518 14519 if (newLast === null) { 14520 newFirst = newLast = capturedUpdate; 14521 } else { 14522 newLast.next = capturedUpdate; 14523 newLast = capturedUpdate; 14524 } 14525 } else { 14526 // There are no base updates. 14527 newFirst = newLast = capturedUpdate; 14528 } 14529 14530 queue = { 14531 baseState: currentQueue.baseState, 14532 firstBaseUpdate: newFirst, 14533 lastBaseUpdate: newLast, 14534 shared: currentQueue.shared, 14535 effects: currentQueue.effects 14536 }; 14537 workInProgress.updateQueue = queue; 14538 return; 14539 } 14540 } // Append the update to the end of the list. 14541 14542 14543 var lastBaseUpdate = queue.lastBaseUpdate; 14544 14545 if (lastBaseUpdate === null) { 14546 queue.firstBaseUpdate = capturedUpdate; 14547 } else { 14548 lastBaseUpdate.next = capturedUpdate; 14549 } 14550 14551 queue.lastBaseUpdate = capturedUpdate; 14552} 14553 14554function getStateFromUpdate(workInProgress, queue, update, prevState, nextProps, instance) { 14555 switch (update.tag) { 14556 case ReplaceState: 14557 { 14558 var payload = update.payload; 14559 14560 if (typeof payload === 'function') { 14561 // Updater function 14562 { 14563 enterDisallowedContextReadInDEV(); 14564 } 14565 14566 var nextState = payload.call(instance, prevState, nextProps); 14567 14568 { 14569 if ( workInProgress.mode & StrictMode) { 14570 disableLogs(); 14571 14572 try { 14573 payload.call(instance, prevState, nextProps); 14574 } finally { 14575 reenableLogs(); 14576 } 14577 } 14578 14579 exitDisallowedContextReadInDEV(); 14580 } 14581 14582 return nextState; 14583 } // State object 14584 14585 14586 return payload; 14587 } 14588 14589 case CaptureUpdate: 14590 { 14591 workInProgress.flags = workInProgress.flags & ~ShouldCapture | DidCapture; 14592 } 14593 // Intentional fallthrough 14594 14595 case UpdateState: 14596 { 14597 var _payload = update.payload; 14598 var partialState; 14599 14600 if (typeof _payload === 'function') { 14601 // Updater function 14602 { 14603 enterDisallowedContextReadInDEV(); 14604 } 14605 14606 partialState = _payload.call(instance, prevState, nextProps); 14607 14608 { 14609 if ( workInProgress.mode & StrictMode) { 14610 disableLogs(); 14611 14612 try { 14613 _payload.call(instance, prevState, nextProps); 14614 } finally { 14615 reenableLogs(); 14616 } 14617 } 14618 14619 exitDisallowedContextReadInDEV(); 14620 } 14621 } else { 14622 // Partial state object 14623 partialState = _payload; 14624 } 14625 14626 if (partialState === null || partialState === undefined) { 14627 // Null and undefined are treated as no-ops. 14628 return prevState; 14629 } // Merge the partial state and the previous state. 14630 14631 14632 return _assign({}, prevState, partialState); 14633 } 14634 14635 case ForceUpdate: 14636 { 14637 hasForceUpdate = true; 14638 return prevState; 14639 } 14640 } 14641 14642 return prevState; 14643} 14644 14645function processUpdateQueue(workInProgress, props, instance, renderLanes) { 14646 // This is always non-null on a ClassComponent or HostRoot 14647 var queue = workInProgress.updateQueue; 14648 hasForceUpdate = false; 14649 14650 { 14651 currentlyProcessingQueue = queue.shared; 14652 } 14653 14654 var firstBaseUpdate = queue.firstBaseUpdate; 14655 var lastBaseUpdate = queue.lastBaseUpdate; // Check if there are pending updates. If so, transfer them to the base queue. 14656 14657 var pendingQueue = queue.shared.pending; 14658 14659 if (pendingQueue !== null) { 14660 queue.shared.pending = null; // The pending queue is circular. Disconnect the pointer between first 14661 // and last so that it's non-circular. 14662 14663 var lastPendingUpdate = pendingQueue; 14664 var firstPendingUpdate = lastPendingUpdate.next; 14665 lastPendingUpdate.next = null; // Append pending updates to base queue 14666 14667 if (lastBaseUpdate === null) { 14668 firstBaseUpdate = firstPendingUpdate; 14669 } else { 14670 lastBaseUpdate.next = firstPendingUpdate; 14671 } 14672 14673 lastBaseUpdate = lastPendingUpdate; // If there's a current queue, and it's different from the base queue, then 14674 // we need to transfer the updates to that queue, too. Because the base 14675 // queue is a singly-linked list with no cycles, we can append to both 14676 // lists and take advantage of structural sharing. 14677 // TODO: Pass `current` as argument 14678 14679 var current = workInProgress.alternate; 14680 14681 if (current !== null) { 14682 // This is always non-null on a ClassComponent or HostRoot 14683 var currentQueue = current.updateQueue; 14684 var currentLastBaseUpdate = currentQueue.lastBaseUpdate; 14685 14686 if (currentLastBaseUpdate !== lastBaseUpdate) { 14687 if (currentLastBaseUpdate === null) { 14688 currentQueue.firstBaseUpdate = firstPendingUpdate; 14689 } else { 14690 currentLastBaseUpdate.next = firstPendingUpdate; 14691 } 14692 14693 currentQueue.lastBaseUpdate = lastPendingUpdate; 14694 } 14695 } 14696 } // These values may change as we process the queue. 14697 14698 14699 if (firstBaseUpdate !== null) { 14700 // Iterate through the list of updates to compute the result. 14701 var newState = queue.baseState; // TODO: Don't need to accumulate this. Instead, we can remove renderLanes 14702 // from the original lanes. 14703 14704 var newLanes = NoLanes; 14705 var newBaseState = null; 14706 var newFirstBaseUpdate = null; 14707 var newLastBaseUpdate = null; 14708 var update = firstBaseUpdate; 14709 14710 do { 14711 var updateLane = update.lane; 14712 var updateEventTime = update.eventTime; 14713 14714 if (!isSubsetOfLanes(renderLanes, updateLane)) { 14715 // Priority is insufficient. Skip this update. If this is the first 14716 // skipped update, the previous update/state is the new base 14717 // update/state. 14718 var clone = { 14719 eventTime: updateEventTime, 14720 lane: updateLane, 14721 tag: update.tag, 14722 payload: update.payload, 14723 callback: update.callback, 14724 next: null 14725 }; 14726 14727 if (newLastBaseUpdate === null) { 14728 newFirstBaseUpdate = newLastBaseUpdate = clone; 14729 newBaseState = newState; 14730 } else { 14731 newLastBaseUpdate = newLastBaseUpdate.next = clone; 14732 } // Update the remaining priority in the queue. 14733 14734 14735 newLanes = mergeLanes(newLanes, updateLane); 14736 } else { 14737 // This update does have sufficient priority. 14738 if (newLastBaseUpdate !== null) { 14739 var _clone = { 14740 eventTime: updateEventTime, 14741 // This update is going to be committed so we never want uncommit 14742 // it. Using NoLane works because 0 is a subset of all bitmasks, so 14743 // this will never be skipped by the check above. 14744 lane: NoLane, 14745 tag: update.tag, 14746 payload: update.payload, 14747 callback: update.callback, 14748 next: null 14749 }; 14750 newLastBaseUpdate = newLastBaseUpdate.next = _clone; 14751 } // Process this update. 14752 14753 14754 newState = getStateFromUpdate(workInProgress, queue, update, newState, props, instance); 14755 var callback = update.callback; 14756 14757 if (callback !== null) { 14758 workInProgress.flags |= Callback; 14759 var effects = queue.effects; 14760 14761 if (effects === null) { 14762 queue.effects = [update]; 14763 } else { 14764 effects.push(update); 14765 } 14766 } 14767 } 14768 14769 update = update.next; 14770 14771 if (update === null) { 14772 pendingQueue = queue.shared.pending; 14773 14774 if (pendingQueue === null) { 14775 break; 14776 } else { 14777 // An update was scheduled from inside a reducer. Add the new 14778 // pending updates to the end of the list and keep processing. 14779 var _lastPendingUpdate = pendingQueue; // Intentionally unsound. Pending updates form a circular list, but we 14780 // unravel them when transferring them to the base queue. 14781 14782 var _firstPendingUpdate = _lastPendingUpdate.next; 14783 _lastPendingUpdate.next = null; 14784 update = _firstPendingUpdate; 14785 queue.lastBaseUpdate = _lastPendingUpdate; 14786 queue.shared.pending = null; 14787 } 14788 } 14789 } while (true); 14790 14791 if (newLastBaseUpdate === null) { 14792 newBaseState = newState; 14793 } 14794 14795 queue.baseState = newBaseState; 14796 queue.firstBaseUpdate = newFirstBaseUpdate; 14797 queue.lastBaseUpdate = newLastBaseUpdate; // Set the remaining expiration time to be whatever is remaining in the queue. 14798 // This should be fine because the only two other things that contribute to 14799 // expiration time are props and context. We're already in the middle of the 14800 // begin phase by the time we start processing the queue, so we've already 14801 // dealt with the props. Context in components that specify 14802 // shouldComponentUpdate is tricky; but we'll have to account for 14803 // that regardless. 14804 14805 markSkippedUpdateLanes(newLanes); 14806 workInProgress.lanes = newLanes; 14807 workInProgress.memoizedState = newState; 14808 } 14809 14810 { 14811 currentlyProcessingQueue = null; 14812 } 14813} 14814 14815function callCallback(callback, context) { 14816 if (!(typeof callback === 'function')) { 14817 { 14818 throw Error( "Invalid argument passed as callback. Expected a function. Instead received: " + callback ); 14819 } 14820 } 14821 14822 callback.call(context); 14823} 14824 14825function resetHasForceUpdateBeforeProcessing() { 14826 hasForceUpdate = false; 14827} 14828function checkHasForceUpdateAfterProcessing() { 14829 return hasForceUpdate; 14830} 14831function commitUpdateQueue(finishedWork, finishedQueue, instance) { 14832 // Commit the effects 14833 var effects = finishedQueue.effects; 14834 finishedQueue.effects = null; 14835 14836 if (effects !== null) { 14837 for (var i = 0; i < effects.length; i++) { 14838 var effect = effects[i]; 14839 var callback = effect.callback; 14840 14841 if (callback !== null) { 14842 effect.callback = null; 14843 callCallback(callback, instance); 14844 } 14845 } 14846 } 14847} 14848 14849var fakeInternalInstance = {}; 14850var isArray = Array.isArray; // React.Component uses a shared frozen object by default. 14851// We'll use it to determine whether we need to initialize legacy refs. 14852 14853var emptyRefsObject = new React.Component().refs; 14854var didWarnAboutStateAssignmentForComponent; 14855var didWarnAboutUninitializedState; 14856var didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate; 14857var didWarnAboutLegacyLifecyclesAndDerivedState; 14858var didWarnAboutUndefinedDerivedState; 14859var warnOnUndefinedDerivedState; 14860var warnOnInvalidCallback; 14861var didWarnAboutDirectlyAssigningPropsToState; 14862var didWarnAboutContextTypeAndContextTypes; 14863var didWarnAboutInvalidateContextType; 14864 14865{ 14866 didWarnAboutStateAssignmentForComponent = new Set(); 14867 didWarnAboutUninitializedState = new Set(); 14868 didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate = new Set(); 14869 didWarnAboutLegacyLifecyclesAndDerivedState = new Set(); 14870 didWarnAboutDirectlyAssigningPropsToState = new Set(); 14871 didWarnAboutUndefinedDerivedState = new Set(); 14872 didWarnAboutContextTypeAndContextTypes = new Set(); 14873 didWarnAboutInvalidateContextType = new Set(); 14874 var didWarnOnInvalidCallback = new Set(); 14875 14876 warnOnInvalidCallback = function (callback, callerName) { 14877 if (callback === null || typeof callback === 'function') { 14878 return; 14879 } 14880 14881 var key = callerName + '_' + callback; 14882 14883 if (!didWarnOnInvalidCallback.has(key)) { 14884 didWarnOnInvalidCallback.add(key); 14885 14886 error('%s(...): Expected the last optional `callback` argument to be a ' + 'function. Instead received: %s.', callerName, callback); 14887 } 14888 }; 14889 14890 warnOnUndefinedDerivedState = function (type, partialState) { 14891 if (partialState === undefined) { 14892 var componentName = getComponentName(type) || 'Component'; 14893 14894 if (!didWarnAboutUndefinedDerivedState.has(componentName)) { 14895 didWarnAboutUndefinedDerivedState.add(componentName); 14896 14897 error('%s.getDerivedStateFromProps(): A valid state object (or null) must be returned. ' + 'You have returned undefined.', componentName); 14898 } 14899 } 14900 }; // This is so gross but it's at least non-critical and can be removed if 14901 // it causes problems. This is meant to give a nicer error message for 14902 // ReactDOM15.unstable_renderSubtreeIntoContainer(reactDOM16Component, 14903 // ...)) which otherwise throws a "_processChildContext is not a function" 14904 // exception. 14905 14906 14907 Object.defineProperty(fakeInternalInstance, '_processChildContext', { 14908 enumerable: false, 14909 value: function () { 14910 { 14911 { 14912 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)." ); 14913 } 14914 } 14915 } 14916 }); 14917 Object.freeze(fakeInternalInstance); 14918} 14919 14920function applyDerivedStateFromProps(workInProgress, ctor, getDerivedStateFromProps, nextProps) { 14921 var prevState = workInProgress.memoizedState; 14922 14923 { 14924 if ( workInProgress.mode & StrictMode) { 14925 disableLogs(); 14926 14927 try { 14928 // Invoke the function an extra time to help detect side-effects. 14929 getDerivedStateFromProps(nextProps, prevState); 14930 } finally { 14931 reenableLogs(); 14932 } 14933 } 14934 } 14935 14936 var partialState = getDerivedStateFromProps(nextProps, prevState); 14937 14938 { 14939 warnOnUndefinedDerivedState(ctor, partialState); 14940 } // Merge the partial state and the previous state. 14941 14942 14943 var memoizedState = partialState === null || partialState === undefined ? prevState : _assign({}, prevState, partialState); 14944 workInProgress.memoizedState = memoizedState; // Once the update queue is empty, persist the derived state onto the 14945 // base state. 14946 14947 if (workInProgress.lanes === NoLanes) { 14948 // Queue is always non-null for classes 14949 var updateQueue = workInProgress.updateQueue; 14950 updateQueue.baseState = memoizedState; 14951 } 14952} 14953var classComponentUpdater = { 14954 isMounted: isMounted, 14955 enqueueSetState: function (inst, payload, callback) { 14956 var fiber = get(inst); 14957 var eventTime = requestEventTime(); 14958 var lane = requestUpdateLane(fiber); 14959 var update = createUpdate(eventTime, lane); 14960 update.payload = payload; 14961 14962 if (callback !== undefined && callback !== null) { 14963 { 14964 warnOnInvalidCallback(callback, 'setState'); 14965 } 14966 14967 update.callback = callback; 14968 } 14969 14970 enqueueUpdate(fiber, update); 14971 scheduleUpdateOnFiber(fiber, lane, eventTime); 14972 }, 14973 enqueueReplaceState: function (inst, payload, callback) { 14974 var fiber = get(inst); 14975 var eventTime = requestEventTime(); 14976 var lane = requestUpdateLane(fiber); 14977 var update = createUpdate(eventTime, lane); 14978 update.tag = ReplaceState; 14979 update.payload = payload; 14980 14981 if (callback !== undefined && callback !== null) { 14982 { 14983 warnOnInvalidCallback(callback, 'replaceState'); 14984 } 14985 14986 update.callback = callback; 14987 } 14988 14989 enqueueUpdate(fiber, update); 14990 scheduleUpdateOnFiber(fiber, lane, eventTime); 14991 }, 14992 enqueueForceUpdate: function (inst, callback) { 14993 var fiber = get(inst); 14994 var eventTime = requestEventTime(); 14995 var lane = requestUpdateLane(fiber); 14996 var update = createUpdate(eventTime, lane); 14997 update.tag = ForceUpdate; 14998 14999 if (callback !== undefined && callback !== null) { 15000 { 15001 warnOnInvalidCallback(callback, 'forceUpdate'); 15002 } 15003 15004 update.callback = callback; 15005 } 15006 15007 enqueueUpdate(fiber, update); 15008 scheduleUpdateOnFiber(fiber, lane, eventTime); 15009 } 15010}; 15011 15012function checkShouldComponentUpdate(workInProgress, ctor, oldProps, newProps, oldState, newState, nextContext) { 15013 var instance = workInProgress.stateNode; 15014 15015 if (typeof instance.shouldComponentUpdate === 'function') { 15016 { 15017 if ( workInProgress.mode & StrictMode) { 15018 disableLogs(); 15019 15020 try { 15021 // Invoke the function an extra time to help detect side-effects. 15022 instance.shouldComponentUpdate(newProps, newState, nextContext); 15023 } finally { 15024 reenableLogs(); 15025 } 15026 } 15027 } 15028 15029 var shouldUpdate = instance.shouldComponentUpdate(newProps, newState, nextContext); 15030 15031 { 15032 if (shouldUpdate === undefined) { 15033 error('%s.shouldComponentUpdate(): Returned undefined instead of a ' + 'boolean value. Make sure to return true or false.', getComponentName(ctor) || 'Component'); 15034 } 15035 } 15036 15037 return shouldUpdate; 15038 } 15039 15040 if (ctor.prototype && ctor.prototype.isPureReactComponent) { 15041 return !shallowEqual(oldProps, newProps) || !shallowEqual(oldState, newState); 15042 } 15043 15044 return true; 15045} 15046 15047function checkClassInstance(workInProgress, ctor, newProps) { 15048 var instance = workInProgress.stateNode; 15049 15050 { 15051 var name = getComponentName(ctor) || 'Component'; 15052 var renderPresent = instance.render; 15053 15054 if (!renderPresent) { 15055 if (ctor.prototype && typeof ctor.prototype.render === 'function') { 15056 error('%s(...): No `render` method found on the returned component ' + 'instance: did you accidentally return an object from the constructor?', name); 15057 } else { 15058 error('%s(...): No `render` method found on the returned component ' + 'instance: you may have forgotten to define `render`.', name); 15059 } 15060 } 15061 15062 if (instance.getInitialState && !instance.getInitialState.isReactClassApproved && !instance.state) { 15063 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); 15064 } 15065 15066 if (instance.getDefaultProps && !instance.getDefaultProps.isReactClassApproved) { 15067 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); 15068 } 15069 15070 if (instance.propTypes) { 15071 error('propTypes was defined as an instance property on %s. Use a static ' + 'property to define propTypes instead.', name); 15072 } 15073 15074 if (instance.contextType) { 15075 error('contextType was defined as an instance property on %s. Use a static ' + 'property to define contextType instead.', name); 15076 } 15077 15078 { 15079 if (instance.contextTypes) { 15080 error('contextTypes was defined as an instance property on %s. Use a static ' + 'property to define contextTypes instead.', name); 15081 } 15082 15083 if (ctor.contextType && ctor.contextTypes && !didWarnAboutContextTypeAndContextTypes.has(ctor)) { 15084 didWarnAboutContextTypeAndContextTypes.add(ctor); 15085 15086 error('%s declares both contextTypes and contextType static properties. ' + 'The legacy contextTypes property will be ignored.', name); 15087 } 15088 } 15089 15090 if (typeof instance.componentShouldUpdate === 'function') { 15091 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); 15092 } 15093 15094 if (ctor.prototype && ctor.prototype.isPureReactComponent && typeof instance.shouldComponentUpdate !== 'undefined') { 15095 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'); 15096 } 15097 15098 if (typeof instance.componentDidUnmount === 'function') { 15099 error('%s has a method called ' + 'componentDidUnmount(). But there is no such lifecycle method. ' + 'Did you mean componentWillUnmount()?', name); 15100 } 15101 15102 if (typeof instance.componentDidReceiveProps === 'function') { 15103 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); 15104 } 15105 15106 if (typeof instance.componentWillRecieveProps === 'function') { 15107 error('%s has a method called ' + 'componentWillRecieveProps(). Did you mean componentWillReceiveProps()?', name); 15108 } 15109 15110 if (typeof instance.UNSAFE_componentWillRecieveProps === 'function') { 15111 error('%s has a method called ' + 'UNSAFE_componentWillRecieveProps(). Did you mean UNSAFE_componentWillReceiveProps()?', name); 15112 } 15113 15114 var hasMutatedProps = instance.props !== newProps; 15115 15116 if (instance.props !== undefined && hasMutatedProps) { 15117 error('%s(...): When calling super() in `%s`, make sure to pass ' + "up the same props that your component's constructor was passed.", name, name); 15118 } 15119 15120 if (instance.defaultProps) { 15121 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); 15122 } 15123 15124 if (typeof instance.getSnapshotBeforeUpdate === 'function' && typeof instance.componentDidUpdate !== 'function' && !didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate.has(ctor)) { 15125 didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate.add(ctor); 15126 15127 error('%s: getSnapshotBeforeUpdate() should be used with componentDidUpdate(). ' + 'This component defines getSnapshotBeforeUpdate() only.', getComponentName(ctor)); 15128 } 15129 15130 if (typeof instance.getDerivedStateFromProps === 'function') { 15131 error('%s: getDerivedStateFromProps() is defined as an instance method ' + 'and will be ignored. Instead, declare it as a static method.', name); 15132 } 15133 15134 if (typeof instance.getDerivedStateFromError === 'function') { 15135 error('%s: getDerivedStateFromError() is defined as an instance method ' + 'and will be ignored. Instead, declare it as a static method.', name); 15136 } 15137 15138 if (typeof ctor.getSnapshotBeforeUpdate === 'function') { 15139 error('%s: getSnapshotBeforeUpdate() is defined as a static method ' + 'and will be ignored. Instead, declare it as an instance method.', name); 15140 } 15141 15142 var _state = instance.state; 15143 15144 if (_state && (typeof _state !== 'object' || isArray(_state))) { 15145 error('%s.state: must be set to an object or null', name); 15146 } 15147 15148 if (typeof instance.getChildContext === 'function' && typeof ctor.childContextTypes !== 'object') { 15149 error('%s.getChildContext(): childContextTypes must be defined in order to ' + 'use getChildContext().', name); 15150 } 15151 } 15152} 15153 15154function adoptClassInstance(workInProgress, instance) { 15155 instance.updater = classComponentUpdater; 15156 workInProgress.stateNode = instance; // The instance needs access to the fiber so that it can schedule updates 15157 15158 set(instance, workInProgress); 15159 15160 { 15161 instance._reactInternalInstance = fakeInternalInstance; 15162 } 15163} 15164 15165function constructClassInstance(workInProgress, ctor, props) { 15166 var isLegacyContextConsumer = false; 15167 var unmaskedContext = emptyContextObject; 15168 var context = emptyContextObject; 15169 var contextType = ctor.contextType; 15170 15171 { 15172 if ('contextType' in ctor) { 15173 var isValid = // Allow null for conditional declaration 15174 contextType === null || contextType !== undefined && contextType.$$typeof === REACT_CONTEXT_TYPE && contextType._context === undefined; // Not a <Context.Consumer> 15175 15176 if (!isValid && !didWarnAboutInvalidateContextType.has(ctor)) { 15177 didWarnAboutInvalidateContextType.add(ctor); 15178 var addendum = ''; 15179 15180 if (contextType === undefined) { 15181 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.'; 15182 } else if (typeof contextType !== 'object') { 15183 addendum = ' However, it is set to a ' + typeof contextType + '.'; 15184 } else if (contextType.$$typeof === REACT_PROVIDER_TYPE) { 15185 addendum = ' Did you accidentally pass the Context.Provider instead?'; 15186 } else if (contextType._context !== undefined) { 15187 // <Context.Consumer> 15188 addendum = ' Did you accidentally pass the Context.Consumer instead?'; 15189 } else { 15190 addendum = ' However, it is set to an object with keys {' + Object.keys(contextType).join(', ') + '}.'; 15191 } 15192 15193 error('%s defines an invalid contextType. ' + 'contextType should point to the Context object returned by React.createContext().%s', getComponentName(ctor) || 'Component', addendum); 15194 } 15195 } 15196 } 15197 15198 if (typeof contextType === 'object' && contextType !== null) { 15199 context = readContext(contextType); 15200 } else { 15201 unmaskedContext = getUnmaskedContext(workInProgress, ctor, true); 15202 var contextTypes = ctor.contextTypes; 15203 isLegacyContextConsumer = contextTypes !== null && contextTypes !== undefined; 15204 context = isLegacyContextConsumer ? getMaskedContext(workInProgress, unmaskedContext) : emptyContextObject; 15205 } // Instantiate twice to help detect side-effects. 15206 15207 15208 { 15209 if ( workInProgress.mode & StrictMode) { 15210 disableLogs(); 15211 15212 try { 15213 new ctor(props, context); // eslint-disable-line no-new 15214 } finally { 15215 reenableLogs(); 15216 } 15217 } 15218 } 15219 15220 var instance = new ctor(props, context); 15221 var state = workInProgress.memoizedState = instance.state !== null && instance.state !== undefined ? instance.state : null; 15222 adoptClassInstance(workInProgress, instance); 15223 15224 { 15225 if (typeof ctor.getDerivedStateFromProps === 'function' && state === null) { 15226 var componentName = getComponentName(ctor) || 'Component'; 15227 15228 if (!didWarnAboutUninitializedState.has(componentName)) { 15229 didWarnAboutUninitializedState.add(componentName); 15230 15231 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); 15232 } 15233 } // If new component APIs are defined, "unsafe" lifecycles won't be called. 15234 // Warn about these lifecycles if they are present. 15235 // Don't warn about react-lifecycles-compat polyfilled methods though. 15236 15237 15238 if (typeof ctor.getDerivedStateFromProps === 'function' || typeof instance.getSnapshotBeforeUpdate === 'function') { 15239 var foundWillMountName = null; 15240 var foundWillReceivePropsName = null; 15241 var foundWillUpdateName = null; 15242 15243 if (typeof instance.componentWillMount === 'function' && instance.componentWillMount.__suppressDeprecationWarning !== true) { 15244 foundWillMountName = 'componentWillMount'; 15245 } else if (typeof instance.UNSAFE_componentWillMount === 'function') { 15246 foundWillMountName = 'UNSAFE_componentWillMount'; 15247 } 15248 15249 if (typeof instance.componentWillReceiveProps === 'function' && instance.componentWillReceiveProps.__suppressDeprecationWarning !== true) { 15250 foundWillReceivePropsName = 'componentWillReceiveProps'; 15251 } else if (typeof instance.UNSAFE_componentWillReceiveProps === 'function') { 15252 foundWillReceivePropsName = 'UNSAFE_componentWillReceiveProps'; 15253 } 15254 15255 if (typeof instance.componentWillUpdate === 'function' && instance.componentWillUpdate.__suppressDeprecationWarning !== true) { 15256 foundWillUpdateName = 'componentWillUpdate'; 15257 } else if (typeof instance.UNSAFE_componentWillUpdate === 'function') { 15258 foundWillUpdateName = 'UNSAFE_componentWillUpdate'; 15259 } 15260 15261 if (foundWillMountName !== null || foundWillReceivePropsName !== null || foundWillUpdateName !== null) { 15262 var _componentName = getComponentName(ctor) || 'Component'; 15263 15264 var newApiName = typeof ctor.getDerivedStateFromProps === 'function' ? 'getDerivedStateFromProps()' : 'getSnapshotBeforeUpdate()'; 15265 15266 if (!didWarnAboutLegacyLifecyclesAndDerivedState.has(_componentName)) { 15267 didWarnAboutLegacyLifecyclesAndDerivedState.add(_componentName); 15268 15269 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 : ''); 15270 } 15271 } 15272 } 15273 } // Cache unmasked context so we can avoid recreating masked context unless necessary. 15274 // ReactFiberContext usually updates this cache but can't for newly-created instances. 15275 15276 15277 if (isLegacyContextConsumer) { 15278 cacheContext(workInProgress, unmaskedContext, context); 15279 } 15280 15281 return instance; 15282} 15283 15284function callComponentWillMount(workInProgress, instance) { 15285 var oldState = instance.state; 15286 15287 if (typeof instance.componentWillMount === 'function') { 15288 instance.componentWillMount(); 15289 } 15290 15291 if (typeof instance.UNSAFE_componentWillMount === 'function') { 15292 instance.UNSAFE_componentWillMount(); 15293 } 15294 15295 if (oldState !== instance.state) { 15296 { 15297 error('%s.componentWillMount(): Assigning directly to this.state is ' + "deprecated (except inside a component's " + 'constructor). Use setState instead.', getComponentName(workInProgress.type) || 'Component'); 15298 } 15299 15300 classComponentUpdater.enqueueReplaceState(instance, instance.state, null); 15301 } 15302} 15303 15304function callComponentWillReceiveProps(workInProgress, instance, newProps, nextContext) { 15305 var oldState = instance.state; 15306 15307 if (typeof instance.componentWillReceiveProps === 'function') { 15308 instance.componentWillReceiveProps(newProps, nextContext); 15309 } 15310 15311 if (typeof instance.UNSAFE_componentWillReceiveProps === 'function') { 15312 instance.UNSAFE_componentWillReceiveProps(newProps, nextContext); 15313 } 15314 15315 if (instance.state !== oldState) { 15316 { 15317 var componentName = getComponentName(workInProgress.type) || 'Component'; 15318 15319 if (!didWarnAboutStateAssignmentForComponent.has(componentName)) { 15320 didWarnAboutStateAssignmentForComponent.add(componentName); 15321 15322 error('%s.componentWillReceiveProps(): Assigning directly to ' + "this.state is deprecated (except inside a component's " + 'constructor). Use setState instead.', componentName); 15323 } 15324 } 15325 15326 classComponentUpdater.enqueueReplaceState(instance, instance.state, null); 15327 } 15328} // Invokes the mount life-cycles on a previously never rendered instance. 15329 15330 15331function mountClassInstance(workInProgress, ctor, newProps, renderLanes) { 15332 { 15333 checkClassInstance(workInProgress, ctor, newProps); 15334 } 15335 15336 var instance = workInProgress.stateNode; 15337 instance.props = newProps; 15338 instance.state = workInProgress.memoizedState; 15339 instance.refs = emptyRefsObject; 15340 initializeUpdateQueue(workInProgress); 15341 var contextType = ctor.contextType; 15342 15343 if (typeof contextType === 'object' && contextType !== null) { 15344 instance.context = readContext(contextType); 15345 } else { 15346 var unmaskedContext = getUnmaskedContext(workInProgress, ctor, true); 15347 instance.context = getMaskedContext(workInProgress, unmaskedContext); 15348 } 15349 15350 { 15351 if (instance.state === newProps) { 15352 var componentName = getComponentName(ctor) || 'Component'; 15353 15354 if (!didWarnAboutDirectlyAssigningPropsToState.has(componentName)) { 15355 didWarnAboutDirectlyAssigningPropsToState.add(componentName); 15356 15357 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); 15358 } 15359 } 15360 15361 if (workInProgress.mode & StrictMode) { 15362 ReactStrictModeWarnings.recordLegacyContextWarning(workInProgress, instance); 15363 } 15364 15365 { 15366 ReactStrictModeWarnings.recordUnsafeLifecycleWarnings(workInProgress, instance); 15367 } 15368 } 15369 15370 processUpdateQueue(workInProgress, newProps, instance, renderLanes); 15371 instance.state = workInProgress.memoizedState; 15372 var getDerivedStateFromProps = ctor.getDerivedStateFromProps; 15373 15374 if (typeof getDerivedStateFromProps === 'function') { 15375 applyDerivedStateFromProps(workInProgress, ctor, getDerivedStateFromProps, newProps); 15376 instance.state = workInProgress.memoizedState; 15377 } // In order to support react-lifecycles-compat polyfilled components, 15378 // Unsafe lifecycles should not be invoked for components using the new APIs. 15379 15380 15381 if (typeof ctor.getDerivedStateFromProps !== 'function' && typeof instance.getSnapshotBeforeUpdate !== 'function' && (typeof instance.UNSAFE_componentWillMount === 'function' || typeof instance.componentWillMount === 'function')) { 15382 callComponentWillMount(workInProgress, instance); // If we had additional state updates during this life-cycle, let's 15383 // process them now. 15384 15385 processUpdateQueue(workInProgress, newProps, instance, renderLanes); 15386 instance.state = workInProgress.memoizedState; 15387 } 15388 15389 if (typeof instance.componentDidMount === 'function') { 15390 workInProgress.flags |= Update; 15391 } 15392} 15393 15394function resumeMountClassInstance(workInProgress, ctor, newProps, renderLanes) { 15395 var instance = workInProgress.stateNode; 15396 var oldProps = workInProgress.memoizedProps; 15397 instance.props = oldProps; 15398 var oldContext = instance.context; 15399 var contextType = ctor.contextType; 15400 var nextContext = emptyContextObject; 15401 15402 if (typeof contextType === 'object' && contextType !== null) { 15403 nextContext = readContext(contextType); 15404 } else { 15405 var nextLegacyUnmaskedContext = getUnmaskedContext(workInProgress, ctor, true); 15406 nextContext = getMaskedContext(workInProgress, nextLegacyUnmaskedContext); 15407 } 15408 15409 var getDerivedStateFromProps = ctor.getDerivedStateFromProps; 15410 var hasNewLifecycles = typeof getDerivedStateFromProps === 'function' || typeof instance.getSnapshotBeforeUpdate === 'function'; // Note: During these life-cycles, instance.props/instance.state are what 15411 // ever the previously attempted to render - not the "current". However, 15412 // during componentDidUpdate we pass the "current" props. 15413 // In order to support react-lifecycles-compat polyfilled components, 15414 // Unsafe lifecycles should not be invoked for components using the new APIs. 15415 15416 if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillReceiveProps === 'function' || typeof instance.componentWillReceiveProps === 'function')) { 15417 if (oldProps !== newProps || oldContext !== nextContext) { 15418 callComponentWillReceiveProps(workInProgress, instance, newProps, nextContext); 15419 } 15420 } 15421 15422 resetHasForceUpdateBeforeProcessing(); 15423 var oldState = workInProgress.memoizedState; 15424 var newState = instance.state = oldState; 15425 processUpdateQueue(workInProgress, newProps, instance, renderLanes); 15426 newState = workInProgress.memoizedState; 15427 15428 if (oldProps === newProps && oldState === newState && !hasContextChanged() && !checkHasForceUpdateAfterProcessing()) { 15429 // If an update was already in progress, we should schedule an Update 15430 // effect even though we're bailing out, so that cWU/cDU are called. 15431 if (typeof instance.componentDidMount === 'function') { 15432 workInProgress.flags |= Update; 15433 } 15434 15435 return false; 15436 } 15437 15438 if (typeof getDerivedStateFromProps === 'function') { 15439 applyDerivedStateFromProps(workInProgress, ctor, getDerivedStateFromProps, newProps); 15440 newState = workInProgress.memoizedState; 15441 } 15442 15443 var shouldUpdate = checkHasForceUpdateAfterProcessing() || checkShouldComponentUpdate(workInProgress, ctor, oldProps, newProps, oldState, newState, nextContext); 15444 15445 if (shouldUpdate) { 15446 // In order to support react-lifecycles-compat polyfilled components, 15447 // Unsafe lifecycles should not be invoked for components using the new APIs. 15448 if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillMount === 'function' || typeof instance.componentWillMount === 'function')) { 15449 if (typeof instance.componentWillMount === 'function') { 15450 instance.componentWillMount(); 15451 } 15452 15453 if (typeof instance.UNSAFE_componentWillMount === 'function') { 15454 instance.UNSAFE_componentWillMount(); 15455 } 15456 } 15457 15458 if (typeof instance.componentDidMount === 'function') { 15459 workInProgress.flags |= Update; 15460 } 15461 } else { 15462 // If an update was already in progress, we should schedule an Update 15463 // effect even though we're bailing out, so that cWU/cDU are called. 15464 if (typeof instance.componentDidMount === 'function') { 15465 workInProgress.flags |= Update; 15466 } // If shouldComponentUpdate returned false, we should still update the 15467 // memoized state to indicate that this work can be reused. 15468 15469 15470 workInProgress.memoizedProps = newProps; 15471 workInProgress.memoizedState = newState; 15472 } // Update the existing instance's state, props, and context pointers even 15473 // if shouldComponentUpdate returns false. 15474 15475 15476 instance.props = newProps; 15477 instance.state = newState; 15478 instance.context = nextContext; 15479 return shouldUpdate; 15480} // Invokes the update life-cycles and returns false if it shouldn't rerender. 15481 15482 15483function updateClassInstance(current, workInProgress, ctor, newProps, renderLanes) { 15484 var instance = workInProgress.stateNode; 15485 cloneUpdateQueue(current, workInProgress); 15486 var unresolvedOldProps = workInProgress.memoizedProps; 15487 var oldProps = workInProgress.type === workInProgress.elementType ? unresolvedOldProps : resolveDefaultProps(workInProgress.type, unresolvedOldProps); 15488 instance.props = oldProps; 15489 var unresolvedNewProps = workInProgress.pendingProps; 15490 var oldContext = instance.context; 15491 var contextType = ctor.contextType; 15492 var nextContext = emptyContextObject; 15493 15494 if (typeof contextType === 'object' && contextType !== null) { 15495 nextContext = readContext(contextType); 15496 } else { 15497 var nextUnmaskedContext = getUnmaskedContext(workInProgress, ctor, true); 15498 nextContext = getMaskedContext(workInProgress, nextUnmaskedContext); 15499 } 15500 15501 var getDerivedStateFromProps = ctor.getDerivedStateFromProps; 15502 var hasNewLifecycles = typeof getDerivedStateFromProps === 'function' || typeof instance.getSnapshotBeforeUpdate === 'function'; // Note: During these life-cycles, instance.props/instance.state are what 15503 // ever the previously attempted to render - not the "current". However, 15504 // during componentDidUpdate we pass the "current" props. 15505 // In order to support react-lifecycles-compat polyfilled components, 15506 // Unsafe lifecycles should not be invoked for components using the new APIs. 15507 15508 if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillReceiveProps === 'function' || typeof instance.componentWillReceiveProps === 'function')) { 15509 if (unresolvedOldProps !== unresolvedNewProps || oldContext !== nextContext) { 15510 callComponentWillReceiveProps(workInProgress, instance, newProps, nextContext); 15511 } 15512 } 15513 15514 resetHasForceUpdateBeforeProcessing(); 15515 var oldState = workInProgress.memoizedState; 15516 var newState = instance.state = oldState; 15517 processUpdateQueue(workInProgress, newProps, instance, renderLanes); 15518 newState = workInProgress.memoizedState; 15519 15520 if (unresolvedOldProps === unresolvedNewProps && oldState === newState && !hasContextChanged() && !checkHasForceUpdateAfterProcessing()) { 15521 // If an update was already in progress, we should schedule an Update 15522 // effect even though we're bailing out, so that cWU/cDU are called. 15523 if (typeof instance.componentDidUpdate === 'function') { 15524 if (unresolvedOldProps !== current.memoizedProps || oldState !== current.memoizedState) { 15525 workInProgress.flags |= Update; 15526 } 15527 } 15528 15529 if (typeof instance.getSnapshotBeforeUpdate === 'function') { 15530 if (unresolvedOldProps !== current.memoizedProps || oldState !== current.memoizedState) { 15531 workInProgress.flags |= Snapshot; 15532 } 15533 } 15534 15535 return false; 15536 } 15537 15538 if (typeof getDerivedStateFromProps === 'function') { 15539 applyDerivedStateFromProps(workInProgress, ctor, getDerivedStateFromProps, newProps); 15540 newState = workInProgress.memoizedState; 15541 } 15542 15543 var shouldUpdate = checkHasForceUpdateAfterProcessing() || checkShouldComponentUpdate(workInProgress, ctor, oldProps, newProps, oldState, newState, nextContext); 15544 15545 if (shouldUpdate) { 15546 // In order to support react-lifecycles-compat polyfilled components, 15547 // Unsafe lifecycles should not be invoked for components using the new APIs. 15548 if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillUpdate === 'function' || typeof instance.componentWillUpdate === 'function')) { 15549 if (typeof instance.componentWillUpdate === 'function') { 15550 instance.componentWillUpdate(newProps, newState, nextContext); 15551 } 15552 15553 if (typeof instance.UNSAFE_componentWillUpdate === 'function') { 15554 instance.UNSAFE_componentWillUpdate(newProps, newState, nextContext); 15555 } 15556 } 15557 15558 if (typeof instance.componentDidUpdate === 'function') { 15559 workInProgress.flags |= Update; 15560 } 15561 15562 if (typeof instance.getSnapshotBeforeUpdate === 'function') { 15563 workInProgress.flags |= Snapshot; 15564 } 15565 } else { 15566 // If an update was already in progress, we should schedule an Update 15567 // effect even though we're bailing out, so that cWU/cDU are called. 15568 if (typeof instance.componentDidUpdate === 'function') { 15569 if (unresolvedOldProps !== current.memoizedProps || oldState !== current.memoizedState) { 15570 workInProgress.flags |= Update; 15571 } 15572 } 15573 15574 if (typeof instance.getSnapshotBeforeUpdate === 'function') { 15575 if (unresolvedOldProps !== current.memoizedProps || oldState !== current.memoizedState) { 15576 workInProgress.flags |= Snapshot; 15577 } 15578 } // If shouldComponentUpdate returned false, we should still update the 15579 // memoized props/state to indicate that this work can be reused. 15580 15581 15582 workInProgress.memoizedProps = newProps; 15583 workInProgress.memoizedState = newState; 15584 } // Update the existing instance's state, props, and context pointers even 15585 // if shouldComponentUpdate returns false. 15586 15587 15588 instance.props = newProps; 15589 instance.state = newState; 15590 instance.context = nextContext; 15591 return shouldUpdate; 15592} 15593 15594var didWarnAboutMaps; 15595var didWarnAboutGenerators; 15596var didWarnAboutStringRefs; 15597var ownerHasKeyUseWarning; 15598var ownerHasFunctionTypeWarning; 15599 15600var warnForMissingKey = function (child, returnFiber) {}; 15601 15602{ 15603 didWarnAboutMaps = false; 15604 didWarnAboutGenerators = false; 15605 didWarnAboutStringRefs = {}; 15606 /** 15607 * Warn if there's no key explicitly set on dynamic arrays of children or 15608 * object keys are not valid. This allows us to keep track of children between 15609 * updates. 15610 */ 15611 15612 ownerHasKeyUseWarning = {}; 15613 ownerHasFunctionTypeWarning = {}; 15614 15615 warnForMissingKey = function (child, returnFiber) { 15616 if (child === null || typeof child !== 'object') { 15617 return; 15618 } 15619 15620 if (!child._store || child._store.validated || child.key != null) { 15621 return; 15622 } 15623 15624 if (!(typeof child._store === 'object')) { 15625 { 15626 throw Error( "React Component in warnForMissingKey should have a _store. This error is likely caused by a bug in React. Please file an issue." ); 15627 } 15628 } 15629 15630 child._store.validated = true; 15631 var componentName = getComponentName(returnFiber.type) || 'Component'; 15632 15633 if (ownerHasKeyUseWarning[componentName]) { 15634 return; 15635 } 15636 15637 ownerHasKeyUseWarning[componentName] = true; 15638 15639 error('Each child in a list should have a unique ' + '"key" prop. See https://reactjs.org/link/warning-keys for ' + 'more information.'); 15640 }; 15641} 15642 15643var isArray$1 = Array.isArray; 15644 15645function coerceRef(returnFiber, current, element) { 15646 var mixedRef = element.ref; 15647 15648 if (mixedRef !== null && typeof mixedRef !== 'function' && typeof mixedRef !== 'object') { 15649 { 15650 // TODO: Clean this up once we turn on the string ref warning for 15651 // everyone, because the strict mode case will no longer be relevant 15652 if ((returnFiber.mode & StrictMode || warnAboutStringRefs) && // We warn in ReactElement.js if owner and self are equal for string refs 15653 // because these cannot be automatically converted to an arrow function 15654 // using a codemod. Therefore, we don't have to warn about string refs again. 15655 !(element._owner && element._self && element._owner.stateNode !== element._self)) { 15656 var componentName = getComponentName(returnFiber.type) || 'Component'; 15657 15658 if (!didWarnAboutStringRefs[componentName]) { 15659 { 15660 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); 15661 } 15662 15663 didWarnAboutStringRefs[componentName] = true; 15664 } 15665 } 15666 } 15667 15668 if (element._owner) { 15669 var owner = element._owner; 15670 var inst; 15671 15672 if (owner) { 15673 var ownerFiber = owner; 15674 15675 if (!(ownerFiber.tag === ClassComponent)) { 15676 { 15677 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" ); 15678 } 15679 } 15680 15681 inst = ownerFiber.stateNode; 15682 } 15683 15684 if (!inst) { 15685 { 15686 throw Error( "Missing owner for string ref " + mixedRef + ". This error is likely caused by a bug in React. Please file an issue." ); 15687 } 15688 } 15689 15690 var stringRef = '' + mixedRef; // Check if previous string ref matches new string ref 15691 15692 if (current !== null && current.ref !== null && typeof current.ref === 'function' && current.ref._stringRef === stringRef) { 15693 return current.ref; 15694 } 15695 15696 var ref = function (value) { 15697 var refs = inst.refs; 15698 15699 if (refs === emptyRefsObject) { 15700 // This is a lazy pooled frozen object, so we need to initialize. 15701 refs = inst.refs = {}; 15702 } 15703 15704 if (value === null) { 15705 delete refs[stringRef]; 15706 } else { 15707 refs[stringRef] = value; 15708 } 15709 }; 15710 15711 ref._stringRef = stringRef; 15712 return ref; 15713 } else { 15714 if (!(typeof mixedRef === 'string')) { 15715 { 15716 throw Error( "Expected ref to be a function, a string, an object returned by React.createRef(), or null." ); 15717 } 15718 } 15719 15720 if (!element._owner) { 15721 { 15722 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." ); 15723 } 15724 } 15725 } 15726 } 15727 15728 return mixedRef; 15729} 15730 15731function throwOnInvalidObjectType(returnFiber, newChild) { 15732 if (returnFiber.type !== 'textarea') { 15733 { 15734 { 15735 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." ); 15736 } 15737 } 15738 } 15739} 15740 15741function warnOnFunctionType(returnFiber) { 15742 { 15743 var componentName = getComponentName(returnFiber.type) || 'Component'; 15744 15745 if (ownerHasFunctionTypeWarning[componentName]) { 15746 return; 15747 } 15748 15749 ownerHasFunctionTypeWarning[componentName] = true; 15750 15751 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.'); 15752 } 15753} // We avoid inlining this to avoid potential deopts from using try/catch. 15754// to be able to optimize each path individually by branching early. This needs 15755// a compiler or we can do it manually. Helpers that don't need this branching 15756// live outside of this function. 15757 15758 15759function ChildReconciler(shouldTrackSideEffects) { 15760 function deleteChild(returnFiber, childToDelete) { 15761 if (!shouldTrackSideEffects) { 15762 // Noop. 15763 return; 15764 } // Deletions are added in reversed order so we add it to the front. 15765 // At this point, the return fiber's effect list is empty except for 15766 // deletions, so we can just append the deletion to the list. The remaining 15767 // effects aren't added until the complete phase. Once we implement 15768 // resuming, this may not be true. 15769 15770 15771 var last = returnFiber.lastEffect; 15772 15773 if (last !== null) { 15774 last.nextEffect = childToDelete; 15775 returnFiber.lastEffect = childToDelete; 15776 } else { 15777 returnFiber.firstEffect = returnFiber.lastEffect = childToDelete; 15778 } 15779 15780 childToDelete.nextEffect = null; 15781 childToDelete.flags = Deletion; 15782 } 15783 15784 function deleteRemainingChildren(returnFiber, currentFirstChild) { 15785 if (!shouldTrackSideEffects) { 15786 // Noop. 15787 return null; 15788 } // TODO: For the shouldClone case, this could be micro-optimized a bit by 15789 // assuming that after the first child we've already added everything. 15790 15791 15792 var childToDelete = currentFirstChild; 15793 15794 while (childToDelete !== null) { 15795 deleteChild(returnFiber, childToDelete); 15796 childToDelete = childToDelete.sibling; 15797 } 15798 15799 return null; 15800 } 15801 15802 function mapRemainingChildren(returnFiber, currentFirstChild) { 15803 // Add the remaining children to a temporary map so that we can find them by 15804 // keys quickly. Implicit (null) keys get added to this set with their index 15805 // instead. 15806 var existingChildren = new Map(); 15807 var existingChild = currentFirstChild; 15808 15809 while (existingChild !== null) { 15810 if (existingChild.key !== null) { 15811 existingChildren.set(existingChild.key, existingChild); 15812 } else { 15813 existingChildren.set(existingChild.index, existingChild); 15814 } 15815 15816 existingChild = existingChild.sibling; 15817 } 15818 15819 return existingChildren; 15820 } 15821 15822 function useFiber(fiber, pendingProps) { 15823 // We currently set sibling to null and index to 0 here because it is easy 15824 // to forget to do before returning it. E.g. for the single child case. 15825 var clone = createWorkInProgress(fiber, pendingProps); 15826 clone.index = 0; 15827 clone.sibling = null; 15828 return clone; 15829 } 15830 15831 function placeChild(newFiber, lastPlacedIndex, newIndex) { 15832 newFiber.index = newIndex; 15833 15834 if (!shouldTrackSideEffects) { 15835 // Noop. 15836 return lastPlacedIndex; 15837 } 15838 15839 var current = newFiber.alternate; 15840 15841 if (current !== null) { 15842 var oldIndex = current.index; 15843 15844 if (oldIndex < lastPlacedIndex) { 15845 // This is a move. 15846 newFiber.flags = Placement; 15847 return lastPlacedIndex; 15848 } else { 15849 // This item can stay in place. 15850 return oldIndex; 15851 } 15852 } else { 15853 // This is an insertion. 15854 newFiber.flags = Placement; 15855 return lastPlacedIndex; 15856 } 15857 } 15858 15859 function placeSingleChild(newFiber) { 15860 // This is simpler for the single child case. We only need to do a 15861 // placement for inserting new children. 15862 if (shouldTrackSideEffects && newFiber.alternate === null) { 15863 newFiber.flags = Placement; 15864 } 15865 15866 return newFiber; 15867 } 15868 15869 function updateTextNode(returnFiber, current, textContent, lanes) { 15870 if (current === null || current.tag !== HostText) { 15871 // Insert 15872 var created = createFiberFromText(textContent, returnFiber.mode, lanes); 15873 created.return = returnFiber; 15874 return created; 15875 } else { 15876 // Update 15877 var existing = useFiber(current, textContent); 15878 existing.return = returnFiber; 15879 return existing; 15880 } 15881 } 15882 15883 function updateElement(returnFiber, current, element, lanes) { 15884 if (current !== null) { 15885 if (current.elementType === element.type || ( // Keep this check inline so it only runs on the false path: 15886 isCompatibleFamilyForHotReloading(current, element) )) { 15887 // Move based on index 15888 var existing = useFiber(current, element.props); 15889 existing.ref = coerceRef(returnFiber, current, element); 15890 existing.return = returnFiber; 15891 15892 { 15893 existing._debugSource = element._source; 15894 existing._debugOwner = element._owner; 15895 } 15896 15897 return existing; 15898 } 15899 } // Insert 15900 15901 15902 var created = createFiberFromElement(element, returnFiber.mode, lanes); 15903 created.ref = coerceRef(returnFiber, current, element); 15904 created.return = returnFiber; 15905 return created; 15906 } 15907 15908 function updatePortal(returnFiber, current, portal, lanes) { 15909 if (current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.implementation) { 15910 // Insert 15911 var created = createFiberFromPortal(portal, returnFiber.mode, lanes); 15912 created.return = returnFiber; 15913 return created; 15914 } else { 15915 // Update 15916 var existing = useFiber(current, portal.children || []); 15917 existing.return = returnFiber; 15918 return existing; 15919 } 15920 } 15921 15922 function updateFragment(returnFiber, current, fragment, lanes, key) { 15923 if (current === null || current.tag !== Fragment) { 15924 // Insert 15925 var created = createFiberFromFragment(fragment, returnFiber.mode, lanes, key); 15926 created.return = returnFiber; 15927 return created; 15928 } else { 15929 // Update 15930 var existing = useFiber(current, fragment); 15931 existing.return = returnFiber; 15932 return existing; 15933 } 15934 } 15935 15936 function createChild(returnFiber, newChild, lanes) { 15937 if (typeof newChild === 'string' || typeof newChild === 'number') { 15938 // Text nodes don't have keys. If the previous node is implicitly keyed 15939 // we can continue to replace it without aborting even if it is not a text 15940 // node. 15941 var created = createFiberFromText('' + newChild, returnFiber.mode, lanes); 15942 created.return = returnFiber; 15943 return created; 15944 } 15945 15946 if (typeof newChild === 'object' && newChild !== null) { 15947 switch (newChild.$$typeof) { 15948 case REACT_ELEMENT_TYPE: 15949 { 15950 var _created = createFiberFromElement(newChild, returnFiber.mode, lanes); 15951 15952 _created.ref = coerceRef(returnFiber, null, newChild); 15953 _created.return = returnFiber; 15954 return _created; 15955 } 15956 15957 case REACT_PORTAL_TYPE: 15958 { 15959 var _created2 = createFiberFromPortal(newChild, returnFiber.mode, lanes); 15960 15961 _created2.return = returnFiber; 15962 return _created2; 15963 } 15964 } 15965 15966 if (isArray$1(newChild) || getIteratorFn(newChild)) { 15967 var _created3 = createFiberFromFragment(newChild, returnFiber.mode, lanes, null); 15968 15969 _created3.return = returnFiber; 15970 return _created3; 15971 } 15972 15973 throwOnInvalidObjectType(returnFiber, newChild); 15974 } 15975 15976 { 15977 if (typeof newChild === 'function') { 15978 warnOnFunctionType(returnFiber); 15979 } 15980 } 15981 15982 return null; 15983 } 15984 15985 function updateSlot(returnFiber, oldFiber, newChild, lanes) { 15986 // Update the fiber if the keys match, otherwise return null. 15987 var key = oldFiber !== null ? oldFiber.key : null; 15988 15989 if (typeof newChild === 'string' || typeof newChild === 'number') { 15990 // Text nodes don't have keys. If the previous node is implicitly keyed 15991 // we can continue to replace it without aborting even if it is not a text 15992 // node. 15993 if (key !== null) { 15994 return null; 15995 } 15996 15997 return updateTextNode(returnFiber, oldFiber, '' + newChild, lanes); 15998 } 15999 16000 if (typeof newChild === 'object' && newChild !== null) { 16001 switch (newChild.$$typeof) { 16002 case REACT_ELEMENT_TYPE: 16003 { 16004 if (newChild.key === key) { 16005 if (newChild.type === REACT_FRAGMENT_TYPE) { 16006 return updateFragment(returnFiber, oldFiber, newChild.props.children, lanes, key); 16007 } 16008 16009 return updateElement(returnFiber, oldFiber, newChild, lanes); 16010 } else { 16011 return null; 16012 } 16013 } 16014 16015 case REACT_PORTAL_TYPE: 16016 { 16017 if (newChild.key === key) { 16018 return updatePortal(returnFiber, oldFiber, newChild, lanes); 16019 } else { 16020 return null; 16021 } 16022 } 16023 } 16024 16025 if (isArray$1(newChild) || getIteratorFn(newChild)) { 16026 if (key !== null) { 16027 return null; 16028 } 16029 16030 return updateFragment(returnFiber, oldFiber, newChild, lanes, null); 16031 } 16032 16033 throwOnInvalidObjectType(returnFiber, newChild); 16034 } 16035 16036 { 16037 if (typeof newChild === 'function') { 16038 warnOnFunctionType(returnFiber); 16039 } 16040 } 16041 16042 return null; 16043 } 16044 16045 function updateFromMap(existingChildren, returnFiber, newIdx, newChild, lanes) { 16046 if (typeof newChild === 'string' || typeof newChild === 'number') { 16047 // Text nodes don't have keys, so we neither have to check the old nor 16048 // new node for the key. If both are text nodes, they match. 16049 var matchedFiber = existingChildren.get(newIdx) || null; 16050 return updateTextNode(returnFiber, matchedFiber, '' + newChild, lanes); 16051 } 16052 16053 if (typeof newChild === 'object' && newChild !== null) { 16054 switch (newChild.$$typeof) { 16055 case REACT_ELEMENT_TYPE: 16056 { 16057 var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null; 16058 16059 if (newChild.type === REACT_FRAGMENT_TYPE) { 16060 return updateFragment(returnFiber, _matchedFiber, newChild.props.children, lanes, newChild.key); 16061 } 16062 16063 return updateElement(returnFiber, _matchedFiber, newChild, lanes); 16064 } 16065 16066 case REACT_PORTAL_TYPE: 16067 { 16068 var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null; 16069 16070 return updatePortal(returnFiber, _matchedFiber2, newChild, lanes); 16071 } 16072 16073 } 16074 16075 if (isArray$1(newChild) || getIteratorFn(newChild)) { 16076 var _matchedFiber3 = existingChildren.get(newIdx) || null; 16077 16078 return updateFragment(returnFiber, _matchedFiber3, newChild, lanes, null); 16079 } 16080 16081 throwOnInvalidObjectType(returnFiber, newChild); 16082 } 16083 16084 { 16085 if (typeof newChild === 'function') { 16086 warnOnFunctionType(returnFiber); 16087 } 16088 } 16089 16090 return null; 16091 } 16092 /** 16093 * Warns if there is a duplicate or missing key 16094 */ 16095 16096 16097 function warnOnInvalidKey(child, knownKeys, returnFiber) { 16098 { 16099 if (typeof child !== 'object' || child === null) { 16100 return knownKeys; 16101 } 16102 16103 switch (child.$$typeof) { 16104 case REACT_ELEMENT_TYPE: 16105 case REACT_PORTAL_TYPE: 16106 warnForMissingKey(child, returnFiber); 16107 var key = child.key; 16108 16109 if (typeof key !== 'string') { 16110 break; 16111 } 16112 16113 if (knownKeys === null) { 16114 knownKeys = new Set(); 16115 knownKeys.add(key); 16116 break; 16117 } 16118 16119 if (!knownKeys.has(key)) { 16120 knownKeys.add(key); 16121 break; 16122 } 16123 16124 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); 16125 16126 break; 16127 } 16128 } 16129 16130 return knownKeys; 16131 } 16132 16133 function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, lanes) { 16134 // This algorithm can't optimize by searching from both ends since we 16135 // don't have backpointers on fibers. I'm trying to see how far we can get 16136 // with that model. If it ends up not being worth the tradeoffs, we can 16137 // add it later. 16138 // Even with a two ended optimization, we'd want to optimize for the case 16139 // where there are few changes and brute force the comparison instead of 16140 // going for the Map. It'd like to explore hitting that path first in 16141 // forward-only mode and only go for the Map once we notice that we need 16142 // lots of look ahead. This doesn't handle reversal as well as two ended 16143 // search but that's unusual. Besides, for the two ended optimization to 16144 // work on Iterables, we'd need to copy the whole set. 16145 // In this first iteration, we'll just live with hitting the bad case 16146 // (adding everything to a Map) in for every insert/move. 16147 // If you change this code, also update reconcileChildrenIterator() which 16148 // uses the same algorithm. 16149 { 16150 // First, validate keys. 16151 var knownKeys = null; 16152 16153 for (var i = 0; i < newChildren.length; i++) { 16154 var child = newChildren[i]; 16155 knownKeys = warnOnInvalidKey(child, knownKeys, returnFiber); 16156 } 16157 } 16158 16159 var resultingFirstChild = null; 16160 var previousNewFiber = null; 16161 var oldFiber = currentFirstChild; 16162 var lastPlacedIndex = 0; 16163 var newIdx = 0; 16164 var nextOldFiber = null; 16165 16166 for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) { 16167 if (oldFiber.index > newIdx) { 16168 nextOldFiber = oldFiber; 16169 oldFiber = null; 16170 } else { 16171 nextOldFiber = oldFiber.sibling; 16172 } 16173 16174 var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], lanes); 16175 16176 if (newFiber === null) { 16177 // TODO: This breaks on empty slots like null children. That's 16178 // unfortunate because it triggers the slow path all the time. We need 16179 // a better way to communicate whether this was a miss or null, 16180 // boolean, undefined, etc. 16181 if (oldFiber === null) { 16182 oldFiber = nextOldFiber; 16183 } 16184 16185 break; 16186 } 16187 16188 if (shouldTrackSideEffects) { 16189 if (oldFiber && newFiber.alternate === null) { 16190 // We matched the slot, but we didn't reuse the existing fiber, so we 16191 // need to delete the existing child. 16192 deleteChild(returnFiber, oldFiber); 16193 } 16194 } 16195 16196 lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx); 16197 16198 if (previousNewFiber === null) { 16199 // TODO: Move out of the loop. This only happens for the first run. 16200 resultingFirstChild = newFiber; 16201 } else { 16202 // TODO: Defer siblings if we're not at the right index for this slot. 16203 // I.e. if we had null values before, then we want to defer this 16204 // for each null value. However, we also don't want to call updateSlot 16205 // with the previous one. 16206 previousNewFiber.sibling = newFiber; 16207 } 16208 16209 previousNewFiber = newFiber; 16210 oldFiber = nextOldFiber; 16211 } 16212 16213 if (newIdx === newChildren.length) { 16214 // We've reached the end of the new children. We can delete the rest. 16215 deleteRemainingChildren(returnFiber, oldFiber); 16216 return resultingFirstChild; 16217 } 16218 16219 if (oldFiber === null) { 16220 // If we don't have any more existing children we can choose a fast path 16221 // since the rest will all be insertions. 16222 for (; newIdx < newChildren.length; newIdx++) { 16223 var _newFiber = createChild(returnFiber, newChildren[newIdx], lanes); 16224 16225 if (_newFiber === null) { 16226 continue; 16227 } 16228 16229 lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx); 16230 16231 if (previousNewFiber === null) { 16232 // TODO: Move out of the loop. This only happens for the first run. 16233 resultingFirstChild = _newFiber; 16234 } else { 16235 previousNewFiber.sibling = _newFiber; 16236 } 16237 16238 previousNewFiber = _newFiber; 16239 } 16240 16241 return resultingFirstChild; 16242 } // Add all children to a key map for quick lookups. 16243 16244 16245 var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves. 16246 16247 for (; newIdx < newChildren.length; newIdx++) { 16248 var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], lanes); 16249 16250 if (_newFiber2 !== null) { 16251 if (shouldTrackSideEffects) { 16252 if (_newFiber2.alternate !== null) { 16253 // The new fiber is a work in progress, but if there exists a 16254 // current, that means that we reused the fiber. We need to delete 16255 // it from the child list so that we don't add it to the deletion 16256 // list. 16257 existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key); 16258 } 16259 } 16260 16261 lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx); 16262 16263 if (previousNewFiber === null) { 16264 resultingFirstChild = _newFiber2; 16265 } else { 16266 previousNewFiber.sibling = _newFiber2; 16267 } 16268 16269 previousNewFiber = _newFiber2; 16270 } 16271 } 16272 16273 if (shouldTrackSideEffects) { 16274 // Any existing children that weren't consumed above were deleted. We need 16275 // to add them to the deletion list. 16276 existingChildren.forEach(function (child) { 16277 return deleteChild(returnFiber, child); 16278 }); 16279 } 16280 16281 return resultingFirstChild; 16282 } 16283 16284 function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, lanes) { 16285 // This is the same implementation as reconcileChildrenArray(), 16286 // but using the iterator instead. 16287 var iteratorFn = getIteratorFn(newChildrenIterable); 16288 16289 if (!(typeof iteratorFn === 'function')) { 16290 { 16291 throw Error( "An object is not an iterable. This error is likely caused by a bug in React. Please file an issue." ); 16292 } 16293 } 16294 16295 { 16296 // We don't support rendering Generators because it's a mutation. 16297 // See https://github.com/facebook/react/issues/12995 16298 if (typeof Symbol === 'function' && // $FlowFixMe Flow doesn't know about toStringTag 16299 newChildrenIterable[Symbol.toStringTag] === 'Generator') { 16300 if (!didWarnAboutGenerators) { 16301 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.'); 16302 } 16303 16304 didWarnAboutGenerators = true; 16305 } // Warn about using Maps as children 16306 16307 16308 if (newChildrenIterable.entries === iteratorFn) { 16309 if (!didWarnAboutMaps) { 16310 error('Using Maps as children is not supported. ' + 'Use an array of keyed ReactElements instead.'); 16311 } 16312 16313 didWarnAboutMaps = true; 16314 } // First, validate keys. 16315 // We'll get a different iterator later for the main pass. 16316 16317 16318 var _newChildren = iteratorFn.call(newChildrenIterable); 16319 16320 if (_newChildren) { 16321 var knownKeys = null; 16322 16323 var _step = _newChildren.next(); 16324 16325 for (; !_step.done; _step = _newChildren.next()) { 16326 var child = _step.value; 16327 knownKeys = warnOnInvalidKey(child, knownKeys, returnFiber); 16328 } 16329 } 16330 } 16331 16332 var newChildren = iteratorFn.call(newChildrenIterable); 16333 16334 if (!(newChildren != null)) { 16335 { 16336 throw Error( "An iterable object provided no iterator." ); 16337 } 16338 } 16339 16340 var resultingFirstChild = null; 16341 var previousNewFiber = null; 16342 var oldFiber = currentFirstChild; 16343 var lastPlacedIndex = 0; 16344 var newIdx = 0; 16345 var nextOldFiber = null; 16346 var step = newChildren.next(); 16347 16348 for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) { 16349 if (oldFiber.index > newIdx) { 16350 nextOldFiber = oldFiber; 16351 oldFiber = null; 16352 } else { 16353 nextOldFiber = oldFiber.sibling; 16354 } 16355 16356 var newFiber = updateSlot(returnFiber, oldFiber, step.value, lanes); 16357 16358 if (newFiber === null) { 16359 // TODO: This breaks on empty slots like null children. That's 16360 // unfortunate because it triggers the slow path all the time. We need 16361 // a better way to communicate whether this was a miss or null, 16362 // boolean, undefined, etc. 16363 if (oldFiber === null) { 16364 oldFiber = nextOldFiber; 16365 } 16366 16367 break; 16368 } 16369 16370 if (shouldTrackSideEffects) { 16371 if (oldFiber && newFiber.alternate === null) { 16372 // We matched the slot, but we didn't reuse the existing fiber, so we 16373 // need to delete the existing child. 16374 deleteChild(returnFiber, oldFiber); 16375 } 16376 } 16377 16378 lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx); 16379 16380 if (previousNewFiber === null) { 16381 // TODO: Move out of the loop. This only happens for the first run. 16382 resultingFirstChild = newFiber; 16383 } else { 16384 // TODO: Defer siblings if we're not at the right index for this slot. 16385 // I.e. if we had null values before, then we want to defer this 16386 // for each null value. However, we also don't want to call updateSlot 16387 // with the previous one. 16388 previousNewFiber.sibling = newFiber; 16389 } 16390 16391 previousNewFiber = newFiber; 16392 oldFiber = nextOldFiber; 16393 } 16394 16395 if (step.done) { 16396 // We've reached the end of the new children. We can delete the rest. 16397 deleteRemainingChildren(returnFiber, oldFiber); 16398 return resultingFirstChild; 16399 } 16400 16401 if (oldFiber === null) { 16402 // If we don't have any more existing children we can choose a fast path 16403 // since the rest will all be insertions. 16404 for (; !step.done; newIdx++, step = newChildren.next()) { 16405 var _newFiber3 = createChild(returnFiber, step.value, lanes); 16406 16407 if (_newFiber3 === null) { 16408 continue; 16409 } 16410 16411 lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx); 16412 16413 if (previousNewFiber === null) { 16414 // TODO: Move out of the loop. This only happens for the first run. 16415 resultingFirstChild = _newFiber3; 16416 } else { 16417 previousNewFiber.sibling = _newFiber3; 16418 } 16419 16420 previousNewFiber = _newFiber3; 16421 } 16422 16423 return resultingFirstChild; 16424 } // Add all children to a key map for quick lookups. 16425 16426 16427 var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves. 16428 16429 for (; !step.done; newIdx++, step = newChildren.next()) { 16430 var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, lanes); 16431 16432 if (_newFiber4 !== null) { 16433 if (shouldTrackSideEffects) { 16434 if (_newFiber4.alternate !== null) { 16435 // The new fiber is a work in progress, but if there exists a 16436 // current, that means that we reused the fiber. We need to delete 16437 // it from the child list so that we don't add it to the deletion 16438 // list. 16439 existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key); 16440 } 16441 } 16442 16443 lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx); 16444 16445 if (previousNewFiber === null) { 16446 resultingFirstChild = _newFiber4; 16447 } else { 16448 previousNewFiber.sibling = _newFiber4; 16449 } 16450 16451 previousNewFiber = _newFiber4; 16452 } 16453 } 16454 16455 if (shouldTrackSideEffects) { 16456 // Any existing children that weren't consumed above were deleted. We need 16457 // to add them to the deletion list. 16458 existingChildren.forEach(function (child) { 16459 return deleteChild(returnFiber, child); 16460 }); 16461 } 16462 16463 return resultingFirstChild; 16464 } 16465 16466 function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, lanes) { 16467 // There's no need to check for keys on text nodes since we don't have a 16468 // way to define them. 16469 if (currentFirstChild !== null && currentFirstChild.tag === HostText) { 16470 // We already have an existing node so let's just update it and delete 16471 // the rest. 16472 deleteRemainingChildren(returnFiber, currentFirstChild.sibling); 16473 var existing = useFiber(currentFirstChild, textContent); 16474 existing.return = returnFiber; 16475 return existing; 16476 } // The existing first child is not a text node so we need to create one 16477 // and delete the existing ones. 16478 16479 16480 deleteRemainingChildren(returnFiber, currentFirstChild); 16481 var created = createFiberFromText(textContent, returnFiber.mode, lanes); 16482 created.return = returnFiber; 16483 return created; 16484 } 16485 16486 function reconcileSingleElement(returnFiber, currentFirstChild, element, lanes) { 16487 var key = element.key; 16488 var child = currentFirstChild; 16489 16490 while (child !== null) { 16491 // TODO: If key === null and child.key === null, then this only applies to 16492 // the first item in the list. 16493 if (child.key === key) { 16494 switch (child.tag) { 16495 case Fragment: 16496 { 16497 if (element.type === REACT_FRAGMENT_TYPE) { 16498 deleteRemainingChildren(returnFiber, child.sibling); 16499 var existing = useFiber(child, element.props.children); 16500 existing.return = returnFiber; 16501 16502 { 16503 existing._debugSource = element._source; 16504 existing._debugOwner = element._owner; 16505 } 16506 16507 return existing; 16508 } 16509 16510 break; 16511 } 16512 16513 case Block: 16514 16515 // We intentionally fallthrough here if enableBlocksAPI is not on. 16516 // eslint-disable-next-lined no-fallthrough 16517 16518 default: 16519 { 16520 if (child.elementType === element.type || ( // Keep this check inline so it only runs on the false path: 16521 isCompatibleFamilyForHotReloading(child, element) )) { 16522 deleteRemainingChildren(returnFiber, child.sibling); 16523 16524 var _existing3 = useFiber(child, element.props); 16525 16526 _existing3.ref = coerceRef(returnFiber, child, element); 16527 _existing3.return = returnFiber; 16528 16529 { 16530 _existing3._debugSource = element._source; 16531 _existing3._debugOwner = element._owner; 16532 } 16533 16534 return _existing3; 16535 } 16536 16537 break; 16538 } 16539 } // Didn't match. 16540 16541 16542 deleteRemainingChildren(returnFiber, child); 16543 break; 16544 } else { 16545 deleteChild(returnFiber, child); 16546 } 16547 16548 child = child.sibling; 16549 } 16550 16551 if (element.type === REACT_FRAGMENT_TYPE) { 16552 var created = createFiberFromFragment(element.props.children, returnFiber.mode, lanes, element.key); 16553 created.return = returnFiber; 16554 return created; 16555 } else { 16556 var _created4 = createFiberFromElement(element, returnFiber.mode, lanes); 16557 16558 _created4.ref = coerceRef(returnFiber, currentFirstChild, element); 16559 _created4.return = returnFiber; 16560 return _created4; 16561 } 16562 } 16563 16564 function reconcileSinglePortal(returnFiber, currentFirstChild, portal, lanes) { 16565 var key = portal.key; 16566 var child = currentFirstChild; 16567 16568 while (child !== null) { 16569 // TODO: If key === null and child.key === null, then this only applies to 16570 // the first item in the list. 16571 if (child.key === key) { 16572 if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) { 16573 deleteRemainingChildren(returnFiber, child.sibling); 16574 var existing = useFiber(child, portal.children || []); 16575 existing.return = returnFiber; 16576 return existing; 16577 } else { 16578 deleteRemainingChildren(returnFiber, child); 16579 break; 16580 } 16581 } else { 16582 deleteChild(returnFiber, child); 16583 } 16584 16585 child = child.sibling; 16586 } 16587 16588 var created = createFiberFromPortal(portal, returnFiber.mode, lanes); 16589 created.return = returnFiber; 16590 return created; 16591 } // This API will tag the children with the side-effect of the reconciliation 16592 // itself. They will be added to the side-effect list as we pass through the 16593 // children and the parent. 16594 16595 16596 function reconcileChildFibers(returnFiber, currentFirstChild, newChild, lanes) { 16597 // This function is not recursive. 16598 // If the top level item is an array, we treat it as a set of children, 16599 // not as a fragment. Nested arrays on the other hand will be treated as 16600 // fragment nodes. Recursion happens at the normal flow. 16601 // Handle top level unkeyed fragments as if they were arrays. 16602 // This leads to an ambiguity between <>{[...]}</> and <>...</>. 16603 // We treat the ambiguous cases above the same. 16604 var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null; 16605 16606 if (isUnkeyedTopLevelFragment) { 16607 newChild = newChild.props.children; 16608 } // Handle object types 16609 16610 16611 var isObject = typeof newChild === 'object' && newChild !== null; 16612 16613 if (isObject) { 16614 switch (newChild.$$typeof) { 16615 case REACT_ELEMENT_TYPE: 16616 return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, lanes)); 16617 16618 case REACT_PORTAL_TYPE: 16619 return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, lanes)); 16620 16621 } 16622 } 16623 16624 if (typeof newChild === 'string' || typeof newChild === 'number') { 16625 return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, lanes)); 16626 } 16627 16628 if (isArray$1(newChild)) { 16629 return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, lanes); 16630 } 16631 16632 if (getIteratorFn(newChild)) { 16633 return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, lanes); 16634 } 16635 16636 if (isObject) { 16637 throwOnInvalidObjectType(returnFiber, newChild); 16638 } 16639 16640 { 16641 if (typeof newChild === 'function') { 16642 warnOnFunctionType(returnFiber); 16643 } 16644 } 16645 16646 if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) { 16647 // If the new child is undefined, and the return fiber is a composite 16648 // component, throw an error. If Fiber return types are disabled, 16649 // we already threw above. 16650 switch (returnFiber.tag) { 16651 case ClassComponent: 16652 { 16653 { 16654 var instance = returnFiber.stateNode; 16655 16656 if (instance.render._isMockFunction) { 16657 // We allow auto-mocks to proceed as if they're returning null. 16658 break; 16659 } 16660 } 16661 } 16662 // Intentionally fall through to the next case, which handles both 16663 // functions and classes 16664 // eslint-disable-next-lined no-fallthrough 16665 16666 case Block: 16667 case FunctionComponent: 16668 case ForwardRef: 16669 case SimpleMemoComponent: 16670 { 16671 { 16672 { 16673 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." ); 16674 } 16675 } 16676 } 16677 } 16678 } // Remaining cases are all treated as empty. 16679 16680 16681 return deleteRemainingChildren(returnFiber, currentFirstChild); 16682 } 16683 16684 return reconcileChildFibers; 16685} 16686 16687var reconcileChildFibers = ChildReconciler(true); 16688var mountChildFibers = ChildReconciler(false); 16689function cloneChildFibers(current, workInProgress) { 16690 if (!(current === null || workInProgress.child === current.child)) { 16691 { 16692 throw Error( "Resuming work not yet implemented." ); 16693 } 16694 } 16695 16696 if (workInProgress.child === null) { 16697 return; 16698 } 16699 16700 var currentChild = workInProgress.child; 16701 var newChild = createWorkInProgress(currentChild, currentChild.pendingProps); 16702 workInProgress.child = newChild; 16703 newChild.return = workInProgress; 16704 16705 while (currentChild.sibling !== null) { 16706 currentChild = currentChild.sibling; 16707 newChild = newChild.sibling = createWorkInProgress(currentChild, currentChild.pendingProps); 16708 newChild.return = workInProgress; 16709 } 16710 16711 newChild.sibling = null; 16712} // Reset a workInProgress child set to prepare it for a second pass. 16713 16714function resetChildFibers(workInProgress, lanes) { 16715 var child = workInProgress.child; 16716 16717 while (child !== null) { 16718 resetWorkInProgress(child, lanes); 16719 child = child.sibling; 16720 } 16721} 16722 16723var NO_CONTEXT = {}; 16724var contextStackCursor$1 = createCursor(NO_CONTEXT); 16725var contextFiberStackCursor = createCursor(NO_CONTEXT); 16726var rootInstanceStackCursor = createCursor(NO_CONTEXT); 16727 16728function requiredContext(c) { 16729 if (!(c !== NO_CONTEXT)) { 16730 { 16731 throw Error( "Expected host context to exist. This error is likely caused by a bug in React. Please file an issue." ); 16732 } 16733 } 16734 16735 return c; 16736} 16737 16738function getRootHostContainer() { 16739 var rootInstance = requiredContext(rootInstanceStackCursor.current); 16740 return rootInstance; 16741} 16742 16743function pushHostContainer(fiber, nextRootInstance) { 16744 // Push current root instance onto the stack; 16745 // This allows us to reset root when portals are popped. 16746 push(rootInstanceStackCursor, nextRootInstance, fiber); // Track the context and the Fiber that provided it. 16747 // This enables us to pop only Fibers that provide unique contexts. 16748 16749 push(contextFiberStackCursor, fiber, fiber); // Finally, we need to push the host context to the stack. 16750 // However, we can't just call getRootHostContext() and push it because 16751 // we'd have a different number of entries on the stack depending on 16752 // whether getRootHostContext() throws somewhere in renderer code or not. 16753 // So we push an empty value first. This lets us safely unwind on errors. 16754 16755 push(contextStackCursor$1, NO_CONTEXT, fiber); 16756 var nextRootContext = getRootHostContext(nextRootInstance); // Now that we know this function doesn't throw, replace it. 16757 16758 pop(contextStackCursor$1, fiber); 16759 push(contextStackCursor$1, nextRootContext, fiber); 16760} 16761 16762function popHostContainer(fiber) { 16763 pop(contextStackCursor$1, fiber); 16764 pop(contextFiberStackCursor, fiber); 16765 pop(rootInstanceStackCursor, fiber); 16766} 16767 16768function getHostContext() { 16769 var context = requiredContext(contextStackCursor$1.current); 16770 return context; 16771} 16772 16773function pushHostContext(fiber) { 16774 var rootInstance = requiredContext(rootInstanceStackCursor.current); 16775 var context = requiredContext(contextStackCursor$1.current); 16776 var nextContext = getChildHostContext(context, fiber.type); // Don't push this Fiber's context unless it's unique. 16777 16778 if (context === nextContext) { 16779 return; 16780 } // Track the context and the Fiber that provided it. 16781 // This enables us to pop only Fibers that provide unique contexts. 16782 16783 16784 push(contextFiberStackCursor, fiber, fiber); 16785 push(contextStackCursor$1, nextContext, fiber); 16786} 16787 16788function popHostContext(fiber) { 16789 // Do not pop unless this Fiber provided the current context. 16790 // pushHostContext() only pushes Fibers that provide unique contexts. 16791 if (contextFiberStackCursor.current !== fiber) { 16792 return; 16793 } 16794 16795 pop(contextStackCursor$1, fiber); 16796 pop(contextFiberStackCursor, fiber); 16797} 16798 16799var DefaultSuspenseContext = 0; // The Suspense Context is split into two parts. The lower bits is 16800// inherited deeply down the subtree. The upper bits only affect 16801// this immediate suspense boundary and gets reset each new 16802// boundary or suspense list. 16803 16804var SubtreeSuspenseContextMask = 1; // Subtree Flags: 16805// InvisibleParentSuspenseContext indicates that one of our parent Suspense 16806// boundaries is not currently showing visible main content. 16807// Either because it is already showing a fallback or is not mounted at all. 16808// We can use this to determine if it is desirable to trigger a fallback at 16809// the parent. If not, then we might need to trigger undesirable boundaries 16810// and/or suspend the commit to avoid hiding the parent content. 16811 16812var InvisibleParentSuspenseContext = 1; // Shallow Flags: 16813// ForceSuspenseFallback can be used by SuspenseList to force newly added 16814// items into their fallback state during one of the render passes. 16815 16816var ForceSuspenseFallback = 2; 16817var suspenseStackCursor = createCursor(DefaultSuspenseContext); 16818function hasSuspenseContext(parentContext, flag) { 16819 return (parentContext & flag) !== 0; 16820} 16821function setDefaultShallowSuspenseContext(parentContext) { 16822 return parentContext & SubtreeSuspenseContextMask; 16823} 16824function setShallowSuspenseContext(parentContext, shallowContext) { 16825 return parentContext & SubtreeSuspenseContextMask | shallowContext; 16826} 16827function addSubtreeSuspenseContext(parentContext, subtreeContext) { 16828 return parentContext | subtreeContext; 16829} 16830function pushSuspenseContext(fiber, newContext) { 16831 push(suspenseStackCursor, newContext, fiber); 16832} 16833function popSuspenseContext(fiber) { 16834 pop(suspenseStackCursor, fiber); 16835} 16836 16837function shouldCaptureSuspense(workInProgress, hasInvisibleParent) { 16838 // If it was the primary children that just suspended, capture and render the 16839 // fallback. Otherwise, don't capture and bubble to the next boundary. 16840 var nextState = workInProgress.memoizedState; 16841 16842 if (nextState !== null) { 16843 if (nextState.dehydrated !== null) { 16844 // A dehydrated boundary always captures. 16845 return true; 16846 } 16847 16848 return false; 16849 } 16850 16851 var props = workInProgress.memoizedProps; // In order to capture, the Suspense component must have a fallback prop. 16852 16853 if (props.fallback === undefined) { 16854 return false; 16855 } // Regular boundaries always capture. 16856 16857 16858 if (props.unstable_avoidThisFallback !== true) { 16859 return true; 16860 } // If it's a boundary we should avoid, then we prefer to bubble up to the 16861 // parent boundary if it is currently invisible. 16862 16863 16864 if (hasInvisibleParent) { 16865 return false; 16866 } // If the parent is not able to handle it, we must handle it. 16867 16868 16869 return true; 16870} 16871function findFirstSuspended(row) { 16872 var node = row; 16873 16874 while (node !== null) { 16875 if (node.tag === SuspenseComponent) { 16876 var state = node.memoizedState; 16877 16878 if (state !== null) { 16879 var dehydrated = state.dehydrated; 16880 16881 if (dehydrated === null || isSuspenseInstancePending(dehydrated) || isSuspenseInstanceFallback(dehydrated)) { 16882 return node; 16883 } 16884 } 16885 } else if (node.tag === SuspenseListComponent && // revealOrder undefined can't be trusted because it don't 16886 // keep track of whether it suspended or not. 16887 node.memoizedProps.revealOrder !== undefined) { 16888 var didSuspend = (node.flags & DidCapture) !== NoFlags; 16889 16890 if (didSuspend) { 16891 return node; 16892 } 16893 } else if (node.child !== null) { 16894 node.child.return = node; 16895 node = node.child; 16896 continue; 16897 } 16898 16899 if (node === row) { 16900 return null; 16901 } 16902 16903 while (node.sibling === null) { 16904 if (node.return === null || node.return === row) { 16905 return null; 16906 } 16907 16908 node = node.return; 16909 } 16910 16911 node.sibling.return = node.return; 16912 node = node.sibling; 16913 } 16914 16915 return null; 16916} 16917 16918var NoFlags$1 = 16919/* */ 169200; // Represents whether effect should fire. 16921 16922var HasEffect = 16923/* */ 169241; // Represents the phase in which the effect (not the clean-up) fires. 16925 16926var Layout = 16927/* */ 169282; 16929var Passive$1 = 16930/* */ 169314; 16932 16933// This may have been an insertion or a hydration. 16934 16935var hydrationParentFiber = null; 16936var nextHydratableInstance = null; 16937var isHydrating = false; 16938 16939function enterHydrationState(fiber) { 16940 16941 var parentInstance = fiber.stateNode.containerInfo; 16942 nextHydratableInstance = getFirstHydratableChild(parentInstance); 16943 hydrationParentFiber = fiber; 16944 isHydrating = true; 16945 return true; 16946} 16947 16948function deleteHydratableInstance(returnFiber, instance) { 16949 { 16950 switch (returnFiber.tag) { 16951 case HostRoot: 16952 didNotHydrateContainerInstance(returnFiber.stateNode.containerInfo, instance); 16953 break; 16954 16955 case HostComponent: 16956 didNotHydrateInstance(returnFiber.type, returnFiber.memoizedProps, returnFiber.stateNode, instance); 16957 break; 16958 } 16959 } 16960 16961 var childToDelete = createFiberFromHostInstanceForDeletion(); 16962 childToDelete.stateNode = instance; 16963 childToDelete.return = returnFiber; 16964 childToDelete.flags = Deletion; // This might seem like it belongs on progressedFirstDeletion. However, 16965 // these children are not part of the reconciliation list of children. 16966 // Even if we abort and rereconcile the children, that will try to hydrate 16967 // again and the nodes are still in the host tree so these will be 16968 // recreated. 16969 16970 if (returnFiber.lastEffect !== null) { 16971 returnFiber.lastEffect.nextEffect = childToDelete; 16972 returnFiber.lastEffect = childToDelete; 16973 } else { 16974 returnFiber.firstEffect = returnFiber.lastEffect = childToDelete; 16975 } 16976} 16977 16978function insertNonHydratedInstance(returnFiber, fiber) { 16979 fiber.flags = fiber.flags & ~Hydrating | Placement; 16980 16981 { 16982 switch (returnFiber.tag) { 16983 case HostRoot: 16984 { 16985 var parentContainer = returnFiber.stateNode.containerInfo; 16986 16987 switch (fiber.tag) { 16988 case HostComponent: 16989 var type = fiber.type; 16990 var props = fiber.pendingProps; 16991 didNotFindHydratableContainerInstance(parentContainer, type); 16992 break; 16993 16994 case HostText: 16995 var text = fiber.pendingProps; 16996 didNotFindHydratableContainerTextInstance(parentContainer, text); 16997 break; 16998 } 16999 17000 break; 17001 } 17002 17003 case HostComponent: 17004 { 17005 var parentType = returnFiber.type; 17006 var parentProps = returnFiber.memoizedProps; 17007 var parentInstance = returnFiber.stateNode; 17008 17009 switch (fiber.tag) { 17010 case HostComponent: 17011 var _type = fiber.type; 17012 var _props = fiber.pendingProps; 17013 didNotFindHydratableInstance(parentType, parentProps, parentInstance, _type); 17014 break; 17015 17016 case HostText: 17017 var _text = fiber.pendingProps; 17018 didNotFindHydratableTextInstance(parentType, parentProps, parentInstance, _text); 17019 break; 17020 17021 case SuspenseComponent: 17022 didNotFindHydratableSuspenseInstance(parentType, parentProps); 17023 break; 17024 } 17025 17026 break; 17027 } 17028 17029 default: 17030 return; 17031 } 17032 } 17033} 17034 17035function tryHydrate(fiber, nextInstance) { 17036 switch (fiber.tag) { 17037 case HostComponent: 17038 { 17039 var type = fiber.type; 17040 var props = fiber.pendingProps; 17041 var instance = canHydrateInstance(nextInstance, type); 17042 17043 if (instance !== null) { 17044 fiber.stateNode = instance; 17045 return true; 17046 } 17047 17048 return false; 17049 } 17050 17051 case HostText: 17052 { 17053 var text = fiber.pendingProps; 17054 var textInstance = canHydrateTextInstance(nextInstance, text); 17055 17056 if (textInstance !== null) { 17057 fiber.stateNode = textInstance; 17058 return true; 17059 } 17060 17061 return false; 17062 } 17063 17064 case SuspenseComponent: 17065 { 17066 17067 return false; 17068 } 17069 17070 default: 17071 return false; 17072 } 17073} 17074 17075function tryToClaimNextHydratableInstance(fiber) { 17076 if (!isHydrating) { 17077 return; 17078 } 17079 17080 var nextInstance = nextHydratableInstance; 17081 17082 if (!nextInstance) { 17083 // Nothing to hydrate. Make it an insertion. 17084 insertNonHydratedInstance(hydrationParentFiber, fiber); 17085 isHydrating = false; 17086 hydrationParentFiber = fiber; 17087 return; 17088 } 17089 17090 var firstAttemptedInstance = nextInstance; 17091 17092 if (!tryHydrate(fiber, nextInstance)) { 17093 // If we can't hydrate this instance let's try the next one. 17094 // We use this as a heuristic. It's based on intuition and not data so it 17095 // might be flawed or unnecessary. 17096 nextInstance = getNextHydratableSibling(firstAttemptedInstance); 17097 17098 if (!nextInstance || !tryHydrate(fiber, nextInstance)) { 17099 // Nothing to hydrate. Make it an insertion. 17100 insertNonHydratedInstance(hydrationParentFiber, fiber); 17101 isHydrating = false; 17102 hydrationParentFiber = fiber; 17103 return; 17104 } // We matched the next one, we'll now assume that the first one was 17105 // superfluous and we'll delete it. Since we can't eagerly delete it 17106 // we'll have to schedule a deletion. To do that, this node needs a dummy 17107 // fiber associated with it. 17108 17109 17110 deleteHydratableInstance(hydrationParentFiber, firstAttemptedInstance); 17111 } 17112 17113 hydrationParentFiber = fiber; 17114 nextHydratableInstance = getFirstHydratableChild(nextInstance); 17115} 17116 17117function prepareToHydrateHostInstance(fiber, rootContainerInstance, hostContext) { 17118 17119 var instance = fiber.stateNode; 17120 var updatePayload = hydrateInstance(instance, fiber.type, fiber.memoizedProps, rootContainerInstance, hostContext, fiber); // TODO: Type this specific to this type of component. 17121 17122 fiber.updateQueue = updatePayload; // If the update payload indicates that there is a change or if there 17123 // is a new ref we mark this as an update. 17124 17125 if (updatePayload !== null) { 17126 return true; 17127 } 17128 17129 return false; 17130} 17131 17132function prepareToHydrateHostTextInstance(fiber) { 17133 17134 var textInstance = fiber.stateNode; 17135 var textContent = fiber.memoizedProps; 17136 var shouldUpdate = hydrateTextInstance(textInstance, textContent, fiber); 17137 17138 { 17139 if (shouldUpdate) { 17140 // We assume that prepareToHydrateHostTextInstance is called in a context where the 17141 // hydration parent is the parent host component of this host text. 17142 var returnFiber = hydrationParentFiber; 17143 17144 if (returnFiber !== null) { 17145 switch (returnFiber.tag) { 17146 case HostRoot: 17147 { 17148 var parentContainer = returnFiber.stateNode.containerInfo; 17149 didNotMatchHydratedContainerTextInstance(parentContainer, textInstance, textContent); 17150 break; 17151 } 17152 17153 case HostComponent: 17154 { 17155 var parentType = returnFiber.type; 17156 var parentProps = returnFiber.memoizedProps; 17157 var parentInstance = returnFiber.stateNode; 17158 didNotMatchHydratedTextInstance(parentType, parentProps, parentInstance, textInstance, textContent); 17159 break; 17160 } 17161 } 17162 } 17163 } 17164 } 17165 17166 return shouldUpdate; 17167} 17168 17169function skipPastDehydratedSuspenseInstance(fiber) { 17170 17171 var suspenseState = fiber.memoizedState; 17172 var suspenseInstance = suspenseState !== null ? suspenseState.dehydrated : null; 17173 17174 if (!suspenseInstance) { 17175 { 17176 throw Error( "Expected to have a hydrated suspense instance. This error is likely caused by a bug in React. Please file an issue." ); 17177 } 17178 } 17179 17180 return getNextHydratableInstanceAfterSuspenseInstance(suspenseInstance); 17181} 17182 17183function popToNextHostParent(fiber) { 17184 var parent = fiber.return; 17185 17186 while (parent !== null && parent.tag !== HostComponent && parent.tag !== HostRoot && parent.tag !== SuspenseComponent) { 17187 parent = parent.return; 17188 } 17189 17190 hydrationParentFiber = parent; 17191} 17192 17193function popHydrationState(fiber) { 17194 17195 if (fiber !== hydrationParentFiber) { 17196 // We're deeper than the current hydration context, inside an inserted 17197 // tree. 17198 return false; 17199 } 17200 17201 if (!isHydrating) { 17202 // If we're not currently hydrating but we're in a hydration context, then 17203 // we were an insertion and now need to pop up reenter hydration of our 17204 // siblings. 17205 popToNextHostParent(fiber); 17206 isHydrating = true; 17207 return false; 17208 } 17209 17210 var type = fiber.type; // If we have any remaining hydratable nodes, we need to delete them now. 17211 // We only do this deeper than head and body since they tend to have random 17212 // other nodes in them. We also ignore components with pure text content in 17213 // side of them. 17214 // TODO: Better heuristic. 17215 17216 if (fiber.tag !== HostComponent || type !== 'head' && type !== 'body' && !shouldSetTextContent(type, fiber.memoizedProps)) { 17217 var nextInstance = nextHydratableInstance; 17218 17219 while (nextInstance) { 17220 deleteHydratableInstance(fiber, nextInstance); 17221 nextInstance = getNextHydratableSibling(nextInstance); 17222 } 17223 } 17224 17225 popToNextHostParent(fiber); 17226 17227 if (fiber.tag === SuspenseComponent) { 17228 nextHydratableInstance = skipPastDehydratedSuspenseInstance(fiber); 17229 } else { 17230 nextHydratableInstance = hydrationParentFiber ? getNextHydratableSibling(fiber.stateNode) : null; 17231 } 17232 17233 return true; 17234} 17235 17236function resetHydrationState() { 17237 17238 hydrationParentFiber = null; 17239 nextHydratableInstance = null; 17240 isHydrating = false; 17241} 17242 17243function getIsHydrating() { 17244 return isHydrating; 17245} 17246 17247// and should be reset before starting a new render. 17248// This tracks which mutable sources need to be reset after a render. 17249 17250var workInProgressSources = []; 17251var rendererSigil$1; 17252 17253{ 17254 // Used to detect multiple renderers using the same mutable source. 17255 rendererSigil$1 = {}; 17256} 17257 17258function markSourceAsDirty(mutableSource) { 17259 workInProgressSources.push(mutableSource); 17260} 17261function resetWorkInProgressVersions() { 17262 for (var i = 0; i < workInProgressSources.length; i++) { 17263 var mutableSource = workInProgressSources[i]; 17264 17265 { 17266 mutableSource._workInProgressVersionPrimary = null; 17267 } 17268 } 17269 17270 workInProgressSources.length = 0; 17271} 17272function getWorkInProgressVersion(mutableSource) { 17273 { 17274 return mutableSource._workInProgressVersionPrimary; 17275 } 17276} 17277function setWorkInProgressVersion(mutableSource, version) { 17278 { 17279 mutableSource._workInProgressVersionPrimary = version; 17280 } 17281 17282 workInProgressSources.push(mutableSource); 17283} 17284function warnAboutMultipleRenderersDEV(mutableSource) { 17285 { 17286 { 17287 if (mutableSource._currentPrimaryRenderer == null) { 17288 mutableSource._currentPrimaryRenderer = rendererSigil$1; 17289 } else if (mutableSource._currentPrimaryRenderer !== rendererSigil$1) { 17290 error('Detected multiple renderers concurrently rendering the ' + 'same mutable source. This is currently unsupported.'); 17291 } 17292 } 17293 } 17294} // Eager reads the version of a mutable source and stores it on the root. 17295 17296var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher, 17297 ReactCurrentBatchConfig$1 = ReactSharedInternals.ReactCurrentBatchConfig; 17298var didWarnAboutMismatchedHooksForComponent; 17299var didWarnAboutUseOpaqueIdentifier; 17300 17301{ 17302 didWarnAboutUseOpaqueIdentifier = {}; 17303 didWarnAboutMismatchedHooksForComponent = new Set(); 17304} 17305 17306// These are set right before calling the component. 17307var renderLanes = NoLanes; // The work-in-progress fiber. I've named it differently to distinguish it from 17308// the work-in-progress hook. 17309 17310var currentlyRenderingFiber$1 = null; // Hooks are stored as a linked list on the fiber's memoizedState field. The 17311// current hook list is the list that belongs to the current fiber. The 17312// work-in-progress hook list is a new list that will be added to the 17313// work-in-progress fiber. 17314 17315var currentHook = null; 17316var workInProgressHook = null; // Whether an update was scheduled at any point during the render phase. This 17317// does not get reset if we do another render pass; only when we're completely 17318// finished evaluating this component. This is an optimization so we know 17319// whether we need to clear render phase updates after a throw. 17320 17321var didScheduleRenderPhaseUpdate = false; // Where an update was scheduled only during the current render pass. This 17322// gets reset after each attempt. 17323// TODO: Maybe there's some way to consolidate this with 17324// `didScheduleRenderPhaseUpdate`. Or with `numberOfReRenders`. 17325 17326var didScheduleRenderPhaseUpdateDuringThisPass = false; 17327var RE_RENDER_LIMIT = 25; // In DEV, this is the name of the currently executing primitive hook 17328 17329var currentHookNameInDev = null; // In DEV, this list ensures that hooks are called in the same order between renders. 17330// The list stores the order of hooks used during the initial render (mount). 17331// Subsequent renders (updates) reference this list. 17332 17333var hookTypesDev = null; 17334var hookTypesUpdateIndexDev = -1; // In DEV, this tracks whether currently rendering component needs to ignore 17335// the dependencies for Hooks that need them (e.g. useEffect or useMemo). 17336// When true, such Hooks will always be "remounted". Only used during hot reload. 17337 17338var ignorePreviousDependencies = false; 17339 17340function mountHookTypesDev() { 17341 { 17342 var hookName = currentHookNameInDev; 17343 17344 if (hookTypesDev === null) { 17345 hookTypesDev = [hookName]; 17346 } else { 17347 hookTypesDev.push(hookName); 17348 } 17349 } 17350} 17351 17352function updateHookTypesDev() { 17353 { 17354 var hookName = currentHookNameInDev; 17355 17356 if (hookTypesDev !== null) { 17357 hookTypesUpdateIndexDev++; 17358 17359 if (hookTypesDev[hookTypesUpdateIndexDev] !== hookName) { 17360 warnOnHookMismatchInDev(hookName); 17361 } 17362 } 17363 } 17364} 17365 17366function checkDepsAreArrayDev(deps) { 17367 { 17368 if (deps !== undefined && deps !== null && !Array.isArray(deps)) { 17369 // Verify deps, but only on mount to avoid extra checks. 17370 // It's unlikely their type would change as usually you define them inline. 17371 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); 17372 } 17373 } 17374} 17375 17376function warnOnHookMismatchInDev(currentHookName) { 17377 { 17378 var componentName = getComponentName(currentlyRenderingFiber$1.type); 17379 17380 if (!didWarnAboutMismatchedHooksForComponent.has(componentName)) { 17381 didWarnAboutMismatchedHooksForComponent.add(componentName); 17382 17383 if (hookTypesDev !== null) { 17384 var table = ''; 17385 var secondColumnStart = 30; 17386 17387 for (var i = 0; i <= hookTypesUpdateIndexDev; i++) { 17388 var oldHookName = hookTypesDev[i]; 17389 var newHookName = i === hookTypesUpdateIndexDev ? currentHookName : oldHookName; 17390 var row = i + 1 + ". " + oldHookName; // Extra space so second column lines up 17391 // lol @ IE not supporting String#repeat 17392 17393 while (row.length < secondColumnStart) { 17394 row += ' '; 17395 } 17396 17397 row += newHookName + '\n'; 17398 table += row; 17399 } 17400 17401 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); 17402 } 17403 } 17404 } 17405} 17406 17407function throwInvalidHookError() { 17408 { 17409 { 17410 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." ); 17411 } 17412 } 17413} 17414 17415function areHookInputsEqual(nextDeps, prevDeps) { 17416 { 17417 if (ignorePreviousDependencies) { 17418 // Only true when this component is being hot reloaded. 17419 return false; 17420 } 17421 } 17422 17423 if (prevDeps === null) { 17424 { 17425 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); 17426 } 17427 17428 return false; 17429 } 17430 17431 { 17432 // Don't bother comparing lengths in prod because these arrays should be 17433 // passed inline. 17434 if (nextDeps.length !== prevDeps.length) { 17435 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(', ') + "]"); 17436 } 17437 } 17438 17439 for (var i = 0; i < prevDeps.length && i < nextDeps.length; i++) { 17440 if (objectIs(nextDeps[i], prevDeps[i])) { 17441 continue; 17442 } 17443 17444 return false; 17445 } 17446 17447 return true; 17448} 17449 17450function renderWithHooks(current, workInProgress, Component, props, secondArg, nextRenderLanes) { 17451 renderLanes = nextRenderLanes; 17452 currentlyRenderingFiber$1 = workInProgress; 17453 17454 { 17455 hookTypesDev = current !== null ? current._debugHookTypes : null; 17456 hookTypesUpdateIndexDev = -1; // Used for hot reloading: 17457 17458 ignorePreviousDependencies = current !== null && current.type !== workInProgress.type; 17459 } 17460 17461 workInProgress.memoizedState = null; 17462 workInProgress.updateQueue = null; 17463 workInProgress.lanes = NoLanes; // The following should have already been reset 17464 // currentHook = null; 17465 // workInProgressHook = null; 17466 // didScheduleRenderPhaseUpdate = false; 17467 // TODO Warn if no hooks are used at all during mount, then some are used during update. 17468 // Currently we will identify the update render as a mount because memoizedState === null. 17469 // This is tricky because it's valid for certain types of components (e.g. React.lazy) 17470 // Using memoizedState to differentiate between mount/update only works if at least one stateful hook is used. 17471 // Non-stateful hooks (e.g. context) don't get added to memoizedState, 17472 // so memoizedState would be null during updates and mounts. 17473 17474 { 17475 if (current !== null && current.memoizedState !== null) { 17476 ReactCurrentDispatcher$1.current = HooksDispatcherOnUpdateInDEV; 17477 } else if (hookTypesDev !== null) { 17478 // This dispatcher handles an edge case where a component is updating, 17479 // but no stateful hooks have been used. 17480 // We want to match the production code behavior (which will use HooksDispatcherOnMount), 17481 // but with the extra DEV validation to ensure hooks ordering hasn't changed. 17482 // This dispatcher does that. 17483 ReactCurrentDispatcher$1.current = HooksDispatcherOnMountWithHookTypesInDEV; 17484 } else { 17485 ReactCurrentDispatcher$1.current = HooksDispatcherOnMountInDEV; 17486 } 17487 } 17488 17489 var children = Component(props, secondArg); // Check if there was a render phase update 17490 17491 if (didScheduleRenderPhaseUpdateDuringThisPass) { 17492 // Keep rendering in a loop for as long as render phase updates continue to 17493 // be scheduled. Use a counter to prevent infinite loops. 17494 var numberOfReRenders = 0; 17495 17496 do { 17497 didScheduleRenderPhaseUpdateDuringThisPass = false; 17498 17499 if (!(numberOfReRenders < RE_RENDER_LIMIT)) { 17500 { 17501 throw Error( "Too many re-renders. React limits the number of renders to prevent an infinite loop." ); 17502 } 17503 } 17504 17505 numberOfReRenders += 1; 17506 17507 { 17508 // Even when hot reloading, allow dependencies to stabilize 17509 // after first render to prevent infinite render phase updates. 17510 ignorePreviousDependencies = false; 17511 } // Start over from the beginning of the list 17512 17513 17514 currentHook = null; 17515 workInProgressHook = null; 17516 workInProgress.updateQueue = null; 17517 17518 { 17519 // Also validate hook order for cascading updates. 17520 hookTypesUpdateIndexDev = -1; 17521 } 17522 17523 ReactCurrentDispatcher$1.current = HooksDispatcherOnRerenderInDEV ; 17524 children = Component(props, secondArg); 17525 } while (didScheduleRenderPhaseUpdateDuringThisPass); 17526 } // We can assume the previous dispatcher is always this one, since we set it 17527 // at the beginning of the render phase and there's no re-entrancy. 17528 17529 17530 ReactCurrentDispatcher$1.current = ContextOnlyDispatcher; 17531 17532 { 17533 workInProgress._debugHookTypes = hookTypesDev; 17534 } // This check uses currentHook so that it works the same in DEV and prod bundles. 17535 // hookTypesDev could catch more cases (e.g. context) but only in DEV bundles. 17536 17537 17538 var didRenderTooFewHooks = currentHook !== null && currentHook.next !== null; 17539 renderLanes = NoLanes; 17540 currentlyRenderingFiber$1 = null; 17541 currentHook = null; 17542 workInProgressHook = null; 17543 17544 { 17545 currentHookNameInDev = null; 17546 hookTypesDev = null; 17547 hookTypesUpdateIndexDev = -1; 17548 } 17549 17550 didScheduleRenderPhaseUpdate = false; 17551 17552 if (!!didRenderTooFewHooks) { 17553 { 17554 throw Error( "Rendered fewer hooks than expected. This may be caused by an accidental early return statement." ); 17555 } 17556 } 17557 17558 return children; 17559} 17560function bailoutHooks(current, workInProgress, lanes) { 17561 workInProgress.updateQueue = current.updateQueue; 17562 workInProgress.flags &= ~(Passive | Update); 17563 current.lanes = removeLanes(current.lanes, lanes); 17564} 17565function resetHooksAfterThrow() { 17566 // We can assume the previous dispatcher is always this one, since we set it 17567 // at the beginning of the render phase and there's no re-entrancy. 17568 ReactCurrentDispatcher$1.current = ContextOnlyDispatcher; 17569 17570 if (didScheduleRenderPhaseUpdate) { 17571 // There were render phase updates. These are only valid for this render 17572 // phase, which we are now aborting. Remove the updates from the queues so 17573 // they do not persist to the next render. Do not remove updates from hooks 17574 // that weren't processed. 17575 // 17576 // Only reset the updates from the queue if it has a clone. If it does 17577 // not have a clone, that means it wasn't processed, and the updates were 17578 // scheduled before we entered the render phase. 17579 var hook = currentlyRenderingFiber$1.memoizedState; 17580 17581 while (hook !== null) { 17582 var queue = hook.queue; 17583 17584 if (queue !== null) { 17585 queue.pending = null; 17586 } 17587 17588 hook = hook.next; 17589 } 17590 17591 didScheduleRenderPhaseUpdate = false; 17592 } 17593 17594 renderLanes = NoLanes; 17595 currentlyRenderingFiber$1 = null; 17596 currentHook = null; 17597 workInProgressHook = null; 17598 17599 { 17600 hookTypesDev = null; 17601 hookTypesUpdateIndexDev = -1; 17602 currentHookNameInDev = null; 17603 isUpdatingOpaqueValueInRenderPhase = false; 17604 } 17605 17606 didScheduleRenderPhaseUpdateDuringThisPass = false; 17607} 17608 17609function mountWorkInProgressHook() { 17610 var hook = { 17611 memoizedState: null, 17612 baseState: null, 17613 baseQueue: null, 17614 queue: null, 17615 next: null 17616 }; 17617 17618 if (workInProgressHook === null) { 17619 // This is the first hook in the list 17620 currentlyRenderingFiber$1.memoizedState = workInProgressHook = hook; 17621 } else { 17622 // Append to the end of the list 17623 workInProgressHook = workInProgressHook.next = hook; 17624 } 17625 17626 return workInProgressHook; 17627} 17628 17629function updateWorkInProgressHook() { 17630 // This function is used both for updates and for re-renders triggered by a 17631 // render phase update. It assumes there is either a current hook we can 17632 // clone, or a work-in-progress hook from a previous render pass that we can 17633 // use as a base. When we reach the end of the base list, we must switch to 17634 // the dispatcher used for mounts. 17635 var nextCurrentHook; 17636 17637 if (currentHook === null) { 17638 var current = currentlyRenderingFiber$1.alternate; 17639 17640 if (current !== null) { 17641 nextCurrentHook = current.memoizedState; 17642 } else { 17643 nextCurrentHook = null; 17644 } 17645 } else { 17646 nextCurrentHook = currentHook.next; 17647 } 17648 17649 var nextWorkInProgressHook; 17650 17651 if (workInProgressHook === null) { 17652 nextWorkInProgressHook = currentlyRenderingFiber$1.memoizedState; 17653 } else { 17654 nextWorkInProgressHook = workInProgressHook.next; 17655 } 17656 17657 if (nextWorkInProgressHook !== null) { 17658 // There's already a work-in-progress. Reuse it. 17659 workInProgressHook = nextWorkInProgressHook; 17660 nextWorkInProgressHook = workInProgressHook.next; 17661 currentHook = nextCurrentHook; 17662 } else { 17663 // Clone from the current hook. 17664 if (!(nextCurrentHook !== null)) { 17665 { 17666 throw Error( "Rendered more hooks than during the previous render." ); 17667 } 17668 } 17669 17670 currentHook = nextCurrentHook; 17671 var newHook = { 17672 memoizedState: currentHook.memoizedState, 17673 baseState: currentHook.baseState, 17674 baseQueue: currentHook.baseQueue, 17675 queue: currentHook.queue, 17676 next: null 17677 }; 17678 17679 if (workInProgressHook === null) { 17680 // This is the first hook in the list. 17681 currentlyRenderingFiber$1.memoizedState = workInProgressHook = newHook; 17682 } else { 17683 // Append to the end of the list. 17684 workInProgressHook = workInProgressHook.next = newHook; 17685 } 17686 } 17687 17688 return workInProgressHook; 17689} 17690 17691function createFunctionComponentUpdateQueue() { 17692 return { 17693 lastEffect: null 17694 }; 17695} 17696 17697function basicStateReducer(state, action) { 17698 // $FlowFixMe: Flow doesn't like mixed types 17699 return typeof action === 'function' ? action(state) : action; 17700} 17701 17702function mountReducer(reducer, initialArg, init) { 17703 var hook = mountWorkInProgressHook(); 17704 var initialState; 17705 17706 if (init !== undefined) { 17707 initialState = init(initialArg); 17708 } else { 17709 initialState = initialArg; 17710 } 17711 17712 hook.memoizedState = hook.baseState = initialState; 17713 var queue = hook.queue = { 17714 pending: null, 17715 dispatch: null, 17716 lastRenderedReducer: reducer, 17717 lastRenderedState: initialState 17718 }; 17719 var dispatch = queue.dispatch = dispatchAction.bind(null, currentlyRenderingFiber$1, queue); 17720 return [hook.memoizedState, dispatch]; 17721} 17722 17723function updateReducer(reducer, initialArg, init) { 17724 var hook = updateWorkInProgressHook(); 17725 var queue = hook.queue; 17726 17727 if (!(queue !== null)) { 17728 { 17729 throw Error( "Should have a queue. This is likely a bug in React. Please file an issue." ); 17730 } 17731 } 17732 17733 queue.lastRenderedReducer = reducer; 17734 var current = currentHook; // The last rebase update that is NOT part of the base state. 17735 17736 var baseQueue = current.baseQueue; // The last pending update that hasn't been processed yet. 17737 17738 var pendingQueue = queue.pending; 17739 17740 if (pendingQueue !== null) { 17741 // We have new updates that haven't been processed yet. 17742 // We'll add them to the base queue. 17743 if (baseQueue !== null) { 17744 // Merge the pending queue and the base queue. 17745 var baseFirst = baseQueue.next; 17746 var pendingFirst = pendingQueue.next; 17747 baseQueue.next = pendingFirst; 17748 pendingQueue.next = baseFirst; 17749 } 17750 17751 { 17752 if (current.baseQueue !== baseQueue) { 17753 // Internal invariant that should never happen, but feasibly could in 17754 // the future if we implement resuming, or some form of that. 17755 error('Internal error: Expected work-in-progress queue to be a clone. ' + 'This is a bug in React.'); 17756 } 17757 } 17758 17759 current.baseQueue = baseQueue = pendingQueue; 17760 queue.pending = null; 17761 } 17762 17763 if (baseQueue !== null) { 17764 // We have a queue to process. 17765 var first = baseQueue.next; 17766 var newState = current.baseState; 17767 var newBaseState = null; 17768 var newBaseQueueFirst = null; 17769 var newBaseQueueLast = null; 17770 var update = first; 17771 17772 do { 17773 var updateLane = update.lane; 17774 17775 if (!isSubsetOfLanes(renderLanes, updateLane)) { 17776 // Priority is insufficient. Skip this update. If this is the first 17777 // skipped update, the previous update/state is the new base 17778 // update/state. 17779 var clone = { 17780 lane: updateLane, 17781 action: update.action, 17782 eagerReducer: update.eagerReducer, 17783 eagerState: update.eagerState, 17784 next: null 17785 }; 17786 17787 if (newBaseQueueLast === null) { 17788 newBaseQueueFirst = newBaseQueueLast = clone; 17789 newBaseState = newState; 17790 } else { 17791 newBaseQueueLast = newBaseQueueLast.next = clone; 17792 } // Update the remaining priority in the queue. 17793 // TODO: Don't need to accumulate this. Instead, we can remove 17794 // renderLanes from the original lanes. 17795 17796 17797 currentlyRenderingFiber$1.lanes = mergeLanes(currentlyRenderingFiber$1.lanes, updateLane); 17798 markSkippedUpdateLanes(updateLane); 17799 } else { 17800 // This update does have sufficient priority. 17801 if (newBaseQueueLast !== null) { 17802 var _clone = { 17803 // This update is going to be committed so we never want uncommit 17804 // it. Using NoLane works because 0 is a subset of all bitmasks, so 17805 // this will never be skipped by the check above. 17806 lane: NoLane, 17807 action: update.action, 17808 eagerReducer: update.eagerReducer, 17809 eagerState: update.eagerState, 17810 next: null 17811 }; 17812 newBaseQueueLast = newBaseQueueLast.next = _clone; 17813 } // Process this update. 17814 17815 17816 if (update.eagerReducer === reducer) { 17817 // If this update was processed eagerly, and its reducer matches the 17818 // current reducer, we can use the eagerly computed state. 17819 newState = update.eagerState; 17820 } else { 17821 var action = update.action; 17822 newState = reducer(newState, action); 17823 } 17824 } 17825 17826 update = update.next; 17827 } while (update !== null && update !== first); 17828 17829 if (newBaseQueueLast === null) { 17830 newBaseState = newState; 17831 } else { 17832 newBaseQueueLast.next = newBaseQueueFirst; 17833 } // Mark that the fiber performed work, but only if the new state is 17834 // different from the current state. 17835 17836 17837 if (!objectIs(newState, hook.memoizedState)) { 17838 markWorkInProgressReceivedUpdate(); 17839 } 17840 17841 hook.memoizedState = newState; 17842 hook.baseState = newBaseState; 17843 hook.baseQueue = newBaseQueueLast; 17844 queue.lastRenderedState = newState; 17845 } 17846 17847 var dispatch = queue.dispatch; 17848 return [hook.memoizedState, dispatch]; 17849} 17850 17851function rerenderReducer(reducer, initialArg, init) { 17852 var hook = updateWorkInProgressHook(); 17853 var queue = hook.queue; 17854 17855 if (!(queue !== null)) { 17856 { 17857 throw Error( "Should have a queue. This is likely a bug in React. Please file an issue." ); 17858 } 17859 } 17860 17861 queue.lastRenderedReducer = reducer; // This is a re-render. Apply the new render phase updates to the previous 17862 // work-in-progress hook. 17863 17864 var dispatch = queue.dispatch; 17865 var lastRenderPhaseUpdate = queue.pending; 17866 var newState = hook.memoizedState; 17867 17868 if (lastRenderPhaseUpdate !== null) { 17869 // The queue doesn't persist past this render pass. 17870 queue.pending = null; 17871 var firstRenderPhaseUpdate = lastRenderPhaseUpdate.next; 17872 var update = firstRenderPhaseUpdate; 17873 17874 do { 17875 // Process this render phase update. We don't have to check the 17876 // priority because it will always be the same as the current 17877 // render's. 17878 var action = update.action; 17879 newState = reducer(newState, action); 17880 update = update.next; 17881 } while (update !== firstRenderPhaseUpdate); // Mark that the fiber performed work, but only if the new state is 17882 // different from the current state. 17883 17884 17885 if (!objectIs(newState, hook.memoizedState)) { 17886 markWorkInProgressReceivedUpdate(); 17887 } 17888 17889 hook.memoizedState = newState; // Don't persist the state accumulated from the render phase updates to 17890 // the base state unless the queue is empty. 17891 // TODO: Not sure if this is the desired semantics, but it's what we 17892 // do for gDSFP. I can't remember why. 17893 17894 if (hook.baseQueue === null) { 17895 hook.baseState = newState; 17896 } 17897 17898 queue.lastRenderedState = newState; 17899 } 17900 17901 return [newState, dispatch]; 17902} 17903 17904function readFromUnsubcribedMutableSource(root, source, getSnapshot) { 17905 { 17906 warnAboutMultipleRenderersDEV(source); 17907 } 17908 17909 var getVersion = source._getVersion; 17910 var version = getVersion(source._source); // Is it safe for this component to read from this source during the current render? 17911 17912 var isSafeToReadFromSource = false; // Check the version first. 17913 // If this render has already been started with a specific version, 17914 // we can use it alone to determine if we can safely read from the source. 17915 17916 var currentRenderVersion = getWorkInProgressVersion(source); 17917 17918 if (currentRenderVersion !== null) { 17919 // It's safe to read if the store hasn't been mutated since the last time 17920 // we read something. 17921 isSafeToReadFromSource = currentRenderVersion === version; 17922 } else { 17923 // If there's no version, then this is the first time we've read from the 17924 // source during the current render pass, so we need to do a bit more work. 17925 // What we need to determine is if there are any hooks that already 17926 // subscribed to the source, and if so, whether there are any pending 17927 // mutations that haven't been synchronized yet. 17928 // 17929 // If there are no pending mutations, then `root.mutableReadLanes` will be 17930 // empty, and we know we can safely read. 17931 // 17932 // If there *are* pending mutations, we may still be able to safely read 17933 // if the currently rendering lanes are inclusive of the pending mutation 17934 // lanes, since that guarantees that the value we're about to read from 17935 // the source is consistent with the values that we read during the most 17936 // recent mutation. 17937 isSafeToReadFromSource = isSubsetOfLanes(renderLanes, root.mutableReadLanes); 17938 17939 if (isSafeToReadFromSource) { 17940 // If it's safe to read from this source during the current render, 17941 // store the version in case other components read from it. 17942 // A changed version number will let those components know to throw and restart the render. 17943 setWorkInProgressVersion(source, version); 17944 } 17945 } 17946 17947 if (isSafeToReadFromSource) { 17948 var snapshot = getSnapshot(source._source); 17949 17950 { 17951 if (typeof snapshot === 'function') { 17952 error('Mutable source should not return a function as the snapshot value. ' + 'Functions may close over mutable values and cause tearing.'); 17953 } 17954 } 17955 17956 return snapshot; 17957 } else { 17958 // This handles the special case of a mutable source being shared between renderers. 17959 // In that case, if the source is mutated between the first and second renderer, 17960 // The second renderer don't know that it needs to reset the WIP version during unwind, 17961 // (because the hook only marks sources as dirty if it's written to their WIP version). 17962 // That would cause this tear check to throw again and eventually be visible to the user. 17963 // We can avoid this infinite loop by explicitly marking the source as dirty. 17964 // 17965 // This can lead to tearing in the first renderer when it resumes, 17966 // but there's nothing we can do about that (short of throwing here and refusing to continue the render). 17967 markSourceAsDirty(source); 17968 17969 { 17970 { 17971 throw Error( "Cannot read from mutable source during the current render without tearing. This is a bug in React. Please file an issue." ); 17972 } 17973 } 17974 } 17975} 17976 17977function useMutableSource(hook, source, getSnapshot, subscribe) { 17978 var root = getWorkInProgressRoot(); 17979 17980 if (!(root !== null)) { 17981 { 17982 throw Error( "Expected a work-in-progress root. This is a bug in React. Please file an issue." ); 17983 } 17984 } 17985 17986 var getVersion = source._getVersion; 17987 var version = getVersion(source._source); 17988 var dispatcher = ReactCurrentDispatcher$1.current; // eslint-disable-next-line prefer-const 17989 17990 var _dispatcher$useState = dispatcher.useState(function () { 17991 return readFromUnsubcribedMutableSource(root, source, getSnapshot); 17992 }), 17993 currentSnapshot = _dispatcher$useState[0], 17994 setSnapshot = _dispatcher$useState[1]; 17995 17996 var snapshot = currentSnapshot; // Grab a handle to the state hook as well. 17997 // We use it to clear the pending update queue if we have a new source. 17998 17999 var stateHook = workInProgressHook; 18000 var memoizedState = hook.memoizedState; 18001 var refs = memoizedState.refs; 18002 var prevGetSnapshot = refs.getSnapshot; 18003 var prevSource = memoizedState.source; 18004 var prevSubscribe = memoizedState.subscribe; 18005 var fiber = currentlyRenderingFiber$1; 18006 hook.memoizedState = { 18007 refs: refs, 18008 source: source, 18009 subscribe: subscribe 18010 }; // Sync the values needed by our subscription handler after each commit. 18011 18012 dispatcher.useEffect(function () { 18013 refs.getSnapshot = getSnapshot; // Normally the dispatch function for a state hook never changes, 18014 // but this hook recreates the queue in certain cases to avoid updates from stale sources. 18015 // handleChange() below needs to reference the dispatch function without re-subscribing, 18016 // so we use a ref to ensure that it always has the latest version. 18017 18018 refs.setSnapshot = setSnapshot; // Check for a possible change between when we last rendered now. 18019 18020 var maybeNewVersion = getVersion(source._source); 18021 18022 if (!objectIs(version, maybeNewVersion)) { 18023 var maybeNewSnapshot = getSnapshot(source._source); 18024 18025 { 18026 if (typeof maybeNewSnapshot === 'function') { 18027 error('Mutable source should not return a function as the snapshot value. ' + 'Functions may close over mutable values and cause tearing.'); 18028 } 18029 } 18030 18031 if (!objectIs(snapshot, maybeNewSnapshot)) { 18032 setSnapshot(maybeNewSnapshot); 18033 var lane = requestUpdateLane(fiber); 18034 markRootMutableRead(root, lane); 18035 } // If the source mutated between render and now, 18036 // there may be state updates already scheduled from the old source. 18037 // Entangle the updates so that they render in the same batch. 18038 18039 18040 markRootEntangled(root, root.mutableReadLanes); 18041 } 18042 }, [getSnapshot, source, subscribe]); // If we got a new source or subscribe function, re-subscribe in a passive effect. 18043 18044 dispatcher.useEffect(function () { 18045 var handleChange = function () { 18046 var latestGetSnapshot = refs.getSnapshot; 18047 var latestSetSnapshot = refs.setSnapshot; 18048 18049 try { 18050 latestSetSnapshot(latestGetSnapshot(source._source)); // Record a pending mutable source update with the same expiration time. 18051 18052 var lane = requestUpdateLane(fiber); 18053 markRootMutableRead(root, lane); 18054 } catch (error) { 18055 // A selector might throw after a source mutation. 18056 // e.g. it might try to read from a part of the store that no longer exists. 18057 // In this case we should still schedule an update with React. 18058 // Worst case the selector will throw again and then an error boundary will handle it. 18059 latestSetSnapshot(function () { 18060 throw error; 18061 }); 18062 } 18063 }; 18064 18065 var unsubscribe = subscribe(source._source, handleChange); 18066 18067 { 18068 if (typeof unsubscribe !== 'function') { 18069 error('Mutable source subscribe function must return an unsubscribe function.'); 18070 } 18071 } 18072 18073 return unsubscribe; 18074 }, [source, subscribe]); // If any of the inputs to useMutableSource change, reading is potentially unsafe. 18075 // 18076 // If either the source or the subscription have changed we can't can't trust the update queue. 18077 // Maybe the source changed in a way that the old subscription ignored but the new one depends on. 18078 // 18079 // If the getSnapshot function changed, we also shouldn't rely on the update queue. 18080 // It's possible that the underlying source was mutated between the when the last "change" event fired, 18081 // and when the current render (with the new getSnapshot function) is processed. 18082 // 18083 // In both cases, we need to throw away pending updates (since they are no longer relevant) 18084 // and treat reading from the source as we do in the mount case. 18085 18086 if (!objectIs(prevGetSnapshot, getSnapshot) || !objectIs(prevSource, source) || !objectIs(prevSubscribe, subscribe)) { 18087 // Create a new queue and setState method, 18088 // So if there are interleaved updates, they get pushed to the older queue. 18089 // When this becomes current, the previous queue and dispatch method will be discarded, 18090 // including any interleaving updates that occur. 18091 var newQueue = { 18092 pending: null, 18093 dispatch: null, 18094 lastRenderedReducer: basicStateReducer, 18095 lastRenderedState: snapshot 18096 }; 18097 newQueue.dispatch = setSnapshot = dispatchAction.bind(null, currentlyRenderingFiber$1, newQueue); 18098 stateHook.queue = newQueue; 18099 stateHook.baseQueue = null; 18100 snapshot = readFromUnsubcribedMutableSource(root, source, getSnapshot); 18101 stateHook.memoizedState = stateHook.baseState = snapshot; 18102 } 18103 18104 return snapshot; 18105} 18106 18107function mountMutableSource(source, getSnapshot, subscribe) { 18108 var hook = mountWorkInProgressHook(); 18109 hook.memoizedState = { 18110 refs: { 18111 getSnapshot: getSnapshot, 18112 setSnapshot: null 18113 }, 18114 source: source, 18115 subscribe: subscribe 18116 }; 18117 return useMutableSource(hook, source, getSnapshot, subscribe); 18118} 18119 18120function updateMutableSource(source, getSnapshot, subscribe) { 18121 var hook = updateWorkInProgressHook(); 18122 return useMutableSource(hook, source, getSnapshot, subscribe); 18123} 18124 18125function mountState(initialState) { 18126 var hook = mountWorkInProgressHook(); 18127 18128 if (typeof initialState === 'function') { 18129 // $FlowFixMe: Flow doesn't like mixed types 18130 initialState = initialState(); 18131 } 18132 18133 hook.memoizedState = hook.baseState = initialState; 18134 var queue = hook.queue = { 18135 pending: null, 18136 dispatch: null, 18137 lastRenderedReducer: basicStateReducer, 18138 lastRenderedState: initialState 18139 }; 18140 var dispatch = queue.dispatch = dispatchAction.bind(null, currentlyRenderingFiber$1, queue); 18141 return [hook.memoizedState, dispatch]; 18142} 18143 18144function updateState(initialState) { 18145 return updateReducer(basicStateReducer); 18146} 18147 18148function rerenderState(initialState) { 18149 return rerenderReducer(basicStateReducer); 18150} 18151 18152function pushEffect(tag, create, destroy, deps) { 18153 var effect = { 18154 tag: tag, 18155 create: create, 18156 destroy: destroy, 18157 deps: deps, 18158 // Circular 18159 next: null 18160 }; 18161 var componentUpdateQueue = currentlyRenderingFiber$1.updateQueue; 18162 18163 if (componentUpdateQueue === null) { 18164 componentUpdateQueue = createFunctionComponentUpdateQueue(); 18165 currentlyRenderingFiber$1.updateQueue = componentUpdateQueue; 18166 componentUpdateQueue.lastEffect = effect.next = effect; 18167 } else { 18168 var lastEffect = componentUpdateQueue.lastEffect; 18169 18170 if (lastEffect === null) { 18171 componentUpdateQueue.lastEffect = effect.next = effect; 18172 } else { 18173 var firstEffect = lastEffect.next; 18174 lastEffect.next = effect; 18175 effect.next = firstEffect; 18176 componentUpdateQueue.lastEffect = effect; 18177 } 18178 } 18179 18180 return effect; 18181} 18182 18183function mountRef(initialValue) { 18184 var hook = mountWorkInProgressHook(); 18185 var ref = { 18186 current: initialValue 18187 }; 18188 18189 { 18190 Object.seal(ref); 18191 } 18192 18193 hook.memoizedState = ref; 18194 return ref; 18195} 18196 18197function updateRef(initialValue) { 18198 var hook = updateWorkInProgressHook(); 18199 return hook.memoizedState; 18200} 18201 18202function mountEffectImpl(fiberFlags, hookFlags, create, deps) { 18203 var hook = mountWorkInProgressHook(); 18204 var nextDeps = deps === undefined ? null : deps; 18205 currentlyRenderingFiber$1.flags |= fiberFlags; 18206 hook.memoizedState = pushEffect(HasEffect | hookFlags, create, undefined, nextDeps); 18207} 18208 18209function updateEffectImpl(fiberFlags, hookFlags, create, deps) { 18210 var hook = updateWorkInProgressHook(); 18211 var nextDeps = deps === undefined ? null : deps; 18212 var destroy = undefined; 18213 18214 if (currentHook !== null) { 18215 var prevEffect = currentHook.memoizedState; 18216 destroy = prevEffect.destroy; 18217 18218 if (nextDeps !== null) { 18219 var prevDeps = prevEffect.deps; 18220 18221 if (areHookInputsEqual(nextDeps, prevDeps)) { 18222 pushEffect(hookFlags, create, destroy, nextDeps); 18223 return; 18224 } 18225 } 18226 } 18227 18228 currentlyRenderingFiber$1.flags |= fiberFlags; 18229 hook.memoizedState = pushEffect(HasEffect | hookFlags, create, destroy, nextDeps); 18230} 18231 18232function mountEffect(create, deps) { 18233 { 18234 // $FlowExpectedError - jest isn't a global, and isn't recognized outside of tests 18235 if ('undefined' !== typeof jest) { 18236 warnIfNotCurrentlyActingEffectsInDEV(currentlyRenderingFiber$1); 18237 } 18238 } 18239 18240 return mountEffectImpl(Update | Passive, Passive$1, create, deps); 18241} 18242 18243function updateEffect(create, deps) { 18244 { 18245 // $FlowExpectedError - jest isn't a global, and isn't recognized outside of tests 18246 if ('undefined' !== typeof jest) { 18247 warnIfNotCurrentlyActingEffectsInDEV(currentlyRenderingFiber$1); 18248 } 18249 } 18250 18251 return updateEffectImpl(Update | Passive, Passive$1, create, deps); 18252} 18253 18254function mountLayoutEffect(create, deps) { 18255 return mountEffectImpl(Update, Layout, create, deps); 18256} 18257 18258function updateLayoutEffect(create, deps) { 18259 return updateEffectImpl(Update, Layout, create, deps); 18260} 18261 18262function imperativeHandleEffect(create, ref) { 18263 if (typeof ref === 'function') { 18264 var refCallback = ref; 18265 18266 var _inst = create(); 18267 18268 refCallback(_inst); 18269 return function () { 18270 refCallback(null); 18271 }; 18272 } else if (ref !== null && ref !== undefined) { 18273 var refObject = ref; 18274 18275 { 18276 if (!refObject.hasOwnProperty('current')) { 18277 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(', ') + '}'); 18278 } 18279 } 18280 18281 var _inst2 = create(); 18282 18283 refObject.current = _inst2; 18284 return function () { 18285 refObject.current = null; 18286 }; 18287 } 18288} 18289 18290function mountImperativeHandle(ref, create, deps) { 18291 { 18292 if (typeof create !== 'function') { 18293 error('Expected useImperativeHandle() second argument to be a function ' + 'that creates a handle. Instead received: %s.', create !== null ? typeof create : 'null'); 18294 } 18295 } // TODO: If deps are provided, should we skip comparing the ref itself? 18296 18297 18298 var effectDeps = deps !== null && deps !== undefined ? deps.concat([ref]) : null; 18299 return mountEffectImpl(Update, Layout, imperativeHandleEffect.bind(null, create, ref), effectDeps); 18300} 18301 18302function updateImperativeHandle(ref, create, deps) { 18303 { 18304 if (typeof create !== 'function') { 18305 error('Expected useImperativeHandle() second argument to be a function ' + 'that creates a handle. Instead received: %s.', create !== null ? typeof create : 'null'); 18306 } 18307 } // TODO: If deps are provided, should we skip comparing the ref itself? 18308 18309 18310 var effectDeps = deps !== null && deps !== undefined ? deps.concat([ref]) : null; 18311 return updateEffectImpl(Update, Layout, imperativeHandleEffect.bind(null, create, ref), effectDeps); 18312} 18313 18314function mountDebugValue(value, formatterFn) {// This hook is normally a no-op. 18315 // The react-debug-hooks package injects its own implementation 18316 // so that e.g. DevTools can display custom hook values. 18317} 18318 18319var updateDebugValue = mountDebugValue; 18320 18321function mountCallback(callback, deps) { 18322 var hook = mountWorkInProgressHook(); 18323 var nextDeps = deps === undefined ? null : deps; 18324 hook.memoizedState = [callback, nextDeps]; 18325 return callback; 18326} 18327 18328function updateCallback(callback, deps) { 18329 var hook = updateWorkInProgressHook(); 18330 var nextDeps = deps === undefined ? null : deps; 18331 var prevState = hook.memoizedState; 18332 18333 if (prevState !== null) { 18334 if (nextDeps !== null) { 18335 var prevDeps = prevState[1]; 18336 18337 if (areHookInputsEqual(nextDeps, prevDeps)) { 18338 return prevState[0]; 18339 } 18340 } 18341 } 18342 18343 hook.memoizedState = [callback, nextDeps]; 18344 return callback; 18345} 18346 18347function mountMemo(nextCreate, deps) { 18348 var hook = mountWorkInProgressHook(); 18349 var nextDeps = deps === undefined ? null : deps; 18350 var nextValue = nextCreate(); 18351 hook.memoizedState = [nextValue, nextDeps]; 18352 return nextValue; 18353} 18354 18355function updateMemo(nextCreate, deps) { 18356 var hook = updateWorkInProgressHook(); 18357 var nextDeps = deps === undefined ? null : deps; 18358 var prevState = hook.memoizedState; 18359 18360 if (prevState !== null) { 18361 // Assume these are defined. If they're not, areHookInputsEqual will warn. 18362 if (nextDeps !== null) { 18363 var prevDeps = prevState[1]; 18364 18365 if (areHookInputsEqual(nextDeps, prevDeps)) { 18366 return prevState[0]; 18367 } 18368 } 18369 } 18370 18371 var nextValue = nextCreate(); 18372 hook.memoizedState = [nextValue, nextDeps]; 18373 return nextValue; 18374} 18375 18376function mountDeferredValue(value) { 18377 var _mountState = mountState(value), 18378 prevValue = _mountState[0], 18379 setValue = _mountState[1]; 18380 18381 mountEffect(function () { 18382 var prevTransition = ReactCurrentBatchConfig$1.transition; 18383 ReactCurrentBatchConfig$1.transition = 1; 18384 18385 try { 18386 setValue(value); 18387 } finally { 18388 ReactCurrentBatchConfig$1.transition = prevTransition; 18389 } 18390 }, [value]); 18391 return prevValue; 18392} 18393 18394function updateDeferredValue(value) { 18395 var _updateState = updateState(), 18396 prevValue = _updateState[0], 18397 setValue = _updateState[1]; 18398 18399 updateEffect(function () { 18400 var prevTransition = ReactCurrentBatchConfig$1.transition; 18401 ReactCurrentBatchConfig$1.transition = 1; 18402 18403 try { 18404 setValue(value); 18405 } finally { 18406 ReactCurrentBatchConfig$1.transition = prevTransition; 18407 } 18408 }, [value]); 18409 return prevValue; 18410} 18411 18412function rerenderDeferredValue(value) { 18413 var _rerenderState = rerenderState(), 18414 prevValue = _rerenderState[0], 18415 setValue = _rerenderState[1]; 18416 18417 updateEffect(function () { 18418 var prevTransition = ReactCurrentBatchConfig$1.transition; 18419 ReactCurrentBatchConfig$1.transition = 1; 18420 18421 try { 18422 setValue(value); 18423 } finally { 18424 ReactCurrentBatchConfig$1.transition = prevTransition; 18425 } 18426 }, [value]); 18427 return prevValue; 18428} 18429 18430function startTransition(setPending, callback) { 18431 var priorityLevel = getCurrentPriorityLevel(); 18432 18433 { 18434 runWithPriority$1(priorityLevel < UserBlockingPriority$2 ? UserBlockingPriority$2 : priorityLevel, function () { 18435 setPending(true); 18436 }); 18437 runWithPriority$1(priorityLevel > NormalPriority$1 ? NormalPriority$1 : priorityLevel, function () { 18438 var prevTransition = ReactCurrentBatchConfig$1.transition; 18439 ReactCurrentBatchConfig$1.transition = 1; 18440 18441 try { 18442 setPending(false); 18443 callback(); 18444 } finally { 18445 ReactCurrentBatchConfig$1.transition = prevTransition; 18446 } 18447 }); 18448 } 18449} 18450 18451function mountTransition() { 18452 var _mountState2 = mountState(false), 18453 isPending = _mountState2[0], 18454 setPending = _mountState2[1]; // The `start` method can be stored on a ref, since `setPending` 18455 // never changes. 18456 18457 18458 var start = startTransition.bind(null, setPending); 18459 mountRef(start); 18460 return [start, isPending]; 18461} 18462 18463function updateTransition() { 18464 var _updateState2 = updateState(), 18465 isPending = _updateState2[0]; 18466 18467 var startRef = updateRef(); 18468 var start = startRef.current; 18469 return [start, isPending]; 18470} 18471 18472function rerenderTransition() { 18473 var _rerenderState2 = rerenderState(), 18474 isPending = _rerenderState2[0]; 18475 18476 var startRef = updateRef(); 18477 var start = startRef.current; 18478 return [start, isPending]; 18479} 18480 18481var isUpdatingOpaqueValueInRenderPhase = false; 18482function getIsUpdatingOpaqueValueInRenderPhaseInDEV() { 18483 { 18484 return isUpdatingOpaqueValueInRenderPhase; 18485 } 18486} 18487 18488function warnOnOpaqueIdentifierAccessInDEV(fiber) { 18489 { 18490 // TODO: Should warn in effects and callbacks, too 18491 var name = getComponentName(fiber.type) || 'Unknown'; 18492 18493 if (getIsRendering() && !didWarnAboutUseOpaqueIdentifier[name]) { 18494 error('The object passed back from useOpaqueIdentifier is meant to be ' + 'passed through to attributes only. Do not read the ' + 'value directly.'); 18495 18496 didWarnAboutUseOpaqueIdentifier[name] = true; 18497 } 18498 } 18499} 18500 18501function mountOpaqueIdentifier() { 18502 var makeId = makeClientIdInDEV.bind(null, warnOnOpaqueIdentifierAccessInDEV.bind(null, currentlyRenderingFiber$1)) ; 18503 18504 if (getIsHydrating()) { 18505 var didUpgrade = false; 18506 var fiber = currentlyRenderingFiber$1; 18507 18508 var readValue = function () { 18509 if (!didUpgrade) { 18510 // Only upgrade once. This works even inside the render phase because 18511 // the update is added to a shared queue, which outlasts the 18512 // in-progress render. 18513 didUpgrade = true; 18514 18515 { 18516 isUpdatingOpaqueValueInRenderPhase = true; 18517 setId(makeId()); 18518 isUpdatingOpaqueValueInRenderPhase = false; 18519 warnOnOpaqueIdentifierAccessInDEV(fiber); 18520 } 18521 } 18522 18523 { 18524 { 18525 throw Error( "The object passed back from useOpaqueIdentifier is meant to be passed through to attributes only. Do not read the value directly." ); 18526 } 18527 } 18528 }; 18529 18530 var id = makeOpaqueHydratingObject(readValue); 18531 var setId = mountState(id)[1]; 18532 18533 if ((currentlyRenderingFiber$1.mode & BlockingMode) === NoMode) { 18534 currentlyRenderingFiber$1.flags |= Update | Passive; 18535 pushEffect(HasEffect | Passive$1, function () { 18536 setId(makeId()); 18537 }, undefined, null); 18538 } 18539 18540 return id; 18541 } else { 18542 var _id = makeId(); 18543 18544 mountState(_id); 18545 return _id; 18546 } 18547} 18548 18549function updateOpaqueIdentifier() { 18550 var id = updateState()[0]; 18551 return id; 18552} 18553 18554function rerenderOpaqueIdentifier() { 18555 var id = rerenderState()[0]; 18556 return id; 18557} 18558 18559function dispatchAction(fiber, queue, action) { 18560 { 18561 if (typeof arguments[3] === 'function') { 18562 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().'); 18563 } 18564 } 18565 18566 var eventTime = requestEventTime(); 18567 var lane = requestUpdateLane(fiber); 18568 var update = { 18569 lane: lane, 18570 action: action, 18571 eagerReducer: null, 18572 eagerState: null, 18573 next: null 18574 }; // Append the update to the end of the list. 18575 18576 var pending = queue.pending; 18577 18578 if (pending === null) { 18579 // This is the first update. Create a circular list. 18580 update.next = update; 18581 } else { 18582 update.next = pending.next; 18583 pending.next = update; 18584 } 18585 18586 queue.pending = update; 18587 var alternate = fiber.alternate; 18588 18589 if (fiber === currentlyRenderingFiber$1 || alternate !== null && alternate === currentlyRenderingFiber$1) { 18590 // This is a render phase update. Stash it in a lazily-created map of 18591 // queue -> linked list of updates. After this render pass, we'll restart 18592 // and apply the stashed updates on top of the work-in-progress hook. 18593 didScheduleRenderPhaseUpdateDuringThisPass = didScheduleRenderPhaseUpdate = true; 18594 } else { 18595 if (fiber.lanes === NoLanes && (alternate === null || alternate.lanes === NoLanes)) { 18596 // The queue is currently empty, which means we can eagerly compute the 18597 // next state before entering the render phase. If the new state is the 18598 // same as the current state, we may be able to bail out entirely. 18599 var lastRenderedReducer = queue.lastRenderedReducer; 18600 18601 if (lastRenderedReducer !== null) { 18602 var prevDispatcher; 18603 18604 { 18605 prevDispatcher = ReactCurrentDispatcher$1.current; 18606 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; 18607 } 18608 18609 try { 18610 var currentState = queue.lastRenderedState; 18611 var eagerState = lastRenderedReducer(currentState, action); // Stash the eagerly computed state, and the reducer used to compute 18612 // it, on the update object. If the reducer hasn't changed by the 18613 // time we enter the render phase, then the eager state can be used 18614 // without calling the reducer again. 18615 18616 update.eagerReducer = lastRenderedReducer; 18617 update.eagerState = eagerState; 18618 18619 if (objectIs(eagerState, currentState)) { 18620 // Fast path. We can bail out without scheduling React to re-render. 18621 // It's still possible that we'll need to rebase this update later, 18622 // if the component re-renders for a different reason and by that 18623 // time the reducer has changed. 18624 return; 18625 } 18626 } catch (error) {// Suppress the error. It will throw again in the render phase. 18627 } finally { 18628 { 18629 ReactCurrentDispatcher$1.current = prevDispatcher; 18630 } 18631 } 18632 } 18633 } 18634 18635 { 18636 // $FlowExpectedError - jest isn't a global, and isn't recognized outside of tests 18637 if ('undefined' !== typeof jest) { 18638 warnIfNotScopedWithMatchingAct(fiber); 18639 warnIfNotCurrentlyActingUpdatesInDev(fiber); 18640 } 18641 } 18642 18643 scheduleUpdateOnFiber(fiber, lane, eventTime); 18644 } 18645} 18646 18647var ContextOnlyDispatcher = { 18648 readContext: readContext, 18649 useCallback: throwInvalidHookError, 18650 useContext: throwInvalidHookError, 18651 useEffect: throwInvalidHookError, 18652 useImperativeHandle: throwInvalidHookError, 18653 useLayoutEffect: throwInvalidHookError, 18654 useMemo: throwInvalidHookError, 18655 useReducer: throwInvalidHookError, 18656 useRef: throwInvalidHookError, 18657 useState: throwInvalidHookError, 18658 useDebugValue: throwInvalidHookError, 18659 useDeferredValue: throwInvalidHookError, 18660 useTransition: throwInvalidHookError, 18661 useMutableSource: throwInvalidHookError, 18662 useOpaqueIdentifier: throwInvalidHookError, 18663 unstable_isNewReconciler: enableNewReconciler 18664}; 18665var HooksDispatcherOnMountInDEV = null; 18666var HooksDispatcherOnMountWithHookTypesInDEV = null; 18667var HooksDispatcherOnUpdateInDEV = null; 18668var HooksDispatcherOnRerenderInDEV = null; 18669var InvalidNestedHooksDispatcherOnMountInDEV = null; 18670var InvalidNestedHooksDispatcherOnUpdateInDEV = null; 18671var InvalidNestedHooksDispatcherOnRerenderInDEV = null; 18672 18673{ 18674 var warnInvalidContextAccess = function () { 18675 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().'); 18676 }; 18677 18678 var warnInvalidHookAccess = function () { 18679 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'); 18680 }; 18681 18682 HooksDispatcherOnMountInDEV = { 18683 readContext: function (context, observedBits) { 18684 return readContext(context, observedBits); 18685 }, 18686 useCallback: function (callback, deps) { 18687 currentHookNameInDev = 'useCallback'; 18688 mountHookTypesDev(); 18689 checkDepsAreArrayDev(deps); 18690 return mountCallback(callback, deps); 18691 }, 18692 useContext: function (context, observedBits) { 18693 currentHookNameInDev = 'useContext'; 18694 mountHookTypesDev(); 18695 return readContext(context, observedBits); 18696 }, 18697 useEffect: function (create, deps) { 18698 currentHookNameInDev = 'useEffect'; 18699 mountHookTypesDev(); 18700 checkDepsAreArrayDev(deps); 18701 return mountEffect(create, deps); 18702 }, 18703 useImperativeHandle: function (ref, create, deps) { 18704 currentHookNameInDev = 'useImperativeHandle'; 18705 mountHookTypesDev(); 18706 checkDepsAreArrayDev(deps); 18707 return mountImperativeHandle(ref, create, deps); 18708 }, 18709 useLayoutEffect: function (create, deps) { 18710 currentHookNameInDev = 'useLayoutEffect'; 18711 mountHookTypesDev(); 18712 checkDepsAreArrayDev(deps); 18713 return mountLayoutEffect(create, deps); 18714 }, 18715 useMemo: function (create, deps) { 18716 currentHookNameInDev = 'useMemo'; 18717 mountHookTypesDev(); 18718 checkDepsAreArrayDev(deps); 18719 var prevDispatcher = ReactCurrentDispatcher$1.current; 18720 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; 18721 18722 try { 18723 return mountMemo(create, deps); 18724 } finally { 18725 ReactCurrentDispatcher$1.current = prevDispatcher; 18726 } 18727 }, 18728 useReducer: function (reducer, initialArg, init) { 18729 currentHookNameInDev = 'useReducer'; 18730 mountHookTypesDev(); 18731 var prevDispatcher = ReactCurrentDispatcher$1.current; 18732 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; 18733 18734 try { 18735 return mountReducer(reducer, initialArg, init); 18736 } finally { 18737 ReactCurrentDispatcher$1.current = prevDispatcher; 18738 } 18739 }, 18740 useRef: function (initialValue) { 18741 currentHookNameInDev = 'useRef'; 18742 mountHookTypesDev(); 18743 return mountRef(initialValue); 18744 }, 18745 useState: function (initialState) { 18746 currentHookNameInDev = 'useState'; 18747 mountHookTypesDev(); 18748 var prevDispatcher = ReactCurrentDispatcher$1.current; 18749 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; 18750 18751 try { 18752 return mountState(initialState); 18753 } finally { 18754 ReactCurrentDispatcher$1.current = prevDispatcher; 18755 } 18756 }, 18757 useDebugValue: function (value, formatterFn) { 18758 currentHookNameInDev = 'useDebugValue'; 18759 mountHookTypesDev(); 18760 return mountDebugValue(); 18761 }, 18762 useDeferredValue: function (value) { 18763 currentHookNameInDev = 'useDeferredValue'; 18764 mountHookTypesDev(); 18765 return mountDeferredValue(value); 18766 }, 18767 useTransition: function () { 18768 currentHookNameInDev = 'useTransition'; 18769 mountHookTypesDev(); 18770 return mountTransition(); 18771 }, 18772 useMutableSource: function (source, getSnapshot, subscribe) { 18773 currentHookNameInDev = 'useMutableSource'; 18774 mountHookTypesDev(); 18775 return mountMutableSource(source, getSnapshot, subscribe); 18776 }, 18777 useOpaqueIdentifier: function () { 18778 currentHookNameInDev = 'useOpaqueIdentifier'; 18779 mountHookTypesDev(); 18780 return mountOpaqueIdentifier(); 18781 }, 18782 unstable_isNewReconciler: enableNewReconciler 18783 }; 18784 HooksDispatcherOnMountWithHookTypesInDEV = { 18785 readContext: function (context, observedBits) { 18786 return readContext(context, observedBits); 18787 }, 18788 useCallback: function (callback, deps) { 18789 currentHookNameInDev = 'useCallback'; 18790 updateHookTypesDev(); 18791 return mountCallback(callback, deps); 18792 }, 18793 useContext: function (context, observedBits) { 18794 currentHookNameInDev = 'useContext'; 18795 updateHookTypesDev(); 18796 return readContext(context, observedBits); 18797 }, 18798 useEffect: function (create, deps) { 18799 currentHookNameInDev = 'useEffect'; 18800 updateHookTypesDev(); 18801 return mountEffect(create, deps); 18802 }, 18803 useImperativeHandle: function (ref, create, deps) { 18804 currentHookNameInDev = 'useImperativeHandle'; 18805 updateHookTypesDev(); 18806 return mountImperativeHandle(ref, create, deps); 18807 }, 18808 useLayoutEffect: function (create, deps) { 18809 currentHookNameInDev = 'useLayoutEffect'; 18810 updateHookTypesDev(); 18811 return mountLayoutEffect(create, deps); 18812 }, 18813 useMemo: function (create, deps) { 18814 currentHookNameInDev = 'useMemo'; 18815 updateHookTypesDev(); 18816 var prevDispatcher = ReactCurrentDispatcher$1.current; 18817 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; 18818 18819 try { 18820 return mountMemo(create, deps); 18821 } finally { 18822 ReactCurrentDispatcher$1.current = prevDispatcher; 18823 } 18824 }, 18825 useReducer: function (reducer, initialArg, init) { 18826 currentHookNameInDev = 'useReducer'; 18827 updateHookTypesDev(); 18828 var prevDispatcher = ReactCurrentDispatcher$1.current; 18829 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; 18830 18831 try { 18832 return mountReducer(reducer, initialArg, init); 18833 } finally { 18834 ReactCurrentDispatcher$1.current = prevDispatcher; 18835 } 18836 }, 18837 useRef: function (initialValue) { 18838 currentHookNameInDev = 'useRef'; 18839 updateHookTypesDev(); 18840 return mountRef(initialValue); 18841 }, 18842 useState: function (initialState) { 18843 currentHookNameInDev = 'useState'; 18844 updateHookTypesDev(); 18845 var prevDispatcher = ReactCurrentDispatcher$1.current; 18846 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; 18847 18848 try { 18849 return mountState(initialState); 18850 } finally { 18851 ReactCurrentDispatcher$1.current = prevDispatcher; 18852 } 18853 }, 18854 useDebugValue: function (value, formatterFn) { 18855 currentHookNameInDev = 'useDebugValue'; 18856 updateHookTypesDev(); 18857 return mountDebugValue(); 18858 }, 18859 useDeferredValue: function (value) { 18860 currentHookNameInDev = 'useDeferredValue'; 18861 updateHookTypesDev(); 18862 return mountDeferredValue(value); 18863 }, 18864 useTransition: function () { 18865 currentHookNameInDev = 'useTransition'; 18866 updateHookTypesDev(); 18867 return mountTransition(); 18868 }, 18869 useMutableSource: function (source, getSnapshot, subscribe) { 18870 currentHookNameInDev = 'useMutableSource'; 18871 updateHookTypesDev(); 18872 return mountMutableSource(source, getSnapshot, subscribe); 18873 }, 18874 useOpaqueIdentifier: function () { 18875 currentHookNameInDev = 'useOpaqueIdentifier'; 18876 updateHookTypesDev(); 18877 return mountOpaqueIdentifier(); 18878 }, 18879 unstable_isNewReconciler: enableNewReconciler 18880 }; 18881 HooksDispatcherOnUpdateInDEV = { 18882 readContext: function (context, observedBits) { 18883 return readContext(context, observedBits); 18884 }, 18885 useCallback: function (callback, deps) { 18886 currentHookNameInDev = 'useCallback'; 18887 updateHookTypesDev(); 18888 return updateCallback(callback, deps); 18889 }, 18890 useContext: function (context, observedBits) { 18891 currentHookNameInDev = 'useContext'; 18892 updateHookTypesDev(); 18893 return readContext(context, observedBits); 18894 }, 18895 useEffect: function (create, deps) { 18896 currentHookNameInDev = 'useEffect'; 18897 updateHookTypesDev(); 18898 return updateEffect(create, deps); 18899 }, 18900 useImperativeHandle: function (ref, create, deps) { 18901 currentHookNameInDev = 'useImperativeHandle'; 18902 updateHookTypesDev(); 18903 return updateImperativeHandle(ref, create, deps); 18904 }, 18905 useLayoutEffect: function (create, deps) { 18906 currentHookNameInDev = 'useLayoutEffect'; 18907 updateHookTypesDev(); 18908 return updateLayoutEffect(create, deps); 18909 }, 18910 useMemo: function (create, deps) { 18911 currentHookNameInDev = 'useMemo'; 18912 updateHookTypesDev(); 18913 var prevDispatcher = ReactCurrentDispatcher$1.current; 18914 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; 18915 18916 try { 18917 return updateMemo(create, deps); 18918 } finally { 18919 ReactCurrentDispatcher$1.current = prevDispatcher; 18920 } 18921 }, 18922 useReducer: function (reducer, initialArg, init) { 18923 currentHookNameInDev = 'useReducer'; 18924 updateHookTypesDev(); 18925 var prevDispatcher = ReactCurrentDispatcher$1.current; 18926 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; 18927 18928 try { 18929 return updateReducer(reducer, initialArg, init); 18930 } finally { 18931 ReactCurrentDispatcher$1.current = prevDispatcher; 18932 } 18933 }, 18934 useRef: function (initialValue) { 18935 currentHookNameInDev = 'useRef'; 18936 updateHookTypesDev(); 18937 return updateRef(); 18938 }, 18939 useState: function (initialState) { 18940 currentHookNameInDev = 'useState'; 18941 updateHookTypesDev(); 18942 var prevDispatcher = ReactCurrentDispatcher$1.current; 18943 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; 18944 18945 try { 18946 return updateState(initialState); 18947 } finally { 18948 ReactCurrentDispatcher$1.current = prevDispatcher; 18949 } 18950 }, 18951 useDebugValue: function (value, formatterFn) { 18952 currentHookNameInDev = 'useDebugValue'; 18953 updateHookTypesDev(); 18954 return updateDebugValue(); 18955 }, 18956 useDeferredValue: function (value) { 18957 currentHookNameInDev = 'useDeferredValue'; 18958 updateHookTypesDev(); 18959 return updateDeferredValue(value); 18960 }, 18961 useTransition: function () { 18962 currentHookNameInDev = 'useTransition'; 18963 updateHookTypesDev(); 18964 return updateTransition(); 18965 }, 18966 useMutableSource: function (source, getSnapshot, subscribe) { 18967 currentHookNameInDev = 'useMutableSource'; 18968 updateHookTypesDev(); 18969 return updateMutableSource(source, getSnapshot, subscribe); 18970 }, 18971 useOpaqueIdentifier: function () { 18972 currentHookNameInDev = 'useOpaqueIdentifier'; 18973 updateHookTypesDev(); 18974 return updateOpaqueIdentifier(); 18975 }, 18976 unstable_isNewReconciler: enableNewReconciler 18977 }; 18978 HooksDispatcherOnRerenderInDEV = { 18979 readContext: function (context, observedBits) { 18980 return readContext(context, observedBits); 18981 }, 18982 useCallback: function (callback, deps) { 18983 currentHookNameInDev = 'useCallback'; 18984 updateHookTypesDev(); 18985 return updateCallback(callback, deps); 18986 }, 18987 useContext: function (context, observedBits) { 18988 currentHookNameInDev = 'useContext'; 18989 updateHookTypesDev(); 18990 return readContext(context, observedBits); 18991 }, 18992 useEffect: function (create, deps) { 18993 currentHookNameInDev = 'useEffect'; 18994 updateHookTypesDev(); 18995 return updateEffect(create, deps); 18996 }, 18997 useImperativeHandle: function (ref, create, deps) { 18998 currentHookNameInDev = 'useImperativeHandle'; 18999 updateHookTypesDev(); 19000 return updateImperativeHandle(ref, create, deps); 19001 }, 19002 useLayoutEffect: function (create, deps) { 19003 currentHookNameInDev = 'useLayoutEffect'; 19004 updateHookTypesDev(); 19005 return updateLayoutEffect(create, deps); 19006 }, 19007 useMemo: function (create, deps) { 19008 currentHookNameInDev = 'useMemo'; 19009 updateHookTypesDev(); 19010 var prevDispatcher = ReactCurrentDispatcher$1.current; 19011 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnRerenderInDEV; 19012 19013 try { 19014 return updateMemo(create, deps); 19015 } finally { 19016 ReactCurrentDispatcher$1.current = prevDispatcher; 19017 } 19018 }, 19019 useReducer: function (reducer, initialArg, init) { 19020 currentHookNameInDev = 'useReducer'; 19021 updateHookTypesDev(); 19022 var prevDispatcher = ReactCurrentDispatcher$1.current; 19023 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnRerenderInDEV; 19024 19025 try { 19026 return rerenderReducer(reducer, initialArg, init); 19027 } finally { 19028 ReactCurrentDispatcher$1.current = prevDispatcher; 19029 } 19030 }, 19031 useRef: function (initialValue) { 19032 currentHookNameInDev = 'useRef'; 19033 updateHookTypesDev(); 19034 return updateRef(); 19035 }, 19036 useState: function (initialState) { 19037 currentHookNameInDev = 'useState'; 19038 updateHookTypesDev(); 19039 var prevDispatcher = ReactCurrentDispatcher$1.current; 19040 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnRerenderInDEV; 19041 19042 try { 19043 return rerenderState(initialState); 19044 } finally { 19045 ReactCurrentDispatcher$1.current = prevDispatcher; 19046 } 19047 }, 19048 useDebugValue: function (value, formatterFn) { 19049 currentHookNameInDev = 'useDebugValue'; 19050 updateHookTypesDev(); 19051 return updateDebugValue(); 19052 }, 19053 useDeferredValue: function (value) { 19054 currentHookNameInDev = 'useDeferredValue'; 19055 updateHookTypesDev(); 19056 return rerenderDeferredValue(value); 19057 }, 19058 useTransition: function () { 19059 currentHookNameInDev = 'useTransition'; 19060 updateHookTypesDev(); 19061 return rerenderTransition(); 19062 }, 19063 useMutableSource: function (source, getSnapshot, subscribe) { 19064 currentHookNameInDev = 'useMutableSource'; 19065 updateHookTypesDev(); 19066 return updateMutableSource(source, getSnapshot, subscribe); 19067 }, 19068 useOpaqueIdentifier: function () { 19069 currentHookNameInDev = 'useOpaqueIdentifier'; 19070 updateHookTypesDev(); 19071 return rerenderOpaqueIdentifier(); 19072 }, 19073 unstable_isNewReconciler: enableNewReconciler 19074 }; 19075 InvalidNestedHooksDispatcherOnMountInDEV = { 19076 readContext: function (context, observedBits) { 19077 warnInvalidContextAccess(); 19078 return readContext(context, observedBits); 19079 }, 19080 useCallback: function (callback, deps) { 19081 currentHookNameInDev = 'useCallback'; 19082 warnInvalidHookAccess(); 19083 mountHookTypesDev(); 19084 return mountCallback(callback, deps); 19085 }, 19086 useContext: function (context, observedBits) { 19087 currentHookNameInDev = 'useContext'; 19088 warnInvalidHookAccess(); 19089 mountHookTypesDev(); 19090 return readContext(context, observedBits); 19091 }, 19092 useEffect: function (create, deps) { 19093 currentHookNameInDev = 'useEffect'; 19094 warnInvalidHookAccess(); 19095 mountHookTypesDev(); 19096 return mountEffect(create, deps); 19097 }, 19098 useImperativeHandle: function (ref, create, deps) { 19099 currentHookNameInDev = 'useImperativeHandle'; 19100 warnInvalidHookAccess(); 19101 mountHookTypesDev(); 19102 return mountImperativeHandle(ref, create, deps); 19103 }, 19104 useLayoutEffect: function (create, deps) { 19105 currentHookNameInDev = 'useLayoutEffect'; 19106 warnInvalidHookAccess(); 19107 mountHookTypesDev(); 19108 return mountLayoutEffect(create, deps); 19109 }, 19110 useMemo: function (create, deps) { 19111 currentHookNameInDev = 'useMemo'; 19112 warnInvalidHookAccess(); 19113 mountHookTypesDev(); 19114 var prevDispatcher = ReactCurrentDispatcher$1.current; 19115 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; 19116 19117 try { 19118 return mountMemo(create, deps); 19119 } finally { 19120 ReactCurrentDispatcher$1.current = prevDispatcher; 19121 } 19122 }, 19123 useReducer: function (reducer, initialArg, init) { 19124 currentHookNameInDev = 'useReducer'; 19125 warnInvalidHookAccess(); 19126 mountHookTypesDev(); 19127 var prevDispatcher = ReactCurrentDispatcher$1.current; 19128 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; 19129 19130 try { 19131 return mountReducer(reducer, initialArg, init); 19132 } finally { 19133 ReactCurrentDispatcher$1.current = prevDispatcher; 19134 } 19135 }, 19136 useRef: function (initialValue) { 19137 currentHookNameInDev = 'useRef'; 19138 warnInvalidHookAccess(); 19139 mountHookTypesDev(); 19140 return mountRef(initialValue); 19141 }, 19142 useState: function (initialState) { 19143 currentHookNameInDev = 'useState'; 19144 warnInvalidHookAccess(); 19145 mountHookTypesDev(); 19146 var prevDispatcher = ReactCurrentDispatcher$1.current; 19147 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; 19148 19149 try { 19150 return mountState(initialState); 19151 } finally { 19152 ReactCurrentDispatcher$1.current = prevDispatcher; 19153 } 19154 }, 19155 useDebugValue: function (value, formatterFn) { 19156 currentHookNameInDev = 'useDebugValue'; 19157 warnInvalidHookAccess(); 19158 mountHookTypesDev(); 19159 return mountDebugValue(); 19160 }, 19161 useDeferredValue: function (value) { 19162 currentHookNameInDev = 'useDeferredValue'; 19163 warnInvalidHookAccess(); 19164 mountHookTypesDev(); 19165 return mountDeferredValue(value); 19166 }, 19167 useTransition: function () { 19168 currentHookNameInDev = 'useTransition'; 19169 warnInvalidHookAccess(); 19170 mountHookTypesDev(); 19171 return mountTransition(); 19172 }, 19173 useMutableSource: function (source, getSnapshot, subscribe) { 19174 currentHookNameInDev = 'useMutableSource'; 19175 warnInvalidHookAccess(); 19176 mountHookTypesDev(); 19177 return mountMutableSource(source, getSnapshot, subscribe); 19178 }, 19179 useOpaqueIdentifier: function () { 19180 currentHookNameInDev = 'useOpaqueIdentifier'; 19181 warnInvalidHookAccess(); 19182 mountHookTypesDev(); 19183 return mountOpaqueIdentifier(); 19184 }, 19185 unstable_isNewReconciler: enableNewReconciler 19186 }; 19187 InvalidNestedHooksDispatcherOnUpdateInDEV = { 19188 readContext: function (context, observedBits) { 19189 warnInvalidContextAccess(); 19190 return readContext(context, observedBits); 19191 }, 19192 useCallback: function (callback, deps) { 19193 currentHookNameInDev = 'useCallback'; 19194 warnInvalidHookAccess(); 19195 updateHookTypesDev(); 19196 return updateCallback(callback, deps); 19197 }, 19198 useContext: function (context, observedBits) { 19199 currentHookNameInDev = 'useContext'; 19200 warnInvalidHookAccess(); 19201 updateHookTypesDev(); 19202 return readContext(context, observedBits); 19203 }, 19204 useEffect: function (create, deps) { 19205 currentHookNameInDev = 'useEffect'; 19206 warnInvalidHookAccess(); 19207 updateHookTypesDev(); 19208 return updateEffect(create, deps); 19209 }, 19210 useImperativeHandle: function (ref, create, deps) { 19211 currentHookNameInDev = 'useImperativeHandle'; 19212 warnInvalidHookAccess(); 19213 updateHookTypesDev(); 19214 return updateImperativeHandle(ref, create, deps); 19215 }, 19216 useLayoutEffect: function (create, deps) { 19217 currentHookNameInDev = 'useLayoutEffect'; 19218 warnInvalidHookAccess(); 19219 updateHookTypesDev(); 19220 return updateLayoutEffect(create, deps); 19221 }, 19222 useMemo: function (create, deps) { 19223 currentHookNameInDev = 'useMemo'; 19224 warnInvalidHookAccess(); 19225 updateHookTypesDev(); 19226 var prevDispatcher = ReactCurrentDispatcher$1.current; 19227 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; 19228 19229 try { 19230 return updateMemo(create, deps); 19231 } finally { 19232 ReactCurrentDispatcher$1.current = prevDispatcher; 19233 } 19234 }, 19235 useReducer: function (reducer, initialArg, init) { 19236 currentHookNameInDev = 'useReducer'; 19237 warnInvalidHookAccess(); 19238 updateHookTypesDev(); 19239 var prevDispatcher = ReactCurrentDispatcher$1.current; 19240 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; 19241 19242 try { 19243 return updateReducer(reducer, initialArg, init); 19244 } finally { 19245 ReactCurrentDispatcher$1.current = prevDispatcher; 19246 } 19247 }, 19248 useRef: function (initialValue) { 19249 currentHookNameInDev = 'useRef'; 19250 warnInvalidHookAccess(); 19251 updateHookTypesDev(); 19252 return updateRef(); 19253 }, 19254 useState: function (initialState) { 19255 currentHookNameInDev = 'useState'; 19256 warnInvalidHookAccess(); 19257 updateHookTypesDev(); 19258 var prevDispatcher = ReactCurrentDispatcher$1.current; 19259 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; 19260 19261 try { 19262 return updateState(initialState); 19263 } finally { 19264 ReactCurrentDispatcher$1.current = prevDispatcher; 19265 } 19266 }, 19267 useDebugValue: function (value, formatterFn) { 19268 currentHookNameInDev = 'useDebugValue'; 19269 warnInvalidHookAccess(); 19270 updateHookTypesDev(); 19271 return updateDebugValue(); 19272 }, 19273 useDeferredValue: function (value) { 19274 currentHookNameInDev = 'useDeferredValue'; 19275 warnInvalidHookAccess(); 19276 updateHookTypesDev(); 19277 return updateDeferredValue(value); 19278 }, 19279 useTransition: function () { 19280 currentHookNameInDev = 'useTransition'; 19281 warnInvalidHookAccess(); 19282 updateHookTypesDev(); 19283 return updateTransition(); 19284 }, 19285 useMutableSource: function (source, getSnapshot, subscribe) { 19286 currentHookNameInDev = 'useMutableSource'; 19287 warnInvalidHookAccess(); 19288 updateHookTypesDev(); 19289 return updateMutableSource(source, getSnapshot, subscribe); 19290 }, 19291 useOpaqueIdentifier: function () { 19292 currentHookNameInDev = 'useOpaqueIdentifier'; 19293 warnInvalidHookAccess(); 19294 updateHookTypesDev(); 19295 return updateOpaqueIdentifier(); 19296 }, 19297 unstable_isNewReconciler: enableNewReconciler 19298 }; 19299 InvalidNestedHooksDispatcherOnRerenderInDEV = { 19300 readContext: function (context, observedBits) { 19301 warnInvalidContextAccess(); 19302 return readContext(context, observedBits); 19303 }, 19304 useCallback: function (callback, deps) { 19305 currentHookNameInDev = 'useCallback'; 19306 warnInvalidHookAccess(); 19307 updateHookTypesDev(); 19308 return updateCallback(callback, deps); 19309 }, 19310 useContext: function (context, observedBits) { 19311 currentHookNameInDev = 'useContext'; 19312 warnInvalidHookAccess(); 19313 updateHookTypesDev(); 19314 return readContext(context, observedBits); 19315 }, 19316 useEffect: function (create, deps) { 19317 currentHookNameInDev = 'useEffect'; 19318 warnInvalidHookAccess(); 19319 updateHookTypesDev(); 19320 return updateEffect(create, deps); 19321 }, 19322 useImperativeHandle: function (ref, create, deps) { 19323 currentHookNameInDev = 'useImperativeHandle'; 19324 warnInvalidHookAccess(); 19325 updateHookTypesDev(); 19326 return updateImperativeHandle(ref, create, deps); 19327 }, 19328 useLayoutEffect: function (create, deps) { 19329 currentHookNameInDev = 'useLayoutEffect'; 19330 warnInvalidHookAccess(); 19331 updateHookTypesDev(); 19332 return updateLayoutEffect(create, deps); 19333 }, 19334 useMemo: function (create, deps) { 19335 currentHookNameInDev = 'useMemo'; 19336 warnInvalidHookAccess(); 19337 updateHookTypesDev(); 19338 var prevDispatcher = ReactCurrentDispatcher$1.current; 19339 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; 19340 19341 try { 19342 return updateMemo(create, deps); 19343 } finally { 19344 ReactCurrentDispatcher$1.current = prevDispatcher; 19345 } 19346 }, 19347 useReducer: function (reducer, initialArg, init) { 19348 currentHookNameInDev = 'useReducer'; 19349 warnInvalidHookAccess(); 19350 updateHookTypesDev(); 19351 var prevDispatcher = ReactCurrentDispatcher$1.current; 19352 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; 19353 19354 try { 19355 return rerenderReducer(reducer, initialArg, init); 19356 } finally { 19357 ReactCurrentDispatcher$1.current = prevDispatcher; 19358 } 19359 }, 19360 useRef: function (initialValue) { 19361 currentHookNameInDev = 'useRef'; 19362 warnInvalidHookAccess(); 19363 updateHookTypesDev(); 19364 return updateRef(); 19365 }, 19366 useState: function (initialState) { 19367 currentHookNameInDev = 'useState'; 19368 warnInvalidHookAccess(); 19369 updateHookTypesDev(); 19370 var prevDispatcher = ReactCurrentDispatcher$1.current; 19371 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; 19372 19373 try { 19374 return rerenderState(initialState); 19375 } finally { 19376 ReactCurrentDispatcher$1.current = prevDispatcher; 19377 } 19378 }, 19379 useDebugValue: function (value, formatterFn) { 19380 currentHookNameInDev = 'useDebugValue'; 19381 warnInvalidHookAccess(); 19382 updateHookTypesDev(); 19383 return updateDebugValue(); 19384 }, 19385 useDeferredValue: function (value) { 19386 currentHookNameInDev = 'useDeferredValue'; 19387 warnInvalidHookAccess(); 19388 updateHookTypesDev(); 19389 return rerenderDeferredValue(value); 19390 }, 19391 useTransition: function () { 19392 currentHookNameInDev = 'useTransition'; 19393 warnInvalidHookAccess(); 19394 updateHookTypesDev(); 19395 return rerenderTransition(); 19396 }, 19397 useMutableSource: function (source, getSnapshot, subscribe) { 19398 currentHookNameInDev = 'useMutableSource'; 19399 warnInvalidHookAccess(); 19400 updateHookTypesDev(); 19401 return updateMutableSource(source, getSnapshot, subscribe); 19402 }, 19403 useOpaqueIdentifier: function () { 19404 currentHookNameInDev = 'useOpaqueIdentifier'; 19405 warnInvalidHookAccess(); 19406 updateHookTypesDev(); 19407 return rerenderOpaqueIdentifier(); 19408 }, 19409 unstable_isNewReconciler: enableNewReconciler 19410 }; 19411} 19412 19413var now$1 = Scheduler.unstable_now; 19414var commitTime = 0; 19415var profilerStartTime = -1; 19416 19417function getCommitTime() { 19418 return commitTime; 19419} 19420 19421function recordCommitTime() { 19422 19423 commitTime = now$1(); 19424} 19425 19426function startProfilerTimer(fiber) { 19427 19428 profilerStartTime = now$1(); 19429 19430 if (fiber.actualStartTime < 0) { 19431 fiber.actualStartTime = now$1(); 19432 } 19433} 19434 19435function stopProfilerTimerIfRunning(fiber) { 19436 19437 profilerStartTime = -1; 19438} 19439 19440function stopProfilerTimerIfRunningAndRecordDelta(fiber, overrideBaseTime) { 19441 19442 if (profilerStartTime >= 0) { 19443 var elapsedTime = now$1() - profilerStartTime; 19444 fiber.actualDuration += elapsedTime; 19445 19446 if (overrideBaseTime) { 19447 fiber.selfBaseDuration = elapsedTime; 19448 } 19449 19450 profilerStartTime = -1; 19451 } 19452} 19453 19454function transferActualDuration(fiber) { 19455 // Transfer time spent rendering these children so we don't lose it 19456 // after we rerender. This is used as a helper in special cases 19457 // where we should count the work of multiple passes. 19458 var child = fiber.child; 19459 19460 while (child) { 19461 fiber.actualDuration += child.actualDuration; 19462 child = child.sibling; 19463 } 19464} 19465 19466var ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner; 19467var didReceiveUpdate = false; 19468var didWarnAboutBadClass; 19469var didWarnAboutModulePatternComponent; 19470var didWarnAboutContextTypeOnFunctionComponent; 19471var didWarnAboutGetDerivedStateOnFunctionComponent; 19472var didWarnAboutFunctionRefs; 19473var didWarnAboutReassigningProps; 19474var didWarnAboutRevealOrder; 19475var didWarnAboutTailOptions; 19476 19477{ 19478 didWarnAboutBadClass = {}; 19479 didWarnAboutModulePatternComponent = {}; 19480 didWarnAboutContextTypeOnFunctionComponent = {}; 19481 didWarnAboutGetDerivedStateOnFunctionComponent = {}; 19482 didWarnAboutFunctionRefs = {}; 19483 didWarnAboutReassigningProps = false; 19484 didWarnAboutRevealOrder = {}; 19485 didWarnAboutTailOptions = {}; 19486} 19487 19488function reconcileChildren(current, workInProgress, nextChildren, renderLanes) { 19489 if (current === null) { 19490 // If this is a fresh new component that hasn't been rendered yet, we 19491 // won't update its child set by applying minimal side-effects. Instead, 19492 // we will add them all to the child before it gets rendered. That means 19493 // we can optimize this reconciliation pass by not tracking side-effects. 19494 workInProgress.child = mountChildFibers(workInProgress, null, nextChildren, renderLanes); 19495 } else { 19496 // If the current child is the same as the work in progress, it means that 19497 // we haven't yet started any work on these children. Therefore, we use 19498 // the clone algorithm to create a copy of all the current children. 19499 // If we had any progressed work already, that is invalid at this point so 19500 // let's throw it out. 19501 workInProgress.child = reconcileChildFibers(workInProgress, current.child, nextChildren, renderLanes); 19502 } 19503} 19504 19505function forceUnmountCurrentAndReconcile(current, workInProgress, nextChildren, renderLanes) { 19506 // This function is fork of reconcileChildren. It's used in cases where we 19507 // want to reconcile without matching against the existing set. This has the 19508 // effect of all current children being unmounted; even if the type and key 19509 // are the same, the old child is unmounted and a new child is created. 19510 // 19511 // To do this, we're going to go through the reconcile algorithm twice. In 19512 // the first pass, we schedule a deletion for all the current children by 19513 // passing null. 19514 workInProgress.child = reconcileChildFibers(workInProgress, current.child, null, renderLanes); // In the second pass, we mount the new children. The trick here is that we 19515 // pass null in place of where we usually pass the current child set. This has 19516 // the effect of remounting all children regardless of whether their 19517 // identities match. 19518 19519 workInProgress.child = reconcileChildFibers(workInProgress, null, nextChildren, renderLanes); 19520} 19521 19522function updateForwardRef(current, workInProgress, Component, nextProps, renderLanes) { 19523 // TODO: current can be non-null here even if the component 19524 // hasn't yet mounted. This happens after the first render suspends. 19525 // We'll need to figure out if this is fine or can cause issues. 19526 { 19527 if (workInProgress.type !== workInProgress.elementType) { 19528 // Lazy component props can't be validated in createElement 19529 // because they're only guaranteed to be resolved here. 19530 var innerPropTypes = Component.propTypes; 19531 19532 if (innerPropTypes) { 19533 checkPropTypes(innerPropTypes, nextProps, // Resolved props 19534 'prop', getComponentName(Component)); 19535 } 19536 } 19537 } 19538 19539 var render = Component.render; 19540 var ref = workInProgress.ref; // The rest is a fork of updateFunctionComponent 19541 19542 var nextChildren; 19543 prepareToReadContext(workInProgress, renderLanes); 19544 19545 { 19546 ReactCurrentOwner$1.current = workInProgress; 19547 setIsRendering(true); 19548 nextChildren = renderWithHooks(current, workInProgress, render, nextProps, ref, renderLanes); 19549 19550 if ( workInProgress.mode & StrictMode) { 19551 disableLogs(); 19552 19553 try { 19554 nextChildren = renderWithHooks(current, workInProgress, render, nextProps, ref, renderLanes); 19555 } finally { 19556 reenableLogs(); 19557 } 19558 } 19559 19560 setIsRendering(false); 19561 } 19562 19563 if (current !== null && !didReceiveUpdate) { 19564 bailoutHooks(current, workInProgress, renderLanes); 19565 return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); 19566 } // React DevTools reads this flag. 19567 19568 19569 workInProgress.flags |= PerformedWork; 19570 reconcileChildren(current, workInProgress, nextChildren, renderLanes); 19571 return workInProgress.child; 19572} 19573 19574function updateMemoComponent(current, workInProgress, Component, nextProps, updateLanes, renderLanes) { 19575 if (current === null) { 19576 var type = Component.type; 19577 19578 if (isSimpleFunctionComponent(type) && Component.compare === null && // SimpleMemoComponent codepath doesn't resolve outer props either. 19579 Component.defaultProps === undefined) { 19580 var resolvedType = type; 19581 19582 { 19583 resolvedType = resolveFunctionForHotReloading(type); 19584 } // If this is a plain function component without default props, 19585 // and with only the default shallow comparison, we upgrade it 19586 // to a SimpleMemoComponent to allow fast path updates. 19587 19588 19589 workInProgress.tag = SimpleMemoComponent; 19590 workInProgress.type = resolvedType; 19591 19592 { 19593 validateFunctionComponentInDev(workInProgress, type); 19594 } 19595 19596 return updateSimpleMemoComponent(current, workInProgress, resolvedType, nextProps, updateLanes, renderLanes); 19597 } 19598 19599 { 19600 var innerPropTypes = type.propTypes; 19601 19602 if (innerPropTypes) { 19603 // Inner memo component props aren't currently validated in createElement. 19604 // We could move it there, but we'd still need this for lazy code path. 19605 checkPropTypes(innerPropTypes, nextProps, // Resolved props 19606 'prop', getComponentName(type)); 19607 } 19608 } 19609 19610 var child = createFiberFromTypeAndProps(Component.type, null, nextProps, workInProgress, workInProgress.mode, renderLanes); 19611 child.ref = workInProgress.ref; 19612 child.return = workInProgress; 19613 workInProgress.child = child; 19614 return child; 19615 } 19616 19617 { 19618 var _type = Component.type; 19619 var _innerPropTypes = _type.propTypes; 19620 19621 if (_innerPropTypes) { 19622 // Inner memo component props aren't currently validated in createElement. 19623 // We could move it there, but we'd still need this for lazy code path. 19624 checkPropTypes(_innerPropTypes, nextProps, // Resolved props 19625 'prop', getComponentName(_type)); 19626 } 19627 } 19628 19629 var currentChild = current.child; // This is always exactly one child 19630 19631 if (!includesSomeLane(updateLanes, renderLanes)) { 19632 // This will be the props with resolved defaultProps, 19633 // unlike current.memoizedProps which will be the unresolved ones. 19634 var prevProps = currentChild.memoizedProps; // Default to shallow comparison 19635 19636 var compare = Component.compare; 19637 compare = compare !== null ? compare : shallowEqual; 19638 19639 if (compare(prevProps, nextProps) && current.ref === workInProgress.ref) { 19640 return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); 19641 } 19642 } // React DevTools reads this flag. 19643 19644 19645 workInProgress.flags |= PerformedWork; 19646 var newChild = createWorkInProgress(currentChild, nextProps); 19647 newChild.ref = workInProgress.ref; 19648 newChild.return = workInProgress; 19649 workInProgress.child = newChild; 19650 return newChild; 19651} 19652 19653function updateSimpleMemoComponent(current, workInProgress, Component, nextProps, updateLanes, renderLanes) { 19654 // TODO: current can be non-null here even if the component 19655 // hasn't yet mounted. This happens when the inner render suspends. 19656 // We'll need to figure out if this is fine or can cause issues. 19657 { 19658 if (workInProgress.type !== workInProgress.elementType) { 19659 // Lazy component props can't be validated in createElement 19660 // because they're only guaranteed to be resolved here. 19661 var outerMemoType = workInProgress.elementType; 19662 19663 if (outerMemoType.$$typeof === REACT_LAZY_TYPE) { 19664 // We warn when you define propTypes on lazy() 19665 // so let's just skip over it to find memo() outer wrapper. 19666 // Inner props for memo are validated later. 19667 var lazyComponent = outerMemoType; 19668 var payload = lazyComponent._payload; 19669 var init = lazyComponent._init; 19670 19671 try { 19672 outerMemoType = init(payload); 19673 } catch (x) { 19674 outerMemoType = null; 19675 } // Inner propTypes will be validated in the function component path. 19676 19677 19678 var outerPropTypes = outerMemoType && outerMemoType.propTypes; 19679 19680 if (outerPropTypes) { 19681 checkPropTypes(outerPropTypes, nextProps, // Resolved (SimpleMemoComponent has no defaultProps) 19682 'prop', getComponentName(outerMemoType)); 19683 } 19684 } 19685 } 19686 } 19687 19688 if (current !== null) { 19689 var prevProps = current.memoizedProps; 19690 19691 if (shallowEqual(prevProps, nextProps) && current.ref === workInProgress.ref && ( // Prevent bailout if the implementation changed due to hot reload. 19692 workInProgress.type === current.type )) { 19693 didReceiveUpdate = false; 19694 19695 if (!includesSomeLane(renderLanes, updateLanes)) { 19696 // The pending lanes were cleared at the beginning of beginWork. We're 19697 // about to bail out, but there might be other lanes that weren't 19698 // included in the current render. Usually, the priority level of the 19699 // remaining updates is accumlated during the evaluation of the 19700 // component (i.e. when processing the update queue). But since since 19701 // we're bailing out early *without* evaluating the component, we need 19702 // to account for it here, too. Reset to the value of the current fiber. 19703 // NOTE: This only applies to SimpleMemoComponent, not MemoComponent, 19704 // because a MemoComponent fiber does not have hooks or an update queue; 19705 // rather, it wraps around an inner component, which may or may not 19706 // contains hooks. 19707 // TODO: Move the reset at in beginWork out of the common path so that 19708 // this is no longer necessary. 19709 workInProgress.lanes = current.lanes; 19710 return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); 19711 } else if ((current.flags & ForceUpdateForLegacySuspense) !== NoFlags) { 19712 // This is a special case that only exists for legacy mode. 19713 // See https://github.com/facebook/react/pull/19216. 19714 didReceiveUpdate = true; 19715 } 19716 } 19717 } 19718 19719 return updateFunctionComponent(current, workInProgress, Component, nextProps, renderLanes); 19720} 19721 19722function updateOffscreenComponent(current, workInProgress, renderLanes) { 19723 var nextProps = workInProgress.pendingProps; 19724 var nextChildren = nextProps.children; 19725 var prevState = current !== null ? current.memoizedState : null; 19726 19727 if (nextProps.mode === 'hidden' || nextProps.mode === 'unstable-defer-without-hiding') { 19728 if ((workInProgress.mode & ConcurrentMode) === NoMode) { 19729 // In legacy sync mode, don't defer the subtree. Render it now. 19730 // TODO: Figure out what we should do in Blocking mode. 19731 var nextState = { 19732 baseLanes: NoLanes 19733 }; 19734 workInProgress.memoizedState = nextState; 19735 pushRenderLanes(workInProgress, renderLanes); 19736 } else if (!includesSomeLane(renderLanes, OffscreenLane)) { 19737 var nextBaseLanes; 19738 19739 if (prevState !== null) { 19740 var prevBaseLanes = prevState.baseLanes; 19741 nextBaseLanes = mergeLanes(prevBaseLanes, renderLanes); 19742 } else { 19743 nextBaseLanes = renderLanes; 19744 } // Schedule this fiber to re-render at offscreen priority. Then bailout. 19745 19746 19747 { 19748 markSpawnedWork(OffscreenLane); 19749 } 19750 19751 workInProgress.lanes = workInProgress.childLanes = laneToLanes(OffscreenLane); 19752 var _nextState = { 19753 baseLanes: nextBaseLanes 19754 }; 19755 workInProgress.memoizedState = _nextState; // We're about to bail out, but we need to push this to the stack anyway 19756 // to avoid a push/pop misalignment. 19757 19758 pushRenderLanes(workInProgress, nextBaseLanes); 19759 return null; 19760 } else { 19761 // Rendering at offscreen, so we can clear the base lanes. 19762 var _nextState2 = { 19763 baseLanes: NoLanes 19764 }; 19765 workInProgress.memoizedState = _nextState2; // Push the lanes that were skipped when we bailed out. 19766 19767 var subtreeRenderLanes = prevState !== null ? prevState.baseLanes : renderLanes; 19768 pushRenderLanes(workInProgress, subtreeRenderLanes); 19769 } 19770 } else { 19771 var _subtreeRenderLanes; 19772 19773 if (prevState !== null) { 19774 _subtreeRenderLanes = mergeLanes(prevState.baseLanes, renderLanes); // Since we're not hidden anymore, reset the state 19775 19776 workInProgress.memoizedState = null; 19777 } else { 19778 // We weren't previously hidden, and we still aren't, so there's nothing 19779 // special to do. Need to push to the stack regardless, though, to avoid 19780 // a push/pop misalignment. 19781 _subtreeRenderLanes = renderLanes; 19782 } 19783 19784 pushRenderLanes(workInProgress, _subtreeRenderLanes); 19785 } 19786 19787 reconcileChildren(current, workInProgress, nextChildren, renderLanes); 19788 return workInProgress.child; 19789} // Note: These happen to have identical begin phases, for now. We shouldn't hold 19790// ourselves to this constraint, though. If the behavior diverges, we should 19791// fork the function. 19792 19793 19794var updateLegacyHiddenComponent = updateOffscreenComponent; 19795 19796function updateFragment(current, workInProgress, renderLanes) { 19797 var nextChildren = workInProgress.pendingProps; 19798 reconcileChildren(current, workInProgress, nextChildren, renderLanes); 19799 return workInProgress.child; 19800} 19801 19802function updateMode(current, workInProgress, renderLanes) { 19803 var nextChildren = workInProgress.pendingProps.children; 19804 reconcileChildren(current, workInProgress, nextChildren, renderLanes); 19805 return workInProgress.child; 19806} 19807 19808function updateProfiler(current, workInProgress, renderLanes) { 19809 { 19810 workInProgress.flags |= Update; // Reset effect durations for the next eventual effect phase. 19811 // These are reset during render to allow the DevTools commit hook a chance to read them, 19812 19813 var stateNode = workInProgress.stateNode; 19814 stateNode.effectDuration = 0; 19815 stateNode.passiveEffectDuration = 0; 19816 } 19817 19818 var nextProps = workInProgress.pendingProps; 19819 var nextChildren = nextProps.children; 19820 reconcileChildren(current, workInProgress, nextChildren, renderLanes); 19821 return workInProgress.child; 19822} 19823 19824function markRef(current, workInProgress) { 19825 var ref = workInProgress.ref; 19826 19827 if (current === null && ref !== null || current !== null && current.ref !== ref) { 19828 // Schedule a Ref effect 19829 workInProgress.flags |= Ref; 19830 } 19831} 19832 19833function updateFunctionComponent(current, workInProgress, Component, nextProps, renderLanes) { 19834 { 19835 if (workInProgress.type !== workInProgress.elementType) { 19836 // Lazy component props can't be validated in createElement 19837 // because they're only guaranteed to be resolved here. 19838 var innerPropTypes = Component.propTypes; 19839 19840 if (innerPropTypes) { 19841 checkPropTypes(innerPropTypes, nextProps, // Resolved props 19842 'prop', getComponentName(Component)); 19843 } 19844 } 19845 } 19846 19847 var context; 19848 19849 { 19850 var unmaskedContext = getUnmaskedContext(workInProgress, Component, true); 19851 context = getMaskedContext(workInProgress, unmaskedContext); 19852 } 19853 19854 var nextChildren; 19855 prepareToReadContext(workInProgress, renderLanes); 19856 19857 { 19858 ReactCurrentOwner$1.current = workInProgress; 19859 setIsRendering(true); 19860 nextChildren = renderWithHooks(current, workInProgress, Component, nextProps, context, renderLanes); 19861 19862 if ( workInProgress.mode & StrictMode) { 19863 disableLogs(); 19864 19865 try { 19866 nextChildren = renderWithHooks(current, workInProgress, Component, nextProps, context, renderLanes); 19867 } finally { 19868 reenableLogs(); 19869 } 19870 } 19871 19872 setIsRendering(false); 19873 } 19874 19875 if (current !== null && !didReceiveUpdate) { 19876 bailoutHooks(current, workInProgress, renderLanes); 19877 return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); 19878 } // React DevTools reads this flag. 19879 19880 19881 workInProgress.flags |= PerformedWork; 19882 reconcileChildren(current, workInProgress, nextChildren, renderLanes); 19883 return workInProgress.child; 19884} 19885 19886function updateClassComponent(current, workInProgress, Component, nextProps, renderLanes) { 19887 { 19888 if (workInProgress.type !== workInProgress.elementType) { 19889 // Lazy component props can't be validated in createElement 19890 // because they're only guaranteed to be resolved here. 19891 var innerPropTypes = Component.propTypes; 19892 19893 if (innerPropTypes) { 19894 checkPropTypes(innerPropTypes, nextProps, // Resolved props 19895 'prop', getComponentName(Component)); 19896 } 19897 } 19898 } // Push context providers early to prevent context stack mismatches. 19899 // During mounting we don't know the child context yet as the instance doesn't exist. 19900 // We will invalidate the child context in finishClassComponent() right after rendering. 19901 19902 19903 var hasContext; 19904 19905 if (isContextProvider(Component)) { 19906 hasContext = true; 19907 pushContextProvider(workInProgress); 19908 } else { 19909 hasContext = false; 19910 } 19911 19912 prepareToReadContext(workInProgress, renderLanes); 19913 var instance = workInProgress.stateNode; 19914 var shouldUpdate; 19915 19916 if (instance === null) { 19917 if (current !== null) { 19918 // A class component without an instance only mounts if it suspended 19919 // inside a non-concurrent tree, in an inconsistent state. We want to 19920 // treat it like a new mount, even though an empty version of it already 19921 // committed. Disconnect the alternate pointers. 19922 current.alternate = null; 19923 workInProgress.alternate = null; // Since this is conceptually a new fiber, schedule a Placement effect 19924 19925 workInProgress.flags |= Placement; 19926 } // In the initial pass we might need to construct the instance. 19927 19928 19929 constructClassInstance(workInProgress, Component, nextProps); 19930 mountClassInstance(workInProgress, Component, nextProps, renderLanes); 19931 shouldUpdate = true; 19932 } else if (current === null) { 19933 // In a resume, we'll already have an instance we can reuse. 19934 shouldUpdate = resumeMountClassInstance(workInProgress, Component, nextProps, renderLanes); 19935 } else { 19936 shouldUpdate = updateClassInstance(current, workInProgress, Component, nextProps, renderLanes); 19937 } 19938 19939 var nextUnitOfWork = finishClassComponent(current, workInProgress, Component, shouldUpdate, hasContext, renderLanes); 19940 19941 { 19942 var inst = workInProgress.stateNode; 19943 19944 if (shouldUpdate && inst.props !== nextProps) { 19945 if (!didWarnAboutReassigningProps) { 19946 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'); 19947 } 19948 19949 didWarnAboutReassigningProps = true; 19950 } 19951 } 19952 19953 return nextUnitOfWork; 19954} 19955 19956function finishClassComponent(current, workInProgress, Component, shouldUpdate, hasContext, renderLanes) { 19957 // Refs should update even if shouldComponentUpdate returns false 19958 markRef(current, workInProgress); 19959 var didCaptureError = (workInProgress.flags & DidCapture) !== NoFlags; 19960 19961 if (!shouldUpdate && !didCaptureError) { 19962 // Context providers should defer to sCU for rendering 19963 if (hasContext) { 19964 invalidateContextProvider(workInProgress, Component, false); 19965 } 19966 19967 return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); 19968 } 19969 19970 var instance = workInProgress.stateNode; // Rerender 19971 19972 ReactCurrentOwner$1.current = workInProgress; 19973 var nextChildren; 19974 19975 if (didCaptureError && typeof Component.getDerivedStateFromError !== 'function') { 19976 // If we captured an error, but getDerivedStateFromError is not defined, 19977 // unmount all the children. componentDidCatch will schedule an update to 19978 // re-render a fallback. This is temporary until we migrate everyone to 19979 // the new API. 19980 // TODO: Warn in a future release. 19981 nextChildren = null; 19982 19983 { 19984 stopProfilerTimerIfRunning(); 19985 } 19986 } else { 19987 { 19988 setIsRendering(true); 19989 nextChildren = instance.render(); 19990 19991 if ( workInProgress.mode & StrictMode) { 19992 disableLogs(); 19993 19994 try { 19995 instance.render(); 19996 } finally { 19997 reenableLogs(); 19998 } 19999 } 20000 20001 setIsRendering(false); 20002 } 20003 } // React DevTools reads this flag. 20004 20005 20006 workInProgress.flags |= PerformedWork; 20007 20008 if (current !== null && didCaptureError) { 20009 // If we're recovering from an error, reconcile without reusing any of 20010 // the existing children. Conceptually, the normal children and the children 20011 // that are shown on error are two different sets, so we shouldn't reuse 20012 // normal children even if their identities match. 20013 forceUnmountCurrentAndReconcile(current, workInProgress, nextChildren, renderLanes); 20014 } else { 20015 reconcileChildren(current, workInProgress, nextChildren, renderLanes); 20016 } // Memoize state using the values we just used to render. 20017 // TODO: Restructure so we never read values from the instance. 20018 20019 20020 workInProgress.memoizedState = instance.state; // The context might have changed so we need to recalculate it. 20021 20022 if (hasContext) { 20023 invalidateContextProvider(workInProgress, Component, true); 20024 } 20025 20026 return workInProgress.child; 20027} 20028 20029function pushHostRootContext(workInProgress) { 20030 var root = workInProgress.stateNode; 20031 20032 if (root.pendingContext) { 20033 pushTopLevelContextObject(workInProgress, root.pendingContext, root.pendingContext !== root.context); 20034 } else if (root.context) { 20035 // Should always be set 20036 pushTopLevelContextObject(workInProgress, root.context, false); 20037 } 20038 20039 pushHostContainer(workInProgress, root.containerInfo); 20040} 20041 20042function updateHostRoot(current, workInProgress, renderLanes) { 20043 pushHostRootContext(workInProgress); 20044 var updateQueue = workInProgress.updateQueue; 20045 20046 if (!(current !== null && updateQueue !== null)) { 20047 { 20048 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." ); 20049 } 20050 } 20051 20052 var nextProps = workInProgress.pendingProps; 20053 var prevState = workInProgress.memoizedState; 20054 var prevChildren = prevState !== null ? prevState.element : null; 20055 cloneUpdateQueue(current, workInProgress); 20056 processUpdateQueue(workInProgress, nextProps, null, renderLanes); 20057 var nextState = workInProgress.memoizedState; // Caution: React DevTools currently depends on this property 20058 // being called "element". 20059 20060 var nextChildren = nextState.element; 20061 20062 if (nextChildren === prevChildren) { 20063 resetHydrationState(); 20064 return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); 20065 } 20066 20067 var root = workInProgress.stateNode; 20068 20069 if (root.hydrate && enterHydrationState(workInProgress)) { 20070 // If we don't have any current children this might be the first pass. 20071 // We always try to hydrate. If this isn't a hydration pass there won't 20072 // be any children to hydrate which is effectively the same thing as 20073 // not hydrating. 20074 { 20075 var mutableSourceEagerHydrationData = root.mutableSourceEagerHydrationData; 20076 20077 if (mutableSourceEagerHydrationData != null) { 20078 for (var i = 0; i < mutableSourceEagerHydrationData.length; i += 2) { 20079 var mutableSource = mutableSourceEagerHydrationData[i]; 20080 var version = mutableSourceEagerHydrationData[i + 1]; 20081 setWorkInProgressVersion(mutableSource, version); 20082 } 20083 } 20084 } 20085 20086 var child = mountChildFibers(workInProgress, null, nextChildren, renderLanes); 20087 workInProgress.child = child; 20088 var node = child; 20089 20090 while (node) { 20091 // Mark each child as hydrating. This is a fast path to know whether this 20092 // tree is part of a hydrating tree. This is used to determine if a child 20093 // node has fully mounted yet, and for scheduling event replaying. 20094 // Conceptually this is similar to Placement in that a new subtree is 20095 // inserted into the React tree here. It just happens to not need DOM 20096 // mutations because it already exists. 20097 node.flags = node.flags & ~Placement | Hydrating; 20098 node = node.sibling; 20099 } 20100 } else { 20101 // Otherwise reset hydration state in case we aborted and resumed another 20102 // root. 20103 reconcileChildren(current, workInProgress, nextChildren, renderLanes); 20104 resetHydrationState(); 20105 } 20106 20107 return workInProgress.child; 20108} 20109 20110function updateHostComponent(current, workInProgress, renderLanes) { 20111 pushHostContext(workInProgress); 20112 20113 if (current === null) { 20114 tryToClaimNextHydratableInstance(workInProgress); 20115 } 20116 20117 var type = workInProgress.type; 20118 var nextProps = workInProgress.pendingProps; 20119 var prevProps = current !== null ? current.memoizedProps : null; 20120 var nextChildren = nextProps.children; 20121 var isDirectTextChild = shouldSetTextContent(type, nextProps); 20122 20123 if (isDirectTextChild) { 20124 // We special case a direct text child of a host node. This is a common 20125 // case. We won't handle it as a reified child. We will instead handle 20126 // this in the host environment that also has access to this prop. That 20127 // avoids allocating another HostText fiber and traversing it. 20128 nextChildren = null; 20129 } else if (prevProps !== null && shouldSetTextContent(type, prevProps)) { 20130 // If we're switching from a direct text child to a normal child, or to 20131 // empty, we need to schedule the text content to be reset. 20132 workInProgress.flags |= ContentReset; 20133 } 20134 20135 markRef(current, workInProgress); 20136 reconcileChildren(current, workInProgress, nextChildren, renderLanes); 20137 return workInProgress.child; 20138} 20139 20140function updateHostText(current, workInProgress) { 20141 if (current === null) { 20142 tryToClaimNextHydratableInstance(workInProgress); 20143 } // Nothing to do here. This is terminal. We'll do the completion step 20144 // immediately after. 20145 20146 20147 return null; 20148} 20149 20150function mountLazyComponent(_current, workInProgress, elementType, updateLanes, renderLanes) { 20151 if (_current !== null) { 20152 // A lazy component only mounts if it suspended inside a non- 20153 // concurrent tree, in an inconsistent state. We want to treat it like 20154 // a new mount, even though an empty version of it already committed. 20155 // Disconnect the alternate pointers. 20156 _current.alternate = null; 20157 workInProgress.alternate = null; // Since this is conceptually a new fiber, schedule a Placement effect 20158 20159 workInProgress.flags |= Placement; 20160 } 20161 20162 var props = workInProgress.pendingProps; 20163 var lazyComponent = elementType; 20164 var payload = lazyComponent._payload; 20165 var init = lazyComponent._init; 20166 var Component = init(payload); // Store the unwrapped component in the type. 20167 20168 workInProgress.type = Component; 20169 var resolvedTag = workInProgress.tag = resolveLazyComponentTag(Component); 20170 var resolvedProps = resolveDefaultProps(Component, props); 20171 var child; 20172 20173 switch (resolvedTag) { 20174 case FunctionComponent: 20175 { 20176 { 20177 validateFunctionComponentInDev(workInProgress, Component); 20178 workInProgress.type = Component = resolveFunctionForHotReloading(Component); 20179 } 20180 20181 child = updateFunctionComponent(null, workInProgress, Component, resolvedProps, renderLanes); 20182 return child; 20183 } 20184 20185 case ClassComponent: 20186 { 20187 { 20188 workInProgress.type = Component = resolveClassForHotReloading(Component); 20189 } 20190 20191 child = updateClassComponent(null, workInProgress, Component, resolvedProps, renderLanes); 20192 return child; 20193 } 20194 20195 case ForwardRef: 20196 { 20197 { 20198 workInProgress.type = Component = resolveForwardRefForHotReloading(Component); 20199 } 20200 20201 child = updateForwardRef(null, workInProgress, Component, resolvedProps, renderLanes); 20202 return child; 20203 } 20204 20205 case MemoComponent: 20206 { 20207 { 20208 if (workInProgress.type !== workInProgress.elementType) { 20209 var outerPropTypes = Component.propTypes; 20210 20211 if (outerPropTypes) { 20212 checkPropTypes(outerPropTypes, resolvedProps, // Resolved for outer only 20213 'prop', getComponentName(Component)); 20214 } 20215 } 20216 } 20217 20218 child = updateMemoComponent(null, workInProgress, Component, resolveDefaultProps(Component.type, resolvedProps), // The inner type can have defaults too 20219 updateLanes, renderLanes); 20220 return child; 20221 } 20222 } 20223 20224 var hint = ''; 20225 20226 { 20227 if (Component !== null && typeof Component === 'object' && Component.$$typeof === REACT_LAZY_TYPE) { 20228 hint = ' Did you wrap a component in React.lazy() more than once?'; 20229 } 20230 } // This message intentionally doesn't mention ForwardRef or MemoComponent 20231 // because the fact that it's a separate type of work is an 20232 // implementation detail. 20233 20234 20235 { 20236 { 20237 throw Error( "Element type is invalid. Received a promise that resolves to: " + Component + ". Lazy element type must resolve to a class or function." + hint ); 20238 } 20239 } 20240} 20241 20242function mountIncompleteClassComponent(_current, workInProgress, Component, nextProps, renderLanes) { 20243 if (_current !== null) { 20244 // An incomplete component only mounts if it suspended inside a non- 20245 // concurrent tree, in an inconsistent state. We want to treat it like 20246 // a new mount, even though an empty version of it already committed. 20247 // Disconnect the alternate pointers. 20248 _current.alternate = null; 20249 workInProgress.alternate = null; // Since this is conceptually a new fiber, schedule a Placement effect 20250 20251 workInProgress.flags |= Placement; 20252 } // Promote the fiber to a class and try rendering again. 20253 20254 20255 workInProgress.tag = ClassComponent; // The rest of this function is a fork of `updateClassComponent` 20256 // Push context providers early to prevent context stack mismatches. 20257 // During mounting we don't know the child context yet as the instance doesn't exist. 20258 // We will invalidate the child context in finishClassComponent() right after rendering. 20259 20260 var hasContext; 20261 20262 if (isContextProvider(Component)) { 20263 hasContext = true; 20264 pushContextProvider(workInProgress); 20265 } else { 20266 hasContext = false; 20267 } 20268 20269 prepareToReadContext(workInProgress, renderLanes); 20270 constructClassInstance(workInProgress, Component, nextProps); 20271 mountClassInstance(workInProgress, Component, nextProps, renderLanes); 20272 return finishClassComponent(null, workInProgress, Component, true, hasContext, renderLanes); 20273} 20274 20275function mountIndeterminateComponent(_current, workInProgress, Component, renderLanes) { 20276 if (_current !== null) { 20277 // An indeterminate component only mounts if it suspended inside a non- 20278 // concurrent tree, in an inconsistent state. We want to treat it like 20279 // a new mount, even though an empty version of it already committed. 20280 // Disconnect the alternate pointers. 20281 _current.alternate = null; 20282 workInProgress.alternate = null; // Since this is conceptually a new fiber, schedule a Placement effect 20283 20284 workInProgress.flags |= Placement; 20285 } 20286 20287 var props = workInProgress.pendingProps; 20288 var context; 20289 20290 { 20291 var unmaskedContext = getUnmaskedContext(workInProgress, Component, false); 20292 context = getMaskedContext(workInProgress, unmaskedContext); 20293 } 20294 20295 prepareToReadContext(workInProgress, renderLanes); 20296 var value; 20297 20298 { 20299 if (Component.prototype && typeof Component.prototype.render === 'function') { 20300 var componentName = getComponentName(Component) || 'Unknown'; 20301 20302 if (!didWarnAboutBadClass[componentName]) { 20303 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); 20304 20305 didWarnAboutBadClass[componentName] = true; 20306 } 20307 } 20308 20309 if (workInProgress.mode & StrictMode) { 20310 ReactStrictModeWarnings.recordLegacyContextWarning(workInProgress, null); 20311 } 20312 20313 setIsRendering(true); 20314 ReactCurrentOwner$1.current = workInProgress; 20315 value = renderWithHooks(null, workInProgress, Component, props, context, renderLanes); 20316 setIsRendering(false); 20317 } // React DevTools reads this flag. 20318 20319 20320 workInProgress.flags |= PerformedWork; 20321 20322 { 20323 // Support for module components is deprecated and is removed behind a flag. 20324 // Whether or not it would crash later, we want to show a good message in DEV first. 20325 if (typeof value === 'object' && value !== null && typeof value.render === 'function' && value.$$typeof === undefined) { 20326 var _componentName = getComponentName(Component) || 'Unknown'; 20327 20328 if (!didWarnAboutModulePatternComponent[_componentName]) { 20329 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); 20330 20331 didWarnAboutModulePatternComponent[_componentName] = true; 20332 } 20333 } 20334 } 20335 20336 if ( // Run these checks in production only if the flag is off. 20337 // Eventually we'll delete this branch altogether. 20338 typeof value === 'object' && value !== null && typeof value.render === 'function' && value.$$typeof === undefined) { 20339 { 20340 var _componentName2 = getComponentName(Component) || 'Unknown'; 20341 20342 if (!didWarnAboutModulePatternComponent[_componentName2]) { 20343 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); 20344 20345 didWarnAboutModulePatternComponent[_componentName2] = true; 20346 } 20347 } // Proceed under the assumption that this is a class instance 20348 20349 20350 workInProgress.tag = ClassComponent; // Throw out any hooks that were used. 20351 20352 workInProgress.memoizedState = null; 20353 workInProgress.updateQueue = null; // Push context providers early to prevent context stack mismatches. 20354 // During mounting we don't know the child context yet as the instance doesn't exist. 20355 // We will invalidate the child context in finishClassComponent() right after rendering. 20356 20357 var hasContext = false; 20358 20359 if (isContextProvider(Component)) { 20360 hasContext = true; 20361 pushContextProvider(workInProgress); 20362 } else { 20363 hasContext = false; 20364 } 20365 20366 workInProgress.memoizedState = value.state !== null && value.state !== undefined ? value.state : null; 20367 initializeUpdateQueue(workInProgress); 20368 var getDerivedStateFromProps = Component.getDerivedStateFromProps; 20369 20370 if (typeof getDerivedStateFromProps === 'function') { 20371 applyDerivedStateFromProps(workInProgress, Component, getDerivedStateFromProps, props); 20372 } 20373 20374 adoptClassInstance(workInProgress, value); 20375 mountClassInstance(workInProgress, Component, props, renderLanes); 20376 return finishClassComponent(null, workInProgress, Component, true, hasContext, renderLanes); 20377 } else { 20378 // Proceed under the assumption that this is a function component 20379 workInProgress.tag = FunctionComponent; 20380 20381 { 20382 20383 if ( workInProgress.mode & StrictMode) { 20384 disableLogs(); 20385 20386 try { 20387 value = renderWithHooks(null, workInProgress, Component, props, context, renderLanes); 20388 } finally { 20389 reenableLogs(); 20390 } 20391 } 20392 } 20393 20394 reconcileChildren(null, workInProgress, value, renderLanes); 20395 20396 { 20397 validateFunctionComponentInDev(workInProgress, Component); 20398 } 20399 20400 return workInProgress.child; 20401 } 20402} 20403 20404function validateFunctionComponentInDev(workInProgress, Component) { 20405 { 20406 if (Component) { 20407 if (Component.childContextTypes) { 20408 error('%s(...): childContextTypes cannot be defined on a function component.', Component.displayName || Component.name || 'Component'); 20409 } 20410 } 20411 20412 if (workInProgress.ref !== null) { 20413 var info = ''; 20414 var ownerName = getCurrentFiberOwnerNameInDevOrNull(); 20415 20416 if (ownerName) { 20417 info += '\n\nCheck the render method of `' + ownerName + '`.'; 20418 } 20419 20420 var warningKey = ownerName || workInProgress._debugID || ''; 20421 var debugSource = workInProgress._debugSource; 20422 20423 if (debugSource) { 20424 warningKey = debugSource.fileName + ':' + debugSource.lineNumber; 20425 } 20426 20427 if (!didWarnAboutFunctionRefs[warningKey]) { 20428 didWarnAboutFunctionRefs[warningKey] = true; 20429 20430 error('Function components cannot be given refs. ' + 'Attempts to access this ref will fail. ' + 'Did you mean to use React.forwardRef()?%s', info); 20431 } 20432 } 20433 20434 if (typeof Component.getDerivedStateFromProps === 'function') { 20435 var _componentName3 = getComponentName(Component) || 'Unknown'; 20436 20437 if (!didWarnAboutGetDerivedStateOnFunctionComponent[_componentName3]) { 20438 error('%s: Function components do not support getDerivedStateFromProps.', _componentName3); 20439 20440 didWarnAboutGetDerivedStateOnFunctionComponent[_componentName3] = true; 20441 } 20442 } 20443 20444 if (typeof Component.contextType === 'object' && Component.contextType !== null) { 20445 var _componentName4 = getComponentName(Component) || 'Unknown'; 20446 20447 if (!didWarnAboutContextTypeOnFunctionComponent[_componentName4]) { 20448 error('%s: Function components do not support contextType.', _componentName4); 20449 20450 didWarnAboutContextTypeOnFunctionComponent[_componentName4] = true; 20451 } 20452 } 20453 } 20454} 20455 20456var SUSPENDED_MARKER = { 20457 dehydrated: null, 20458 retryLane: NoLane 20459}; 20460 20461function mountSuspenseOffscreenState(renderLanes) { 20462 return { 20463 baseLanes: renderLanes 20464 }; 20465} 20466 20467function updateSuspenseOffscreenState(prevOffscreenState, renderLanes) { 20468 return { 20469 baseLanes: mergeLanes(prevOffscreenState.baseLanes, renderLanes) 20470 }; 20471} // TODO: Probably should inline this back 20472 20473 20474function shouldRemainOnFallback(suspenseContext, current, workInProgress, renderLanes) { 20475 // If we're already showing a fallback, there are cases where we need to 20476 // remain on that fallback regardless of whether the content has resolved. 20477 // For example, SuspenseList coordinates when nested content appears. 20478 if (current !== null) { 20479 var suspenseState = current.memoizedState; 20480 20481 if (suspenseState === null) { 20482 // Currently showing content. Don't hide it, even if ForceSuspenseFallack 20483 // is true. More precise name might be "ForceRemainSuspenseFallback". 20484 // Note: This is a factoring smell. Can't remain on a fallback if there's 20485 // no fallback to remain on. 20486 return false; 20487 } 20488 } // Not currently showing content. Consult the Suspense context. 20489 20490 20491 return hasSuspenseContext(suspenseContext, ForceSuspenseFallback); 20492} 20493 20494function getRemainingWorkInPrimaryTree(current, renderLanes) { 20495 // TODO: Should not remove render lanes that were pinged during this render 20496 return removeLanes(current.childLanes, renderLanes); 20497} 20498 20499function updateSuspenseComponent(current, workInProgress, renderLanes) { 20500 var nextProps = workInProgress.pendingProps; // This is used by DevTools to force a boundary to suspend. 20501 20502 { 20503 if (shouldSuspend(workInProgress)) { 20504 workInProgress.flags |= DidCapture; 20505 } 20506 } 20507 20508 var suspenseContext = suspenseStackCursor.current; 20509 var showFallback = false; 20510 var didSuspend = (workInProgress.flags & DidCapture) !== NoFlags; 20511 20512 if (didSuspend || shouldRemainOnFallback(suspenseContext, current)) { 20513 // Something in this boundary's subtree already suspended. Switch to 20514 // rendering the fallback children. 20515 showFallback = true; 20516 workInProgress.flags &= ~DidCapture; 20517 } else { 20518 // Attempting the main content 20519 if (current === null || current.memoizedState !== null) { 20520 // This is a new mount or this boundary is already showing a fallback state. 20521 // Mark this subtree context as having at least one invisible parent that could 20522 // handle the fallback state. 20523 // Boundaries without fallbacks or should be avoided are not considered since 20524 // they cannot handle preferred fallback states. 20525 if (nextProps.fallback !== undefined && nextProps.unstable_avoidThisFallback !== true) { 20526 suspenseContext = addSubtreeSuspenseContext(suspenseContext, InvisibleParentSuspenseContext); 20527 } 20528 } 20529 } 20530 20531 suspenseContext = setDefaultShallowSuspenseContext(suspenseContext); 20532 pushSuspenseContext(workInProgress, suspenseContext); // OK, the next part is confusing. We're about to reconcile the Suspense 20533 // boundary's children. This involves some custom reconcilation logic. Two 20534 // main reasons this is so complicated. 20535 // 20536 // First, Legacy Mode has different semantics for backwards compatibility. The 20537 // primary tree will commit in an inconsistent state, so when we do the 20538 // second pass to render the fallback, we do some exceedingly, uh, clever 20539 // hacks to make that not totally break. Like transferring effects and 20540 // deletions from hidden tree. In Concurrent Mode, it's much simpler, 20541 // because we bailout on the primary tree completely and leave it in its old 20542 // state, no effects. Same as what we do for Offscreen (except that 20543 // Offscreen doesn't have the first render pass). 20544 // 20545 // Second is hydration. During hydration, the Suspense fiber has a slightly 20546 // different layout, where the child points to a dehydrated fragment, which 20547 // contains the DOM rendered by the server. 20548 // 20549 // Third, even if you set all that aside, Suspense is like error boundaries in 20550 // that we first we try to render one tree, and if that fails, we render again 20551 // and switch to a different tree. Like a try/catch block. So we have to track 20552 // which branch we're currently rendering. Ideally we would model this using 20553 // a stack. 20554 20555 if (current === null) { 20556 // Initial mount 20557 // If we're currently hydrating, try to hydrate this boundary. 20558 // But only if this has a fallback. 20559 if (nextProps.fallback !== undefined) { 20560 tryToClaimNextHydratableInstance(workInProgress); // This could've been a dehydrated suspense component. 20561 } 20562 20563 var nextPrimaryChildren = nextProps.children; 20564 var nextFallbackChildren = nextProps.fallback; 20565 20566 if (showFallback) { 20567 var fallbackFragment = mountSuspenseFallbackChildren(workInProgress, nextPrimaryChildren, nextFallbackChildren, renderLanes); 20568 var primaryChildFragment = workInProgress.child; 20569 primaryChildFragment.memoizedState = mountSuspenseOffscreenState(renderLanes); 20570 workInProgress.memoizedState = SUSPENDED_MARKER; 20571 return fallbackFragment; 20572 } else if (typeof nextProps.unstable_expectedLoadTime === 'number') { 20573 // This is a CPU-bound tree. Skip this tree and show a placeholder to 20574 // unblock the surrounding content. Then immediately retry after the 20575 // initial commit. 20576 var _fallbackFragment = mountSuspenseFallbackChildren(workInProgress, nextPrimaryChildren, nextFallbackChildren, renderLanes); 20577 20578 var _primaryChildFragment = workInProgress.child; 20579 _primaryChildFragment.memoizedState = mountSuspenseOffscreenState(renderLanes); 20580 workInProgress.memoizedState = SUSPENDED_MARKER; // Since nothing actually suspended, there will nothing to ping this to 20581 // get it started back up to attempt the next item. While in terms of 20582 // priority this work has the same priority as this current render, it's 20583 // not part of the same transition once the transition has committed. If 20584 // it's sync, we still want to yield so that it can be painted. 20585 // Conceptually, this is really the same as pinging. We can use any 20586 // RetryLane even if it's the one currently rendering since we're leaving 20587 // it behind on this node. 20588 20589 workInProgress.lanes = SomeRetryLane; 20590 20591 { 20592 markSpawnedWork(SomeRetryLane); 20593 } 20594 20595 return _fallbackFragment; 20596 } else { 20597 return mountSuspensePrimaryChildren(workInProgress, nextPrimaryChildren, renderLanes); 20598 } 20599 } else { 20600 // This is an update. 20601 // If the current fiber has a SuspenseState, that means it's already showing 20602 // a fallback. 20603 var prevState = current.memoizedState; 20604 20605 if (prevState !== null) { 20606 20607 if (showFallback) { 20608 var _nextFallbackChildren2 = nextProps.fallback; 20609 var _nextPrimaryChildren2 = nextProps.children; 20610 20611 var _fallbackChildFragment = updateSuspenseFallbackChildren(current, workInProgress, _nextPrimaryChildren2, _nextFallbackChildren2, renderLanes); 20612 20613 var _primaryChildFragment3 = workInProgress.child; 20614 var prevOffscreenState = current.child.memoizedState; 20615 _primaryChildFragment3.memoizedState = prevOffscreenState === null ? mountSuspenseOffscreenState(renderLanes) : updateSuspenseOffscreenState(prevOffscreenState, renderLanes); 20616 _primaryChildFragment3.childLanes = getRemainingWorkInPrimaryTree(current, renderLanes); 20617 workInProgress.memoizedState = SUSPENDED_MARKER; 20618 return _fallbackChildFragment; 20619 } else { 20620 var _nextPrimaryChildren3 = nextProps.children; 20621 20622 var _primaryChildFragment4 = updateSuspensePrimaryChildren(current, workInProgress, _nextPrimaryChildren3, renderLanes); 20623 20624 workInProgress.memoizedState = null; 20625 return _primaryChildFragment4; 20626 } 20627 } else { 20628 // The current tree is not already showing a fallback. 20629 if (showFallback) { 20630 // Timed out. 20631 var _nextFallbackChildren3 = nextProps.fallback; 20632 var _nextPrimaryChildren4 = nextProps.children; 20633 20634 var _fallbackChildFragment2 = updateSuspenseFallbackChildren(current, workInProgress, _nextPrimaryChildren4, _nextFallbackChildren3, renderLanes); 20635 20636 var _primaryChildFragment5 = workInProgress.child; 20637 var _prevOffscreenState = current.child.memoizedState; 20638 _primaryChildFragment5.memoizedState = _prevOffscreenState === null ? mountSuspenseOffscreenState(renderLanes) : updateSuspenseOffscreenState(_prevOffscreenState, renderLanes); 20639 _primaryChildFragment5.childLanes = getRemainingWorkInPrimaryTree(current, renderLanes); // Skip the primary children, and continue working on the 20640 // fallback children. 20641 20642 workInProgress.memoizedState = SUSPENDED_MARKER; 20643 return _fallbackChildFragment2; 20644 } else { 20645 // Still haven't timed out. Continue rendering the children, like we 20646 // normally do. 20647 var _nextPrimaryChildren5 = nextProps.children; 20648 20649 var _primaryChildFragment6 = updateSuspensePrimaryChildren(current, workInProgress, _nextPrimaryChildren5, renderLanes); 20650 20651 workInProgress.memoizedState = null; 20652 return _primaryChildFragment6; 20653 } 20654 } 20655 } 20656} 20657 20658function mountSuspensePrimaryChildren(workInProgress, primaryChildren, renderLanes) { 20659 var mode = workInProgress.mode; 20660 var primaryChildProps = { 20661 mode: 'visible', 20662 children: primaryChildren 20663 }; 20664 var primaryChildFragment = createFiberFromOffscreen(primaryChildProps, mode, renderLanes, null); 20665 primaryChildFragment.return = workInProgress; 20666 workInProgress.child = primaryChildFragment; 20667 return primaryChildFragment; 20668} 20669 20670function mountSuspenseFallbackChildren(workInProgress, primaryChildren, fallbackChildren, renderLanes) { 20671 var mode = workInProgress.mode; 20672 var progressedPrimaryFragment = workInProgress.child; 20673 var primaryChildProps = { 20674 mode: 'hidden', 20675 children: primaryChildren 20676 }; 20677 var primaryChildFragment; 20678 var fallbackChildFragment; 20679 20680 if ((mode & BlockingMode) === NoMode && progressedPrimaryFragment !== null) { 20681 // In legacy mode, we commit the primary tree as if it successfully 20682 // completed, even though it's in an inconsistent state. 20683 primaryChildFragment = progressedPrimaryFragment; 20684 primaryChildFragment.childLanes = NoLanes; 20685 primaryChildFragment.pendingProps = primaryChildProps; 20686 20687 if ( workInProgress.mode & ProfileMode) { 20688 // Reset the durations from the first pass so they aren't included in the 20689 // final amounts. This seems counterintuitive, since we're intentionally 20690 // not measuring part of the render phase, but this makes it match what we 20691 // do in Concurrent Mode. 20692 primaryChildFragment.actualDuration = 0; 20693 primaryChildFragment.actualStartTime = -1; 20694 primaryChildFragment.selfBaseDuration = 0; 20695 primaryChildFragment.treeBaseDuration = 0; 20696 } 20697 20698 fallbackChildFragment = createFiberFromFragment(fallbackChildren, mode, renderLanes, null); 20699 } else { 20700 primaryChildFragment = createFiberFromOffscreen(primaryChildProps, mode, NoLanes, null); 20701 fallbackChildFragment = createFiberFromFragment(fallbackChildren, mode, renderLanes, null); 20702 } 20703 20704 primaryChildFragment.return = workInProgress; 20705 fallbackChildFragment.return = workInProgress; 20706 primaryChildFragment.sibling = fallbackChildFragment; 20707 workInProgress.child = primaryChildFragment; 20708 return fallbackChildFragment; 20709} 20710 20711function createWorkInProgressOffscreenFiber(current, offscreenProps) { 20712 // The props argument to `createWorkInProgress` is `any` typed, so we use this 20713 // wrapper function to constrain it. 20714 return createWorkInProgress(current, offscreenProps); 20715} 20716 20717function updateSuspensePrimaryChildren(current, workInProgress, primaryChildren, renderLanes) { 20718 var currentPrimaryChildFragment = current.child; 20719 var currentFallbackChildFragment = currentPrimaryChildFragment.sibling; 20720 var primaryChildFragment = createWorkInProgressOffscreenFiber(currentPrimaryChildFragment, { 20721 mode: 'visible', 20722 children: primaryChildren 20723 }); 20724 20725 if ((workInProgress.mode & BlockingMode) === NoMode) { 20726 primaryChildFragment.lanes = renderLanes; 20727 } 20728 20729 primaryChildFragment.return = workInProgress; 20730 primaryChildFragment.sibling = null; 20731 20732 if (currentFallbackChildFragment !== null) { 20733 // Delete the fallback child fragment 20734 currentFallbackChildFragment.nextEffect = null; 20735 currentFallbackChildFragment.flags = Deletion; 20736 workInProgress.firstEffect = workInProgress.lastEffect = currentFallbackChildFragment; 20737 } 20738 20739 workInProgress.child = primaryChildFragment; 20740 return primaryChildFragment; 20741} 20742 20743function updateSuspenseFallbackChildren(current, workInProgress, primaryChildren, fallbackChildren, renderLanes) { 20744 var mode = workInProgress.mode; 20745 var currentPrimaryChildFragment = current.child; 20746 var currentFallbackChildFragment = currentPrimaryChildFragment.sibling; 20747 var primaryChildProps = { 20748 mode: 'hidden', 20749 children: primaryChildren 20750 }; 20751 var primaryChildFragment; 20752 20753 if ( // In legacy mode, we commit the primary tree as if it successfully 20754 // completed, even though it's in an inconsistent state. 20755 (mode & BlockingMode) === NoMode && // Make sure we're on the second pass, i.e. the primary child fragment was 20756 // already cloned. In legacy mode, the only case where this isn't true is 20757 // when DevTools forces us to display a fallback; we skip the first render 20758 // pass entirely and go straight to rendering the fallback. (In Concurrent 20759 // Mode, SuspenseList can also trigger this scenario, but this is a legacy- 20760 // only codepath.) 20761 workInProgress.child !== currentPrimaryChildFragment) { 20762 var progressedPrimaryFragment = workInProgress.child; 20763 primaryChildFragment = progressedPrimaryFragment; 20764 primaryChildFragment.childLanes = NoLanes; 20765 primaryChildFragment.pendingProps = primaryChildProps; 20766 20767 if ( workInProgress.mode & ProfileMode) { 20768 // Reset the durations from the first pass so they aren't included in the 20769 // final amounts. This seems counterintuitive, since we're intentionally 20770 // not measuring part of the render phase, but this makes it match what we 20771 // do in Concurrent Mode. 20772 primaryChildFragment.actualDuration = 0; 20773 primaryChildFragment.actualStartTime = -1; 20774 primaryChildFragment.selfBaseDuration = currentPrimaryChildFragment.selfBaseDuration; 20775 primaryChildFragment.treeBaseDuration = currentPrimaryChildFragment.treeBaseDuration; 20776 } // The fallback fiber was added as a deletion effect during the first pass. 20777 // However, since we're going to remain on the fallback, we no longer want 20778 // to delete it. So we need to remove it from the list. Deletions are stored 20779 // on the same list as effects. We want to keep the effects from the primary 20780 // tree. So we copy the primary child fragment's effect list, which does not 20781 // include the fallback deletion effect. 20782 20783 20784 var progressedLastEffect = primaryChildFragment.lastEffect; 20785 20786 if (progressedLastEffect !== null) { 20787 workInProgress.firstEffect = primaryChildFragment.firstEffect; 20788 workInProgress.lastEffect = progressedLastEffect; 20789 progressedLastEffect.nextEffect = null; 20790 } else { 20791 // TODO: Reset this somewhere else? Lol legacy mode is so weird. 20792 workInProgress.firstEffect = workInProgress.lastEffect = null; 20793 } 20794 } else { 20795 primaryChildFragment = createWorkInProgressOffscreenFiber(currentPrimaryChildFragment, primaryChildProps); 20796 } 20797 20798 var fallbackChildFragment; 20799 20800 if (currentFallbackChildFragment !== null) { 20801 fallbackChildFragment = createWorkInProgress(currentFallbackChildFragment, fallbackChildren); 20802 } else { 20803 fallbackChildFragment = createFiberFromFragment(fallbackChildren, mode, renderLanes, null); // Needs a placement effect because the parent (the Suspense boundary) already 20804 // mounted but this is a new fiber. 20805 20806 fallbackChildFragment.flags |= Placement; 20807 } 20808 20809 fallbackChildFragment.return = workInProgress; 20810 primaryChildFragment.return = workInProgress; 20811 primaryChildFragment.sibling = fallbackChildFragment; 20812 workInProgress.child = primaryChildFragment; 20813 return fallbackChildFragment; 20814} 20815 20816function scheduleWorkOnFiber(fiber, renderLanes) { 20817 fiber.lanes = mergeLanes(fiber.lanes, renderLanes); 20818 var alternate = fiber.alternate; 20819 20820 if (alternate !== null) { 20821 alternate.lanes = mergeLanes(alternate.lanes, renderLanes); 20822 } 20823 20824 scheduleWorkOnParentPath(fiber.return, renderLanes); 20825} 20826 20827function propagateSuspenseContextChange(workInProgress, firstChild, renderLanes) { 20828 // Mark any Suspense boundaries with fallbacks as having work to do. 20829 // If they were previously forced into fallbacks, they may now be able 20830 // to unblock. 20831 var node = firstChild; 20832 20833 while (node !== null) { 20834 if (node.tag === SuspenseComponent) { 20835 var state = node.memoizedState; 20836 20837 if (state !== null) { 20838 scheduleWorkOnFiber(node, renderLanes); 20839 } 20840 } else if (node.tag === SuspenseListComponent) { 20841 // If the tail is hidden there might not be an Suspense boundaries 20842 // to schedule work on. In this case we have to schedule it on the 20843 // list itself. 20844 // We don't have to traverse to the children of the list since 20845 // the list will propagate the change when it rerenders. 20846 scheduleWorkOnFiber(node, renderLanes); 20847 } else if (node.child !== null) { 20848 node.child.return = node; 20849 node = node.child; 20850 continue; 20851 } 20852 20853 if (node === workInProgress) { 20854 return; 20855 } 20856 20857 while (node.sibling === null) { 20858 if (node.return === null || node.return === workInProgress) { 20859 return; 20860 } 20861 20862 node = node.return; 20863 } 20864 20865 node.sibling.return = node.return; 20866 node = node.sibling; 20867 } 20868} 20869 20870function findLastContentRow(firstChild) { 20871 // This is going to find the last row among these children that is already 20872 // showing content on the screen, as opposed to being in fallback state or 20873 // new. If a row has multiple Suspense boundaries, any of them being in the 20874 // fallback state, counts as the whole row being in a fallback state. 20875 // Note that the "rows" will be workInProgress, but any nested children 20876 // will still be current since we haven't rendered them yet. The mounted 20877 // order may not be the same as the new order. We use the new order. 20878 var row = firstChild; 20879 var lastContentRow = null; 20880 20881 while (row !== null) { 20882 var currentRow = row.alternate; // New rows can't be content rows. 20883 20884 if (currentRow !== null && findFirstSuspended(currentRow) === null) { 20885 lastContentRow = row; 20886 } 20887 20888 row = row.sibling; 20889 } 20890 20891 return lastContentRow; 20892} 20893 20894function validateRevealOrder(revealOrder) { 20895 { 20896 if (revealOrder !== undefined && revealOrder !== 'forwards' && revealOrder !== 'backwards' && revealOrder !== 'together' && !didWarnAboutRevealOrder[revealOrder]) { 20897 didWarnAboutRevealOrder[revealOrder] = true; 20898 20899 if (typeof revealOrder === 'string') { 20900 switch (revealOrder.toLowerCase()) { 20901 case 'together': 20902 case 'forwards': 20903 case 'backwards': 20904 { 20905 error('"%s" is not a valid value for revealOrder on <SuspenseList />. ' + 'Use lowercase "%s" instead.', revealOrder, revealOrder.toLowerCase()); 20906 20907 break; 20908 } 20909 20910 case 'forward': 20911 case 'backward': 20912 { 20913 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()); 20914 20915 break; 20916 } 20917 20918 default: 20919 error('"%s" is not a supported revealOrder on <SuspenseList />. ' + 'Did you mean "together", "forwards" or "backwards"?', revealOrder); 20920 20921 break; 20922 } 20923 } else { 20924 error('%s is not a supported value for revealOrder on <SuspenseList />. ' + 'Did you mean "together", "forwards" or "backwards"?', revealOrder); 20925 } 20926 } 20927 } 20928} 20929 20930function validateTailOptions(tailMode, revealOrder) { 20931 { 20932 if (tailMode !== undefined && !didWarnAboutTailOptions[tailMode]) { 20933 if (tailMode !== 'collapsed' && tailMode !== 'hidden') { 20934 didWarnAboutTailOptions[tailMode] = true; 20935 20936 error('"%s" is not a supported value for tail on <SuspenseList />. ' + 'Did you mean "collapsed" or "hidden"?', tailMode); 20937 } else if (revealOrder !== 'forwards' && revealOrder !== 'backwards') { 20938 didWarnAboutTailOptions[tailMode] = true; 20939 20940 error('<SuspenseList tail="%s" /> is only valid if revealOrder is ' + '"forwards" or "backwards". ' + 'Did you mean to specify revealOrder="forwards"?', tailMode); 20941 } 20942 } 20943 } 20944} 20945 20946function validateSuspenseListNestedChild(childSlot, index) { 20947 { 20948 var isArray = Array.isArray(childSlot); 20949 var isIterable = !isArray && typeof getIteratorFn(childSlot) === 'function'; 20950 20951 if (isArray || isIterable) { 20952 var type = isArray ? 'array' : 'iterable'; 20953 20954 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); 20955 20956 return false; 20957 } 20958 } 20959 20960 return true; 20961} 20962 20963function validateSuspenseListChildren(children, revealOrder) { 20964 { 20965 if ((revealOrder === 'forwards' || revealOrder === 'backwards') && children !== undefined && children !== null && children !== false) { 20966 if (Array.isArray(children)) { 20967 for (var i = 0; i < children.length; i++) { 20968 if (!validateSuspenseListNestedChild(children[i], i)) { 20969 return; 20970 } 20971 } 20972 } else { 20973 var iteratorFn = getIteratorFn(children); 20974 20975 if (typeof iteratorFn === 'function') { 20976 var childrenIterator = iteratorFn.call(children); 20977 20978 if (childrenIterator) { 20979 var step = childrenIterator.next(); 20980 var _i = 0; 20981 20982 for (; !step.done; step = childrenIterator.next()) { 20983 if (!validateSuspenseListNestedChild(step.value, _i)) { 20984 return; 20985 } 20986 20987 _i++; 20988 } 20989 } 20990 } else { 20991 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); 20992 } 20993 } 20994 } 20995 } 20996} 20997 20998function initSuspenseListRenderState(workInProgress, isBackwards, tail, lastContentRow, tailMode, lastEffectBeforeRendering) { 20999 var renderState = workInProgress.memoizedState; 21000 21001 if (renderState === null) { 21002 workInProgress.memoizedState = { 21003 isBackwards: isBackwards, 21004 rendering: null, 21005 renderingStartTime: 0, 21006 last: lastContentRow, 21007 tail: tail, 21008 tailMode: tailMode, 21009 lastEffect: lastEffectBeforeRendering 21010 }; 21011 } else { 21012 // We can reuse the existing object from previous renders. 21013 renderState.isBackwards = isBackwards; 21014 renderState.rendering = null; 21015 renderState.renderingStartTime = 0; 21016 renderState.last = lastContentRow; 21017 renderState.tail = tail; 21018 renderState.tailMode = tailMode; 21019 renderState.lastEffect = lastEffectBeforeRendering; 21020 } 21021} // This can end up rendering this component multiple passes. 21022// The first pass splits the children fibers into two sets. A head and tail. 21023// We first render the head. If anything is in fallback state, we do another 21024// pass through beginWork to rerender all children (including the tail) with 21025// the force suspend context. If the first render didn't have anything in 21026// in fallback state. Then we render each row in the tail one-by-one. 21027// That happens in the completeWork phase without going back to beginWork. 21028 21029 21030function updateSuspenseListComponent(current, workInProgress, renderLanes) { 21031 var nextProps = workInProgress.pendingProps; 21032 var revealOrder = nextProps.revealOrder; 21033 var tailMode = nextProps.tail; 21034 var newChildren = nextProps.children; 21035 validateRevealOrder(revealOrder); 21036 validateTailOptions(tailMode, revealOrder); 21037 validateSuspenseListChildren(newChildren, revealOrder); 21038 reconcileChildren(current, workInProgress, newChildren, renderLanes); 21039 var suspenseContext = suspenseStackCursor.current; 21040 var shouldForceFallback = hasSuspenseContext(suspenseContext, ForceSuspenseFallback); 21041 21042 if (shouldForceFallback) { 21043 suspenseContext = setShallowSuspenseContext(suspenseContext, ForceSuspenseFallback); 21044 workInProgress.flags |= DidCapture; 21045 } else { 21046 var didSuspendBefore = current !== null && (current.flags & DidCapture) !== NoFlags; 21047 21048 if (didSuspendBefore) { 21049 // If we previously forced a fallback, we need to schedule work 21050 // on any nested boundaries to let them know to try to render 21051 // again. This is the same as context updating. 21052 propagateSuspenseContextChange(workInProgress, workInProgress.child, renderLanes); 21053 } 21054 21055 suspenseContext = setDefaultShallowSuspenseContext(suspenseContext); 21056 } 21057 21058 pushSuspenseContext(workInProgress, suspenseContext); 21059 21060 if ((workInProgress.mode & BlockingMode) === NoMode) { 21061 // In legacy mode, SuspenseList doesn't work so we just 21062 // use make it a noop by treating it as the default revealOrder. 21063 workInProgress.memoizedState = null; 21064 } else { 21065 switch (revealOrder) { 21066 case 'forwards': 21067 { 21068 var lastContentRow = findLastContentRow(workInProgress.child); 21069 var tail; 21070 21071 if (lastContentRow === null) { 21072 // The whole list is part of the tail. 21073 // TODO: We could fast path by just rendering the tail now. 21074 tail = workInProgress.child; 21075 workInProgress.child = null; 21076 } else { 21077 // Disconnect the tail rows after the content row. 21078 // We're going to render them separately later. 21079 tail = lastContentRow.sibling; 21080 lastContentRow.sibling = null; 21081 } 21082 21083 initSuspenseListRenderState(workInProgress, false, // isBackwards 21084 tail, lastContentRow, tailMode, workInProgress.lastEffect); 21085 break; 21086 } 21087 21088 case 'backwards': 21089 { 21090 // We're going to find the first row that has existing content. 21091 // At the same time we're going to reverse the list of everything 21092 // we pass in the meantime. That's going to be our tail in reverse 21093 // order. 21094 var _tail = null; 21095 var row = workInProgress.child; 21096 workInProgress.child = null; 21097 21098 while (row !== null) { 21099 var currentRow = row.alternate; // New rows can't be content rows. 21100 21101 if (currentRow !== null && findFirstSuspended(currentRow) === null) { 21102 // This is the beginning of the main content. 21103 workInProgress.child = row; 21104 break; 21105 } 21106 21107 var nextRow = row.sibling; 21108 row.sibling = _tail; 21109 _tail = row; 21110 row = nextRow; 21111 } // TODO: If workInProgress.child is null, we can continue on the tail immediately. 21112 21113 21114 initSuspenseListRenderState(workInProgress, true, // isBackwards 21115 _tail, null, // last 21116 tailMode, workInProgress.lastEffect); 21117 break; 21118 } 21119 21120 case 'together': 21121 { 21122 initSuspenseListRenderState(workInProgress, false, // isBackwards 21123 null, // tail 21124 null, // last 21125 undefined, workInProgress.lastEffect); 21126 break; 21127 } 21128 21129 default: 21130 { 21131 // The default reveal order is the same as not having 21132 // a boundary. 21133 workInProgress.memoizedState = null; 21134 } 21135 } 21136 } 21137 21138 return workInProgress.child; 21139} 21140 21141function updatePortalComponent(current, workInProgress, renderLanes) { 21142 pushHostContainer(workInProgress, workInProgress.stateNode.containerInfo); 21143 var nextChildren = workInProgress.pendingProps; 21144 21145 if (current === null) { 21146 // Portals are special because we don't append the children during mount 21147 // but at commit. Therefore we need to track insertions which the normal 21148 // flow doesn't do during mount. This doesn't happen at the root because 21149 // the root always starts with a "current" with a null child. 21150 // TODO: Consider unifying this with how the root works. 21151 workInProgress.child = reconcileChildFibers(workInProgress, null, nextChildren, renderLanes); 21152 } else { 21153 reconcileChildren(current, workInProgress, nextChildren, renderLanes); 21154 } 21155 21156 return workInProgress.child; 21157} 21158 21159var hasWarnedAboutUsingNoValuePropOnContextProvider = false; 21160 21161function updateContextProvider(current, workInProgress, renderLanes) { 21162 var providerType = workInProgress.type; 21163 var context = providerType._context; 21164 var newProps = workInProgress.pendingProps; 21165 var oldProps = workInProgress.memoizedProps; 21166 var newValue = newProps.value; 21167 21168 { 21169 if (!('value' in newProps)) { 21170 if (!hasWarnedAboutUsingNoValuePropOnContextProvider) { 21171 hasWarnedAboutUsingNoValuePropOnContextProvider = true; 21172 21173 error('The `value` prop is required for the `<Context.Provider>`. Did you misspell it or forget to pass it?'); 21174 } 21175 } 21176 21177 var providerPropTypes = workInProgress.type.propTypes; 21178 21179 if (providerPropTypes) { 21180 checkPropTypes(providerPropTypes, newProps, 'prop', 'Context.Provider'); 21181 } 21182 } 21183 21184 pushProvider(workInProgress, newValue); 21185 21186 if (oldProps !== null) { 21187 var oldValue = oldProps.value; 21188 var changedBits = calculateChangedBits(context, newValue, oldValue); 21189 21190 if (changedBits === 0) { 21191 // No change. Bailout early if children are the same. 21192 if (oldProps.children === newProps.children && !hasContextChanged()) { 21193 return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); 21194 } 21195 } else { 21196 // The context value changed. Search for matching consumers and schedule 21197 // them to update. 21198 propagateContextChange(workInProgress, context, changedBits, renderLanes); 21199 } 21200 } 21201 21202 var newChildren = newProps.children; 21203 reconcileChildren(current, workInProgress, newChildren, renderLanes); 21204 return workInProgress.child; 21205} 21206 21207var hasWarnedAboutUsingContextAsConsumer = false; 21208 21209function updateContextConsumer(current, workInProgress, renderLanes) { 21210 var context = workInProgress.type; // The logic below for Context differs depending on PROD or DEV mode. In 21211 // DEV mode, we create a separate object for Context.Consumer that acts 21212 // like a proxy to Context. This proxy object adds unnecessary code in PROD 21213 // so we use the old behaviour (Context.Consumer references Context) to 21214 // reduce size and overhead. The separate object references context via 21215 // a property called "_context", which also gives us the ability to check 21216 // in DEV mode if this property exists or not and warn if it does not. 21217 21218 { 21219 if (context._context === undefined) { 21220 // This may be because it's a Context (rather than a Consumer). 21221 // Or it may be because it's older React where they're the same thing. 21222 // We only want to warn if we're sure it's a new React. 21223 if (context !== context.Consumer) { 21224 if (!hasWarnedAboutUsingContextAsConsumer) { 21225 hasWarnedAboutUsingContextAsConsumer = true; 21226 21227 error('Rendering <Context> directly is not supported and will be removed in ' + 'a future major release. Did you mean to render <Context.Consumer> instead?'); 21228 } 21229 } 21230 } else { 21231 context = context._context; 21232 } 21233 } 21234 21235 var newProps = workInProgress.pendingProps; 21236 var render = newProps.children; 21237 21238 { 21239 if (typeof render !== 'function') { 21240 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.'); 21241 } 21242 } 21243 21244 prepareToReadContext(workInProgress, renderLanes); 21245 var newValue = readContext(context, newProps.unstable_observedBits); 21246 var newChildren; 21247 21248 { 21249 ReactCurrentOwner$1.current = workInProgress; 21250 setIsRendering(true); 21251 newChildren = render(newValue); 21252 setIsRendering(false); 21253 } // React DevTools reads this flag. 21254 21255 21256 workInProgress.flags |= PerformedWork; 21257 reconcileChildren(current, workInProgress, newChildren, renderLanes); 21258 return workInProgress.child; 21259} 21260 21261function markWorkInProgressReceivedUpdate() { 21262 didReceiveUpdate = true; 21263} 21264 21265function bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) { 21266 if (current !== null) { 21267 // Reuse previous dependencies 21268 workInProgress.dependencies = current.dependencies; 21269 } 21270 21271 { 21272 // Don't update "base" render times for bailouts. 21273 stopProfilerTimerIfRunning(); 21274 } 21275 21276 markSkippedUpdateLanes(workInProgress.lanes); // Check if the children have any pending work. 21277 21278 if (!includesSomeLane(renderLanes, workInProgress.childLanes)) { 21279 // The children don't have any work either. We can skip them. 21280 // TODO: Once we add back resuming, we should check if the children are 21281 // a work-in-progress set. If so, we need to transfer their effects. 21282 return null; 21283 } else { 21284 // This fiber doesn't have work, but its subtree does. Clone the child 21285 // fibers and continue. 21286 cloneChildFibers(current, workInProgress); 21287 return workInProgress.child; 21288 } 21289} 21290 21291function remountFiber(current, oldWorkInProgress, newWorkInProgress) { 21292 { 21293 var returnFiber = oldWorkInProgress.return; 21294 21295 if (returnFiber === null) { 21296 throw new Error('Cannot swap the root fiber.'); 21297 } // Disconnect from the old current. 21298 // It will get deleted. 21299 21300 21301 current.alternate = null; 21302 oldWorkInProgress.alternate = null; // Connect to the new tree. 21303 21304 newWorkInProgress.index = oldWorkInProgress.index; 21305 newWorkInProgress.sibling = oldWorkInProgress.sibling; 21306 newWorkInProgress.return = oldWorkInProgress.return; 21307 newWorkInProgress.ref = oldWorkInProgress.ref; // Replace the child/sibling pointers above it. 21308 21309 if (oldWorkInProgress === returnFiber.child) { 21310 returnFiber.child = newWorkInProgress; 21311 } else { 21312 var prevSibling = returnFiber.child; 21313 21314 if (prevSibling === null) { 21315 throw new Error('Expected parent to have a child.'); 21316 } 21317 21318 while (prevSibling.sibling !== oldWorkInProgress) { 21319 prevSibling = prevSibling.sibling; 21320 21321 if (prevSibling === null) { 21322 throw new Error('Expected to find the previous sibling.'); 21323 } 21324 } 21325 21326 prevSibling.sibling = newWorkInProgress; 21327 } // Delete the old fiber and place the new one. 21328 // Since the old fiber is disconnected, we have to schedule it manually. 21329 21330 21331 var last = returnFiber.lastEffect; 21332 21333 if (last !== null) { 21334 last.nextEffect = current; 21335 returnFiber.lastEffect = current; 21336 } else { 21337 returnFiber.firstEffect = returnFiber.lastEffect = current; 21338 } 21339 21340 current.nextEffect = null; 21341 current.flags = Deletion; 21342 newWorkInProgress.flags |= Placement; // Restart work from the new fiber. 21343 21344 return newWorkInProgress; 21345 } 21346} 21347 21348function beginWork(current, workInProgress, renderLanes) { 21349 var updateLanes = workInProgress.lanes; 21350 21351 { 21352 if (workInProgress._debugNeedsRemount && current !== null) { 21353 // This will restart the begin phase with a new fiber. 21354 return remountFiber(current, workInProgress, createFiberFromTypeAndProps(workInProgress.type, workInProgress.key, workInProgress.pendingProps, workInProgress._debugOwner || null, workInProgress.mode, workInProgress.lanes)); 21355 } 21356 } 21357 21358 if (current !== null) { 21359 var oldProps = current.memoizedProps; 21360 var newProps = workInProgress.pendingProps; 21361 21362 if (oldProps !== newProps || hasContextChanged() || ( // Force a re-render if the implementation changed due to hot reload: 21363 workInProgress.type !== current.type )) { 21364 // If props or context changed, mark the fiber as having performed work. 21365 // This may be unset if the props are determined to be equal later (memo). 21366 didReceiveUpdate = true; 21367 } else if (!includesSomeLane(renderLanes, updateLanes)) { 21368 didReceiveUpdate = false; // This fiber does not have any pending work. Bailout without entering 21369 // the begin phase. There's still some bookkeeping we that needs to be done 21370 // in this optimized path, mostly pushing stuff onto the stack. 21371 21372 switch (workInProgress.tag) { 21373 case HostRoot: 21374 pushHostRootContext(workInProgress); 21375 resetHydrationState(); 21376 break; 21377 21378 case HostComponent: 21379 pushHostContext(workInProgress); 21380 break; 21381 21382 case ClassComponent: 21383 { 21384 var Component = workInProgress.type; 21385 21386 if (isContextProvider(Component)) { 21387 pushContextProvider(workInProgress); 21388 } 21389 21390 break; 21391 } 21392 21393 case HostPortal: 21394 pushHostContainer(workInProgress, workInProgress.stateNode.containerInfo); 21395 break; 21396 21397 case ContextProvider: 21398 { 21399 var newValue = workInProgress.memoizedProps.value; 21400 pushProvider(workInProgress, newValue); 21401 break; 21402 } 21403 21404 case Profiler: 21405 { 21406 // Profiler should only call onRender when one of its descendants actually rendered. 21407 var hasChildWork = includesSomeLane(renderLanes, workInProgress.childLanes); 21408 21409 if (hasChildWork) { 21410 workInProgress.flags |= Update; 21411 } // Reset effect durations for the next eventual effect phase. 21412 // These are reset during render to allow the DevTools commit hook a chance to read them, 21413 21414 21415 var stateNode = workInProgress.stateNode; 21416 stateNode.effectDuration = 0; 21417 stateNode.passiveEffectDuration = 0; 21418 } 21419 21420 break; 21421 21422 case SuspenseComponent: 21423 { 21424 var state = workInProgress.memoizedState; 21425 21426 if (state !== null) { 21427 // whether to retry the primary children, or to skip over it and 21428 // go straight to the fallback. Check the priority of the primary 21429 // child fragment. 21430 21431 21432 var primaryChildFragment = workInProgress.child; 21433 var primaryChildLanes = primaryChildFragment.childLanes; 21434 21435 if (includesSomeLane(renderLanes, primaryChildLanes)) { 21436 // The primary children have pending work. Use the normal path 21437 // to attempt to render the primary children again. 21438 return updateSuspenseComponent(current, workInProgress, renderLanes); 21439 } else { 21440 // The primary child fragment does not have pending work marked 21441 // on it 21442 pushSuspenseContext(workInProgress, setDefaultShallowSuspenseContext(suspenseStackCursor.current)); // The primary children do not have pending work with sufficient 21443 // priority. Bailout. 21444 21445 var child = bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); 21446 21447 if (child !== null) { 21448 // The fallback children have pending work. Skip over the 21449 // primary children and work on the fallback. 21450 return child.sibling; 21451 } else { 21452 return null; 21453 } 21454 } 21455 } else { 21456 pushSuspenseContext(workInProgress, setDefaultShallowSuspenseContext(suspenseStackCursor.current)); 21457 } 21458 21459 break; 21460 } 21461 21462 case SuspenseListComponent: 21463 { 21464 var didSuspendBefore = (current.flags & DidCapture) !== NoFlags; 21465 21466 var _hasChildWork = includesSomeLane(renderLanes, workInProgress.childLanes); 21467 21468 if (didSuspendBefore) { 21469 if (_hasChildWork) { 21470 // If something was in fallback state last time, and we have all the 21471 // same children then we're still in progressive loading state. 21472 // Something might get unblocked by state updates or retries in the 21473 // tree which will affect the tail. So we need to use the normal 21474 // path to compute the correct tail. 21475 return updateSuspenseListComponent(current, workInProgress, renderLanes); 21476 } // If none of the children had any work, that means that none of 21477 // them got retried so they'll still be blocked in the same way 21478 // as before. We can fast bail out. 21479 21480 21481 workInProgress.flags |= DidCapture; 21482 } // If nothing suspended before and we're rendering the same children, 21483 // then the tail doesn't matter. Anything new that suspends will work 21484 // in the "together" mode, so we can continue from the state we had. 21485 21486 21487 var renderState = workInProgress.memoizedState; 21488 21489 if (renderState !== null) { 21490 // Reset to the "together" mode in case we've started a different 21491 // update in the past but didn't complete it. 21492 renderState.rendering = null; 21493 renderState.tail = null; 21494 renderState.lastEffect = null; 21495 } 21496 21497 pushSuspenseContext(workInProgress, suspenseStackCursor.current); 21498 21499 if (_hasChildWork) { 21500 break; 21501 } else { 21502 // If none of the children had any work, that means that none of 21503 // them got retried so they'll still be blocked in the same way 21504 // as before. We can fast bail out. 21505 return null; 21506 } 21507 } 21508 21509 case OffscreenComponent: 21510 case LegacyHiddenComponent: 21511 { 21512 // Need to check if the tree still needs to be deferred. This is 21513 // almost identical to the logic used in the normal update path, 21514 // so we'll just enter that. The only difference is we'll bail out 21515 // at the next level instead of this one, because the child props 21516 // have not changed. Which is fine. 21517 // TODO: Probably should refactor `beginWork` to split the bailout 21518 // path from the normal path. I'm tempted to do a labeled break here 21519 // but I won't :) 21520 workInProgress.lanes = NoLanes; 21521 return updateOffscreenComponent(current, workInProgress, renderLanes); 21522 } 21523 } 21524 21525 return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); 21526 } else { 21527 if ((current.flags & ForceUpdateForLegacySuspense) !== NoFlags) { 21528 // This is a special case that only exists for legacy mode. 21529 // See https://github.com/facebook/react/pull/19216. 21530 didReceiveUpdate = true; 21531 } else { 21532 // An update was scheduled on this fiber, but there are no new props 21533 // nor legacy context. Set this to false. If an update queue or context 21534 // consumer produces a changed value, it will set this to true. Otherwise, 21535 // the component will assume the children have not changed and bail out. 21536 didReceiveUpdate = false; 21537 } 21538 } 21539 } else { 21540 didReceiveUpdate = false; 21541 } // Before entering the begin phase, clear pending update priority. 21542 // TODO: This assumes that we're about to evaluate the component and process 21543 // the update queue. However, there's an exception: SimpleMemoComponent 21544 // sometimes bails out later in the begin phase. This indicates that we should 21545 // move this assignment out of the common path and into each branch. 21546 21547 21548 workInProgress.lanes = NoLanes; 21549 21550 switch (workInProgress.tag) { 21551 case IndeterminateComponent: 21552 { 21553 return mountIndeterminateComponent(current, workInProgress, workInProgress.type, renderLanes); 21554 } 21555 21556 case LazyComponent: 21557 { 21558 var elementType = workInProgress.elementType; 21559 return mountLazyComponent(current, workInProgress, elementType, updateLanes, renderLanes); 21560 } 21561 21562 case FunctionComponent: 21563 { 21564 var _Component = workInProgress.type; 21565 var unresolvedProps = workInProgress.pendingProps; 21566 var resolvedProps = workInProgress.elementType === _Component ? unresolvedProps : resolveDefaultProps(_Component, unresolvedProps); 21567 return updateFunctionComponent(current, workInProgress, _Component, resolvedProps, renderLanes); 21568 } 21569 21570 case ClassComponent: 21571 { 21572 var _Component2 = workInProgress.type; 21573 var _unresolvedProps = workInProgress.pendingProps; 21574 21575 var _resolvedProps = workInProgress.elementType === _Component2 ? _unresolvedProps : resolveDefaultProps(_Component2, _unresolvedProps); 21576 21577 return updateClassComponent(current, workInProgress, _Component2, _resolvedProps, renderLanes); 21578 } 21579 21580 case HostRoot: 21581 return updateHostRoot(current, workInProgress, renderLanes); 21582 21583 case HostComponent: 21584 return updateHostComponent(current, workInProgress, renderLanes); 21585 21586 case HostText: 21587 return updateHostText(current, workInProgress); 21588 21589 case SuspenseComponent: 21590 return updateSuspenseComponent(current, workInProgress, renderLanes); 21591 21592 case HostPortal: 21593 return updatePortalComponent(current, workInProgress, renderLanes); 21594 21595 case ForwardRef: 21596 { 21597 var type = workInProgress.type; 21598 var _unresolvedProps2 = workInProgress.pendingProps; 21599 21600 var _resolvedProps2 = workInProgress.elementType === type ? _unresolvedProps2 : resolveDefaultProps(type, _unresolvedProps2); 21601 21602 return updateForwardRef(current, workInProgress, type, _resolvedProps2, renderLanes); 21603 } 21604 21605 case Fragment: 21606 return updateFragment(current, workInProgress, renderLanes); 21607 21608 case Mode: 21609 return updateMode(current, workInProgress, renderLanes); 21610 21611 case Profiler: 21612 return updateProfiler(current, workInProgress, renderLanes); 21613 21614 case ContextProvider: 21615 return updateContextProvider(current, workInProgress, renderLanes); 21616 21617 case ContextConsumer: 21618 return updateContextConsumer(current, workInProgress, renderLanes); 21619 21620 case MemoComponent: 21621 { 21622 var _type2 = workInProgress.type; 21623 var _unresolvedProps3 = workInProgress.pendingProps; // Resolve outer props first, then resolve inner props. 21624 21625 var _resolvedProps3 = resolveDefaultProps(_type2, _unresolvedProps3); 21626 21627 { 21628 if (workInProgress.type !== workInProgress.elementType) { 21629 var outerPropTypes = _type2.propTypes; 21630 21631 if (outerPropTypes) { 21632 checkPropTypes(outerPropTypes, _resolvedProps3, // Resolved for outer only 21633 'prop', getComponentName(_type2)); 21634 } 21635 } 21636 } 21637 21638 _resolvedProps3 = resolveDefaultProps(_type2.type, _resolvedProps3); 21639 return updateMemoComponent(current, workInProgress, _type2, _resolvedProps3, updateLanes, renderLanes); 21640 } 21641 21642 case SimpleMemoComponent: 21643 { 21644 return updateSimpleMemoComponent(current, workInProgress, workInProgress.type, workInProgress.pendingProps, updateLanes, renderLanes); 21645 } 21646 21647 case IncompleteClassComponent: 21648 { 21649 var _Component3 = workInProgress.type; 21650 var _unresolvedProps4 = workInProgress.pendingProps; 21651 21652 var _resolvedProps4 = workInProgress.elementType === _Component3 ? _unresolvedProps4 : resolveDefaultProps(_Component3, _unresolvedProps4); 21653 21654 return mountIncompleteClassComponent(current, workInProgress, _Component3, _resolvedProps4, renderLanes); 21655 } 21656 21657 case SuspenseListComponent: 21658 { 21659 return updateSuspenseListComponent(current, workInProgress, renderLanes); 21660 } 21661 21662 case FundamentalComponent: 21663 { 21664 21665 break; 21666 } 21667 21668 case ScopeComponent: 21669 { 21670 21671 break; 21672 } 21673 21674 case Block: 21675 { 21676 21677 break; 21678 } 21679 21680 case OffscreenComponent: 21681 { 21682 return updateOffscreenComponent(current, workInProgress, renderLanes); 21683 } 21684 21685 case LegacyHiddenComponent: 21686 { 21687 return updateLegacyHiddenComponent(current, workInProgress, renderLanes); 21688 } 21689 } 21690 21691 { 21692 { 21693 throw Error( "Unknown unit of work tag (" + workInProgress.tag + "). This error is likely caused by a bug in React. Please file an issue." ); 21694 } 21695 } 21696} 21697 21698function markUpdate(workInProgress) { 21699 // Tag the fiber with an update effect. This turns a Placement into 21700 // a PlacementAndUpdate. 21701 workInProgress.flags |= Update; 21702} 21703 21704function markRef$1(workInProgress) { 21705 workInProgress.flags |= Ref; 21706} 21707 21708var appendAllChildren; 21709var updateHostContainer; 21710var updateHostComponent$1; 21711var updateHostText$1; 21712 21713{ 21714 // Mutation mode 21715 appendAllChildren = function (parent, workInProgress, needsVisibilityToggle, isHidden) { 21716 // We only have the top Fiber that was created but we need recurse down its 21717 // children to find all the terminal nodes. 21718 var node = workInProgress.child; 21719 21720 while (node !== null) { 21721 if (node.tag === HostComponent || node.tag === HostText) { 21722 appendInitialChild(parent, node.stateNode); 21723 } else if (node.tag === HostPortal) ; else if (node.child !== null) { 21724 node.child.return = node; 21725 node = node.child; 21726 continue; 21727 } 21728 21729 if (node === workInProgress) { 21730 return; 21731 } 21732 21733 while (node.sibling === null) { 21734 if (node.return === null || node.return === workInProgress) { 21735 return; 21736 } 21737 21738 node = node.return; 21739 } 21740 21741 node.sibling.return = node.return; 21742 node = node.sibling; 21743 } 21744 }; 21745 21746 updateHostContainer = function (workInProgress) {// Noop 21747 }; 21748 21749 updateHostComponent$1 = function (current, workInProgress, type, newProps, rootContainerInstance) { 21750 // If we have an alternate, that means this is an update and we need to 21751 // schedule a side-effect to do the updates. 21752 var oldProps = current.memoizedProps; 21753 21754 if (oldProps === newProps) { 21755 // In mutation mode, this is sufficient for a bailout because 21756 // we won't touch this node even if children changed. 21757 return; 21758 } // If we get updated because one of our children updated, we don't 21759 // have newProps so we'll have to reuse them. 21760 // TODO: Split the update API as separate for the props vs. children. 21761 // Even better would be if children weren't special cased at all tho. 21762 21763 21764 var instance = workInProgress.stateNode; 21765 var currentHostContext = getHostContext(); // TODO: Experiencing an error where oldProps is null. Suggests a host 21766 // component is hitting the resume path. Figure out why. Possibly 21767 // related to `hidden`. 21768 21769 var updatePayload = prepareUpdate(instance, type, oldProps, newProps, rootContainerInstance, currentHostContext); // TODO: Type this specific to this type of component. 21770 21771 workInProgress.updateQueue = updatePayload; // If the update payload indicates that there is a change or if there 21772 // is a new ref we mark this as an update. All the work is done in commitWork. 21773 21774 if (updatePayload) { 21775 markUpdate(workInProgress); 21776 } 21777 }; 21778 21779 updateHostText$1 = function (current, workInProgress, oldText, newText) { 21780 // If the text differs, mark it as an update. All the work in done in commitWork. 21781 if (oldText !== newText) { 21782 markUpdate(workInProgress); 21783 } 21784 }; 21785} 21786 21787function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) { 21788 if (getIsHydrating()) { 21789 // If we're hydrating, we should consume as many items as we can 21790 // so we don't leave any behind. 21791 return; 21792 } 21793 21794 switch (renderState.tailMode) { 21795 case 'hidden': 21796 { 21797 // Any insertions at the end of the tail list after this point 21798 // should be invisible. If there are already mounted boundaries 21799 // anything before them are not considered for collapsing. 21800 // Therefore we need to go through the whole tail to find if 21801 // there are any. 21802 var tailNode = renderState.tail; 21803 var lastTailNode = null; 21804 21805 while (tailNode !== null) { 21806 if (tailNode.alternate !== null) { 21807 lastTailNode = tailNode; 21808 } 21809 21810 tailNode = tailNode.sibling; 21811 } // Next we're simply going to delete all insertions after the 21812 // last rendered item. 21813 21814 21815 if (lastTailNode === null) { 21816 // All remaining items in the tail are insertions. 21817 renderState.tail = null; 21818 } else { 21819 // Detach the insertion after the last node that was already 21820 // inserted. 21821 lastTailNode.sibling = null; 21822 } 21823 21824 break; 21825 } 21826 21827 case 'collapsed': 21828 { 21829 // Any insertions at the end of the tail list after this point 21830 // should be invisible. If there are already mounted boundaries 21831 // anything before them are not considered for collapsing. 21832 // Therefore we need to go through the whole tail to find if 21833 // there are any. 21834 var _tailNode = renderState.tail; 21835 var _lastTailNode = null; 21836 21837 while (_tailNode !== null) { 21838 if (_tailNode.alternate !== null) { 21839 _lastTailNode = _tailNode; 21840 } 21841 21842 _tailNode = _tailNode.sibling; 21843 } // Next we're simply going to delete all insertions after the 21844 // last rendered item. 21845 21846 21847 if (_lastTailNode === null) { 21848 // All remaining items in the tail are insertions. 21849 if (!hasRenderedATailFallback && renderState.tail !== null) { 21850 // We suspended during the head. We want to show at least one 21851 // row at the tail. So we'll keep on and cut off the rest. 21852 renderState.tail.sibling = null; 21853 } else { 21854 renderState.tail = null; 21855 } 21856 } else { 21857 // Detach the insertion after the last node that was already 21858 // inserted. 21859 _lastTailNode.sibling = null; 21860 } 21861 21862 break; 21863 } 21864 } 21865} 21866 21867function completeWork(current, workInProgress, renderLanes) { 21868 var newProps = workInProgress.pendingProps; 21869 21870 switch (workInProgress.tag) { 21871 case IndeterminateComponent: 21872 case LazyComponent: 21873 case SimpleMemoComponent: 21874 case FunctionComponent: 21875 case ForwardRef: 21876 case Fragment: 21877 case Mode: 21878 case Profiler: 21879 case ContextConsumer: 21880 case MemoComponent: 21881 return null; 21882 21883 case ClassComponent: 21884 { 21885 var Component = workInProgress.type; 21886 21887 if (isContextProvider(Component)) { 21888 popContext(workInProgress); 21889 } 21890 21891 return null; 21892 } 21893 21894 case HostRoot: 21895 { 21896 popHostContainer(workInProgress); 21897 popTopLevelContextObject(workInProgress); 21898 resetWorkInProgressVersions(); 21899 var fiberRoot = workInProgress.stateNode; 21900 21901 if (fiberRoot.pendingContext) { 21902 fiberRoot.context = fiberRoot.pendingContext; 21903 fiberRoot.pendingContext = null; 21904 } 21905 21906 if (current === null || current.child === null) { 21907 // If we hydrated, pop so that we can delete any remaining children 21908 // that weren't hydrated. 21909 var wasHydrated = popHydrationState(workInProgress); 21910 21911 if (wasHydrated) { 21912 // If we hydrated, then we'll need to schedule an update for 21913 // the commit side-effects on the root. 21914 markUpdate(workInProgress); 21915 } else if (!fiberRoot.hydrate) { 21916 // Schedule an effect to clear this container at the start of the next commit. 21917 // This handles the case of React rendering into a container with previous children. 21918 // It's also safe to do for updates too, because current.child would only be null 21919 // if the previous render was null (so the the container would already be empty). 21920 workInProgress.flags |= Snapshot; 21921 } 21922 } 21923 21924 updateHostContainer(workInProgress); 21925 return null; 21926 } 21927 21928 case HostComponent: 21929 { 21930 popHostContext(workInProgress); 21931 var rootContainerInstance = getRootHostContainer(); 21932 var type = workInProgress.type; 21933 21934 if (current !== null && workInProgress.stateNode != null) { 21935 updateHostComponent$1(current, workInProgress, type, newProps, rootContainerInstance); 21936 21937 if (current.ref !== workInProgress.ref) { 21938 markRef$1(workInProgress); 21939 } 21940 } else { 21941 if (!newProps) { 21942 if (!(workInProgress.stateNode !== null)) { 21943 { 21944 throw Error( "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue." ); 21945 } 21946 } // This can happen when we abort work. 21947 21948 21949 return null; 21950 } 21951 21952 var currentHostContext = getHostContext(); // TODO: Move createInstance to beginWork and keep it on a context 21953 // "stack" as the parent. Then append children as we go in beginWork 21954 // or completeWork depending on whether we want to add them top->down or 21955 // bottom->up. Top->down is faster in IE11. 21956 21957 var _wasHydrated = popHydrationState(workInProgress); 21958 21959 if (_wasHydrated) { 21960 // TODO: Move this and createInstance step into the beginPhase 21961 // to consolidate. 21962 if (prepareToHydrateHostInstance(workInProgress, rootContainerInstance, currentHostContext)) { 21963 // If changes to the hydrated node need to be applied at the 21964 // commit-phase we mark this as such. 21965 markUpdate(workInProgress); 21966 } 21967 } else { 21968 var instance = createInstance(type, newProps, rootContainerInstance, currentHostContext, workInProgress); 21969 appendAllChildren(instance, workInProgress, false, false); 21970 workInProgress.stateNode = instance; // Certain renderers require commit-time effects for initial mount. 21971 // (eg DOM renderer supports auto-focus for certain elements). 21972 // Make sure such renderers get scheduled for later work. 21973 21974 if (finalizeInitialChildren(instance, type, newProps, rootContainerInstance)) { 21975 markUpdate(workInProgress); 21976 } 21977 } 21978 21979 if (workInProgress.ref !== null) { 21980 // If there is a ref on a host node we need to schedule a callback 21981 markRef$1(workInProgress); 21982 } 21983 } 21984 21985 return null; 21986 } 21987 21988 case HostText: 21989 { 21990 var newText = newProps; 21991 21992 if (current && workInProgress.stateNode != null) { 21993 var oldText = current.memoizedProps; // If we have an alternate, that means this is an update and we need 21994 // to schedule a side-effect to do the updates. 21995 21996 updateHostText$1(current, workInProgress, oldText, newText); 21997 } else { 21998 if (typeof newText !== 'string') { 21999 if (!(workInProgress.stateNode !== null)) { 22000 { 22001 throw Error( "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue." ); 22002 } 22003 } // This can happen when we abort work. 22004 22005 } 22006 22007 var _rootContainerInstance = getRootHostContainer(); 22008 22009 var _currentHostContext = getHostContext(); 22010 22011 var _wasHydrated2 = popHydrationState(workInProgress); 22012 22013 if (_wasHydrated2) { 22014 if (prepareToHydrateHostTextInstance(workInProgress)) { 22015 markUpdate(workInProgress); 22016 } 22017 } else { 22018 workInProgress.stateNode = createTextInstance(newText, _rootContainerInstance, _currentHostContext, workInProgress); 22019 } 22020 } 22021 22022 return null; 22023 } 22024 22025 case SuspenseComponent: 22026 { 22027 popSuspenseContext(workInProgress); 22028 var nextState = workInProgress.memoizedState; 22029 22030 if ((workInProgress.flags & DidCapture) !== NoFlags) { 22031 // Something suspended. Re-render with the fallback children. 22032 workInProgress.lanes = renderLanes; // Do not reset the effect list. 22033 22034 if ( (workInProgress.mode & ProfileMode) !== NoMode) { 22035 transferActualDuration(workInProgress); 22036 } 22037 22038 return workInProgress; 22039 } 22040 22041 var nextDidTimeout = nextState !== null; 22042 var prevDidTimeout = false; 22043 22044 if (current === null) { 22045 if (workInProgress.memoizedProps.fallback !== undefined) { 22046 popHydrationState(workInProgress); 22047 } 22048 } else { 22049 var prevState = current.memoizedState; 22050 prevDidTimeout = prevState !== null; 22051 } 22052 22053 if (nextDidTimeout && !prevDidTimeout) { 22054 // If this subtreee is running in blocking mode we can suspend, 22055 // otherwise we won't suspend. 22056 // TODO: This will still suspend a synchronous tree if anything 22057 // in the concurrent tree already suspended during this render. 22058 // This is a known bug. 22059 if ((workInProgress.mode & BlockingMode) !== NoMode) { 22060 // TODO: Move this back to throwException because this is too late 22061 // if this is a large tree which is common for initial loads. We 22062 // don't know if we should restart a render or not until we get 22063 // this marker, and this is too late. 22064 // If this render already had a ping or lower pri updates, 22065 // and this is the first time we know we're going to suspend we 22066 // should be able to immediately restart from within throwException. 22067 var hasInvisibleChildContext = current === null && workInProgress.memoizedProps.unstable_avoidThisFallback !== true; 22068 22069 if (hasInvisibleChildContext || hasSuspenseContext(suspenseStackCursor.current, InvisibleParentSuspenseContext)) { 22070 // If this was in an invisible tree or a new render, then showing 22071 // this boundary is ok. 22072 renderDidSuspend(); 22073 } else { 22074 // Otherwise, we're going to have to hide content so we should 22075 // suspend for longer if possible. 22076 renderDidSuspendDelayIfPossible(); 22077 } 22078 } 22079 } 22080 22081 { 22082 // TODO: Only schedule updates if these values are non equal, i.e. it changed. 22083 if (nextDidTimeout || prevDidTimeout) { 22084 // If this boundary just timed out, schedule an effect to attach a 22085 // retry listener to the promise. This flag is also used to hide the 22086 // primary children. In mutation mode, we also need the flag to 22087 // *unhide* children that were previously hidden, so check if this 22088 // is currently timed out, too. 22089 workInProgress.flags |= Update; 22090 } 22091 } 22092 22093 return null; 22094 } 22095 22096 case HostPortal: 22097 popHostContainer(workInProgress); 22098 updateHostContainer(workInProgress); 22099 22100 if (current === null) { 22101 preparePortalMount(workInProgress.stateNode.containerInfo); 22102 } 22103 22104 return null; 22105 22106 case ContextProvider: 22107 // Pop provider fiber 22108 popProvider(workInProgress); 22109 return null; 22110 22111 case IncompleteClassComponent: 22112 { 22113 // Same as class component case. I put it down here so that the tags are 22114 // sequential to ensure this switch is compiled to a jump table. 22115 var _Component = workInProgress.type; 22116 22117 if (isContextProvider(_Component)) { 22118 popContext(workInProgress); 22119 } 22120 22121 return null; 22122 } 22123 22124 case SuspenseListComponent: 22125 { 22126 popSuspenseContext(workInProgress); 22127 var renderState = workInProgress.memoizedState; 22128 22129 if (renderState === null) { 22130 // We're running in the default, "independent" mode. 22131 // We don't do anything in this mode. 22132 return null; 22133 } 22134 22135 var didSuspendAlready = (workInProgress.flags & DidCapture) !== NoFlags; 22136 var renderedTail = renderState.rendering; 22137 22138 if (renderedTail === null) { 22139 // We just rendered the head. 22140 if (!didSuspendAlready) { 22141 // This is the first pass. We need to figure out if anything is still 22142 // suspended in the rendered set. 22143 // If new content unsuspended, but there's still some content that 22144 // didn't. Then we need to do a second pass that forces everything 22145 // to keep showing their fallbacks. 22146 // We might be suspended if something in this render pass suspended, or 22147 // something in the previous committed pass suspended. Otherwise, 22148 // there's no chance so we can skip the expensive call to 22149 // findFirstSuspended. 22150 var cannotBeSuspended = renderHasNotSuspendedYet() && (current === null || (current.flags & DidCapture) === NoFlags); 22151 22152 if (!cannotBeSuspended) { 22153 var row = workInProgress.child; 22154 22155 while (row !== null) { 22156 var suspended = findFirstSuspended(row); 22157 22158 if (suspended !== null) { 22159 didSuspendAlready = true; 22160 workInProgress.flags |= DidCapture; 22161 cutOffTailIfNeeded(renderState, false); // If this is a newly suspended tree, it might not get committed as 22162 // part of the second pass. In that case nothing will subscribe to 22163 // its thennables. Instead, we'll transfer its thennables to the 22164 // SuspenseList so that it can retry if they resolve. 22165 // There might be multiple of these in the list but since we're 22166 // going to wait for all of them anyway, it doesn't really matter 22167 // which ones gets to ping. In theory we could get clever and keep 22168 // track of how many dependencies remain but it gets tricky because 22169 // in the meantime, we can add/remove/change items and dependencies. 22170 // We might bail out of the loop before finding any but that 22171 // doesn't matter since that means that the other boundaries that 22172 // we did find already has their listeners attached. 22173 22174 var newThennables = suspended.updateQueue; 22175 22176 if (newThennables !== null) { 22177 workInProgress.updateQueue = newThennables; 22178 workInProgress.flags |= Update; 22179 } // Rerender the whole list, but this time, we'll force fallbacks 22180 // to stay in place. 22181 // Reset the effect list before doing the second pass since that's now invalid. 22182 22183 22184 if (renderState.lastEffect === null) { 22185 workInProgress.firstEffect = null; 22186 } 22187 22188 workInProgress.lastEffect = renderState.lastEffect; // Reset the child fibers to their original state. 22189 22190 resetChildFibers(workInProgress, renderLanes); // Set up the Suspense Context to force suspense and immediately 22191 // rerender the children. 22192 22193 pushSuspenseContext(workInProgress, setShallowSuspenseContext(suspenseStackCursor.current, ForceSuspenseFallback)); 22194 return workInProgress.child; 22195 } 22196 22197 row = row.sibling; 22198 } 22199 } 22200 22201 if (renderState.tail !== null && now() > getRenderTargetTime()) { 22202 // We have already passed our CPU deadline but we still have rows 22203 // left in the tail. We'll just give up further attempts to render 22204 // the main content and only render fallbacks. 22205 workInProgress.flags |= DidCapture; 22206 didSuspendAlready = true; 22207 cutOffTailIfNeeded(renderState, false); // Since nothing actually suspended, there will nothing to ping this 22208 // to get it started back up to attempt the next item. While in terms 22209 // of priority this work has the same priority as this current render, 22210 // it's not part of the same transition once the transition has 22211 // committed. If it's sync, we still want to yield so that it can be 22212 // painted. Conceptually, this is really the same as pinging. 22213 // We can use any RetryLane even if it's the one currently rendering 22214 // since we're leaving it behind on this node. 22215 22216 workInProgress.lanes = SomeRetryLane; 22217 22218 { 22219 markSpawnedWork(SomeRetryLane); 22220 } 22221 } 22222 } else { 22223 cutOffTailIfNeeded(renderState, false); 22224 } // Next we're going to render the tail. 22225 22226 } else { 22227 // Append the rendered row to the child list. 22228 if (!didSuspendAlready) { 22229 var _suspended = findFirstSuspended(renderedTail); 22230 22231 if (_suspended !== null) { 22232 workInProgress.flags |= DidCapture; 22233 didSuspendAlready = true; // Ensure we transfer the update queue to the parent so that it doesn't 22234 // get lost if this row ends up dropped during a second pass. 22235 22236 var _newThennables = _suspended.updateQueue; 22237 22238 if (_newThennables !== null) { 22239 workInProgress.updateQueue = _newThennables; 22240 workInProgress.flags |= Update; 22241 } 22242 22243 cutOffTailIfNeeded(renderState, true); // This might have been modified. 22244 22245 if (renderState.tail === null && renderState.tailMode === 'hidden' && !renderedTail.alternate && !getIsHydrating() // We don't cut it if we're hydrating. 22246 ) { 22247 // We need to delete the row we just rendered. 22248 // Reset the effect list to what it was before we rendered this 22249 // child. The nested children have already appended themselves. 22250 var lastEffect = workInProgress.lastEffect = renderState.lastEffect; // Remove any effects that were appended after this point. 22251 22252 if (lastEffect !== null) { 22253 lastEffect.nextEffect = null; 22254 } // We're done. 22255 22256 22257 return null; 22258 } 22259 } else if ( // The time it took to render last row is greater than the remaining 22260 // time we have to render. So rendering one more row would likely 22261 // exceed it. 22262 now() * 2 - renderState.renderingStartTime > getRenderTargetTime() && renderLanes !== OffscreenLane) { 22263 // We have now passed our CPU deadline and we'll just give up further 22264 // attempts to render the main content and only render fallbacks. 22265 // The assumption is that this is usually faster. 22266 workInProgress.flags |= DidCapture; 22267 didSuspendAlready = true; 22268 cutOffTailIfNeeded(renderState, false); // Since nothing actually suspended, there will nothing to ping this 22269 // to get it started back up to attempt the next item. While in terms 22270 // of priority this work has the same priority as this current render, 22271 // it's not part of the same transition once the transition has 22272 // committed. If it's sync, we still want to yield so that it can be 22273 // painted. Conceptually, this is really the same as pinging. 22274 // We can use any RetryLane even if it's the one currently rendering 22275 // since we're leaving it behind on this node. 22276 22277 workInProgress.lanes = SomeRetryLane; 22278 22279 { 22280 markSpawnedWork(SomeRetryLane); 22281 } 22282 } 22283 } 22284 22285 if (renderState.isBackwards) { 22286 // The effect list of the backwards tail will have been added 22287 // to the end. This breaks the guarantee that life-cycles fire in 22288 // sibling order but that isn't a strong guarantee promised by React. 22289 // Especially since these might also just pop in during future commits. 22290 // Append to the beginning of the list. 22291 renderedTail.sibling = workInProgress.child; 22292 workInProgress.child = renderedTail; 22293 } else { 22294 var previousSibling = renderState.last; 22295 22296 if (previousSibling !== null) { 22297 previousSibling.sibling = renderedTail; 22298 } else { 22299 workInProgress.child = renderedTail; 22300 } 22301 22302 renderState.last = renderedTail; 22303 } 22304 } 22305 22306 if (renderState.tail !== null) { 22307 // We still have tail rows to render. 22308 // Pop a row. 22309 var next = renderState.tail; 22310 renderState.rendering = next; 22311 renderState.tail = next.sibling; 22312 renderState.lastEffect = workInProgress.lastEffect; 22313 renderState.renderingStartTime = now(); 22314 next.sibling = null; // Restore the context. 22315 // TODO: We can probably just avoid popping it instead and only 22316 // setting it the first time we go from not suspended to suspended. 22317 22318 var suspenseContext = suspenseStackCursor.current; 22319 22320 if (didSuspendAlready) { 22321 suspenseContext = setShallowSuspenseContext(suspenseContext, ForceSuspenseFallback); 22322 } else { 22323 suspenseContext = setDefaultShallowSuspenseContext(suspenseContext); 22324 } 22325 22326 pushSuspenseContext(workInProgress, suspenseContext); // Do a pass over the next row. 22327 22328 return next; 22329 } 22330 22331 return null; 22332 } 22333 22334 case FundamentalComponent: 22335 { 22336 22337 break; 22338 } 22339 22340 case ScopeComponent: 22341 { 22342 22343 break; 22344 } 22345 22346 case Block: 22347 22348 break; 22349 22350 case OffscreenComponent: 22351 case LegacyHiddenComponent: 22352 { 22353 popRenderLanes(workInProgress); 22354 22355 if (current !== null) { 22356 var _nextState = workInProgress.memoizedState; 22357 var _prevState = current.memoizedState; 22358 var prevIsHidden = _prevState !== null; 22359 var nextIsHidden = _nextState !== null; 22360 22361 if (prevIsHidden !== nextIsHidden && newProps.mode !== 'unstable-defer-without-hiding') { 22362 workInProgress.flags |= Update; 22363 } 22364 } 22365 22366 return null; 22367 } 22368 } 22369 22370 { 22371 { 22372 throw Error( "Unknown unit of work tag (" + workInProgress.tag + "). This error is likely caused by a bug in React. Please file an issue." ); 22373 } 22374 } 22375} 22376 22377function unwindWork(workInProgress, renderLanes) { 22378 switch (workInProgress.tag) { 22379 case ClassComponent: 22380 { 22381 var Component = workInProgress.type; 22382 22383 if (isContextProvider(Component)) { 22384 popContext(workInProgress); 22385 } 22386 22387 var flags = workInProgress.flags; 22388 22389 if (flags & ShouldCapture) { 22390 workInProgress.flags = flags & ~ShouldCapture | DidCapture; 22391 22392 if ( (workInProgress.mode & ProfileMode) !== NoMode) { 22393 transferActualDuration(workInProgress); 22394 } 22395 22396 return workInProgress; 22397 } 22398 22399 return null; 22400 } 22401 22402 case HostRoot: 22403 { 22404 popHostContainer(workInProgress); 22405 popTopLevelContextObject(workInProgress); 22406 resetWorkInProgressVersions(); 22407 var _flags = workInProgress.flags; 22408 22409 if (!((_flags & DidCapture) === NoFlags)) { 22410 { 22411 throw Error( "The root failed to unmount after an error. This is likely a bug in React. Please file an issue." ); 22412 } 22413 } 22414 22415 workInProgress.flags = _flags & ~ShouldCapture | DidCapture; 22416 return workInProgress; 22417 } 22418 22419 case HostComponent: 22420 { 22421 // TODO: popHydrationState 22422 popHostContext(workInProgress); 22423 return null; 22424 } 22425 22426 case SuspenseComponent: 22427 { 22428 popSuspenseContext(workInProgress); 22429 22430 var _flags2 = workInProgress.flags; 22431 22432 if (_flags2 & ShouldCapture) { 22433 workInProgress.flags = _flags2 & ~ShouldCapture | DidCapture; // Captured a suspense effect. Re-render the boundary. 22434 22435 if ( (workInProgress.mode & ProfileMode) !== NoMode) { 22436 transferActualDuration(workInProgress); 22437 } 22438 22439 return workInProgress; 22440 } 22441 22442 return null; 22443 } 22444 22445 case SuspenseListComponent: 22446 { 22447 popSuspenseContext(workInProgress); // SuspenseList doesn't actually catch anything. It should've been 22448 // caught by a nested boundary. If not, it should bubble through. 22449 22450 return null; 22451 } 22452 22453 case HostPortal: 22454 popHostContainer(workInProgress); 22455 return null; 22456 22457 case ContextProvider: 22458 popProvider(workInProgress); 22459 return null; 22460 22461 case OffscreenComponent: 22462 case LegacyHiddenComponent: 22463 popRenderLanes(workInProgress); 22464 return null; 22465 22466 default: 22467 return null; 22468 } 22469} 22470 22471function unwindInterruptedWork(interruptedWork) { 22472 switch (interruptedWork.tag) { 22473 case ClassComponent: 22474 { 22475 var childContextTypes = interruptedWork.type.childContextTypes; 22476 22477 if (childContextTypes !== null && childContextTypes !== undefined) { 22478 popContext(interruptedWork); 22479 } 22480 22481 break; 22482 } 22483 22484 case HostRoot: 22485 { 22486 popHostContainer(interruptedWork); 22487 popTopLevelContextObject(interruptedWork); 22488 resetWorkInProgressVersions(); 22489 break; 22490 } 22491 22492 case HostComponent: 22493 { 22494 popHostContext(interruptedWork); 22495 break; 22496 } 22497 22498 case HostPortal: 22499 popHostContainer(interruptedWork); 22500 break; 22501 22502 case SuspenseComponent: 22503 popSuspenseContext(interruptedWork); 22504 break; 22505 22506 case SuspenseListComponent: 22507 popSuspenseContext(interruptedWork); 22508 break; 22509 22510 case ContextProvider: 22511 popProvider(interruptedWork); 22512 break; 22513 22514 case OffscreenComponent: 22515 case LegacyHiddenComponent: 22516 popRenderLanes(interruptedWork); 22517 break; 22518 } 22519} 22520 22521function createCapturedValue(value, source) { 22522 // If the value is an error, call this function immediately after it is thrown 22523 // so the stack is accurate. 22524 return { 22525 value: value, 22526 source: source, 22527 stack: getStackByFiberInDevAndProd(source) 22528 }; 22529} 22530 22531// This module is forked in different environments. 22532// By default, return `true` to log errors to the console. 22533// Forks can return `false` if this isn't desirable. 22534function showErrorDialog(boundary, errorInfo) { 22535 return true; 22536} 22537 22538function logCapturedError(boundary, errorInfo) { 22539 try { 22540 var logError = showErrorDialog(boundary, errorInfo); // Allow injected showErrorDialog() to prevent default console.error logging. 22541 // This enables renderers like ReactNative to better manage redbox behavior. 22542 22543 if (logError === false) { 22544 return; 22545 } 22546 22547 var error = errorInfo.value; 22548 22549 if (true) { 22550 var source = errorInfo.source; 22551 var stack = errorInfo.stack; 22552 var componentStack = stack !== null ? stack : ''; // Browsers support silencing uncaught errors by calling 22553 // `preventDefault()` in window `error` handler. 22554 // We record this information as an expando on the error. 22555 22556 if (error != null && error._suppressLogging) { 22557 if (boundary.tag === ClassComponent) { 22558 // The error is recoverable and was silenced. 22559 // Ignore it and don't print the stack addendum. 22560 // This is handy for testing error boundaries without noise. 22561 return; 22562 } // The error is fatal. Since the silencing might have 22563 // been accidental, we'll surface it anyway. 22564 // However, the browser would have silenced the original error 22565 // so we'll print it first, and then print the stack addendum. 22566 22567 22568 console['error'](error); // Don't transform to our wrapper 22569 // For a more detailed description of this block, see: 22570 // https://github.com/facebook/react/pull/13384 22571 } 22572 22573 var componentName = source ? getComponentName(source.type) : null; 22574 var componentNameMessage = componentName ? "The above error occurred in the <" + componentName + "> component:" : 'The above error occurred in one of your React components:'; 22575 var errorBoundaryMessage; 22576 var errorBoundaryName = getComponentName(boundary.type); 22577 22578 if (errorBoundaryName) { 22579 errorBoundaryMessage = "React will try to recreate this component tree from scratch " + ("using the error boundary you provided, " + errorBoundaryName + "."); 22580 } else { 22581 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.'; 22582 } 22583 22584 var combinedMessage = componentNameMessage + "\n" + componentStack + "\n\n" + ("" + errorBoundaryMessage); // In development, we provide our own message with just the component stack. 22585 // We don't include the original error message and JS stack because the browser 22586 // has already printed it. Even if the application swallows the error, it is still 22587 // displayed by the browser thanks to the DEV-only fake event trick in ReactErrorUtils. 22588 22589 console['error'](combinedMessage); // Don't transform to our wrapper 22590 } else {} 22591 } catch (e) { 22592 // This method must not throw, or React internal state will get messed up. 22593 // If console.error is overridden, or logCapturedError() shows a dialog that throws, 22594 // we want to report this error outside of the normal stack as a last resort. 22595 // https://github.com/facebook/react/issues/13188 22596 setTimeout(function () { 22597 throw e; 22598 }); 22599 } 22600} 22601 22602var PossiblyWeakMap$1 = typeof WeakMap === 'function' ? WeakMap : Map; 22603 22604function createRootErrorUpdate(fiber, errorInfo, lane) { 22605 var update = createUpdate(NoTimestamp, lane); // Unmount the root by rendering null. 22606 22607 update.tag = CaptureUpdate; // Caution: React DevTools currently depends on this property 22608 // being called "element". 22609 22610 update.payload = { 22611 element: null 22612 }; 22613 var error = errorInfo.value; 22614 22615 update.callback = function () { 22616 onUncaughtError(error); 22617 logCapturedError(fiber, errorInfo); 22618 }; 22619 22620 return update; 22621} 22622 22623function createClassErrorUpdate(fiber, errorInfo, lane) { 22624 var update = createUpdate(NoTimestamp, lane); 22625 update.tag = CaptureUpdate; 22626 var getDerivedStateFromError = fiber.type.getDerivedStateFromError; 22627 22628 if (typeof getDerivedStateFromError === 'function') { 22629 var error$1 = errorInfo.value; 22630 22631 update.payload = function () { 22632 logCapturedError(fiber, errorInfo); 22633 return getDerivedStateFromError(error$1); 22634 }; 22635 } 22636 22637 var inst = fiber.stateNode; 22638 22639 if (inst !== null && typeof inst.componentDidCatch === 'function') { 22640 update.callback = function callback() { 22641 { 22642 markFailedErrorBoundaryForHotReloading(fiber); 22643 } 22644 22645 if (typeof getDerivedStateFromError !== 'function') { 22646 // To preserve the preexisting retry behavior of error boundaries, 22647 // we keep track of which ones already failed during this batch. 22648 // This gets reset before we yield back to the browser. 22649 // TODO: Warn in strict mode if getDerivedStateFromError is 22650 // not defined. 22651 markLegacyErrorBoundaryAsFailed(this); // Only log here if componentDidCatch is the only error boundary method defined 22652 22653 logCapturedError(fiber, errorInfo); 22654 } 22655 22656 var error$1 = errorInfo.value; 22657 var stack = errorInfo.stack; 22658 this.componentDidCatch(error$1, { 22659 componentStack: stack !== null ? stack : '' 22660 }); 22661 22662 { 22663 if (typeof getDerivedStateFromError !== 'function') { 22664 // If componentDidCatch is the only error boundary method defined, 22665 // then it needs to call setState to recover from errors. 22666 // If no state update is scheduled then the boundary will swallow the error. 22667 if (!includesSomeLane(fiber.lanes, SyncLane)) { 22668 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'); 22669 } 22670 } 22671 } 22672 }; 22673 } else { 22674 update.callback = function () { 22675 markFailedErrorBoundaryForHotReloading(fiber); 22676 }; 22677 } 22678 22679 return update; 22680} 22681 22682function attachPingListener(root, wakeable, lanes) { 22683 // Attach a listener to the promise to "ping" the root and retry. But only if 22684 // one does not already exist for the lanes we're currently rendering (which 22685 // acts like a "thread ID" here). 22686 var pingCache = root.pingCache; 22687 var threadIDs; 22688 22689 if (pingCache === null) { 22690 pingCache = root.pingCache = new PossiblyWeakMap$1(); 22691 threadIDs = new Set(); 22692 pingCache.set(wakeable, threadIDs); 22693 } else { 22694 threadIDs = pingCache.get(wakeable); 22695 22696 if (threadIDs === undefined) { 22697 threadIDs = new Set(); 22698 pingCache.set(wakeable, threadIDs); 22699 } 22700 } 22701 22702 if (!threadIDs.has(lanes)) { 22703 // Memoize using the thread ID to prevent redundant listeners. 22704 threadIDs.add(lanes); 22705 var ping = pingSuspendedRoot.bind(null, root, wakeable, lanes); 22706 wakeable.then(ping, ping); 22707 } 22708} 22709 22710function throwException(root, returnFiber, sourceFiber, value, rootRenderLanes) { 22711 // The source fiber did not complete. 22712 sourceFiber.flags |= Incomplete; // Its effect list is no longer valid. 22713 22714 sourceFiber.firstEffect = sourceFiber.lastEffect = null; 22715 22716 if (value !== null && typeof value === 'object' && typeof value.then === 'function') { 22717 // This is a wakeable. 22718 var wakeable = value; 22719 22720 if ((sourceFiber.mode & BlockingMode) === NoMode) { 22721 // Reset the memoizedState to what it was before we attempted 22722 // to render it. 22723 var currentSource = sourceFiber.alternate; 22724 22725 if (currentSource) { 22726 sourceFiber.updateQueue = currentSource.updateQueue; 22727 sourceFiber.memoizedState = currentSource.memoizedState; 22728 sourceFiber.lanes = currentSource.lanes; 22729 } else { 22730 sourceFiber.updateQueue = null; 22731 sourceFiber.memoizedState = null; 22732 } 22733 } 22734 22735 var hasInvisibleParentBoundary = hasSuspenseContext(suspenseStackCursor.current, InvisibleParentSuspenseContext); // Schedule the nearest Suspense to re-render the timed out view. 22736 22737 var _workInProgress = returnFiber; 22738 22739 do { 22740 if (_workInProgress.tag === SuspenseComponent && shouldCaptureSuspense(_workInProgress, hasInvisibleParentBoundary)) { 22741 // Found the nearest boundary. 22742 // Stash the promise on the boundary fiber. If the boundary times out, we'll 22743 // attach another listener to flip the boundary back to its normal state. 22744 var wakeables = _workInProgress.updateQueue; 22745 22746 if (wakeables === null) { 22747 var updateQueue = new Set(); 22748 updateQueue.add(wakeable); 22749 _workInProgress.updateQueue = updateQueue; 22750 } else { 22751 wakeables.add(wakeable); 22752 } // If the boundary is outside of blocking mode, we should *not* 22753 // suspend the commit. Pretend as if the suspended component rendered 22754 // null and keep rendering. In the commit phase, we'll schedule a 22755 // subsequent synchronous update to re-render the Suspense. 22756 // 22757 // Note: It doesn't matter whether the component that suspended was 22758 // inside a blocking mode tree. If the Suspense is outside of it, we 22759 // should *not* suspend the commit. 22760 22761 22762 if ((_workInProgress.mode & BlockingMode) === NoMode) { 22763 _workInProgress.flags |= DidCapture; 22764 sourceFiber.flags |= ForceUpdateForLegacySuspense; // We're going to commit this fiber even though it didn't complete. 22765 // But we shouldn't call any lifecycle methods or callbacks. Remove 22766 // all lifecycle effect tags. 22767 22768 sourceFiber.flags &= ~(LifecycleEffectMask | Incomplete); 22769 22770 if (sourceFiber.tag === ClassComponent) { 22771 var currentSourceFiber = sourceFiber.alternate; 22772 22773 if (currentSourceFiber === null) { 22774 // This is a new mount. Change the tag so it's not mistaken for a 22775 // completed class component. For example, we should not call 22776 // componentWillUnmount if it is deleted. 22777 sourceFiber.tag = IncompleteClassComponent; 22778 } else { 22779 // When we try rendering again, we should not reuse the current fiber, 22780 // since it's known to be in an inconsistent state. Use a force update to 22781 // prevent a bail out. 22782 var update = createUpdate(NoTimestamp, SyncLane); 22783 update.tag = ForceUpdate; 22784 enqueueUpdate(sourceFiber, update); 22785 } 22786 } // The source fiber did not complete. Mark it with Sync priority to 22787 // indicate that it still has pending work. 22788 22789 22790 sourceFiber.lanes = mergeLanes(sourceFiber.lanes, SyncLane); // Exit without suspending. 22791 22792 return; 22793 } // Confirmed that the boundary is in a concurrent mode tree. Continue 22794 // with the normal suspend path. 22795 // 22796 // After this we'll use a set of heuristics to determine whether this 22797 // render pass will run to completion or restart or "suspend" the commit. 22798 // The actual logic for this is spread out in different places. 22799 // 22800 // This first principle is that if we're going to suspend when we complete 22801 // a root, then we should also restart if we get an update or ping that 22802 // might unsuspend it, and vice versa. The only reason to suspend is 22803 // because you think you might want to restart before committing. However, 22804 // it doesn't make sense to restart only while in the period we're suspended. 22805 // 22806 // Restarting too aggressively is also not good because it starves out any 22807 // intermediate loading state. So we use heuristics to determine when. 22808 // Suspense Heuristics 22809 // 22810 // If nothing threw a Promise or all the same fallbacks are already showing, 22811 // then don't suspend/restart. 22812 // 22813 // If this is an initial render of a new tree of Suspense boundaries and 22814 // those trigger a fallback, then don't suspend/restart. We want to ensure 22815 // that we can show the initial loading state as quickly as possible. 22816 // 22817 // If we hit a "Delayed" case, such as when we'd switch from content back into 22818 // a fallback, then we should always suspend/restart. Transitions apply 22819 // to this case. If none is defined, JND is used instead. 22820 // 22821 // If we're already showing a fallback and it gets "retried", allowing us to show 22822 // another level, but there's still an inner boundary that would show a fallback, 22823 // then we suspend/restart for 500ms since the last time we showed a fallback 22824 // anywhere in the tree. This effectively throttles progressive loading into a 22825 // consistent train of commits. This also gives us an opportunity to restart to 22826 // get to the completed state slightly earlier. 22827 // 22828 // If there's ambiguity due to batching it's resolved in preference of: 22829 // 1) "delayed", 2) "initial render", 3) "retry". 22830 // 22831 // We want to ensure that a "busy" state doesn't get force committed. We want to 22832 // ensure that new initial loading states can commit as soon as possible. 22833 22834 22835 attachPingListener(root, wakeable, rootRenderLanes); 22836 _workInProgress.flags |= ShouldCapture; 22837 _workInProgress.lanes = rootRenderLanes; 22838 return; 22839 } // This boundary already captured during this render. Continue to the next 22840 // boundary. 22841 22842 22843 _workInProgress = _workInProgress.return; 22844 } while (_workInProgress !== null); // No boundary was found. Fallthrough to error mode. 22845 // TODO: Use invariant so the message is stripped in prod? 22846 22847 22848 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.'); 22849 } // We didn't find a boundary that could handle this type of exception. Start 22850 // over and traverse parent path again, this time treating the exception 22851 // as an error. 22852 22853 22854 renderDidError(); 22855 value = createCapturedValue(value, sourceFiber); 22856 var workInProgress = returnFiber; 22857 22858 do { 22859 switch (workInProgress.tag) { 22860 case HostRoot: 22861 { 22862 var _errorInfo = value; 22863 workInProgress.flags |= ShouldCapture; 22864 var lane = pickArbitraryLane(rootRenderLanes); 22865 workInProgress.lanes = mergeLanes(workInProgress.lanes, lane); 22866 22867 var _update = createRootErrorUpdate(workInProgress, _errorInfo, lane); 22868 22869 enqueueCapturedUpdate(workInProgress, _update); 22870 return; 22871 } 22872 22873 case ClassComponent: 22874 // Capture and retry 22875 var errorInfo = value; 22876 var ctor = workInProgress.type; 22877 var instance = workInProgress.stateNode; 22878 22879 if ((workInProgress.flags & DidCapture) === NoFlags && (typeof ctor.getDerivedStateFromError === 'function' || instance !== null && typeof instance.componentDidCatch === 'function' && !isAlreadyFailedLegacyErrorBoundary(instance))) { 22880 workInProgress.flags |= ShouldCapture; 22881 22882 var _lane = pickArbitraryLane(rootRenderLanes); 22883 22884 workInProgress.lanes = mergeLanes(workInProgress.lanes, _lane); // Schedule the error boundary to re-render using updated state 22885 22886 var _update2 = createClassErrorUpdate(workInProgress, errorInfo, _lane); 22887 22888 enqueueCapturedUpdate(workInProgress, _update2); 22889 return; 22890 } 22891 22892 break; 22893 } 22894 22895 workInProgress = workInProgress.return; 22896 } while (workInProgress !== null); 22897} 22898 22899var didWarnAboutUndefinedSnapshotBeforeUpdate = null; 22900 22901{ 22902 didWarnAboutUndefinedSnapshotBeforeUpdate = new Set(); 22903} 22904 22905var PossiblyWeakSet = typeof WeakSet === 'function' ? WeakSet : Set; 22906 22907var callComponentWillUnmountWithTimer = function (current, instance) { 22908 instance.props = current.memoizedProps; 22909 instance.state = current.memoizedState; 22910 22911 { 22912 instance.componentWillUnmount(); 22913 } 22914}; // Capture errors so they don't interrupt unmounting. 22915 22916 22917function safelyCallComponentWillUnmount(current, instance) { 22918 { 22919 invokeGuardedCallback(null, callComponentWillUnmountWithTimer, null, current, instance); 22920 22921 if (hasCaughtError()) { 22922 var unmountError = clearCaughtError(); 22923 captureCommitPhaseError(current, unmountError); 22924 } 22925 } 22926} 22927 22928function safelyDetachRef(current) { 22929 var ref = current.ref; 22930 22931 if (ref !== null) { 22932 if (typeof ref === 'function') { 22933 { 22934 invokeGuardedCallback(null, ref, null, null); 22935 22936 if (hasCaughtError()) { 22937 var refError = clearCaughtError(); 22938 captureCommitPhaseError(current, refError); 22939 } 22940 } 22941 } else { 22942 ref.current = null; 22943 } 22944 } 22945} 22946 22947function safelyCallDestroy(current, destroy) { 22948 { 22949 invokeGuardedCallback(null, destroy, null); 22950 22951 if (hasCaughtError()) { 22952 var error = clearCaughtError(); 22953 captureCommitPhaseError(current, error); 22954 } 22955 } 22956} 22957 22958function commitBeforeMutationLifeCycles(current, finishedWork) { 22959 switch (finishedWork.tag) { 22960 case FunctionComponent: 22961 case ForwardRef: 22962 case SimpleMemoComponent: 22963 case Block: 22964 { 22965 return; 22966 } 22967 22968 case ClassComponent: 22969 { 22970 if (finishedWork.flags & Snapshot) { 22971 if (current !== null) { 22972 var prevProps = current.memoizedProps; 22973 var prevState = current.memoizedState; 22974 var instance = finishedWork.stateNode; // We could update instance props and state here, 22975 // but instead we rely on them being set during last render. 22976 // TODO: revisit this when we implement resuming. 22977 22978 { 22979 if (finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps) { 22980 if (instance.props !== finishedWork.memoizedProps) { 22981 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'); 22982 } 22983 22984 if (instance.state !== finishedWork.memoizedState) { 22985 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'); 22986 } 22987 } 22988 } 22989 22990 var snapshot = instance.getSnapshotBeforeUpdate(finishedWork.elementType === finishedWork.type ? prevProps : resolveDefaultProps(finishedWork.type, prevProps), prevState); 22991 22992 { 22993 var didWarnSet = didWarnAboutUndefinedSnapshotBeforeUpdate; 22994 22995 if (snapshot === undefined && !didWarnSet.has(finishedWork.type)) { 22996 didWarnSet.add(finishedWork.type); 22997 22998 error('%s.getSnapshotBeforeUpdate(): A snapshot value (or null) ' + 'must be returned. You have returned undefined.', getComponentName(finishedWork.type)); 22999 } 23000 } 23001 23002 instance.__reactInternalSnapshotBeforeUpdate = snapshot; 23003 } 23004 } 23005 23006 return; 23007 } 23008 23009 case HostRoot: 23010 { 23011 { 23012 if (finishedWork.flags & Snapshot) { 23013 var root = finishedWork.stateNode; 23014 clearContainer(root.containerInfo); 23015 } 23016 } 23017 23018 return; 23019 } 23020 23021 case HostComponent: 23022 case HostText: 23023 case HostPortal: 23024 case IncompleteClassComponent: 23025 // Nothing to do for these component types 23026 return; 23027 } 23028 23029 { 23030 { 23031 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." ); 23032 } 23033 } 23034} 23035 23036function commitHookEffectListUnmount(tag, finishedWork) { 23037 var updateQueue = finishedWork.updateQueue; 23038 var lastEffect = updateQueue !== null ? updateQueue.lastEffect : null; 23039 23040 if (lastEffect !== null) { 23041 var firstEffect = lastEffect.next; 23042 var effect = firstEffect; 23043 23044 do { 23045 if ((effect.tag & tag) === tag) { 23046 // Unmount 23047 var destroy = effect.destroy; 23048 effect.destroy = undefined; 23049 23050 if (destroy !== undefined) { 23051 destroy(); 23052 } 23053 } 23054 23055 effect = effect.next; 23056 } while (effect !== firstEffect); 23057 } 23058} 23059 23060function commitHookEffectListMount(tag, finishedWork) { 23061 var updateQueue = finishedWork.updateQueue; 23062 var lastEffect = updateQueue !== null ? updateQueue.lastEffect : null; 23063 23064 if (lastEffect !== null) { 23065 var firstEffect = lastEffect.next; 23066 var effect = firstEffect; 23067 23068 do { 23069 if ((effect.tag & tag) === tag) { 23070 // Mount 23071 var create = effect.create; 23072 effect.destroy = create(); 23073 23074 { 23075 var destroy = effect.destroy; 23076 23077 if (destroy !== undefined && typeof destroy !== 'function') { 23078 var addendum = void 0; 23079 23080 if (destroy === null) { 23081 addendum = ' You returned null. If your effect does not require clean ' + 'up, return undefined (or nothing).'; 23082 } else if (typeof destroy.then === 'function') { 23083 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'; 23084 } else { 23085 addendum = ' You returned: ' + destroy; 23086 } 23087 23088 error('An effect function must not return anything besides a function, ' + 'which is used for clean-up.%s', addendum); 23089 } 23090 } 23091 } 23092 23093 effect = effect.next; 23094 } while (effect !== firstEffect); 23095 } 23096} 23097 23098function schedulePassiveEffects(finishedWork) { 23099 var updateQueue = finishedWork.updateQueue; 23100 var lastEffect = updateQueue !== null ? updateQueue.lastEffect : null; 23101 23102 if (lastEffect !== null) { 23103 var firstEffect = lastEffect.next; 23104 var effect = firstEffect; 23105 23106 do { 23107 var _effect = effect, 23108 next = _effect.next, 23109 tag = _effect.tag; 23110 23111 if ((tag & Passive$1) !== NoFlags$1 && (tag & HasEffect) !== NoFlags$1) { 23112 enqueuePendingPassiveHookEffectUnmount(finishedWork, effect); 23113 enqueuePendingPassiveHookEffectMount(finishedWork, effect); 23114 } 23115 23116 effect = next; 23117 } while (effect !== firstEffect); 23118 } 23119} 23120 23121function commitLifeCycles(finishedRoot, current, finishedWork, committedLanes) { 23122 switch (finishedWork.tag) { 23123 case FunctionComponent: 23124 case ForwardRef: 23125 case SimpleMemoComponent: 23126 case Block: 23127 { 23128 // At this point layout effects have already been destroyed (during mutation phase). 23129 // This is done to prevent sibling component effects from interfering with each other, 23130 // e.g. a destroy function in one component should never override a ref set 23131 // by a create function in another component during the same commit. 23132 { 23133 commitHookEffectListMount(Layout | HasEffect, finishedWork); 23134 } 23135 23136 schedulePassiveEffects(finishedWork); 23137 return; 23138 } 23139 23140 case ClassComponent: 23141 { 23142 var instance = finishedWork.stateNode; 23143 23144 if (finishedWork.flags & Update) { 23145 if (current === null) { 23146 // We could update instance props and state here, 23147 // but instead we rely on them being set during last render. 23148 // TODO: revisit this when we implement resuming. 23149 { 23150 if (finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps) { 23151 if (instance.props !== finishedWork.memoizedProps) { 23152 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'); 23153 } 23154 23155 if (instance.state !== finishedWork.memoizedState) { 23156 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'); 23157 } 23158 } 23159 } 23160 23161 { 23162 instance.componentDidMount(); 23163 } 23164 } else { 23165 var prevProps = finishedWork.elementType === finishedWork.type ? current.memoizedProps : resolveDefaultProps(finishedWork.type, current.memoizedProps); 23166 var prevState = current.memoizedState; // We could update instance props and state here, 23167 // but instead we rely on them being set during last render. 23168 // TODO: revisit this when we implement resuming. 23169 23170 { 23171 if (finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps) { 23172 if (instance.props !== finishedWork.memoizedProps) { 23173 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'); 23174 } 23175 23176 if (instance.state !== finishedWork.memoizedState) { 23177 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'); 23178 } 23179 } 23180 } 23181 23182 { 23183 instance.componentDidUpdate(prevProps, prevState, instance.__reactInternalSnapshotBeforeUpdate); 23184 } 23185 } 23186 } // TODO: I think this is now always non-null by the time it reaches the 23187 // commit phase. Consider removing the type check. 23188 23189 23190 var updateQueue = finishedWork.updateQueue; 23191 23192 if (updateQueue !== null) { 23193 { 23194 if (finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps) { 23195 if (instance.props !== finishedWork.memoizedProps) { 23196 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'); 23197 } 23198 23199 if (instance.state !== finishedWork.memoizedState) { 23200 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'); 23201 } 23202 } 23203 } // We could update instance props and state here, 23204 // but instead we rely on them being set during last render. 23205 // TODO: revisit this when we implement resuming. 23206 23207 23208 commitUpdateQueue(finishedWork, updateQueue, instance); 23209 } 23210 23211 return; 23212 } 23213 23214 case HostRoot: 23215 { 23216 // TODO: I think this is now always non-null by the time it reaches the 23217 // commit phase. Consider removing the type check. 23218 var _updateQueue = finishedWork.updateQueue; 23219 23220 if (_updateQueue !== null) { 23221 var _instance = null; 23222 23223 if (finishedWork.child !== null) { 23224 switch (finishedWork.child.tag) { 23225 case HostComponent: 23226 _instance = getPublicInstance(finishedWork.child.stateNode); 23227 break; 23228 23229 case ClassComponent: 23230 _instance = finishedWork.child.stateNode; 23231 break; 23232 } 23233 } 23234 23235 commitUpdateQueue(finishedWork, _updateQueue, _instance); 23236 } 23237 23238 return; 23239 } 23240 23241 case HostComponent: 23242 { 23243 var _instance2 = finishedWork.stateNode; // Renderers may schedule work to be done after host components are mounted 23244 // (eg DOM renderer may schedule auto-focus for inputs and form controls). 23245 // These effects should only be committed when components are first mounted, 23246 // aka when there is no current/alternate. 23247 23248 if (current === null && finishedWork.flags & Update) { 23249 var type = finishedWork.type; 23250 var props = finishedWork.memoizedProps; 23251 commitMount(_instance2, type, props); 23252 } 23253 23254 return; 23255 } 23256 23257 case HostText: 23258 { 23259 // We have no life-cycles associated with text. 23260 return; 23261 } 23262 23263 case HostPortal: 23264 { 23265 // We have no life-cycles associated with portals. 23266 return; 23267 } 23268 23269 case Profiler: 23270 { 23271 { 23272 var _finishedWork$memoize2 = finishedWork.memoizedProps, 23273 onCommit = _finishedWork$memoize2.onCommit, 23274 onRender = _finishedWork$memoize2.onRender; 23275 var effectDuration = finishedWork.stateNode.effectDuration; 23276 var commitTime = getCommitTime(); 23277 23278 if (typeof onRender === 'function') { 23279 { 23280 onRender(finishedWork.memoizedProps.id, current === null ? 'mount' : 'update', finishedWork.actualDuration, finishedWork.treeBaseDuration, finishedWork.actualStartTime, commitTime, finishedRoot.memoizedInteractions); 23281 } 23282 } 23283 } 23284 23285 return; 23286 } 23287 23288 case SuspenseComponent: 23289 { 23290 commitSuspenseHydrationCallbacks(finishedRoot, finishedWork); 23291 return; 23292 } 23293 23294 case SuspenseListComponent: 23295 case IncompleteClassComponent: 23296 case FundamentalComponent: 23297 case ScopeComponent: 23298 case OffscreenComponent: 23299 case LegacyHiddenComponent: 23300 return; 23301 } 23302 23303 { 23304 { 23305 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." ); 23306 } 23307 } 23308} 23309 23310function hideOrUnhideAllChildren(finishedWork, isHidden) { 23311 { 23312 // We only have the top Fiber that was inserted but we need to recurse down its 23313 // children to find all the terminal nodes. 23314 var node = finishedWork; 23315 23316 while (true) { 23317 if (node.tag === HostComponent) { 23318 var instance = node.stateNode; 23319 23320 if (isHidden) { 23321 hideInstance(instance); 23322 } else { 23323 unhideInstance(node.stateNode, node.memoizedProps); 23324 } 23325 } else if (node.tag === HostText) { 23326 var _instance3 = node.stateNode; 23327 23328 if (isHidden) { 23329 hideTextInstance(_instance3); 23330 } else { 23331 unhideTextInstance(_instance3, node.memoizedProps); 23332 } 23333 } else if ((node.tag === OffscreenComponent || node.tag === LegacyHiddenComponent) && node.memoizedState !== null && node !== finishedWork) ; else if (node.child !== null) { 23334 node.child.return = node; 23335 node = node.child; 23336 continue; 23337 } 23338 23339 if (node === finishedWork) { 23340 return; 23341 } 23342 23343 while (node.sibling === null) { 23344 if (node.return === null || node.return === finishedWork) { 23345 return; 23346 } 23347 23348 node = node.return; 23349 } 23350 23351 node.sibling.return = node.return; 23352 node = node.sibling; 23353 } 23354 } 23355} 23356 23357function commitAttachRef(finishedWork) { 23358 var ref = finishedWork.ref; 23359 23360 if (ref !== null) { 23361 var instance = finishedWork.stateNode; 23362 var instanceToUse; 23363 23364 switch (finishedWork.tag) { 23365 case HostComponent: 23366 instanceToUse = getPublicInstance(instance); 23367 break; 23368 23369 default: 23370 instanceToUse = instance; 23371 } // Moved outside to ensure DCE works with this flag 23372 23373 if (typeof ref === 'function') { 23374 ref(instanceToUse); 23375 } else { 23376 { 23377 if (!ref.hasOwnProperty('current')) { 23378 error('Unexpected ref object provided for %s. ' + 'Use either a ref-setter function or React.createRef().', getComponentName(finishedWork.type)); 23379 } 23380 } 23381 23382 ref.current = instanceToUse; 23383 } 23384 } 23385} 23386 23387function commitDetachRef(current) { 23388 var currentRef = current.ref; 23389 23390 if (currentRef !== null) { 23391 if (typeof currentRef === 'function') { 23392 currentRef(null); 23393 } else { 23394 currentRef.current = null; 23395 } 23396 } 23397} // User-originating errors (lifecycles and refs) should not interrupt 23398// deletion, so don't let them throw. Host-originating errors should 23399// interrupt deletion, so it's okay 23400 23401 23402function commitUnmount(finishedRoot, current, renderPriorityLevel) { 23403 onCommitUnmount(current); 23404 23405 switch (current.tag) { 23406 case FunctionComponent: 23407 case ForwardRef: 23408 case MemoComponent: 23409 case SimpleMemoComponent: 23410 case Block: 23411 { 23412 var updateQueue = current.updateQueue; 23413 23414 if (updateQueue !== null) { 23415 var lastEffect = updateQueue.lastEffect; 23416 23417 if (lastEffect !== null) { 23418 var firstEffect = lastEffect.next; 23419 var effect = firstEffect; 23420 23421 do { 23422 var _effect2 = effect, 23423 destroy = _effect2.destroy, 23424 tag = _effect2.tag; 23425 23426 if (destroy !== undefined) { 23427 if ((tag & Passive$1) !== NoFlags$1) { 23428 enqueuePendingPassiveHookEffectUnmount(current, effect); 23429 } else { 23430 { 23431 safelyCallDestroy(current, destroy); 23432 } 23433 } 23434 } 23435 23436 effect = effect.next; 23437 } while (effect !== firstEffect); 23438 } 23439 } 23440 23441 return; 23442 } 23443 23444 case ClassComponent: 23445 { 23446 safelyDetachRef(current); 23447 var instance = current.stateNode; 23448 23449 if (typeof instance.componentWillUnmount === 'function') { 23450 safelyCallComponentWillUnmount(current, instance); 23451 } 23452 23453 return; 23454 } 23455 23456 case HostComponent: 23457 { 23458 safelyDetachRef(current); 23459 return; 23460 } 23461 23462 case HostPortal: 23463 { 23464 // TODO: this is recursive. 23465 // We are also not using this parent because 23466 // the portal will get pushed immediately. 23467 { 23468 unmountHostComponents(finishedRoot, current); 23469 } 23470 23471 return; 23472 } 23473 23474 case FundamentalComponent: 23475 { 23476 23477 return; 23478 } 23479 23480 case DehydratedFragment: 23481 { 23482 23483 return; 23484 } 23485 23486 case ScopeComponent: 23487 { 23488 23489 return; 23490 } 23491 } 23492} 23493 23494function commitNestedUnmounts(finishedRoot, root, renderPriorityLevel) { 23495 // While we're inside a removed host node we don't want to call 23496 // removeChild on the inner nodes because they're removed by the top 23497 // call anyway. We also want to call componentWillUnmount on all 23498 // composites before this host node is removed from the tree. Therefore 23499 // we do an inner loop while we're still inside the host node. 23500 var node = root; 23501 23502 while (true) { 23503 commitUnmount(finishedRoot, node); // Visit children because they may contain more composite or host nodes. 23504 // Skip portals because commitUnmount() currently visits them recursively. 23505 23506 if (node.child !== null && ( // If we use mutation we drill down into portals using commitUnmount above. 23507 // If we don't use mutation we drill down into portals here instead. 23508 node.tag !== HostPortal)) { 23509 node.child.return = node; 23510 node = node.child; 23511 continue; 23512 } 23513 23514 if (node === root) { 23515 return; 23516 } 23517 23518 while (node.sibling === null) { 23519 if (node.return === null || node.return === root) { 23520 return; 23521 } 23522 23523 node = node.return; 23524 } 23525 23526 node.sibling.return = node.return; 23527 node = node.sibling; 23528 } 23529} 23530 23531function detachFiberMutation(fiber) { 23532 // Cut off the return pointers to disconnect it from the tree. Ideally, we 23533 // should clear the child pointer of the parent alternate to let this 23534 // get GC:ed but we don't know which for sure which parent is the current 23535 // one so we'll settle for GC:ing the subtree of this child. This child 23536 // itself will be GC:ed when the parent updates the next time. 23537 // Note: we cannot null out sibling here, otherwise it can cause issues 23538 // with findDOMNode and how it requires the sibling field to carry out 23539 // traversal in a later effect. See PR #16820. We now clear the sibling 23540 // field after effects, see: detachFiberAfterEffects. 23541 // 23542 // Don't disconnect stateNode now; it will be detached in detachFiberAfterEffects. 23543 // It may be required if the current component is an error boundary, 23544 // and one of its descendants throws while unmounting a passive effect. 23545 fiber.alternate = null; 23546 fiber.child = null; 23547 fiber.dependencies = null; 23548 fiber.firstEffect = null; 23549 fiber.lastEffect = null; 23550 fiber.memoizedProps = null; 23551 fiber.memoizedState = null; 23552 fiber.pendingProps = null; 23553 fiber.return = null; 23554 fiber.updateQueue = null; 23555 23556 { 23557 fiber._debugOwner = null; 23558 } 23559} 23560 23561function getHostParentFiber(fiber) { 23562 var parent = fiber.return; 23563 23564 while (parent !== null) { 23565 if (isHostParent(parent)) { 23566 return parent; 23567 } 23568 23569 parent = parent.return; 23570 } 23571 23572 { 23573 { 23574 throw Error( "Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue." ); 23575 } 23576 } 23577} 23578 23579function isHostParent(fiber) { 23580 return fiber.tag === HostComponent || fiber.tag === HostRoot || fiber.tag === HostPortal; 23581} 23582 23583function getHostSibling(fiber) { 23584 // We're going to search forward into the tree until we find a sibling host 23585 // node. Unfortunately, if multiple insertions are done in a row we have to 23586 // search past them. This leads to exponential search for the next sibling. 23587 // TODO: Find a more efficient way to do this. 23588 var node = fiber; 23589 23590 siblings: while (true) { 23591 // If we didn't find anything, let's try the next sibling. 23592 while (node.sibling === null) { 23593 if (node.return === null || isHostParent(node.return)) { 23594 // If we pop out of the root or hit the parent the fiber we are the 23595 // last sibling. 23596 return null; 23597 } 23598 23599 node = node.return; 23600 } 23601 23602 node.sibling.return = node.return; 23603 node = node.sibling; 23604 23605 while (node.tag !== HostComponent && node.tag !== HostText && node.tag !== DehydratedFragment) { 23606 // If it is not host node and, we might have a host node inside it. 23607 // Try to search down until we find one. 23608 if (node.flags & Placement) { 23609 // If we don't have a child, try the siblings instead. 23610 continue siblings; 23611 } // If we don't have a child, try the siblings instead. 23612 // We also skip portals because they are not part of this host tree. 23613 23614 23615 if (node.child === null || node.tag === HostPortal) { 23616 continue siblings; 23617 } else { 23618 node.child.return = node; 23619 node = node.child; 23620 } 23621 } // Check if this host node is stable or about to be placed. 23622 23623 23624 if (!(node.flags & Placement)) { 23625 // Found it! 23626 return node.stateNode; 23627 } 23628 } 23629} 23630 23631function commitPlacement(finishedWork) { 23632 23633 23634 var parentFiber = getHostParentFiber(finishedWork); // Note: these two variables *must* always be updated together. 23635 23636 var parent; 23637 var isContainer; 23638 var parentStateNode = parentFiber.stateNode; 23639 23640 switch (parentFiber.tag) { 23641 case HostComponent: 23642 parent = parentStateNode; 23643 isContainer = false; 23644 break; 23645 23646 case HostRoot: 23647 parent = parentStateNode.containerInfo; 23648 isContainer = true; 23649 break; 23650 23651 case HostPortal: 23652 parent = parentStateNode.containerInfo; 23653 isContainer = true; 23654 break; 23655 23656 case FundamentalComponent: 23657 23658 // eslint-disable-next-line-no-fallthrough 23659 23660 default: 23661 { 23662 { 23663 throw Error( "Invalid host parent fiber. This error is likely caused by a bug in React. Please file an issue." ); 23664 } 23665 } 23666 23667 } 23668 23669 if (parentFiber.flags & ContentReset) { 23670 // Reset the text content of the parent before doing any insertions 23671 resetTextContent(parent); // Clear ContentReset from the effect tag 23672 23673 parentFiber.flags &= ~ContentReset; 23674 } 23675 23676 var before = getHostSibling(finishedWork); // We only have the top Fiber that was inserted but we need to recurse down its 23677 // children to find all the terminal nodes. 23678 23679 if (isContainer) { 23680 insertOrAppendPlacementNodeIntoContainer(finishedWork, before, parent); 23681 } else { 23682 insertOrAppendPlacementNode(finishedWork, before, parent); 23683 } 23684} 23685 23686function insertOrAppendPlacementNodeIntoContainer(node, before, parent) { 23687 var tag = node.tag; 23688 var isHost = tag === HostComponent || tag === HostText; 23689 23690 if (isHost || enableFundamentalAPI ) { 23691 var stateNode = isHost ? node.stateNode : node.stateNode.instance; 23692 23693 if (before) { 23694 insertInContainerBefore(parent, stateNode, before); 23695 } else { 23696 appendChildToContainer(parent, stateNode); 23697 } 23698 } else if (tag === HostPortal) ; else { 23699 var child = node.child; 23700 23701 if (child !== null) { 23702 insertOrAppendPlacementNodeIntoContainer(child, before, parent); 23703 var sibling = child.sibling; 23704 23705 while (sibling !== null) { 23706 insertOrAppendPlacementNodeIntoContainer(sibling, before, parent); 23707 sibling = sibling.sibling; 23708 } 23709 } 23710 } 23711} 23712 23713function insertOrAppendPlacementNode(node, before, parent) { 23714 var tag = node.tag; 23715 var isHost = tag === HostComponent || tag === HostText; 23716 23717 if (isHost || enableFundamentalAPI ) { 23718 var stateNode = isHost ? node.stateNode : node.stateNode.instance; 23719 23720 if (before) { 23721 insertBefore(parent, stateNode, before); 23722 } else { 23723 appendChild(parent, stateNode); 23724 } 23725 } else if (tag === HostPortal) ; else { 23726 var child = node.child; 23727 23728 if (child !== null) { 23729 insertOrAppendPlacementNode(child, before, parent); 23730 var sibling = child.sibling; 23731 23732 while (sibling !== null) { 23733 insertOrAppendPlacementNode(sibling, before, parent); 23734 sibling = sibling.sibling; 23735 } 23736 } 23737 } 23738} 23739 23740function unmountHostComponents(finishedRoot, current, renderPriorityLevel) { 23741 // We only have the top Fiber that was deleted but we need to recurse down its 23742 // children to find all the terminal nodes. 23743 var node = current; // Each iteration, currentParent is populated with node's host parent if not 23744 // currentParentIsValid. 23745 23746 var currentParentIsValid = false; // Note: these two variables *must* always be updated together. 23747 23748 var currentParent; 23749 var currentParentIsContainer; 23750 23751 while (true) { 23752 if (!currentParentIsValid) { 23753 var parent = node.return; 23754 23755 findParent: while (true) { 23756 if (!(parent !== null)) { 23757 { 23758 throw Error( "Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue." ); 23759 } 23760 } 23761 23762 var parentStateNode = parent.stateNode; 23763 23764 switch (parent.tag) { 23765 case HostComponent: 23766 currentParent = parentStateNode; 23767 currentParentIsContainer = false; 23768 break findParent; 23769 23770 case HostRoot: 23771 currentParent = parentStateNode.containerInfo; 23772 currentParentIsContainer = true; 23773 break findParent; 23774 23775 case HostPortal: 23776 currentParent = parentStateNode.containerInfo; 23777 currentParentIsContainer = true; 23778 break findParent; 23779 23780 } 23781 23782 parent = parent.return; 23783 } 23784 23785 currentParentIsValid = true; 23786 } 23787 23788 if (node.tag === HostComponent || node.tag === HostText) { 23789 commitNestedUnmounts(finishedRoot, node); // After all the children have unmounted, it is now safe to remove the 23790 // node from the tree. 23791 23792 if (currentParentIsContainer) { 23793 removeChildFromContainer(currentParent, node.stateNode); 23794 } else { 23795 removeChild(currentParent, node.stateNode); 23796 } // Don't visit children because we already visited them. 23797 23798 } else if (node.tag === HostPortal) { 23799 if (node.child !== null) { 23800 // When we go into a portal, it becomes the parent to remove from. 23801 // We will reassign it back when we pop the portal on the way up. 23802 currentParent = node.stateNode.containerInfo; 23803 currentParentIsContainer = true; // Visit children because portals might contain host components. 23804 23805 node.child.return = node; 23806 node = node.child; 23807 continue; 23808 } 23809 } else { 23810 commitUnmount(finishedRoot, node); // Visit children because we may find more host components below. 23811 23812 if (node.child !== null) { 23813 node.child.return = node; 23814 node = node.child; 23815 continue; 23816 } 23817 } 23818 23819 if (node === current) { 23820 return; 23821 } 23822 23823 while (node.sibling === null) { 23824 if (node.return === null || node.return === current) { 23825 return; 23826 } 23827 23828 node = node.return; 23829 23830 if (node.tag === HostPortal) { 23831 // When we go out of the portal, we need to restore the parent. 23832 // Since we don't keep a stack of them, we will search for it. 23833 currentParentIsValid = false; 23834 } 23835 } 23836 23837 node.sibling.return = node.return; 23838 node = node.sibling; 23839 } 23840} 23841 23842function commitDeletion(finishedRoot, current, renderPriorityLevel) { 23843 { 23844 // Recursively delete all host nodes from the parent. 23845 // Detach refs and call componentWillUnmount() on the whole subtree. 23846 unmountHostComponents(finishedRoot, current); 23847 } 23848 23849 var alternate = current.alternate; 23850 detachFiberMutation(current); 23851 23852 if (alternate !== null) { 23853 detachFiberMutation(alternate); 23854 } 23855} 23856 23857function commitWork(current, finishedWork) { 23858 23859 switch (finishedWork.tag) { 23860 case FunctionComponent: 23861 case ForwardRef: 23862 case MemoComponent: 23863 case SimpleMemoComponent: 23864 case Block: 23865 { 23866 // Layout effects are destroyed during the mutation phase so that all 23867 // destroy functions for all fibers are called before any create functions. 23868 // This prevents sibling component effects from interfering with each other, 23869 // e.g. a destroy function in one component should never override a ref set 23870 // by a create function in another component during the same commit. 23871 { 23872 commitHookEffectListUnmount(Layout | HasEffect, finishedWork); 23873 } 23874 23875 return; 23876 } 23877 23878 case ClassComponent: 23879 { 23880 return; 23881 } 23882 23883 case HostComponent: 23884 { 23885 var instance = finishedWork.stateNode; 23886 23887 if (instance != null) { 23888 // Commit the work prepared earlier. 23889 var newProps = finishedWork.memoizedProps; // For hydration we reuse the update path but we treat the oldProps 23890 // as the newProps. The updatePayload will contain the real change in 23891 // this case. 23892 23893 var oldProps = current !== null ? current.memoizedProps : newProps; 23894 var type = finishedWork.type; // TODO: Type the updateQueue to be specific to host components. 23895 23896 var updatePayload = finishedWork.updateQueue; 23897 finishedWork.updateQueue = null; 23898 23899 if (updatePayload !== null) { 23900 commitUpdate(instance, updatePayload, type, oldProps, newProps); 23901 } 23902 } 23903 23904 return; 23905 } 23906 23907 case HostText: 23908 { 23909 if (!(finishedWork.stateNode !== null)) { 23910 { 23911 throw Error( "This should have a text node initialized. This error is likely caused by a bug in React. Please file an issue." ); 23912 } 23913 } 23914 23915 var textInstance = finishedWork.stateNode; 23916 var newText = finishedWork.memoizedProps; // For hydration we reuse the update path but we treat the oldProps 23917 // as the newProps. The updatePayload will contain the real change in 23918 // this case. 23919 23920 var oldText = current !== null ? current.memoizedProps : newText; 23921 commitTextUpdate(textInstance, oldText, newText); 23922 return; 23923 } 23924 23925 case HostRoot: 23926 { 23927 { 23928 var _root = finishedWork.stateNode; 23929 23930 if (_root.hydrate) { 23931 // We've just hydrated. No need to hydrate again. 23932 _root.hydrate = false; 23933 commitHydratedContainer(_root.containerInfo); 23934 } 23935 } 23936 23937 return; 23938 } 23939 23940 case Profiler: 23941 { 23942 return; 23943 } 23944 23945 case SuspenseComponent: 23946 { 23947 commitSuspenseComponent(finishedWork); 23948 attachSuspenseRetryListeners(finishedWork); 23949 return; 23950 } 23951 23952 case SuspenseListComponent: 23953 { 23954 attachSuspenseRetryListeners(finishedWork); 23955 return; 23956 } 23957 23958 case IncompleteClassComponent: 23959 { 23960 return; 23961 } 23962 23963 case FundamentalComponent: 23964 { 23965 23966 break; 23967 } 23968 23969 case ScopeComponent: 23970 { 23971 23972 break; 23973 } 23974 23975 case OffscreenComponent: 23976 case LegacyHiddenComponent: 23977 { 23978 var newState = finishedWork.memoizedState; 23979 var isHidden = newState !== null; 23980 hideOrUnhideAllChildren(finishedWork, isHidden); 23981 return; 23982 } 23983 } 23984 23985 { 23986 { 23987 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." ); 23988 } 23989 } 23990} 23991 23992function commitSuspenseComponent(finishedWork) { 23993 var newState = finishedWork.memoizedState; 23994 23995 if (newState !== null) { 23996 markCommitTimeOfFallback(); 23997 23998 { 23999 // Hide the Offscreen component that contains the primary children. TODO: 24000 // Ideally, this effect would have been scheduled on the Offscreen fiber 24001 // itself. That's how unhiding works: the Offscreen component schedules an 24002 // effect on itself. However, in this case, the component didn't complete, 24003 // so the fiber was never added to the effect list in the normal path. We 24004 // could have appended it to the effect list in the Suspense component's 24005 // second pass, but doing it this way is less complicated. This would be 24006 // simpler if we got rid of the effect list and traversed the tree, like 24007 // we're planning to do. 24008 var primaryChildParent = finishedWork.child; 24009 hideOrUnhideAllChildren(primaryChildParent, true); 24010 } 24011 } 24012} 24013 24014function commitSuspenseHydrationCallbacks(finishedRoot, finishedWork) { 24015 24016 var newState = finishedWork.memoizedState; 24017 24018 if (newState === null) { 24019 var current = finishedWork.alternate; 24020 24021 if (current !== null) { 24022 var prevState = current.memoizedState; 24023 24024 if (prevState !== null) { 24025 var suspenseInstance = prevState.dehydrated; 24026 24027 if (suspenseInstance !== null) { 24028 commitHydratedSuspenseInstance(suspenseInstance); 24029 } 24030 } 24031 } 24032 } 24033} 24034 24035function attachSuspenseRetryListeners(finishedWork) { 24036 // If this boundary just timed out, then it will have a set of wakeables. 24037 // For each wakeable, attach a listener so that when it resolves, React 24038 // attempts to re-render the boundary in the primary (pre-timeout) state. 24039 var wakeables = finishedWork.updateQueue; 24040 24041 if (wakeables !== null) { 24042 finishedWork.updateQueue = null; 24043 var retryCache = finishedWork.stateNode; 24044 24045 if (retryCache === null) { 24046 retryCache = finishedWork.stateNode = new PossiblyWeakSet(); 24047 } 24048 24049 wakeables.forEach(function (wakeable) { 24050 // Memoize using the boundary fiber to prevent redundant listeners. 24051 var retry = resolveRetryWakeable.bind(null, finishedWork, wakeable); 24052 24053 if (!retryCache.has(wakeable)) { 24054 { 24055 if (wakeable.__reactDoNotTraceInteractions !== true) { 24056 retry = tracing.unstable_wrap(retry); 24057 } 24058 } 24059 24060 retryCache.add(wakeable); 24061 wakeable.then(retry, retry); 24062 } 24063 }); 24064 } 24065} // This function detects when a Suspense boundary goes from visible to hidden. 24066// It returns false if the boundary is already hidden. 24067// TODO: Use an effect tag. 24068 24069 24070function isSuspenseBoundaryBeingHidden(current, finishedWork) { 24071 if (current !== null) { 24072 var oldState = current.memoizedState; 24073 24074 if (oldState === null || oldState.dehydrated !== null) { 24075 var newState = finishedWork.memoizedState; 24076 return newState !== null && newState.dehydrated === null; 24077 } 24078 } 24079 24080 return false; 24081} 24082 24083function commitResetTextContent(current) { 24084 24085 resetTextContent(current.stateNode); 24086} 24087 24088var COMPONENT_TYPE = 0; 24089var HAS_PSEUDO_CLASS_TYPE = 1; 24090var ROLE_TYPE = 2; 24091var TEST_NAME_TYPE = 3; 24092var TEXT_TYPE = 4; 24093 24094if (typeof Symbol === 'function' && Symbol.for) { 24095 var symbolFor$1 = Symbol.for; 24096 COMPONENT_TYPE = symbolFor$1('selector.component'); 24097 HAS_PSEUDO_CLASS_TYPE = symbolFor$1('selector.has_pseudo_class'); 24098 ROLE_TYPE = symbolFor$1('selector.role'); 24099 TEST_NAME_TYPE = symbolFor$1('selector.test_id'); 24100 TEXT_TYPE = symbolFor$1('selector.text'); 24101} 24102var commitHooks = []; 24103function onCommitRoot$1() { 24104 { 24105 commitHooks.forEach(function (commitHook) { 24106 return commitHook(); 24107 }); 24108 } 24109} 24110 24111var ceil = Math.ceil; 24112var ReactCurrentDispatcher$2 = ReactSharedInternals.ReactCurrentDispatcher, 24113 ReactCurrentOwner$2 = ReactSharedInternals.ReactCurrentOwner, 24114 IsSomeRendererActing = ReactSharedInternals.IsSomeRendererActing; 24115var NoContext = 24116/* */ 241170; 24118var BatchedContext = 24119/* */ 241201; 24121var EventContext = 24122/* */ 241232; 24124var DiscreteEventContext = 24125/* */ 241264; 24127var LegacyUnbatchedContext = 24128/* */ 241298; 24130var RenderContext = 24131/* */ 2413216; 24133var CommitContext = 24134/* */ 2413532; 24136var RetryAfterError = 24137/* */ 2413864; 24139var RootIncomplete = 0; 24140var RootFatalErrored = 1; 24141var RootErrored = 2; 24142var RootSuspended = 3; 24143var RootSuspendedWithDelay = 4; 24144var RootCompleted = 5; // Describes where we are in the React execution stack 24145 24146var executionContext = NoContext; // The root we're working on 24147 24148var workInProgressRoot = null; // The fiber we're working on 24149 24150var workInProgress = null; // The lanes we're rendering 24151 24152var workInProgressRootRenderLanes = NoLanes; // Stack that allows components to change the render lanes for its subtree 24153// This is a superset of the lanes we started working on at the root. The only 24154// case where it's different from `workInProgressRootRenderLanes` is when we 24155// enter a subtree that is hidden and needs to be unhidden: Suspense and 24156// Offscreen component. 24157// 24158// Most things in the work loop should deal with workInProgressRootRenderLanes. 24159// Most things in begin/complete phases should deal with subtreeRenderLanes. 24160 24161var subtreeRenderLanes = NoLanes; 24162var subtreeRenderLanesCursor = createCursor(NoLanes); // Whether to root completed, errored, suspended, etc. 24163 24164var workInProgressRootExitStatus = RootIncomplete; // A fatal error, if one is thrown 24165 24166var workInProgressRootFatalError = null; // "Included" lanes refer to lanes that were worked on during this render. It's 24167// slightly different than `renderLanes` because `renderLanes` can change as you 24168// enter and exit an Offscreen tree. This value is the combination of all render 24169// lanes for the entire render phase. 24170 24171var workInProgressRootIncludedLanes = NoLanes; // The work left over by components that were visited during this render. Only 24172// includes unprocessed updates, not work in bailed out children. 24173 24174var workInProgressRootSkippedLanes = NoLanes; // Lanes that were updated (in an interleaved event) during this render. 24175 24176var workInProgressRootUpdatedLanes = NoLanes; // Lanes that were pinged (in an interleaved event) during this render. 24177 24178var workInProgressRootPingedLanes = NoLanes; 24179var mostRecentlyUpdatedRoot = null; // The most recent time we committed a fallback. This lets us ensure a train 24180// model where we don't commit new loading states in too quick succession. 24181 24182var globalMostRecentFallbackTime = 0; 24183var FALLBACK_THROTTLE_MS = 500; // The absolute time for when we should start giving up on rendering 24184// more and prefer CPU suspense heuristics instead. 24185 24186var workInProgressRootRenderTargetTime = Infinity; // How long a render is supposed to take before we start following CPU 24187// suspense heuristics and opt out of rendering more content. 24188 24189var RENDER_TIMEOUT_MS = 500; 24190 24191function resetRenderTimer() { 24192 workInProgressRootRenderTargetTime = now() + RENDER_TIMEOUT_MS; 24193} 24194 24195function getRenderTargetTime() { 24196 return workInProgressRootRenderTargetTime; 24197} 24198var nextEffect = null; 24199var hasUncaughtError = false; 24200var firstUncaughtError = null; 24201var legacyErrorBoundariesThatAlreadyFailed = null; 24202var rootDoesHavePassiveEffects = false; 24203var rootWithPendingPassiveEffects = null; 24204var pendingPassiveEffectsRenderPriority = NoPriority$1; 24205var pendingPassiveEffectsLanes = NoLanes; 24206var pendingPassiveHookEffectsMount = []; 24207var pendingPassiveHookEffectsUnmount = []; 24208var rootsWithPendingDiscreteUpdates = null; // Use these to prevent an infinite loop of nested updates 24209 24210var NESTED_UPDATE_LIMIT = 50; 24211var nestedUpdateCount = 0; 24212var rootWithNestedUpdates = null; 24213var NESTED_PASSIVE_UPDATE_LIMIT = 50; 24214var nestedPassiveUpdateCount = 0; // Marks the need to reschedule pending interactions at these lanes 24215// during the commit phase. This enables them to be traced across components 24216// that spawn new work during render. E.g. hidden boundaries, suspended SSR 24217// hydration or SuspenseList. 24218// TODO: Can use a bitmask instead of an array 24219 24220var spawnedWorkDuringRender = null; // If two updates are scheduled within the same event, we should treat their 24221// event times as simultaneous, even if the actual clock time has advanced 24222// between the first and second call. 24223 24224var currentEventTime = NoTimestamp; 24225var currentEventWipLanes = NoLanes; 24226var currentEventPendingLanes = NoLanes; // Dev only flag that tracks if passive effects are currently being flushed. 24227// We warn about state updates for unmounted components differently in this case. 24228 24229var isFlushingPassiveEffects = false; 24230var focusedInstanceHandle = null; 24231var shouldFireAfterActiveInstanceBlur = false; 24232function getWorkInProgressRoot() { 24233 return workInProgressRoot; 24234} 24235function requestEventTime() { 24236 if ((executionContext & (RenderContext | CommitContext)) !== NoContext) { 24237 // We're inside React, so it's fine to read the actual time. 24238 return now(); 24239 } // We're not inside React, so we may be in the middle of a browser event. 24240 24241 24242 if (currentEventTime !== NoTimestamp) { 24243 // Use the same start time for all updates until we enter React again. 24244 return currentEventTime; 24245 } // This is the first update since React yielded. Compute a new start time. 24246 24247 24248 currentEventTime = now(); 24249 return currentEventTime; 24250} 24251function requestUpdateLane(fiber) { 24252 // Special cases 24253 var mode = fiber.mode; 24254 24255 if ((mode & BlockingMode) === NoMode) { 24256 return SyncLane; 24257 } else if ((mode & ConcurrentMode) === NoMode) { 24258 return getCurrentPriorityLevel() === ImmediatePriority$1 ? SyncLane : SyncBatchedLane; 24259 } // The algorithm for assigning an update to a lane should be stable for all 24260 // updates at the same priority within the same event. To do this, the inputs 24261 // to the algorithm must be the same. For example, we use the `renderLanes` 24262 // to avoid choosing a lane that is already in the middle of rendering. 24263 // 24264 // However, the "included" lanes could be mutated in between updates in the 24265 // same event, like if you perform an update inside `flushSync`. Or any other 24266 // code path that might call `prepareFreshStack`. 24267 // 24268 // The trick we use is to cache the first of each of these inputs within an 24269 // event. Then reset the cached values once we can be sure the event is over. 24270 // Our heuristic for that is whenever we enter a concurrent work loop. 24271 // 24272 // We'll do the same for `currentEventPendingLanes` below. 24273 24274 24275 if (currentEventWipLanes === NoLanes) { 24276 currentEventWipLanes = workInProgressRootIncludedLanes; 24277 } 24278 24279 var isTransition = requestCurrentTransition() !== NoTransition; 24280 24281 if (isTransition) { 24282 if (currentEventPendingLanes !== NoLanes) { 24283 currentEventPendingLanes = mostRecentlyUpdatedRoot !== null ? mostRecentlyUpdatedRoot.pendingLanes : NoLanes; 24284 } 24285 24286 return findTransitionLane(currentEventWipLanes, currentEventPendingLanes); 24287 } // TODO: Remove this dependency on the Scheduler priority. 24288 // To do that, we're replacing it with an update lane priority. 24289 24290 24291 var schedulerPriority = getCurrentPriorityLevel(); // The old behavior was using the priority level of the Scheduler. 24292 // This couples React to the Scheduler internals, so we're replacing it 24293 // with the currentUpdateLanePriority above. As an example of how this 24294 // could be problematic, if we're not inside `Scheduler.runWithPriority`, 24295 // then we'll get the priority of the current running Scheduler task, 24296 // which is probably not what we want. 24297 24298 var lane; 24299 24300 if ( // TODO: Temporary. We're removing the concept of discrete updates. 24301 (executionContext & DiscreteEventContext) !== NoContext && schedulerPriority === UserBlockingPriority$2) { 24302 lane = findUpdateLane(InputDiscreteLanePriority, currentEventWipLanes); 24303 } else { 24304 var schedulerLanePriority = schedulerPriorityToLanePriority(schedulerPriority); 24305 24306 lane = findUpdateLane(schedulerLanePriority, currentEventWipLanes); 24307 } 24308 24309 return lane; 24310} 24311 24312function requestRetryLane(fiber) { 24313 // This is a fork of `requestUpdateLane` designed specifically for Suspense 24314 // "retries" — a special update that attempts to flip a Suspense boundary 24315 // from its placeholder state to its primary/resolved state. 24316 // Special cases 24317 var mode = fiber.mode; 24318 24319 if ((mode & BlockingMode) === NoMode) { 24320 return SyncLane; 24321 } else if ((mode & ConcurrentMode) === NoMode) { 24322 return getCurrentPriorityLevel() === ImmediatePriority$1 ? SyncLane : SyncBatchedLane; 24323 } // See `requestUpdateLane` for explanation of `currentEventWipLanes` 24324 24325 24326 if (currentEventWipLanes === NoLanes) { 24327 currentEventWipLanes = workInProgressRootIncludedLanes; 24328 } 24329 24330 return findRetryLane(currentEventWipLanes); 24331} 24332 24333function scheduleUpdateOnFiber(fiber, lane, eventTime) { 24334 checkForNestedUpdates(); 24335 warnAboutRenderPhaseUpdatesInDEV(fiber); 24336 var root = markUpdateLaneFromFiberToRoot(fiber, lane); 24337 24338 if (root === null) { 24339 warnAboutUpdateOnUnmountedFiberInDEV(fiber); 24340 return null; 24341 } // Mark that the root has a pending update. 24342 24343 24344 markRootUpdated(root, lane, eventTime); 24345 24346 if (root === workInProgressRoot) { 24347 // Received an update to a tree that's in the middle of rendering. Mark 24348 // that there was an interleaved update work on this root. Unless the 24349 // `deferRenderPhaseUpdateToNextBatch` flag is off and this is a render 24350 // phase update. In that case, we don't treat render phase updates as if 24351 // they were interleaved, for backwards compat reasons. 24352 { 24353 workInProgressRootUpdatedLanes = mergeLanes(workInProgressRootUpdatedLanes, lane); 24354 } 24355 24356 if (workInProgressRootExitStatus === RootSuspendedWithDelay) { 24357 // The root already suspended with a delay, which means this render 24358 // definitely won't finish. Since we have a new update, let's mark it as 24359 // suspended now, right before marking the incoming update. This has the 24360 // effect of interrupting the current render and switching to the update. 24361 // TODO: Make sure this doesn't override pings that happen while we've 24362 // already started rendering. 24363 markRootSuspended$1(root, workInProgressRootRenderLanes); 24364 } 24365 } // TODO: requestUpdateLanePriority also reads the priority. Pass the 24366 // priority as an argument to that function and this one. 24367 24368 24369 var priorityLevel = getCurrentPriorityLevel(); 24370 24371 if (lane === SyncLane) { 24372 if ( // Check if we're inside unbatchedUpdates 24373 (executionContext & LegacyUnbatchedContext) !== NoContext && // Check if we're not already rendering 24374 (executionContext & (RenderContext | CommitContext)) === NoContext) { 24375 // Register pending interactions on the root to avoid losing traced interaction data. 24376 schedulePendingInteractions(root, lane); // This is a legacy edge case. The initial mount of a ReactDOM.render-ed 24377 // root inside of batchedUpdates should be synchronous, but layout updates 24378 // should be deferred until the end of the batch. 24379 24380 performSyncWorkOnRoot(root); 24381 } else { 24382 ensureRootIsScheduled(root, eventTime); 24383 schedulePendingInteractions(root, lane); 24384 24385 if (executionContext === NoContext) { 24386 // Flush the synchronous work now, unless we're already working or inside 24387 // a batch. This is intentionally inside scheduleUpdateOnFiber instead of 24388 // scheduleCallbackForFiber to preserve the ability to schedule a callback 24389 // without immediately flushing it. We only do this for user-initiated 24390 // updates, to preserve historical behavior of legacy mode. 24391 resetRenderTimer(); 24392 flushSyncCallbackQueue(); 24393 } 24394 } 24395 } else { 24396 // Schedule a discrete update but only if it's not Sync. 24397 if ((executionContext & DiscreteEventContext) !== NoContext && ( // Only updates at user-blocking priority or greater are considered 24398 // discrete, even inside a discrete event. 24399 priorityLevel === UserBlockingPriority$2 || priorityLevel === ImmediatePriority$1)) { 24400 // This is the result of a discrete event. Track the lowest priority 24401 // discrete update per root so we can flush them early, if needed. 24402 if (rootsWithPendingDiscreteUpdates === null) { 24403 rootsWithPendingDiscreteUpdates = new Set([root]); 24404 } else { 24405 rootsWithPendingDiscreteUpdates.add(root); 24406 } 24407 } // Schedule other updates after in case the callback is sync. 24408 24409 24410 ensureRootIsScheduled(root, eventTime); 24411 schedulePendingInteractions(root, lane); 24412 } // We use this when assigning a lane for a transition inside 24413 // `requestUpdateLane`. We assume it's the same as the root being updated, 24414 // since in the common case of a single root app it probably is. If it's not 24415 // the same root, then it's not a huge deal, we just might batch more stuff 24416 // together more than necessary. 24417 24418 24419 mostRecentlyUpdatedRoot = root; 24420} // This is split into a separate function so we can mark a fiber with pending 24421// work without treating it as a typical update that originates from an event; 24422// e.g. retrying a Suspense boundary isn't an update, but it does schedule work 24423// on a fiber. 24424 24425function markUpdateLaneFromFiberToRoot(sourceFiber, lane) { 24426 // Update the source fiber's lanes 24427 sourceFiber.lanes = mergeLanes(sourceFiber.lanes, lane); 24428 var alternate = sourceFiber.alternate; 24429 24430 if (alternate !== null) { 24431 alternate.lanes = mergeLanes(alternate.lanes, lane); 24432 } 24433 24434 { 24435 if (alternate === null && (sourceFiber.flags & (Placement | Hydrating)) !== NoFlags) { 24436 warnAboutUpdateOnNotYetMountedFiberInDEV(sourceFiber); 24437 } 24438 } // Walk the parent path to the root and update the child expiration time. 24439 24440 24441 var node = sourceFiber; 24442 var parent = sourceFiber.return; 24443 24444 while (parent !== null) { 24445 parent.childLanes = mergeLanes(parent.childLanes, lane); 24446 alternate = parent.alternate; 24447 24448 if (alternate !== null) { 24449 alternate.childLanes = mergeLanes(alternate.childLanes, lane); 24450 } else { 24451 { 24452 if ((parent.flags & (Placement | Hydrating)) !== NoFlags) { 24453 warnAboutUpdateOnNotYetMountedFiberInDEV(sourceFiber); 24454 } 24455 } 24456 } 24457 24458 node = parent; 24459 parent = parent.return; 24460 } 24461 24462 if (node.tag === HostRoot) { 24463 var root = node.stateNode; 24464 return root; 24465 } else { 24466 return null; 24467 } 24468} // Use this function to schedule a task for a root. There's only one task per 24469// root; if a task was already scheduled, we'll check to make sure the priority 24470// of the existing task is the same as the priority of the next level that the 24471// root has work on. This function is called on every update, and right before 24472// exiting a task. 24473 24474 24475function ensureRootIsScheduled(root, currentTime) { 24476 var existingCallbackNode = root.callbackNode; // Check if any lanes are being starved by other work. If so, mark them as 24477 // expired so we know to work on those next. 24478 24479 markStarvedLanesAsExpired(root, currentTime); // Determine the next lanes to work on, and their priority. 24480 24481 var nextLanes = getNextLanes(root, root === workInProgressRoot ? workInProgressRootRenderLanes : NoLanes); // This returns the priority level computed during the `getNextLanes` call. 24482 24483 var newCallbackPriority = returnNextLanesPriority(); 24484 24485 if (nextLanes === NoLanes) { 24486 // Special case: There's nothing to work on. 24487 if (existingCallbackNode !== null) { 24488 cancelCallback(existingCallbackNode); 24489 root.callbackNode = null; 24490 root.callbackPriority = NoLanePriority; 24491 } 24492 24493 return; 24494 } // Check if there's an existing task. We may be able to reuse it. 24495 24496 24497 if (existingCallbackNode !== null) { 24498 var existingCallbackPriority = root.callbackPriority; 24499 24500 if (existingCallbackPriority === newCallbackPriority) { 24501 // The priority hasn't changed. We can reuse the existing task. Exit. 24502 return; 24503 } // The priority changed. Cancel the existing callback. We'll schedule a new 24504 // one below. 24505 24506 24507 cancelCallback(existingCallbackNode); 24508 } // Schedule a new callback. 24509 24510 24511 var newCallbackNode; 24512 24513 if (newCallbackPriority === SyncLanePriority) { 24514 // Special case: Sync React callbacks are scheduled on a special 24515 // internal queue 24516 newCallbackNode = scheduleSyncCallback(performSyncWorkOnRoot.bind(null, root)); 24517 } else if (newCallbackPriority === SyncBatchedLanePriority) { 24518 newCallbackNode = scheduleCallback(ImmediatePriority$1, performSyncWorkOnRoot.bind(null, root)); 24519 } else { 24520 var schedulerPriorityLevel = lanePriorityToSchedulerPriority(newCallbackPriority); 24521 newCallbackNode = scheduleCallback(schedulerPriorityLevel, performConcurrentWorkOnRoot.bind(null, root)); 24522 } 24523 24524 root.callbackPriority = newCallbackPriority; 24525 root.callbackNode = newCallbackNode; 24526} // This is the entry point for every concurrent task, i.e. anything that 24527// goes through Scheduler. 24528 24529 24530function performConcurrentWorkOnRoot(root) { 24531 // Since we know we're in a React event, we can clear the current 24532 // event time. The next update will compute a new event time. 24533 currentEventTime = NoTimestamp; 24534 currentEventWipLanes = NoLanes; 24535 currentEventPendingLanes = NoLanes; 24536 24537 if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) { 24538 { 24539 throw Error( "Should not already be working." ); 24540 } 24541 } // Flush any pending passive effects before deciding which lanes to work on, 24542 // in case they schedule additional work. 24543 24544 24545 var originalCallbackNode = root.callbackNode; 24546 var didFlushPassiveEffects = flushPassiveEffects(); 24547 24548 if (didFlushPassiveEffects) { 24549 // Something in the passive effect phase may have canceled the current task. 24550 // Check if the task node for this root was changed. 24551 if (root.callbackNode !== originalCallbackNode) { 24552 // The current task was canceled. Exit. We don't need to call 24553 // `ensureRootIsScheduled` because the check above implies either that 24554 // there's a new task, or that there's no remaining work on this root. 24555 return null; 24556 } 24557 } // Determine the next expiration time to work on, using the fields stored 24558 // on the root. 24559 24560 24561 var lanes = getNextLanes(root, root === workInProgressRoot ? workInProgressRootRenderLanes : NoLanes); 24562 24563 if (lanes === NoLanes) { 24564 // Defensive coding. This is never expected to happen. 24565 return null; 24566 } 24567 24568 var exitStatus = renderRootConcurrent(root, lanes); 24569 24570 if (includesSomeLane(workInProgressRootIncludedLanes, workInProgressRootUpdatedLanes)) { 24571 // The render included lanes that were updated during the render phase. 24572 // For example, when unhiding a hidden tree, we include all the lanes 24573 // that were previously skipped when the tree was hidden. That set of 24574 // lanes is a superset of the lanes we started rendering with. 24575 // 24576 // So we'll throw out the current work and restart. 24577 prepareFreshStack(root, NoLanes); 24578 } else if (exitStatus !== RootIncomplete) { 24579 if (exitStatus === RootErrored) { 24580 executionContext |= RetryAfterError; // If an error occurred during hydration, 24581 // discard server response and fall back to client side render. 24582 24583 if (root.hydrate) { 24584 root.hydrate = false; 24585 clearContainer(root.containerInfo); 24586 } // If something threw an error, try rendering one more time. We'll render 24587 // synchronously to block concurrent data mutations, and we'll includes 24588 // all pending updates are included. If it still fails after the second 24589 // attempt, we'll give up and commit the resulting tree. 24590 24591 24592 lanes = getLanesToRetrySynchronouslyOnError(root); 24593 24594 if (lanes !== NoLanes) { 24595 exitStatus = renderRootSync(root, lanes); 24596 } 24597 } 24598 24599 if (exitStatus === RootFatalErrored) { 24600 var fatalError = workInProgressRootFatalError; 24601 prepareFreshStack(root, NoLanes); 24602 markRootSuspended$1(root, lanes); 24603 ensureRootIsScheduled(root, now()); 24604 throw fatalError; 24605 } // We now have a consistent tree. The next step is either to commit it, 24606 // or, if something suspended, wait to commit it after a timeout. 24607 24608 24609 var finishedWork = root.current.alternate; 24610 root.finishedWork = finishedWork; 24611 root.finishedLanes = lanes; 24612 finishConcurrentRender(root, exitStatus, lanes); 24613 } 24614 24615 ensureRootIsScheduled(root, now()); 24616 24617 if (root.callbackNode === originalCallbackNode) { 24618 // The task node scheduled for this root is the same one that's 24619 // currently executed. Need to return a continuation. 24620 return performConcurrentWorkOnRoot.bind(null, root); 24621 } 24622 24623 return null; 24624} 24625 24626function finishConcurrentRender(root, exitStatus, lanes) { 24627 switch (exitStatus) { 24628 case RootIncomplete: 24629 case RootFatalErrored: 24630 { 24631 { 24632 { 24633 throw Error( "Root did not complete. This is a bug in React." ); 24634 } 24635 } 24636 } 24637 // Flow knows about invariant, so it complains if I add a break 24638 // statement, but eslint doesn't know about invariant, so it complains 24639 // if I do. eslint-disable-next-line no-fallthrough 24640 24641 case RootErrored: 24642 { 24643 // We should have already attempted to retry this tree. If we reached 24644 // this point, it errored again. Commit it. 24645 commitRoot(root); 24646 break; 24647 } 24648 24649 case RootSuspended: 24650 { 24651 markRootSuspended$1(root, lanes); // We have an acceptable loading state. We need to figure out if we 24652 // should immediately commit it or wait a bit. 24653 24654 if (includesOnlyRetries(lanes) && // do not delay if we're inside an act() scope 24655 !shouldForceFlushFallbacksInDEV()) { 24656 // This render only included retries, no updates. Throttle committing 24657 // retries so that we don't show too many loading states too quickly. 24658 var msUntilTimeout = globalMostRecentFallbackTime + FALLBACK_THROTTLE_MS - now(); // Don't bother with a very short suspense time. 24659 24660 if (msUntilTimeout > 10) { 24661 var nextLanes = getNextLanes(root, NoLanes); 24662 24663 if (nextLanes !== NoLanes) { 24664 // There's additional work on this root. 24665 break; 24666 } 24667 24668 var suspendedLanes = root.suspendedLanes; 24669 24670 if (!isSubsetOfLanes(suspendedLanes, lanes)) { 24671 // We should prefer to render the fallback of at the last 24672 // suspended level. Ping the last suspended level to try 24673 // rendering it again. 24674 // FIXME: What if the suspended lanes are Idle? Should not restart. 24675 var eventTime = requestEventTime(); 24676 markRootPinged(root, suspendedLanes); 24677 break; 24678 } // The render is suspended, it hasn't timed out, and there's no 24679 // lower priority work to do. Instead of committing the fallback 24680 // immediately, wait for more data to arrive. 24681 24682 24683 root.timeoutHandle = scheduleTimeout(commitRoot.bind(null, root), msUntilTimeout); 24684 break; 24685 } 24686 } // The work expired. Commit immediately. 24687 24688 24689 commitRoot(root); 24690 break; 24691 } 24692 24693 case RootSuspendedWithDelay: 24694 { 24695 markRootSuspended$1(root, lanes); 24696 24697 if (includesOnlyTransitions(lanes)) { 24698 // This is a transition, so we should exit without committing a 24699 // placeholder and without scheduling a timeout. Delay indefinitely 24700 // until we receive more data. 24701 break; 24702 } 24703 24704 if (!shouldForceFlushFallbacksInDEV()) { 24705 // This is not a transition, but we did trigger an avoided state. 24706 // Schedule a placeholder to display after a short delay, using the Just 24707 // Noticeable Difference. 24708 // TODO: Is the JND optimization worth the added complexity? If this is 24709 // the only reason we track the event time, then probably not. 24710 // Consider removing. 24711 var mostRecentEventTime = getMostRecentEventTime(root, lanes); 24712 var eventTimeMs = mostRecentEventTime; 24713 var timeElapsedMs = now() - eventTimeMs; 24714 24715 var _msUntilTimeout = jnd(timeElapsedMs) - timeElapsedMs; // Don't bother with a very short suspense time. 24716 24717 24718 if (_msUntilTimeout > 10) { 24719 // Instead of committing the fallback immediately, wait for more data 24720 // to arrive. 24721 root.timeoutHandle = scheduleTimeout(commitRoot.bind(null, root), _msUntilTimeout); 24722 break; 24723 } 24724 } // Commit the placeholder. 24725 24726 24727 commitRoot(root); 24728 break; 24729 } 24730 24731 case RootCompleted: 24732 { 24733 // The work completed. Ready to commit. 24734 commitRoot(root); 24735 break; 24736 } 24737 24738 default: 24739 { 24740 { 24741 { 24742 throw Error( "Unknown root exit status." ); 24743 } 24744 } 24745 } 24746 } 24747} 24748 24749function markRootSuspended$1(root, suspendedLanes) { 24750 // When suspending, we should always exclude lanes that were pinged or (more 24751 // rarely, since we try to avoid it) updated during the render phase. 24752 // TODO: Lol maybe there's a better way to factor this besides this 24753 // obnoxiously named function :) 24754 suspendedLanes = removeLanes(suspendedLanes, workInProgressRootPingedLanes); 24755 suspendedLanes = removeLanes(suspendedLanes, workInProgressRootUpdatedLanes); 24756 markRootSuspended(root, suspendedLanes); 24757} // This is the entry point for synchronous tasks that don't go 24758// through Scheduler 24759 24760 24761function performSyncWorkOnRoot(root) { 24762 if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) { 24763 { 24764 throw Error( "Should not already be working." ); 24765 } 24766 } 24767 24768 flushPassiveEffects(); 24769 var lanes; 24770 var exitStatus; 24771 24772 if (root === workInProgressRoot && includesSomeLane(root.expiredLanes, workInProgressRootRenderLanes)) { 24773 // There's a partial tree, and at least one of its lanes has expired. Finish 24774 // rendering it before rendering the rest of the expired work. 24775 lanes = workInProgressRootRenderLanes; 24776 exitStatus = renderRootSync(root, lanes); 24777 24778 if (includesSomeLane(workInProgressRootIncludedLanes, workInProgressRootUpdatedLanes)) { 24779 // The render included lanes that were updated during the render phase. 24780 // For example, when unhiding a hidden tree, we include all the lanes 24781 // that were previously skipped when the tree was hidden. That set of 24782 // lanes is a superset of the lanes we started rendering with. 24783 // 24784 // Note that this only happens when part of the tree is rendered 24785 // concurrently. If the whole tree is rendered synchronously, then there 24786 // are no interleaved events. 24787 lanes = getNextLanes(root, lanes); 24788 exitStatus = renderRootSync(root, lanes); 24789 } 24790 } else { 24791 lanes = getNextLanes(root, NoLanes); 24792 exitStatus = renderRootSync(root, lanes); 24793 } 24794 24795 if (root.tag !== LegacyRoot && exitStatus === RootErrored) { 24796 executionContext |= RetryAfterError; // If an error occurred during hydration, 24797 // discard server response and fall back to client side render. 24798 24799 if (root.hydrate) { 24800 root.hydrate = false; 24801 clearContainer(root.containerInfo); 24802 } // If something threw an error, try rendering one more time. We'll render 24803 // synchronously to block concurrent data mutations, and we'll includes 24804 // all pending updates are included. If it still fails after the second 24805 // attempt, we'll give up and commit the resulting tree. 24806 24807 24808 lanes = getLanesToRetrySynchronouslyOnError(root); 24809 24810 if (lanes !== NoLanes) { 24811 exitStatus = renderRootSync(root, lanes); 24812 } 24813 } 24814 24815 if (exitStatus === RootFatalErrored) { 24816 var fatalError = workInProgressRootFatalError; 24817 prepareFreshStack(root, NoLanes); 24818 markRootSuspended$1(root, lanes); 24819 ensureRootIsScheduled(root, now()); 24820 throw fatalError; 24821 } // We now have a consistent tree. Because this is a sync render, we 24822 // will commit it even if something suspended. 24823 24824 24825 var finishedWork = root.current.alternate; 24826 root.finishedWork = finishedWork; 24827 root.finishedLanes = lanes; 24828 commitRoot(root); // Before exiting, make sure there's a callback scheduled for the next 24829 // pending level. 24830 24831 ensureRootIsScheduled(root, now()); 24832 return null; 24833} 24834function flushDiscreteUpdates() { 24835 // TODO: Should be able to flush inside batchedUpdates, but not inside `act`. 24836 // However, `act` uses `batchedUpdates`, so there's no way to distinguish 24837 // those two cases. Need to fix this before exposing flushDiscreteUpdates 24838 // as a public API. 24839 if ((executionContext & (BatchedContext | RenderContext | CommitContext)) !== NoContext) { 24840 { 24841 if ((executionContext & RenderContext) !== NoContext) { 24842 error('unstable_flushDiscreteUpdates: Cannot flush updates when React is ' + 'already rendering.'); 24843 } 24844 } // We're already rendering, so we can't synchronously flush pending work. 24845 // This is probably a nested event dispatch triggered by a lifecycle/effect, 24846 // like `el.focus()`. Exit. 24847 24848 24849 return; 24850 } 24851 24852 flushPendingDiscreteUpdates(); // If the discrete updates scheduled passive effects, flush them now so that 24853 // they fire before the next serial event. 24854 24855 flushPassiveEffects(); 24856} 24857 24858function flushPendingDiscreteUpdates() { 24859 if (rootsWithPendingDiscreteUpdates !== null) { 24860 // For each root with pending discrete updates, schedule a callback to 24861 // immediately flush them. 24862 var roots = rootsWithPendingDiscreteUpdates; 24863 rootsWithPendingDiscreteUpdates = null; 24864 roots.forEach(function (root) { 24865 markDiscreteUpdatesExpired(root); 24866 ensureRootIsScheduled(root, now()); 24867 }); 24868 } // Now flush the immediate queue. 24869 24870 24871 flushSyncCallbackQueue(); 24872} 24873 24874function batchedUpdates$1(fn, a) { 24875 var prevExecutionContext = executionContext; 24876 executionContext |= BatchedContext; 24877 24878 try { 24879 return fn(a); 24880 } finally { 24881 executionContext = prevExecutionContext; 24882 24883 if (executionContext === NoContext) { 24884 // Flush the immediate callbacks that were scheduled during this batch 24885 resetRenderTimer(); 24886 flushSyncCallbackQueue(); 24887 } 24888 } 24889} 24890function batchedEventUpdates$1(fn, a) { 24891 var prevExecutionContext = executionContext; 24892 executionContext |= EventContext; 24893 24894 try { 24895 return fn(a); 24896 } finally { 24897 executionContext = prevExecutionContext; 24898 24899 if (executionContext === NoContext) { 24900 // Flush the immediate callbacks that were scheduled during this batch 24901 resetRenderTimer(); 24902 flushSyncCallbackQueue(); 24903 } 24904 } 24905} 24906function discreteUpdates$1(fn, a, b, c, d) { 24907 var prevExecutionContext = executionContext; 24908 executionContext |= DiscreteEventContext; 24909 24910 { 24911 try { 24912 return runWithPriority$1(UserBlockingPriority$2, fn.bind(null, a, b, c, d)); 24913 } finally { 24914 executionContext = prevExecutionContext; 24915 24916 if (executionContext === NoContext) { 24917 // Flush the immediate callbacks that were scheduled during this batch 24918 resetRenderTimer(); 24919 flushSyncCallbackQueue(); 24920 } 24921 } 24922 } 24923} 24924function unbatchedUpdates(fn, a) { 24925 var prevExecutionContext = executionContext; 24926 executionContext &= ~BatchedContext; 24927 executionContext |= LegacyUnbatchedContext; 24928 24929 try { 24930 return fn(a); 24931 } finally { 24932 executionContext = prevExecutionContext; 24933 24934 if (executionContext === NoContext) { 24935 // Flush the immediate callbacks that were scheduled during this batch 24936 resetRenderTimer(); 24937 flushSyncCallbackQueue(); 24938 } 24939 } 24940} 24941function flushSync(fn, a) { 24942 var prevExecutionContext = executionContext; 24943 24944 if ((prevExecutionContext & (RenderContext | CommitContext)) !== NoContext) { 24945 { 24946 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.'); 24947 } 24948 24949 return fn(a); 24950 } 24951 24952 executionContext |= BatchedContext; 24953 24954 { 24955 try { 24956 if (fn) { 24957 return runWithPriority$1(ImmediatePriority$1, fn.bind(null, a)); 24958 } else { 24959 return undefined; 24960 } 24961 } finally { 24962 executionContext = prevExecutionContext; // Flush the immediate callbacks that were scheduled during this batch. 24963 // Note that this will happen even if batchedUpdates is higher up 24964 // the stack. 24965 24966 flushSyncCallbackQueue(); 24967 } 24968 } 24969} 24970function pushRenderLanes(fiber, lanes) { 24971 push(subtreeRenderLanesCursor, subtreeRenderLanes, fiber); 24972 subtreeRenderLanes = mergeLanes(subtreeRenderLanes, lanes); 24973 workInProgressRootIncludedLanes = mergeLanes(workInProgressRootIncludedLanes, lanes); 24974} 24975function popRenderLanes(fiber) { 24976 subtreeRenderLanes = subtreeRenderLanesCursor.current; 24977 pop(subtreeRenderLanesCursor, fiber); 24978} 24979 24980function prepareFreshStack(root, lanes) { 24981 root.finishedWork = null; 24982 root.finishedLanes = NoLanes; 24983 var timeoutHandle = root.timeoutHandle; 24984 24985 if (timeoutHandle !== noTimeout) { 24986 // The root previous suspended and scheduled a timeout to commit a fallback 24987 // state. Now that we have additional work, cancel the timeout. 24988 root.timeoutHandle = noTimeout; // $FlowFixMe Complains noTimeout is not a TimeoutID, despite the check above 24989 24990 cancelTimeout(timeoutHandle); 24991 } 24992 24993 if (workInProgress !== null) { 24994 var interruptedWork = workInProgress.return; 24995 24996 while (interruptedWork !== null) { 24997 unwindInterruptedWork(interruptedWork); 24998 interruptedWork = interruptedWork.return; 24999 } 25000 } 25001 25002 workInProgressRoot = root; 25003 workInProgress = createWorkInProgress(root.current, null); 25004 workInProgressRootRenderLanes = subtreeRenderLanes = workInProgressRootIncludedLanes = lanes; 25005 workInProgressRootExitStatus = RootIncomplete; 25006 workInProgressRootFatalError = null; 25007 workInProgressRootSkippedLanes = NoLanes; 25008 workInProgressRootUpdatedLanes = NoLanes; 25009 workInProgressRootPingedLanes = NoLanes; 25010 25011 { 25012 spawnedWorkDuringRender = null; 25013 } 25014 25015 { 25016 ReactStrictModeWarnings.discardPendingWarnings(); 25017 } 25018} 25019 25020function handleError(root, thrownValue) { 25021 do { 25022 var erroredWork = workInProgress; 25023 25024 try { 25025 // Reset module-level state that was set during the render phase. 25026 resetContextDependencies(); 25027 resetHooksAfterThrow(); 25028 resetCurrentFiber(); // TODO: I found and added this missing line while investigating a 25029 // separate issue. Write a regression test using string refs. 25030 25031 ReactCurrentOwner$2.current = null; 25032 25033 if (erroredWork === null || erroredWork.return === null) { 25034 // Expected to be working on a non-root fiber. This is a fatal error 25035 // because there's no ancestor that can handle it; the root is 25036 // supposed to capture all errors that weren't caught by an error 25037 // boundary. 25038 workInProgressRootExitStatus = RootFatalErrored; 25039 workInProgressRootFatalError = thrownValue; // Set `workInProgress` to null. This represents advancing to the next 25040 // sibling, or the parent if there are no siblings. But since the root 25041 // has no siblings nor a parent, we set it to null. Usually this is 25042 // handled by `completeUnitOfWork` or `unwindWork`, but since we're 25043 // intentionally not calling those, we need set it here. 25044 // TODO: Consider calling `unwindWork` to pop the contexts. 25045 25046 workInProgress = null; 25047 return; 25048 } 25049 25050 if (enableProfilerTimer && erroredWork.mode & ProfileMode) { 25051 // Record the time spent rendering before an error was thrown. This 25052 // avoids inaccurate Profiler durations in the case of a 25053 // suspended render. 25054 stopProfilerTimerIfRunningAndRecordDelta(erroredWork, true); 25055 } 25056 25057 throwException(root, erroredWork.return, erroredWork, thrownValue, workInProgressRootRenderLanes); 25058 completeUnitOfWork(erroredWork); 25059 } catch (yetAnotherThrownValue) { 25060 // Something in the return path also threw. 25061 thrownValue = yetAnotherThrownValue; 25062 25063 if (workInProgress === erroredWork && erroredWork !== null) { 25064 // If this boundary has already errored, then we had trouble processing 25065 // the error. Bubble it to the next boundary. 25066 erroredWork = erroredWork.return; 25067 workInProgress = erroredWork; 25068 } else { 25069 erroredWork = workInProgress; 25070 } 25071 25072 continue; 25073 } // Return to the normal work loop. 25074 25075 25076 return; 25077 } while (true); 25078} 25079 25080function pushDispatcher() { 25081 var prevDispatcher = ReactCurrentDispatcher$2.current; 25082 ReactCurrentDispatcher$2.current = ContextOnlyDispatcher; 25083 25084 if (prevDispatcher === null) { 25085 // The React isomorphic package does not include a default dispatcher. 25086 // Instead the first renderer will lazily attach one, in order to give 25087 // nicer error messages. 25088 return ContextOnlyDispatcher; 25089 } else { 25090 return prevDispatcher; 25091 } 25092} 25093 25094function popDispatcher(prevDispatcher) { 25095 ReactCurrentDispatcher$2.current = prevDispatcher; 25096} 25097 25098function pushInteractions(root) { 25099 { 25100 var prevInteractions = tracing.__interactionsRef.current; 25101 tracing.__interactionsRef.current = root.memoizedInteractions; 25102 return prevInteractions; 25103 } 25104} 25105 25106function popInteractions(prevInteractions) { 25107 { 25108 tracing.__interactionsRef.current = prevInteractions; 25109 } 25110} 25111 25112function markCommitTimeOfFallback() { 25113 globalMostRecentFallbackTime = now(); 25114} 25115function markSkippedUpdateLanes(lane) { 25116 workInProgressRootSkippedLanes = mergeLanes(lane, workInProgressRootSkippedLanes); 25117} 25118function renderDidSuspend() { 25119 if (workInProgressRootExitStatus === RootIncomplete) { 25120 workInProgressRootExitStatus = RootSuspended; 25121 } 25122} 25123function renderDidSuspendDelayIfPossible() { 25124 if (workInProgressRootExitStatus === RootIncomplete || workInProgressRootExitStatus === RootSuspended) { 25125 workInProgressRootExitStatus = RootSuspendedWithDelay; 25126 } // Check if there are updates that we skipped tree that might have unblocked 25127 // this render. 25128 25129 25130 if (workInProgressRoot !== null && (includesNonIdleWork(workInProgressRootSkippedLanes) || includesNonIdleWork(workInProgressRootUpdatedLanes))) { 25131 // Mark the current render as suspended so that we switch to working on 25132 // the updates that were skipped. Usually we only suspend at the end of 25133 // the render phase. 25134 // TODO: We should probably always mark the root as suspended immediately 25135 // (inside this function), since by suspending at the end of the render 25136 // phase introduces a potential mistake where we suspend lanes that were 25137 // pinged or updated while we were rendering. 25138 markRootSuspended$1(workInProgressRoot, workInProgressRootRenderLanes); 25139 } 25140} 25141function renderDidError() { 25142 if (workInProgressRootExitStatus !== RootCompleted) { 25143 workInProgressRootExitStatus = RootErrored; 25144 } 25145} // Called during render to determine if anything has suspended. 25146// Returns false if we're not sure. 25147 25148function renderHasNotSuspendedYet() { 25149 // If something errored or completed, we can't really be sure, 25150 // so those are false. 25151 return workInProgressRootExitStatus === RootIncomplete; 25152} 25153 25154function renderRootSync(root, lanes) { 25155 var prevExecutionContext = executionContext; 25156 executionContext |= RenderContext; 25157 var prevDispatcher = pushDispatcher(); // If the root or lanes have changed, throw out the existing stack 25158 // and prepare a fresh one. Otherwise we'll continue where we left off. 25159 25160 if (workInProgressRoot !== root || workInProgressRootRenderLanes !== lanes) { 25161 prepareFreshStack(root, lanes); 25162 startWorkOnPendingInteractions(root, lanes); 25163 } 25164 25165 var prevInteractions = pushInteractions(root); 25166 25167 do { 25168 try { 25169 workLoopSync(); 25170 break; 25171 } catch (thrownValue) { 25172 handleError(root, thrownValue); 25173 } 25174 } while (true); 25175 25176 resetContextDependencies(); 25177 25178 { 25179 popInteractions(prevInteractions); 25180 } 25181 25182 executionContext = prevExecutionContext; 25183 popDispatcher(prevDispatcher); 25184 25185 if (workInProgress !== null) { 25186 // This is a sync render, so we should have finished the whole tree. 25187 { 25188 { 25189 throw Error( "Cannot commit an incomplete root. This error is likely caused by a bug in React. Please file an issue." ); 25190 } 25191 } 25192 } 25193 25194 25195 workInProgressRoot = null; 25196 workInProgressRootRenderLanes = NoLanes; 25197 return workInProgressRootExitStatus; 25198} // The work loop is an extremely hot path. Tell Closure not to inline it. 25199 25200/** @noinline */ 25201 25202 25203function workLoopSync() { 25204 // Already timed out, so perform work without checking if we need to yield. 25205 while (workInProgress !== null) { 25206 performUnitOfWork(workInProgress); 25207 } 25208} 25209 25210function renderRootConcurrent(root, lanes) { 25211 var prevExecutionContext = executionContext; 25212 executionContext |= RenderContext; 25213 var prevDispatcher = pushDispatcher(); // If the root or lanes have changed, throw out the existing stack 25214 // and prepare a fresh one. Otherwise we'll continue where we left off. 25215 25216 if (workInProgressRoot !== root || workInProgressRootRenderLanes !== lanes) { 25217 resetRenderTimer(); 25218 prepareFreshStack(root, lanes); 25219 startWorkOnPendingInteractions(root, lanes); 25220 } 25221 25222 var prevInteractions = pushInteractions(root); 25223 25224 do { 25225 try { 25226 workLoopConcurrent(); 25227 break; 25228 } catch (thrownValue) { 25229 handleError(root, thrownValue); 25230 } 25231 } while (true); 25232 25233 resetContextDependencies(); 25234 25235 { 25236 popInteractions(prevInteractions); 25237 } 25238 25239 popDispatcher(prevDispatcher); 25240 executionContext = prevExecutionContext; 25241 25242 25243 if (workInProgress !== null) { 25244 25245 return RootIncomplete; 25246 } else { 25247 25248 25249 workInProgressRoot = null; 25250 workInProgressRootRenderLanes = NoLanes; // Return the final exit status. 25251 25252 return workInProgressRootExitStatus; 25253 } 25254} 25255/** @noinline */ 25256 25257 25258function workLoopConcurrent() { 25259 // Perform work until Scheduler asks us to yield 25260 while (workInProgress !== null && !shouldYield()) { 25261 performUnitOfWork(workInProgress); 25262 } 25263} 25264 25265function performUnitOfWork(unitOfWork) { 25266 // The current, flushed, state of this fiber is the alternate. Ideally 25267 // nothing should rely on this, but relying on it here means that we don't 25268 // need an additional field on the work in progress. 25269 var current = unitOfWork.alternate; 25270 setCurrentFiber(unitOfWork); 25271 var next; 25272 25273 if ( (unitOfWork.mode & ProfileMode) !== NoMode) { 25274 startProfilerTimer(unitOfWork); 25275 next = beginWork$1(current, unitOfWork, subtreeRenderLanes); 25276 stopProfilerTimerIfRunningAndRecordDelta(unitOfWork, true); 25277 } else { 25278 next = beginWork$1(current, unitOfWork, subtreeRenderLanes); 25279 } 25280 25281 resetCurrentFiber(); 25282 unitOfWork.memoizedProps = unitOfWork.pendingProps; 25283 25284 if (next === null) { 25285 // If this doesn't spawn new work, complete the current work. 25286 completeUnitOfWork(unitOfWork); 25287 } else { 25288 workInProgress = next; 25289 } 25290 25291 ReactCurrentOwner$2.current = null; 25292} 25293 25294function completeUnitOfWork(unitOfWork) { 25295 // Attempt to complete the current unit of work, then move to the next 25296 // sibling. If there are no more siblings, return to the parent fiber. 25297 var completedWork = unitOfWork; 25298 25299 do { 25300 // The current, flushed, state of this fiber is the alternate. Ideally 25301 // nothing should rely on this, but relying on it here means that we don't 25302 // need an additional field on the work in progress. 25303 var current = completedWork.alternate; 25304 var returnFiber = completedWork.return; // Check if the work completed or if something threw. 25305 25306 if ((completedWork.flags & Incomplete) === NoFlags) { 25307 setCurrentFiber(completedWork); 25308 var next = void 0; 25309 25310 if ( (completedWork.mode & ProfileMode) === NoMode) { 25311 next = completeWork(current, completedWork, subtreeRenderLanes); 25312 } else { 25313 startProfilerTimer(completedWork); 25314 next = completeWork(current, completedWork, subtreeRenderLanes); // Update render duration assuming we didn't error. 25315 25316 stopProfilerTimerIfRunningAndRecordDelta(completedWork, false); 25317 } 25318 25319 resetCurrentFiber(); 25320 25321 if (next !== null) { 25322 // Completing this fiber spawned new work. Work on that next. 25323 workInProgress = next; 25324 return; 25325 } 25326 25327 resetChildLanes(completedWork); 25328 25329 if (returnFiber !== null && // Do not append effects to parents if a sibling failed to complete 25330 (returnFiber.flags & Incomplete) === NoFlags) { 25331 // Append all the effects of the subtree and this fiber onto the effect 25332 // list of the parent. The completion order of the children affects the 25333 // side-effect order. 25334 if (returnFiber.firstEffect === null) { 25335 returnFiber.firstEffect = completedWork.firstEffect; 25336 } 25337 25338 if (completedWork.lastEffect !== null) { 25339 if (returnFiber.lastEffect !== null) { 25340 returnFiber.lastEffect.nextEffect = completedWork.firstEffect; 25341 } 25342 25343 returnFiber.lastEffect = completedWork.lastEffect; 25344 } // If this fiber had side-effects, we append it AFTER the children's 25345 // side-effects. We can perform certain side-effects earlier if needed, 25346 // by doing multiple passes over the effect list. We don't want to 25347 // schedule our own side-effect on our own list because if end up 25348 // reusing children we'll schedule this effect onto itself since we're 25349 // at the end. 25350 25351 25352 var flags = completedWork.flags; // Skip both NoWork and PerformedWork tags when creating the effect 25353 // list. PerformedWork effect is read by React DevTools but shouldn't be 25354 // committed. 25355 25356 if (flags > PerformedWork) { 25357 if (returnFiber.lastEffect !== null) { 25358 returnFiber.lastEffect.nextEffect = completedWork; 25359 } else { 25360 returnFiber.firstEffect = completedWork; 25361 } 25362 25363 returnFiber.lastEffect = completedWork; 25364 } 25365 } 25366 } else { 25367 // This fiber did not complete because something threw. Pop values off 25368 // the stack without entering the complete phase. If this is a boundary, 25369 // capture values if possible. 25370 var _next = unwindWork(completedWork); // Because this fiber did not complete, don't reset its expiration time. 25371 25372 25373 if (_next !== null) { 25374 // If completing this work spawned new work, do that next. We'll come 25375 // back here again. 25376 // Since we're restarting, remove anything that is not a host effect 25377 // from the effect tag. 25378 _next.flags &= HostEffectMask; 25379 workInProgress = _next; 25380 return; 25381 } 25382 25383 if ( (completedWork.mode & ProfileMode) !== NoMode) { 25384 // Record the render duration for the fiber that errored. 25385 stopProfilerTimerIfRunningAndRecordDelta(completedWork, false); // Include the time spent working on failed children before continuing. 25386 25387 var actualDuration = completedWork.actualDuration; 25388 var child = completedWork.child; 25389 25390 while (child !== null) { 25391 actualDuration += child.actualDuration; 25392 child = child.sibling; 25393 } 25394 25395 completedWork.actualDuration = actualDuration; 25396 } 25397 25398 if (returnFiber !== null) { 25399 // Mark the parent fiber as incomplete and clear its effect list. 25400 returnFiber.firstEffect = returnFiber.lastEffect = null; 25401 returnFiber.flags |= Incomplete; 25402 } 25403 } 25404 25405 var siblingFiber = completedWork.sibling; 25406 25407 if (siblingFiber !== null) { 25408 // If there is more work to do in this returnFiber, do that next. 25409 workInProgress = siblingFiber; 25410 return; 25411 } // Otherwise, return to the parent 25412 25413 25414 completedWork = returnFiber; // Update the next thing we're working on in case something throws. 25415 25416 workInProgress = completedWork; 25417 } while (completedWork !== null); // We've reached the root. 25418 25419 25420 if (workInProgressRootExitStatus === RootIncomplete) { 25421 workInProgressRootExitStatus = RootCompleted; 25422 } 25423} 25424 25425function resetChildLanes(completedWork) { 25426 if ( // TODO: Move this check out of the hot path by moving `resetChildLanes` 25427 // to switch statement in `completeWork`. 25428 (completedWork.tag === LegacyHiddenComponent || completedWork.tag === OffscreenComponent) && completedWork.memoizedState !== null && !includesSomeLane(subtreeRenderLanes, OffscreenLane) && (completedWork.mode & ConcurrentMode) !== NoLanes) { 25429 // The children of this component are hidden. Don't bubble their 25430 // expiration times. 25431 return; 25432 } 25433 25434 var newChildLanes = NoLanes; // Bubble up the earliest expiration time. 25435 25436 if ( (completedWork.mode & ProfileMode) !== NoMode) { 25437 // In profiling mode, resetChildExpirationTime is also used to reset 25438 // profiler durations. 25439 var actualDuration = completedWork.actualDuration; 25440 var treeBaseDuration = completedWork.selfBaseDuration; // When a fiber is cloned, its actualDuration is reset to 0. This value will 25441 // only be updated if work is done on the fiber (i.e. it doesn't bailout). 25442 // When work is done, it should bubble to the parent's actualDuration. If 25443 // the fiber has not been cloned though, (meaning no work was done), then 25444 // this value will reflect the amount of time spent working on a previous 25445 // render. In that case it should not bubble. We determine whether it was 25446 // cloned by comparing the child pointer. 25447 25448 var shouldBubbleActualDurations = completedWork.alternate === null || completedWork.child !== completedWork.alternate.child; 25449 var child = completedWork.child; 25450 25451 while (child !== null) { 25452 newChildLanes = mergeLanes(newChildLanes, mergeLanes(child.lanes, child.childLanes)); 25453 25454 if (shouldBubbleActualDurations) { 25455 actualDuration += child.actualDuration; 25456 } 25457 25458 treeBaseDuration += child.treeBaseDuration; 25459 child = child.sibling; 25460 } 25461 25462 var isTimedOutSuspense = completedWork.tag === SuspenseComponent && completedWork.memoizedState !== null; 25463 25464 if (isTimedOutSuspense) { 25465 // Don't count time spent in a timed out Suspense subtree as part of the base duration. 25466 var primaryChildFragment = completedWork.child; 25467 25468 if (primaryChildFragment !== null) { 25469 treeBaseDuration -= primaryChildFragment.treeBaseDuration; 25470 } 25471 } 25472 25473 completedWork.actualDuration = actualDuration; 25474 completedWork.treeBaseDuration = treeBaseDuration; 25475 } else { 25476 var _child = completedWork.child; 25477 25478 while (_child !== null) { 25479 newChildLanes = mergeLanes(newChildLanes, mergeLanes(_child.lanes, _child.childLanes)); 25480 _child = _child.sibling; 25481 } 25482 } 25483 25484 completedWork.childLanes = newChildLanes; 25485} 25486 25487function commitRoot(root) { 25488 var renderPriorityLevel = getCurrentPriorityLevel(); 25489 runWithPriority$1(ImmediatePriority$1, commitRootImpl.bind(null, root, renderPriorityLevel)); 25490 return null; 25491} 25492 25493function commitRootImpl(root, renderPriorityLevel) { 25494 do { 25495 // `flushPassiveEffects` will call `flushSyncUpdateQueue` at the end, which 25496 // means `flushPassiveEffects` will sometimes result in additional 25497 // passive effects. So we need to keep flushing in a loop until there are 25498 // no more pending effects. 25499 // TODO: Might be better if `flushPassiveEffects` did not automatically 25500 // flush synchronous work at the end, to avoid factoring hazards like this. 25501 flushPassiveEffects(); 25502 } while (rootWithPendingPassiveEffects !== null); 25503 25504 flushRenderPhaseStrictModeWarningsInDEV(); 25505 25506 if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) { 25507 { 25508 throw Error( "Should not already be working." ); 25509 } 25510 } 25511 25512 var finishedWork = root.finishedWork; 25513 var lanes = root.finishedLanes; 25514 25515 if (finishedWork === null) { 25516 25517 return null; 25518 } 25519 25520 root.finishedWork = null; 25521 root.finishedLanes = NoLanes; 25522 25523 if (!(finishedWork !== root.current)) { 25524 { 25525 throw Error( "Cannot commit the same tree as before. This error is likely caused by a bug in React. Please file an issue." ); 25526 } 25527 } // commitRoot never returns a continuation; it always finishes synchronously. 25528 // So we can clear these now to allow a new callback to be scheduled. 25529 25530 25531 root.callbackNode = null; // Update the first and last pending times on this root. The new first 25532 // pending time is whatever is left on the root fiber. 25533 25534 var remainingLanes = mergeLanes(finishedWork.lanes, finishedWork.childLanes); 25535 markRootFinished(root, remainingLanes); // Clear already finished discrete updates in case that a later call of 25536 // `flushDiscreteUpdates` starts a useless render pass which may cancels 25537 // a scheduled timeout. 25538 25539 if (rootsWithPendingDiscreteUpdates !== null) { 25540 if (!hasDiscreteLanes(remainingLanes) && rootsWithPendingDiscreteUpdates.has(root)) { 25541 rootsWithPendingDiscreteUpdates.delete(root); 25542 } 25543 } 25544 25545 if (root === workInProgressRoot) { 25546 // We can reset these now that they are finished. 25547 workInProgressRoot = null; 25548 workInProgress = null; 25549 workInProgressRootRenderLanes = NoLanes; 25550 } // Get the list of effects. 25551 25552 25553 var firstEffect; 25554 25555 if (finishedWork.flags > PerformedWork) { 25556 // A fiber's effect list consists only of its children, not itself. So if 25557 // the root has an effect, we need to add it to the end of the list. The 25558 // resulting list is the set that would belong to the root's parent, if it 25559 // had one; that is, all the effects in the tree including the root. 25560 if (finishedWork.lastEffect !== null) { 25561 finishedWork.lastEffect.nextEffect = finishedWork; 25562 firstEffect = finishedWork.firstEffect; 25563 } else { 25564 firstEffect = finishedWork; 25565 } 25566 } else { 25567 // There is no effect on the root. 25568 firstEffect = finishedWork.firstEffect; 25569 } 25570 25571 if (firstEffect !== null) { 25572 25573 var prevExecutionContext = executionContext; 25574 executionContext |= CommitContext; 25575 var prevInteractions = pushInteractions(root); // Reset this to null before calling lifecycles 25576 25577 ReactCurrentOwner$2.current = null; // The commit phase is broken into several sub-phases. We do a separate pass 25578 // of the effect list for each phase: all mutation effects come before all 25579 // layout effects, and so on. 25580 // The first phase a "before mutation" phase. We use this phase to read the 25581 // state of the host tree right before we mutate it. This is where 25582 // getSnapshotBeforeUpdate is called. 25583 25584 focusedInstanceHandle = prepareForCommit(root.containerInfo); 25585 shouldFireAfterActiveInstanceBlur = false; 25586 nextEffect = firstEffect; 25587 25588 do { 25589 { 25590 invokeGuardedCallback(null, commitBeforeMutationEffects, null); 25591 25592 if (hasCaughtError()) { 25593 if (!(nextEffect !== null)) { 25594 { 25595 throw Error( "Should be working on an effect." ); 25596 } 25597 } 25598 25599 var error = clearCaughtError(); 25600 captureCommitPhaseError(nextEffect, error); 25601 nextEffect = nextEffect.nextEffect; 25602 } 25603 } 25604 } while (nextEffect !== null); // We no longer need to track the active instance fiber 25605 25606 25607 focusedInstanceHandle = null; 25608 25609 { 25610 // Mark the current commit time to be shared by all Profilers in this 25611 // batch. This enables them to be grouped later. 25612 recordCommitTime(); 25613 } // The next phase is the mutation phase, where we mutate the host tree. 25614 25615 25616 nextEffect = firstEffect; 25617 25618 do { 25619 { 25620 invokeGuardedCallback(null, commitMutationEffects, null, root, renderPriorityLevel); 25621 25622 if (hasCaughtError()) { 25623 if (!(nextEffect !== null)) { 25624 { 25625 throw Error( "Should be working on an effect." ); 25626 } 25627 } 25628 25629 var _error = clearCaughtError(); 25630 25631 captureCommitPhaseError(nextEffect, _error); 25632 nextEffect = nextEffect.nextEffect; 25633 } 25634 } 25635 } while (nextEffect !== null); 25636 25637 resetAfterCommit(root.containerInfo); // The work-in-progress tree is now the current tree. This must come after 25638 // the mutation phase, so that the previous tree is still current during 25639 // componentWillUnmount, but before the layout phase, so that the finished 25640 // work is current during componentDidMount/Update. 25641 25642 root.current = finishedWork; // The next phase is the layout phase, where we call effects that read 25643 // the host tree after it's been mutated. The idiomatic use case for this is 25644 // layout, but class component lifecycles also fire here for legacy reasons. 25645 25646 nextEffect = firstEffect; 25647 25648 do { 25649 { 25650 invokeGuardedCallback(null, commitLayoutEffects, null, root, lanes); 25651 25652 if (hasCaughtError()) { 25653 if (!(nextEffect !== null)) { 25654 { 25655 throw Error( "Should be working on an effect." ); 25656 } 25657 } 25658 25659 var _error2 = clearCaughtError(); 25660 25661 captureCommitPhaseError(nextEffect, _error2); 25662 nextEffect = nextEffect.nextEffect; 25663 } 25664 } 25665 } while (nextEffect !== null); 25666 25667 nextEffect = null; // Tell Scheduler to yield at the end of the frame, so the browser has an 25668 // opportunity to paint. 25669 25670 requestPaint(); 25671 25672 { 25673 popInteractions(prevInteractions); 25674 } 25675 25676 executionContext = prevExecutionContext; 25677 } else { 25678 // No effects. 25679 root.current = finishedWork; // Measure these anyway so the flamegraph explicitly shows that there were 25680 // no effects. 25681 // TODO: Maybe there's a better way to report this. 25682 25683 { 25684 recordCommitTime(); 25685 } 25686 } 25687 25688 var rootDidHavePassiveEffects = rootDoesHavePassiveEffects; 25689 25690 if (rootDoesHavePassiveEffects) { 25691 // This commit has passive effects. Stash a reference to them. But don't 25692 // schedule a callback until after flushing layout work. 25693 rootDoesHavePassiveEffects = false; 25694 rootWithPendingPassiveEffects = root; 25695 pendingPassiveEffectsLanes = lanes; 25696 pendingPassiveEffectsRenderPriority = renderPriorityLevel; 25697 } else { 25698 // We are done with the effect chain at this point so let's clear the 25699 // nextEffect pointers to assist with GC. If we have passive effects, we'll 25700 // clear this in flushPassiveEffects. 25701 nextEffect = firstEffect; 25702 25703 while (nextEffect !== null) { 25704 var nextNextEffect = nextEffect.nextEffect; 25705 nextEffect.nextEffect = null; 25706 25707 if (nextEffect.flags & Deletion) { 25708 detachFiberAfterEffects(nextEffect); 25709 } 25710 25711 nextEffect = nextNextEffect; 25712 } 25713 } // Read this again, since an effect might have updated it 25714 25715 25716 remainingLanes = root.pendingLanes; // Check if there's remaining work on this root 25717 25718 if (remainingLanes !== NoLanes) { 25719 { 25720 if (spawnedWorkDuringRender !== null) { 25721 var expirationTimes = spawnedWorkDuringRender; 25722 spawnedWorkDuringRender = null; 25723 25724 for (var i = 0; i < expirationTimes.length; i++) { 25725 scheduleInteractions(root, expirationTimes[i], root.memoizedInteractions); 25726 } 25727 } 25728 25729 schedulePendingInteractions(root, remainingLanes); 25730 } 25731 } else { 25732 // If there's no remaining work, we can clear the set of already failed 25733 // error boundaries. 25734 legacyErrorBoundariesThatAlreadyFailed = null; 25735 } 25736 25737 { 25738 if (!rootDidHavePassiveEffects) { 25739 // If there are no passive effects, then we can complete the pending interactions. 25740 // Otherwise, we'll wait until after the passive effects are flushed. 25741 // Wait to do this until after remaining work has been scheduled, 25742 // so that we don't prematurely signal complete for interactions when there's e.g. hidden work. 25743 finishPendingInteractions(root, lanes); 25744 } 25745 } 25746 25747 if (remainingLanes === SyncLane) { 25748 // Count the number of times the root synchronously re-renders without 25749 // finishing. If there are too many, it indicates an infinite update loop. 25750 if (root === rootWithNestedUpdates) { 25751 nestedUpdateCount++; 25752 } else { 25753 nestedUpdateCount = 0; 25754 rootWithNestedUpdates = root; 25755 } 25756 } else { 25757 nestedUpdateCount = 0; 25758 } 25759 25760 onCommitRoot(finishedWork.stateNode, renderPriorityLevel); 25761 25762 { 25763 onCommitRoot$1(); 25764 } // Always call this before exiting `commitRoot`, to ensure that any 25765 // additional work on this root is scheduled. 25766 25767 25768 ensureRootIsScheduled(root, now()); 25769 25770 if (hasUncaughtError) { 25771 hasUncaughtError = false; 25772 var _error3 = firstUncaughtError; 25773 firstUncaughtError = null; 25774 throw _error3; 25775 } 25776 25777 if ((executionContext & LegacyUnbatchedContext) !== NoContext) { 25778 // a ReactDOM.render-ed root inside of batchedUpdates. The commit fired 25779 // synchronously, but layout updates should be deferred until the end 25780 // of the batch. 25781 25782 25783 return null; 25784 } // If layout work was scheduled, flush it now. 25785 25786 25787 flushSyncCallbackQueue(); 25788 25789 return null; 25790} 25791 25792function commitBeforeMutationEffects() { 25793 while (nextEffect !== null) { 25794 var current = nextEffect.alternate; 25795 25796 if (!shouldFireAfterActiveInstanceBlur && focusedInstanceHandle !== null) { 25797 if ((nextEffect.flags & Deletion) !== NoFlags) { 25798 if (doesFiberContain(nextEffect, focusedInstanceHandle)) { 25799 shouldFireAfterActiveInstanceBlur = true; 25800 } 25801 } else { 25802 // TODO: Move this out of the hot path using a dedicated effect tag. 25803 if (nextEffect.tag === SuspenseComponent && isSuspenseBoundaryBeingHidden(current, nextEffect) && doesFiberContain(nextEffect, focusedInstanceHandle)) { 25804 shouldFireAfterActiveInstanceBlur = true; 25805 } 25806 } 25807 } 25808 25809 var flags = nextEffect.flags; 25810 25811 if ((flags & Snapshot) !== NoFlags) { 25812 setCurrentFiber(nextEffect); 25813 commitBeforeMutationLifeCycles(current, nextEffect); 25814 resetCurrentFiber(); 25815 } 25816 25817 if ((flags & Passive) !== NoFlags) { 25818 // If there are passive effects, schedule a callback to flush at 25819 // the earliest opportunity. 25820 if (!rootDoesHavePassiveEffects) { 25821 rootDoesHavePassiveEffects = true; 25822 scheduleCallback(NormalPriority$1, function () { 25823 flushPassiveEffects(); 25824 return null; 25825 }); 25826 } 25827 } 25828 25829 nextEffect = nextEffect.nextEffect; 25830 } 25831} 25832 25833function commitMutationEffects(root, renderPriorityLevel) { 25834 // TODO: Should probably move the bulk of this function to commitWork. 25835 while (nextEffect !== null) { 25836 setCurrentFiber(nextEffect); 25837 var flags = nextEffect.flags; 25838 25839 if (flags & ContentReset) { 25840 commitResetTextContent(nextEffect); 25841 } 25842 25843 if (flags & Ref) { 25844 var current = nextEffect.alternate; 25845 25846 if (current !== null) { 25847 commitDetachRef(current); 25848 } 25849 } // The following switch statement is only concerned about placement, 25850 // updates, and deletions. To avoid needing to add a case for every possible 25851 // bitmap value, we remove the secondary effects from the effect tag and 25852 // switch on that value. 25853 25854 25855 var primaryFlags = flags & (Placement | Update | Deletion | Hydrating); 25856 25857 switch (primaryFlags) { 25858 case Placement: 25859 { 25860 commitPlacement(nextEffect); // Clear the "placement" from effect tag so that we know that this is 25861 // inserted, before any life-cycles like componentDidMount gets called. 25862 // TODO: findDOMNode doesn't rely on this any more but isMounted does 25863 // and isMounted is deprecated anyway so we should be able to kill this. 25864 25865 nextEffect.flags &= ~Placement; 25866 break; 25867 } 25868 25869 case PlacementAndUpdate: 25870 { 25871 // Placement 25872 commitPlacement(nextEffect); // Clear the "placement" from effect tag so that we know that this is 25873 // inserted, before any life-cycles like componentDidMount gets called. 25874 25875 nextEffect.flags &= ~Placement; // Update 25876 25877 var _current = nextEffect.alternate; 25878 commitWork(_current, nextEffect); 25879 break; 25880 } 25881 25882 case Hydrating: 25883 { 25884 nextEffect.flags &= ~Hydrating; 25885 break; 25886 } 25887 25888 case HydratingAndUpdate: 25889 { 25890 nextEffect.flags &= ~Hydrating; // Update 25891 25892 var _current2 = nextEffect.alternate; 25893 commitWork(_current2, nextEffect); 25894 break; 25895 } 25896 25897 case Update: 25898 { 25899 var _current3 = nextEffect.alternate; 25900 commitWork(_current3, nextEffect); 25901 break; 25902 } 25903 25904 case Deletion: 25905 { 25906 commitDeletion(root, nextEffect); 25907 break; 25908 } 25909 } 25910 25911 resetCurrentFiber(); 25912 nextEffect = nextEffect.nextEffect; 25913 } 25914} 25915 25916function commitLayoutEffects(root, committedLanes) { 25917 25918 25919 while (nextEffect !== null) { 25920 setCurrentFiber(nextEffect); 25921 var flags = nextEffect.flags; 25922 25923 if (flags & (Update | Callback)) { 25924 var current = nextEffect.alternate; 25925 commitLifeCycles(root, current, nextEffect); 25926 } 25927 25928 { 25929 if (flags & Ref) { 25930 commitAttachRef(nextEffect); 25931 } 25932 } 25933 25934 resetCurrentFiber(); 25935 nextEffect = nextEffect.nextEffect; 25936 } 25937} 25938 25939function flushPassiveEffects() { 25940 // Returns whether passive effects were flushed. 25941 if (pendingPassiveEffectsRenderPriority !== NoPriority$1) { 25942 var priorityLevel = pendingPassiveEffectsRenderPriority > NormalPriority$1 ? NormalPriority$1 : pendingPassiveEffectsRenderPriority; 25943 pendingPassiveEffectsRenderPriority = NoPriority$1; 25944 25945 { 25946 return runWithPriority$1(priorityLevel, flushPassiveEffectsImpl); 25947 } 25948 } 25949 25950 return false; 25951} 25952function enqueuePendingPassiveHookEffectMount(fiber, effect) { 25953 pendingPassiveHookEffectsMount.push(effect, fiber); 25954 25955 if (!rootDoesHavePassiveEffects) { 25956 rootDoesHavePassiveEffects = true; 25957 scheduleCallback(NormalPriority$1, function () { 25958 flushPassiveEffects(); 25959 return null; 25960 }); 25961 } 25962} 25963function enqueuePendingPassiveHookEffectUnmount(fiber, effect) { 25964 pendingPassiveHookEffectsUnmount.push(effect, fiber); 25965 25966 { 25967 fiber.flags |= PassiveUnmountPendingDev; 25968 var alternate = fiber.alternate; 25969 25970 if (alternate !== null) { 25971 alternate.flags |= PassiveUnmountPendingDev; 25972 } 25973 } 25974 25975 if (!rootDoesHavePassiveEffects) { 25976 rootDoesHavePassiveEffects = true; 25977 scheduleCallback(NormalPriority$1, function () { 25978 flushPassiveEffects(); 25979 return null; 25980 }); 25981 } 25982} 25983 25984function invokePassiveEffectCreate(effect) { 25985 var create = effect.create; 25986 effect.destroy = create(); 25987} 25988 25989function flushPassiveEffectsImpl() { 25990 if (rootWithPendingPassiveEffects === null) { 25991 return false; 25992 } 25993 25994 var root = rootWithPendingPassiveEffects; 25995 var lanes = pendingPassiveEffectsLanes; 25996 rootWithPendingPassiveEffects = null; 25997 pendingPassiveEffectsLanes = NoLanes; 25998 25999 if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) { 26000 { 26001 throw Error( "Cannot flush passive effects while already rendering." ); 26002 } 26003 } 26004 26005 { 26006 isFlushingPassiveEffects = true; 26007 } 26008 26009 var prevExecutionContext = executionContext; 26010 executionContext |= CommitContext; 26011 var prevInteractions = pushInteractions(root); // It's important that ALL pending passive effect destroy functions are called 26012 // before ANY passive effect create functions are called. 26013 // Otherwise effects in sibling components might interfere with each other. 26014 // e.g. a destroy function in one component may unintentionally override a ref 26015 // value set by a create function in another component. 26016 // Layout effects have the same constraint. 26017 // First pass: Destroy stale passive effects. 26018 26019 var unmountEffects = pendingPassiveHookEffectsUnmount; 26020 pendingPassiveHookEffectsUnmount = []; 26021 26022 for (var i = 0; i < unmountEffects.length; i += 2) { 26023 var _effect = unmountEffects[i]; 26024 var fiber = unmountEffects[i + 1]; 26025 var destroy = _effect.destroy; 26026 _effect.destroy = undefined; 26027 26028 { 26029 fiber.flags &= ~PassiveUnmountPendingDev; 26030 var alternate = fiber.alternate; 26031 26032 if (alternate !== null) { 26033 alternate.flags &= ~PassiveUnmountPendingDev; 26034 } 26035 } 26036 26037 if (typeof destroy === 'function') { 26038 { 26039 setCurrentFiber(fiber); 26040 26041 { 26042 invokeGuardedCallback(null, destroy, null); 26043 } 26044 26045 if (hasCaughtError()) { 26046 if (!(fiber !== null)) { 26047 { 26048 throw Error( "Should be working on an effect." ); 26049 } 26050 } 26051 26052 var error = clearCaughtError(); 26053 captureCommitPhaseError(fiber, error); 26054 } 26055 26056 resetCurrentFiber(); 26057 } 26058 } 26059 } // Second pass: Create new passive effects. 26060 26061 26062 var mountEffects = pendingPassiveHookEffectsMount; 26063 pendingPassiveHookEffectsMount = []; 26064 26065 for (var _i = 0; _i < mountEffects.length; _i += 2) { 26066 var _effect2 = mountEffects[_i]; 26067 var _fiber = mountEffects[_i + 1]; 26068 26069 { 26070 setCurrentFiber(_fiber); 26071 26072 { 26073 invokeGuardedCallback(null, invokePassiveEffectCreate, null, _effect2); 26074 } 26075 26076 if (hasCaughtError()) { 26077 if (!(_fiber !== null)) { 26078 { 26079 throw Error( "Should be working on an effect." ); 26080 } 26081 } 26082 26083 var _error4 = clearCaughtError(); 26084 26085 captureCommitPhaseError(_fiber, _error4); 26086 } 26087 26088 resetCurrentFiber(); 26089 } 26090 } // Note: This currently assumes there are no passive effects on the root fiber 26091 // because the root is not part of its own effect list. 26092 // This could change in the future. 26093 26094 26095 var effect = root.current.firstEffect; 26096 26097 while (effect !== null) { 26098 var nextNextEffect = effect.nextEffect; // Remove nextEffect pointer to assist GC 26099 26100 effect.nextEffect = null; 26101 26102 if (effect.flags & Deletion) { 26103 detachFiberAfterEffects(effect); 26104 } 26105 26106 effect = nextNextEffect; 26107 } 26108 26109 { 26110 popInteractions(prevInteractions); 26111 finishPendingInteractions(root, lanes); 26112 } 26113 26114 { 26115 isFlushingPassiveEffects = false; 26116 } 26117 26118 executionContext = prevExecutionContext; 26119 flushSyncCallbackQueue(); // If additional passive effects were scheduled, increment a counter. If this 26120 // exceeds the limit, we'll fire a warning. 26121 26122 nestedPassiveUpdateCount = rootWithPendingPassiveEffects === null ? 0 : nestedPassiveUpdateCount + 1; 26123 return true; 26124} 26125 26126function isAlreadyFailedLegacyErrorBoundary(instance) { 26127 return legacyErrorBoundariesThatAlreadyFailed !== null && legacyErrorBoundariesThatAlreadyFailed.has(instance); 26128} 26129function markLegacyErrorBoundaryAsFailed(instance) { 26130 if (legacyErrorBoundariesThatAlreadyFailed === null) { 26131 legacyErrorBoundariesThatAlreadyFailed = new Set([instance]); 26132 } else { 26133 legacyErrorBoundariesThatAlreadyFailed.add(instance); 26134 } 26135} 26136 26137function prepareToThrowUncaughtError(error) { 26138 if (!hasUncaughtError) { 26139 hasUncaughtError = true; 26140 firstUncaughtError = error; 26141 } 26142} 26143 26144var onUncaughtError = prepareToThrowUncaughtError; 26145 26146function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error) { 26147 var errorInfo = createCapturedValue(error, sourceFiber); 26148 var update = createRootErrorUpdate(rootFiber, errorInfo, SyncLane); 26149 enqueueUpdate(rootFiber, update); 26150 var eventTime = requestEventTime(); 26151 var root = markUpdateLaneFromFiberToRoot(rootFiber, SyncLane); 26152 26153 if (root !== null) { 26154 markRootUpdated(root, SyncLane, eventTime); 26155 ensureRootIsScheduled(root, eventTime); 26156 schedulePendingInteractions(root, SyncLane); 26157 } 26158} 26159 26160function captureCommitPhaseError(sourceFiber, error) { 26161 if (sourceFiber.tag === HostRoot) { 26162 // Error was thrown at the root. There is no parent, so the root 26163 // itself should capture it. 26164 captureCommitPhaseErrorOnRoot(sourceFiber, sourceFiber, error); 26165 return; 26166 } 26167 26168 var fiber = sourceFiber.return; 26169 26170 while (fiber !== null) { 26171 if (fiber.tag === HostRoot) { 26172 captureCommitPhaseErrorOnRoot(fiber, sourceFiber, error); 26173 return; 26174 } else if (fiber.tag === ClassComponent) { 26175 var ctor = fiber.type; 26176 var instance = fiber.stateNode; 26177 26178 if (typeof ctor.getDerivedStateFromError === 'function' || typeof instance.componentDidCatch === 'function' && !isAlreadyFailedLegacyErrorBoundary(instance)) { 26179 var errorInfo = createCapturedValue(error, sourceFiber); 26180 var update = createClassErrorUpdate(fiber, errorInfo, SyncLane); 26181 enqueueUpdate(fiber, update); 26182 var eventTime = requestEventTime(); 26183 var root = markUpdateLaneFromFiberToRoot(fiber, SyncLane); 26184 26185 if (root !== null) { 26186 markRootUpdated(root, SyncLane, eventTime); 26187 ensureRootIsScheduled(root, eventTime); 26188 schedulePendingInteractions(root, SyncLane); 26189 } else { 26190 // This component has already been unmounted. 26191 // We can't schedule any follow up work for the root because the fiber is already unmounted, 26192 // but we can still call the log-only boundary so the error isn't swallowed. 26193 // 26194 // TODO This is only a temporary bandaid for the old reconciler fork. 26195 // We can delete this special case once the new fork is merged. 26196 if (typeof instance.componentDidCatch === 'function' && !isAlreadyFailedLegacyErrorBoundary(instance)) { 26197 try { 26198 instance.componentDidCatch(error, errorInfo); 26199 } catch (errorToIgnore) {// TODO Ignore this error? Rethrow it? 26200 // This is kind of an edge case. 26201 } 26202 } 26203 } 26204 26205 return; 26206 } 26207 } 26208 26209 fiber = fiber.return; 26210 } 26211} 26212function pingSuspendedRoot(root, wakeable, pingedLanes) { 26213 var pingCache = root.pingCache; 26214 26215 if (pingCache !== null) { 26216 // The wakeable resolved, so we no longer need to memoize, because it will 26217 // never be thrown again. 26218 pingCache.delete(wakeable); 26219 } 26220 26221 var eventTime = requestEventTime(); 26222 markRootPinged(root, pingedLanes); 26223 26224 if (workInProgressRoot === root && isSubsetOfLanes(workInProgressRootRenderLanes, pingedLanes)) { 26225 // Received a ping at the same priority level at which we're currently 26226 // rendering. We might want to restart this render. This should mirror 26227 // the logic of whether or not a root suspends once it completes. 26228 // TODO: If we're rendering sync either due to Sync, Batched or expired, 26229 // we should probably never restart. 26230 // If we're suspended with delay, or if it's a retry, we'll always suspend 26231 // so we can always restart. 26232 if (workInProgressRootExitStatus === RootSuspendedWithDelay || workInProgressRootExitStatus === RootSuspended && includesOnlyRetries(workInProgressRootRenderLanes) && now() - globalMostRecentFallbackTime < FALLBACK_THROTTLE_MS) { 26233 // Restart from the root. 26234 prepareFreshStack(root, NoLanes); 26235 } else { 26236 // Even though we can't restart right now, we might get an 26237 // opportunity later. So we mark this render as having a ping. 26238 workInProgressRootPingedLanes = mergeLanes(workInProgressRootPingedLanes, pingedLanes); 26239 } 26240 } 26241 26242 ensureRootIsScheduled(root, eventTime); 26243 schedulePendingInteractions(root, pingedLanes); 26244} 26245 26246function retryTimedOutBoundary(boundaryFiber, retryLane) { 26247 // The boundary fiber (a Suspense component or SuspenseList component) 26248 // previously was rendered in its fallback state. One of the promises that 26249 // suspended it has resolved, which means at least part of the tree was 26250 // likely unblocked. Try rendering again, at a new expiration time. 26251 if (retryLane === NoLane) { 26252 retryLane = requestRetryLane(boundaryFiber); 26253 } // TODO: Special case idle priority? 26254 26255 26256 var eventTime = requestEventTime(); 26257 var root = markUpdateLaneFromFiberToRoot(boundaryFiber, retryLane); 26258 26259 if (root !== null) { 26260 markRootUpdated(root, retryLane, eventTime); 26261 ensureRootIsScheduled(root, eventTime); 26262 schedulePendingInteractions(root, retryLane); 26263 } 26264} 26265function resolveRetryWakeable(boundaryFiber, wakeable) { 26266 var retryLane = NoLane; // Default 26267 26268 var retryCache; 26269 26270 { 26271 retryCache = boundaryFiber.stateNode; 26272 } 26273 26274 if (retryCache !== null) { 26275 // The wakeable resolved, so we no longer need to memoize, because it will 26276 // never be thrown again. 26277 retryCache.delete(wakeable); 26278 } 26279 26280 retryTimedOutBoundary(boundaryFiber, retryLane); 26281} // Computes the next Just Noticeable Difference (JND) boundary. 26282// The theory is that a person can't tell the difference between small differences in time. 26283// Therefore, if we wait a bit longer than necessary that won't translate to a noticeable 26284// difference in the experience. However, waiting for longer might mean that we can avoid 26285// showing an intermediate loading state. The longer we have already waited, the harder it 26286// is to tell small differences in time. Therefore, the longer we've already waited, 26287// the longer we can wait additionally. At some point we have to give up though. 26288// We pick a train model where the next boundary commits at a consistent schedule. 26289// These particular numbers are vague estimates. We expect to adjust them based on research. 26290 26291function jnd(timeElapsed) { 26292 return timeElapsed < 120 ? 120 : timeElapsed < 480 ? 480 : timeElapsed < 1080 ? 1080 : timeElapsed < 1920 ? 1920 : timeElapsed < 3000 ? 3000 : timeElapsed < 4320 ? 4320 : ceil(timeElapsed / 1960) * 1960; 26293} 26294 26295function checkForNestedUpdates() { 26296 if (nestedUpdateCount > NESTED_UPDATE_LIMIT) { 26297 nestedUpdateCount = 0; 26298 rootWithNestedUpdates = null; 26299 26300 { 26301 { 26302 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." ); 26303 } 26304 } 26305 } 26306 26307 { 26308 if (nestedPassiveUpdateCount > NESTED_PASSIVE_UPDATE_LIMIT) { 26309 nestedPassiveUpdateCount = 0; 26310 26311 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.'); 26312 } 26313 } 26314} 26315 26316function flushRenderPhaseStrictModeWarningsInDEV() { 26317 { 26318 ReactStrictModeWarnings.flushLegacyContextWarning(); 26319 26320 { 26321 ReactStrictModeWarnings.flushPendingUnsafeLifecycleWarnings(); 26322 } 26323 } 26324} 26325 26326var didWarnStateUpdateForNotYetMountedComponent = null; 26327 26328function warnAboutUpdateOnNotYetMountedFiberInDEV(fiber) { 26329 { 26330 if ((executionContext & RenderContext) !== NoContext) { 26331 // We let the other warning about render phase updates deal with this one. 26332 return; 26333 } 26334 26335 if (!(fiber.mode & (BlockingMode | ConcurrentMode))) { 26336 return; 26337 } 26338 26339 var tag = fiber.tag; 26340 26341 if (tag !== IndeterminateComponent && tag !== HostRoot && tag !== ClassComponent && tag !== FunctionComponent && tag !== ForwardRef && tag !== MemoComponent && tag !== SimpleMemoComponent && tag !== Block) { 26342 // Only warn for user-defined components, not internal ones like Suspense. 26343 return; 26344 } // We show the whole stack but dedupe on the top component's name because 26345 // the problematic code almost always lies inside that component. 26346 26347 26348 var componentName = getComponentName(fiber.type) || 'ReactComponent'; 26349 26350 if (didWarnStateUpdateForNotYetMountedComponent !== null) { 26351 if (didWarnStateUpdateForNotYetMountedComponent.has(componentName)) { 26352 return; 26353 } 26354 26355 didWarnStateUpdateForNotYetMountedComponent.add(componentName); 26356 } else { 26357 didWarnStateUpdateForNotYetMountedComponent = new Set([componentName]); 26358 } 26359 26360 var previousFiber = current; 26361 26362 try { 26363 setCurrentFiber(fiber); 26364 26365 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.'); 26366 } finally { 26367 if (previousFiber) { 26368 setCurrentFiber(fiber); 26369 } else { 26370 resetCurrentFiber(); 26371 } 26372 } 26373 } 26374} 26375 26376var didWarnStateUpdateForUnmountedComponent = null; 26377 26378function warnAboutUpdateOnUnmountedFiberInDEV(fiber) { 26379 { 26380 var tag = fiber.tag; 26381 26382 if (tag !== HostRoot && tag !== ClassComponent && tag !== FunctionComponent && tag !== ForwardRef && tag !== MemoComponent && tag !== SimpleMemoComponent && tag !== Block) { 26383 // Only warn for user-defined components, not internal ones like Suspense. 26384 return; 26385 } // If there are pending passive effects unmounts for this Fiber, 26386 // we can assume that they would have prevented this update. 26387 26388 26389 if ((fiber.flags & PassiveUnmountPendingDev) !== NoFlags) { 26390 return; 26391 } // We show the whole stack but dedupe on the top component's name because 26392 // the problematic code almost always lies inside that component. 26393 26394 26395 var componentName = getComponentName(fiber.type) || 'ReactComponent'; 26396 26397 if (didWarnStateUpdateForUnmountedComponent !== null) { 26398 if (didWarnStateUpdateForUnmountedComponent.has(componentName)) { 26399 return; 26400 } 26401 26402 didWarnStateUpdateForUnmountedComponent.add(componentName); 26403 } else { 26404 didWarnStateUpdateForUnmountedComponent = new Set([componentName]); 26405 } 26406 26407 if (isFlushingPassiveEffects) ; else { 26408 var previousFiber = current; 26409 26410 try { 26411 setCurrentFiber(fiber); 26412 26413 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'); 26414 } finally { 26415 if (previousFiber) { 26416 setCurrentFiber(fiber); 26417 } else { 26418 resetCurrentFiber(); 26419 } 26420 } 26421 } 26422 } 26423} 26424 26425var beginWork$1; 26426 26427{ 26428 var dummyFiber = null; 26429 26430 beginWork$1 = function (current, unitOfWork, lanes) { 26431 // If a component throws an error, we replay it again in a synchronously 26432 // dispatched event, so that the debugger will treat it as an uncaught 26433 // error See ReactErrorUtils for more information. 26434 // Before entering the begin phase, copy the work-in-progress onto a dummy 26435 // fiber. If beginWork throws, we'll use this to reset the state. 26436 var originalWorkInProgressCopy = assignFiberPropertiesInDEV(dummyFiber, unitOfWork); 26437 26438 try { 26439 return beginWork(current, unitOfWork, lanes); 26440 } catch (originalError) { 26441 if (originalError !== null && typeof originalError === 'object' && typeof originalError.then === 'function') { 26442 // Don't replay promises. Treat everything else like an error. 26443 throw originalError; 26444 } // Keep this code in sync with handleError; any changes here must have 26445 // corresponding changes there. 26446 26447 26448 resetContextDependencies(); 26449 resetHooksAfterThrow(); // Don't reset current debug fiber, since we're about to work on the 26450 // same fiber again. 26451 // Unwind the failed stack frame 26452 26453 unwindInterruptedWork(unitOfWork); // Restore the original properties of the fiber. 26454 26455 assignFiberPropertiesInDEV(unitOfWork, originalWorkInProgressCopy); 26456 26457 if ( unitOfWork.mode & ProfileMode) { 26458 // Reset the profiler timer. 26459 startProfilerTimer(unitOfWork); 26460 } // Run beginWork again. 26461 26462 26463 invokeGuardedCallback(null, beginWork, null, current, unitOfWork, lanes); 26464 26465 if (hasCaughtError()) { 26466 var replayError = clearCaughtError(); // `invokeGuardedCallback` sometimes sets an expando `_suppressLogging`. 26467 // Rethrow this error instead of the original one. 26468 26469 throw replayError; 26470 } else { 26471 // This branch is reachable if the render phase is impure. 26472 throw originalError; 26473 } 26474 } 26475 }; 26476} 26477 26478var didWarnAboutUpdateInRender = false; 26479var didWarnAboutUpdateInRenderForAnotherComponent; 26480 26481{ 26482 didWarnAboutUpdateInRenderForAnotherComponent = new Set(); 26483} 26484 26485function warnAboutRenderPhaseUpdatesInDEV(fiber) { 26486 { 26487 if (isRendering && (executionContext & RenderContext) !== NoContext && !getIsUpdatingOpaqueValueInRenderPhaseInDEV()) { 26488 switch (fiber.tag) { 26489 case FunctionComponent: 26490 case ForwardRef: 26491 case SimpleMemoComponent: 26492 { 26493 var renderingComponentName = workInProgress && getComponentName(workInProgress.type) || 'Unknown'; // Dedupe by the rendering component because it's the one that needs to be fixed. 26494 26495 var dedupeKey = renderingComponentName; 26496 26497 if (!didWarnAboutUpdateInRenderForAnotherComponent.has(dedupeKey)) { 26498 didWarnAboutUpdateInRenderForAnotherComponent.add(dedupeKey); 26499 var setStateComponentName = getComponentName(fiber.type) || 'Unknown'; 26500 26501 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); 26502 } 26503 26504 break; 26505 } 26506 26507 case ClassComponent: 26508 { 26509 if (!didWarnAboutUpdateInRender) { 26510 error('Cannot update during an existing state transition (such as ' + 'within `render`). Render methods should be a pure ' + 'function of props and state.'); 26511 26512 didWarnAboutUpdateInRender = true; 26513 } 26514 26515 break; 26516 } 26517 } 26518 } 26519 } 26520} // a 'shared' variable that changes when act() opens/closes in tests. 26521 26522 26523var IsThisRendererActing = { 26524 current: false 26525}; 26526function warnIfNotScopedWithMatchingAct(fiber) { 26527 { 26528 if ( IsSomeRendererActing.current === true && IsThisRendererActing.current !== true) { 26529 var previousFiber = current; 26530 26531 try { 26532 setCurrentFiber(fiber); 26533 26534 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. 26535 '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. 26536 'import TestRenderer fr' + "om react-test-renderer';\n" + 'const {act} = TestRenderer;\n' + '// ...\n' + 'act(() => ...);'); 26537 } finally { 26538 if (previousFiber) { 26539 setCurrentFiber(fiber); 26540 } else { 26541 resetCurrentFiber(); 26542 } 26543 } 26544 } 26545 } 26546} 26547function warnIfNotCurrentlyActingEffectsInDEV(fiber) { 26548 { 26549 if ( (fiber.mode & StrictMode) !== NoMode && IsSomeRendererActing.current === false && IsThisRendererActing.current === false) { 26550 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)); 26551 } 26552 } 26553} 26554 26555function warnIfNotCurrentlyActingUpdatesInDEV(fiber) { 26556 { 26557 if ( executionContext === NoContext && IsSomeRendererActing.current === false && IsThisRendererActing.current === false) { 26558 var previousFiber = current; 26559 26560 try { 26561 setCurrentFiber(fiber); 26562 26563 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)); 26564 } finally { 26565 if (previousFiber) { 26566 setCurrentFiber(fiber); 26567 } else { 26568 resetCurrentFiber(); 26569 } 26570 } 26571 } 26572 } 26573} 26574 26575var warnIfNotCurrentlyActingUpdatesInDev = warnIfNotCurrentlyActingUpdatesInDEV; // In tests, we want to enforce a mocked scheduler. 26576 26577var didWarnAboutUnmockedScheduler = false; // TODO Before we release concurrent mode, revisit this and decide whether a mocked 26578// scheduler is the actual recommendation. The alternative could be a testing build, 26579// a new lib, or whatever; we dunno just yet. This message is for early adopters 26580// to get their tests right. 26581 26582function warnIfUnmockedScheduler(fiber) { 26583 { 26584 if (didWarnAboutUnmockedScheduler === false && Scheduler.unstable_flushAllWithoutAsserting === undefined) { 26585 if (fiber.mode & BlockingMode || fiber.mode & ConcurrentMode) { 26586 didWarnAboutUnmockedScheduler = true; 26587 26588 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. 26589 "jest.mock('scheduler', () => require" + "('scheduler/unstable_mock'));\n\n" + 'For more info, visit https://reactjs.org/link/mock-scheduler'); 26590 } 26591 } 26592 } 26593} 26594 26595function computeThreadID(root, lane) { 26596 // Interaction threads are unique per root and expiration time. 26597 // NOTE: Intentionally unsound cast. All that matters is that it's a number 26598 // and it represents a batch of work. Could make a helper function instead, 26599 // but meh this is fine for now. 26600 return lane * 1000 + root.interactionThreadID; 26601} 26602 26603function markSpawnedWork(lane) { 26604 26605 if (spawnedWorkDuringRender === null) { 26606 spawnedWorkDuringRender = [lane]; 26607 } else { 26608 spawnedWorkDuringRender.push(lane); 26609 } 26610} 26611 26612function scheduleInteractions(root, lane, interactions) { 26613 26614 if (interactions.size > 0) { 26615 var pendingInteractionMap = root.pendingInteractionMap; 26616 var pendingInteractions = pendingInteractionMap.get(lane); 26617 26618 if (pendingInteractions != null) { 26619 interactions.forEach(function (interaction) { 26620 if (!pendingInteractions.has(interaction)) { 26621 // Update the pending async work count for previously unscheduled interaction. 26622 interaction.__count++; 26623 } 26624 26625 pendingInteractions.add(interaction); 26626 }); 26627 } else { 26628 pendingInteractionMap.set(lane, new Set(interactions)); // Update the pending async work count for the current interactions. 26629 26630 interactions.forEach(function (interaction) { 26631 interaction.__count++; 26632 }); 26633 } 26634 26635 var subscriber = tracing.__subscriberRef.current; 26636 26637 if (subscriber !== null) { 26638 var threadID = computeThreadID(root, lane); 26639 subscriber.onWorkScheduled(interactions, threadID); 26640 } 26641 } 26642} 26643 26644function schedulePendingInteractions(root, lane) { 26645 26646 scheduleInteractions(root, lane, tracing.__interactionsRef.current); 26647} 26648 26649function startWorkOnPendingInteractions(root, lanes) { 26650 // we can accurately attribute time spent working on it, And so that cascading 26651 // work triggered during the render phase will be associated with it. 26652 26653 26654 var interactions = new Set(); 26655 root.pendingInteractionMap.forEach(function (scheduledInteractions, scheduledLane) { 26656 if (includesSomeLane(lanes, scheduledLane)) { 26657 scheduledInteractions.forEach(function (interaction) { 26658 return interactions.add(interaction); 26659 }); 26660 } 26661 }); // Store the current set of interactions on the FiberRoot for a few reasons: 26662 // We can re-use it in hot functions like performConcurrentWorkOnRoot() 26663 // without having to recalculate it. We will also use it in commitWork() to 26664 // pass to any Profiler onRender() hooks. This also provides DevTools with a 26665 // way to access it when the onCommitRoot() hook is called. 26666 26667 root.memoizedInteractions = interactions; 26668 26669 if (interactions.size > 0) { 26670 var subscriber = tracing.__subscriberRef.current; 26671 26672 if (subscriber !== null) { 26673 var threadID = computeThreadID(root, lanes); 26674 26675 try { 26676 subscriber.onWorkStarted(interactions, threadID); 26677 } catch (error) { 26678 // If the subscriber throws, rethrow it in a separate task 26679 scheduleCallback(ImmediatePriority$1, function () { 26680 throw error; 26681 }); 26682 } 26683 } 26684 } 26685} 26686 26687function finishPendingInteractions(root, committedLanes) { 26688 26689 var remainingLanesAfterCommit = root.pendingLanes; 26690 var subscriber; 26691 26692 try { 26693 subscriber = tracing.__subscriberRef.current; 26694 26695 if (subscriber !== null && root.memoizedInteractions.size > 0) { 26696 // FIXME: More than one lane can finish in a single commit. 26697 var threadID = computeThreadID(root, committedLanes); 26698 subscriber.onWorkStopped(root.memoizedInteractions, threadID); 26699 } 26700 } catch (error) { 26701 // If the subscriber throws, rethrow it in a separate task 26702 scheduleCallback(ImmediatePriority$1, function () { 26703 throw error; 26704 }); 26705 } finally { 26706 // Clear completed interactions from the pending Map. 26707 // Unless the render was suspended or cascading work was scheduled, 26708 // In which case– leave pending interactions until the subsequent render. 26709 var pendingInteractionMap = root.pendingInteractionMap; 26710 pendingInteractionMap.forEach(function (scheduledInteractions, lane) { 26711 // Only decrement the pending interaction count if we're done. 26712 // If there's still work at the current priority, 26713 // That indicates that we are waiting for suspense data. 26714 if (!includesSomeLane(remainingLanesAfterCommit, lane)) { 26715 pendingInteractionMap.delete(lane); 26716 scheduledInteractions.forEach(function (interaction) { 26717 interaction.__count--; 26718 26719 if (subscriber !== null && interaction.__count === 0) { 26720 try { 26721 subscriber.onInteractionScheduledWorkCompleted(interaction); 26722 } catch (error) { 26723 // If the subscriber throws, rethrow it in a separate task 26724 scheduleCallback(ImmediatePriority$1, function () { 26725 throw error; 26726 }); 26727 } 26728 } 26729 }); 26730 } 26731 }); 26732 } 26733} // `act` testing API 26734 26735function shouldForceFlushFallbacksInDEV() { 26736 // Never force flush in production. This function should get stripped out. 26737 return actingUpdatesScopeDepth > 0; 26738} 26739// so we can tell if any async act() calls try to run in parallel. 26740 26741 26742var actingUpdatesScopeDepth = 0; 26743 26744function detachFiberAfterEffects(fiber) { 26745 fiber.sibling = null; 26746 fiber.stateNode = null; 26747} 26748 26749var resolveFamily = null; // $FlowFixMe Flow gets confused by a WeakSet feature check below. 26750 26751var failedBoundaries = null; 26752var setRefreshHandler = function (handler) { 26753 { 26754 resolveFamily = handler; 26755 } 26756}; 26757function resolveFunctionForHotReloading(type) { 26758 { 26759 if (resolveFamily === null) { 26760 // Hot reloading is disabled. 26761 return type; 26762 } 26763 26764 var family = resolveFamily(type); 26765 26766 if (family === undefined) { 26767 return type; 26768 } // Use the latest known implementation. 26769 26770 26771 return family.current; 26772 } 26773} 26774function resolveClassForHotReloading(type) { 26775 // No implementation differences. 26776 return resolveFunctionForHotReloading(type); 26777} 26778function resolveForwardRefForHotReloading(type) { 26779 { 26780 if (resolveFamily === null) { 26781 // Hot reloading is disabled. 26782 return type; 26783 } 26784 26785 var family = resolveFamily(type); 26786 26787 if (family === undefined) { 26788 // Check if we're dealing with a real forwardRef. Don't want to crash early. 26789 if (type !== null && type !== undefined && typeof type.render === 'function') { 26790 // ForwardRef is special because its resolved .type is an object, 26791 // but it's possible that we only have its inner render function in the map. 26792 // If that inner render function is different, we'll build a new forwardRef type. 26793 var currentRender = resolveFunctionForHotReloading(type.render); 26794 26795 if (type.render !== currentRender) { 26796 var syntheticType = { 26797 $$typeof: REACT_FORWARD_REF_TYPE, 26798 render: currentRender 26799 }; 26800 26801 if (type.displayName !== undefined) { 26802 syntheticType.displayName = type.displayName; 26803 } 26804 26805 return syntheticType; 26806 } 26807 } 26808 26809 return type; 26810 } // Use the latest known implementation. 26811 26812 26813 return family.current; 26814 } 26815} 26816function isCompatibleFamilyForHotReloading(fiber, element) { 26817 { 26818 if (resolveFamily === null) { 26819 // Hot reloading is disabled. 26820 return false; 26821 } 26822 26823 var prevType = fiber.elementType; 26824 var nextType = element.type; // If we got here, we know types aren't === equal. 26825 26826 var needsCompareFamilies = false; 26827 var $$typeofNextType = typeof nextType === 'object' && nextType !== null ? nextType.$$typeof : null; 26828 26829 switch (fiber.tag) { 26830 case ClassComponent: 26831 { 26832 if (typeof nextType === 'function') { 26833 needsCompareFamilies = true; 26834 } 26835 26836 break; 26837 } 26838 26839 case FunctionComponent: 26840 { 26841 if (typeof nextType === 'function') { 26842 needsCompareFamilies = true; 26843 } else if ($$typeofNextType === REACT_LAZY_TYPE) { 26844 // We don't know the inner type yet. 26845 // We're going to assume that the lazy inner type is stable, 26846 // and so it is sufficient to avoid reconciling it away. 26847 // We're not going to unwrap or actually use the new lazy type. 26848 needsCompareFamilies = true; 26849 } 26850 26851 break; 26852 } 26853 26854 case ForwardRef: 26855 { 26856 if ($$typeofNextType === REACT_FORWARD_REF_TYPE) { 26857 needsCompareFamilies = true; 26858 } else if ($$typeofNextType === REACT_LAZY_TYPE) { 26859 needsCompareFamilies = true; 26860 } 26861 26862 break; 26863 } 26864 26865 case MemoComponent: 26866 case SimpleMemoComponent: 26867 { 26868 if ($$typeofNextType === REACT_MEMO_TYPE) { 26869 // TODO: if it was but can no longer be simple, 26870 // we shouldn't set this. 26871 needsCompareFamilies = true; 26872 } else if ($$typeofNextType === REACT_LAZY_TYPE) { 26873 needsCompareFamilies = true; 26874 } 26875 26876 break; 26877 } 26878 26879 default: 26880 return false; 26881 } // Check if both types have a family and it's the same one. 26882 26883 26884 if (needsCompareFamilies) { 26885 // Note: memo() and forwardRef() we'll compare outer rather than inner type. 26886 // This means both of them need to be registered to preserve state. 26887 // If we unwrapped and compared the inner types for wrappers instead, 26888 // then we would risk falsely saying two separate memo(Foo) 26889 // calls are equivalent because they wrap the same Foo function. 26890 var prevFamily = resolveFamily(prevType); 26891 26892 if (prevFamily !== undefined && prevFamily === resolveFamily(nextType)) { 26893 return true; 26894 } 26895 } 26896 26897 return false; 26898 } 26899} 26900function markFailedErrorBoundaryForHotReloading(fiber) { 26901 { 26902 if (resolveFamily === null) { 26903 // Hot reloading is disabled. 26904 return; 26905 } 26906 26907 if (typeof WeakSet !== 'function') { 26908 return; 26909 } 26910 26911 if (failedBoundaries === null) { 26912 failedBoundaries = new WeakSet(); 26913 } 26914 26915 failedBoundaries.add(fiber); 26916 } 26917} 26918var scheduleRefresh = function (root, update) { 26919 { 26920 if (resolveFamily === null) { 26921 // Hot reloading is disabled. 26922 return; 26923 } 26924 26925 var staleFamilies = update.staleFamilies, 26926 updatedFamilies = update.updatedFamilies; 26927 flushPassiveEffects(); 26928 flushSync(function () { 26929 scheduleFibersWithFamiliesRecursively(root.current, updatedFamilies, staleFamilies); 26930 }); 26931 } 26932}; 26933var scheduleRoot = function (root, element) { 26934 { 26935 if (root.context !== emptyContextObject) { 26936 // Super edge case: root has a legacy _renderSubtree context 26937 // but we don't know the parentComponent so we can't pass it. 26938 // Just ignore. We'll delete this with _renderSubtree code path later. 26939 return; 26940 } 26941 26942 flushPassiveEffects(); 26943 flushSync(function () { 26944 updateContainer(element, root, null, null); 26945 }); 26946 } 26947}; 26948 26949function scheduleFibersWithFamiliesRecursively(fiber, updatedFamilies, staleFamilies) { 26950 { 26951 var alternate = fiber.alternate, 26952 child = fiber.child, 26953 sibling = fiber.sibling, 26954 tag = fiber.tag, 26955 type = fiber.type; 26956 var candidateType = null; 26957 26958 switch (tag) { 26959 case FunctionComponent: 26960 case SimpleMemoComponent: 26961 case ClassComponent: 26962 candidateType = type; 26963 break; 26964 26965 case ForwardRef: 26966 candidateType = type.render; 26967 break; 26968 } 26969 26970 if (resolveFamily === null) { 26971 throw new Error('Expected resolveFamily to be set during hot reload.'); 26972 } 26973 26974 var needsRender = false; 26975 var needsRemount = false; 26976 26977 if (candidateType !== null) { 26978 var family = resolveFamily(candidateType); 26979 26980 if (family !== undefined) { 26981 if (staleFamilies.has(family)) { 26982 needsRemount = true; 26983 } else if (updatedFamilies.has(family)) { 26984 if (tag === ClassComponent) { 26985 needsRemount = true; 26986 } else { 26987 needsRender = true; 26988 } 26989 } 26990 } 26991 } 26992 26993 if (failedBoundaries !== null) { 26994 if (failedBoundaries.has(fiber) || alternate !== null && failedBoundaries.has(alternate)) { 26995 needsRemount = true; 26996 } 26997 } 26998 26999 if (needsRemount) { 27000 fiber._debugNeedsRemount = true; 27001 } 27002 27003 if (needsRemount || needsRender) { 27004 scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp); 27005 } 27006 27007 if (child !== null && !needsRemount) { 27008 scheduleFibersWithFamiliesRecursively(child, updatedFamilies, staleFamilies); 27009 } 27010 27011 if (sibling !== null) { 27012 scheduleFibersWithFamiliesRecursively(sibling, updatedFamilies, staleFamilies); 27013 } 27014 } 27015} 27016 27017var findHostInstancesForRefresh = function (root, families) { 27018 { 27019 var hostInstances = new Set(); 27020 var types = new Set(families.map(function (family) { 27021 return family.current; 27022 })); 27023 findHostInstancesForMatchingFibersRecursively(root.current, types, hostInstances); 27024 return hostInstances; 27025 } 27026}; 27027 27028function findHostInstancesForMatchingFibersRecursively(fiber, types, hostInstances) { 27029 { 27030 var child = fiber.child, 27031 sibling = fiber.sibling, 27032 tag = fiber.tag, 27033 type = fiber.type; 27034 var candidateType = null; 27035 27036 switch (tag) { 27037 case FunctionComponent: 27038 case SimpleMemoComponent: 27039 case ClassComponent: 27040 candidateType = type; 27041 break; 27042 27043 case ForwardRef: 27044 candidateType = type.render; 27045 break; 27046 } 27047 27048 var didMatch = false; 27049 27050 if (candidateType !== null) { 27051 if (types.has(candidateType)) { 27052 didMatch = true; 27053 } 27054 } 27055 27056 if (didMatch) { 27057 // We have a match. This only drills down to the closest host components. 27058 // There's no need to search deeper because for the purpose of giving 27059 // visual feedback, "flashing" outermost parent rectangles is sufficient. 27060 findHostInstancesForFiberShallowly(fiber, hostInstances); 27061 } else { 27062 // If there's no match, maybe there will be one further down in the child tree. 27063 if (child !== null) { 27064 findHostInstancesForMatchingFibersRecursively(child, types, hostInstances); 27065 } 27066 } 27067 27068 if (sibling !== null) { 27069 findHostInstancesForMatchingFibersRecursively(sibling, types, hostInstances); 27070 } 27071 } 27072} 27073 27074function findHostInstancesForFiberShallowly(fiber, hostInstances) { 27075 { 27076 var foundHostInstances = findChildHostInstancesForFiberShallowly(fiber, hostInstances); 27077 27078 if (foundHostInstances) { 27079 return; 27080 } // If we didn't find any host children, fallback to closest host parent. 27081 27082 27083 var node = fiber; 27084 27085 while (true) { 27086 switch (node.tag) { 27087 case HostComponent: 27088 hostInstances.add(node.stateNode); 27089 return; 27090 27091 case HostPortal: 27092 hostInstances.add(node.stateNode.containerInfo); 27093 return; 27094 27095 case HostRoot: 27096 hostInstances.add(node.stateNode.containerInfo); 27097 return; 27098 } 27099 27100 if (node.return === null) { 27101 throw new Error('Expected to reach root first.'); 27102 } 27103 27104 node = node.return; 27105 } 27106 } 27107} 27108 27109function findChildHostInstancesForFiberShallowly(fiber, hostInstances) { 27110 { 27111 var node = fiber; 27112 var foundHostInstances = false; 27113 27114 while (true) { 27115 if (node.tag === HostComponent) { 27116 // We got a match. 27117 foundHostInstances = true; 27118 hostInstances.add(node.stateNode); // There may still be more, so keep searching. 27119 } else if (node.child !== null) { 27120 node.child.return = node; 27121 node = node.child; 27122 continue; 27123 } 27124 27125 if (node === fiber) { 27126 return foundHostInstances; 27127 } 27128 27129 while (node.sibling === null) { 27130 if (node.return === null || node.return === fiber) { 27131 return foundHostInstances; 27132 } 27133 27134 node = node.return; 27135 } 27136 27137 node.sibling.return = node.return; 27138 node = node.sibling; 27139 } 27140 } 27141 27142 return false; 27143} 27144 27145var hasBadMapPolyfill; 27146 27147{ 27148 hasBadMapPolyfill = false; 27149 27150 try { 27151 var nonExtensibleObject = Object.preventExtensions({}); 27152 /* eslint-disable no-new */ 27153 27154 new Map([[nonExtensibleObject, null]]); 27155 new Set([nonExtensibleObject]); 27156 /* eslint-enable no-new */ 27157 } catch (e) { 27158 // TODO: Consider warning about bad polyfills 27159 hasBadMapPolyfill = true; 27160 } 27161} 27162 27163var debugCounter = 1; 27164 27165function FiberNode(tag, pendingProps, key, mode) { 27166 // Instance 27167 this.tag = tag; 27168 this.key = key; 27169 this.elementType = null; 27170 this.type = null; 27171 this.stateNode = null; // Fiber 27172 27173 this.return = null; 27174 this.child = null; 27175 this.sibling = null; 27176 this.index = 0; 27177 this.ref = null; 27178 this.pendingProps = pendingProps; 27179 this.memoizedProps = null; 27180 this.updateQueue = null; 27181 this.memoizedState = null; 27182 this.dependencies = null; 27183 this.mode = mode; // Effects 27184 27185 this.flags = NoFlags; 27186 this.nextEffect = null; 27187 this.firstEffect = null; 27188 this.lastEffect = null; 27189 this.lanes = NoLanes; 27190 this.childLanes = NoLanes; 27191 this.alternate = null; 27192 27193 { 27194 // Note: The following is done to avoid a v8 performance cliff. 27195 // 27196 // Initializing the fields below to smis and later updating them with 27197 // double values will cause Fibers to end up having separate shapes. 27198 // This behavior/bug has something to do with Object.preventExtension(). 27199 // Fortunately this only impacts DEV builds. 27200 // Unfortunately it makes React unusably slow for some applications. 27201 // To work around this, initialize the fields below with doubles. 27202 // 27203 // Learn more about this here: 27204 // https://github.com/facebook/react/issues/14365 27205 // https://bugs.chromium.org/p/v8/issues/detail?id=8538 27206 this.actualDuration = Number.NaN; 27207 this.actualStartTime = Number.NaN; 27208 this.selfBaseDuration = Number.NaN; 27209 this.treeBaseDuration = Number.NaN; // It's okay to replace the initial doubles with smis after initialization. 27210 // This won't trigger the performance cliff mentioned above, 27211 // and it simplifies other profiler code (including DevTools). 27212 27213 this.actualDuration = 0; 27214 this.actualStartTime = -1; 27215 this.selfBaseDuration = 0; 27216 this.treeBaseDuration = 0; 27217 } 27218 27219 { 27220 // This isn't directly used but is handy for debugging internals: 27221 this._debugID = debugCounter++; 27222 this._debugSource = null; 27223 this._debugOwner = null; 27224 this._debugNeedsRemount = false; 27225 this._debugHookTypes = null; 27226 27227 if (!hasBadMapPolyfill && typeof Object.preventExtensions === 'function') { 27228 Object.preventExtensions(this); 27229 } 27230 } 27231} // This is a constructor function, rather than a POJO constructor, still 27232// please ensure we do the following: 27233// 1) Nobody should add any instance methods on this. Instance methods can be 27234// more difficult to predict when they get optimized and they are almost 27235// never inlined properly in static compilers. 27236// 2) Nobody should rely on `instanceof Fiber` for type testing. We should 27237// always know when it is a fiber. 27238// 3) We might want to experiment with using numeric keys since they are easier 27239// to optimize in a non-JIT environment. 27240// 4) We can easily go from a constructor to a createFiber object literal if that 27241// is faster. 27242// 5) It should be easy to port this to a C struct and keep a C implementation 27243// compatible. 27244 27245 27246var createFiber = function (tag, pendingProps, key, mode) { 27247 // $FlowFixMe: the shapes are exact here but Flow doesn't like constructors 27248 return new FiberNode(tag, pendingProps, key, mode); 27249}; 27250 27251function shouldConstruct$1(Component) { 27252 var prototype = Component.prototype; 27253 return !!(prototype && prototype.isReactComponent); 27254} 27255 27256function isSimpleFunctionComponent(type) { 27257 return typeof type === 'function' && !shouldConstruct$1(type) && type.defaultProps === undefined; 27258} 27259function resolveLazyComponentTag(Component) { 27260 if (typeof Component === 'function') { 27261 return shouldConstruct$1(Component) ? ClassComponent : FunctionComponent; 27262 } else if (Component !== undefined && Component !== null) { 27263 var $$typeof = Component.$$typeof; 27264 27265 if ($$typeof === REACT_FORWARD_REF_TYPE) { 27266 return ForwardRef; 27267 } 27268 27269 if ($$typeof === REACT_MEMO_TYPE) { 27270 return MemoComponent; 27271 } 27272 } 27273 27274 return IndeterminateComponent; 27275} // This is used to create an alternate fiber to do work on. 27276 27277function createWorkInProgress(current, pendingProps) { 27278 var workInProgress = current.alternate; 27279 27280 if (workInProgress === null) { 27281 // We use a double buffering pooling technique because we know that we'll 27282 // only ever need at most two versions of a tree. We pool the "other" unused 27283 // node that we're free to reuse. This is lazily created to avoid allocating 27284 // extra objects for things that are never updated. It also allow us to 27285 // reclaim the extra memory if needed. 27286 workInProgress = createFiber(current.tag, pendingProps, current.key, current.mode); 27287 workInProgress.elementType = current.elementType; 27288 workInProgress.type = current.type; 27289 workInProgress.stateNode = current.stateNode; 27290 27291 { 27292 // DEV-only fields 27293 workInProgress._debugID = current._debugID; 27294 workInProgress._debugSource = current._debugSource; 27295 workInProgress._debugOwner = current._debugOwner; 27296 workInProgress._debugHookTypes = current._debugHookTypes; 27297 } 27298 27299 workInProgress.alternate = current; 27300 current.alternate = workInProgress; 27301 } else { 27302 workInProgress.pendingProps = pendingProps; // Needed because Blocks store data on type. 27303 27304 workInProgress.type = current.type; // We already have an alternate. 27305 // Reset the effect tag. 27306 27307 workInProgress.flags = NoFlags; // The effect list is no longer valid. 27308 27309 workInProgress.nextEffect = null; 27310 workInProgress.firstEffect = null; 27311 workInProgress.lastEffect = null; 27312 27313 { 27314 // We intentionally reset, rather than copy, actualDuration & actualStartTime. 27315 // This prevents time from endlessly accumulating in new commits. 27316 // This has the downside of resetting values for different priority renders, 27317 // But works for yielding (the common case) and should support resuming. 27318 workInProgress.actualDuration = 0; 27319 workInProgress.actualStartTime = -1; 27320 } 27321 } 27322 27323 workInProgress.childLanes = current.childLanes; 27324 workInProgress.lanes = current.lanes; 27325 workInProgress.child = current.child; 27326 workInProgress.memoizedProps = current.memoizedProps; 27327 workInProgress.memoizedState = current.memoizedState; 27328 workInProgress.updateQueue = current.updateQueue; // Clone the dependencies object. This is mutated during the render phase, so 27329 // it cannot be shared with the current fiber. 27330 27331 var currentDependencies = current.dependencies; 27332 workInProgress.dependencies = currentDependencies === null ? null : { 27333 lanes: currentDependencies.lanes, 27334 firstContext: currentDependencies.firstContext 27335 }; // These will be overridden during the parent's reconciliation 27336 27337 workInProgress.sibling = current.sibling; 27338 workInProgress.index = current.index; 27339 workInProgress.ref = current.ref; 27340 27341 { 27342 workInProgress.selfBaseDuration = current.selfBaseDuration; 27343 workInProgress.treeBaseDuration = current.treeBaseDuration; 27344 } 27345 27346 { 27347 workInProgress._debugNeedsRemount = current._debugNeedsRemount; 27348 27349 switch (workInProgress.tag) { 27350 case IndeterminateComponent: 27351 case FunctionComponent: 27352 case SimpleMemoComponent: 27353 workInProgress.type = resolveFunctionForHotReloading(current.type); 27354 break; 27355 27356 case ClassComponent: 27357 workInProgress.type = resolveClassForHotReloading(current.type); 27358 break; 27359 27360 case ForwardRef: 27361 workInProgress.type = resolveForwardRefForHotReloading(current.type); 27362 break; 27363 } 27364 } 27365 27366 return workInProgress; 27367} // Used to reuse a Fiber for a second pass. 27368 27369function resetWorkInProgress(workInProgress, renderLanes) { 27370 // This resets the Fiber to what createFiber or createWorkInProgress would 27371 // have set the values to before during the first pass. Ideally this wouldn't 27372 // be necessary but unfortunately many code paths reads from the workInProgress 27373 // when they should be reading from current and writing to workInProgress. 27374 // We assume pendingProps, index, key, ref, return are still untouched to 27375 // avoid doing another reconciliation. 27376 // Reset the effect tag but keep any Placement tags, since that's something 27377 // that child fiber is setting, not the reconciliation. 27378 workInProgress.flags &= Placement; // The effect list is no longer valid. 27379 27380 workInProgress.nextEffect = null; 27381 workInProgress.firstEffect = null; 27382 workInProgress.lastEffect = null; 27383 var current = workInProgress.alternate; 27384 27385 if (current === null) { 27386 // Reset to createFiber's initial values. 27387 workInProgress.childLanes = NoLanes; 27388 workInProgress.lanes = renderLanes; 27389 workInProgress.child = null; 27390 workInProgress.memoizedProps = null; 27391 workInProgress.memoizedState = null; 27392 workInProgress.updateQueue = null; 27393 workInProgress.dependencies = null; 27394 workInProgress.stateNode = null; 27395 27396 { 27397 // Note: We don't reset the actualTime counts. It's useful to accumulate 27398 // actual time across multiple render passes. 27399 workInProgress.selfBaseDuration = 0; 27400 workInProgress.treeBaseDuration = 0; 27401 } 27402 } else { 27403 // Reset to the cloned values that createWorkInProgress would've. 27404 workInProgress.childLanes = current.childLanes; 27405 workInProgress.lanes = current.lanes; 27406 workInProgress.child = current.child; 27407 workInProgress.memoizedProps = current.memoizedProps; 27408 workInProgress.memoizedState = current.memoizedState; 27409 workInProgress.updateQueue = current.updateQueue; // Needed because Blocks store data on type. 27410 27411 workInProgress.type = current.type; // Clone the dependencies object. This is mutated during the render phase, so 27412 // it cannot be shared with the current fiber. 27413 27414 var currentDependencies = current.dependencies; 27415 workInProgress.dependencies = currentDependencies === null ? null : { 27416 lanes: currentDependencies.lanes, 27417 firstContext: currentDependencies.firstContext 27418 }; 27419 27420 { 27421 // Note: We don't reset the actualTime counts. It's useful to accumulate 27422 // actual time across multiple render passes. 27423 workInProgress.selfBaseDuration = current.selfBaseDuration; 27424 workInProgress.treeBaseDuration = current.treeBaseDuration; 27425 } 27426 } 27427 27428 return workInProgress; 27429} 27430function createHostRootFiber(tag) { 27431 var mode; 27432 27433 if (tag === ConcurrentRoot) { 27434 mode = ConcurrentMode | BlockingMode | StrictMode; 27435 } else if (tag === BlockingRoot) { 27436 mode = BlockingMode | StrictMode; 27437 } else { 27438 mode = NoMode; 27439 } 27440 27441 if ( isDevToolsPresent) { 27442 // Always collect profile timings when DevTools are present. 27443 // This enables DevTools to start capturing timing at any point– 27444 // Without some nodes in the tree having empty base times. 27445 mode |= ProfileMode; 27446 } 27447 27448 return createFiber(HostRoot, null, null, mode); 27449} 27450function createFiberFromTypeAndProps(type, // React$ElementType 27451key, pendingProps, owner, mode, lanes) { 27452 var fiberTag = IndeterminateComponent; // The resolved type is set if we know what the final type will be. I.e. it's not lazy. 27453 27454 var resolvedType = type; 27455 27456 if (typeof type === 'function') { 27457 if (shouldConstruct$1(type)) { 27458 fiberTag = ClassComponent; 27459 27460 { 27461 resolvedType = resolveClassForHotReloading(resolvedType); 27462 } 27463 } else { 27464 { 27465 resolvedType = resolveFunctionForHotReloading(resolvedType); 27466 } 27467 } 27468 } else if (typeof type === 'string') { 27469 fiberTag = HostComponent; 27470 } else { 27471 getTag: switch (type) { 27472 case REACT_FRAGMENT_TYPE: 27473 return createFiberFromFragment(pendingProps.children, mode, lanes, key); 27474 27475 case REACT_DEBUG_TRACING_MODE_TYPE: 27476 fiberTag = Mode; 27477 mode |= DebugTracingMode; 27478 break; 27479 27480 case REACT_STRICT_MODE_TYPE: 27481 fiberTag = Mode; 27482 mode |= StrictMode; 27483 break; 27484 27485 case REACT_PROFILER_TYPE: 27486 return createFiberFromProfiler(pendingProps, mode, lanes, key); 27487 27488 case REACT_SUSPENSE_TYPE: 27489 return createFiberFromSuspense(pendingProps, mode, lanes, key); 27490 27491 case REACT_SUSPENSE_LIST_TYPE: 27492 return createFiberFromSuspenseList(pendingProps, mode, lanes, key); 27493 27494 case REACT_OFFSCREEN_TYPE: 27495 return createFiberFromOffscreen(pendingProps, mode, lanes, key); 27496 27497 case REACT_LEGACY_HIDDEN_TYPE: 27498 return createFiberFromLegacyHidden(pendingProps, mode, lanes, key); 27499 27500 case REACT_SCOPE_TYPE: 27501 27502 // eslint-disable-next-line no-fallthrough 27503 27504 default: 27505 { 27506 if (typeof type === 'object' && type !== null) { 27507 switch (type.$$typeof) { 27508 case REACT_PROVIDER_TYPE: 27509 fiberTag = ContextProvider; 27510 break getTag; 27511 27512 case REACT_CONTEXT_TYPE: 27513 // This is a consumer 27514 fiberTag = ContextConsumer; 27515 break getTag; 27516 27517 case REACT_FORWARD_REF_TYPE: 27518 fiberTag = ForwardRef; 27519 27520 { 27521 resolvedType = resolveForwardRefForHotReloading(resolvedType); 27522 } 27523 27524 break getTag; 27525 27526 case REACT_MEMO_TYPE: 27527 fiberTag = MemoComponent; 27528 break getTag; 27529 27530 case REACT_LAZY_TYPE: 27531 fiberTag = LazyComponent; 27532 resolvedType = null; 27533 break getTag; 27534 27535 case REACT_BLOCK_TYPE: 27536 fiberTag = Block; 27537 break getTag; 27538 } 27539 } 27540 27541 var info = ''; 27542 27543 { 27544 if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) { 27545 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.'; 27546 } 27547 27548 var ownerName = owner ? getComponentName(owner.type) : null; 27549 27550 if (ownerName) { 27551 info += '\n\nCheck the render method of `' + ownerName + '`.'; 27552 } 27553 } 27554 27555 { 27556 { 27557 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 ); 27558 } 27559 } 27560 } 27561 } 27562 } 27563 27564 var fiber = createFiber(fiberTag, pendingProps, key, mode); 27565 fiber.elementType = type; 27566 fiber.type = resolvedType; 27567 fiber.lanes = lanes; 27568 27569 { 27570 fiber._debugOwner = owner; 27571 } 27572 27573 return fiber; 27574} 27575function createFiberFromElement(element, mode, lanes) { 27576 var owner = null; 27577 27578 { 27579 owner = element._owner; 27580 } 27581 27582 var type = element.type; 27583 var key = element.key; 27584 var pendingProps = element.props; 27585 var fiber = createFiberFromTypeAndProps(type, key, pendingProps, owner, mode, lanes); 27586 27587 { 27588 fiber._debugSource = element._source; 27589 fiber._debugOwner = element._owner; 27590 } 27591 27592 return fiber; 27593} 27594function createFiberFromFragment(elements, mode, lanes, key) { 27595 var fiber = createFiber(Fragment, elements, key, mode); 27596 fiber.lanes = lanes; 27597 return fiber; 27598} 27599 27600function createFiberFromProfiler(pendingProps, mode, lanes, key) { 27601 { 27602 if (typeof pendingProps.id !== 'string') { 27603 error('Profiler must specify an "id" as a prop'); 27604 } 27605 } 27606 27607 var fiber = createFiber(Profiler, pendingProps, key, mode | ProfileMode); // TODO: The Profiler fiber shouldn't have a type. It has a tag. 27608 27609 fiber.elementType = REACT_PROFILER_TYPE; 27610 fiber.type = REACT_PROFILER_TYPE; 27611 fiber.lanes = lanes; 27612 27613 { 27614 fiber.stateNode = { 27615 effectDuration: 0, 27616 passiveEffectDuration: 0 27617 }; 27618 } 27619 27620 return fiber; 27621} 27622 27623function createFiberFromSuspense(pendingProps, mode, lanes, key) { 27624 var fiber = createFiber(SuspenseComponent, pendingProps, key, mode); // TODO: The SuspenseComponent fiber shouldn't have a type. It has a tag. 27625 // This needs to be fixed in getComponentName so that it relies on the tag 27626 // instead. 27627 27628 fiber.type = REACT_SUSPENSE_TYPE; 27629 fiber.elementType = REACT_SUSPENSE_TYPE; 27630 fiber.lanes = lanes; 27631 return fiber; 27632} 27633function createFiberFromSuspenseList(pendingProps, mode, lanes, key) { 27634 var fiber = createFiber(SuspenseListComponent, pendingProps, key, mode); 27635 27636 { 27637 // TODO: The SuspenseListComponent fiber shouldn't have a type. It has a tag. 27638 // This needs to be fixed in getComponentName so that it relies on the tag 27639 // instead. 27640 fiber.type = REACT_SUSPENSE_LIST_TYPE; 27641 } 27642 27643 fiber.elementType = REACT_SUSPENSE_LIST_TYPE; 27644 fiber.lanes = lanes; 27645 return fiber; 27646} 27647function createFiberFromOffscreen(pendingProps, mode, lanes, key) { 27648 var fiber = createFiber(OffscreenComponent, pendingProps, key, mode); // TODO: The OffscreenComponent fiber shouldn't have a type. It has a tag. 27649 // This needs to be fixed in getComponentName so that it relies on the tag 27650 // instead. 27651 27652 { 27653 fiber.type = REACT_OFFSCREEN_TYPE; 27654 } 27655 27656 fiber.elementType = REACT_OFFSCREEN_TYPE; 27657 fiber.lanes = lanes; 27658 return fiber; 27659} 27660function createFiberFromLegacyHidden(pendingProps, mode, lanes, key) { 27661 var fiber = createFiber(LegacyHiddenComponent, pendingProps, key, mode); // TODO: The LegacyHidden fiber shouldn't have a type. It has a tag. 27662 // This needs to be fixed in getComponentName so that it relies on the tag 27663 // instead. 27664 27665 { 27666 fiber.type = REACT_LEGACY_HIDDEN_TYPE; 27667 } 27668 27669 fiber.elementType = REACT_LEGACY_HIDDEN_TYPE; 27670 fiber.lanes = lanes; 27671 return fiber; 27672} 27673function createFiberFromText(content, mode, lanes) { 27674 var fiber = createFiber(HostText, content, null, mode); 27675 fiber.lanes = lanes; 27676 return fiber; 27677} 27678function createFiberFromHostInstanceForDeletion() { 27679 var fiber = createFiber(HostComponent, null, null, NoMode); // TODO: These should not need a type. 27680 27681 fiber.elementType = 'DELETED'; 27682 fiber.type = 'DELETED'; 27683 return fiber; 27684} 27685function createFiberFromPortal(portal, mode, lanes) { 27686 var pendingProps = portal.children !== null ? portal.children : []; 27687 var fiber = createFiber(HostPortal, pendingProps, portal.key, mode); 27688 fiber.lanes = lanes; 27689 fiber.stateNode = { 27690 containerInfo: portal.containerInfo, 27691 pendingChildren: null, 27692 // Used by persistent updates 27693 implementation: portal.implementation 27694 }; 27695 return fiber; 27696} // Used for stashing WIP properties to replay failed work in DEV. 27697 27698function assignFiberPropertiesInDEV(target, source) { 27699 if (target === null) { 27700 // This Fiber's initial properties will always be overwritten. 27701 // We only use a Fiber to ensure the same hidden class so DEV isn't slow. 27702 target = createFiber(IndeterminateComponent, null, null, NoMode); 27703 } // This is intentionally written as a list of all properties. 27704 // We tried to use Object.assign() instead but this is called in 27705 // the hottest path, and Object.assign() was too slow: 27706 // https://github.com/facebook/react/issues/12502 27707 // This code is DEV-only so size is not a concern. 27708 27709 27710 target.tag = source.tag; 27711 target.key = source.key; 27712 target.elementType = source.elementType; 27713 target.type = source.type; 27714 target.stateNode = source.stateNode; 27715 target.return = source.return; 27716 target.child = source.child; 27717 target.sibling = source.sibling; 27718 target.index = source.index; 27719 target.ref = source.ref; 27720 target.pendingProps = source.pendingProps; 27721 target.memoizedProps = source.memoizedProps; 27722 target.updateQueue = source.updateQueue; 27723 target.memoizedState = source.memoizedState; 27724 target.dependencies = source.dependencies; 27725 target.mode = source.mode; 27726 target.flags = source.flags; 27727 target.nextEffect = source.nextEffect; 27728 target.firstEffect = source.firstEffect; 27729 target.lastEffect = source.lastEffect; 27730 target.lanes = source.lanes; 27731 target.childLanes = source.childLanes; 27732 target.alternate = source.alternate; 27733 27734 { 27735 target.actualDuration = source.actualDuration; 27736 target.actualStartTime = source.actualStartTime; 27737 target.selfBaseDuration = source.selfBaseDuration; 27738 target.treeBaseDuration = source.treeBaseDuration; 27739 } 27740 27741 target._debugID = source._debugID; 27742 target._debugSource = source._debugSource; 27743 target._debugOwner = source._debugOwner; 27744 target._debugNeedsRemount = source._debugNeedsRemount; 27745 target._debugHookTypes = source._debugHookTypes; 27746 return target; 27747} 27748 27749function FiberRootNode(containerInfo, tag, hydrate) { 27750 this.tag = tag; 27751 this.containerInfo = containerInfo; 27752 this.pendingChildren = null; 27753 this.current = null; 27754 this.pingCache = null; 27755 this.finishedWork = null; 27756 this.timeoutHandle = noTimeout; 27757 this.context = null; 27758 this.pendingContext = null; 27759 this.hydrate = hydrate; 27760 this.callbackNode = null; 27761 this.callbackPriority = NoLanePriority; 27762 this.eventTimes = createLaneMap(NoLanes); 27763 this.expirationTimes = createLaneMap(NoTimestamp); 27764 this.pendingLanes = NoLanes; 27765 this.suspendedLanes = NoLanes; 27766 this.pingedLanes = NoLanes; 27767 this.expiredLanes = NoLanes; 27768 this.mutableReadLanes = NoLanes; 27769 this.finishedLanes = NoLanes; 27770 this.entangledLanes = NoLanes; 27771 this.entanglements = createLaneMap(NoLanes); 27772 27773 { 27774 this.mutableSourceEagerHydrationData = null; 27775 } 27776 27777 { 27778 this.interactionThreadID = tracing.unstable_getThreadID(); 27779 this.memoizedInteractions = new Set(); 27780 this.pendingInteractionMap = new Map(); 27781 } 27782 27783 { 27784 switch (tag) { 27785 case BlockingRoot: 27786 this._debugRootType = 'createBlockingRoot()'; 27787 break; 27788 27789 case ConcurrentRoot: 27790 this._debugRootType = 'createRoot()'; 27791 break; 27792 27793 case LegacyRoot: 27794 this._debugRootType = 'createLegacyRoot()'; 27795 break; 27796 } 27797 } 27798} 27799 27800function createFiberRoot(containerInfo, tag, hydrate, hydrationCallbacks) { 27801 var root = new FiberRootNode(containerInfo, tag, hydrate); 27802 // stateNode is any. 27803 27804 27805 var uninitializedFiber = createHostRootFiber(tag); 27806 root.current = uninitializedFiber; 27807 uninitializedFiber.stateNode = root; 27808 initializeUpdateQueue(uninitializedFiber); 27809 return root; 27810} 27811 27812// This ensures that the version used for server rendering matches the one 27813// that is eventually read during hydration. 27814// If they don't match there's a potential tear and a full deopt render is required. 27815 27816function registerMutableSourceForHydration(root, mutableSource) { 27817 var getVersion = mutableSource._getVersion; 27818 var version = getVersion(mutableSource._source); // TODO Clear this data once all pending hydration work is finished. 27819 // Retaining it forever may interfere with GC. 27820 27821 if (root.mutableSourceEagerHydrationData == null) { 27822 root.mutableSourceEagerHydrationData = [mutableSource, version]; 27823 } else { 27824 root.mutableSourceEagerHydrationData.push(mutableSource, version); 27825 } 27826} 27827 27828function createPortal(children, containerInfo, // TODO: figure out the API for cross-renderer implementation. 27829implementation) { 27830 var key = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null; 27831 return { 27832 // This tag allow us to uniquely identify this as a React Portal 27833 $$typeof: REACT_PORTAL_TYPE, 27834 key: key == null ? null : '' + key, 27835 children: children, 27836 containerInfo: containerInfo, 27837 implementation: implementation 27838 }; 27839} 27840 27841var didWarnAboutNestedUpdates; 27842var didWarnAboutFindNodeInStrictMode; 27843 27844{ 27845 didWarnAboutNestedUpdates = false; 27846 didWarnAboutFindNodeInStrictMode = {}; 27847} 27848 27849function getContextForSubtree(parentComponent) { 27850 if (!parentComponent) { 27851 return emptyContextObject; 27852 } 27853 27854 var fiber = get(parentComponent); 27855 var parentContext = findCurrentUnmaskedContext(fiber); 27856 27857 if (fiber.tag === ClassComponent) { 27858 var Component = fiber.type; 27859 27860 if (isContextProvider(Component)) { 27861 return processChildContext(fiber, Component, parentContext); 27862 } 27863 } 27864 27865 return parentContext; 27866} 27867 27868function findHostInstanceWithWarning(component, methodName) { 27869 { 27870 var fiber = get(component); 27871 27872 if (fiber === undefined) { 27873 if (typeof component.render === 'function') { 27874 { 27875 { 27876 throw Error( "Unable to find node on an unmounted component." ); 27877 } 27878 } 27879 } else { 27880 { 27881 { 27882 throw Error( "Argument appears to not be a ReactComponent. Keys: " + Object.keys(component) ); 27883 } 27884 } 27885 } 27886 } 27887 27888 var hostFiber = findCurrentHostFiber(fiber); 27889 27890 if (hostFiber === null) { 27891 return null; 27892 } 27893 27894 if (hostFiber.mode & StrictMode) { 27895 var componentName = getComponentName(fiber.type) || 'Component'; 27896 27897 if (!didWarnAboutFindNodeInStrictMode[componentName]) { 27898 didWarnAboutFindNodeInStrictMode[componentName] = true; 27899 var previousFiber = current; 27900 27901 try { 27902 setCurrentFiber(hostFiber); 27903 27904 if (fiber.mode & StrictMode) { 27905 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); 27906 } else { 27907 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); 27908 } 27909 } finally { 27910 // Ideally this should reset to previous but this shouldn't be called in 27911 // render and there's another warning for that anyway. 27912 if (previousFiber) { 27913 setCurrentFiber(previousFiber); 27914 } else { 27915 resetCurrentFiber(); 27916 } 27917 } 27918 } 27919 } 27920 27921 return hostFiber.stateNode; 27922 } 27923} 27924 27925function createContainer(containerInfo, tag, hydrate, hydrationCallbacks) { 27926 return createFiberRoot(containerInfo, tag, hydrate); 27927} 27928function updateContainer(element, container, parentComponent, callback) { 27929 { 27930 onScheduleRoot(container, element); 27931 } 27932 27933 var current$1 = container.current; 27934 var eventTime = requestEventTime(); 27935 27936 { 27937 // $FlowExpectedError - jest isn't a global, and isn't recognized outside of tests 27938 if ('undefined' !== typeof jest) { 27939 warnIfUnmockedScheduler(current$1); 27940 warnIfNotScopedWithMatchingAct(current$1); 27941 } 27942 } 27943 27944 var lane = requestUpdateLane(current$1); 27945 27946 var context = getContextForSubtree(parentComponent); 27947 27948 if (container.context === null) { 27949 container.context = context; 27950 } else { 27951 container.pendingContext = context; 27952 } 27953 27954 { 27955 if (isRendering && current !== null && !didWarnAboutNestedUpdates) { 27956 didWarnAboutNestedUpdates = true; 27957 27958 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'); 27959 } 27960 } 27961 27962 var update = createUpdate(eventTime, lane); // Caution: React DevTools currently depends on this property 27963 // being called "element". 27964 27965 update.payload = { 27966 element: element 27967 }; 27968 callback = callback === undefined ? null : callback; 27969 27970 if (callback !== null) { 27971 { 27972 if (typeof callback !== 'function') { 27973 error('render(...): Expected the last optional `callback` argument to be a ' + 'function. Instead received: %s.', callback); 27974 } 27975 } 27976 27977 update.callback = callback; 27978 } 27979 27980 enqueueUpdate(current$1, update); 27981 scheduleUpdateOnFiber(current$1, lane, eventTime); 27982 return lane; 27983} 27984function getPublicRootInstance(container) { 27985 var containerFiber = container.current; 27986 27987 if (!containerFiber.child) { 27988 return null; 27989 } 27990 27991 switch (containerFiber.child.tag) { 27992 case HostComponent: 27993 return getPublicInstance(containerFiber.child.stateNode); 27994 27995 default: 27996 return containerFiber.child.stateNode; 27997 } 27998} 27999 28000function markRetryLaneImpl(fiber, retryLane) { 28001 var suspenseState = fiber.memoizedState; 28002 28003 if (suspenseState !== null && suspenseState.dehydrated !== null) { 28004 suspenseState.retryLane = higherPriorityLane(suspenseState.retryLane, retryLane); 28005 } 28006} // Increases the priority of thennables when they resolve within this boundary. 28007 28008 28009function markRetryLaneIfNotHydrated(fiber, retryLane) { 28010 markRetryLaneImpl(fiber, retryLane); 28011 var alternate = fiber.alternate; 28012 28013 if (alternate) { 28014 markRetryLaneImpl(alternate, retryLane); 28015 } 28016} 28017 28018function attemptUserBlockingHydration$1(fiber) { 28019 if (fiber.tag !== SuspenseComponent) { 28020 // We ignore HostRoots here because we can't increase 28021 // their priority and they should not suspend on I/O, 28022 // since you have to wrap anything that might suspend in 28023 // Suspense. 28024 return; 28025 } 28026 28027 var eventTime = requestEventTime(); 28028 var lane = InputDiscreteHydrationLane; 28029 scheduleUpdateOnFiber(fiber, lane, eventTime); 28030 markRetryLaneIfNotHydrated(fiber, lane); 28031} 28032function attemptContinuousHydration$1(fiber) { 28033 if (fiber.tag !== SuspenseComponent) { 28034 // We ignore HostRoots here because we can't increase 28035 // their priority and they should not suspend on I/O, 28036 // since you have to wrap anything that might suspend in 28037 // Suspense. 28038 return; 28039 } 28040 28041 var eventTime = requestEventTime(); 28042 var lane = SelectiveHydrationLane; 28043 scheduleUpdateOnFiber(fiber, lane, eventTime); 28044 markRetryLaneIfNotHydrated(fiber, lane); 28045} 28046function attemptHydrationAtCurrentPriority$1(fiber) { 28047 if (fiber.tag !== SuspenseComponent) { 28048 // We ignore HostRoots here because we can't increase 28049 // their priority other than synchronously flush it. 28050 return; 28051 } 28052 28053 var eventTime = requestEventTime(); 28054 var lane = requestUpdateLane(fiber); 28055 scheduleUpdateOnFiber(fiber, lane, eventTime); 28056 markRetryLaneIfNotHydrated(fiber, lane); 28057} 28058function runWithPriority$2(priority, fn) { 28059 28060 try { 28061 setCurrentUpdateLanePriority(priority); 28062 return fn(); 28063 } finally { 28064 } 28065} 28066function findHostInstanceWithNoPortals(fiber) { 28067 var hostFiber = findCurrentHostFiberWithNoPortals(fiber); 28068 28069 if (hostFiber === null) { 28070 return null; 28071 } 28072 28073 if (hostFiber.tag === FundamentalComponent) { 28074 return hostFiber.stateNode.instance; 28075 } 28076 28077 return hostFiber.stateNode; 28078} 28079 28080var shouldSuspendImpl = function (fiber) { 28081 return false; 28082}; 28083 28084function shouldSuspend(fiber) { 28085 return shouldSuspendImpl(fiber); 28086} 28087var overrideHookState = null; 28088var overrideHookStateDeletePath = null; 28089var overrideHookStateRenamePath = null; 28090var overrideProps = null; 28091var overridePropsDeletePath = null; 28092var overridePropsRenamePath = null; 28093var scheduleUpdate = null; 28094var setSuspenseHandler = null; 28095 28096{ 28097 var copyWithDeleteImpl = function (obj, path, index) { 28098 var key = path[index]; 28099 var updated = Array.isArray(obj) ? obj.slice() : _assign({}, obj); 28100 28101 if (index + 1 === path.length) { 28102 if (Array.isArray(updated)) { 28103 updated.splice(key, 1); 28104 } else { 28105 delete updated[key]; 28106 } 28107 28108 return updated; 28109 } // $FlowFixMe number or string is fine here 28110 28111 28112 updated[key] = copyWithDeleteImpl(obj[key], path, index + 1); 28113 return updated; 28114 }; 28115 28116 var copyWithDelete = function (obj, path) { 28117 return copyWithDeleteImpl(obj, path, 0); 28118 }; 28119 28120 var copyWithRenameImpl = function (obj, oldPath, newPath, index) { 28121 var oldKey = oldPath[index]; 28122 var updated = Array.isArray(obj) ? obj.slice() : _assign({}, obj); 28123 28124 if (index + 1 === oldPath.length) { 28125 var newKey = newPath[index]; // $FlowFixMe number or string is fine here 28126 28127 updated[newKey] = updated[oldKey]; 28128 28129 if (Array.isArray(updated)) { 28130 updated.splice(oldKey, 1); 28131 } else { 28132 delete updated[oldKey]; 28133 } 28134 } else { 28135 // $FlowFixMe number or string is fine here 28136 updated[oldKey] = copyWithRenameImpl( // $FlowFixMe number or string is fine here 28137 obj[oldKey], oldPath, newPath, index + 1); 28138 } 28139 28140 return updated; 28141 }; 28142 28143 var copyWithRename = function (obj, oldPath, newPath) { 28144 if (oldPath.length !== newPath.length) { 28145 warn('copyWithRename() expects paths of the same length'); 28146 28147 return; 28148 } else { 28149 for (var i = 0; i < newPath.length - 1; i++) { 28150 if (oldPath[i] !== newPath[i]) { 28151 warn('copyWithRename() expects paths to be the same except for the deepest key'); 28152 28153 return; 28154 } 28155 } 28156 } 28157 28158 return copyWithRenameImpl(obj, oldPath, newPath, 0); 28159 }; 28160 28161 var copyWithSetImpl = function (obj, path, index, value) { 28162 if (index >= path.length) { 28163 return value; 28164 } 28165 28166 var key = path[index]; 28167 var updated = Array.isArray(obj) ? obj.slice() : _assign({}, obj); // $FlowFixMe number or string is fine here 28168 28169 updated[key] = copyWithSetImpl(obj[key], path, index + 1, value); 28170 return updated; 28171 }; 28172 28173 var copyWithSet = function (obj, path, value) { 28174 return copyWithSetImpl(obj, path, 0, value); 28175 }; 28176 28177 var findHook = function (fiber, id) { 28178 // For now, the "id" of stateful hooks is just the stateful hook index. 28179 // This may change in the future with e.g. nested hooks. 28180 var currentHook = fiber.memoizedState; 28181 28182 while (currentHook !== null && id > 0) { 28183 currentHook = currentHook.next; 28184 id--; 28185 } 28186 28187 return currentHook; 28188 }; // Support DevTools editable values for useState and useReducer. 28189 28190 28191 overrideHookState = function (fiber, id, path, value) { 28192 var hook = findHook(fiber, id); 28193 28194 if (hook !== null) { 28195 var newState = copyWithSet(hook.memoizedState, path, value); 28196 hook.memoizedState = newState; 28197 hook.baseState = newState; // We aren't actually adding an update to the queue, 28198 // because there is no update we can add for useReducer hooks that won't trigger an error. 28199 // (There's no appropriate action type for DevTools overrides.) 28200 // As a result though, React will see the scheduled update as a noop and bailout. 28201 // Shallow cloning props works as a workaround for now to bypass the bailout check. 28202 28203 fiber.memoizedProps = _assign({}, fiber.memoizedProps); 28204 scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp); 28205 } 28206 }; 28207 28208 overrideHookStateDeletePath = function (fiber, id, path) { 28209 var hook = findHook(fiber, id); 28210 28211 if (hook !== null) { 28212 var newState = copyWithDelete(hook.memoizedState, path); 28213 hook.memoizedState = newState; 28214 hook.baseState = newState; // We aren't actually adding an update to the queue, 28215 // because there is no update we can add for useReducer hooks that won't trigger an error. 28216 // (There's no appropriate action type for DevTools overrides.) 28217 // As a result though, React will see the scheduled update as a noop and bailout. 28218 // Shallow cloning props works as a workaround for now to bypass the bailout check. 28219 28220 fiber.memoizedProps = _assign({}, fiber.memoizedProps); 28221 scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp); 28222 } 28223 }; 28224 28225 overrideHookStateRenamePath = function (fiber, id, oldPath, newPath) { 28226 var hook = findHook(fiber, id); 28227 28228 if (hook !== null) { 28229 var newState = copyWithRename(hook.memoizedState, oldPath, newPath); 28230 hook.memoizedState = newState; 28231 hook.baseState = newState; // We aren't actually adding an update to the queue, 28232 // because there is no update we can add for useReducer hooks that won't trigger an error. 28233 // (There's no appropriate action type for DevTools overrides.) 28234 // As a result though, React will see the scheduled update as a noop and bailout. 28235 // Shallow cloning props works as a workaround for now to bypass the bailout check. 28236 28237 fiber.memoizedProps = _assign({}, fiber.memoizedProps); 28238 scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp); 28239 } 28240 }; // Support DevTools props for function components, forwardRef, memo, host components, etc. 28241 28242 28243 overrideProps = function (fiber, path, value) { 28244 fiber.pendingProps = copyWithSet(fiber.memoizedProps, path, value); 28245 28246 if (fiber.alternate) { 28247 fiber.alternate.pendingProps = fiber.pendingProps; 28248 } 28249 28250 scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp); 28251 }; 28252 28253 overridePropsDeletePath = function (fiber, path) { 28254 fiber.pendingProps = copyWithDelete(fiber.memoizedProps, path); 28255 28256 if (fiber.alternate) { 28257 fiber.alternate.pendingProps = fiber.pendingProps; 28258 } 28259 28260 scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp); 28261 }; 28262 28263 overridePropsRenamePath = function (fiber, oldPath, newPath) { 28264 fiber.pendingProps = copyWithRename(fiber.memoizedProps, oldPath, newPath); 28265 28266 if (fiber.alternate) { 28267 fiber.alternate.pendingProps = fiber.pendingProps; 28268 } 28269 28270 scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp); 28271 }; 28272 28273 scheduleUpdate = function (fiber) { 28274 scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp); 28275 }; 28276 28277 setSuspenseHandler = function (newShouldSuspendImpl) { 28278 shouldSuspendImpl = newShouldSuspendImpl; 28279 }; 28280} 28281 28282function findHostInstanceByFiber(fiber) { 28283 var hostFiber = findCurrentHostFiber(fiber); 28284 28285 if (hostFiber === null) { 28286 return null; 28287 } 28288 28289 return hostFiber.stateNode; 28290} 28291 28292function emptyFindFiberByHostInstance(instance) { 28293 return null; 28294} 28295 28296function getCurrentFiberForDevTools() { 28297 return current; 28298} 28299 28300function injectIntoDevTools(devToolsConfig) { 28301 var findFiberByHostInstance = devToolsConfig.findFiberByHostInstance; 28302 var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher; 28303 return injectInternals({ 28304 bundleType: devToolsConfig.bundleType, 28305 version: devToolsConfig.version, 28306 rendererPackageName: devToolsConfig.rendererPackageName, 28307 rendererConfig: devToolsConfig.rendererConfig, 28308 overrideHookState: overrideHookState, 28309 overrideHookStateDeletePath: overrideHookStateDeletePath, 28310 overrideHookStateRenamePath: overrideHookStateRenamePath, 28311 overrideProps: overrideProps, 28312 overridePropsDeletePath: overridePropsDeletePath, 28313 overridePropsRenamePath: overridePropsRenamePath, 28314 setSuspenseHandler: setSuspenseHandler, 28315 scheduleUpdate: scheduleUpdate, 28316 currentDispatcherRef: ReactCurrentDispatcher, 28317 findHostInstanceByFiber: findHostInstanceByFiber, 28318 findFiberByHostInstance: findFiberByHostInstance || emptyFindFiberByHostInstance, 28319 // React Refresh 28320 findHostInstancesForRefresh: findHostInstancesForRefresh , 28321 scheduleRefresh: scheduleRefresh , 28322 scheduleRoot: scheduleRoot , 28323 setRefreshHandler: setRefreshHandler , 28324 // Enables DevTools to append owner stacks to error messages in DEV mode. 28325 getCurrentFiber: getCurrentFiberForDevTools 28326 }); 28327} 28328 28329function ReactDOMRoot(container, options) { 28330 this._internalRoot = createRootImpl(container, ConcurrentRoot, options); 28331} 28332 28333function ReactDOMBlockingRoot(container, tag, options) { 28334 this._internalRoot = createRootImpl(container, tag, options); 28335} 28336 28337ReactDOMRoot.prototype.render = ReactDOMBlockingRoot.prototype.render = function (children) { 28338 var root = this._internalRoot; 28339 28340 { 28341 if (typeof arguments[1] === 'function') { 28342 error('render(...): does not support the second callback argument. ' + 'To execute a side effect after rendering, declare it in a component body with useEffect().'); 28343 } 28344 28345 var container = root.containerInfo; 28346 28347 if (container.nodeType !== COMMENT_NODE) { 28348 var hostInstance = findHostInstanceWithNoPortals(root.current); 28349 28350 if (hostInstance) { 28351 if (hostInstance.parentNode !== container) { 28352 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."); 28353 } 28354 } 28355 } 28356 } 28357 28358 updateContainer(children, root, null, null); 28359}; 28360 28361ReactDOMRoot.prototype.unmount = ReactDOMBlockingRoot.prototype.unmount = function () { 28362 { 28363 if (typeof arguments[0] === 'function') { 28364 error('unmount(...): does not support a callback argument. ' + 'To execute a side effect after rendering, declare it in a component body with useEffect().'); 28365 } 28366 } 28367 28368 var root = this._internalRoot; 28369 var container = root.containerInfo; 28370 updateContainer(null, root, null, function () { 28371 unmarkContainerAsRoot(container); 28372 }); 28373}; 28374 28375function createRootImpl(container, tag, options) { 28376 // Tag is either LegacyRoot or Concurrent Root 28377 var hydrate = options != null && options.hydrate === true; 28378 var hydrationCallbacks = options != null && options.hydrationOptions || null; 28379 var mutableSources = options != null && options.hydrationOptions != null && options.hydrationOptions.mutableSources || null; 28380 var root = createContainer(container, tag, hydrate); 28381 markContainerAsRoot(root.current, container); 28382 var containerNodeType = container.nodeType; 28383 28384 { 28385 var rootContainerElement = container.nodeType === COMMENT_NODE ? container.parentNode : container; 28386 listenToAllSupportedEvents(rootContainerElement); 28387 } 28388 28389 if (mutableSources) { 28390 for (var i = 0; i < mutableSources.length; i++) { 28391 var mutableSource = mutableSources[i]; 28392 registerMutableSourceForHydration(root, mutableSource); 28393 } 28394 } 28395 28396 return root; 28397} 28398function createLegacyRoot(container, options) { 28399 return new ReactDOMBlockingRoot(container, LegacyRoot, options); 28400} 28401function isValidContainer(node) { 28402 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 ')); 28403} 28404 28405var ReactCurrentOwner$3 = ReactSharedInternals.ReactCurrentOwner; 28406var topLevelUpdateWarnings; 28407var warnedAboutHydrateAPI = false; 28408 28409{ 28410 topLevelUpdateWarnings = function (container) { 28411 if (container._reactRootContainer && container.nodeType !== COMMENT_NODE) { 28412 var hostInstance = findHostInstanceWithNoPortals(container._reactRootContainer._internalRoot.current); 28413 28414 if (hostInstance) { 28415 if (hostInstance.parentNode !== container) { 28416 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.'); 28417 } 28418 } 28419 } 28420 28421 var isRootRenderedBySomeReact = !!container._reactRootContainer; 28422 var rootEl = getReactRootElementInContainer(container); 28423 var hasNonRootReactChild = !!(rootEl && getInstanceFromNode(rootEl)); 28424 28425 if (hasNonRootReactChild && !isRootRenderedBySomeReact) { 28426 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.'); 28427 } 28428 28429 if (container.nodeType === ELEMENT_NODE && container.tagName && container.tagName.toUpperCase() === 'BODY') { 28430 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.'); 28431 } 28432 }; 28433} 28434 28435function getReactRootElementInContainer(container) { 28436 if (!container) { 28437 return null; 28438 } 28439 28440 if (container.nodeType === DOCUMENT_NODE) { 28441 return container.documentElement; 28442 } else { 28443 return container.firstChild; 28444 } 28445} 28446 28447function shouldHydrateDueToLegacyHeuristic(container) { 28448 var rootElement = getReactRootElementInContainer(container); 28449 return !!(rootElement && rootElement.nodeType === ELEMENT_NODE && rootElement.hasAttribute(ROOT_ATTRIBUTE_NAME)); 28450} 28451 28452function legacyCreateRootFromDOMContainer(container, forceHydrate) { 28453 var shouldHydrate = forceHydrate || shouldHydrateDueToLegacyHeuristic(container); // First clear any existing content. 28454 28455 if (!shouldHydrate) { 28456 var warned = false; 28457 var rootSibling; 28458 28459 while (rootSibling = container.lastChild) { 28460 { 28461 if (!warned && rootSibling.nodeType === ELEMENT_NODE && rootSibling.hasAttribute(ROOT_ATTRIBUTE_NAME)) { 28462 warned = true; 28463 28464 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.'); 28465 } 28466 } 28467 28468 container.removeChild(rootSibling); 28469 } 28470 } 28471 28472 { 28473 if (shouldHydrate && !forceHydrate && !warnedAboutHydrateAPI) { 28474 warnedAboutHydrateAPI = true; 28475 28476 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.'); 28477 } 28478 } 28479 28480 return createLegacyRoot(container, shouldHydrate ? { 28481 hydrate: true 28482 } : undefined); 28483} 28484 28485function warnOnInvalidCallback$1(callback, callerName) { 28486 { 28487 if (callback !== null && typeof callback !== 'function') { 28488 error('%s(...): Expected the last optional `callback` argument to be a ' + 'function. Instead received: %s.', callerName, callback); 28489 } 28490 } 28491} 28492 28493function legacyRenderSubtreeIntoContainer(parentComponent, children, container, forceHydrate, callback) { 28494 { 28495 topLevelUpdateWarnings(container); 28496 warnOnInvalidCallback$1(callback === undefined ? null : callback, 'render'); 28497 } // TODO: Without `any` type, Flow says "Property cannot be accessed on any 28498 // member of intersection type." Whyyyyyy. 28499 28500 28501 var root = container._reactRootContainer; 28502 var fiberRoot; 28503 28504 if (!root) { 28505 // Initial mount 28506 root = container._reactRootContainer = legacyCreateRootFromDOMContainer(container, forceHydrate); 28507 fiberRoot = root._internalRoot; 28508 28509 if (typeof callback === 'function') { 28510 var originalCallback = callback; 28511 28512 callback = function () { 28513 var instance = getPublicRootInstance(fiberRoot); 28514 originalCallback.call(instance); 28515 }; 28516 } // Initial mount should not be batched. 28517 28518 28519 unbatchedUpdates(function () { 28520 updateContainer(children, fiberRoot, parentComponent, callback); 28521 }); 28522 } else { 28523 fiberRoot = root._internalRoot; 28524 28525 if (typeof callback === 'function') { 28526 var _originalCallback = callback; 28527 28528 callback = function () { 28529 var instance = getPublicRootInstance(fiberRoot); 28530 28531 _originalCallback.call(instance); 28532 }; 28533 } // Update 28534 28535 28536 updateContainer(children, fiberRoot, parentComponent, callback); 28537 } 28538 28539 return getPublicRootInstance(fiberRoot); 28540} 28541 28542function findDOMNode(componentOrElement) { 28543 { 28544 var owner = ReactCurrentOwner$3.current; 28545 28546 if (owner !== null && owner.stateNode !== null) { 28547 var warnedAboutRefsInRender = owner.stateNode._warnedAboutRefsInRender; 28548 28549 if (!warnedAboutRefsInRender) { 28550 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'); 28551 } 28552 28553 owner.stateNode._warnedAboutRefsInRender = true; 28554 } 28555 } 28556 28557 if (componentOrElement == null) { 28558 return null; 28559 } 28560 28561 if (componentOrElement.nodeType === ELEMENT_NODE) { 28562 return componentOrElement; 28563 } 28564 28565 { 28566 return findHostInstanceWithWarning(componentOrElement, 'findDOMNode'); 28567 } 28568} 28569function hydrate(element, container, callback) { 28570 if (!isValidContainer(container)) { 28571 { 28572 throw Error( "Target container is not a DOM element." ); 28573 } 28574 } 28575 28576 { 28577 var isModernRoot = isContainerMarkedAsRoot(container) && container._reactRootContainer === undefined; 28578 28579 if (isModernRoot) { 28580 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)?'); 28581 } 28582 } // TODO: throw or warn if we couldn't hydrate? 28583 28584 28585 return legacyRenderSubtreeIntoContainer(null, element, container, true, callback); 28586} 28587function render(element, container, callback) { 28588 if (!isValidContainer(container)) { 28589 { 28590 throw Error( "Target container is not a DOM element." ); 28591 } 28592 } 28593 28594 { 28595 var isModernRoot = isContainerMarkedAsRoot(container) && container._reactRootContainer === undefined; 28596 28597 if (isModernRoot) { 28598 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)?'); 28599 } 28600 } 28601 28602 return legacyRenderSubtreeIntoContainer(null, element, container, false, callback); 28603} 28604function unstable_renderSubtreeIntoContainer(parentComponent, element, containerNode, callback) { 28605 if (!isValidContainer(containerNode)) { 28606 { 28607 throw Error( "Target container is not a DOM element." ); 28608 } 28609 } 28610 28611 if (!(parentComponent != null && has(parentComponent))) { 28612 { 28613 throw Error( "parentComponent must be a valid React Component" ); 28614 } 28615 } 28616 28617 return legacyRenderSubtreeIntoContainer(parentComponent, element, containerNode, false, callback); 28618} 28619function unmountComponentAtNode(container) { 28620 if (!isValidContainer(container)) { 28621 { 28622 throw Error( "unmountComponentAtNode(...): Target container is not a DOM element." ); 28623 } 28624 } 28625 28626 { 28627 var isModernRoot = isContainerMarkedAsRoot(container) && container._reactRootContainer === undefined; 28628 28629 if (isModernRoot) { 28630 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()?'); 28631 } 28632 } 28633 28634 if (container._reactRootContainer) { 28635 { 28636 var rootEl = getReactRootElementInContainer(container); 28637 var renderedByDifferentReact = rootEl && !getInstanceFromNode(rootEl); 28638 28639 if (renderedByDifferentReact) { 28640 error("unmountComponentAtNode(): The node you're attempting to unmount " + 'was rendered by another copy of React.'); 28641 } 28642 } // Unmount should not be batched. 28643 28644 28645 unbatchedUpdates(function () { 28646 legacyRenderSubtreeIntoContainer(null, null, container, false, function () { 28647 // $FlowFixMe This should probably use `delete container._reactRootContainer` 28648 container._reactRootContainer = null; 28649 unmarkContainerAsRoot(container); 28650 }); 28651 }); // If you call unmountComponentAtNode twice in quick succession, you'll 28652 // get `true` twice. That's probably fine? 28653 28654 return true; 28655 } else { 28656 { 28657 var _rootEl = getReactRootElementInContainer(container); 28658 28659 var hasNonRootReactChild = !!(_rootEl && getInstanceFromNode(_rootEl)); // Check if the container itself is a React root node. 28660 28661 var isContainerReactRoot = container.nodeType === ELEMENT_NODE && isValidContainer(container.parentNode) && !!container.parentNode._reactRootContainer; 28662 28663 if (hasNonRootReactChild) { 28664 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.'); 28665 } 28666 } 28667 28668 return false; 28669 } 28670} 28671 28672setAttemptUserBlockingHydration(attemptUserBlockingHydration$1); 28673setAttemptContinuousHydration(attemptContinuousHydration$1); 28674setAttemptHydrationAtCurrentPriority(attemptHydrationAtCurrentPriority$1); 28675setAttemptHydrationAtPriority(runWithPriority$2); 28676var didWarnAboutUnstableCreatePortal = false; 28677 28678{ 28679 if (typeof Map !== 'function' || // $FlowIssue Flow incorrectly thinks Map has no prototype 28680 Map.prototype == null || typeof Map.prototype.forEach !== 'function' || typeof Set !== 'function' || // $FlowIssue Flow incorrectly thinks Set has no prototype 28681 Set.prototype == null || typeof Set.prototype.clear !== 'function' || typeof Set.prototype.forEach !== 'function') { 28682 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'); 28683 } 28684} 28685 28686setRestoreImplementation(restoreControlledState$3); 28687setBatchingImplementation(batchedUpdates$1, discreteUpdates$1, flushDiscreteUpdates, batchedEventUpdates$1); 28688 28689function createPortal$1(children, container) { 28690 var key = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; 28691 28692 if (!isValidContainer(container)) { 28693 { 28694 throw Error( "Target container is not a DOM element." ); 28695 } 28696 } // TODO: pass ReactDOM portal implementation as third argument 28697 // $FlowFixMe The Flow type is opaque but there's no way to actually create it. 28698 28699 28700 return createPortal(children, container, null, key); 28701} 28702 28703function renderSubtreeIntoContainer(parentComponent, element, containerNode, callback) { 28704 28705 return unstable_renderSubtreeIntoContainer(parentComponent, element, containerNode, callback); 28706} 28707 28708function unstable_createPortal(children, container) { 28709 var key = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; 28710 28711 { 28712 if (!didWarnAboutUnstableCreatePortal) { 28713 didWarnAboutUnstableCreatePortal = true; 28714 28715 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.'); 28716 } 28717 } 28718 28719 return createPortal$1(children, container, key); 28720} 28721 28722var Internals = { 28723 // Keep in sync with ReactTestUtils.js, and ReactTestUtilsAct.js. 28724 // This is an array for better minification. 28725 Events: [getInstanceFromNode, getNodeFromInstance, getFiberCurrentPropsFromNode, enqueueStateRestore, restoreStateIfNeeded, flushPassiveEffects, // TODO: This is related to `act`, not events. Move to separate key? 28726 IsThisRendererActing] 28727}; 28728var foundDevTools = injectIntoDevTools({ 28729 findFiberByHostInstance: getClosestInstanceFromNode, 28730 bundleType: 1 , 28731 version: ReactVersion, 28732 rendererPackageName: 'react-dom' 28733}); 28734 28735{ 28736 if (!foundDevTools && canUseDOM && window.top === window.self) { 28737 // If we're in Chrome or Firefox, provide a download link if not installed. 28738 if (navigator.userAgent.indexOf('Chrome') > -1 && navigator.userAgent.indexOf('Edge') === -1 || navigator.userAgent.indexOf('Firefox') > -1) { 28739 var protocol = window.location.protocol; // Don't warn in exotic cases like chrome-extension://. 28740 28741 if (/^(https?|file):$/.test(protocol)) { 28742 // eslint-disable-next-line react-internal/no-production-logging 28743 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'); 28744 } 28745 } 28746 } 28747} 28748 28749exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = Internals; 28750exports.createPortal = createPortal$1; 28751exports.findDOMNode = findDOMNode; 28752exports.flushSync = flushSync; 28753exports.hydrate = hydrate; 28754exports.render = render; 28755exports.unmountComponentAtNode = unmountComponentAtNode; 28756exports.unstable_batchedUpdates = batchedUpdates$1; 28757exports.unstable_createPortal = unstable_createPortal; 28758exports.unstable_renderSubtreeIntoContainer = renderSubtreeIntoContainer; 28759exports.version = ReactVersion; 28760 })(); 28761} 28762 28763 28764/***/ }), 28765
vendor: 1,428 bytes, lines 28766-28809
28766/***/ "./node_modules/react-dom/index.js": 28767/*!*****************************************!*\ 28768 !*** ./node_modules/react-dom/index.js ***! 28769 \*****************************************/ 28770/***/ ((module, __unused_webpack_exports, __webpack_require__) => { 28771 28772"use strict"; 28773 28774 28775function checkDCE() { 28776 /* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */ 28777 if ( 28778 typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ === 'undefined' || 28779 typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE !== 'function' 28780 ) { 28781 return; 28782 } 28783 if (true) { 28784 // This branch is unreachable because this function is only called 28785 // in production, but the condition is true only in development. 28786 // Therefore if the branch is still here, dead code elimination wasn't 28787 // properly applied. 28788 // Don't change the message. React DevTools relies on it. Also make sure 28789 // this message doesn't occur elsewhere in this function, or it will cause 28790 // a false positive. 28791 throw new Error('^_^'); 28792 } 28793 try { 28794 // Verify that the code above has been dead code eliminated (DCE'd). 28795 __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(checkDCE); 28796 } catch (err) { 28797 // DevTools shouldn't crash React, no matter what. 28798 // We should still report in case we break this code. 28799 console.error(err); 28800 } 28801} 28802 28803if (false) {} else { 28804 module.exports = __webpack_require__(/*! ./cjs/react-dom.development.js */ "./node_modules/react-dom/cjs/react-dom.development.js"); 28805} 28806 28807 28808/***/ }), 28809
vendor: 38,787 bytes, lines 28810-30041
28810/***/ "./node_modules/react/cjs/react-jsx-runtime.development.js": 28811/*!*****************************************************************!*\ 28812 !*** ./node_modules/react/cjs/react-jsx-runtime.development.js ***! 28813 \*****************************************************************/ 28814/***/ ((__unused_webpack_module, exports, __webpack_require__) => { 28815 28816"use strict"; 28817/** @license React v17.0.2 28818 * react-jsx-runtime.development.js 28819 * 28820 * Copyright (c) Facebook, Inc. and its affiliates. 28821 * 28822 * This source code is licensed under the MIT license found in the 28823 * LICENSE file in the root directory of this source tree. 28824 */ 28825 28826 28827 28828if (true) { 28829 (function() { 28830'use strict'; 28831 28832var React = __webpack_require__(/*! react */ "./node_modules/react/index.js"); 28833var _assign = __webpack_require__(/*! object-assign */ "./node_modules/object-assign/index.js"); 28834 28835// ATTENTION 28836// When adding new symbols to this file, 28837// Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols' 28838// The Symbol used to tag the ReactElement-like types. If there is no native Symbol 28839// nor polyfill, then a plain number is used for performance. 28840var REACT_ELEMENT_TYPE = 0xeac7; 28841var REACT_PORTAL_TYPE = 0xeaca; 28842exports.Fragment = 0xeacb; 28843var REACT_STRICT_MODE_TYPE = 0xeacc; 28844var REACT_PROFILER_TYPE = 0xead2; 28845var REACT_PROVIDER_TYPE = 0xeacd; 28846var REACT_CONTEXT_TYPE = 0xeace; 28847var REACT_FORWARD_REF_TYPE = 0xead0; 28848var REACT_SUSPENSE_TYPE = 0xead1; 28849var REACT_SUSPENSE_LIST_TYPE = 0xead8; 28850var REACT_MEMO_TYPE = 0xead3; 28851var REACT_LAZY_TYPE = 0xead4; 28852var REACT_BLOCK_TYPE = 0xead9; 28853var REACT_SERVER_BLOCK_TYPE = 0xeada; 28854var REACT_FUNDAMENTAL_TYPE = 0xead5; 28855var REACT_SCOPE_TYPE = 0xead7; 28856var REACT_OPAQUE_ID_TYPE = 0xeae0; 28857var REACT_DEBUG_TRACING_MODE_TYPE = 0xeae1; 28858var REACT_OFFSCREEN_TYPE = 0xeae2; 28859var REACT_LEGACY_HIDDEN_TYPE = 0xeae3; 28860 28861if (typeof Symbol === 'function' && Symbol.for) { 28862 var symbolFor = Symbol.for; 28863 REACT_ELEMENT_TYPE = symbolFor('react.element'); 28864 REACT_PORTAL_TYPE = symbolFor('react.portal'); 28865 exports.Fragment = symbolFor('react.fragment'); 28866 REACT_STRICT_MODE_TYPE = symbolFor('react.strict_mode'); 28867 REACT_PROFILER_TYPE = symbolFor('react.profiler'); 28868 REACT_PROVIDER_TYPE = symbolFor('react.provider'); 28869 REACT_CONTEXT_TYPE = symbolFor('react.context'); 28870 REACT_FORWARD_REF_TYPE = symbolFor('react.forward_ref'); 28871 REACT_SUSPENSE_TYPE = symbolFor('react.suspense'); 28872 REACT_SUSPENSE_LIST_TYPE = symbolFor('react.suspense_list'); 28873 REACT_MEMO_TYPE = symbolFor('react.memo'); 28874 REACT_LAZY_TYPE = symbolFor('react.lazy'); 28875 REACT_BLOCK_TYPE = symbolFor('react.block'); 28876 REACT_SERVER_BLOCK_TYPE = symbolFor('react.server.block'); 28877 REACT_FUNDAMENTAL_TYPE = symbolFor('react.fundamental'); 28878 REACT_SCOPE_TYPE = symbolFor('react.scope'); 28879 REACT_OPAQUE_ID_TYPE = symbolFor('react.opaque.id'); 28880 REACT_DEBUG_TRACING_MODE_TYPE = symbolFor('react.debug_trace_mode'); 28881 REACT_OFFSCREEN_TYPE = symbolFor('react.offscreen'); 28882 REACT_LEGACY_HIDDEN_TYPE = symbolFor('react.legacy_hidden'); 28883} 28884 28885var MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator; 28886var FAUX_ITERATOR_SYMBOL = '@@iterator'; 28887function getIteratorFn(maybeIterable) { 28888 if (maybeIterable === null || typeof maybeIterable !== 'object') { 28889 return null; 28890 } 28891 28892 var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]; 28893 28894 if (typeof maybeIterator === 'function') { 28895 return maybeIterator; 28896 } 28897 28898 return null; 28899} 28900 28901var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; 28902 28903function error(format) { 28904 { 28905 for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { 28906 args[_key2 - 1] = arguments[_key2]; 28907 } 28908 28909 printWarning('error', format, args); 28910 } 28911} 28912 28913function printWarning(level, format, args) { 28914 // When changing this logic, you might want to also 28915 // update consoleWithStackDev.www.js as well. 28916 { 28917 var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; 28918 var stack = ReactDebugCurrentFrame.getStackAddendum(); 28919 28920 if (stack !== '') { 28921 format += '%s'; 28922 args = args.concat([stack]); 28923 } 28924 28925 var argsWithFormat = args.map(function (item) { 28926 return '' + item; 28927 }); // Careful: RN currently depends on this prefix 28928 28929 argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it 28930 // breaks IE9: https://github.com/facebook/react/issues/13610 28931 // eslint-disable-next-line react-internal/no-production-logging 28932 28933 Function.prototype.apply.call(console[level], console, argsWithFormat); 28934 } 28935} 28936 28937// Filter certain DOM attributes (e.g. src, href) if their values are empty strings. 28938 28939var enableScopeAPI = false; // Experimental Create Event Handle API. 28940 28941function isValidElementType(type) { 28942 if (typeof type === 'string' || typeof type === 'function') { 28943 return true; 28944 } // Note: typeof might be other than 'symbol' or 'number' (e.g. if it's a polyfill). 28945 28946 28947 if (type === exports.Fragment || type === REACT_PROFILER_TYPE || type === REACT_DEBUG_TRACING_MODE_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || type === REACT_LEGACY_HIDDEN_TYPE || enableScopeAPI ) { 28948 return true; 28949 } 28950 28951 if (typeof type === 'object' && type !== null) { 28952 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) { 28953 return true; 28954 } 28955 } 28956 28957 return false; 28958} 28959 28960function getWrappedName(outerType, innerType, wrapperName) { 28961 var functionName = innerType.displayName || innerType.name || ''; 28962 return outerType.displayName || (functionName !== '' ? wrapperName + "(" + functionName + ")" : wrapperName); 28963} 28964 28965function getContextName(type) { 28966 return type.displayName || 'Context'; 28967} 28968 28969function getComponentName(type) { 28970 if (type == null) { 28971 // Host root, text node or just invalid type. 28972 return null; 28973 } 28974 28975 { 28976 if (typeof type.tag === 'number') { 28977 error('Received an unexpected object in getComponentName(). ' + 'This is likely a bug in React. Please file an issue.'); 28978 } 28979 } 28980 28981 if (typeof type === 'function') { 28982 return type.displayName || type.name || null; 28983 } 28984 28985 if (typeof type === 'string') { 28986 return type; 28987 } 28988 28989 switch (type) { 28990 case exports.Fragment: 28991 return 'Fragment'; 28992 28993 case REACT_PORTAL_TYPE: 28994 return 'Portal'; 28995 28996 case REACT_PROFILER_TYPE: 28997 return 'Profiler'; 28998 28999 case REACT_STRICT_MODE_TYPE: 29000 return 'StrictMode'; 29001 29002 case REACT_SUSPENSE_TYPE: 29003 return 'Suspense'; 29004 29005 case REACT_SUSPENSE_LIST_TYPE: 29006 return 'SuspenseList'; 29007 } 29008 29009 if (typeof type === 'object') { 29010 switch (type.$$typeof) { 29011 case REACT_CONTEXT_TYPE: 29012 var context = type; 29013 return getContextName(context) + '.Consumer'; 29014 29015 case REACT_PROVIDER_TYPE: 29016 var provider = type; 29017 return getContextName(provider._context) + '.Provider'; 29018 29019 case REACT_FORWARD_REF_TYPE: 29020 return getWrappedName(type, type.render, 'ForwardRef'); 29021 29022 case REACT_MEMO_TYPE: 29023 return getComponentName(type.type); 29024 29025 case REACT_BLOCK_TYPE: 29026 return getComponentName(type._render); 29027 29028 case REACT_LAZY_TYPE: 29029 { 29030 var lazyComponent = type; 29031 var payload = lazyComponent._payload; 29032 var init = lazyComponent._init; 29033 29034 try { 29035 return getComponentName(init(payload)); 29036 } catch (x) { 29037 return null; 29038 } 29039 } 29040 } 29041 } 29042 29043 return null; 29044} 29045 29046// Helpers to patch console.logs to avoid logging during side-effect free 29047// replaying on render function. This currently only patches the object 29048// lazily which won't cover if the log function was extracted eagerly. 29049// We could also eagerly patch the method. 29050var disabledDepth = 0; 29051var prevLog; 29052var prevInfo; 29053var prevWarn; 29054var prevError; 29055var prevGroup; 29056var prevGroupCollapsed; 29057var prevGroupEnd; 29058 29059function disabledLog() {} 29060 29061disabledLog.__reactDisabledLog = true; 29062function disableLogs() { 29063 { 29064 if (disabledDepth === 0) { 29065 /* eslint-disable react-internal/no-production-logging */ 29066 prevLog = console.log; 29067 prevInfo = console.info; 29068 prevWarn = console.warn; 29069 prevError = console.error; 29070 prevGroup = console.group; 29071 prevGroupCollapsed = console.groupCollapsed; 29072 prevGroupEnd = console.groupEnd; // https://github.com/facebook/react/issues/19099 29073 29074 var props = { 29075 configurable: true, 29076 enumerable: true, 29077 value: disabledLog, 29078 writable: true 29079 }; // $FlowFixMe Flow thinks console is immutable. 29080 29081 Object.defineProperties(console, { 29082 info: props, 29083 log: props, 29084 warn: props, 29085 error: props, 29086 group: props, 29087 groupCollapsed: props, 29088 groupEnd: props 29089 }); 29090 /* eslint-enable react-internal/no-production-logging */ 29091 } 29092 29093 disabledDepth++; 29094 } 29095} 29096function reenableLogs() { 29097 { 29098 disabledDepth--; 29099 29100 if (disabledDepth === 0) { 29101 /* eslint-disable react-internal/no-production-logging */ 29102 var props = { 29103 configurable: true, 29104 enumerable: true, 29105 writable: true 29106 }; // $FlowFixMe Flow thinks console is immutable. 29107 29108 Object.defineProperties(console, { 29109 log: _assign({}, props, { 29110 value: prevLog 29111 }), 29112 info: _assign({}, props, { 29113 value: prevInfo 29114 }), 29115 warn: _assign({}, props, { 29116 value: prevWarn 29117 }), 29118 error: _assign({}, props, { 29119 value: prevError 29120 }), 29121 group: _assign({}, props, { 29122 value: prevGroup 29123 }), 29124 groupCollapsed: _assign({}, props, { 29125 value: prevGroupCollapsed 29126 }), 29127 groupEnd: _assign({}, props, { 29128 value: prevGroupEnd 29129 }) 29130 }); 29131 /* eslint-enable react-internal/no-production-logging */ 29132 } 29133 29134 if (disabledDepth < 0) { 29135 error('disabledDepth fell below zero. ' + 'This is a bug in React. Please file an issue.'); 29136 } 29137 } 29138} 29139 29140var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher; 29141var prefix; 29142function describeBuiltInComponentFrame(name, source, ownerFn) { 29143 { 29144 if (prefix === undefined) { 29145 // Extract the VM specific prefix used by each line. 29146 try { 29147 throw Error(); 29148 } catch (x) { 29149 var match = x.stack.trim().match(/\n( *(at )?)/); 29150 prefix = match && match[1] || ''; 29151 } 29152 } // We use the prefix to ensure our stacks line up with native stack frames. 29153 29154 29155 return '\n' + prefix + name; 29156 } 29157} 29158var reentry = false; 29159var componentFrameCache; 29160 29161{ 29162 var PossiblyWeakMap = typeof WeakMap === 'function' ? WeakMap : Map; 29163 componentFrameCache = new PossiblyWeakMap(); 29164} 29165 29166function describeNativeComponentFrame(fn, construct) { 29167 // If something asked for a stack inside a fake render, it should get ignored. 29168 if (!fn || reentry) { 29169 return ''; 29170 } 29171 29172 { 29173 var frame = componentFrameCache.get(fn); 29174 29175 if (frame !== undefined) { 29176 return frame; 29177 } 29178 } 29179 29180 var control; 29181 reentry = true; 29182 var previousPrepareStackTrace = Error.prepareStackTrace; // $FlowFixMe It does accept undefined. 29183 29184 Error.prepareStackTrace = undefined; 29185 var previousDispatcher; 29186 29187 { 29188 previousDispatcher = ReactCurrentDispatcher.current; // Set the dispatcher in DEV because this might be call in the render function 29189 // for warnings. 29190 29191 ReactCurrentDispatcher.current = null; 29192 disableLogs(); 29193 } 29194 29195 try { 29196 // This should throw. 29197 if (construct) { 29198 // Something should be setting the props in the constructor. 29199 var Fake = function () { 29200 throw Error(); 29201 }; // $FlowFixMe 29202 29203 29204 Object.defineProperty(Fake.prototype, 'props', { 29205 set: function () { 29206 // We use a throwing setter instead of frozen or non-writable props 29207 // because that won't throw in a non-strict mode function. 29208 throw Error(); 29209 } 29210 }); 29211 29212 if (typeof Reflect === 'object' && Reflect.construct) { 29213 // We construct a different control for this case to include any extra 29214 // frames added by the construct call. 29215 try { 29216 Reflect.construct(Fake, []); 29217 } catch (x) { 29218 control = x; 29219 } 29220 29221 Reflect.construct(fn, [], Fake); 29222 } else { 29223 try { 29224 Fake.call(); 29225 } catch (x) { 29226 control = x; 29227 } 29228 29229 fn.call(Fake.prototype); 29230 } 29231 } else { 29232 try { 29233 throw Error(); 29234 } catch (x) { 29235 control = x; 29236 } 29237 29238 fn(); 29239 } 29240 } catch (sample) { 29241 // This is inlined manually because closure doesn't do it for us. 29242 if (sample && control && typeof sample.stack === 'string') { 29243 // This extracts the first frame from the sample that isn't also in the control. 29244 // Skipping one frame that we assume is the frame that calls the two. 29245 var sampleLines = sample.stack.split('\n'); 29246 var controlLines = control.stack.split('\n'); 29247 var s = sampleLines.length - 1; 29248 var c = controlLines.length - 1; 29249 29250 while (s >= 1 && c >= 0 && sampleLines[s] !== controlLines[c]) { 29251 // We expect at least one stack frame to be shared. 29252 // Typically this will be the root most one. However, stack frames may be 29253 // cut off due to maximum stack limits. In this case, one maybe cut off 29254 // earlier than the other. We assume that the sample is longer or the same 29255 // and there for cut off earlier. So we should find the root most frame in 29256 // the sample somewhere in the control. 29257 c--; 29258 } 29259 29260 for (; s >= 1 && c >= 0; s--, c--) { 29261 // Next we find the first one that isn't the same which should be the 29262 // frame that called our sample function and the control. 29263 if (sampleLines[s] !== controlLines[c]) { 29264 // In V8, the first line is describing the message but other VMs don't. 29265 // If we're about to return the first line, and the control is also on the same 29266 // line, that's a pretty good indicator that our sample threw at same line as 29267 // the control. I.e. before we entered the sample frame. So we ignore this result. 29268 // This can happen if you passed a class to function component, or non-function. 29269 if (s !== 1 || c !== 1) { 29270 do { 29271 s--; 29272 c--; // We may still have similar intermediate frames from the construct call. 29273 // The next one that isn't the same should be our match though. 29274 29275 if (c < 0 || sampleLines[s] !== controlLines[c]) { 29276 // V8 adds a "new" prefix for native classes. Let's remove it to make it prettier. 29277 var _frame = '\n' + sampleLines[s].replace(' at new ', ' at '); 29278 29279 { 29280 if (typeof fn === 'function') { 29281 componentFrameCache.set(fn, _frame); 29282 } 29283 } // Return the line we found. 29284 29285 29286 return _frame; 29287 } 29288 } while (s >= 1 && c >= 0); 29289 } 29290 29291 break; 29292 } 29293 } 29294 } 29295 } finally { 29296 reentry = false; 29297 29298 { 29299 ReactCurrentDispatcher.current = previousDispatcher; 29300 reenableLogs(); 29301 } 29302 29303 Error.prepareStackTrace = previousPrepareStackTrace; 29304 } // Fallback to just using the name if we couldn't make it throw. 29305 29306 29307 var name = fn ? fn.displayName || fn.name : ''; 29308 var syntheticFrame = name ? describeBuiltInComponentFrame(name) : ''; 29309 29310 { 29311 if (typeof fn === 'function') { 29312 componentFrameCache.set(fn, syntheticFrame); 29313 } 29314 } 29315 29316 return syntheticFrame; 29317} 29318function describeFunctionComponentFrame(fn, source, ownerFn) { 29319 { 29320 return describeNativeComponentFrame(fn, false); 29321 } 29322} 29323 29324function shouldConstruct(Component) { 29325 var prototype = Component.prototype; 29326 return !!(prototype && prototype.isReactComponent); 29327} 29328 29329function describeUnknownElementTypeFrameInDEV(type, source, ownerFn) { 29330 29331 if (type == null) { 29332 return ''; 29333 } 29334 29335 if (typeof type === 'function') { 29336 { 29337 return describeNativeComponentFrame(type, shouldConstruct(type)); 29338 } 29339 } 29340 29341 if (typeof type === 'string') { 29342 return describeBuiltInComponentFrame(type); 29343 } 29344 29345 switch (type) { 29346 case REACT_SUSPENSE_TYPE: 29347 return describeBuiltInComponentFrame('Suspense'); 29348 29349 case REACT_SUSPENSE_LIST_TYPE: 29350 return describeBuiltInComponentFrame('SuspenseList'); 29351 } 29352 29353 if (typeof type === 'object') { 29354 switch (type.$$typeof) { 29355 case REACT_FORWARD_REF_TYPE: 29356 return describeFunctionComponentFrame(type.render); 29357 29358 case REACT_MEMO_TYPE: 29359 // Memo may contain any component type so we recursively resolve it. 29360 return describeUnknownElementTypeFrameInDEV(type.type, source, ownerFn); 29361 29362 case REACT_BLOCK_TYPE: 29363 return describeFunctionComponentFrame(type._render); 29364 29365 case REACT_LAZY_TYPE: 29366 { 29367 var lazyComponent = type; 29368 var payload = lazyComponent._payload; 29369 var init = lazyComponent._init; 29370 29371 try { 29372 // Lazy may contain any component type so we recursively resolve it. 29373 return describeUnknownElementTypeFrameInDEV(init(payload), source, ownerFn); 29374 } catch (x) {} 29375 } 29376 } 29377 } 29378 29379 return ''; 29380} 29381 29382var loggedTypeFailures = {}; 29383var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; 29384 29385function setCurrentlyValidatingElement(element) { 29386 { 29387 if (element) { 29388 var owner = element._owner; 29389 var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null); 29390 ReactDebugCurrentFrame.setExtraStackFrame(stack); 29391 } else { 29392 ReactDebugCurrentFrame.setExtraStackFrame(null); 29393 } 29394 } 29395} 29396 29397function checkPropTypes(typeSpecs, values, location, componentName, element) { 29398 { 29399 // $FlowFixMe This is okay but Flow doesn't know it. 29400 var has = Function.call.bind(Object.prototype.hasOwnProperty); 29401 29402 for (var typeSpecName in typeSpecs) { 29403 if (has(typeSpecs, typeSpecName)) { 29404 var error$1 = void 0; // Prop type validation may throw. In case they do, we don't want to 29405 // fail the render phase where it didn't fail before. So we log it. 29406 // After these have been cleaned up, we'll let them throw. 29407 29408 try { 29409 // This is intentionally an invariant that gets caught. It's the same 29410 // behavior as without this statement except with a better message. 29411 if (typeof typeSpecs[typeSpecName] !== 'function') { 29412 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`.'); 29413 err.name = 'Invariant Violation'; 29414 throw err; 29415 } 29416 29417 error$1 = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED'); 29418 } catch (ex) { 29419 error$1 = ex; 29420 } 29421 29422 if (error$1 && !(error$1 instanceof Error)) { 29423 setCurrentlyValidatingElement(element); 29424 29425 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); 29426 29427 setCurrentlyValidatingElement(null); 29428 } 29429 29430 if (error$1 instanceof Error && !(error$1.message in loggedTypeFailures)) { 29431 // Only monitor this failure once because there tends to be a lot of the 29432 // same error. 29433 loggedTypeFailures[error$1.message] = true; 29434 setCurrentlyValidatingElement(element); 29435 29436 error('Failed %s type: %s', location, error$1.message); 29437 29438 setCurrentlyValidatingElement(null); 29439 } 29440 } 29441 } 29442 } 29443} 29444 29445var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner; 29446var hasOwnProperty = Object.prototype.hasOwnProperty; 29447var RESERVED_PROPS = { 29448 key: true, 29449 ref: true, 29450 __self: true, 29451 __source: true 29452}; 29453var specialPropKeyWarningShown; 29454var specialPropRefWarningShown; 29455var didWarnAboutStringRefs; 29456 29457{ 29458 didWarnAboutStringRefs = {}; 29459} 29460 29461function hasValidRef(config) { 29462 { 29463 if (hasOwnProperty.call(config, 'ref')) { 29464 var getter = Object.getOwnPropertyDescriptor(config, 'ref').get; 29465 29466 if (getter && getter.isReactWarning) { 29467 return false; 29468 } 29469 } 29470 } 29471 29472 return config.ref !== undefined; 29473} 29474 29475function hasValidKey(config) { 29476 { 29477 if (hasOwnProperty.call(config, 'key')) { 29478 var getter = Object.getOwnPropertyDescriptor(config, 'key').get; 29479 29480 if (getter && getter.isReactWarning) { 29481 return false; 29482 } 29483 } 29484 } 29485 29486 return config.key !== undefined; 29487} 29488 29489function warnIfStringRefCannotBeAutoConverted(config, self) { 29490 { 29491 if (typeof config.ref === 'string' && ReactCurrentOwner.current && self && ReactCurrentOwner.current.stateNode !== self) { 29492 var componentName = getComponentName(ReactCurrentOwner.current.type); 29493 29494 if (!didWarnAboutStringRefs[componentName]) { 29495 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', getComponentName(ReactCurrentOwner.current.type), config.ref); 29496 29497 didWarnAboutStringRefs[componentName] = true; 29498 } 29499 } 29500 } 29501} 29502 29503function defineKeyPropWarningGetter(props, displayName) { 29504 { 29505 var warnAboutAccessingKey = function () { 29506 if (!specialPropKeyWarningShown) { 29507 specialPropKeyWarningShown = true; 29508 29509 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); 29510 } 29511 }; 29512 29513 warnAboutAccessingKey.isReactWarning = true; 29514 Object.defineProperty(props, 'key', { 29515 get: warnAboutAccessingKey, 29516 configurable: true 29517 }); 29518 } 29519} 29520 29521function defineRefPropWarningGetter(props, displayName) { 29522 { 29523 var warnAboutAccessingRef = function () { 29524 if (!specialPropRefWarningShown) { 29525 specialPropRefWarningShown = true; 29526 29527 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); 29528 } 29529 }; 29530 29531 warnAboutAccessingRef.isReactWarning = true; 29532 Object.defineProperty(props, 'ref', { 29533 get: warnAboutAccessingRef, 29534 configurable: true 29535 }); 29536 } 29537} 29538/** 29539 * Factory method to create a new React element. This no longer adheres to 29540 * the class pattern, so do not use new to call it. Also, instanceof check 29541 * will not work. Instead test $$typeof field against Symbol.for('react.element') to check 29542 * if something is a React Element. 29543 * 29544 * @param {*} type 29545 * @param {*} props 29546 * @param {*} key 29547 * @param {string|object} ref 29548 * @param {*} owner 29549 * @param {*} self A *temporary* helper to detect places where `this` is 29550 * different from the `owner` when React.createElement is called, so that we 29551 * can warn. We want to get rid of owner and replace string `ref`s with arrow 29552 * functions, and as long as `this` and owner are the same, there will be no 29553 * change in behavior. 29554 * @param {*} source An annotation object (added by a transpiler or otherwise) 29555 * indicating filename, line number, and/or other information. 29556 * @internal 29557 */ 29558 29559 29560var ReactElement = function (type, key, ref, self, source, owner, props) { 29561 var element = { 29562 // This tag allows us to uniquely identify this as a React Element 29563 $$typeof: REACT_ELEMENT_TYPE, 29564 // Built-in properties that belong on the element 29565 type: type, 29566 key: key, 29567 ref: ref, 29568 props: props, 29569 // Record the component responsible for creating this element. 29570 _owner: owner 29571 }; 29572 29573 { 29574 // The validation flag is currently mutative. We put it on 29575 // an external backing store so that we can freeze the whole object. 29576 // This can be replaced with a WeakMap once they are implemented in 29577 // commonly used development environments. 29578 element._store = {}; // To make comparing ReactElements easier for testing purposes, we make 29579 // the validation flag non-enumerable (where possible, which should 29580 // include every environment we run tests in), so the test framework 29581 // ignores it. 29582 29583 Object.defineProperty(element._store, 'validated', { 29584 configurable: false, 29585 enumerable: false, 29586 writable: true, 29587 value: false 29588 }); // self and source are DEV only properties. 29589 29590 Object.defineProperty(element, '_self', { 29591 configurable: false, 29592 enumerable: false, 29593 writable: false, 29594 value: self 29595 }); // Two elements created in two different places should be considered 29596 // equal for testing purposes and therefore we hide it from enumeration. 29597 29598 Object.defineProperty(element, '_source', { 29599 configurable: false, 29600 enumerable: false, 29601 writable: false, 29602 value: source 29603 }); 29604 29605 if (Object.freeze) { 29606 Object.freeze(element.props); 29607 Object.freeze(element); 29608 } 29609 } 29610 29611 return element; 29612}; 29613/** 29614 * https://github.com/reactjs/rfcs/pull/107 29615 * @param {*} type 29616 * @param {object} props 29617 * @param {string} key 29618 */ 29619 29620function jsxDEV(type, config, maybeKey, source, self) { 29621 { 29622 var propName; // Reserved names are extracted 29623 29624 var props = {}; 29625 var key = null; 29626 var ref = null; // Currently, key can be spread in as a prop. This causes a potential 29627 // issue if key is also explicitly declared (ie. <div {...props} key="Hi" /> 29628 // or <div key="Hi" {...props} /> ). We want to deprecate key spread, 29629 // but as an intermediary step, we will use jsxDEV for everything except 29630 // <div {...props} key="Hi" />, because we aren't currently able to tell if 29631 // key is explicitly declared to be undefined or not. 29632 29633 if (maybeKey !== undefined) { 29634 key = '' + maybeKey; 29635 } 29636 29637 if (hasValidKey(config)) { 29638 key = '' + config.key; 29639 } 29640 29641 if (hasValidRef(config)) { 29642 ref = config.ref; 29643 warnIfStringRefCannotBeAutoConverted(config, self); 29644 } // Remaining properties are added to a new props object 29645 29646 29647 for (propName in config) { 29648 if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) { 29649 props[propName] = config[propName]; 29650 } 29651 } // Resolve default props 29652 29653 29654 if (type && type.defaultProps) { 29655 var defaultProps = type.defaultProps; 29656 29657 for (propName in defaultProps) { 29658 if (props[propName] === undefined) { 29659 props[propName] = defaultProps[propName]; 29660 } 29661 } 29662 } 29663 29664 if (key || ref) { 29665 var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type; 29666 29667 if (key) { 29668 defineKeyPropWarningGetter(props, displayName); 29669 } 29670 29671 if (ref) { 29672 defineRefPropWarningGetter(props, displayName); 29673 } 29674 } 29675 29676 return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props); 29677 } 29678} 29679 29680var ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner; 29681var ReactDebugCurrentFrame$1 = ReactSharedInternals.ReactDebugCurrentFrame; 29682 29683function setCurrentlyValidatingElement$1(element) { 29684 { 29685 if (element) { 29686 var owner = element._owner; 29687 var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null); 29688 ReactDebugCurrentFrame$1.setExtraStackFrame(stack); 29689 } else { 29690 ReactDebugCurrentFrame$1.setExtraStackFrame(null); 29691 } 29692 } 29693} 29694 29695var propTypesMisspellWarningShown; 29696 29697{ 29698 propTypesMisspellWarningShown = false; 29699} 29700/** 29701 * Verifies the object is a ReactElement. 29702 * See https://reactjs.org/docs/react-api.html#isvalidelement 29703 * @param {?object} object 29704 * @return {boolean} True if `object` is a ReactElement. 29705 * @final 29706 */ 29707 29708function isValidElement(object) { 29709 { 29710 return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE; 29711 } 29712} 29713 29714function getDeclarationErrorAddendum() { 29715 { 29716 if (ReactCurrentOwner$1.current) { 29717 var name = getComponentName(ReactCurrentOwner$1.current.type); 29718 29719 if (name) { 29720 return '\n\nCheck the render method of `' + name + '`.'; 29721 } 29722 } 29723 29724 return ''; 29725 } 29726} 29727 29728function getSourceInfoErrorAddendum(source) { 29729 { 29730 if (source !== undefined) { 29731 var fileName = source.fileName.replace(/^.*[\\\/]/, ''); 29732 var lineNumber = source.lineNumber; 29733 return '\n\nCheck your code at ' + fileName + ':' + lineNumber + '.'; 29734 } 29735 29736 return ''; 29737 } 29738} 29739/** 29740 * Warn if there's no key explicitly set on dynamic arrays of children or 29741 * object keys are not valid. This allows us to keep track of children between 29742 * updates. 29743 */ 29744 29745 29746var ownerHasKeyUseWarning = {}; 29747 29748function getCurrentComponentErrorInfo(parentType) { 29749 { 29750 var info = getDeclarationErrorAddendum(); 29751 29752 if (!info) { 29753 var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name; 29754 29755 if (parentName) { 29756 info = "\n\nCheck the top-level render call using <" + parentName + ">."; 29757 } 29758 } 29759 29760 return info; 29761 } 29762} 29763/** 29764 * Warn if the element doesn't have an explicit key assigned to it. 29765 * This element is in an array. The array could grow and shrink or be 29766 * reordered. All children that haven't already been validated are required to 29767 * have a "key" property assigned to it. Error statuses are cached so a warning 29768 * will only be shown once. 29769 * 29770 * @internal 29771 * @param {ReactElement} element Element that requires a key. 29772 * @param {*} parentType element's parent's type. 29773 */ 29774 29775 29776function validateExplicitKey(element, parentType) { 29777 { 29778 if (!element._store || element._store.validated || element.key != null) { 29779 return; 29780 } 29781 29782 element._store.validated = true; 29783 var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType); 29784 29785 if (ownerHasKeyUseWarning[currentComponentErrorInfo]) { 29786 return; 29787 } 29788 29789 ownerHasKeyUseWarning[currentComponentErrorInfo] = true; // Usually the current owner is the offender, but if it accepts children as a 29790 // property, it may be the creator of the child that's responsible for 29791 // assigning it a key. 29792 29793 var childOwner = ''; 29794 29795 if (element && element._owner && element._owner !== ReactCurrentOwner$1.current) { 29796 // Give the component that originally created this child. 29797 childOwner = " It was passed a child from " + getComponentName(element._owner.type) + "."; 29798 } 29799 29800 setCurrentlyValidatingElement$1(element); 29801 29802 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); 29803 29804 setCurrentlyValidatingElement$1(null); 29805 } 29806} 29807/** 29808 * Ensure that every element either is passed in a static location, in an 29809 * array with an explicit keys property defined, or in an object literal 29810 * with valid key property. 29811 * 29812 * @internal 29813 * @param {ReactNode} node Statically passed child of any type. 29814 * @param {*} parentType node's parent's type. 29815 */ 29816 29817 29818function validateChildKeys(node, parentType) { 29819 { 29820 if (typeof node !== 'object') { 29821 return; 29822 } 29823 29824 if (Array.isArray(node)) { 29825 for (var i = 0; i < node.length; i++) { 29826 var child = node[i]; 29827 29828 if (isValidElement(child)) { 29829 validateExplicitKey(child, parentType); 29830 } 29831 } 29832 } else if (isValidElement(node)) { 29833 // This element was passed in a valid location. 29834 if (node._store) { 29835 node._store.validated = true; 29836 } 29837 } else if (node) { 29838 var iteratorFn = getIteratorFn(node); 29839 29840 if (typeof iteratorFn === 'function') { 29841 // Entry iterators used to provide implicit keys, 29842 // but now we print a separate warning for them later. 29843 if (iteratorFn !== node.entries) { 29844 var iterator = iteratorFn.call(node); 29845 var step; 29846 29847 while (!(step = iterator.next()).done) { 29848 if (isValidElement(step.value)) { 29849 validateExplicitKey(step.value, parentType); 29850 } 29851 } 29852 } 29853 } 29854 } 29855 } 29856} 29857/** 29858 * Given an element, validate that its props follow the propTypes definition, 29859 * provided by the type. 29860 * 29861 * @param {ReactElement} element 29862 */ 29863 29864 29865function validatePropTypes(element) { 29866 { 29867 var type = element.type; 29868 29869 if (type === null || type === undefined || typeof type === 'string') { 29870 return; 29871 } 29872 29873 var propTypes; 29874 29875 if (typeof type === 'function') { 29876 propTypes = type.propTypes; 29877 } else if (typeof type === 'object' && (type.$$typeof === REACT_FORWARD_REF_TYPE || // Note: Memo only checks outer props here. 29878 // Inner props are checked in the reconciler. 29879 type.$$typeof === REACT_MEMO_TYPE)) { 29880 propTypes = type.propTypes; 29881 } else { 29882 return; 29883 } 29884 29885 if (propTypes) { 29886 // Intentionally inside to avoid triggering lazy initializers: 29887 var name = getComponentName(type); 29888 checkPropTypes(propTypes, element.props, 'prop', name, element); 29889 } else if (type.PropTypes !== undefined && !propTypesMisspellWarningShown) { 29890 propTypesMisspellWarningShown = true; // Intentionally inside to avoid triggering lazy initializers: 29891 29892 var _name = getComponentName(type); 29893 29894 error('Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?', _name || 'Unknown'); 29895 } 29896 29897 if (typeof type.getDefaultProps === 'function' && !type.getDefaultProps.isReactClassApproved) { 29898 error('getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.'); 29899 } 29900 } 29901} 29902/** 29903 * Given a fragment, validate that it can only be provided with fragment props 29904 * @param {ReactElement} fragment 29905 */ 29906 29907 29908function validateFragmentProps(fragment) { 29909 { 29910 var keys = Object.keys(fragment.props); 29911 29912 for (var i = 0; i < keys.length; i++) { 29913 var key = keys[i]; 29914 29915 if (key !== 'children' && key !== 'key') { 29916 setCurrentlyValidatingElement$1(fragment); 29917 29918 error('Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', key); 29919 29920 setCurrentlyValidatingElement$1(null); 29921 break; 29922 } 29923 } 29924 29925 if (fragment.ref !== null) { 29926 setCurrentlyValidatingElement$1(fragment); 29927 29928 error('Invalid attribute `ref` supplied to `React.Fragment`.'); 29929 29930 setCurrentlyValidatingElement$1(null); 29931 } 29932 } 29933} 29934 29935function jsxWithValidation(type, props, key, isStaticChildren, source, self) { 29936 { 29937 var validType = isValidElementType(type); // We warn in this case but don't throw. We expect the element creation to 29938 // succeed and there will likely be errors in render. 29939 29940 if (!validType) { 29941 var info = ''; 29942 29943 if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) { 29944 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."; 29945 } 29946 29947 var sourceInfo = getSourceInfoErrorAddendum(source); 29948 29949 if (sourceInfo) { 29950 info += sourceInfo; 29951 } else { 29952 info += getDeclarationErrorAddendum(); 29953 } 29954 29955 var typeString; 29956 29957 if (type === null) { 29958 typeString = 'null'; 29959 } else if (Array.isArray(type)) { 29960 typeString = 'array'; 29961 } else if (type !== undefined && type.$$typeof === REACT_ELEMENT_TYPE) { 29962 typeString = "<" + (getComponentName(type.type) || 'Unknown') + " />"; 29963 info = ' Did you accidentally export a JSX literal instead of a component?'; 29964 } else { 29965 typeString = typeof type; 29966 } 29967 29968 error('React.jsx: type is invalid -- expected a string (for ' + 'built-in components) or a class/function (for composite ' + 'components) but got: %s.%s', typeString, info); 29969 } 29970 29971 var element = jsxDEV(type, props, key, source, self); // The result can be nullish if a mock or a custom function is used. 29972 // TODO: Drop this when these are no longer allowed as the type argument. 29973 29974 if (element == null) { 29975 return element; 29976 } // Skip key warning if the type isn't valid since our key validation logic 29977 // doesn't expect a non-string/function type and can throw confusing errors. 29978 // We don't want exception behavior to differ between dev and prod. 29979 // (Rendering will throw with a helpful message and as soon as the type is 29980 // fixed, the key warnings will appear.) 29981 29982 29983 if (validType) { 29984 var children = props.children; 29985 29986 if (children !== undefined) { 29987 if (isStaticChildren) { 29988 if (Array.isArray(children)) { 29989 for (var i = 0; i < children.length; i++) { 29990 validateChildKeys(children[i], type); 29991 } 29992 29993 if (Object.freeze) { 29994 Object.freeze(children); 29995 } 29996 } else { 29997 error('React.jsx: Static children should always be an array. ' + 'You are likely explicitly calling React.jsxs or React.jsxDEV. ' + 'Use the Babel transform instead.'); 29998 } 29999 } else { 30000 validateChildKeys(children, type); 30001 } 30002 } 30003 } 30004 30005 if (type === exports.Fragment) { 30006 validateFragmentProps(element); 30007 } else { 30008 validatePropTypes(element); 30009 } 30010 30011 return element; 30012 } 30013} // These two functions exist to still get child warnings in dev 30014// even with the prod transform. This means that jsxDEV is purely 30015// opt-in behavior for better messages but that we won't stop 30016// giving you warnings if you use production apis. 30017 30018function jsxWithValidationStatic(type, props, key) { 30019 { 30020 return jsxWithValidation(type, props, key, true); 30021 } 30022} 30023function jsxWithValidationDynamic(type, props, key) { 30024 { 30025 return jsxWithValidation(type, props, key, false); 30026 } 30027} 30028 30029var jsx = jsxWithValidationDynamic ; // we may want to special case jsxs internally to take advantage of static children. 30030// for now we can ship identical prod functions 30031 30032var jsxs = jsxWithValidationStatic ; 30033 30034exports.jsx = jsx; 30035exports.jsxs = jsxs; 30036 })(); 30037} 30038 30039 30040/***/ }), 30041
vendor: 72,479 bytes, lines 30042-32385
30042/***/ "./node_modules/react/cjs/react.development.js": 30043/*!*****************************************************!*\ 30044 !*** ./node_modules/react/cjs/react.development.js ***! 30045 \*****************************************************/ 30046/***/ ((__unused_webpack_module, exports, __webpack_require__) => { 30047 30048"use strict"; 30049/** @license React v17.0.2 30050 * react.development.js 30051 * 30052 * Copyright (c) Facebook, Inc. and its affiliates. 30053 * 30054 * This source code is licensed under the MIT license found in the 30055 * LICENSE file in the root directory of this source tree. 30056 */ 30057 30058 30059 30060if (true) { 30061 (function() { 30062'use strict'; 30063 30064var _assign = __webpack_require__(/*! object-assign */ "./node_modules/object-assign/index.js"); 30065 30066// TODO: this is special because it gets imported during build. 30067var ReactVersion = '17.0.2'; 30068 30069// ATTENTION 30070// When adding new symbols to this file, 30071// Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols' 30072// The Symbol used to tag the ReactElement-like types. If there is no native Symbol 30073// nor polyfill, then a plain number is used for performance. 30074var REACT_ELEMENT_TYPE = 0xeac7; 30075var REACT_PORTAL_TYPE = 0xeaca; 30076exports.Fragment = 0xeacb; 30077exports.StrictMode = 0xeacc; 30078exports.Profiler = 0xead2; 30079var REACT_PROVIDER_TYPE = 0xeacd; 30080var REACT_CONTEXT_TYPE = 0xeace; 30081var REACT_FORWARD_REF_TYPE = 0xead0; 30082exports.Suspense = 0xead1; 30083var REACT_SUSPENSE_LIST_TYPE = 0xead8; 30084var REACT_MEMO_TYPE = 0xead3; 30085var REACT_LAZY_TYPE = 0xead4; 30086var REACT_BLOCK_TYPE = 0xead9; 30087var REACT_SERVER_BLOCK_TYPE = 0xeada; 30088var REACT_FUNDAMENTAL_TYPE = 0xead5; 30089var REACT_SCOPE_TYPE = 0xead7; 30090var REACT_OPAQUE_ID_TYPE = 0xeae0; 30091var REACT_DEBUG_TRACING_MODE_TYPE = 0xeae1; 30092var REACT_OFFSCREEN_TYPE = 0xeae2; 30093var REACT_LEGACY_HIDDEN_TYPE = 0xeae3; 30094 30095if (typeof Symbol === 'function' && Symbol.for) { 30096 var symbolFor = Symbol.for; 30097 REACT_ELEMENT_TYPE = symbolFor('react.element'); 30098 REACT_PORTAL_TYPE = symbolFor('react.portal'); 30099 exports.Fragment = symbolFor('react.fragment'); 30100 exports.StrictMode = symbolFor('react.strict_mode'); 30101 exports.Profiler = symbolFor('react.profiler'); 30102 REACT_PROVIDER_TYPE = symbolFor('react.provider'); 30103 REACT_CONTEXT_TYPE = symbolFor('react.context'); 30104 REACT_FORWARD_REF_TYPE = symbolFor('react.forward_ref'); 30105 exports.Suspense = symbolFor('react.suspense'); 30106 REACT_SUSPENSE_LIST_TYPE = symbolFor('react.suspense_list'); 30107 REACT_MEMO_TYPE = symbolFor('react.memo'); 30108 REACT_LAZY_TYPE = symbolFor('react.lazy'); 30109 REACT_BLOCK_TYPE = symbolFor('react.block'); 30110 REACT_SERVER_BLOCK_TYPE = symbolFor('react.server.block'); 30111 REACT_FUNDAMENTAL_TYPE = symbolFor('react.fundamental'); 30112 REACT_SCOPE_TYPE = symbolFor('react.scope'); 30113 REACT_OPAQUE_ID_TYPE = symbolFor('react.opaque.id'); 30114 REACT_DEBUG_TRACING_MODE_TYPE = symbolFor('react.debug_trace_mode'); 30115 REACT_OFFSCREEN_TYPE = symbolFor('react.offscreen'); 30116 REACT_LEGACY_HIDDEN_TYPE = symbolFor('react.legacy_hidden'); 30117} 30118 30119var MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator; 30120var FAUX_ITERATOR_SYMBOL = '@@iterator'; 30121function getIteratorFn(maybeIterable) { 30122 if (maybeIterable === null || typeof maybeIterable !== 'object') { 30123 return null; 30124 } 30125 30126 var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]; 30127 30128 if (typeof maybeIterator === 'function') { 30129 return maybeIterator; 30130 } 30131 30132 return null; 30133} 30134 30135/** 30136 * Keeps track of the current dispatcher. 30137 */ 30138var ReactCurrentDispatcher = { 30139 /** 30140 * @internal 30141 * @type {ReactComponent} 30142 */ 30143 current: null 30144}; 30145 30146/** 30147 * Keeps track of the current batch's configuration such as how long an update 30148 * should suspend for if it needs to. 30149 */ 30150var ReactCurrentBatchConfig = { 30151 transition: 0 30152}; 30153 30154/** 30155 * Keeps track of the current owner. 30156 * 30157 * The current owner is the component who should own any components that are 30158 * currently being constructed. 30159 */ 30160var ReactCurrentOwner = { 30161 /** 30162 * @internal 30163 * @type {ReactComponent} 30164 */ 30165 current: null 30166}; 30167 30168var ReactDebugCurrentFrame = {}; 30169var currentExtraStackFrame = null; 30170function setExtraStackFrame(stack) { 30171 { 30172 currentExtraStackFrame = stack; 30173 } 30174} 30175 30176{ 30177 ReactDebugCurrentFrame.setExtraStackFrame = function (stack) { 30178 { 30179 currentExtraStackFrame = stack; 30180 } 30181 }; // Stack implementation injected by the current renderer. 30182 30183 30184 ReactDebugCurrentFrame.getCurrentStack = null; 30185 30186 ReactDebugCurrentFrame.getStackAddendum = function () { 30187 var stack = ''; // Add an extra top frame while an element is being validated 30188 30189 if (currentExtraStackFrame) { 30190 stack += currentExtraStackFrame; 30191 } // Delegate to the injected renderer-specific implementation 30192 30193 30194 var impl = ReactDebugCurrentFrame.getCurrentStack; 30195 30196 if (impl) { 30197 stack += impl() || ''; 30198 } 30199 30200 return stack; 30201 }; 30202} 30203 30204/** 30205 * Used by act() to track whether you're inside an act() scope. 30206 */ 30207var IsSomeRendererActing = { 30208 current: false 30209}; 30210 30211var ReactSharedInternals = { 30212 ReactCurrentDispatcher: ReactCurrentDispatcher, 30213 ReactCurrentBatchConfig: ReactCurrentBatchConfig, 30214 ReactCurrentOwner: ReactCurrentOwner, 30215 IsSomeRendererActing: IsSomeRendererActing, 30216 // Used by renderers to avoid bundling object-assign twice in UMD bundles: 30217 assign: _assign 30218}; 30219 30220{ 30221 ReactSharedInternals.ReactDebugCurrentFrame = ReactDebugCurrentFrame; 30222} 30223 30224// by calls to these methods by a Babel plugin. 30225// 30226// In PROD (or in packages without access to React internals), 30227// they are left as they are instead. 30228 30229function warn(format) { 30230 { 30231 for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { 30232 args[_key - 1] = arguments[_key]; 30233 } 30234 30235 printWarning('warn', format, args); 30236 } 30237} 30238function error(format) { 30239 { 30240 for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { 30241 args[_key2 - 1] = arguments[_key2]; 30242 } 30243 30244 printWarning('error', format, args); 30245 } 30246} 30247 30248function printWarning(level, format, args) { 30249 // When changing this logic, you might want to also 30250 // update consoleWithStackDev.www.js as well. 30251 { 30252 var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; 30253 var stack = ReactDebugCurrentFrame.getStackAddendum(); 30254 30255 if (stack !== '') { 30256 format += '%s'; 30257 args = args.concat([stack]); 30258 } 30259 30260 var argsWithFormat = args.map(function (item) { 30261 return '' + item; 30262 }); // Careful: RN currently depends on this prefix 30263 30264 argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it 30265 // breaks IE9: https://github.com/facebook/react/issues/13610 30266 // eslint-disable-next-line react-internal/no-production-logging 30267 30268 Function.prototype.apply.call(console[level], console, argsWithFormat); 30269 } 30270} 30271 30272var didWarnStateUpdateForUnmountedComponent = {}; 30273 30274function warnNoop(publicInstance, callerName) { 30275 { 30276 var _constructor = publicInstance.constructor; 30277 var componentName = _constructor && (_constructor.displayName || _constructor.name) || 'ReactClass'; 30278 var warningKey = componentName + "." + callerName; 30279 30280 if (didWarnStateUpdateForUnmountedComponent[warningKey]) { 30281 return; 30282 } 30283 30284 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); 30285 30286 didWarnStateUpdateForUnmountedComponent[warningKey] = true; 30287 } 30288} 30289/** 30290 * This is the abstract API for an update queue. 30291 */ 30292 30293 30294var ReactNoopUpdateQueue = { 30295 /** 30296 * Checks whether or not this composite component is mounted. 30297 * @param {ReactClass} publicInstance The instance we want to test. 30298 * @return {boolean} True if mounted, false otherwise. 30299 * @protected 30300 * @final 30301 */ 30302 isMounted: function (publicInstance) { 30303 return false; 30304 }, 30305 30306 /** 30307 * Forces an update. This should only be invoked when it is known with 30308 * certainty that we are **not** in a DOM transaction. 30309 * 30310 * You may want to call this when you know that some deeper aspect of the 30311 * component's state has changed but `setState` was not called. 30312 * 30313 * This will not invoke `shouldComponentUpdate`, but it will invoke 30314 * `componentWillUpdate` and `componentDidUpdate`. 30315 * 30316 * @param {ReactClass} publicInstance The instance that should rerender. 30317 * @param {?function} callback Called after component is updated. 30318 * @param {?string} callerName name of the calling function in the public API. 30319 * @internal 30320 */ 30321 enqueueForceUpdate: function (publicInstance, callback, callerName) { 30322 warnNoop(publicInstance, 'forceUpdate'); 30323 }, 30324 30325 /** 30326 * Replaces all of the state. Always use this or `setState` to mutate state. 30327 * You should treat `this.state` as immutable. 30328 * 30329 * There is no guarantee that `this.state` will be immediately updated, so 30330 * accessing `this.state` after calling this method may return the old value. 30331 * 30332 * @param {ReactClass} publicInstance The instance that should rerender. 30333 * @param {object} completeState Next state. 30334 * @param {?function} callback Called after component is updated. 30335 * @param {?string} callerName name of the calling function in the public API. 30336 * @internal 30337 */ 30338 enqueueReplaceState: function (publicInstance, completeState, callback, callerName) { 30339 warnNoop(publicInstance, 'replaceState'); 30340 }, 30341 30342 /** 30343 * Sets a subset of the state. This only exists because _pendingState is 30344 * internal. This provides a merging strategy that is not available to deep 30345 * properties which is confusing. TODO: Expose pendingState or don't use it 30346 * during the merge. 30347 * 30348 * @param {ReactClass} publicInstance The instance that should rerender. 30349 * @param {object} partialState Next partial state to be merged with state. 30350 * @param {?function} callback Called after component is updated. 30351 * @param {?string} Name of the calling function in the public API. 30352 * @internal 30353 */ 30354 enqueueSetState: function (publicInstance, partialState, callback, callerName) { 30355 warnNoop(publicInstance, 'setState'); 30356 } 30357}; 30358 30359var emptyObject = {}; 30360 30361{ 30362 Object.freeze(emptyObject); 30363} 30364/** 30365 * Base class helpers for the updating state of a component. 30366 */ 30367 30368 30369function Component(props, context, updater) { 30370 this.props = props; 30371 this.context = context; // If a component has string refs, we will assign a different object later. 30372 30373 this.refs = emptyObject; // We initialize the default updater but the real one gets injected by the 30374 // renderer. 30375 30376 this.updater = updater || ReactNoopUpdateQueue; 30377} 30378 30379Component.prototype.isReactComponent = {}; 30380/** 30381 * Sets a subset of the state. Always use this to mutate 30382 * state. You should treat `this.state` as immutable. 30383 * 30384 * There is no guarantee that `this.state` will be immediately updated, so 30385 * accessing `this.state` after calling this method may return the old value. 30386 * 30387 * There is no guarantee that calls to `setState` will run synchronously, 30388 * as they may eventually be batched together. You can provide an optional 30389 * callback that will be executed when the call to setState is actually 30390 * completed. 30391 * 30392 * When a function is provided to setState, it will be called at some point in 30393 * the future (not synchronously). It will be called with the up to date 30394 * component arguments (state, props, context). These values can be different 30395 * from this.* because your function may be called after receiveProps but before 30396 * shouldComponentUpdate, and this new state, props, and context will not yet be 30397 * assigned to this. 30398 * 30399 * @param {object|function} partialState Next partial state or function to 30400 * produce next partial state to be merged with current state. 30401 * @param {?function} callback Called after state is updated. 30402 * @final 30403 * @protected 30404 */ 30405 30406Component.prototype.setState = function (partialState, callback) { 30407 if (!(typeof partialState === 'object' || typeof partialState === 'function' || partialState == null)) { 30408 { 30409 throw Error( "setState(...): takes an object of state variables to update or a function which returns an object of state variables." ); 30410 } 30411 } 30412 30413 this.updater.enqueueSetState(this, partialState, callback, 'setState'); 30414}; 30415/** 30416 * Forces an update. This should only be invoked when it is known with 30417 * certainty that we are **not** in a DOM transaction. 30418 * 30419 * You may want to call this when you know that some deeper aspect of the 30420 * component's state has changed but `setState` was not called. 30421 * 30422 * This will not invoke `shouldComponentUpdate`, but it will invoke 30423 * `componentWillUpdate` and `componentDidUpdate`. 30424 * 30425 * @param {?function} callback Called after update is complete. 30426 * @final 30427 * @protected 30428 */ 30429 30430 30431Component.prototype.forceUpdate = function (callback) { 30432 this.updater.enqueueForceUpdate(this, callback, 'forceUpdate'); 30433}; 30434/** 30435 * Deprecated APIs. These APIs used to exist on classic React classes but since 30436 * we would like to deprecate them, we're not going to move them over to this 30437 * modern base class. Instead, we define a getter that warns if it's accessed. 30438 */ 30439 30440 30441{ 30442 var deprecatedAPIs = { 30443 isMounted: ['isMounted', 'Instead, make sure to clean up subscriptions and pending requests in ' + 'componentWillUnmount to prevent memory leaks.'], 30444 replaceState: ['replaceState', 'Refactor your code to use setState instead (see ' + 'https://github.com/facebook/react/issues/3236).'] 30445 }; 30446 30447 var defineDeprecationWarning = function (methodName, info) { 30448 Object.defineProperty(Component.prototype, methodName, { 30449 get: function () { 30450 warn('%s(...) is deprecated in plain JavaScript React classes. %s', info[0], info[1]); 30451 30452 return undefined; 30453 } 30454 }); 30455 }; 30456 30457 for (var fnName in deprecatedAPIs) { 30458 if (deprecatedAPIs.hasOwnProperty(fnName)) { 30459 defineDeprecationWarning(fnName, deprecatedAPIs[fnName]); 30460 } 30461 } 30462} 30463 30464function ComponentDummy() {} 30465 30466ComponentDummy.prototype = Component.prototype; 30467/** 30468 * Convenience component with default shallow equality check for sCU. 30469 */ 30470 30471function PureComponent(props, context, updater) { 30472 this.props = props; 30473 this.context = context; // If a component has string refs, we will assign a different object later. 30474 30475 this.refs = emptyObject; 30476 this.updater = updater || ReactNoopUpdateQueue; 30477} 30478 30479var pureComponentPrototype = PureComponent.prototype = new ComponentDummy(); 30480pureComponentPrototype.constructor = PureComponent; // Avoid an extra prototype jump for these methods. 30481 30482_assign(pureComponentPrototype, Component.prototype); 30483 30484pureComponentPrototype.isPureReactComponent = true; 30485 30486// an immutable object with a single mutable value 30487function createRef() { 30488 var refObject = { 30489 current: null 30490 }; 30491 30492 { 30493 Object.seal(refObject); 30494 } 30495 30496 return refObject; 30497} 30498 30499function getWrappedName(outerType, innerType, wrapperName) { 30500 var functionName = innerType.displayName || innerType.name || ''; 30501 return outerType.displayName || (functionName !== '' ? wrapperName + "(" + functionName + ")" : wrapperName); 30502} 30503 30504function getContextName(type) { 30505 return type.displayName || 'Context'; 30506} 30507 30508function getComponentName(type) { 30509 if (type == null) { 30510 // Host root, text node or just invalid type. 30511 return null; 30512 } 30513 30514 { 30515 if (typeof type.tag === 'number') { 30516 error('Received an unexpected object in getComponentName(). ' + 'This is likely a bug in React. Please file an issue.'); 30517 } 30518 } 30519 30520 if (typeof type === 'function') { 30521 return type.displayName || type.name || null; 30522 } 30523 30524 if (typeof type === 'string') { 30525 return type; 30526 } 30527 30528 switch (type) { 30529 case exports.Fragment: 30530 return 'Fragment'; 30531 30532 case REACT_PORTAL_TYPE: 30533 return 'Portal'; 30534 30535 case exports.Profiler: 30536 return 'Profiler'; 30537 30538 case exports.StrictMode: 30539 return 'StrictMode'; 30540 30541 case exports.Suspense: 30542 return 'Suspense'; 30543 30544 case REACT_SUSPENSE_LIST_TYPE: 30545 return 'SuspenseList'; 30546 } 30547 30548 if (typeof type === 'object') { 30549 switch (type.$$typeof) { 30550 case REACT_CONTEXT_TYPE: 30551 var context = type; 30552 return getContextName(context) + '.Consumer'; 30553 30554 case REACT_PROVIDER_TYPE: 30555 var provider = type; 30556 return getContextName(provider._context) + '.Provider'; 30557 30558 case REACT_FORWARD_REF_TYPE: 30559 return getWrappedName(type, type.render, 'ForwardRef'); 30560 30561 case REACT_MEMO_TYPE: 30562 return getComponentName(type.type); 30563 30564 case REACT_BLOCK_TYPE: 30565 return getComponentName(type._render); 30566 30567 case REACT_LAZY_TYPE: 30568 { 30569 var lazyComponent = type; 30570 var payload = lazyComponent._payload; 30571 var init = lazyComponent._init; 30572 30573 try { 30574 return getComponentName(init(payload)); 30575 } catch (x) { 30576 return null; 30577 } 30578 } 30579 } 30580 } 30581 30582 return null; 30583} 30584 30585var hasOwnProperty = Object.prototype.hasOwnProperty; 30586var RESERVED_PROPS = { 30587 key: true, 30588 ref: true, 30589 __self: true, 30590 __source: true 30591}; 30592var specialPropKeyWarningShown, specialPropRefWarningShown, didWarnAboutStringRefs; 30593 30594{ 30595 didWarnAboutStringRefs = {}; 30596} 30597 30598function hasValidRef(config) { 30599 { 30600 if (hasOwnProperty.call(config, 'ref')) { 30601 var getter = Object.getOwnPropertyDescriptor(config, 'ref').get; 30602 30603 if (getter && getter.isReactWarning) { 30604 return false; 30605 } 30606 } 30607 } 30608 30609 return config.ref !== undefined; 30610} 30611 30612function hasValidKey(config) { 30613 { 30614 if (hasOwnProperty.call(config, 'key')) { 30615 var getter = Object.getOwnPropertyDescriptor(config, 'key').get; 30616 30617 if (getter && getter.isReactWarning) { 30618 return false; 30619 } 30620 } 30621 } 30622 30623 return config.key !== undefined; 30624} 30625 30626function defineKeyPropWarningGetter(props, displayName) { 30627 var warnAboutAccessingKey = function () { 30628 { 30629 if (!specialPropKeyWarningShown) { 30630 specialPropKeyWarningShown = true; 30631 30632 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); 30633 } 30634 } 30635 }; 30636 30637 warnAboutAccessingKey.isReactWarning = true; 30638 Object.defineProperty(props, 'key', { 30639 get: warnAboutAccessingKey, 30640 configurable: true 30641 }); 30642} 30643 30644function defineRefPropWarningGetter(props, displayName) { 30645 var warnAboutAccessingRef = function () { 30646 { 30647 if (!specialPropRefWarningShown) { 30648 specialPropRefWarningShown = true; 30649 30650 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); 30651 } 30652 } 30653 }; 30654 30655 warnAboutAccessingRef.isReactWarning = true; 30656 Object.defineProperty(props, 'ref', { 30657 get: warnAboutAccessingRef, 30658 configurable: true 30659 }); 30660} 30661 30662function warnIfStringRefCannotBeAutoConverted(config) { 30663 { 30664 if (typeof config.ref === 'string' && ReactCurrentOwner.current && config.__self && ReactCurrentOwner.current.stateNode !== config.__self) { 30665 var componentName = getComponentName(ReactCurrentOwner.current.type); 30666 30667 if (!didWarnAboutStringRefs[componentName]) { 30668 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); 30669 30670 didWarnAboutStringRefs[componentName] = true; 30671 } 30672 } 30673 } 30674} 30675/** 30676 * Factory method to create a new React element. This no longer adheres to 30677 * the class pattern, so do not use new to call it. Also, instanceof check 30678 * will not work. Instead test $$typeof field against Symbol.for('react.element') to check 30679 * if something is a React Element. 30680 * 30681 * @param {*} type 30682 * @param {*} props 30683 * @param {*} key 30684 * @param {string|object} ref 30685 * @param {*} owner 30686 * @param {*} self A *temporary* helper to detect places where `this` is 30687 * different from the `owner` when React.createElement is called, so that we 30688 * can warn. We want to get rid of owner and replace string `ref`s with arrow 30689 * functions, and as long as `this` and owner are the same, there will be no 30690 * change in behavior. 30691 * @param {*} source An annotation object (added by a transpiler or otherwise) 30692 * indicating filename, line number, and/or other information. 30693 * @internal 30694 */ 30695 30696 30697var ReactElement = function (type, key, ref, self, source, owner, props) { 30698 var element = { 30699 // This tag allows us to uniquely identify this as a React Element 30700 $$typeof: REACT_ELEMENT_TYPE, 30701 // Built-in properties that belong on the element 30702 type: type, 30703 key: key, 30704 ref: ref, 30705 props: props, 30706 // Record the component responsible for creating this element. 30707 _owner: owner 30708 }; 30709 30710 { 30711 // The validation flag is currently mutative. We put it on 30712 // an external backing store so that we can freeze the whole object. 30713 // This can be replaced with a WeakMap once they are implemented in 30714 // commonly used development environments. 30715 element._store = {}; // To make comparing ReactElements easier for testing purposes, we make 30716 // the validation flag non-enumerable (where possible, which should 30717 // include every environment we run tests in), so the test framework 30718 // ignores it. 30719 30720 Object.defineProperty(element._store, 'validated', { 30721 configurable: false, 30722 enumerable: false, 30723 writable: true, 30724 value: false 30725 }); // self and source are DEV only properties. 30726 30727 Object.defineProperty(element, '_self', { 30728 configurable: false, 30729 enumerable: false, 30730 writable: false, 30731 value: self 30732 }); // Two elements created in two different places should be considered 30733 // equal for testing purposes and therefore we hide it from enumeration. 30734 30735 Object.defineProperty(element, '_source', { 30736 configurable: false, 30737 enumerable: false, 30738 writable: false, 30739 value: source 30740 }); 30741 30742 if (Object.freeze) { 30743 Object.freeze(element.props); 30744 Object.freeze(element); 30745 } 30746 } 30747 30748 return element; 30749}; 30750/** 30751 * Create and return a new ReactElement of the given type. 30752 * See https://reactjs.org/docs/react-api.html#createelement 30753 */ 30754 30755function createElement(type, config, children) { 30756 var propName; // Reserved names are extracted 30757 30758 var props = {}; 30759 var key = null; 30760 var ref = null; 30761 var self = null; 30762 var source = null; 30763 30764 if (config != null) { 30765 if (hasValidRef(config)) { 30766 ref = config.ref; 30767 30768 { 30769 warnIfStringRefCannotBeAutoConverted(config); 30770 } 30771 } 30772 30773 if (hasValidKey(config)) { 30774 key = '' + config.key; 30775 } 30776 30777 self = config.__self === undefined ? null : config.__self; 30778 source = config.__source === undefined ? null : config.__source; // Remaining properties are added to a new props object 30779 30780 for (propName in config) { 30781 if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) { 30782 props[propName] = config[propName]; 30783 } 30784 } 30785 } // Children can be more than one argument, and those are transferred onto 30786 // the newly allocated props object. 30787 30788 30789 var childrenLength = arguments.length - 2; 30790 30791 if (childrenLength === 1) { 30792 props.children = children; 30793 } else if (childrenLength > 1) { 30794 var childArray = Array(childrenLength); 30795 30796 for (var i = 0; i < childrenLength; i++) { 30797 childArray[i] = arguments[i + 2]; 30798 } 30799 30800 { 30801 if (Object.freeze) { 30802 Object.freeze(childArray); 30803 } 30804 } 30805 30806 props.children = childArray; 30807 } // Resolve default props 30808 30809 30810 if (type && type.defaultProps) { 30811 var defaultProps = type.defaultProps; 30812 30813 for (propName in defaultProps) { 30814 if (props[propName] === undefined) { 30815 props[propName] = defaultProps[propName]; 30816 } 30817 } 30818 } 30819 30820 { 30821 if (key || ref) { 30822 var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type; 30823 30824 if (key) { 30825 defineKeyPropWarningGetter(props, displayName); 30826 } 30827 30828 if (ref) { 30829 defineRefPropWarningGetter(props, displayName); 30830 } 30831 } 30832 } 30833 30834 return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props); 30835} 30836function cloneAndReplaceKey(oldElement, newKey) { 30837 var newElement = ReactElement(oldElement.type, newKey, oldElement.ref, oldElement._self, oldElement._source, oldElement._owner, oldElement.props); 30838 return newElement; 30839} 30840/** 30841 * Clone and return a new ReactElement using element as the starting point. 30842 * See https://reactjs.org/docs/react-api.html#cloneelement 30843 */ 30844 30845function cloneElement(element, config, children) { 30846 if (!!(element === null || element === undefined)) { 30847 { 30848 throw Error( "React.cloneElement(...): The argument must be a React element, but you passed " + element + "." ); 30849 } 30850 } 30851 30852 var propName; // Original props are copied 30853 30854 var props = _assign({}, element.props); // Reserved names are extracted 30855 30856 30857 var key = element.key; 30858 var ref = element.ref; // Self is preserved since the owner is preserved. 30859 30860 var self = element._self; // Source is preserved since cloneElement is unlikely to be targeted by a 30861 // transpiler, and the original source is probably a better indicator of the 30862 // true owner. 30863 30864 var source = element._source; // Owner will be preserved, unless ref is overridden 30865 30866 var owner = element._owner; 30867 30868 if (config != null) { 30869 if (hasValidRef(config)) { 30870 // Silently steal the ref from the parent. 30871 ref = config.ref; 30872 owner = ReactCurrentOwner.current; 30873 } 30874 30875 if (hasValidKey(config)) { 30876 key = '' + config.key; 30877 } // Remaining properties override existing props 30878 30879 30880 var defaultProps; 30881 30882 if (element.type && element.type.defaultProps) { 30883 defaultProps = element.type.defaultProps; 30884 } 30885 30886 for (propName in config) { 30887 if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) { 30888 if (config[propName] === undefined && defaultProps !== undefined) { 30889 // Resolve default props 30890 props[propName] = defaultProps[propName]; 30891 } else { 30892 props[propName] = config[propName]; 30893 } 30894 } 30895 } 30896 } // Children can be more than one argument, and those are transferred onto 30897 // the newly allocated props object. 30898 30899 30900 var childrenLength = arguments.length - 2; 30901 30902 if (childrenLength === 1) { 30903 props.children = children; 30904 } else if (childrenLength > 1) { 30905 var childArray = Array(childrenLength); 30906 30907 for (var i = 0; i < childrenLength; i++) { 30908 childArray[i] = arguments[i + 2]; 30909 } 30910 30911 props.children = childArray; 30912 } 30913 30914 return ReactElement(element.type, key, ref, self, source, owner, props); 30915} 30916/** 30917 * Verifies the object is a ReactElement. 30918 * See https://reactjs.org/docs/react-api.html#isvalidelement 30919 * @param {?object} object 30920 * @return {boolean} True if `object` is a ReactElement. 30921 * @final 30922 */ 30923 30924function isValidElement(object) { 30925 return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE; 30926} 30927 30928var SEPARATOR = '.'; 30929var SUBSEPARATOR = ':'; 30930/** 30931 * Escape and wrap key so it is safe to use as a reactid 30932 * 30933 * @param {string} key to be escaped. 30934 * @return {string} the escaped key. 30935 */ 30936 30937function escape(key) { 30938 var escapeRegex = /[=:]/g; 30939 var escaperLookup = { 30940 '=': '=0', 30941 ':': '=2' 30942 }; 30943 var escapedString = key.replace(escapeRegex, function (match) { 30944 return escaperLookup[match]; 30945 }); 30946 return '$' + escapedString; 30947} 30948/** 30949 * TODO: Test that a single child and an array with one item have the same key 30950 * pattern. 30951 */ 30952 30953 30954var didWarnAboutMaps = false; 30955var userProvidedKeyEscapeRegex = /\/+/g; 30956 30957function escapeUserProvidedKey(text) { 30958 return text.replace(userProvidedKeyEscapeRegex, '$&/'); 30959} 30960/** 30961 * Generate a key string that identifies a element within a set. 30962 * 30963 * @param {*} element A element that could contain a manual key. 30964 * @param {number} index Index that is used if a manual key is not provided. 30965 * @return {string} 30966 */ 30967 30968 30969function getElementKey(element, index) { 30970 // Do some typechecking here since we call this blindly. We want to ensure 30971 // that we don't block potential future ES APIs. 30972 if (typeof element === 'object' && element !== null && element.key != null) { 30973 // Explicit key 30974 return escape('' + element.key); 30975 } // Implicit key determined by the index in the set 30976 30977 30978 return index.toString(36); 30979} 30980 30981function mapIntoArray(children, array, escapedPrefix, nameSoFar, callback) { 30982 var type = typeof children; 30983 30984 if (type === 'undefined' || type === 'boolean') { 30985 // All of the above are perceived as null. 30986 children = null; 30987 } 30988 30989 var invokeCallback = false; 30990 30991 if (children === null) { 30992 invokeCallback = true; 30993 } else { 30994 switch (type) { 30995 case 'string': 30996 case 'number': 30997 invokeCallback = true; 30998 break; 30999 31000 case 'object': 31001 switch (children.$$typeof) { 31002 case REACT_ELEMENT_TYPE: 31003 case REACT_PORTAL_TYPE: 31004 invokeCallback = true; 31005 } 31006 31007 } 31008 } 31009 31010 if (invokeCallback) { 31011 var _child = children; 31012 var mappedChild = callback(_child); // If it's the only child, treat the name as if it was wrapped in an array 31013 // so that it's consistent if the number of children grows: 31014 31015 var childKey = nameSoFar === '' ? SEPARATOR + getElementKey(_child, 0) : nameSoFar; 31016 31017 if (Array.isArray(mappedChild)) { 31018 var escapedChildKey = ''; 31019 31020 if (childKey != null) { 31021 escapedChildKey = escapeUserProvidedKey(childKey) + '/'; 31022 } 31023 31024 mapIntoArray(mappedChild, array, escapedChildKey, '', function (c) { 31025 return c; 31026 }); 31027 } else if (mappedChild != null) { 31028 if (isValidElement(mappedChild)) { 31029 mappedChild = cloneAndReplaceKey(mappedChild, // Keep both the (mapped) and old keys if they differ, just as 31030 // traverseAllChildren used to do for objects as children 31031 escapedPrefix + ( // $FlowFixMe Flow incorrectly thinks React.Portal doesn't have a key 31032 mappedChild.key && (!_child || _child.key !== mappedChild.key) ? // $FlowFixMe Flow incorrectly thinks existing element's key can be a number 31033 escapeUserProvidedKey('' + mappedChild.key) + '/' : '') + childKey); 31034 } 31035 31036 array.push(mappedChild); 31037 } 31038 31039 return 1; 31040 } 31041 31042 var child; 31043 var nextName; 31044 var subtreeCount = 0; // Count of children found in the current subtree. 31045 31046 var nextNamePrefix = nameSoFar === '' ? SEPARATOR : nameSoFar + SUBSEPARATOR; 31047 31048 if (Array.isArray(children)) { 31049 for (var i = 0; i < children.length; i++) { 31050 child = children[i]; 31051 nextName = nextNamePrefix + getElementKey(child, i); 31052 subtreeCount += mapIntoArray(child, array, escapedPrefix, nextName, callback); 31053 } 31054 } else { 31055 var iteratorFn = getIteratorFn(children); 31056 31057 if (typeof iteratorFn === 'function') { 31058 var iterableChildren = children; 31059 31060 { 31061 // Warn about using Maps as children 31062 if (iteratorFn === iterableChildren.entries) { 31063 if (!didWarnAboutMaps) { 31064 warn('Using Maps as children is not supported. ' + 'Use an array of keyed ReactElements instead.'); 31065 } 31066 31067 didWarnAboutMaps = true; 31068 } 31069 } 31070 31071 var iterator = iteratorFn.call(iterableChildren); 31072 var step; 31073 var ii = 0; 31074 31075 while (!(step = iterator.next()).done) { 31076 child = step.value; 31077 nextName = nextNamePrefix + getElementKey(child, ii++); 31078 subtreeCount += mapIntoArray(child, array, escapedPrefix, nextName, callback); 31079 } 31080 } else if (type === 'object') { 31081 var childrenString = '' + children; 31082 31083 { 31084 { 31085 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." ); 31086 } 31087 } 31088 } 31089 } 31090 31091 return subtreeCount; 31092} 31093 31094/** 31095 * Maps children that are typically specified as `props.children`. 31096 * 31097 * See https://reactjs.org/docs/react-api.html#reactchildrenmap 31098 * 31099 * The provided mapFunction(child, index) will be called for each 31100 * leaf child. 31101 * 31102 * @param {?*} children Children tree container. 31103 * @param {function(*, int)} func The map function. 31104 * @param {*} context Context for mapFunction. 31105 * @return {object} Object containing the ordered map of results. 31106 */ 31107function mapChildren(children, func, context) { 31108 if (children == null) { 31109 return children; 31110 } 31111 31112 var result = []; 31113 var count = 0; 31114 mapIntoArray(children, result, '', '', function (child) { 31115 return func.call(context, child, count++); 31116 }); 31117 return result; 31118} 31119/** 31120 * Count the number of children that are typically specified as 31121 * `props.children`. 31122 * 31123 * See https://reactjs.org/docs/react-api.html#reactchildrencount 31124 * 31125 * @param {?*} children Children tree container. 31126 * @return {number} The number of children. 31127 */ 31128 31129 31130function countChildren(children) { 31131 var n = 0; 31132 mapChildren(children, function () { 31133 n++; // Don't return anything 31134 }); 31135 return n; 31136} 31137 31138/** 31139 * Iterates through children that are typically specified as `props.children`. 31140 * 31141 * See https://reactjs.org/docs/react-api.html#reactchildrenforeach 31142 * 31143 * The provided forEachFunc(child, index) will be called for each 31144 * leaf child. 31145 * 31146 * @param {?*} children Children tree container. 31147 * @param {function(*, int)} forEachFunc 31148 * @param {*} forEachContext Context for forEachContext. 31149 */ 31150function forEachChildren(children, forEachFunc, forEachContext) { 31151 mapChildren(children, function () { 31152 forEachFunc.apply(this, arguments); // Don't return anything. 31153 }, forEachContext); 31154} 31155/** 31156 * Flatten a children object (typically specified as `props.children`) and 31157 * return an array with appropriately re-keyed children. 31158 * 31159 * See https://reactjs.org/docs/react-api.html#reactchildrentoarray 31160 */ 31161 31162 31163function toArray(children) { 31164 return mapChildren(children, function (child) { 31165 return child; 31166 }) || []; 31167} 31168/** 31169 * Returns the first child in a collection of children and verifies that there 31170 * is only one child in the collection. 31171 * 31172 * See https://reactjs.org/docs/react-api.html#reactchildrenonly 31173 * 31174 * The current implementation of this function assumes that a single child gets 31175 * passed without a wrapper, but the purpose of this helper function is to 31176 * abstract away the particular structure of children. 31177 * 31178 * @param {?object} children Child collection structure. 31179 * @return {ReactElement} The first and only `ReactElement` contained in the 31180 * structure. 31181 */ 31182 31183 31184function onlyChild(children) { 31185 if (!isValidElement(children)) { 31186 { 31187 throw Error( "React.Children.only expected to receive a single React element child." ); 31188 } 31189 } 31190 31191 return children; 31192} 31193 31194function createContext(defaultValue, calculateChangedBits) { 31195 if (calculateChangedBits === undefined) { 31196 calculateChangedBits = null; 31197 } else { 31198 { 31199 if (calculateChangedBits !== null && typeof calculateChangedBits !== 'function') { 31200 error('createContext: Expected the optional second argument to be a ' + 'function. Instead received: %s', calculateChangedBits); 31201 } 31202 } 31203 } 31204 31205 var context = { 31206 $$typeof: REACT_CONTEXT_TYPE, 31207 _calculateChangedBits: calculateChangedBits, 31208 // As a workaround to support multiple concurrent renderers, we categorize 31209 // some renderers as primary and others as secondary. We only expect 31210 // there to be two concurrent renderers at most: React Native (primary) and 31211 // Fabric (secondary); React DOM (primary) and React ART (secondary). 31212 // Secondary renderers store their context values on separate fields. 31213 _currentValue: defaultValue, 31214 _currentValue2: defaultValue, 31215 // Used to track how many concurrent renderers this context currently 31216 // supports within in a single renderer. Such as parallel server rendering. 31217 _threadCount: 0, 31218 // These are circular 31219 Provider: null, 31220 Consumer: null 31221 }; 31222 context.Provider = { 31223 $$typeof: REACT_PROVIDER_TYPE, 31224 _context: context 31225 }; 31226 var hasWarnedAboutUsingNestedContextConsumers = false; 31227 var hasWarnedAboutUsingConsumerProvider = false; 31228 var hasWarnedAboutDisplayNameOnConsumer = false; 31229 31230 { 31231 // A separate object, but proxies back to the original context object for 31232 // backwards compatibility. It has a different $$typeof, so we can properly 31233 // warn for the incorrect usage of Context as a Consumer. 31234 var Consumer = { 31235 $$typeof: REACT_CONTEXT_TYPE, 31236 _context: context, 31237 _calculateChangedBits: context._calculateChangedBits 31238 }; // $FlowFixMe: Flow complains about not setting a value, which is intentional here 31239 31240 Object.defineProperties(Consumer, { 31241 Provider: { 31242 get: function () { 31243 if (!hasWarnedAboutUsingConsumerProvider) { 31244 hasWarnedAboutUsingConsumerProvider = true; 31245 31246 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?'); 31247 } 31248 31249 return context.Provider; 31250 }, 31251 set: function (_Provider) { 31252 context.Provider = _Provider; 31253 } 31254 }, 31255 _currentValue: { 31256 get: function () { 31257 return context._currentValue; 31258 }, 31259 set: function (_currentValue) { 31260 context._currentValue = _currentValue; 31261 } 31262 }, 31263 _currentValue2: { 31264 get: function () { 31265 return context._currentValue2; 31266 }, 31267 set: function (_currentValue2) { 31268 context._currentValue2 = _currentValue2; 31269 } 31270 }, 31271 _threadCount: { 31272 get: function () { 31273 return context._threadCount; 31274 }, 31275 set: function (_threadCount) { 31276 context._threadCount = _threadCount; 31277 } 31278 }, 31279 Consumer: { 31280 get: function () { 31281 if (!hasWarnedAboutUsingNestedContextConsumers) { 31282 hasWarnedAboutUsingNestedContextConsumers = true; 31283 31284 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?'); 31285 } 31286 31287 return context.Consumer; 31288 } 31289 }, 31290 displayName: { 31291 get: function () { 31292 return context.displayName; 31293 }, 31294 set: function (displayName) { 31295 if (!hasWarnedAboutDisplayNameOnConsumer) { 31296 warn('Setting `displayName` on Context.Consumer has no effect. ' + "You should set it directly on the context with Context.displayName = '%s'.", displayName); 31297 31298 hasWarnedAboutDisplayNameOnConsumer = true; 31299 } 31300 } 31301 } 31302 }); // $FlowFixMe: Flow complains about missing properties because it doesn't understand defineProperty 31303 31304 context.Consumer = Consumer; 31305 } 31306 31307 { 31308 context._currentRenderer = null; 31309 context._currentRenderer2 = null; 31310 } 31311 31312 return context; 31313} 31314 31315var Uninitialized = -1; 31316var Pending = 0; 31317var Resolved = 1; 31318var Rejected = 2; 31319 31320function lazyInitializer(payload) { 31321 if (payload._status === Uninitialized) { 31322 var ctor = payload._result; 31323 var thenable = ctor(); // Transition to the next state. 31324 31325 var pending = payload; 31326 pending._status = Pending; 31327 pending._result = thenable; 31328 thenable.then(function (moduleObject) { 31329 if (payload._status === Pending) { 31330 var defaultExport = moduleObject.default; 31331 31332 { 31333 if (defaultExport === undefined) { 31334 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. 31335 'const MyComponent = lazy(() => imp' + "ort('./MyComponent'))", moduleObject); 31336 } 31337 } // Transition to the next state. 31338 31339 31340 var resolved = payload; 31341 resolved._status = Resolved; 31342 resolved._result = defaultExport; 31343 } 31344 }, function (error) { 31345 if (payload._status === Pending) { 31346 // Transition to the next state. 31347 var rejected = payload; 31348 rejected._status = Rejected; 31349 rejected._result = error; 31350 } 31351 }); 31352 } 31353 31354 if (payload._status === Resolved) { 31355 return payload._result; 31356 } else { 31357 throw payload._result; 31358 } 31359} 31360 31361function lazy(ctor) { 31362 var payload = { 31363 // We use these fields to store the result. 31364 _status: -1, 31365 _result: ctor 31366 }; 31367 var lazyType = { 31368 $$typeof: REACT_LAZY_TYPE, 31369 _payload: payload, 31370 _init: lazyInitializer 31371 }; 31372 31373 { 31374 // In production, this would just set it on the object. 31375 var defaultProps; 31376 var propTypes; // $FlowFixMe 31377 31378 Object.defineProperties(lazyType, { 31379 defaultProps: { 31380 configurable: true, 31381 get: function () { 31382 return defaultProps; 31383 }, 31384 set: function (newDefaultProps) { 31385 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.'); 31386 31387 defaultProps = newDefaultProps; // Match production behavior more closely: 31388 // $FlowFixMe 31389 31390 Object.defineProperty(lazyType, 'defaultProps', { 31391 enumerable: true 31392 }); 31393 } 31394 }, 31395 propTypes: { 31396 configurable: true, 31397 get: function () { 31398 return propTypes; 31399 }, 31400 set: function (newPropTypes) { 31401 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.'); 31402 31403 propTypes = newPropTypes; // Match production behavior more closely: 31404 // $FlowFixMe 31405 31406 Object.defineProperty(lazyType, 'propTypes', { 31407 enumerable: true 31408 }); 31409 } 31410 } 31411 }); 31412 } 31413 31414 return lazyType; 31415} 31416 31417function forwardRef(render) { 31418 { 31419 if (render != null && render.$$typeof === REACT_MEMO_TYPE) { 31420 error('forwardRef requires a render function but received a `memo` ' + 'component. Instead of forwardRef(memo(...)), use ' + 'memo(forwardRef(...)).'); 31421 } else if (typeof render !== 'function') { 31422 error('forwardRef requires a render function but was given %s.', render === null ? 'null' : typeof render); 31423 } else { 31424 if (render.length !== 0 && render.length !== 2) { 31425 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.'); 31426 } 31427 } 31428 31429 if (render != null) { 31430 if (render.defaultProps != null || render.propTypes != null) { 31431 error('forwardRef render functions do not support propTypes or defaultProps. ' + 'Did you accidentally pass a React component?'); 31432 } 31433 } 31434 } 31435 31436 var elementType = { 31437 $$typeof: REACT_FORWARD_REF_TYPE, 31438 render: render 31439 }; 31440 31441 { 31442 var ownName; 31443 Object.defineProperty(elementType, 'displayName', { 31444 enumerable: false, 31445 configurable: true, 31446 get: function () { 31447 return ownName; 31448 }, 31449 set: function (name) { 31450 ownName = name; 31451 31452 if (render.displayName == null) { 31453 render.displayName = name; 31454 } 31455 } 31456 }); 31457 } 31458 31459 return elementType; 31460} 31461 31462// Filter certain DOM attributes (e.g. src, href) if their values are empty strings. 31463 31464var enableScopeAPI = false; // Experimental Create Event Handle API. 31465 31466function isValidElementType(type) { 31467 if (typeof type === 'string' || typeof type === 'function') { 31468 return true; 31469 } // Note: typeof might be other than 'symbol' or 'number' (e.g. if it's a polyfill). 31470 31471 31472 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 ) { 31473 return true; 31474 } 31475 31476 if (typeof type === 'object' && type !== null) { 31477 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) { 31478 return true; 31479 } 31480 } 31481 31482 return false; 31483} 31484 31485function memo(type, compare) { 31486 { 31487 if (!isValidElementType(type)) { 31488 error('memo: The first argument must be a component. Instead ' + 'received: %s', type === null ? 'null' : typeof type); 31489 } 31490 } 31491 31492 var elementType = { 31493 $$typeof: REACT_MEMO_TYPE, 31494 type: type, 31495 compare: compare === undefined ? null : compare 31496 }; 31497 31498 { 31499 var ownName; 31500 Object.defineProperty(elementType, 'displayName', { 31501 enumerable: false, 31502 configurable: true, 31503 get: function () { 31504 return ownName; 31505 }, 31506 set: function (name) { 31507 ownName = name; 31508 31509 if (type.displayName == null) { 31510 type.displayName = name; 31511 } 31512 } 31513 }); 31514 } 31515 31516 return elementType; 31517} 31518 31519function resolveDispatcher() { 31520 var dispatcher = ReactCurrentDispatcher.current; 31521 31522 if (!(dispatcher !== null)) { 31523 { 31524 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." ); 31525 } 31526 } 31527 31528 return dispatcher; 31529} 31530 31531function useContext(Context, unstable_observedBits) { 31532 var dispatcher = resolveDispatcher(); 31533 31534 { 31535 if (unstable_observedBits !== undefined) { 31536 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' : ''); 31537 } // TODO: add a more generic warning for invalid values. 31538 31539 31540 if (Context._context !== undefined) { 31541 var realContext = Context._context; // Don't deduplicate because this legitimately causes bugs 31542 // and nobody should be using this in existing code. 31543 31544 if (realContext.Consumer === Context) { 31545 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?'); 31546 } else if (realContext.Provider === Context) { 31547 error('Calling useContext(Context.Provider) is not supported. ' + 'Did you mean to call useContext(Context) instead?'); 31548 } 31549 } 31550 } 31551 31552 return dispatcher.useContext(Context, unstable_observedBits); 31553} 31554function useState(initialState) { 31555 var dispatcher = resolveDispatcher(); 31556 return dispatcher.useState(initialState); 31557} 31558function useReducer(reducer, initialArg, init) { 31559 var dispatcher = resolveDispatcher(); 31560 return dispatcher.useReducer(reducer, initialArg, init); 31561} 31562function useRef(initialValue) { 31563 var dispatcher = resolveDispatcher(); 31564 return dispatcher.useRef(initialValue); 31565} 31566function useEffect(create, deps) { 31567 var dispatcher = resolveDispatcher(); 31568 return dispatcher.useEffect(create, deps); 31569} 31570function useLayoutEffect(create, deps) { 31571 var dispatcher = resolveDispatcher(); 31572 return dispatcher.useLayoutEffect(create, deps); 31573} 31574function useCallback(callback, deps) { 31575 var dispatcher = resolveDispatcher(); 31576 return dispatcher.useCallback(callback, deps); 31577} 31578function useMemo(create, deps) { 31579 var dispatcher = resolveDispatcher(); 31580 return dispatcher.useMemo(create, deps); 31581} 31582function useImperativeHandle(ref, create, deps) { 31583 var dispatcher = resolveDispatcher(); 31584 return dispatcher.useImperativeHandle(ref, create, deps); 31585} 31586function useDebugValue(value, formatterFn) { 31587 { 31588 var dispatcher = resolveDispatcher(); 31589 return dispatcher.useDebugValue(value, formatterFn); 31590 } 31591} 31592 31593// Helpers to patch console.logs to avoid logging during side-effect free 31594// replaying on render function. This currently only patches the object 31595// lazily which won't cover if the log function was extracted eagerly. 31596// We could also eagerly patch the method. 31597var disabledDepth = 0; 31598var prevLog; 31599var prevInfo; 31600var prevWarn; 31601var prevError; 31602var prevGroup; 31603var prevGroupCollapsed; 31604var prevGroupEnd; 31605 31606function disabledLog() {} 31607 31608disabledLog.__reactDisabledLog = true; 31609function disableLogs() { 31610 { 31611 if (disabledDepth === 0) { 31612 /* eslint-disable react-internal/no-production-logging */ 31613 prevLog = console.log; 31614 prevInfo = console.info; 31615 prevWarn = console.warn; 31616 prevError = console.error; 31617 prevGroup = console.group; 31618 prevGroupCollapsed = console.groupCollapsed; 31619 prevGroupEnd = console.groupEnd; // https://github.com/facebook/react/issues/19099 31620 31621 var props = { 31622 configurable: true, 31623 enumerable: true, 31624 value: disabledLog, 31625 writable: true 31626 }; // $FlowFixMe Flow thinks console is immutable. 31627 31628 Object.defineProperties(console, { 31629 info: props, 31630 log: props, 31631 warn: props, 31632 error: props, 31633 group: props, 31634 groupCollapsed: props, 31635 groupEnd: props 31636 }); 31637 /* eslint-enable react-internal/no-production-logging */ 31638 } 31639 31640 disabledDepth++; 31641 } 31642} 31643function reenableLogs() { 31644 { 31645 disabledDepth--; 31646 31647 if (disabledDepth === 0) { 31648 /* eslint-disable react-internal/no-production-logging */ 31649 var props = { 31650 configurable: true, 31651 enumerable: true, 31652 writable: true 31653 }; // $FlowFixMe Flow thinks console is immutable. 31654 31655 Object.defineProperties(console, { 31656 log: _assign({}, props, { 31657 value: prevLog 31658 }), 31659 info: _assign({}, props, { 31660 value: prevInfo 31661 }), 31662 warn: _assign({}, props, { 31663 value: prevWarn 31664 }), 31665 error: _assign({}, props, { 31666 value: prevError 31667 }), 31668 group: _assign({}, props, { 31669 value: prevGroup 31670 }), 31671 groupCollapsed: _assign({}, props, { 31672 value: prevGroupCollapsed 31673 }), 31674 groupEnd: _assign({}, props, { 31675 value: prevGroupEnd 31676 }) 31677 }); 31678 /* eslint-enable react-internal/no-production-logging */ 31679 } 31680 31681 if (disabledDepth < 0) { 31682 error('disabledDepth fell below zero. ' + 'This is a bug in React. Please file an issue.'); 31683 } 31684 } 31685} 31686 31687var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher; 31688var prefix; 31689function describeBuiltInComponentFrame(name, source, ownerFn) { 31690 { 31691 if (prefix === undefined) { 31692 // Extract the VM specific prefix used by each line. 31693 try { 31694 throw Error(); 31695 } catch (x) { 31696 var match = x.stack.trim().match(/\n( *(at )?)/); 31697 prefix = match && match[1] || ''; 31698 } 31699 } // We use the prefix to ensure our stacks line up with native stack frames. 31700 31701 31702 return '\n' + prefix + name; 31703 } 31704} 31705var reentry = false; 31706var componentFrameCache; 31707 31708{ 31709 var PossiblyWeakMap = typeof WeakMap === 'function' ? WeakMap : Map; 31710 componentFrameCache = new PossiblyWeakMap(); 31711} 31712 31713function describeNativeComponentFrame(fn, construct) { 31714 // If something asked for a stack inside a fake render, it should get ignored. 31715 if (!fn || reentry) { 31716 return ''; 31717 } 31718 31719 { 31720 var frame = componentFrameCache.get(fn); 31721 31722 if (frame !== undefined) { 31723 return frame; 31724 } 31725 } 31726 31727 var control; 31728 reentry = true; 31729 var previousPrepareStackTrace = Error.prepareStackTrace; // $FlowFixMe It does accept undefined. 31730 31731 Error.prepareStackTrace = undefined; 31732 var previousDispatcher; 31733 31734 { 31735 previousDispatcher = ReactCurrentDispatcher$1.current; // Set the dispatcher in DEV because this might be call in the render function 31736 // for warnings. 31737 31738 ReactCurrentDispatcher$1.current = null; 31739 disableLogs(); 31740 } 31741 31742 try { 31743 // This should throw. 31744 if (construct) { 31745 // Something should be setting the props in the constructor. 31746 var Fake = function () { 31747 throw Error(); 31748 }; // $FlowFixMe 31749 31750 31751 Object.defineProperty(Fake.prototype, 'props', { 31752 set: function () { 31753 // We use a throwing setter instead of frozen or non-writable props 31754 // because that won't throw in a non-strict mode function. 31755 throw Error(); 31756 } 31757 }); 31758 31759 if (typeof Reflect === 'object' && Reflect.construct) { 31760 // We construct a different control for this case to include any extra 31761 // frames added by the construct call. 31762 try { 31763 Reflect.construct(Fake, []); 31764 } catch (x) { 31765 control = x; 31766 } 31767 31768 Reflect.construct(fn, [], Fake); 31769 } else { 31770 try { 31771 Fake.call(); 31772 } catch (x) { 31773 control = x; 31774 } 31775 31776 fn.call(Fake.prototype); 31777 } 31778 } else { 31779 try { 31780 throw Error(); 31781 } catch (x) { 31782 control = x; 31783 } 31784 31785 fn(); 31786 } 31787 } catch (sample) { 31788 // This is inlined manually because closure doesn't do it for us. 31789 if (sample && control && typeof sample.stack === 'string') { 31790 // This extracts the first frame from the sample that isn't also in the control. 31791 // Skipping one frame that we assume is the frame that calls the two. 31792 var sampleLines = sample.stack.split('\n'); 31793 var controlLines = control.stack.split('\n'); 31794 var s = sampleLines.length - 1; 31795 var c = controlLines.length - 1; 31796 31797 while (s >= 1 && c >= 0 && sampleLines[s] !== controlLines[c]) { 31798 // We expect at least one stack frame to be shared. 31799 // Typically this will be the root most one. However, stack frames may be 31800 // cut off due to maximum stack limits. In this case, one maybe cut off 31801 // earlier than the other. We assume that the sample is longer or the same 31802 // and there for cut off earlier. So we should find the root most frame in 31803 // the sample somewhere in the control. 31804 c--; 31805 } 31806 31807 for (; s >= 1 && c >= 0; s--, c--) { 31808 // Next we find the first one that isn't the same which should be the 31809 // frame that called our sample function and the control. 31810 if (sampleLines[s] !== controlLines[c]) { 31811 // In V8, the first line is describing the message but other VMs don't. 31812 // If we're about to return the first line, and the control is also on the same 31813 // line, that's a pretty good indicator that our sample threw at same line as 31814 // the control. I.e. before we entered the sample frame. So we ignore this result. 31815 // This can happen if you passed a class to function component, or non-function. 31816 if (s !== 1 || c !== 1) { 31817 do { 31818 s--; 31819 c--; // We may still have similar intermediate frames from the construct call. 31820 // The next one that isn't the same should be our match though. 31821 31822 if (c < 0 || sampleLines[s] !== controlLines[c]) { 31823 // V8 adds a "new" prefix for native classes. Let's remove it to make it prettier. 31824 var _frame = '\n' + sampleLines[s].replace(' at new ', ' at '); 31825 31826 { 31827 if (typeof fn === 'function') { 31828 componentFrameCache.set(fn, _frame); 31829 } 31830 } // Return the line we found. 31831 31832 31833 return _frame; 31834 } 31835 } while (s >= 1 && c >= 0); 31836 } 31837 31838 break; 31839 } 31840 } 31841 } 31842 } finally { 31843 reentry = false; 31844 31845 { 31846 ReactCurrentDispatcher$1.current = previousDispatcher; 31847 reenableLogs(); 31848 } 31849 31850 Error.prepareStackTrace = previousPrepareStackTrace; 31851 } // Fallback to just using the name if we couldn't make it throw. 31852 31853 31854 var name = fn ? fn.displayName || fn.name : ''; 31855 var syntheticFrame = name ? describeBuiltInComponentFrame(name) : ''; 31856 31857 { 31858 if (typeof fn === 'function') { 31859 componentFrameCache.set(fn, syntheticFrame); 31860 } 31861 } 31862 31863 return syntheticFrame; 31864} 31865function describeFunctionComponentFrame(fn, source, ownerFn) { 31866 { 31867 return describeNativeComponentFrame(fn, false); 31868 } 31869} 31870 31871function shouldConstruct(Component) { 31872 var prototype = Component.prototype; 31873 return !!(prototype && prototype.isReactComponent); 31874} 31875 31876function describeUnknownElementTypeFrameInDEV(type, source, ownerFn) { 31877 31878 if (type == null) { 31879 return ''; 31880 } 31881 31882 if (typeof type === 'function') { 31883 { 31884 return describeNativeComponentFrame(type, shouldConstruct(type)); 31885 } 31886 } 31887 31888 if (typeof type === 'string') { 31889 return describeBuiltInComponentFrame(type); 31890 } 31891 31892 switch (type) { 31893 case exports.Suspense: 31894 return describeBuiltInComponentFrame('Suspense'); 31895 31896 case REACT_SUSPENSE_LIST_TYPE: 31897 return describeBuiltInComponentFrame('SuspenseList'); 31898 } 31899 31900 if (typeof type === 'object') { 31901 switch (type.$$typeof) { 31902 case REACT_FORWARD_REF_TYPE: 31903 return describeFunctionComponentFrame(type.render); 31904 31905 case REACT_MEMO_TYPE: 31906 // Memo may contain any component type so we recursively resolve it. 31907 return describeUnknownElementTypeFrameInDEV(type.type, source, ownerFn); 31908 31909 case REACT_BLOCK_TYPE: 31910 return describeFunctionComponentFrame(type._render); 31911 31912 case REACT_LAZY_TYPE: 31913 { 31914 var lazyComponent = type; 31915 var payload = lazyComponent._payload; 31916 var init = lazyComponent._init; 31917 31918 try { 31919 // Lazy may contain any component type so we recursively resolve it. 31920 return describeUnknownElementTypeFrameInDEV(init(payload), source, ownerFn); 31921 } catch (x) {} 31922 } 31923 } 31924 } 31925 31926 return ''; 31927} 31928 31929var loggedTypeFailures = {}; 31930var ReactDebugCurrentFrame$1 = ReactSharedInternals.ReactDebugCurrentFrame; 31931 31932function setCurrentlyValidatingElement(element) { 31933 { 31934 if (element) { 31935 var owner = element._owner; 31936 var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null); 31937 ReactDebugCurrentFrame$1.setExtraStackFrame(stack); 31938 } else { 31939 ReactDebugCurrentFrame$1.setExtraStackFrame(null); 31940 } 31941 } 31942} 31943 31944function checkPropTypes(typeSpecs, values, location, componentName, element) { 31945 { 31946 // $FlowFixMe This is okay but Flow doesn't know it. 31947 var has = Function.call.bind(Object.prototype.hasOwnProperty); 31948 31949 for (var typeSpecName in typeSpecs) { 31950 if (has(typeSpecs, typeSpecName)) { 31951 var error$1 = void 0; // Prop type validation may throw. In case they do, we don't want to 31952 // fail the render phase where it didn't fail before. So we log it. 31953 // After these have been cleaned up, we'll let them throw. 31954 31955 try { 31956 // This is intentionally an invariant that gets caught. It's the same 31957 // behavior as without this statement except with a better message. 31958 if (typeof typeSpecs[typeSpecName] !== 'function') { 31959 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`.'); 31960 err.name = 'Invariant Violation'; 31961 throw err; 31962 } 31963 31964 error$1 = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED'); 31965 } catch (ex) { 31966 error$1 = ex; 31967 } 31968 31969 if (error$1 && !(error$1 instanceof Error)) { 31970 setCurrentlyValidatingElement(element); 31971 31972 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); 31973 31974 setCurrentlyValidatingElement(null); 31975 } 31976 31977 if (error$1 instanceof Error && !(error$1.message in loggedTypeFailures)) { 31978 // Only monitor this failure once because there tends to be a lot of the 31979 // same error. 31980 loggedTypeFailures[error$1.message] = true; 31981 setCurrentlyValidatingElement(element); 31982 31983 error('Failed %s type: %s', location, error$1.message); 31984 31985 setCurrentlyValidatingElement(null); 31986 } 31987 } 31988 } 31989 } 31990} 31991 31992function setCurrentlyValidatingElement$1(element) { 31993 { 31994 if (element) { 31995 var owner = element._owner; 31996 var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null); 31997 setExtraStackFrame(stack); 31998 } else { 31999 setExtraStackFrame(null); 32000 } 32001 } 32002} 32003 32004var propTypesMisspellWarningShown; 32005 32006{ 32007 propTypesMisspellWarningShown = false; 32008} 32009 32010function getDeclarationErrorAddendum() { 32011 if (ReactCurrentOwner.current) { 32012 var name = getComponentName(ReactCurrentOwner.current.type); 32013 32014 if (name) { 32015 return '\n\nCheck the render method of `' + name + '`.'; 32016 } 32017 } 32018 32019 return ''; 32020} 32021 32022function getSourceInfoErrorAddendum(source) { 32023 if (source !== undefined) { 32024 var fileName = source.fileName.replace(/^.*[\\\/]/, ''); 32025 var lineNumber = source.lineNumber; 32026 return '\n\nCheck your code at ' + fileName + ':' + lineNumber + '.'; 32027 } 32028 32029 return ''; 32030} 32031 32032function getSourceInfoErrorAddendumForProps(elementProps) { 32033 if (elementProps !== null && elementProps !== undefined) { 32034 return getSourceInfoErrorAddendum(elementProps.__source); 32035 } 32036 32037 return ''; 32038} 32039/** 32040 * Warn if there's no key explicitly set on dynamic arrays of children or 32041 * object keys are not valid. This allows us to keep track of children between 32042 * updates. 32043 */ 32044 32045 32046var ownerHasKeyUseWarning = {}; 32047 32048function getCurrentComponentErrorInfo(parentType) { 32049 var info = getDeclarationErrorAddendum(); 32050 32051 if (!info) { 32052 var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name; 32053 32054 if (parentName) { 32055 info = "\n\nCheck the top-level render call using <" + parentName + ">."; 32056 } 32057 } 32058 32059 return info; 32060} 32061/** 32062 * Warn if the element doesn't have an explicit key assigned to it. 32063 * This element is in an array. The array could grow and shrink or be 32064 * reordered. All children that haven't already been validated are required to 32065 * have a "key" property assigned to it. Error statuses are cached so a warning 32066 * will only be shown once. 32067 * 32068 * @internal 32069 * @param {ReactElement} element Element that requires a key. 32070 * @param {*} parentType element's parent's type. 32071 */ 32072 32073 32074function validateExplicitKey(element, parentType) { 32075 if (!element._store || element._store.validated || element.key != null) { 32076 return; 32077 } 32078 32079 element._store.validated = true; 32080 var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType); 32081 32082 if (ownerHasKeyUseWarning[currentComponentErrorInfo]) { 32083 return; 32084 } 32085 32086 ownerHasKeyUseWarning[currentComponentErrorInfo] = true; // Usually the current owner is the offender, but if it accepts children as a 32087 // property, it may be the creator of the child that's responsible for 32088 // assigning it a key. 32089 32090 var childOwner = ''; 32091 32092 if (element && element._owner && element._owner !== ReactCurrentOwner.current) { 32093 // Give the component that originally created this child. 32094 childOwner = " It was passed a child from " + getComponentName(element._owner.type) + "."; 32095 } 32096 32097 { 32098 setCurrentlyValidatingElement$1(element); 32099 32100 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); 32101 32102 setCurrentlyValidatingElement$1(null); 32103 } 32104} 32105/** 32106 * Ensure that every element either is passed in a static location, in an 32107 * array with an explicit keys property defined, or in an object literal 32108 * with valid key property. 32109 * 32110 * @internal 32111 * @param {ReactNode} node Statically passed child of any type. 32112 * @param {*} parentType node's parent's type. 32113 */ 32114 32115 32116function validateChildKeys(node, parentType) { 32117 if (typeof node !== 'object') { 32118 return; 32119 } 32120 32121 if (Array.isArray(node)) { 32122 for (var i = 0; i < node.length; i++) { 32123 var child = node[i]; 32124 32125 if (isValidElement(child)) { 32126 validateExplicitKey(child, parentType); 32127 } 32128 } 32129 } else if (isValidElement(node)) { 32130 // This element was passed in a valid location. 32131 if (node._store) { 32132 node._store.validated = true; 32133 } 32134 } else if (node) { 32135 var iteratorFn = getIteratorFn(node); 32136 32137 if (typeof iteratorFn === 'function') { 32138 // Entry iterators used to provide implicit keys, 32139 // but now we print a separate warning for them later. 32140 if (iteratorFn !== node.entries) { 32141 var iterator = iteratorFn.call(node); 32142 var step; 32143 32144 while (!(step = iterator.next()).done) { 32145 if (isValidElement(step.value)) { 32146 validateExplicitKey(step.value, parentType); 32147 } 32148 } 32149 } 32150 } 32151 } 32152} 32153/** 32154 * Given an element, validate that its props follow the propTypes definition, 32155 * provided by the type. 32156 * 32157 * @param {ReactElement} element 32158 */ 32159 32160 32161function validatePropTypes(element) { 32162 { 32163 var type = element.type; 32164 32165 if (type === null || type === undefined || typeof type === 'string') { 32166 return; 32167 } 32168 32169 var propTypes; 32170 32171 if (typeof type === 'function') { 32172 propTypes = type.propTypes; 32173 } else if (typeof type === 'object' && (type.$$typeof === REACT_FORWARD_REF_TYPE || // Note: Memo only checks outer props here. 32174 // Inner props are checked in the reconciler. 32175 type.$$typeof === REACT_MEMO_TYPE)) { 32176 propTypes = type.propTypes; 32177 } else { 32178 return; 32179 } 32180 32181 if (propTypes) { 32182 // Intentionally inside to avoid triggering lazy initializers: 32183 var name = getComponentName(type); 32184 checkPropTypes(propTypes, element.props, 'prop', name, element); 32185 } else if (type.PropTypes !== undefined && !propTypesMisspellWarningShown) { 32186 propTypesMisspellWarningShown = true; // Intentionally inside to avoid triggering lazy initializers: 32187 32188 var _name = getComponentName(type); 32189 32190 error('Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?', _name || 'Unknown'); 32191 } 32192 32193 if (typeof type.getDefaultProps === 'function' && !type.getDefaultProps.isReactClassApproved) { 32194 error('getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.'); 32195 } 32196 } 32197} 32198/** 32199 * Given a fragment, validate that it can only be provided with fragment props 32200 * @param {ReactElement} fragment 32201 */ 32202 32203 32204function validateFragmentProps(fragment) { 32205 { 32206 var keys = Object.keys(fragment.props); 32207 32208 for (var i = 0; i < keys.length; i++) { 32209 var key = keys[i]; 32210 32211 if (key !== 'children' && key !== 'key') { 32212 setCurrentlyValidatingElement$1(fragment); 32213 32214 error('Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', key); 32215 32216 setCurrentlyValidatingElement$1(null); 32217 break; 32218 } 32219 } 32220 32221 if (fragment.ref !== null) { 32222 setCurrentlyValidatingElement$1(fragment); 32223 32224 error('Invalid attribute `ref` supplied to `React.Fragment`.'); 32225 32226 setCurrentlyValidatingElement$1(null); 32227 } 32228 } 32229} 32230function createElementWithValidation(type, props, children) { 32231 var validType = isValidElementType(type); // We warn in this case but don't throw. We expect the element creation to 32232 // succeed and there will likely be errors in render. 32233 32234 if (!validType) { 32235 var info = ''; 32236 32237 if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) { 32238 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."; 32239 } 32240 32241 var sourceInfo = getSourceInfoErrorAddendumForProps(props); 32242 32243 if (sourceInfo) { 32244 info += sourceInfo; 32245 } else { 32246 info += getDeclarationErrorAddendum(); 32247 } 32248 32249 var typeString; 32250 32251 if (type === null) { 32252 typeString = 'null'; 32253 } else if (Array.isArray(type)) { 32254 typeString = 'array'; 32255 } else if (type !== undefined && type.$$typeof === REACT_ELEMENT_TYPE) { 32256 typeString = "<" + (getComponentName(type.type) || 'Unknown') + " />"; 32257 info = ' Did you accidentally export a JSX literal instead of a component?'; 32258 } else { 32259 typeString = typeof type; 32260 } 32261 32262 { 32263 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); 32264 } 32265 } 32266 32267 var element = createElement.apply(this, arguments); // The result can be nullish if a mock or a custom function is used. 32268 // TODO: Drop this when these are no longer allowed as the type argument. 32269 32270 if (element == null) { 32271 return element; 32272 } // Skip key warning if the type isn't valid since our key validation logic 32273 // doesn't expect a non-string/function type and can throw confusing errors. 32274 // We don't want exception behavior to differ between dev and prod. 32275 // (Rendering will throw with a helpful message and as soon as the type is 32276 // fixed, the key warnings will appear.) 32277 32278 32279 if (validType) { 32280 for (var i = 2; i < arguments.length; i++) { 32281 validateChildKeys(arguments[i], type); 32282 } 32283 } 32284 32285 if (type === exports.Fragment) { 32286 validateFragmentProps(element); 32287 } else { 32288 validatePropTypes(element); 32289 } 32290 32291 return element; 32292} 32293var didWarnAboutDeprecatedCreateFactory = false; 32294function createFactoryWithValidation(type) { 32295 var validatedFactory = createElementWithValidation.bind(null, type); 32296 validatedFactory.type = type; 32297 32298 { 32299 if (!didWarnAboutDeprecatedCreateFactory) { 32300 didWarnAboutDeprecatedCreateFactory = true; 32301 32302 warn('React.createFactory() is deprecated and will be removed in ' + 'a future major release. Consider using JSX ' + 'or use React.createElement() directly instead.'); 32303 } // Legacy hook: remove it 32304 32305 32306 Object.defineProperty(validatedFactory, 'type', { 32307 enumerable: false, 32308 get: function () { 32309 warn('Factory.type is deprecated. Access the class directly ' + 'before passing it to createFactory.'); 32310 32311 Object.defineProperty(this, 'type', { 32312 value: type 32313 }); 32314 return type; 32315 } 32316 }); 32317 } 32318 32319 return validatedFactory; 32320} 32321function cloneElementWithValidation(element, props, children) { 32322 var newElement = cloneElement.apply(this, arguments); 32323 32324 for (var i = 2; i < arguments.length; i++) { 32325 validateChildKeys(arguments[i], newElement.type); 32326 } 32327 32328 validatePropTypes(newElement); 32329 return newElement; 32330} 32331 32332{ 32333 32334 try { 32335 var frozenObject = Object.freeze({}); 32336 /* eslint-disable no-new */ 32337 32338 new Map([[frozenObject, null]]); 32339 new Set([frozenObject]); 32340 /* eslint-enable no-new */ 32341 } catch (e) { 32342 } 32343} 32344 32345var createElement$1 = createElementWithValidation ; 32346var cloneElement$1 = cloneElementWithValidation ; 32347var createFactory = createFactoryWithValidation ; 32348var Children = { 32349 map: mapChildren, 32350 forEach: forEachChildren, 32351 count: countChildren, 32352 toArray: toArray, 32353 only: onlyChild 32354}; 32355 32356exports.Children = Children; 32357exports.Component = Component; 32358exports.PureComponent = PureComponent; 32359exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = ReactSharedInternals; 32360exports.cloneElement = cloneElement$1; 32361exports.createContext = createContext; 32362exports.createElement = createElement$1; 32363exports.createFactory = createFactory; 32364exports.createRef = createRef; 32365exports.forwardRef = forwardRef; 32366exports.isValidElement = isValidElement; 32367exports.lazy = lazy; 32368exports.memo = memo; 32369exports.useCallback = useCallback; 32370exports.useContext = useContext; 32371exports.useDebugValue = useDebugValue; 32372exports.useEffect = useEffect; 32373exports.useImperativeHandle = useImperativeHandle; 32374exports.useLayoutEffect = useLayoutEffect; 32375exports.useMemo = useMemo; 32376exports.useReducer = useReducer; 32377exports.useRef = useRef; 32378exports.useState = useState; 32379exports.version = ReactVersion; 32380 })(); 32381} 32382 32383 32384/***/ }), 32385
vendor: 411 bytes, lines 32386-32401
32386/***/ "./node_modules/react/index.js": 32387/*!*************************************!*\ 32388 !*** ./node_modules/react/index.js ***! 32389 \*************************************/ 32390/***/ ((module, __unused_webpack_exports, __webpack_require__) => { 32391 32392"use strict"; 32393 32394 32395if (false) {} else { 32396 module.exports = __webpack_require__(/*! ./cjs/react.development.js */ "./node_modules/react/cjs/react.development.js"); 32397} 32398 32399 32400/***/ }), 32401
vendor: 459 bytes, lines 32402-32417
32402/***/ "./node_modules/react/jsx-runtime.js": 32403/*!*******************************************!*\ 32404 !*** ./node_modules/react/jsx-runtime.js ***! 32405 \*******************************************/ 32406/***/ ((module, __unused_webpack_exports, __webpack_require__) => { 32407 32408"use strict"; 32409 32410 32411if (false) {} else { 32412 module.exports = __webpack_require__(/*! ./cjs/react-jsx-runtime.development.js */ "./node_modules/react/cjs/react-jsx-runtime.development.js"); 32413} 32414 32415 32416/***/ }), 32417
vendor: 9,325 bytes, lines 32418-32775
32418/***/ "./node_modules/scheduler/cjs/scheduler-tracing.development.js": 32419/*!*********************************************************************!*\ 32420 !*** ./node_modules/scheduler/cjs/scheduler-tracing.development.js ***! 32421 \*********************************************************************/ 32422/***/ ((__unused_webpack_module, exports) => { 32423 32424"use strict"; 32425/** @license React v0.20.2 32426 * scheduler-tracing.development.js 32427 * 32428 * Copyright (c) Facebook, Inc. and its affiliates. 32429 * 32430 * This source code is licensed under the MIT license found in the 32431 * LICENSE file in the root directory of this source tree. 32432 */ 32433 32434 32435 32436if (true) { 32437 (function() { 32438'use strict'; 32439 32440var DEFAULT_THREAD_ID = 0; // Counters used to generate unique IDs. 32441 32442var interactionIDCounter = 0; 32443var threadIDCounter = 0; // Set of currently traced interactions. 32444// Interactions "stack"– 32445// Meaning that newly traced interactions are appended to the previously active set. 32446// When an interaction goes out of scope, the previous set (if any) is restored. 32447 32448exports.__interactionsRef = null; // Listener(s) to notify when interactions begin and end. 32449 32450exports.__subscriberRef = null; 32451 32452{ 32453 exports.__interactionsRef = { 32454 current: new Set() 32455 }; 32456 exports.__subscriberRef = { 32457 current: null 32458 }; 32459} 32460function unstable_clear(callback) { 32461 32462 var prevInteractions = exports.__interactionsRef.current; 32463 exports.__interactionsRef.current = new Set(); 32464 32465 try { 32466 return callback(); 32467 } finally { 32468 exports.__interactionsRef.current = prevInteractions; 32469 } 32470} 32471function unstable_getCurrent() { 32472 { 32473 return exports.__interactionsRef.current; 32474 } 32475} 32476function unstable_getThreadID() { 32477 return ++threadIDCounter; 32478} 32479function unstable_trace(name, timestamp, callback) { 32480 var threadID = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : DEFAULT_THREAD_ID; 32481 32482 var interaction = { 32483 __count: 1, 32484 id: interactionIDCounter++, 32485 name: name, 32486 timestamp: timestamp 32487 }; 32488 var prevInteractions = exports.__interactionsRef.current; // Traced interactions should stack/accumulate. 32489 // To do that, clone the current interactions. 32490 // The previous set will be restored upon completion. 32491 32492 var interactions = new Set(prevInteractions); 32493 interactions.add(interaction); 32494 exports.__interactionsRef.current = interactions; 32495 var subscriber = exports.__subscriberRef.current; 32496 var returnValue; 32497 32498 try { 32499 if (subscriber !== null) { 32500 subscriber.onInteractionTraced(interaction); 32501 } 32502 } finally { 32503 try { 32504 if (subscriber !== null) { 32505 subscriber.onWorkStarted(interactions, threadID); 32506 } 32507 } finally { 32508 try { 32509 returnValue = callback(); 32510 } finally { 32511 exports.__interactionsRef.current = prevInteractions; 32512 32513 try { 32514 if (subscriber !== null) { 32515 subscriber.onWorkStopped(interactions, threadID); 32516 } 32517 } finally { 32518 interaction.__count--; // If no async work was scheduled for this interaction, 32519 // Notify subscribers that it's completed. 32520 32521 if (subscriber !== null && interaction.__count === 0) { 32522 subscriber.onInteractionScheduledWorkCompleted(interaction); 32523 } 32524 } 32525 } 32526 } 32527 } 32528 32529 return returnValue; 32530} 32531function unstable_wrap(callback) { 32532 var threadID = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_THREAD_ID; 32533 32534 var wrappedInteractions = exports.__interactionsRef.current; 32535 var subscriber = exports.__subscriberRef.current; 32536 32537 if (subscriber !== null) { 32538 subscriber.onWorkScheduled(wrappedInteractions, threadID); 32539 } // Update the pending async work count for the current interactions. 32540 // Update after calling subscribers in case of error. 32541 32542 32543 wrappedInteractions.forEach(function (interaction) { 32544 interaction.__count++; 32545 }); 32546 var hasRun = false; 32547 32548 function wrapped() { 32549 var prevInteractions = exports.__interactionsRef.current; 32550 exports.__interactionsRef.current = wrappedInteractions; 32551 subscriber = exports.__subscriberRef.current; 32552 32553 try { 32554 var returnValue; 32555 32556 try { 32557 if (subscriber !== null) { 32558 subscriber.onWorkStarted(wrappedInteractions, threadID); 32559 } 32560 } finally { 32561 try { 32562 returnValue = callback.apply(undefined, arguments); 32563 } finally { 32564 exports.__interactionsRef.current = prevInteractions; 32565 32566 if (subscriber !== null) { 32567 subscriber.onWorkStopped(wrappedInteractions, threadID); 32568 } 32569 } 32570 } 32571 32572 return returnValue; 32573 } finally { 32574 if (!hasRun) { 32575 // We only expect a wrapped function to be executed once, 32576 // But in the event that it's executed more than once– 32577 // Only decrement the outstanding interaction counts once. 32578 hasRun = true; // Update pending async counts for all wrapped interactions. 32579 // If this was the last scheduled async work for any of them, 32580 // Mark them as completed. 32581 32582 wrappedInteractions.forEach(function (interaction) { 32583 interaction.__count--; 32584 32585 if (subscriber !== null && interaction.__count === 0) { 32586 subscriber.onInteractionScheduledWorkCompleted(interaction); 32587 } 32588 }); 32589 } 32590 } 32591 } 32592 32593 wrapped.cancel = function cancel() { 32594 subscriber = exports.__subscriberRef.current; 32595 32596 try { 32597 if (subscriber !== null) { 32598 subscriber.onWorkCanceled(wrappedInteractions, threadID); 32599 } 32600 } finally { 32601 // Update pending async counts for all wrapped interactions. 32602 // If this was the last scheduled async work for any of them, 32603 // Mark them as completed. 32604 wrappedInteractions.forEach(function (interaction) { 32605 interaction.__count--; 32606 32607 if (subscriber && interaction.__count === 0) { 32608 subscriber.onInteractionScheduledWorkCompleted(interaction); 32609 } 32610 }); 32611 } 32612 }; 32613 32614 return wrapped; 32615} 32616 32617var subscribers = null; 32618 32619{ 32620 subscribers = new Set(); 32621} 32622 32623function unstable_subscribe(subscriber) { 32624 { 32625 subscribers.add(subscriber); 32626 32627 if (subscribers.size === 1) { 32628 exports.__subscriberRef.current = { 32629 onInteractionScheduledWorkCompleted: onInteractionScheduledWorkCompleted, 32630 onInteractionTraced: onInteractionTraced, 32631 onWorkCanceled: onWorkCanceled, 32632 onWorkScheduled: onWorkScheduled, 32633 onWorkStarted: onWorkStarted, 32634 onWorkStopped: onWorkStopped 32635 }; 32636 } 32637 } 32638} 32639function unstable_unsubscribe(subscriber) { 32640 { 32641 subscribers.delete(subscriber); 32642 32643 if (subscribers.size === 0) { 32644 exports.__subscriberRef.current = null; 32645 } 32646 } 32647} 32648 32649function onInteractionTraced(interaction) { 32650 var didCatchError = false; 32651 var caughtError = null; 32652 subscribers.forEach(function (subscriber) { 32653 try { 32654 subscriber.onInteractionTraced(interaction); 32655 } catch (error) { 32656 if (!didCatchError) { 32657 didCatchError = true; 32658 caughtError = error; 32659 } 32660 } 32661 }); 32662 32663 if (didCatchError) { 32664 throw caughtError; 32665 } 32666} 32667 32668function onInteractionScheduledWorkCompleted(interaction) { 32669 var didCatchError = false; 32670 var caughtError = null; 32671 subscribers.forEach(function (subscriber) { 32672 try { 32673 subscriber.onInteractionScheduledWorkCompleted(interaction); 32674 } catch (error) { 32675 if (!didCatchError) { 32676 didCatchError = true; 32677 caughtError = error; 32678 } 32679 } 32680 }); 32681 32682 if (didCatchError) { 32683 throw caughtError; 32684 } 32685} 32686 32687function onWorkScheduled(interactions, threadID) { 32688 var didCatchError = false; 32689 var caughtError = null; 32690 subscribers.forEach(function (subscriber) { 32691 try { 32692 subscriber.onWorkScheduled(interactions, threadID); 32693 } catch (error) { 32694 if (!didCatchError) { 32695 didCatchError = true; 32696 caughtError = error; 32697 } 32698 } 32699 }); 32700 32701 if (didCatchError) { 32702 throw caughtError; 32703 } 32704} 32705 32706function onWorkStarted(interactions, threadID) { 32707 var didCatchError = false; 32708 var caughtError = null; 32709 subscribers.forEach(function (subscriber) { 32710 try { 32711 subscriber.onWorkStarted(interactions, threadID); 32712 } catch (error) { 32713 if (!didCatchError) { 32714 didCatchError = true; 32715 caughtError = error; 32716 } 32717 } 32718 }); 32719 32720 if (didCatchError) { 32721 throw caughtError; 32722 } 32723} 32724 32725function onWorkStopped(interactions, threadID) { 32726 var didCatchError = false; 32727 var caughtError = null; 32728 subscribers.forEach(function (subscriber) { 32729 try { 32730 subscriber.onWorkStopped(interactions, threadID); 32731 } catch (error) { 32732 if (!didCatchError) { 32733 didCatchError = true; 32734 caughtError = error; 32735 } 32736 } 32737 }); 32738 32739 if (didCatchError) { 32740 throw caughtError; 32741 } 32742} 32743 32744function onWorkCanceled(interactions, threadID) { 32745 var didCatchError = false; 32746 var caughtError = null; 32747 subscribers.forEach(function (subscriber) { 32748 try { 32749 subscriber.onWorkCanceled(interactions, threadID); 32750 } catch (error) { 32751 if (!didCatchError) { 32752 didCatchError = true; 32753 caughtError = error; 32754 } 32755 } 32756 }); 32757 32758 if (didCatchError) { 32759 throw caughtError; 32760 } 32761} 32762 32763exports.unstable_clear = unstable_clear; 32764exports.unstable_getCurrent = unstable_getCurrent; 32765exports.unstable_getThreadID = unstable_getThreadID; 32766exports.unstable_subscribe = unstable_subscribe; 32767exports.unstable_trace = unstable_trace; 32768exports.unstable_unsubscribe = unstable_unsubscribe; 32769exports.unstable_wrap = unstable_wrap; 32770 })(); 32771} 32772 32773 32774/***/ }), 32775
vendor: 17,855 bytes, lines 32776-33432
32776/***/ "./node_modules/scheduler/cjs/scheduler.development.js": 32777/*!*************************************************************!*\ 32778 !*** ./node_modules/scheduler/cjs/scheduler.development.js ***! 32779 \*************************************************************/ 32780/***/ ((__unused_webpack_module, exports) => { 32781 32782"use strict"; 32783/** @license React v0.20.2 32784 * scheduler.development.js 32785 * 32786 * Copyright (c) Facebook, Inc. and its affiliates. 32787 * 32788 * This source code is licensed under the MIT license found in the 32789 * LICENSE file in the root directory of this source tree. 32790 */ 32791 32792 32793 32794if (true) { 32795 (function() { 32796'use strict'; 32797 32798var enableSchedulerDebugging = false; 32799var enableProfiling = false; 32800 32801var requestHostCallback; 32802var requestHostTimeout; 32803var cancelHostTimeout; 32804var requestPaint; 32805var hasPerformanceNow = typeof performance === 'object' && typeof performance.now === 'function'; 32806 32807if (hasPerformanceNow) { 32808 var localPerformance = performance; 32809 32810 exports.unstable_now = function () { 32811 return localPerformance.now(); 32812 }; 32813} else { 32814 var localDate = Date; 32815 var initialTime = localDate.now(); 32816 32817 exports.unstable_now = function () { 32818 return localDate.now() - initialTime; 32819 }; 32820} 32821 32822if ( // If Scheduler runs in a non-DOM environment, it falls back to a naive 32823// implementation using setTimeout. 32824typeof window === 'undefined' || // Check if MessageChannel is supported, too. 32825typeof MessageChannel !== 'function') { 32826 // If this accidentally gets imported in a non-browser environment, e.g. JavaScriptCore, 32827 // fallback to a naive implementation. 32828 var _callback = null; 32829 var _timeoutID = null; 32830 32831 var _flushCallback = function () { 32832 if (_callback !== null) { 32833 try { 32834 var currentTime = exports.unstable_now(); 32835 var hasRemainingTime = true; 32836 32837 _callback(hasRemainingTime, currentTime); 32838 32839 _callback = null; 32840 } catch (e) { 32841 setTimeout(_flushCallback, 0); 32842 throw e; 32843 } 32844 } 32845 }; 32846 32847 requestHostCallback = function (cb) { 32848 if (_callback !== null) { 32849 // Protect against re-entrancy. 32850 setTimeout(requestHostCallback, 0, cb); 32851 } else { 32852 _callback = cb; 32853 setTimeout(_flushCallback, 0); 32854 } 32855 }; 32856 32857 requestHostTimeout = function (cb, ms) { 32858 _timeoutID = setTimeout(cb, ms); 32859 }; 32860 32861 cancelHostTimeout = function () { 32862 clearTimeout(_timeoutID); 32863 }; 32864 32865 exports.unstable_shouldYield = function () { 32866 return false; 32867 }; 32868 32869 requestPaint = exports.unstable_forceFrameRate = function () {}; 32870} else { 32871 // Capture local references to native APIs, in case a polyfill overrides them. 32872 var _setTimeout = window.setTimeout; 32873 var _clearTimeout = window.clearTimeout; 32874 32875 if (typeof console !== 'undefined') { 32876 // TODO: Scheduler no longer requires these methods to be polyfilled. But 32877 // maybe we want to continue warning if they don't exist, to preserve the 32878 // option to rely on it in the future? 32879 var requestAnimationFrame = window.requestAnimationFrame; 32880 var cancelAnimationFrame = window.cancelAnimationFrame; 32881 32882 if (typeof requestAnimationFrame !== 'function') { 32883 // Using console['error'] to evade Babel and ESLint 32884 console['error']("This browser doesn't support requestAnimationFrame. " + 'Make sure that you load a ' + 'polyfill in older browsers. https://reactjs.org/link/react-polyfills'); 32885 } 32886 32887 if (typeof cancelAnimationFrame !== 'function') { 32888 // Using console['error'] to evade Babel and ESLint 32889 console['error']("This browser doesn't support cancelAnimationFrame. " + 'Make sure that you load a ' + 'polyfill in older browsers. https://reactjs.org/link/react-polyfills'); 32890 } 32891 } 32892 32893 var isMessageLoopRunning = false; 32894 var scheduledHostCallback = null; 32895 var taskTimeoutID = -1; // Scheduler periodically yields in case there is other work on the main 32896 // thread, like user events. By default, it yields multiple times per frame. 32897 // It does not attempt to align with frame boundaries, since most tasks don't 32898 // need to be frame aligned; for those that do, use requestAnimationFrame. 32899 32900 var yieldInterval = 5; 32901 var deadline = 0; // TODO: Make this configurable 32902 32903 { 32904 // `isInputPending` is not available. Since we have no way of knowing if 32905 // there's pending input, always yield at the end of the frame. 32906 exports.unstable_shouldYield = function () { 32907 return exports.unstable_now() >= deadline; 32908 }; // Since we yield every frame regardless, `requestPaint` has no effect. 32909 32910 32911 requestPaint = function () {}; 32912 } 32913 32914 exports.unstable_forceFrameRate = function (fps) { 32915 if (fps < 0 || fps > 125) { 32916 // Using console['error'] to evade Babel and ESLint 32917 console['error']('forceFrameRate takes a positive int between 0 and 125, ' + 'forcing frame rates higher than 125 fps is not supported'); 32918 return; 32919 } 32920 32921 if (fps > 0) { 32922 yieldInterval = Math.floor(1000 / fps); 32923 } else { 32924 // reset the framerate 32925 yieldInterval = 5; 32926 } 32927 }; 32928 32929 var performWorkUntilDeadline = function () { 32930 if (scheduledHostCallback !== null) { 32931 var currentTime = exports.unstable_now(); // Yield after `yieldInterval` ms, regardless of where we are in the vsync 32932 // cycle. This means there's always time remaining at the beginning of 32933 // the message event. 32934 32935 deadline = currentTime + yieldInterval; 32936 var hasTimeRemaining = true; 32937 32938 try { 32939 var hasMoreWork = scheduledHostCallback(hasTimeRemaining, currentTime); 32940 32941 if (!hasMoreWork) { 32942 isMessageLoopRunning = false; 32943 scheduledHostCallback = null; 32944 } else { 32945 // If there's more work, schedule the next message event at the end 32946 // of the preceding one. 32947 port.postMessage(null); 32948 } 32949 } catch (error) { 32950 // If a scheduler task throws, exit the current browser task so the 32951 // error can be observed. 32952 port.postMessage(null); 32953 throw error; 32954 } 32955 } else { 32956 isMessageLoopRunning = false; 32957 } // Yielding to the browser will give it a chance to paint, so we can 32958 }; 32959 32960 var channel = new MessageChannel(); 32961 var port = channel.port2; 32962 channel.port1.onmessage = performWorkUntilDeadline; 32963 32964 requestHostCallback = function (callback) { 32965 scheduledHostCallback = callback; 32966 32967 if (!isMessageLoopRunning) { 32968 isMessageLoopRunning = true; 32969 port.postMessage(null); 32970 } 32971 }; 32972 32973 requestHostTimeout = function (callback, ms) { 32974 taskTimeoutID = _setTimeout(function () { 32975 callback(exports.unstable_now()); 32976 }, ms); 32977 }; 32978 32979 cancelHostTimeout = function () { 32980 _clearTimeout(taskTimeoutID); 32981 32982 taskTimeoutID = -1; 32983 }; 32984} 32985 32986function push(heap, node) { 32987 var index = heap.length; 32988 heap.push(node); 32989 siftUp(heap, node, index); 32990} 32991function peek(heap) { 32992 var first = heap[0]; 32993 return first === undefined ? null : first; 32994} 32995function pop(heap) { 32996 var first = heap[0]; 32997 32998 if (first !== undefined) { 32999 var last = heap.pop(); 33000 33001 if (last !== first) { 33002 heap[0] = last; 33003 siftDown(heap, last, 0); 33004 } 33005 33006 return first; 33007 } else { 33008 return null; 33009 } 33010} 33011 33012function siftUp(heap, node, i) { 33013 var index = i; 33014 33015 while (true) { 33016 var parentIndex = index - 1 >>> 1; 33017 var parent = heap[parentIndex]; 33018 33019 if (parent !== undefined && compare(parent, node) > 0) { 33020 // The parent is larger. Swap positions. 33021 heap[parentIndex] = node; 33022 heap[index] = parent; 33023 index = parentIndex; 33024 } else { 33025 // The parent is smaller. Exit. 33026 return; 33027 } 33028 } 33029} 33030 33031function siftDown(heap, node, i) { 33032 var index = i; 33033 var length = heap.length; 33034 33035 while (index < length) { 33036 var leftIndex = (index + 1) * 2 - 1; 33037 var left = heap[leftIndex]; 33038 var rightIndex = leftIndex + 1; 33039 var right = heap[rightIndex]; // If the left or right node is smaller, swap with the smaller of those. 33040 33041 if (left !== undefined && compare(left, node) < 0) { 33042 if (right !== undefined && compare(right, left) < 0) { 33043 heap[index] = right; 33044 heap[rightIndex] = node; 33045 index = rightIndex; 33046 } else { 33047 heap[index] = left; 33048 heap[leftIndex] = node; 33049 index = leftIndex; 33050 } 33051 } else if (right !== undefined && compare(right, node) < 0) { 33052 heap[index] = right; 33053 heap[rightIndex] = node; 33054 index = rightIndex; 33055 } else { 33056 // Neither child is smaller. Exit. 33057 return; 33058 } 33059 } 33060} 33061 33062function compare(a, b) { 33063 // Compare sort index first, then task id. 33064 var diff = a.sortIndex - b.sortIndex; 33065 return diff !== 0 ? diff : a.id - b.id; 33066} 33067 33068// TODO: Use symbols? 33069var ImmediatePriority = 1; 33070var UserBlockingPriority = 2; 33071var NormalPriority = 3; 33072var LowPriority = 4; 33073var IdlePriority = 5; 33074 33075function markTaskErrored(task, ms) { 33076} 33077 33078/* eslint-disable no-var */ 33079// Math.pow(2, 30) - 1 33080// 0b111111111111111111111111111111 33081 33082var maxSigned31BitInt = 1073741823; // Times out immediately 33083 33084var IMMEDIATE_PRIORITY_TIMEOUT = -1; // Eventually times out 33085 33086var USER_BLOCKING_PRIORITY_TIMEOUT = 250; 33087var NORMAL_PRIORITY_TIMEOUT = 5000; 33088var LOW_PRIORITY_TIMEOUT = 10000; // Never times out 33089 33090var IDLE_PRIORITY_TIMEOUT = maxSigned31BitInt; // Tasks are stored on a min heap 33091 33092var taskQueue = []; 33093var timerQueue = []; // Incrementing id counter. Used to maintain insertion order. 33094 33095var taskIdCounter = 1; // Pausing the scheduler is useful for debugging. 33096var currentTask = null; 33097var currentPriorityLevel = NormalPriority; // This is set while performing work, to prevent re-entrancy. 33098 33099var isPerformingWork = false; 33100var isHostCallbackScheduled = false; 33101var isHostTimeoutScheduled = false; 33102 33103function advanceTimers(currentTime) { 33104 // Check for tasks that are no longer delayed and add them to the queue. 33105 var timer = peek(timerQueue); 33106 33107 while (timer !== null) { 33108 if (timer.callback === null) { 33109 // Timer was cancelled. 33110 pop(timerQueue); 33111 } else if (timer.startTime <= currentTime) { 33112 // Timer fired. Transfer to the task queue. 33113 pop(timerQueue); 33114 timer.sortIndex = timer.expirationTime; 33115 push(taskQueue, timer); 33116 } else { 33117 // Remaining timers are pending. 33118 return; 33119 } 33120 33121 timer = peek(timerQueue); 33122 } 33123} 33124 33125function handleTimeout(currentTime) { 33126 isHostTimeoutScheduled = false; 33127 advanceTimers(currentTime); 33128 33129 if (!isHostCallbackScheduled) { 33130 if (peek(taskQueue) !== null) { 33131 isHostCallbackScheduled = true; 33132 requestHostCallback(flushWork); 33133 } else { 33134 var firstTimer = peek(timerQueue); 33135 33136 if (firstTimer !== null) { 33137 requestHostTimeout(handleTimeout, firstTimer.startTime - currentTime); 33138 } 33139 } 33140 } 33141} 33142 33143function flushWork(hasTimeRemaining, initialTime) { 33144 33145 33146 isHostCallbackScheduled = false; 33147 33148 if (isHostTimeoutScheduled) { 33149 // We scheduled a timeout but it's no longer needed. Cancel it. 33150 isHostTimeoutScheduled = false; 33151 cancelHostTimeout(); 33152 } 33153 33154 isPerformingWork = true; 33155 var previousPriorityLevel = currentPriorityLevel; 33156 33157 try { 33158 if (enableProfiling) { 33159 try { 33160 return workLoop(hasTimeRemaining, initialTime); 33161 } catch (error) { 33162 if (currentTask !== null) { 33163 var currentTime = exports.unstable_now(); 33164 markTaskErrored(currentTask, currentTime); 33165 currentTask.isQueued = false; 33166 } 33167 33168 throw error; 33169 } 33170 } else { 33171 // No catch in prod code path. 33172 return workLoop(hasTimeRemaining, initialTime); 33173 } 33174 } finally { 33175 currentTask = null; 33176 currentPriorityLevel = previousPriorityLevel; 33177 isPerformingWork = false; 33178 } 33179} 33180 33181function workLoop(hasTimeRemaining, initialTime) { 33182 var currentTime = initialTime; 33183 advanceTimers(currentTime); 33184 currentTask = peek(taskQueue); 33185 33186 while (currentTask !== null && !(enableSchedulerDebugging )) { 33187 if (currentTask.expirationTime > currentTime && (!hasTimeRemaining || exports.unstable_shouldYield())) { 33188 // This currentTask hasn't expired, and we've reached the deadline. 33189 break; 33190 } 33191 33192 var callback = currentTask.callback; 33193 33194 if (typeof callback === 'function') { 33195 currentTask.callback = null; 33196 currentPriorityLevel = currentTask.priorityLevel; 33197 var didUserCallbackTimeout = currentTask.expirationTime <= currentTime; 33198 33199 var continuationCallback = callback(didUserCallbackTimeout); 33200 currentTime = exports.unstable_now(); 33201 33202 if (typeof continuationCallback === 'function') { 33203 currentTask.callback = continuationCallback; 33204 } else { 33205 33206 if (currentTask === peek(taskQueue)) { 33207 pop(taskQueue); 33208 } 33209 } 33210 33211 advanceTimers(currentTime); 33212 } else { 33213 pop(taskQueue); 33214 } 33215 33216 currentTask = peek(taskQueue); 33217 } // Return whether there's additional work 33218 33219 33220 if (currentTask !== null) { 33221 return true; 33222 } else { 33223 var firstTimer = peek(timerQueue); 33224 33225 if (firstTimer !== null) { 33226 requestHostTimeout(handleTimeout, firstTimer.startTime - currentTime); 33227 } 33228 33229 return false; 33230 } 33231} 33232 33233function unstable_runWithPriority(priorityLevel, eventHandler) { 33234 switch (priorityLevel) { 33235 case ImmediatePriority: 33236 case UserBlockingPriority: 33237 case NormalPriority: 33238 case LowPriority: 33239 case IdlePriority: 33240 break; 33241 33242 default: 33243 priorityLevel = NormalPriority; 33244 } 33245 33246 var previousPriorityLevel = currentPriorityLevel; 33247 currentPriorityLevel = priorityLevel; 33248 33249 try { 33250 return eventHandler(); 33251 } finally { 33252 currentPriorityLevel = previousPriorityLevel; 33253 } 33254} 33255 33256function unstable_next(eventHandler) { 33257 var priorityLevel; 33258 33259 switch (currentPriorityLevel) { 33260 case ImmediatePriority: 33261 case UserBlockingPriority: 33262 case NormalPriority: 33263 // Shift down to normal priority 33264 priorityLevel = NormalPriority; 33265 break; 33266 33267 default: 33268 // Anything lower than normal priority should remain at the current level. 33269 priorityLevel = currentPriorityLevel; 33270 break; 33271 } 33272 33273 var previousPriorityLevel = currentPriorityLevel; 33274 currentPriorityLevel = priorityLevel; 33275 33276 try { 33277 return eventHandler(); 33278 } finally { 33279 currentPriorityLevel = previousPriorityLevel; 33280 } 33281} 33282 33283function unstable_wrapCallback(callback) { 33284 var parentPriorityLevel = currentPriorityLevel; 33285 return function () { 33286 // This is a fork of runWithPriority, inlined for performance. 33287 var previousPriorityLevel = currentPriorityLevel; 33288 currentPriorityLevel = parentPriorityLevel; 33289 33290 try { 33291 return callback.apply(this, arguments); 33292 } finally { 33293 currentPriorityLevel = previousPriorityLevel; 33294 } 33295 }; 33296} 33297 33298function unstable_scheduleCallback(priorityLevel, callback, options) { 33299 var currentTime = exports.unstable_now(); 33300 var startTime; 33301 33302 if (typeof options === 'object' && options !== null) { 33303 var delay = options.delay; 33304 33305 if (typeof delay === 'number' && delay > 0) { 33306 startTime = currentTime + delay; 33307 } else { 33308 startTime = currentTime; 33309 } 33310 } else { 33311 startTime = currentTime; 33312 } 33313 33314 var timeout; 33315 33316 switch (priorityLevel) { 33317 case ImmediatePriority: 33318 timeout = IMMEDIATE_PRIORITY_TIMEOUT; 33319 break; 33320 33321 case UserBlockingPriority: 33322 timeout = USER_BLOCKING_PRIORITY_TIMEOUT; 33323 break; 33324 33325 case IdlePriority: 33326 timeout = IDLE_PRIORITY_TIMEOUT; 33327 break; 33328 33329 case LowPriority: 33330 timeout = LOW_PRIORITY_TIMEOUT; 33331 break; 33332 33333 case NormalPriority: 33334 default: 33335 timeout = NORMAL_PRIORITY_TIMEOUT; 33336 break; 33337 } 33338 33339 var expirationTime = startTime + timeout; 33340 var newTask = { 33341 id: taskIdCounter++, 33342 callback: callback, 33343 priorityLevel: priorityLevel, 33344 startTime: startTime, 33345 expirationTime: expirationTime, 33346 sortIndex: -1 33347 }; 33348 33349 if (startTime > currentTime) { 33350 // This is a delayed task. 33351 newTask.sortIndex = startTime; 33352 push(timerQueue, newTask); 33353 33354 if (peek(taskQueue) === null && newTask === peek(timerQueue)) { 33355 // All tasks are delayed, and this is the task with the earliest delay. 33356 if (isHostTimeoutScheduled) { 33357 // Cancel an existing timeout. 33358 cancelHostTimeout(); 33359 } else { 33360 isHostTimeoutScheduled = true; 33361 } // Schedule a timeout. 33362 33363 33364 requestHostTimeout(handleTimeout, startTime - currentTime); 33365 } 33366 } else { 33367 newTask.sortIndex = expirationTime; 33368 push(taskQueue, newTask); 33369 // wait until the next time we yield. 33370 33371 33372 if (!isHostCallbackScheduled && !isPerformingWork) { 33373 isHostCallbackScheduled = true; 33374 requestHostCallback(flushWork); 33375 } 33376 } 33377 33378 return newTask; 33379} 33380 33381function unstable_pauseExecution() { 33382} 33383 33384function unstable_continueExecution() { 33385 33386 if (!isHostCallbackScheduled && !isPerformingWork) { 33387 isHostCallbackScheduled = true; 33388 requestHostCallback(flushWork); 33389 } 33390} 33391 33392function unstable_getFirstCallbackNode() { 33393 return peek(taskQueue); 33394} 33395 33396function unstable_cancelCallback(task) { 33397 // remove from the queue because you can't remove arbitrary nodes from an 33398 // array based heap, only the first one.) 33399 33400 33401 task.callback = null; 33402} 33403 33404function unstable_getCurrentPriorityLevel() { 33405 return currentPriorityLevel; 33406} 33407 33408var unstable_requestPaint = requestPaint; 33409var unstable_Profiling = null; 33410 33411exports.unstable_IdlePriority = IdlePriority; 33412exports.unstable_ImmediatePriority = ImmediatePriority; 33413exports.unstable_LowPriority = LowPriority; 33414exports.unstable_NormalPriority = NormalPriority; 33415exports.unstable_Profiling = unstable_Profiling; 33416exports.unstable_UserBlockingPriority = UserBlockingPriority; 33417exports.unstable_cancelCallback = unstable_cancelCallback; 33418exports.unstable_continueExecution = unstable_continueExecution; 33419exports.unstable_getCurrentPriorityLevel = unstable_getCurrentPriorityLevel; 33420exports.unstable_getFirstCallbackNode = unstable_getFirstCallbackNode; 33421exports.unstable_next = unstable_next; 33422exports.unstable_pauseExecution = unstable_pauseExecution; 33423exports.unstable_requestPaint = unstable_requestPaint; 33424exports.unstable_runWithPriority = unstable_runWithPriority; 33425exports.unstable_scheduleCallback = unstable_scheduleCallback; 33426exports.unstable_wrapCallback = unstable_wrapCallback; 33427 })(); 33428} 33429 33430 33431/***/ }), 33432
vendor: 439 bytes, lines 33433-33448
33433/***/ "./node_modules/scheduler/index.js": 33434/*!*****************************************!*\ 33435 !*** ./node_modules/scheduler/index.js ***! 33436 \*****************************************/ 33437/***/ ((module, __unused_webpack_exports, __webpack_require__) => { 33438 33439"use strict"; 33440 33441 33442if (false) {} else { 33443 module.exports = __webpack_require__(/*! ./cjs/scheduler.development.js */ "./node_modules/scheduler/cjs/scheduler.development.js"); 33444} 33445 33446 33447/***/ }), 33448
vendor: 460 bytes, lines 33449-33463
33449/***/ "./node_modules/scheduler/tracing.js": 33450/*!*******************************************!*\ 33451 !*** ./node_modules/scheduler/tracing.js ***! 33452 \*******************************************/ 33453/***/ ((module, __unused_webpack_exports, __webpack_require__) => { 33454 33455"use strict"; 33456 33457 33458if (false) {} else { 33459 module.exports = __webpack_require__(/*! ./cjs/scheduler-tracing.development.js */ "./node_modules/scheduler/cjs/scheduler-tracing.development.js"); 33460} 33461 33462 33463/***/ })
vendor: 6,880 bytes, lines 33463-33631
33463 33464 33465/******/ }); 33466/************************************************************************/ 33467/******/ // The module cache 33468/******/ var __webpack_module_cache__ = {}; 33469/******/ 33470/******/ // The require function 33471/******/ function __webpack_require__(moduleId) { 33472/******/ // Check if module is in cache 33473/******/ var cachedModule = __webpack_module_cache__[moduleId]; 33474/******/ if (cachedModule !== undefined) { 33475/******/ return cachedModule.exports; 33476/******/ } 33477/******/ // Create a new module (and put it into the cache) 33478/******/ var module = __webpack_module_cache__[moduleId] = { 33479/******/ // no module.id needed 33480/******/ // no module.loaded needed 33481/******/ exports: {} 33482/******/ }; 33483/******/ 33484/******/ // Execute the module function 33485/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); 33486/******/ 33487/******/ // Return the exports of the module 33488/******/ return module.exports; 33489/******/ } 33490/******/ 33491/******/ // expose the modules object (__webpack_modules__) 33492/******/ __webpack_require__.m = __webpack_modules__; 33493/******/ 33494/************************************************************************/ 33495/******/ /* webpack/runtime/chunk loaded */ 33496/******/ (() => { 33497/******/ var deferred = []; 33498/******/ __webpack_require__.O = (result, chunkIds, fn, priority) => { 33499/******/ if(chunkIds) { 33500/******/ priority = priority || 0; 33501/******/ for(var i = deferred.length; i > 0 && deferred[i - 1][2] > priority; i--) deferred[i] = deferred[i - 1]; 33502/******/ deferred[i] = [chunkIds, fn, priority]; 33503/******/ return; 33504/******/ } 33505/******/ var notFulfilled = Infinity; 33506/******/ for (var i = 0; i < deferred.length; i++) { 33507/******/ var [chunkIds, fn, priority] = deferred[i]; 33508/******/ var fulfilled = true; 33509/******/ for (var j = 0; j < chunkIds.length; j++) { 33510/******/ if ((priority & 1 === 0 || notFulfilled >= priority) && Object.keys(__webpack_require__.O).every((key) => (__webpack_require__.O[key](chunkIds[j])))) { 33511/******/ chunkIds.splice(j--, 1); 33512/******/ } else { 33513/******/ fulfilled = false; 33514/******/ if(priority < notFulfilled) notFulfilled = priority; 33515/******/ } 33516/******/ } 33517/******/ if(fulfilled) { 33518/******/ deferred.splice(i--, 1) 33519/******/ var r = fn(); 33520/******/ if (r !== undefined) result = r; 33521/******/ } 33522/******/ } 33523/******/ return result; 33524/******/ }; 33525/******/ })(); 33526/******/ 33527/******/ /* webpack/runtime/compat get default export */ 33528/******/ (() => { 33529/******/ // getDefaultExport function for compatibility with non-harmony modules 33530/******/ __webpack_require__.n = (module) => { 33531/******/ var getter = module && module.__esModule ? 33532/******/ () => (module['default']) : 33533/******/ () => (module); 33534/******/ __webpack_require__.d(getter, { a: getter }); 33535/******/ return getter; 33536/******/ }; 33537/******/ })(); 33538/******/ 33539/******/ /* webpack/runtime/define property getters */ 33540/******/ (() => { 33541/******/ // define getter functions for harmony exports 33542/******/ __webpack_require__.d = (exports, definition) => { 33543/******/ for(var key in definition) { 33544/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { 33545/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); 33546/******/ } 33547/******/ } 33548/******/ }; 33549/******/ })(); 33550/******/ 33551/******/ /* webpack/runtime/hasOwnProperty shorthand */ 33552/******/ (() => { 33553/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) 33554/******/ })(); 33555/******/ 33556/******/ /* webpack/runtime/make namespace object */ 33557/******/ (() => { 33558/******/ // define __esModule on exports 33559/******/ __webpack_require__.r = (exports) => { 33560/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { 33561/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); 33562/******/ } 33563/******/ Object.defineProperty(exports, '__esModule', { value: true }); 33564/******/ }; 33565/******/ })(); 33566/******/ 33567/******/ /* webpack/runtime/jsonp chunk loading */ 33568/******/ (() => { 33569/******/ // no baseURI 33570/******/ 33571/******/ // object to store loaded and loading chunks 33572/******/ // undefined = chunk not loaded, null = chunk preloaded/prefetched 33573/******/ // [resolve, reject, Promise] = chunk loading, 0 = chunk loaded 33574/******/ var installedChunks = { 33575/******/ "/dist/index": 0, 33576/******/ "dist/app": 0 33577/******/ }; 33578/******/ 33579/******/ // no chunk on demand loading 33580/******/ 33581/******/ // no prefetching 33582/******/ 33583/******/ // no preloaded 33584/******/ 33585/******/ // no HMR 33586/******/ 33587/******/ // no HMR manifest 33588/******/ 33589/******/ __webpack_require__.O.j = (chunkId) => (installedChunks[chunkId] === 0); 33590/******/ 33591/******/ // install a JSONP callback for chunk loading 33592/******/ var webpackJsonpCallback = (parentChunkLoadingFunction, data) => { 33593/******/ var [chunkIds, moreModules, runtime] = data; 33594/******/ // add "moreModules" to the modules object, 33595/******/ // then flag all "chunkIds" as loaded and fire callback 33596/******/ var moduleId, chunkId, i = 0; 33597/******/ if(chunkIds.some((id) => (installedChunks[id] !== 0))) { 33598/******/ for(moduleId in moreModules) { 33599/******/ if(__webpack_require__.o(moreModules, moduleId)) { 33600/******/ __webpack_require__.m[moduleId] = moreModules[moduleId]; 33601/******/ } 33602/******/ } 33603/******/ if(runtime) var result = runtime(__webpack_require__); 33604/******/ } 33605/******/ if(parentChunkLoadingFunction) parentChunkLoadingFunction(data); 33606/******/ for(;i < chunkIds.length; i++) { 33607/******/ chunkId = chunkIds[i]; 33608/******/ if(__webpack_require__.o(installedChunks, chunkId) && installedChunks[chunkId]) { 33609/******/ installedChunks[chunkId][0](); 33610/******/ } 33611/******/ installedChunks[chunkIds[i]] = 0; 33612/******/ } 33613/******/ return __webpack_require__.O(result); 33614/******/ } 33615/******/ 33616/******/ var chunkLoadingGlobal = self["webpackChunkhowdoi"] = self["webpackChunkhowdoi"] || []; 33617/******/ chunkLoadingGlobal.forEach(webpackJsonpCallback.bind(null, 0)); 33618/******/ chunkLoadingGlobal.push = webpackJsonpCallback.bind(null, chunkLoadingGlobal.push.bind(chunkLoadingGlobal)); 33619/******/ })(); 33620/******/ 33621/************************************************************************/ 33622/******/ 33623/******/ // startup 33624/******/ // Load entry module and return exports 33625/******/ // This entry module depends on other loaded chunks and execution need to be delayed 33626/******/ __webpack_require__.O(undefined, ["dist/app"], () => (__webpack_require__("./src/index.js"))) 33627/******/ var __webpack_exports__ = __webpack_require__.O(undefined, ["dist/app"], () => (__webpack_require__("./src/app.scss"))) 33628/******/ __webpack_exports__ = __webpack_require__.O(__webpack_exports__); 33629/******/ 33630/******/ })() 33631;
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.